tdf#153972 Fix color filter when cells have no content
[LibreOffice.git] / include / sot / storage.hxx
blobdd44b020694a050aae0c05cc17cf6f9430d0bc29
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::sun::star::embed { class XStorage; }
31 namespace com::sun::star::uno { class Any; }
32 namespace com::sun::star::uno { template <typename > class Reference; }
34 enum class SotClipboardFormatId : sal_uInt32;
36 class BaseStorageStream;
38 class SOT_DLLPUBLIC SotTempStream final : virtual public SvRefBase, public SvStream
40 friend class SotStorage;
42 virtual ~SotTempStream() override;
43 public:
44 SotTempStream(OUString const & rString, StreamMode = StreamMode::STD_READWRITE);
46 void CopyTo(SotTempStream * pDestStm);
49 class SOT_DLLPUBLIC SotStorageStream final : virtual public SotObject, public SvStream
51 friend class SotStorage;
52 BaseStorageStream * pOwnStm; // pointer to the own stream
54 virtual std::size_t GetData(void* pData, std::size_t nSize) override;
55 virtual std::size_t PutData(const void* pData, std::size_t nSize) override;
56 virtual sal_uInt64 SeekPos(sal_uInt64 nPos) override;
57 virtual void FlushData() override;
59 virtual ~SotStorageStream() override;
60 public:
61 SotStorageStream(BaseStorageStream *pBaseStream);
63 virtual void ResetError() override;
65 virtual void SetSize(sal_uInt64 nNewSize) override;
66 sal_uInt32 GetSize() const;
67 void Commit();
68 bool SetProperty(OUString const & rName, css::uno::Any const & rValue);
69 virtual sal_uInt64 TellEnd() override;
72 class BaseStorage;
73 class SOT_DLLPUBLIC SotStorage final : virtual public SotObject
75 friend class SotStorageStream;
77 BaseStorage* m_pOwnStg; // target storage
78 SvStream* m_pStorStm; // only for SDSTORAGES
79 ErrCode m_nError;
80 OUString m_aName;// name of the storage
81 bool m_bIsRoot; // e.g.: File Storage
82 bool m_bDelStm;
83 OString m_aKey; // aKey.Len != 0 -> encryption
84 sal_Int32 m_nVersion;
86 virtual ~SotStorage() override;
87 void CreateStorage(bool bUCBStorage, StreamMode);
88 public:
89 SotStorage(OUString const & rString, StreamMode eMode = StreamMode::STD_READWRITE);
90 SotStorage(bool bUCBStorage, const OUString & rString,
91 StreamMode = StreamMode::STD_READWRITE);
92 SotStorage(BaseStorage * pStorage);
93 SotStorage(SvStream & rStream);
94 SotStorage(bool bUCBStorage, SvStream & rStream);
95 SotStorage(SvStream * rStream, bool bDelete);
97 std::unique_ptr<SvMemoryStream> CreateMemoryStream();
99 static bool IsStorageFile(OUString const & rFileName);
100 static bool IsStorageFile(SvStream* pStream);
102 const OUString& GetName() const;
104 bool Validate();
106 const OString& GetKey() const { return m_aKey;}
108 void SetVersion(sal_Int32 nVersion)
110 m_nVersion = nVersion;
112 sal_Int32 GetVersion() const
114 return m_nVersion;
117 ErrCode GetError() const
119 return m_nError.IgnoreWarning();
121 void SetError(ErrCode nErrorCode)
123 if (m_nError == ERRCODE_NONE)
124 m_nError = nErrorCode;
127 void SignAsRoot(bool bRoot) { m_bIsRoot = bRoot; }
129 // own data sector
130 void SetClass(const SvGlobalName & rClass,
131 SotClipboardFormatId bOriginalClipFormat,
132 const OUString & rUserTypeName);
134 SvGlobalName GetClassName(); // type of data in the storage
135 SotClipboardFormatId GetFormat();
136 OUString GetUserName();
138 // list of all elements
139 void FillInfoList(SvStorageInfoList *) const;
140 bool CopyTo(SotStorage * pDestStg);
141 bool Commit();
143 // create stream with connection to Storage,
144 // more or less a Parent-Child relationship
145 tools::SvRef<SotStorageStream> OpenSotStream(const OUString & rEleName,
146 StreamMode = StreamMode::STD_READWRITE);
147 SotStorage* OpenSotStorage(const OUString & rEleName,
148 StreamMode = StreamMode::STD_READWRITE,
149 bool transacted = true);
151 // query whether Storage or Stream
152 bool IsStream( const OUString & rEleName ) const;
153 bool IsStorage( const OUString & rEleName ) const;
154 bool IsContained( const OUString & rEleName ) const;
155 // remove element
156 bool Remove(const OUString & rEleName);
157 bool CopyTo(const OUString & rEleName, SotStorage* pDest,
158 const OUString & rNewName);
160 bool IsOLEStorage() const;
161 static bool IsOLEStorage(const OUString & rFileName);
162 static bool IsOLEStorage(SvStream* pStream);
164 static SotStorage* OpenOLEStorage(css::uno::Reference<css::embed::XStorage> const & xStorage,
165 OUString const & rEleName, StreamMode = StreamMode::STD_READWRITE);
166 static SotClipboardFormatId GetFormatID(css::uno::Reference<css::embed::XStorage> const & xStorage);
167 static sal_Int32 GetVersion(css::uno::Reference<css::embed::XStorage> const & xStorage);
170 #endif // INCLUDED_SOT_STORAGE_HXX
172 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */