bump product version to 5.0.4.1
[LibreOffice.git] / xmloff / source / text / txtdrope.cxx
blob21ffb51307196490a4e6893f98c205152aa45116
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <rtl/ustrbuf.hxx>
21 #include <com/sun/star/style/DropCapFormat.hpp>
22 #include <sax/tools/converter.hxx>
23 #include <xmloff/xmltoken.hxx>
24 #include <xmloff/xmlexp.hxx>
25 #include <xmloff/xmluconv.hxx>
26 #include <xmloff/xmlnmspe.hxx>
27 #include "txtdrope.hxx"
29 using namespace ::com::sun::star;
30 using namespace ::com::sun::star::style;
31 using namespace ::com::sun::star::uno;
33 using namespace ::xmloff::token;
36 XMLTextDropCapExport::XMLTextDropCapExport( SvXMLExport& rExp ) :
37 rExport(rExp)
41 XMLTextDropCapExport::~XMLTextDropCapExport()
45 void XMLTextDropCapExport::exportXML( const Any& rAny,
46 bool bWholeWord,
47 const OUString& rStyleName )
49 DropCapFormat aFormat;
50 rAny >>= aFormat;
51 OUString sValue;
52 OUStringBuffer sBuffer;
53 if( aFormat.Lines > 1 )
55 SvXMLUnitConverter& rUnitConv = rExport.GetMM100UnitConverter();
57 // style:lines
58 ::sax::Converter::convertNumber( sBuffer, (sal_Int32)aFormat.Lines );
59 rExport.AddAttribute( XML_NAMESPACE_STYLE, XML_LINES,
60 sBuffer.makeStringAndClear() );
62 // style:length
63 if( bWholeWord )
65 sValue = GetXMLToken(XML_WORD);
67 else if( aFormat.Count > 1 )
69 ::sax::Converter::convertNumber(sBuffer, (sal_Int32)aFormat.Count);
70 sValue = sBuffer.makeStringAndClear();
72 if( !sValue.isEmpty() )
73 rExport.AddAttribute( XML_NAMESPACE_STYLE, XML_LENGTH, sValue );
75 // style:distance
76 if( aFormat.Distance > 0 )
78 rUnitConv.convertMeasureToXML( sBuffer, aFormat.Distance );
79 rExport.AddAttribute( XML_NAMESPACE_STYLE, XML_DISTANCE,
80 sBuffer.makeStringAndClear() );
83 // style:style-name
84 if( !rStyleName.isEmpty() )
85 rExport.AddAttribute( XML_NAMESPACE_STYLE, XML_STYLE_NAME,
86 rExport.EncodeStyleName( rStyleName ) );
89 SvXMLElementExport aElem( rExport, XML_NAMESPACE_STYLE, XML_DROP_CAP,
90 false, false );
95 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */