Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
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>
26 :
27 : using namespace ::com::sun::star;
28 :
29 : using namespace ::xmloff::token;
30 :
31 : SvXMLEnumMapEntry const pXML_Para_Adjust_Enum[] =
32 : {
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 }
41 : };
42 :
43 : SvXMLEnumMapEntry const pXML_Para_Align_Last_Enum[] =
44 : {
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 }
50 : };
51 :
52 :
53 : // class XMLParaAdjustPropHdl
54 :
55 :
56 23184 : XMLParaAdjustPropHdl::~XMLParaAdjustPropHdl()
57 : {
58 : // nothing to do
59 23184 : }
60 :
61 1820 : bool XMLParaAdjustPropHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& ) const
62 : {
63 : sal_uInt16 eAdjust;
64 1820 : bool bRet = SvXMLUnitConverter::convertEnum( eAdjust, rStrImpValue, pXML_Para_Adjust_Enum );
65 1820 : if( bRet )
66 1820 : rValue <<= (sal_Int16)eAdjust;
67 :
68 1820 : return bRet;
69 : }
70 :
71 176 : bool XMLParaAdjustPropHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const
72 : {
73 176 : if(!rValue.hasValue())
74 0 : return false;
75 176 : OUStringBuffer aOut;
76 176 : sal_Int16 nVal = 0;
77 :
78 176 : rValue >>= nVal;
79 :
80 176 : bool bRet = SvXMLUnitConverter::convertEnum( aOut, nVal, pXML_Para_Adjust_Enum, XML_START );
81 :
82 176 : rStrExpValue = aOut.makeStringAndClear();
83 :
84 176 : return bRet;
85 : }
86 :
87 :
88 : // class XMLLastLineAdjustPropHdl
89 :
90 :
91 23184 : XMLLastLineAdjustPropHdl::~XMLLastLineAdjustPropHdl()
92 : {
93 : // nothing to do
94 23184 : }
95 :
96 4 : bool XMLLastLineAdjustPropHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& ) const
97 : {
98 : sal_uInt16 eAdjust;
99 4 : bool bRet = SvXMLUnitConverter::convertEnum( eAdjust, rStrImpValue, pXML_Para_Align_Last_Enum );
100 4 : if( bRet )
101 4 : rValue <<= (sal_Int16)eAdjust;
102 :
103 4 : return bRet;
104 : }
105 :
106 176 : bool XMLLastLineAdjustPropHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const
107 : {
108 176 : OUStringBuffer aOut;
109 176 : sal_Int16 nVal = 0;
110 176 : bool bRet = false;
111 :
112 176 : rValue >>= nVal;
113 :
114 176 : if( nVal != style::ParagraphAdjust_LEFT )
115 0 : bRet = SvXMLUnitConverter::convertEnum( aOut, nVal, pXML_Para_Align_Last_Enum, XML_START );
116 :
117 176 : rStrExpValue = aOut.makeStringAndClear();
118 :
119 176 : return bRet;
120 : }
121 :
122 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|