LibreOffice Module xmloff (master) 1
adjushdl.cxx
Go to the documentation of this file.
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 <xmloff/xmlement.hxx>
24#include <rtl/ustrbuf.hxx>
25#include <com/sun/star/style/ParagraphAdjust.hpp>
26#include <com/sun/star/uno/Any.hxx>
27
28using namespace ::com::sun::star;
29
30using namespace ::xmloff::token;
31
33{
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) }
42};
43
45{
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) }
51};
52
53
54
55
57{
58 // nothing to do
59}
60
61bool XMLParaAdjustPropHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& ) const
62{
63 style::ParagraphAdjust eAdjust;
64 bool bRet = SvXMLUnitConverter::convertEnum( eAdjust, rStrImpValue, pXML_Para_Adjust_Enum );
65 if( bRet )
66 rValue <<= static_cast<sal_Int16>(eAdjust);
67
68 return bRet;
69}
70
71bool XMLParaAdjustPropHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const
72{
73 if(!rValue.hasValue())
74 return false;
75 OUStringBuffer aOut;
76 sal_Int16 nVal = 0;
77
78 rValue >>= nVal;
79
80 bool bRet = SvXMLUnitConverter::convertEnum( aOut, static_cast<style::ParagraphAdjust>(nVal), pXML_Para_Adjust_Enum, XML_START );
81
82 rStrExpValue = aOut.makeStringAndClear();
83
84 return bRet;
85}
86
87
88
89
91{
92 // nothing to do
93}
94
95bool XMLLastLineAdjustPropHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& ) const
96{
97 style::ParagraphAdjust eAdjust;
98 bool bRet = SvXMLUnitConverter::convertEnum( eAdjust, rStrImpValue, pXML_Para_Align_Last_Enum );
99 if( bRet )
100 rValue <<= static_cast<sal_Int16>(eAdjust);
101
102 return bRet;
103}
104
105bool XMLLastLineAdjustPropHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const
106{
107 OUStringBuffer aOut;
108 sal_Int16 nVal = 0;
109 bool bRet = false;
110
111 rValue >>= nVal;
112
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 );
115
116 rStrExpValue = aOut.makeStringAndClear();
117
118 return bRet;
119}
120
121/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SvXMLEnumMapEntry< style::ParagraphAdjust > const pXML_Para_Align_Last_Enum[]
Definition: adjushdl.cxx:44
SvXMLEnumMapEntry< style::ParagraphAdjust > const pXML_Para_Adjust_Enum[]
Definition: adjushdl.cxx:32
the SvXMLTypeConverter converts values of various types from their internal representation to the tex...
Definition: xmluconv.hxx:83
static bool convertEnum(EnumT &rEnum, std::u16string_view rValue, const SvXMLEnumMapEntry< EnumT > *pMap)
convert string to enum using given enum map, if the enum is not found in the map, this method will re...
Definition: xmluconv.hxx:145
virtual bool importXML(const OUString &rStrImpValue, css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Imports the given value according to the XML-data-type corresponding to the derived class.
Definition: adjushdl.cxx:95
virtual bool exportXML(OUString &rStrExpValue, const css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Exports the given value according to the XML-data-type corresponding to the derived class.
Definition: adjushdl.cxx:105
virtual ~XMLLastLineAdjustPropHdl() override
Definition: adjushdl.cxx:90
virtual bool exportXML(OUString &rStrExpValue, const css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Exports the given value according to the XML-data-type corresponding to the derived class.
Definition: adjushdl.cxx:71
virtual bool importXML(const OUString &rStrImpValue, css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Imports the given value according to the XML-data-type corresponding to the derived class.
Definition: adjushdl.cxx:61
virtual ~XMLParaAdjustPropHdl() override
Definition: adjushdl.cxx:56
Handling of tokens in XML:
bool hasValue()