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 <tools/solar.h>
22 #include <xmloff/xmltoken.hxx>
23 #include <xmloff/xmluconv.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
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
, 0 }
44 SvXMLEnumMapEntry
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
, 0 }
53 ///////////////////////////////////////////////////////////////////////////////
55 // class XMLParaAdjustPropHdl
58 XMLParaAdjustPropHdl::~XMLParaAdjustPropHdl()
63 sal_Bool
XMLParaAdjustPropHdl::importXML( const OUString
& rStrImpValue
, uno::Any
& rValue
, const SvXMLUnitConverter
& ) const
66 sal_Bool bRet
= SvXMLUnitConverter::convertEnum( eAdjust
, rStrImpValue
, pXML_Para_Adjust_Enum
);
68 rValue
<<= (sal_Int16
)eAdjust
;
73 sal_Bool
XMLParaAdjustPropHdl::exportXML( OUString
& rStrExpValue
, const uno::Any
& rValue
, const SvXMLUnitConverter
& ) const
75 if(!rValue
.hasValue())
82 sal_Bool bRet
= SvXMLUnitConverter::convertEnum( aOut
, nVal
, pXML_Para_Adjust_Enum
, XML_START
);
84 rStrExpValue
= aOut
.makeStringAndClear();
89 ///////////////////////////////////////////////////////////////////////////////
91 // class XMLLastLineAdjustPropHdl
94 XMLLastLineAdjustPropHdl::~XMLLastLineAdjustPropHdl()
99 sal_Bool
XMLLastLineAdjustPropHdl::importXML( const OUString
& rStrImpValue
, uno::Any
& rValue
, const SvXMLUnitConverter
& ) const
102 sal_Bool bRet
= SvXMLUnitConverter::convertEnum( eAdjust
, rStrImpValue
, pXML_Para_Align_Last_Enum
);
104 rValue
<<= (sal_Int16
)eAdjust
;
109 sal_Bool
XMLLastLineAdjustPropHdl::exportXML( OUString
& rStrExpValue
, const uno::Any
& rValue
, const SvXMLUnitConverter
& ) const
113 sal_Bool bRet
= sal_False
;
117 if( nVal
!= style::ParagraphAdjust_LEFT
)
118 bRet
= SvXMLUnitConverter::convertEnum( aOut
, nVal
, pXML_Para_Align_Last_Enum
, XML_START
);
120 rStrExpValue
= aOut
.makeStringAndClear();
125 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */