1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "scriptdocument.hxx"
22 #include "basidesh.hrc"
24 #include "dlgeddef.hxx"
25 #include "doceventnotifier.hxx"
26 #include "documentenumeration.hxx"
28 #include <com/sun/star/uri/UriReferenceFactory.hpp>
29 #include <com/sun/star/util/theMacroExpander.hpp>
30 #include <com/sun/star/document/MacroExecMode.hpp>
31 #include <com/sun/star/frame/XStorable.hpp>
32 #include <com/sun/star/frame/FrameSearchFlag.hpp>
33 #include <com/sun/star/frame/XDesktop.hpp>
34 #include <com/sun/star/frame/XModel2.hpp>
35 #include <com/sun/star/awt/XWindow2.hpp>
36 #include <com/sun/star/document/XEmbeddedScripts.hpp>
37 #include <com/sun/star/script/vba/XVBACompatibility.hpp>
38 #include <com/sun/star/script/vba/XVBAModuleInfo.hpp>
40 #include <sfx2/objsh.hxx>
41 #include <sfx2/bindings.hxx>
42 #include <sfx2/docfile.hxx>
45 #include <basic/basicmanagerrepository.hxx>
47 #include <xmlscript/xmldlg_imexp.hxx>
49 #include <unotools/syslocale.hxx>
51 #include <unotools/collatorwrapper.hxx>
53 #include <tools/diagnose_ex.h>
55 #include <comphelper/documentinfo.hxx>
56 #include <comphelper/processfactory.hxx>
57 #include <comphelper/propertysequence.hxx>
59 #include <osl/file.hxx>
60 #include <rtl/uri.hxx>
66 using ::com::sun::star::uno::Sequence
;
67 using ::com::sun::star::uno::Reference
;
68 using ::com::sun::star::frame::XModel
;
69 using ::com::sun::star::beans::XPropertySet
;
70 using ::com::sun::star::script::XLibraryContainer
;
71 using ::com::sun::star::uno::UNO_QUERY_THROW
;
72 using ::com::sun::star::uno::UNO_SET_THROW
;
73 using ::com::sun::star::beans::XPropertySetInfo
;
74 using ::com::sun::star::uno::Exception
;
75 using ::com::sun::star::container::XNameContainer
;
76 using ::com::sun::star::container::NoSuchElementException
;
77 using ::com::sun::star::uno::UNO_QUERY
;
78 using ::com::sun::star::task::XStatusIndicator
;
79 using ::com::sun::star::uno::makeAny
;
80 using ::com::sun::star::script::XLibraryContainer2
;
81 using ::com::sun::star::lang::XMultiServiceFactory
;
82 using ::com::sun::star::uri::UriReferenceFactory
;
83 using ::com::sun::star::uri::XUriReferenceFactory
;
84 using ::com::sun::star::uri::XUriReference
;
85 using ::com::sun::star::uno::XComponentContext
;
86 using ::com::sun::star::util::XMacroExpander
;
87 using ::com::sun::star::util::theMacroExpander
;
88 using ::com::sun::star::io::XInputStreamProvider
;
89 using ::com::sun::star::uno::Any
;
90 using ::com::sun::star::io::XInputStream
;
91 using ::com::sun::star::frame::XStorable
;
92 using ::com::sun::star::util::XModifiable
;
93 using ::com::sun::star::frame::XController
;
94 using ::com::sun::star::frame::XFrame
;
95 using ::com::sun::star::util::URL
;
96 using ::com::sun::star::frame::XDispatchProvider
;
97 using ::com::sun::star::frame::XDispatch
;
98 using ::com::sun::star::beans::PropertyValue
;
99 using ::com::sun::star::frame::XDesktop
;
100 using ::com::sun::star::container::XEnumerationAccess
;
101 using ::com::sun::star::container::XEnumeration
;
102 using ::com::sun::star::frame::XModel2
;
103 using ::com::sun::star::awt::XWindow2
;
104 using ::com::sun::star::document::XEventListener
;
105 using ::com::sun::star::lang::EventObject
;
106 using ::com::sun::star::uno::RuntimeException
;
107 using ::com::sun::star::document::XEmbeddedScripts
;
108 using ::com::sun::star::script::ModuleInfo
;
109 using ::com::sun::star::script::vba::XVBACompatibility
;
110 using ::com::sun::star::script::vba::XVBAModuleInfo
;
112 namespace MacroExecMode
= ::com::sun::star::document::MacroExecMode
;
113 namespace FrameSearchFlag
= ::com::sun::star::frame::FrameSearchFlag
;
118 static bool StringCompareLessThan( const OUString
& lhs
, const OUString
& rhs
)
120 return lhs
.compareToIgnoreAsciiCase( rhs
) < 0;
123 class FilterDocuments
: public docs::IDocumentDescriptorFilter
126 explicit FilterDocuments(bool _bFilterInvisible
)
127 : m_bFilterInvisible(_bFilterInvisible
)
131 virtual ~FilterDocuments() {}
133 virtual bool includeDocument( const docs::DocumentDescriptor
& _rDocument
) const SAL_OVERRIDE
;
136 static bool impl_isDocumentVisible_nothrow( const docs::DocumentDescriptor
& _rDocument
);
139 bool m_bFilterInvisible
;
142 bool FilterDocuments::impl_isDocumentVisible_nothrow( const docs::DocumentDescriptor
& _rDocument
)
146 for ( docs::Controllers::const_iterator controller
= _rDocument
.aControllers
.begin();
147 controller
!= _rDocument
.aControllers
.end();
151 Reference
< XFrame
> xFrame( (*controller
)->getFrame(), UNO_SET_THROW
);
152 Reference
< XWindow2
> xContainer( xFrame
->getContainerWindow(), UNO_QUERY_THROW
);
153 if ( xContainer
->isVisible() )
157 catch( const Exception
& )
159 DBG_UNHANDLED_EXCEPTION();
164 bool FilterDocuments::includeDocument( const docs::DocumentDescriptor
& _rDocument
) const
166 Reference
< XEmbeddedScripts
> xScripts( _rDocument
.xModel
, UNO_QUERY
);
167 if ( !xScripts
.is() )
169 if ( !m_bFilterInvisible
|| impl_isDocumentVisible_nothrow( _rDocument
) )
174 void lcl_getAllModels_throw( docs::Documents
& _out_rModels
, bool _bVisibleOnly
)
176 _out_rModels
.clear();
178 FilterDocuments
aFilter( _bVisibleOnly
);
179 docs::DocumentEnumeration
aEnum(
180 comphelper::getProcessComponentContext(), &aFilter
);
182 aEnum
.getDocuments( _out_rModels
);
186 class ScriptDocument::Impl
: public DocumentEventListener
189 bool m_bIsApplication
;
191 bool m_bDocumentClosed
;
192 Reference
< XModel
> m_xDocument
;
193 Reference
< XModifiable
> m_xDocModify
;
194 Reference
< XEmbeddedScripts
> m_xScriptAccess
;
195 boost::scoped_ptr
< DocumentEventNotifier
> m_pDocListener
;
199 explicit Impl(Reference
<XModel
> const& rxDocument
);
202 /** determines whether the instance refers to a valid "document" with script and
205 inline bool isValid() const { return m_bValid
; }
206 /** determines whether the instance refers to a non-closed document
208 inline bool isAlive() const { return m_bValid
&& ( m_bIsApplication
|| !m_bDocumentClosed
); }
209 /// determines whether the "document" refers to the application in real
210 inline bool isApplication() const { return m_bValid
&& m_bIsApplication
; }
211 /// determines whether the document refers to a real document (instead of the application)
212 inline bool isDocument() const { return m_bValid
&& !m_bIsApplication
; }
214 /** invalidates the instance
218 const Reference
< XModel
>&
219 getDocumentRef() const { return m_xDocument
; }
221 /// returns a library container belonging to the document
222 Reference
< XLibraryContainer
>
223 getLibraryContainer( LibraryContainerType _eType
) const;
225 /// determines whether a given library is part of the shared installation
226 bool isLibraryShared( const OUString
& _rLibName
, LibraryContainerType _eType
);
228 /** returns the current frame of the document
230 To be called for documents only, not for the application.
232 If <FALSE/> is returned, an assertion will be raised in non-product builds.
234 bool getCurrentFrame( Reference
< XFrame
>& _out_rxFrame
) const;
236 // versions with the same signature/semantics as in ScriptDocument itself
237 bool isReadOnly() const;
238 bool isInVBAMode() const;
240 getBasicManager() const;
243 void setDocumentModified() const;
244 bool isDocumentModified() const;
245 bool saveDocument( const Reference
< XStatusIndicator
>& _rxStatusIndicator
) const;
247 OUString
getTitle() const;
248 OUString
getURL() const;
250 bool allowMacros() const;
252 Reference
< XNameContainer
>
253 getLibrary( LibraryContainerType _eType
, const OUString
& _rLibName
, bool _bLoadLibrary
) const;
254 bool hasLibrary( LibraryContainerType _eType
, const OUString
& _rLibName
) const;
255 Reference
< XNameContainer
>
256 getOrCreateLibrary( LibraryContainerType _eType
, const OUString
& _rLibName
) const;
258 void loadLibraryIfExists( LibraryContainerType _eType
, const OUString
& _rLibrary
);
260 bool removeModuleOrDialog( LibraryContainerType _eType
, const OUString
& _rLibName
, const OUString
& _rModuleName
);
261 bool hasModuleOrDialog( LibraryContainerType _eType
, const OUString
& _rLibName
, const OUString
& _rModName
) const;
262 bool getModuleOrDialog( LibraryContainerType _eType
, const OUString
& _rLibName
, const OUString
& _rObjectName
, Any
& _out_rModuleOrDialog
);
263 bool renameModuleOrDialog( LibraryContainerType _eType
, const OUString
& _rLibName
, const OUString
& _rOldName
, const OUString
& _rNewName
, const Reference
< XNameContainer
>& _rxExistingDialogModel
);
264 bool createModule( const OUString
& _rLibName
, const OUString
& _rModName
, bool _bCreateMain
, OUString
& _out_rNewModuleCode
) const;
265 bool insertModuleOrDialog( LibraryContainerType _eType
, const OUString
& _rObjectName
, const OUString
& _rModName
, const Any
& _rElement
) const;
266 bool updateModule( const OUString
& _rLibName
, const OUString
& _rModName
, const OUString
& _rModuleCode
) const;
267 bool createDialog( const OUString
& _rLibName
, const OUString
& _rDialogName
, Reference
< XInputStreamProvider
>& _out_rDialogProvider
) const;
270 // DocumentEventListener
271 virtual void onDocumentCreated( const ScriptDocument
& _rDocument
) SAL_OVERRIDE
;
272 virtual void onDocumentOpened( const ScriptDocument
& _rDocument
) SAL_OVERRIDE
;
273 virtual void onDocumentSave( const ScriptDocument
& _rDocument
) SAL_OVERRIDE
;
274 virtual void onDocumentSaveDone( const ScriptDocument
& _rDocument
) SAL_OVERRIDE
;
275 virtual void onDocumentSaveAs( const ScriptDocument
& _rDocument
) SAL_OVERRIDE
;
276 virtual void onDocumentSaveAsDone( const ScriptDocument
& _rDocument
) SAL_OVERRIDE
;
277 virtual void onDocumentClosed( const ScriptDocument
& _rDocument
) SAL_OVERRIDE
;
278 virtual void onDocumentTitleChanged( const ScriptDocument
& _rDocument
) SAL_OVERRIDE
;
279 virtual void onDocumentModeChanged( const ScriptDocument
& _rDocument
) SAL_OVERRIDE
;
282 bool impl_initDocument_nothrow( const Reference
< XModel
>& _rxModel
);
286 ScriptDocument::Impl::Impl()
287 :m_bIsApplication( true )
289 ,m_bDocumentClosed( false )
293 ScriptDocument::Impl::Impl( const Reference
< XModel
>& _rxDocument
)
294 :m_bIsApplication( false )
296 ,m_bDocumentClosed( false )
298 if ( _rxDocument
.is() )
300 if ( impl_initDocument_nothrow( _rxDocument
) )
306 ScriptDocument::Impl::~Impl()
311 void ScriptDocument::Impl::invalidate()
313 m_bIsApplication
= false;
315 m_bDocumentClosed
= false;
318 m_xDocModify
.clear();
319 m_xScriptAccess
.clear();
321 if ( m_pDocListener
.get() )
322 m_pDocListener
->dispose();
325 bool ScriptDocument::Impl::impl_initDocument_nothrow( const Reference
< XModel
>& _rxModel
)
329 m_xDocument
.set ( _rxModel
, UNO_SET_THROW
);
330 m_xDocModify
.set ( _rxModel
, UNO_QUERY_THROW
);
331 m_xScriptAccess
.set ( _rxModel
, UNO_QUERY
);
333 m_bValid
= m_xScriptAccess
.is();
336 m_pDocListener
.reset( new DocumentEventNotifier( *this, _rxModel
) );
338 catch( const Exception
& )
340 DBG_UNHANDLED_EXCEPTION();
352 Reference
< XLibraryContainer
> ScriptDocument::Impl::getLibraryContainer( LibraryContainerType _eType
) const
354 OSL_ENSURE( isValid(), "ScriptDocument::Impl::getLibraryContainer: invalid!" );
356 Reference
< XLibraryContainer
> xContainer
;
362 if ( isApplication() )
363 xContainer
.set( _eType
== E_SCRIPTS
? SfxGetpApp()->GetBasicContainer() : SfxGetpApp()->GetDialogContainer(), UNO_QUERY_THROW
);
367 _eType
== E_SCRIPTS
? m_xScriptAccess
->getBasicLibraries() : m_xScriptAccess
->getDialogLibraries(),
371 catch( const Exception
& )
373 DBG_UNHANDLED_EXCEPTION();
378 bool ScriptDocument::Impl::isReadOnly() const
380 OSL_ENSURE( isValid(), "ScriptDocument::Impl::isReadOnly: invalid state!" );
381 OSL_ENSURE( !isApplication(), "ScriptDocument::Impl::isReadOnly: not allowed to be called for the application!" );
383 bool bIsReadOnly
= true;
384 if ( isValid() && !isApplication() )
388 // note that XStorable is required by the OfficeDocument service
389 Reference
< XStorable
> xDocStorable( m_xDocument
, UNO_QUERY_THROW
);
390 bIsReadOnly
= xDocStorable
->isReadonly();
392 catch( const Exception
& )
394 DBG_UNHANDLED_EXCEPTION();
400 bool ScriptDocument::Impl::isInVBAMode() const
402 bool bResult
= false;
403 if ( !isApplication() )
405 Reference
< XVBACompatibility
> xVBACompat( getLibraryContainer( E_SCRIPTS
), UNO_QUERY
);
406 if ( xVBACompat
.is() )
407 bResult
= xVBACompat
->getVBACompatibilityMode();
412 BasicManager
* ScriptDocument::Impl::getBasicManager() const
416 OSL_ENSURE( isValid(), "ScriptDocument::Impl::getBasicManager: invalid state!" );
420 if ( isApplication() )
421 return SfxApplication::GetBasicManager();
423 return ::basic::BasicManagerRepository::getDocumentBasicManager( m_xDocument
);
425 catch (const css::ucb::ContentCreationException
& e
)
427 SAL_WARN( "basctl.basicide", "ScriptDocument::getBasicManager: Caught exception: " << e
.Message
);
432 Reference
< XModel
> ScriptDocument::Impl::getDocument() const
434 OSL_ENSURE( isValid(), "ScriptDocument::Impl::getDocument: invalid state!" );
435 OSL_ENSURE( isDocument(), "ScriptDocument::Impl::getDocument: for documents only!" );
436 if ( !isValid() || !isDocument() )
443 Reference
< XNameContainer
> ScriptDocument::Impl::getLibrary( LibraryContainerType _eType
, const OUString
& _rLibName
, bool _bLoadLibrary
) const
445 OSL_ENSURE( isValid(), "ScriptDocument::Impl::getLibrary: invalid state!" );
447 Reference
< XNameContainer
> xContainer
;
450 Reference
< XLibraryContainer
> xLibContainer
= getLibraryContainer( _eType
);
453 if ( xLibContainer
.is() )
454 xContainer
.set( xLibContainer
->getByName( _rLibName
), UNO_QUERY_THROW
);
457 if ( !xContainer
.is() )
458 throw NoSuchElementException();
461 if ( _bLoadLibrary
&& !xLibContainer
->isLibraryLoaded( _rLibName
) )
462 xLibContainer
->loadLibrary( _rLibName
);
464 catch( const NoSuchElementException
& )
466 throw; // allowed to leave
468 catch( const Exception
& )
470 DBG_UNHANDLED_EXCEPTION();
477 bool ScriptDocument::Impl::hasLibrary( LibraryContainerType _eType
, const OUString
& _rLibName
) const
482 Reference
< XLibraryContainer
> xLibContainer
= getLibraryContainer( _eType
);
483 bHas
= xLibContainer
.is() && xLibContainer
->hasByName( _rLibName
);
485 catch( const Exception
& )
487 DBG_UNHANDLED_EXCEPTION();
493 Reference
< XNameContainer
> ScriptDocument::Impl::getOrCreateLibrary( LibraryContainerType _eType
, const OUString
& _rLibName
) const
495 Reference
< XNameContainer
> xLibrary
;
498 Reference
< XLibraryContainer
> xLibContainer( getLibraryContainer( _eType
), UNO_QUERY_THROW
);
499 if ( xLibContainer
->hasByName( _rLibName
) )
500 xLibrary
.set( xLibContainer
->getByName( _rLibName
), UNO_QUERY_THROW
);
502 xLibrary
.set( xLibContainer
->createLibrary( _rLibName
), UNO_QUERY_THROW
);
504 if ( !xLibContainer
->isLibraryLoaded( _rLibName
) )
505 xLibContainer
->loadLibrary( _rLibName
);
507 catch( const Exception
& )
509 DBG_UNHANDLED_EXCEPTION();
515 void ScriptDocument::Impl::loadLibraryIfExists( LibraryContainerType _eType
, const OUString
& _rLibrary
)
519 Reference
< XLibraryContainer
> xLibContainer( getLibraryContainer( _eType
) );
520 if ( xLibContainer
.is() && xLibContainer
->hasByName( _rLibrary
) && !xLibContainer
->isLibraryLoaded( _rLibrary
) )
521 xLibContainer
->loadLibrary( _rLibrary
);
523 catch( const Exception
& )
525 DBG_UNHANDLED_EXCEPTION();
530 bool ScriptDocument::Impl::removeModuleOrDialog( LibraryContainerType _eType
, const OUString
& _rLibName
, const OUString
& _rModuleName
)
532 OSL_ENSURE( isValid(), "ScriptDocument::Impl::removeModuleOrDialog: invalid!" );
537 Reference
< XNameContainer
> xLib( getLibrary( _eType
, _rLibName
, true ) );
540 xLib
->removeByName( _rModuleName
);
544 catch( const Exception
& )
546 DBG_UNHANDLED_EXCEPTION();
553 bool ScriptDocument::Impl::hasModuleOrDialog( LibraryContainerType _eType
, const OUString
& _rLibName
, const OUString
& _rModName
) const
555 OSL_ENSURE( isValid(), "ScriptDocument::Impl::hasModuleOrDialog: invalid!" );
561 Reference
< XNameContainer
> xLib( getLibrary( _eType
, _rLibName
, true ) );
563 return xLib
->hasByName( _rModName
);
565 catch( const Exception
& )
567 DBG_UNHANDLED_EXCEPTION();
573 bool ScriptDocument::Impl::getModuleOrDialog( LibraryContainerType _eType
, const OUString
& _rLibName
, const OUString
& _rObjectName
, Any
& _out_rModuleOrDialog
)
575 OSL_ENSURE( isValid(), "ScriptDocument::Impl::getModuleOrDialog: invalid!" );
579 _out_rModuleOrDialog
.clear();
582 Reference
< XNameContainer
> xLib( getLibrary( _eType
, _rLibName
, true ), UNO_QUERY_THROW
);
583 if ( xLib
->hasByName( _rObjectName
) )
585 _out_rModuleOrDialog
= xLib
->getByName( _rObjectName
);
589 catch( const Exception
& )
591 DBG_UNHANDLED_EXCEPTION();
597 bool ScriptDocument::Impl::renameModuleOrDialog( LibraryContainerType _eType
, const OUString
& _rLibName
,
598 const OUString
& _rOldName
, const OUString
& _rNewName
, const Reference
< XNameContainer
>& _rxExistingDialogModel
)
600 OSL_ENSURE( isValid(), "ScriptDocument::Impl::renameModuleOrDialog: invalid!" );
606 Reference
< XNameContainer
> xLib( getLibrary( _eType
, _rLibName
, true ), UNO_QUERY_THROW
);
609 Any
aElement( xLib
->getByName( _rOldName
) );
611 // remove element from container
612 xLib
->removeByName( _rOldName
);
614 // if it's a dialog, import and export, to reflect the new name
615 if ( _eType
== E_DIALOGS
)
617 // create dialog model
618 Reference
< XComponentContext
> aContext(
619 comphelper::getProcessComponentContext() );
620 Reference
< XNameContainer
> xDialogModel
;
621 if ( _rxExistingDialogModel
.is() )
622 xDialogModel
= _rxExistingDialogModel
;
625 ( aContext
->getServiceManager()->
626 createInstanceWithContext(
627 "com.sun.star.awt.UnoControlDialogModel",
631 // import dialog model
632 Reference
< XInputStreamProvider
> xISP( aElement
, UNO_QUERY_THROW
);
633 if ( !_rxExistingDialogModel
.is() )
635 Reference
< XInputStream
> xInput( xISP
->createInputStream(), UNO_QUERY_THROW
);
636 ::xmlscript::importDialogModel( xInput
, xDialogModel
, aContext
, isDocument() ? getDocument() : Reference
< XModel
>() );
639 // set new name as property
640 Reference
< XPropertySet
> xDlgPSet( xDialogModel
, UNO_QUERY_THROW
);
641 xDlgPSet
->setPropertyValue( DLGED_PROP_NAME
, makeAny( _rNewName
) );
643 // export dialog model
644 xISP
= ::xmlscript::exportDialogModel( xDialogModel
, aContext
, isDocument() ? getDocument() : Reference
< XModel
>() );
648 // insert element by new name in container
649 if ( _eType
== E_SCRIPTS
)
651 Reference
< XVBAModuleInfo
> xVBAModuleInfo( xLib
, UNO_QUERY
);
652 if ( xVBAModuleInfo
->hasModuleInfo( _rOldName
) )
654 ModuleInfo sModuleInfo
= xVBAModuleInfo
->getModuleInfo( _rOldName
);
655 xVBAModuleInfo
->removeModuleInfo( _rOldName
);
656 xVBAModuleInfo
->insertModuleInfo( _rNewName
, sModuleInfo
);
659 xLib
->insertByName( _rNewName
, aElement
);
662 catch( const Exception
& )
664 DBG_UNHANDLED_EXCEPTION();
670 bool ScriptDocument::Impl::createModule( const OUString
& _rLibName
, const OUString
& _rModName
, bool _bCreateMain
, OUString
& _out_rNewModuleCode
) const
672 _out_rNewModuleCode
.clear();
675 Reference
< XNameContainer
> xLib( getLibrary( E_SCRIPTS
, _rLibName
, true ) );
676 if ( !xLib
.is() || xLib
->hasByName( _rModName
) )
680 _out_rNewModuleCode
= "REM ***** BASIC *****\n\n" ;
682 _out_rNewModuleCode
+= "Sub Main\n\nEnd Sub\n" ;
684 // insert module into library
685 xLib
->insertByName( _rModName
, makeAny( _out_rNewModuleCode
) );
687 catch( const Exception
& )
689 DBG_UNHANDLED_EXCEPTION();
697 bool ScriptDocument::Impl::insertModuleOrDialog( LibraryContainerType _eType
, const OUString
& _rLibName
, const OUString
& _rObjectName
, const Any
& _rElement
) const
701 Reference
< XNameContainer
> xLib( getOrCreateLibrary( _eType
, _rLibName
), UNO_QUERY_THROW
);
702 if ( xLib
->hasByName( _rObjectName
) )
705 xLib
->insertByName( _rObjectName
, _rElement
);
708 catch( const Exception
& )
710 DBG_UNHANDLED_EXCEPTION();
716 bool ScriptDocument::Impl::updateModule( const OUString
& _rLibName
, const OUString
& _rModName
, const OUString
& _rModuleCode
) const
720 Reference
< XNameContainer
> xLib( getOrCreateLibrary( E_SCRIPTS
, _rLibName
), UNO_QUERY_THROW
);
721 if ( !xLib
->hasByName( _rModName
) )
723 xLib
->replaceByName( _rModName
, makeAny( _rModuleCode
) );
726 catch( const Exception
& )
728 DBG_UNHANDLED_EXCEPTION();
734 bool ScriptDocument::Impl::createDialog( const OUString
& _rLibName
, const OUString
& _rDialogName
, Reference
< XInputStreamProvider
>& _out_rDialogProvider
) const
738 Reference
< XNameContainer
> xLib( getLibrary( E_DIALOGS
, _rLibName
, true ), UNO_QUERY_THROW
);
741 _out_rDialogProvider
.clear();
742 if ( xLib
->hasByName( _rDialogName
) )
745 // create new dialog model
746 Reference
< XComponentContext
> aContext(
747 comphelper::getProcessComponentContext() );
748 Reference
< XNameContainer
> xDialogModel(
749 aContext
->getServiceManager()->createInstanceWithContext(
750 "com.sun.star.awt.UnoControlDialogModel", aContext
),
754 Reference
< XPropertySet
> xDlgPSet( xDialogModel
, UNO_QUERY_THROW
);
755 xDlgPSet
->setPropertyValue( DLGED_PROP_NAME
, makeAny( _rDialogName
) );
757 // export dialog model
758 _out_rDialogProvider
= ::xmlscript::exportDialogModel( xDialogModel
, aContext
, isDocument() ? getDocument() : Reference
< XModel
>() );
760 // insert dialog into library
761 xLib
->insertByName( _rDialogName
, makeAny( _out_rDialogProvider
) );
763 catch( const Exception
& )
765 DBG_UNHANDLED_EXCEPTION();
768 return _out_rDialogProvider
.is();
772 void ScriptDocument::Impl::setDocumentModified() const
774 OSL_ENSURE( isValid() && isDocument(), "ScriptDocument::Impl::setDocumentModified: only to be called for real documents!" );
775 if ( isValid() && isDocument() )
779 m_xDocModify
->setModified( true );
781 catch( const Exception
& )
783 DBG_UNHANDLED_EXCEPTION();
789 bool ScriptDocument::Impl::isDocumentModified() const
791 OSL_ENSURE( isValid() && isDocument(), "ScriptDocument::Impl::isDocumentModified: only to be called for real documents!" );
792 bool bIsModified
= false;
793 if ( isValid() && isDocument() )
797 bIsModified
= m_xDocModify
->isModified();
799 catch( const Exception
& )
801 DBG_UNHANDLED_EXCEPTION();
808 bool ScriptDocument::Impl::saveDocument( const Reference
< XStatusIndicator
>& _rxStatusIndicator
) const
810 Reference
< XFrame
> xFrame
;
811 if ( !getCurrentFrame( xFrame
) )
814 Sequence
< PropertyValue
> aArgs
;
815 if ( _rxStatusIndicator
.is() )
817 aArgs
= ::comphelper::InitPropertySequence({
818 { "StatusIndicator", makeAny(_rxStatusIndicator
) }
825 aURL
.Complete
= ".uno:Save" ;
826 aURL
.Main
= aURL
.Complete
;
827 aURL
.Protocol
= ".uno:" ;
830 Reference
< XDispatchProvider
> xDispProv( xFrame
, UNO_QUERY_THROW
);
831 Reference
< XDispatch
> xDispatch(
832 xDispProv
->queryDispatch( aURL
, "_self", FrameSearchFlag::AUTO
),
835 xDispatch
->dispatch( aURL
, aArgs
);
837 catch( const Exception
& )
839 DBG_UNHANDLED_EXCEPTION();
847 OUString
ScriptDocument::Impl::getTitle() const
849 OSL_PRECOND( isValid() && isDocument(), "ScriptDocument::Impl::getTitle: for documents only!" );
852 if ( isValid() && isDocument() )
854 sTitle
= ::comphelper::DocumentInfo::getDocumentTitle( m_xDocument
);
860 OUString
ScriptDocument::Impl::getURL() const
862 OSL_PRECOND( isValid() && isDocument(), "ScriptDocument::Impl::getURL: for documents only!" );
865 if ( isValid() && isDocument() )
869 sURL
= m_xDocument
->getURL();
871 catch( const Exception
& )
873 DBG_UNHANDLED_EXCEPTION();
880 bool ScriptDocument::Impl::allowMacros() const
882 OSL_ENSURE( isValid() && isDocument(), "ScriptDocument::Impl::allowMacros: for documents only!" );
884 if ( isValid() && isDocument() )
888 bAllow
= m_xScriptAccess
->getAllowMacroExecution();
890 catch( const Exception
& )
892 DBG_UNHANDLED_EXCEPTION();
899 bool ScriptDocument::Impl::getCurrentFrame( Reference
< XFrame
>& _out_rxFrame
) const
901 _out_rxFrame
.clear();
902 OSL_PRECOND( isValid() && isDocument(), "ScriptDocument::Impl::getCurrentFrame: documents only!" );
903 if ( !isValid() || !isDocument() )
908 Reference
< XModel
> xDocument( m_xDocument
, UNO_SET_THROW
);
909 Reference
< XController
> xController( xDocument
->getCurrentController(), UNO_SET_THROW
);
910 _out_rxFrame
.set( xController
->getFrame(), UNO_SET_THROW
);
912 catch( const Exception
& )
914 DBG_UNHANDLED_EXCEPTION();
917 return _out_rxFrame
.is();
921 bool ScriptDocument::Impl::isLibraryShared( const OUString
& _rLibName
, LibraryContainerType _eType
)
923 bool bIsShared
= false;
926 Reference
< XLibraryContainer2
> xLibContainer( getLibraryContainer( _eType
), UNO_QUERY_THROW
);
928 if ( !xLibContainer
->hasByName( _rLibName
) || !xLibContainer
->isLibraryLink( _rLibName
) )
931 Reference
< XComponentContext
> xContext( ::comphelper::getProcessComponentContext() );
932 Reference
< XUriReferenceFactory
> xUriFac
= UriReferenceFactory::create(xContext
);
934 OUString
aLinkURL( xLibContainer
->getLibraryLinkURL( _rLibName
) );
935 Reference
< XUriReference
> xUriRef( xUriFac
->parse( aLinkURL
), UNO_QUERY_THROW
);
937 OUString aScheme
= xUriRef
->getScheme();
938 if ( aScheme
.equalsIgnoreAsciiCase("file") )
942 else if ( aScheme
.equalsIgnoreAsciiCase("vnd.sun.star.pkg") )
944 OUString aAuthority
= xUriRef
->getAuthority();
945 if ( aAuthority
.matchIgnoreAsciiCase("vnd.sun.star.expand:") )
947 OUString
aDecodedURL( aAuthority
.copy( sizeof ( "vnd.sun.star.expand:" ) - 1 ) );
948 aDecodedURL
= ::rtl::Uri::decode( aDecodedURL
, rtl_UriDecodeWithCharset
, RTL_TEXTENCODING_UTF8
);
949 Reference
< XMacroExpander
> xMacroExpander
= theMacroExpander::get(xContext
);
950 aFileURL
= xMacroExpander
->expandMacros( aDecodedURL
);
954 if ( !aFileURL
.isEmpty() )
956 ::osl::DirectoryItem aFileItem
;
957 ::osl::FileStatus
aFileStatus( osl_FileStatus_Mask_FileURL
);
958 OSL_VERIFY( ::osl::DirectoryItem::get( aFileURL
, aFileItem
) == ::osl::FileBase::E_None
);
959 OSL_VERIFY( aFileItem
.getFileStatus( aFileStatus
) == ::osl::FileBase::E_None
);
960 OUString
aCanonicalFileURL( aFileStatus
.getFileURL() );
962 OUString
aSearchURL1( "share/basic" );
963 OUString
aSearchURL2( "share/uno_packages" );
964 OUString
aSearchURL3( "share/extensions" );
965 if( aCanonicalFileURL
.indexOf( aSearchURL1
) >= 0 ||
966 aCanonicalFileURL
.indexOf( aSearchURL2
) >= 0 ||
967 aCanonicalFileURL
.indexOf( aSearchURL3
) >= 0 )
971 catch( const Exception
& )
973 DBG_UNHANDLED_EXCEPTION();
980 void ScriptDocument::Impl::onDocumentCreated( const ScriptDocument
& /*_rDocument*/ )
985 void ScriptDocument::Impl::onDocumentOpened( const ScriptDocument
& /*_rDocument*/ )
990 void ScriptDocument::Impl::onDocumentSave( const ScriptDocument
& /*_rDocument*/ )
995 void ScriptDocument::Impl::onDocumentSaveDone( const ScriptDocument
& /*_rDocument*/ )
1000 void ScriptDocument::Impl::onDocumentSaveAs( const ScriptDocument
& /*_rDocument*/ )
1002 // not interested in
1005 void ScriptDocument::Impl::onDocumentSaveAsDone( const ScriptDocument
& /*_rDocument*/ )
1007 // not interested in
1010 void ScriptDocument::Impl::onDocumentClosed( const ScriptDocument
& _rDocument
)
1012 DBG_TESTSOLARMUTEX();
1013 OSL_PRECOND( isValid(), "ScriptDocument::Impl::onDocumentClosed: should not be listening if I'm not valid!" );
1015 bool bMyDocument
= m_xDocument
== _rDocument
.getDocument();
1016 OSL_PRECOND( bMyDocument
, "ScriptDocument::Impl::onDocumentClosed: didn't want to know *this*!" );
1019 m_bDocumentClosed
= true;
1024 void ScriptDocument::Impl::onDocumentTitleChanged( const ScriptDocument
& /*_rDocument*/ )
1026 // not interested in
1029 void ScriptDocument::Impl::onDocumentModeChanged( const ScriptDocument
& /*_rDocument*/ )
1031 // not interested in
1035 ScriptDocument::ScriptDocument()
1040 ScriptDocument::ScriptDocument( ScriptDocument::SpecialDocument _eType
)
1041 :m_pImpl( new Impl( Reference
< XModel
>() ) )
1043 OSL_ENSURE( _eType
== NoDocument
, "ScriptDocument::ScriptDocument: unknown SpecialDocument type!" );
1048 ScriptDocument::ScriptDocument( const Reference
< XModel
>& _rxDocument
)
1049 :m_pImpl( new Impl( _rxDocument
) )
1051 OSL_ENSURE( _rxDocument
.is(), "ScriptDocument::ScriptDocument: document must not be NULL!" );
1052 // a NULL document results in an uninitialized instance, and for this
1053 // purpose, there is a dedicated constructor
1057 ScriptDocument::ScriptDocument( const ScriptDocument
& _rSource
)
1058 :m_pImpl( _rSource
.m_pImpl
)
1063 ScriptDocument::~ScriptDocument()
1068 const ScriptDocument
& ScriptDocument::getApplicationScriptDocument()
1070 static ScriptDocument s_aApplicationScripts
;
1071 return s_aApplicationScripts
;
1075 ScriptDocument
ScriptDocument::getDocumentForBasicManager( const BasicManager
* _pManager
)
1077 if ( _pManager
== SfxApplication::GetBasicManager() )
1078 return getApplicationScriptDocument();
1080 docs::Documents aDocuments
;
1081 lcl_getAllModels_throw( aDocuments
, false );
1083 for ( docs::Documents::const_iterator doc
= aDocuments
.begin();
1084 doc
!= aDocuments
.end();
1088 const BasicManager
* pDocBasicManager
= ::basic::BasicManagerRepository::getDocumentBasicManager( doc
->xModel
);
1089 if ( ( pDocBasicManager
!= SfxApplication::GetBasicManager() )
1090 && ( pDocBasicManager
== _pManager
)
1093 return ScriptDocument( doc
->xModel
);
1097 OSL_FAIL( "ScriptDocument::getDocumentForBasicManager: did not find a document for this manager!" );
1098 return ScriptDocument( NoDocument
);
1102 ScriptDocument
ScriptDocument::getDocumentWithURLOrCaption( const OUString
& _rUrlOrCaption
)
1104 ScriptDocument
aDocument( getApplicationScriptDocument() );
1105 if ( _rUrlOrCaption
.isEmpty() )
1108 docs::Documents aDocuments
;
1109 lcl_getAllModels_throw( aDocuments
, false );
1111 for ( docs::Documents::const_iterator doc
= aDocuments
.begin();
1112 doc
!= aDocuments
.end();
1116 const ScriptDocument aCheck
= ScriptDocument( doc
->xModel
);
1117 if ( _rUrlOrCaption
== aCheck
.getTitle()
1118 || _rUrlOrCaption
== aCheck
.getURL()
1132 struct DocumentTitleLess
: public ::std::binary_function
< ScriptDocument
, ScriptDocument
, bool >
1134 explicit DocumentTitleLess( const CollatorWrapper
& _rCollator
)
1135 :m_aCollator( _rCollator
)
1139 bool operator()( const ScriptDocument
& _lhs
, const ScriptDocument
& _rhs
) const
1141 return m_aCollator
.compareString( _lhs
.getTitle(), _rhs
.getTitle() ) < 0;
1144 const CollatorWrapper m_aCollator
;
1149 ScriptDocuments
ScriptDocument::getAllScriptDocuments( ScriptDocument::ScriptDocumentList _eListType
)
1151 ScriptDocuments aScriptDocs
;
1153 // include application?
1154 if ( _eListType
== AllWithApplication
)
1155 aScriptDocs
.push_back( getApplicationScriptDocument() );
1160 docs::Documents aDocuments
;
1161 lcl_getAllModels_throw( aDocuments
, true /* exclude invisible */ );
1163 for ( docs::Documents::const_iterator doc
= aDocuments
.begin();
1164 doc
!= aDocuments
.end();
1168 // exclude documents without script/library containers
1169 ScriptDocument
aDoc( doc
->xModel
);
1170 if ( !aDoc
.isValid() )
1173 aScriptDocs
.push_back( aDoc
);
1176 catch( const Exception
& )
1178 DBG_UNHANDLED_EXCEPTION();
1181 // sort document list by doc title?
1182 if ( _eListType
== DocumentsSorted
)
1184 CollatorWrapper
aCollator( ::comphelper::getProcessComponentContext() );
1185 aCollator
.loadDefaultCollator( SvtSysLocale().GetLanguageTag().getLocale(), 0 );
1186 ::std::sort( aScriptDocs
.begin(), aScriptDocs
.end(), DocumentTitleLess( aCollator
) );
1193 bool ScriptDocument::operator==( const ScriptDocument
& _rhs
) const
1195 return m_pImpl
->getDocumentRef() == _rhs
.m_pImpl
->getDocumentRef();
1199 sal_Int32
ScriptDocument::hashCode() const
1201 return sal::static_int_cast
<sal_Int32
>(reinterpret_cast< sal_IntPtr
>( m_pImpl
->getDocumentRef().get() ));
1205 bool ScriptDocument::isValid() const
1207 return m_pImpl
->isValid();
1211 bool ScriptDocument::isAlive() const
1213 return m_pImpl
->isAlive();
1217 Reference
< XLibraryContainer
> ScriptDocument::getLibraryContainer( LibraryContainerType _eType
) const
1219 return m_pImpl
->getLibraryContainer( _eType
);
1223 Reference
< XNameContainer
> ScriptDocument::getLibrary( LibraryContainerType _eType
, const OUString
& _rLibName
, bool _bLoadLibrary
) const
1225 return m_pImpl
->getLibrary( _eType
, _rLibName
, _bLoadLibrary
);
1229 bool ScriptDocument::hasLibrary( LibraryContainerType _eType
, const OUString
& _rLibName
) const
1231 return m_pImpl
->hasLibrary( _eType
, _rLibName
);
1235 Reference
< XNameContainer
> ScriptDocument::getOrCreateLibrary( LibraryContainerType _eType
, const OUString
& _rLibName
) const
1237 return m_pImpl
->getOrCreateLibrary( _eType
, _rLibName
);
1241 void ScriptDocument::loadLibraryIfExists( LibraryContainerType _eType
, const OUString
& _rLibrary
)
1243 m_pImpl
->loadLibraryIfExists( _eType
, _rLibrary
);
1247 Sequence
< OUString
> ScriptDocument::getObjectNames( LibraryContainerType _eType
, const OUString
& _rLibName
) const
1249 Sequence
< OUString
> aModuleNames
;
1253 if ( hasLibrary( _eType
, _rLibName
) )
1255 Reference
< XNameContainer
> xLib( getLibrary( _eType
, _rLibName
, false ) );
1257 aModuleNames
= xLib
->getElementNames();
1260 catch( const Exception
& )
1262 DBG_UNHANDLED_EXCEPTION();
1266 ::std::sort( aModuleNames
.getArray() , aModuleNames
.getArray() + aModuleNames
.getLength() , StringCompareLessThan
);
1268 return aModuleNames
;
1272 OUString
ScriptDocument::createObjectName( LibraryContainerType _eType
, const OUString
& _rLibName
) const
1274 OUString aObjectName
;
1276 OUString aBaseName
= _eType
== E_SCRIPTS
? OUString("Module") : OUString("Dialog");
1278 Sequence
< OUString
> aUsedNames( getObjectNames( _eType
, _rLibName
) );
1279 ::std::set
< OUString
> aUsedNamesCheck
;
1280 ::std::copy( aUsedNames
.getConstArray(), aUsedNames
.getConstArray() + aUsedNames
.getLength(),
1281 ::std::insert_iterator
< ::std::set
< OUString
> >( aUsedNamesCheck
, aUsedNamesCheck
.begin() ) );
1283 bool bValid
= false;
1287 aObjectName
= aBaseName
;
1288 aObjectName
+= OUString::number( i
);
1290 if ( aUsedNamesCheck
.find( aObjectName
) == aUsedNamesCheck
.end() )
1300 Sequence
< OUString
> ScriptDocument::getLibraryNames() const
1302 return GetMergedLibraryNames( getLibraryContainer( E_SCRIPTS
), getLibraryContainer( E_DIALOGS
) );
1306 bool ScriptDocument::isReadOnly() const
1308 return m_pImpl
->isReadOnly();
1312 bool ScriptDocument::isApplication() const
1314 return m_pImpl
->isApplication();
1317 bool ScriptDocument::isInVBAMode() const
1319 return m_pImpl
->isInVBAMode();
1323 BasicManager
* ScriptDocument::getBasicManager() const
1325 return m_pImpl
->getBasicManager();
1329 Reference
< XModel
> ScriptDocument::getDocument() const
1331 return m_pImpl
->getDocument();
1335 Reference
< XModel
> ScriptDocument::getDocumentOrNull() const
1338 return m_pImpl
->getDocument();
1343 bool ScriptDocument::removeModule( const OUString
& _rLibName
, const OUString
& _rModuleName
) const
1345 return m_pImpl
->removeModuleOrDialog( E_SCRIPTS
, _rLibName
, _rModuleName
);
1349 bool ScriptDocument::hasModule( const OUString
& _rLibName
, const OUString
& _rModuleName
) const
1351 return m_pImpl
->hasModuleOrDialog( E_SCRIPTS
, _rLibName
, _rModuleName
);
1355 bool ScriptDocument::getModule( const OUString
& _rLibName
, const OUString
& _rModName
, OUString
& _out_rModuleSource
) const
1358 if ( !m_pImpl
->getModuleOrDialog( E_SCRIPTS
, _rLibName
, _rModName
, aCode
) )
1360 OSL_VERIFY( aCode
>>= _out_rModuleSource
);
1365 bool ScriptDocument::renameModule( const OUString
& _rLibName
, const OUString
& _rOldName
, const OUString
& _rNewName
) const
1367 return m_pImpl
->renameModuleOrDialog( E_SCRIPTS
, _rLibName
, _rOldName
, _rNewName
, NULL
);
1371 bool ScriptDocument::createModule( const OUString
& _rLibName
, const OUString
& _rModName
, bool _bCreateMain
, OUString
& _out_rNewModuleCode
) const
1373 if ( !m_pImpl
->createModule( _rLibName
, _rModName
, _bCreateMain
, _out_rNewModuleCode
) )
1376 // doc shell modified
1377 MarkDocumentModified( *const_cast< ScriptDocument
* >( this ) ); // here?
1382 bool ScriptDocument::insertModule( const OUString
& _rLibName
, const OUString
& _rModName
, const OUString
& _rModuleCode
) const
1384 return m_pImpl
->insertModuleOrDialog( E_SCRIPTS
, _rLibName
, _rModName
, makeAny( _rModuleCode
) );
1388 bool ScriptDocument::updateModule( const OUString
& _rLibName
, const OUString
& _rModName
, const OUString
& _rModuleCode
) const
1390 return m_pImpl
->updateModule( _rLibName
, _rModName
, _rModuleCode
);
1394 bool ScriptDocument::removeDialog( const OUString
& _rLibName
, const OUString
& _rDialogName
) const
1396 return m_pImpl
->removeModuleOrDialog( E_DIALOGS
, _rLibName
, _rDialogName
);
1400 bool ScriptDocument::hasDialog( const OUString
& _rLibName
, const OUString
& _rDialogName
) const
1402 return m_pImpl
->hasModuleOrDialog( E_DIALOGS
, _rLibName
, _rDialogName
);
1406 bool ScriptDocument::getDialog( const OUString
& _rLibName
, const OUString
& _rDialogName
, Reference
< XInputStreamProvider
>& _out_rDialogProvider
) const
1409 if ( !m_pImpl
->getModuleOrDialog( E_DIALOGS
, _rLibName
, _rDialogName
, aCode
) )
1411 OSL_VERIFY( aCode
>>= _out_rDialogProvider
);
1412 return _out_rDialogProvider
.is();
1416 bool ScriptDocument::renameDialog( const OUString
& _rLibName
, const OUString
& _rOldName
, const OUString
& _rNewName
, const Reference
< XNameContainer
>& _rxExistingDialogModel
) const
1418 return m_pImpl
->renameModuleOrDialog( E_DIALOGS
, _rLibName
, _rOldName
, _rNewName
, _rxExistingDialogModel
);
1422 bool ScriptDocument::createDialog( const OUString
& _rLibName
, const OUString
& _rDialogName
, Reference
< XInputStreamProvider
>& _out_rDialogProvider
) const
1424 if ( !m_pImpl
->createDialog( _rLibName
, _rDialogName
, _out_rDialogProvider
) )
1427 MarkDocumentModified( *const_cast< ScriptDocument
* >( this ) ); // here?
1432 bool ScriptDocument::insertDialog( const OUString
& _rLibName
, const OUString
& _rDialogName
, const Reference
< XInputStreamProvider
>& _rxDialogProvider
) const
1434 return m_pImpl
->insertModuleOrDialog( E_DIALOGS
, _rLibName
, _rDialogName
, makeAny( _rxDialogProvider
) );
1438 void ScriptDocument::setDocumentModified() const
1440 m_pImpl
->setDocumentModified();
1444 bool ScriptDocument::isDocumentModified() const
1446 return m_pImpl
->isDocumentModified();
1450 bool ScriptDocument::saveDocument( const Reference
< XStatusIndicator
>& _rxStatusIndicator
) const
1452 return m_pImpl
->saveDocument( _rxStatusIndicator
);
1456 LibraryLocation
ScriptDocument::getLibraryLocation( const OUString
& _rLibName
) const
1458 LibraryLocation eLocation
= LIBRARY_LOCATION_UNKNOWN
;
1459 if ( !_rLibName
.isEmpty() )
1463 eLocation
= LIBRARY_LOCATION_DOCUMENT
;
1467 if ( ( hasLibrary( E_SCRIPTS
, _rLibName
) && !m_pImpl
->isLibraryShared( _rLibName
, E_SCRIPTS
) )
1468 || ( hasLibrary( E_DIALOGS
, _rLibName
) && !m_pImpl
->isLibraryShared( _rLibName
, E_DIALOGS
) )
1471 eLocation
= LIBRARY_LOCATION_USER
;
1475 eLocation
= LIBRARY_LOCATION_SHARE
;
1484 OUString
ScriptDocument::getTitle( LibraryLocation _eLocation
, LibraryType _eType
) const
1488 switch ( _eLocation
)
1490 case LIBRARY_LOCATION_USER
:
1494 case LIBRARY_TYPE_MODULE
: aTitle
= IDE_RESSTR(RID_STR_USERMACROS
); break;
1495 case LIBRARY_TYPE_DIALOG
: aTitle
= IDE_RESSTR(RID_STR_USERDIALOGS
); break;
1496 case LIBRARY_TYPE_ALL
: aTitle
= IDE_RESSTR(RID_STR_USERMACROSDIALOGS
); break;
1501 case LIBRARY_LOCATION_SHARE
:
1505 case LIBRARY_TYPE_MODULE
: aTitle
= IDE_RESSTR(RID_STR_SHAREMACROS
); break;
1506 case LIBRARY_TYPE_DIALOG
: aTitle
= IDE_RESSTR(RID_STR_SHAREDIALOGS
); break;
1507 case LIBRARY_TYPE_ALL
: aTitle
= IDE_RESSTR(RID_STR_SHAREMACROSDIALOGS
); break;
1513 case LIBRARY_LOCATION_DOCUMENT
:
1514 aTitle
= getTitle();
1525 OUString
ScriptDocument::getTitle() const
1527 return m_pImpl
->getTitle();
1531 OUString
ScriptDocument::getURL() const
1533 return m_pImpl
->getURL();
1537 bool ScriptDocument::isActive() const
1539 bool bIsActive( false );
1542 Reference
< XFrame
> xFrame
;
1543 if ( m_pImpl
->getCurrentFrame( xFrame
) )
1544 bIsActive
= xFrame
->isActive();
1546 catch( const Exception
& )
1548 DBG_UNHANDLED_EXCEPTION();
1554 bool ScriptDocument::allowMacros() const
1556 return m_pImpl
->allowMacros();
1559 } // namespace basctl
1561 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */