Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / include / sfx2 / objsh.hxx
blob0352f2f1ac2a4df9932b8d498a54a1fc810ae8c7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
19 #ifndef INCLUDED_SFX2_OBJSH_HXX
20 #define INCLUDED_SFX2_OBJSH_HXX
22 #include <sal/config.h>
23 #include <sfx2/dllapi.h>
24 #include <sfx2/signaturestate.hxx>
25 #include <sal/types.h>
26 #include <vcl/errcode.hxx>
27 #include <com/sun/star/uno/Reference.h>
28 #include <com/sun/star/uno/Sequence.hxx>
30 #include <svl/poolitem.hxx>
31 #include <sot/formats.hxx>
32 #include <sot/object.hxx>
33 #include <tools/gen.hxx>
34 #include <tools/link.hxx>
36 #include <sfx2/shell.hxx>
37 #include <comphelper/embeddedobjectcontainer.hxx>
38 #include <memory>
39 #include <set>
40 #include <o3tl/typed_flags_set.hxx>
41 #include <functional>
43 class SbxValue;
44 class SbxArray;
45 class BasicManager;
46 class SfxMedium;
47 class SfxObjectFactory;
48 class SfxDocumentInfoDialog;
49 class SfxStyleSheetBasePool;
50 class StarBASIC;
51 class Printer;
52 class SvKeyValueIterator;
53 class SfxBaseModel;
54 class SfxModule;
55 class SfxProgress;
56 class GDIMetaFile;
57 class INetURLObject;
58 class IndexBitSet;
59 class JobSetup;
60 class Button;
61 class OutputDevice;
62 class Color;
63 class Fraction;
64 class SvGlobalName;
65 class InfobarData;
67 enum class SfxModelFlags;
68 enum class SfxEventHintId;
69 enum class InfobarType;
71 // These values presumably must match exactly the corresponding
72 // css::embed::Aspects ones (in offapi/com/sun/star/embed/Aspects.idl)
73 // and the DVASPECT_* ones in the Win32 API.
75 #define ASPECT_CONTENT 1
76 #define ASPECT_THUMBNAIL 2 /* 120 * 120, 6 Colors DIB in MetaFile */
77 #define ASPECT_ICON 4
78 #define ASPECT_DOCPRINT 8
80 namespace sfx2
82 class SvLinkSource;
83 class StyleManager;
86 namespace vcl { class Window; }
87 namespace com::sun::star::beans { struct PropertyValue; }
88 namespace com::sun::star::document { struct CmisVersion; }
89 namespace com::sun::star::embed { class XStorage; }
90 namespace com::sun::star::frame { class XModel; }
91 namespace com::sun::star::graphic { class XGraphic; }
92 namespace com::sun::star::io { class XStream; }
93 namespace com::sun::star::script { class XLibraryContainer; }
94 namespace com::sun::star::security { class XCertificate; }
95 namespace com::sun::star::security { class XDocumentDigitalSignatures; }
96 namespace com::sun::star::security { struct DocumentSignatureInformation; }
97 namespace com::sun::star::task { class XInteractionHandler; }
99 namespace com { namespace sun { namespace star {
100 namespace document {
101 class XDocumentProperties;
103 namespace lang {
104 class XComponent;
106 namespace text {
107 class XTextRange;
109 } } }
111 namespace sfx2 { class IXmlIdRegistry; }
113 #define SFX_TITLE_TITLE 0
114 #define SFX_TITLE_FILENAME 1
115 #define SFX_TITLE_FULLNAME 2
116 #define SFX_TITLE_APINAME 3
117 #define SFX_TITLE_DETECT 4
118 #define SFX_TITLE_CAPTION 5
119 #define SFX_TITLE_PICKLIST 6
120 #define SFX_TITLE_HISTORY 7
121 #define SFX_TITLE_MAXLEN 10 // this gives the limits on length
123 enum class SfxLoadedFlags
125 NONE = 0,
126 MAINDOCUMENT = 1,
127 IMAGES = 2,
128 ALL = MAINDOCUMENT | IMAGES
130 namespace o3tl
132 template<> struct typed_flags<SfxLoadedFlags> : is_typed_flags<SfxLoadedFlags, 0x03> {};
135 enum class HiddenInformation
137 NONE = 0x0000,
138 RECORDEDCHANGES = 0x0001,
139 NOTES = 0x0002,
140 DOCUMENTVERSIONS = 0x0004
142 namespace o3tl
144 template<> struct typed_flags<HiddenInformation> : is_typed_flags<HiddenInformation, 0x07> {};
147 namespace weld { class Window; }
149 enum class HiddenWarningFact
151 WhenSaving = 0,
152 WhenPrinting,
153 WhenSigning,
154 WhenCreatingPDF
157 enum class SfxObjectCreateMode
159 EMBEDDED,
160 STANDARD,
161 ORGANIZER,
162 INTERNAL
166 The class SfxObjectShell is the base class for SFx-objects, ie documents
167 and parts of documents that can be integrated as separate objects
168 into foreign objects.
171 struct TransferableObjectDescriptor;
172 template<class T> bool checkSfxObjectShell(const SfxObjectShell* pShell)
174 return dynamic_cast<const T*>(pShell) != nullptr;
177 class SFX2_DLLPUBLIC SfxObjectShell :
178 public SfxShell, virtual public SotObject,
179 public ::comphelper::IEmbeddedHelper
181 friend struct ModifyBlocker_Impl;
182 friend class SfxObjectShellLock;
184 private:
185 std::unique_ptr<struct SfxObjectShell_Impl> pImpl; // internal data
187 SfxMedium * pMedium; // Description of the file for example
188 // storage that contains the object
189 SfxObjectCreateMode eCreateMode; // Purpose of the object
190 bool bHasName :1; // sal_True := existing object,
191 // sal_False := new object
192 bool bIsInGenerateThumbnail; //optimize thumbnail generate and store procedure to improve odt saving performance, i120030
193 bool mbAvoidRecentDocs; ///< Avoid adding to the recent documents list, if not necessary.
195 enum TriState {undefined, yes, no};
196 TriState mbContinueImportOnFilterExceptions = undefined; // try to import as much as possible
198 bool CloseInternal();
200 SAL_DLLPRIVATE void UpdateTime_Impl(const css::uno::Reference<
201 css::document::XDocumentProperties> & i_xDocProps);
203 SAL_DLLPRIVATE bool SaveTo_Impl(SfxMedium &rMedium, const SfxItemSet* pSet );
205 protected:
206 SfxObjectShell(SfxObjectCreateMode);
207 SfxObjectShell(SfxModelFlags); // see sfxmodelfactory.hxx
208 virtual ~SfxObjectShell() override;
210 void ModifyChanged();
211 virtual bool Close() override;
213 /// template method, called by FlushDocInfo; this implementation is empty
214 virtual void DoFlushDocInfo();
216 // helper method
217 void AddToRecentlyUsedList();
219 public:
220 SFX_DECL_INTERFACE(SFX_INTERFACE_SFXDOCSH)
222 private:
223 /// SfxInterface initializer.
224 static void InitInterface_Impl();
226 public:
227 static const css::uno::Sequence<sal_Int8>& getUnoTunnelId();
228 /* Stampit disable/enable cancel button for print jobs
229 default = true = enable! */
230 void Stamp_SetPrintCancelState(bool bState);
231 bool Stamp_GetPrintCancelState() const;
233 static OUString CreateShellID( const SfxObjectShell* pShell );
235 // Document-Shell Iterator
236 static SfxObjectShell* GetFirst( const std::function<bool ( const SfxObjectShell* )>& isObjectShell = nullptr,
237 bool bOnlyVisible = true );
238 static SfxObjectShell* GetNext( const SfxObjectShell& rPrev,
239 const std::function<bool ( const SfxObjectShell* )>& isObjectShell = nullptr,
240 bool bOnlyVisible = true );
241 static SfxObjectShell* Current();
242 static css::uno::Reference< css::uno::XInterface >
243 GetCurrentComponent();
244 static void SetCurrentComponent( const css::uno::Reference< css::uno::XInterface >& _rxComponent );
246 virtual void Invalidate(sal_uInt16 nId = 0) override;
248 SfxModule* GetModule() const;
250 virtual SfxObjectFactory& GetFactory() const=0;
251 SfxMedium * GetMedium() const { return pMedium; }
252 css::uno::Reference< css::document::XDocumentProperties >
253 getDocProperties() const;
254 void UpdateDocInfoForSave( );
255 void FlushDocInfo();
256 bool HasName() const { return bHasName; }
257 OUString GetAPIName() const;
258 void SetReadOnly();
259 bool IsReadOnly() const;
260 bool IsReadOnlyMedium() const;
261 bool IsOriginallyReadOnlyMedium() const;
262 bool IsOriginallyLoadedReadOnlyMedium() const;
263 void SetReadOnlyUI( bool bReadOnly = true );
264 bool IsReadOnlyUI() const;
265 void SetNoName();
266 bool IsInModalMode() const;
267 bool IsInPrepareClose() const;
268 bool AcceptStateUpdate() const;
269 bool IsHelpDocument() const;
271 bool IsDocShared() const;
272 OUString GetSharedFileURL() const;
273 bool SwitchToShared( bool bShared, bool bSave );
274 SAL_DLLPRIVATE void FreeSharedFile( const OUString& aTempFileURL );
275 SAL_DLLPRIVATE void DoNotCleanShareControlFile();
276 void SetSharedXMLFlag( bool bFlag ) const;
277 bool HasSharedXMLFlagSet() const;
279 SAL_DLLPRIVATE void SetModalMode_Impl(bool bModal);
280 SAL_DLLPRIVATE void SetMacroMode_Impl(bool bModal=true);
282 void ResetError();
283 ErrCode GetError() const;
284 ErrCode GetErrorCode() const;
285 void SetError(ErrCode rErr);
288 * Initialize bare minimum just enough for unit test runs.
290 * @return true if the initialization is successful, false otherwise.
292 void DoInitUnitTest();
293 bool DoInitNew( SfxMedium* pMedium=nullptr );
294 bool DoLoad( SfxMedium* pMedium );
295 bool DoLoadExternal( SfxMedium* pMed );
296 bool DoSave();
297 bool DoSaveAs( SfxMedium &rNewStor );
298 bool DoSaveObjectAs( SfxMedium &rNewStor, bool bCommit );
300 // TODO/LATER: currently only overridden in Calc, should be made non-virtual
301 virtual bool DoSaveCompleted( SfxMedium* pNewStor=nullptr, bool bRegisterRecent=true );
303 bool LoadOwnFormat( SfxMedium& pMedium );
304 virtual bool SaveAsOwnFormat( SfxMedium& pMedium );
305 virtual bool ConvertFrom( SfxMedium &rMedium );
306 virtual bool ConvertTo( SfxMedium &rMedium );
307 virtual bool InitNew( const css::uno::Reference< css::embed::XStorage >& xStorage );
308 virtual bool Load( SfxMedium &rMedium );
309 virtual bool LoadFrom( SfxMedium& rMedium );
310 virtual bool Save();
311 virtual bool SaveAs( SfxMedium &rMedium );
312 virtual bool SaveCompleted( const css::uno::Reference< css::embed::XStorage >& xStorage );
313 bool SwitchPersistance(
314 const css::uno::Reference< css::embed::XStorage >& xStorage );
315 virtual void UpdateLinks();
316 virtual bool LoadExternal( SfxMedium& rMedium );
317 bool IsConfigOptionsChecked() const;
318 void SetConfigOptionsChecked( bool bChecked );
320 // called for a few slots like SID_SAVE[AS]DOC, SID_PRINTDOC[DIRECT], derived classes may abort the action
321 virtual bool QuerySlotExecutable( sal_uInt16 nSlotId );
323 void SaveChildren(bool bObjectsOnly=false);
324 bool SaveAsChildren( SfxMedium &rMedium );
325 bool SwitchChildrenPersistance(
326 const css::uno::Reference< css::embed::XStorage >& xStorage,
327 bool bForceNonModified = false );
328 bool SaveCompletedChildren();
330 /** a very special case to insert at a position in Writer from UNO,
331 via OwnSubFilterService */
332 virtual bool InsertGeneratedStream(SfxMedium& rMedium,
333 css::uno::Reference<css::text::XTextRange> const& xInsertPosition);
334 virtual bool ImportFrom( SfxMedium &rMedium,
335 css::uno::Reference<css::text::XTextRange> const& xInsertPosition);
336 bool ExportTo( SfxMedium &rMedium );
338 /** Returns to if preparing was successful, else false. */
339 bool PrepareForSigning(weld::Window* pDialogParent);
340 bool CheckIsReadonly(bool bSignScriptingContent);
341 void RecheckSignature(bool bAlsoRecheckScriptingSignature);
342 void AfterSigning(bool bSignSuccess, bool bSignScriptingContent);
343 bool HasValidSignatures() const;
344 SignatureState GetDocumentSignatureState();
345 void SignDocumentContent(weld::Window* pDialogParent);
346 css::uno::Sequence<css::security::DocumentSignatureInformation> GetDocumentSignatureInformation(
347 bool bScriptingContent,
348 const css::uno::Reference<css::security::XDocumentDigitalSignatures>& xSigner
349 = css::uno::Reference<css::security::XDocumentDigitalSignatures>());
351 bool SignDocumentContentUsingCertificate(const css::uno::Reference<css::security::XCertificate>& xCertificate);
353 void SignSignatureLine(weld::Window* pDialogParent, const OUString& aSignatureLineId,
354 const css::uno::Reference<css::security::XCertificate>& xCert,
355 const css::uno::Reference<css::graphic::XGraphic>& xValidGraphic,
356 const css::uno::Reference<css::graphic::XGraphic>& xInvalidGraphic,
357 const OUString& aComment);
358 SignatureState GetScriptingSignatureState();
359 void SignScriptingContent(weld::Window* pDialogParent);
360 DECL_LINK(SignDocumentHandler, Button*, void);
362 virtual std::unique_ptr<SfxDocumentInfoDialog> CreateDocumentInfoDialog(weld::Window* pParent, const SfxItemSet& rItemSet);
364 ErrCode CallBasic( const OUString& rMacro, const OUString& rBasicName,
365 SbxArray* pArgs, SbxValue* pRet = nullptr );
367 ErrCode CallXScript(
368 const OUString& rScriptURL,
369 const css::uno::Sequence< css::uno::Any >& aParams,
370 css::uno::Any& aRet,
371 css::uno::Sequence< sal_Int16 >& aOutParamIndex,
372 css::uno::Sequence< css::uno::Any >& aOutParam,
373 bool bRaiseError = true,
374 const css::uno::Any* aCaller = nullptr );
376 static ErrCode CallXScript(
377 const css::uno::Reference< css::uno::XInterface >& _rxScriptContext,
378 const OUString& rScriptURL,
379 const css::uno::Sequence< css::uno::Any >& aParams,
380 css::uno::Any& aRet,
381 css::uno::Sequence< sal_Int16 >& aOutParamIndex,
382 css::uno::Sequence< css::uno::Any >& aOutParam,
383 bool bRaiseError = true,
384 const css::uno::Any* aCaller = nullptr
387 /** adjusts the internal macro mode, according to the current security settings
389 Finally, the macro mode is either NEVER_EXECUTE or ALWAYS_EXECUTE_NO_WARN.
391 @return
392 whether macros from this document should be executed
394 bool AdjustMacroMode();
396 static bool UnTrustedScript(const OUString& rScriptURL);
398 SvKeyValueIterator* GetHeaderAttributes();
399 void ClearHeaderAttributesForSourceViewHack();
400 void SetHeaderAttributesForSourceViewHack();
402 bool IsQueryLoadTemplate() const;
403 bool IsUseUserData() const;
404 bool IsUseThumbnailSave() const;
405 bool IsLoadReadonly() const;
406 bool IsSaveVersionOnClose() const;
407 void SetQueryLoadTemplate( bool b );
408 void SetUseUserData( bool bNew );
409 void SetUseThumbnailSave( bool _bNew );
410 void SetLoadReadonly( bool _bReadonly );
411 void SetSaveVersionOnClose( bool bSet );
412 void ResetFromTemplate( const OUString& rTemplateName, const OUString& rFileName );
414 // TODO/LATER: the following two methods should be replaced by Get/SetModifPasswordInfo in future
415 sal_uInt32 GetModifyPasswordHash() const;
416 bool SetModifyPasswordHash( sal_uInt32 nHash );
418 void SetMacroCallsSeenWhileLoading();
419 bool GetMacroCallsSeenWhileLoading() const;
421 const css::uno::Sequence< css::beans::PropertyValue >& GetModifyPasswordInfo() const;
422 bool SetModifyPasswordInfo( const css::uno::Sequence< css::beans::PropertyValue >& aInfo );
424 static ErrCode HandleFilter( SfxMedium* pMedium, SfxObjectShell const * pDoc );
426 virtual bool PrepareClose(bool bUI = true);
427 virtual HiddenInformation GetHiddenInformationState( HiddenInformation nStates );
428 sal_Int16 QueryHiddenInformation( HiddenWarningFact eFact, weld::Window* pParent );
429 bool IsSecurityOptOpenReadOnly() const;
430 void SetSecurityOptOpenReadOnly( bool bOpenReadOnly );
432 Size GetFirstPageSize() const;
433 bool DoClose();
434 std::shared_ptr<GDIMetaFile> GetPreviewMetaFile( bool bFullContent = false ) const;
435 virtual void CancelTransfers();
437 bool GenerateAndStoreThumbnail(
438 bool bEncrypted,
439 const css::uno::Reference< css::embed::XStorage >& xStor );
441 bool WriteThumbnail(
442 bool bEncrypted,
443 const css::uno::Reference< css::io::XStream >& xStream );
445 bool IsInGenerateAndStoreThumbnail() const {return bIsInGenerateThumbnail;}//optimize thumbnail generate and store procedure to improve odt saving performance, i120030
447 /// Don't add to the recent documents - it's an expensive operation, sometimes it is not wanted.
448 bool IsAvoidRecentDocs() const { return mbAvoidRecentDocs; }
450 /// Don't add to the recent documents - it's an expensive operation, sometimes it is not wanted.
451 void AvoidRecentDocs(bool bAvoid) { mbAvoidRecentDocs = bAvoid; }
453 /// On first error ask user if import should continue; return saved answer.
454 bool IsContinueImportOnFilterExceptions(const OUString& aErrMessage);
456 // Transfer IFace
457 bool IsAbortingImport() const;
458 void FinishedLoading( SfxLoadedFlags nWhich = SfxLoadedFlags::ALL );
460 virtual void SetFormatSpecificCompatibilityOptions( const OUString& /*rFilterTypeName*/ ) { /* Do not do anything here; Derived classes must overload to do actual work */ };
462 void TemplateDisconnectionAfterLoad();
463 void SetLoading(SfxLoadedFlags nFlags);
464 bool IsLoading() const;
465 bool IsLoadingFinished() const;
466 void SetAutoLoad( const INetURLObject&, sal_uInt32 nTime, bool bReload );
467 bool IsAutoLoadLocked() const;
469 // Misc
470 bool IsPreview() const;
471 SfxObjectCreateMode GetCreateMode() const { return eCreateMode; }
472 SfxProgress* GetProgress() const;
473 void SetWaitCursor( bool bSet ) const;
475 // Naming Interface
476 void SetTitle( const OUString& rTitle );
477 /* Small non-zero values of nMaxLen don't mean length, but have a magic meaning:
478 0 (default)
479 the title itself, as it is
481 1 (==SFX_TITLE_FILENAME)
482 provides the logical file name without path
483 (under WNT depending on the system settings
484 without extension)
486 2 (==SFX_TITLE_FULLNAME)
487 provides the logical file names with full path
488 (remote =>:: com:: sun:: star:: util:: URL)
490 3 (==SFX_TITLE_APINAME)
491 provides the logical filename without path
492 and extension
494 4 (==SFX_TITLE_DETECT)
495 provides the complete title, if not set yet
496 it will be created from DocInfo or the name of
497 the medium.
499 5 (==SFX_TITLE_CAPTION)
500 provides the Title just like MB now in the
501 CaptionBar view
503 6 (==SFX_TITLE_PICKLIST)
504 returns the Title, just like MB now would
505 display it in the PickList
507 7 (==SFX_TITLE_HISTORY)
508 returns the Title just like MB now would
509 display it in the History
511 10 bis USHRT_MAX
512 provides the 'nMaxLength' of the logical
513 file name including the path
514 (remote => css::util::URL)
516 OUString GetTitle( sal_uInt16 nMaxLen = 0 ) const;
517 void InvalidateName(); // Re-set to unnamed
519 #if defined(_WIN32)
520 // DDE-Interface
521 long DdeExecute( const OUString& rCmd );
522 virtual bool DdeGetData( const OUString& rItem,
523 const OUString& rMimeType,
524 css::uno::Any & rValue );
525 virtual bool DdeSetData( const OUString& rItem,
526 const OUString& rMimeType,
527 const css::uno::Any & rValue );
528 #endif
529 virtual ::sfx2::SvLinkSource* DdeCreateLinkSource( const OUString& rItem );
530 virtual void ReconnectDdeLink(SfxObjectShell& rServer);
532 static void ReconnectDdeLinks(SfxObjectShell& rServer);
534 // Contents
535 virtual SfxStyleSheetBasePool* GetStyleSheetPool();
537 virtual void LoadStyles(SfxObjectShell &rSource);
539 virtual sfx2::StyleManager* GetStyleManager();
541 // Determine the position of the "Automatic" filter in the stylist
542 void SetAutoStyleFilterIndex(sal_uInt16 nSet);
543 sal_uInt16 GetAutoStyleFilterIndex() const;
544 bool HasBasic() const;
545 BasicManager* GetBasicManager() const;
546 css::uno::Reference< css::script::XLibraryContainer >
547 GetBasicContainer();
548 css::uno::Reference< css::script::XLibraryContainer >
549 GetDialogContainer();
550 StarBASIC* GetBasic() const;
552 virtual std::set<Color> GetDocColors();
554 // Documents, for which to format the view size
556 virtual SfxObjectShell* GetObjectShell() override;
558 css::uno::Reference< css::frame::XModel >
559 GetModel() const;
560 // Only temporarily for the applications!
561 void SetBaseModel( SfxBaseModel* pModel );
562 css::uno::Reference< css::frame::XModel > GetBaseModel() const;
563 // Only temporarily for the applications!
565 virtual css::uno::Sequence< OUString > GetEventNames();
567 vcl::Window* GetDialogParent( SfxMedium const * pMedium=nullptr );
568 static SfxObjectShell* CreateObject( const OUString& rServiceName, SfxObjectCreateMode = SfxObjectCreateMode::STANDARD );
569 static SfxObjectShell* CreateObjectByFactoryName( const OUString& rURL, SfxObjectCreateMode = SfxObjectCreateMode::STANDARD );
570 static css::uno::Reference< css::lang::XComponent >
571 CreateAndLoadComponent( const SfxItemSet& rSet );
572 static SfxObjectShell* GetShellFromComponent( const css::uno::Reference< css::lang::XComponent >& xComp );
573 static OUString GetServiceNameFromFactory( const OUString& rFact );
574 bool IsInPlaceActive() const;
575 bool IsUIActive() const;
577 static bool CopyStoragesOfUnknownMediaType(
578 const css::uno::Reference< css::embed::XStorage >& xSource,
579 const css::uno::Reference<css::embed::XStorage>& xTarget,
580 const css::uno::Sequence<OUString>& rExceptions = css::uno::Sequence<OUString>());
582 // The functions from SvPersist
583 void EnableSetModified( bool bEnable = true );
584 bool IsEnableSetModified() const;
585 virtual void SetModified( bool bModified = true );
586 bool IsModified() const;
589 * @param bChart true if the file is a chart doc and FillClass should not be called
591 void SetupStorage(
592 const css::uno::Reference< css::embed::XStorage >& xStorage,
593 sal_Int32 nVersion, bool bTemplate ) const;
595 css::uno::Reference< css::embed::XStorage > const & GetStorage();
597 SvGlobalName const & GetClassName() const;
599 // comphelper::IEmbeddedHelper
600 virtual css::uno::Reference< css::task::XInteractionHandler > getInteractionHandler() const override;
601 virtual css::uno::Reference < css::embed::XStorage > getStorage() const override
603 return const_cast<SfxObjectShell*>(this)->GetStorage();
605 virtual comphelper::EmbeddedObjectContainer& getEmbeddedObjectContainer() const override
607 return GetEmbeddedObjectContainer();
609 bool isEnableSetModified() const override
611 return IsEnableSetModified();
613 virtual OUString getDocumentBaseURL() const override;
615 comphelper::EmbeddedObjectContainer& GetEmbeddedObjectContainer() const;
616 void ClearEmbeddedObjects();
618 // The functions from SvEmbeddedObject
619 virtual Printer * GetDocumentPrinter();
620 virtual OutputDevice* GetDocumentRefDev();
621 virtual void OnDocumentPrinterChanged( Printer * pNewPrinter );
622 virtual tools::Rectangle GetVisArea( sal_uInt16 nAspect ) const;
623 virtual void SetVisArea( const tools::Rectangle & rVisArea );
624 const tools::Rectangle & GetVisArea() const;
625 void SetVisAreaSize( const Size & rVisSize );
627 MapUnit GetMapUnit() const;
628 void SetMapUnit( MapUnit nMUnit );
630 void FillTransferableObjectDescriptor( TransferableObjectDescriptor& rDesc ) const;
631 void DoDraw( OutputDevice *, const Point & rObjPos,
632 const Size & rSize,
633 const JobSetup & rSetup,
634 sal_uInt16 nAspect = ASPECT_CONTENT );
635 virtual void Draw( OutputDevice *, const JobSetup & rSetup,
636 sal_uInt16 nAspect ) = 0;
639 virtual void FillClass( SvGlobalName * pClassName,
640 SotClipboardFormatId * pFormat,
641 OUString * pFullTypeName,
642 sal_Int32 nVersion,
643 bool bTemplate = false) const = 0;
645 // change recording and respective passwword protection for Writer and Calc
646 // slots available for Writer: FN_REDLINE_ON, FN_REDLINE_ON
647 // slots used for Calc: FID_CHG_RECORD, SID_CHG_PROTECT
648 virtual bool IsChangeRecording() const;
649 virtual bool HasChangeRecordProtection() const;
650 virtual void SetChangeRecording( bool bActivate );
651 virtual void SetProtectionPassword( const OUString &rPassword );
652 virtual bool GetProtectionHash( /*out*/ css::uno::Sequence< sal_Int8 > &rPasswordHash );
654 static bool IsOwnStorageFormat(const SfxMedium &);
656 /** Append Infobar once the frame is ready.
657 Useful when you want to register an Infobar before the doc/frame is fully loaded. */
658 void AppendInfoBarWhenReady(const OUString& sId, const OUString& sPrimaryMessage,
659 const OUString& sSecondaryMessage, InfobarType aInfobarType,
660 bool bShowCloseButton = true);
661 std::vector<InfobarData>& getPendingInfobars();
663 SAL_DLLPRIVATE std::shared_ptr<GDIMetaFile> CreatePreviewMetaFile_Impl(bool bFullContent) const;
665 SAL_DLLPRIVATE static bool IsPackageStorageFormat_Impl(const SfxMedium &);
667 SAL_DLLPRIVATE bool ConnectTmpStorage_Impl( const css::uno::Reference< css::embed::XStorage >& xStorage, SfxMedium* pMedium );
668 SAL_DLLPRIVATE bool DisconnectStorage_Impl( SfxMedium& rSrcMedium, SfxMedium& rTargetMedium );
670 SAL_DLLPRIVATE bool PutURLContentsToVersionStream_Impl(
671 const OUString& aURL,
672 const css::uno::Reference< css::embed::XStorage >& xDocStorage,
673 const OUString& aStreamName );
675 SAL_DLLPRIVATE OUString CreateTempCopyOfStorage_Impl(
676 const css::uno::Reference< css::embed::XStorage >& xStorage );
678 SAL_DLLPRIVATE void InitOwnModel_Impl();
679 SAL_DLLPRIVATE void BreakMacroSign_Impl( bool bBreakMacroSing );
680 SAL_DLLPRIVATE void CheckSecurityOnLoading_Impl();
681 SAL_DLLPRIVATE void CheckForBrokenDocSignatures_Impl();
682 SAL_DLLPRIVATE static SignatureState ImplCheckSignaturesInformation(
683 const css::uno::Sequence< css::security::DocumentSignatureInformation >& aInfos );
684 SAL_DLLPRIVATE void CheckEncryption_Impl( const css::uno::Reference< css::task::XInteractionHandler >& xHandler );
685 SAL_DLLPRIVATE void SetModifyPasswordEntered( bool bEntered = true );
686 SAL_DLLPRIVATE bool IsModifyPasswordEntered() const;
688 SAL_DLLPRIVATE void InitBasicManager_Impl();
689 SAL_DLLPRIVATE SfxObjectShell_Impl* Get_Impl() { return pImpl.get(); }
691 SAL_DLLPRIVATE static bool UseInteractionToHandleError(
692 const css::uno::Reference< css::task::XInteractionHandler >& xHandler,
693 ErrCode nError );
694 SAL_DLLPRIVATE const SfxObjectShell_Impl* Get_Impl() const { return pImpl.get(); }
696 SAL_DLLPRIVATE void SetCreateMode_Impl( SfxObjectCreateMode nMode );
698 SAL_DLLPRIVATE void DoDraw_Impl( OutputDevice* pDev,
699 const Point & rViewPos,
700 const Fraction & rScaleX,
701 const Fraction & rScaleY,
702 const JobSetup & rSetup,
703 sal_uInt16 nAspect );
705 // Shell Interface
706 SAL_DLLPRIVATE void ExecFile_Impl(SfxRequest &);
707 SAL_DLLPRIVATE void GetState_Impl(SfxItemSet&);
708 SAL_DLLPRIVATE void PrintExec_Impl(SfxRequest &);
709 SAL_DLLPRIVATE void PrintState_Impl(SfxItemSet&);
710 SAL_DLLPRIVATE void ExecProps_Impl(SfxRequest &);
711 SAL_DLLPRIVATE void StateProps_Impl(SfxItemSet &);
712 SAL_DLLPRIVATE void ExecView_Impl(SfxRequest &);
713 SAL_DLLPRIVATE static void StateView_Impl(SfxItemSet &);
715 // Load/Save public internals
716 SAL_DLLPRIVATE bool ImportFromGeneratedStream_Impl(
717 const css::uno::Reference< css::io::XStream >& xStream,
718 const css::uno::Sequence< css::beans::PropertyValue >& aMediaDescr );
719 SAL_DLLPRIVATE void UpdateFromTemplate_Impl();
720 SAL_DLLPRIVATE bool CanReload_Impl();
721 SAL_DLLPRIVATE void SetNamedVisibility_Impl();
722 SAL_DLLPRIVATE bool DoSave_Impl( const SfxItemSet* pSet );
723 SAL_DLLPRIVATE bool Save_Impl( const SfxItemSet* pSet );
724 SAL_DLLPRIVATE bool PreDoSaveAs_Impl(const OUString& rFileName, const OUString& rFiltName, SfxItemSet const & rItemSet);
725 SAL_DLLPRIVATE bool APISaveAs_Impl(const OUString& aFileName, SfxItemSet& rItemSet);
726 SAL_DLLPRIVATE bool CommonSaveAs_Impl(const INetURLObject& aURL, const OUString& aFilterName, SfxItemSet& rItemSet);
727 SAL_DLLPRIVATE bool GeneralInit_Impl(
728 const css::uno::Reference< css::embed::XStorage >& xStorage,
729 bool bTypeMustBeSetAlready );
730 SAL_DLLPRIVATE void PrepareSecondTryLoad_Impl();
731 SAL_DLLPRIVATE void SetInitialized_Impl( const bool i_fromInitNew );
733 // public-internals
734 SAL_DLLPRIVATE IndexBitSet& GetNoSet_Impl();
735 SAL_DLLPRIVATE void SetProgress_Impl( SfxProgress *pProgress );
736 SAL_DLLPRIVATE void PostActivateEvent_Impl( SfxViewFrame const * );
737 SAL_DLLPRIVATE void SetActivateEvent_Impl(SfxEventHintId );
738 SAL_DLLPRIVATE SfxObjectShell* GetParentShellByModel_Impl();
740 // configuration items
741 SAL_DLLPRIVATE SignatureState ImplGetSignatureState( bool bScriptingContent = false );
743 SAL_DLLPRIVATE bool QuerySaveSizeExceededModules_Impl( const css::uno::Reference< css::task::XInteractionHandler >& xHandler );
744 SAL_DLLPRIVATE static bool QueryAllowExoticFormat_Impl( const css::uno::Reference< css::task::XInteractionHandler >& xHandler,
745 const OUString& rURL,
746 const OUString& rFilterUIName);
748 SAL_DLLPRIVATE void CheckOut( );
749 SAL_DLLPRIVATE void CancelCheckOut( );
750 SAL_DLLPRIVATE void CheckIn( );
751 SAL_DLLPRIVATE css::uno::Sequence< css::document::CmisVersion > GetCmisVersions() const;
753 /** override this if you have a XmlIdRegistry. */
754 virtual const sfx2::IXmlIdRegistry* GetXmlIdRegistry() const { return nullptr; }
757 #define SFX_GLOBAL_CLASSID \
758 0x9eaba5c3, 0xb232, 0x4309, \
759 0x84, 0x5f, 0x5f, 0x15, 0xea, 0x50, 0xd0, 0x74
761 struct ModifyBlocker_Impl
763 SfxObjectShell* pPersist;
764 bool bWasEnabled;
765 ModifyBlocker_Impl( SfxObjectShell* pPersistP ) : pPersist( pPersistP )
767 bWasEnabled = pPersistP->IsEnableSetModified();
768 if ( bWasEnabled )
769 pPersistP->EnableSetModified( false );
771 ~ModifyBlocker_Impl()
773 if ( bWasEnabled )
774 pPersist->EnableSetModified( bWasEnabled );
779 typedef tools::SvRef<SfxObjectShell> SfxObjectShellRef;
781 class SfxObjectShellLock
783 protected:
784 SfxObjectShell * pObj;
785 public:
786 SfxObjectShellLock() { pObj = nullptr; }
787 inline SfxObjectShellLock( const SfxObjectShellLock & rObj );
788 inline SfxObjectShellLock( SfxObjectShellLock && rObj ) noexcept;
789 inline SfxObjectShellLock( SfxObjectShell * pObjP );
790 inline void Clear();
791 inline ~SfxObjectShellLock();
792 inline SfxObjectShellLock & operator = ( const SfxObjectShellLock & rObj );
793 inline SfxObjectShellLock & operator = ( SfxObjectShellLock && rObj );
794 inline SfxObjectShellLock & operator = ( SfxObjectShell * pObj );
795 bool Is() const { return pObj != nullptr; }
796 SfxObjectShell * operator & () const { return pObj; }
797 SfxObjectShell * operator -> () const { return pObj; }
798 SfxObjectShell & operator * () const { return *pObj; }
799 operator SfxObjectShell * () const { return pObj; }
801 inline SfxObjectShellLock::SfxObjectShellLock( const SfxObjectShellLock & rObj )
803 pObj = rObj.pObj;
804 if( pObj )
805 pObj->OwnerLock( true );
807 inline SfxObjectShellLock::SfxObjectShellLock( SfxObjectShellLock && rObj ) noexcept
809 pObj = rObj.pObj;
810 rObj.pObj = nullptr;
812 inline SfxObjectShellLock::SfxObjectShellLock( SfxObjectShell * pObjP )
814 pObj = pObjP;
815 if( pObj )
816 pObj->OwnerLock( true );
818 inline void SfxObjectShellLock::Clear()
820 if( pObj )
822 SfxObjectShell* const pRefObj = pObj;
823 pObj = nullptr;
824 pRefObj->OwnerLock( false );
827 inline SfxObjectShellLock::~SfxObjectShellLock()
829 if( pObj )
830 pObj->OwnerLock( false );
832 inline SfxObjectShellLock & SfxObjectShellLock::operator=( const SfxObjectShellLock & rObj )
834 if( rObj.pObj )
835 rObj.pObj->OwnerLock( true );
836 SfxObjectShell* const pRefObj = pObj;
837 pObj = rObj.pObj;
838 if( pRefObj )
839 pRefObj->OwnerLock( false );
840 return *this;
842 inline SfxObjectShellLock & SfxObjectShellLock::operator=( SfxObjectShellLock && rObj )
844 if (pObj)
845 pObj->OwnerLock( false );
846 pObj = rObj.pObj;
847 rObj.pObj = nullptr;
848 return *this;
850 inline SfxObjectShellLock & SfxObjectShellLock::operator=( SfxObjectShell * pObjP )
852 return *this = SfxObjectShellLock( pObjP );
855 class SFX2_DLLPUBLIC SfxObjectShellItem final : public SfxPoolItem
857 SfxObjectShell* pObjSh;
859 public:
860 static SfxPoolItem* CreateDefault();
862 SfxObjectShellItem() :
863 SfxPoolItem( 0 ),
864 pObjSh( nullptr )
866 SfxObjectShellItem( sal_uInt16 nWhichId,
867 SfxObjectShell *pObjShell ):
868 SfxPoolItem( nWhichId ),
869 pObjSh( pObjShell )
872 virtual bool operator==( const SfxPoolItem& ) const override;
873 virtual SfxPoolItem* Clone( SfxItemPool *pPool = nullptr ) const override;
874 virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override;
875 virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override;
878 #endif
880 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */