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
{
31 class OOXMLValue
: public Value
34 typedef tools::SvRef
<OOXMLValue
> Pointer_t
;
36 virtual ~OOXMLValue() override
;
38 OOXMLValue(OOXMLValue
const &) = default;
39 OOXMLValue(OOXMLValue
&&) = default;
40 OOXMLValue
& operator =(OOXMLValue
const &) = default;
41 OOXMLValue
& operator =(OOXMLValue
&&) = default;
43 virtual int getInt() const override
;
45 virtual OUString
getString() const override
;
46 virtual css::uno::Any
getAny() const override
;
47 virtual writerfilter::Reference
<Properties
>::Pointer_t
getProperties() override
;
48 virtual writerfilter::Reference
<BinaryObj
>::Pointer_t
getBinary() override
;
49 #ifdef DEBUG_WRITERFILTER
50 virtual std::string
toString() const override
;
52 virtual OOXMLValue
* clone() const;
55 class OOXMLProperty
: public Sprm
58 typedef tools::SvRef
<OOXMLProperty
> Pointer_t
;
59 enum Type_t
{ SPRM
, ATTRIBUTE
};
62 mutable OOXMLValue::Pointer_t mpValue
;
66 OOXMLProperty(Id id
, const OOXMLValue::Pointer_t
& pValue
, Type_t eType
);
67 OOXMLProperty(const OOXMLProperty
& rSprm
) = delete;
68 virtual ~OOXMLProperty() override
;
70 sal_uInt32
getId() const override
;
71 Value::Pointer_t
getValue() override
;
72 writerfilter::Reference
<Properties
>::Pointer_t
getProps() override
;
73 #ifdef DEBUG_WRITERFILTER
74 std::string
getName() const override
;
75 std::string
toString() const override
;
77 void resolve(Properties
& rProperties
);
80 class OOXMLBinaryValue
: public OOXMLValue
82 OOXMLBinaryObjectReference::Pointer_t
const mpBinaryObj
;
84 explicit OOXMLBinaryValue(OOXMLBinaryObjectReference::Pointer_t
const & pBinaryObj
);
85 virtual ~OOXMLBinaryValue() override
;
87 virtual writerfilter::Reference
<BinaryObj
>::Pointer_t
getBinary() override
;
88 #ifdef DEBUG_WRITERFILTER
89 virtual std::string
toString() const override
;
91 virtual OOXMLValue
* clone() const override
;
94 class OOXMLBooleanValue
: public OOXMLValue
97 explicit OOXMLBooleanValue(bool bValue
);
99 static OOXMLValue::Pointer_t
const & Create (bool bValue
);
100 static OOXMLValue::Pointer_t
const & Create (const char *pValue
);
102 virtual ~OOXMLBooleanValue() override
;
104 OOXMLBooleanValue(OOXMLBooleanValue
const &) = default;
105 OOXMLBooleanValue(OOXMLBooleanValue
&&) = default;
106 OOXMLBooleanValue
& operator =(OOXMLBooleanValue
const &) = delete; // due to const mbValue
107 OOXMLBooleanValue
& operator =(OOXMLBooleanValue
&&) = delete; // due to const mbValue
109 virtual int getInt() const override
;
110 virtual css::uno::Any
getAny() const override
;
111 #ifdef DEBUG_WRITERFILTER
112 virtual std::string
toString() const override
;
114 virtual OOXMLValue
* clone() const override
;
117 class OOXMLStringValue
: public OOXMLValue
121 explicit OOXMLStringValue(const OUString
& rStr
);
122 virtual ~OOXMLStringValue() override
;
124 OOXMLStringValue(OOXMLStringValue
const &) = default;
125 OOXMLStringValue(OOXMLStringValue
&&) = default;
126 OOXMLStringValue
& operator =(OOXMLStringValue
const &) = delete; // due to const mStr
127 OOXMLStringValue
& operator =(OOXMLStringValue
&&) = delete; // due to const mStr
129 virtual css::uno::Any
getAny() const override
;
130 virtual OUString
getString() const override
;
131 #ifdef DEBUG_WRITERFILTER
132 virtual std::string
toString() const override
;
134 virtual OOXMLValue
* clone() const override
;
137 class OOXMLInputStreamValue
: public OOXMLValue
139 css::uno::Reference
<css::io::XInputStream
> mxInputStream
;
142 explicit OOXMLInputStreamValue(css::uno::Reference
<css::io::XInputStream
> const & xInputStream
);
143 virtual ~OOXMLInputStreamValue() override
;
145 virtual css::uno::Any
getAny() const override
;
146 #ifdef DEBUG_WRITERFILTER
147 virtual std::string
toString() const override
;
149 virtual OOXMLValue
* clone() const override
;
152 class OOXMLPropertySet
: public writerfilter::Reference
<Properties
>
155 typedef std::vector
<OOXMLProperty::Pointer_t
> OOXMLProperties_t
;
156 typedef tools::SvRef
<OOXMLPropertySet
> Pointer_t
;
158 OOXMLProperties_t mProperties
;
159 void add(const OOXMLProperty::Pointer_t
& pProperty
);
162 virtual ~OOXMLPropertySet() override
;
164 OOXMLPropertySet(OOXMLPropertySet
const &) = default;
165 OOXMLPropertySet(OOXMLPropertySet
&&) = default;
166 OOXMLPropertySet
& operator =(OOXMLPropertySet
const &) = default;
167 OOXMLPropertySet
& operator =(OOXMLPropertySet
&&) = default;
169 void resolve(Properties
& rHandler
) override
;
170 void add(Id id
, const OOXMLValue::Pointer_t
& pValue
, OOXMLProperty::Type_t eType
);
171 void add(const OOXMLPropertySet::Pointer_t
& pPropertySet
);
172 OOXMLPropertySet
* clone() const;
174 OOXMLProperties_t::iterator
begin();
175 OOXMLProperties_t::iterator
end();
176 OOXMLProperties_t::const_iterator
begin() const;
177 OOXMLProperties_t::const_iterator
end() const;
179 #ifdef DEBUG_WRITERFILTER
180 std::string
toString();
186 class OOXMLTable
: public writerfilter::Reference
<Table
>
189 typedef tools::SvRef
<OOXMLValue
> ValuePointer_t
;
191 virtual ~OOXMLTable() override
;
193 OOXMLTable(OOXMLTable
const &) = default;
194 OOXMLTable(OOXMLTable
&&) = default;
195 OOXMLTable
& operator =(OOXMLTable
const &) = default;
196 OOXMLTable
& operator =(OOXMLTable
&&) = default;
198 void resolve(Table
& rTable
) override
;
199 void add(const ValuePointer_t
& pPropertySet
);
200 OOXMLTable
* clone() const;
202 typedef std::vector
<ValuePointer_t
> PropertySets_t
;
203 PropertySets_t mPropertySets
;
206 class OOXMLPropertySetValue
: public OOXMLValue
208 OOXMLPropertySet::Pointer_t
const mpPropertySet
;
210 explicit OOXMLPropertySetValue(const OOXMLPropertySet::Pointer_t
& pPropertySet
);
211 virtual ~OOXMLPropertySetValue() override
;
213 OOXMLPropertySetValue(OOXMLPropertySetValue
const &) = default;
214 OOXMLPropertySetValue(OOXMLPropertySetValue
&&) = default;
215 OOXMLPropertySetValue
& operator =(OOXMLPropertySetValue
const &) = delete; // due to const mpPropertySet
216 OOXMLPropertySetValue
& operator =(OOXMLPropertySetValue
&&) = delete; // due to const mpPropertySet
218 virtual writerfilter::Reference
<Properties
>::Pointer_t
getProperties() override
;
219 #ifdef DEBUG_WRITERFILTER
220 virtual std::string
toString() const override
;
222 virtual OOXMLValue
* clone() const override
;
225 class OOXMLIntegerValue
: public OOXMLValue
227 sal_Int32
const mnValue
;
228 explicit OOXMLIntegerValue(sal_Int32 nValue
);
230 static OOXMLValue::Pointer_t
Create (sal_Int32 nValue
);
231 virtual ~OOXMLIntegerValue() override
;
233 OOXMLIntegerValue(OOXMLIntegerValue
const &) = default;
234 OOXMLIntegerValue(OOXMLIntegerValue
&&) = default;
235 OOXMLIntegerValue
& operator =(OOXMLIntegerValue
const &) = delete; // due to const mnValue
236 OOXMLIntegerValue
& operator =(OOXMLIntegerValue
&&) = delete; // due to const mnValue
238 virtual int getInt() const override
;
239 virtual css::uno::Any
getAny() const override
;
240 #ifdef DEBUG_WRITERFILTER
241 virtual std::string
toString() const override
;
243 virtual OOXMLValue
* clone() const override
;
246 class OOXMLHexValue
: public OOXMLValue
251 explicit OOXMLHexValue(sal_uInt32 nValue
);
252 explicit OOXMLHexValue(const char * pValue
);
253 virtual ~OOXMLHexValue() override
;
255 OOXMLHexValue(OOXMLHexValue
const &) = default;
256 OOXMLHexValue(OOXMLHexValue
&&) = default;
257 OOXMLHexValue
& operator =(OOXMLHexValue
const &) = default;
258 OOXMLHexValue
& operator =(OOXMLHexValue
&&) = default;
260 virtual int getInt() const override
;
261 #ifdef DEBUG_WRITERFILTER
262 virtual std::string
toString() const override
;
264 virtual OOXMLValue
* clone() const override
;
267 class OOXMLHexColorValue
: public OOXMLHexValue
270 explicit OOXMLHexColorValue(const char * pValue
);
273 class OOXMLUniversalMeasureValue
: public OOXMLValue
278 OOXMLUniversalMeasureValue(const char * pValue
, sal_uInt32 npPt
);
279 virtual ~OOXMLUniversalMeasureValue() override
;
281 OOXMLUniversalMeasureValue(OOXMLUniversalMeasureValue
const &) = default;
282 OOXMLUniversalMeasureValue(OOXMLUniversalMeasureValue
&&) = default;
283 OOXMLUniversalMeasureValue
& operator =(OOXMLUniversalMeasureValue
const &) = default;
284 OOXMLUniversalMeasureValue
& operator =(OOXMLUniversalMeasureValue
&&) = default;
286 virtual int getInt() const override
;
287 #ifdef DEBUG_WRITERFILTER
288 virtual std::string
toString() const override
;
292 /// npPt is quotient defining how much units are in 1 pt
293 template <sal_uInt32 npPt
> class OOXMLNthPtMeasureValue
: public OOXMLUniversalMeasureValue
296 explicit OOXMLNthPtMeasureValue(const char * pValue
)
297 : OOXMLUniversalMeasureValue(pValue
, npPt
) {}
298 virtual OOXMLValue
* clone() const override
300 return new OOXMLNthPtMeasureValue
<npPt
>(*this);
304 /// Handles OOXML's ST_TwipsMeasure value.
305 typedef OOXMLNthPtMeasureValue
<20> OOXMLTwipsMeasureValue
;
307 /// Handles OOXML's ST_HpsMeasure value.
308 typedef OOXMLNthPtMeasureValue
<2> OOXMLHpsMeasureValue
;
310 class OOXMLMeasurementOrPercentValue
: public OOXMLValue
314 explicit OOXMLMeasurementOrPercentValue(const char * pValue
);
316 virtual int getInt() const override
;
317 virtual OOXMLValue
* clone() const override
319 return new OOXMLMeasurementOrPercentValue(*this);
321 #ifdef DEBUG_WRITERFILTER
322 virtual std::string
toString() const override
;
326 class OOXMLShapeValue
: public OOXMLValue
328 css::uno::Reference
<css::drawing::XShape
> mrShape
;
330 explicit OOXMLShapeValue(css::uno::Reference
<css::drawing::XShape
> const & rShape
);
331 virtual ~OOXMLShapeValue() override
;
333 virtual css::uno::Any
getAny() const override
;
334 #ifdef DEBUG_WRITERFILTER
335 virtual std::string
toString() const override
;
337 virtual OOXMLValue
* clone() const override
;
340 class OOXMLStarMathValue
: public OOXMLValue
342 css::uno::Reference
< css::embed::XEmbeddedObject
> component
;
344 explicit OOXMLStarMathValue( css::uno::Reference
< css::embed::XEmbeddedObject
> const & component
);
345 virtual ~OOXMLStarMathValue() override
;
347 virtual css::uno::Any
getAny() const override
;
348 #ifdef DEBUG_WRITERFILTER
349 virtual std::string
toString() const override
;
351 virtual OOXMLValue
* clone() const override
;
354 class OOXMLPropertySetEntryToString
: public Properties
360 explicit OOXMLPropertySetEntryToString(Id nId
);
361 virtual ~OOXMLPropertySetEntryToString() override
;
363 virtual void sprm(Sprm
& rSprm
) override
;
364 virtual void attribute(Id nId
, Value
& rValue
) override
;
366 const OUString
& getString() const { return mStr
;}
369 class OOXMLPropertySetEntryToInteger
: public Properties
374 explicit OOXMLPropertySetEntryToInteger(Id nId
);
375 virtual ~OOXMLPropertySetEntryToInteger() override
;
377 virtual void sprm(Sprm
& rSprm
) override
;
378 virtual void attribute(Id nId
, Value
& rValue
) override
;
380 int getValue() const { return mnValue
;}
383 class OOXMLPropertySetEntryToBool
: public Properties
388 explicit OOXMLPropertySetEntryToBool(Id nId
);
389 virtual ~OOXMLPropertySetEntryToBool() override
;
391 virtual void sprm(Sprm
& rSprm
) override
;
392 virtual void attribute(Id nId
, Value
& rValue
) override
;
394 bool getValue() const { return mValue
; }
400 #endif // INCLUDED_WRITERFILTER_SOURCE_OOXML_OOXMLPROPERTYSET_HXX
402 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */