Line data Source code
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>
24 : #include <sfx2/signaturestate.hxx>
25 : #include <sal/types.h>
26 : #include <tools/errcode.hxx>
27 : #include <com/sun/star/frame/XFrame.hpp>
28 : #include <com/sun/star/uno/Reference.h>
29 : #include <com/sun/star/uno/Sequence.hxx>
30 : #include <com/sun/star/script/XLibraryContainer.hpp>
31 : #include <com/sun/star/script/provider/XScriptProviderSupplier.hpp>
32 : #include <com/sun/star/embed/XStorage.hpp>
33 : #include <com/sun/star/beans/PropertyValue.hpp>
34 : #include <com/sun/star/security/DocumentSignatureInformation.hpp>
35 : #include <com/sun/star/security/XDocumentDigitalSignatures.hpp>
36 : #include <com/sun/star/task/XInteractionHandler.hpp>
37 : #include <com/sun/star/beans/XPropertySet.hpp>
38 : #include <com/sun/star/document/CmisVersion.hpp>
39 :
40 : #include <vcl/timer.hxx>
41 : #include <vcl/vclptr.hxx>
42 : #include <svl/poolitem.hxx>
43 : #include <vcl/bitmap.hxx>
44 : #include <sot/formats.hxx>
45 : #include <sot/object.hxx>
46 : #include <rsc/rscsfx.hxx>
47 :
48 : #include <sfx2/XmlIdRegistry.hxx>
49 : #include <sfx2/shell.hxx>
50 : #include <comphelper/embeddedobjectcontainer.hxx>
51 : #include <com/sun/star/frame/XModel.hpp>
52 : #include <memory>
53 : #include <set>
54 : #include <o3tl/typed_flags_set.hxx>
55 :
56 : #define LOK_USE_UNSTABLE_API
57 : #include <LibreOfficeKit/LibreOfficeKitTypes.h>
58 :
59 : class SbxValue;
60 : class SvxMacro;
61 : class SbxArray;
62 : class BasicManager;
63 : class SfxMedium;
64 : class SfxObjectFactory;
65 : class SfxDocumentInfoDialog;
66 : class SfxStyleSheetBasePool;
67 : class INote;
68 : class SfxStyleSheetPool;
69 : class SfxFrame;
70 : class SbMethod;
71 : class StarBASIC;
72 : class Printer;
73 : class SvKeyValueIterator;
74 : class SfxBaseModel;
75 : class SfxModule;
76 : class SvData;
77 : class SfxProgress;
78 : class GDIMetaFile;
79 : class Bitmap;
80 : class INetURLObject;
81 : class IndexBitSet;
82 : class JobSetup;
83 : class Size;
84 : class Point;
85 : enum class SfxModelFlags;
86 :
87 : // These values presumably must match exactly the corresponding
88 : // css::embed::Aspects ones (in offapi/com/sun/star/embed/Aspects.idl)
89 : // and the DVASPECT_* ones in the Win32 API.
90 :
91 : #define ASPECT_CONTENT 1
92 : #define ASPECT_THUMBNAIL 2 /* 120 * 120, 6 Colors DIB in MetaFile */
93 : #define ASPECT_ICON 4
94 : #define ASPECT_DOCPRINT 8
95 :
96 : // must be the same as in OLE2
97 : #define SVOBJ_MISCSTATUS_NOTRESIZEABLE 512
98 : #define SVOBJ_MISCSTATUS_RESIZEONPRINTERCHANGE 2048
99 :
100 : namespace sfx2
101 : {
102 : class SvLinkSource;
103 : class StyleManager;
104 : }
105 :
106 : namespace com { namespace sun { namespace star { namespace datatransfer { class XTransferable; } } } }
107 :
108 : namespace com { namespace sun { namespace star {
109 : namespace document {
110 : class XDocumentProperties;
111 : }
112 : namespace lang {
113 : class XComponent;
114 : }
115 : namespace text {
116 : class XTextRange;
117 : }
118 : } } }
119 :
120 : enum class SfxObjectShellFlags
121 : {
122 : HASOPENDOC = 0x01L,
123 : HASMENU = 0x04L,
124 : DONTLOADFILTERS = 0x08L,
125 : DONTCLOSE = 0x10L,
126 : NODOCINFO = 0x20L,
127 : STD_NORMAL = HASOPENDOC,
128 : STD_SPECIAL = DONTLOADFILTERS,
129 : UNDEFINED = 0xf000000
130 : };
131 : namespace o3tl
132 : {
133 : template<> struct typed_flags<SfxObjectShellFlags> : is_typed_flags<SfxObjectShellFlags, 0xf00003d> {};
134 : }
135 :
136 : #define SFX_TITLE_TITLE 0
137 : #define SFX_TITLE_FILENAME 1
138 : #define SFX_TITLE_FULLNAME 2
139 : #define SFX_TITLE_APINAME 3
140 : #define SFX_TITLE_DETECT 4
141 : #define SFX_TITLE_CAPTION 5
142 : #define SFX_TITLE_PICKLIST 6
143 : #define SFX_TITLE_HISTORY 7
144 : #define SFX_TITLE_MAXLEN 10 // this gives the limits on length
145 :
146 : enum class SfxLoadedFlags
147 : {
148 : NONE = 0,
149 : MAINDOCUMENT = 1,
150 : IMAGES = 2,
151 : ALL = MAINDOCUMENT | IMAGES
152 : };
153 : namespace o3tl
154 : {
155 : template<> struct typed_flags<SfxLoadedFlags> : is_typed_flags<SfxLoadedFlags, 0x03> {};
156 : }
157 :
158 : enum class HiddenInformation
159 : {
160 : NONE = 0x0000,
161 : RECORDEDCHANGES = 0x0001,
162 : NOTES = 0x0002,
163 : DOCUMENTVERSIONS = 0x0004
164 : };
165 : namespace o3tl
166 : {
167 : template<> struct typed_flags<HiddenInformation> : is_typed_flags<HiddenInformation, 0x07> {};
168 : }
169 :
170 : enum class HiddenWarningFact
171 : {
172 : WhenSaving = 0,
173 : WhenPrinting,
174 : WhenSigning,
175 : WhenCreatingPDF
176 : };
177 :
178 : enum class SfxObjectCreateMode
179 : {
180 : EMBEDDED,
181 : STANDARD,
182 : PREVIEW,
183 : ORGANIZER,
184 : PLUGIN,
185 : INTERNAL
186 : };
187 :
188 : /*
189 : The class SfxObjectShell is the base class for SFx-objects, ie documents
190 : and parts of documents that can be integrated as separate objects
191 : into foreign objects.
192 : */
193 :
194 : class SfxToolBoxConfig;
195 : struct TransferableObjectDescriptor;
196 :
197 : class SFX2_DLLPUBLIC SfxObjectShell :
198 : public SfxShell, virtual public SotObject,
199 : public ::comphelper::IEmbeddedHelper, public ::sfx2::IXmlIdRegistrySupplier
200 : {
201 : friend struct ModifyBlocker_Impl;
202 : friend class SfxObjectShellLock;
203 :
204 : private:
205 : struct SfxObjectShell_Impl* pImp; // internal data
206 :
207 : SfxMedium * pMedium; // Description of the file for example
208 : // storage that contains the object
209 : SfxStyleSheetBasePool* pStyleSheetPool; // StyleSheets
210 : SfxObjectCreateMode eCreateMode; // Purpose of the object
211 : bool bHasName :1; // sal_True := existing object,
212 : // sal_False := new object
213 : bool bIsInGenerateThumbnail; //optimize thumbnail generate and store procedure to improve odt saving performance, i120030
214 :
215 : bool CloseInternal();
216 : private:
217 : SAL_DLLPRIVATE void UpdateTime_Impl(const ::com::sun::star::uno::Reference<
218 : ::com::sun::star::document::XDocumentProperties> & i_xDocProps);
219 :
220 : SAL_DLLPRIVATE bool SaveTo_Impl(SfxMedium &rMedium, const SfxItemSet* pSet );
221 :
222 : protected:
223 : SfxObjectShell(SfxObjectCreateMode);
224 : SfxObjectShell(SfxModelFlags); // see sfxmodelfactory.hxx
225 : virtual ~SfxObjectShell();
226 :
227 : void ModifyChanged();
228 : virtual bool Close() SAL_OVERRIDE;
229 :
230 : /** declares the document to have capabilities to contain basic/dialog libraries
231 : */
232 : void SetHasNoBasic();
233 :
234 : /// template method, called by FlushDocInfo; this implementation is empty
235 : virtual void DoFlushDocInfo();
236 :
237 : // helper method
238 : void AddToRecentlyUsedList();
239 :
240 : public:
241 : TYPEINFO_OVERRIDE();
242 208 : SFX_DECL_INTERFACE(SFX_INTERFACE_SFXDOCSH)
243 :
244 : private:
245 : /// SfxInterface initializer.
246 : static void InitInterface_Impl();
247 :
248 : public:
249 : static const com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelId();
250 : /* Stampit disable/enable cancel button for print jobs
251 : default = true = enable! */
252 : void Stamp_SetPrintCancelState(bool bState);
253 : bool Stamp_GetPrintCancelState() const;
254 :
255 : static OUString CreateShellID( const SfxObjectShell* pShell );
256 :
257 : // Document-Shell Iterator
258 : static SfxObjectShell* GetFirst( const TypeId* pType = 0,
259 : bool bOnlyVisible = true );
260 : static SfxObjectShell* GetNext( const SfxObjectShell& rPrev,
261 : const TypeId* pType = 0,
262 : bool bOnlyVisible = true );
263 : static SfxObjectShell* Current();
264 : static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
265 : GetCurrentComponent();
266 : static void SetCurrentComponent( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxComponent );
267 :
268 : virtual void Invalidate(sal_uInt16 nId = 0) SAL_OVERRIDE;
269 :
270 : SfxObjectShellFlags GetFlags( ) const;
271 :
272 : SfxModule* GetModule() const;
273 :
274 : virtual SfxObjectFactory& GetFactory() const=0;
275 76983384 : SfxMedium * GetMedium() const { return pMedium; }
276 : ::com::sun::star::uno::Reference<
277 : ::com::sun::star::document::XDocumentProperties > getDocProperties();
278 : void UpdateDocInfoForSave( );
279 : void FlushDocInfo();
280 48463 : bool HasName() const { return bHasName; }
281 : OUString GetAPIName() const;
282 : void SetReadOnly();
283 : bool IsReadOnly() const;
284 : bool IsReadOnlyMedium() const;
285 : bool IsOriginallyReadOnlyMedium() const;
286 : void SetReadOnlyUI( bool bReadOnly = true );
287 : bool IsReadOnlyUI() const;
288 : void SetNoName();
289 : bool IsInModalMode() const;
290 : bool IsInPrepareClose() const;
291 : bool AcceptStateUpdate() const;
292 : bool IsHelpDocument() const;
293 :
294 : bool IsDocShared() const;
295 : OUString GetSharedFileURL() const;
296 : bool SwitchToShared( bool bShared, bool bSave );
297 : SAL_DLLPRIVATE void FreeSharedFile();
298 : SAL_DLLPRIVATE void FreeSharedFile( const OUString& aTempFileURL );
299 : SAL_DLLPRIVATE void DoNotCleanShareControlFile();
300 : void SetSharedXMLFlag( bool bFlag ) const;
301 : bool HasSharedXMLFlagSet() const;
302 :
303 : SAL_DLLPRIVATE void SetModalMode_Impl(bool bModal=true);
304 : SAL_DLLPRIVATE void SetMacroMode_Impl(bool bModal=true);
305 :
306 : void ResetError();
307 : sal_uInt32 GetError() const;
308 : sal_uInt32 GetErrorCode() const;
309 : void SetError( sal_uInt32 rErr, const OUString& aLogMessage );
310 :
311 : void AddLog( const OUString& aMessage );
312 : void StoreLog();
313 :
314 : /**
315 : * Initialize bare minimum just enough for unit test runs.
316 : *
317 : * @return true if the initialization is successful, false otherwise.
318 : */
319 : bool DoInitUnitTest();
320 : bool DoInitNew( SfxMedium* pMedium=0 );
321 : bool DoLoad( SfxMedium* pMedium );
322 : bool DoLoadExternal( SfxMedium* pMed );
323 : bool DoSave();
324 : bool DoSaveAs( SfxMedium &rNewStor );
325 : bool DoSaveObjectAs( SfxMedium &rNewStor, bool bCommit );
326 :
327 : // TODO/LATER: currently only overridden in Calc, should be made non-virtual
328 : virtual bool DoSaveCompleted( SfxMedium* pNewStor=0 );
329 :
330 : bool LoadOwnFormat( SfxMedium& pMedium );
331 : virtual bool SaveAsOwnFormat( SfxMedium& pMedium );
332 : virtual bool ConvertFrom( SfxMedium &rMedium );
333 : virtual bool ConvertTo( SfxMedium &rMedium );
334 : virtual bool InitNew( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage );
335 : virtual bool Load( SfxMedium &rMedium );
336 : virtual bool LoadFrom( SfxMedium& rMedium );
337 : virtual bool Save();
338 : virtual bool SaveAs( SfxMedium &rMedium );
339 : virtual bool SaveCompleted( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage );
340 : bool SwitchPersistance(
341 : const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage );
342 : virtual void UpdateLinks();
343 : virtual bool LoadExternal( SfxMedium& rMedium );
344 : /**
345 : * Called when the Options dialog is dismissed with the OK button, to
346 : * handle potentially conflicting option settings.
347 : */
348 : virtual void CheckConfigOptions();
349 : bool IsConfigOptionsChecked() const;
350 : void SetConfigOptionsChecked( bool bChecked );
351 :
352 : // called for a few slots like SID_SAVE[AS]DOC, SID_PRINTDOC[DIRECT], derived classes may abort the action
353 : virtual bool QuerySlotExecutable( sal_uInt16 nSlotId );
354 :
355 : bool SaveChildren(bool bObjectsOnly=false);
356 : bool SaveAsChildren( SfxMedium &rMedium );
357 : bool SwitchChildrenPersistance(
358 : const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage,
359 : bool bForceNonModified = false );
360 : bool SaveCompletedChildren( bool bSuccess );
361 :
362 : /** a very special case to insert at a position in Writer from UNO,
363 : via OwnSubFilterService */
364 : virtual bool InsertGeneratedStream(SfxMedium& rMedium,
365 : css::uno::Reference<css::text::XTextRange> const& xInsertPosition);
366 : virtual bool ImportFrom( SfxMedium &rMedium,
367 : css::uno::Reference<css::text::XTextRange> const& xInsertPosition);
368 : bool ExportTo( SfxMedium &rMedium );
369 :
370 : // xmlsec05, check with SFX team
371 : SignatureState GetDocumentSignatureState();
372 : void SignDocumentContent();
373 : SignatureState GetScriptingSignatureState();
374 : void SignScriptingContent();
375 :
376 : virtual VclPtr<SfxDocumentInfoDialog> CreateDocumentInfoDialog(
377 : vcl::Window *pParent, const SfxItemSet& );
378 :
379 : ErrCode CallBasic( const OUString& rMacro, const OUString& rBasicName,
380 : SbxArray* pArgs = 0, SbxValue* pRet = 0 );
381 :
382 : ErrCode CallXScript(
383 : const OUString& rScriptURL,
384 : const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aParams,
385 : ::com::sun::star::uno::Any& aRet,
386 : ::com::sun::star::uno::Sequence< sal_Int16 >& aOutParamIndex,
387 : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aOutParam,
388 : bool bRaiseError = true,
389 : const ::com::sun::star::uno::Any* aCaller = 0 );
390 :
391 : static ErrCode CallXScript(
392 : const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxScriptContext,
393 : const OUString& rScriptURL,
394 : const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aParams,
395 : ::com::sun::star::uno::Any& aRet,
396 : ::com::sun::star::uno::Sequence< sal_Int16 >& aOutParamIndex,
397 : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aOutParam,
398 : bool bRaiseError = true,
399 : const ::com::sun::star::uno::Any* aCaller = 0
400 : );
401 :
402 : /** adjusts the internal macro mode, according to the current security settings
403 :
404 : Finally, the macro mode is either NEVER_EXECUTE or ALWAYS_EXECUTE_NO_WARN.
405 :
406 : @return
407 : whether macros from this document should be executed
408 : */
409 : bool AdjustMacroMode( const OUString& rScriptType, bool _bSuppressUI = false );
410 :
411 : SvKeyValueIterator* GetHeaderAttributes();
412 : void ClearHeaderAttributesForSourceViewHack();
413 : void SetHeaderAttributesForSourceViewHack();
414 :
415 : bool IsTemplate() const;
416 :
417 : bool IsQueryLoadTemplate() const;
418 : bool IsUseUserData() const;
419 : bool IsLoadReadonly() const;
420 : bool IsSaveVersionOnClose() const;
421 : void SetQueryLoadTemplate( bool b );
422 : void SetUseUserData( bool bNew );
423 : void SetLoadReadonly( bool _bReadonly );
424 : void SetSaveVersionOnClose( bool bSet );
425 : void ResetFromTemplate( const OUString& rTemplateName, const OUString& rFileName );
426 :
427 : // TODO/LATER: the following two methods should be replaced by Get/SetModifPasswordInfo in future
428 : sal_uInt32 GetModifyPasswordHash() const;
429 : bool SetModifyPasswordHash( sal_uInt32 nHash );
430 :
431 : ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > GetModifyPasswordInfo() const;
432 : bool SetModifyPasswordInfo( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aInfo );
433 :
434 : static sal_uInt32 HandleFilter( SfxMedium* pMedium, SfxObjectShell* pDoc );
435 :
436 : virtual bool PrepareClose(bool bUI = true);
437 : virtual bool IsInformationLost();
438 : virtual HiddenInformation GetHiddenInformationState( HiddenInformation nStates );
439 : sal_Int16 QueryHiddenInformation( HiddenWarningFact eFact, vcl::Window* pParent );
440 : bool IsSecurityOptOpenReadOnly() const;
441 : void SetSecurityOptOpenReadOnly( bool bOpenReadOnly = true );
442 :
443 : virtual Size GetFirstPageSize();
444 : bool DoClose();
445 : virtual void PrepareReload();
446 : std::shared_ptr<GDIMetaFile> GetPreviewMetaFile( bool bFullContent = false ) const;
447 : virtual void CancelTransfers();
448 :
449 : bool GenerateAndStoreThumbnail(
450 : bool bEncrypted,
451 : bool bIsTemplate,
452 : const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStor );
453 :
454 : bool WriteThumbnail(
455 : bool bEncrypted,
456 : bool bIsTemplate,
457 : const ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream >& xStream );
458 :
459 445 : bool IsInGenerateAndStoreThumbnail() const {return bIsInGenerateThumbnail;}//optimize thumbnail generate and store procedure to improve odt saving performance, i120030
460 :
461 : // Transfer IFace
462 : void AbortImport();
463 : bool IsAbortingImport() const;
464 : bool IsReloading() const;
465 : void FinishedLoading( SfxLoadedFlags nWhich = SfxLoadedFlags::ALL );
466 : void TemplateDisconnectionAfterLoad();
467 : bool IsLoading() const;
468 : bool IsLoadingFinished() const;
469 : void SetAutoLoad( const INetURLObject&, sal_uInt32 nTime, bool bReload = true );
470 : bool IsAutoLoadLocked() const;
471 : void NotifyReloadAvailable();
472 :
473 : // Misc
474 : bool IsPreview() const;
475 119148 : SfxObjectCreateMode GetCreateMode() const { return eCreateMode; }
476 : SfxProgress* GetProgress() const;
477 : void SetWaitCursor( bool bSet ) const;
478 :
479 : // Naming Interface
480 : void SetTitle( const OUString& rTitle );
481 : OUString GetTitle( sal_uInt16 nMaxLen = 0 ) const;
482 : void InvalidateName(); // Re-set to unnamed
483 :
484 : #if defined WNT
485 : // DDE-Interface
486 : long DdeExecute( const OUString& rCmd );
487 : virtual bool DdeGetData( const OUString& rItem,
488 : const OUString& rMimeType,
489 : ::com::sun::star::uno::Any & rValue );
490 : virtual bool DdeSetData( const OUString& rItem,
491 : const OUString& rMimeType,
492 : const ::com::sun::star::uno::Any & rValue );
493 : #endif
494 : virtual ::sfx2::SvLinkSource* DdeCreateLinkSource( const OUString& rItem );
495 : virtual void ReconnectDdeLink(SfxObjectShell& rServer);
496 :
497 : static void ReconnectDdeLinks(SfxObjectShell& rServer);
498 :
499 : // Contents
500 : virtual SfxStyleSheetBasePool* GetStyleSheetPool();
501 : void SetStyleSheetPool(SfxStyleSheetBasePool *pBasePool )
502 : {
503 : pStyleSheetPool = pBasePool;
504 : }
505 :
506 : virtual void LoadStyles(SfxObjectShell &rSource);
507 :
508 : virtual sfx2::StyleManager* GetStyleManager();
509 :
510 : // Determine the position of the "Automatic" filter in the stylist
511 : void SetAutoStyleFilterIndex(sal_uInt16 nSet);
512 : sal_uInt16 GetAutoStyleFilterIndex();
513 : bool HasBasic() const;
514 : BasicManager* GetBasicManager() const;
515 : com::sun::star::uno::Reference< com::sun::star::script::XLibraryContainer >
516 : GetBasicContainer();
517 : com::sun::star::uno::Reference< com::sun::star::script::XLibraryContainer >
518 : GetDialogContainer();
519 : StarBASIC* GetBasic() const;
520 :
521 : virtual std::set<Color> GetDocColors();
522 :
523 : void ReadNote( INote * );
524 : void UpdateNote( INote * );
525 :
526 : // Documents, for which to format the view size
527 :
528 : virtual SfxObjectShell* GetObjectShell() SAL_OVERRIDE;
529 :
530 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >
531 : GetModel() const;
532 : // Only temporarily for the applications!
533 : void SetBaseModel( SfxBaseModel* pModel );
534 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > GetBaseModel() const;
535 : // Only temporarily for the applications!
536 :
537 : virtual ::com::sun::star::uno::Sequence< OUString > GetEventNames();
538 :
539 : vcl::Window* GetDialogParent( SfxMedium* pMedium=0 );
540 : static SfxObjectShell* CreateObject( const OUString& rServiceName, SfxObjectCreateMode = SfxObjectCreateMode::STANDARD );
541 : static SfxObjectShell* CreateObjectByFactoryName( const OUString& rURL, SfxObjectCreateMode = SfxObjectCreateMode::STANDARD );
542 : static ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >
543 : CreateAndLoadComponent( const SfxItemSet& rSet, SfxFrame* pFrame = NULL );
544 : static SfxObjectShell* GetShellFromComponent( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& xComp );
545 : static OUString GetServiceNameFromFactory( const OUString& rFact );
546 : bool IsInPlaceActive();
547 : bool IsUIActive();
548 : virtual void InPlaceActivate( bool );
549 :
550 : static bool CopyStoragesOfUnknownMediaType(
551 : const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xSource,
552 : const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xTarget );
553 :
554 : // The functions from SvPersist
555 : void EnableSetModified( bool bEnable = true );
556 : bool IsEnableSetModified() const;
557 : virtual void SetModified( bool bModified = true );
558 : bool IsModified();
559 :
560 : /**
561 : * @param bChart true if the file is a chart doc and FillClass should not be called
562 : */
563 : void SetupStorage(
564 : const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage,
565 : sal_Int32 nVersion, bool bTemplate, bool bChart = false ) const;
566 :
567 : ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > GetStorage();
568 :
569 : SvGlobalName GetClassName() const;
570 :
571 : // comphelper::IEmbeddedHelper
572 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler > getInteractionHandler() const SAL_OVERRIDE;
573 112 : virtual com::sun::star::uno::Reference < com::sun::star::embed::XStorage > getStorage() const SAL_OVERRIDE
574 : {
575 112 : return const_cast<SfxObjectShell*>(this)->GetStorage();
576 : }
577 641 : virtual comphelper::EmbeddedObjectContainer& getEmbeddedObjectContainer() const SAL_OVERRIDE
578 : {
579 641 : return GetEmbeddedObjectContainer();
580 : }
581 0 : bool isEnableSetModified() const SAL_OVERRIDE
582 : {
583 0 : return IsEnableSetModified();
584 : }
585 : comphelper::EmbeddedObjectContainer& GetEmbeddedObjectContainer() const;
586 : void ClearEmbeddedObjects();
587 :
588 : // The functions from SvEmbeddedObject
589 : virtual Printer * GetDocumentPrinter();
590 : virtual OutputDevice* GetDocumentRefDev();
591 : virtual void OnDocumentPrinterChanged( Printer * pNewPrinter );
592 : virtual Rectangle GetVisArea( sal_uInt16 nAspect ) const;
593 : virtual void SetVisArea( const Rectangle & rVisArea );
594 : const Rectangle & GetVisArea() const;
595 : void SetVisAreaSize( const Size & rVisSize );
596 : virtual sal_uIntPtr GetMiscStatus() const;
597 :
598 : MapUnit GetMapUnit() const;
599 : void SetMapUnit( MapUnit nMUnit );
600 :
601 : void FillTransferableObjectDescriptor( TransferableObjectDescriptor& rDesc ) const;
602 : void DoDraw( OutputDevice *, const Point & rObjPos,
603 : const Size & rSize,
604 : const JobSetup & rSetup,
605 : sal_uInt16 nAspect = ASPECT_CONTENT );
606 : virtual void Draw( OutputDevice *, const JobSetup & rSetup,
607 : sal_uInt16 nAspect = ASPECT_CONTENT ) = 0;
608 :
609 :
610 : virtual void FillClass( SvGlobalName * pClassName,
611 : SotClipboardFormatId * pFormat,
612 : OUString * pAppName,
613 : OUString * pFullTypeName,
614 : OUString * pShortTypeName,
615 : sal_Int32 nVersion,
616 : bool bTemplate = false) const = 0;
617 :
618 : // change recording and respective passwword protection for Writer and Calc
619 : // slots available for Writer: FN_REDLINE_ON, FN_REDLINE_ON
620 : // slots used for Calc: FID_CHG_RECORD, SID_CHG_PROTECT
621 : virtual bool IsChangeRecording() const;
622 : virtual bool HasChangeRecordProtection() const;
623 : virtual void SetChangeRecording( bool bActivate );
624 : virtual bool SetProtectionPassword( const OUString &rPassword );
625 : virtual bool GetProtectionHash( /*out*/ ::com::sun::star::uno::Sequence< sal_Int8 > &rPasswordHash );
626 :
627 : SAL_DLLPRIVATE std::shared_ptr<GDIMetaFile> CreatePreviewMetaFile_Impl( bool bFullContent ) const;
628 :
629 : SAL_DLLPRIVATE bool IsOwnStorageFormat_Impl(const SfxMedium &) const;
630 :
631 : SAL_DLLPRIVATE bool IsPackageStorageFormat_Impl(const SfxMedium &) const;
632 :
633 : SAL_DLLPRIVATE bool ConnectTmpStorage_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage, SfxMedium* pMedium );
634 : SAL_DLLPRIVATE bool DisconnectStorage_Impl( SfxMedium& rSrcMedium, SfxMedium& rTargetMedium );
635 :
636 : SAL_DLLPRIVATE bool PutURLContentsToVersionStream_Impl(
637 : const OUString& aURL,
638 : const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xDocStorage,
639 : const OUString& aStreamName );
640 :
641 : SAL_DLLPRIVATE OUString CreateTempCopyOfStorage_Impl(
642 : const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage );
643 :
644 : SAL_DLLPRIVATE void InitOwnModel_Impl();
645 : SAL_DLLPRIVATE void BreakMacroSign_Impl( bool bBreakMacroSing );
646 : SAL_DLLPRIVATE void CheckSecurityOnLoading_Impl();
647 : SAL_DLLPRIVATE void CheckForBrokenDocSignatures_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& xHandler );
648 : SAL_DLLPRIVATE SignatureState ImplCheckSignaturesInformation(
649 : const ::com::sun::star::uno::Sequence< ::com::sun::star::security::DocumentSignatureInformation >& aInfos );
650 : SAL_DLLPRIVATE void CheckEncryption_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& xHandler );
651 : SAL_DLLPRIVATE void SetModifyPasswordEntered( bool bEntered = true );
652 : SAL_DLLPRIVATE bool IsModifyPasswordEntered();
653 :
654 : SAL_DLLPRIVATE void InitBasicManager_Impl();
655 70050 : SAL_DLLPRIVATE SfxObjectShell_Impl* Get_Impl() { return pImp; }
656 :
657 : SAL_DLLPRIVATE static bool UseInteractionToHandleError(
658 : const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& xHandler,
659 : sal_uInt32 nError );
660 128952 : SAL_DLLPRIVATE const SfxObjectShell_Impl* Get_Impl() const { return pImp; }
661 :
662 : SAL_DLLPRIVATE void SetCreateMode_Impl( SfxObjectCreateMode nMode );
663 :
664 : SAL_DLLPRIVATE void DoDraw_Impl( OutputDevice* pDev,
665 : const Point & rViewPos,
666 : const Fraction & rScaleX,
667 : const Fraction & rScaleY,
668 : const JobSetup & rSetup,
669 : sal_uInt16 nAspect );
670 :
671 : // Shell Interface
672 : SAL_DLLPRIVATE void ExecFile_Impl(SfxRequest &);
673 : SAL_DLLPRIVATE void GetState_Impl(SfxItemSet&);
674 : SAL_DLLPRIVATE void PrintExec_Impl(SfxRequest &);
675 : SAL_DLLPRIVATE void PrintState_Impl(SfxItemSet&);
676 : SAL_DLLPRIVATE void ExecProps_Impl(SfxRequest &);
677 : SAL_DLLPRIVATE void StateProps_Impl(SfxItemSet &);
678 : SAL_DLLPRIVATE void ExecView_Impl(SfxRequest &);
679 : SAL_DLLPRIVATE void StateView_Impl(SfxItemSet &);
680 :
681 : // Load/Save public internals
682 : SAL_DLLPRIVATE bool ImportFromGeneratedStream_Impl(
683 : const ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream >& xStream,
684 : const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aMediaDescr );
685 : SAL_DLLPRIVATE void PositionView_Impl();
686 : SAL_DLLPRIVATE void UpdateFromTemplate_Impl();
687 : SAL_DLLPRIVATE bool CanReload_Impl();
688 : SAL_DLLPRIVATE void SetNamedVisibility_Impl();
689 : SAL_DLLPRIVATE bool DoSave_Impl( const SfxItemSet* pSet=0 );
690 : SAL_DLLPRIVATE bool Save_Impl( const SfxItemSet* pSet=0 );
691 : SAL_DLLPRIVATE bool PreDoSaveAs_Impl(const OUString &rFileName, const OUString &rFiltName, SfxItemSet *);
692 : SAL_DLLPRIVATE bool APISaveAs_Impl ( const OUString& aFileName, SfxItemSet* aParams );
693 : SAL_DLLPRIVATE bool CommonSaveAs_Impl ( const INetURLObject& aURL, const OUString& aFilterName, SfxItemSet* aParams );
694 : SAL_DLLPRIVATE bool GeneralInit_Impl(
695 : const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage,
696 : bool bTypeMustBeSetAlready );
697 : SAL_DLLPRIVATE void PrepareSecondTryLoad_Impl();
698 : SAL_DLLPRIVATE void SetInitialized_Impl( const bool i_fromInitNew );
699 :
700 : // public-internals
701 : SAL_DLLPRIVATE IndexBitSet& GetNoSet_Impl();
702 : SAL_DLLPRIVATE void SetProgress_Impl( SfxProgress *pProgress );
703 : SAL_DLLPRIVATE void PostActivateEvent_Impl( SfxViewFrame* );
704 : SAL_DLLPRIVATE void SetActivateEvent_Impl(sal_uInt16 );
705 : SAL_DLLPRIVATE SfxObjectShell* GetParentShellByModel_Impl();
706 :
707 : // configuration items
708 : SAL_DLLPRIVATE SfxToolBoxConfig* GetToolBoxConfig_Impl();
709 : SAL_DLLPRIVATE SignatureState ImplGetSignatureState( bool bScriptingContent = false );
710 :
711 : SAL_DLLPRIVATE ::com::sun::star::uno::Sequence< ::com::sun::star::security::DocumentSignatureInformation >
712 : ImplAnalyzeSignature(
713 : bool bScriptingContent,
714 : const ::com::sun::star::uno::Reference< ::com::sun::star::security::XDocumentDigitalSignatures >& xSigner
715 : = ::com::sun::star::uno::Reference< ::com::sun::star::security::XDocumentDigitalSignatures >() );
716 :
717 : SAL_DLLPRIVATE void ImplSign( bool bScriptingContent = false );
718 : SAL_DLLPRIVATE bool QuerySaveSizeExceededModules_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& xHandler );
719 :
720 : SAL_DLLPRIVATE void CheckOut( );
721 : SAL_DLLPRIVATE void CancelCheckOut( );
722 : SAL_DLLPRIVATE void CheckIn( );
723 : SAL_DLLPRIVATE ::com::sun::star::uno::Sequence< ::com::sun::star::document::CmisVersion > GetCmisVersions();
724 :
725 : /**
726 : * Interface shared by document shell. Allow LOK calls from sfx.
727 : * Default behavior doesn't do anything. relevant SfxObjectShells should override
728 : * the default behavior and implements LOK calls.
729 : */
730 : virtual void libreOfficeKitCallback(int nType, const char* pPayload) const;
731 : virtual bool isTiledRendering() const;
732 : };
733 :
734 : #define SFX_GLOBAL_CLASSID \
735 : 0x9eaba5c3, 0xb232, 0x4309, \
736 : 0x84, 0x5f, 0x5f, 0x15, 0xea, 0x50, 0xd0, 0x74
737 :
738 : struct ModifyBlocker_Impl
739 : {
740 : SfxObjectShell* pPersist;
741 : bool bWasEnabled;
742 6626 : ModifyBlocker_Impl( SfxObjectShell* pPersistP ) : pPersist( pPersistP )
743 : {
744 6626 : bWasEnabled = pPersistP->IsEnableSetModified();
745 6626 : if ( bWasEnabled )
746 2244 : pPersistP->EnableSetModified( false );
747 6626 : }
748 6626 : ~ModifyBlocker_Impl()
749 : {
750 6626 : if ( bWasEnabled )
751 2244 : pPersist->EnableSetModified( bWasEnabled );
752 6626 : }
753 : };
754 :
755 :
756 : #ifndef SFX_DECL_OBJECTSHELL_DEFINED
757 : #define SFX_DECL_OBJECTSHELL_DEFINED
758 : typedef tools::SvRef<SfxObjectShell> SfxObjectShellRef;
759 : #endif
760 :
761 : class SfxObjectShellLock
762 : {
763 : protected:
764 : SfxObjectShell * pObj;
765 : public:
766 5779 : inline SfxObjectShellLock() { pObj = 0; }
767 : inline SfxObjectShellLock( const SfxObjectShellLock & rObj );
768 : inline SfxObjectShellLock( SfxObjectShell * pObjP );
769 : inline void Clear();
770 : inline ~SfxObjectShellLock();
771 : inline SfxObjectShellLock & operator = ( const SfxObjectShellLock & rObj );
772 : inline SfxObjectShellLock & operator = ( SfxObjectShell * pObj );
773 51 : inline bool Is() const { return pObj != NULL; }
774 0 : inline SfxObjectShell * operator & () const { return pObj; }
775 181 : inline SfxObjectShell * operator -> () const { return pObj; }
776 47 : inline SfxObjectShell & operator * () const { return *pObj; }
777 130 : inline operator SfxObjectShell * () const { return pObj; }
778 : };
779 1 : inline SfxObjectShellLock::SfxObjectShellLock( const SfxObjectShellLock & rObj )
780 1 : { pObj = rObj.pObj; if( pObj ) { pObj->OwnerLock( true ); } }
781 149 : inline SfxObjectShellLock::SfxObjectShellLock( SfxObjectShell * pObjP )
782 149 : { pObj = pObjP; if( pObj ) { pObj->OwnerLock( true ); } }
783 50 : inline void SfxObjectShellLock::Clear()
784 : {
785 50 : if( pObj )
786 : {
787 0 : SfxObjectShell* const pRefObj = pObj;
788 0 : pObj = 0;
789 0 : pRefObj->OwnerLock( false );
790 : }
791 50 : }
792 5915 : inline SfxObjectShellLock::~SfxObjectShellLock()
793 5915 : { if( pObj ) { pObj->OwnerLock( false ); } }
794 140 : inline SfxObjectShellLock & SfxObjectShellLock::
795 : operator = ( const SfxObjectShellLock & rObj )
796 : {
797 140 : if( rObj.pObj ) rObj.pObj->OwnerLock( true );
798 140 : SfxObjectShell* const pRefObj = pObj;
799 140 : pObj = rObj.pObj;
800 140 : if( pRefObj ) { pRefObj->OwnerLock( false ); }
801 140 : return *this;
802 : }
803 91 : inline SfxObjectShellLock & SfxObjectShellLock::operator = ( SfxObjectShell * pObjP )
804 91 : { return *this = SfxObjectShellLock( pObjP ); }
805 :
806 0 : class AutoReloadTimer_Impl : public Timer
807 : {
808 : OUString aUrl;
809 : SfxObjectShell* pObjSh;
810 :
811 : public:
812 : AutoReloadTimer_Impl( const OUString& rURL, sal_uInt32 nTime,
813 : SfxObjectShell* pSh );
814 : virtual void Invoke() SAL_OVERRIDE;
815 : };
816 :
817 0 : class SFX2_DLLPUBLIC SfxObjectShellItem: public SfxPoolItem
818 : {
819 : SfxObjectShell* pObjSh;
820 :
821 : public:
822 : TYPEINFO_OVERRIDE();
823 0 : SfxObjectShellItem() :
824 : SfxPoolItem( 0 ),
825 0 : pObjSh( 0 )
826 0 : {}
827 : SfxObjectShellItem( SfxObjectShell *pObjShell ):
828 : SfxPoolItem( 0 ),
829 : pObjSh( pObjShell )
830 : {}
831 0 : SfxObjectShellItem( sal_uInt16 nWhichId,
832 : SfxObjectShell *pObjShell ):
833 : SfxPoolItem( nWhichId ),
834 0 : pObjSh( pObjShell )
835 0 : {}
836 :
837 : virtual bool operator==( const SfxPoolItem& ) const SAL_OVERRIDE;
838 : virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const SAL_OVERRIDE;
839 : virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const SAL_OVERRIDE;
840 : virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) SAL_OVERRIDE;
841 : SfxObjectShell* GetObjectShell() const
842 : { return pObjSh; }
843 :
844 : };
845 :
846 : #endif
847 :
848 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|