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