Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <rtl/ustrbuf.hxx>
30 : : #include <com/sun/star/style/DropCapFormat.hpp>
31 : : #include <sax/tools/converter.hxx>
32 : : #include <xmloff/xmltoken.hxx>
33 : : #include <xmloff/xmlexp.hxx>
34 : : #include <xmloff/xmluconv.hxx>
35 : : #include "xmloff/xmlnmspe.hxx"
36 : : #include "txtdrope.hxx"
37 : :
38 : : using namespace ::com::sun::star;
39 : : using namespace ::com::sun::star::style;
40 : : using namespace ::com::sun::star::uno;
41 : : using ::rtl::OUString;
42 : : using ::rtl::OUStringBuffer;
43 : :
44 : : using namespace ::xmloff::token;
45 : :
46 : :
47 : 753 : XMLTextDropCapExport::XMLTextDropCapExport( SvXMLExport& rExp ) :
48 : 753 : rExport(rExp)
49 : : {
50 : 753 : }
51 : :
52 : 743 : XMLTextDropCapExport::~XMLTextDropCapExport()
53 : : {
54 : 743 : }
55 : :
56 : 0 : void XMLTextDropCapExport::exportXML( const Any& rAny,
57 : : sal_Bool bWholeWord,
58 : : const OUString& rStyleName )
59 : : {
60 : 0 : DropCapFormat aFormat;
61 [ # # ]: 0 : rAny >>= aFormat;
62 : 0 : OUString sValue;
63 : 0 : OUStringBuffer sBuffer;
64 [ # # ]: 0 : if( aFormat.Lines > 1 )
65 : : {
66 : 0 : SvXMLUnitConverter& rUnitConv = rExport.GetMM100UnitConverter();
67 : :
68 : : // style:lines
69 [ # # ]: 0 : ::sax::Converter::convertNumber( sBuffer, (sal_Int32)aFormat.Lines );
70 : : rExport.AddAttribute( XML_NAMESPACE_STYLE, XML_LINES,
71 [ # # ][ # # ]: 0 : sBuffer.makeStringAndClear() );
72 : :
73 : : // style:length
74 [ # # ]: 0 : if( bWholeWord )
75 : : {
76 [ # # ]: 0 : sValue = GetXMLToken(XML_WORD);
77 : : }
78 [ # # ]: 0 : else if( aFormat.Count > 1 )
79 : : {
80 [ # # ]: 0 : ::sax::Converter::convertNumber(sBuffer, (sal_Int32)aFormat.Count);
81 [ # # ]: 0 : sValue = sBuffer.makeStringAndClear();
82 : : }
83 [ # # ]: 0 : if( !sValue.isEmpty() )
84 [ # # ]: 0 : rExport.AddAttribute( XML_NAMESPACE_STYLE, XML_LENGTH, sValue );
85 : :
86 : : // style:distance
87 [ # # ]: 0 : if( aFormat.Distance > 0 )
88 : : {
89 [ # # ]: 0 : rUnitConv.convertMeasureToXML( sBuffer, aFormat.Distance );
90 : : rExport.AddAttribute( XML_NAMESPACE_STYLE, XML_DISTANCE,
91 [ # # ][ # # ]: 0 : sBuffer.makeStringAndClear() );
92 : : }
93 : :
94 : : // style:style-name
95 [ # # ]: 0 : if( !rStyleName.isEmpty() )
96 : : rExport.AddAttribute( XML_NAMESPACE_STYLE, XML_STYLE_NAME,
97 [ # # ][ # # ]: 0 : rExport.EncodeStyleName( rStyleName ) );
98 : : }
99 : :
100 : : SvXMLElementExport aElem( rExport, XML_NAMESPACE_STYLE, XML_DROP_CAP,
101 [ # # ][ # # ]: 0 : sal_False, sal_False );
102 : 0 : }
103 : :
104 : :
105 : :
106 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|