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 <osl/diagnose.h>
25 #include <xmloff/xmlement.hxx>
26 #include <xmloff/xmlnamespace.hxx>
27 #include <xmloff/xmltoken.hxx>
28 #include <xmloff/xmluconv.hxx>
29 #include <xmloff/xmlexp.hxx>
30 #include <xmltabe.hxx>
33 using namespace ::com::sun::star
;
34 using namespace ::xmloff::token
;
36 SvXMLEnumMapEntry
<style::TabAlign
> const pXML_tabstop_style
[] =
38 { XML_LEFT
, style::TabAlign_LEFT
},
39 { XML_CENTER
, style::TabAlign_CENTER
},
40 { XML_RIGHT
, style::TabAlign_RIGHT
},
41 { XML_CHAR
, style::TabAlign_DECIMAL
},
42 { XML_DEFAULT
, style::TabAlign_DEFAULT
}, // ?????????????????????????????????????
43 { XML_TOKEN_INVALID
, style::TabAlign(0) }
46 void SvxXMLTabStopExport::exportTabStop( const css::style::TabStop
* pTabStop
)
48 SvXMLUnitConverter
& rUnitConv
= rExport
.GetMM100UnitConverter();
51 OUStringBuffer sBuffer
;
54 rUnitConv
.convertMeasureToXML( sBuffer
, pTabStop
->Position
);
55 rExport
.AddAttribute( XML_NAMESPACE_STYLE
, XML_POSITION
,
56 sBuffer
.makeStringAndClear() );
59 if( style::TabAlign_LEFT
!= pTabStop
->Alignment
)
61 SvXMLUnitConverter::convertEnum( sBuffer
, pTabStop
->Alignment
,
63 rExport
.AddAttribute( XML_NAMESPACE_STYLE
, XML_TYPE
,
64 sBuffer
.makeStringAndClear() );
68 if( style::TabAlign_DECIMAL
== pTabStop
->Alignment
&&
69 pTabStop
->DecimalChar
!= 0 )
71 sBuffer
.append( pTabStop
->DecimalChar
);
72 rExport
.AddAttribute( XML_NAMESPACE_STYLE
, XML_CHAR
,
73 sBuffer
.makeStringAndClear() );
77 if( ' ' != pTabStop
->FillChar
&& 0 != pTabStop
->FillChar
)
79 rExport
.AddAttribute( XML_NAMESPACE_STYLE
, XML_LEADER_STYLE
,
80 GetXMLToken('.' == pTabStop
->FillChar
? XML_DOTTED
83 sBuffer
.append( pTabStop
->FillChar
);
84 rExport
.AddAttribute( XML_NAMESPACE_STYLE
, XML_LEADER_TEXT
,
85 sBuffer
.makeStringAndClear() );
88 SvXMLElementExport
rElem( rExport
, XML_NAMESPACE_STYLE
, XML_TAB_STOP
,
93 SvxXMLTabStopExport::SvxXMLTabStopExport(
99 void SvxXMLTabStopExport::Export( const uno::Any
& rAny
)
101 uno::Sequence
< css::style::TabStop
> aSeq
;
104 OSL_FAIL( "SvxXMLTabStopExport needs a Sequence css::style::TabStop>" );
108 SvXMLElementExport
rElem( rExport
, XML_NAMESPACE_STYLE
, XML_TAB_STOPS
,
111 for (const auto& rTab
: aSeq
)
113 if( style::TabAlign_DEFAULT
!= rTab
.Alignment
)
114 exportTabStop( &rTab
);
120 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */