LibreOffice Module sfx2 (master) 1
objsh.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19#ifndef INCLUDED_SFX2_OBJSH_HXX
20#define INCLUDED_SFX2_OBJSH_HXX
21
22#include <sal/config.h>
23#include <sfx2/dllapi.h>
25#include <sal/types.h>
27#include <com/sun/star/uno/Reference.h>
28#include <com/sun/star/uno/Sequence.hxx>
29#include <com/sun/star/frame/XModel3.hpp>
30#include <vcl/bitmapex.hxx>
31
32#include <svl/poolitem.hxx>
33#include <sot/formats.hxx>
34#include <sot/object.hxx>
35#include <tools/gen.hxx>
36#include <tools/link.hxx>
37
38#include <sfx2/shell.hxx>
40#include <memory>
41#include <set>
42#include <string_view>
43
45#include <functional>
47
48namespace weld {class Button; }
49namespace model {class ColorSet; }
50struct NamedColor;
51class SbxValue;
52class SbxArray;
53class BasicManager;
54class SfxMedium;
58class StarBASIC;
59class Printer;
61class SfxBaseModel;
62class SfxModule;
63class SfxProgress;
64class GDIMetaFile;
65class INetURLObject;
66class IndexBitSet;
67class JobSetup;
68class OutputDevice;
69class Color;
70class Fraction;
71class SvGlobalName;
72class InfobarData;
73class VirtualDevice;
74
75enum class SfxModelFlags;
76enum class SfxEventHintId;
77enum class InfobarType;
78
79// These values presumably must match exactly the corresponding
80// css::embed::Aspects ones (in offapi/com/sun/star/embed/Aspects.idl)
81// and the DVASPECT_* ones in the Win32 API.
82
83#define ASPECT_CONTENT 1
84#define ASPECT_THUMBNAIL 2 /* 120 * 120, 6 Colors DIB in MetaFile */
85#define ASPECT_ICON 4
86#define ASPECT_DOCPRINT 8
87
88namespace sfx2
89{
90 class SvLinkSource;
91 class StyleManager;
92}
93
94namespace com::sun::star::awt { class XWindow; }
95namespace com::sun::star::beans { struct PropertyValue; }
96namespace com::sun::star::document { struct CmisVersion; }
97namespace com::sun::star::document { class XDocumentProperties; }
98namespace com::sun::star::embed { class XStorage; }
99namespace com::sun::star::frame { class XModel; }
100namespace com::sun::star::graphic { class XGraphic; }
101namespace com::sun::star::io { class XStream; }
102namespace com::sun::star::script { class XLibraryContainer; }
103namespace com::sun::star::security { class XCertificate; }
104namespace com::sun::star::security { class XDocumentDigitalSignatures; }
105namespace com::sun::star::security { struct DocumentSignatureInformation; }
106namespace com::sun::star::task { class XInteractionHandler; }
107namespace com::sun::star::lang { class XComponent; }
108namespace com::sun::star::text { class XTextRange; }
109
110namespace sfx2 { class IXmlIdRegistry; }
111
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 // this gives the limits on length
121
123{
124 NONE = 0,
125 MAINDOCUMENT = 1,
126 IMAGES = 2,
128};
129namespace o3tl
130{
131 template<> struct typed_flags<SfxLoadedFlags> : is_typed_flags<SfxLoadedFlags, 0x03> {};
132}
133
135{
136 NONE = 0x0000,
137 RECORDEDCHANGES = 0x0001,
138 NOTES = 0x0002,
139 DOCUMENTVERSIONS = 0x0004
140};
141namespace o3tl
142{
143 template<> struct typed_flags<HiddenInformation> : is_typed_flags<HiddenInformation, 0x07> {};
144}
145
146namespace weld { class Window; }
147
149{
150 WhenSaving = 0,
154};
155
157{
158 EMBEDDED,
159 STANDARD,
160 ORGANIZER,
162};
163
164/*
165 The class SfxObjectShell is the base class for SFx-objects, ie documents
166 and parts of documents that can be integrated as separate objects
167 into foreign objects.
168 There can be multiple edit windows (SfxViewShell) for one SfxObjectShell.
169*/
170
172template<class T> bool checkSfxObjectShell(const SfxObjectShell* pShell)
173{
174 return dynamic_cast<const T*>(pShell) != nullptr;
175}
176
178 public SfxShell, virtual public SotObject,
180{
181friend struct ModifyBlocker_Impl;
183
184private:
185 std::unique_ptr<struct SfxObjectShell_Impl> pImpl; // internal data
186
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
194 bool bRememberSignature; // Do we want to remember the signature.
195
196 enum TriState {undefined, yes, no};
197 TriState mbContinueImportOnFilterExceptions = undefined; // try to import as much as possible
198
199 bool CloseInternal();
200
201 SAL_DLLPRIVATE void UpdateTime_Impl(const css::uno::Reference<
202 css::document::XDocumentProperties> & i_xDocProps);
203
204 css::uno::Sequence< css::security::DocumentSignatureInformation > rSignatureInfosRemembered;
205
206 SAL_DLLPRIVATE bool SaveTo_Impl(SfxMedium &rMedium, const SfxItemSet* pSet );
207
208protected:
210 SfxObjectShell(SfxModelFlags); // see sfxmodelfactory.hxx
211 virtual ~SfxObjectShell() override;
212
213 void ModifyChanged();
214 virtual bool Close() override;
215
217 virtual void DoFlushDocInfo();
218
219 // helper method
220 void AddToRecentlyUsedList();
221
222 // Parent class for actual guard objects that would do useful work
224 {
225 public:
227 };
228
229public:
231
232private:
234 static void InitInterface_Impl();
235
236public:
237 static const css::uno::Sequence<sal_Int8>& getUnoTunnelId();
238 /* Stampit disable/enable cancel button for print jobs
239 default = true = enable! */
240 void Stamp_SetPrintCancelState(bool bState);
241 bool Stamp_GetPrintCancelState() const;
242
243 static OUString CreateShellID( const SfxObjectShell* pShell );
244
245 // Document-Shell Iterator
246 SAL_WARN_UNUSED_RESULT static SfxObjectShell* GetFirst( const std::function<bool ( const SfxObjectShell* )>& isObjectShell = nullptr,
247 bool bOnlyVisible = true );
248 SAL_WARN_UNUSED_RESULT static SfxObjectShell* GetNext( const SfxObjectShell& rPrev,
249 const std::function<bool ( const SfxObjectShell* )>& isObjectShell = nullptr,
250 bool bOnlyVisible = true );
251 SAL_WARN_UNUSED_RESULT static SfxObjectShell* Current();
252 static css::uno::Reference< css::uno::XInterface >
253 GetCurrentComponent();
254 static void SetCurrentComponent( const css::uno::Reference< css::uno::XInterface >& _rxComponent );
255
256 virtual void Invalidate(sal_uInt16 nId = 0) override;
257
258 SfxModule* GetModule() const;
259
260 virtual SfxObjectFactory& GetFactory() const=0;
261 SfxMedium * GetMedium() const { return pMedium; }
262 css::uno::Reference< css::document::XDocumentProperties >
263 getDocProperties() const;
264 void UpdateDocInfoForSave( );
265 void FlushDocInfo();
266 bool HasName() const { return bHasName; }
267 OUString GetAPIName() const;
268 void SetReadOnly();
269 bool IsReadOnly() const;
270 bool IsReadOnlyMedium() const;
271 bool IsOriginallyReadOnlyMedium() const;
272 bool IsOriginallyLoadedReadOnlyMedium() const;
273 void SetReadOnlyUI( bool bReadOnly = true );
274 bool IsReadOnlyUI() const;
275 void SetNoName();
276 bool IsInModalMode() const;
277 bool IsInPrepareClose() const;
278 bool AcceptStateUpdate() const;
279 bool IsHelpDocument() const;
280
281 bool IsDocShared() const;
282 OUString GetSharedFileURL() const;
283 bool SwitchToShared( bool bShared, bool bSave );
284 SAL_DLLPRIVATE void FreeSharedFile( const OUString& aTempFileURL );
285 SAL_DLLPRIVATE void DoNotCleanShareControlFile();
286 void SetSharedXMLFlag( bool bFlag ) const;
288
289 SAL_DLLPRIVATE void SetModalMode_Impl(bool bModal);
290 SAL_DLLPRIVATE void SetMacroMode_Impl(bool bModal=true);
291
292 void ResetError();
293 ErrCode GetError() const;
294 ErrCode GetErrorCode() const;
295 void SetError(ErrCode rErr);
296
302 void DoInitUnitTest();
303 bool DoInitNew();
304 bool DoLoad( SfxMedium* pMedium );
305 bool DoLoadExternal( SfxMedium* pMed );
306 bool DoSave();
307 bool DoSaveAs( SfxMedium &rNewStor );
308 bool DoSaveObjectAs( SfxMedium &rNewStor, bool bCommit );
309
310 // TODO/LATER: currently only overridden in Calc, should be made non-virtual
311 virtual bool DoSaveCompleted( SfxMedium* pNewStor=nullptr, bool bRegisterRecent=true );
313 virtual void TerminateEditing() {}
314
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 );
320 virtual bool Load( SfxMedium &rMedium );
321 virtual bool LoadFrom( SfxMedium& rMedium );
322 virtual bool Save();
323 virtual bool SaveAs( 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 );
327 virtual void UpdateLinks();
328 virtual bool LoadExternal( SfxMedium& rMedium );
329 bool IsConfigOptionsChecked() const;
330 void SetConfigOptionsChecked( bool bChecked );
331
332 // called for a few slots like SID_SAVE[AS]DOC, SID_PRINTDOC[DIRECT], derived classes may abort the action
333 virtual bool QuerySlotExecutable( sal_uInt16 nSlotId );
334
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();
341
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);
348 bool ExportTo( SfxMedium &rMedium );
349
351 bool PrepareForSigning(weld::Window* pDialogParent);
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;
356 SignatureState GetDocumentSignatureState();
357 bool SignDocumentContent(weld::Window* pDialogParent);
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>());
362
363 bool SignDocumentContentUsingCertificate(const css::uno::Reference<css::security::XCertificate>& xCertificate);
364 bool ResignDocument(css::uno::Sequence< css::security::DocumentSignatureInformation >& rSignaturesInfo);
365
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);
371 SignatureState GetScriptingSignatureState();
372 bool SignScriptingContent(weld::Window* pDialogParent);
373 DECL_DLLPRIVATE_LINK(SignDocumentHandler, weld::Button&, void);
374
375 virtual std::shared_ptr<SfxDocumentInfoDialog> CreateDocumentInfoDialog(weld::Window* pParent, const SfxItemSet& rItemSet);
376
377 ErrCode CallBasic( std::u16string_view rMacro, std::u16string_view rBasicName,
378 SbxArray* pArgs, SbxValue* pRet = nullptr );
379
380 ErrCode CallXScript(
381 const OUString& rScriptURL,
382 const css::uno::Sequence< css::uno::Any >& aParams,
383 css::uno::Any& aRet,
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 );
388
390 const css::uno::Reference< css::uno::XInterface >& _rxScriptContext,
391 const OUString& rScriptURL,
392 const css::uno::Sequence< css::uno::Any >& aParams,
393 css::uno::Any& aRet,
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
398 );
399
407 bool AdjustMacroMode();
408
409 static bool UnTrustedScript(const OUString& rScriptURL);
410
411 static bool isScriptAccessAllowed(const css::uno::Reference<css::uno::XInterface>& rScriptContext);
412
413 SvKeyValueIterator* GetHeaderAttributes();
414 void ClearHeaderAttributesForSourceViewHack();
415 void SetHeaderAttributesForSourceViewHack();
416
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 );
428
429 // TODO/LATER: the following two methods should be replaced by Get/SetModifPasswordInfo in future
430 sal_uInt32 GetModifyPasswordHash() const;
431 bool SetModifyPasswordHash( sal_uInt32 nHash );
432
433 void SetMacroCallsSeenWhileLoading();
434 bool GetMacroCallsSeenWhileLoading() const;
435
436 const css::uno::Sequence< css::beans::PropertyValue >& GetModifyPasswordInfo() const;
437 bool SetModifyPasswordInfo( const css::uno::Sequence< css::beans::PropertyValue >& aInfo );
438
439 static ErrCode HandleFilter( SfxMedium* pMedium, SfxObjectShell const * pDoc );
440
441 virtual bool PrepareClose(bool bUI = true);
442 virtual HiddenInformation GetHiddenInformationState( HiddenInformation nStates );
443 sal_Int16 QueryHiddenInformation( HiddenWarningFact eFact, weld::Window* pParent );
444 bool IsSecurityOptOpenReadOnly() const;
445 void SetSecurityOptOpenReadOnly( bool bOpenReadOnly );
446
447 Size GetFirstPageSize() const;
448 bool DoClose();
449 std::shared_ptr<GDIMetaFile> GetPreviewMetaFile( bool bFullContent = false ) const;
450 BitmapEx GetPreviewBitmap() const;
451 virtual void CancelTransfers();
452
453 bool GenerateAndStoreThumbnail(
454 bool bEncrypted,
455 const css::uno::Reference< css::embed::XStorage >& xStor );
456
457 bool WriteThumbnail(
458 bool bEncrypted,
459 const css::uno::Reference< css::io::XStream >& xStream );
460
461 bool IsInGenerateAndStoreThumbnail() const {return bIsInGenerateThumbnail;}//optimize thumbnail generate and store procedure to improve odt saving performance, i120030
462
464 bool IsAvoidRecentDocs() const { return mbAvoidRecentDocs; }
465
466 bool IsRememberingSignature() const { return bRememberSignature; }
467
469 void AvoidRecentDocs(bool bAvoid) { mbAvoidRecentDocs = bAvoid; }
470
472 bool IsContinueImportOnFilterExceptions(std::u16string_view aErrMessage);
473
474 // Transfer IFace
475 bool IsAbortingImport() const;
476 void FinishedLoading( SfxLoadedFlags nWhich = SfxLoadedFlags::ALL );
477
478 void TemplateDisconnectionAfterLoad();
479 void SetLoading(SfxLoadedFlags nFlags);
480 bool IsLoading() const;
481 bool IsLoadingFinished() const;
482 void SetAutoLoad( const INetURLObject&, sal_uInt32 nTime, bool bReload );
483 bool IsAutoLoadLocked() const;
484
485 // Misc
486 bool IsPreview() const;
487 SfxObjectCreateMode GetCreateMode() const { return eCreateMode; }
488 SfxProgress* GetProgress() const;
489 void SetWaitCursor( bool bSet ) const;
490
491 // Naming Interface
492 void SetTitle( const OUString& rTitle );
493 /* Small non-zero values of nMaxLen don't mean length, but have a magic meaning:
494 0 (default)
495 the title itself, as it is
496
497 1 (==SFX_TITLE_FILENAME)
498 provides the logical file name without path
499 (under WNT depending on the system settings
500 without extension)
501
502 2 (==SFX_TITLE_FULLNAME)
503 provides the logical file names with full path
504 (remote =>:: com:: sun:: star:: util:: URL)
505
506 3 (==SFX_TITLE_APINAME)
507 provides the logical filename without path
508 and extension
509
510 4 (==SFX_TITLE_DETECT)
511 provides the complete title, if not set yet
512 it will be created from DocInfo or the name of
513 the medium.
514
515 5 (==SFX_TITLE_CAPTION)
516 provides the Title just like MB now in the
517 CaptionBar view
518
519 6 (==SFX_TITLE_PICKLIST)
520 returns the Title, just like MB now would
521 display it in the PickList
522
523 7 (==SFX_TITLE_HISTORY)
524 returns the Title just like MB now would
525 display it in the History
526
527 10 bis USHRT_MAX
528 provides the 'nMaxLength' of the logical
529 file name including the path
530 (remote => css::util::URL)
531 */
532 OUString GetTitle( sal_uInt16 nMaxLen = 0 ) const;
533 void InvalidateName(); // Re-set to unnamed
534
535#if defined(_WIN32)
536 // DDE-Interface
537 bool DdeExecute( const OUString& rCmd );
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 );
544#endif
545 virtual ::sfx2::SvLinkSource* DdeCreateLinkSource( const OUString& rItem );
546 virtual void ReconnectDdeLink(SfxObjectShell& rServer);
547
548 static void ReconnectDdeLinks(SfxObjectShell& rServer);
549
550 // Contents
551 virtual SfxStyleSheetBasePool* GetStyleSheetPool();
552
553 virtual void LoadStyles(SfxObjectShell &rSource);
554
555 virtual sfx2::StyleManager* GetStyleManager();
556
557 // Determine the position of the "Automatic" filter in the stylist
558 void SetAutoStyleFilterIndex(sal_uInt16 nSet);
559 sal_uInt16 GetAutoStyleFilterIndex() const;
560 bool HasBasic() const;
561 BasicManager* GetBasicManager() const;
562 css::uno::Reference< css::script::XLibraryContainer >
563 GetBasicContainer();
564 css::uno::Reference< css::script::XLibraryContainer >
565 GetDialogContainer();
566 StarBASIC* GetBasic() const;
567
568 std::optional<NamedColor> GetRecentColor(sal_uInt16 nSlotId);
569 void SetRecentColor(sal_uInt16 nSlotId, const NamedColor& rColor);
570
571 virtual std::set<Color> GetDocColors();
572 virtual std::shared_ptr<model::ColorSet> GetThemeColors();
573
574 // Accessibility Check
575 virtual sfx::AccessibilityIssueCollection runAccessibilityCheck();
576
577 // Documents, for which to format the view size
578
579 virtual SfxObjectShell* GetObjectShell() override;
580
581 css::uno::Reference< css::frame::XModel3 >
582 GetModel() const;
583 // Only temporarily for the applications!
584 void SetBaseModel( SfxBaseModel* pModel );
585 css::uno::Reference< css::frame::XModel3 > GetBaseModel() const;
586 // Only temporarily for the applications!
587
588 virtual css::uno::Sequence< OUString > GetEventNames();
589
590 css::uno::Reference<css::awt::XWindow> GetDialogParent(SfxMedium const* pMedium = nullptr);
591 static SfxObjectShell* CreateObject( const OUString& rServiceName, SfxObjectCreateMode = SfxObjectCreateMode::STANDARD );
592 static SfxObjectShell* CreateObjectByFactoryName( const OUString& rURL, SfxObjectCreateMode = SfxObjectCreateMode::STANDARD );
593 static css::uno::Reference< css::lang::XComponent >
594 CreateAndLoadComponent( const SfxItemSet& rSet );
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;
600
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>());
605
606 bool isEditDocLocked() const;
607 bool isContentExtractionLocked() const;
608 bool isExportLocked() const;
609 bool isPrintLocked() const;
610 bool isSaveLocked() const;
611
612 // The functions from SvPersist
613 void EnableSetModified( bool bEnable = true );
614 bool IsEnableSetModified() const;
615 virtual void SetModified( bool bModified = true );
616 bool IsModified() const;
617
621 void SetupStorage(
622 const css::uno::Reference< css::embed::XStorage >& xStorage,
623 sal_Int32 nVersion, bool bTemplate ) const;
624
625 css::uno::Reference< css::embed::XStorage > const & GetStorage();
626
627 SvGlobalName const & GetClassName() const;
628
629 // comphelper::IEmbeddedHelper
630 virtual css::uno::Reference< css::task::XInteractionHandler > getInteractionHandler() const override;
631 virtual css::uno::Reference < css::embed::XStorage > getStorage() const override
632 {
633 return const_cast<SfxObjectShell*>(this)->GetStorage();
634 }
636 {
637 return GetEmbeddedObjectContainer();
638 }
639 bool isEnableSetModified() const override
640 {
641 return IsEnableSetModified();
642 }
643 virtual OUString getDocumentBaseURL() const override;
644
645 comphelper::EmbeddedObjectContainer& GetEmbeddedObjectContainer() const;
646 void ClearEmbeddedObjects();
647
648 // The functions from SvEmbeddedObject
649 virtual Printer * GetDocumentPrinter();
650 virtual OutputDevice* GetDocumentRefDev();
651 virtual void OnDocumentPrinterChanged( Printer * pNewPrinter );
652 virtual tools::Rectangle GetVisArea( sal_uInt16 nAspect ) const;
653 virtual void SetVisArea( const tools::Rectangle & rVisArea );
654 const tools::Rectangle & GetVisArea() const;
655 void SetVisAreaSize( const Size & rVisSize );
656
657 MapUnit GetMapUnit() const;
658 void SetMapUnit( MapUnit nMUnit );
659
660 void FillTransferableObjectDescriptor( TransferableObjectDescriptor& rDesc ) const;
661 void DoDraw( OutputDevice *, const Point & rObjPos,
662 const Size & rSize,
663 const JobSetup & rSetup,
664 sal_uInt16 nAspect = ASPECT_CONTENT,
665 bool bOutputForScreen = false );
666 virtual void Draw( OutputDevice *, const JobSetup & rSetup,
667 sal_uInt16 nAspect, bool bOutputForScreen ) = 0;
668
669
670 virtual void FillClass( SvGlobalName * pClassName,
671 SotClipboardFormatId * pFormat,
672 OUString * pFullTypeName,
673 sal_Int32 nVersion,
674 bool bTemplate = false) const = 0;
675
676 // change recording and respective passwword protection for Writer and Calc
677 // slots available for Writer: FN_REDLINE_ON, FN_REDLINE_ON
678 // slots used for Calc: FID_CHG_RECORD, SID_CHG_PROTECT
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( /*out*/ css::uno::Sequence< sal_Int8 > &rPasswordHash );
684
685 static bool IsOwnStorageFormat(const SfxMedium &);
686
689 void AppendInfoBarWhenReady(const OUString& sId, const OUString& sPrimaryMessage,
690 const OUString& sSecondaryMessage, InfobarType aInfobarType,
691 bool bShowCloseButton = true);
692 std::vector<InfobarData>& getPendingInfobars();
693
694 SAL_DLLPRIVATE bool CreatePreview_Impl(bool bFullContent, VirtualDevice* pDevice, GDIMetaFile* pFile) const;
695
696 SAL_DLLPRIVATE static bool IsPackageStorageFormat_Impl(const SfxMedium &);
697
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 );
700
701 SAL_DLLPRIVATE bool PutURLContentsToVersionStream_Impl(
702 const OUString& aURL,
703 const css::uno::Reference< css::embed::XStorage >& xDocStorage,
704 const OUString& aStreamName );
705
706 SAL_DLLPRIVATE OUString CreateTempCopyOfStorage_Impl(
707 const css::uno::Reference< css::embed::XStorage >& xStorage );
708
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;
716
717 SAL_DLLPRIVATE void InitBasicManager_Impl();
718 SAL_DLLPRIVATE SfxObjectShell_Impl* Get_Impl() { return pImpl.get(); }
719
720 SAL_DLLPRIVATE static bool UseInteractionToHandleError(
721 const css::uno::Reference< css::task::XInteractionHandler >& xHandler,
722 ErrCode nError );
723 SAL_DLLPRIVATE const SfxObjectShell_Impl* Get_Impl() const { return pImpl.get(); }
724
725 SAL_DLLPRIVATE void SetCreateMode_Impl( SfxObjectCreateMode nMode );
726
727 SAL_DLLPRIVATE void DoDraw_Impl( OutputDevice* pDev,
728 const Point & rViewPos,
729 const Fraction & rScaleX,
730 const Fraction & rScaleY,
731 const JobSetup & rSetup,
732 sal_uInt16 nAspect,
733 bool bOutputForScreen );
734
735 // Shell Interface
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 &);
744
745 // Load/Save public internals
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 );
754 SAL_DLLPRIVATE bool
755 PreDoSaveAs_Impl(const OUString& rFileName, const OUString& rFiltName,
756 SfxItemSet const& rItemSet,
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);
760 SAL_DLLPRIVATE bool
761 CommonSaveAs_Impl(const INetURLObject& aURL, const OUString& aFilterName, SfxItemSet& rItemSet,
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 );
768
769 // public-internals
770 SAL_DLLPRIVATE IndexBitSet& GetNoSet_Impl();
771 SAL_DLLPRIVATE void SetProgress_Impl( SfxProgress *pProgress );
772 SAL_DLLPRIVATE void PostActivateEvent_Impl( SfxViewFrame const * );
773 SAL_DLLPRIVATE void SetActivateEvent_Impl(SfxEventHintId );
774
775 // configuration items
776 SAL_DLLPRIVATE SignatureState ImplGetSignatureState( bool bScriptingContent = false );
777
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);
782
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;
787
789 virtual const sfx2::IXmlIdRegistry* GetXmlIdRegistry() const { return nullptr; }
790
792 bool IsSignPDF() const;
793
795 css::uno::Reference<css::security::XCertificate> GetSignPDFCertificate() const;
796
798 css::uno::Sequence< css::beans::PropertyValue > GetDocumentProtectionFromGrabBag() const;
799
800 // Lock all unlocked views, and returns a guard object which unlocks those views when destructed
801 virtual std::unique_ptr<LockAllViewsGuard> LockAllViews()
802 {
803 return std::make_unique<LockAllViewsGuard>();
804 }
805
806};
807
808#define SFX_GLOBAL_CLASSID \
809 0x9eaba5c3, 0xb232, 0x4309, \
810 0x84, 0x5f, 0x5f, 0x15, 0xea, 0x50, 0xd0, 0x74
811
813 {
814 private:
817 public:
818 ModifyBlocker_Impl( SfxObjectShell* pPersistP ) : pPersist( pPersistP )
819 {
820 bWasEnabled = pPersistP->IsEnableSetModified();
821 if ( bWasEnabled )
822 pPersistP->EnableSetModified( false );
823 }
825 {
826 if ( bWasEnabled )
828 }
829 };
830
831
833
835{
837public:
838 SfxObjectShellLock() { pObj = nullptr; }
839 inline SfxObjectShellLock( const SfxObjectShellLock & rObj );
840 inline SfxObjectShellLock( SfxObjectShellLock && rObj ) noexcept;
841 inline SfxObjectShellLock( SfxObjectShell * pObjP );
842 inline void Clear();
843 inline ~SfxObjectShellLock();
844 inline SfxObjectShellLock & operator = ( const SfxObjectShellLock & rObj );
847 bool Is() const { return pObj != nullptr; }
848 SfxObjectShell * operator & () const { return pObj; }
849 SfxObjectShell * operator -> () const { return pObj; }
850 SfxObjectShell & operator * () const { return *pObj; }
851 operator SfxObjectShell * () const { return pObj; }
852};
854{
855 pObj = rObj.pObj;
856 if( pObj )
857 pObj->OwnerLock( true );
858}
860{
861 pObj = rObj.pObj;
862 rObj.pObj = nullptr;
863}
865{
866 pObj = pObjP;
867 if( pObj )
868 pObj->OwnerLock( true );
869}
871{
872 if( pObj )
873 {
874 SfxObjectShell* const pRefObj = pObj;
875 pObj = nullptr;
876 pRefObj->OwnerLock( false );
877 }
878}
880{
881 if( pObj )
882 pObj->OwnerLock( false );
883}
885{
886 if( rObj.pObj )
887 rObj.pObj->OwnerLock( true );
888 SfxObjectShell* const pRefObj = pObj;
889 pObj = rObj.pObj;
890 if( pRefObj )
891 pRefObj->OwnerLock( false );
892 return *this;
893}
895{
896 if (pObj)
897 pObj->OwnerLock( false );
898 pObj = rObj.pObj;
899 rObj.pObj = nullptr;
900 return *this;
901}
903{
904 *this = SfxObjectShellLock( pObjP );
905 return *this;
906}
907
909{
911
912public:
913 static SfxPoolItem* CreateDefault();
914
916 SfxPoolItem( 0 ),
917 pObjSh( nullptr )
918 {}
919 SfxObjectShellItem( sal_uInt16 nWhichId,
920 SfxObjectShell *pObjShell ):
921 SfxPoolItem( nWhichId ),
922 pObjSh( pObjShell )
923 {}
924
925 virtual bool operator==( const SfxPoolItem& ) const override;
926 virtual SfxObjectShellItem* Clone( SfxItemPool *pPool = nullptr ) const override;
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;
929};
930
931#endif
932
933/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const sal_uInt16 nVersion
Definition: childwin.cxx:43
SfxObjectShell * pObjSh
Definition: objsh.hxx:910
SfxObjectShellItem(sal_uInt16 nWhichId, SfxObjectShell *pObjShell)
Definition: objsh.hxx:919
SfxObjectShell * operator->() const
Definition: objsh.hxx:849
bool Is() const
Definition: objsh.hxx:847
SfxObjectShell * pObj
Definition: objsh.hxx:836
SfxObjectShellLock & operator=(const SfxObjectShellLock &rObj)
Definition: objsh.hxx:884
SfxObjectShell * operator&() const
Definition: objsh.hxx:848
SfxObjectShell & operator*() const
Definition: objsh.hxx:850
bool IsInGenerateAndStoreThumbnail() const
Definition: objsh.hxx:461
SAL_DLLPRIVATE const SfxObjectShell_Impl * Get_Impl() const
Definition: objsh.hxx:723
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
Definition: objsh.hxx:631
bool IsAvoidRecentDocs() const
Don't add to the recent documents - it's an expensive operation, sometimes it is not wanted.
Definition: objsh.hxx:464
bool HasName() const
Definition: objsh.hxx:266
bool IsEnableSetModified() const
Definition: objmisc.cxx:248
SfxObjectCreateMode eCreateMode
Definition: objsh.hxx:189
css::uno::Sequence< css::security::DocumentSignatureInformation > rSignatureInfosRemembered
Definition: objsh.hxx:204
void SetSharedXMLFlag(bool bFlag) const
bool bRememberSignature
Definition: objsh.hxx:194
virtual SfxObjectFactory & GetFactory() const =0
virtual std::unique_ptr< LockAllViewsGuard > LockAllViews()
Definition: objsh.hxx:801
bool isEnableSetModified() const override
Definition: objsh.hxx:639
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)
SfxMedium * pMedium
Definition: objsh.hxx:187
SAL_DLLPRIVATE SfxObjectShell_Impl * Get_Impl()
Definition: objsh.hxx:718
SfxMedium * GetMedium() const
Definition: objsh.hxx:261
bool HasSharedXMLFlagSet() const
virtual const sfx2::IXmlIdRegistry * GetXmlIdRegistry() const
override this if you have a XmlIdRegistry.
Definition: objsh.hxx:789
std::unique_ptr< struct SfxObjectShell_Impl > pImpl
Definition: objsh.hxx:185
void EnableSetModified(bool bEnable=true)
Definition: objmisc.cxx:241
bool mbAvoidRecentDocs
Avoid adding to the recent documents list, if not necessary.
Definition: objsh.hxx:193
virtual void FillClass(SvGlobalName *pClassName, SotClipboardFormatId *pFormat, OUString *pFullTypeName, sal_Int32 nVersion, bool bTemplate=false) const =0
SfxObjectCreateMode GetCreateMode() const
Definition: objsh.hxx:487
virtual comphelper::EmbeddedObjectContainer & getEmbeddedObjectContainer() const override
Definition: objsh.hxx:635
bool bIsInGenerateThumbnail
Definition: objsh.hxx:192
bool IsRememberingSignature() const
Definition: objsh.hxx:466
virtual void TerminateEditing()
Terminate any in-flight editing. Used before saving, primarily by Calc to commit cell changes.
Definition: objsh.hxx:313
void AvoidRecentDocs(bool bAvoid)
Don't add to the recent documents - it's an expensive operation, sometimes it is not wanted.
Definition: objsh.hxx:469
SAL_DLLPRIVATE void DoNotCleanShareControlFile()
DECL_DLLPRIVATE_LINK(SignDocumentHandler, weld::Button &, void)
bool bHasName
Definition: objsh.hxx:190
The class SfxShell is the base class for all classes, which provide the functionality of the form <Sl...
Definition: shell.hxx:128
virtual void Invalidate(sal_uInt16 nId=0)
With this method can the slots of the subclasses be invalidated through the slot Id or alternatively ...
Definition: shell.cxx:235
virtual SfxObjectShell * GetObjectShell()
Definition: shell.cxx:649
void OwnerLock(bool bLock)
virtual bool Close()
bool DoClose()
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
#define SFX2_DLLPUBLIC
Definition: dllapi.h:29
SfxEventHintId
Definition: event.hxx:116
constexpr OUStringLiteral IsReadOnly(u"IsReadOnly")
SotClipboardFormatId
InfobarType
Definition: infobar.hxx:22
UpdateLinks
MapUnit
MapUnit GetMapUnit()
NONE
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)
HiddenInformation
Definition: objsh.hxx:135
#define ASPECT_CONTENT
Definition: objsh.hxx:83
SfxObjectCreateMode
Definition: objsh.hxx:157
tools::SvRef< SfxObjectShell > SfxObjectShellRef
Definition: objsh.hxx:832
bool checkSfxObjectShell(const SfxObjectShell *pShell)
Definition: objsh.hxx:172
HiddenWarningFact
Definition: objsh.hxx:149
SfxLoadedFlags
Definition: objsh.hxx:123
SfxModelFlags
static SfxItemSet & rSet
Definition: shell.cxx:534
#define SFX_DECL_INTERFACE(nId)
Definition: shell.hxx:532
constexpr auto SFX_INTERFACE_SFXDOCSH
Definition: shell.hxx:62
SignatureState
ModifyBlocker_Impl(SfxObjectShell *pPersistP)
Definition: objsh.hxx:818
SfxObjectShell * pPersist
Definition: objsh.hxx:815
unsigned char sal_uInt8
#define SAL_WARN_UNUSED_RESULT
bool operator==(const XclFontData &rLeft, const XclFontData &rRight)
int SetError()
int GetError()