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 <tools/debug.hxx>
21 : #include <rtl/ustrbuf.hxx>
22 : #include <tools/fontenum.hxx>
23 : #include <com/sun/star/uno/Any.hxx>
24 : #include <com/sun/star/drawing/FillStyle.hpp>
25 : #include <com/sun/star/style/DropCapFormat.hpp>
26 : #include <com/sun/star/text/FontRelief.hpp>
27 : #include <com/sun/star/text/WrapTextMode.hpp>
28 : #include <com/sun/star/text/XTextColumns.hpp>
29 : #include <com/sun/star/text/TextColumn.hpp>
30 : #include <com/sun/star/text/RelOrientation.hpp>
31 : #include <com/sun/star/text/HoriOrientation.hpp>
32 : #include <com/sun/star/text/VertOrientation.hpp>
33 : #include <com/sun/star/text/RubyAdjust.hpp>
34 : #include <com/sun/star/text/FontEmphasis.hpp>
35 : #include <com/sun/star/text/ParagraphVertAlign.hpp>
36 : #include <sax/tools/converter.hxx>
37 : #include <xmloff/xmltypes.hxx>
38 : #include <xmloff/xmluconv.hxx>
39 : #include <xmloff/xmltoken.hxx>
40 : #include "XMLAnchorTypePropHdl.hxx"
41 : #include <xmloff/XMLConstantsPropertyHandler.hxx>
42 : #include "XMLClipPropertyHandler.hxx"
43 : #include "XMLTextColumnsPropertyHandler.hxx"
44 : #include <xmloff/NamedBoolPropertyHdl.hxx>
45 : #include "txtprhdl.hxx"
46 : // OD 2004-05-05 #i28701#
47 : #include <com/sun/star/text/WrapInfluenceOnPosition.hpp>
48 :
49 :
50 :
51 : using namespace ::com::sun::star;
52 : using namespace ::com::sun::star::uno;
53 : using namespace ::com::sun::star::style;
54 : using namespace ::com::sun::star::text;
55 : using namespace ::xmloff::token;
56 :
57 : // ---------------------------------------------------------------------------
58 :
59 : SvXMLEnumMapEntry const pXML_HoriPos_Enum[] =
60 : {
61 : { XML_FROM_LEFT, HoriOrientation::NONE },
62 : { XML_FROM_INSIDE, HoriOrientation::NONE }, // import only
63 : { XML_LEFT, HoriOrientation::LEFT },
64 : { XML_INSIDE, HoriOrientation::LEFT }, // import only
65 : { XML_CENTER, HoriOrientation::CENTER },
66 : { XML_RIGHT, HoriOrientation::RIGHT },
67 : { XML_OUTSIDE, HoriOrientation::RIGHT }, // import only
68 : { XML_TOKEN_INVALID, 0 }
69 : };
70 :
71 : SvXMLEnumMapEntry const pXML_HoriPosMirrored_Enum[] =
72 : {
73 : { XML_FROM_INSIDE, HoriOrientation::NONE },
74 : { XML_INSIDE, HoriOrientation::LEFT },
75 : { XML_CENTER, HoriOrientation::CENTER },
76 : { XML_OUTSIDE, HoriOrientation::RIGHT },
77 : { XML_TOKEN_INVALID, 0 }
78 : };
79 :
80 : SvXMLEnumMapEntry const pXML_HoriRel_Enum[] =
81 : {
82 : { XML_PARAGRAPH, RelOrientation::FRAME },
83 : { XML_PARAGRAPH_CONTENT, RelOrientation::PRINT_AREA },
84 : { XML_PAGE, RelOrientation::PAGE_FRAME },
85 : { XML_PAGE_CONTENT, RelOrientation::PAGE_PRINT_AREA },
86 : { XML_PARAGRAPH_START_MARGIN, RelOrientation::FRAME_LEFT },
87 : { XML_PARAGRAPH_END_MARGIN, RelOrientation::FRAME_RIGHT },
88 : { XML_PAGE_START_MARGIN, RelOrientation::PAGE_LEFT },
89 : { XML_PAGE_END_MARGIN, RelOrientation::PAGE_RIGHT },
90 : { XML_CHAR, RelOrientation::CHAR },
91 : { XML_FRAME, RelOrientation::FRAME }, // import only
92 : { XML_FRAME_CONTENT, RelOrientation::PRINT_AREA }, // import only
93 : { XML_FRAME_START_MARGIN, RelOrientation::FRAME_LEFT }, // import only
94 : { XML_FRAME_END_MARGIN, RelOrientation::FRAME_RIGHT }, // import only
95 : { XML_TOKEN_INVALID, 0 }
96 : };
97 :
98 : SvXMLEnumMapEntry const pXML_HoriRelFrame_Enum[] =
99 : {
100 : { XML_FRAME, RelOrientation::FRAME },
101 : { XML_FRAME_CONTENT, RelOrientation::PRINT_AREA },
102 : { XML_PAGE, RelOrientation::PAGE_FRAME },
103 : { XML_PAGE_CONTENT, RelOrientation::PAGE_PRINT_AREA },
104 : { XML_FRAME_START_MARGIN, RelOrientation::FRAME_LEFT },
105 : { XML_FRAME_END_MARGIN, RelOrientation::FRAME_RIGHT },
106 : { XML_PAGE_START_MARGIN, RelOrientation::PAGE_LEFT },
107 : { XML_PAGE_END_MARGIN, RelOrientation::PAGE_RIGHT },
108 : { XML_CHAR, RelOrientation::CHAR },
109 : { XML_TOKEN_INVALID, 0 }
110 : };
111 :
112 : SvXMLEnumMapEntry const pXML_HoriMirror_Enum[] =
113 : {
114 : { XML_FROM_LEFT, sal_False },
115 : { XML_FROM_INSIDE, sal_True },
116 : { XML_LEFT, sal_False },
117 : { XML_INSIDE, sal_True },
118 : { XML_CENTER, sal_False },
119 : { XML_RIGHT, sal_False },
120 : { XML_OUTSIDE, sal_True },
121 : { XML_TOKEN_INVALID, 0 }
122 : };
123 :
124 : SvXMLEnumMapEntry const pXML_VertPos_Enum[] =
125 : {
126 : { XML_FROM_TOP, VertOrientation::NONE },
127 : { XML_TOP, VertOrientation::TOP },
128 : { XML_TOP, VertOrientation::CHAR_TOP }, // export only
129 : { XML_TOP, VertOrientation::LINE_TOP }, // export only
130 : { XML_MIDDLE, VertOrientation::CENTER },
131 : { XML_MIDDLE, VertOrientation::CHAR_CENTER }, // export only
132 : { XML_MIDDLE, VertOrientation::LINE_CENTER }, // export only
133 : { XML_BOTTOM, VertOrientation::BOTTOM },
134 : { XML_BOTTOM, VertOrientation::CHAR_BOTTOM }, // export only
135 : { XML_BOTTOM, VertOrientation::LINE_BOTTOM }, // export only
136 : { XML_BELOW, VertOrientation::CHAR_BOTTOM }, // import only
137 : { XML_TOKEN_INVALID, 0 }
138 : };
139 :
140 : SvXMLEnumMapEntry const pXML_VertPosAtChar_Enum[] =
141 : {
142 : { XML_FROM_TOP, VertOrientation::NONE },
143 : { XML_TOP, VertOrientation::TOP },
144 : { XML_TOP, VertOrientation::CHAR_TOP }, // export only
145 : { XML_TOP, VertOrientation::LINE_TOP }, // export only
146 : { XML_MIDDLE, VertOrientation::CENTER },
147 : { XML_MIDDLE, VertOrientation::CHAR_CENTER }, // export only
148 : { XML_MIDDLE, VertOrientation::LINE_CENTER }, // export only
149 : { XML_BOTTOM, VertOrientation::BOTTOM },
150 : { XML_BELOW, VertOrientation::CHAR_BOTTOM }, // export only
151 : { XML_BOTTOM, VertOrientation::LINE_BOTTOM }, // export only
152 : { XML_TOKEN_INVALID, 0 }
153 : };
154 :
155 : SvXMLEnumMapEntry const pXML_VertRel_Enum[] =
156 : {
157 : { XML_PARAGRAPH, RelOrientation::FRAME },
158 : { XML_PARAGRAPH_CONTENT, RelOrientation::PRINT_AREA },
159 : { XML_CHAR, RelOrientation::CHAR },
160 : // DVO, OD 17.09.2003 #i18732# - allow vertical alignment at page
161 : { XML_PAGE, RelOrientation::PAGE_FRAME },
162 : { XML_PAGE_CONTENT, RelOrientation::PAGE_PRINT_AREA },
163 : { XML_FRAME, RelOrientation::FRAME }, // import only
164 : { XML_FRAME_CONTENT, RelOrientation::PRINT_AREA }, // import only
165 : // OD 13.11.2003 #i22341# - new vertical alignment at top of line
166 : { XML_LINE, RelOrientation::TEXT_LINE },
167 : { XML_TOKEN_INVALID, 0 }
168 : };
169 :
170 : SvXMLEnumMapEntry const pXML_VertRelPage_Enum[] =
171 : {
172 : { XML_PAGE, RelOrientation::FRAME },
173 : { XML_PAGE_CONTENT, RelOrientation::PRINT_AREA },
174 : { XML_PAGE, RelOrientation::PAGE_FRAME },
175 : { XML_PAGE_CONTENT, RelOrientation::PAGE_PRINT_AREA },
176 : { XML_TOKEN_INVALID, 0 }
177 : };
178 :
179 : SvXMLEnumMapEntry const pXML_VertRelFrame_Enum[] =
180 : {
181 : { XML_FRAME, RelOrientation::FRAME },
182 : { XML_FRAME_CONTENT, RelOrientation::PRINT_AREA },
183 : { XML_TOKEN_INVALID, 0 }
184 : };
185 :
186 : SvXMLEnumMapEntry const pXML_VertRelAsChar_Enum[] =
187 : {
188 : { XML_BASELINE, VertOrientation::TOP },
189 : { XML_BASELINE, VertOrientation::CENTER }, // export only
190 : { XML_BASELINE, VertOrientation::BOTTOM }, // export only
191 : { XML_TEXT, VertOrientation::CHAR_TOP },
192 : { XML_TEXT, VertOrientation::CHAR_CENTER }, // export only
193 : { XML_TEXT, VertOrientation::CHAR_BOTTOM }, // export only
194 : { XML_LINE, VertOrientation::LINE_TOP },
195 : { XML_LINE, VertOrientation::LINE_CENTER }, // export only
196 : { XML_LINE, VertOrientation::LINE_BOTTOM }, // export only
197 : { XML_TOKEN_INVALID, 0 }
198 : };
199 :
200 : SvXMLEnumMapEntry const pXML_RubyAdjust_Enum[] =
201 : {
202 : { XML_LEFT, RubyAdjust_LEFT },
203 : { XML_CENTER, RubyAdjust_CENTER },
204 : { XML_RIGHT, RubyAdjust_RIGHT },
205 : { XML_DISTRIBUTE_LETTER, RubyAdjust_BLOCK },
206 : { XML_DISTRIBUTE_SPACE, RubyAdjust_INDENT_BLOCK },
207 : { XML_TOKEN_INVALID, 0 }
208 : };
209 :
210 : SvXMLEnumMapEntry const pXML_FontRelief_Enum[] =
211 : {
212 : { XML_NONE, FontRelief::NONE },
213 : { XML_ENGRAVED, FontRelief::ENGRAVED },
214 : { XML_EMBOSSED, FontRelief::EMBOSSED },
215 : { XML_TOKEN_INVALID, 0 }
216 : };
217 :
218 : SvXMLEnumMapEntry const pXML_VerticalAlign_Enum[] =
219 : {
220 : { XML_TOP, ParagraphVertAlign::TOP },
221 : { XML_MIDDLE, ParagraphVertAlign::CENTER },
222 : { XML_BOTTOM, ParagraphVertAlign::BOTTOM },
223 : { XML_BASELINE, ParagraphVertAlign::BASELINE },
224 : { XML_AUTO, ParagraphVertAlign::AUTOMATIC },
225 : { XML_TOKEN_INVALID, 0 }
226 : };
227 :
228 : // OD 2004-05-05 #i28701#
229 : SvXMLEnumMapEntry const pXML_WrapInfluenceOnPosition_Enum[] =
230 : {
231 : // Tokens have been renamed and <XML_ITERATIVE> has been added (#i35017#)
232 : { XML_ONCE_SUCCESSIVE, WrapInfluenceOnPosition::ONCE_SUCCESSIVE },
233 : { XML_ONCE_CONCURRENT, WrapInfluenceOnPosition::ONCE_CONCURRENT },
234 : { XML_ITERATIVE, WrapInfluenceOnPosition::ITERATIVE },
235 : { XML_TOKEN_INVALID, 0 }
236 : };
237 :
238 : SvXMLEnumMapEntry const pXML_FillStyle_Enum[] =
239 : {
240 : { XML_NONE, drawing::FillStyle_NONE },
241 : { XML_SOLID, drawing::FillStyle_SOLID },
242 : { XML_BITMAP, drawing::FillStyle_BITMAP },
243 : { XML_GRADIENT, drawing::FillStyle_GRADIENT },
244 : { XML_HATCH, drawing::FillStyle_HATCH },
245 : { XML_TOKEN_INVALID, 0 }
246 : };
247 :
248 : // ---------------------------------------------------------------------------
249 :
250 1438 : class XMLDropCapPropHdl_Impl : public XMLPropertyHandler
251 : {
252 : public:
253 : virtual ~XMLDropCapPropHdl_Impl ();
254 :
255 : virtual bool equals(
256 : const ::com::sun::star::uno::Any& r1,
257 : const ::com::sun::star::uno::Any& r2 ) const;
258 :
259 : /// TabStops will be imported/exported as XML-Elements. So the Import/Export-work must be done at another place.
260 : virtual sal_Bool importXML(
261 : const OUString& rStrImpValue,
262 : ::com::sun::star::uno::Any& rValue,
263 : const SvXMLUnitConverter& ) const;
264 : virtual sal_Bool exportXML(
265 : OUString& rStrExpValue,
266 : const ::com::sun::star::uno::Any& rValue,
267 : const SvXMLUnitConverter& ) const;
268 : };
269 :
270 2866 : XMLDropCapPropHdl_Impl::~XMLDropCapPropHdl_Impl ()
271 : {
272 2866 : }
273 :
274 0 : bool XMLDropCapPropHdl_Impl::equals(
275 : const Any& r1,
276 : const Any& r2 ) const
277 : {
278 0 : DropCapFormat aFormat1, aFormat2;
279 0 : r1 >>= aFormat1;
280 0 : r2 >>= aFormat2;
281 :
282 0 : return (aFormat1.Lines <=1 && aFormat2.Lines <=1) ||
283 0 : (aFormat1.Lines == aFormat2.Lines &&
284 0 : aFormat1.Count == aFormat2.Count &&
285 0 : aFormat1.Distance == aFormat2.Distance);
286 : }
287 :
288 0 : sal_Bool XMLDropCapPropHdl_Impl::importXML(
289 : const OUString&,
290 : Any&,
291 : const SvXMLUnitConverter& ) const
292 : {
293 : DBG_ASSERT( !this, "drop caps are an element import property" );
294 0 : return sal_False;
295 : }
296 :
297 0 : sal_Bool XMLDropCapPropHdl_Impl::exportXML(
298 : OUString&,
299 : const Any&,
300 : const SvXMLUnitConverter& ) const
301 : {
302 : DBG_ASSERT( !this, "drop caps are an element export property" );
303 0 : return sal_False;
304 : }
305 :
306 : // ---------------------------------------------------------------------------
307 :
308 713 : class XMLOpaquePropHdl_Impl : public XMLPropertyHandler
309 : {
310 : public:
311 : virtual ~XMLOpaquePropHdl_Impl ();
312 :
313 : virtual sal_Bool importXML(
314 : const OUString& rStrImpValue,
315 : ::com::sun::star::uno::Any& rValue,
316 : const SvXMLUnitConverter& ) const;
317 : virtual sal_Bool exportXML(
318 : OUString& rStrExpValue,
319 : const ::com::sun::star::uno::Any& rValue,
320 : const SvXMLUnitConverter& ) const;
321 : };
322 :
323 6 : sal_Bool XMLOpaquePropHdl_Impl::importXML(
324 : const OUString& rStrImpValue,
325 : Any& rValue,
326 : const SvXMLUnitConverter& ) const
327 : {
328 6 : sal_Bool bRet = sal_True;
329 6 : sal_Bool bVal = sal_False;
330 6 : if( IsXMLToken( rStrImpValue, XML_FOREGROUND ) )
331 6 : bVal = sal_True;
332 0 : else if( !IsXMLToken( rStrImpValue, XML_BACKGROUND ) )
333 0 : bRet = sal_False;
334 :
335 6 : if( bRet )
336 6 : rValue.setValue( &bVal, ::getBooleanCppuType() );
337 :
338 6 : return bRet;
339 : }
340 :
341 2 : sal_Bool XMLOpaquePropHdl_Impl::exportXML(
342 : OUString& rStrExpValue,
343 : const Any& rValue,
344 : const SvXMLUnitConverter& ) const
345 : {
346 2 : if( *(sal_Bool *)rValue.getValue() )
347 2 : rStrExpValue = GetXMLToken( XML_FOREGROUND );
348 : else
349 0 : rStrExpValue = GetXMLToken( XML_BACKGROUND );
350 :
351 2 : return sal_True;
352 : }
353 :
354 1426 : XMLOpaquePropHdl_Impl::~XMLOpaquePropHdl_Impl ()
355 : {
356 1426 : }
357 :
358 : // ---------------------------------------------------------------------------
359 :
360 713 : class XMLContourModePropHdl_Impl : public XMLPropertyHandler
361 : {
362 : public:
363 : virtual ~XMLContourModePropHdl_Impl ();
364 :
365 : virtual sal_Bool importXML(
366 : const OUString& rStrImpValue,
367 : ::com::sun::star::uno::Any& rValue,
368 : const SvXMLUnitConverter& ) const;
369 : virtual sal_Bool exportXML(
370 : OUString& rStrExpValue,
371 : const ::com::sun::star::uno::Any& rValue,
372 : const SvXMLUnitConverter& ) const;
373 : };
374 :
375 0 : sal_Bool XMLContourModePropHdl_Impl::importXML(
376 : const OUString& rStrImpValue,
377 : Any& rValue,
378 : const SvXMLUnitConverter& ) const
379 : {
380 0 : sal_Bool bRet = sal_True;
381 0 : sal_Bool bVal = sal_False;
382 0 : if( IsXMLToken( rStrImpValue, XML_OUTSIDE ) )
383 0 : bVal = sal_True;
384 0 : else if( ! IsXMLToken( rStrImpValue, XML_FULL ) )
385 0 : bRet = sal_False;
386 :
387 0 : if( bRet )
388 0 : rValue.setValue( &bVal, ::getBooleanCppuType() );
389 :
390 0 : return bRet;
391 : }
392 :
393 0 : sal_Bool XMLContourModePropHdl_Impl::exportXML(
394 : OUString& rStrExpValue,
395 : const Any& rValue,
396 : const SvXMLUnitConverter& ) const
397 : {
398 0 : if( *(sal_Bool *)rValue.getValue() )
399 0 : rStrExpValue = GetXMLToken( XML_OUTSIDE );
400 : else
401 0 : rStrExpValue = GetXMLToken( XML_FULL );
402 :
403 0 : return sal_True;
404 : }
405 :
406 1426 : XMLContourModePropHdl_Impl::~XMLContourModePropHdl_Impl()
407 : {
408 1426 : }
409 :
410 : // ---------------------------------------------------------------------------
411 :
412 713 : class XMLParagraphOnlyPropHdl_Impl : public XMLPropertyHandler
413 : {
414 : public:
415 : virtual ~XMLParagraphOnlyPropHdl_Impl ();
416 :
417 : virtual sal_Bool importXML(
418 : const OUString& rStrImpValue,
419 : ::com::sun::star::uno::Any& rValue,
420 : const SvXMLUnitConverter& ) const;
421 : virtual sal_Bool exportXML(
422 : OUString& rStrExpValue,
423 : const ::com::sun::star::uno::Any& rValue,
424 : const SvXMLUnitConverter& ) const;
425 : };
426 :
427 23 : sal_Bool XMLParagraphOnlyPropHdl_Impl::importXML(
428 : const OUString& rStrImpValue,
429 : Any& rValue,
430 : const SvXMLUnitConverter& ) const
431 : {
432 23 : sal_Bool bRet = sal_True;
433 23 : sal_Bool bVal = sal_False;
434 :
435 23 : if( ! IsXMLToken( rStrImpValue, XML_NO_LIMIT ) )
436 : {
437 0 : sal_Int32 nValue = 0;
438 0 : bRet = ::sax::Converter::convertNumber( nValue, rStrImpValue );
439 0 : bVal = 1 == nValue;
440 : }
441 :
442 23 : if( bRet )
443 23 : rValue.setValue( &bVal, ::getBooleanCppuType() );
444 :
445 23 : return bRet;
446 : }
447 :
448 7 : sal_Bool XMLParagraphOnlyPropHdl_Impl::exportXML(
449 : OUString& rStrExpValue,
450 : const Any& rValue,
451 : const SvXMLUnitConverter& ) const
452 : {
453 7 : if( *(sal_Bool *)rValue.getValue() )
454 0 : rStrExpValue = GetXMLToken( XML_1 );
455 : else
456 7 : rStrExpValue = GetXMLToken( XML_NO_LIMIT );
457 :
458 7 : return sal_True;
459 : }
460 :
461 1426 : XMLParagraphOnlyPropHdl_Impl::~XMLParagraphOnlyPropHdl_Impl()
462 : {
463 1426 : }
464 :
465 : // ---------------------------------------------------------------------------
466 :
467 : SvXMLEnumMapEntry const pXML_Wrap_Enum[] =
468 : {
469 : { XML_NONE, WrapTextMode_NONE },
470 : { XML_RUN_THROUGH, WrapTextMode_THROUGHT },
471 : { XML_PARALLEL, WrapTextMode_PARALLEL },
472 : { XML_DYNAMIC, WrapTextMode_DYNAMIC },
473 : { XML_LEFT, WrapTextMode_LEFT },
474 : { XML_RIGHT, WrapTextMode_RIGHT },
475 : { XML_TOKEN_INVALID, 0 }
476 : };
477 :
478 713 : class XMLWrapPropHdl_Impl : public XMLPropertyHandler
479 : {
480 : public:
481 : virtual ~XMLWrapPropHdl_Impl ();
482 :
483 : virtual sal_Bool importXML(
484 : const OUString& rStrImpValue,
485 : ::com::sun::star::uno::Any& rValue,
486 : const SvXMLUnitConverter& ) const;
487 : virtual sal_Bool exportXML(
488 : OUString& rStrExpValue,
489 : const ::com::sun::star::uno::Any& rValue,
490 : const SvXMLUnitConverter& ) const;
491 : };
492 :
493 28 : sal_Bool XMLWrapPropHdl_Impl::importXML(
494 : const OUString& rStrImpValue,
495 : Any& rValue,
496 : const SvXMLUnitConverter& ) const
497 : {
498 : sal_uInt16 nWrap;
499 : sal_Bool bRet = SvXMLUnitConverter::convertEnum( nWrap, rStrImpValue,
500 28 : pXML_Wrap_Enum );
501 :
502 28 : if( bRet )
503 28 : rValue <<= (WrapTextMode)nWrap;
504 :
505 28 : return bRet;
506 : }
507 :
508 7 : sal_Bool XMLWrapPropHdl_Impl::exportXML(
509 : OUString& rStrExpValue,
510 : const Any& rValue,
511 : const SvXMLUnitConverter& ) const
512 : {
513 7 : OUStringBuffer aOut;
514 : WrapTextMode eVal;
515 :
516 7 : rValue >>= eVal;
517 :
518 7 : sal_Bool bRet = SvXMLUnitConverter::convertEnum( aOut, eVal, pXML_Wrap_Enum, XML_NONE );
519 :
520 7 : rStrExpValue = aOut.makeStringAndClear();
521 :
522 7 : return bRet;
523 : }
524 :
525 1426 : XMLWrapPropHdl_Impl::~XMLWrapPropHdl_Impl ()
526 : {
527 1426 : }
528 :
529 : // ---------------------------------------------------------------------------
530 :
531 : class XMLFrameProtectPropHdl_Impl : public XMLPropertyHandler
532 : {
533 : const OUString sVal;
534 : public:
535 2043 : XMLFrameProtectPropHdl_Impl( enum XMLTokenEnum eVal ) :
536 2043 : sVal( GetXMLToken(eVal) ) {}
537 : virtual ~XMLFrameProtectPropHdl_Impl ();
538 :
539 : virtual sal_Bool importXML(
540 : const OUString& rStrImpValue,
541 : ::com::sun::star::uno::Any& rValue,
542 : const SvXMLUnitConverter& ) const;
543 : virtual sal_Bool exportXML(
544 : OUString& rStrExpValue,
545 : const ::com::sun::star::uno::Any& rValue,
546 : const SvXMLUnitConverter& ) const;
547 : };
548 :
549 0 : sal_Bool XMLFrameProtectPropHdl_Impl::importXML(
550 : const OUString& rStrImpValue,
551 : Any& rValue,
552 : const SvXMLUnitConverter& ) const
553 : {
554 0 : sal_Bool bRet = sal_True;
555 0 : sal_Bool bVal = sal_False;
556 0 : if( ! IsXMLToken( rStrImpValue, XML_NONE ) )
557 : {
558 0 : bRet = sal_False;
559 0 : SvXMLTokenEnumerator aTokenEnum( rStrImpValue );
560 0 : OUString aToken;
561 0 : while( aTokenEnum.getNextToken( aToken ) )
562 : {
563 0 : bRet = sal_True;
564 0 : if( aToken == sVal )
565 : {
566 0 : bVal = sal_True;
567 0 : break;
568 : }
569 0 : }
570 : }
571 :
572 0 : if( bRet )
573 0 : rValue.setValue( &bVal, ::getBooleanCppuType() );
574 :
575 0 : return bRet;
576 : }
577 :
578 0 : sal_Bool XMLFrameProtectPropHdl_Impl::exportXML(
579 : OUString& rStrExpValue,
580 : const Any& rValue,
581 : const SvXMLUnitConverter& ) const
582 : {
583 0 : if( *(sal_Bool *)rValue.getValue() )
584 : {
585 0 : if( rStrExpValue.isEmpty() ||
586 0 : IsXMLToken( rStrExpValue, XML_NONE ) )
587 : {
588 0 : rStrExpValue = sVal;
589 : }
590 : else
591 : {
592 0 : OUStringBuffer aOut( rStrExpValue.getLength() + 1 +
593 0 : sVal.getLength() );
594 0 : aOut.append( rStrExpValue );
595 0 : aOut.append( (sal_Unicode)' ' );
596 0 : aOut.append( sVal );
597 0 : rStrExpValue = aOut.makeStringAndClear();
598 : }
599 : }
600 0 : else if( rStrExpValue.isEmpty() )
601 : {
602 0 : rStrExpValue = GetXMLToken( XML_NONE );
603 : }
604 :
605 0 : return sal_True;
606 : }
607 :
608 4086 : XMLFrameProtectPropHdl_Impl::~XMLFrameProtectPropHdl_Impl()
609 : {
610 4086 : }
611 :
612 : // ---------------------------------------------------------------------------
613 :
614 : SvXMLEnumMapEntry const pXML_Anchor_Enum[] =
615 : {
616 : { XML_CHAR, TextContentAnchorType_AT_CHARACTER },
617 : { XML_PAGE, TextContentAnchorType_AT_PAGE },
618 : { XML_FRAME, TextContentAnchorType_AT_FRAME },
619 : { XML_PARAGRAPH, TextContentAnchorType_AT_PARAGRAPH },
620 : { XML_AS_CHAR, TextContentAnchorType_AS_CHARACTER },
621 : { XML_TOKEN_INVALID, 0 }
622 : };
623 :
624 :
625 20 : sal_Bool XMLAnchorTypePropHdl::importXML(
626 : const OUString& rStrImpValue,
627 : Any& rValue,
628 : const SvXMLUnitConverter& ) const
629 : {
630 : sal_uInt16 nAnchor;
631 : sal_Bool bRet = SvXMLUnitConverter::convertEnum( nAnchor, rStrImpValue,
632 20 : pXML_Anchor_Enum );
633 :
634 20 : if( bRet )
635 20 : rValue <<= (TextContentAnchorType)nAnchor;
636 :
637 20 : return bRet;
638 : }
639 :
640 17 : sal_Bool XMLAnchorTypePropHdl::exportXML(
641 : OUString& rStrExpValue,
642 : const Any& rValue,
643 : const SvXMLUnitConverter& ) const
644 : {
645 17 : OUStringBuffer aOut;
646 : TextContentAnchorType eVal;
647 :
648 17 : rValue >>= eVal;
649 :
650 17 : sal_Bool bRet = SvXMLUnitConverter::convertEnum( aOut, eVal, pXML_Anchor_Enum, XML_PARAGRAPH );
651 :
652 17 : rStrExpValue = aOut.makeStringAndClear();
653 :
654 17 : return bRet;
655 : }
656 :
657 1196 : XMLAnchorTypePropHdl::~XMLAnchorTypePropHdl()
658 : {
659 1196 : }
660 :
661 51 : sal_Bool XMLAnchorTypePropHdl::convert( const OUString& rStrImpValue,
662 : TextContentAnchorType& rType )
663 : {
664 : sal_uInt16 nAnchor;
665 : sal_Bool bRet = SvXMLUnitConverter::convertEnum( nAnchor, rStrImpValue,
666 51 : pXML_Anchor_Enum );
667 51 : if( bRet )
668 51 : rType = (TextContentAnchorType)nAnchor;
669 51 : return bRet;
670 : }
671 :
672 : // ---------------------------------------------------------------------------
673 :
674 :
675 2650 : XMLTextColumnsPropertyHandler::~XMLTextColumnsPropertyHandler ()
676 : {
677 2650 : }
678 :
679 76 : bool XMLTextColumnsPropertyHandler::equals(
680 : const Any& r1,
681 : const Any& r2 ) const
682 : {
683 76 : Reference < XTextColumns > xColumns1;
684 76 : r1 >>= xColumns1;
685 :
686 152 : Reference < XTextColumns > xColumns2;
687 76 : r2 >>= xColumns2;
688 :
689 106 : if( xColumns1->getColumnCount() != xColumns2->getColumnCount() ||
690 30 : xColumns1->getReferenceValue() != xColumns2->getReferenceValue() )
691 46 : return sal_False;
692 :
693 60 : Sequence < TextColumn > aColumns1 = xColumns1->getColumns();
694 60 : Sequence < TextColumn > aColumns2 = xColumns2->getColumns();
695 30 : sal_Int32 nCount = aColumns1.getLength();
696 30 : if( aColumns2.getLength() != nCount )
697 0 : return sal_False;
698 :
699 30 : const TextColumn *pColumns1 = aColumns1.getArray();
700 30 : const TextColumn *pColumns2 = aColumns2.getArray();
701 :
702 66 : while( nCount-- )
703 : {
704 12 : if( pColumns1->Width != pColumns2->Width ||
705 12 : pColumns1->LeftMargin != pColumns2->LeftMargin ||
706 6 : pColumns1->RightMargin != pColumns2->RightMargin )
707 0 : return sal_False;
708 :
709 6 : pColumns1++;
710 6 : pColumns2++;
711 : }
712 :
713 106 : return sal_True;
714 : }
715 :
716 0 : sal_Bool XMLTextColumnsPropertyHandler::importXML(
717 : const OUString&,
718 : Any&,
719 : const SvXMLUnitConverter& ) const
720 : {
721 : DBG_ASSERT( !this, "columns are an element import property" );
722 0 : return sal_False;
723 : }
724 :
725 0 : sal_Bool XMLTextColumnsPropertyHandler::exportXML(
726 : OUString&,
727 : const Any&,
728 : const SvXMLUnitConverter& ) const
729 : {
730 : DBG_ASSERT( !this, "columns are an element export property" );
731 0 : return sal_False;
732 : }
733 :
734 : // ---------------------------------------------------------------------------
735 :
736 713 : class XMLHoriMirrorPropHdl_Impl : public XMLPropertyHandler
737 : {
738 : public:
739 : virtual ~XMLHoriMirrorPropHdl_Impl ();
740 :
741 : virtual sal_Bool importXML(
742 : const OUString& rStrImpValue,
743 : ::com::sun::star::uno::Any& rValue,
744 : const SvXMLUnitConverter& ) const;
745 : virtual sal_Bool exportXML(
746 : OUString& rStrExpValue,
747 : const ::com::sun::star::uno::Any& rValue,
748 : const SvXMLUnitConverter& ) const;
749 : };
750 :
751 41 : sal_Bool XMLHoriMirrorPropHdl_Impl::importXML(
752 : const OUString& rStrImpValue,
753 : Any& rValue,
754 : const SvXMLUnitConverter& ) const
755 : {
756 : sal_uInt16 nHoriMirror;
757 : sal_Bool bRet = SvXMLUnitConverter::convertEnum( nHoriMirror, rStrImpValue,
758 41 : pXML_HoriMirror_Enum );
759 :
760 41 : if( bRet )
761 : {
762 41 : sal_Bool bTmp = nHoriMirror != 0;
763 41 : rValue.setValue( &bTmp, ::getBooleanCppuType() );
764 : }
765 :
766 41 : return bRet;
767 : }
768 :
769 0 : sal_Bool XMLHoriMirrorPropHdl_Impl::exportXML(
770 : OUString&,
771 : const Any&,
772 : const SvXMLUnitConverter& ) const
773 : {
774 : DBG_ASSERT( !this, "HorMirror properyt shouldn't be exported" );
775 :
776 0 : return sal_False;
777 : }
778 :
779 1426 : XMLHoriMirrorPropHdl_Impl::~XMLHoriMirrorPropHdl_Impl ()
780 : {
781 1426 : }
782 :
783 : // ---------------------------------------------------------------------------
784 :
785 : class XMLGrfMirrorPropHdl_Impl : public XMLPropertyHandler
786 : {
787 : const OUString sVal;
788 : sal_Bool bHori;
789 :
790 : public:
791 2043 : XMLGrfMirrorPropHdl_Impl( enum XMLTokenEnum eVal, sal_Bool bH ) :
792 2043 : sVal( GetXMLToken( eVal ) ),
793 4086 : bHori( bH ) {}
794 : virtual ~XMLGrfMirrorPropHdl_Impl ();
795 :
796 : virtual sal_Bool importXML(
797 : const OUString& rStrImpValue,
798 : ::com::sun::star::uno::Any& rValue,
799 : const SvXMLUnitConverter& ) const;
800 : virtual sal_Bool exportXML(
801 : OUString& rStrExpValue,
802 : const ::com::sun::star::uno::Any& rValue,
803 : const SvXMLUnitConverter& ) const;
804 : };
805 :
806 9 : sal_Bool XMLGrfMirrorPropHdl_Impl::importXML(
807 : const OUString& rStrImpValue,
808 : Any& rValue,
809 : const SvXMLUnitConverter& ) const
810 : {
811 9 : sal_Bool bRet = sal_True;
812 9 : sal_Bool bVal = sal_False;
813 9 : if( ! IsXMLToken( rStrImpValue, XML_NONE ) )
814 : {
815 0 : bRet = sal_False;
816 0 : SvXMLTokenEnumerator aTokenEnum( rStrImpValue );
817 0 : OUString aToken;
818 0 : while( aTokenEnum.getNextToken( aToken ) )
819 : {
820 0 : bRet = sal_True;
821 0 : if( aToken == sVal ||
822 0 : (bHori && IsXMLToken( aToken, XML_HORIZONTAL ) ) )
823 : {
824 0 : bVal = sal_True;
825 0 : break;
826 : }
827 0 : }
828 : }
829 :
830 9 : if( bRet )
831 9 : rValue.setValue( &bVal, ::getBooleanCppuType() );
832 :
833 9 : return bRet;
834 : }
835 :
836 0 : sal_Bool XMLGrfMirrorPropHdl_Impl::exportXML(
837 : OUString& rStrExpValue,
838 : const Any& rValue,
839 : const SvXMLUnitConverter& ) const
840 : {
841 0 : if( *(sal_Bool *)rValue.getValue() )
842 : {
843 0 : if( rStrExpValue.isEmpty() ||
844 0 : IsXMLToken( rStrExpValue, XML_NONE ) )
845 : {
846 0 : rStrExpValue = sVal;
847 : }
848 0 : else if( bHori &&
849 : /* XML_HORIZONTAL_ON_LEFT_PAGES and XML_HORIZONTAL_ON_RIGHT_PAGES
850 : are replaced by XML_HORIZONTAL_ON_EVEN and XML_HORIZONTAL_ON_ODD.
851 : (#i49139#)
852 : */
853 0 : ( IsXMLToken( rStrExpValue, XML_HORIZONTAL_ON_EVEN ) ||
854 0 : IsXMLToken( rStrExpValue, XML_HORIZONTAL_ON_ODD ) ))
855 : {
856 0 : rStrExpValue = GetXMLToken( XML_HORIZONTAL );
857 : }
858 : else
859 : {
860 0 : OUStringBuffer aOut( rStrExpValue.getLength() + 1 +
861 0 : sVal.getLength() );
862 0 : aOut.append( rStrExpValue );
863 0 : aOut.append( (sal_Unicode)' ' );
864 0 : aOut.append( sVal );
865 0 : rStrExpValue = aOut.makeStringAndClear();
866 : }
867 : }
868 0 : else if( rStrExpValue.isEmpty() )
869 : {
870 0 : rStrExpValue = GetXMLToken( XML_NONE );
871 : }
872 :
873 0 : return sal_True;
874 : }
875 :
876 4086 : XMLGrfMirrorPropHdl_Impl::~XMLGrfMirrorPropHdl_Impl()
877 : {
878 4086 : }
879 :
880 : // ---------------------------------------------------------------------------
881 :
882 : SvXMLEnumMapEntry const pXML_Emphasize_Enum[] =
883 : {
884 : { XML_NONE, FontEmphasis::NONE },
885 : { XML_DOT, FontEmphasis::DOT_ABOVE },
886 : { XML_CIRCLE, FontEmphasis::CIRCLE_ABOVE },
887 : { XML_DISC, FontEmphasis::DISK_ABOVE },
888 : { XML_ACCENT, FontEmphasis::ACCENT_ABOVE },
889 : { XML_TOKEN_INVALID, 0 }
890 : };
891 : class XMLTextEmphasizePropHdl_Impl : public XMLPropertyHandler
892 : {
893 : public:
894 1936 : XMLTextEmphasizePropHdl_Impl() {}
895 : virtual ~XMLTextEmphasizePropHdl_Impl();
896 :
897 : virtual sal_Bool importXML(
898 : const OUString& rStrImpValue,
899 : ::com::sun::star::uno::Any& rValue,
900 : const SvXMLUnitConverter& ) const;
901 : virtual sal_Bool exportXML(
902 : OUString& rStrExpValue,
903 : const ::com::sun::star::uno::Any& rValue,
904 : const SvXMLUnitConverter& ) const;
905 : };
906 :
907 40 : sal_Bool XMLTextEmphasizePropHdl_Impl::importXML(
908 : const OUString& rStrImpValue,
909 : Any& rValue,
910 : const SvXMLUnitConverter& ) const
911 : {
912 40 : sal_Bool bRet = sal_True;
913 40 : sal_uInt16 nVal = FontEmphasis::NONE;
914 40 : sal_Bool bBelow = sal_False;
915 40 : sal_Bool bHasPos = sal_False, bHasType = sal_False;
916 40 : OUString aToken;
917 :
918 40 : SvXMLTokenEnumerator aTokenEnum( rStrImpValue );
919 120 : while( aTokenEnum.getNextToken( aToken ) )
920 : {
921 40 : if( !bHasPos && IsXMLToken( aToken, XML_ABOVE ) )
922 : {
923 0 : bBelow = sal_False;
924 0 : bHasPos = sal_True;
925 : }
926 40 : else if( !bHasPos && IsXMLToken( aToken, XML_BELOW ) )
927 : {
928 0 : bBelow = sal_True;
929 0 : bHasPos = sal_True;
930 : }
931 80 : else if( !bHasType &&
932 : SvXMLUnitConverter::convertEnum( nVal, aToken,
933 40 : pXML_Emphasize_Enum ))
934 : {
935 40 : bHasType = sal_True;
936 : }
937 : else
938 : {
939 0 : bRet = sal_False;
940 0 : break;
941 : }
942 : }
943 :
944 40 : if( bRet )
945 : {
946 40 : if( FontEmphasis::NONE != nVal && bBelow )
947 0 : nVal += 10;
948 40 : rValue <<= (sal_Int16)nVal;
949 : }
950 :
951 40 : return bRet;
952 : }
953 :
954 15 : sal_Bool XMLTextEmphasizePropHdl_Impl::exportXML(
955 : OUString& rStrExpValue,
956 : const Any& rValue,
957 : const SvXMLUnitConverter& ) const
958 : {
959 15 : OUStringBuffer aOut( 15 );
960 15 : sal_Bool bRet = sal_True;
961 15 : sal_Int16 nType = sal_Int16();
962 15 : if( rValue >>= nType )
963 : {
964 15 : sal_Bool bBelow = sal_False;
965 15 : if( nType > 10 )
966 : {
967 0 : bBelow = sal_True;
968 0 : nType -= 10;
969 : }
970 : bRet = SvXMLUnitConverter::convertEnum( aOut, nType,
971 : pXML_Emphasize_Enum,
972 15 : XML_DOT );
973 15 : if( bRet )
974 : {
975 15 : if( nType != 0 )
976 : {
977 0 : enum XMLTokenEnum ePos = bBelow ? XML_BELOW : XML_ABOVE;
978 0 : aOut.append( (sal_Unicode)' ' );
979 0 : aOut.append( GetXMLToken(ePos) );
980 : }
981 15 : rStrExpValue = aOut.makeStringAndClear();
982 : }
983 : }
984 :
985 15 : return bRet;
986 : }
987 :
988 3862 : XMLTextEmphasizePropHdl_Impl::~XMLTextEmphasizePropHdl_Impl()
989 : {
990 3862 : }
991 :
992 :
993 : // ---------------------------------------------------------------------------
994 :
995 : class XMLTextCombineCharPropHdl_Impl : public XMLPropertyHandler
996 : {
997 : public:
998 1936 : XMLTextCombineCharPropHdl_Impl() {}
999 : virtual ~XMLTextCombineCharPropHdl_Impl();
1000 :
1001 : virtual sal_Bool importXML(
1002 : const OUString& rStrImpValue,
1003 : ::com::sun::star::uno::Any& rValue,
1004 : const SvXMLUnitConverter& ) const;
1005 : virtual sal_Bool exportXML(
1006 : OUString& rStrExpValue,
1007 : const ::com::sun::star::uno::Any& rValue,
1008 : const SvXMLUnitConverter& ) const;
1009 : };
1010 :
1011 0 : sal_Bool XMLTextCombineCharPropHdl_Impl::importXML(
1012 : const OUString& rStrImpValue,
1013 : Any& rValue,
1014 : const SvXMLUnitConverter& ) const
1015 : {
1016 0 : if( !rStrImpValue.isEmpty() )
1017 0 : rValue <<= rStrImpValue.copy( 0, 1 );
1018 : else
1019 0 : rValue <<= rStrImpValue;
1020 :
1021 0 : return sal_True;
1022 : }
1023 :
1024 0 : sal_Bool XMLTextCombineCharPropHdl_Impl::exportXML(
1025 : OUString& rStrExpValue,
1026 : const Any& rValue,
1027 : const SvXMLUnitConverter& ) const
1028 : {
1029 0 : rValue >>= rStrExpValue;
1030 :
1031 : // #i114107# attribute of type "character": export only if length is 1
1032 0 : return (1 == rStrExpValue.getLength()) ? sal_True : sal_False;
1033 : }
1034 :
1035 3862 : XMLTextCombineCharPropHdl_Impl::~XMLTextCombineCharPropHdl_Impl()
1036 : {
1037 3862 : }
1038 :
1039 : // ---------------------------------------------------------------------------
1040 :
1041 : class XMLTextRelWidthHeightPropHdl_Impl : public XMLPropertyHandler
1042 : {
1043 : public:
1044 593 : XMLTextRelWidthHeightPropHdl_Impl() {}
1045 : virtual ~XMLTextRelWidthHeightPropHdl_Impl();
1046 :
1047 : virtual sal_Bool importXML(
1048 : const OUString& rStrImpValue,
1049 : ::com::sun::star::uno::Any& rValue,
1050 : const SvXMLUnitConverter& ) const;
1051 : virtual sal_Bool exportXML(
1052 : OUString& rStrExpValue,
1053 : const ::com::sun::star::uno::Any& rValue,
1054 : const SvXMLUnitConverter& ) const;
1055 : };
1056 :
1057 2 : sal_Bool XMLTextRelWidthHeightPropHdl_Impl::importXML(
1058 : const OUString& rStrImpValue,
1059 : Any& rValue,
1060 : const SvXMLUnitConverter& ) const
1061 : {
1062 : sal_Int32 nValue;
1063 2 : bool const bRet = ::sax::Converter::convertPercent( nValue, rStrImpValue );
1064 2 : if( bRet )
1065 0 : rValue <<= (sal_Int16)nValue;
1066 :
1067 2 : return bRet;
1068 : }
1069 :
1070 0 : sal_Bool XMLTextRelWidthHeightPropHdl_Impl::exportXML(
1071 : OUString& rStrExpValue,
1072 : const Any& rValue,
1073 : const SvXMLUnitConverter& ) const
1074 : {
1075 0 : sal_Bool bRet = sal_False;
1076 0 : sal_Int16 nValue = sal_Int16();
1077 0 : if( (rValue >>= nValue) && nValue > 0 )
1078 : {
1079 0 : OUStringBuffer aOut;
1080 0 : ::sax::Converter::convertPercent( aOut, nValue );
1081 0 : rStrExpValue = aOut.makeStringAndClear();
1082 :
1083 0 : bRet = sal_True;
1084 : }
1085 :
1086 0 : return bRet;
1087 : }
1088 :
1089 1186 : XMLTextRelWidthHeightPropHdl_Impl::~XMLTextRelWidthHeightPropHdl_Impl()
1090 : {
1091 1186 : }
1092 :
1093 : // ---------------------------------------------------------------------------
1094 :
1095 : class XMLTextSyncWidthHeightPropHdl_Impl : public XMLPropertyHandler
1096 : {
1097 : const OUString sValue;
1098 :
1099 : public:
1100 0 : XMLTextSyncWidthHeightPropHdl_Impl( enum XMLTokenEnum eValue ) :
1101 0 : sValue( GetXMLToken(eValue) ) {}
1102 : virtual ~XMLTextSyncWidthHeightPropHdl_Impl();
1103 :
1104 : virtual sal_Bool importXML(
1105 : const OUString& rStrImpValue,
1106 : ::com::sun::star::uno::Any& rValue,
1107 : const SvXMLUnitConverter& ) const;
1108 : virtual sal_Bool exportXML(
1109 : OUString& rStrExpValue,
1110 : const ::com::sun::star::uno::Any& rValue,
1111 : const SvXMLUnitConverter& ) const;
1112 : };
1113 :
1114 0 : sal_Bool XMLTextSyncWidthHeightPropHdl_Impl::importXML(
1115 : const OUString& rStrImpValue,
1116 : Any& rValue,
1117 : const SvXMLUnitConverter& ) const
1118 : {
1119 0 : sal_Bool bValue = (rStrImpValue == sValue );
1120 0 : rValue.setValue( &bValue, ::getBooleanCppuType() );
1121 :
1122 0 : return sal_True;
1123 : }
1124 :
1125 0 : sal_Bool XMLTextSyncWidthHeightPropHdl_Impl::exportXML(
1126 : OUString& rStrExpValue,
1127 : const Any& rValue,
1128 : const SvXMLUnitConverter& ) const
1129 : {
1130 0 : sal_Bool bRet = sal_False;
1131 0 : if( *(sal_Bool *)rValue.getValue() )
1132 : {
1133 0 : rStrExpValue = sValue;
1134 0 : bRet = sal_True;
1135 : }
1136 :
1137 0 : return bRet;
1138 : }
1139 :
1140 0 : XMLTextSyncWidthHeightPropHdl_Impl::~XMLTextSyncWidthHeightPropHdl_Impl()
1141 : {
1142 0 : }
1143 :
1144 : // ---------------------------------------------------------------------------
1145 :
1146 : class XMLTextRotationAnglePropHdl_Impl : public XMLPropertyHandler
1147 : {
1148 :
1149 : public:
1150 1936 : XMLTextRotationAnglePropHdl_Impl() {}
1151 : virtual ~XMLTextRotationAnglePropHdl_Impl();
1152 :
1153 : virtual sal_Bool importXML(
1154 : const OUString& rStrImpValue,
1155 : ::com::sun::star::uno::Any& rValue,
1156 : const SvXMLUnitConverter& ) const;
1157 : virtual sal_Bool exportXML(
1158 : OUString& rStrExpValue,
1159 : const ::com::sun::star::uno::Any& rValue,
1160 : const SvXMLUnitConverter& ) const;
1161 : };
1162 :
1163 8 : sal_Bool XMLTextRotationAnglePropHdl_Impl::importXML(
1164 : const OUString& rStrImpValue,
1165 : Any& rValue,
1166 : const SvXMLUnitConverter& ) const
1167 : {
1168 : sal_Int32 nValue;
1169 8 : bool const bRet = ::sax::Converter::convertNumber( nValue, rStrImpValue );
1170 8 : if( bRet )
1171 : {
1172 8 : nValue = (nValue % 360 );
1173 8 : if( nValue < 0 )
1174 0 : nValue = 360 + nValue;
1175 : sal_Int16 nAngle;
1176 8 : if( nValue < 45 || nValue > 315 )
1177 8 : nAngle = 0;
1178 0 : else if( nValue < 180 )
1179 0 : nAngle = 900;
1180 : else /* if nValalue <= 315 ) */
1181 0 : nAngle = 2700;
1182 8 : rValue <<= nAngle;
1183 : }
1184 :
1185 8 : return bRet;
1186 : }
1187 :
1188 0 : sal_Bool XMLTextRotationAnglePropHdl_Impl::exportXML(
1189 : OUString& rStrExpValue,
1190 : const Any& rValue,
1191 : const SvXMLUnitConverter& ) const
1192 : {
1193 0 : sal_Int16 nAngle = sal_Int16();
1194 0 : sal_Bool bRet = ( rValue >>= nAngle );
1195 0 : if( bRet )
1196 : {
1197 0 : OUStringBuffer aOut;
1198 0 : ::sax::Converter::convertNumber( aOut, nAngle / 10 );
1199 0 : rStrExpValue = aOut.makeStringAndClear();
1200 : }
1201 : OSL_ENSURE( bRet, "illegal rotation angle" );
1202 :
1203 0 : return bRet;
1204 : }
1205 :
1206 3862 : XMLTextRotationAnglePropHdl_Impl::~XMLTextRotationAnglePropHdl_Impl()
1207 : {
1208 3862 : }
1209 : // ---------------------------------------------------------------------------
1210 : class XMLNumber8OneBasedHdl : public XMLPropertyHandler
1211 : {
1212 :
1213 : public:
1214 1438 : XMLNumber8OneBasedHdl() {}
1215 2866 : virtual ~XMLNumber8OneBasedHdl() {};
1216 :
1217 : virtual sal_Bool importXML(
1218 : const OUString& rStrImpValue,
1219 : ::com::sun::star::uno::Any& rValue,
1220 : const SvXMLUnitConverter& ) const;
1221 : virtual sal_Bool exportXML(
1222 : OUString& rStrExpValue,
1223 : const ::com::sun::star::uno::Any& rValue,
1224 : const SvXMLUnitConverter& ) const;
1225 : };
1226 :
1227 0 : sal_Bool XMLNumber8OneBasedHdl::importXML(
1228 : const OUString& rStrImpValue,
1229 : Any& rValue,
1230 : const SvXMLUnitConverter& ) const
1231 : {
1232 0 : sal_Int32 nValue = 0;
1233 0 : bool const bRet = ::sax::Converter::convertNumber(nValue, rStrImpValue);
1234 0 : if( bRet )
1235 0 : rValue <<= static_cast<sal_Int8>( nValue - 1 );
1236 0 : return bRet;
1237 : }
1238 :
1239 0 : sal_Bool XMLNumber8OneBasedHdl::exportXML(
1240 : OUString& rStrExpValue,
1241 : const Any& rValue,
1242 : const SvXMLUnitConverter& ) const
1243 : {
1244 0 : sal_Int8 nValue = sal_Int8();
1245 0 : sal_Bool bRet = ( rValue >>= nValue );
1246 0 : if( bRet )
1247 : {
1248 0 : OUStringBuffer aOut;
1249 0 : ::sax::Converter::convertNumber( aOut, nValue + 1 );
1250 0 : rStrExpValue = aOut.makeStringAndClear();
1251 : }
1252 0 : return bRet;
1253 : }
1254 : // ---------------------------------------------------------------------------
1255 : class XMLTextPropertyHandlerFactory_Impl
1256 : {
1257 : public:
1258 : const XMLPropertyHandler *GetPropertyHandler( sal_Int32 nType ) const;
1259 :
1260 : XMLTextPropertyHandlerFactory_Impl();
1261 : ~XMLTextPropertyHandlerFactory_Impl();
1262 : };
1263 :
1264 47058 : const XMLPropertyHandler *XMLTextPropertyHandlerFactory_Impl::GetPropertyHandler
1265 : ( sal_Int32 nType ) const
1266 : {
1267 47058 : const XMLPropertyHandler* pHdl = 0;
1268 47058 : switch( nType )
1269 : {
1270 : case XML_TYPE_TEXT_DROPCAP:
1271 1438 : pHdl = new XMLDropCapPropHdl_Impl;
1272 1438 : break;
1273 : case XML_TYPE_TEXT_WRAP:
1274 713 : pHdl = new XMLWrapPropHdl_Impl;
1275 713 : break;
1276 : case XML_TYPE_TEXT_PARAGRAPH_ONLY:
1277 713 : pHdl = new XMLParagraphOnlyPropHdl_Impl;
1278 713 : break;
1279 : case XML_TYPE_TEXT_WRAP_OUTSIDE:
1280 713 : pHdl = new XMLContourModePropHdl_Impl;
1281 713 : break;
1282 : case XML_TYPE_TEXT_OPAQUE:
1283 713 : pHdl = new XMLOpaquePropHdl_Impl;
1284 713 : break;
1285 : case XML_TYPE_TEXT_PROTECT_CONTENT:
1286 681 : pHdl = new XMLFrameProtectPropHdl_Impl( XML_CONTENT );
1287 681 : break;
1288 : case XML_TYPE_TEXT_PROTECT_SIZE:
1289 681 : pHdl = new XMLFrameProtectPropHdl_Impl( XML_SIZE );
1290 681 : break;
1291 : case XML_TYPE_TEXT_PROTECT_POSITION:
1292 681 : pHdl = new XMLFrameProtectPropHdl_Impl( XML_POSITION );
1293 681 : break;
1294 : case XML_TYPE_TEXT_ANCHOR_TYPE:
1295 593 : pHdl = new XMLAnchorTypePropHdl;
1296 593 : break;
1297 : case XML_TYPE_TEXT_COLUMNS:
1298 1171 : pHdl = new XMLTextColumnsPropertyHandler;
1299 1171 : break;
1300 : case XML_TYPE_TEXT_HORIZONTAL_POS:
1301 713 : pHdl = new XMLConstantsPropertyHandler( pXML_HoriPos_Enum, XML_TOKEN_INVALID );
1302 713 : break;
1303 : case XML_TYPE_TEXT_HORIZONTAL_POS_MIRRORED:
1304 713 : pHdl = new XMLConstantsPropertyHandler( pXML_HoriPosMirrored_Enum, XML_TOKEN_INVALID );
1305 713 : break;
1306 : case XML_TYPE_TEXT_HORIZONTAL_REL:
1307 713 : pHdl = new XMLConstantsPropertyHandler( pXML_HoriRel_Enum, XML_TOKEN_INVALID );
1308 713 : break;
1309 : case XML_TYPE_TEXT_HORIZONTAL_REL_FRAME:
1310 713 : pHdl = new XMLConstantsPropertyHandler( pXML_HoriRelFrame_Enum, XML_TOKEN_INVALID );
1311 713 : break;
1312 : case XML_TYPE_TEXT_HORIZONTAL_MIRROR:
1313 713 : pHdl = new XMLHoriMirrorPropHdl_Impl;
1314 713 : break;
1315 : case XML_TYPE_TEXT_VERTICAL_POS:
1316 713 : pHdl = new XMLConstantsPropertyHandler( pXML_VertPos_Enum, XML_TOKEN_INVALID );
1317 713 : break;
1318 : case XML_TYPE_TEXT_VERTICAL_POS_AT_CHAR:
1319 713 : pHdl = new XMLConstantsPropertyHandler( pXML_VertPosAtChar_Enum, XML_TOKEN_INVALID );
1320 713 : break;
1321 : case XML_TYPE_TEXT_VERTICAL_REL:
1322 713 : pHdl = new XMLConstantsPropertyHandler( pXML_VertRel_Enum, XML_TOKEN_INVALID );
1323 713 : break;
1324 : case XML_TYPE_TEXT_VERTICAL_REL_PAGE:
1325 713 : pHdl = new XMLConstantsPropertyHandler( pXML_VertRelPage_Enum, XML_TOKEN_INVALID );
1326 713 : break;
1327 : case XML_TYPE_TEXT_VERTICAL_REL_FRAME:
1328 713 : pHdl = new XMLConstantsPropertyHandler( pXML_VertRelFrame_Enum, XML_TOKEN_INVALID );
1329 713 : break;
1330 : case XML_TYPE_TEXT_VERTICAL_REL_AS_CHAR:
1331 713 : pHdl = new XMLConstantsPropertyHandler( pXML_VertRelAsChar_Enum, XML_TOKEN_INVALID );
1332 713 : break;
1333 : case XML_TYPE_TEXT_MIRROR_VERTICAL:
1334 681 : pHdl = new XMLGrfMirrorPropHdl_Impl( XML_VERTICAL, sal_False );
1335 681 : break;
1336 : case XML_TYPE_TEXT_MIRROR_HORIZONTAL_LEFT:
1337 : // XML_HORIZONTAL_ON_LEFT_PAGES is replaced by XML_HORIZONTAL_ON_EVEN. (#i49139#)
1338 681 : pHdl = new XMLGrfMirrorPropHdl_Impl( XML_HORIZONTAL_ON_EVEN, sal_True );
1339 681 : break;
1340 : case XML_TYPE_TEXT_MIRROR_HORIZONTAL_RIGHT:
1341 : // XML_HORIZONTAL_ON_RIGHT_PAGES is replaced by XML_HORIZONTAL_ON_ODD. (#i49139#)
1342 681 : pHdl = new XMLGrfMirrorPropHdl_Impl( XML_HORIZONTAL_ON_ODD, sal_True );
1343 681 : break;
1344 : case XML_TYPE_TEXT_CLIP:
1345 681 : pHdl = new XMLClipPropertyHandler( sal_False );
1346 681 : break;
1347 : case XML_TYPE_TEXT_CLIP11:
1348 681 : pHdl = new XMLClipPropertyHandler( sal_True );
1349 681 : break;
1350 : case XML_TYPE_TEXT_EMPHASIZE:
1351 1936 : pHdl = new XMLTextEmphasizePropHdl_Impl;
1352 1936 : break;
1353 : case XML_TYPE_TEXT_COMBINE:
1354 : pHdl = new XMLNamedBoolPropertyHdl( GetXMLToken( XML_LINES ),
1355 1936 : GetXMLToken( XML_NONE ) );
1356 1936 : break;
1357 : case XML_TYPE_TEXT_COMBINE_CHARACTERS:
1358 : pHdl = new XMLNamedBoolPropertyHdl( GetXMLToken( XML_LETTERS ),
1359 498 : GetXMLToken( XML_NONE ) );
1360 498 : break;
1361 : case XML_TYPE_TEXT_COMBINECHAR:
1362 1936 : pHdl = new XMLTextCombineCharPropHdl_Impl;
1363 1936 : break;
1364 : case XML_TYPE_TEXT_AUTOSPACE:
1365 : pHdl = new XMLNamedBoolPropertyHdl( GetXMLToken( XML_IDEOGRAPH_ALPHA ),
1366 1936 : GetXMLToken( XML_NONE ) );
1367 1936 : break;
1368 : case XML_TYPE_TEXT_PUNCTUATION_WRAP:
1369 : pHdl = new XMLNamedBoolPropertyHdl( GetXMLToken( XML_HANGING ),
1370 1936 : GetXMLToken( XML_SIMPLE ) );
1371 1936 : break;
1372 : case XML_TYPE_TEXT_LINE_BREAK:
1373 : pHdl = new XMLNamedBoolPropertyHdl( GetXMLToken( XML_STRICT ),
1374 1936 : GetXMLToken( XML_NORMAL ) );
1375 1936 : break;
1376 : case XML_TYPE_TEXT_REL_WIDTH_HEIGHT:
1377 593 : pHdl = new XMLTextRelWidthHeightPropHdl_Impl;
1378 593 : break;
1379 : case XML_TYPE_TEXT_SYNC_WIDTH_HEIGHT:
1380 0 : pHdl = new XMLTextSyncWidthHeightPropHdl_Impl( XML_SCALE );
1381 0 : break;
1382 : case XML_TYPE_TEXT_SYNC_WIDTH_HEIGHT_MIN:
1383 0 : pHdl = new XMLTextSyncWidthHeightPropHdl_Impl( XML_SCALE_MIN );
1384 0 : break;
1385 : case XML_TYPE_TEXT_RUBY_ADJUST:
1386 490 : pHdl = new XMLConstantsPropertyHandler( pXML_RubyAdjust_Enum, XML_TOKEN_INVALID );
1387 490 : break;
1388 : case XML_TYPE_TEXT_FONT_RELIEF:
1389 1936 : pHdl = new XMLConstantsPropertyHandler( pXML_FontRelief_Enum, XML_TOKEN_INVALID );
1390 1936 : break;
1391 : case XML_TYPE_TEXT_ROTATION_ANGLE:
1392 1936 : pHdl = new XMLTextRotationAnglePropHdl_Impl;
1393 1936 : break;
1394 : case XML_TYPE_TEXT_ROTATION_SCALE:
1395 : pHdl = new XMLNamedBoolPropertyHdl( GetXMLToken( XML_FIXED ),
1396 1936 : GetXMLToken( XML_LINE_HEIGHT ) );
1397 1936 : break;
1398 : case XML_TYPE_TEXT_VERTICAL_ALIGN:
1399 1438 : pHdl = new XMLConstantsPropertyHandler( pXML_VerticalAlign_Enum, XML_TOKEN_INVALID );
1400 1438 : break;
1401 : case XML_TYPE_TEXT_RUBY_POSITION:
1402 : pHdl = new XMLNamedBoolPropertyHdl( ::xmloff::token::XML_ABOVE,
1403 490 : ::xmloff::token::XML_BELOW );
1404 490 : break;
1405 : // OD 2004-05-05 #i28701#
1406 : case XML_TYPE_WRAP_INFLUENCE_ON_POSITION:
1407 : pHdl = new XMLConstantsPropertyHandler( pXML_WrapInfluenceOnPosition_Enum,
1408 1055 : XML_TOKEN_INVALID );
1409 1055 : break;
1410 : case XML_TYPE_BORDER_MODEL:
1411 : pHdl = new XMLNamedBoolPropertyHdl( xmloff::token::XML_COLLAPSING,
1412 116 : xmloff::token::XML_SEPARATING );
1413 116 : break;
1414 : case XML_TYPE_TEXT_LINE_MODE:
1415 : pHdl = new XMLNamedBoolPropertyHdl(
1416 : ::xmloff::token::XML_SKIP_WHITE_SPACE,
1417 1936 : ::xmloff::token::XML_CONTINUOUS);
1418 1936 : break;
1419 : case XML_TYPE_TEXT_KEEP:
1420 : pHdl = new XMLNamedBoolPropertyHdl(
1421 : ::xmloff::token::XML_ALWAYS,
1422 1438 : ::xmloff::token::XML_AUTO);
1423 1438 : break;
1424 : case XML_TYPE_TEXT_NKEEP:
1425 : pHdl = new XMLNamedBoolPropertyHdl(
1426 : ::xmloff::token::XML_AUTO,
1427 116 : ::xmloff::token::XML_ALWAYS);
1428 116 : break;
1429 : case XML_TYPE_TEXT_NUMBER8_ONE_BASED:
1430 1438 : pHdl = new XMLNumber8OneBasedHdl();
1431 1438 : break;
1432 : case XML_TYPE_FILLSTYLE:
1433 681 : pHdl = new XMLConstantsPropertyHandler( pXML_FillStyle_Enum, XML_TOKEN_INVALID );
1434 681 : break;
1435 : }
1436 :
1437 47058 : return pHdl;
1438 : }
1439 :
1440 4203 : XMLTextPropertyHandlerFactory_Impl::XMLTextPropertyHandlerFactory_Impl()
1441 : {
1442 4203 : }
1443 :
1444 4198 : XMLTextPropertyHandlerFactory_Impl::~XMLTextPropertyHandlerFactory_Impl()
1445 : {
1446 4198 : }
1447 :
1448 : // ----------------------------------------------------------------------------
1449 :
1450 4203 : XMLTextPropertyHandlerFactory::XMLTextPropertyHandlerFactory() :
1451 : XMLPropertyHandlerFactory(),
1452 4203 : pImpl( new XMLTextPropertyHandlerFactory_Impl )
1453 : {
1454 4203 : }
1455 :
1456 12594 : XMLTextPropertyHandlerFactory::~XMLTextPropertyHandlerFactory()
1457 : {
1458 4198 : delete pImpl;
1459 8396 : }
1460 :
1461 340917 : const XMLPropertyHandler *XMLTextPropertyHandlerFactory::GetPropertyHandler(
1462 : sal_Int32 nType ) const
1463 : {
1464 : const XMLPropertyHandler *pHdl =
1465 340917 : XMLPropertyHandlerFactory::GetPropertyHandler( nType );
1466 :
1467 340917 : if( !pHdl )
1468 : {
1469 47058 : const XMLPropertyHandler *pNewHdl = pImpl->GetPropertyHandler( nType );
1470 :
1471 47058 : if( pNewHdl )
1472 47058 : PutHdlCache( nType, pNewHdl );
1473 :
1474 47058 : pHdl = pNewHdl;
1475 : }
1476 :
1477 340917 : return pHdl;
1478 : }
1479 :
1480 :
1481 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|