1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: VisAreaExport.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmloff.hxx"
33 #include <com/sun/star/awt/Rectangle.hpp>
34 #include "VisAreaExport.hxx"
35 #include <xmloff/xmlexp.hxx>
36 #include "xmlnmspe.hxx"
37 #include <xmloff/nmspmap.hxx>
38 #include <xmloff/xmltoken.hxx>
39 #include <xmloff/xmluconv.hxx>
40 #include <tools/gen.hxx>
42 using namespace ::xmloff::token
;
45 XMLVisAreaExport::XMLVisAreaExport(SvXMLExport
& rExport
, const sal_Char
*pName
,
46 const Rectangle
& aRect
, const MapUnit aMapUnit
)
48 SvXMLUnitConverter
& rUnitConv
= rExport
.GetMM100UnitConverter();
50 // write VisArea Element and its Attributes
51 rtl::OUStringBuffer sBuffer
;
52 rUnitConv
.convertMeasure(sBuffer
, aRect
.getX(), aMapUnit
);
53 rExport
.AddAttribute(XML_NAMESPACE_OFFICE
, XML_X
, sBuffer
.makeStringAndClear());
54 rUnitConv
.convertMeasure(sBuffer
, aRect
.getY(), aMapUnit
);
55 rExport
.AddAttribute(XML_NAMESPACE_OFFICE
, XML_Y
, sBuffer
.makeStringAndClear());
56 rUnitConv
.convertMeasure(sBuffer
, aRect
.getWidth(), aMapUnit
);
57 rExport
.AddAttribute(XML_NAMESPACE_OFFICE
, XML_WIDTH
, sBuffer
.makeStringAndClear());
58 rUnitConv
.convertMeasure(sBuffer
, aRect
.getHeight(), aMapUnit
);
59 rExport
.AddAttribute(XML_NAMESPACE_OFFICE
, XML_HEIGHT
, sBuffer
.makeStringAndClear());
60 SvXMLElementExport
aVisAreaElem(rExport
, XML_NAMESPACE_OFFICE
, pName
, sal_True
, sal_True
);
63 XMLVisAreaExport::XMLVisAreaExport(SvXMLExport
& rExport
, const sal_Char
*pName
,
64 const com::sun::star::awt::Rectangle
& aRect
, const sal_Int16 nMeasureUnit
)
66 MapUnit aMapUnit
= (MapUnit
)nMeasureUnit
;
68 SvXMLUnitConverter
& rUnitConv
= rExport
.GetMM100UnitConverter();
70 // write VisArea Element and its Attributes
71 rtl::OUStringBuffer sBuffer
;
72 rUnitConv
.convertMeasure(sBuffer
, aRect
.X
, aMapUnit
);
73 rExport
.AddAttribute(XML_NAMESPACE_OFFICE
, XML_X
, sBuffer
.makeStringAndClear());
74 rUnitConv
.convertMeasure(sBuffer
, aRect
.Y
, aMapUnit
);
75 rExport
.AddAttribute(XML_NAMESPACE_OFFICE
, XML_Y
, sBuffer
.makeStringAndClear());
76 rUnitConv
.convertMeasure(sBuffer
, aRect
.Width
, aMapUnit
);
77 rExport
.AddAttribute(XML_NAMESPACE_OFFICE
, XML_WIDTH
, sBuffer
.makeStringAndClear());
78 rUnitConv
.convertMeasure(sBuffer
, aRect
.Height
, aMapUnit
);
79 rExport
.AddAttribute(XML_NAMESPACE_OFFICE
, XML_HEIGHT
, sBuffer
.makeStringAndClear());
80 SvXMLElementExport
aVisAreaElem(rExport
, XML_NAMESPACE_OFFICE
, pName
, sal_True
, sal_True
);
83 XMLVisAreaExport::~XMLVisAreaExport()