LCOV - code coverage report
Current view: top level - libreoffice/sfx2/inc/sfx2 - docfile.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 3 3 100.0 %
Date: 2012-12-27 Functions: 2 10 20.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10