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