bump product version to 6.3.0.0.beta1
[LibreOffice.git] / include / sot / storage.hxx
blobbea06931d089907537fad2de83c11457d6982d80
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 <sot/object.hxx>
24 #include <tools/stream.hxx>
25 #include <tools/globname.hxx>
26 #include <vcl/errcode.hxx>
27 #include <sot/storinfo.hxx>
28 #include <sot/sotdllapi.h>
30 namespace com { namespace sun { namespace star { namespace embed { class XStorage; } } } }
31 namespace com { namespace sun { namespace star { namespace uno { class Any; } } } }
32 namespace com { namespace sun { namespace star { namespace uno { template <typename > class Reference; } } } }
34 enum class SotClipboardFormatId : sal_uInt32;
36 class BaseStorageStream;
38 class SOT_DLLPUBLIC SotStorageStream : virtual public SotObject, public SvStream
40 friend class SotStorage;
41 BaseStorageStream * pOwnStm; // pointer to the own stream
42 protected:
43 virtual std::size_t GetData(void* pData, std::size_t nSize) override;
44 virtual std::size_t PutData(const void* pData, std::size_t nSize) override;
45 virtual sal_uInt64 SeekPos(sal_uInt64 nPos) override;
46 virtual void FlushData() override;
48 virtual ~SotStorageStream() override;
49 public:
50 SotStorageStream(OUString const & rString,
51 StreamMode = StreamMode::STD_READWRITE);
52 SotStorageStream(BaseStorageStream *pBaseStream);
54 virtual void ResetError() override;
56 virtual void SetSize(sal_uInt64 nNewSize) override;
57 sal_uInt32 GetSize() const;
58 void CopyTo(SotStorageStream * pDestStm);
59 bool Commit();
60 bool SetProperty(OUString const & rName, css::uno::Any const & rValue);
61 virtual sal_uInt64 TellEnd() override;
64 class BaseStorage;
65 class SOT_DLLPUBLIC SotStorage : virtual public SotObject
67 friend class SotStorageStream;
69 BaseStorage* m_pOwnStg; // target storage
70 SvStream* m_pStorStm; // only for SDSTORAGES
71 ErrCode m_nError;
72 OUString m_aName;// name of the storage
73 bool m_bIsRoot; // e.g.: File Storage
74 bool m_bDelStm;
75 OString m_aKey; // aKey.Len != 0 -> encryption
76 sal_Int32 m_nVersion;
78 protected:
79 virtual ~SotStorage() override;
80 void CreateStorage(bool bUCBStorage, StreamMode);
81 public:
82 SotStorage(OUString const & rString, StreamMode eMode = StreamMode::STD_READWRITE);
83 SotStorage(bool bUCBStorage, const OUString & rString,
84 StreamMode = StreamMode::STD_READWRITE);
85 SotStorage(BaseStorage * pStorage);
86 SotStorage(SvStream & rStream);
87 SotStorage(bool bUCBStorage, SvStream & rStream);
88 SotStorage(SvStream * rStream, bool bDelete);
90 std::unique_ptr<SvMemoryStream> CreateMemoryStream();
92 static bool IsStorageFile(OUString const & rFileName);
93 static bool IsStorageFile(SvStream* pStream);
95 const OUString& GetName() const;
97 bool Validate();
99 const OString& GetKey() const { return m_aKey;}
101 void SetVersion(sal_Int32 nVersion)
103 m_nVersion = nVersion;
105 sal_Int32 GetVersion() const
107 return m_nVersion;
110 ErrCode GetError() const
112 return m_nError.IgnoreWarning();
114 void SetError(ErrCode nErrorCode)
116 if (m_nError == ERRCODE_NONE)
117 m_nError = nErrorCode;
120 void SignAsRoot(bool bRoot) { m_bIsRoot = bRoot; }
122 // own data sector
123 void SetClass(const SvGlobalName & rClass,
124 SotClipboardFormatId bOriginalClipFormat,
125 const OUString & rUserTypeName);
127 SvGlobalName GetClassName(); // type of data in the storage
128 SotClipboardFormatId GetFormat();
129 OUString GetUserName();
131 // list of all elements
132 void FillInfoList(SvStorageInfoList *) const;
133 bool CopyTo(SotStorage * pDestStg);
134 bool Commit();
136 // create stream with connection to Storage,
137 // more or less a Parent-Child relationship
138 SotStorageStream* OpenSotStream(const OUString & rEleName,
139 StreamMode = StreamMode::STD_READWRITE);
140 SotStorage* OpenSotStorage(const OUString & rEleName,
141 StreamMode = StreamMode::STD_READWRITE,
142 bool transacted = true);
144 // query whether Storage or Stream
145 bool IsStream( const OUString & rEleName ) const;
146 bool IsStorage( const OUString & rEleName ) const;
147 bool IsContained( const OUString & rEleName ) const;
148 // remove element
149 bool Remove(const OUString & rEleName);
150 bool CopyTo(const OUString & rEleName, SotStorage* pDest,
151 const OUString & rNewName);
153 bool IsOLEStorage() const;
154 static bool IsOLEStorage(const OUString & rFileName);
155 static bool IsOLEStorage(SvStream* pStream);
157 static SotStorage* OpenOLEStorage(css::uno::Reference<css::embed::XStorage> const & xStorage,
158 OUString const & rEleName, StreamMode = StreamMode::STD_READWRITE);
159 static SotClipboardFormatId GetFormatID(css::uno::Reference<css::embed::XStorage> const & xStorage);
160 static sal_Int32 GetVersion(css::uno::Reference<css::embed::XStorage> const & xStorage);
163 #endif // INCLUDED_SOT_STORAGE_HXX
165 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */