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 .
21 #include <scriptdocument.hxx>
23 #include <strings.hrc>
25 #include <dlgeddef.hxx>
26 #include <doceventnotifier.hxx>
27 #include "documentenumeration.hxx"
29 #include <com/sun/star/ucb/ContentCreationException.hpp>
30 #include <com/sun/star/uri/UriReferenceFactory.hpp>
31 #include <com/sun/star/util/theMacroExpander.hpp>
32 #include <com/sun/star/frame/XStorable.hpp>
33 #include <com/sun/star/frame/FrameSearchFlag.hpp>
34 #include <com/sun/star/frame/XDispatchProvider.hpp>
35 #include <com/sun/star/awt/XWindow2.hpp>
36 #include <com/sun/star/beans/XPropertySet.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 #include <com/sun/star/script/ModuleInfo.hpp>
41 #include <com/sun/star/script/ModuleType.hpp>
43 #include <sfx2/app.hxx>
44 #include <sfx2/objsh.hxx>
45 #include <sfx2/bindings.hxx>
46 #include <sfx2/docfile.hxx>
48 #include <basic/basicmanagerrepository.hxx>
50 #include <xmlscript/xmldlg_imexp.hxx>
52 #include <i18nlangtag/languagetag.hxx>
54 #include <comphelper/diagnose_ex.hxx>
55 #include <config_folders.h>
56 #include <tools/debug.hxx>
58 #include <comphelper/documentinfo.hxx>
59 #include <comphelper/processfactory.hxx>
60 #include <comphelper/propertysequence.hxx>
61 #include <comphelper/string.hxx>
63 #include <vcl/svapp.hxx>
64 #include <vcl/settings.hxx>
66 #include <osl/file.hxx>
67 #include <rtl/uri.hxx>
73 using ::com::sun::star::uno::Sequence
;
74 using ::com::sun::star::uno::Reference
;
75 using ::com::sun::star::frame::XModel
;
76 using ::com::sun::star::beans::XPropertySet
;
77 using ::com::sun::star::script::XLibraryContainer
;
78 using ::com::sun::star::uno::UNO_QUERY_THROW
;
79 using ::com::sun::star::uno::UNO_SET_THROW
;
80 using ::com::sun::star::uno::Exception
;
81 using ::com::sun::star::container::XNameContainer
;
82 using ::com::sun::star::container::NoSuchElementException
;
83 using ::com::sun::star::uno::UNO_QUERY
;
84 using ::com::sun::star::task::XStatusIndicator
;
85 using ::com::sun::star::uno::Any
;
86 using ::com::sun::star::script::XLibraryContainer2
;
87 using ::com::sun::star::uri::UriReferenceFactory
;
88 using ::com::sun::star::uri::XUriReferenceFactory
;
89 using ::com::sun::star::uri::XUriReference
;
90 using ::com::sun::star::uno::XComponentContext
;
91 using ::com::sun::star::util::XMacroExpander
;
92 using ::com::sun::star::util::theMacroExpander
;
93 using ::com::sun::star::io::XInputStreamProvider
;
94 using ::com::sun::star::uno::Any
;
95 using ::com::sun::star::io::XInputStream
;
96 using ::com::sun::star::frame::XStorable
;
97 using ::com::sun::star::util::XModifiable
;
98 using ::com::sun::star::frame::XController
;
99 using ::com::sun::star::frame::XFrame
;
100 using ::com::sun::star::util::URL
;
101 using ::com::sun::star::frame::XDispatchProvider
;
102 using ::com::sun::star::frame::XDispatch
;
103 using ::com::sun::star::beans::PropertyValue
;
104 using ::com::sun::star::awt::XWindow2
;
105 using ::com::sun::star::document::XEmbeddedScripts
;
106 using ::com::sun::star::script::ModuleInfo
;
107 using ::com::sun::star::script::vba::XVBACompatibility
;
108 using ::com::sun::star::script::vba::XVBAModuleInfo
;
110 namespace FrameSearchFlag
= ::com::sun::star::frame::FrameSearchFlag
;
115 class FilterDocuments
: public docs::IDocumentDescriptorFilter
118 explicit FilterDocuments(bool _bFilterInvisible
)
119 : m_bFilterInvisible(_bFilterInvisible
)
123 virtual ~FilterDocuments() {}
125 virtual bool includeDocument( const docs::DocumentDescriptor
& _rDocument
) const override
;
128 static bool impl_isDocumentVisible_nothrow( const docs::DocumentDescriptor
& _rDocument
);
131 bool m_bFilterInvisible
;
134 bool FilterDocuments::impl_isDocumentVisible_nothrow( const docs::DocumentDescriptor
& _rDocument
)
138 for (auto const& controller
: _rDocument
.aControllers
)
140 Reference
< XFrame
> xFrame( controller
->getFrame(), UNO_SET_THROW
);
141 Reference
< XWindow2
> xContainer( xFrame
->getContainerWindow(), UNO_QUERY_THROW
);
142 if ( xContainer
->isVisible() )
146 catch( const Exception
& )
148 DBG_UNHANDLED_EXCEPTION("basctl.basicide");
153 bool FilterDocuments::includeDocument( const docs::DocumentDescriptor
& _rDocument
) const
155 Reference
< XEmbeddedScripts
> xScripts( _rDocument
.xModel
, UNO_QUERY
);
156 if ( !xScripts
.is() )
158 return !m_bFilterInvisible
|| impl_isDocumentVisible_nothrow( _rDocument
);
161 void lcl_getAllModels_throw( docs::Documents
& _out_rModels
, bool _bVisibleOnly
)
163 _out_rModels
.clear();
165 FilterDocuments
aFilter( _bVisibleOnly
);
166 docs::DocumentEnumeration
aEnum(
167 comphelper::getProcessComponentContext(), &aFilter
);
169 aEnum
.getDocuments( _out_rModels
);
173 class ScriptDocument::Impl
: public DocumentEventListener
176 bool m_bIsApplication
;
178 bool m_bDocumentClosed
;
179 Reference
< XModel
> m_xDocument
;
180 Reference
< XModifiable
> m_xDocModify
;
181 Reference
< XEmbeddedScripts
> m_xScriptAccess
;
182 std::unique_ptr
< DocumentEventNotifier
> m_pDocListener
;
186 explicit Impl(Reference
<XModel
> const& rxDocument
);
187 virtual ~Impl() override
;
189 /** determines whether the instance refers to a valid "document" with script and
192 bool isValid() const { return m_bValid
; }
193 /** determines whether the instance refers to a non-closed document
195 bool isAlive() const { return m_bValid
&& ( m_bIsApplication
|| !m_bDocumentClosed
); }
196 /// determines whether the "document" refers to the application in real
197 bool isApplication() const { return m_bValid
&& m_bIsApplication
; }
198 /// determines whether the document refers to a real document (instead of the application)
199 bool isDocument() const { return m_bValid
&& !m_bIsApplication
; }
201 /** invalidates the instance
205 const Reference
< XModel
>&
206 getDocumentRef() const { return m_xDocument
; }
208 /// returns a library container belonging to the document
209 Reference
< XLibraryContainer
>
210 getLibraryContainer( LibraryContainerType _eType
) const;
212 /// determines whether a given library is part of the shared installation
213 bool isLibraryShared( const OUString
& _rLibName
, LibraryContainerType _eType
);
215 /** returns the current frame of the document
217 To be called for documents only, not for the application.
219 If <FALSE/> is returned, an assertion will be raised in non-product builds.
221 bool getCurrentFrame( Reference
< XFrame
>& _out_rxFrame
) const;
223 // versions with the same signature/semantics as in ScriptDocument itself
224 bool isReadOnly() const;
225 bool isInVBAMode() const;
227 getBasicManager() const;
230 void setDocumentModified() const;
231 bool isDocumentModified() const;
232 void saveDocument( const Reference
< XStatusIndicator
>& _rxStatusIndicator
) const;
234 OUString
getTitle() const;
235 OUString
getURL() const;
237 bool allowMacros() const;
239 Reference
< XNameContainer
>
240 getLibrary( LibraryContainerType _eType
, const OUString
& _rLibName
, bool _bLoadLibrary
) const;
241 bool hasLibrary( LibraryContainerType _eType
, const OUString
& _rLibName
) const;
242 Reference
< XNameContainer
>
243 getOrCreateLibrary( LibraryContainerType _eType
, const OUString
& _rLibName
) const;
245 void loadLibraryIfExists( LibraryContainerType _eType
, const OUString
& _rLibrary
);
247 bool removeModuleOrDialog( LibraryContainerType _eType
, const OUString
& _rLibName
, const OUString
& _rModuleName
);
248 bool hasModuleOrDialog( LibraryContainerType _eType
, const OUString
& _rLibName
, const OUString
& _rModName
) const;
249 bool getModuleOrDialog( LibraryContainerType _eType
, const OUString
& _rLibName
, const OUString
& _rObjectName
, Any
& _out_rModuleOrDialog
);
250 bool renameModuleOrDialog( LibraryContainerType _eType
, const OUString
& _rLibName
, const OUString
& _rOldName
, const OUString
& _rNewName
, const Reference
< XNameContainer
>& _rxExistingDialogModel
);
251 bool createModule( const OUString
& _rLibName
, const OUString
& _rModName
, bool _bCreateMain
, OUString
& _out_rNewModuleCode
) const;
252 bool insertModuleOrDialog( LibraryContainerType _eType
, const OUString
& _rObjectName
, const OUString
& _rModName
, const Any
& _rElement
) const;
253 bool updateModule( const OUString
& _rLibName
, const OUString
& _rModName
, const OUString
& _rModuleCode
) const;
254 bool createDialog( const OUString
& _rLibName
, const OUString
& _rDialogName
, Reference
< XInputStreamProvider
>& _out_rDialogProvider
) const;
257 // DocumentEventListener
258 virtual void onDocumentCreated( const ScriptDocument
& _rDocument
) override
;
259 virtual void onDocumentOpened( const ScriptDocument
& _rDocument
) override
;
260 virtual void onDocumentSave( const ScriptDocument
& _rDocument
) override
;
261 virtual void onDocumentSaveDone( const ScriptDocument
& _rDocument
) override
;
262 virtual void onDocumentSaveAs( const ScriptDocument
& _rDocument
) override
;
263 virtual void onDocumentSaveAsDone( const ScriptDocument
& _rDocument
) override
;
264 virtual void onDocumentClosed( const ScriptDocument
& _rDocument
) override
;
265 virtual void onDocumentTitleChanged( const ScriptDocument
& _rDocument
) override
;
266 virtual void onDocumentModeChanged( const ScriptDocument
& _rDocument
) override
;
269 bool impl_initDocument_nothrow( const Reference
< XModel
>& _rxModel
);
273 ScriptDocument::Impl::Impl()
274 :m_bIsApplication( true )
276 ,m_bDocumentClosed( false )
280 ScriptDocument::Impl::Impl( const Reference
< XModel
>& _rxDocument
)
281 :m_bIsApplication( false )
283 ,m_bDocumentClosed( false )
285 if ( _rxDocument
.is() )
286 impl_initDocument_nothrow( _rxDocument
);
289 ScriptDocument::Impl::~Impl()
294 void ScriptDocument::Impl::invalidate()
296 m_bIsApplication
= false;
298 m_bDocumentClosed
= false;
301 m_xDocModify
.clear();
302 m_xScriptAccess
.clear();
305 m_pDocListener
->dispose();
308 bool ScriptDocument::Impl::impl_initDocument_nothrow( const Reference
< XModel
>& _rxModel
)
312 m_xDocument
.set ( _rxModel
, UNO_SET_THROW
);
313 m_xDocModify
.set ( _rxModel
, UNO_QUERY_THROW
);
314 m_xScriptAccess
.set ( _rxModel
, UNO_QUERY
);
316 m_bValid
= m_xScriptAccess
.is();
319 m_pDocListener
.reset( new DocumentEventNotifier( *this, _rxModel
) );
321 catch( const Exception
& )
323 DBG_UNHANDLED_EXCEPTION("basctl.basicide");
335 Reference
< XLibraryContainer
> ScriptDocument::Impl::getLibraryContainer( LibraryContainerType _eType
) const
337 OSL_ENSURE( isValid(), "ScriptDocument::Impl::getLibraryContainer: invalid!" );
339 Reference
< XLibraryContainer
> xContainer
;
345 if ( isApplication() )
346 xContainer
.set( _eType
== E_SCRIPTS
? SfxGetpApp()->GetBasicContainer() : SfxGetpApp()->GetDialogContainer(), UNO_QUERY_THROW
);
350 _eType
== E_SCRIPTS
? m_xScriptAccess
->getBasicLibraries() : m_xScriptAccess
->getDialogLibraries(),
354 catch( const Exception
& )
356 DBG_UNHANDLED_EXCEPTION("basctl.basicide");
361 bool ScriptDocument::Impl::isReadOnly() const
363 OSL_ENSURE( isValid(), "ScriptDocument::Impl::isReadOnly: invalid state!" );
364 OSL_ENSURE( !isApplication(), "ScriptDocument::Impl::isReadOnly: not allowed to be called for the application!" );
366 bool bIsReadOnly
= true;
367 if ( isValid() && !isApplication() )
371 // note that XStorable is required by the OfficeDocument service
372 Reference
< XStorable
> xDocStorable( m_xDocument
, UNO_QUERY_THROW
);
373 bIsReadOnly
= xDocStorable
->isReadonly();
375 catch( const Exception
& )
377 DBG_UNHANDLED_EXCEPTION("basctl.basicide");
383 bool ScriptDocument::Impl::isInVBAMode() const
385 bool bResult
= false;
386 if ( !isApplication() )
388 Reference
< XVBACompatibility
> xVBACompat( getLibraryContainer( E_SCRIPTS
), UNO_QUERY
);
389 if ( xVBACompat
.is() )
390 bResult
= xVBACompat
->getVBACompatibilityMode();
395 BasicManager
* ScriptDocument::Impl::getBasicManager() const
399 OSL_ENSURE( isValid(), "ScriptDocument::Impl::getBasicManager: invalid state!" );
403 if ( isApplication() )
404 return SfxApplication::GetBasicManager();
406 return ::basic::BasicManagerRepository::getDocumentBasicManager( m_xDocument
);
408 catch (const css::ucb::ContentCreationException
&)
410 TOOLS_WARN_EXCEPTION( "basctl.basicide", "ScriptDocument::getBasicManager" );
415 Reference
< XModel
> ScriptDocument::Impl::getDocument() const
417 OSL_ENSURE( isValid(), "ScriptDocument::Impl::getDocument: invalid state!" );
418 OSL_ENSURE( isDocument(), "ScriptDocument::Impl::getDocument: for documents only!" );
419 if ( !isValid() || !isDocument() )
426 Reference
< XNameContainer
> ScriptDocument::Impl::getLibrary( LibraryContainerType _eType
, const OUString
& _rLibName
, bool _bLoadLibrary
) const
428 OSL_ENSURE( isValid(), "ScriptDocument::Impl::getLibrary: invalid state!" );
430 Reference
< XNameContainer
> xContainer
;
433 Reference
< XLibraryContainer
> xLibContainer
= getLibraryContainer( _eType
);
434 if ( isValid() && xLibContainer
.is() )
435 xContainer
.set( xLibContainer
->getByName( _rLibName
), UNO_QUERY_THROW
);
437 if ( !xContainer
.is() )
438 throw NoSuchElementException();
441 if ( _bLoadLibrary
&& !xLibContainer
->isLibraryLoaded( _rLibName
) )
442 xLibContainer
->loadLibrary( _rLibName
);
444 catch( const NoSuchElementException
& )
446 throw; // allowed to leave
448 catch( const Exception
& )
450 DBG_UNHANDLED_EXCEPTION("basctl.basicide");
457 bool ScriptDocument::Impl::hasLibrary( LibraryContainerType _eType
, const OUString
& _rLibName
) const
462 Reference
< XLibraryContainer
> xLibContainer
= getLibraryContainer( _eType
);
463 bHas
= xLibContainer
.is() && xLibContainer
->hasByName( _rLibName
);
465 catch( const Exception
& )
467 DBG_UNHANDLED_EXCEPTION("basctl.basicide");
473 Reference
< XNameContainer
> ScriptDocument::Impl::getOrCreateLibrary( LibraryContainerType _eType
, const OUString
& _rLibName
) const
475 Reference
< XNameContainer
> xLibrary
;
478 Reference
< XLibraryContainer
> xLibContainer( getLibraryContainer( _eType
), UNO_SET_THROW
);
479 if ( xLibContainer
->hasByName( _rLibName
) )
480 xLibrary
.set( xLibContainer
->getByName( _rLibName
), UNO_QUERY_THROW
);
482 xLibrary
.set( xLibContainer
->createLibrary( _rLibName
), UNO_SET_THROW
);
484 if ( !xLibContainer
->isLibraryLoaded( _rLibName
) )
485 xLibContainer
->loadLibrary( _rLibName
);
487 catch( const Exception
& )
489 DBG_UNHANDLED_EXCEPTION("basctl.basicide");
495 void ScriptDocument::Impl::loadLibraryIfExists( LibraryContainerType _eType
, const OUString
& _rLibrary
)
499 Reference
< XLibraryContainer
> xLibContainer( getLibraryContainer( _eType
) );
500 if ( xLibContainer
.is() && xLibContainer
->hasByName( _rLibrary
) && !xLibContainer
->isLibraryLoaded( _rLibrary
) )
501 xLibContainer
->loadLibrary( _rLibrary
);
503 catch( const Exception
& )
505 DBG_UNHANDLED_EXCEPTION("basctl.basicide");
510 bool ScriptDocument::Impl::removeModuleOrDialog( LibraryContainerType _eType
, const OUString
& _rLibName
, const OUString
& _rModuleName
)
512 OSL_ENSURE( isValid(), "ScriptDocument::Impl::removeModuleOrDialog: invalid!" );
517 Reference
< XNameContainer
> xLib( getLibrary( _eType
, _rLibName
, true ) );
520 xLib
->removeByName( _rModuleName
);
521 Reference
< XVBAModuleInfo
> xVBAModuleInfo(xLib
, UNO_QUERY
);
522 if(xVBAModuleInfo
.is() && xVBAModuleInfo
->hasModuleInfo(_rModuleName
))
523 xVBAModuleInfo
->removeModuleInfo(_rModuleName
);
527 catch( const Exception
& )
529 DBG_UNHANDLED_EXCEPTION("basctl.basicide");
535 bool ScriptDocument::Impl::hasModuleOrDialog( LibraryContainerType _eType
, const OUString
& _rLibName
, const OUString
& _rModName
) const
537 OSL_ENSURE( isValid(), "ScriptDocument::Impl::hasModuleOrDialog: invalid!" );
543 Reference
< XNameContainer
> xLib( getLibrary( _eType
, _rLibName
, true ) );
545 return xLib
->hasByName( _rModName
);
547 catch( const Exception
& )
549 DBG_UNHANDLED_EXCEPTION("basctl.basicide");
555 bool ScriptDocument::Impl::getModuleOrDialog( LibraryContainerType _eType
, const OUString
& _rLibName
, const OUString
& _rObjectName
, Any
& _out_rModuleOrDialog
)
557 OSL_ENSURE( isValid(), "ScriptDocument::Impl::getModuleOrDialog: invalid!" );
561 _out_rModuleOrDialog
.clear();
564 Reference
< XNameContainer
> xLib( getLibrary( _eType
, _rLibName
, true ), UNO_SET_THROW
);
565 if ( xLib
->hasByName( _rObjectName
) )
567 _out_rModuleOrDialog
= xLib
->getByName( _rObjectName
);
571 catch( const Exception
& )
573 DBG_UNHANDLED_EXCEPTION("basctl.basicide");
579 bool ScriptDocument::Impl::renameModuleOrDialog( LibraryContainerType _eType
, const OUString
& _rLibName
,
580 const OUString
& _rOldName
, const OUString
& _rNewName
, const Reference
< XNameContainer
>& _rxExistingDialogModel
)
582 OSL_ENSURE( isValid(), "ScriptDocument::Impl::renameModuleOrDialog: invalid!" );
588 Reference
< XNameContainer
> xLib( getLibrary( _eType
, _rLibName
, true ), UNO_SET_THROW
);
591 Any
aElement( xLib
->getByName( _rOldName
) );
593 // remove element from container
594 xLib
->removeByName( _rOldName
);
596 // if it's a dialog, import and export, to reflect the new name
597 if ( _eType
== E_DIALOGS
)
599 // create dialog model
600 Reference
< XComponentContext
> aContext(
601 comphelper::getProcessComponentContext() );
602 Reference
< XNameContainer
> xDialogModel
;
603 if ( _rxExistingDialogModel
.is() )
604 xDialogModel
= _rxExistingDialogModel
;
607 ( aContext
->getServiceManager()->
608 createInstanceWithContext(
609 "com.sun.star.awt.UnoControlDialogModel",
613 // import dialog model
614 Reference
< XInputStreamProvider
> xISP( aElement
, UNO_QUERY_THROW
);
615 if ( !_rxExistingDialogModel
.is() )
617 Reference
< XInputStream
> xInput( xISP
->createInputStream(), UNO_SET_THROW
);
618 ::xmlscript::importDialogModel( xInput
, xDialogModel
, aContext
, isDocument() ? getDocument() : Reference
< XModel
>() );
621 // set new name as property
622 Reference
< XPropertySet
> xDlgPSet( xDialogModel
, UNO_QUERY_THROW
);
623 xDlgPSet
->setPropertyValue( DLGED_PROP_NAME
, Any( _rNewName
) );
625 // export dialog model
626 xISP
= ::xmlscript::exportDialogModel( xDialogModel
, aContext
, isDocument() ? getDocument() : Reference
< XModel
>() );
630 // insert element by new name in container
631 if ( _eType
== E_SCRIPTS
)
633 Reference
< XVBAModuleInfo
> xVBAModuleInfo( xLib
, UNO_QUERY
);
634 if ( xVBAModuleInfo
.is() && xVBAModuleInfo
->hasModuleInfo( _rOldName
) )
636 ModuleInfo sModuleInfo
= xVBAModuleInfo
->getModuleInfo( _rOldName
);
637 xVBAModuleInfo
->removeModuleInfo( _rOldName
);
638 xVBAModuleInfo
->insertModuleInfo( _rNewName
, sModuleInfo
);
641 xLib
->insertByName( _rNewName
, aElement
);
644 catch( const Exception
& )
646 DBG_UNHANDLED_EXCEPTION("basctl.basicide");
652 bool ScriptDocument::Impl::createModule( const OUString
& _rLibName
, const OUString
& _rModName
, bool _bCreateMain
, OUString
& _out_rNewModuleCode
) const
654 _out_rNewModuleCode
.clear();
657 Reference
< XNameContainer
> xLib( getLibrary( E_SCRIPTS
, _rLibName
, true ) );
658 if ( !xLib
.is() || xLib
->hasByName( _rModName
) )
662 _out_rNewModuleCode
= "REM ***** BASIC *****\n\n" ;
664 _out_rNewModuleCode
+= "Sub Main\n\nEnd Sub\n" ;
666 Reference
< XVBAModuleInfo
> xVBAModuleInfo(xLib
, UNO_QUERY
);
667 if (xVBAModuleInfo
.is())
669 css::script::ModuleInfo aModuleInfo
;
670 aModuleInfo
.ModuleType
= css::script::ModuleType::NORMAL
;
671 xVBAModuleInfo
->insertModuleInfo(_rModName
, aModuleInfo
);
674 // insert module into library
675 xLib
->insertByName( _rModName
, Any( _out_rNewModuleCode
) );
677 catch( const Exception
& )
679 DBG_UNHANDLED_EXCEPTION("basctl.basicide");
687 bool ScriptDocument::Impl::insertModuleOrDialog( LibraryContainerType _eType
, const OUString
& _rLibName
, const OUString
& _rObjectName
, const Any
& _rElement
) const
691 Reference
< XNameContainer
> xLib( getOrCreateLibrary( _eType
, _rLibName
), UNO_SET_THROW
);
692 if ( xLib
->hasByName( _rObjectName
) )
695 xLib
->insertByName( _rObjectName
, _rElement
);
698 catch( const Exception
& )
700 DBG_UNHANDLED_EXCEPTION("basctl.basicide");
706 bool ScriptDocument::Impl::updateModule( const OUString
& _rLibName
, const OUString
& _rModName
, const OUString
& _rModuleCode
) const
710 Reference
< XNameContainer
> xLib( getOrCreateLibrary( E_SCRIPTS
, _rLibName
), UNO_SET_THROW
);
711 if ( !xLib
->hasByName( _rModName
) )
713 xLib
->replaceByName( _rModName
, Any( _rModuleCode
) );
716 catch( const Exception
& )
718 DBG_UNHANDLED_EXCEPTION("basctl.basicide");
724 bool ScriptDocument::Impl::createDialog( const OUString
& _rLibName
, const OUString
& _rDialogName
, Reference
< XInputStreamProvider
>& _out_rDialogProvider
) const
728 Reference
< XNameContainer
> xLib( getLibrary( E_DIALOGS
, _rLibName
, true ), UNO_SET_THROW
);
731 _out_rDialogProvider
.clear();
732 if ( xLib
->hasByName( _rDialogName
) )
735 // create new dialog model
736 Reference
< XComponentContext
> aContext(
737 comphelper::getProcessComponentContext() );
738 Reference
< XNameContainer
> xDialogModel(
739 aContext
->getServiceManager()->createInstanceWithContext(
740 "com.sun.star.awt.UnoControlDialogModel", aContext
),
744 Reference
< XPropertySet
> xDlgPSet( xDialogModel
, UNO_QUERY_THROW
);
745 xDlgPSet
->setPropertyValue( DLGED_PROP_NAME
, Any( _rDialogName
) );
747 // export dialog model
748 _out_rDialogProvider
= ::xmlscript::exportDialogModel( xDialogModel
, aContext
, isDocument() ? getDocument() : Reference
< XModel
>() );
750 // insert dialog into library
751 xLib
->insertByName( _rDialogName
, Any( _out_rDialogProvider
) );
753 catch( const Exception
& )
755 DBG_UNHANDLED_EXCEPTION("basctl.basicide");
758 return _out_rDialogProvider
.is();
762 void ScriptDocument::Impl::setDocumentModified() const
764 OSL_ENSURE( isValid() && isDocument(), "ScriptDocument::Impl::setDocumentModified: only to be called for real documents!" );
765 if ( isValid() && isDocument() )
769 m_xDocModify
->setModified( true );
771 catch( const Exception
& )
773 DBG_UNHANDLED_EXCEPTION("basctl.basicide");
779 bool ScriptDocument::Impl::isDocumentModified() const
781 OSL_ENSURE( isValid() && isDocument(), "ScriptDocument::Impl::isDocumentModified: only to be called for real documents!" );
782 bool bIsModified
= false;
783 if ( isValid() && isDocument() )
787 bIsModified
= m_xDocModify
->isModified();
789 catch( const Exception
& )
791 DBG_UNHANDLED_EXCEPTION("basctl.basicide");
798 void ScriptDocument::Impl::saveDocument( const Reference
< XStatusIndicator
>& _rxStatusIndicator
) const
800 Reference
< XFrame
> xFrame
;
801 if ( !getCurrentFrame( xFrame
) )
804 Sequence
< PropertyValue
> aArgs
;
805 if ( _rxStatusIndicator
.is() )
807 aArgs
= ::comphelper::InitPropertySequence({
808 { "StatusIndicator", Any(_rxStatusIndicator
) }
815 aURL
.Complete
= ".uno:Save" ;
816 aURL
.Main
= aURL
.Complete
;
817 aURL
.Protocol
= ".uno:" ;
820 Reference
< XDispatchProvider
> xDispProv( xFrame
, UNO_QUERY_THROW
);
821 Reference
< XDispatch
> xDispatch(
822 xDispProv
->queryDispatch( aURL
, "_self", FrameSearchFlag::AUTO
),
825 xDispatch
->dispatch( aURL
, aArgs
);
827 catch( const Exception
& )
829 DBG_UNHANDLED_EXCEPTION("basctl.basicide");
834 OUString
ScriptDocument::Impl::getTitle() const
836 OSL_PRECOND( isValid() && isDocument(), "ScriptDocument::Impl::getTitle: for documents only!" );
839 if ( isValid() && isDocument() )
841 sTitle
= ::comphelper::DocumentInfo::getDocumentTitle( m_xDocument
);
847 OUString
ScriptDocument::Impl::getURL() const
849 OSL_PRECOND( isValid() && isDocument(), "ScriptDocument::Impl::getURL: for documents only!" );
852 if ( isValid() && isDocument() )
856 sURL
= m_xDocument
->getURL();
858 catch( const Exception
& )
860 DBG_UNHANDLED_EXCEPTION("basctl.basicide");
867 bool ScriptDocument::Impl::allowMacros() const
869 OSL_ENSURE( isValid() && isDocument(), "ScriptDocument::Impl::allowMacros: for documents only!" );
871 if ( isValid() && isDocument() )
875 bAllow
= m_xScriptAccess
->getAllowMacroExecution();
877 catch( const Exception
& )
879 DBG_UNHANDLED_EXCEPTION("basctl.basicide");
886 bool ScriptDocument::Impl::getCurrentFrame( Reference
< XFrame
>& _out_rxFrame
) const
888 _out_rxFrame
.clear();
889 OSL_PRECOND( isValid() && isDocument(), "ScriptDocument::Impl::getCurrentFrame: documents only!" );
890 if ( !isValid() || !isDocument() )
895 Reference
< XModel
> xDocument( m_xDocument
, UNO_SET_THROW
);
896 Reference
< XController
> xController( xDocument
->getCurrentController(), UNO_SET_THROW
);
897 _out_rxFrame
.set( xController
->getFrame(), UNO_SET_THROW
);
899 catch( const Exception
& )
901 DBG_UNHANDLED_EXCEPTION("basctl.basicide");
904 return _out_rxFrame
.is();
908 bool ScriptDocument::Impl::isLibraryShared( const OUString
& _rLibName
, LibraryContainerType _eType
)
910 bool bIsShared
= false;
913 Reference
< XLibraryContainer2
> xLibContainer( getLibraryContainer( _eType
), UNO_QUERY_THROW
);
915 if ( !xLibContainer
->hasByName( _rLibName
) || !xLibContainer
->isLibraryLink( _rLibName
) )
918 Reference
< XComponentContext
> xContext( ::comphelper::getProcessComponentContext() );
919 Reference
< XUriReferenceFactory
> xUriFac
= UriReferenceFactory::create(xContext
);
921 OUString
aLinkURL( xLibContainer
->getLibraryLinkURL( _rLibName
) );
922 Reference
< XUriReference
> xUriRef( xUriFac
->parse( aLinkURL
), UNO_SET_THROW
);
924 OUString aScheme
= xUriRef
->getScheme();
925 if ( aScheme
.equalsIgnoreAsciiCase("file") )
929 else if ( aScheme
.equalsIgnoreAsciiCase("vnd.sun.star.pkg") )
931 OUString aDecodedURL
= xUriRef
->getAuthority();
932 if (aDecodedURL
.startsWithIgnoreAsciiCase("vnd.sun.star.expand:", &aDecodedURL
))
934 aDecodedURL
= ::rtl::Uri::decode( aDecodedURL
, rtl_UriDecodeWithCharset
, RTL_TEXTENCODING_UTF8
);
935 Reference
< XMacroExpander
> xMacroExpander
= theMacroExpander::get(xContext
);
936 aFileURL
= xMacroExpander
->expandMacros( aDecodedURL
);
940 if ( !aFileURL
.isEmpty() )
942 ::osl::DirectoryItem aFileItem
;
943 ::osl::FileStatus
aFileStatus( osl_FileStatus_Mask_FileURL
);
944 OSL_VERIFY( ::osl::DirectoryItem::get( aFileURL
, aFileItem
) == ::osl::FileBase::E_None
);
945 OSL_VERIFY( aFileItem
.getFileStatus( aFileStatus
) == ::osl::FileBase::E_None
);
946 OUString
aCanonicalFileURL( aFileStatus
.getFileURL() );
948 if( aCanonicalFileURL
.indexOf( LIBO_SHARE_FOLDER
"/basic" ) >= 0 ||
949 aCanonicalFileURL
.indexOf( LIBO_SHARE_FOLDER
"/uno_packages" ) >= 0 ||
950 aCanonicalFileURL
.indexOf( LIBO_SHARE_FOLDER
"/extensions" ) >= 0 )
954 catch( const Exception
& )
956 DBG_UNHANDLED_EXCEPTION("basctl.basicide");
963 void ScriptDocument::Impl::onDocumentCreated( const ScriptDocument
& /*_rDocument*/ )
968 void ScriptDocument::Impl::onDocumentOpened( const ScriptDocument
& /*_rDocument*/ )
973 void ScriptDocument::Impl::onDocumentSave( const ScriptDocument
& /*_rDocument*/ )
978 void ScriptDocument::Impl::onDocumentSaveDone( const ScriptDocument
& /*_rDocument*/ )
983 void ScriptDocument::Impl::onDocumentSaveAs( const ScriptDocument
& /*_rDocument*/ )
988 void ScriptDocument::Impl::onDocumentSaveAsDone( const ScriptDocument
& /*_rDocument*/ )
993 void ScriptDocument::Impl::onDocumentClosed( const ScriptDocument
& _rDocument
)
995 DBG_TESTSOLARMUTEX();
996 OSL_PRECOND( isValid(), "ScriptDocument::Impl::onDocumentClosed: should not be listening if I'm not valid!" );
998 bool bMyDocument
= m_xDocument
== _rDocument
.getDocument();
999 OSL_PRECOND( bMyDocument
, "ScriptDocument::Impl::onDocumentClosed: didn't want to know *this*!" );
1002 m_bDocumentClosed
= true;
1007 void ScriptDocument::Impl::onDocumentTitleChanged( const ScriptDocument
& /*_rDocument*/ )
1009 // not interested in
1012 void ScriptDocument::Impl::onDocumentModeChanged( const ScriptDocument
& /*_rDocument*/ )
1014 // not interested in
1018 ScriptDocument::ScriptDocument()
1019 :m_pImpl(std::make_shared
<Impl
>())
1023 ScriptDocument::ScriptDocument( ScriptDocument::SpecialDocument _eType
)
1024 :m_pImpl( std::make_shared
<Impl
>( Reference
< XModel
>() ) )
1026 OSL_ENSURE( _eType
== NoDocument
, "ScriptDocument::ScriptDocument: unknown SpecialDocument type!" );
1030 ScriptDocument::ScriptDocument( const Reference
< XModel
>& _rxDocument
)
1031 :m_pImpl( std::make_shared
<Impl
>( _rxDocument
) )
1033 OSL_ENSURE( _rxDocument
.is(), "ScriptDocument::ScriptDocument: document must not be NULL!" );
1034 // a NULL document results in an uninitialized instance, and for this
1035 // purpose, there is a dedicated constructor
1039 const ScriptDocument
& ScriptDocument::getApplicationScriptDocument()
1041 static ScriptDocument s_aApplicationScripts
;
1042 return s_aApplicationScripts
;
1046 ScriptDocument
ScriptDocument::getDocumentForBasicManager( const BasicManager
* _pManager
)
1048 if ( _pManager
== SfxApplication::GetBasicManager() )
1049 return getApplicationScriptDocument();
1051 docs::Documents aDocuments
;
1052 lcl_getAllModels_throw( aDocuments
, false );
1054 for (auto const& doc
: aDocuments
)
1056 const BasicManager
* pDocBasicManager
= ::basic::BasicManagerRepository::getDocumentBasicManager( doc
.xModel
);
1057 if ( ( pDocBasicManager
!= SfxApplication::GetBasicManager() )
1058 && ( pDocBasicManager
== _pManager
)
1061 return ScriptDocument( doc
.xModel
);
1065 OSL_FAIL( "ScriptDocument::getDocumentForBasicManager: did not find a document for this manager!" );
1066 return ScriptDocument( NoDocument
);
1070 ScriptDocument
ScriptDocument::getDocumentWithURLOrCaption( std::u16string_view _rUrlOrCaption
)
1072 ScriptDocument
aDocument( getApplicationScriptDocument() );
1073 if ( _rUrlOrCaption
.empty() )
1076 docs::Documents aDocuments
;
1077 lcl_getAllModels_throw( aDocuments
, false );
1079 for (auto const& doc
: aDocuments
)
1081 const ScriptDocument
aCheck( doc
.xModel
);
1082 if ( _rUrlOrCaption
== aCheck
.getTitle()
1083 || _rUrlOrCaption
== aCheck
.m_pImpl
->getURL()
1094 ScriptDocuments
ScriptDocument::getAllScriptDocuments( ScriptDocument::ScriptDocumentList _eListType
)
1096 ScriptDocuments aScriptDocs
;
1098 // include application?
1099 if ( _eListType
== AllWithApplication
)
1100 aScriptDocs
.push_back( getApplicationScriptDocument() );
1105 docs::Documents aDocuments
;
1106 lcl_getAllModels_throw( aDocuments
, true /* exclude invisible */ );
1108 for (auto const& doc
: aDocuments
)
1110 // exclude documents without script/library containers
1111 ScriptDocument
aDoc( doc
.xModel
);
1112 if ( !aDoc
.isValid() )
1115 aScriptDocs
.push_back( aDoc
);
1118 catch( const Exception
& )
1120 DBG_UNHANDLED_EXCEPTION("basctl.basicide");
1123 // sort document list by doc title?
1124 if ( _eListType
== DocumentsSorted
)
1126 auto const sort
= comphelper::string::NaturalStringSorter(
1127 comphelper::getProcessComponentContext(),
1128 Application::GetSettings().GetUILanguageTag().getLocale());
1129 std::sort(aScriptDocs
.begin(), aScriptDocs
.end(),
1130 [&sort
](const ScriptDocument
& rLHS
, const ScriptDocument
& rRHS
) {
1131 return sort
.compare(rLHS
.getTitle(), rRHS
.getTitle()) < 0;
1139 bool ScriptDocument::operator==( const ScriptDocument
& _rhs
) const
1141 return m_pImpl
->getDocumentRef() == _rhs
.m_pImpl
->getDocumentRef();
1145 sal_Int32
ScriptDocument::hashCode() const
1147 return sal::static_int_cast
<sal_Int32
>(reinterpret_cast< sal_IntPtr
>( m_pImpl
->getDocumentRef().get() ));
1151 bool ScriptDocument::isValid() const
1153 return m_pImpl
->isValid();
1157 bool ScriptDocument::isAlive() const
1159 return m_pImpl
->isAlive();
1163 Reference
< XLibraryContainer
> ScriptDocument::getLibraryContainer( LibraryContainerType _eType
) const
1165 return m_pImpl
->getLibraryContainer( _eType
);
1169 Reference
< XNameContainer
> ScriptDocument::getLibrary( LibraryContainerType _eType
, const OUString
& _rLibName
, bool _bLoadLibrary
) const
1171 return m_pImpl
->getLibrary( _eType
, _rLibName
, _bLoadLibrary
);
1175 bool ScriptDocument::hasLibrary( LibraryContainerType _eType
, const OUString
& _rLibName
) const
1177 return m_pImpl
->hasLibrary( _eType
, _rLibName
);
1181 Reference
< XNameContainer
> ScriptDocument::getOrCreateLibrary( LibraryContainerType _eType
, const OUString
& _rLibName
) const
1183 return m_pImpl
->getOrCreateLibrary( _eType
, _rLibName
);
1187 void ScriptDocument::loadLibraryIfExists( LibraryContainerType _eType
, const OUString
& _rLibrary
)
1189 m_pImpl
->loadLibraryIfExists( _eType
, _rLibrary
);
1193 Sequence
< OUString
> ScriptDocument::getObjectNames( LibraryContainerType _eType
, const OUString
& _rLibName
) const
1195 Sequence
< OUString
> aModuleNames
;
1199 if ( hasLibrary( _eType
, _rLibName
) )
1201 Reference
< XNameContainer
> xLib( getLibrary( _eType
, _rLibName
, false ) );
1203 aModuleNames
= xLib
->getElementNames();
1206 catch( const Exception
& )
1208 DBG_UNHANDLED_EXCEPTION("basctl.basicide");
1212 auto const sort
= comphelper::string::NaturalStringSorter(
1213 comphelper::getProcessComponentContext(),
1214 Application::GetSettings().GetUILanguageTag().getLocale());
1215 auto [begin
, end
] = asNonConstRange(aModuleNames
);
1216 std::sort(begin
, end
,
1217 [&sort
](const OUString
& rLHS
, const OUString
& rRHS
) {
1218 return sort
.compare(rLHS
, rRHS
) < 0;
1220 return aModuleNames
;
1224 OUString
ScriptDocument::createObjectName( LibraryContainerType _eType
, const OUString
& _rLibName
) const
1226 OUString aObjectName
;
1228 OUString aBaseName
= _eType
== E_SCRIPTS
? OUString("Module") : OUString("Dialog");
1230 const Sequence
< OUString
> aUsedNames( getObjectNames( _eType
, _rLibName
) );
1231 std::set
< OUString
> aUsedNamesCheck( aUsedNames
.begin(), aUsedNames
.end() );
1233 bool bValid
= false;
1237 aObjectName
= aBaseName
1238 + OUString::number( i
);
1240 if ( aUsedNamesCheck
.find( aObjectName
) == aUsedNamesCheck
.end() )
1250 Sequence
< OUString
> ScriptDocument::getLibraryNames() const
1252 return GetMergedLibraryNames( getLibraryContainer( E_SCRIPTS
), getLibraryContainer( E_DIALOGS
) );
1256 bool ScriptDocument::isReadOnly() const
1258 return m_pImpl
->isReadOnly();
1262 bool ScriptDocument::isApplication() const
1264 return m_pImpl
->isApplication();
1267 bool ScriptDocument::isInVBAMode() const
1269 return m_pImpl
->isInVBAMode();
1273 BasicManager
* ScriptDocument::getBasicManager() const
1275 return m_pImpl
->getBasicManager();
1279 Reference
< XModel
> ScriptDocument::getDocument() const
1281 return m_pImpl
->getDocument();
1285 Reference
< XModel
> ScriptDocument::getDocumentOrNull() const
1288 return m_pImpl
->getDocument();
1293 bool ScriptDocument::removeModule( const OUString
& _rLibName
, const OUString
& _rModuleName
) const
1295 return m_pImpl
->removeModuleOrDialog( E_SCRIPTS
, _rLibName
, _rModuleName
);
1299 bool ScriptDocument::hasModule( const OUString
& _rLibName
, const OUString
& _rModuleName
) const
1301 return m_pImpl
->hasModuleOrDialog( E_SCRIPTS
, _rLibName
, _rModuleName
);
1305 bool ScriptDocument::getModule( const OUString
& _rLibName
, const OUString
& _rModName
, OUString
& _out_rModuleSource
) const
1308 if ( !m_pImpl
->getModuleOrDialog( E_SCRIPTS
, _rLibName
, _rModName
, aCode
) )
1310 OSL_VERIFY( aCode
>>= _out_rModuleSource
);
1315 bool ScriptDocument::renameModule( const OUString
& _rLibName
, const OUString
& _rOldName
, const OUString
& _rNewName
) const
1317 return m_pImpl
->renameModuleOrDialog( E_SCRIPTS
, _rLibName
, _rOldName
, _rNewName
, nullptr );
1321 bool ScriptDocument::createModule( const OUString
& _rLibName
, const OUString
& _rModName
, bool _bCreateMain
, OUString
& _out_rNewModuleCode
) const
1323 if ( !m_pImpl
->createModule( _rLibName
, _rModName
, _bCreateMain
, _out_rNewModuleCode
) )
1326 // doc shell modified
1327 MarkDocumentModified( *const_cast< ScriptDocument
* >( this ) ); // here?
1332 bool ScriptDocument::insertModule( const OUString
& _rLibName
, const OUString
& _rModName
, const OUString
& _rModuleCode
) const
1334 return m_pImpl
->insertModuleOrDialog( E_SCRIPTS
, _rLibName
, _rModName
, Any( _rModuleCode
) );
1338 bool ScriptDocument::updateModule( const OUString
& _rLibName
, const OUString
& _rModName
, const OUString
& _rModuleCode
) const
1340 return m_pImpl
->updateModule( _rLibName
, _rModName
, _rModuleCode
);
1344 bool ScriptDocument::removeDialog( const OUString
& _rLibName
, const OUString
& _rDialogName
) const
1346 return m_pImpl
->removeModuleOrDialog( E_DIALOGS
, _rLibName
, _rDialogName
);
1350 bool ScriptDocument::hasDialog( const OUString
& _rLibName
, const OUString
& _rDialogName
) const
1352 return m_pImpl
->hasModuleOrDialog( E_DIALOGS
, _rLibName
, _rDialogName
);
1356 bool ScriptDocument::getDialog( const OUString
& _rLibName
, const OUString
& _rDialogName
, Reference
< XInputStreamProvider
>& _out_rDialogProvider
) const
1359 if ( !m_pImpl
->getModuleOrDialog( E_DIALOGS
, _rLibName
, _rDialogName
, aCode
) )
1361 OSL_VERIFY( aCode
>>= _out_rDialogProvider
);
1362 return _out_rDialogProvider
.is();
1366 bool ScriptDocument::renameDialog( const OUString
& _rLibName
, const OUString
& _rOldName
, const OUString
& _rNewName
, const Reference
< XNameContainer
>& _rxExistingDialogModel
) const
1368 return m_pImpl
->renameModuleOrDialog( E_DIALOGS
, _rLibName
, _rOldName
, _rNewName
, _rxExistingDialogModel
);
1372 bool ScriptDocument::createDialog( const OUString
& _rLibName
, const OUString
& _rDialogName
, Reference
< XInputStreamProvider
>& _out_rDialogProvider
) const
1374 if ( !m_pImpl
->createDialog( _rLibName
, _rDialogName
, _out_rDialogProvider
) )
1377 MarkDocumentModified( *const_cast< ScriptDocument
* >( this ) ); // here?
1382 bool ScriptDocument::insertDialog( const OUString
& _rLibName
, const OUString
& _rDialogName
, const Reference
< XInputStreamProvider
>& _rxDialogProvider
) const
1384 return m_pImpl
->insertModuleOrDialog( E_DIALOGS
, _rLibName
, _rDialogName
, Any( _rxDialogProvider
) );
1388 void ScriptDocument::setDocumentModified() const
1390 m_pImpl
->setDocumentModified();
1394 bool ScriptDocument::isDocumentModified() const
1396 return m_pImpl
->isDocumentModified();
1400 void ScriptDocument::saveDocument( const Reference
< XStatusIndicator
>& _rxStatusIndicator
) const
1402 m_pImpl
->saveDocument( _rxStatusIndicator
);
1406 LibraryLocation
ScriptDocument::getLibraryLocation( const OUString
& _rLibName
) const
1408 LibraryLocation eLocation
= LIBRARY_LOCATION_UNKNOWN
;
1409 if ( !_rLibName
.isEmpty() )
1413 eLocation
= LIBRARY_LOCATION_DOCUMENT
;
1417 if ( ( hasLibrary( E_SCRIPTS
, _rLibName
) && !m_pImpl
->isLibraryShared( _rLibName
, E_SCRIPTS
) )
1418 || ( hasLibrary( E_DIALOGS
, _rLibName
) && !m_pImpl
->isLibraryShared( _rLibName
, E_DIALOGS
) )
1421 eLocation
= LIBRARY_LOCATION_USER
;
1425 eLocation
= LIBRARY_LOCATION_SHARE
;
1434 OUString
ScriptDocument::getTitle( LibraryLocation _eLocation
, LibraryType _eType
) const
1438 switch ( _eLocation
)
1440 case LIBRARY_LOCATION_USER
:
1444 case LibraryType::Module
: aTitle
= IDEResId(RID_STR_USERMACROS
); break;
1445 case LibraryType::Dialog
: aTitle
= IDEResId(RID_STR_USERDIALOGS
); break;
1446 case LibraryType::All
: aTitle
= IDEResId(RID_STR_USERMACROSDIALOGS
); break;
1452 case LIBRARY_LOCATION_SHARE
:
1456 case LibraryType::Module
: aTitle
= IDEResId(RID_STR_SHAREMACROS
); break;
1457 case LibraryType::Dialog
: aTitle
= IDEResId(RID_STR_SHAREDIALOGS
); break;
1458 case LibraryType::All
: aTitle
= IDEResId(RID_STR_SHAREMACROSDIALOGS
); break;
1464 case LIBRARY_LOCATION_DOCUMENT
:
1465 aTitle
= getTitle();
1475 OUString
ScriptDocument::getTitle() const
1477 return m_pImpl
->getTitle();
1481 bool ScriptDocument::isActive() const
1483 bool bIsActive( false );
1486 Reference
< XFrame
> xFrame
;
1487 if ( m_pImpl
->getCurrentFrame( xFrame
) )
1488 bIsActive
= xFrame
->isActive();
1490 catch( const Exception
& )
1492 DBG_UNHANDLED_EXCEPTION("basctl.basicide");
1498 bool ScriptDocument::allowMacros() const
1500 return m_pImpl
->allowMacros();
1503 } // namespace basctl
1505 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */