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 .
20 #include "adjushdl.hxx"
21 #include <xmloff/xmltoken.hxx>
22 #include <xmloff/xmluconv.hxx>
23 #include <xmloff/xmlement.hxx>
24 #include <rtl/ustrbuf.hxx>
25 #include <com/sun/star/style/ParagraphAdjust.hpp>
26 #include <com/sun/star/uno/Any.hxx>
28 using namespace ::com::sun::star
;
30 using namespace ::xmloff::token
;
32 SvXMLEnumMapEntry
<style::ParagraphAdjust
> const pXML_Para_Adjust_Enum
[] =
34 { XML_START
, style::ParagraphAdjust_LEFT
},
35 { XML_END
, style::ParagraphAdjust_RIGHT
},
36 { XML_CENTER
, style::ParagraphAdjust_CENTER
},
37 { XML_JUSTIFY
, style::ParagraphAdjust_BLOCK
},
38 { XML_JUSTIFIED
, style::ParagraphAdjust_BLOCK
}, // obsolete
39 { XML_LEFT
, style::ParagraphAdjust_LEFT
},
40 { XML_RIGHT
, style::ParagraphAdjust_RIGHT
},
41 { XML_TOKEN_INVALID
, style::ParagraphAdjust(0) }
44 SvXMLEnumMapEntry
<style::ParagraphAdjust
> const pXML_Para_Align_Last_Enum
[] =
46 { XML_START
, style::ParagraphAdjust_LEFT
},
47 { XML_CENTER
, style::ParagraphAdjust_CENTER
},
48 { XML_JUSTIFY
, style::ParagraphAdjust_BLOCK
},
49 { XML_JUSTIFIED
, style::ParagraphAdjust_BLOCK
}, // obsolete
50 { XML_TOKEN_INVALID
, style::ParagraphAdjust(0) }
56 XMLParaAdjustPropHdl::~XMLParaAdjustPropHdl()
61 bool XMLParaAdjustPropHdl::importXML( const OUString
& rStrImpValue
, uno::Any
& rValue
, const SvXMLUnitConverter
& ) const
63 style::ParagraphAdjust eAdjust
;
64 bool bRet
= SvXMLUnitConverter::convertEnum( eAdjust
, rStrImpValue
, pXML_Para_Adjust_Enum
);
66 rValue
<<= static_cast<sal_Int16
>(eAdjust
);
71 bool XMLParaAdjustPropHdl::exportXML( OUString
& rStrExpValue
, const uno::Any
& rValue
, const SvXMLUnitConverter
& ) const
73 if(!rValue
.hasValue())
80 bool bRet
= SvXMLUnitConverter::convertEnum( aOut
, static_cast<style::ParagraphAdjust
>(nVal
), pXML_Para_Adjust_Enum
, XML_START
);
82 rStrExpValue
= aOut
.makeStringAndClear();
90 XMLLastLineAdjustPropHdl::~XMLLastLineAdjustPropHdl()
95 bool XMLLastLineAdjustPropHdl::importXML( const OUString
& rStrImpValue
, uno::Any
& rValue
, const SvXMLUnitConverter
& ) const
97 style::ParagraphAdjust eAdjust
;
98 bool bRet
= SvXMLUnitConverter::convertEnum( eAdjust
, rStrImpValue
, pXML_Para_Align_Last_Enum
);
100 rValue
<<= static_cast<sal_Int16
>(eAdjust
);
105 bool XMLLastLineAdjustPropHdl::exportXML( OUString
& rStrExpValue
, const uno::Any
& rValue
, const SvXMLUnitConverter
& ) const
113 if( static_cast<style::ParagraphAdjust
>(nVal
) != style::ParagraphAdjust_LEFT
)
114 bRet
= SvXMLUnitConverter::convertEnum( aOut
, static_cast<style::ParagraphAdjust
>(nVal
), pXML_Para_Align_Last_Enum
, XML_START
);
116 rStrExpValue
= aOut
.makeStringAndClear();
121 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */