LCOV - code coverage report
Current view: top level - extensions/source/nsplugin/source - so_instance.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 212 0.0 %
Date: 2012-08-25 Functions: 0 10 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      31                 :            : #include <com/sun/star/frame/XDispatchProviderInterception.hpp>
      32                 :            : #include <com/sun/star/lang/SystemDependent.hpp>
      33                 :            : #include <com/sun/star/awt/XSystemChildFactory.hpp>
      34                 :            : #include <com/sun/star/awt/XVclWindowPeer.hpp>
      35                 :            : #include <com/sun/star/util/XCloseable.hpp>
      36                 :            : #include <com/sun/star/lang/DisposedException.hpp>
      37                 :            : #include <com/sun/star/ucb/SimpleFileAccess.hpp>
      38                 :            : #include <com/sun/star/presentation/XPresentation.hpp>
      39                 :            : #include <com/sun/star/presentation/XPresentationSupplier.hpp>
      40                 :            : #include <vcl/window.hxx>
      41                 :            : #include <rtl/textenc.h>
      42                 :            : #include <rtl/locale.h>
      43                 :            : #include <osl/nlsupport.h>
      44                 :            : 
      45                 :            : #include <stdio.h>
      46                 :            : #include <stdlib.h>
      47                 :            : #include <string.h>
      48                 :            : #include <unistd.h>
      49                 :            : #include <errno.h>
      50                 :            : 
      51                 :            : #include "so_instance.hxx"
      52                 :            : #include "ns_debug.hxx"
      53                 :            : #include "so_env.hxx"
      54                 :            : #include "nsp_windows.hxx"
      55                 :            : #include "so_closelistener.hxx"
      56                 :            : #include <osl/process.h>
      57                 :            : 
      58                 :            : namespace css=com::sun::star;
      59                 :            : using namespace com::sun::star::uno;
      60                 :            : using namespace com::sun::star::lang;
      61                 :            : using namespace com::sun::star::connection;
      62                 :            : using namespace cppu;
      63                 :            : using namespace com::sun::star;
      64                 :            : 
      65                 :            : using ::rtl::OUString;
      66                 :            : using ::rtl::OString;
      67                 :            : 
      68                 :            : char SoPluginInstance::sSO_Dir[] = {0};
      69                 :          0 : Reference< XMultiServiceFactory > SoPluginInstance::mxRemoteMSF = Reference< XMultiServiceFactory >(NULL);
      70                 :            : 
      71                 :          0 : SoPluginInstance::SoPluginInstance(long pParent, Reference< XMultiServiceFactory > xMSF):
      72                 :            :     m_xUnoWin(NULL),
      73                 :            :     m_xComponent(NULL),
      74                 :            :     m_xFrame(NULL),
      75                 :            :     m_xFrames(NULL),
      76                 :            :     m_xDispatcher(NULL),
      77                 :            :     m_xDispatchProvider(NULL),
      78                 :          0 :     m_pCloseListener(NULL)
      79                 :            : {
      80                 :          0 :     m_nWidth = 0;
      81                 :          0 :     m_nHeight = 0;
      82                 :          0 :     m_nX = 0;
      83                 :          0 :     m_nY = 0;
      84                 :          0 :     m_nFlag = 15;
      85                 :          0 :     m_bInit = sal_False;
      86                 :          0 :     m_hParent = 0;
      87                 :          0 :     m_pParent = pParent;
      88                 :          0 :     m_dParentStyl = 0;
      89                 :          0 :     mxRemoteMSF = xMSF;
      90                 :          0 : }
      91                 :            : 
      92                 :          0 : SoPluginInstance::~SoPluginInstance()
      93                 :            : {
      94                 :          0 : }
      95                 :            : 
      96                 :          0 : sal_Bool SoPluginInstance::SetURL(char* aURL)
      97                 :            : {
      98                 :          0 :     debug_fprintf(NSP_LOG_APPEND, "SoPluginInstance::SetURL %s\n", aURL);
      99                 :          0 :     sal_uInt16 encoding = 11;
     100                 :            : 
     101                 :          0 :     rtl_Locale* pLocale = NULL;
     102                 :          0 :     osl_getProcessLocale(&pLocale);
     103                 :          0 :     encoding = osl_getTextEncodingFromLocale(pLocale);
     104                 :            : 
     105                 :          0 :     m_sURL = ::rtl::OUString(aURL, strlen(aURL), encoding);
     106                 :            :     debug_fprintf(NSP_LOG_APPEND, "SetURL %s\nencoding is: %d\n", ::rtl::OUStringToOString(m_sURL,
     107                 :          0 :         RTL_TEXTENCODING_GB_18030).getStr(), m_sURL.getLength(), encoding);
     108                 :          0 :     return sal_True;
     109                 :            : }
     110                 :            : 
     111                 :            : // plugin window UI part: create window, load document
     112                 :          0 : sal_Bool SoPluginInstance::LoadDocument(NSP_HWND hParent)
     113                 :            : {
     114                 :            :     // If doc has been loaded, we just resize the window and return
     115                 :          0 :     if(m_bInit)
     116                 :            :     {
     117                 :          0 :         debug_fprintf(NSP_LOG_APPEND, "only reset windows size\n");
     118                 :          0 :         m_xUnoWin->setPosSize( m_nX, m_nY, m_nWidth, m_nHeight, m_nFlag );
     119                 :            :         debug_fprintf(NSP_LOG_APPEND, "set windows to x:%d y:%d w:%d h%d falg:%d\n",
     120                 :          0 :             m_nX, m_nY, m_nWidth, m_nHeight, m_nFlag);
     121                 :          0 :         return sal_True;
     122                 :            :     }
     123                 :            : 
     124                 :            :     // If mxRemoteMSF is not initialized, we assert and return sal_False
     125                 :          0 :     if(!mxRemoteMSF.is())
     126                 :            :     {
     127                 :          0 :         debug_fprintf(NSP_LOG_APPEND, "Remote StarOfiice ServiceManager is not initilzed correctly!\n");
     128                 :          0 :         return sal_False;
     129                 :            :     }
     130                 :            : 
     131                 :            :     try
     132                 :            :     {
     133                 :            :         // try to create netscape plugin window
     134                 :            :         Reference< awt::XToolkit > xToolkit(
     135                 :          0 :             mxRemoteMSF->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.Toolkit")) ),
     136                 :          0 :             uno::UNO_QUERY );
     137                 :          0 :         if( !xToolkit.is() )
     138                 :            :         {
     139                 :          0 :             debug_fprintf(NSP_LOG_APPEND, "Can not create Toolkit!\n");
     140                 :          0 :             return sal_False;
     141                 :            :         }
     142                 :            : 
     143                 :            :         // prepare parameters for plugin window
     144                 :          0 :         css::uno::Any hwndParent = css::uno::makeAny((sal_Int32)hParent);
     145                 :            : #ifdef UNIX
     146                 :          0 :         sal_Int16 nWindowType = css::lang::SystemDependent::SYSTEM_XWINDOW;
     147                 :            : #endif //end of UNIX
     148                 :            : #ifdef WNT
     149                 :            :         sal_Int16 nWindowType = css::lang::SystemDependent::SYSTEM_WIN32;
     150                 :            : #endif //end of WNT
     151                 :            : 
     152                 :          0 :         Reference< awt::XSystemChildFactory > xToolkitSystemChildFactory(xToolkit, uno::UNO_QUERY);
     153                 :          0 :         if (!xToolkitSystemChildFactory.is())
     154                 :            :         {
     155                 :          0 :             debug_fprintf(NSP_LOG_APPEND, "print by Nsplugin, get xToolkitSystemChildFactory failure.\n");
     156                 :          0 :             return sal_False;
     157                 :            :         }
     158                 :            : 
     159                 :          0 :         debug_fprintf(NSP_LOG_APPEND, "print by Nsplugin,  try to create plugin container window HWIN:%ld.\n", hParent);
     160                 :            : 
     161                 :            :         // create the plugin window
     162                 :            :         Reference< awt::XWindowPeer > xNewWinPeer =
     163                 :          0 :             xToolkitSystemChildFactory->createSystemChild( hwndParent,
     164                 :          0 :                 css::uno::Sequence<sal_Int8>(), nWindowType );
     165                 :          0 :         if ( !xNewWinPeer.is() )
     166                 :            :         {
     167                 :          0 :             debug_fprintf(NSP_LOG_APPEND, "can not create first window\n", hParent);
     168                 :          0 :             return sal_False;
     169                 :            :         }
     170                 :            : 
     171                 :            :         // get interface of first window
     172                 :          0 :         m_xUnoWin = Reference< awt::XWindow >( xNewWinPeer, uno::UNO_QUERY );
     173                 :          0 :         if( !m_xUnoWin.is() )
     174                 :            :         {
     175                 :          0 :             debug_fprintf(NSP_LOG_APPEND, "can not get interface of first window\n", hParent);
     176                 :          0 :             return sal_False;
     177                 :            :         }
     178                 :            : 
     179                 :            :         // initialize window
     180                 :          0 :         xNewWinPeer->setBackground( COL_GRAY );
     181                 :          0 :         m_xUnoWin->setVisible( sal_True );
     182                 :          0 :         m_xUnoWin->setPosSize( m_nX, m_nY, m_nWidth, m_nHeight, m_nFlag );
     183                 :            :         debug_fprintf(NSP_LOG_APPEND, "set windows to x:%d y:%d w:%d h%d falg:%d\n",
     184                 :          0 :             m_nX, m_nY, m_nWidth, m_nHeight, m_nFlag);
     185                 :            : 
     186                 :            :         // create frame
     187                 :            :         m_xFrame = Reference< frame::XFrame >(
     188                 :          0 :             mxRemoteMSF->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Frame") )),
     189                 :          0 :             uno::UNO_QUERY );
     190                 :          0 :         if (!m_xFrame.is())
     191                 :            :         {
     192                 :          0 :             debug_fprintf(NSP_LOG_APPEND, "can not create frame\n");
     193                 :          0 :             return sal_False;
     194                 :            :         }
     195                 :            : 
     196                 :            :         // initialize frame
     197                 :          0 :         m_xFrame->initialize( m_xUnoWin );
     198                 :            : 
     199                 :            :         try
     200                 :            :         {
     201                 :            :             // currently ignore errors in this code
     202                 :          0 :             uno::Reference< beans::XPropertySet > xFrameProps( m_xFrame, uno::UNO_QUERY_THROW );
     203                 :          0 :             uno::Reference< beans::XPropertySet > xLMProps;
     204                 :          0 :             xFrameProps->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("LayoutManager")) ) >>= xLMProps;
     205                 :          0 :             if ( xLMProps.is() )
     206                 :          0 :                 xLMProps->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AutomaticToolbars")), uno::makeAny( (sal_Bool)sal_False ) );
     207                 :            :         }
     208                 :          0 :         catch( const uno::Exception& )
     209                 :            :         {}
     210                 :            : 
     211                 :            :         // get frames supplier
     212                 :            :         Reference< frame::XFramesSupplier > m_xFramesSupplier(
     213                 :          0 :             mxRemoteMSF->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop")) ),
     214                 :          0 :             uno::UNO_QUERY );
     215                 :          0 :         if ( !m_xFramesSupplier.is() )
     216                 :            :         {
     217                 :          0 :             debug_fprintf(NSP_LOG_APPEND, "can not get desktop\n");
     218                 :          0 :             return sal_False;
     219                 :            :         }
     220                 :            : 
     221                 :            :         // get frames
     222                 :          0 :         m_xFrames = m_xFramesSupplier->getFrames();
     223                 :          0 :         if ( !m_xFrames.is() )
     224                 :            :         {
     225                 :          0 :             debug_fprintf(NSP_LOG_APPEND, "can not get frames from FramesSupplier\n");
     226                 :          0 :             return sal_False;
     227                 :            :         }
     228                 :            : 
     229                 :            :         // append m_xFrame to m_xFrames
     230                 :          0 :         m_xFrames->append( m_xFrame );
     231                 :            : 
     232                 :            :         // create XComponentLoader
     233                 :          0 :         Reference< frame::XComponentLoader > xLoader( m_xFrame, uno::UNO_QUERY );
     234                 :          0 :         if ( !xLoader.is() )
     235                 :            :         {
     236                 :          0 :             debug_fprintf(NSP_LOG_APPEND, "can not get ComponentLoader to load URL\n");
     237                 :          0 :             return sal_False;
     238                 :            :         }
     239                 :            : 
     240                 :            :         //create stream for the document
     241                 :          0 :         Reference< beans::XPropertySet > xFactoryProperties( mxRemoteMSF, uno::UNO_QUERY );
     242                 :          0 :         Reference< uno::XComponentContext > xContext( xFactoryProperties->getPropertyValue( "DefaultContext" ), UNO_QUERY );
     243                 :          0 :         Reference< ucb::XSimpleFileAccess2 > xSimpleFileAccess( ucb::SimpleFileAccess::create(xContext) );
     244                 :          0 :         Reference<io::XInputStream> xInputStream = xSimpleFileAccess->openFileRead( m_sURL );
     245                 :            : 
     246                 :          0 :         if(!xInputStream.is())
     247                 :            :         {
     248                 :          0 :             debug_fprintf(NSP_LOG_APPEND, "can not create XInputStream for URL\n");
     249                 :          0 :             return sal_False;
     250                 :            :         }
     251                 :            : 
     252                 :            :         // prepare to load document
     253                 :          0 :         debug_fprintf(NSP_LOG_APPEND, "try to load document\n");
     254                 :          0 :         Sequence< ::com::sun::star::beans::PropertyValue > setPropValues(3);
     255                 :          0 :         setPropValues[0].Name = OUString( RTL_CONSTASCII_USTRINGPARAM("ViewOnly") );
     256                 :          0 :         setPropValues[0].Value <<= sal_True;
     257                 :          0 :         setPropValues[1].Name = OUString( RTL_CONSTASCII_USTRINGPARAM("ReadOnly") );
     258                 :          0 :         setPropValues[1].Value <<= sal_True;
     259                 :          0 :         setPropValues[2].Name = OUString(RTL_CONSTASCII_USTRINGPARAM("InputStream"));
     260                 :          0 :         setPropValues[2].Value <<= xInputStream;
     261                 :            :         /*
     262                 :            :         setPropValues[ 3 ].Name = "FilterName";
     263                 :            :         setPropValues[ 3 ].Value =  "Flat XML File";*/
     264                 :            : 
     265                 :            :         debug_fprintf(NSP_LOG_APPEND, "try to load copy of URL from local file %s:%d\n",
     266                 :            :             ::rtl::OUStringToOString( m_sURL, RTL_TEXTENCODING_ASCII_US ).getStr( ),
     267                 :          0 :             m_sURL.getLength() );
     268                 :            : 
     269                 :            :         // load document
     270                 :          0 :          Sequence< ::com::sun::star::beans::PropertyValue > setPropValues2(3);
     271                 :          0 :         setPropValues2[0].Name = OUString( RTL_CONSTASCII_USTRINGPARAM("ViewOnly") );
     272                 :          0 :         setPropValues2[0].Value <<= sal_True;
     273                 :          0 :         setPropValues2[1].Name = OUString( RTL_CONSTASCII_USTRINGPARAM("ReadOnly") );
     274                 :          0 :         setPropValues2[1].Value <<= sal_True;
     275                 :          0 :         setPropValues2[2].Name = OUString( RTL_CONSTASCII_USTRINGPARAM("AsTemplate") );
     276                 :          0 :         setPropValues2[2].Value <<= sal_False;
     277                 :          0 :         m_xComponent = xLoader->loadComponentFromURL(
     278                 :            :             m_sURL,
     279                 :          0 :             m_xFrame->getName(), 0, setPropValues2 );
     280                 :            : 
     281                 :          0 :         if ( !m_xComponent.is() )
     282                 :            :         {
     283                 :          0 :             debug_fprintf(NSP_LOG_APPEND, "print by Nsplugin, Load Componment error\n");
     284                 :          0 :             return sal_False;
     285                 :            :         }
     286                 :            : 
     287                 :            :          // register the closelistener that will prevent closing of the component
     288                 :          0 :         Reference< util::XCloseable > xCloseable( m_xFrame, uno::UNO_QUERY );
     289                 :          0 :         if ( xCloseable.is() )
     290                 :            :         {
     291                 :          0 :             m_pCloseListener = new PluginDocumentClosePreventer();
     292                 :          0 :             m_xCloseListener = Reference< util::XCloseListener >( m_pCloseListener );
     293                 :          0 :             xCloseable->addCloseListener( m_xCloseListener );
     294                 :            :         }
     295                 :            : 
     296                 :            :         //free the input stream, it is hold by the m_xComponent
     297                 :          0 :         xInputStream = Reference<io::XInputStream>();
     298                 :            : 
     299                 :          0 :         debug_fprintf(NSP_LOG_APPEND, "load document success\n");
     300                 :            : 
     301                 :            :         // create frame::XDispatchHelper and frame::XDispatchProvider
     302                 :            :         m_xDispatcher = Reference< frame::XDispatchHelper > (
     303                 :          0 :             mxRemoteMSF->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.DispatchHelper"))),
     304                 :          0 :             uno::UNO_QUERY );
     305                 :          0 :         if(!m_xDispatcher.is())
     306                 :            :         {
     307                 :          0 :             debug_fprintf(NSP_LOG_APPEND, "m_xDispatcher can not be getten\n");
     308                 :          0 :             return sal_False;
     309                 :            :         }
     310                 :          0 :         m_xDispatchProvider = Reference< frame::XDispatchProvider >(m_xFrame, uno::UNO_QUERY);
     311                 :          0 :         if(!m_xDispatchProvider.is())
     312                 :            :         {
     313                 :          0 :             debug_fprintf(NSP_LOG_APPEND, "m_xDispatchProvider can not be getten\n");
     314                 :          0 :             return sal_False;
     315                 :            :         }
     316                 :            : 
     317                 :            :         //try to enable toolbar and tool windows
     318                 :          0 :         Sequence< ::com::sun::star::beans::PropertyValue > propertyValue(1);
     319                 :          0 :         propertyValue[0].Name = OUString( RTL_CONSTASCII_USTRINGPARAM("FunctionBarVisible") );
     320                 :          0 :         propertyValue[0].Value <<= sal_True;
     321                 :          0 :         m_xDispatcher->executeDispatch(m_xDispatchProvider,
     322                 :            :                 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:FunctionBarVisible")),
     323                 :          0 :                 m_xFrame->getName(), 0,
     324                 :          0 :                 propertyValue );
     325                 :            : 
     326                 :            :         // reset window style of parent window
     327                 :            : #ifdef WNT
     328                 :            :         m_dParentStyl = ::NSP_ResetWinStyl (m_hParent);
     329                 :            : #endif
     330                 :          0 :         m_bInit = sal_True;
     331                 :            : 
     332                 :            :         try
     333                 :            :         {
     334                 :            :             // in case of presentation try to set the mode of slide-show, and start it
     335                 :          0 :             uno::Reference< presentation::XPresentationSupplier > xPresSuppl( m_xComponent, uno::UNO_QUERY_THROW );
     336                 :          0 :             uno::Reference< presentation::XPresentation > xPres( xPresSuppl->getPresentation(), uno::UNO_SET_THROW );
     337                 :          0 :             uno::Reference< beans::XPropertySet > xProps( xPresSuppl->getPresentation(), uno::UNO_QUERY_THROW );
     338                 :          0 :             xProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsFullScreen" ) ), uno::makeAny( sal_False ) );
     339                 :          0 :             xPres->start();
     340                 :            :         }
     341                 :          0 :         catch( const uno::Exception& )
     342                 :          0 :         {}
     343                 :            :     }
     344                 :          0 :     catch( const uno::Exception& e )
     345                 :            :     {
     346                 :          0 :         debug_fprintf(NSP_LOG_APPEND, "Unknown exception while loading document in netscape plugin windows\n");
     347                 :          0 :         OString o = OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US );
     348                 :          0 :         debug_fprintf(NSP_LOG_APPEND, "error: %s \n", o.pData->buffer );
     349                 :          0 :         return sal_False;
     350                 :            :     }
     351                 :          0 :     return sal_True;
     352                 :            : }
     353                 :            : 
     354                 :          0 : sal_Bool SoPluginInstance::SetWindow(NSP_HWND hParent, int x, int y, int w, int h)
     355                 :            : {
     356                 :          0 :     sal_Bool bRetval(sal_True);
     357                 :            : 
     358                 :          0 :     if ( m_hParent && !hParent )
     359                 :            :     {
     360                 :            :         // the plugin instance has the parent window set already and now it becomes NULL as parent window
     361                 :            :         // that means that the instance should be closed
     362                 :          0 :         Destroy();
     363                 :          0 :         m_hParent = hParent;
     364                 :            :     }
     365                 :            :     else
     366                 :            :     {
     367                 :          0 :         m_hParent = hParent;
     368                 :            : 
     369                 :            :         debug_fprintf(NSP_LOG_APPEND, "SoPluginInstance::SetWindow %s : %d\n",
     370                 :            :             ::rtl::OUStringToOString(m_sURL, RTL_TEXTENCODING_ASCII_US).getStr(),
     371                 :          0 :             m_sURL.getLength() );
     372                 :          0 :         m_nWidth = w;
     373                 :          0 :         m_nHeight =h;
     374                 :          0 :         m_nX = x;
     375                 :          0 :         m_nY = y;
     376                 :            : 
     377                 :          0 :         if ( m_sURL.isEmpty() )
     378                 :          0 :             return sal_True;
     379                 :            : 
     380                 :          0 :         if(!mxRemoteMSF.is())
     381                 :            :         {
     382                 :          0 :             debug_fprintf(NSP_LOG_APPEND, "Remote StarOfiice ServiceManager is not initilzed correctly!\n");
     383                 :          0 :             return sal_False;
     384                 :            :         }
     385                 :          0 :         debug_fprintf(NSP_LOG_APPEND, "in SoPluginInstance::SetWindow, begin LoadDocument(hParent)\n");
     386                 :          0 :         bRetval = LoadDocument(hParent);  // Load document into current window
     387                 :          0 :         if(!bRetval){
     388                 :            :             // try to reload document again
     389                 :          0 :             debug_fprintf(NSP_LOG_APPEND, "load document error, try to reload it once again\n");
     390                 :          0 :             mxRemoteMSF = Reference< XMultiServiceFactory >();
     391                 :          0 :             m_bInit = sal_False;
     392                 :          0 :             bRetval = LoadDocument(hParent);
     393                 :          0 :             debug_fprintf(NSP_LOG_APPEND, "load document again, return %d\n", bRetval);
     394                 :            :         }
     395                 :            :     }
     396                 :            : 
     397                 :          0 :     return bRetval;
     398                 :            : }
     399                 :            : 
     400                 :          0 : sal_Bool SoPluginInstance::Destroy(void)
     401                 :            : {
     402                 :            : #ifdef WNT
     403                 :            :     if(m_dParentStyl != 0)
     404                 :            :         NSP_RestoreWinStyl(m_hParent, m_dParentStyl);
     405                 :            : #endif
     406                 :            : 
     407                 :          0 :     uno::Reference< util::XCloseable > xCloseable( m_xFrame, uno::UNO_QUERY );
     408                 :            : 
     409                 :            :     try
     410                 :            :     {
     411                 :          0 :         if ( m_xCloseListener.is() )
     412                 :            :         {
     413                 :          0 :             if ( m_pCloseListener )
     414                 :          0 :                 m_pCloseListener->StopPreventClose();
     415                 :            : 
     416                 :          0 :             if ( xCloseable.is() )
     417                 :          0 :                 xCloseable->removeCloseListener( m_xCloseListener );
     418                 :            :         }
     419                 :            :     }
     420                 :          0 :     catch( const uno::Exception& )
     421                 :            :     {}
     422                 :            : 
     423                 :            :     try
     424                 :            :     {
     425                 :          0 :         uno::Sequence< uno::Any > aArgs( 1 );
     426                 :          0 :         aArgs[0] <<= m_xFrame;
     427                 :            :         uno::Reference< lang::XComponent > xDocumentCloser(
     428                 :          0 :             mxRemoteMSF->createInstanceWithArguments(
     429                 :            :                 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.embed.DocumentCloser" ) ),
     430                 :          0 :                 aArgs ),
     431                 :          0 :             uno::UNO_QUERY_THROW );
     432                 :            : 
     433                 :          0 :         xDocumentCloser->dispose(); // this call should close the document
     434                 :            :     }
     435                 :          0 :     catch( const uno::Exception& )
     436                 :            :     {
     437                 :          0 :            debug_fprintf(NSP_LOG_APPEND, "print by Nsplugin.exe, could not close the document correctly!\n");
     438                 :            :         try
     439                 :            :         {
     440                 :          0 :             if ( xCloseable.is() )
     441                 :          0 :                 xCloseable->close( sal_True );
     442                 :            :             else
     443                 :            :             {
     444                 :          0 :                 uno::Reference< lang::XComponent > xDisposable( m_xFrame, uno::UNO_QUERY );
     445                 :          0 :                 if ( xDisposable.is() )
     446                 :          0 :                     xDisposable->dispose();
     447                 :            :             }
     448                 :            :         }
     449                 :          0 :         catch (const uno::Exception&)
     450                 :            :         {
     451                 :            :         }
     452                 :            :     }
     453                 :            : 
     454                 :          0 :     m_xUnoWin = Reference< awt::XWindow >();
     455                 :          0 :     m_xComponent = Reference< XComponent >();
     456                 :          0 :     m_xFrame = Reference< frame::XFrame >();
     457                 :          0 :     m_xFrames = Reference< frame::XFrames >();
     458                 :          0 :     m_xDispatcher = Reference< frame::XDispatchHelper >();
     459                 :          0 :     m_xDispatchProvider = Reference< frame::XDispatchProvider >();
     460                 :          0 :     return sal_True;
     461                 :            : }
     462                 :            : 
     463                 :          0 : sal_Bool SoPluginInstance::Print(void)
     464                 :            : {
     465                 :          0 :     if(!m_xDispatcher.is())
     466                 :          0 :         return sal_False;
     467                 :            : 
     468                 :          0 :     Sequence< ::com::sun::star::beans::PropertyValue > propertyValue(1);
     469                 :          0 :     m_xDispatcher->executeDispatch(m_xDispatchProvider,
     470                 :            :         ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:PrintDefault")),
     471                 :          0 :         m_xFrame->getName(), 0,
     472                 :          0 :         propertyValue );
     473                 :          0 :     return sal_True;
     474                 :          0 : }
     475                 :            : 
     476                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10