Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
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"
28 :
29 : using namespace ::com::sun::star;
30 : using namespace ::com::sun::star::style;
31 : using namespace ::com::sun::star::uno;
32 :
33 : using namespace ::xmloff::token;
34 :
35 :
36 12828 : XMLTextDropCapExport::XMLTextDropCapExport( SvXMLExport& rExp ) :
37 12828 : rExport(rExp)
38 : {
39 12828 : }
40 :
41 12818 : XMLTextDropCapExport::~XMLTextDropCapExport()
42 : {
43 12818 : }
44 :
45 4 : void XMLTextDropCapExport::exportXML( const Any& rAny,
46 : bool bWholeWord,
47 : const OUString& rStyleName )
48 : {
49 4 : DropCapFormat aFormat;
50 4 : rAny >>= aFormat;
51 4 : OUString sValue;
52 8 : OUStringBuffer sBuffer;
53 4 : if( aFormat.Lines > 1 )
54 : {
55 4 : SvXMLUnitConverter& rUnitConv = rExport.GetMM100UnitConverter();
56 :
57 : // style:lines
58 4 : ::sax::Converter::convertNumber( sBuffer, (sal_Int32)aFormat.Lines );
59 : rExport.AddAttribute( XML_NAMESPACE_STYLE, XML_LINES,
60 4 : sBuffer.makeStringAndClear() );
61 :
62 : // style:length
63 4 : if( bWholeWord )
64 : {
65 0 : sValue = GetXMLToken(XML_WORD);
66 : }
67 4 : else if( aFormat.Count > 1 )
68 : {
69 0 : ::sax::Converter::convertNumber(sBuffer, (sal_Int32)aFormat.Count);
70 0 : sValue = sBuffer.makeStringAndClear();
71 : }
72 4 : if( !sValue.isEmpty() )
73 0 : rExport.AddAttribute( XML_NAMESPACE_STYLE, XML_LENGTH, sValue );
74 :
75 : // style:distance
76 4 : if( aFormat.Distance > 0 )
77 : {
78 0 : rUnitConv.convertMeasureToXML( sBuffer, aFormat.Distance );
79 : rExport.AddAttribute( XML_NAMESPACE_STYLE, XML_DISTANCE,
80 0 : sBuffer.makeStringAndClear() );
81 : }
82 :
83 : // style:style-name
84 4 : if( !rStyleName.isEmpty() )
85 : rExport.AddAttribute( XML_NAMESPACE_STYLE, XML_STYLE_NAME,
86 4 : rExport.EncodeStyleName( rStyleName ) );
87 : }
88 :
89 : SvXMLElementExport aElem( rExport, XML_NAMESPACE_STYLE, XML_DROP_CAP,
90 8 : false, false );
91 4 : }
92 :
93 :
94 :
95 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|