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 .
19 #ifndef INCLUDED_WRITERFILTER_SOURCE_OOXML_OOXMLPROPERTYSET_HXX
20 #define INCLUDED_WRITERFILTER_SOURCE_OOXML_OOXMLPROPERTYSET_HXX
23 #include "OOXMLBinaryObjectReference.hxx"
24 #include <com/sun/star/embed/XEmbeddedObject.hpp>
25 #include <dmapper/resourcemodel.hxx>
27 namespace writerfilter::ooxml
29 class OOXMLValue
: public Value
32 typedef tools::SvRef
<OOXMLValue
> Pointer_t
;
34 virtual ~OOXMLValue() override
;
36 OOXMLValue(OOXMLValue
const&) = default;
37 OOXMLValue(OOXMLValue
&&) = default;
38 OOXMLValue
& operator=(OOXMLValue
const&) = default;
39 OOXMLValue
& operator=(OOXMLValue
&&) = default;
41 virtual int getInt() const override
;
43 virtual OUString
getString() const override
;
44 virtual css::uno::Any
getAny() const override
;
45 virtual writerfilter::Reference
<Properties
>::Pointer_t
getProperties() override
;
46 virtual writerfilter::Reference
<BinaryObj
>::Pointer_t
getBinary() override
;
48 virtual std::string
toString() const override
;
50 virtual OOXMLValue
* clone() const;
53 class OOXMLProperty
: public Sprm
56 typedef tools::SvRef
<OOXMLProperty
> Pointer_t
;
65 mutable OOXMLValue::Pointer_t mpValue
;
69 OOXMLProperty(Id id
, const OOXMLValue::Pointer_t
& pValue
, Type_t eType
);
70 OOXMLProperty(const OOXMLProperty
& rSprm
) = delete;
71 virtual ~OOXMLProperty() override
;
73 sal_uInt32
getId() const override
;
74 Value::Pointer_t
getValue() override
;
75 writerfilter::Reference
<Properties
>::Pointer_t
getProps() override
;
77 std::string
getName() const override
;
78 std::string
toString() const override
;
80 void resolve(Properties
& rProperties
);
83 class OOXMLBinaryValue
: public OOXMLValue
85 mutable OOXMLBinaryObjectReference::Pointer_t mpBinaryObj
;
88 explicit OOXMLBinaryValue(OOXMLBinaryObjectReference::Pointer_t
const& pBinaryObj
);
89 virtual ~OOXMLBinaryValue() override
;
91 virtual writerfilter::Reference
<BinaryObj
>::Pointer_t
getBinary() override
;
93 virtual std::string
toString() const override
;
95 virtual OOXMLValue
* clone() const override
;
98 class OOXMLBooleanValue
: public OOXMLValue
101 explicit OOXMLBooleanValue(bool bValue
);
104 static OOXMLValue::Pointer_t
const& Create(bool bValue
);
105 static OOXMLValue::Pointer_t
const& Create(const char* pValue
);
107 virtual ~OOXMLBooleanValue() override
;
109 OOXMLBooleanValue(OOXMLBooleanValue
const&) = default;
110 OOXMLBooleanValue(OOXMLBooleanValue
&&) = default;
111 OOXMLBooleanValue
& operator=(OOXMLBooleanValue
const&) = delete; // due to const mbValue
112 OOXMLBooleanValue
& operator=(OOXMLBooleanValue
&&) = delete; // due to const mbValue
114 virtual int getInt() const override
;
115 virtual css::uno::Any
getAny() const override
;
117 virtual std::string
toString() const override
;
119 virtual OOXMLValue
* clone() const override
;
122 class OOXMLStringValue
: public OOXMLValue
127 explicit OOXMLStringValue(const OUString
& rStr
);
128 virtual ~OOXMLStringValue() override
;
130 OOXMLStringValue(OOXMLStringValue
const&) = default;
131 OOXMLStringValue(OOXMLStringValue
&&) = default;
132 OOXMLStringValue
& operator=(OOXMLStringValue
const&) = delete; // due to const mStr
133 OOXMLStringValue
& operator=(OOXMLStringValue
&&) = delete; // due to const mStr
135 virtual css::uno::Any
getAny() const override
;
136 virtual OUString
getString() const override
;
138 virtual std::string
toString() const override
;
140 virtual OOXMLValue
* clone() const override
;
143 class OOXMLInputStreamValue
: public OOXMLValue
145 css::uno::Reference
<css::io::XInputStream
> mxInputStream
;
148 explicit OOXMLInputStreamValue(css::uno::Reference
<css::io::XInputStream
> const& xInputStream
);
149 virtual ~OOXMLInputStreamValue() override
;
151 virtual css::uno::Any
getAny() const override
;
153 virtual std::string
toString() const override
;
155 virtual OOXMLValue
* clone() const override
;
158 class OOXMLPropertySet
: public writerfilter::Reference
<Properties
>
161 typedef std::vector
<OOXMLProperty::Pointer_t
> OOXMLProperties_t
;
162 typedef tools::SvRef
<OOXMLPropertySet
> Pointer_t
;
165 OOXMLProperties_t mProperties
;
166 void add(const OOXMLProperty::Pointer_t
& pProperty
);
170 virtual ~OOXMLPropertySet() override
;
172 OOXMLPropertySet(OOXMLPropertySet
const&) = default;
173 OOXMLPropertySet(OOXMLPropertySet
&&) = default;
174 OOXMLPropertySet
& operator=(OOXMLPropertySet
const&) = default;
175 OOXMLPropertySet
& operator=(OOXMLPropertySet
&&) = default;
177 void resolve(Properties
& rHandler
) override
;
178 void add(Id id
, const OOXMLValue::Pointer_t
& pValue
, OOXMLProperty::Type_t eType
);
179 void add(const OOXMLPropertySet::Pointer_t
& pPropertySet
);
180 OOXMLPropertySet
* clone() const;
182 OOXMLProperties_t::iterator
begin();
183 OOXMLProperties_t::iterator
end();
184 OOXMLProperties_t::const_iterator
begin() const;
185 OOXMLProperties_t::const_iterator
end() const;
188 std::string
toString();
194 class OOXMLTable
: public writerfilter::Reference
<Table
>
197 typedef tools::SvRef
<OOXMLValue
> ValuePointer_t
;
199 virtual ~OOXMLTable() override
;
201 OOXMLTable(OOXMLTable
const&) = default;
202 OOXMLTable(OOXMLTable
&&) = default;
203 OOXMLTable
& operator=(OOXMLTable
const&) = default;
204 OOXMLTable
& operator=(OOXMLTable
&&) = default;
206 void resolve(Table
& rTable
) override
;
207 void add(const ValuePointer_t
& pPropertySet
);
208 OOXMLTable
* clone() const;
211 typedef std::vector
<ValuePointer_t
> PropertySets_t
;
212 PropertySets_t mPropertySets
;
215 class OOXMLPropertySetValue
: public OOXMLValue
217 OOXMLPropertySet::Pointer_t mpPropertySet
;
220 explicit OOXMLPropertySetValue(const OOXMLPropertySet::Pointer_t
& pPropertySet
);
221 virtual ~OOXMLPropertySetValue() override
;
223 OOXMLPropertySetValue(OOXMLPropertySetValue
const&) = default;
224 OOXMLPropertySetValue(OOXMLPropertySetValue
&&) = default;
225 OOXMLPropertySetValue
& operator=(OOXMLPropertySetValue
const&)
226 = delete; // due to const mpPropertySet
227 OOXMLPropertySetValue
& operator=(OOXMLPropertySetValue
&&)
228 = delete; // due to const mpPropertySet
230 virtual writerfilter::Reference
<Properties
>::Pointer_t
getProperties() override
;
232 virtual std::string
toString() const override
;
234 virtual OOXMLValue
* clone() const override
;
237 class OOXMLIntegerValue
: public OOXMLValue
240 explicit OOXMLIntegerValue(sal_Int32 nValue
);
243 static OOXMLValue::Pointer_t
Create(sal_Int32 nValue
);
244 virtual ~OOXMLIntegerValue() override
;
246 OOXMLIntegerValue(OOXMLIntegerValue
const&) = default;
247 OOXMLIntegerValue(OOXMLIntegerValue
&&) = default;
248 OOXMLIntegerValue
& operator=(OOXMLIntegerValue
const&) = delete; // due to const mnValue
249 OOXMLIntegerValue
& operator=(OOXMLIntegerValue
&&) = delete; // due to const mnValue
251 virtual int getInt() const override
;
252 virtual css::uno::Any
getAny() const override
;
254 virtual std::string
toString() const override
;
256 virtual OOXMLValue
* clone() const override
;
259 class OOXMLHexValue
: public OOXMLValue
265 explicit OOXMLHexValue(sal_uInt32 nValue
);
266 explicit OOXMLHexValue(const char* pValue
);
267 virtual ~OOXMLHexValue() override
;
269 OOXMLHexValue(OOXMLHexValue
const&) = default;
270 OOXMLHexValue(OOXMLHexValue
&&) = default;
271 OOXMLHexValue
& operator=(OOXMLHexValue
const&) = default;
272 OOXMLHexValue
& operator=(OOXMLHexValue
&&) = default;
274 virtual int getInt() const override
;
276 virtual std::string
toString() const override
;
278 virtual OOXMLValue
* clone() const override
;
281 class OOXMLHexColorValue
: public OOXMLHexValue
284 explicit OOXMLHexColorValue(const char* pValue
);
287 class OOXMLUniversalMeasureValue
: public OOXMLValue
293 OOXMLUniversalMeasureValue(const char* pValue
, sal_uInt32 npPt
);
294 virtual ~OOXMLUniversalMeasureValue() override
;
296 OOXMLUniversalMeasureValue(OOXMLUniversalMeasureValue
const&) = default;
297 OOXMLUniversalMeasureValue(OOXMLUniversalMeasureValue
&&) = default;
298 OOXMLUniversalMeasureValue
& operator=(OOXMLUniversalMeasureValue
const&) = default;
299 OOXMLUniversalMeasureValue
& operator=(OOXMLUniversalMeasureValue
&&) = default;
301 virtual int getInt() const override
;
303 virtual std::string
toString() const override
;
307 /// npPt is quotient defining how much units are in 1 pt
308 template <sal_uInt32 npPt
> class OOXMLNthPtMeasureValue
: public OOXMLUniversalMeasureValue
311 explicit OOXMLNthPtMeasureValue(const char* pValue
)
312 : OOXMLUniversalMeasureValue(pValue
, npPt
)
315 virtual OOXMLValue
* clone() const override
{ return new OOXMLNthPtMeasureValue
<npPt
>(*this); }
318 /// Handles OOXML's ST_TwipsMeasure value.
319 typedef OOXMLNthPtMeasureValue
<20> OOXMLTwipsMeasureValue
;
321 /// Handles OOXML's ST_HpsMeasure value.
322 typedef OOXMLNthPtMeasureValue
<2> OOXMLHpsMeasureValue
;
324 class OOXMLMeasurementOrPercentValue
: public OOXMLValue
329 explicit OOXMLMeasurementOrPercentValue(const char* pValue
);
331 virtual int getInt() const override
;
332 virtual OOXMLValue
* clone() const override
{ return new OOXMLMeasurementOrPercentValue(*this); }
334 virtual std::string
toString() const override
;
338 class OOXMLShapeValue
: public OOXMLValue
340 css::uno::Reference
<css::drawing::XShape
> mrShape
;
343 explicit OOXMLShapeValue(css::uno::Reference
<css::drawing::XShape
> const& rShape
);
344 virtual ~OOXMLShapeValue() override
;
346 virtual css::uno::Any
getAny() const override
;
348 virtual std::string
toString() const override
;
350 virtual OOXMLValue
* clone() const override
;
353 class OOXMLStarMathValue
: public OOXMLValue
355 css::uno::Reference
<css::embed::XEmbeddedObject
> component
;
358 explicit OOXMLStarMathValue(css::uno::Reference
<css::embed::XEmbeddedObject
> const& component
);
359 virtual ~OOXMLStarMathValue() override
;
361 virtual css::uno::Any
getAny() const override
;
363 virtual std::string
toString() const override
;
365 virtual OOXMLValue
* clone() const override
;
368 class OOXMLPropertySetEntryToString
: public Properties
374 explicit OOXMLPropertySetEntryToString(Id nId
);
375 virtual ~OOXMLPropertySetEntryToString() override
;
377 virtual void sprm(Sprm
& rSprm
) override
;
378 virtual void attribute(Id nId
, Value
& rValue
) override
;
380 const OUString
& getString() const { return mStr
; }
383 class OOXMLPropertySetEntryToInteger
: public Properties
389 explicit OOXMLPropertySetEntryToInteger(Id nId
);
390 virtual ~OOXMLPropertySetEntryToInteger() override
;
392 virtual void sprm(Sprm
& rSprm
) override
;
393 virtual void attribute(Id nId
, Value
& rValue
) override
;
395 int getValue() const { return mnValue
; }
398 class OOXMLPropertySetEntryToBool
: public Properties
404 explicit OOXMLPropertySetEntryToBool(Id nId
);
405 virtual ~OOXMLPropertySetEntryToBool() override
;
407 virtual void sprm(Sprm
& rSprm
) override
;
408 virtual void attribute(Id nId
, Value
& rValue
) override
;
410 bool getValue() const { return mValue
; }
414 #endif // INCLUDED_WRITERFILTER_SOURCE_OOXML_OOXMLPROPERTYSET_HXX
416 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */