19#ifndef INCLUDED_SFX2_OBJSH_HXX
20#define INCLUDED_SFX2_OBJSH_HXX
27#include <com/sun/star/uno/Reference.h>
28#include <com/sun/star/uno/Sequence.hxx>
29#include <com/sun/star/frame/XModel3.hpp>
49namespace model {
class ColorSet; }
83#define ASPECT_CONTENT 1
84#define ASPECT_THUMBNAIL 2
86#define ASPECT_DOCPRINT 8
110namespace sfx2 {
class IXmlIdRegistry; }
112#define SFX_TITLE_TITLE 0
113#define SFX_TITLE_FILENAME 1
114#define SFX_TITLE_FULLNAME 2
115#define SFX_TITLE_APINAME 3
116#define SFX_TITLE_DETECT 4
117#define SFX_TITLE_CAPTION 5
118#define SFX_TITLE_PICKLIST 6
119#define SFX_TITLE_HISTORY 7
120#define SFX_TITLE_MAXLEN 10
174 return dynamic_cast<const T*
>(pShell) !=
nullptr;
185 std::unique_ptr<struct SfxObjectShell_Impl>
pImpl;
197 TriState mbContinueImportOnFilterExceptions = undefined;
199 bool CloseInternal();
201 SAL_DLLPRIVATE
void UpdateTime_Impl(
const css::uno::Reference<
202 css::document::XDocumentProperties> & i_xDocProps);
214 virtual bool Close()
override;
217 virtual void DoFlushDocInfo();
220 void AddToRecentlyUsedList();
234 static void InitInterface_Impl();
237 static const css::uno::Sequence<sal_Int8>& getUnoTunnelId();
240 void Stamp_SetPrintCancelState(
bool bState);
241 bool Stamp_GetPrintCancelState()
const;
247 bool bOnlyVisible =
true );
249 const std::function<
bool (
const SfxObjectShell* )>& isObjectShell =
nullptr,
250 bool bOnlyVisible =
true );
252 static css::uno::Reference< css::uno::XInterface >
253 GetCurrentComponent();
254 static void SetCurrentComponent(
const css::uno::Reference< css::uno::XInterface >& _rxComponent );
256 virtual void Invalidate(sal_uInt16 nId = 0)
override;
262 css::uno::Reference< css::document::XDocumentProperties >
263 getDocProperties()
const;
264 void UpdateDocInfoForSave( );
267 OUString GetAPIName()
const;
270 bool IsReadOnlyMedium()
const;
271 bool IsOriginallyReadOnlyMedium()
const;
272 bool IsOriginallyLoadedReadOnlyMedium()
const;
273 void SetReadOnlyUI(
bool bReadOnly =
true );
274 bool IsReadOnlyUI()
const;
276 bool IsInModalMode()
const;
277 bool IsInPrepareClose()
const;
278 bool AcceptStateUpdate()
const;
279 bool IsHelpDocument()
const;
281 bool IsDocShared()
const;
282 OUString GetSharedFileURL()
const;
289 SAL_DLLPRIVATE
void SetModalMode_Impl(
bool bModal);
290 SAL_DLLPRIVATE
void SetMacroMode_Impl(
bool bModal=
true);
302 void DoInitUnitTest();
308 bool DoSaveObjectAs(
SfxMedium &rNewStor,
bool bCommit );
311 virtual bool DoSaveCompleted(
SfxMedium* pNewStor=
nullptr,
bool bRegisterRecent=
true );
315 bool LoadOwnFormat(
SfxMedium& pMedium );
316 virtual bool SaveAsOwnFormat(
SfxMedium& pMedium );
317 virtual bool ConvertFrom(
SfxMedium &rMedium );
318 virtual bool ConvertTo(
SfxMedium &rMedium );
319 virtual bool InitNew(
const css::uno::Reference< css::embed::XStorage >& xStorage );
321 virtual bool LoadFrom(
SfxMedium& rMedium );
324 virtual bool SaveCompleted(
const css::uno::Reference< css::embed::XStorage >& xStorage );
325 bool SwitchPersistence(
326 const css::uno::Reference< css::embed::XStorage >& xStorage );
328 virtual bool LoadExternal(
SfxMedium& rMedium );
329 bool IsConfigOptionsChecked()
const;
330 void SetConfigOptionsChecked(
bool bChecked );
333 virtual bool QuerySlotExecutable( sal_uInt16 nSlotId );
335 void SaveChildren(
bool bObjectsOnly=
false);
336 bool SaveAsChildren(
SfxMedium &rMedium );
337 bool SwitchChildrenPersistence(
338 const css::uno::Reference< css::embed::XStorage >& xStorage,
339 bool bForceNonModified =
false );
340 bool SaveCompletedChildren();
344 virtual bool InsertGeneratedStream(
SfxMedium& rMedium,
345 css::uno::Reference<css::text::XTextRange>
const& xInsertPosition);
346 virtual bool ImportFrom(
SfxMedium &rMedium,
347 css::uno::Reference<css::text::XTextRange>
const& xInsertPosition);
352 bool CheckIsReadonly(
bool bSignScriptingContent,
weld::Window* pDialogParent =
nullptr);
353 void RecheckSignature(
bool bAlsoRecheckScriptingSignature);
354 void AfterSigning(
bool bSignSuccess,
bool bSignScriptingContent);
355 bool HasValidSignatures()
const;
358 css::uno::Sequence<css::security::DocumentSignatureInformation> GetDocumentSignatureInformation(
359 bool bScriptingContent,
360 const css::uno::Reference<css::security::XDocumentDigitalSignatures>& xSigner
361 = css::uno::Reference<css::security::XDocumentDigitalSignatures>());
363 bool SignDocumentContentUsingCertificate(
const css::uno::Reference<css::security::XCertificate>& xCertificate);
364 bool ResignDocument(css::uno::Sequence< css::security::DocumentSignatureInformation >& rSignaturesInfo);
366 void SignSignatureLine(
weld::Window* pDialogParent,
const OUString& aSignatureLineId,
367 const css::uno::Reference<css::security::XCertificate>& xCert,
368 const css::uno::Reference<css::graphic::XGraphic>& xValidGraphic,
369 const css::uno::Reference<css::graphic::XGraphic>& xInvalidGraphic,
370 const OUString& aComment);
375 virtual std::shared_ptr<SfxDocumentInfoDialog> CreateDocumentInfoDialog(
weld::Window* pParent,
const SfxItemSet& rItemSet);
377 ErrCode CallBasic( std::u16string_view rMacro, std::u16string_view rBasicName,
381 const OUString& rScriptURL,
382 const css::uno::Sequence< css::uno::Any >& aParams,
384 css::uno::Sequence< sal_Int16 >& aOutParamIndex,
385 css::uno::Sequence< css::uno::Any >& aOutParam,
386 bool bRaiseError =
true,
387 const css::uno::Any* aCaller =
nullptr );
390 const css::uno::Reference< css::uno::XInterface >& _rxScriptContext,
391 const OUString& rScriptURL,
392 const css::uno::Sequence< css::uno::Any >& aParams,
394 css::uno::Sequence< sal_Int16 >& aOutParamIndex,
395 css::uno::Sequence< css::uno::Any >& aOutParam,
396 bool bRaiseError =
true,
397 const css::uno::Any* aCaller =
nullptr
407 bool AdjustMacroMode();
409 static bool UnTrustedScript(
const OUString& rScriptURL);
411 static bool isScriptAccessAllowed(
const css::uno::Reference<css::uno::XInterface>& rScriptContext);
414 void ClearHeaderAttributesForSourceViewHack();
415 void SetHeaderAttributesForSourceViewHack();
417 bool IsQueryLoadTemplate()
const;
418 bool IsUseUserData()
const;
419 bool IsUseThumbnailSave()
const;
420 bool IsLoadReadonly()
const;
421 bool IsSaveVersionOnClose()
const;
422 void SetQueryLoadTemplate(
bool b );
423 void SetUseUserData(
bool bNew );
424 void SetUseThumbnailSave(
bool _bNew );
425 void SetLoadReadonly(
bool _bReadonly );
426 void SetSaveVersionOnClose(
bool bSet );
427 void ResetFromTemplate(
const OUString& rTemplateName, std::u16string_view rFileName );
430 sal_uInt32 GetModifyPasswordHash()
const;
431 bool SetModifyPasswordHash( sal_uInt32 nHash );
433 void SetMacroCallsSeenWhileLoading();
434 bool GetMacroCallsSeenWhileLoading()
const;
436 const css::uno::Sequence< css::beans::PropertyValue >& GetModifyPasswordInfo()
const;
437 bool SetModifyPasswordInfo(
const css::uno::Sequence< css::beans::PropertyValue >& aInfo );
441 virtual bool PrepareClose(
bool bUI =
true);
444 bool IsSecurityOptOpenReadOnly()
const;
445 void SetSecurityOptOpenReadOnly(
bool bOpenReadOnly );
447 Size GetFirstPageSize()
const;
449 std::shared_ptr<GDIMetaFile> GetPreviewMetaFile(
bool bFullContent =
false )
const;
451 virtual void CancelTransfers();
453 bool GenerateAndStoreThumbnail(
455 const css::uno::Reference< css::embed::XStorage >& xStor );
459 const css::uno::Reference< css::io::XStream >& xStream );
472 bool IsContinueImportOnFilterExceptions(std::u16string_view aErrMessage);
475 bool IsAbortingImport()
const;
478 void TemplateDisconnectionAfterLoad();
480 bool IsLoading()
const;
481 bool IsLoadingFinished()
const;
482 void SetAutoLoad(
const INetURLObject&, sal_uInt32 nTime,
bool bReload );
483 bool IsAutoLoadLocked()
const;
486 bool IsPreview()
const;
489 void SetWaitCursor(
bool bSet )
const;
492 void SetTitle(
const OUString& rTitle );
532 OUString
GetTitle( sal_uInt16 nMaxLen = 0 )
const;
533 void InvalidateName();
538 virtual bool DdeGetData(
const OUString& rItem,
539 const OUString& rMimeType,
540 css::uno::Any & rValue );
541 virtual bool DdeSetData(
const OUString& rItem,
542 const OUString& rMimeType,
543 const css::uno::Any & rValue );
545 virtual ::sfx2::SvLinkSource* DdeCreateLinkSource(
const OUString& rItem );
558 void SetAutoStyleFilterIndex(sal_uInt16 nSet);
559 sal_uInt16 GetAutoStyleFilterIndex()
const;
560 bool HasBasic()
const;
562 css::uno::Reference< css::script::XLibraryContainer >
564 css::uno::Reference< css::script::XLibraryContainer >
565 GetDialogContainer();
568 std::optional<NamedColor> GetRecentColor(sal_uInt16 nSlotId);
569 void SetRecentColor(sal_uInt16 nSlotId,
const NamedColor& rColor);
571 virtual std::set<Color> GetDocColors();
572 virtual std::shared_ptr<model::ColorSet> GetThemeColors();
581 css::uno::Reference< css::frame::XModel3 >
585 css::uno::Reference< css::frame::XModel3 > GetBaseModel()
const;
588 virtual css::uno::Sequence< OUString > GetEventNames();
590 css::uno::Reference<css::awt::XWindow> GetDialogParent(
SfxMedium const* pMedium =
nullptr);
593 static css::uno::Reference< css::lang::XComponent >
595 static SfxObjectShell* GetShellFromComponent(
const css::uno::Reference< css::uno::XInterface >& xComp);
596 static SfxObjectShell* GetParentShell(
const css::uno::Reference<css::uno::XInterface>& xChild);
597 static OUString GetServiceNameFromFactory(
const OUString& rFact );
598 bool IsInPlaceActive()
const;
599 bool IsUIActive()
const;
601 static bool CopyStoragesOfUnknownMediaType(
602 const css::uno::Reference< css::embed::XStorage >& xSource,
603 const css::uno::Reference<css::embed::XStorage>& xTarget,
604 const css::uno::Sequence<OUString>& rExceptions = css::uno::Sequence<OUString>());
606 bool isEditDocLocked()
const;
607 bool isContentExtractionLocked()
const;
608 bool isExportLocked()
const;
609 bool isPrintLocked()
const;
610 bool isSaveLocked()
const;
613 void EnableSetModified(
bool bEnable =
true );
614 bool IsEnableSetModified()
const;
615 virtual void SetModified(
bool bModified =
true );
616 bool IsModified()
const;
622 const css::uno::Reference< css::embed::XStorage >& xStorage,
623 sal_Int32
nVersion,
bool bTemplate )
const;
625 css::uno::Reference< css::embed::XStorage >
const & GetStorage();
630 virtual css::uno::Reference< css::task::XInteractionHandler >
getInteractionHandler()
const override;
631 virtual css::uno::Reference < css::embed::XStorage >
getStorage()
const override
637 return GetEmbeddedObjectContainer();
641 return IsEnableSetModified();
646 void ClearEmbeddedObjects();
649 virtual Printer * GetDocumentPrinter();
651 virtual void OnDocumentPrinterChanged(
Printer * pNewPrinter );
655 void SetVisAreaSize(
const Size & rVisSize );
658 void SetMapUnit(
MapUnit nMUnit );
665 bool bOutputForScreen =
false );
667 sal_uInt16 nAspect,
bool bOutputForScreen ) = 0;
672 OUString * pFullTypeName,
674 bool bTemplate =
false)
const = 0;
679 virtual bool IsChangeRecording()
const;
680 virtual bool HasChangeRecordProtection()
const;
681 virtual void SetChangeRecording(
bool bActivate,
bool bLockAllViews =
false );
682 virtual void SetProtectionPassword(
const OUString &rPassword );
683 virtual bool GetProtectionHash( css::uno::Sequence< sal_Int8 > &rPasswordHash );
685 static bool IsOwnStorageFormat(
const SfxMedium &);
689 void AppendInfoBarWhenReady(
const OUString& sId,
const OUString& sPrimaryMessage,
690 const OUString& sSecondaryMessage,
InfobarType aInfobarType,
691 bool bShowCloseButton =
true);
692 std::vector<InfobarData>& getPendingInfobars();
696 SAL_DLLPRIVATE
static bool IsPackageStorageFormat_Impl(
const SfxMedium &);
698 SAL_DLLPRIVATE
bool ConnectTmpStorage_Impl(
const css::uno::Reference< css::embed::XStorage >& xStorage,
SfxMedium* pMedium );
699 SAL_DLLPRIVATE
bool DisconnectStorage_Impl(
SfxMedium& rSrcMedium,
SfxMedium& rTargetMedium );
701 SAL_DLLPRIVATE
bool PutURLContentsToVersionStream_Impl(
702 const OUString& aURL,
703 const css::uno::Reference< css::embed::XStorage >& xDocStorage,
704 const OUString& aStreamName );
706 SAL_DLLPRIVATE OUString CreateTempCopyOfStorage_Impl(
707 const css::uno::Reference< css::embed::XStorage >& xStorage );
709 SAL_DLLPRIVATE
void InitOwnModel_Impl();
710 SAL_DLLPRIVATE
void BreakMacroSign_Impl(
bool bBreakMacroSing );
711 SAL_DLLPRIVATE
void CheckSecurityOnLoading_Impl();
712 SAL_DLLPRIVATE
void CheckForBrokenDocSignatures_Impl();
713 SAL_DLLPRIVATE
void CheckEncryption_Impl(
const css::uno::Reference< css::task::XInteractionHandler >& xHandler );
714 SAL_DLLPRIVATE
void SetModifyPasswordEntered(
bool bEntered =
true );
715 SAL_DLLPRIVATE
bool IsModifyPasswordEntered()
const;
717 SAL_DLLPRIVATE
void InitBasicManager_Impl();
720 SAL_DLLPRIVATE
static bool UseInteractionToHandleError(
721 const css::uno::Reference< css::task::XInteractionHandler >& xHandler,
728 const Point & rViewPos,
733 bool bOutputForScreen );
736 SAL_DLLPRIVATE
void ExecFile_Impl(
SfxRequest &);
737 SAL_DLLPRIVATE
void GetState_Impl(
SfxItemSet&);
738 SAL_DLLPRIVATE
void PrintExec_Impl(
SfxRequest &);
739 SAL_DLLPRIVATE
void PrintState_Impl(
SfxItemSet&);
740 SAL_DLLPRIVATE
void ExecProps_Impl(
SfxRequest &);
741 SAL_DLLPRIVATE
void StateProps_Impl(
SfxItemSet &);
742 SAL_DLLPRIVATE
void ExecView_Impl(
SfxRequest &);
743 SAL_DLLPRIVATE
static void StateView_Impl(
SfxItemSet &);
746 SAL_DLLPRIVATE
bool ImportFromGeneratedStream_Impl(
747 const css::uno::Reference< css::io::XStream >& xStream,
748 const css::uno::Sequence< css::beans::PropertyValue >& aMediaDescr );
749 SAL_DLLPRIVATE
void UpdateFromTemplate_Impl();
750 SAL_DLLPRIVATE
bool CanReload_Impl();
751 SAL_DLLPRIVATE
void SetNamedVisibility_Impl();
752 SAL_DLLPRIVATE
bool DoSave_Impl(
const SfxItemSet* pSet );
753 SAL_DLLPRIVATE
bool Save_Impl(
const SfxItemSet* pSet );
755 PreDoSaveAs_Impl(
const OUString& rFileName,
const OUString& rFiltName,
757 const css::uno::Sequence<css::beans::PropertyValue>& rArgs);
758 SAL_DLLPRIVATE
bool APISaveAs_Impl(std::u16string_view aFileName,
SfxItemSet& rItemSet,
759 const css::uno::Sequence<css::beans::PropertyValue>& rArgs);
762 const css::uno::Sequence<css::beans::PropertyValue>& rArgs);
763 SAL_DLLPRIVATE
bool GeneralInit_Impl(
764 const css::uno::Reference< css::embed::XStorage >& xStorage,
765 bool bTypeMustBeSetAlready );
766 SAL_DLLPRIVATE
void PrepareSecondTryLoad_Impl();
767 SAL_DLLPRIVATE
void SetInitialized_Impl(
const bool i_fromInitNew );
771 SAL_DLLPRIVATE
void SetProgress_Impl(
SfxProgress *pProgress );
772 SAL_DLLPRIVATE
void PostActivateEvent_Impl(
SfxViewFrame const * );
776 SAL_DLLPRIVATE
SignatureState ImplGetSignatureState(
bool bScriptingContent =
false );
778 SAL_DLLPRIVATE
bool QuerySaveSizeExceededModules_Impl(
const css::uno::Reference< css::task::XInteractionHandler >& xHandler );
779 SAL_DLLPRIVATE
static bool QueryAllowExoticFormat_Impl(
const css::uno::Reference< css::task::XInteractionHandler >& xHandler,
780 const OUString& rURL,
781 const OUString& rFilterUIName);
783 SAL_DLLPRIVATE
void CheckOut( );
784 SAL_DLLPRIVATE
void CancelCheckOut( );
785 SAL_DLLPRIVATE
void CheckIn( );
786 SAL_DLLPRIVATE css::uno::Sequence< css::document::CmisVersion > GetCmisVersions()
const;
792 bool IsSignPDF()
const;
795 css::uno::Reference<css::security::XCertificate> GetSignPDFCertificate()
const;
798 css::uno::Sequence< css::beans::PropertyValue > GetDocumentProtectionFromGrabBag()
const;
803 return std::make_unique<LockAllViewsGuard>();
808#define SFX_GLOBAL_CLASSID \
809 0x9eaba5c3, 0xb232, 0x4309, \
810 0x84, 0x5f, 0x5f, 0x15, 0xea, 0x50, 0xd0, 0x74
847 bool Is()
const {
return pObj !=
nullptr; }
927 virtual bool QueryValue( css::uno::Any& rVal,
sal_uInt8 nMemberId = 0 )
const override;
928 virtual bool PutValue(
const css::uno::Any& rVal,
sal_uInt8 nMemberId )
override;
const sal_uInt16 nVersion
SfxObjectShellItem(sal_uInt16 nWhichId, SfxObjectShell *pObjShell)
SfxObjectShell * operator->() const
SfxObjectShellLock & operator=(const SfxObjectShellLock &rObj)
SfxObjectShell * operator&() const
SfxObjectShell & operator*() const
virtual ~LockAllViewsGuard()
bool IsInGenerateAndStoreThumbnail() const
SAL_DLLPRIVATE const SfxObjectShell_Impl * Get_Impl() const
static ErrCode CallXScript(const css::uno::Reference< css::uno::XInterface > &_rxScriptContext, const OUString &rScriptURL, const css::uno::Sequence< css::uno::Any > &aParams, css::uno::Any &aRet, css::uno::Sequence< sal_Int16 > &aOutParamIndex, css::uno::Sequence< css::uno::Any > &aOutParam, bool bRaiseError=true, const css::uno::Any *aCaller=nullptr)
virtual css::uno::Reference< css::embed::XStorage > getStorage() const override
bool IsAvoidRecentDocs() const
Don't add to the recent documents - it's an expensive operation, sometimes it is not wanted.
bool IsEnableSetModified() const
SfxObjectCreateMode eCreateMode
css::uno::Sequence< css::security::DocumentSignatureInformation > rSignatureInfosRemembered
void SetSharedXMLFlag(bool bFlag) const
virtual SfxObjectFactory & GetFactory() const =0
virtual std::unique_ptr< LockAllViewsGuard > LockAllViews()
bool isEnableSetModified() const override
bool SwitchToShared(bool bShared, bool bSave)
virtual void Draw(OutputDevice *, const JobSetup &rSetup, sal_uInt16 nAspect, bool bOutputForScreen)=0
SAL_DLLPRIVATE void FreeSharedFile(const OUString &aTempFileURL)
SAL_DLLPRIVATE SfxObjectShell_Impl * Get_Impl()
SfxMedium * GetMedium() const
bool HasSharedXMLFlagSet() const
virtual const sfx2::IXmlIdRegistry * GetXmlIdRegistry() const
override this if you have a XmlIdRegistry.
std::unique_ptr< struct SfxObjectShell_Impl > pImpl
void EnableSetModified(bool bEnable=true)
bool mbAvoidRecentDocs
Avoid adding to the recent documents list, if not necessary.
virtual void FillClass(SvGlobalName *pClassName, SotClipboardFormatId *pFormat, OUString *pFullTypeName, sal_Int32 nVersion, bool bTemplate=false) const =0
SfxObjectCreateMode GetCreateMode() const
virtual comphelper::EmbeddedObjectContainer & getEmbeddedObjectContainer() const override
bool bIsInGenerateThumbnail
bool IsRememberingSignature() const
virtual void TerminateEditing()
Terminate any in-flight editing. Used before saving, primarily by Calc to commit cell changes.
void AvoidRecentDocs(bool bAvoid)
Don't add to the recent documents - it's an expensive operation, sometimes it is not wanted.
SAL_DLLPRIVATE void DoNotCleanShareControlFile()
DECL_DLLPRIVATE_LINK(SignDocumentHandler, weld::Button &, void)
The class SfxShell is the base class for all classes, which provide the functionality of the form <Sl...
virtual void Invalidate(sal_uInt16 nId=0)
With this method can the slots of the subclasses be invalidated through the slot Id or alternatively ...
virtual SfxObjectShell * GetObjectShell()
void OwnerLock(bool bLock)
virtual css::uno::Reference< css::task::XInteractionHandler > getInteractionHandler() const=0
virtual OUString getDocumentBaseURL() const=0
interface for getElementByMetadataReference; for use by sfx2::DocumentMetadataAccess
virtual void SetTitle(const OUString &rNewTitle) override
constexpr OUStringLiteral IsReadOnly(u"IsReadOnly")
Implementation of the interface com.sun.star.rdf.XDocumentMetadataAccess.
css::uno::Reference< css::animations::XAnimationNode > Clone(const css::uno::Reference< css::animations::XAnimationNode > &xSourceNode, const SdPage *pSource=nullptr, const SdPage *pTarget=nullptr)
UNOTOOLS_DLLPUBLIC bool GetTitle(OUString const &url, OUString *title)
tools::SvRef< SfxObjectShell > SfxObjectShellRef
bool checkSfxObjectShell(const SfxObjectShell *pShell)
#define SFX_DECL_INTERFACE(nId)
constexpr auto SFX_INTERFACE_SFXDOCSH
ModifyBlocker_Impl(SfxObjectShell *pPersistP)
SfxObjectShell * pPersist
#define SAL_WARN_UNUSED_RESULT
bool operator==(const XclFontData &rLeft, const XclFontData &rRight)