update emoji autocorrect entries from po-files
[LibreOffice.git] / include / sot / storage.hxx
blob0850bde76323a74521163b327d08da21970eda97
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_SOT_STORAGE_HXX
21 #define INCLUDED_SOT_STORAGE_HXX
23 #include <com/sun/star/uno/Any.hxx>
24 #include <com/sun/star/uno/Reference.h>
26 #include <com/sun/star/io/XInputStream.hpp>
27 #include <com/sun/star/embed/XStorage.hpp>
28 #include <sot/object.hxx>
29 #include <sot/factory.hxx>
30 #include <tools/stream.hxx>
31 #include <tools/errcode.hxx>
32 #include <sot/storinfo.hxx>
33 #include <sot/sotdllapi.h>
35 class SotStorage;
37 enum class SotClipboardFormatId : sal_uLong;
39 /*************************************************************************
40 *************************************************************************/
41 class SotStorage;
42 class BaseStorageStream;
43 class SOT_DLLPUBLIC SotStorageStream : virtual public SotObject, public SvStream
45 friend class SotStorage;
46 BaseStorageStream * pOwnStm; // pointer to the own stream
47 protected:
48 virtual sal_uLong GetData( void* pData, sal_uLong nSize ) SAL_OVERRIDE;
49 virtual sal_uLong PutData( const void* pData, sal_uLong nSize ) SAL_OVERRIDE;
50 virtual sal_uInt64 SeekPos(sal_uInt64 nPos) SAL_OVERRIDE;
51 virtual void FlushData() SAL_OVERRIDE;
52 virtual ~SotStorageStream();
53 public:
54 SotStorageStream( const OUString &,
55 StreamMode = STREAM_STD_READWRITE );
56 SotStorageStream( BaseStorageStream *pStm );
57 SotStorageStream();
59 private:
60 static SotFactory ** GetFactoryAdress()
61 { return &(SOTDATA()->pSotStorageStreamFactory); }
62 public:
63 static void * CreateInstance( SotObject ** = NULL );
64 static SotFactory * ClassFactory();
65 virtual const SotFactory * GetSvFactory() const SAL_OVERRIDE;
66 virtual void * Cast( const SotFactory * ) SAL_OVERRIDE;
68 virtual void ResetError() SAL_OVERRIDE;
70 virtual void SetSize( sal_uInt64 nNewSize ) SAL_OVERRIDE;
71 sal_uInt32 GetSize() const;
72 bool CopyTo( SotStorageStream * pDestStm );
73 bool Commit();
74 bool SetProperty( const OUString& rName, const ::com::sun::star::uno::Any& rValue );
75 virtual sal_uInt64 remainingSize() SAL_OVERRIDE;
78 namespace ucbhelper
80 class Content;
83 class BaseStorage;
84 class UNOStorageHolder;
85 class SOT_DLLPUBLIC SotStorage : virtual public SotObject
87 friend class SotStorageStream;
89 BaseStorage * m_pOwnStg; // target storage
90 SvStream * m_pStorStm; // only for SDSTORAGES
91 sal_uLong m_nError;
92 OUString m_aName; // name of the storage
93 bool m_bIsRoot; // e.g.: File Storage
94 bool m_bDelStm;
95 OString m_aKey; // aKey.Len != 0 -> encryption
96 long m_nVersion;
98 protected:
99 virtual ~SotStorage();
100 void CreateStorage( bool bUCBStorage, StreamMode, bool transacted );
101 public:
102 SotStorage( const OUString &,
103 StreamMode = STREAM_STD_READWRITE,
104 bool transacted = false );
105 SotStorage( bool bUCBStorage, const OUString &,
106 StreamMode = STREAM_STD_READWRITE );
107 SotStorage( BaseStorage * );
108 SotStorage( SvStream & rStm );
109 SotStorage( bool bUCBStorage, SvStream & rStm );
110 SotStorage( SvStream * pStm, bool bDelete );
111 SotStorage();
113 private:
114 static SotFactory ** GetFactoryAdress()
115 { return &(SOTDATA()->pSotStorageFactory); }
116 public:
117 static void * CreateInstance( SotObject ** = NULL );
118 static SotFactory * ClassFactory();
119 virtual const SotFactory * GetSvFactory() const SAL_OVERRIDE;
120 virtual void * Cast( const SotFactory * ) SAL_OVERRIDE;
122 SvMemoryStream * CreateMemoryStream();
124 static bool IsStorageFile( const OUString & rFileName );
125 static bool IsStorageFile( SvStream* pStream );
127 const OUString& GetName() const;
129 bool Validate();
131 const OString& GetKey() const { return m_aKey;}
133 void SetVersion( long nVers )
135 m_nVersion = nVers;
137 long GetVersion() const
139 return m_nVersion;
142 sal_uLong GetErrorCode() const { return m_nError; }
143 sal_uLong GetError() const { return ERRCODE_TOERROR(m_nError); }
144 void SetError( sal_uLong nErrorCode )
146 if( m_nError == SVSTREAM_OK )
147 m_nError = nErrorCode;
150 bool IsRoot() const { return m_bIsRoot; }
151 void SignAsRoot( bool b = true ) { m_bIsRoot = b; }
152 void SetDeleteStream( bool bDelete ) { m_bDelStm = bDelete; }
154 // own data sector
155 void SetClass( const SvGlobalName & rClass,
156 SotClipboardFormatId bOriginalClipFormat,
157 const OUString & rUserTypeName );
158 SvGlobalName GetClassName(); // type of data in the storage
159 SotClipboardFormatId GetFormat();
160 OUString GetUserName();
162 // list of all elements
163 void FillInfoList( SvStorageInfoList * ) const;
164 bool CopyTo( SotStorage * pDestStg );
165 bool Commit();
167 // create stream with connection to Storage,
168 // more or less a Parent-Child relationship
169 SotStorageStream * OpenSotStream( const OUString & rEleName,
170 StreamMode = STREAM_STD_READWRITE );
171 SotStorage * OpenSotStorage( const OUString & rEleName,
172 StreamMode = STREAM_STD_READWRITE,
173 bool transacted = true );
174 // query whether Storage or Stream
175 bool IsStream( const OUString & rEleName ) const;
176 bool IsStorage( const OUString & rEleName ) const;
177 bool IsContained( const OUString & rEleName ) const;
178 // remove element
179 bool Remove( const OUString & rEleName );
180 bool CopyTo( const OUString & rEleName, SotStorage * pDest,
181 const OUString & rNewName );
183 bool IsOLEStorage() const;
184 static bool IsOLEStorage( const OUString & rFileName );
185 static bool IsOLEStorage( SvStream* pStream );
187 static SotStorage* OpenOLEStorage( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& xStorage,
188 const OUString& rEleName, StreamMode = STREAM_STD_READWRITE );
189 static SotClipboardFormatId GetFormatID( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& xStorage );
190 static sal_Int32 GetVersion( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& xStorage );
193 #endif // _SVSTOR_HXX
195 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */