android: Update app-specific/MIME type icons
[LibreOffice.git] / writerfilter / source / ooxml / OOXMLPropertySet.hxx
blob2c851ab53823cb85dd29c4323ae14cb635713482
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 .
19 #pragma once
21 #include <vector>
22 #include "OOXMLBinaryObjectReference.hxx"
23 #include <com/sun/star/embed/XEmbeddedObject.hpp>
24 #include <dmapper/resourcemodel.hxx>
26 namespace writerfilter::ooxml
28 class OOXMLValue : public Value
30 public:
31 typedef tools::SvRef<OOXMLValue> Pointer_t;
32 OOXMLValue();
33 virtual ~OOXMLValue() override;
35 OOXMLValue(OOXMLValue const&) = default;
36 OOXMLValue(OOXMLValue&&) = default;
37 OOXMLValue& operator=(OOXMLValue const&) = default;
38 OOXMLValue& operator=(OOXMLValue&&) = default;
40 virtual int getInt() const override;
42 virtual OUString getString() const override;
43 virtual css::uno::Any getAny() const override;
44 virtual writerfilter::Reference<Properties>::Pointer_t getProperties() override;
45 virtual writerfilter::Reference<BinaryObj>::Pointer_t getBinary() override;
46 #ifdef DBG_UTIL
47 virtual std::string toString() const override;
48 #endif
49 virtual OOXMLValue* clone() const;
52 class OOXMLProperty final : public Sprm
54 public:
55 typedef tools::SvRef<OOXMLProperty> Pointer_t;
56 enum Type_t
58 SPRM,
59 ATTRIBUTE
62 private:
63 Id mId;
64 mutable OOXMLValue::Pointer_t mpValue;
65 Type_t meType;
67 public:
68 OOXMLProperty(Id id, OOXMLValue::Pointer_t pValue, Type_t eType);
69 OOXMLProperty(const OOXMLProperty& rSprm) = delete;
70 virtual ~OOXMLProperty() override;
72 sal_uInt32 getId() const override;
73 Value::Pointer_t getValue() override;
74 writerfilter::Reference<Properties>::Pointer_t getProps() override;
75 #ifdef DBG_UTIL
76 std::string getName() const override;
77 std::string toString() const override;
78 #endif
79 void resolve(Properties& rProperties);
82 class OOXMLBinaryValue final : public OOXMLValue
84 mutable OOXMLBinaryObjectReference::Pointer_t mpBinaryObj;
86 public:
87 explicit OOXMLBinaryValue(OOXMLBinaryObjectReference::Pointer_t pBinaryObj);
88 virtual ~OOXMLBinaryValue() override;
90 virtual writerfilter::Reference<BinaryObj>::Pointer_t getBinary() override;
91 #ifdef DBG_UTIL
92 virtual std::string toString() const override;
93 #endif
94 virtual OOXMLValue* clone() const override;
97 class OOXMLBooleanValue final : public OOXMLValue
99 bool mbValue;
100 explicit OOXMLBooleanValue(bool bValue);
102 public:
103 static OOXMLValue::Pointer_t const& Create(bool bValue);
104 static OOXMLValue::Pointer_t const& Create(std::string_view pValue);
106 virtual ~OOXMLBooleanValue() override;
108 OOXMLBooleanValue(OOXMLBooleanValue const&) = default;
109 OOXMLBooleanValue(OOXMLBooleanValue&&) = default;
110 OOXMLBooleanValue& operator=(OOXMLBooleanValue const&) = delete; // due to const mbValue
111 OOXMLBooleanValue& operator=(OOXMLBooleanValue&&) = delete; // due to const mbValue
113 virtual int getInt() const override;
114 virtual css::uno::Any getAny() const override;
115 #ifdef DBG_UTIL
116 virtual std::string toString() const override;
117 #endif
118 virtual OOXMLValue* clone() const override;
121 class OOXMLStringValue final : public OOXMLValue
123 OUString mStr;
125 public:
126 explicit OOXMLStringValue(OUString sStr);
127 virtual ~OOXMLStringValue() override;
129 OOXMLStringValue(OOXMLStringValue const&) = default;
130 OOXMLStringValue(OOXMLStringValue&&) = default;
131 OOXMLStringValue& operator=(OOXMLStringValue const&) = delete; // due to const mStr
132 OOXMLStringValue& operator=(OOXMLStringValue&&) = delete; // due to const mStr
134 virtual css::uno::Any getAny() const override;
135 virtual OUString getString() const override;
136 #ifdef DBG_UTIL
137 virtual std::string toString() const override;
138 #endif
139 virtual OOXMLValue* clone() const override;
142 class OOXMLInputStreamValue final : public OOXMLValue
144 css::uno::Reference<css::io::XInputStream> mxInputStream;
146 public:
147 explicit OOXMLInputStreamValue(css::uno::Reference<css::io::XInputStream> xInputStream);
148 virtual ~OOXMLInputStreamValue() override;
150 virtual css::uno::Any getAny() const override;
151 #ifdef DBG_UTIL
152 virtual std::string toString() const override;
153 #endif
154 virtual OOXMLValue* clone() const override;
157 class OOXMLPropertySet final : public writerfilter::Reference<Properties>
159 public:
160 typedef std::vector<OOXMLProperty::Pointer_t> OOXMLProperties_t;
161 typedef tools::SvRef<OOXMLPropertySet> Pointer_t;
163 private:
164 OOXMLProperties_t mProperties;
165 void add(const OOXMLProperty::Pointer_t& pProperty);
167 public:
168 OOXMLPropertySet();
169 virtual ~OOXMLPropertySet() override;
171 OOXMLPropertySet(OOXMLPropertySet const&) = default;
172 OOXMLPropertySet(OOXMLPropertySet&&) = default;
173 OOXMLPropertySet& operator=(OOXMLPropertySet const&) = default;
174 OOXMLPropertySet& operator=(OOXMLPropertySet&&) = default;
176 void resolve(Properties& rHandler) override;
177 void add(Id id, const OOXMLValue::Pointer_t& pValue, OOXMLProperty::Type_t eType);
178 void add(const OOXMLPropertySet::Pointer_t& pPropertySet);
179 OOXMLPropertySet* clone() const;
181 OOXMLProperties_t::iterator begin();
182 OOXMLProperties_t::iterator end();
183 OOXMLProperties_t::const_iterator begin() const;
184 OOXMLProperties_t::const_iterator end() const;
186 #ifdef DBG_UTIL
187 std::string toString();
188 #endif
191 class OOXMLValue;
193 class OOXMLTable final : public writerfilter::Reference<Table>
195 public:
196 typedef tools::SvRef<OOXMLValue> ValuePointer_t;
197 OOXMLTable();
198 virtual ~OOXMLTable() override;
200 OOXMLTable(OOXMLTable const&) = default;
201 OOXMLTable(OOXMLTable&&) = default;
202 OOXMLTable& operator=(OOXMLTable const&) = default;
203 OOXMLTable& operator=(OOXMLTable&&) = default;
205 void resolve(Table& rTable) override;
206 void add(const ValuePointer_t& pPropertySet);
207 OOXMLTable* clone() const;
209 private:
210 typedef std::vector<ValuePointer_t> PropertySets_t;
211 PropertySets_t mPropertySets;
214 class OOXMLPropertySetValue final : public OOXMLValue
216 OOXMLPropertySet::Pointer_t mpPropertySet;
218 public:
219 explicit OOXMLPropertySetValue(OOXMLPropertySet::Pointer_t pPropertySet);
220 virtual ~OOXMLPropertySetValue() override;
222 OOXMLPropertySetValue(OOXMLPropertySetValue const&) = default;
223 OOXMLPropertySetValue(OOXMLPropertySetValue&&) = default;
224 OOXMLPropertySetValue& operator=(OOXMLPropertySetValue const&)
225 = delete; // due to const mpPropertySet
226 OOXMLPropertySetValue& operator=(OOXMLPropertySetValue&&)
227 = delete; // due to const mpPropertySet
229 virtual writerfilter::Reference<Properties>::Pointer_t getProperties() override;
230 #ifdef DBG_UTIL
231 virtual std::string toString() const override;
232 #endif
233 virtual OOXMLValue* clone() const override;
236 class OOXMLIntegerValue final : public OOXMLValue
238 sal_Int32 mnValue;
239 explicit OOXMLIntegerValue(sal_Int32 nValue);
241 public:
242 static OOXMLValue::Pointer_t Create(sal_Int32 nValue);
243 virtual ~OOXMLIntegerValue() override;
245 OOXMLIntegerValue(OOXMLIntegerValue const&) = default;
246 OOXMLIntegerValue(OOXMLIntegerValue&&) = default;
247 OOXMLIntegerValue& operator=(OOXMLIntegerValue const&) = delete; // due to const mnValue
248 OOXMLIntegerValue& operator=(OOXMLIntegerValue&&) = delete; // due to const mnValue
250 virtual int getInt() const override;
251 virtual css::uno::Any getAny() const override;
252 #ifdef DBG_UTIL
253 virtual std::string toString() const override;
254 #endif
255 virtual OOXMLValue* clone() const override;
258 class OOXMLHexValue : public OOXMLValue
260 protected:
261 sal_uInt32 mnValue;
263 public:
264 explicit OOXMLHexValue(sal_uInt32 nValue);
265 explicit OOXMLHexValue(std::string_view pValue);
266 virtual ~OOXMLHexValue() override;
268 OOXMLHexValue(OOXMLHexValue const&) = default;
269 OOXMLHexValue(OOXMLHexValue&&) = default;
270 OOXMLHexValue& operator=(OOXMLHexValue const&) = default;
271 OOXMLHexValue& operator=(OOXMLHexValue&&) = default;
273 virtual int getInt() const override;
274 #ifdef DBG_UTIL
275 virtual std::string toString() const override;
276 #endif
277 virtual OOXMLValue* clone() const override;
280 class OOXMLHexColorValue final : public OOXMLHexValue
282 public:
283 explicit OOXMLHexColorValue(std::string_view pValue);
286 class OOXMLUniversalMeasureValue : public OOXMLValue
288 private:
289 int mnValue;
291 public:
292 OOXMLUniversalMeasureValue(std::string_view pValue, sal_uInt32 npPt);
293 virtual ~OOXMLUniversalMeasureValue() override;
295 OOXMLUniversalMeasureValue(OOXMLUniversalMeasureValue const&) = default;
296 OOXMLUniversalMeasureValue(OOXMLUniversalMeasureValue&&) = default;
297 OOXMLUniversalMeasureValue& operator=(OOXMLUniversalMeasureValue const&) = default;
298 OOXMLUniversalMeasureValue& operator=(OOXMLUniversalMeasureValue&&) = default;
300 virtual int getInt() const override;
301 #ifdef DBG_UTIL
302 virtual std::string toString() const override;
303 #endif
306 /// npPt is quotient defining how much units are in 1 pt
307 template <sal_uInt32 npPt> class OOXMLNthPtMeasureValue final : public OOXMLUniversalMeasureValue
309 public:
310 explicit OOXMLNthPtMeasureValue(std::string_view pValue)
311 : OOXMLUniversalMeasureValue(pValue, npPt)
314 virtual OOXMLValue* clone() const override { return new OOXMLNthPtMeasureValue<npPt>(*this); }
317 /// Handles OOXML's ST_TwipsMeasure value.
318 typedef OOXMLNthPtMeasureValue<20> OOXMLTwipsMeasureValue;
320 /// Handles OOXML's ST_HpsMeasure value.
321 typedef OOXMLNthPtMeasureValue<2> OOXMLHpsMeasureValue;
323 class OOXMLMeasurementOrPercentValue final : public OOXMLValue
325 int mnValue;
327 public:
328 explicit OOXMLMeasurementOrPercentValue(std::string_view pValue);
330 virtual int getInt() const override;
331 virtual OOXMLValue* clone() const override { return new OOXMLMeasurementOrPercentValue(*this); }
332 #ifdef DBG_UTIL
333 virtual std::string toString() const override;
334 #endif
337 class OOXMLShapeValue final : public OOXMLValue
339 css::uno::Reference<css::drawing::XShape> mrShape;
341 public:
342 explicit OOXMLShapeValue(css::uno::Reference<css::drawing::XShape> xShape);
343 virtual ~OOXMLShapeValue() override;
345 virtual css::uno::Any getAny() const override;
346 #ifdef DBG_UTIL
347 virtual std::string toString() const override;
348 #endif
349 virtual OOXMLValue* clone() const override;
352 class OOXMLStarMathValue final : public OOXMLValue
354 css::uno::Reference<css::embed::XEmbeddedObject> m_component;
356 public:
357 explicit OOXMLStarMathValue(css::uno::Reference<css::embed::XEmbeddedObject> component);
358 virtual ~OOXMLStarMathValue() override;
360 virtual css::uno::Any getAny() const override;
361 #ifdef DBG_UTIL
362 virtual std::string toString() const override;
363 #endif
364 virtual OOXMLValue* clone() const override;
367 class OOXMLPropertySetEntryToString final : public Properties
369 Id mnId;
370 OUString mStr;
372 public:
373 explicit OOXMLPropertySetEntryToString(Id nId);
374 virtual ~OOXMLPropertySetEntryToString() override;
376 virtual void sprm(Sprm& rSprm) override;
377 virtual void attribute(Id nId, Value& rValue) override;
379 const OUString& getString() const { return mStr; }
382 class OOXMLPropertySetEntryToInteger final : public Properties
384 Id mnId;
385 int mnValue;
387 public:
388 explicit OOXMLPropertySetEntryToInteger(Id nId);
389 virtual ~OOXMLPropertySetEntryToInteger() override;
391 virtual void sprm(Sprm& rSprm) override;
392 virtual void attribute(Id nId, Value& rValue) override;
394 int getValue() const { return mnValue; }
397 class OOXMLPropertySetEntryToBool final : public Properties
399 Id mnId;
400 bool mValue;
402 public:
403 explicit OOXMLPropertySetEntryToBool(Id nId);
404 virtual ~OOXMLPropertySetEntryToBool() override;
406 virtual void sprm(Sprm& rSprm) override;
407 virtual void attribute(Id nId, Value& rValue) override;
409 bool getValue() const { return mValue; }
413 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */