1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
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
31 typedef tools::SvRef
<OOXMLValue
> Pointer_t
;
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
;
47 virtual std::string
toString() const override
;
49 virtual OOXMLValue
* clone() const;
52 class OOXMLProperty final
: public Sprm
55 typedef tools::SvRef
<OOXMLProperty
> Pointer_t
;
64 mutable OOXMLValue::Pointer_t mpValue
;
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
;
76 std::string
getName() const override
;
77 std::string
toString() const override
;
79 void resolve(Properties
& rProperties
);
82 class OOXMLBinaryValue final
: public OOXMLValue
84 mutable OOXMLBinaryObjectReference::Pointer_t mpBinaryObj
;
87 explicit OOXMLBinaryValue(OOXMLBinaryObjectReference::Pointer_t pBinaryObj
);
88 virtual ~OOXMLBinaryValue() override
;
90 virtual writerfilter::Reference
<BinaryObj
>::Pointer_t
getBinary() override
;
92 virtual std::string
toString() const override
;
94 virtual OOXMLValue
* clone() const override
;
97 class OOXMLBooleanValue final
: public OOXMLValue
100 explicit OOXMLBooleanValue(bool bValue
);
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
;
116 virtual std::string
toString() const override
;
118 virtual OOXMLValue
* clone() const override
;
121 class OOXMLStringValue final
: public OOXMLValue
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
;
137 virtual std::string
toString() const override
;
139 virtual OOXMLValue
* clone() const override
;
142 class OOXMLInputStreamValue final
: public OOXMLValue
144 css::uno::Reference
<css::io::XInputStream
> mxInputStream
;
147 explicit OOXMLInputStreamValue(css::uno::Reference
<css::io::XInputStream
> xInputStream
);
148 virtual ~OOXMLInputStreamValue() override
;
150 virtual css::uno::Any
getAny() const override
;
152 virtual std::string
toString() const override
;
154 virtual OOXMLValue
* clone() const override
;
157 class OOXMLPropertySet final
: public writerfilter::Reference
<Properties
>
160 typedef std::vector
<OOXMLProperty::Pointer_t
> OOXMLProperties_t
;
161 typedef tools::SvRef
<OOXMLPropertySet
> Pointer_t
;
164 OOXMLProperties_t mProperties
;
165 void add(const OOXMLProperty::Pointer_t
& pProperty
);
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;
187 std::string
toString();
193 class OOXMLTable final
: public writerfilter::Reference
<Table
>
196 typedef tools::SvRef
<OOXMLValue
> ValuePointer_t
;
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;
210 typedef std::vector
<ValuePointer_t
> PropertySets_t
;
211 PropertySets_t mPropertySets
;
214 class OOXMLPropertySetValue final
: public OOXMLValue
216 OOXMLPropertySet::Pointer_t mpPropertySet
;
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
;
231 virtual std::string
toString() const override
;
233 virtual OOXMLValue
* clone() const override
;
236 class OOXMLIntegerValue final
: public OOXMLValue
239 explicit OOXMLIntegerValue(sal_Int32 nValue
);
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
;
253 virtual std::string
toString() const override
;
255 virtual OOXMLValue
* clone() const override
;
258 class OOXMLHexValue
: public OOXMLValue
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
;
275 virtual std::string
toString() const override
;
277 virtual OOXMLValue
* clone() const override
;
280 class OOXMLHexColorValue final
: public OOXMLHexValue
283 explicit OOXMLHexColorValue(std::string_view pValue
);
286 class OOXMLUniversalMeasureValue
: public OOXMLValue
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
;
302 virtual std::string
toString() const override
;
306 /// npPt is quotient defining how much units are in 1 pt
307 template <sal_uInt32 npPt
> class OOXMLNthPtMeasureValue final
: public OOXMLUniversalMeasureValue
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
328 explicit OOXMLMeasurementOrPercentValue(std::string_view pValue
);
330 virtual int getInt() const override
;
331 virtual OOXMLValue
* clone() const override
{ return new OOXMLMeasurementOrPercentValue(*this); }
333 virtual std::string
toString() const override
;
337 class OOXMLShapeValue final
: public OOXMLValue
339 css::uno::Reference
<css::drawing::XShape
> mrShape
;
342 explicit OOXMLShapeValue(css::uno::Reference
<css::drawing::XShape
> xShape
);
343 virtual ~OOXMLShapeValue() override
;
345 virtual css::uno::Any
getAny() const override
;
347 virtual std::string
toString() const override
;
349 virtual OOXMLValue
* clone() const override
;
352 class OOXMLStarMathValue final
: public OOXMLValue
354 css::uno::Reference
<css::embed::XEmbeddedObject
> m_component
;
357 explicit OOXMLStarMathValue(css::uno::Reference
<css::embed::XEmbeddedObject
> component
);
358 virtual ~OOXMLStarMathValue() override
;
360 virtual css::uno::Any
getAny() const override
;
362 virtual std::string
toString() const override
;
364 virtual OOXMLValue
* clone() const override
;
367 class OOXMLPropertySetEntryToString final
: public Properties
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
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
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: */