merge the formfield patch from ooo-build
[ooovba.git] / xmloff / source / text / txtdrope.cxx
blob3a6cfa71f99dd9ec3c99c922ac39735efe880d32
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: txtdrope.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 <tools/debug.hxx>
34 #include <rtl/ustrbuf.hxx>
35 #include <com/sun/star/style/DropCapFormat.hpp>
36 #include <xmloff/xmltoken.hxx>
37 #include <xmloff/xmlexp.hxx>
38 #include <xmloff/xmluconv.hxx>
39 #include "xmlnmspe.hxx"
40 #include "txtdrope.hxx"
42 using namespace ::com::sun::star;
43 using namespace ::com::sun::star::style;
44 using namespace ::com::sun::star::uno;
45 using ::rtl::OUString;
46 using ::rtl::OUStringBuffer;
48 using namespace ::xmloff::token;
51 XMLTextDropCapExport::XMLTextDropCapExport( SvXMLExport& rExp ) :
52 rExport(rExp)
56 XMLTextDropCapExport::~XMLTextDropCapExport()
60 void XMLTextDropCapExport::exportXML( const Any& rAny,
61 sal_Bool bWholeWord,
62 const OUString& rStyleName )
64 DropCapFormat aFormat;
65 rAny >>= aFormat;
66 OUString sValue;
67 OUStringBuffer sBuffer;
68 if( aFormat.Lines > 1 )
70 SvXMLUnitConverter& rUnitConv = rExport.GetMM100UnitConverter();
72 // style:lines
73 rUnitConv.convertNumber( sBuffer, (sal_Int32)aFormat.Lines );
74 rExport.AddAttribute( XML_NAMESPACE_STYLE, XML_LINES,
75 sBuffer.makeStringAndClear() );
77 // style:length
78 if( bWholeWord )
80 sValue = GetXMLToken(XML_WORD);
82 else if( aFormat.Count > 1 )
84 rUnitConv.convertNumber( sBuffer, (sal_Int32)aFormat.Count );
85 sValue = sBuffer.makeStringAndClear();
87 if( sValue.getLength() )
88 rExport.AddAttribute( XML_NAMESPACE_STYLE, XML_LENGTH, sValue );
90 // style:distance
91 if( aFormat.Distance > 0 )
93 rUnitConv.convertMeasure( sBuffer, aFormat.Distance );
94 rExport.AddAttribute( XML_NAMESPACE_STYLE, XML_DISTANCE,
95 sBuffer.makeStringAndClear() );
98 // style:style-name
99 if( rStyleName.getLength() )
100 rExport.AddAttribute( XML_NAMESPACE_STYLE, XML_STYLE_NAME,
101 rExport.EncodeStyleName( rStyleName ) );
104 SvXMLElementExport aElem( rExport, XML_NAMESPACE_STYLE, XML_DROP_CAP,
105 sal_False, sal_False );