1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef INCLUDED_OOXML_PROPERTY_SET_IMPL_HXX
24 #define INCLUDED_OOXML_PROPERTY_SET_IMPL_HXX
25 
26 #include <vector>
27 #include "OOXMLPropertySet.hxx"
28 #include "OOXMLBinaryObjectReference.hxx"
29 
30 namespace com {
31 namespace sun {
32 namespace star {
33 namespace drawing {
34 class XShape;
35 }}}}
36 
37 namespace writerfilter {
38 namespace ooxml
39 {
40 using namespace ::std;
41 using ::com::sun::star::drawing::XShape;
42 
43 class OOXMLValue : public Value
44 {
45 public:
46     typedef boost::shared_ptr<OOXMLValue> Pointer_t;
47     OOXMLValue();
48     virtual ~OOXMLValue();
49 
50     virtual sal_Int32 getInt() const;
51     virtual bool getBool() const;
52     virtual ::rtl::OUString getString() const;
53     virtual uno::Any getAny() const;
54     virtual writerfilter::Reference<Properties>::Pointer_t getProperties();
55     virtual writerfilter::Reference<Stream>::Pointer_t getStream();
56     virtual writerfilter::Reference<BinaryObj>::Pointer_t getBinary();
57     virtual string toString() const;
58     virtual OOXMLValue * clone() const;
59 };
60 
61 class OOXMLPropertyImpl : public OOXMLProperty
62 {
63 public:
64     enum Type_t { SPRM, ATTRIBUTE };
65 private:
66     Id mId;
67     mutable OOXMLValue::Pointer_t mpValue;
68     Type_t meType;
69 
70 public:
71     typedef boost::shared_ptr<OOXMLProperty> Pointer_t;
72 
73     OOXMLPropertyImpl(Id id, OOXMLValue::Pointer_t pValue, Type_t eType);
74     OOXMLPropertyImpl(const OOXMLPropertyImpl & rSprm);
75     virtual ~OOXMLPropertyImpl();
76 
77     virtual sal_uInt32 getId() const;
78     virtual Value::Pointer_t getValue();
79     virtual writerfilter::Reference<BinaryObj>::Pointer_t getBinary();
80     virtual writerfilter::Reference<Stream>::Pointer_t getStream();
81     virtual writerfilter::Reference<Properties>::Pointer_t getProps();
82     virtual string getName() const;
83     virtual Kind getKind();
84     virtual string toString() const;
85     virtual Sprm * clone();
86     virtual void resolve(Properties & rProperties);
87 };
88 
89 class OOXMLBinaryValue : public OOXMLValue
90 {
91 protected:
92     mutable OOXMLBinaryObjectReference::Pointer_t mpBinaryObj;
93 public:
94     explicit OOXMLBinaryValue(OOXMLBinaryObjectReference::Pointer_t pBinaryObj);
95     virtual ~OOXMLBinaryValue();
96 
97     virtual writerfilter::Reference<BinaryObj>::Pointer_t getBinary();
98     virtual string toString() const;
99     virtual OOXMLValue * clone() const;
100 };
101 
102 class OOXMLBooleanValue : public OOXMLValue
103 {
104 protected:
105     bool mbValue;
106 public:
107     explicit OOXMLBooleanValue(bool bValue);
108     explicit OOXMLBooleanValue(const rtl::OUString & rValue);
109     virtual ~OOXMLBooleanValue();
110 
111     virtual sal_Int32 getInt() const;
112     virtual bool getBool() const;
113     virtual uno::Any getAny() const;
114     virtual string toString() const;
115     virtual OOXMLValue * clone() const;
116 };
117 
118 class OOXMLStringValue : public OOXMLValue
119 {
120 protected:
121     rtl::OUString mStr;
122 public:
123     explicit OOXMLStringValue(const rtl::OUString & rStr);
124     virtual ~OOXMLStringValue();
125 
126     virtual uno::Any getAny() const;
127     virtual rtl::OUString getString() const;
128     virtual string toString() const;
129     virtual OOXMLValue * clone() const;
130 };
131 
132 class OOXMLInputStreamValue : public OOXMLValue
133 {
134 protected:
135     uno::Reference<io::XInputStream> mxInputStream;
136 
137 public:
138     explicit OOXMLInputStreamValue(uno::Reference<io::XInputStream> xInputStream);
139     virtual ~OOXMLInputStreamValue();
140 
141     virtual uno::Any getAny() const;
142     virtual string toString() const;
143     virtual OOXMLValue * clone() const;
144 };
145 
146 struct OOXMLPropertySetImplCompare
147 {
148     bool operator()(const OOXMLProperty::Pointer_t x,
149                     const OOXMLProperty::Pointer_t y) const;
150 };
151 
152 class OOXMLPropertySetImpl : public OOXMLPropertySet
153 {
154 public:
155     typedef vector<OOXMLProperty::Pointer_t> OOXMLProperties_t;
156 private:
157     OOXMLProperties_t mProperties;
158     string msType;
159 public:
160     OOXMLPropertySetImpl();
161     virtual ~OOXMLPropertySetImpl();
162 
163     virtual void resolve(Properties & rHandler);
164     virtual string getType() const;
165     virtual void add(OOXMLProperty::Pointer_t pProperty);
166     virtual void add(OOXMLPropertySet::Pointer_t pPropertySet);
167     virtual OOXMLPropertySet * clone() const;
168 
169     OOXMLProperties_t::iterator begin();
170     OOXMLProperties_t::iterator end();
171     OOXMLProperties_t::const_iterator begin() const;
172     OOXMLProperties_t::const_iterator end() const;
173 
174     virtual void setType(const string & rsType);
175 
176     virtual string toString();
177 };
178 
179 class OOXMLPropertySetValue : public OOXMLValue
180 {
181     OOXMLPropertySet::Pointer_t mpPropertySet;
182 public:
183     OOXMLPropertySetValue(OOXMLPropertySet::Pointer_t pPropertySet);
184     virtual ~OOXMLPropertySetValue();
185 
186     virtual writerfilter::Reference<Properties>::Pointer_t getProperties();
187     virtual string toString() const;
188     virtual OOXMLValue * clone() const;
189 };
190 
191 class OOXMLIntegerValue : public OOXMLValue
192 {
193 protected:
194     sal_Int32 mnValue;
195 public:
196     explicit OOXMLIntegerValue(sal_Int32 nValue);
197     explicit OOXMLIntegerValue(const rtl::OUString & rValue);
198     virtual ~OOXMLIntegerValue();
199 
200     virtual sal_Int32 getInt() const;
201     virtual uno::Any getAny() const;
202     virtual string toString() const;
203     virtual OOXMLValue * clone() const;
204 };
205 
206 class OOXMLHexValue : public OOXMLValue
207 {
208 protected:
209     sal_uInt32 mnValue;
210 public:
211     explicit OOXMLHexValue(sal_uInt32 nValue);
212     explicit OOXMLHexValue(const rtl::OUString & rValue);
213     virtual ~OOXMLHexValue();
214 
215     virtual sal_Int32 getInt() const;
216     virtual string toString() const;
217     virtual OOXMLValue * clone() const;
218 };
219 
220 class OOXMLShapeValue : public OOXMLValue
221 {
222 protected:
223     uno::Reference<XShape> mrShape;
224 public:
225     explicit OOXMLShapeValue(uno::Reference<XShape> rShape);
226     virtual ~OOXMLShapeValue();
227 
228     virtual uno::Any getAny() const;
229     virtual string toString() const;
230     virtual OOXMLValue * clone() const;
231 };
232 
233 class OOXMLTableImpl : public OOXMLTable
234 {
235 public:
236     typedef boost::shared_ptr<OOXMLValue> ValuePointer_t;
237 private:
238     typedef vector<ValuePointer_t> PropertySets_t;
239     PropertySets_t mPropertySets;
240 
241 public:
242     OOXMLTableImpl();
243     virtual ~OOXMLTableImpl();
244 
245     virtual void resolve(Table & rTable);
246     virtual void add(ValuePointer_t pPropertySet);
247     virtual string getType() const;
248     virtual OOXMLTable * clone() const;
249 };
250 
251 class OOXMLPropertySetEntryToString : public Properties
252 {
253     Id mnId;
254     ::rtl::OUString mStr;
255 
256 public:
257     OOXMLPropertySetEntryToString(Id nId);
258     virtual ~OOXMLPropertySetEntryToString();
259 
260     virtual void sprm(Sprm & rSprm);
261     virtual void attribute(Id nId, Value & rValue);
262 
263     const ::rtl::OUString & getString() const;
264 };
265 
266 class OOXMLPropertySetEntryToInteger : public Properties
267 {
268     Id mnId;
269     int mnValue;
270 public:
271     OOXMLPropertySetEntryToInteger(Id nId);
272     virtual ~OOXMLPropertySetEntryToInteger();
273 
274     virtual void sprm(Sprm & rSprm);
275     virtual void attribute(Id nId, Value & rValue);
276 
277     int getValue() const;
278 };
279 
280 Sprm::Kind SprmKind(sal_uInt32 nSprmCode);
281 
282 }  // namespace ooxml
283 } // namespace writerfilter
284 
285 #endif // INCLUDED_OOXML_PROPERTY_SET_IMPL_HXX
286