merge the formfield patch from ooo-build
[ooovba.git] / xmloff / source / style / xmltabe.cxx
blobb59c8167e18bf318220a1830f677aee7c0689b53
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: xmltabe.cxx,v $
10 * $Revision: 1.16 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmloff.hxx"
34 #include <tools/debug.hxx>
35 #include <com/sun/star/style/TabStop.hpp>
36 #include <com/sun/star/style/TabAlign.hpp>
37 #include <rtl/ustrbuf.hxx>
38 #include <xmloff/nmspmap.hxx>
39 #include "xmlnmspe.hxx"
40 #include <xmloff/xmltoken.hxx>
41 #include <xmloff/xmluconv.hxx>
42 #include <xmloff/xmlexp.hxx>
43 #include "xmltabe.hxx"
45 using ::rtl::OUString;
46 using ::rtl::OUStringBuffer;
48 using namespace ::com::sun::star;
49 using namespace ::xmloff::token;
51 SvXMLEnumMapEntry pXML_tabstop_style[] =
53 { XML_LEFT, style::TabAlign_LEFT },
54 { XML_CENTER, style::TabAlign_CENTER },
55 { XML_RIGHT, style::TabAlign_RIGHT },
56 { XML_CHAR, style::TabAlign_DECIMAL },
57 { XML_DEFAULT, style::TabAlign_DEFAULT }, // ?????????????????????????????????????
58 { XML_TOKEN_INVALID, 0 }
61 void SvxXMLTabStopExport::exportTabStop( const ::com::sun::star::style::TabStop* pTabStop )
63 SvXMLUnitConverter& rUnitConv = rExport.GetMM100UnitConverter();
65 // text:level
66 OUStringBuffer sBuffer;
68 // position attribute
69 rUnitConv.convertMeasure( sBuffer, pTabStop->Position );
70 rExport.AddAttribute( XML_NAMESPACE_STYLE, XML_POSITION,
71 sBuffer.makeStringAndClear() );
73 // type attribute
74 if( style::TabAlign_LEFT != pTabStop->Alignment )
76 rUnitConv.convertEnum( sBuffer, pTabStop->Alignment,
77 pXML_tabstop_style );
78 rExport.AddAttribute( XML_NAMESPACE_STYLE, XML_TYPE,
79 sBuffer.makeStringAndClear() );
82 // char
83 if( style::TabAlign_DECIMAL == pTabStop->Alignment &&
84 pTabStop->DecimalChar != 0 )
86 sBuffer.append( pTabStop->DecimalChar );
87 rExport.AddAttribute( XML_NAMESPACE_STYLE, XML_CHAR,
88 sBuffer.makeStringAndClear() );
91 // leader-char
92 if( ' ' != pTabStop->FillChar && 0 != pTabStop->FillChar )
94 rExport.AddAttribute( XML_NAMESPACE_STYLE, XML_LEADER_STYLE,
95 GetXMLToken('.' == pTabStop->FillChar ? XML_DOTTED
96 : XML_SOLID) );
98 sBuffer.append( pTabStop->FillChar );
99 rExport.AddAttribute( XML_NAMESPACE_STYLE, XML_LEADER_TEXT,
100 sBuffer.makeStringAndClear() );
103 SvXMLElementExport rElem( rExport, XML_NAMESPACE_STYLE, XML_TAB_STOP,
104 sal_True, sal_True );
108 SvxXMLTabStopExport::SvxXMLTabStopExport(
109 SvXMLExport& rExp)
110 : rExport( rExp )
114 SvxXMLTabStopExport::~SvxXMLTabStopExport()
118 void SvxXMLTabStopExport::Export( const uno::Any& rAny )
120 uno::Sequence< ::com::sun::star::style::TabStop> aSeq;
121 if(!(rAny >>= aSeq))
123 DBG_ERROR( "SvxXMLTabStopExport needs a Sequence ::com::sun::star::style::TabStop>" );
125 else
127 const ::com::sun::star::style::TabStop* pTabs = aSeq.getConstArray();
128 const sal_Int32 nTabs = aSeq.getLength();
130 // ignore default tab stop here
131 //if( 1 == nTabs && style::TabAlign_DEFAULT == pTabs[0].Alignment )
132 // return;
134 SvXMLElementExport rElem( rExport, XML_NAMESPACE_STYLE, XML_TAB_STOPS,
135 sal_True, sal_True );
137 for( sal_Int32 nIndex = 0; nIndex < nTabs; nIndex++ )
139 if( style::TabAlign_DEFAULT != pTabs[nIndex].Alignment )
140 exportTabStop( &(pTabs[nIndex]) );