[Solved] OpenOffice Plugin call before save event

Discussions about using 3rd party extension with OpenOffice.org

[Solved] OpenOffice Plugin call before save event

Postby Rushna » Mon Jun 12, 2017 12:01 pm

Hey everyone!
I have written to program a Java AddOn (extension) in Netbeans 8.0.2 with Java (1.8) for OpenOffice Writer. I already downloaded the Apache OpenOffice Plugin for Netbeans8.2 and I have created a AddOn but I want to call this addOn before save event Pragmatically.
Last edited by Rushna on Thu Jul 13, 2017 11:25 am, edited 1 time in total.
OpenOffice 4.3.1 on Windows 7
Rushna
 
Posts: 19
Joined: Tue May 09, 2017 12:42 pm

Re: OpenOffice Plugin call before save event

Postby Villeroy » Mon Jun 12, 2017 7:14 pm

Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, OpenOffice 4.x & LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 26399
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: OpenOffice Plugin call before save event

Postby Rushna » Wed Jun 14, 2017 12:02 pm

Hi Villeroy,

thanks for your response ! i have updated my code based on your recommended link but i am still missing something. could you please provide me an example about how to call my plugin before save event to the OpenOffice Writer ?
OpenOffice 4.3.1 on Windows 7
Rushna
 
Posts: 19
Joined: Tue May 09, 2017 12:42 pm

Re: OpenOffice Plugin call before save event

Postby Rushna » Fri Jun 23, 2017 12:17 pm

Hi All...,
I am using ag.ion.noa_2.2.3 (noa) jar file to call plugin before save event and there is a AbstractDocument class in which onSave() ,onSaveAs() but don't know how to call
in my plugin code.
Please help me out.

my code to create plugin:
Code: Select all   Expand viewCollapse view
public final class Test1AddOn extends WeakBase
   implements com.sun.star.frame.XDispatchProvider,
              com.sun.star.frame.XDispatch,
              com.sun.star.lang.XServiceInfo,
              com.sun.star.lang.XInitialization
{

   
   
    private final XComponentContext m_xContext;
    private com.sun.star.frame.XFrame m_xFrame;
    private static final String m_implementationName = Test1AddOn.class.getName();
    private static final String m_implementationName1="Rushna World!";
    private static final String[] m_serviceNames = {
        "com.sun.star.frame.ProtocolHandler" };
    private Object xStorable;


    public Test1AddOn( XComponentContext context )
    {
        m_xContext = context;
        System.out.println("Hello Test");
    };

    public static XSingleComponentFactory __getComponentFactory( String sImplementationName ) {
        XSingleComponentFactory xFactory = null;

        if ( sImplementationName.equals( m_implementationName ) )
            xFactory = Factory.createComponentFactory(Test1AddOn.class, m_serviceNames);
        return xFactory;
    }

    public static boolean __writeRegistryServiceInfo( XRegistryKey xRegistryKey ) {
        System.out.println("Hello writeRegistryService");
        return Factory.writeRegistryServiceInfo(m_implementationName,
                                                m_serviceNames,
                                                xRegistryKey);
       
    }

    // com.sun.star.frame.XDispatchProvider:
    public com.sun.star.frame.XDispatch queryDispatch( com.sun.star.util.URL aURL,
                                                       String sTargetFrameName,
                                                       int iSearchFlags )
    {
        if ( aURL.Protocol.compareTo("com.example.test1addon:") == 0 )
        {
            if ( aURL.Path.compareTo("Rushna") == 0 )
           return this;
        }
        return null;
    }

    // com.sun.star.frame.XDispatchProvider:
    public com.sun.star.frame.XDispatch[] queryDispatches(
         com.sun.star.frame.DispatchDescriptor[] seqDescriptors )
    {
        int nCount = seqDescriptors.length;
        com.sun.star.frame.XDispatch[] seqDispatcher =
            new com.sun.star.frame.XDispatch[seqDescriptors.length];

        for( int i=0; i < nCount; ++i )
        {
            seqDispatcher[i] = queryDispatch(seqDescriptors[i].FeatureURL,
                                             seqDescriptors[i].FrameName,
                                             seqDescriptors[i].SearchFlags );
        }
     
        return seqDispatcher;
    }

    // com.sun.star.frame.XDispatch:
     public void dispatch( com.sun.star.util.URL aURL,
                           com.sun.star.beans.PropertyValue[] aArguments )
    {
         if ( aURL.Protocol.compareTo("com.example.test1addon:") == 0 )
        {
            if ( aURL.Path.compareTo("Rushna") == 0 )
            {   


            Main_Form r=new Main_Form();
                r.setVisible(true);     
             
   XTextDocument xDoc = (XTextDocument) UnoRuntime.queryInterface(
XTextDocument.class, m_xFrame.getController().getModel());
//xDoc.getText().setString(“Hello World”);

xDoc.getText().setString(m_implementationName1);
   
                return;
            }
        }//create a text file in D drive.
         
         
    }
   
    public void addStatusListener( com.sun.star.frame.XStatusListener xControl,
                                    com.sun.star.util.URL aURL )
    {
       // add your own code here
    }

    public void removeStatusListener( com.sun.star.frame.XStatusListener xControl,
                                       com.sun.star.util.URL aURL )
    {
        // add your own code here
    }

    // com.sun.star.lang.XServiceInfo:
    public String getImplementationName() {
       
         return m_implementationName;
    }

    public boolean supportsService( String sService ) {
        int len = m_serviceNames.length;

        for( int i=0; i < len; i++) {
            if (sService.equals(m_serviceNames[i]))

                return true;
        }
        return false;
    }

    public String[] getSupportedServiceNames() {
       System.out.println("Hello Support");
       return m_serviceNames;
    }

    // com.sun.star.lang.XInitialization:
    public void initialize( Object[] object )
        throws com.sun.star.uno.Exception
    {
        if ( object.length > 0 )
        {
            m_xFrame = (com.sun.star.frame.XFrame)UnoRuntime.queryInterface(
                com.sun.star.frame.XFrame.class, object[0]);
           
           }
           
        }

   
    }
