bump product version to 4.2.0.1
[LibreOffice.git] / include / sfx2 / docfile.hxx
blob33450a3895d767060be0f17e4f5adc08d2d510b7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SFX2_DOCFILE_HXX
21 #define INCLUDED_SFX2_DOCFILE_HXX
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 <cppuhelper/weak.hxx>
39 #include <rtl/ustring.hxx>
40 #include <svl/lstner.hxx>
41 #include <tools/link.hxx>
42 #include <tools/stream.hxx>
43 #include <ucbhelper/content.hxx>
44 #include <vector>
46 class SvKeyValueIterator;
47 class SfxObjectFactory;
48 class SfxFilter;
49 class SfxMedium_Impl;
50 class INetURLObject;
51 class SfxObjectShell;
52 class SfxFrame;
53 class Timer;
54 class SfxItemSet;
55 class DateTime;
57 class SFX2_DLLPUBLIC SfxMedium : public SvRefBase
59 SfxMedium_Impl* pImp;
61 SAL_DLLPRIVATE void SetIsRemote_Impl();
62 SAL_DLLPRIVATE void CloseInStream_Impl();
63 SAL_DLLPRIVATE sal_Bool CloseOutStream_Impl();
64 SAL_DLLPRIVATE void CloseStreams_Impl();
65 DECL_DLLPRIVATE_STATIC_LINK( SfxMedium, UCBHdl_Impl, sal_uInt32 * );
67 SAL_DLLPRIVATE void SetEncryptionDataToStorage_Impl();
69 public:
71 SfxMedium();
72 /**
73 * @param pSet Takes ownership
75 SfxMedium( const OUString &rName,
76 StreamMode nOpenMode,
77 const SfxFilter *pFilter = 0,
78 SfxItemSet *pSet = 0 );
79 /**
80 * @param pSet Takes ownership
82 SfxMedium( const OUString &rName,
83 const OUString &rReferer,
84 StreamMode nOpenMode,
85 const SfxFilter *pFilter = 0,
86 SfxItemSet *pSet = 0 );
88 /**
89 * @param pSet does NOT take ownership
91 SfxMedium( const css::uno::Reference< css::embed::XStorage >& xStorage,
92 const OUString& rBaseURL,
93 const SfxItemSet* pSet=0 );
94 /**
95 * @param pSet does NOT take ownership
97 SfxMedium( const css::uno::Reference< css::embed::XStorage >& xStorage,
98 const OUString& rBaseURL,
99 const OUString& rTypeName,
100 const SfxItemSet* pSet=0 );
101 SfxMedium( const css::uno::Sequence< css::beans::PropertyValue >& aArgs );
103 ~SfxMedium();
105 void UseInteractionHandler( sal_Bool );
106 css::uno::Reference< css::task::XInteractionHandler >
107 GetInteractionHandler();
109 void setStreamToLoadFrom(
110 const css::uno::Reference<css::io::XInputStream>& xInputStream,
111 sal_Bool bIsReadOnly);
113 void SetLoadTargetFrame(SfxFrame* pFrame );
114 SfxFrame* GetLoadTargetFrame() const;
116 void SetFilter(const SfxFilter *pFlt, sal_Bool bResetOrig = sal_False);
117 const SfxFilter* GetFilter() const;
118 const SfxFilter * GetOrigFilter( sal_Bool bNotCurrent = sal_False ) const;
119 const OUString& GetOrigURL() const;
121 SfxItemSet * GetItemSet() const;
122 void Close();
123 void CloseAndRelease();
124 void ReOpen();
125 void CompleteReOpen();
126 const OUString& GetName() const;
127 const INetURLObject& GetURLObject() const;
129 void CheckFileDate( const css::util::DateTime& aInitDate );
130 sal_Bool DocNeedsFileDateCheck();
131 css::util::DateTime GetInitFileDate( sal_Bool bIgnoreOldValue );
133 css::uno::Reference< css::ucb::XContent > GetContent() const;
134 const OUString& GetPhysicalName() const;
135 sal_Bool IsRemote();
136 sal_Bool IsOpen() const; // { return aStorage.Is() || pInStream; }
137 void DownLoad( const Link& aLink = Link());
138 void SetDoneLink( const Link& rLink );
140 sal_uInt32 GetErrorCode() const;
141 sal_uInt32 GetError() const
142 { return ERRCODE_TOERROR(GetErrorCode()); }
143 sal_uInt32 GetLastStorageCreationState();
145 void SetError( sal_uInt32 nError, const OUString& aLogMessage );
147 void AddLog( const OUString& aMessage );
149 void CloseInStream();
150 sal_Bool CloseOutStream();
152 void CloseStorage();
154 StreamMode GetOpenMode() const;
155 void SetOpenMode( StreamMode nStorOpen, sal_Bool bDontClose = sal_False );
157 SvStream* GetInStream();
158 SvStream* GetOutStream();
160 sal_Bool Commit();
161 sal_Bool IsStorage();
163 sal_Int8 ShowLockedDocumentDialog( const css::uno::Sequence< OUString >& aData, sal_Bool bIsLoading, sal_Bool bOwnLock );
164 void LockOrigFileOnDemand( sal_Bool bLoading, sal_Bool bNoUI );
165 void UnlockFile( sal_Bool bReleaseLockStream );
167 css::uno::Reference< css::embed::XStorage > GetStorage( sal_Bool bCreateTempIfNo = sal_True );
168 css::uno::Reference< css::embed::XStorage > GetOutputStorage();
169 void ResetError();
170 sal_Bool UsesCache() const;
171 void SetUsesCache( sal_Bool );
172 sal_Bool IsExpired() const;
173 void SetName( const OUString& rName, sal_Bool bSetOrigURL = sal_False );
174 sal_Bool IsAllowedForExternalBrowser() const;
175 long GetFileVersion() const;
177 const css::uno::Sequence < css::util::RevisionTag >&
178 GetVersionList( bool _bNoReload = false );
179 sal_Bool IsReadOnly();
181 // Whether the medium had originally been opened r/o, independent of later
182 // changes via SetOpenMode; used to keep track of the "true" state of the
183 // medium across toggles via SID_EDITDOC (which do change SetOpenMode):
184 bool IsOriginallyReadOnly() const;
186 css::uno::Reference< css::io::XInputStream > GetInputStream();
188 void CreateTempFile( sal_Bool bReplace = sal_True );
189 void CreateTempFileNoCopy();
190 OUString SwitchDocumentToTempFile();
191 sal_Bool SwitchDocumentToFile( const OUString& aURL );
193 OUString GetBaseURL( bool bForSaving=false );
194 void SetInCheckIn( bool bInCheckIn );
195 bool IsInCheckIn( );
197 SAL_DLLPRIVATE sal_Bool HasStorage_Impl() const;
199 SAL_DLLPRIVATE void StorageBackup_Impl();
200 SAL_DLLPRIVATE OUString GetBackup_Impl();
202 SAL_DLLPRIVATE css::uno::Reference< css::embed::XStorage > GetZipStorageToSign_Impl( sal_Bool bReadOnly = sal_True );
203 SAL_DLLPRIVATE void CloseZipStorage_Impl();
205 // the storage that will be returned by the medium on GetStorage request
206 SAL_DLLPRIVATE void SetStorage_Impl( const css::uno::Reference< css::embed::XStorage >& xNewStorage );
208 SAL_DLLPRIVATE css::uno::Reference< css::io::XInputStream > GetInputStream_Impl();
209 SAL_DLLPRIVATE void CloseAndReleaseStreams_Impl();
210 SAL_DLLPRIVATE sal_uInt16 AddVersion_Impl( css::util::RevisionTag& rVersion );
211 SAL_DLLPRIVATE sal_Bool TransferVersionList_Impl( SfxMedium& rMedium );
212 SAL_DLLPRIVATE sal_Bool SaveVersionList_Impl( sal_Bool bUseXML );
213 SAL_DLLPRIVATE sal_Bool RemoveVersion_Impl( const OUString& rVersion );
215 SAL_DLLPRIVATE void SetExpired_Impl( const DateTime& rDateTime );
216 SAL_DLLPRIVATE SvKeyValueIterator* GetHeaderAttributes_Impl();
218 // Diese Protokolle liefern MIME Typen
219 SAL_DLLPRIVATE sal_Bool SupportsMIME_Impl() const;
221 SAL_DLLPRIVATE void Init_Impl();
222 SAL_DLLPRIVATE void ForceSynchronStream_Impl( sal_Bool bSynchron );
224 SAL_DLLPRIVATE void GetLockingStream_Impl();
225 SAL_DLLPRIVATE void GetMedium_Impl();
226 SAL_DLLPRIVATE sal_Bool TryDirectTransfer( const OUString& aURL, SfxItemSet& aTargetSet );
227 SAL_DLLPRIVATE void Transfer_Impl();
228 SAL_DLLPRIVATE void CreateFileStream();
229 SAL_DLLPRIVATE void SetUpdatePickList(sal_Bool);
230 SAL_DLLPRIVATE sal_Bool IsUpdatePickList() const;
232 SAL_DLLPRIVATE void SetLongName(const OUString &rName);
233 SAL_DLLPRIVATE const OUString & GetLongName() const;
234 SAL_DLLPRIVATE ErrCode CheckOpenMode_Impl( sal_Bool bSilent, sal_Bool bAllowRO = sal_True );
235 SAL_DLLPRIVATE sal_Bool IsPreview_Impl();
236 SAL_DLLPRIVATE void ClearBackup_Impl();
237 SAL_DLLPRIVATE void Done_Impl( ErrCode );
238 SAL_DLLPRIVATE void SetPhysicalName_Impl(const OUString& rName);
239 SAL_DLLPRIVATE void CanDisposeStorage_Impl( sal_Bool bDisposeStorage );
240 SAL_DLLPRIVATE sal_Bool WillDisposeStorageOnClose_Impl();
242 SAL_DLLPRIVATE void DoBackup_Impl();
243 SAL_DLLPRIVATE void DoInternalBackup_Impl( const ::ucbhelper::Content& aOriginalContent );
244 SAL_DLLPRIVATE void DoInternalBackup_Impl( const ::ucbhelper::Content& aOriginalContent,
245 const OUString& aPrefix,
246 const OUString& aExtension,
247 const OUString& aDestDir );
249 SAL_DLLPRIVATE sal_Bool UseBackupToRestore_Impl( ::ucbhelper::Content& aOriginalContent,
250 const css::uno::Reference< css::ucb::XCommandEnvironment >& xComEnv );
252 SAL_DLLPRIVATE sal_Bool StorageCommit_Impl();
254 SAL_DLLPRIVATE sal_Bool TransactedTransferForFS_Impl( const INetURLObject& aSource,
255 const INetURLObject& aDest,
256 const css::uno::Reference< css::ucb::XCommandEnvironment >& xComEnv );
258 SAL_DLLPRIVATE sal_Bool SignContents_Impl( sal_Bool bScriptingContent, const OUString& aODFVersion, sal_Bool bHasValidDocumentSignature );
260 // the following two methods must be used and make sence only during saving currently
261 // TODO/LATER: in future the signature state should be controlled by the medium not by the document
262 // in this case the methods will be used generally, and might need to be renamed
263 SAL_DLLPRIVATE sal_uInt16 GetCachedSignatureState_Impl();
264 SAL_DLLPRIVATE void SetCachedSignatureState_Impl( sal_uInt16 nState );
266 static css::uno::Sequence < css::util::RevisionTag > GetVersionList(
267 const css::uno::Reference< css::embed::XStorage >& xStorage );
268 static OUString CreateTempCopyWithExt( const OUString& aURL );
269 static sal_Bool CallApproveHandler( const css::uno::Reference< css::task::XInteractionHandler >& xHandler, css::uno::Any aRequest, sal_Bool bAllowAbort );
271 static sal_Bool SetWritableForUserOnly( const OUString& aURL );
272 static sal_uInt32 CreatePasswordToModifyHash( const OUString& aPasswd, sal_Bool bWriter );
275 SV_DECL_IMPL_REF( SfxMedium )
277 typedef ::std::vector< SfxMedium* > SfxMediumList;
279 #endif
281 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */