Branch data 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 : :
20 : : #ifndef _SFXDOCFILE_HXX
21 : : #define _SFXDOCFILE_HXX
22 : :
23 : : #include <com/sun/star/io/XSeekable.hpp>
24 : : #include "sal/config.h"
25 : : #include "sfx2/dllapi.h"
26 : : #include "sal/types.h"
27 : : #include <com/sun/star/util/RevisionTag.hpp>
28 : : #include <com/sun/star/util/DateTime.hpp>
29 : : #include <com/sun/star/io/XOutputStream.hpp>
30 : : #include <com/sun/star/io/XInputStream.hpp>
31 : : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
32 : : #include <com/sun/star/lang/XServiceInfo.hpp>
33 : : #include <com/sun/star/ucb/XContent.hpp>
34 : : #include <com/sun/star/ucb/XCommandEnvironment.hpp>
35 : : #include <com/sun/star/task/XInteractionHandler.hpp>
36 : : #include <com/sun/star/embed/XStorage.hpp>
37 : : #include <com/sun/star/beans/PropertyValue.hpp>
38 : : #include <tools/link.hxx>
39 : : #include <tools/stream.hxx>
40 : : #include <tools/string.hxx>
41 : : #include <svl/lstner.hxx>
42 : :
43 : : #include <cppuhelper/weak.hxx>
44 : : #include <ucbhelper/content.hxx>
45 : :
46 : : #include <vector>
47 : :
48 : : class SvKeyValueIterator;
49 : : class SfxObjectFactory;
50 : : class SfxFilter;
51 : : class SfxMedium_Impl;
52 : : class INetURLObject;
53 : : class SfxObjectShell;
54 : : class SfxFrame;
55 : : class Timer;
56 : : class SfxItemSet;
57 : : class DateTime;
58 : :
59 : : #define XMULTISERVICEFACTORY ::com::sun::star::lang::XMultiServiceFactory
60 : : #define XSERVICEINFO ::com::sun::star::lang::XServiceInfo
61 : : #define OWEAKOBJECT ::cppu::OWeakObject
62 : : #define REFERENCE ::com::sun::star::uno::Reference
63 : : #define XINTERFACE ::com::sun::star::uno::XInterface
64 : : #define EXCEPTION ::com::sun::star::uno::Exception
65 : : #define RUNTIMEEXCEPTION ::com::sun::star::uno::RuntimeException
66 : : #define ANY ::com::sun::star::uno::Any
67 : :
68 : : class SFX2_DLLPUBLIC SfxMedium : public SvRefBase
69 : : {
70 : : SfxMedium_Impl* pImp;
71 : :
72 : : #if _SOLAR__PRIVATE
73 : : SAL_DLLPRIVATE void SetIsRemote_Impl();
74 : : SAL_DLLPRIVATE void CloseInStream_Impl();
75 : : SAL_DLLPRIVATE sal_Bool CloseOutStream_Impl();
76 : : SAL_DLLPRIVATE void CloseStreams_Impl();
77 : : DECL_DLLPRIVATE_STATIC_LINK( SfxMedium, UCBHdl_Impl, sal_uInt32 * );
78 : :
79 : : SAL_DLLPRIVATE void SetEncryptionDataToStorage_Impl();
80 : : #endif
81 : :
82 : : public:
83 : :
84 : : SfxMedium();
85 : : SfxMedium( const String &rName,
86 : : StreamMode nOpenMode,
87 : : const SfxFilter *pFilter = 0,
88 : : SfxItemSet *pSet = 0 );
89 : : //TODO: the next, non-defined overload is only there to
90 : : // detect uses of the above (String, StreamMode, etc.)
91 : : // overload from when it still had an additional third
92 : : // parameter sal_Bool bDirect, where now a leftover
93 : : // "false" or "sal_False" could be mistaken for a null
94 : : // pointer argument for the pFilter parameter; it can be
95 : : // removed once we are confident all old uses of the
96 : : // original overload have been adapted (in platform
97 : : // specific code etc.):
98 : : SfxMedium(String const &, StreamMode, void *)
99 : : /* = delete */;
100 : :
101 : : SfxMedium( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage,
102 : : const String& rBaseURL,
103 : : const SfxItemSet* pSet=0 );
104 : : SfxMedium( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArgs );
105 : :
106 : : ~SfxMedium();
107 : :
108 : : void UseInteractionHandler( sal_Bool );
109 : : ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >
110 : : GetInteractionHandler();
111 : :
112 : : void setStreamToLoadFrom(
113 : : const com::sun::star::uno::Reference<com::sun::star::io::XInputStream>& xInputStream,
114 : : sal_Bool bIsReadOnly);
115 : :
116 : : void SetLoadTargetFrame(SfxFrame* pFrame );
117 : : SfxFrame* GetLoadTargetFrame() const;
118 : :
119 : : void SetFilter(const SfxFilter *pFlt, sal_Bool bResetOrig = sal_False);
120 : : const SfxFilter* GetFilter() const;
121 : : const SfxFilter * GetOrigFilter( sal_Bool bNotCurrent = sal_False ) const;
122 : : const rtl::OUString& GetOrigURL() const;
123 : :
124 : : SfxItemSet * GetItemSet() const;
125 : : void Close();
126 : : void CloseAndRelease();
127 : : void ReOpen();
128 : : void CompleteReOpen();
129 : : const rtl::OUString& GetName() const;
130 : : const INetURLObject& GetURLObject() const;
131 : :
132 : : void CheckFileDate( const ::com::sun::star::util::DateTime& aInitDate );
133 : : sal_Bool DocNeedsFileDateCheck();
134 : : ::com::sun::star::util::DateTime GetInitFileDate( sal_Bool bIgnoreOldValue );
135 : :
136 : : ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent > GetContent() const;
137 : : const rtl::OUString& GetPhysicalName() const;
138 : : sal_Bool IsRemote();
139 : : sal_Bool IsOpen() const; // { return aStorage.Is() || pInStream; }
140 : : void DownLoad( const Link& aLink = Link());
141 : : void SetDoneLink( const Link& rLink );
142 : :
143 : : sal_uInt32 GetErrorCode() const;
144 : 13200 : sal_uInt32 GetError() const
145 : 13200 : { return ERRCODE_TOERROR(GetErrorCode()); }
146 : : sal_uInt32 GetLastStorageCreationState();
147 : :
148 : : void SetError( sal_uInt32 nError, const ::rtl::OUString& aLogMessage );
149 : :
150 : : void AddLog( const ::rtl::OUString& aMessage );
151 : :
152 : : void CloseInStream();
153 : : sal_Bool CloseOutStream();
154 : :
155 : : void CloseStorage();
156 : :
157 : : StreamMode GetOpenMode() const;
158 : : void SetOpenMode( StreamMode nStorOpen, sal_Bool bDontClose = sal_False );
159 : :
160 : : SvStream* GetInStream();
161 : : SvStream* GetOutStream();
162 : :
163 : : sal_Bool Commit();
164 : : sal_Bool IsStorage();
165 : :
166 : : sal_Int8 ShowLockedDocumentDialog( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aData, sal_Bool bIsLoading, sal_Bool bOwnLock );
167 : : bool LockOrigFileOnDemand( sal_Bool bLoading, sal_Bool bNoUI );
168 : : void UnlockFile( sal_Bool bReleaseLockStream );
169 : :
170 : : ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > GetStorage( sal_Bool bCreateTempIfNo = sal_True );
171 : : ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > GetOutputStorage();
172 : : void ResetError();
173 : : sal_Bool UsesCache() const;
174 : : void SetUsesCache( sal_Bool );
175 : : sal_Bool IsExpired() const;
176 : : void SetName( const String& rName, sal_Bool bSetOrigURL = sal_False );
177 : : sal_Bool IsAllowedForExternalBrowser() const;
178 : : long GetFileVersion() const;
179 : :
180 : : const com::sun::star::uno::Sequence < com::sun::star::util::RevisionTag >&
181 : : GetVersionList( bool _bNoReload = false );
182 : : sal_Bool IsReadOnly();
183 : :
184 : : // Whether the medium had originally been opened r/o, independent of later
185 : : // changes via SetOpenMode; used to keep track of the "true" state of the
186 : : // medium across toggles via SID_EDITDOC (which do change SetOpenMode):
187 : : bool IsOriginallyReadOnly() const;
188 : :
189 : : ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > GetInputStream();
190 : :
191 : : void CreateTempFile( sal_Bool bReplace = sal_True );
192 : : void CreateTempFileNoCopy();
193 : : ::rtl::OUString SwitchDocumentToTempFile();
194 : : sal_Bool SwitchDocumentToFile( const rtl::OUString& aURL );
195 : :
196 : : ::rtl::OUString GetBaseURL( bool bForSaving=false );
197 : :
198 : : #if _SOLAR__PRIVATE
199 : : SAL_DLLPRIVATE sal_Bool HasStorage_Impl() const;
200 : :
201 : : SAL_DLLPRIVATE void StorageBackup_Impl();
202 : : SAL_DLLPRIVATE ::rtl::OUString GetBackup_Impl();
203 : :
204 : : SAL_DLLPRIVATE ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > GetZipStorageToSign_Impl( sal_Bool bReadOnly = sal_True );
205 : : SAL_DLLPRIVATE void CloseZipStorage_Impl();
206 : :
207 : : // the storage that will be returned by the medium on GetStorage request
208 : : SAL_DLLPRIVATE void SetStorage_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xNewStorage );
209 : :
210 : : SAL_DLLPRIVATE ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > GetInputStream_Impl();
211 : : SAL_DLLPRIVATE void CloseAndReleaseStreams_Impl();
212 : : SAL_DLLPRIVATE sal_uInt16 AddVersion_Impl( com::sun::star::util::RevisionTag& rVersion );
213 : : SAL_DLLPRIVATE sal_Bool TransferVersionList_Impl( SfxMedium& rMedium );
214 : : SAL_DLLPRIVATE sal_Bool SaveVersionList_Impl( sal_Bool bUseXML );
215 : : SAL_DLLPRIVATE sal_Bool RemoveVersion_Impl( const ::rtl::OUString& rVersion );
216 : :
217 : : SAL_DLLPRIVATE void SetExpired_Impl( const DateTime& rDateTime );
218 : : SAL_DLLPRIVATE SvKeyValueIterator* GetHeaderAttributes_Impl();
219 : :
220 : : // Diese Protokolle liefern MIME Typen
221 : : SAL_DLLPRIVATE sal_Bool SupportsMIME_Impl() const;
222 : :
223 : : SAL_DLLPRIVATE void Init_Impl();
224 : : SAL_DLLPRIVATE void ForceSynchronStream_Impl( sal_Bool bSynchron );
225 : :
226 : : SAL_DLLPRIVATE void GetLockingStream_Impl();
227 : : SAL_DLLPRIVATE void GetMedium_Impl();
228 : : SAL_DLLPRIVATE sal_Bool TryDirectTransfer( const ::rtl::OUString& aURL, SfxItemSet& aTargetSet );
229 : : SAL_DLLPRIVATE void Transfer_Impl();
230 : : SAL_DLLPRIVATE void CreateFileStream();
231 : : SAL_DLLPRIVATE void SetUpdatePickList(sal_Bool);
232 : : SAL_DLLPRIVATE sal_Bool IsUpdatePickList() const;
233 : :
234 : : SAL_DLLPRIVATE void SetLongName(const rtl::OUString &rName);
235 : : SAL_DLLPRIVATE const rtl::OUString & GetLongName() const;
236 : : SAL_DLLPRIVATE ErrCode CheckOpenMode_Impl( sal_Bool bSilent, sal_Bool bAllowRO = sal_True );
237 : : SAL_DLLPRIVATE sal_Bool IsPreview_Impl();
238 : : SAL_DLLPRIVATE void ClearBackup_Impl();
239 : : SAL_DLLPRIVATE void Done_Impl( ErrCode );
240 : : SAL_DLLPRIVATE void SetPhysicalName_Impl(const rtl::OUString& rName);
241 : : SAL_DLLPRIVATE void CanDisposeStorage_Impl( sal_Bool bDisposeStorage );
242 : : SAL_DLLPRIVATE sal_Bool WillDisposeStorageOnClose_Impl();
243 : :
244 : : SAL_DLLPRIVATE void DoBackup_Impl();
245 : : SAL_DLLPRIVATE void DoInternalBackup_Impl( const ::ucbhelper::Content& aOriginalContent );
246 : : SAL_DLLPRIVATE void DoInternalBackup_Impl( const ::ucbhelper::Content& aOriginalContent,
247 : : const String& aPrefix,
248 : : const String& aExtension,
249 : : const String& aDestDir );
250 : :
251 : : SAL_DLLPRIVATE sal_Bool UseBackupToRestore_Impl( ::ucbhelper::Content& aOriginalContent,
252 : : const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >& xComEnv );
253 : :
254 : : SAL_DLLPRIVATE sal_Bool StorageCommit_Impl();
255 : :
256 : : SAL_DLLPRIVATE sal_Bool TransactedTransferForFS_Impl( const INetURLObject& aSource,
257 : : const INetURLObject& aDest,
258 : : const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >& xComEnv );
259 : :
260 : : SAL_DLLPRIVATE sal_Bool SignContents_Impl( sal_Bool bScriptingContent, const ::rtl::OUString& aODFVersion, sal_Bool bHasValidDocumentSignature );
261 : :
262 : : // the following two methods must be used and make sence only during saving currently
263 : : // TODO/LATER: in future the signature state should be controlled by the medium not by the document
264 : : // in this case the methods will be used generally, and might need to be renamed
265 : : SAL_DLLPRIVATE sal_uInt16 GetCachedSignatureState_Impl();
266 : : SAL_DLLPRIVATE void SetCachedSignatureState_Impl( sal_uInt16 nState );
267 : : #endif
268 : :
269 : : static com::sun::star::uno::Sequence < com::sun::star::util::RevisionTag > GetVersionList(
270 : : const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage );
271 : : static ::rtl::OUString CreateTempCopyWithExt( const ::rtl::OUString& aURL );
272 : : static sal_Bool CallApproveHandler( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& xHandler, ::com::sun::star::uno::Any aRequest, sal_Bool bAllowAbort );
273 : :
274 : : static sal_Bool SetWritableForUserOnly( const ::rtl::OUString& aURL );
275 : : static sal_uInt32 CreatePasswordToModifyHash( const ::rtl::OUString& aPasswd, sal_Bool bWriter );
276 : : };
277 : :
278 [ + - ][ + - ]: 523 : SV_DECL_IMPL_REF( SfxMedium )
[ + + ][ + + ]
[ + - ][ + - ]
[ + - ]
279 : :
280 : : typedef ::std::vector< SfxMedium* > SfxMediumList;
281 : :
282 : : #endif
283 : :
284 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|