Update ooo320-m1
[ooovba.git] / xmloff / source / style / XMLRectangleMembersHandler.cxx
blobacf97ca1d49414aed7aaa53d0555c193e174ebf9
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: XMLRectangleMembersHandler.cxx,v $
10 * $Revision: 1.9 $
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 <xmloff/xmluconv.hxx>
34 #include <rtl/ustrbuf.hxx>
35 #include <com/sun/star/uno/Any.hxx>
37 #ifndef _COM_SUN_STAR_AWT_RECTANGLE_HDL_
38 #include <com/sun/star/awt/Rectangle.hdl>
39 #endif
40 #include "XMLRectangleMembersHandler.hxx"
41 #include <xmloff/xmltypes.hxx>
43 using namespace ::com::sun::star;
44 using namespace ::com::sun::star::uno;
45 using ::rtl::OUString;
46 using ::rtl::OUStringBuffer;
49 XMLRectangleMembersHdl::XMLRectangleMembersHdl( sal_Int32 nType )
50 : mnType( nType )
54 sal_Int32 X;
55 sal_Int32 Y;
56 sal_Int32 Width;
57 sal_Int32 Height;
59 XMLRectangleMembersHdl::~XMLRectangleMembersHdl()
63 sal_Bool XMLRectangleMembersHdl::importXML(
64 const OUString& rStrImpValue,
65 Any& rValue,
66 const SvXMLUnitConverter& rUnitConverter ) const
68 awt::Rectangle aRect( 0, 0, 0, 0 );
69 if( rValue.hasValue() )
70 rValue >>= aRect;
72 sal_Int32 nValue;
74 if( rUnitConverter.convertMeasure( nValue, rStrImpValue ) )
76 switch( mnType )
78 case XML_TYPE_RECTANGLE_LEFT :
79 aRect.X = nValue;
80 break;
81 case XML_TYPE_RECTANGLE_TOP :
82 aRect.Y = nValue;
83 break;
84 case XML_TYPE_RECTANGLE_WIDTH :
85 aRect.Width = nValue;
86 break;
87 case XML_TYPE_RECTANGLE_HEIGHT :
88 aRect.Height = nValue;
89 break;
92 rValue <<= aRect;
93 return sal_True;
96 return sal_False;
99 sal_Bool XMLRectangleMembersHdl::exportXML(
100 OUString& rStrExpValue,
101 const Any& rValue,
102 const SvXMLUnitConverter& rUnitConverter ) const
104 awt::Rectangle aRect( 0, 0, 0, 0 );
105 rValue >>= aRect;
107 sal_Int32 nValue;
109 switch( mnType )
111 case XML_TYPE_RECTANGLE_LEFT :
112 nValue = aRect.X;
113 break;
114 case XML_TYPE_RECTANGLE_TOP :
115 nValue = aRect.Y;
116 break;
117 case XML_TYPE_RECTANGLE_WIDTH :
118 nValue = aRect.Width;
119 break;
120 case XML_TYPE_RECTANGLE_HEIGHT :
121 nValue = aRect.Height;
122 break;
123 default:
124 nValue = 0; // TODO What value should this be?
125 break;
128 rtl::OUStringBuffer sBuffer;
129 rUnitConverter.convertMeasure( sBuffer, nValue );
130 rStrExpValue = sBuffer.makeStringAndClear();
131 return sal_True;