LibreOffice Module writerfilter (master) 1
OOXMLPropertySet.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19#pragma once
20
21#include <vector>
23#include <com/sun/star/embed/XEmbeddedObject.hpp>
25
26namespace writerfilter::ooxml
27{
28class OOXMLValue : public Value
29{
30public:
32 OOXMLValue();
33 virtual ~OOXMLValue() override;
34
35 OOXMLValue(OOXMLValue const&) = default;
36 OOXMLValue(OOXMLValue&&) = default;
37 OOXMLValue& operator=(OOXMLValue const&) = default;
39
40 virtual int getInt() const override;
41 ;
42 virtual OUString getString() const override;
43 virtual css::uno::Any getAny() const override;
46#ifdef DBG_UTIL
47 virtual std::string toString() const override;
48#endif
49 virtual OOXMLValue* clone() const;
50};
51
52class OOXMLProperty final : public Sprm
53{
54public:
56 enum Type_t
57 {
60 };
61
62private:
66
67public:
69 OOXMLProperty(const OOXMLProperty& rSprm) = delete;
70 virtual ~OOXMLProperty() override;
71
72 sal_uInt32 getId() const override;
73 Value::Pointer_t getValue() override;
75#ifdef DBG_UTIL
76 std::string getName() const override;
77 std::string toString() const override;
78#endif
79 void resolve(Properties& rProperties);
80};
81
82class OOXMLBinaryValue final : public OOXMLValue
83{
85
86public:
88 virtual ~OOXMLBinaryValue() override;
89
91#ifdef DBG_UTIL
92 virtual std::string toString() const override;
93#endif
94 virtual OOXMLValue* clone() const override;
95};
96
97class OOXMLBooleanValue final : public OOXMLValue
98{
99 bool mbValue;
100 explicit OOXMLBooleanValue(bool bValue);
101
102public:
103 static OOXMLValue::Pointer_t const& Create(bool bValue);
104 static OOXMLValue::Pointer_t const& Create(std::string_view pValue);
105
106 virtual ~OOXMLBooleanValue() override;
107
110 OOXMLBooleanValue& operator=(OOXMLBooleanValue const&) = delete; // due to const mbValue
111 OOXMLBooleanValue& operator=(OOXMLBooleanValue&&) = delete; // due to const mbValue
112
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;
119};
120
121class OOXMLStringValue final : public OOXMLValue
122{
123 OUString mStr;
124
125public:
126 explicit OOXMLStringValue(OUString sStr);
127 virtual ~OOXMLStringValue() override;
128
131 OOXMLStringValue& operator=(OOXMLStringValue const&) = delete; // due to const mStr
132 OOXMLStringValue& operator=(OOXMLStringValue&&) = delete; // due to const mStr
133
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;
140};
141
143{
144 css::uno::Reference<css::io::XInputStream> mxInputStream;
145
146public:
147 explicit OOXMLInputStreamValue(css::uno::Reference<css::io::XInputStream> xInputStream);
148 virtual ~OOXMLInputStreamValue() override;
149
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;
155};
156
157class OOXMLPropertySet final : public writerfilter::Reference<Properties>
158{
159public:
160 typedef std::vector<OOXMLProperty::Pointer_t> OOXMLProperties_t;
162
163private:
165 void add(const OOXMLProperty::Pointer_t& pProperty);
166
167public:
169 virtual ~OOXMLPropertySet() override;
170
175
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;
180
181 OOXMLProperties_t::iterator begin();
182 OOXMLProperties_t::iterator end();
183 OOXMLProperties_t::const_iterator begin() const;
184 OOXMLProperties_t::const_iterator end() const;
185
186#ifdef DBG_UTIL
187 std::string toString();
188#endif
189};
190
191class OOXMLValue;
192
193class OOXMLTable final : public writerfilter::Reference<Table>
194{
195public:
197 OOXMLTable();
198 virtual ~OOXMLTable() override;
199
200 OOXMLTable(OOXMLTable const&) = default;
201 OOXMLTable(OOXMLTable&&) = default;
202 OOXMLTable& operator=(OOXMLTable const&) = default;
204
205 void resolve(Table& rTable) override;
206 void add(const ValuePointer_t& pPropertySet);
207 OOXMLTable* clone() const;
208
209private:
210 typedef std::vector<ValuePointer_t> PropertySets_t;
212};
213
215{
217
218public:
220 virtual ~OOXMLPropertySetValue() override;
221
225 = delete; // due to const mpPropertySet
227 = delete; // due to const mpPropertySet
228
230#ifdef DBG_UTIL
231 virtual std::string toString() const override;
232#endif
233 virtual OOXMLValue* clone() const override;
234};
235
236class OOXMLIntegerValue final : public OOXMLValue
237{
238 sal_Int32 mnValue;
239 explicit OOXMLIntegerValue(sal_Int32 nValue);
240
241public:
242 static OOXMLValue::Pointer_t Create(sal_Int32 nValue);
243 virtual ~OOXMLIntegerValue() override;
244
247 OOXMLIntegerValue& operator=(OOXMLIntegerValue const&) = delete; // due to const mnValue
248 OOXMLIntegerValue& operator=(OOXMLIntegerValue&&) = delete; // due to const mnValue
249
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;
256};
257
259{
260protected:
261 sal_uInt32 mnValue;
262
263public:
264 explicit OOXMLHexValue(sal_uInt32 nValue);
265 explicit OOXMLHexValue(std::string_view pValue);
266 virtual ~OOXMLHexValue() override;
267
268 OOXMLHexValue(OOXMLHexValue const&) = default;
272
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;
278};
279
281{
282public:
283 explicit OOXMLHexColorValue(std::string_view pValue);
284};
285
287{
288private:
290
291public:
292 OOXMLUniversalMeasureValue(std::string_view pValue, sal_uInt32 npPt);
293 virtual ~OOXMLUniversalMeasureValue() override;
294
299
300 virtual int getInt() const override;
301#ifdef DBG_UTIL
302 virtual std::string toString() const override;
303#endif
304};
305
307template <sal_uInt32 npPt> class OOXMLNthPtMeasureValue final : public OOXMLUniversalMeasureValue
308{
309public:
310 explicit OOXMLNthPtMeasureValue(std::string_view pValue)
311 : OOXMLUniversalMeasureValue(pValue, npPt)
312 {
313 }
314 virtual OOXMLValue* clone() const override { return new OOXMLNthPtMeasureValue<npPt>(*this); }
315};
316
319
322
324{
326
327public:
328 explicit OOXMLMeasurementOrPercentValue(std::string_view pValue);
329
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
335};
336
337class OOXMLShapeValue final : public OOXMLValue
338{
339 css::uno::Reference<css::drawing::XShape> mrShape;
340
341public:
342 explicit OOXMLShapeValue(css::uno::Reference<css::drawing::XShape> xShape);
343 virtual ~OOXMLShapeValue() override;
344
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;
350};
351
352class OOXMLStarMathValue final : public OOXMLValue
353{
354 css::uno::Reference<css::embed::XEmbeddedObject> m_component;
355
356public:
357 explicit OOXMLStarMathValue(css::uno::Reference<css::embed::XEmbeddedObject> component);
358 virtual ~OOXMLStarMathValue() override;
359
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;
365};
366
368{
370 OUString mStr;
371
372public:
373 explicit OOXMLPropertySetEntryToString(Id nId);
374 virtual ~OOXMLPropertySetEntryToString() override;
375
376 virtual void sprm(Sprm& rSprm) override;
377 virtual void attribute(Id nId, Value& rValue) override;
378
379 const OUString& getString() const { return mStr; }
380};
381
383{
386
387public:
389 virtual ~OOXMLPropertySetEntryToInteger() override;
390
391 virtual void sprm(Sprm& rSprm) override;
392 virtual void attribute(Id nId, Value& rValue) override;
393
394 int getValue() const { return mnValue; }
395};
396
398{
400 bool mValue;
401
402public:
403 explicit OOXMLPropertySetEntryToBool(Id nId);
404 virtual ~OOXMLPropertySetEntryToBool() override;
405
406 virtual void sprm(Sprm& rSprm) override;
407 virtual void attribute(Id nId, Value& rValue) override;
408
409 bool getValue() const { return mValue; }
410};
411}
412
413/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Handler for properties.
Reference to a resource that generates events and sends them to a handler.
tools::SvRef< Reference< BinaryObj > > Pointer_t
Pointer to reference.
An SPRM: Section, Paragraph and Run Modifier.
Handler for tables.
OOXMLBinaryValue(OOXMLBinaryObjectReference::Pointer_t pBinaryObj)
virtual writerfilter::Reference< BinaryObj >::Pointer_t getBinary() override
Returns binary object of this value.
virtual std::string toString() const override
Returns string representation of this value.
virtual OOXMLValue * clone() const override
OOXMLBinaryObjectReference::Pointer_t mpBinaryObj
virtual css::uno::Any getAny() const override
Returns representation of the value as uno::Any.
virtual int getInt() const override
Returns integer representation of the value.
virtual std::string toString() const override
Returns string representation of this value.
OOXMLBooleanValue & operator=(OOXMLBooleanValue &&)=delete
OOXMLBooleanValue(OOXMLBooleanValue const &)=default
static OOXMLValue::Pointer_t const & Create(bool bValue)
OOXMLBooleanValue(OOXMLBooleanValue &&)=default
OOXMLBooleanValue & operator=(OOXMLBooleanValue const &)=delete
virtual OOXMLValue * clone() const override
virtual int getInt() const override
Returns integer representation of the value.
OOXMLHexValue(OOXMLHexValue const &)=default
virtual OOXMLValue * clone() const override
OOXMLHexValue(OOXMLHexValue &&)=default
OOXMLHexValue & operator=(OOXMLHexValue const &)=default
OOXMLHexValue & operator=(OOXMLHexValue &&)=default
virtual std::string toString() const override
Returns string representation of this value.
virtual OOXMLValue * clone() const override
virtual std::string toString() const override
Returns string representation of this value.
css::uno::Reference< css::io::XInputStream > mxInputStream
OOXMLInputStreamValue(css::uno::Reference< css::io::XInputStream > xInputStream)
virtual css::uno::Any getAny() const override
Returns representation of the value as uno::Any.
static OOXMLValue::Pointer_t Create(sal_Int32 nValue)
virtual std::string toString() const override
Returns string representation of this value.
virtual css::uno::Any getAny() const override
Returns representation of the value as uno::Any.
OOXMLIntegerValue & operator=(OOXMLIntegerValue &&)=delete
OOXMLIntegerValue & operator=(OOXMLIntegerValue const &)=delete
OOXMLIntegerValue(OOXMLIntegerValue const &)=default
virtual int getInt() const override
Returns integer representation of the value.
OOXMLIntegerValue(OOXMLIntegerValue &&)=default
virtual OOXMLValue * clone() const override
virtual OOXMLValue * clone() const override
virtual int getInt() const override
Returns integer representation of the value.
virtual std::string toString() const override
Returns string representation of this value.
npPt is quotient defining how much units are in 1 pt
virtual OOXMLValue * clone() const override
virtual void attribute(Id nId, Value &rValue) override
Receives an attribute.
virtual void sprm(Sprm &rSprm) override
Receives a SPRM.
virtual void sprm(Sprm &rSprm) override
Receives a SPRM.
virtual void attribute(Id nId, Value &rValue) override
Receives an attribute.
virtual void sprm(Sprm &rSprm) override
Receives a SPRM.
virtual void attribute(Id nId, Value &rValue) override
Receives an attribute.
OOXMLPropertySetValue & operator=(OOXMLPropertySetValue &&)=delete
OOXMLPropertySetValue(OOXMLPropertySetValue &&)=default
OOXMLPropertySetValue & operator=(OOXMLPropertySetValue const &)=delete
OOXMLPropertySetValue(OOXMLPropertySet::Pointer_t pPropertySet)
OOXMLPropertySetValue(OOXMLPropertySetValue const &)=default
virtual OOXMLValue * clone() const override
virtual writerfilter::Reference< Properties >::Pointer_t getProperties() override
Returns properties of this value.
virtual std::string toString() const override
Returns string representation of this value.
tools::SvRef< OOXMLPropertySet > Pointer_t
void resolve(Properties &rHandler) override
Resolves the reference.
OOXMLProperties_t::iterator begin()
OOXMLProperties_t::iterator end()
OOXMLPropertySet(OOXMLPropertySet const &)=default
OOXMLPropertySet & operator=(OOXMLPropertySet &&)=default
void add(const OOXMLProperty::Pointer_t &pProperty)
OOXMLPropertySet(OOXMLPropertySet &&)=default
std::vector< OOXMLProperty::Pointer_t > OOXMLProperties_t
OOXMLPropertySet & operator=(OOXMLPropertySet const &)=default
sal_uInt32 getId() const override
Returns id of the SPRM.
std::string getName() const override
Returns name of sprm.
std::string toString() const override
Returns string representation of sprm.
OOXMLProperty(const OOXMLProperty &rSprm)=delete
void resolve(Properties &rProperties)
writerfilter::Reference< Properties >::Pointer_t getProps() override
Returns reference to properties contained in the SPRM.
tools::SvRef< OOXMLProperty > Pointer_t
Value::Pointer_t getValue() override
Returns value of the SPRM.
OOXMLProperty(Id id, OOXMLValue::Pointer_t pValue, Type_t eType)
css::uno::Reference< css::drawing::XShape > mrShape
virtual css::uno::Any getAny() const override
Returns representation of the value as uno::Any.
virtual std::string toString() const override
Returns string representation of this value.
virtual OOXMLValue * clone() const override
OOXMLShapeValue(css::uno::Reference< css::drawing::XShape > xShape)
virtual css::uno::Any getAny() const override
Returns representation of the value as uno::Any.
virtual OOXMLValue * clone() const override
css::uno::Reference< css::embed::XEmbeddedObject > m_component
virtual std::string toString() const override
Returns string representation of this value.
OOXMLStarMathValue(css::uno::Reference< css::embed::XEmbeddedObject > component)
virtual css::uno::Any getAny() const override
Returns representation of the value as uno::Any.
virtual OOXMLValue * clone() const override
virtual OUString getString() const override
Returns string representation of the value.
OOXMLStringValue & operator=(OOXMLStringValue &&)=delete
OOXMLStringValue & operator=(OOXMLStringValue const &)=delete
virtual std::string toString() const override
Returns string representation of this value.
OOXMLStringValue(OOXMLStringValue &&)=default
OOXMLStringValue(OOXMLStringValue const &)=default
OOXMLTable & operator=(OOXMLTable const &)=default
tools::SvRef< OOXMLValue > ValuePointer_t
OOXMLTable(OOXMLTable &&)=default
void add(const ValuePointer_t &pPropertySet)
OOXMLTable(OOXMLTable const &)=default
OOXMLTable & operator=(OOXMLTable &&)=default
std::vector< ValuePointer_t > PropertySets_t
void resolve(Table &rTable) override
Resolves the reference.
OOXMLUniversalMeasureValue(std::string_view pValue, sal_uInt32 npPt)
virtual int getInt() const override
Returns integer representation of the value.
virtual std::string toString() const override
Returns string representation of this value.
OOXMLUniversalMeasureValue(OOXMLUniversalMeasureValue &&)=default
OOXMLUniversalMeasureValue & operator=(OOXMLUniversalMeasureValue &&)=default
OOXMLUniversalMeasureValue & operator=(OOXMLUniversalMeasureValue const &)=default
OOXMLUniversalMeasureValue(OOXMLUniversalMeasureValue const &)=default
OOXMLValue(OOXMLValue const &)=default
virtual std::string toString() const override
Returns string representation of this value.
virtual writerfilter::Reference< BinaryObj >::Pointer_t getBinary() override
Returns binary object of this value.
OOXMLValue & operator=(OOXMLValue &&)=default
virtual OOXMLValue * clone() const
OOXMLValue & operator=(OOXMLValue const &)=default
virtual writerfilter::Reference< Properties >::Pointer_t getProperties() override
Returns properties of this value.
virtual css::uno::Any getAny() const override
Returns representation of the value as uno::Any.
virtual OUString getString() const override
Returns string representation of the value.
OOXMLValue(OOXMLValue &&)=default
virtual int getInt() const override
Returns integer representation of the value.
tools::SvRef< OOXMLValue > Pointer_t
OOXMLNthPtMeasureValue< 2 > OOXMLHpsMeasureValue
Handles OOXML's ST_HpsMeasure value.
OOXMLNthPtMeasureValue< 20 > OOXMLTwipsMeasureValue
Handles OOXML's ST_TwipsMeasure value.
The classes in this file define the interfaces for the resource model of the DocTokenizer:
sal_uInt32 Id