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>
55#include <config_folders.h>
66#include <osl/file.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)
123 virtual ~FilterDocuments() {}
125 virtual bool includeDocument(
const docs::DocumentDescriptor& _rDocument )
const override;
128 static bool impl_isDocumentVisible_nothrow(
const docs::DocumentDescriptor& _rDocument );
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& )
153 bool FilterDocuments::includeDocument(
const docs::DocumentDescriptor& _rDocument )
const
156 if ( !xScripts.is() )
161 void lcl_getAllModels_throw(
docs::Documents& _out_rModels,
bool _bVisibleOnly )
163 _out_rModels.clear();
165 FilterDocuments aFilter( _bVisibleOnly );
166 docs::DocumentEnumeration aEnum(
169 aEnum.getDocuments( _out_rModels );
187 virtual ~Impl()
override;
251 bool createModule(
const OUString& _rLibName,
const OUString& _rModName,
bool _bCreateMain, OUString& _out_rNewModuleCode )
const;
253 bool updateModule(
const OUString& _rLibName,
const OUString& _rModName,
const OUString& _rModuleCode )
const;
274 :m_bIsApplication( true )
276 ,m_bDocumentClosed( false )
281 :m_bIsApplication( false )
283 ,m_bDocumentClosed( false )
285 if ( _rxDocument.is() )
296 m_bIsApplication =
false;
298 m_bDocumentClosed =
false;
301 m_xDocModify.clear();
302 m_xScriptAccess.clear();
305 m_pDocListener->dispose();
313 m_xDocModify.set ( _rxModel, UNO_QUERY_THROW );
314 m_xScriptAccess.set ( _rxModel, UNO_QUERY );
316 m_bValid = m_xScriptAccess.is();
337 OSL_ENSURE(
isValid(),
"ScriptDocument::Impl::getLibraryContainer: invalid!" );
350 _eType ==
E_SCRIPTS ? m_xScriptAccess->getBasicLibraries() : m_xScriptAccess->getDialogLibraries(),
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;
373 bIsReadOnly = xDocStorable->isReadonly();
385 bool bResult =
false;
389 if ( xVBACompat.is() )
390 bResult = xVBACompat->getVBACompatibilityMode();
399 OSL_ENSURE(
isValid(),
"ScriptDocument::Impl::getBasicManager: invalid state!" );
406 return ::basic::BasicManagerRepository::getDocumentBasicManager(
m_xDocument );
408 catch (
const css::ucb::ContentCreationException&)
417 OSL_ENSURE(
isValid(),
"ScriptDocument::Impl::getDocument: invalid state!" );
418 OSL_ENSURE(
isDocument(),
"ScriptDocument::Impl::getDocument: for documents only!" );
428 OSL_ENSURE(
isValid(),
"ScriptDocument::Impl::getLibrary: invalid state!" );
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& )
463 bHas = xLibContainer.is() && xLibContainer->hasByName( _rLibName );
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 );
500 if ( xLibContainer.is() && xLibContainer->hasByName( _rLibrary ) && !xLibContainer->isLibraryLoaded( _rLibrary ) )
501 xLibContainer->loadLibrary( _rLibrary );
512 OSL_ENSURE(
isValid(),
"ScriptDocument::Impl::removeModuleOrDialog: invalid!" );
520 xLib->removeByName( _rModuleName );
522 if(xVBAModuleInfo.is() && xVBAModuleInfo->hasModuleInfo(_rModuleName))
523 xVBAModuleInfo->removeModuleInfo(_rModuleName);
537 OSL_ENSURE(
isValid(),
"ScriptDocument::Impl::hasModuleOrDialog: invalid!" );
545 return xLib->hasByName( _rModName );
557 OSL_ENSURE(
isValid(),
"ScriptDocument::Impl::getModuleOrDialog: invalid!" );
561 _out_rModuleOrDialog.clear();
565 if ( xLib->hasByName( _rObjectName ) )
567 _out_rModuleOrDialog = xLib->getByName( _rObjectName );
582 OSL_ENSURE(
isValid(),
"ScriptDocument::Impl::renameModuleOrDialog: invalid!" );
591 Any aElement( xLib->getByName( _rOldName ) );
594 xLib->removeByName( _rOldName );
603 if ( _rxExistingDialogModel.is() )
604 xDialogModel = _rxExistingDialogModel;
607 ( aContext->getServiceManager()->
608 createInstanceWithContext(
609 "com.sun.star.awt.UnoControlDialogModel",
615 if ( !_rxExistingDialogModel.is() )
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 );
654 _out_rNewModuleCode.clear();
658 if ( !xLib.is() || xLib->hasByName( _rModName ) )
662 _out_rNewModuleCode =
"REM ***** BASIC *****\n\n" ;
664 _out_rNewModuleCode +=
"Sub Main\n\nEnd Sub\n" ;
667 if (xVBAModuleInfo.is())
669 css::script::ModuleInfo aModuleInfo;
670 aModuleInfo.ModuleType = css::script::ModuleType::NORMAL;
671 xVBAModuleInfo->insertModuleInfo(_rModName, aModuleInfo);
675 xLib->insertByName( _rModName,
Any( _out_rNewModuleCode ) );
692 if ( xLib->hasByName( _rObjectName ) )
695 xLib->insertByName( _rObjectName, _rElement );
711 if ( !xLib->hasByName( _rModName ) )
713 xLib->replaceByName( _rModName,
Any( _rModuleCode ) );
731 _out_rDialogProvider.clear();
732 if ( xLib->hasByName( _rDialogName ) )
739 aContext->getServiceManager()->createInstanceWithContext(
740 "com.sun.star.awt.UnoControlDialogModel", aContext ),
751 xLib->insertByName( _rDialogName,
Any( _out_rDialogProvider ) );
758 return _out_rDialogProvider.is();
764 OSL_ENSURE(
isValid() &&
isDocument(),
"ScriptDocument::Impl::setDocumentModified: only to be called for real documents!" );
769 m_xDocModify->setModified(
true );
781 OSL_ENSURE(
isValid() &&
isDocument(),
"ScriptDocument::Impl::isDocumentModified: only to be called for real documents!" );
782 bool bIsModified =
false;
787 bIsModified = m_xDocModify->isModified();
801 if ( !getCurrentFrame(
xFrame ) )
805 if ( _rxStatusIndicator.is() )
807 aArgs = ::comphelper::InitPropertySequence({
808 {
"StatusIndicator",
Any(_rxStatusIndicator) }
815 aURL.Complete =
".uno:Save" ;
817 aURL.Protocol =
".uno:" ;
822 xDispProv->queryDispatch(
aURL,
"_self", FrameSearchFlag::AUTO ),
836 OSL_PRECOND(
isValid() &&
isDocument(),
"ScriptDocument::Impl::getTitle: for documents only!" );
841 sTitle = ::comphelper::DocumentInfo::getDocumentTitle(
m_xDocument );
849 OSL_PRECOND(
isValid() &&
isDocument(),
"ScriptDocument::Impl::getURL: for documents only!" );
869 OSL_ENSURE(
isValid() &&
isDocument(),
"ScriptDocument::Impl::allowMacros: for documents only!" );
875 bAllow = m_xScriptAccess->getAllowMacroExecution();
888 _out_rxFrame.clear();
889 OSL_PRECOND(
isValid() &&
isDocument(),
"ScriptDocument::Impl::getCurrentFrame: documents only!" );
897 _out_rxFrame.set(
xController->getFrame(), UNO_SET_THROW );
904 return _out_rxFrame.is();
910 bool bIsShared =
false;
915 if ( !xLibContainer->hasByName( _rLibName ) || !xLibContainer->isLibraryLink( _rLibName ) )
921 OUString aLinkURL( xLibContainer->getLibraryLinkURL( _rLibName ) );
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 );
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 )
996 OSL_PRECOND(
isValid(),
"ScriptDocument::Impl::onDocumentClosed: should not be listening if I'm not valid!" );
999 OSL_PRECOND( bMyDocument,
"ScriptDocument::Impl::onDocumentClosed: didn't want to know *this*!" );
1002 m_bDocumentClosed =
true;
1026 OSL_ENSURE( _eType ==
NoDocument,
"ScriptDocument::ScriptDocument: unknown SpecialDocument type!" );
1033 OSL_ENSURE( _rxDocument.is(),
"ScriptDocument::ScriptDocument: document must not be NULL!" );
1042 return s_aApplicationScripts;
1052 lcl_getAllModels_throw( aDocuments,
false );
1054 for (
auto const& doc : aDocuments)
1058 && ( pDocBasicManager == _pManager )
1065 OSL_FAIL(
"ScriptDocument::getDocumentForBasicManager: did not find a document for this manager!" );
1073 if ( _rUrlOrCaption.empty() )
1077 lcl_getAllModels_throw( aDocuments,
false );
1079 for (
auto const& doc : aDocuments)
1082 if ( _rUrlOrCaption == aCheck.
getTitle()
1083 || _rUrlOrCaption == aCheck.
m_pImpl->getURL()
1106 lcl_getAllModels_throw( aDocuments,
true );
1108 for (
auto const& doc : aDocuments)
1115 aScriptDocs.push_back( aDoc );
1129 std::sort(aScriptDocs.begin(), aScriptDocs.end(),
1131 return sort.compare(rLHS.getTitle(), rRHS.getTitle()) < 0;
1141 return m_pImpl->getDocumentRef() == _rhs.
m_pImpl->getDocumentRef();
1147 return sal::static_int_cast<sal_Int32>(
reinterpret_cast< sal_IntPtr
>(
m_pImpl->getDocumentRef().get() ));
1165 return m_pImpl->getLibraryContainer( _eType );
1171 return m_pImpl->getLibrary( _eType, _rLibName, _bLoadLibrary );
1177 return m_pImpl->hasLibrary( _eType, _rLibName );
1183 return m_pImpl->getOrCreateLibrary( _eType, _rLibName );
1189 m_pImpl->loadLibraryIfExists( _eType, _rLibrary );
1203 aModuleNames = xLib->getElementNames();
1215 auto [
begin,
end] = asNonConstRange(aModuleNames);
1217 [&sort](
const OUString& rLHS,
const OUString& rRHS) {
1218 return sort.compare(rLHS, rRHS) < 0;
1220 return aModuleNames;
1226 OUString aObjectName;
1228 OUString aBaseName = _eType ==
E_SCRIPTS ? OUString(
"Module") : OUString(
"Dialog");
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() )
1264 return m_pImpl->isApplication();
1269 return m_pImpl->isInVBAMode();
1275 return m_pImpl->getBasicManager();
1281 return m_pImpl->getDocument();
1288 return m_pImpl->getDocument();
1295 return m_pImpl->removeModuleOrDialog(
E_SCRIPTS, _rLibName, _rModuleName );
1308 if ( !
m_pImpl->getModuleOrDialog(
E_SCRIPTS, _rLibName, _rModName, aCode ) )
1310 OSL_VERIFY( aCode >>= _out_rModuleSource );
1317 return m_pImpl->renameModuleOrDialog(
E_SCRIPTS, _rLibName, _rOldName, _rNewName,
nullptr );
1323 if ( !
m_pImpl->createModule( _rLibName, _rModName, _bCreateMain, _out_rNewModuleCode ) )
1334 return m_pImpl->insertModuleOrDialog(
E_SCRIPTS, _rLibName, _rModName,
Any( _rModuleCode ) );
1340 return m_pImpl->updateModule( _rLibName, _rModName, _rModuleCode );
1346 return m_pImpl->removeModuleOrDialog(
E_DIALOGS, _rLibName, _rDialogName );
1359 if ( !
m_pImpl->getModuleOrDialog(
E_DIALOGS, _rLibName, _rDialogName, aCode ) )
1361 OSL_VERIFY( aCode >>= _out_rDialogProvider );
1362 return _out_rDialogProvider.is();
1368 return m_pImpl->renameModuleOrDialog(
E_DIALOGS, _rLibName, _rOldName, _rNewName, _rxExistingDialogModel );
1374 if ( !
m_pImpl->createDialog( _rLibName, _rDialogName, _out_rDialogProvider ) )
1384 return m_pImpl->insertModuleOrDialog(
E_DIALOGS, _rLibName, _rDialogName,
Any( _rxDialogProvider ) );
1390 m_pImpl->setDocumentModified();
1396 return m_pImpl->isDocumentModified();
1402 m_pImpl->saveDocument( _rxStatusIndicator );
1409 if ( !_rLibName.isEmpty() )
1438 switch ( _eLocation )
1483 bool bIsActive(
false );
1488 bIsActive =
xFrame->isActive();
1500 return m_pImpl->allowMacros();
SfxApplication * SfxGetpApp()
static const AllSettings & GetSettings()
static BasicManager * GetBasicManager()
allows registering at theGlobalEventBroadcaster for global document events
virtual void onDocumentSaveAs(const ScriptDocument &_rDocument) override
virtual void onDocumentOpened(const ScriptDocument &_rDocument) override
bool createModule(const OUString &_rLibName, const OUString &_rModName, bool _bCreateMain, OUString &_out_rNewModuleCode) const
bool isDocumentModified() const
virtual void onDocumentModeChanged(const ScriptDocument &_rDocument) override
virtual void onDocumentSaveDone(const ScriptDocument &_rDocument) override
Reference< XNameContainer > getOrCreateLibrary(LibraryContainerType _eType, const OUString &_rLibName) const
bool hasLibrary(LibraryContainerType _eType, const OUString &_rLibName) const
bool hasModuleOrDialog(LibraryContainerType _eType, const OUString &_rLibName, const OUString &_rModName) const
void saveDocument(const Reference< XStatusIndicator > &_rxStatusIndicator) const
void setDocumentModified() const
OUString getTitle() const
bool createDialog(const OUString &_rLibName, const OUString &_rDialogName, Reference< XInputStreamProvider > &_out_rDialogProvider) const
Reference< XModel > getDocument() const
Reference< XLibraryContainer > getLibraryContainer(LibraryContainerType _eType) const
returns a library container belonging to the document
Reference< XModifiable > m_xDocModify
bool isValid() const
determines whether the instance refers to a valid "document" with script and dialog libraries
Reference< XEmbeddedScripts > m_xScriptAccess
virtual void onDocumentClosed(const ScriptDocument &_rDocument) override
bool impl_initDocument_nothrow(const Reference< XModel > &_rxModel)
bool renameModuleOrDialog(LibraryContainerType _eType, const OUString &_rLibName, const OUString &_rOldName, const OUString &_rNewName, const Reference< XNameContainer > &_rxExistingDialogModel)
virtual void onDocumentSave(const ScriptDocument &_rDocument) override
bool isAlive() const
determines whether the instance refers to a non-closed document
bool removeModuleOrDialog(LibraryContainerType _eType, const OUString &_rLibName, const OUString &_rModuleName)
bool insertModuleOrDialog(LibraryContainerType _eType, const OUString &_rObjectName, const OUString &_rModName, const Any &_rElement) const
void invalidate()
invalidates the instance
BasicManager * getBasicManager() const
bool isApplication() const
determines whether the "document" refers to the application in real
bool updateModule(const OUString &_rLibName, const OUString &_rModName, const OUString &_rModuleCode) const
bool isDocument() const
determines whether the document refers to a real document (instead of the application)
bool isLibraryShared(const OUString &_rLibName, LibraryContainerType _eType)
determines whether a given library is part of the shared installation
virtual void onDocumentSaveAsDone(const ScriptDocument &_rDocument) override
virtual void onDocumentTitleChanged(const ScriptDocument &_rDocument) override
virtual void onDocumentCreated(const ScriptDocument &_rDocument) override
void loadLibraryIfExists(LibraryContainerType _eType, const OUString &_rLibrary)
std::unique_ptr< DocumentEventNotifier > m_pDocListener
Reference< XModel > m_xDocument
const Reference< XModel > & getDocumentRef() const
bool getModuleOrDialog(LibraryContainerType _eType, const OUString &_rLibName, const OUString &_rObjectName, Any &_out_rModuleOrDialog)
Reference< XNameContainer > getLibrary(LibraryContainerType _eType, const OUString &_rLibName, bool _bLoadLibrary) const
bool getCurrentFrame(Reference< XFrame > &_out_rxFrame) const
returns the current frame of the document
encapsulates a document which contains Basic scripts and dialogs
css::uno::Reference< css::container::XNameContainer > getOrCreateLibrary(LibraryContainerType _eType, const OUString &_rLibName) const
creates a script or dialog library in the document, or returns an existing one
OUString getTitle(LibraryLocation _eLocation, LibraryType _eType=LibraryType::All) const
returns the title for the document
bool getModule(const OUString &_rLibName, const OUString &_rModName, OUString &_rModuleSource) const
retrieves a module's source
sal_Int32 hashCode() const
retrieves a (pretty simple) hash code for the document
bool insertModule(const OUString &_rLibName, const OUString &_rModName, const OUString &_rModuleCode) const
inserts a given piece as code as module
bool renameDialog(const OUString &_rLibName, const OUString &_rOldName, const OUString &_rNewName, const css::uno::Reference< css::container::XNameContainer > &_rxExistingDialogModel) const
renames a dialog
bool allowMacros() const
determines whether macro execution for this document is allowed
bool hasLibrary(LibraryContainerType _eType, const OUString &_rLibName) const
determines whether there exists a library of the given type, with the given name
css::uno::Reference< css::script::XLibraryContainer > getLibraryContainer(LibraryContainerType _eType) const
returns the Basic or Dialog library container of the document
bool isDocumentModified() const
determines whether the document is modified @precond the instance operates on a real document,...
bool removeModule(const OUString &_rLibName, const OUString &_rModuleName) const
removes a given script module from the document
css::uno::Reference< css::frame::XModel > getDocumentOrNull() const
returns the UNO component representing the document which the instance operates on
bool getDialog(const OUString &_rLibName, const OUString &_rDialogName, css::uno::Reference< css::io::XInputStreamProvider > &_out_rDialogProvider) const
retrieves a dialog
css::uno::Reference< css::frame::XModel > getDocument() const
returns the UNO component representing the document which the instance operates on
bool isDocument() const
determines whether the ScriptDocument instance operates on a real document, as opposed to the whole a...
BasicManager * getBasicManager() const
returns the BasicManager associated with this instance
ScriptDocumentList
operation mode for getAllScriptDocuments
@ AllWithApplication
all ScriptDocuments, including the dedicated one which represents the application-wide scripts/dialog...
@ DocumentsSorted
real documents only, sorted lexicographically by their title (using the sys locale's default collator...
static ScriptDocuments getAllScriptDocuments(ScriptDocumentList _eListType)
returns the set of ScriptDocument instances, one for each open document which contains Basic/Dialog c...
ScriptDocument()
creates a ScriptDocument instance which operates on the application-wide scripts and dialogs
bool removeDialog(const OUString &_rLibName, const OUString &_rDialogName) const
removes a given dialog from the document
bool updateModule(const OUString &_rLibName, const OUString &_rModName, const OUString &_rModuleCode) const
updates a given module with new code
static const ScriptDocument & getApplicationScriptDocument()
returns a reference to a shared ScriptDocument instance which operates on the application-wide script...
css::uno::Reference< css::container::XNameContainer > getLibrary(LibraryContainerType _eType, const OUString &_rLibName, bool _bLoadLibrary) const
returns a script or dialog library given by name
std::shared_ptr< Impl > m_pImpl
bool isReadOnly() const
determines whether the document is read-only
static ScriptDocument getDocumentForBasicManager(const BasicManager *_pManager)
returns a (newly created) ScriptDocument instance for the document to which a given BasicManager belo...
bool createModule(const OUString &_rLibName, const OUString &_rModName, bool _bCreateMain, OUString &_out_rNewModuleCode) const
creates a module with the given name in the given library
bool renameModule(const OUString &_rLibName, const OUString &_rOldName, const OUString &_rNewName) const
renames a module
bool isAlive() const
determines whether the document instance is alive
static ScriptDocument getDocumentWithURLOrCaption(std::u16string_view _rUrlOrCaption)
returns a (newly created) ScriptDocument instance for the document with a given caption or URL
void saveDocument(const css::uno::Reference< css::task::XStatusIndicator > &_rxStatusIndicator) const
saves the document, if the instance refers to a real document @precond isApplication returns <FALSE>
void setDocumentModified() const
marks the document as modified @precond the instance operates on a real document, not on the applicat...
bool insertDialog(const OUString &_rLibName, const OUString &_rDialogName, const css::uno::Reference< css::io::XInputStreamProvider > &_rDialogProvider) const
inserts a given dialog into a given library
css::uno::Sequence< OUString > getLibraryNames() const
retrieves the (combined) names of all script and dialog libraries
OUString getTitle() const
returns the title of the document
bool operator==(const ScriptDocument &_rhs) const
bool isActive() const
determines whether the document is currently the one-and-only application-wide active document
bool hasDialog(const OUString &_rLibName, const OUString &_rDialogName) const
determines whether a dialog with the given name exists in the given library
css::uno::Sequence< OUString > getObjectNames(LibraryContainerType _eType, const OUString &_rLibName) const
returns the names of the modules in a given script or dialog library of the document
bool hasModule(const OUString &_rLibName, const OUString &_rModName) const
determines whether a module with the given name exists in the given library
void loadLibraryIfExists(LibraryContainerType _eType, const OUString &_rLibrary)
loads a script or dialog library given by name, if there is such a library
bool createDialog(const OUString &_rLibName, const OUString &_rDialogName, css::uno::Reference< css::io::XInputStreamProvider > &_out_rDialogProvider) const
create a dialog
LibraryLocation getLibraryLocation(const OUString &_rLibName) const
returns the location of a library given by name
bool isApplication() const
determines whether the ScriptDocument instance operates on the whole application, as opposed to a rea...
bool isValid() const
determines whether the document is actually able to contain Basic/Dialog libraries
OUString createObjectName(LibraryContainerType _eType, const OUString &_rLibName) const
retrieves a name for a newly to be created module or dialog
static BasicManager * getDocumentBasicManager(const css::uno::Reference< css::frame::XModel > &_rxDocumentModel)
Reference< XOfficeDatabaseDocument > m_xDocument
#define DBG_TESTSOLARMUTEX()
#define TOOLS_WARN_EXCEPTION(area, stream)
#define DBG_UNHANDLED_EXCEPTION(...)
Reference< XDispatch > xDispatch
std::vector< DocumentDescriptor > Documents
constexpr OUStringLiteral DLGED_PROP_NAME
@ LIBRARY_LOCATION_UNKNOWN
@ LIBRARY_LOCATION_DOCUMENT
void MarkDocumentModified(const ScriptDocument &rDocument)
std::vector< ScriptDocument > ScriptDocuments
Sequence< OUString > GetMergedLibraryNames(const Reference< script::XLibraryContainer > &xModLibContainer, const Reference< script::XLibraryContainer > &xDlgLibContainer)
OUString IDEResId(TranslateId aId)
const LanguageTag & getLocale()
Reference< XComponentContext > getProcessComponentContext()
std::shared_ptr< T > make_shared(Args &&... args)
enumrange< T >::Iterator begin(enumrange< T >)
Reference< XController > xController
Reference< XFrame > xFrame