LCOV - code coverage report
Current view: top level - basctl/source/basicide - scriptdocument.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 573 0.0 %
Date: 2014-04-11 Functions: 0 105 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "scriptdocument.hxx"
      21             : #include "basobj.hxx"
      22             : #include "basidesh.hrc"
      23             : #include "iderid.hxx"
      24             : #include "dlgeddef.hxx"
      25             : #include "doceventnotifier.hxx"
      26             : #include "documentenumeration.hxx"
      27             : 
      28             : #include <boost/scoped_ptr.hpp>
      29             : #include <com/sun/star/uri/UriReferenceFactory.hpp>
      30             : #include <com/sun/star/util/theMacroExpander.hpp>
      31             : #include <com/sun/star/document/MacroExecMode.hpp>
      32             : #include <com/sun/star/frame/XStorable.hpp>
      33             : #include <com/sun/star/frame/FrameSearchFlag.hpp>
      34             : #include <com/sun/star/frame/XDesktop.hpp>
      35             : #include <com/sun/star/frame/XModel2.hpp>
      36             : #include <com/sun/star/awt/XWindow2.hpp>
      37             : #include <com/sun/star/document/XEmbeddedScripts.hpp>
      38             : #include <com/sun/star/script/vba/XVBACompatibility.hpp>
      39             : #include <com/sun/star/script/vba/XVBAModuleInfo.hpp>
      40             : 
      41             : #include <sfx2/objsh.hxx>
      42             : #include <sfx2/app.hxx>
      43             : #include <sfx2/viewfrm.hxx>
      44             : #include <sfx2/bindings.hxx>
      45             : #include <sfx2/docfile.hxx>
      46             : 
      47             : #include <vcl/svapp.hxx>
      48             : 
      49             : #include <basic/basicmanagerrepository.hxx>
      50             : 
      51             : #include <xmlscript/xmldlg_imexp.hxx>
      52             : 
      53             : #include <unotools/syslocale.hxx>
      54             : 
      55             : #include <unotools/collatorwrapper.hxx>
      56             : 
      57             : #include <tools/diagnose_ex.h>
      58             : 
      59             : #include <comphelper/processfactory.hxx>
      60             : #include <comphelper/documentinfo.hxx>
      61             : 
      62             : #include <osl/mutex.hxx>
      63             : 
      64             : #include <cppuhelper/implbase1.hxx>
      65             : 
      66             : #include <rtl/uri.hxx>
      67             : #include <rtl/bootstrap.hxx>
      68             : 
      69             : #include <osl/process.h>
      70             : #include <osl/file.hxx>
      71             : 
      72             : #include <set>
      73             : 
      74             : namespace basctl
      75             : {
      76             :     using ::com::sun::star::uno::Sequence;
      77             :     using ::com::sun::star::uno::Reference;
      78             :     using ::com::sun::star::frame::XModel;
      79             :     using ::com::sun::star::beans::XPropertySet;
      80             :     using ::com::sun::star::script::XLibraryContainer;
      81             :     using ::com::sun::star::uno::UNO_QUERY_THROW;
      82             :     using ::com::sun::star::uno::UNO_SET_THROW;
      83             :     using ::com::sun::star::beans::XPropertySetInfo;
      84             :     using ::com::sun::star::uno::Exception;
      85             :     using ::com::sun::star::container::XNameContainer;
      86             :     using ::com::sun::star::container::NoSuchElementException;
      87             :     using ::com::sun::star::uno::UNO_QUERY;
      88             :     using ::com::sun::star::task::XStatusIndicator;
      89             :     using ::com::sun::star::uno::makeAny;
      90             :     using ::com::sun::star::script::XLibraryContainer2;
      91             :     using ::com::sun::star::lang::XMultiServiceFactory;
      92             :     using ::com::sun::star::uri::UriReferenceFactory;
      93             :     using ::com::sun::star::uri::XUriReferenceFactory;
      94             :     using ::com::sun::star::uri::XUriReference;
      95             :     using ::com::sun::star::uno::XComponentContext;
      96             :     using ::com::sun::star::util::XMacroExpander;
      97             :     using ::com::sun::star::util::theMacroExpander;
      98             :     using ::com::sun::star::io::XInputStreamProvider;
      99             :     using ::com::sun::star::uno::Any;
     100             :     using ::com::sun::star::io::XInputStream;
     101             :     using ::com::sun::star::frame::XStorable;
     102             :     using ::com::sun::star::util::XModifiable;
     103             :     using ::com::sun::star::frame::XController;
     104             :     using ::com::sun::star::frame::XFrame;
     105             :     using ::com::sun::star::util::URL;
     106             :     using ::com::sun::star::frame::XDispatchProvider;
     107             :     using ::com::sun::star::frame::XDispatch;
     108             :     using ::com::sun::star::beans::PropertyValue;
     109             :     using ::com::sun::star::frame::XDesktop;
     110             :     using ::com::sun::star::container::XEnumerationAccess;
     111             :     using ::com::sun::star::container::XEnumeration;
     112             :     using ::com::sun::star::frame::XModel2;
     113             :     using ::com::sun::star::awt::XWindow2;
     114             :     using ::com::sun::star::document::XEventListener;
     115             :     using ::com::sun::star::lang::EventObject;
     116             :     using ::com::sun::star::uno::RuntimeException;
     117             :     using ::com::sun::star::document::XEventBroadcaster;
     118             :     using ::com::sun::star::document::XEmbeddedScripts;
     119             :     using ::com::sun::star::script::ModuleInfo;
     120             :     using ::com::sun::star::script::vba::XVBACompatibility;
     121             :     using ::com::sun::star::script::vba::XVBAModuleInfo;
     122             : 
     123             :     namespace MacroExecMode = ::com::sun::star::document::MacroExecMode;
     124             :     namespace FrameSearchFlag = ::com::sun::star::frame::FrameSearchFlag;
     125             : 
     126             : 
     127             :     //= helper
     128             : 
     129             :     namespace
     130             :     {
     131           0 :         static bool StringCompareLessThan( const OUString& lhs, const OUString& rhs )
     132             :         {
     133           0 :             return lhs.compareToIgnoreAsciiCase( rhs ) < 0;
     134             :         }
     135             : 
     136             :         class FilterDocuments : public docs::IDocumentDescriptorFilter
     137             :         {
     138             :         public:
     139           0 :             FilterDocuments( bool _bFilterInvisible ) : m_bFilterInvisible( _bFilterInvisible ) { }
     140             : 
     141           0 :             virtual ~FilterDocuments() {}
     142             : 
     143             :             virtual bool    includeDocument( const docs::DocumentDescriptor& _rDocument ) const SAL_OVERRIDE;
     144             : 
     145             :         private:
     146             :             bool    impl_isDocumentVisible_nothrow( const docs::DocumentDescriptor& _rDocument ) const;
     147             : 
     148             :         private:
     149             :             bool    m_bFilterInvisible;
     150             :         };
     151             : 
     152           0 :         bool FilterDocuments::impl_isDocumentVisible_nothrow( const docs::DocumentDescriptor& _rDocument ) const
     153             :         {
     154             :             try
     155             :             {
     156           0 :                 for (   docs::Controllers::const_iterator controller = _rDocument.aControllers.begin();
     157           0 :                         controller != _rDocument.aControllers.end();
     158             :                         ++controller
     159             :                     )
     160             :                 {
     161           0 :                     Reference< XFrame > xFrame( (*controller)->getFrame(), UNO_SET_THROW );
     162           0 :                     Reference< XWindow2 > xContainer( xFrame->getContainerWindow(), UNO_QUERY_THROW );
     163           0 :                     if ( xContainer->isVisible() )
     164           0 :                         return true;
     165           0 :                 }
     166             :             }
     167           0 :             catch( const Exception& )
     168             :             {
     169             :                 DBG_UNHANDLED_EXCEPTION();
     170             :             }
     171           0 :             return false;
     172             :         }
     173             : 
     174           0 :         bool FilterDocuments::includeDocument( const docs::DocumentDescriptor& _rDocument ) const
     175             :         {
     176           0 :             Reference< XEmbeddedScripts > xScripts( _rDocument.xModel, UNO_QUERY );
     177           0 :             if ( !xScripts.is() )
     178           0 :                 return false;
     179           0 :             if ( !m_bFilterInvisible || impl_isDocumentVisible_nothrow( _rDocument ) )
     180           0 :                 return true;
     181           0 :             return false;
     182             :         }
     183             : 
     184           0 :         void lcl_getAllModels_throw( docs::Documents& _out_rModels, bool _bVisibleOnly )
     185             :         {
     186           0 :             _out_rModels.clear();
     187             : 
     188           0 :             FilterDocuments aFilter( _bVisibleOnly );
     189             :             docs::DocumentEnumeration aEnum(
     190           0 :                 comphelper::getProcessComponentContext(), &aFilter );
     191             : 
     192           0 :             aEnum.getDocuments( _out_rModels );
     193           0 :         }
     194             :     }
     195             : 
     196             :     class ScriptDocument::Impl : public DocumentEventListener
     197             :     {
     198             :     private:
     199             :         bool                            m_bIsApplication;
     200             :         bool                            m_bValid;
     201             :         bool                            m_bDocumentClosed;
     202             :         Reference< XModel >             m_xDocument;
     203             :         Reference< XModifiable >        m_xDocModify;
     204             :         Reference< XEmbeddedScripts >   m_xScriptAccess;
     205             :         boost::scoped_ptr< DocumentEventNotifier > m_pDocListener;
     206             : 
     207             :     public:
     208             :         Impl ();
     209             :         Impl (Reference<XModel> const& rxDocument);
     210             :         virtual ~Impl ();
     211             : 
     212             :         /** determines whether the instance refers to a valid "document" with script and
     213             :             dialog libraries
     214             :         */
     215           0 :         inline  bool    isValid()       const   { return m_bValid; }
     216             :         /** determines whether the instance refers to a non-closed document
     217             :         */
     218           0 :         inline  bool    isAlive()       const   { return m_bValid ? ( m_bIsApplication ? true : !m_bDocumentClosed ) : false; }
     219             :         /// determines whether the "document" refers to the application in real
     220           0 :         inline  bool    isApplication() const   { return m_bValid && m_bIsApplication; }
     221             :         /// determines whether the document refers to a real document (instead of the application)
     222           0 :         inline  bool    isDocument()    const   { return m_bValid && !m_bIsApplication; }
     223             : 
     224             :         /** invalidates the instance
     225             :         */
     226             :         void    invalidate();
     227             : 
     228             :         const Reference< XModel >&
     229           0 :                         getDocumentRef() const { return m_xDocument; }
     230             : 
     231             :         /// returns a library container belonging to the document
     232             :         Reference< XLibraryContainer >
     233             :                     getLibraryContainer( LibraryContainerType _eType ) const;
     234             : 
     235             :         /// determines whether a given library is part of the shared installation
     236             :         bool        isLibraryShared( const OUString& _rLibName, LibraryContainerType _eType );
     237             : 
     238             :         /** returns the current frame of the document
     239             : 
     240             :             To be called for documents only, not for the application.
     241             : 
     242             :             If <FALSE/> is returned, an assertion will be raised in non-product builds.
     243             :         */
     244             :         bool        getCurrentFrame( Reference< XFrame >& _out_rxFrame ) const;
     245             : 
     246             :         // versions with the same signature/semantics as in ScriptDocument itself
     247             :         bool        isReadOnly() const;
     248             :         bool        isInVBAMode() const;
     249             :         BasicManager*
     250             :                     getBasicManager() const;
     251             :         Reference< XModel >
     252             :                     getDocument() const;
     253             :         void        setDocumentModified() const;
     254             :         bool        isDocumentModified() const;
     255             :         bool        saveDocument( const Reference< XStatusIndicator >& _rxStatusIndicator ) const;
     256             : 
     257             :         OUString    getTitle() const;
     258             :         OUString    getURL() const;
     259             : 
     260             :         bool        allowMacros() const;
     261             : 
     262             :         Reference< XNameContainer >
     263             :                     getLibrary( LibraryContainerType _eType, const OUString& _rLibName, bool _bLoadLibrary ) const
     264             :                         SAL_THROW((NoSuchElementException));
     265             :         bool        hasLibrary( LibraryContainerType _eType, const OUString& _rLibName ) const;
     266             :         Reference< XNameContainer >
     267             :                     getOrCreateLibrary( LibraryContainerType _eType, const OUString& _rLibName ) const;
     268             : 
     269             :         void        loadLibraryIfExists( LibraryContainerType _eType, const OUString& _rLibrary );
     270             : 
     271             :         bool        removeModuleOrDialog( LibraryContainerType _eType, const OUString& _rLibName, const OUString& _rModuleName );
     272             :         bool        hasModuleOrDialog( LibraryContainerType _eType, const OUString& _rLibName, const OUString& _rModName ) const;
     273             :         bool        getModuleOrDialog( LibraryContainerType _eType, const OUString& _rLibName, const OUString& _rObjectName, Any& _out_rModuleOrDialog );
     274             :         bool        renameModuleOrDialog( LibraryContainerType _eType, const OUString& _rLibName, const OUString& _rOldName, const OUString& _rNewName, const Reference< XNameContainer >& _rxExistingDialogModel );
     275             :         bool        createModule( const OUString& _rLibName, const OUString& _rModName, bool _bCreateMain, OUString& _out_rNewModuleCode ) const;
     276             :         bool        insertModuleOrDialog( LibraryContainerType _eType, const OUString& _rObjectName, const OUString& _rModName, const Any& _rElement ) const;
     277             :         bool        updateModule( const OUString& _rLibName, const OUString& _rModName, const OUString& _rModuleCode ) const;
     278             :         bool        createDialog( const OUString& _rLibName, const OUString& _rDialogName, Reference< XInputStreamProvider >& _out_rDialogProvider ) const;
     279             : 
     280             :     protected:
     281             :         // DocumentEventListener
     282             :         virtual void onDocumentCreated( const ScriptDocument& _rDocument ) SAL_OVERRIDE;
     283             :         virtual void onDocumentOpened( const ScriptDocument& _rDocument ) SAL_OVERRIDE;
     284             :         virtual void onDocumentSave( const ScriptDocument& _rDocument ) SAL_OVERRIDE;
     285             :         virtual void onDocumentSaveDone( const ScriptDocument& _rDocument ) SAL_OVERRIDE;
     286             :         virtual void onDocumentSaveAs( const ScriptDocument& _rDocument ) SAL_OVERRIDE;
     287             :         virtual void onDocumentSaveAsDone( const ScriptDocument& _rDocument ) SAL_OVERRIDE;
     288             :         virtual void onDocumentClosed( const ScriptDocument& _rDocument ) SAL_OVERRIDE;
     289             :         virtual void onDocumentTitleChanged( const ScriptDocument& _rDocument ) SAL_OVERRIDE;
     290             :         virtual void onDocumentModeChanged( const ScriptDocument& _rDocument ) SAL_OVERRIDE;
     291             : 
     292             :     private:
     293             :         bool        impl_initDocument_nothrow( const Reference< XModel >& _rxModel );
     294             :     };
     295             : 
     296             : 
     297             :     //= ScriptDocument::Impl - implementation
     298             : 
     299           0 :     ScriptDocument::Impl::Impl()
     300             :         :m_bIsApplication( true )
     301             :         ,m_bValid( true )
     302           0 :         ,m_bDocumentClosed( false )
     303             :     {
     304           0 :     }
     305             : 
     306           0 :     ScriptDocument::Impl::Impl( const Reference< XModel >& _rxDocument )
     307             :         :m_bIsApplication( false )
     308             :         ,m_bValid( false )
     309           0 :         ,m_bDocumentClosed( false )
     310             :     {
     311           0 :         if ( _rxDocument.is() )
     312             :         {
     313           0 :             if ( impl_initDocument_nothrow( _rxDocument ) )
     314             :             {
     315             :             }
     316             :         }
     317           0 :     }
     318             : 
     319           0 :     ScriptDocument::Impl::~Impl()
     320             :     {
     321           0 :         invalidate();
     322           0 :     }
     323             : 
     324           0 :     void ScriptDocument::Impl::invalidate()
     325             :     {
     326           0 :         m_bIsApplication = false;
     327           0 :         m_bValid = false;
     328           0 :         m_bDocumentClosed = false;
     329             : 
     330           0 :         m_xDocument.clear();
     331           0 :         m_xDocModify.clear();
     332           0 :         m_xScriptAccess.clear();
     333             : 
     334           0 :         if ( m_pDocListener.get() )
     335           0 :             m_pDocListener->dispose();
     336           0 :     }
     337             : 
     338           0 :     bool ScriptDocument::Impl::impl_initDocument_nothrow( const Reference< XModel >& _rxModel )
     339             :     {
     340             :         try
     341             :         {
     342           0 :             m_xDocument.set     ( _rxModel, UNO_SET_THROW );
     343           0 :             m_xDocModify.set    ( _rxModel, UNO_QUERY_THROW );
     344           0 :             m_xScriptAccess.set ( _rxModel, UNO_QUERY );
     345             : 
     346           0 :             m_bValid = m_xScriptAccess.is();
     347             : 
     348           0 :             if ( m_bValid )
     349           0 :                 m_pDocListener.reset( new DocumentEventNotifier( *this, _rxModel ) );
     350             :         }
     351           0 :         catch( const Exception& )
     352             :         {
     353             :             DBG_UNHANDLED_EXCEPTION();
     354           0 :             m_bValid = false;
     355             :         }
     356             : 
     357           0 :         if ( !m_bValid )
     358             :         {
     359           0 :             invalidate();
     360             :         }
     361             : 
     362           0 :         return m_bValid;
     363             :     }
     364             : 
     365           0 :     Reference< XLibraryContainer > ScriptDocument::Impl::getLibraryContainer( LibraryContainerType _eType ) const
     366             :     {
     367             :         OSL_ENSURE( isValid(), "ScriptDocument::Impl::getLibraryContainer: invalid!" );
     368             : 
     369           0 :         Reference< XLibraryContainer > xContainer;
     370           0 :         if ( !isValid() )
     371           0 :             return xContainer;
     372             : 
     373             :         try
     374             :         {
     375           0 :             if ( isApplication() )
     376           0 :                 xContainer.set( _eType == E_SCRIPTS ? SFX_APP()->GetBasicContainer() : SFX_APP()->GetDialogContainer(), UNO_QUERY_THROW );
     377             :             else
     378             :             {
     379             :                 xContainer.set(
     380           0 :                     _eType == E_SCRIPTS ? m_xScriptAccess->getBasicLibraries() : m_xScriptAccess->getDialogLibraries(),
     381           0 :                     UNO_QUERY_THROW );
     382             :             }
     383             :         }
     384           0 :         catch( const Exception& )
     385             :         {
     386             :             DBG_UNHANDLED_EXCEPTION();
     387             :         }
     388           0 :         return xContainer;
     389             :     }
     390             : 
     391           0 :     bool ScriptDocument::Impl::isReadOnly() const
     392             :     {
     393             :         OSL_ENSURE( isValid(), "ScriptDocument::Impl::isReadOnly: invalid state!" );
     394             :         OSL_ENSURE( !isApplication(), "ScriptDocument::Impl::isReadOnly: not allowed to be called for the application!" );
     395             : 
     396           0 :         bool bIsReadOnly = true;
     397           0 :         if ( isValid() && !isApplication() )
     398             :         {
     399             :             try
     400             :             {
     401             :                 // note that XStorable is required by the OfficeDocument service
     402           0 :                 Reference< XStorable > xDocStorable( m_xDocument, UNO_QUERY_THROW );
     403           0 :                 bIsReadOnly = xDocStorable->isReadonly();
     404             :             }
     405           0 :             catch( const Exception& )
     406             :             {
     407             :                 DBG_UNHANDLED_EXCEPTION();
     408             :             }
     409             :         }
     410           0 :         return bIsReadOnly;
     411             :     }
     412             : 
     413           0 :     bool ScriptDocument::Impl::isInVBAMode() const
     414             :     {
     415           0 :         bool bResult = false;
     416           0 :         if ( !isApplication() )
     417             :         {
     418           0 :             Reference< XVBACompatibility > xVBACompat( getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
     419           0 :             if ( xVBACompat.is() )
     420           0 :                 bResult = xVBACompat->getVBACompatibilityMode();
     421             :         }
     422           0 :         return bResult;
     423             :     }
     424             : 
     425             : 
     426           0 :     BasicManager* ScriptDocument::Impl::getBasicManager() const
     427             :     {
     428             :         OSL_ENSURE( isValid(), "ScriptDocument::Impl::getBasicManager: invalid state!" );
     429           0 :         if ( !isValid() )
     430           0 :             return NULL;
     431             : 
     432           0 :         if ( isApplication() )
     433           0 :             return SFX_APP()->GetBasicManager();
     434             : 
     435           0 :         return ::basic::BasicManagerRepository::getDocumentBasicManager( m_xDocument );
     436             :     }
     437             : 
     438             : 
     439           0 :     Reference< XModel > ScriptDocument::Impl::getDocument() const
     440             :     {
     441             :         OSL_ENSURE( isValid(), "ScriptDocument::Impl::getDocument: invalid state!" );
     442             :         OSL_ENSURE( isDocument(), "ScriptDocument::Impl::getDocument: for documents only!" );
     443           0 :         if ( !isValid() || !isDocument() )
     444           0 :             return NULL;
     445             : 
     446           0 :         return m_xDocument;
     447             :     }
     448             : 
     449             : 
     450           0 :     Reference< XNameContainer > ScriptDocument::Impl::getLibrary( LibraryContainerType _eType, const OUString& _rLibName, bool _bLoadLibrary ) const
     451             :         SAL_THROW((NoSuchElementException))
     452             :     {
     453             :         OSL_ENSURE( isValid(), "ScriptDocument::Impl::getLibrary: invalid state!" );
     454             : 
     455           0 :         Reference< XNameContainer > xContainer;
     456             :         try
     457             :         {
     458           0 :             Reference< XLibraryContainer > xLibContainer = getLibraryContainer( _eType );
     459           0 :             if ( isValid() )
     460             :             {
     461           0 :                 if ( xLibContainer.is() )
     462           0 :                     xContainer.set( xLibContainer->getByName( _rLibName ), UNO_QUERY_THROW );
     463             :             }
     464             : 
     465           0 :             if ( !xContainer.is() )
     466           0 :                 throw NoSuchElementException();
     467             : 
     468             :             // load library
     469           0 :             if ( _bLoadLibrary && !xLibContainer->isLibraryLoaded( _rLibName ) )
     470           0 :                 xLibContainer->loadLibrary( _rLibName );
     471             :         }
     472           0 :         catch( const NoSuchElementException& )
     473             :         {
     474           0 :             throw;  // allowed to leave
     475             :         }
     476           0 :         catch( const Exception& )
     477             :         {
     478             :             DBG_UNHANDLED_EXCEPTION();
     479             :         }
     480             : 
     481           0 :         return xContainer;
     482             :     }
     483             : 
     484             : 
     485           0 :     bool ScriptDocument::Impl::hasLibrary( LibraryContainerType _eType, const OUString& _rLibName ) const
     486             :     {
     487           0 :         bool bHas = false;
     488             :         try
     489             :         {
     490           0 :             Reference< XLibraryContainer > xLibContainer = getLibraryContainer( _eType );
     491           0 :             bHas = xLibContainer.is() && xLibContainer->hasByName( _rLibName );
     492             :         }
     493           0 :         catch( const Exception& )
     494             :         {
     495             :             DBG_UNHANDLED_EXCEPTION();
     496             :         }
     497           0 :         return bHas;
     498             :     }
     499             : 
     500             : 
     501           0 :     Reference< XNameContainer > ScriptDocument::Impl::getOrCreateLibrary( LibraryContainerType _eType, const OUString& _rLibName ) const
     502             :     {
     503           0 :         Reference< XNameContainer > xLibrary;
     504             :         try
     505             :         {
     506           0 :             Reference< XLibraryContainer > xLibContainer( getLibraryContainer( _eType ), UNO_QUERY_THROW );
     507           0 :             if ( xLibContainer->hasByName( _rLibName ) )
     508           0 :                 xLibrary.set( xLibContainer->getByName( _rLibName ), UNO_QUERY_THROW );
     509             :             else
     510           0 :                 xLibrary.set( xLibContainer->createLibrary( _rLibName ), UNO_QUERY_THROW );
     511             : 
     512           0 :             if ( !xLibContainer->isLibraryLoaded( _rLibName ) )
     513           0 :                 xLibContainer->loadLibrary( _rLibName );
     514             :         }
     515           0 :         catch( const Exception& )
     516             :         {
     517             :             DBG_UNHANDLED_EXCEPTION();
     518             :         }
     519           0 :         return xLibrary;
     520             :     }
     521             : 
     522             : 
     523           0 :     void ScriptDocument::Impl::loadLibraryIfExists( LibraryContainerType _eType, const OUString& _rLibrary )
     524             :     {
     525             :         try
     526             :         {
     527           0 :             Reference< XLibraryContainer > xLibContainer( getLibraryContainer( _eType ) );
     528           0 :             if ( xLibContainer.is() && xLibContainer->hasByName( _rLibrary ) && !xLibContainer->isLibraryLoaded( _rLibrary ) )
     529           0 :                 xLibContainer->loadLibrary( _rLibrary );
     530             :         }
     531           0 :         catch( const Exception& )
     532             :         {
     533             :             DBG_UNHANDLED_EXCEPTION();
     534             :         }
     535           0 :     }
     536             : 
     537             : 
     538           0 :     bool ScriptDocument::Impl::removeModuleOrDialog( LibraryContainerType _eType, const OUString& _rLibName, const OUString& _rModuleName )
     539             :     {
     540             :         OSL_ENSURE( isValid(), "ScriptDocument::Impl::removeModuleOrDialog: invalid!" );
     541           0 :         if ( isValid() )
     542             :         {
     543             :             try
     544             :             {
     545           0 :                 Reference< XNameContainer > xLib( getLibrary( _eType, _rLibName, true ) );
     546           0 :                 if ( xLib.is() )
     547             :                 {
     548           0 :                     xLib->removeByName( _rModuleName );
     549           0 :                     return true;
     550           0 :                 }
     551             :             }
     552           0 :             catch( const Exception& )
     553             :             {
     554             :                 DBG_UNHANDLED_EXCEPTION();
     555             :             }
     556             :         }
     557           0 :         return false;
     558             :     }
     559             : 
     560             : 
     561           0 :     bool ScriptDocument::Impl::hasModuleOrDialog( LibraryContainerType _eType, const OUString& _rLibName, const OUString& _rModName ) const
     562             :     {
     563             :         OSL_ENSURE( isValid(), "ScriptDocument::Impl::hasModuleOrDialog: invalid!" );
     564           0 :         if ( !isValid() )
     565           0 :             return false;
     566             : 
     567             :         try
     568             :         {
     569           0 :             Reference< XNameContainer > xLib( getLibrary( _eType, _rLibName, true ) );
     570           0 :             if ( xLib.is() )
     571           0 :                 return xLib->hasByName( _rModName );
     572             :         }
     573           0 :         catch( const Exception& )
     574             :         {
     575             :             DBG_UNHANDLED_EXCEPTION();
     576             :         }
     577           0 :         return false;
     578             :     }
     579             : 
     580             : 
     581           0 :     bool ScriptDocument::Impl::getModuleOrDialog( LibraryContainerType _eType, const OUString& _rLibName, const OUString& _rObjectName, Any& _out_rModuleOrDialog )
     582             :     {
     583             :         OSL_ENSURE( isValid(), "ScriptDocument::Impl::getModuleOrDialog: invalid!" );
     584           0 :         if ( !isValid() )
     585           0 :             return false;
     586             : 
     587           0 :         _out_rModuleOrDialog.clear();
     588             :         try
     589             :         {
     590           0 :             Reference< XNameContainer > xLib( getLibrary( _eType, _rLibName, true ), UNO_QUERY_THROW );
     591           0 :             if ( xLib->hasByName( _rObjectName ) )
     592             :             {
     593           0 :                 _out_rModuleOrDialog = xLib->getByName( _rObjectName );
     594           0 :                 return true;
     595           0 :             }
     596             :         }
     597           0 :         catch( const Exception& )
     598             :         {
     599             :             DBG_UNHANDLED_EXCEPTION();
     600             :         }
     601           0 :         return false;
     602             :     }
     603             : 
     604             : 
     605           0 :     bool ScriptDocument::Impl::renameModuleOrDialog( LibraryContainerType _eType, const OUString& _rLibName,
     606             :         const OUString& _rOldName, const OUString& _rNewName, const Reference< XNameContainer >& _rxExistingDialogModel )
     607             :     {
     608             :         OSL_ENSURE( isValid(), "ScriptDocument::Impl::renameModuleOrDialog: invalid!" );
     609           0 :         if ( !isValid() )
     610           0 :             return false;
     611             : 
     612             :         try
     613             :         {
     614           0 :             Reference< XNameContainer > xLib( getLibrary( _eType, _rLibName, true ), UNO_QUERY_THROW );
     615             : 
     616             :             // get element
     617           0 :             Any aElement( xLib->getByName( _rOldName ) );
     618             : 
     619             :             // remove element from container
     620           0 :             xLib->removeByName( _rOldName );
     621             : 
     622             :             // if it's a dialog, import and export, to reflect the new name
     623           0 :             if ( _eType == E_DIALOGS )
     624             :             {
     625             :                 // create dialog model
     626             :                 Reference< XComponentContext > aContext(
     627           0 :                     comphelper::getProcessComponentContext() );
     628           0 :                 Reference< XNameContainer > xDialogModel;
     629           0 :                 if ( _rxExistingDialogModel.is() )
     630           0 :                     xDialogModel = _rxExistingDialogModel;
     631             :                 else
     632             :                     xDialogModel.set(
     633           0 :                         ( aContext->getServiceManager()->
     634             :                           createInstanceWithContext(
     635             :                               "com.sun.star.awt.UnoControlDialogModel",
     636           0 :                               aContext ) ),
     637           0 :                         UNO_QUERY_THROW );
     638             : 
     639             :                 // import dialog model
     640           0 :                 Reference< XInputStreamProvider > xISP( aElement, UNO_QUERY_THROW );
     641           0 :                 if ( !_rxExistingDialogModel.is() )
     642             :                 {
     643           0 :                     Reference< XInputStream > xInput( xISP->createInputStream(), UNO_QUERY_THROW );
     644           0 :                     ::xmlscript::importDialogModel( xInput, xDialogModel, aContext, isDocument() ? getDocument() : Reference< XModel >() );
     645             :                 }
     646             : 
     647             :                 // set new name as property
     648           0 :                 Reference< XPropertySet > xDlgPSet( xDialogModel, UNO_QUERY_THROW );
     649           0 :                 xDlgPSet->setPropertyValue( DLGED_PROP_NAME, makeAny( _rNewName ) );
     650             : 
     651             :                 // export dialog model
     652           0 :                 xISP = ::xmlscript::exportDialogModel( xDialogModel, aContext, isDocument() ? getDocument() : Reference< XModel >() );
     653           0 :                 aElement <<= xISP;
     654             :             }
     655             : 
     656             :             // insert element by new name in container
     657           0 :             if ( _eType == E_SCRIPTS )
     658             :             {
     659           0 :                 Reference< XVBAModuleInfo > xVBAModuleInfo( xLib, UNO_QUERY );
     660           0 :                 if ( xVBAModuleInfo->hasModuleInfo( _rOldName ) )
     661             :                 {
     662           0 :                     ModuleInfo sModuleInfo = xVBAModuleInfo->getModuleInfo( _rOldName );
     663           0 :                     xVBAModuleInfo->removeModuleInfo( _rOldName );
     664           0 :                     xVBAModuleInfo->insertModuleInfo( _rNewName, sModuleInfo );
     665           0 :                 }
     666             :             }
     667           0 :             xLib->insertByName( _rNewName, aElement );
     668           0 :             return true;
     669             :         }
     670           0 :         catch( const Exception& )
     671             :         {
     672             :             DBG_UNHANDLED_EXCEPTION();
     673             :         }
     674           0 :         return false;
     675             :     }
     676             : 
     677             : 
     678           0 :     bool ScriptDocument::Impl::createModule( const OUString& _rLibName, const OUString& _rModName, bool _bCreateMain, OUString& _out_rNewModuleCode ) const
     679             :     {
     680           0 :         _out_rNewModuleCode = OUString();
     681             :         try
     682             :         {
     683           0 :             Reference< XNameContainer > xLib( getLibrary( E_SCRIPTS, _rLibName, true ) );
     684           0 :             if ( !xLib.is() || xLib->hasByName( _rModName ) )
     685           0 :                 return false;
     686             : 
     687             :             // create new module
     688           0 :             _out_rNewModuleCode = "REM  *****  BASIC  *****\n\n" ;
     689           0 :             if ( _bCreateMain )
     690           0 :                 _out_rNewModuleCode += "Sub Main\n\nEnd Sub\n" ;
     691             : 
     692             :             // insert module into library
     693           0 :             xLib->insertByName( _rModName, makeAny( _out_rNewModuleCode ) );
     694             :         }
     695           0 :         catch( const Exception& )
     696             :         {
     697             :             DBG_UNHANDLED_EXCEPTION();
     698           0 :             return false;
     699             :         }
     700             : 
     701           0 :         return true;
     702             :     }
     703             : 
     704             : 
     705           0 :     bool ScriptDocument::Impl::insertModuleOrDialog( LibraryContainerType _eType, const OUString& _rLibName, const OUString& _rObjectName, const Any& _rElement ) const
     706             :     {
     707             :         try
     708             :         {
     709           0 :             Reference< XNameContainer > xLib( getOrCreateLibrary( _eType, _rLibName ), UNO_QUERY_THROW );
     710           0 :             if ( xLib->hasByName( _rObjectName ) )
     711           0 :                 return false;
     712             : 
     713           0 :             xLib->insertByName( _rObjectName, _rElement );
     714           0 :             return true;
     715             :         }
     716           0 :         catch( const Exception& )
     717             :         {
     718             :             DBG_UNHANDLED_EXCEPTION();
     719             :         }
     720           0 :         return false;
     721             :     }
     722             : 
     723             : 
     724           0 :     bool ScriptDocument::Impl::updateModule( const OUString& _rLibName, const OUString& _rModName, const OUString& _rModuleCode ) const
     725             :     {
     726             :         try
     727             :         {
     728           0 :             Reference< XNameContainer > xLib( getOrCreateLibrary( E_SCRIPTS, _rLibName ), UNO_QUERY_THROW );
     729           0 :             if ( !xLib->hasByName( _rModName ) )
     730           0 :                 return false;
     731           0 :             xLib->replaceByName( _rModName, makeAny( _rModuleCode ) );
     732           0 :             return true;
     733             :         }
     734           0 :         catch( const Exception& )
     735             :         {
     736             :             DBG_UNHANDLED_EXCEPTION();
     737             :         }
     738           0 :         return false;
     739             :     }
     740             : 
     741             : 
     742           0 :     bool ScriptDocument::Impl::createDialog( const OUString& _rLibName, const OUString& _rDialogName, Reference< XInputStreamProvider >& _out_rDialogProvider ) const
     743             :     {
     744             :         try
     745             :         {
     746           0 :             Reference< XNameContainer > xLib( getLibrary( E_DIALOGS, _rLibName, true ), UNO_QUERY_THROW );
     747             : 
     748             :             // create dialog
     749           0 :             _out_rDialogProvider.clear();
     750           0 :             if ( xLib->hasByName( _rDialogName ) )
     751           0 :                 return false;
     752             : 
     753             :             // create new dialog model
     754             :             Reference< XComponentContext > aContext(
     755           0 :                 comphelper::getProcessComponentContext() );
     756             :             Reference< XNameContainer > xDialogModel(
     757           0 :                 aContext->getServiceManager()->createInstanceWithContext(
     758           0 :                     "com.sun.star.awt.UnoControlDialogModel", aContext ),
     759           0 :                 UNO_QUERY_THROW );
     760             : 
     761             :             // set name property
     762           0 :             Reference< XPropertySet > xDlgPSet( xDialogModel, UNO_QUERY_THROW );
     763           0 :             xDlgPSet->setPropertyValue( DLGED_PROP_NAME, makeAny( _rDialogName ) );
     764             : 
     765             :             // export dialog model
     766           0 :             _out_rDialogProvider = ::xmlscript::exportDialogModel( xDialogModel, aContext, isDocument() ? getDocument() : Reference< XModel >() );
     767             : 
     768             :             // insert dialog into library
     769           0 :             xLib->insertByName( _rDialogName, makeAny( _out_rDialogProvider ) );
     770             :         }
     771           0 :         catch( const Exception& )
     772             :         {
     773             :             DBG_UNHANDLED_EXCEPTION();
     774             :         }
     775             : 
     776           0 :         return _out_rDialogProvider.is();
     777             :     }
     778             : 
     779             : 
     780           0 :     void ScriptDocument::Impl::setDocumentModified() const
     781             :     {
     782             :         OSL_ENSURE( isValid() && isDocument(), "ScriptDocument::Impl::setDocumentModified: only to be called for real documents!" );
     783           0 :         if ( isValid() && isDocument() )
     784             :         {
     785             :             try
     786             :             {
     787           0 :                 m_xDocModify->setModified( true );
     788             :             }
     789           0 :             catch( const Exception& )
     790             :             {
     791             :                 DBG_UNHANDLED_EXCEPTION();
     792             :             }
     793             :         }
     794           0 :     }
     795             : 
     796             : 
     797           0 :     bool ScriptDocument::Impl::isDocumentModified() const
     798             :     {
     799             :         OSL_ENSURE( isValid() && isDocument(), "ScriptDocument::Impl::isDocumentModified: only to be called for real documents!" );
     800           0 :         bool bIsModified = false;
     801           0 :         if ( isValid() && isDocument() )
     802             :         {
     803             :             try
     804             :             {
     805           0 :                 bIsModified = m_xDocModify->isModified();
     806             :             }
     807           0 :             catch( const Exception& )
     808             :             {
     809             :                 DBG_UNHANDLED_EXCEPTION();
     810             :             }
     811             :         }
     812           0 :         return bIsModified;
     813             :     }
     814             : 
     815             : 
     816           0 :     bool ScriptDocument::Impl::saveDocument( const Reference< XStatusIndicator >& _rxStatusIndicator ) const
     817             :     {
     818           0 :         Reference< XFrame > xFrame;
     819           0 :         if ( !getCurrentFrame( xFrame ) )
     820           0 :             return false;
     821             : 
     822           0 :         Sequence< PropertyValue > aArgs;
     823           0 :         if ( _rxStatusIndicator.is() )
     824             :         {
     825           0 :             aArgs.realloc(1);
     826           0 :             aArgs[0].Name = "StatusIndicator" ;
     827           0 :             aArgs[0].Value <<= _rxStatusIndicator;
     828             :         }
     829             : 
     830             :         try
     831             :         {
     832           0 :             URL aURL;
     833           0 :             aURL.Complete = ".uno:Save" ;
     834           0 :             aURL.Main = aURL.Complete;
     835           0 :             aURL.Protocol = ".uno:" ;
     836           0 :             aURL.Path = "Save" ;
     837             : 
     838           0 :             Reference< XDispatchProvider > xDispProv( xFrame, UNO_QUERY_THROW );
     839             :             Reference< XDispatch > xDispatch(
     840           0 :                 xDispProv->queryDispatch( aURL, "_self", FrameSearchFlag::AUTO ),
     841           0 :                 UNO_SET_THROW );
     842             : 
     843           0 :             xDispatch->dispatch( aURL, aArgs );
     844             :         }
     845           0 :         catch( const Exception& )
     846             :         {
     847             :             DBG_UNHANDLED_EXCEPTION();
     848           0 :             return false;
     849             :         }
     850             : 
     851           0 :         return true;
     852             :     }
     853             : 
     854             : 
     855           0 :     OUString ScriptDocument::Impl::getTitle() const
     856             :     {
     857             :         OSL_PRECOND( isValid() && isDocument(), "ScriptDocument::Impl::getTitle: for documents only!" );
     858             : 
     859           0 :         OUString sTitle;
     860           0 :         if ( isValid() && isDocument() )
     861             :         {
     862           0 :             sTitle = ::comphelper::DocumentInfo::getDocumentTitle( m_xDocument );
     863             :         }
     864           0 :         return sTitle;
     865             :     }
     866             : 
     867             : 
     868           0 :     OUString ScriptDocument::Impl::getURL() const
     869             :     {
     870             :         OSL_PRECOND( isValid() && isDocument(), "ScriptDocument::Impl::getURL: for documents only!" );
     871             : 
     872           0 :         OUString sURL;
     873           0 :         if ( isValid() && isDocument() )
     874             :         {
     875             :             try
     876             :             {
     877           0 :                 sURL = m_xDocument->getURL();
     878             :             }
     879           0 :             catch( const Exception& )
     880             :             {
     881             :                 DBG_UNHANDLED_EXCEPTION();
     882             :             }
     883             :         }
     884           0 :         return sURL;
     885             :     }
     886             : 
     887             : 
     888           0 :     bool ScriptDocument::Impl::allowMacros() const
     889             :     {
     890             :         OSL_ENSURE( isValid() && isDocument(), "ScriptDocument::Impl::allowMacros: for documents only!" );
     891           0 :         bool bAllow = false;
     892           0 :         if ( isValid() && isDocument() )
     893             :         {
     894             :             try
     895             :             {
     896           0 :                 bAllow = m_xScriptAccess->getAllowMacroExecution();
     897             :             }
     898           0 :             catch( const Exception& )
     899             :             {
     900             :                 DBG_UNHANDLED_EXCEPTION();
     901             :             }
     902             :         }
     903           0 :         return bAllow;
     904             :     }
     905             : 
     906             : 
     907           0 :     bool ScriptDocument::Impl::getCurrentFrame( Reference< XFrame >& _out_rxFrame ) const
     908             :     {
     909           0 :         _out_rxFrame.clear();
     910             :         OSL_PRECOND( isValid() && isDocument(), "ScriptDocument::Impl::getCurrentFrame: documents only!" );
     911           0 :         if ( !isValid() || !isDocument() )
     912           0 :             return false;
     913             : 
     914             :         try
     915             :         {
     916           0 :             Reference< XModel > xDocument( m_xDocument, UNO_SET_THROW );
     917           0 :             Reference< XController > xController( xDocument->getCurrentController(), UNO_SET_THROW );
     918           0 :             _out_rxFrame.set( xController->getFrame(), UNO_SET_THROW );
     919             :         }
     920           0 :         catch( const Exception& )
     921             :         {
     922             :             DBG_UNHANDLED_EXCEPTION();
     923             :         }
     924             : 
     925           0 :         return _out_rxFrame.is();
     926             :     }
     927             : 
     928             : 
     929           0 :     bool ScriptDocument::Impl::isLibraryShared( const OUString& _rLibName, LibraryContainerType _eType )
     930             :     {
     931           0 :         bool bIsShared = false;
     932             :         try
     933             :         {
     934           0 :             Reference< XLibraryContainer2 > xLibContainer( getLibraryContainer( _eType ), UNO_QUERY_THROW );
     935             : 
     936           0 :             if ( !xLibContainer->hasByName( _rLibName ) || !xLibContainer->isLibraryLink( _rLibName ) )
     937           0 :                 return false;
     938           0 :             OUString aFileURL;
     939           0 :             Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
     940           0 :             Reference< XUriReferenceFactory > xUriFac = UriReferenceFactory::create(xContext);
     941             : 
     942           0 :             OUString aLinkURL( xLibContainer->getLibraryLinkURL( _rLibName ) );
     943           0 :             Reference< XUriReference > xUriRef( xUriFac->parse( aLinkURL ), UNO_QUERY_THROW );
     944             : 
     945           0 :             OUString aScheme = xUriRef->getScheme();
     946           0 :             if ( aScheme.equalsIgnoreAsciiCase("file") )
     947             :             {
     948           0 :                 aFileURL = aLinkURL;
     949             :             }
     950           0 :             else if ( aScheme.equalsIgnoreAsciiCase("vnd.sun.star.pkg") )
     951             :             {
     952           0 :                 OUString aAuthority = xUriRef->getAuthority();
     953           0 :                 if ( aAuthority.matchIgnoreAsciiCase("vnd.sun.star.expand:") )
     954             :                 {
     955           0 :                     OUString aDecodedURL( aAuthority.copy( sizeof ( "vnd.sun.star.expand:" ) - 1 ) );
     956           0 :                     aDecodedURL = ::rtl::Uri::decode( aDecodedURL, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 );
     957           0 :                     Reference< XMacroExpander > xMacroExpander = theMacroExpander::get(xContext);
     958           0 :                     aFileURL = xMacroExpander->expandMacros( aDecodedURL );
     959           0 :                 }
     960             :             }
     961             : 
     962           0 :             if ( !aFileURL.isEmpty() )
     963             :             {
     964           0 :                 ::osl::DirectoryItem aFileItem;
     965           0 :                 ::osl::FileStatus aFileStatus( osl_FileStatus_Mask_FileURL );
     966           0 :                 OSL_VERIFY( ::osl::DirectoryItem::get( aFileURL, aFileItem ) == ::osl::FileBase::E_None );
     967           0 :                 OSL_VERIFY( aFileItem.getFileStatus( aFileStatus ) == ::osl::FileBase::E_None );
     968           0 :                 OUString aCanonicalFileURL( aFileStatus.getFileURL() );
     969             : 
     970           0 :                 OUString aSearchURL1( "share/basic" );
     971           0 :                 OUString aSearchURL2( "share/uno_packages" );
     972           0 :                 OUString aSearchURL3( "share/extensions" );
     973           0 :                 if( aCanonicalFileURL.indexOf( aSearchURL1 ) >= 0 ||
     974           0 :                     aCanonicalFileURL.indexOf( aSearchURL2 ) >= 0 ||
     975           0 :                     aCanonicalFileURL.indexOf( aSearchURL3 ) >= 0 )
     976           0 :                         bIsShared = true;
     977           0 :             }
     978             :         }
     979           0 :         catch( const Exception& )
     980             :         {
     981             :             DBG_UNHANDLED_EXCEPTION();
     982             :         }
     983             : 
     984           0 :         return bIsShared;
     985             :     }
     986             : 
     987             : 
     988           0 :     void ScriptDocument::Impl::onDocumentCreated( const ScriptDocument& /*_rDocument*/ )
     989             :     {
     990             :         // not interested in
     991           0 :     }
     992             : 
     993           0 :     void ScriptDocument::Impl::onDocumentOpened( const ScriptDocument& /*_rDocument*/ )
     994             :     {
     995             :         // not interested in
     996           0 :     }
     997             : 
     998           0 :     void ScriptDocument::Impl::onDocumentSave( const ScriptDocument& /*_rDocument*/ )
     999             :     {
    1000             :         // not interested in
    1001           0 :     }
    1002             : 
    1003           0 :     void ScriptDocument::Impl::onDocumentSaveDone( const ScriptDocument& /*_rDocument*/ )
    1004             :     {
    1005             :         // not interested in
    1006           0 :     }
    1007             : 
    1008           0 :     void ScriptDocument::Impl::onDocumentSaveAs( const ScriptDocument& /*_rDocument*/ )
    1009             :     {
    1010             :         // not interested in
    1011           0 :     }
    1012             : 
    1013           0 :     void ScriptDocument::Impl::onDocumentSaveAsDone( const ScriptDocument& /*_rDocument*/ )
    1014             :     {
    1015             :         // not interested in
    1016           0 :     }
    1017             : 
    1018           0 :     void ScriptDocument::Impl::onDocumentClosed( const ScriptDocument& _rDocument )
    1019             :     {
    1020             :         DBG_TESTSOLARMUTEX();
    1021             :         OSL_PRECOND( isValid(), "ScriptDocument::Impl::onDocumentClosed: should not be listening if I'm not valid!" );
    1022             : 
    1023           0 :         bool bMyDocument = m_xDocument == _rDocument.getDocument();
    1024             :         OSL_PRECOND( bMyDocument, "ScriptDocument::Impl::onDocumentClosed: didn't want to know *this*!" );
    1025           0 :         if ( bMyDocument )
    1026             :         {
    1027           0 :             m_bDocumentClosed = true;
    1028             :         }
    1029           0 :     }
    1030             : 
    1031             : 
    1032           0 :     void ScriptDocument::Impl::onDocumentTitleChanged( const ScriptDocument& /*_rDocument*/ )
    1033             :     {
    1034             :         // not interested in
    1035           0 :     }
    1036             : 
    1037           0 :     void ScriptDocument::Impl::onDocumentModeChanged( const ScriptDocument& /*_rDocument*/ )
    1038             :     {
    1039             :         // not interested in
    1040           0 :     }
    1041             : 
    1042             : 
    1043             :     //= ScriptDocument
    1044             : 
    1045           0 :     ScriptDocument::ScriptDocument()
    1046           0 :         :m_pImpl(new Impl)
    1047           0 :     { }
    1048             : 
    1049             : 
    1050           0 :     ScriptDocument::ScriptDocument( ScriptDocument::SpecialDocument _eType )
    1051           0 :         :m_pImpl( new Impl( Reference< XModel >() ) )
    1052             :     {
    1053             :         OSL_ENSURE( _eType == NoDocument, "ScriptDocument::ScriptDocument: unknown SpecialDocument type!" );
    1054             :         (void)_eType;
    1055           0 :     }
    1056             : 
    1057             : 
    1058           0 :     ScriptDocument::ScriptDocument( const Reference< XModel >& _rxDocument )
    1059           0 :         :m_pImpl( new Impl( _rxDocument ) )
    1060             :     {
    1061             :         OSL_ENSURE( _rxDocument.is(), "ScriptDocument::ScriptDocument: document must not be NULL!" );
    1062             :             // a NULL document results in an uninitialized instance, and for this
    1063             :             // purpose, there is a dedicated constructor
    1064           0 :     }
    1065             : 
    1066             : 
    1067           0 :     ScriptDocument::ScriptDocument( const ScriptDocument& _rSource )
    1068           0 :         :m_pImpl( _rSource.m_pImpl )
    1069             :     {
    1070           0 :     }
    1071             : 
    1072             : 
    1073           0 :     ScriptDocument::~ScriptDocument()
    1074             :     {
    1075           0 :     }
    1076             : 
    1077             : 
    1078           0 :     const ScriptDocument& ScriptDocument::getApplicationScriptDocument()
    1079             :     {
    1080           0 :         static ScriptDocument s_aApplicationScripts;
    1081           0 :         return s_aApplicationScripts;
    1082             :     }
    1083             : 
    1084             : 
    1085           0 :     ScriptDocument ScriptDocument::getDocumentForBasicManager( const BasicManager* _pManager )
    1086             :     {
    1087           0 :         if ( _pManager == SFX_APP()->GetBasicManager() )
    1088           0 :             return getApplicationScriptDocument();
    1089             : 
    1090           0 :         docs::Documents aDocuments;
    1091           0 :         lcl_getAllModels_throw( aDocuments, false );
    1092             : 
    1093           0 :         for (   docs::Documents::const_iterator doc = aDocuments.begin();
    1094           0 :                 doc != aDocuments.end();
    1095             :                 ++doc
    1096             :             )
    1097             :         {
    1098           0 :             const BasicManager* pDocBasicManager = ::basic::BasicManagerRepository::getDocumentBasicManager( doc->xModel );
    1099           0 :             if  (   ( pDocBasicManager != SFX_APP()->GetBasicManager() )
    1100           0 :                 &&  ( pDocBasicManager == _pManager )
    1101             :                 )
    1102             :             {
    1103           0 :                 return ScriptDocument( doc->xModel );
    1104             :             }
    1105             :         }
    1106             : 
    1107             :         OSL_FAIL( "ScriptDocument::getDocumentForBasicManager: did not find a document for this manager!" );
    1108           0 :         return ScriptDocument( NoDocument );
    1109             :     }
    1110             : 
    1111             : 
    1112           0 :     ScriptDocument ScriptDocument::getDocumentWithURLOrCaption( const OUString& _rUrlOrCaption )
    1113             :     {
    1114           0 :         ScriptDocument aDocument( getApplicationScriptDocument() );
    1115           0 :         if ( _rUrlOrCaption.isEmpty() )
    1116           0 :             return aDocument;
    1117             : 
    1118           0 :         docs::Documents aDocuments;
    1119           0 :         lcl_getAllModels_throw( aDocuments, false );
    1120             : 
    1121           0 :         for (   docs::Documents::const_iterator doc = aDocuments.begin();
    1122           0 :                 doc != aDocuments.end();
    1123             :                 ++doc
    1124             :             )
    1125             :         {
    1126           0 :             const ScriptDocument aCheck = ScriptDocument( doc->xModel );
    1127           0 :             if  (   _rUrlOrCaption == aCheck.getTitle()
    1128           0 :                 ||  _rUrlOrCaption == aCheck.getURL()
    1129             :                 )
    1130             :             {
    1131           0 :                 aDocument = aCheck;
    1132           0 :                 break;
    1133             :             }
    1134           0 :         }
    1135             : 
    1136           0 :         return aDocument;
    1137             :     }
    1138             : 
    1139             : 
    1140             :     namespace
    1141             :     {
    1142           0 :         struct DocumentTitleLess : public ::std::binary_function< ScriptDocument, ScriptDocument, bool >
    1143             :         {
    1144           0 :             DocumentTitleLess( const CollatorWrapper& _rCollator )
    1145           0 :                 :m_aCollator( _rCollator )
    1146             :             {
    1147           0 :             }
    1148             : 
    1149           0 :             bool operator()( const ScriptDocument& _lhs, const ScriptDocument& _rhs ) const
    1150             :             {
    1151           0 :                 return m_aCollator.compareString( _lhs.getTitle(), _rhs.getTitle() ) < 0;
    1152             :             }
    1153             :         private:
    1154             :             const CollatorWrapper   m_aCollator;
    1155             :         };
    1156             :     }
    1157             : 
    1158             : 
    1159           0 :     ScriptDocuments ScriptDocument::getAllScriptDocuments( ScriptDocument::ScriptDocumentList _eListType )
    1160             :     {
    1161           0 :         ScriptDocuments aScriptDocs;
    1162             : 
    1163             :         // include application?
    1164           0 :         if ( _eListType == AllWithApplication )
    1165           0 :             aScriptDocs.push_back( getApplicationScriptDocument() );
    1166             : 
    1167             :         // obtain documents
    1168             :         try
    1169             :         {
    1170           0 :             docs::Documents aDocuments;
    1171           0 :             lcl_getAllModels_throw( aDocuments, true /* exclude invisible */ );
    1172             : 
    1173           0 :             for (   docs::Documents::const_iterator doc = aDocuments.begin();
    1174           0 :                     doc != aDocuments.end();
    1175             :                     ++doc
    1176             :                 )
    1177             :             {
    1178             :                 // exclude documents without script/library containers
    1179           0 :                 ScriptDocument aDoc( doc->xModel );
    1180           0 :                 if ( !aDoc.isValid() )
    1181           0 :                     continue;
    1182             : 
    1183           0 :                 aScriptDocs.push_back( aDoc );
    1184           0 :             }
    1185             :         }
    1186           0 :         catch( const Exception& )
    1187             :         {
    1188             :             DBG_UNHANDLED_EXCEPTION();
    1189             :         }
    1190             : 
    1191             :         // sort document list by doc title?
    1192           0 :         if ( _eListType == DocumentsSorted )
    1193             :         {
    1194           0 :             CollatorWrapper aCollator( ::comphelper::getProcessComponentContext() );
    1195           0 :             aCollator.loadDefaultCollator( SvtSysLocale().GetLanguageTag().getLocale(), 0 );
    1196           0 :             ::std::sort( aScriptDocs.begin(), aScriptDocs.end(), DocumentTitleLess( aCollator ) );
    1197             :         }
    1198             : 
    1199           0 :         return aScriptDocs;
    1200             :     }
    1201             : 
    1202             : 
    1203           0 :     bool ScriptDocument::operator==( const ScriptDocument& _rhs ) const
    1204             :     {
    1205           0 :         return m_pImpl->getDocumentRef() == _rhs.m_pImpl->getDocumentRef();
    1206             :     }
    1207             : 
    1208             : 
    1209           0 :     sal_Int32 ScriptDocument::hashCode() const
    1210             :     {
    1211           0 :         return sal::static_int_cast<sal_Int32>(reinterpret_cast< sal_IntPtr >( m_pImpl->getDocumentRef().get() ));
    1212             :     }
    1213             : 
    1214             : 
    1215           0 :     bool ScriptDocument::isValid() const
    1216             :     {
    1217           0 :         return m_pImpl->isValid();
    1218             :     }
    1219             : 
    1220             : 
    1221           0 :     bool ScriptDocument::isAlive() const
    1222             :     {
    1223           0 :         return m_pImpl->isAlive();
    1224             :     }
    1225             : 
    1226             : 
    1227           0 :     Reference< XLibraryContainer > ScriptDocument::getLibraryContainer( LibraryContainerType _eType ) const
    1228             :     {
    1229           0 :         return m_pImpl->getLibraryContainer( _eType );
    1230             :     }
    1231             : 
    1232             : 
    1233           0 :     Reference< XNameContainer > ScriptDocument::getLibrary( LibraryContainerType _eType, const OUString& _rLibName, bool _bLoadLibrary ) const
    1234             :         SAL_THROW((NoSuchElementException))
    1235             :     {
    1236           0 :         return m_pImpl->getLibrary( _eType, _rLibName, _bLoadLibrary );
    1237             :     }
    1238             : 
    1239             : 
    1240           0 :     bool ScriptDocument::hasLibrary( LibraryContainerType _eType, const OUString& _rLibName ) const
    1241             :     {
    1242           0 :         return m_pImpl->hasLibrary( _eType, _rLibName );
    1243             :     }
    1244             : 
    1245             : 
    1246           0 :     Reference< XNameContainer > ScriptDocument::getOrCreateLibrary( LibraryContainerType _eType, const OUString& _rLibName ) const
    1247             :     {
    1248           0 :         return m_pImpl->getOrCreateLibrary( _eType, _rLibName );
    1249             :     }
    1250             : 
    1251             : 
    1252           0 :     void ScriptDocument::loadLibraryIfExists( LibraryContainerType _eType, const OUString& _rLibrary )
    1253             :     {
    1254           0 :         m_pImpl->loadLibraryIfExists( _eType, _rLibrary );
    1255           0 :     }
    1256             : 
    1257             : 
    1258           0 :     Sequence< OUString > ScriptDocument::getObjectNames( LibraryContainerType _eType, const OUString& _rLibName ) const
    1259             :     {
    1260           0 :         Sequence< OUString > aModuleNames;
    1261             : 
    1262             :         try
    1263             :         {
    1264           0 :             if ( hasLibrary( _eType, _rLibName ) )
    1265             :             {
    1266           0 :                 Reference< XNameContainer > xLib( getLibrary( _eType, _rLibName, false ) );
    1267           0 :                 if ( xLib.is() )
    1268           0 :                     aModuleNames = xLib->getElementNames();
    1269             :             }
    1270             :         }
    1271           0 :         catch( const Exception& )
    1272             :         {
    1273             :             DBG_UNHANDLED_EXCEPTION();
    1274             :         }
    1275             : 
    1276             :         // sort
    1277           0 :         ::std::sort( aModuleNames.getArray() , aModuleNames.getArray() + aModuleNames.getLength() , StringCompareLessThan );
    1278             : 
    1279           0 :         return aModuleNames;
    1280             :     }
    1281             : 
    1282             : 
    1283           0 :     OUString ScriptDocument::createObjectName( LibraryContainerType _eType, const OUString& _rLibName ) const
    1284             :     {
    1285           0 :         OUString aObjectName;
    1286             : 
    1287           0 :         OUString aBaseName = _eType == E_SCRIPTS ? OUString("Module") : OUString("Dialog");
    1288             : 
    1289           0 :         Sequence< OUString > aUsedNames( getObjectNames( _eType, _rLibName ) );
    1290           0 :         ::std::set< OUString > aUsedNamesCheck;
    1291           0 :         ::std::copy( aUsedNames.getConstArray(), aUsedNames.getConstArray() + aUsedNames.getLength(),
    1292           0 :             ::std::insert_iterator< ::std::set< OUString > >( aUsedNamesCheck, aUsedNamesCheck.begin() ) );
    1293             : 
    1294           0 :         bool bValid = false;
    1295           0 :         sal_Int32 i = 1;
    1296           0 :         while ( !bValid )
    1297             :         {
    1298           0 :             aObjectName = aBaseName;
    1299           0 :             aObjectName += OUString::number( i );
    1300             : 
    1301           0 :             if ( aUsedNamesCheck.find( aObjectName ) == aUsedNamesCheck.end() )
    1302           0 :                 bValid = true;
    1303             : 
    1304           0 :             ++i;
    1305             :         }
    1306             : 
    1307           0 :         return aObjectName;
    1308             :     }
    1309             : 
    1310             : 
    1311           0 :     Sequence< OUString > ScriptDocument::getLibraryNames() const
    1312             :     {
    1313           0 :         return GetMergedLibraryNames( getLibraryContainer( E_SCRIPTS ), getLibraryContainer( E_DIALOGS ) );
    1314             :     }
    1315             : 
    1316             : 
    1317           0 :     bool ScriptDocument::isReadOnly() const
    1318             :     {
    1319           0 :         return m_pImpl->isReadOnly();
    1320             :     }
    1321             : 
    1322             : 
    1323           0 :     bool ScriptDocument::isApplication() const
    1324             :     {
    1325           0 :         return m_pImpl->isApplication();
    1326             :     }
    1327             : 
    1328           0 :     bool ScriptDocument::isInVBAMode() const
    1329             :     {
    1330           0 :         return m_pImpl->isInVBAMode();
    1331             :     }
    1332             : 
    1333             : 
    1334           0 :     BasicManager* ScriptDocument::getBasicManager() const
    1335             :     {
    1336           0 :         return m_pImpl->getBasicManager();
    1337             :     }
    1338             : 
    1339             : 
    1340           0 :     Reference< XModel > ScriptDocument::getDocument() const
    1341             :     {
    1342           0 :         return m_pImpl->getDocument();
    1343             :     }
    1344             : 
    1345             : 
    1346           0 :     Reference< XModel > ScriptDocument::getDocumentOrNull() const
    1347             :     {
    1348           0 :         if ( isDocument() )
    1349           0 :             return m_pImpl->getDocument();
    1350           0 :         return NULL;
    1351             :     }
    1352             : 
    1353             : 
    1354           0 :     bool ScriptDocument::removeModule( const OUString& _rLibName, const OUString& _rModuleName ) const
    1355             :     {
    1356           0 :         return m_pImpl->removeModuleOrDialog( E_SCRIPTS, _rLibName, _rModuleName );
    1357             :     }
    1358             : 
    1359             : 
    1360           0 :     bool ScriptDocument::hasModule( const OUString& _rLibName, const OUString& _rModuleName ) const
    1361             :     {
    1362           0 :         return m_pImpl->hasModuleOrDialog( E_SCRIPTS, _rLibName, _rModuleName );
    1363             :     }
    1364             : 
    1365             : 
    1366           0 :     bool ScriptDocument::getModule( const OUString& _rLibName, const OUString& _rModName, OUString& _out_rModuleSource ) const
    1367             :     {
    1368           0 :         Any aCode;
    1369           0 :         if ( !m_pImpl->getModuleOrDialog( E_SCRIPTS, _rLibName, _rModName, aCode ) )
    1370           0 :             return false;
    1371           0 :         OSL_VERIFY( aCode >>= _out_rModuleSource );
    1372           0 :         return true;
    1373             :     }
    1374             : 
    1375             : 
    1376           0 :     bool ScriptDocument::renameModule( const OUString& _rLibName, const OUString& _rOldName, const OUString& _rNewName ) const
    1377             :     {
    1378           0 :         return m_pImpl->renameModuleOrDialog( E_SCRIPTS, _rLibName, _rOldName, _rNewName, NULL );
    1379             :     }
    1380             : 
    1381             : 
    1382           0 :     bool ScriptDocument::createModule( const OUString& _rLibName, const OUString& _rModName, bool _bCreateMain, OUString& _out_rNewModuleCode ) const
    1383             :     {
    1384           0 :         if ( !m_pImpl->createModule( _rLibName, _rModName, _bCreateMain, _out_rNewModuleCode ) )
    1385           0 :             return false;
    1386             : 
    1387             :         // doc shell modified
    1388           0 :         MarkDocumentModified( *const_cast< ScriptDocument* >( this ) );    // here?
    1389           0 :         return true;
    1390             :     }
    1391             : 
    1392             : 
    1393           0 :     bool ScriptDocument::insertModule( const OUString& _rLibName, const OUString& _rModName, const OUString& _rModuleCode ) const
    1394             :     {
    1395           0 :         return m_pImpl->insertModuleOrDialog( E_SCRIPTS, _rLibName, _rModName, makeAny( _rModuleCode ) );
    1396             :     }
    1397             : 
    1398             : 
    1399           0 :     bool ScriptDocument::updateModule( const OUString& _rLibName, const OUString& _rModName, const OUString& _rModuleCode ) const
    1400             :     {
    1401           0 :         return m_pImpl->updateModule( _rLibName, _rModName, _rModuleCode );
    1402             :     }
    1403             : 
    1404             : 
    1405           0 :     bool ScriptDocument::removeDialog( const OUString& _rLibName, const OUString& _rDialogName ) const
    1406             :     {
    1407           0 :         return m_pImpl->removeModuleOrDialog( E_DIALOGS, _rLibName, _rDialogName );
    1408             :     }
    1409             : 
    1410             : 
    1411           0 :     bool ScriptDocument::hasDialog( const OUString& _rLibName, const OUString& _rDialogName ) const
    1412             :     {
    1413           0 :         return m_pImpl->hasModuleOrDialog( E_DIALOGS, _rLibName, _rDialogName );
    1414             :     }
    1415             : 
    1416             : 
    1417           0 :     bool ScriptDocument::getDialog( const OUString& _rLibName, const OUString& _rDialogName, Reference< XInputStreamProvider >& _out_rDialogProvider ) const
    1418             :     {
    1419           0 :         Any aCode;
    1420           0 :         if ( !m_pImpl->getModuleOrDialog( E_DIALOGS, _rLibName, _rDialogName, aCode ) )
    1421           0 :             return false;
    1422           0 :         OSL_VERIFY( aCode >>= _out_rDialogProvider );
    1423           0 :         return _out_rDialogProvider.is();
    1424             :     }
    1425             : 
    1426             : 
    1427           0 :     bool ScriptDocument::renameDialog( const OUString& _rLibName, const OUString& _rOldName, const OUString& _rNewName, const Reference< XNameContainer >& _rxExistingDialogModel ) const
    1428             :     {
    1429           0 :         return m_pImpl->renameModuleOrDialog( E_DIALOGS, _rLibName, _rOldName, _rNewName, _rxExistingDialogModel );
    1430             :     }
    1431             : 
    1432             : 
    1433           0 :     bool ScriptDocument::createDialog( const OUString& _rLibName, const OUString& _rDialogName, Reference< XInputStreamProvider >& _out_rDialogProvider ) const
    1434             :     {
    1435           0 :         if ( !m_pImpl->createDialog( _rLibName, _rDialogName, _out_rDialogProvider ) )
    1436           0 :             return false;
    1437             : 
    1438           0 :         MarkDocumentModified( *const_cast< ScriptDocument* >( this ) );    // here?
    1439           0 :         return true;
    1440             :     }
    1441             : 
    1442             : 
    1443           0 :     bool ScriptDocument::insertDialog( const OUString& _rLibName, const OUString& _rDialogName, const Reference< XInputStreamProvider >& _rxDialogProvider ) const
    1444             :     {
    1445           0 :         return m_pImpl->insertModuleOrDialog( E_DIALOGS, _rLibName, _rDialogName, makeAny( _rxDialogProvider ) );
    1446             :     }
    1447             : 
    1448             : 
    1449           0 :     void ScriptDocument::setDocumentModified() const
    1450             :     {
    1451           0 :         m_pImpl->setDocumentModified();
    1452           0 :     }
    1453             : 
    1454             : 
    1455           0 :     bool ScriptDocument::isDocumentModified() const
    1456             :     {
    1457           0 :         return m_pImpl->isDocumentModified();
    1458             :     }
    1459             : 
    1460             : 
    1461           0 :     bool ScriptDocument::saveDocument( const Reference< XStatusIndicator >& _rxStatusIndicator ) const
    1462             :     {
    1463           0 :         return m_pImpl->saveDocument( _rxStatusIndicator );
    1464             :     }
    1465             : 
    1466             : 
    1467           0 :     LibraryLocation ScriptDocument::getLibraryLocation( const OUString& _rLibName ) const
    1468             :     {
    1469           0 :         LibraryLocation eLocation = LIBRARY_LOCATION_UNKNOWN;
    1470           0 :         if ( !_rLibName.isEmpty() )
    1471             :         {
    1472           0 :             if ( isDocument() )
    1473             :             {
    1474           0 :                 eLocation = LIBRARY_LOCATION_DOCUMENT;
    1475             :             }
    1476             :             else
    1477             :             {
    1478           0 :                 if  (  ( hasLibrary( E_SCRIPTS, _rLibName ) && !m_pImpl->isLibraryShared( _rLibName, E_SCRIPTS ) )
    1479           0 :                     || ( hasLibrary( E_DIALOGS, _rLibName ) && !m_pImpl->isLibraryShared( _rLibName, E_DIALOGS ) )
    1480             :                     )
    1481             :                 {
    1482           0 :                     eLocation = LIBRARY_LOCATION_USER;
    1483             :                 }
    1484             :                 else
    1485             :                 {
    1486           0 :                     eLocation = LIBRARY_LOCATION_SHARE;
    1487             :                 }
    1488             :             }
    1489             :         }
    1490             : 
    1491           0 :         return eLocation;
    1492             :     }
    1493             : 
    1494             : 
    1495           0 :     OUString ScriptDocument::getTitle( LibraryLocation _eLocation, LibraryType _eType ) const
    1496             :     {
    1497           0 :         OUString aTitle;
    1498             : 
    1499           0 :         switch ( _eLocation )
    1500             :         {
    1501             :             case LIBRARY_LOCATION_USER:
    1502             :             {
    1503           0 :                 switch ( _eType )
    1504             :                 {
    1505           0 :                 case LIBRARY_TYPE_MODULE:   aTitle = IDE_RESSTR(RID_STR_USERMACROS); break;
    1506           0 :                 case LIBRARY_TYPE_DIALOG:   aTitle = IDE_RESSTR(RID_STR_USERDIALOGS); break;
    1507           0 :                 case LIBRARY_TYPE_ALL:      aTitle = IDE_RESSTR(RID_STR_USERMACROSDIALOGS); break;
    1508             :                 default:
    1509           0 :                     break;
    1510             :             }
    1511           0 :             break;
    1512             :             case LIBRARY_LOCATION_SHARE:
    1513             :             {
    1514           0 :                 switch ( _eType )
    1515             :                 {
    1516           0 :                 case LIBRARY_TYPE_MODULE:   aTitle = IDE_RESSTR(RID_STR_SHAREMACROS); break;
    1517           0 :                 case LIBRARY_TYPE_DIALOG:   aTitle = IDE_RESSTR(RID_STR_SHAREDIALOGS); break;
    1518           0 :                 case LIBRARY_TYPE_ALL:      aTitle = IDE_RESSTR(RID_STR_SHAREMACROSDIALOGS); break;
    1519             :                 default:
    1520           0 :                     break;
    1521             :                 }
    1522             :             }
    1523           0 :             break;
    1524             :             case LIBRARY_LOCATION_DOCUMENT:
    1525           0 :                 aTitle = getTitle();
    1526           0 :                 break;
    1527             :             default:
    1528           0 :                 break;
    1529             :             }
    1530             :         }
    1531             : 
    1532           0 :         return aTitle;
    1533             :     }
    1534             : 
    1535             : 
    1536           0 :     OUString ScriptDocument::getTitle() const
    1537             :     {
    1538           0 :         return m_pImpl->getTitle();
    1539             :     }
    1540             : 
    1541             : 
    1542           0 :     OUString ScriptDocument::getURL() const
    1543             :     {
    1544           0 :         return m_pImpl->getURL();
    1545             :     }
    1546             : 
    1547             : 
    1548           0 :     bool ScriptDocument::isActive() const
    1549             :     {
    1550           0 :         bool bIsActive( false );
    1551             :         try
    1552             :         {
    1553           0 :             Reference< XFrame > xFrame;
    1554           0 :             if ( m_pImpl->getCurrentFrame( xFrame ) )
    1555           0 :                 bIsActive = xFrame->isActive();
    1556             :         }
    1557           0 :         catch( const Exception& )
    1558             :         {
    1559             :             DBG_UNHANDLED_EXCEPTION();
    1560             :         }
    1561           0 :         return bIsActive;
    1562             :     }
    1563             : 
    1564             : 
    1565           0 :     bool ScriptDocument::allowMacros() const
    1566             :     {
    1567           0 :         return m_pImpl->allowMacros();
    1568             :     }
    1569             : 
    1570             : } // namespace basctl
    1571             : 
    1572             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10