Bump version to 6.4-15
[LibreOffice.git] / include / sfx2 / objsh.hxx
blob2d6a4c3cd2d3f0bccff80fc6a6a1b2655105f1f1
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>
29 #include <vcl/bitmapex.hxx>
31 #include <svl/poolitem.hxx>
32 #include <sot/formats.hxx>
33 #include <sot/object.hxx>
34 #include <tools/gen.hxx>
35 #include <tools/link.hxx>
37 #include <sfx2/shell.hxx>
38 #include <comphelper/embeddedobjectcontainer.hxx>
39 #include <memory>
40 #include <set>
41 #include <o3tl/typed_flags_set.hxx>
42 #include <functional>
44 class SbxValue;
45 class SbxArray;
46 class BasicManager;
47 class SfxMedium;
48 class SfxObjectFactory;
49 class SfxDocumentInfoDialog;
50 class SfxStyleSheetBasePool;
51 class StarBASIC;
52 class Printer;
53 class SvKeyValueIterator;
54 class SfxBaseModel;
55 class SfxModule;
56 class SfxProgress;
57 class GDIMetaFile;
58 class INetURLObject;
59 class IndexBitSet;
60 class JobSetup;
61 class Button;
62 class OutputDevice;
63 class Color;
64 class Fraction;
65 class SvGlobalName;
66 class InfobarData;
67 class VirtualDevice;
69 enum class SfxModelFlags;
70 enum class SfxEventHintId;
71 enum class InfobarType;
73 // These values presumably must match exactly the corresponding
74 // css::embed::Aspects ones (in offapi/com/sun/star/embed/Aspects.idl)
75 // and the DVASPECT_* ones in the Win32 API.
77 #define ASPECT_CONTENT 1
78 #define ASPECT_THUMBNAIL 2 /* 120 * 120, 6 Colors DIB in MetaFile */
79 #define ASPECT_ICON 4
80 #define ASPECT_DOCPRINT 8
82 namespace sfx2
84 class SvLinkSource;
85 class StyleManager;
88 namespace vcl { class Window; }
89 namespace com::sun::star::beans { struct PropertyValue; }
90 namespace com::sun::star::document { struct CmisVersion; }
91 namespace com::sun::star::embed { class XStorage; }
92 namespace com::sun::star::frame { class XModel; }
93 namespace com::sun::star::graphic { class XGraphic; }
94 namespace com::sun::star::io { class XStream; }
95 namespace com::sun::star::script { class XLibraryContainer; }
96 namespace com::sun::star::security { class XCertificate; }
97 namespace com::sun::star::security { class XDocumentDigitalSignatures; }
98 namespace com::sun::star::security { struct DocumentSignatureInformation; }
99 namespace com::sun::star::task { class XInteractionHandler; }
101 namespace com { namespace sun { namespace star {
102 namespace document {
103 class XDocumentProperties;
105 namespace lang {
106 class XComponent;
108 namespace text {
109 class XTextRange;
111 } } }
113 namespace sfx2 { class IXmlIdRegistry; }
115 #define SFX_TITLE_TITLE 0
116 #define SFX_TITLE_FILENAME 1
117 #define SFX_TITLE_FULLNAME 2
118 #define SFX_TITLE_APINAME 3
119 #define SFX_TITLE_DETECT 4
120 #define SFX_TITLE_CAPTION 5
121 #define SFX_TITLE_PICKLIST 6
122 #define SFX_TITLE_HISTORY 7
123 #define SFX_TITLE_MAXLEN 10 // this gives the limits on length
125 enum class SfxLoadedFlags
127 NONE = 0,
128 MAINDOCUMENT = 1,
129 IMAGES = 2,
130 ALL = MAINDOCUMENT | IMAGES
132 namespace o3tl
134 template<> struct typed_flags<SfxLoadedFlags> : is_typed_flags<SfxLoadedFlags, 0x03> {};
137 enum class HiddenInformation
139 NONE = 0x0000,
140 RECORDEDCHANGES = 0x0001,
141 NOTES = 0x0002,
142 DOCUMENTVERSIONS = 0x0004
144 namespace o3tl
146 template<> struct typed_flags<HiddenInformation> : is_typed_flags<HiddenInformation, 0x07> {};
149 namespace weld { class Window; }
151 enum class HiddenWarningFact
153 WhenSaving = 0,
154 WhenPrinting,
155 WhenSigning,
156 WhenCreatingPDF
159 enum class SfxObjectCreateMode
161 EMBEDDED,
162 STANDARD,
163 ORGANIZER,
164 INTERNAL
168 The class SfxObjectShell is the base class for SFx-objects, ie documents
169 and parts of documents that can be integrated as separate objects
170 into foreign objects.
173 struct TransferableObjectDescriptor;
174 template<class T> bool checkSfxObjectShell(const SfxObjectShell* pShell)
176 return dynamic_cast<const T*>(pShell) != nullptr;
179 class SFX2_DLLPUBLIC SfxObjectShell :
180 public SfxShell, virtual public SotObject,
181 public ::comphelper::IEmbeddedHelper
183 friend struct ModifyBlocker_Impl;
184 friend class SfxObjectShellLock;
186 private:
187 std::unique_ptr<struct SfxObjectShell_Impl> pImpl; // internal data
189 SfxMedium * pMedium; // Description of the file for example
190 // storage that contains the object
191 SfxObjectCreateMode eCreateMode; // Purpose of the object
192 bool bHasName :1; // sal_True := existing object,
193 // sal_False := new object
194 bool bIsInGenerateThumbnail; //optimize thumbnail generate and store procedure to improve odt saving performance, i120030
195 bool mbAvoidRecentDocs; ///< Avoid adding to the recent documents list, if not necessary.
197 enum TriState {undefined, yes, no};
198 TriState mbContinueImportOnFilterExceptions = undefined; // try to import as much as possible
200 bool CloseInternal();
202 SAL_DLLPRIVATE void UpdateTime_Impl(const css::uno::Reference<
203 css::document::XDocumentProperties> & i_xDocProps);
205 SAL_DLLPRIVATE bool SaveTo_Impl(SfxMedium &rMedium, const SfxItemSet* pSet );
207 protected:
208 SfxObjectShell(SfxObjectCreateMode);
209 SfxObjectShell(SfxModelFlags); // see sfxmodelfactory.hxx
210 virtual ~SfxObjectShell() override;
212 void ModifyChanged();
213 virtual bool Close() override;
215 /// template method, called by FlushDocInfo; this implementation is empty
216 virtual void DoFlushDocInfo();
218 // helper method
219 void AddToRecentlyUsedList();
221 public:
222 SFX_DECL_INTERFACE(SFX_INTERFACE_SFXDOCSH)
224 private:
225 /// SfxInterface initializer.
226 static void InitInterface_Impl();
228 public:
229 static const css::uno::Sequence<sal_Int8>& getUnoTunnelId();
230 /* Stampit disable/enable cancel button for print jobs
231 default = true = enable! */
232 void Stamp_SetPrintCancelState(bool bState);
233 bool Stamp_GetPrintCancelState() const;
235 static OUString CreateShellID( const SfxObjectShell* pShell );
237 // Document-Shell Iterator
238 static SfxObjectShell* GetFirst( const std::function<bool ( const SfxObjectShell* )>& isObjectShell = nullptr,
239 bool bOnlyVisible = true );
240 static SfxObjectShell* GetNext( const SfxObjectShell& rPrev,
241 const std::function<bool ( const SfxObjectShell* )>& isObjectShell = nullptr,
242 bool bOnlyVisible = true );
243 static SfxObjectShell* Current();
244 static css::uno::Reference< css::uno::XInterface >
245 GetCurrentComponent();
246 static void SetCurrentComponent( const css::uno::Reference< css::uno::XInterface >& _rxComponent );
248 virtual void Invalidate(sal_uInt16 nId = 0) override;
250 SfxModule* GetModule() const;
252 virtual SfxObjectFactory& GetFactory() const=0;
253 SfxMedium * GetMedium() const { return pMedium; }
254 css::uno::Reference< css::document::XDocumentProperties >
255 getDocProperties() const;
256 void UpdateDocInfoForSave( );
257 void FlushDocInfo();
258 bool HasName() const { return bHasName; }
259 OUString GetAPIName() const;
260 void SetReadOnly();
261 bool IsReadOnly() const;
262 bool IsReadOnlyMedium() const;
263 bool IsOriginallyReadOnlyMedium() const;
264 bool IsOriginallyLoadedReadOnlyMedium() const;
265 void SetReadOnlyUI( bool bReadOnly = true );
266 bool IsReadOnlyUI() const;
267 void SetNoName();
268 bool IsInModalMode() const;
269 bool IsInPrepareClose() const;
270 bool AcceptStateUpdate() const;
271 bool IsHelpDocument() const;
273 bool IsDocShared() const;
274 OUString GetSharedFileURL() const;
275 bool SwitchToShared( bool bShared, bool bSave );
276 SAL_DLLPRIVATE void FreeSharedFile( const OUString& aTempFileURL );
277 SAL_DLLPRIVATE void DoNotCleanShareControlFile();
278 void SetSharedXMLFlag( bool bFlag ) const;
279 bool HasSharedXMLFlagSet() const;
281 SAL_DLLPRIVATE void SetModalMode_Impl(bool bModal);
282 SAL_DLLPRIVATE void SetMacroMode_Impl(bool bModal=true);
284 void ResetError();
285 ErrCode GetError() const;
286 ErrCode GetErrorCode() const;
287 void SetError(ErrCode rErr);
290 * Initialize bare minimum just enough for unit test runs.
292 * @return true if the initialization is successful, false otherwise.
294 void DoInitUnitTest();
295 bool DoInitNew( SfxMedium* pMedium=nullptr );
296 bool DoLoad( SfxMedium* pMedium );
297 bool DoLoadExternal( SfxMedium* pMed );
298 bool DoSave();
299 bool DoSaveAs( SfxMedium &rNewStor );
300 bool DoSaveObjectAs( SfxMedium &rNewStor, bool bCommit );
302 // TODO/LATER: currently only overridden in Calc, should be made non-virtual
303 virtual bool DoSaveCompleted( SfxMedium* pNewStor=nullptr, bool bRegisterRecent=true );
304 /// Terminate any in-flight editing. Used before saving, primarily by Calc to commit cell changes.
305 virtual void TerminateEditing() {}
307 bool LoadOwnFormat( SfxMedium& pMedium );
308 virtual bool SaveAsOwnFormat( SfxMedium& pMedium );
309 virtual bool ConvertFrom( SfxMedium &rMedium );
310 virtual bool ConvertTo( SfxMedium &rMedium );
311 virtual bool InitNew( const css::uno::Reference< css::embed::XStorage >& xStorage );
312 virtual bool Load( SfxMedium &rMedium );
313 virtual bool LoadFrom( SfxMedium& rMedium );
314 virtual bool Save();
315 virtual bool SaveAs( SfxMedium &rMedium );
316 virtual bool SaveCompleted( const css::uno::Reference< css::embed::XStorage >& xStorage );
317 bool SwitchPersistance(
318 const css::uno::Reference< css::embed::XStorage >& xStorage );
319 virtual void UpdateLinks();
320 virtual bool LoadExternal( SfxMedium& rMedium );
321 bool IsConfigOptionsChecked() const;
322 void SetConfigOptionsChecked( bool bChecked );
324 // called for a few slots like SID_SAVE[AS]DOC, SID_PRINTDOC[DIRECT], derived classes may abort the action
325 virtual bool QuerySlotExecutable( sal_uInt16 nSlotId );
327 void SaveChildren(bool bObjectsOnly=false);
328 bool SaveAsChildren( SfxMedium &rMedium );
329 bool SwitchChildrenPersistance(
330 const css::uno::Reference< css::embed::XStorage >& xStorage,
331 bool bForceNonModified = false );
332 bool SaveCompletedChildren();
334 /** a very special case to insert at a position in Writer from UNO,
335 via OwnSubFilterService */
336 virtual bool InsertGeneratedStream(SfxMedium& rMedium,
337 css::uno::Reference<css::text::XTextRange> const& xInsertPosition);
338 virtual bool ImportFrom( SfxMedium &rMedium,
339 css::uno::Reference<css::text::XTextRange> const& xInsertPosition);
340 bool ExportTo( SfxMedium &rMedium );
342 /** Returns to if preparing was successful, else false. */
343 bool PrepareForSigning(weld::Window* pDialogParent);
344 bool CheckIsReadonly(bool bSignScriptingContent);
345 void RecheckSignature(bool bAlsoRecheckScriptingSignature);
346 void AfterSigning(bool bSignSuccess, bool bSignScriptingContent);
347 bool HasValidSignatures() const;
348 SignatureState GetDocumentSignatureState();
349 void SignDocumentContent(weld::Window* pDialogParent);
350 css::uno::Sequence<css::security::DocumentSignatureInformation> GetDocumentSignatureInformation(
351 bool bScriptingContent,
352 const css::uno::Reference<css::security::XDocumentDigitalSignatures>& xSigner
353 = css::uno::Reference<css::security::XDocumentDigitalSignatures>());
355 bool SignDocumentContentUsingCertificate(const css::uno::Reference<css::security::XCertificate>& xCertificate);
357 void SignSignatureLine(weld::Window* pDialogParent, const OUString& aSignatureLineId,
358 const css::uno::Reference<css::security::XCertificate>& xCert,
359 const css::uno::Reference<css::graphic::XGraphic>& xValidGraphic,
360 const css::uno::Reference<css::graphic::XGraphic>& xInvalidGraphic,
361 const OUString& aComment);
362 SignatureState GetScriptingSignatureState();
363 void SignScriptingContent(weld::Window* pDialogParent);
364 DECL_LINK(SignDocumentHandler, Button*, void);
366 virtual std::unique_ptr<SfxDocumentInfoDialog> CreateDocumentInfoDialog(weld::Window* pParent, const SfxItemSet& rItemSet);
368 ErrCode CallBasic( const OUString& rMacro, const OUString& rBasicName,
369 SbxArray* pArgs, SbxValue* pRet = nullptr );
371 ErrCode CallXScript(
372 const OUString& rScriptURL,
373 const css::uno::Sequence< css::uno::Any >& aParams,
374 css::uno::Any& aRet,
375 css::uno::Sequence< sal_Int16 >& aOutParamIndex,
376 css::uno::Sequence< css::uno::Any >& aOutParam,
377 bool bRaiseError = true,
378 const css::uno::Any* aCaller = nullptr );
380 static ErrCode CallXScript(
381 const css::uno::Reference< css::uno::XInterface >& _rxScriptContext,
382 const OUString& rScriptURL,
383 const css::uno::Sequence< css::uno::Any >& aParams,
384 css::uno::Any& aRet,
385 css::uno::Sequence< sal_Int16 >& aOutParamIndex,
386 css::uno::Sequence< css::uno::Any >& aOutParam,
387 bool bRaiseError = true,
388 const css::uno::Any* aCaller = nullptr
391 /** adjusts the internal macro mode, according to the current security settings
393 Finally, the macro mode is either NEVER_EXECUTE or ALWAYS_EXECUTE_NO_WARN.
395 @return
396 whether macros from this document should be executed
398 bool AdjustMacroMode();
400 static bool UnTrustedScript(const OUString& rScriptURL);
402 SvKeyValueIterator* GetHeaderAttributes();
403 void ClearHeaderAttributesForSourceViewHack();
404 void SetHeaderAttributesForSourceViewHack();
406 bool IsQueryLoadTemplate() const;
407 bool IsUseUserData() const;
408 bool IsUseThumbnailSave() const;
409 bool IsLoadReadonly() const;
410 bool IsSaveVersionOnClose() const;
411 void SetQueryLoadTemplate( bool b );
412 void SetUseUserData( bool bNew );
413 void SetUseThumbnailSave( bool _bNew );
414 void SetLoadReadonly( bool _bReadonly );
415 void SetSaveVersionOnClose( bool bSet );
416 void ResetFromTemplate( const OUString& rTemplateName, const OUString& rFileName );
418 // TODO/LATER: the following two methods should be replaced by Get/SetModifPasswordInfo in future
419 sal_uInt32 GetModifyPasswordHash() const;
420 bool SetModifyPasswordHash( sal_uInt32 nHash );
422 void SetMacroCallsSeenWhileLoading();
423 bool GetMacroCallsSeenWhileLoading() const;
425 const css::uno::Sequence< css::beans::PropertyValue >& GetModifyPasswordInfo() const;
426 bool SetModifyPasswordInfo( const css::uno::Sequence< css::beans::PropertyValue >& aInfo );
428 static ErrCode HandleFilter( SfxMedium* pMedium, SfxObjectShell const * pDoc );
430 virtual bool PrepareClose(bool bUI = true);
431 virtual HiddenInformation GetHiddenInformationState( HiddenInformation nStates );
432 sal_Int16 QueryHiddenInformation( HiddenWarningFact eFact, weld::Window* pParent );
433 bool IsSecurityOptOpenReadOnly() const;
434 void SetSecurityOptOpenReadOnly( bool bOpenReadOnly );
436 Size GetFirstPageSize() const;
437 bool DoClose();
438 std::shared_ptr<GDIMetaFile> GetPreviewMetaFile( bool bFullContent = false ) const;
439 BitmapEx GetPreviewBitmap(
440 bool bFullContent = false,
441 BmpConversion nColorConversion = BmpConversion::N24Bit,
442 BmpScaleFlag nScaleFlag = BmpScaleFlag::BestQuality) const;
443 virtual void CancelTransfers();
445 bool GenerateAndStoreThumbnail(
446 bool bEncrypted,
447 const css::uno::Reference< css::embed::XStorage >& xStor );
449 bool WriteThumbnail(
450 bool bEncrypted,
451 const css::uno::Reference< css::io::XStream >& xStream );
453 bool IsInGenerateAndStoreThumbnail() const {return bIsInGenerateThumbnail;}//optimize thumbnail generate and store procedure to improve odt saving performance, i120030
455 /// Don't add to the recent documents - it's an expensive operation, sometimes it is not wanted.
456 bool IsAvoidRecentDocs() const { return mbAvoidRecentDocs; }
458 /// Don't add to the recent documents - it's an expensive operation, sometimes it is not wanted.
459 void AvoidRecentDocs(bool bAvoid) { mbAvoidRecentDocs = bAvoid; }
461 /// On first error ask user if import should continue; return saved answer.
462 bool IsContinueImportOnFilterExceptions(const OUString& aErrMessage);
464 // Transfer IFace
465 bool IsAbortingImport() const;
466 void FinishedLoading( SfxLoadedFlags nWhich = SfxLoadedFlags::ALL );
468 virtual void SetFormatSpecificCompatibilityOptions( const OUString& /*rFilterTypeName*/ ) { /* Do not do anything here; Derived classes must overload to do actual work */ };
470 void TemplateDisconnectionAfterLoad();
471 void SetLoading(SfxLoadedFlags nFlags);
472 bool IsLoading() const;
473 bool IsLoadingFinished() const;
474 void SetAutoLoad( const INetURLObject&, sal_uInt32 nTime, bool bReload );
475 bool IsAutoLoadLocked() const;
477 // Misc
478 bool IsPreview() const;
479 SfxObjectCreateMode GetCreateMode() const { return eCreateMode; }
480 SfxProgress* GetProgress() const;
481 void SetWaitCursor( bool bSet ) const;
483 // Naming Interface
484 void SetTitle( const OUString& rTitle );
485 /* Small non-zero values of nMaxLen don't mean length, but have a magic meaning:
486 0 (default)
487 the title itself, as it is
489 1 (==SFX_TITLE_FILENAME)
490 provides the logical file name without path
491 (under WNT depending on the system settings
492 without extension)
494 2 (==SFX_TITLE_FULLNAME)
495 provides the logical file names with full path
496 (remote =>:: com:: sun:: star:: util:: URL)
498 3 (==SFX_TITLE_APINAME)
499 provides the logical filename without path
500 and extension
502 4 (==SFX_TITLE_DETECT)
503 provides the complete title, if not set yet
504 it will be created from DocInfo or the name of
505 the medium.
507 5 (==SFX_TITLE_CAPTION)
508 provides the Title just like MB now in the
509 CaptionBar view
511 6 (==SFX_TITLE_PICKLIST)
512 returns the Title, just like MB now would
513 display it in the PickList
515 7 (==SFX_TITLE_HISTORY)
516 returns the Title just like MB now would
517 display it in the History
519 10 bis USHRT_MAX
520 provides the 'nMaxLength' of the logical
521 file name including the path
522 (remote => css::util::URL)
524 OUString GetTitle( sal_uInt16 nMaxLen = 0 ) const;
525 void InvalidateName(); // Re-set to unnamed
527 #if defined(_WIN32)
528 // DDE-Interface
529 long DdeExecute( const OUString& rCmd );
530 virtual bool DdeGetData( const OUString& rItem,
531 const OUString& rMimeType,
532 css::uno::Any & rValue );
533 virtual bool DdeSetData( const OUString& rItem,
534 const OUString& rMimeType,
535 const css::uno::Any & rValue );
536 #endif
537 virtual ::sfx2::SvLinkSource* DdeCreateLinkSource( const OUString& rItem );
538 virtual void ReconnectDdeLink(SfxObjectShell& rServer);
540 static void ReconnectDdeLinks(SfxObjectShell& rServer);
542 // Contents
543 virtual SfxStyleSheetBasePool* GetStyleSheetPool();
545 virtual void LoadStyles(SfxObjectShell &rSource);
547 virtual sfx2::StyleManager* GetStyleManager();
549 // Determine the position of the "Automatic" filter in the stylist
550 void SetAutoStyleFilterIndex(sal_uInt16 nSet);
551 sal_uInt16 GetAutoStyleFilterIndex() const;
552 bool HasBasic() const;
553 BasicManager* GetBasicManager() const;
554 css::uno::Reference< css::script::XLibraryContainer >
555 GetBasicContainer();
556 css::uno::Reference< css::script::XLibraryContainer >
557 GetDialogContainer();
558 StarBASIC* GetBasic() const;
560 virtual std::set<Color> GetDocColors();
562 // Documents, for which to format the view size
564 virtual SfxObjectShell* GetObjectShell() override;
566 css::uno::Reference< css::frame::XModel >
567 GetModel() const;
568 // Only temporarily for the applications!
569 void SetBaseModel( SfxBaseModel* pModel );
570 css::uno::Reference< css::frame::XModel > GetBaseModel() const;
571 // Only temporarily for the applications!
573 virtual css::uno::Sequence< OUString > GetEventNames();
575 vcl::Window* GetDialogParent( SfxMedium const * pMedium=nullptr );
576 static SfxObjectShell* CreateObject( const OUString& rServiceName, SfxObjectCreateMode = SfxObjectCreateMode::STANDARD );
577 static SfxObjectShell* CreateObjectByFactoryName( const OUString& rURL, SfxObjectCreateMode = SfxObjectCreateMode::STANDARD );
578 static css::uno::Reference< css::lang::XComponent >
579 CreateAndLoadComponent( const SfxItemSet& rSet );
580 static SfxObjectShell* GetShellFromComponent( const css::uno::Reference< css::lang::XComponent >& xComp );
581 static OUString GetServiceNameFromFactory( const OUString& rFact );
582 bool IsInPlaceActive() const;
583 bool IsUIActive() const;
585 static bool CopyStoragesOfUnknownMediaType(
586 const css::uno::Reference< css::embed::XStorage >& xSource,
587 const css::uno::Reference<css::embed::XStorage>& xTarget,
588 const css::uno::Sequence<OUString>& rExceptions = css::uno::Sequence<OUString>());
590 // The functions from SvPersist
591 void EnableSetModified( bool bEnable = true );
592 bool IsEnableSetModified() const;
593 virtual void SetModified( bool bModified = true );
594 bool IsModified() const;
597 * @param bChart true if the file is a chart doc and FillClass should not be called
599 void SetupStorage(
600 const css::uno::Reference< css::embed::XStorage >& xStorage,
601 sal_Int32 nVersion, bool bTemplate ) const;
603 css::uno::Reference< css::embed::XStorage > const & GetStorage();
605 SvGlobalName const & GetClassName() const;
607 // comphelper::IEmbeddedHelper
608 virtual css::uno::Reference< css::task::XInteractionHandler > getInteractionHandler() const override;
609 virtual css::uno::Reference < css::embed::XStorage > getStorage() const override
611 return const_cast<SfxObjectShell*>(this)->GetStorage();
613 virtual comphelper::EmbeddedObjectContainer& getEmbeddedObjectContainer() const override
615 return GetEmbeddedObjectContainer();
617 bool isEnableSetModified() const override
619 return IsEnableSetModified();
621 virtual OUString getDocumentBaseURL() const override;
623 comphelper::EmbeddedObjectContainer& GetEmbeddedObjectContainer() const;
624 void ClearEmbeddedObjects();
626 // The functions from SvEmbeddedObject
627 virtual Printer * GetDocumentPrinter();
628 virtual OutputDevice* GetDocumentRefDev();
629 virtual void OnDocumentPrinterChanged( Printer * pNewPrinter );
630 virtual tools::Rectangle GetVisArea( sal_uInt16 nAspect ) const;
631 virtual void SetVisArea( const tools::Rectangle & rVisArea );
632 const tools::Rectangle & GetVisArea() const;
633 void SetVisAreaSize( const Size & rVisSize );
635 MapUnit GetMapUnit() const;
636 void SetMapUnit( MapUnit nMUnit );
638 void FillTransferableObjectDescriptor( TransferableObjectDescriptor& rDesc ) const;
639 void DoDraw( OutputDevice *, const Point & rObjPos,
640 const Size & rSize,
641 const JobSetup & rSetup,
642 sal_uInt16 nAspect = ASPECT_CONTENT );
643 virtual void Draw( OutputDevice *, const JobSetup & rSetup,
644 sal_uInt16 nAspect ) = 0;
647 virtual void FillClass( SvGlobalName * pClassName,
648 SotClipboardFormatId * pFormat,
649 OUString * pFullTypeName,
650 sal_Int32 nVersion,
651 bool bTemplate = false) const = 0;
653 // change recording and respective passwword protection for Writer and Calc
654 // slots available for Writer: FN_REDLINE_ON, FN_REDLINE_ON
655 // slots used for Calc: FID_CHG_RECORD, SID_CHG_PROTECT
656 virtual bool IsChangeRecording() const;
657 virtual bool HasChangeRecordProtection() const;
658 virtual void SetChangeRecording( bool bActivate );
659 virtual void SetProtectionPassword( const OUString &rPassword );
660 virtual bool GetProtectionHash( /*out*/ css::uno::Sequence< sal_Int8 > &rPasswordHash );
662 static bool IsOwnStorageFormat(const SfxMedium &);
664 /** Append Infobar once the frame is ready.
665 Useful when you want to register an Infobar before the doc/frame is fully loaded. */
666 void AppendInfoBarWhenReady(const OUString& sId, const OUString& sPrimaryMessage,
667 const OUString& sSecondaryMessage, InfobarType aInfobarType,
668 bool bShowCloseButton = true);
669 std::vector<InfobarData>& getPendingInfobars();
671 SAL_DLLPRIVATE bool CreatePreview_Impl(bool bFullContent, VirtualDevice* pDevice, GDIMetaFile* pFile) const;
673 SAL_DLLPRIVATE static bool IsPackageStorageFormat_Impl(const SfxMedium &);
675 SAL_DLLPRIVATE bool ConnectTmpStorage_Impl( const css::uno::Reference< css::embed::XStorage >& xStorage, SfxMedium* pMedium );
676 SAL_DLLPRIVATE bool DisconnectStorage_Impl( SfxMedium& rSrcMedium, SfxMedium& rTargetMedium );
678 SAL_DLLPRIVATE bool PutURLContentsToVersionStream_Impl(
679 const OUString& aURL,
680 const css::uno::Reference< css::embed::XStorage >& xDocStorage,
681 const OUString& aStreamName );
683 SAL_DLLPRIVATE OUString CreateTempCopyOfStorage_Impl(
684 const css::uno::Reference< css::embed::XStorage >& xStorage );
686 SAL_DLLPRIVATE void InitOwnModel_Impl();
687 SAL_DLLPRIVATE void BreakMacroSign_Impl( bool bBreakMacroSing );
688 SAL_DLLPRIVATE void CheckSecurityOnLoading_Impl();
689 SAL_DLLPRIVATE void CheckForBrokenDocSignatures_Impl();
690 SAL_DLLPRIVATE void CheckEncryption_Impl( const css::uno::Reference< css::task::XInteractionHandler >& xHandler );
691 SAL_DLLPRIVATE void SetModifyPasswordEntered( bool bEntered = true );
692 SAL_DLLPRIVATE bool IsModifyPasswordEntered() const;
694 SAL_DLLPRIVATE void InitBasicManager_Impl();
695 SAL_DLLPRIVATE SfxObjectShell_Impl* Get_Impl() { return pImpl.get(); }
697 SAL_DLLPRIVATE static bool UseInteractionToHandleError(
698 const css::uno::Reference< css::task::XInteractionHandler >& xHandler,
699 ErrCode nError );
700 SAL_DLLPRIVATE const SfxObjectShell_Impl* Get_Impl() const { return pImpl.get(); }
702 SAL_DLLPRIVATE void SetCreateMode_Impl( SfxObjectCreateMode nMode );
704 SAL_DLLPRIVATE void DoDraw_Impl( OutputDevice* pDev,
705 const Point & rViewPos,
706 const Fraction & rScaleX,
707 const Fraction & rScaleY,
708 const JobSetup & rSetup,
709 sal_uInt16 nAspect );
711 // Shell Interface
712 SAL_DLLPRIVATE void ExecFile_Impl(SfxRequest &);
713 SAL_DLLPRIVATE void GetState_Impl(SfxItemSet&);
714 SAL_DLLPRIVATE void PrintExec_Impl(SfxRequest &);
715 SAL_DLLPRIVATE void PrintState_Impl(SfxItemSet&);
716 SAL_DLLPRIVATE void ExecProps_Impl(SfxRequest &);
717 SAL_DLLPRIVATE void StateProps_Impl(SfxItemSet &);
718 SAL_DLLPRIVATE void ExecView_Impl(SfxRequest &);
719 SAL_DLLPRIVATE static void StateView_Impl(SfxItemSet &);
721 // Load/Save public internals
722 SAL_DLLPRIVATE bool ImportFromGeneratedStream_Impl(
723 const css::uno::Reference< css::io::XStream >& xStream,
724 const css::uno::Sequence< css::beans::PropertyValue >& aMediaDescr );
725 SAL_DLLPRIVATE void UpdateFromTemplate_Impl();
726 SAL_DLLPRIVATE bool CanReload_Impl();
727 SAL_DLLPRIVATE void SetNamedVisibility_Impl();
728 SAL_DLLPRIVATE bool DoSave_Impl( const SfxItemSet* pSet );
729 SAL_DLLPRIVATE bool Save_Impl( const SfxItemSet* pSet );
730 SAL_DLLPRIVATE bool
731 PreDoSaveAs_Impl(const OUString& rFileName, const OUString& rFiltName,
732 SfxItemSet const& rItemSet,
733 const css::uno::Sequence<css::beans::PropertyValue>& rArgs);
734 SAL_DLLPRIVATE bool APISaveAs_Impl(const OUString& aFileName, SfxItemSet& rItemSet,
735 const css::uno::Sequence<css::beans::PropertyValue>& rArgs);
736 SAL_DLLPRIVATE bool
737 CommonSaveAs_Impl(const INetURLObject& aURL, const OUString& aFilterName, SfxItemSet& rItemSet,
738 const css::uno::Sequence<css::beans::PropertyValue>& rArgs);
739 SAL_DLLPRIVATE bool GeneralInit_Impl(
740 const css::uno::Reference< css::embed::XStorage >& xStorage,
741 bool bTypeMustBeSetAlready );
742 SAL_DLLPRIVATE void PrepareSecondTryLoad_Impl();
743 SAL_DLLPRIVATE void SetInitialized_Impl( const bool i_fromInitNew );
745 // public-internals
746 SAL_DLLPRIVATE IndexBitSet& GetNoSet_Impl();
747 SAL_DLLPRIVATE void SetProgress_Impl( SfxProgress *pProgress );
748 SAL_DLLPRIVATE void PostActivateEvent_Impl( SfxViewFrame const * );
749 SAL_DLLPRIVATE void SetActivateEvent_Impl(SfxEventHintId );
750 SAL_DLLPRIVATE SfxObjectShell* GetParentShellByModel_Impl();
752 // configuration items
753 SAL_DLLPRIVATE SignatureState ImplGetSignatureState( bool bScriptingContent = false );
755 SAL_DLLPRIVATE bool QuerySaveSizeExceededModules_Impl( const css::uno::Reference< css::task::XInteractionHandler >& xHandler );
756 SAL_DLLPRIVATE static bool QueryAllowExoticFormat_Impl( const css::uno::Reference< css::task::XInteractionHandler >& xHandler,
757 const OUString& rURL,
758 const OUString& rFilterUIName);
760 SAL_DLLPRIVATE void CheckOut( );
761 SAL_DLLPRIVATE void CancelCheckOut( );
762 SAL_DLLPRIVATE void CheckIn( );
763 SAL_DLLPRIVATE css::uno::Sequence< css::document::CmisVersion > GetCmisVersions() const;
765 /** override this if you have a XmlIdRegistry. */
766 virtual const sfx2::IXmlIdRegistry* GetXmlIdRegistry() const { return nullptr; }
768 /// Is this read-only object shell opened via .uno:SignPDF?
769 bool IsSignPDF() const;
771 /// Gets the certificate that is already picked by the user but not yet used for signing.
772 css::uno::Reference<css::security::XCertificate> GetSignPDFCertificate() const;
775 #define SFX_GLOBAL_CLASSID \
776 0x9eaba5c3, 0xb232, 0x4309, \
777 0x84, 0x5f, 0x5f, 0x15, 0xea, 0x50, 0xd0, 0x74
779 struct ModifyBlocker_Impl
781 SfxObjectShell* pPersist;
782 bool bWasEnabled;
783 ModifyBlocker_Impl( SfxObjectShell* pPersistP ) : pPersist( pPersistP )
785 bWasEnabled = pPersistP->IsEnableSetModified();
786 if ( bWasEnabled )
787 pPersistP->EnableSetModified( false );
789 ~ModifyBlocker_Impl()
791 if ( bWasEnabled )
792 pPersist->EnableSetModified( bWasEnabled );
797 typedef tools::SvRef<SfxObjectShell> SfxObjectShellRef;
799 class SfxObjectShellLock
801 protected:
802 SfxObjectShell * pObj;
803 public:
804 SfxObjectShellLock() { pObj = nullptr; }
805 inline SfxObjectShellLock( const SfxObjectShellLock & rObj );
806 inline SfxObjectShellLock( SfxObjectShellLock && rObj ) noexcept;
807 inline SfxObjectShellLock( SfxObjectShell * pObjP );
808 inline void Clear();
809 inline ~SfxObjectShellLock();
810 inline SfxObjectShellLock & operator = ( const SfxObjectShellLock & rObj );
811 inline SfxObjectShellLock & operator = ( SfxObjectShellLock && rObj );
812 inline SfxObjectShellLock & operator = ( SfxObjectShell * pObj );
813 bool Is() const { return pObj != nullptr; }
814 SfxObjectShell * operator & () const { return pObj; }
815 SfxObjectShell * operator -> () const { return pObj; }
816 SfxObjectShell & operator * () const { return *pObj; }
817 operator SfxObjectShell * () const { return pObj; }
819 inline SfxObjectShellLock::SfxObjectShellLock( const SfxObjectShellLock & rObj )
821 pObj = rObj.pObj;
822 if( pObj )
823 pObj->OwnerLock( true );
825 inline SfxObjectShellLock::SfxObjectShellLock( SfxObjectShellLock && rObj ) noexcept
827 pObj = rObj.pObj;
828 rObj.pObj = nullptr;
830 inline SfxObjectShellLock::SfxObjectShellLock( SfxObjectShell * pObjP )
832 pObj = pObjP;
833 if( pObj )
834 pObj->OwnerLock( true );
836 inline void SfxObjectShellLock::Clear()
838 if( pObj )
840 SfxObjectShell* const pRefObj = pObj;
841 pObj = nullptr;
842 pRefObj->OwnerLock( false );
845 inline SfxObjectShellLock::~SfxObjectShellLock()
847 if( pObj )
848 pObj->OwnerLock( false );
850 inline SfxObjectShellLock & SfxObjectShellLock::operator=( const SfxObjectShellLock & rObj )
852 if( rObj.pObj )
853 rObj.pObj->OwnerLock( true );
854 SfxObjectShell* const pRefObj = pObj;
855 pObj = rObj.pObj;
856 if( pRefObj )
857 pRefObj->OwnerLock( false );
858 return *this;
860 inline SfxObjectShellLock & SfxObjectShellLock::operator=( SfxObjectShellLock && rObj )
862 if (pObj)
863 pObj->OwnerLock( false );
864 pObj = rObj.pObj;
865 rObj.pObj = nullptr;
866 return *this;
868 inline SfxObjectShellLock & SfxObjectShellLock::operator=( SfxObjectShell * pObjP )
870 return *this = SfxObjectShellLock( pObjP );
873 class SFX2_DLLPUBLIC SfxObjectShellItem final : public SfxPoolItem
875 SfxObjectShell* pObjSh;
877 public:
878 static SfxPoolItem* CreateDefault();
880 SfxObjectShellItem() :
881 SfxPoolItem( 0 ),
882 pObjSh( nullptr )
884 SfxObjectShellItem( sal_uInt16 nWhichId,
885 SfxObjectShell *pObjShell ):
886 SfxPoolItem( nWhichId ),
887 pObjSh( pObjShell )
890 virtual bool operator==( const SfxPoolItem& ) const override;
891 virtual SfxPoolItem* Clone( SfxItemPool *pPool = nullptr ) const override;
892 virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override;
893 virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override;
896 #endif
898 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */