xref: /aoo4110/main/xmloff/source/text/txtdrope.cxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_xmloff.hxx"
26 #include <tools/debug.hxx>
27 #include <rtl/ustrbuf.hxx>
28 #include <com/sun/star/style/DropCapFormat.hpp>
29 #include <xmloff/xmltoken.hxx>
30 #include <xmloff/xmlexp.hxx>
31 #include <xmloff/xmluconv.hxx>
32 #include "xmloff/xmlnmspe.hxx"
33 #include "txtdrope.hxx"
34 
35 using namespace ::com::sun::star;
36 using namespace ::com::sun::star::style;
37 using namespace ::com::sun::star::uno;
38 using ::rtl::OUString;
39 using ::rtl::OUStringBuffer;
40 
41 using namespace ::xmloff::token;
42 
43 
XMLTextDropCapExport(SvXMLExport & rExp)44 XMLTextDropCapExport::XMLTextDropCapExport( SvXMLExport& rExp ) :
45     rExport(rExp)
46 {
47 }
48 
~XMLTextDropCapExport()49 XMLTextDropCapExport::~XMLTextDropCapExport()
50 {
51 }
52 
exportXML(const Any & rAny,sal_Bool bWholeWord,const OUString & rStyleName)53 void XMLTextDropCapExport::exportXML( const Any& rAny,
54 									  sal_Bool bWholeWord,
55 									  const OUString& rStyleName )
56 {
57 	DropCapFormat aFormat;
58 	rAny >>= aFormat;
59 	OUString sValue;
60 	OUStringBuffer sBuffer;
61 	if( aFormat.Lines > 1 )
62 	{
63         SvXMLUnitConverter& rUnitConv = rExport.GetMM100UnitConverter();
64 
65 		// style:lines
66 		rUnitConv.convertNumber( sBuffer, (sal_Int32)aFormat.Lines );
67 		rExport.AddAttribute( XML_NAMESPACE_STYLE, XML_LINES,
68                               sBuffer.makeStringAndClear() );
69 
70 		// style:length
71 		if( bWholeWord )
72 		{
73 			sValue = GetXMLToken(XML_WORD);
74 		}
75 		else if( aFormat.Count > 1 )
76 		{
77 			rUnitConv.convertNumber( sBuffer, (sal_Int32)aFormat.Count );
78 			sValue = sBuffer.makeStringAndClear();
79 		}
80 		if( sValue.getLength() )
81 			rExport.AddAttribute( XML_NAMESPACE_STYLE, XML_LENGTH, sValue );
82 
83 		// style:distance
84 		if( aFormat.Distance > 0 )
85 		{
86 			rUnitConv.convertMeasure( sBuffer, aFormat.Distance );
87 			rExport.AddAttribute( XML_NAMESPACE_STYLE, XML_DISTANCE,
88                                   sBuffer.makeStringAndClear() );
89 		}
90 
91 		// style:style-name
92 		if( rStyleName.getLength() )
93 			rExport.AddAttribute( XML_NAMESPACE_STYLE, XML_STYLE_NAME,
94                                   rExport.EncodeStyleName( rStyleName ) );
95 	}
96 
97     SvXMLElementExport aElem( rExport, XML_NAMESPACE_STYLE, XML_DROP_CAP,
98                               sal_False, sal_False );
99 }
100 
101 
102 
103