LibreOffice Module sfx2 (master) 1
|
encapsulates handling the macro mode of a document More...
#include <docmacromode.hxx>
Public Member Functions | |
DocumentMacroMode (IMacroDocumentAccess &_rDocumentAccess) | |
creates an instance More... | |
bool | allowMacroExecution () |
allows macro execution in the document More... | |
bool | disallowMacroExecution () |
disallows macro execution in the document More... | |
bool | adjustMacroMode (const css::uno::Reference< css::task::XInteractionHandler > &_rxInteraction, bool bHasValidContentSignature=false) |
checks whether the document allows executing contained macros. More... | |
bool | isMacroExecutionDisallowed () const |
determines whether macro execution is disallowed More... | |
bool | hasMacroLibrary () const |
determines whether the document actually has a macros library More... | |
bool | hasUnsignedContentError () const |
bool | checkMacrosOnLoading (const css::uno::Reference< css::task::XInteractionHandler > &_rxInteraction, bool bHasValidContentSignature=false) |
checks the macro execution mode while loading the document. More... | |
Static Public Member Functions | |
static bool | storageHasMacros (const css::uno::Reference< css::embed::XStorage > &_rxStorage) |
determines whether the given document storage has sub storages containing scripts or macros. More... | |
static bool | containerHasBasicMacros (const css::uno::Reference< css::script::XLibraryContainer > &xContainer) |
Private Attributes | |
std::shared_ptr< DocumentMacroMode_Data > | m_xData |
encapsulates handling the macro mode of a document
Definition at line 173 of file docmacromode.hxx.
sfx2::DocumentMacroMode::DocumentMacroMode | ( | IMacroDocumentAccess & | _rDocumentAccess | ) |
creates an instance
_rDocumentAccess | access to the document which this instance works for. Must live as long as the DocumentMacroMode instance lives, at least |
Definition at line 95 of file docmacromode.cxx.
References make_shared().
bool sfx2::DocumentMacroMode::adjustMacroMode | ( | const css::uno::Reference< css::task::XInteractionHandler > & | _rxInteraction, |
bool | bHasValidContentSignature = false |
||
) |
checks whether the document allows executing contained macros.
The method transforms the current macro execution mode into either ALWAYS_EXECUTE_NO_WARN or NEVER_EXECUTE, depending on the current value, possible configuration settings, and possible user interaction.
_rxInteraction | A handler for interactions which might become necessary. This includes
|
If the user needs to be asked for macro execution confirmation, and if this parameter is <NULL>, the most defensive assumptions will be made, effectively disabling macro execution.
bHasValidContentSignature | Whether the document content is signed and the signature is valid. |
Definition at line 112 of file docmacromode.cxx.
References allowMacroExecution(), BROKEN, disallowMacroExecution(), Exception, SvtSecurityOptions::GetMacroSecurityLevel(), INetURLObject::GetMainURL(), SvtSecurityOptions::IsMacroDisabled(), SvtSecurityOptions::IsReadOnly(), m_xData, SvtSecurityOptions::MacroTrustedAuthors, INetURLObject::NONE, NOTVALIDATED, OK, and INetURLObject::removeSegment().
Referenced by checkMacrosOnLoading().
bool sfx2::DocumentMacroMode::allowMacroExecution | ( | ) |
allows macro execution in the document
Effectively, the macro mode is set to MacroExecMode::ALWAYS_EXECUTE_NO_WARN.
Definition at line 100 of file docmacromode.cxx.
References m_xData.
Referenced by adjustMacroMode(), and checkMacrosOnLoading().
bool sfx2::DocumentMacroMode::checkMacrosOnLoading | ( | const css::uno::Reference< css::task::XInteractionHandler > & | _rxInteraction, |
bool | bHasValidContentSignature = false |
||
) |
checks the macro execution mode while loading the document.
This must be called when the loading is effectively finished, but before any macro action happened.
The method will disallow macro execution for this document if it is disabled globally (SvtSecurityOptions::IsMacroDisabled). Otherwise, it will check whether the document contains a macro storage or macro libraries. If so, it will properly calculate the MacroExecutionMode by calling adjustMacroMode.
If the document doesn't contain macros, yet, then the macro execution for this document will be allowed (again: unless disabled globally), since in this case macros which later are newly created by the user should be allowed, of course.
Definition at line 419 of file docmacromode.cxx.
References adjustMacroMode(), allowMacroExecution(), disallowMacroExecution(), hasMacroLibrary(), SvtSecurityOptions::IsMacroDisabled(), isMacroExecutionDisallowed(), and m_xData.
|
static |
Definition at line 323 of file docmacromode.cxx.
References Any, DBG_UNHANDLED_EXCEPTION, Exception, and u.
Referenced by hasMacroLibrary().
bool sfx2::DocumentMacroMode::disallowMacroExecution | ( | ) |
disallows macro execution in the document
Effectively, the macro mode is set to MacroExecMode::NEVER_EXECUTE.
Definition at line 106 of file docmacromode.cxx.
References m_xData.
Referenced by adjustMacroMode(), and checkMacrosOnLoading().
bool sfx2::DocumentMacroMode::hasMacroLibrary | ( | ) | const |
determines whether the document actually has a macros library
Effectively, this method checks the Basic library container (as returned by IMacroDocumentAccess::getEmbeddedDocumentScripts().getBasicLibraries) for content.
Definition at line 365 of file docmacromode.cxx.
References containerHasBasicMacros(), DBG_UNHANDLED_EXCEPTION, Exception, and m_xData.
Referenced by SfxViewFrame::AppendContainsMacrosInfobar(), and checkMacrosOnLoading().
bool sfx2::DocumentMacroMode::hasUnsignedContentError | ( | ) | const |
Definition at line 386 of file docmacromode.cxx.
References m_xData.
Referenced by SfxViewFrame::AppendContainsMacrosInfobar().
bool sfx2::DocumentMacroMode::isMacroExecutionDisallowed | ( | ) | const |
determines whether macro execution is disallowed
There's a number of reasons why macro execution could be disallowed:
Note that if this method returns <FALSE>, then subsequent calls of ->adjustMacroMode can still return <FALSE>. That is, if the current macro execution mode for the document is not yet known (and in particular not MacroExecMode::NEVER_EXECUTE), then ->isMacroExecutionDisallowed will return <FALSE>. However, a subsequent call to ->adjustMacroMode can result in the user denying macro execution, in which ->adjustMacroMode will return <FALSE>, and the next call to isMacroExecutionDisallowed will return <TRUE>.
Definition at line 317 of file docmacromode.cxx.
References m_xData.
Referenced by checkMacrosOnLoading().
|
static |
determines whether the given document storage has sub storages containing scripts or macros.
Effectively, the method checks for the presence of a sub-storage name "Scripts" (where BeanShell-/JavaScript-/Python-Scripts are stored, and a sub storage named "Basic" (where Basic scripts are stored).
Definition at line 392 of file docmacromode.cxx.
References DBG_UNHANDLED_EXCEPTION, Exception, and u.
|
private |
Definition at line 300 of file docmacromode.hxx.
Referenced by adjustMacroMode(), allowMacroExecution(), checkMacrosOnLoading(), disallowMacroExecution(), hasMacroLibrary(), hasUnsignedContentError(), and isMacroExecutionDisallowed().