tdf#130857 qt weld: Implement QtInstanceWidget::get_text_height
[LibreOffice.git] / include / sot / storage.hxx
blob39246b779a2937767bd87e72fe51e0cf2473dfc6
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 <comphelper/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 namespace SotTempStream
40 SOT_DLLPUBLIC std::unique_ptr<SvStream> Create(OUString const & rString, StreamMode = StreamMode::STD_READWRITE);
43 class SOT_DLLPUBLIC SotStorageStream final : virtual public SotObject, public SvStream
45 friend class SotStorage;
46 BaseStorageStream * pOwnStm; // pointer to the own stream
48 virtual std::size_t GetData(void* pData, std::size_t nSize) override;
49 virtual std::size_t PutData(const void* pData, std::size_t nSize) override;
50 virtual sal_uInt64 SeekPos(sal_uInt64 nPos) override;
51 virtual void FlushData() override;
53 virtual ~SotStorageStream() override;
54 public:
55 SotStorageStream(BaseStorageStream *pBaseStream);
57 virtual void ResetError() override;
59 virtual void SetSize(sal_uInt64 nNewSize) override;
60 sal_uInt32 GetSize() const;
61 void Commit();
62 bool SetProperty(OUString const & rName, css::uno::Any const & rValue);
63 virtual sal_uInt64 TellEnd() override;
66 class BaseStorage;
67 class SOT_DLLPUBLIC SotStorage final : virtual public SotObject
69 friend class SotStorageStream;
71 BaseStorage* m_pOwnStg; // target storage
72 SvStream* m_pStorStm; // only for SDSTORAGES
73 ErrCode m_nError;
74 OUString m_aName;// name of the storage
75 bool m_bIsRoot; // e.g.: File Storage
76 bool m_bDelStm;
77 OString m_aKey; // aKey.Len != 0 -> encryption
78 sal_Int32 m_nVersion;
80 virtual ~SotStorage() override;
81 void CreateStorage(bool bUCBStorage, StreamMode);
82 public:
83 SotStorage(OUString const & rString, StreamMode eMode = StreamMode::STD_READWRITE);
84 SotStorage(bool bUCBStorage, const OUString & rString,
85 StreamMode = StreamMode::STD_READWRITE);
86 SotStorage(BaseStorage * pStorage);
87 SotStorage(SvStream & rStream);
88 SotStorage(bool bUCBStorage, SvStream & rStream);
89 SotStorage(SvStream * rStream, bool bDelete);
91 std::unique_ptr<SvMemoryStream> CreateMemoryStream();
93 static bool IsStorageFile(OUString const & rFileName);
94 static bool IsStorageFile(SvStream* pStream);
96 const OUString& GetName() const;
98 bool Validate();
100 const OString& GetKey() const { return m_aKey;}
102 void SetVersion(sal_Int32 nVersion)
104 m_nVersion = nVersion;
106 sal_Int32 GetVersion() const
108 return m_nVersion;
111 ErrCode GetError() const
113 return m_nError.IgnoreWarning();
115 void SetError(ErrCode nErrorCode)
117 if (m_nError == ERRCODE_NONE)
118 m_nError = nErrorCode;
121 void SignAsRoot(bool bRoot) { m_bIsRoot = bRoot; }
123 // own data sector
124 void SetClass(const SvGlobalName & rClass,
125 SotClipboardFormatId bOriginalClipFormat,
126 const OUString & rUserTypeName);
128 SvGlobalName GetClassName(); // type of data in the storage
129 SotClipboardFormatId GetFormat();
130 OUString GetUserName();
132 // list of all elements
133 void FillInfoList(SvStorageInfoList *) const;
134 bool CopyTo(SotStorage * pDestStg);
135 bool Commit();
137 // create stream with connection to Storage,
138 // more or less a Parent-Child relationship
139 rtl::Reference<SotStorageStream> OpenSotStream(const OUString & rEleName,
140 StreamMode = StreamMode::STD_READWRITE);
141 rtl::Reference<SotStorage> OpenSotStorage(const OUString & rEleName,
142 StreamMode = StreamMode::STD_READWRITE,
143 bool transacted = true);
145 // query whether Storage or Stream
146 bool IsStream( const OUString & rEleName ) const;
147 bool IsStorage( const OUString & rEleName ) const;
148 bool IsContained( const OUString & rEleName ) const;
149 // remove element
150 bool Remove(const OUString & rEleName);
151 bool CopyTo(const OUString & rEleName, SotStorage* pDest,
152 const OUString & rNewName);
154 bool IsOLEStorage() const;
155 static bool IsOLEStorage(const OUString & rFileName);
156 static bool IsOLEStorage(SvStream* pStream);
158 static rtl::Reference<SotStorage> OpenOLEStorage(css::uno::Reference<css::embed::XStorage> const & xStorage,
159 OUString const & rEleName, StreamMode = StreamMode::STD_READWRITE);
160 static SotClipboardFormatId GetFormatID(css::uno::Reference<css::embed::XStorage> const & xStorage);
161 static sal_Int32 GetVersion(css::uno::Reference<css::embed::XStorage> const & xStorage);
164 #endif // INCLUDED_SOT_STORAGE_HXX
166 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */