1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include <com/sun/star/style/TabStop.hpp>
22 #include <com/sun/star/style/TabAlign.hpp>
23 #include <rtl/ustrbuf.hxx>
24 #include <xmloff/nmspmap.hxx>
25 #include <xmloff/xmlnmspe.hxx>
26 #include <xmloff/xmltoken.hxx>
27 #include <xmloff/xmluconv.hxx>
28 #include <xmloff/xmlexp.hxx>
29 #include <xmloff/xmltabe.hxx>
32 using namespace ::com::sun::star
;
33 using namespace ::xmloff::token
;
35 SvXMLEnumMapEntry pXML_tabstop_style
[] =
37 { XML_LEFT
, style::TabAlign_LEFT
},
38 { XML_CENTER
, style::TabAlign_CENTER
},
39 { XML_RIGHT
, style::TabAlign_RIGHT
},
40 { XML_CHAR
, style::TabAlign_DECIMAL
},
41 { XML_DEFAULT
, style::TabAlign_DEFAULT
}, // ?????????????????????????????????????
42 { XML_TOKEN_INVALID
, 0 }
45 void SvxXMLTabStopExport::exportTabStop( const ::com::sun::star::style::TabStop
* pTabStop
)
47 SvXMLUnitConverter
& rUnitConv
= rExport
.GetMM100UnitConverter();
50 OUStringBuffer sBuffer
;
53 rUnitConv
.convertMeasureToXML( sBuffer
, pTabStop
->Position
);
54 rExport
.AddAttribute( XML_NAMESPACE_STYLE
, XML_POSITION
,
55 sBuffer
.makeStringAndClear() );
58 if( style::TabAlign_LEFT
!= pTabStop
->Alignment
)
60 SvXMLUnitConverter::convertEnum( sBuffer
, pTabStop
->Alignment
,
62 rExport
.AddAttribute( XML_NAMESPACE_STYLE
, XML_TYPE
,
63 sBuffer
.makeStringAndClear() );
67 if( style::TabAlign_DECIMAL
== pTabStop
->Alignment
&&
68 pTabStop
->DecimalChar
!= 0 )
70 sBuffer
.append( pTabStop
->DecimalChar
);
71 rExport
.AddAttribute( XML_NAMESPACE_STYLE
, XML_CHAR
,
72 sBuffer
.makeStringAndClear() );
76 if( ' ' != pTabStop
->FillChar
&& 0 != pTabStop
->FillChar
)
78 rExport
.AddAttribute( XML_NAMESPACE_STYLE
, XML_LEADER_STYLE
,
79 GetXMLToken('.' == pTabStop
->FillChar
? XML_DOTTED
82 sBuffer
.append( pTabStop
->FillChar
);
83 rExport
.AddAttribute( XML_NAMESPACE_STYLE
, XML_LEADER_TEXT
,
84 sBuffer
.makeStringAndClear() );
87 SvXMLElementExport
rElem( rExport
, XML_NAMESPACE_STYLE
, XML_TAB_STOP
,
92 SvxXMLTabStopExport::SvxXMLTabStopExport(
98 SvxXMLTabStopExport::~SvxXMLTabStopExport()
102 void SvxXMLTabStopExport::Export( const uno::Any
& rAny
)
104 uno::Sequence
< ::com::sun::star::style::TabStop
> aSeq
;
107 OSL_FAIL( "SvxXMLTabStopExport needs a Sequence ::com::sun::star::style::TabStop>" );
111 const ::com::sun::star::style::TabStop
* pTabs
= aSeq
.getConstArray();
112 const sal_Int32 nTabs
= aSeq
.getLength();
114 SvXMLElementExport
rElem( rExport
, XML_NAMESPACE_STYLE
, XML_TAB_STOPS
,
117 for( sal_Int32 nIndex
= 0; nIndex
< nTabs
; nIndex
++ )
119 if( style::TabAlign_DEFAULT
!= pTabs
[nIndex
].Alignment
)
120 exportTabStop( &(pTabs
[nIndex
]) );
126 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */