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