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 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_xmloff.hxx" 26 #include <com/sun/star/awt/Rectangle.hpp> 27 #include "xmloff/VisAreaExport.hxx" 28 #include <xmloff/xmlexp.hxx> 29 #include "xmloff/xmlnmspe.hxx" 30 #include <xmloff/nmspmap.hxx> 31 #include <xmloff/xmltoken.hxx> 32 #include <xmloff/xmluconv.hxx> 33 #include <tools/gen.hxx> 34 35 using namespace ::xmloff::token; 36 37 38 XMLVisAreaExport::XMLVisAreaExport(SvXMLExport& rExport, const sal_Char *pName, 39 const Rectangle& aRect, const MapUnit aMapUnit) 40 { 41 SvXMLUnitConverter& rUnitConv = rExport.GetMM100UnitConverter(); 42 43 // write VisArea Element and its Attributes 44 rtl::OUStringBuffer sBuffer; 45 rUnitConv.convertMeasure(sBuffer, aRect.getX(), aMapUnit); 46 rExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_X, sBuffer.makeStringAndClear()); 47 rUnitConv.convertMeasure(sBuffer, aRect.getY(), aMapUnit); 48 rExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_Y, sBuffer.makeStringAndClear()); 49 rUnitConv.convertMeasure(sBuffer, aRect.getWidth(), aMapUnit); 50 rExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_WIDTH, sBuffer.makeStringAndClear()); 51 rUnitConv.convertMeasure(sBuffer, aRect.getHeight(), aMapUnit); 52 rExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_HEIGHT, sBuffer.makeStringAndClear()); 53 SvXMLElementExport aVisAreaElem(rExport, XML_NAMESPACE_OFFICE, pName, sal_True, sal_True); 54 } 55 56 XMLVisAreaExport::XMLVisAreaExport(SvXMLExport& rExport, const sal_Char *pName, 57 const com::sun::star::awt::Rectangle& aRect, const sal_Int16 nMeasureUnit ) 58 { 59 MapUnit aMapUnit = (MapUnit)nMeasureUnit; 60 61 SvXMLUnitConverter& rUnitConv = rExport.GetMM100UnitConverter(); 62 63 // write VisArea Element and its Attributes 64 rtl::OUStringBuffer sBuffer; 65 rUnitConv.convertMeasure(sBuffer, aRect.X, aMapUnit); 66 rExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_X, sBuffer.makeStringAndClear()); 67 rUnitConv.convertMeasure(sBuffer, aRect.Y, aMapUnit); 68 rExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_Y, sBuffer.makeStringAndClear()); 69 rUnitConv.convertMeasure(sBuffer, aRect.Width, aMapUnit); 70 rExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_WIDTH, sBuffer.makeStringAndClear()); 71 rUnitConv.convertMeasure(sBuffer, aRect.Height, aMapUnit); 72 rExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_HEIGHT, sBuffer.makeStringAndClear()); 73 SvXMLElementExport aVisAreaElem(rExport, XML_NAMESPACE_OFFICE, pName, sal_True, sal_True); 74 } 75 76 XMLVisAreaExport::~XMLVisAreaExport() 77 { 78 } 79 80 81