xref: /trunk/main/xmloff/source/draw/XMLImageMapExport.cxx (revision 63bba73cc51e0afb45f8a8d578158724bb5afee8)
1*63bba73cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*63bba73cSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*63bba73cSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*63bba73cSAndrew Rist  * distributed with this work for additional information
6*63bba73cSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*63bba73cSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*63bba73cSAndrew Rist  * "License"); you may not use this file except in compliance
9*63bba73cSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*63bba73cSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*63bba73cSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*63bba73cSAndrew Rist  * software distributed under the License is distributed on an
15*63bba73cSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*63bba73cSAndrew Rist  * KIND, either express or implied.  See the License for the
17*63bba73cSAndrew Rist  * specific language governing permissions and limitations
18*63bba73cSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*63bba73cSAndrew Rist  *************************************************************/
21*63bba73cSAndrew Rist 
22*63bba73cSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_xmloff.hxx"
26cdf0e10cSrcweir #include "XMLImageMapExport.hxx"
27cdf0e10cSrcweir #include <rtl/ustring.hxx>
28cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
29cdf0e10cSrcweir #include <tools/debug.hxx>
30cdf0e10cSrcweir #include <com/sun/star/uno/Reference.h>
31cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.h>
32cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
33cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
34cdf0e10cSrcweir #include <com/sun/star/container/XIndexContainer.hpp>
35cdf0e10cSrcweir 
36cdf0e10cSrcweir #ifndef _COM_SUN_STAR_DOCUMENT_XEVENTSSUPPLIER_HPP
37cdf0e10cSrcweir #include <com/sun/star/document/XEventsSupplier.hpp>
38cdf0e10cSrcweir #endif
39cdf0e10cSrcweir #include <com/sun/star/awt/Rectangle.hpp>
40cdf0e10cSrcweir #include <com/sun/star/awt/Point.hpp>
41cdf0e10cSrcweir #include <com/sun/star/awt/Size.hpp>
42cdf0e10cSrcweir #include <com/sun/star/drawing/PointSequence.hpp>
43cdf0e10cSrcweir #include <xmloff/xmlexp.hxx>
44cdf0e10cSrcweir #include "xmloff/xmlnmspe.hxx"
45cdf0e10cSrcweir #include <xmloff/xmltoken.hxx>
46cdf0e10cSrcweir #include <xmloff/XMLEventExport.hxx>
47cdf0e10cSrcweir #include <xmloff/xmluconv.hxx>
48cdf0e10cSrcweir #include "xexptran.hxx"
49cdf0e10cSrcweir 
50cdf0e10cSrcweir 
51cdf0e10cSrcweir 
52cdf0e10cSrcweir using namespace ::com::sun::star;
53cdf0e10cSrcweir using namespace ::xmloff::token;
54cdf0e10cSrcweir 
55cdf0e10cSrcweir using ::rtl::OUString;
56cdf0e10cSrcweir using ::rtl::OUStringBuffer;
57cdf0e10cSrcweir using ::com::sun::star::uno::Any;
58cdf0e10cSrcweir using ::com::sun::star::uno::UNO_QUERY;
59cdf0e10cSrcweir using ::com::sun::star::uno::Sequence;
60cdf0e10cSrcweir using ::com::sun::star::uno::Reference;
61cdf0e10cSrcweir using ::com::sun::star::beans::XPropertySet;
62cdf0e10cSrcweir using ::com::sun::star::container::XIndexContainer;
63cdf0e10cSrcweir using ::com::sun::star::document::XEventsSupplier;
64cdf0e10cSrcweir using ::com::sun::star::lang::XServiceInfo;
65cdf0e10cSrcweir using ::com::sun::star::drawing::PointSequence;
66cdf0e10cSrcweir 
67cdf0e10cSrcweir 
68cdf0e10cSrcweir const sal_Char sAPI_ImageMapRectangleObject[] = "com.sun.star.image.ImageMapRectangleObject";
69cdf0e10cSrcweir const sal_Char sAPI_ImageMapCircleObject[] = "com.sun.star.image.ImageMapCircleObject";
70cdf0e10cSrcweir const sal_Char sAPI_ImageMapPolygonObject[] = "com.sun.star.image.ImageMapPolygonObject";
71cdf0e10cSrcweir 
72cdf0e10cSrcweir XMLImageMapExport::XMLImageMapExport(SvXMLExport& rExp) :
73cdf0e10cSrcweir     msBoundary(RTL_CONSTASCII_USTRINGPARAM("Boundary")),
74cdf0e10cSrcweir     msCenter(RTL_CONSTASCII_USTRINGPARAM("Center")),
75cdf0e10cSrcweir     msDescription(RTL_CONSTASCII_USTRINGPARAM("Description")),
76cdf0e10cSrcweir     msImageMap(RTL_CONSTASCII_USTRINGPARAM("ImageMap")),
77cdf0e10cSrcweir     msIsActive(RTL_CONSTASCII_USTRINGPARAM("IsActive")),
78cdf0e10cSrcweir     msName(RTL_CONSTASCII_USTRINGPARAM("Name")),
79cdf0e10cSrcweir     msPolygon(RTL_CONSTASCII_USTRINGPARAM("Polygon")),
80cdf0e10cSrcweir     msRadius(RTL_CONSTASCII_USTRINGPARAM("Radius")),
81cdf0e10cSrcweir     msTarget(RTL_CONSTASCII_USTRINGPARAM("Target")),
82cdf0e10cSrcweir     msURL(RTL_CONSTASCII_USTRINGPARAM("URL")),
83cdf0e10cSrcweir     msTitle(RTL_CONSTASCII_USTRINGPARAM("Title")),
84cdf0e10cSrcweir     mrExport(rExp),
85cdf0e10cSrcweir     mbWhiteSpace(sal_True)
86cdf0e10cSrcweir {
87cdf0e10cSrcweir }
88cdf0e10cSrcweir 
89cdf0e10cSrcweir XMLImageMapExport::~XMLImageMapExport()
90cdf0e10cSrcweir {
91cdf0e10cSrcweir 
92cdf0e10cSrcweir }
93cdf0e10cSrcweir 
94cdf0e10cSrcweir void XMLImageMapExport::Export(
95cdf0e10cSrcweir     const Reference<XPropertySet> & rPropertySet)
96cdf0e10cSrcweir {
97cdf0e10cSrcweir     if (rPropertySet->getPropertySetInfo()->hasPropertyByName(msImageMap))
98cdf0e10cSrcweir     {
99cdf0e10cSrcweir         Any aAny = rPropertySet->getPropertyValue(msImageMap);
100cdf0e10cSrcweir         Reference<XIndexContainer> aContainer;
101cdf0e10cSrcweir         aAny >>= aContainer;
102cdf0e10cSrcweir 
103cdf0e10cSrcweir         Export(aContainer);
104cdf0e10cSrcweir     }
105cdf0e10cSrcweir     // else: no ImageMap property -> nothing to do
106cdf0e10cSrcweir }
107cdf0e10cSrcweir 
108cdf0e10cSrcweir void XMLImageMapExport::Export(
109cdf0e10cSrcweir     const Reference<XIndexContainer> & rContainer)
110cdf0e10cSrcweir {
111cdf0e10cSrcweir     if (rContainer.is())
112cdf0e10cSrcweir     {
113cdf0e10cSrcweir         if (rContainer->hasElements())
114cdf0e10cSrcweir         {
115cdf0e10cSrcweir             // image map container element
116cdf0e10cSrcweir             SvXMLElementExport aImageMapElement(
117cdf0e10cSrcweir                 mrExport, XML_NAMESPACE_DRAW, XML_IMAGE_MAP,
118cdf0e10cSrcweir                 mbWhiteSpace, mbWhiteSpace);
119cdf0e10cSrcweir 
120cdf0e10cSrcweir             // iterate over image map elements and call ExportMapEntry(...)
121cdf0e10cSrcweir             // for each
122cdf0e10cSrcweir             sal_Int32 nLength = rContainer->getCount();
123cdf0e10cSrcweir             for(sal_Int32 i = 0; i < nLength; i++)
124cdf0e10cSrcweir             {
125cdf0e10cSrcweir                 Any aAny = rContainer->getByIndex(i);
126cdf0e10cSrcweir                 Reference<XPropertySet> rElement;
127cdf0e10cSrcweir                 aAny >>= rElement;
128cdf0e10cSrcweir 
129cdf0e10cSrcweir                 DBG_ASSERT(rElement.is(), "Image map element is empty!");
130cdf0e10cSrcweir                 if (rElement.is())
131cdf0e10cSrcweir                 {
132cdf0e10cSrcweir                     ExportMapEntry(rElement);
133cdf0e10cSrcweir                 }
134cdf0e10cSrcweir             }
135cdf0e10cSrcweir         }
136cdf0e10cSrcweir         // else: container is empty -> nothing to do
137cdf0e10cSrcweir     }
138cdf0e10cSrcweir     // else: no container -> nothign to do
139cdf0e10cSrcweir }
140cdf0e10cSrcweir 
141cdf0e10cSrcweir 
142cdf0e10cSrcweir void XMLImageMapExport::ExportMapEntry(
143cdf0e10cSrcweir     const Reference<XPropertySet> & rPropertySet)
144cdf0e10cSrcweir {
145cdf0e10cSrcweir     Reference<XServiceInfo> xServiceInfo(rPropertySet, UNO_QUERY);
146cdf0e10cSrcweir     if (xServiceInfo.is())
147cdf0e10cSrcweir     {
148cdf0e10cSrcweir         enum XMLTokenEnum eType = XML_TOKEN_INVALID;
149cdf0e10cSrcweir 
150cdf0e10cSrcweir         // distinguish map entries by their service name
151cdf0e10cSrcweir         Sequence<OUString> sServiceNames =
152cdf0e10cSrcweir             xServiceInfo->getSupportedServiceNames();
153cdf0e10cSrcweir         sal_Int32 nLength = sServiceNames.getLength();
154cdf0e10cSrcweir         for( sal_Int32 i=0; i<nLength; i++ )
155cdf0e10cSrcweir         {
156cdf0e10cSrcweir             OUString& rName = sServiceNames[i];
157cdf0e10cSrcweir 
158cdf0e10cSrcweir             if ( rName.equalsAsciiL(sAPI_ImageMapRectangleObject,
159cdf0e10cSrcweir                                     sizeof(sAPI_ImageMapRectangleObject)-1) )
160cdf0e10cSrcweir             {
161cdf0e10cSrcweir                 eType = XML_AREA_RECTANGLE;
162cdf0e10cSrcweir                 break;
163cdf0e10cSrcweir             }
164cdf0e10cSrcweir             else if ( rName.equalsAsciiL(sAPI_ImageMapCircleObject,
165cdf0e10cSrcweir                                          sizeof(sAPI_ImageMapCircleObject)-1) )
166cdf0e10cSrcweir             {
167cdf0e10cSrcweir                 eType = XML_AREA_CIRCLE;
168cdf0e10cSrcweir                 break;
169cdf0e10cSrcweir             }
170cdf0e10cSrcweir             else if ( rName.equalsAsciiL(sAPI_ImageMapPolygonObject,
171cdf0e10cSrcweir                                          sizeof(sAPI_ImageMapPolygonObject)-1))
172cdf0e10cSrcweir             {
173cdf0e10cSrcweir                 eType = XML_AREA_POLYGON;
174cdf0e10cSrcweir                 break;
175cdf0e10cSrcweir             }
176cdf0e10cSrcweir         }
177cdf0e10cSrcweir 
178cdf0e10cSrcweir         // return from method if no proper service is found!
179cdf0e10cSrcweir         DBG_ASSERT(XML_TOKEN_INVALID != eType,
180cdf0e10cSrcweir                    "Image map element doesn't support appropriate service!");
181cdf0e10cSrcweir         if (XML_TOKEN_INVALID == eType)
182cdf0e10cSrcweir             return;
183cdf0e10cSrcweir 
184cdf0e10cSrcweir         // now: handle ImageMapObject properties (those for all types)
185cdf0e10cSrcweir 
186cdf0e10cSrcweir         // XLINK (URL property)
187cdf0e10cSrcweir         Any aAny = rPropertySet->getPropertyValue(msURL);
188cdf0e10cSrcweir         OUString sHref;
189cdf0e10cSrcweir         aAny >>= sHref;
190cdf0e10cSrcweir         if (sHref.getLength() > 0)
191cdf0e10cSrcweir         {
192cdf0e10cSrcweir             mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, mrExport.GetRelativeReference(sHref));
193cdf0e10cSrcweir         }
194cdf0e10cSrcweir         mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
195cdf0e10cSrcweir 
196cdf0e10cSrcweir         // Target property (and xlink:show)
197cdf0e10cSrcweir         aAny = rPropertySet->getPropertyValue(msTarget);
198cdf0e10cSrcweir         OUString sTargt;
199cdf0e10cSrcweir         aAny >>= sTargt;
200cdf0e10cSrcweir         if (sTargt.getLength() > 0)
201cdf0e10cSrcweir         {
202cdf0e10cSrcweir             mrExport.AddAttribute(
203cdf0e10cSrcweir                 XML_NAMESPACE_OFFICE, XML_TARGET_FRAME_NAME, sTargt);
204cdf0e10cSrcweir 
205cdf0e10cSrcweir             mrExport.AddAttribute(
206cdf0e10cSrcweir                 XML_NAMESPACE_XLINK, XML_SHOW,
207cdf0e10cSrcweir                 sTargt.equalsAsciiL( "_blank", sizeof("_blank")-1 )
208cdf0e10cSrcweir                                         ? XML_NEW : XML_REPLACE );
209cdf0e10cSrcweir         }
210cdf0e10cSrcweir 
211cdf0e10cSrcweir         // name
212cdf0e10cSrcweir         aAny = rPropertySet->getPropertyValue(msName);
213cdf0e10cSrcweir         OUString sItemName;
214cdf0e10cSrcweir         aAny >>= sItemName;
215cdf0e10cSrcweir         if (sItemName.getLength() > 0)
216cdf0e10cSrcweir         {
217cdf0e10cSrcweir             mrExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_NAME, sItemName);
218cdf0e10cSrcweir         }
219cdf0e10cSrcweir 
220cdf0e10cSrcweir         // is-active
221cdf0e10cSrcweir         aAny = rPropertySet->getPropertyValue(msIsActive);
222cdf0e10cSrcweir         if (! *(sal_Bool*)aAny.getValue())
223cdf0e10cSrcweir         {
224cdf0e10cSrcweir             mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_NOHREF, XML_NOHREF);
225cdf0e10cSrcweir         }
226cdf0e10cSrcweir 
227cdf0e10cSrcweir         // call specific rectangle/circle/... method
228cdf0e10cSrcweir         // also prepare element name
229cdf0e10cSrcweir         switch (eType)
230cdf0e10cSrcweir         {
231cdf0e10cSrcweir             case XML_AREA_RECTANGLE:
232cdf0e10cSrcweir                 ExportRectangle(rPropertySet);
233cdf0e10cSrcweir                 break;
234cdf0e10cSrcweir             case XML_AREA_CIRCLE:
235cdf0e10cSrcweir                 ExportCircle(rPropertySet);
236cdf0e10cSrcweir                 break;
237cdf0e10cSrcweir             case XML_AREA_POLYGON:
238cdf0e10cSrcweir                 ExportPolygon(rPropertySet);
239cdf0e10cSrcweir                 break;
240cdf0e10cSrcweir             default:
241cdf0e10cSrcweir                 break;
242cdf0e10cSrcweir         }
243cdf0e10cSrcweir 
244cdf0e10cSrcweir         // write element
245cdf0e10cSrcweir         DBG_ASSERT(XML_TOKEN_INVALID != eType,
246cdf0e10cSrcweir                    "No name?! How did this happen?");
247cdf0e10cSrcweir         SvXMLElementExport aAreaElement(mrExport, XML_NAMESPACE_DRAW, eType,
248cdf0e10cSrcweir                                         mbWhiteSpace, mbWhiteSpace);
249cdf0e10cSrcweir 
250cdf0e10cSrcweir         // title property (as <svg:title> element)
251cdf0e10cSrcweir         OUString sTitle;
252cdf0e10cSrcweir         rPropertySet->getPropertyValue(msTitle) >>= sTitle;
253cdf0e10cSrcweir         if(sTitle.getLength())
254cdf0e10cSrcweir         {
255cdf0e10cSrcweir             SvXMLElementExport aEventElemt(mrExport, XML_NAMESPACE_SVG, XML_TITLE, mbWhiteSpace, sal_False);
256cdf0e10cSrcweir             mrExport.Characters(sTitle);
257cdf0e10cSrcweir         }
258cdf0e10cSrcweir 
259cdf0e10cSrcweir         // description property (as <svg:desc> element)
260cdf0e10cSrcweir         OUString sDescription;
261cdf0e10cSrcweir         rPropertySet->getPropertyValue(msDescription) >>= sDescription;
262cdf0e10cSrcweir         if (sDescription.getLength() > 0)
263cdf0e10cSrcweir         {
264cdf0e10cSrcweir             SvXMLElementExport aDesc(mrExport, XML_NAMESPACE_SVG, XML_DESC, mbWhiteSpace, sal_False);
265cdf0e10cSrcweir             mrExport.Characters(sDescription);
266cdf0e10cSrcweir         }
267cdf0e10cSrcweir 
268cdf0e10cSrcweir         // export events attached to this
269cdf0e10cSrcweir         Reference<XEventsSupplier> xSupplier(rPropertySet, UNO_QUERY);
270cdf0e10cSrcweir         mrExport.GetEventExport().Export(xSupplier, mbWhiteSpace);
271cdf0e10cSrcweir     }
272cdf0e10cSrcweir     // else: no service info -> can't determine type -> ignore entry
273cdf0e10cSrcweir }
274cdf0e10cSrcweir 
275cdf0e10cSrcweir void XMLImageMapExport::ExportRectangle(
276cdf0e10cSrcweir     const Reference<XPropertySet> & rPropertySet)
277cdf0e10cSrcweir {
278cdf0e10cSrcweir     // get boundary rectangle
279cdf0e10cSrcweir     Any aAny = rPropertySet->getPropertyValue(msBoundary);
280cdf0e10cSrcweir     awt::Rectangle aRectangle;
281cdf0e10cSrcweir     aAny >>= aRectangle;
282cdf0e10cSrcweir 
283cdf0e10cSrcweir     // parameters svg:x, svg:y, svg:width, svg:height
284cdf0e10cSrcweir     OUStringBuffer aBuffer;
285cdf0e10cSrcweir     mrExport.GetMM100UnitConverter().convertMeasure(aBuffer, aRectangle.X);
286cdf0e10cSrcweir     mrExport.AddAttribute( XML_NAMESPACE_SVG, XML_X,
287cdf0e10cSrcweir                           aBuffer.makeStringAndClear() );
288cdf0e10cSrcweir     mrExport.GetMM100UnitConverter().convertMeasure(aBuffer, aRectangle.Y);
289cdf0e10cSrcweir     mrExport.AddAttribute( XML_NAMESPACE_SVG, XML_Y,
290cdf0e10cSrcweir                           aBuffer.makeStringAndClear() );
291cdf0e10cSrcweir     mrExport.GetMM100UnitConverter().convertMeasure(aBuffer, aRectangle.Width);
292cdf0e10cSrcweir     mrExport.AddAttribute( XML_NAMESPACE_SVG, XML_WIDTH,
293cdf0e10cSrcweir                           aBuffer.makeStringAndClear() );
294cdf0e10cSrcweir     mrExport.GetMM100UnitConverter().convertMeasure(aBuffer, aRectangle.Height);
295cdf0e10cSrcweir     mrExport.AddAttribute( XML_NAMESPACE_SVG, XML_HEIGHT,
296cdf0e10cSrcweir                           aBuffer.makeStringAndClear() );
297cdf0e10cSrcweir }
298cdf0e10cSrcweir 
299cdf0e10cSrcweir void XMLImageMapExport::ExportCircle(
300cdf0e10cSrcweir     const Reference<XPropertySet> & rPropertySet)
301cdf0e10cSrcweir {
302cdf0e10cSrcweir     // get boundary rectangle
303cdf0e10cSrcweir     Any aAny = rPropertySet->getPropertyValue(msCenter);
304cdf0e10cSrcweir     awt::Point aCenter;
305cdf0e10cSrcweir     aAny >>= aCenter;
306cdf0e10cSrcweir 
307cdf0e10cSrcweir     // parameters svg:cx, svg:cy
308cdf0e10cSrcweir     OUStringBuffer aBuffer;
309cdf0e10cSrcweir     mrExport.GetMM100UnitConverter().convertMeasure(aBuffer, aCenter.X);
310cdf0e10cSrcweir     mrExport.AddAttribute( XML_NAMESPACE_SVG, XML_CX,
311cdf0e10cSrcweir                           aBuffer.makeStringAndClear() );
312cdf0e10cSrcweir     mrExport.GetMM100UnitConverter().convertMeasure(aBuffer, aCenter.Y);
313cdf0e10cSrcweir     mrExport.AddAttribute( XML_NAMESPACE_SVG, XML_CY,
314cdf0e10cSrcweir                           aBuffer.makeStringAndClear() );
315cdf0e10cSrcweir 
316cdf0e10cSrcweir     // radius
317cdf0e10cSrcweir     aAny = rPropertySet->getPropertyValue(msRadius);
318cdf0e10cSrcweir     sal_Int32 nRadius = 0;
319cdf0e10cSrcweir     aAny >>= nRadius;
320cdf0e10cSrcweir     mrExport.GetMM100UnitConverter().convertMeasure(aBuffer, nRadius);
321cdf0e10cSrcweir     mrExport.AddAttribute( XML_NAMESPACE_SVG, XML_R,
322cdf0e10cSrcweir                           aBuffer.makeStringAndClear() );
323cdf0e10cSrcweir }
324cdf0e10cSrcweir 
325cdf0e10cSrcweir void XMLImageMapExport::ExportPolygon(
326cdf0e10cSrcweir     const Reference<XPropertySet> & rPropertySet)
327cdf0e10cSrcweir {
328cdf0e10cSrcweir     // polygons get exported as bounding box, viewbox, and coordinate
329cdf0e10cSrcweir     // pair sequence. The bounding box is always the entire image.
330cdf0e10cSrcweir 
331cdf0e10cSrcweir     // get polygon point sequence
332cdf0e10cSrcweir     Any aAny = rPropertySet->getPropertyValue(msPolygon);
333cdf0e10cSrcweir     PointSequence aPoly;
334cdf0e10cSrcweir     aAny >>= aPoly;
335cdf0e10cSrcweir 
336cdf0e10cSrcweir     // get bounding box (assume top-left to be 0,0)
337cdf0e10cSrcweir     sal_Int32 nWidth = 0;
338cdf0e10cSrcweir     sal_Int32 nHeight = 0;
339cdf0e10cSrcweir     sal_Int32 nLength = aPoly.getLength();
340cdf0e10cSrcweir     const struct awt::Point* pPointPtr = aPoly.getConstArray();
341cdf0e10cSrcweir     for ( sal_Int32 i = 0; i < nLength; i++ )
342cdf0e10cSrcweir     {
343cdf0e10cSrcweir         sal_Int32 nPolyX = pPointPtr->X;
344cdf0e10cSrcweir         sal_Int32 nPolyY = pPointPtr->Y;
345cdf0e10cSrcweir 
346cdf0e10cSrcweir         if ( nPolyX > nWidth )
347cdf0e10cSrcweir             nWidth = nPolyX;
348cdf0e10cSrcweir         if ( nPolyY > nHeight )
349cdf0e10cSrcweir             nHeight = nPolyY;
350cdf0e10cSrcweir 
351cdf0e10cSrcweir         pPointPtr++;
352cdf0e10cSrcweir     }
353cdf0e10cSrcweir     DBG_ASSERT(nWidth > 0, "impossible Polygon found");
354cdf0e10cSrcweir     DBG_ASSERT(nHeight > 0, "impossible Polygon found");
355cdf0e10cSrcweir 
356cdf0e10cSrcweir     // parameters svg:x, svg:y, svg:width, svg:height
357cdf0e10cSrcweir     OUStringBuffer aBuffer;
358cdf0e10cSrcweir     mrExport.GetMM100UnitConverter().convertMeasure(aBuffer, 0);
359cdf0e10cSrcweir     mrExport.AddAttribute( XML_NAMESPACE_SVG, XML_X,
360cdf0e10cSrcweir                           aBuffer.makeStringAndClear() );
361cdf0e10cSrcweir     mrExport.GetMM100UnitConverter().convertMeasure(aBuffer, 0);
362cdf0e10cSrcweir     mrExport.AddAttribute( XML_NAMESPACE_SVG, XML_Y,
363cdf0e10cSrcweir                           aBuffer.makeStringAndClear() );
364cdf0e10cSrcweir     mrExport.GetMM100UnitConverter().convertMeasure(aBuffer, nWidth);
365cdf0e10cSrcweir     mrExport.AddAttribute( XML_NAMESPACE_SVG, XML_WIDTH,
366cdf0e10cSrcweir                           aBuffer.makeStringAndClear() );
367cdf0e10cSrcweir     mrExport.GetMM100UnitConverter().convertMeasure(aBuffer, nHeight);
368cdf0e10cSrcweir     mrExport.AddAttribute( XML_NAMESPACE_SVG, XML_HEIGHT,
369cdf0e10cSrcweir                           aBuffer.makeStringAndClear() );
370cdf0e10cSrcweir 
371cdf0e10cSrcweir     // svg:viewbox
372cdf0e10cSrcweir     SdXMLImExViewBox aViewBox(0, 0, nWidth, nHeight);
373cdf0e10cSrcweir     mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_VIEWBOX,
374cdf0e10cSrcweir                 aViewBox.GetExportString());
375cdf0e10cSrcweir 
376cdf0e10cSrcweir     // export point sequence
377cdf0e10cSrcweir     awt::Point aPoint(0, 0);
378cdf0e10cSrcweir     awt::Size aSize(nWidth, nHeight);
379cdf0e10cSrcweir     SdXMLImExPointsElement aPoints( &aPoly, aViewBox, aPoint, aSize );
380cdf0e10cSrcweir     mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_POINTS,
381cdf0e10cSrcweir                           aPoints.GetExportString());
382cdf0e10cSrcweir }
383