bump product version to 5.0.4.1
[LibreOffice.git] / xmloff / source / style / adjushdl.cxx
blob3abb34e2b3b370cc112ba01267bc6cb013263e08
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <rtl/ustrbuf.hxx>
24 #include <com/sun/star/style/ParagraphAdjust.hpp>
25 #include <com/sun/star/uno/Any.hxx>
27 using namespace ::com::sun::star;
29 using namespace ::xmloff::token;
31 SvXMLEnumMapEntry const pXML_Para_Adjust_Enum[] =
33 { XML_START, style::ParagraphAdjust_LEFT },
34 { XML_END, style::ParagraphAdjust_RIGHT },
35 { XML_CENTER, style::ParagraphAdjust_CENTER },
36 { XML_JUSTIFY, style::ParagraphAdjust_BLOCK },
37 { XML_JUSTIFIED, style::ParagraphAdjust_BLOCK }, // obsolete
38 { XML_LEFT, style::ParagraphAdjust_LEFT },
39 { XML_RIGHT, style::ParagraphAdjust_RIGHT },
40 { XML_TOKEN_INVALID, 0 }
43 SvXMLEnumMapEntry const pXML_Para_Align_Last_Enum[] =
45 { XML_START, style::ParagraphAdjust_LEFT },
46 { XML_CENTER, style::ParagraphAdjust_CENTER },
47 { XML_JUSTIFY, style::ParagraphAdjust_BLOCK },
48 { XML_JUSTIFIED, style::ParagraphAdjust_BLOCK }, // obsolete
49 { XML_TOKEN_INVALID, 0 }
53 // class XMLParaAdjustPropHdl
56 XMLParaAdjustPropHdl::~XMLParaAdjustPropHdl()
58 // nothing to do
61 bool XMLParaAdjustPropHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& ) const
63 sal_uInt16 eAdjust;
64 bool bRet = SvXMLUnitConverter::convertEnum( eAdjust, rStrImpValue, pXML_Para_Adjust_Enum );
65 if( bRet )
66 rValue <<= (sal_Int16)eAdjust;
68 return bRet;
71 bool XMLParaAdjustPropHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const
73 if(!rValue.hasValue())
74 return false;
75 OUStringBuffer aOut;
76 sal_Int16 nVal = 0;
78 rValue >>= nVal;
80 bool bRet = SvXMLUnitConverter::convertEnum( aOut, nVal, pXML_Para_Adjust_Enum, XML_START );
82 rStrExpValue = aOut.makeStringAndClear();
84 return bRet;
88 // class XMLLastLineAdjustPropHdl
91 XMLLastLineAdjustPropHdl::~XMLLastLineAdjustPropHdl()
93 // nothing to do
96 bool XMLLastLineAdjustPropHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& ) const
98 sal_uInt16 eAdjust;
99 bool bRet = SvXMLUnitConverter::convertEnum( eAdjust, rStrImpValue, pXML_Para_Align_Last_Enum );
100 if( bRet )
101 rValue <<= (sal_Int16)eAdjust;
103 return bRet;
106 bool XMLLastLineAdjustPropHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const
108 OUStringBuffer aOut;
109 sal_Int16 nVal = 0;
110 bool bRet = false;
112 rValue >>= nVal;
114 if( nVal != style::ParagraphAdjust_LEFT )
115 bRet = SvXMLUnitConverter::convertEnum( aOut, nVal, pXML_Para_Align_Last_Enum, XML_START );
117 rStrExpValue = aOut.makeStringAndClear();
119 return bRet;
122 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */