1*b4a4f18cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*b4a4f18cSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*b4a4f18cSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*b4a4f18cSAndrew Rist  * distributed with this work for additional information
6*b4a4f18cSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*b4a4f18cSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*b4a4f18cSAndrew Rist  * "License"); you may not use this file except in compliance
9*b4a4f18cSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*b4a4f18cSAndrew Rist  *
11*b4a4f18cSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*b4a4f18cSAndrew Rist  *
13*b4a4f18cSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*b4a4f18cSAndrew Rist  * software distributed under the License is distributed on an
15*b4a4f18cSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b4a4f18cSAndrew Rist  * KIND, either express or implied.  See the License for the
17*b4a4f18cSAndrew Rist  * specific language governing permissions and limitations
18*b4a4f18cSAndrew Rist  * under the License.
19*b4a4f18cSAndrew Rist  *
20*b4a4f18cSAndrew Rist  *************************************************************/
21*b4a4f18cSAndrew Rist 
22*b4a4f18cSAndrew Rist 
23cdf0e10cSrcweir #include <stdio.h>
24cdf0e10cSrcweir #include <stdlib.h>
25cdf0e10cSrcweir #include <fstream>
26cdf0e10cSrcweir #include <string>
27cdf0e10cSrcweir #include <com/sun/star/awt/Point.hpp>
28cdf0e10cSrcweir #include <com/sun/star/awt/Rectangle.hpp>
29cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
30cdf0e10cSrcweir #include <com/sun/star/drawing/BitmapMode.hpp>
31cdf0e10cSrcweir #include <com/sun/star/drawing/FillStyle.hpp>
32cdf0e10cSrcweir #include <com/sun/star/drawing/HomogenMatrix3.hpp>
33cdf0e10cSrcweir #include <com/sun/star/text/TextContentAnchorType.hpp>
34cdf0e10cSrcweir #include <resourcemodel/WW8ResourceModel.hxx>
35cdf0e10cSrcweir #include <resourcemodel/TagLogger.hxx>
36cdf0e10cSrcweir #include <resourcemodel/util.hxx>
37cdf0e10cSrcweir 
38cdf0e10cSrcweir namespace writerfilter
39cdf0e10cSrcweir {
40cdf0e10cSrcweir using namespace com::sun::star;
41cdf0e10cSrcweir using namespace std;
42cdf0e10cSrcweir using text::TextContentAnchorType;
43cdf0e10cSrcweir 
logger_file()44cdf0e10cSrcweir static string & logger_file()
45cdf0e10cSrcweir {
46cdf0e10cSrcweir 	static string _logger_file = string(getenv("TEMP")?getenv("TEMP"):"/tmp") + "/writerfilter.ooxml.tmp";
47cdf0e10cSrcweir 	return _logger_file;
48cdf0e10cSrcweir }
49cdf0e10cSrcweir 
logger_stream()50cdf0e10cSrcweir static ofstream & logger_stream()
51cdf0e10cSrcweir {
52cdf0e10cSrcweir 	static ofstream _logger_stream(logger_file().c_str());
53cdf0e10cSrcweir 	return _logger_stream;
54cdf0e10cSrcweir }
55cdf0e10cSrcweir 
56cdf0e10cSrcweir 
logger(string prefix,string message)57cdf0e10cSrcweir void logger(string prefix, string message)
58cdf0e10cSrcweir {
59cdf0e10cSrcweir     logger_stream() << prefix <<  ":" << message << endl;
60cdf0e10cSrcweir     logger_stream().flush();
61cdf0e10cSrcweir }
62cdf0e10cSrcweir 
xmlify(const string & str)63cdf0e10cSrcweir     string xmlify(const string & str)
64cdf0e10cSrcweir     {
65cdf0e10cSrcweir         string result = "";
66cdf0e10cSrcweir         char sBuffer[16];
67cdf0e10cSrcweir 
68cdf0e10cSrcweir         for (string::const_iterator aIt = str.begin(); aIt != str.end(); ++aIt)
69cdf0e10cSrcweir         {
70cdf0e10cSrcweir             char c = *aIt;
71cdf0e10cSrcweir 
72cdf0e10cSrcweir             if (isprint(c) && c != '\"')
73cdf0e10cSrcweir             {
74cdf0e10cSrcweir                 if (c == '<')
75cdf0e10cSrcweir                     result += "&lt;";
76cdf0e10cSrcweir                 else if (c == '>')
77cdf0e10cSrcweir                     result += "&gt;";
78cdf0e10cSrcweir                 else if (c == '&')
79cdf0e10cSrcweir                     result += "&amp;";
80cdf0e10cSrcweir                 else
81cdf0e10cSrcweir                     result += c;
82cdf0e10cSrcweir             }
83cdf0e10cSrcweir             else
84cdf0e10cSrcweir             {
85cdf0e10cSrcweir                 snprintf(sBuffer, sizeof(sBuffer), "\\%03d", c);
86cdf0e10cSrcweir                 result += sBuffer;
87cdf0e10cSrcweir             }
88cdf0e10cSrcweir         }
89cdf0e10cSrcweir 
90cdf0e10cSrcweir         return result;
91cdf0e10cSrcweir     }
92cdf0e10cSrcweir 
93cdf0e10cSrcweir #ifdef DEBUG
propertysetToString(uno::Reference<beans::XPropertySet> const & xPropSet)94cdf0e10cSrcweir string propertysetToString(uno::Reference<beans::XPropertySet> const & xPropSet)
95cdf0e10cSrcweir {
96cdf0e10cSrcweir     string sResult;
97cdf0e10cSrcweir 
98cdf0e10cSrcweir     static int nAttribNames = 9;
99cdf0e10cSrcweir     static string sPropertyAttribNames[9] =
100cdf0e10cSrcweir         {
101cdf0e10cSrcweir             "MAYBEVOID",
102cdf0e10cSrcweir             "BOUND",
103cdf0e10cSrcweir             "CONSTRAINED",
104cdf0e10cSrcweir             "TRANSIENT",
105cdf0e10cSrcweir             "READONLY",
106cdf0e10cSrcweir             "MAYBEAMBIGUOUS",
107cdf0e10cSrcweir             "MAYBEDEFAULT",
108cdf0e10cSrcweir             "REMOVEABLE",
109cdf0e10cSrcweir             "OPTIONAL"
110cdf0e10cSrcweir         };
111cdf0e10cSrcweir 
112cdf0e10cSrcweir     static const ::rtl::OUString sMetaFile(RTL_CONSTASCII_USTRINGPARAM("MetaFile"));
113cdf0e10cSrcweir 
114cdf0e10cSrcweir     uno::Reference<beans::XPropertySetInfo> xPropSetInfo
115cdf0e10cSrcweir         (xPropSet->getPropertySetInfo());
116cdf0e10cSrcweir 
117cdf0e10cSrcweir     if (xPropSetInfo.is())
118cdf0e10cSrcweir     {
119cdf0e10cSrcweir         uno::Sequence<beans::Property> aProps(xPropSetInfo->getProperties());
120cdf0e10cSrcweir 
121cdf0e10cSrcweir         sResult +="<propertyset>";
122cdf0e10cSrcweir 
123cdf0e10cSrcweir         for (sal_Int32 n = 0; n < aProps.getLength(); n++)
124cdf0e10cSrcweir         {
125cdf0e10cSrcweir             ::rtl::OUString sPropName(aProps[n].Name);
126cdf0e10cSrcweir 
127cdf0e10cSrcweir             if (xPropSetInfo->hasPropertyByName(sPropName))
128cdf0e10cSrcweir             {
129cdf0e10cSrcweir                 bool bPropertyFound = true;
130cdf0e10cSrcweir                 uno::Any aAny;
131cdf0e10cSrcweir                 try
132cdf0e10cSrcweir                 {
133cdf0e10cSrcweir                     if (sPropName == sMetaFile)
134cdf0e10cSrcweir                         bPropertyFound = false;
135cdf0e10cSrcweir                     else
136cdf0e10cSrcweir                         xPropSet->getPropertyValue(sPropName) >>= aAny;
137cdf0e10cSrcweir                 }
138cdf0e10cSrcweir                 catch (beans::UnknownPropertyException)
139cdf0e10cSrcweir                 {
140cdf0e10cSrcweir                     bPropertyFound = false;
141cdf0e10cSrcweir                 }
142cdf0e10cSrcweir 
143cdf0e10cSrcweir                 if (bPropertyFound)
144cdf0e10cSrcweir                 {
145cdf0e10cSrcweir                     sResult += "<property name=\"";
146cdf0e10cSrcweir                     sResult += OUStringToOString
147cdf0e10cSrcweir                         (sPropName, RTL_TEXTENCODING_ASCII_US).getStr();
148cdf0e10cSrcweir                     sResult +="\" type=\"";
149cdf0e10cSrcweir 
150cdf0e10cSrcweir                     ::rtl::OUString sPropType(aProps[n].Type.getTypeName());
151cdf0e10cSrcweir                     sResult += OUStringToOString
152cdf0e10cSrcweir                         (sPropType, RTL_TEXTENCODING_ASCII_US).getStr();
153cdf0e10cSrcweir 
154cdf0e10cSrcweir                     sResult += "\" attribs=\"";
155cdf0e10cSrcweir 
156cdf0e10cSrcweir                     sal_uInt16 nMask = 1;
157cdf0e10cSrcweir                     bool bFirstAttrib = true;
158cdf0e10cSrcweir                     sal_uInt16 nAttribs = aProps[n].Attributes;
159cdf0e10cSrcweir                     for (int i = 0; i < nAttribNames; i++)
160cdf0e10cSrcweir                     {
161cdf0e10cSrcweir                         if ((nAttribs & nMask) != 0)
162cdf0e10cSrcweir                         {
163cdf0e10cSrcweir                             if (bFirstAttrib)
164cdf0e10cSrcweir                                 bFirstAttrib = false;
165cdf0e10cSrcweir                             else
166cdf0e10cSrcweir                                 sResult += "|";
167cdf0e10cSrcweir 
168cdf0e10cSrcweir                             sResult += sPropertyAttribNames[i];
169cdf0e10cSrcweir                         }
170cdf0e10cSrcweir 
171cdf0e10cSrcweir                         nMask <<= 1;
172cdf0e10cSrcweir                     }
173cdf0e10cSrcweir 
174cdf0e10cSrcweir                     sResult += "\">";
175cdf0e10cSrcweir 
176cdf0e10cSrcweir                     char buffer[256];
177cdf0e10cSrcweir                     if (sPropType ==
178cdf0e10cSrcweir                         ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM
179cdf0e10cSrcweir                                         ("byte")))
180cdf0e10cSrcweir                     {
181cdf0e10cSrcweir                         sal_Int8 nValue = 0;
182cdf0e10cSrcweir                         aAny >>= nValue;
183cdf0e10cSrcweir 
184cdf0e10cSrcweir                         snprintf(buffer, sizeof(buffer), "%d", nValue);
185cdf0e10cSrcweir                         sResult += buffer;
186cdf0e10cSrcweir                     }
187cdf0e10cSrcweir                     if (sPropType ==
188cdf0e10cSrcweir                         ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM
189cdf0e10cSrcweir                                         ("short")))
190cdf0e10cSrcweir                     {
191cdf0e10cSrcweir                         sal_Int16 nValue = 0;
192cdf0e10cSrcweir                         aAny >>= nValue;
193cdf0e10cSrcweir 
194cdf0e10cSrcweir                         snprintf(buffer, sizeof(buffer), "%d", nValue);
195cdf0e10cSrcweir                         sResult += buffer;
196cdf0e10cSrcweir                     }
197cdf0e10cSrcweir                     else if (sPropType ==
198cdf0e10cSrcweir                              ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM
199cdf0e10cSrcweir                                              ("long")))
200cdf0e10cSrcweir                     {
201cdf0e10cSrcweir                         sal_Int32 nValue = 0;
202cdf0e10cSrcweir                         aAny >>= nValue;
203cdf0e10cSrcweir 
204cdf0e10cSrcweir                         snprintf(buffer, sizeof(buffer), "%" SAL_PRIdINT32, nValue);
205cdf0e10cSrcweir                         sResult += buffer;
206cdf0e10cSrcweir                     }
207cdf0e10cSrcweir                     else if (sPropType ==
208cdf0e10cSrcweir                              ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM
209cdf0e10cSrcweir                                              ("float")))
210cdf0e10cSrcweir                     {
211cdf0e10cSrcweir                         float nValue = 0.0;
212cdf0e10cSrcweir                         aAny >>= nValue;
213cdf0e10cSrcweir 
214cdf0e10cSrcweir                         snprintf(buffer, sizeof(buffer), "%f", nValue);
215cdf0e10cSrcweir                         sResult += buffer;
216cdf0e10cSrcweir                     }
217cdf0e10cSrcweir                     else if (sPropType ==
218cdf0e10cSrcweir                              ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM
219cdf0e10cSrcweir                                              ("double")))
220cdf0e10cSrcweir                     {
221cdf0e10cSrcweir                         double nValue = 0.0;
222cdf0e10cSrcweir                         aAny >>= nValue;
223cdf0e10cSrcweir 
224cdf0e10cSrcweir                         snprintf(buffer, sizeof(buffer), "%lf", nValue);
225cdf0e10cSrcweir                         sResult += buffer;
226cdf0e10cSrcweir                     }
227cdf0e10cSrcweir                     else if (sPropType ==
228cdf0e10cSrcweir                              ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM
229cdf0e10cSrcweir                                              ("boolean")))
230cdf0e10cSrcweir                     {
231cdf0e10cSrcweir                         sal_Bool nValue = sal_False;
232cdf0e10cSrcweir                         aAny >>= nValue;
233cdf0e10cSrcweir 
234cdf0e10cSrcweir                         if (nValue)
235cdf0e10cSrcweir                             sResult += "true";
236cdf0e10cSrcweir                         else
237cdf0e10cSrcweir                             sResult += "false";
238cdf0e10cSrcweir                     }
239cdf0e10cSrcweir                     else if (sPropType ==
240cdf0e10cSrcweir                              ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM
241cdf0e10cSrcweir                                              ("string")))
242cdf0e10cSrcweir                     {
243cdf0e10cSrcweir                         ::rtl::OUString sValue;
244cdf0e10cSrcweir                         aAny >>= sValue;
245cdf0e10cSrcweir 
246cdf0e10cSrcweir                         sResult += OUStringToOString
247cdf0e10cSrcweir                             (sValue, RTL_TEXTENCODING_ASCII_US).getStr();
248cdf0e10cSrcweir                     }
249cdf0e10cSrcweir                     else if (sPropType ==
250cdf0e10cSrcweir                              ::rtl::OUString
251cdf0e10cSrcweir                              (RTL_CONSTASCII_USTRINGPARAM
252cdf0e10cSrcweir                               ("com.sun.star.text.TextContentAnchorType")))
253cdf0e10cSrcweir                     {
254cdf0e10cSrcweir                         text::TextContentAnchorType nValue;
255cdf0e10cSrcweir                         aAny >>= nValue;
256cdf0e10cSrcweir 
257cdf0e10cSrcweir                         switch (nValue)
258cdf0e10cSrcweir                         {
259cdf0e10cSrcweir                         case text::TextContentAnchorType_AT_PARAGRAPH:
260cdf0e10cSrcweir                             sResult += "AT_PARAGRAPH";
261cdf0e10cSrcweir                             break;
262cdf0e10cSrcweir                         case text::TextContentAnchorType_AS_CHARACTER:
263cdf0e10cSrcweir                             sResult += "AS_CHARACTER";
264cdf0e10cSrcweir                             break;
265cdf0e10cSrcweir                         case text::TextContentAnchorType_AT_PAGE:
266cdf0e10cSrcweir                             sResult += "AT_PAGE";
267cdf0e10cSrcweir                             break;
268cdf0e10cSrcweir                         case text::TextContentAnchorType_AT_FRAME:
269cdf0e10cSrcweir                             sResult += "AT_FRAME";
270cdf0e10cSrcweir                             break;
271cdf0e10cSrcweir                         case text::TextContentAnchorType_AT_CHARACTER:
272cdf0e10cSrcweir                             sResult += "AT_CHARACTER";
273cdf0e10cSrcweir                             break;
274cdf0e10cSrcweir                         case text::TextContentAnchorType_MAKE_FIXED_SIZE:
275cdf0e10cSrcweir                             sResult += "MAKE_FIXED_SIZE";
276cdf0e10cSrcweir                             break;
277cdf0e10cSrcweir                         default:
278cdf0e10cSrcweir                             break;
279cdf0e10cSrcweir                         }
280cdf0e10cSrcweir                     }
281cdf0e10cSrcweir                     else if (sPropType ==
282cdf0e10cSrcweir                              ::rtl::OUString
283cdf0e10cSrcweir                              (RTL_CONSTASCII_USTRINGPARAM
284cdf0e10cSrcweir                               ("com.sun.star.awt.Point")))
285cdf0e10cSrcweir                     {
286cdf0e10cSrcweir                         awt::Point aPoint;
287cdf0e10cSrcweir                         aAny >>= aPoint;
288cdf0e10cSrcweir 
289cdf0e10cSrcweir                         snprintf(buffer, sizeof(buffer), "(%" SAL_PRIdINT32 ", %" SAL_PRIdINT32 ")", aPoint.X,
290cdf0e10cSrcweir                                  aPoint.Y);
291cdf0e10cSrcweir 
292cdf0e10cSrcweir                         sResult += buffer;
293cdf0e10cSrcweir                     }
294cdf0e10cSrcweir                     else if (sPropType ==
295cdf0e10cSrcweir                              ::rtl::OUString
296cdf0e10cSrcweir                              (RTL_CONSTASCII_USTRINGPARAM
297cdf0e10cSrcweir                               ("com.sun.star.awt.Rectangle")))
298cdf0e10cSrcweir                     {
299cdf0e10cSrcweir                         awt::Rectangle aRect;
300cdf0e10cSrcweir                         aAny >>= aRect;
301cdf0e10cSrcweir 
302cdf0e10cSrcweir                         snprintf(buffer, sizeof(buffer), "(%" SAL_PRIdINT32 ", %" SAL_PRIdINT32 ", %" SAL_PRIdINT32 ", %" SAL_PRIdINT32 ")",
303cdf0e10cSrcweir                                  aRect.X, aRect.Y, aRect.Width, aRect.Height);
304cdf0e10cSrcweir                         sResult += buffer;
305cdf0e10cSrcweir                     }
306cdf0e10cSrcweir                     else if (sPropType ==
307cdf0e10cSrcweir                              ::rtl::OUString
308cdf0e10cSrcweir                              (RTL_CONSTASCII_USTRINGPARAM
309cdf0e10cSrcweir                               ("com.sun.star.drawing.FillStyle")))
310cdf0e10cSrcweir                     {
311cdf0e10cSrcweir                         drawing::FillStyle nValue;
312cdf0e10cSrcweir                         aAny >>= nValue;
313cdf0e10cSrcweir 
314cdf0e10cSrcweir                         switch (nValue)
315cdf0e10cSrcweir                         {
316cdf0e10cSrcweir                         case drawing::FillStyle_NONE:
317cdf0e10cSrcweir                             sResult += "NONE";
318cdf0e10cSrcweir                             break;
319cdf0e10cSrcweir                         case drawing::FillStyle_SOLID:
320cdf0e10cSrcweir                             sResult += "SOLID";
321cdf0e10cSrcweir                             break;
322cdf0e10cSrcweir                         case drawing::FillStyle_GRADIENT:
323cdf0e10cSrcweir                             sResult += "GRADIENT";
324cdf0e10cSrcweir                             break;
325cdf0e10cSrcweir                         case drawing::FillStyle_HATCH:
326cdf0e10cSrcweir                             sResult += "HATCH";
327cdf0e10cSrcweir                             break;
328cdf0e10cSrcweir                         case drawing::FillStyle_BITMAP:
329cdf0e10cSrcweir                             sResult += "BITMAP";
330cdf0e10cSrcweir                             break;
331cdf0e10cSrcweir                         case drawing::FillStyle_MAKE_FIXED_SIZE:
332cdf0e10cSrcweir                             sResult += "MAKE_FIXED_SIZE";
333cdf0e10cSrcweir                             break;
334cdf0e10cSrcweir                         }
335cdf0e10cSrcweir                     }
336cdf0e10cSrcweir                     else if (sPropType ==
337cdf0e10cSrcweir                              ::rtl::OUString
338cdf0e10cSrcweir                              (RTL_CONSTASCII_USTRINGPARAM
339cdf0e10cSrcweir                               ("com.sun.star.drawing.BitmapMode")))
340cdf0e10cSrcweir                     {
341cdf0e10cSrcweir                         drawing::BitmapMode nValue;
342cdf0e10cSrcweir                         aAny >>= nValue;
343cdf0e10cSrcweir 
344cdf0e10cSrcweir                         switch (nValue)
345cdf0e10cSrcweir                         {
346cdf0e10cSrcweir                         case drawing::BitmapMode_REPEAT:
347cdf0e10cSrcweir                             sResult += "REPEAT";
348cdf0e10cSrcweir                             break;
349cdf0e10cSrcweir                         case drawing::BitmapMode_STRETCH:
350cdf0e10cSrcweir                             sResult += "STRETCH";
351cdf0e10cSrcweir                             break;
352cdf0e10cSrcweir                         case drawing::BitmapMode_NO_REPEAT:
353cdf0e10cSrcweir                             sResult += "NO_REPEAT";
354cdf0e10cSrcweir                             break;
355cdf0e10cSrcweir                         case drawing::BitmapMode_MAKE_FIXED_SIZE:
356cdf0e10cSrcweir                             sResult += "MAKE_FIXED_SIZE";
357cdf0e10cSrcweir                             break;
358cdf0e10cSrcweir                         }
359cdf0e10cSrcweir                     }
360cdf0e10cSrcweir                     else if (sPropType ==
361cdf0e10cSrcweir                              ::rtl::OUString
362cdf0e10cSrcweir                              (RTL_CONSTASCII_USTRINGPARAM
363cdf0e10cSrcweir                               ("com.sun.star.drawing.HomogenMatrix3")))
364cdf0e10cSrcweir                     {
365cdf0e10cSrcweir                         drawing::HomogenMatrix3 aMatrix;
366cdf0e10cSrcweir                         aAny >>= aMatrix;
367cdf0e10cSrcweir 
368cdf0e10cSrcweir                         snprintf(buffer, sizeof(buffer),
369cdf0e10cSrcweir                                  "((%f %f %f)(%f %f %f)(%f %f %f))",
370cdf0e10cSrcweir                                  aMatrix.Line1.Column1,
371cdf0e10cSrcweir                                  aMatrix.Line1.Column2,
372cdf0e10cSrcweir                                  aMatrix.Line1.Column3,
373cdf0e10cSrcweir                                  aMatrix.Line2.Column1,
374cdf0e10cSrcweir                                  aMatrix.Line2.Column2,
375cdf0e10cSrcweir                                  aMatrix.Line2.Column3,
376cdf0e10cSrcweir                                  aMatrix.Line3.Column1,
377cdf0e10cSrcweir                                  aMatrix.Line3.Column2,
378cdf0e10cSrcweir                                  aMatrix.Line3.Column3);
379cdf0e10cSrcweir                         sResult += buffer;
380cdf0e10cSrcweir                     }
381cdf0e10cSrcweir 
382cdf0e10cSrcweir                     sResult += "</property>";
383cdf0e10cSrcweir                 }
384cdf0e10cSrcweir             }
385cdf0e10cSrcweir 			else
386cdf0e10cSrcweir 			{
387cdf0e10cSrcweir 				sResult += "<unknown-property>";
388cdf0e10cSrcweir 				sResult += OUStringToOString
389cdf0e10cSrcweir 				(sPropName, RTL_TEXTENCODING_ASCII_US).getStr();
390cdf0e10cSrcweir 				sResult += "</unknown-property>";
391cdf0e10cSrcweir 			}
392cdf0e10cSrcweir         }
393cdf0e10cSrcweir         sResult += "</propertyset>";
394cdf0e10cSrcweir     }
395cdf0e10cSrcweir 
396cdf0e10cSrcweir     return sResult;
397cdf0e10cSrcweir }
398cdf0e10cSrcweir 
toString(uno::Reference<text::XTextRange> textRange)399cdf0e10cSrcweir string toString(uno::Reference< text::XTextRange > textRange)
400cdf0e10cSrcweir {
401cdf0e10cSrcweir     string result;
402cdf0e10cSrcweir 
403cdf0e10cSrcweir     if (textRange.get())
404cdf0e10cSrcweir     {
405cdf0e10cSrcweir         rtl::OUString aOUStr = textRange->getString();
406cdf0e10cSrcweir         rtl::OString aOStr(aOUStr.getStr(), aOUStr.getLength(),  RTL_TEXTENCODING_ASCII_US );
407cdf0e10cSrcweir 
408cdf0e10cSrcweir         result = aOStr.getStr();
409cdf0e10cSrcweir     }
410cdf0e10cSrcweir     else
411cdf0e10cSrcweir     {
412cdf0e10cSrcweir         result="(nil)";
413cdf0e10cSrcweir     }
414cdf0e10cSrcweir 
415cdf0e10cSrcweir     return result;
416cdf0e10cSrcweir }
417cdf0e10cSrcweir 
toString(const string & rString)418cdf0e10cSrcweir string toString(const string & rString)
419cdf0e10cSrcweir {
420cdf0e10cSrcweir     return rString;
421cdf0e10cSrcweir }
422cdf0e10cSrcweir #endif
423cdf0e10cSrcweir }
424