LibreOffice Module xmloff (master) 1
cdouthdl.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 "cdouthdl.hxx"
21#include <xmloff/xmltoken.hxx>
22#include <xmloff/xmluconv.hxx>
23#include <xmloff/xmlement.hxx>
24#include <rtl/ustrbuf.hxx>
25#include <osl/diagnose.h>
26
27#include <com/sun/star/awt/FontStrikeout.hpp>
28#include <com/sun/star/uno/Any.hxx>
29
30using namespace ::com::sun::star;
31using namespace ::com::sun::star::awt;
32using namespace ::xmloff::token;
33
35{
36 { XML_NONE, awt::FontStrikeout::NONE },
37 { XML_SINGLE, awt::FontStrikeout::SINGLE },
38 { XML_DOUBLE, awt::FontStrikeout::DOUBLE },
39 { XML_SINGLE, awt::FontStrikeout::BOLD },
40 { XML_SINGLE, awt::FontStrikeout::SLASH },
41 { XML_SINGLE, awt::FontStrikeout::X },
43};
44
46{
47 { XML_NONE, awt::FontStrikeout::NONE },
48 { XML_SOLID, awt::FontStrikeout::SINGLE },
49 { XML_SOLID, awt::FontStrikeout::DOUBLE },
50 { XML_SOLID, awt::FontStrikeout::BOLD },
51 { XML_SOLID, awt::FontStrikeout::SLASH },
52 { XML_SOLID, awt::FontStrikeout::X },
53 { XML_DOTTED, awt::FontStrikeout::SINGLE },
54 { XML_DASH, awt::FontStrikeout::SINGLE },
55 { XML_LONG_DASH, awt::FontStrikeout::SINGLE },
56 { XML_DOT_DASH, awt::FontStrikeout::SINGLE },
57 { XML_DOT_DOT_DASH, awt::FontStrikeout::SINGLE },
58 { XML_WAVE, awt::FontStrikeout::SINGLE },
60};
61
63{
64 { XML_AUTO, awt::FontStrikeout::NONE },
65 { XML_AUTO, awt::FontStrikeout::SINGLE },
66 { XML_AUTO, awt::FontStrikeout::DOUBLE },
67 { XML_BOLD, awt::FontStrikeout::BOLD },
68 { XML_AUTO, awt::FontStrikeout::SLASH },
69 { XML_AUTO, awt::FontStrikeout::X },
70 { XML_THIN, awt::FontStrikeout::NONE },
71 { XML_MEDIUM, awt::FontStrikeout::NONE },
72 { XML_THICK, awt::FontStrikeout::NONE },
74};
75
76
78{
79 // nothing to do
80}
81
82bool XMLCrossedOutTypePropHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& ) const
83{
84 sal_uInt16 eNewStrikeout = 0;
86 eNewStrikeout, rStrImpValue, pXML_CrossedoutType_Enum );
87 if( bRet )
88 {
89 // multi property: style and width might be set already.
90 // If the old value is NONE, the new is used unchanged.
91 sal_Int16 eStrikeout = sal_Int16();
92 if( (rValue >>= eStrikeout) && awt::FontStrikeout::NONE!=eStrikeout )
93 {
94 switch( eNewStrikeout )
95 {
96 case awt::FontStrikeout::NONE:
97 case awt::FontStrikeout::SINGLE:
98 // keep existing line style
99 eNewStrikeout = eStrikeout;
100 break;
101 case awt::FontStrikeout::DOUBLE:
102 // A double line style has priority over a solid or a bold
103 // line style,
104 // but not about any other line style
105 switch( eStrikeout )
106 {
107 case awt::FontStrikeout::SINGLE:
108 case awt::FontStrikeout::BOLD:
109 break;
110 default:
111 // If a double line style is not supported for the existing
112 // value, keep the new one
113 eNewStrikeout = eStrikeout;
114 break;
115 }
116 break;
117 default:
118 OSL_ENSURE( bRet, "unexpected line type value" );
119 break;
120 }
121 if( eNewStrikeout != eStrikeout )
122 rValue <<= static_cast<sal_Int16>(eNewStrikeout);
123 }
124 else
125 {
126 rValue <<= static_cast<sal_Int16>(eNewStrikeout);
127 }
128 }
129
130 return bRet;
131}
132
133bool XMLCrossedOutTypePropHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const
134{
135 bool bRet = false;
136 sal_uInt16 nValue = sal_uInt16();
137
138 if (rValue >>= nValue)
139 {
140 OUStringBuffer aOut;
143 if( bRet )
144 rStrExpValue = aOut.makeStringAndClear();
145 }
146
147 return bRet;
148}
149
150
152{
153 // nothing to do
154}
155
156bool XMLCrossedOutStylePropHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& ) const
157{
158 sal_uInt16 eNewStrikeout(0);
160 eNewStrikeout, rStrImpValue, pXML_CrossedoutStyle_Enum );
161 if( bRet )
162 {
163 // multi property: style and width might be set already.
164 // If the old value is NONE, the new is used unchanged.
165 sal_Int16 eStrikeout = sal_Int16();
166 if( (rValue >>= eStrikeout) && awt::FontStrikeout::NONE!=eStrikeout )
167 {
168 // one NONE a SINGLE are possible new values. For both, the
169 // existing value is kept.
170 }
171 else
172 {
173 rValue <<= static_cast<sal_Int16>(eNewStrikeout);
174 }
175 }
176
177 return bRet;
178}
179
180bool XMLCrossedOutStylePropHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const
181{
182 bool bRet = false;
183 sal_uInt16 nValue = sal_uInt16();
184
185 if( rValue >>= nValue )
186 {
187 OUStringBuffer aOut;
190 if( bRet )
191 rStrExpValue = aOut.makeStringAndClear();
192 }
193
194 return bRet;
195}
196
197
199{
200 // nothing to do
201}
202
203bool XMLCrossedOutWidthPropHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& ) const
204{
205 sal_uInt16 eNewStrikeout = 0;
207 eNewStrikeout, rStrImpValue, pXML_CrossedoutWidth_Enum );
208 if( bRet )
209 {
210 // multi property: style and width might be set already.
211 // If the old value is NONE, the new is used unchanged.
212 sal_Int16 eStrikeout = sal_Int16();
213 if( (rValue >>= eStrikeout) && awt::FontStrikeout::NONE!=eStrikeout )
214 {
215 switch( eNewStrikeout )
216 {
217 case awt::FontStrikeout::NONE:
218 // keep existing line style
219 eNewStrikeout = eStrikeout;
220 break;
221 case awt::FontStrikeout::BOLD:
222 switch( eStrikeout )
223 {
224 case awt::FontStrikeout::SINGLE:
225 break;
226 default:
227 // If a double line style is not supported for the existing
228 // value, keep the new one
229 eNewStrikeout = eStrikeout;
230 break;
231 }
232 break;
233 default:
234 OSL_ENSURE( bRet, "unexpected line type value" );
235 break;
236 }
237 if( eNewStrikeout != eStrikeout )
238 rValue <<= static_cast<sal_Int16>(eNewStrikeout);
239 }
240 else
241 {
242 rValue <<= static_cast<sal_Int16>(eNewStrikeout);
243 }
244 }
245
246 return bRet;
247}
248
249bool XMLCrossedOutWidthPropHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const
250{
251 bool bRet = false;
252 sal_uInt16 nValue = sal_uInt16();
253
254 if( (rValue >>= nValue) && (awt::FontStrikeout::BOLD == nValue) )
255 {
256 OUStringBuffer aOut;
259 if( bRet )
260 rStrExpValue = aOut.makeStringAndClear();
261 }
262
263 return bRet;
264}
265
266
268{
269 // nothing to do
270}
271
272bool XMLCrossedOutTextPropHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& ) const
273{
274 bool bRet = false;
275
276 if( !rStrImpValue.isEmpty() )
277 {
278 sal_Int16 eStrikeout = ('/' == rStrImpValue[0]
279 ? awt::FontStrikeout::SLASH
280 : awt::FontStrikeout::X);
281 rValue <<= eStrikeout;
282 bRet = true;
283 }
284
285 return bRet;
286}
287
288bool XMLCrossedOutTextPropHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const
289{
290 bool bRet = false;
291 sal_Int16 nValue = sal_Int16();
292
293 if( (rValue >>= nValue) &&
294 (awt::FontStrikeout::SLASH == nValue || awt::FontStrikeout::X == nValue) )
295 {
296 rStrExpValue = OUString(
297 static_cast< sal_Unicode>( awt::FontStrikeout::SLASH == nValue ? '/'
298 : 'X' ) );
299 bRet = true;
300 }
301
302 return bRet;
303}
304
305/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SvXMLEnumMapEntry< sal_uInt16 > const pXML_CrossedoutStyle_Enum[]
Definition: cdouthdl.cxx:45
SvXMLEnumMapEntry< sal_uInt16 > const pXML_CrossedoutType_Enum[]
Definition: cdouthdl.cxx:34
SvXMLEnumMapEntry< sal_uInt16 > const pXML_CrossedoutWidth_Enum[]
Definition: cdouthdl.cxx:62
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 ~XMLCrossedOutStylePropHdl() override
Definition: cdouthdl.cxx:151
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: cdouthdl.cxx:156
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: cdouthdl.cxx:180
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: cdouthdl.cxx:288
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: cdouthdl.cxx:272
virtual ~XMLCrossedOutTextPropHdl() override
Definition: cdouthdl.cxx:267
virtual ~XMLCrossedOutTypePropHdl() override
Definition: cdouthdl.cxx:77
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: cdouthdl.cxx:133
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: cdouthdl.cxx:82
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: cdouthdl.cxx:249
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: cdouthdl.cxx:203
virtual ~XMLCrossedOutWidthPropHdl() override
Definition: cdouthdl.cxx:198
sal_Int16 nValue
Handling of tokens in XML:
sal_uInt16 sal_Unicode