OpenOffice 4.3.1 on Windows 7
Rushna
 
Posts: 19
Joined: Tue May 09, 2017 12:42 pm

Re: OpenOffice Plugin call before save event

Postby Villeroy » Fri Jun 23, 2017 6:55 pm

This is too sophisticated to be discussed on this forum, I think. You should write to developers mailing list for LibreOffice or OpenOffice.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, OpenOffice 4.x & LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 26399
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: OpenOffice Plugin call before save event

Postby Rushna » Mon Jul 03, 2017 12:56 pm

please share with me email id of OpenOffice or LibreOffice developers.
OpenOffice 4.3.1 on Windows 7
Rushna
 
Posts: 19
Joined: Tue May 09, 2017 12:42 pm

Re: OpenOffice Plugin call before save event

Postby robleyd » Mon Jul 03, 2017 2:07 pm

Cheers
David
Apache OpenOffice 4.2.0 Build 9820 alpha version - Slackware 14.2 - 64 bit
LibreOffice 6.0.7.3 - Slackware 14.2 - 64 bit
Apache OpenOffice 4.1.4 - Windows 7 Virtual machine
User avatar
robleyd
Moderator
 
Posts: 2515
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: [Solved] OpenOffice Plugin call before save event

Postby Rushna » Thu Jul 20, 2017 12:35 pm

Hi All,
"OnSave" and "OnSaveAs" should be delivered before the document is saved, and "OnSaveDone " and "OnSaveAsDone" after it is saved.

But I am getting the same result "OnSaveAs" and "OnSaveAsDone" it's delivered after the save in both cases.
please help.
OpenOffice 4.3.1 on Windows 7
Rushna
 
Posts: 19
Joined: Tue May 09, 2017 12:42 pm


Return to Extensions

Who is online

Users browsing this forum: No registered users and 0 guests