Line data Source code
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 : #ifndef INCLUDED_OOXML_PROPERTY_SET_IMPL_HXX
20 : #define INCLUDED_OOXML_PROPERTY_SET_IMPL_HXX
21 :
22 : #include <vector>
23 : #include "OOXMLPropertySet.hxx"
24 : #include "OOXMLBinaryObjectReference.hxx"
25 : #include <com/sun/star/embed/XEmbeddedObject.hpp>
26 :
27 : namespace com {
28 : namespace sun {
29 : namespace star {
30 : namespace drawing {
31 : class XShape;
32 : }}}}
33 :
34 : namespace writerfilter {
35 : namespace ooxml
36 : {
37 : using namespace ::std;
38 : using ::com::sun::star::drawing::XShape;
39 :
40 0 : class OOXMLValue : public Value
41 : {
42 : public:
43 : typedef boost::shared_ptr<OOXMLValue> Pointer_t;
44 : OOXMLValue();
45 : virtual ~OOXMLValue();
46 :
47 : virtual int getInt() const SAL_OVERRIDE;
48 : virtual bool getBool() const;
49 : virtual OUString getString() const SAL_OVERRIDE;
50 : virtual uno::Any getAny() const SAL_OVERRIDE;
51 : virtual writerfilter::Reference<Properties>::Pointer_t getProperties() SAL_OVERRIDE;
52 : virtual writerfilter::Reference<Stream>::Pointer_t getStream() SAL_OVERRIDE;
53 : virtual writerfilter::Reference<BinaryObj>::Pointer_t getBinary() SAL_OVERRIDE;
54 : virtual string toString() const SAL_OVERRIDE;
55 : virtual OOXMLValue * clone() const;
56 : };
57 :
58 : class OOXMLPropertyImpl : public OOXMLProperty
59 : {
60 : public:
61 : enum Type_t { SPRM, ATTRIBUTE };
62 : private:
63 : Id mId;
64 : mutable OOXMLValue::Pointer_t mpValue;
65 : Type_t meType;
66 :
67 : public:
68 : typedef boost::shared_ptr<OOXMLProperty> Pointer_t;
69 :
70 : OOXMLPropertyImpl(Id id, OOXMLValue::Pointer_t pValue, Type_t eType);
71 : OOXMLPropertyImpl(const OOXMLPropertyImpl & rSprm);
72 : virtual ~OOXMLPropertyImpl();
73 :
74 : virtual sal_uInt32 getId() const SAL_OVERRIDE;
75 : virtual Value::Pointer_t getValue() SAL_OVERRIDE;
76 : virtual writerfilter::Reference<BinaryObj>::Pointer_t getBinary() SAL_OVERRIDE;
77 : virtual writerfilter::Reference<Stream>::Pointer_t getStream() SAL_OVERRIDE;
78 : virtual writerfilter::Reference<Properties>::Pointer_t getProps() SAL_OVERRIDE;
79 : virtual string getName() const SAL_OVERRIDE;
80 : virtual Kind getKind() SAL_OVERRIDE;
81 : virtual string toString() const SAL_OVERRIDE;
82 : virtual Sprm * clone() SAL_OVERRIDE;
83 : virtual void resolve(Properties & rProperties) SAL_OVERRIDE;
84 : };
85 :
86 : class OOXMLBinaryValue : public OOXMLValue
87 : {
88 : protected:
89 : mutable OOXMLBinaryObjectReference::Pointer_t mpBinaryObj;
90 : public:
91 : explicit OOXMLBinaryValue(OOXMLBinaryObjectReference::Pointer_t pBinaryObj);
92 : virtual ~OOXMLBinaryValue();
93 :
94 : virtual writerfilter::Reference<BinaryObj>::Pointer_t getBinary() SAL_OVERRIDE;
95 : virtual string toString() const SAL_OVERRIDE;
96 : virtual OOXMLValue * clone() const SAL_OVERRIDE;
97 : };
98 :
99 0 : class OOXMLBooleanValue : public OOXMLValue
100 : {
101 : protected:
102 : bool mbValue;
103 : public:
104 : explicit OOXMLBooleanValue(bool bValue);
105 : explicit OOXMLBooleanValue(const OUString & rValue);
106 : virtual ~OOXMLBooleanValue();
107 :
108 : virtual int getInt() const SAL_OVERRIDE;
109 : virtual bool getBool() const SAL_OVERRIDE;
110 : virtual uno::Any getAny() const SAL_OVERRIDE;
111 : virtual string toString() const SAL_OVERRIDE;
112 : virtual OOXMLValue * clone() const SAL_OVERRIDE;
113 : };
114 :
115 0 : class OOXMLStringValue : public OOXMLValue
116 : {
117 : protected:
118 : OUString mStr;
119 : public:
120 : explicit OOXMLStringValue(const OUString & rStr);
121 : virtual ~OOXMLStringValue();
122 :
123 : virtual uno::Any getAny() const SAL_OVERRIDE;
124 : virtual OUString getString() const SAL_OVERRIDE;
125 : virtual string toString() const SAL_OVERRIDE;
126 : virtual OOXMLValue * clone() const SAL_OVERRIDE;
127 : };
128 :
129 : class OOXMLInputStreamValue : public OOXMLValue
130 : {
131 : protected:
132 : uno::Reference<io::XInputStream> mxInputStream;
133 :
134 : public:
135 : explicit OOXMLInputStreamValue(uno::Reference<io::XInputStream> xInputStream);
136 : virtual ~OOXMLInputStreamValue();
137 :
138 : virtual uno::Any getAny() const SAL_OVERRIDE;
139 : virtual string toString() const SAL_OVERRIDE;
140 : virtual OOXMLValue * clone() const SAL_OVERRIDE;
141 : };
142 :
143 : struct OOXMLPropertySetImplCompare
144 : {
145 : bool operator()(const OOXMLProperty::Pointer_t x,
146 : const OOXMLProperty::Pointer_t y) const;
147 : };
148 :
149 0 : class OOXMLPropertySetImpl : public OOXMLPropertySet
150 : {
151 : public:
152 : typedef vector<OOXMLProperty::Pointer_t> OOXMLProperties_t;
153 : private:
154 : OOXMLProperties_t mProperties;
155 : string msType;
156 : public:
157 : OOXMLPropertySetImpl();
158 : virtual ~OOXMLPropertySetImpl();
159 :
160 : virtual void resolve(Properties & rHandler) SAL_OVERRIDE;
161 : virtual string getType() const SAL_OVERRIDE;
162 : virtual void add(OOXMLProperty::Pointer_t pProperty) SAL_OVERRIDE;
163 : virtual void add(OOXMLPropertySet::Pointer_t pPropertySet) SAL_OVERRIDE;
164 : virtual OOXMLPropertySet * clone() const SAL_OVERRIDE;
165 :
166 : OOXMLProperties_t::iterator begin();
167 : OOXMLProperties_t::iterator end();
168 : OOXMLProperties_t::const_iterator begin() const;
169 : OOXMLProperties_t::const_iterator end() const;
170 :
171 : virtual void setType(const string & rsType) SAL_OVERRIDE;
172 :
173 : virtual string toString() SAL_OVERRIDE;
174 : };
175 :
176 0 : class OOXMLPropertySetValue : public OOXMLValue
177 : {
178 : OOXMLPropertySet::Pointer_t mpPropertySet;
179 : public:
180 : OOXMLPropertySetValue(OOXMLPropertySet::Pointer_t pPropertySet);
181 : virtual ~OOXMLPropertySetValue();
182 :
183 : virtual writerfilter::Reference<Properties>::Pointer_t getProperties() SAL_OVERRIDE;
184 : virtual string toString() const SAL_OVERRIDE;
185 : virtual OOXMLValue * clone() const SAL_OVERRIDE;
186 : };
187 :
188 0 : class OOXMLIntegerValue : public OOXMLValue
189 : {
190 : protected:
191 : sal_Int32 mnValue;
192 : public:
193 : explicit OOXMLIntegerValue(sal_Int32 nValue);
194 : explicit OOXMLIntegerValue(const OUString & rValue);
195 : virtual ~OOXMLIntegerValue();
196 :
197 : virtual int getInt() const SAL_OVERRIDE;
198 : virtual uno::Any getAny() const SAL_OVERRIDE;
199 : virtual string toString() const SAL_OVERRIDE;
200 : virtual OOXMLValue * clone() const SAL_OVERRIDE;
201 : };
202 :
203 0 : class OOXMLHexValue : public OOXMLValue
204 : {
205 : protected:
206 : sal_uInt32 mnValue;
207 : public:
208 : explicit OOXMLHexValue(sal_uInt32 nValue);
209 : explicit OOXMLHexValue(const OUString & rValue);
210 : virtual ~OOXMLHexValue();
211 :
212 : virtual int getInt() const SAL_OVERRIDE;
213 : virtual string toString() const SAL_OVERRIDE;
214 : virtual OOXMLValue * clone() const SAL_OVERRIDE;
215 : };
216 :
217 : /// Handles OOXML's ST_UniversalMeasure value.
218 0 : class OOXMLUniversalMeasureValue : public OOXMLValue
219 : {
220 : protected:
221 : sal_uInt32 mnValue;
222 : public:
223 : explicit OOXMLUniversalMeasureValue(const OUString& rValue);
224 : virtual ~OOXMLUniversalMeasureValue();
225 :
226 : virtual int getInt() const SAL_OVERRIDE;
227 : virtual string toString() const SAL_OVERRIDE;
228 : virtual OOXMLValue* clone() const SAL_OVERRIDE;
229 : };
230 :
231 : class OOXMLShapeValue : public OOXMLValue
232 : {
233 : protected:
234 : uno::Reference<XShape> mrShape;
235 : public:
236 : explicit OOXMLShapeValue(uno::Reference<XShape> rShape);
237 : virtual ~OOXMLShapeValue();
238 :
239 : virtual uno::Any getAny() const SAL_OVERRIDE;
240 : virtual string toString() const SAL_OVERRIDE;
241 : virtual OOXMLValue * clone() const SAL_OVERRIDE;
242 : };
243 :
244 : class OOXMLStarMathValue : public OOXMLValue
245 : {
246 : protected:
247 : uno::Reference< embed::XEmbeddedObject > component;
248 : public:
249 : explicit OOXMLStarMathValue( uno::Reference< embed::XEmbeddedObject > component );
250 : virtual ~OOXMLStarMathValue();
251 :
252 : virtual uno::Any getAny() const SAL_OVERRIDE;
253 : virtual string toString() const SAL_OVERRIDE;
254 : virtual OOXMLValue * clone() const SAL_OVERRIDE;
255 : };
256 :
257 0 : class OOXMLTableImpl : public OOXMLTable
258 : {
259 : public:
260 : typedef boost::shared_ptr<OOXMLValue> ValuePointer_t;
261 : private:
262 : typedef vector<ValuePointer_t> PropertySets_t;
263 : PropertySets_t mPropertySets;
264 :
265 : public:
266 : OOXMLTableImpl();
267 : virtual ~OOXMLTableImpl();
268 :
269 : virtual void resolve(Table & rTable) SAL_OVERRIDE;
270 : virtual void add(ValuePointer_t pPropertySet);
271 : virtual string getType() const SAL_OVERRIDE;
272 : virtual OOXMLTable * clone() const SAL_OVERRIDE;
273 : };
274 :
275 : class OOXMLPropertySetEntryToString : public Properties
276 : {
277 : Id mnId;
278 : OUString mStr;
279 :
280 : public:
281 : OOXMLPropertySetEntryToString(Id nId);
282 : virtual ~OOXMLPropertySetEntryToString();
283 :
284 : virtual void sprm(Sprm & rSprm) SAL_OVERRIDE;
285 : virtual void attribute(Id nId, Value & rValue) SAL_OVERRIDE;
286 :
287 : const OUString & getString() const;
288 : };
289 :
290 : class OOXMLPropertySetEntryToInteger : public Properties
291 : {
292 : Id mnId;
293 : int mnValue;
294 : public:
295 : OOXMLPropertySetEntryToInteger(Id nId);
296 : virtual ~OOXMLPropertySetEntryToInteger();
297 :
298 : virtual void sprm(Sprm & rSprm) SAL_OVERRIDE;
299 : virtual void attribute(Id nId, Value & rValue) SAL_OVERRIDE;
300 :
301 : int getValue() const;
302 : };
303 :
304 : Sprm::Kind SprmKind(sal_uInt32 nSprmCode);
305 :
306 : } // namespace ooxml
307 : } // namespace writerfilter
308 :
309 : #endif // INCLUDED_OOXML_PROPERTY_SET_IMPL_HXX
310 :
311 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|