XMLImageMapExport.cxx (63bba73c) | XMLImageMapExport.cxx (1f882ec4) |
---|---|
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 --- 5 unchanged lines hidden (view full) --- 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 | 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 --- 5 unchanged lines hidden (view full) --- 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 | |
24// MARKER(update_precomp.py): autogen include statement, do not remove 25#include "precompiled_xmloff.hxx" 26#include "XMLImageMapExport.hxx" 27#include <rtl/ustring.hxx> 28#include <rtl/ustrbuf.hxx> 29#include <tools/debug.hxx> 30#include <com/sun/star/uno/Reference.h> 31#include <com/sun/star/uno/Sequence.h> 32#include <com/sun/star/beans/XPropertySet.hpp> 33#include <com/sun/star/lang/XServiceInfo.hpp> 34#include <com/sun/star/container/XIndexContainer.hpp> | 22// MARKER(update_precomp.py): autogen include statement, do not remove 23#include "precompiled_xmloff.hxx" 24#include "XMLImageMapExport.hxx" 25#include <rtl/ustring.hxx> 26#include <rtl/ustrbuf.hxx> 27#include <tools/debug.hxx> 28#include <com/sun/star/uno/Reference.h> 29#include <com/sun/star/uno/Sequence.h> 30#include <com/sun/star/beans/XPropertySet.hpp> 31#include <com/sun/star/lang/XServiceInfo.hpp> 32#include <com/sun/star/container/XIndexContainer.hpp> |
35 36#ifndef _COM_SUN_STAR_DOCUMENT_XEVENTSSUPPLIER_HPP | |
37#include <com/sun/star/document/XEventsSupplier.hpp> | 33#include <com/sun/star/document/XEventsSupplier.hpp> |
38#endif | |
39#include <com/sun/star/awt/Rectangle.hpp> 40#include <com/sun/star/awt/Point.hpp> 41#include <com/sun/star/awt/Size.hpp> 42#include <com/sun/star/drawing/PointSequence.hpp> 43#include <xmloff/xmlexp.hxx> 44#include "xmloff/xmlnmspe.hxx" 45#include <xmloff/xmltoken.hxx> 46#include <xmloff/XMLEventExport.hxx> 47#include <xmloff/xmluconv.hxx> 48#include "xexptran.hxx" | 34#include <com/sun/star/awt/Rectangle.hpp> 35#include <com/sun/star/awt/Point.hpp> 36#include <com/sun/star/awt/Size.hpp> 37#include <com/sun/star/drawing/PointSequence.hpp> 38#include <xmloff/xmlexp.hxx> 39#include "xmloff/xmlnmspe.hxx" 40#include <xmloff/xmltoken.hxx> 41#include <xmloff/XMLEventExport.hxx> 42#include <xmloff/xmluconv.hxx> 43#include "xexptran.hxx" |
44#include <basegfx/polygon/b2dpolygon.hxx> 45#include <basegfx/polygon/b2dpolygontools.hxx> |
|
49 | 46 |
50 51 | |
52using namespace ::com::sun::star; 53using namespace ::xmloff::token; 54 55using ::rtl::OUString; 56using ::rtl::OUStringBuffer; 57using ::com::sun::star::uno::Any; 58using ::com::sun::star::uno::UNO_QUERY; 59using ::com::sun::star::uno::Sequence; --- 257 unchanged lines hidden (view full) --- 317 aAny = rPropertySet->getPropertyValue(msRadius); 318 sal_Int32 nRadius = 0; 319 aAny >>= nRadius; 320 mrExport.GetMM100UnitConverter().convertMeasure(aBuffer, nRadius); 321 mrExport.AddAttribute( XML_NAMESPACE_SVG, XML_R, 322 aBuffer.makeStringAndClear() ); 323} 324 | 47using namespace ::com::sun::star; 48using namespace ::xmloff::token; 49 50using ::rtl::OUString; 51using ::rtl::OUStringBuffer; 52using ::com::sun::star::uno::Any; 53using ::com::sun::star::uno::UNO_QUERY; 54using ::com::sun::star::uno::Sequence; --- 257 unchanged lines hidden (view full) --- 312 aAny = rPropertySet->getPropertyValue(msRadius); 313 sal_Int32 nRadius = 0; 314 aAny >>= nRadius; 315 mrExport.GetMM100UnitConverter().convertMeasure(aBuffer, nRadius); 316 mrExport.AddAttribute( XML_NAMESPACE_SVG, XML_R, 317 aBuffer.makeStringAndClear() ); 318} 319 |
325void XMLImageMapExport::ExportPolygon( 326 const Reference<XPropertySet> & rPropertySet) | 320void XMLImageMapExport::ExportPolygon(const Reference<XPropertySet> & rPropertySet) |
327{ | 321{ |
328 // polygons get exported as bounding box, viewbox, and coordinate 329 // pair sequence. The bounding box is always the entire image. | 322 // polygons get exported as bounding box, viewbox, and coordinate 323 // pair sequence. The bounding box is always the entire image. |
330 | 324 |
331 // get polygon point sequence 332 Any aAny = rPropertySet->getPropertyValue(msPolygon); 333 PointSequence aPoly; 334 aAny >>= aPoly; | 325 // get polygon point sequence 326 Any aAny = rPropertySet->getPropertyValue(msPolygon); 327 PointSequence aPoly; 328 aAny >>= aPoly; |
335 | 329 |
336 // get bounding box (assume top-left to be 0,0) 337 sal_Int32 nWidth = 0; 338 sal_Int32 nHeight = 0; 339 sal_Int32 nLength = aPoly.getLength(); 340 const struct awt::Point* pPointPtr = aPoly.getConstArray(); 341 for ( sal_Int32 i = 0; i < nLength; i++ ) 342 { 343 sal_Int32 nPolyX = pPointPtr->X; 344 sal_Int32 nPolyY = pPointPtr->Y; | 330 const basegfx::B2DPolygon aPolygon( 331 basegfx::tools::UnoPointSequenceToB2DPolygon( 332 aPoly)); 333 const basegfx::B2DRange aPolygonRange(aPolygon.getB2DRange()); |
345 | 334 |
346 if ( nPolyX > nWidth ) 347 nWidth = nPolyX; 348 if ( nPolyY > nHeight ) 349 nHeight = nPolyY; | 335 // parameters svg:x, svg:y, svg:width, svg:height 336 OUStringBuffer aBuffer; |
350 | 337 |
351 pPointPtr++; 352 } 353 DBG_ASSERT(nWidth > 0, "impossible Polygon found"); 354 DBG_ASSERT(nHeight > 0, "impossible Polygon found"); | 338 mrExport.GetMM100UnitConverter().convertMeasure(aBuffer, 0); 339 mrExport.AddAttribute( XML_NAMESPACE_SVG, XML_X, aBuffer.makeStringAndClear() ); 340 mrExport.GetMM100UnitConverter().convertMeasure(aBuffer, 0); 341 mrExport.AddAttribute( XML_NAMESPACE_SVG, XML_Y, aBuffer.makeStringAndClear() ); 342 mrExport.GetMM100UnitConverter().convertMeasure(aBuffer, basegfx::fround(aPolygonRange.getWidth())); 343 mrExport.AddAttribute( XML_NAMESPACE_SVG, XML_WIDTH, aBuffer.makeStringAndClear() ); 344 mrExport.GetMM100UnitConverter().convertMeasure(aBuffer, basegfx::fround(aPolygonRange.getHeight())); 345 mrExport.AddAttribute( XML_NAMESPACE_SVG, XML_HEIGHT, aBuffer.makeStringAndClear() ); |
355 | 346 |
356 // parameters svg:x, svg:y, svg:width, svg:height 357 OUStringBuffer aBuffer; 358 mrExport.GetMM100UnitConverter().convertMeasure(aBuffer, 0); 359 mrExport.AddAttribute( XML_NAMESPACE_SVG, XML_X, 360 aBuffer.makeStringAndClear() ); 361 mrExport.GetMM100UnitConverter().convertMeasure(aBuffer, 0); 362 mrExport.AddAttribute( XML_NAMESPACE_SVG, XML_Y, 363 aBuffer.makeStringAndClear() ); 364 mrExport.GetMM100UnitConverter().convertMeasure(aBuffer, nWidth); 365 mrExport.AddAttribute( XML_NAMESPACE_SVG, XML_WIDTH, 366 aBuffer.makeStringAndClear() ); 367 mrExport.GetMM100UnitConverter().convertMeasure(aBuffer, nHeight); 368 mrExport.AddAttribute( XML_NAMESPACE_SVG, XML_HEIGHT, 369 aBuffer.makeStringAndClear() ); | 347 // svg:viewbox 348 SdXMLImExViewBox aViewBox(0.0, 0.0, aPolygonRange.getWidth(), aPolygonRange.getHeight()); 349 mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_VIEWBOX, aViewBox.GetExportString()); |
370 | 350 |
371 // svg:viewbox 372 SdXMLImExViewBox aViewBox(0, 0, nWidth, nHeight); 373 mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_VIEWBOX, 374 aViewBox.GetExportString()); | 351 // export point sequence 352 const ::rtl::OUString aPointString( 353 basegfx::tools::exportToSvgPoints( 354 aPolygon)); |
375 | 355 |
376 // export point sequence 377 awt::Point aPoint(0, 0); 378 awt::Size aSize(nWidth, nHeight); 379 SdXMLImExPointsElement aPoints( &aPoly, aViewBox, aPoint, aSize ); 380 mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_POINTS, 381 aPoints.GetExportString()); | 356 mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_POINTS, aPointString); |
382} | 357} |
358 359// eof |
|