Avoid potential negative array index access to cached text.
[LibreOffice.git] / xmloff / source / text / txtprhdl.cxx
blobf7c3a9790dda8fce36a19e7349e684abd4b582fc
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 <sal/config.h>
22 #include <o3tl/any.hxx>
23 #include <osl/diagnose.h>
24 #include <rtl/ustrbuf.hxx>
25 #include <sal/log.hxx>
26 #include <com/sun/star/uno/Any.hxx>
27 #include <com/sun/star/drawing/FillStyle.hpp>
28 #include <com/sun/star/style/DropCapFormat.hpp>
29 #include <com/sun/star/text/FontRelief.hpp>
30 #include <com/sun/star/text/WrapTextMode.hpp>
31 #include <com/sun/star/text/XTextColumns.hpp>
32 #include <com/sun/star/text/TextColumn.hpp>
33 #include <com/sun/star/text/RelOrientation.hpp>
34 #include <com/sun/star/text/HoriOrientation.hpp>
35 #include <com/sun/star/text/VertOrientation.hpp>
36 #include <com/sun/star/text/RubyAdjust.hpp>
37 #include <com/sun/star/text/RubyPosition.hpp>
38 #include <com/sun/star/text/FontEmphasis.hpp>
39 #include <com/sun/star/text/ParagraphVertAlign.hpp>
40 #include <com/sun/star/graphic/XGraphic.hpp>
41 #include <sax/tools/converter.hxx>
42 #include <xmloff/xmltypes.hxx>
43 #include <xmloff/xmluconv.hxx>
44 #include <xmloff/xmltoken.hxx>
45 #include <xmloff/xmlement.hxx>
46 #include "XMLAnchorTypePropHdl.hxx"
47 #include <enummaps.hxx>
48 #include <xmloff/XMLConstantsPropertyHandler.hxx>
49 #include <XMLClipPropertyHandler.hxx>
50 #include <XMLTextColumnsPropertyHandler.hxx>
51 #include <xmloff/NamedBoolPropertyHdl.hxx>
52 #include "txtprhdl.hxx"
53 #include <com/sun/star/text/WrapInfluenceOnPosition.hpp>
54 #include <com/sun/star/drawing/TextVerticalAdjust.hpp>
55 #include <xmloff/EnumPropertyHdl.hxx>
56 #include <XMLFillBitmapSizePropertyHandler.hxx>
57 #include <XMLBitmapLogicalSizePropertyHandler.hxx>
58 #include <XMLBitmapRepeatOffsetPropertyHandler.hxx>
59 #include <xmloff/XMLComplexColorHandler.hxx>
60 #include <vcl/graph.hxx>
62 using namespace ::com::sun::star;
63 using namespace ::com::sun::star::uno;
64 using namespace ::com::sun::star::style;
65 using namespace ::com::sun::star::text;
66 using namespace ::xmloff::token;
67 using namespace ::com::sun::star::drawing;
69 SvXMLEnumMapEntry<sal_uInt16> const pXML_HoriPos_Enum[] =
71 { XML_FROM_LEFT, HoriOrientation::NONE },
72 { XML_FROM_INSIDE, HoriOrientation::NONE }, // import only
73 { XML_LEFT, HoriOrientation::LEFT },
74 { XML_INSIDE, HoriOrientation::LEFT }, // import only
75 { XML_CENTER, HoriOrientation::CENTER },
76 { XML_RIGHT, HoriOrientation::RIGHT },
77 { XML_OUTSIDE, HoriOrientation::RIGHT }, // import only
78 { XML_TOKEN_INVALID, 0 }
81 SvXMLEnumMapEntry<sal_uInt16> const pXML_HoriPosMirrored_Enum[] =
83 { XML_FROM_INSIDE, HoriOrientation::NONE },
84 { XML_INSIDE, HoriOrientation::LEFT },
85 { XML_CENTER, HoriOrientation::CENTER },
86 { XML_OUTSIDE, HoriOrientation::RIGHT },
87 { XML_TOKEN_INVALID, 0 }
90 SvXMLEnumMapEntry<sal_uInt16> const pXML_HoriRel_Enum[] =
92 { XML_PARAGRAPH, RelOrientation::FRAME },
93 { XML_PARAGRAPH_CONTENT, RelOrientation::PRINT_AREA },
94 { XML_PAGE, RelOrientation::PAGE_FRAME },
95 { XML_PAGE_CONTENT, RelOrientation::PAGE_PRINT_AREA },
96 { XML_PARAGRAPH_START_MARGIN, RelOrientation::FRAME_LEFT },
97 { XML_PARAGRAPH_END_MARGIN, RelOrientation::FRAME_RIGHT },
98 { XML_PAGE_START_MARGIN, RelOrientation::PAGE_LEFT },
99 { XML_PAGE_END_MARGIN, RelOrientation::PAGE_RIGHT },
100 { XML_CHAR, RelOrientation::CHAR },
101 { XML_FRAME, RelOrientation::FRAME }, // import only
102 { XML_FRAME_CONTENT, RelOrientation::PRINT_AREA }, // import only
103 { XML_FRAME_START_MARGIN, RelOrientation::FRAME_LEFT }, // import only
104 { XML_FRAME_END_MARGIN, RelOrientation::FRAME_RIGHT }, // import only
105 { XML_TOKEN_INVALID, 0 }
108 SvXMLEnumMapEntry<sal_uInt16> const pXML_HoriRelFrame_Enum[] =
110 { XML_FRAME, RelOrientation::FRAME },
111 { XML_FRAME_CONTENT, RelOrientation::PRINT_AREA },
112 { XML_PAGE, RelOrientation::PAGE_FRAME },
113 { XML_PAGE_CONTENT, RelOrientation::PAGE_PRINT_AREA },
114 { XML_FRAME_START_MARGIN, RelOrientation::FRAME_LEFT },
115 { XML_FRAME_END_MARGIN, RelOrientation::FRAME_RIGHT },
116 { XML_PAGE_START_MARGIN, RelOrientation::PAGE_LEFT },
117 { XML_PAGE_END_MARGIN, RelOrientation::PAGE_RIGHT },
118 { XML_CHAR, RelOrientation::CHAR },
119 { XML_TOKEN_INVALID, 0 }
122 SvXMLEnumMapEntry<bool> const pXML_HoriMirror_Enum[] =
124 { XML_FROM_LEFT, false },
125 { XML_FROM_INSIDE, true },
126 { XML_LEFT, false },
127 { XML_INSIDE, true },
128 { XML_CENTER, false },
129 { XML_RIGHT, false },
130 { XML_OUTSIDE, true },
131 { XML_TOKEN_INVALID, false }
134 SvXMLEnumMapEntry<sal_uInt16> const pXML_VertPosAtChar_Enum[] =
136 { XML_FROM_TOP, VertOrientation::NONE },
137 { XML_TOP, VertOrientation::TOP },
138 { XML_TOP, VertOrientation::CHAR_TOP }, // export only
139 { XML_TOP, VertOrientation::LINE_TOP }, // export only
140 { XML_MIDDLE, VertOrientation::CENTER },
141 { XML_MIDDLE, VertOrientation::CHAR_CENTER }, // export only
142 { XML_MIDDLE, VertOrientation::LINE_CENTER }, // export only
143 { XML_BOTTOM, VertOrientation::BOTTOM },
144 { XML_BELOW, VertOrientation::CHAR_BOTTOM }, // export only
145 { XML_BOTTOM, VertOrientation::LINE_BOTTOM }, // export only
146 { XML_TOKEN_INVALID, 0 }
149 SvXMLEnumMapEntry<sal_uInt16> const pXML_VertRel_Enum[] =
151 { XML_PARAGRAPH, RelOrientation::FRAME },
152 { XML_PARAGRAPH_CONTENT, RelOrientation::PRINT_AREA },
153 { XML_CHAR, RelOrientation::CHAR },
154 // DVO, OD 17.09.2003 #i18732# - allow vertical alignment at page
155 { XML_PAGE, RelOrientation::PAGE_FRAME },
156 { XML_PAGE_CONTENT, RelOrientation::PAGE_PRINT_AREA },
157 { XML_PAGE_CONTENT_TOP, RelOrientation::PAGE_PRINT_AREA_TOP },
158 { XML_PAGE_CONTENT_BOTTOM, RelOrientation::PAGE_PRINT_AREA_BOTTOM },
159 { XML_FRAME, RelOrientation::FRAME }, // import only
160 { XML_FRAME_CONTENT, RelOrientation::PRINT_AREA }, // import only
161 // OD 13.11.2003 #i22341# - new vertical alignment at top of line
162 { XML_LINE, RelOrientation::TEXT_LINE },
163 { XML_TOKEN_INVALID, 0 }
166 SvXMLEnumMapEntry<sal_uInt16> const pXML_VertRelPage_Enum[] =
168 { XML_PAGE, RelOrientation::FRAME },
169 { XML_PAGE_CONTENT, RelOrientation::PRINT_AREA },
170 { XML_PAGE, RelOrientation::PAGE_FRAME },
171 { XML_PAGE_CONTENT, RelOrientation::PAGE_PRINT_AREA },
172 { XML_PAGE_CONTENT_TOP, RelOrientation::PAGE_PRINT_AREA_TOP },
173 { XML_PAGE_CONTENT_BOTTOM, RelOrientation::PAGE_PRINT_AREA_BOTTOM },
174 { XML_TOKEN_INVALID, 0 }
177 SvXMLEnumMapEntry<sal_uInt16> const pXML_VertRelFrame_Enum[] =
179 { XML_FRAME, RelOrientation::FRAME },
180 { XML_FRAME_CONTENT, RelOrientation::PRINT_AREA },
181 { XML_TOKEN_INVALID, 0 }
184 SvXMLEnumMapEntry<sal_uInt16> const pXML_VertRelAsChar_Enum[] =
186 { XML_BASELINE, VertOrientation::TOP },
187 { XML_BASELINE, VertOrientation::CENTER }, // export only
188 { XML_BASELINE, VertOrientation::BOTTOM }, // export only
189 { XML_TEXT, VertOrientation::CHAR_TOP },
190 { XML_TEXT, VertOrientation::CHAR_CENTER }, // export only
191 { XML_TEXT, VertOrientation::CHAR_BOTTOM }, // export only
192 { XML_LINE, VertOrientation::LINE_TOP },
193 { XML_LINE, VertOrientation::LINE_CENTER }, // export only
194 { XML_LINE, VertOrientation::LINE_BOTTOM }, // export only
195 { XML_TOKEN_INVALID, 0 }
198 SvXMLEnumMapEntry<RubyAdjust> const pXML_RubyAdjust_Enum[] =
200 { XML_LEFT, RubyAdjust_LEFT },
201 { XML_CENTER, RubyAdjust_CENTER },
202 { XML_RIGHT, RubyAdjust_RIGHT },
203 { XML_DISTRIBUTE_LETTER, RubyAdjust_BLOCK },
204 { XML_DISTRIBUTE_SPACE, RubyAdjust_INDENT_BLOCK },
205 { XML_TOKEN_INVALID, RubyAdjust(0) }
208 SvXMLEnumMapEntry<sal_Int16> const pXML_RubyPosition_Enum[] =
210 { XML_ABOVE, RubyPosition::ABOVE},
211 { XML_BELOW, RubyPosition::BELOW},
212 { XML_INTER_CHARACTER, RubyPosition::INTER_CHARACTER},
213 { XML_TOKEN_INVALID, 0 }
216 SvXMLEnumMapEntry<sal_uInt16> const pXML_FontRelief_Enum[] =
218 { XML_NONE, FontRelief::NONE },
219 { XML_ENGRAVED, FontRelief::ENGRAVED },
220 { XML_EMBOSSED, FontRelief::EMBOSSED },
221 { XML_TOKEN_INVALID, 0 }
224 SvXMLEnumMapEntry<sal_uInt16> const pXML_ParaVerticalAlign_Enum[] =
226 { XML_TOP, ParagraphVertAlign::TOP },
227 { XML_MIDDLE, ParagraphVertAlign::CENTER },
228 { XML_BOTTOM, ParagraphVertAlign::BOTTOM },
229 { XML_BASELINE, ParagraphVertAlign::BASELINE },
230 { XML_AUTO, ParagraphVertAlign::AUTOMATIC },
231 { XML_TOKEN_INVALID, 0 }
234 // OD 2004-05-05 #i28701#
235 SvXMLEnumMapEntry<sal_uInt16> const pXML_WrapInfluenceOnPosition_Enum[] =
237 // Tokens have been renamed and <XML_ITERATIVE> has been added (#i35017#)
238 { XML_ONCE_SUCCESSIVE, WrapInfluenceOnPosition::ONCE_SUCCESSIVE },
239 { XML_ONCE_CONCURRENT, WrapInfluenceOnPosition::ONCE_CONCURRENT },
240 { XML_ITERATIVE, WrapInfluenceOnPosition::ITERATIVE },
241 { XML_TOKEN_INVALID, 0 }
244 SvXMLEnumMapEntry<drawing::TextVerticalAdjust> const pXML_VerticalAlign_Enum[] =
246 { XML_TOP, drawing::TextVerticalAdjust_TOP },
247 { XML_MIDDLE, drawing::TextVerticalAdjust_CENTER },
248 { XML_BOTTOM, drawing::TextVerticalAdjust_BOTTOM },
249 { XML_JUSTIFY, drawing::TextVerticalAdjust_BLOCK },
250 { XML_TOKEN_INVALID, drawing::TextVerticalAdjust(0) }
253 namespace {
255 class XMLDropCapPropHdl_Impl : public XMLPropertyHandler
257 public:
258 virtual bool equals(
259 const css::uno::Any& r1,
260 const css::uno::Any& r2 ) const override;
262 /// TabStops will be imported/exported as XML-Elements. So the Import/Export-work must be done at another place.
263 virtual bool importXML(
264 const OUString& rStrImpValue,
265 css::uno::Any& rValue,
266 const SvXMLUnitConverter& ) const override;
267 virtual bool exportXML(
268 OUString& rStrExpValue,
269 const css::uno::Any& rValue,
270 const SvXMLUnitConverter& ) const override;
275 bool XMLDropCapPropHdl_Impl::equals(
276 const Any& r1,
277 const Any& r2 ) const
279 DropCapFormat aFormat1, aFormat2;
280 r1 >>= aFormat1;
281 r2 >>= aFormat2;
283 return (aFormat1.Lines <=1 && aFormat2.Lines <=1) ||
284 (aFormat1.Lines == aFormat2.Lines &&
285 aFormat1.Count == aFormat2.Count &&
286 aFormat1.Distance == aFormat2.Distance);
289 bool XMLDropCapPropHdl_Impl::importXML(
290 const OUString&,
291 Any&,
292 const SvXMLUnitConverter& ) const
294 SAL_WARN( "xmloff", "drop caps are an element import property" );
295 return false;
298 bool XMLDropCapPropHdl_Impl::exportXML(
299 OUString&,
300 const Any&,
301 const SvXMLUnitConverter& ) const
303 SAL_WARN( "xmloff", "drop caps are an element export property" );
304 return false;
307 namespace {
309 class XMLOpaquePropHdl_Impl : public XMLPropertyHandler
311 public:
312 virtual bool importXML(
313 const OUString& rStrImpValue,
314 css::uno::Any& rValue,
315 const SvXMLUnitConverter& ) const override;
316 virtual bool exportXML(
317 OUString& rStrExpValue,
318 const css::uno::Any& rValue,
319 const SvXMLUnitConverter& ) const override;
324 bool XMLOpaquePropHdl_Impl::importXML(
325 const OUString& rStrImpValue,
326 Any& rValue,
327 const SvXMLUnitConverter& ) const
329 bool bRet = true;
330 bool bVal = false;
331 if( IsXMLToken( rStrImpValue, XML_FOREGROUND ) )
332 bVal = true;
333 else if( !IsXMLToken( rStrImpValue, XML_BACKGROUND ) )
334 bRet = false;
336 if( bRet )
337 rValue <<= bVal;
339 return bRet;
342 bool XMLOpaquePropHdl_Impl::exportXML(
343 OUString& rStrExpValue,
344 const Any& rValue,
345 const SvXMLUnitConverter& ) const
347 if( *o3tl::doAccess<bool>(rValue) )
348 rStrExpValue = GetXMLToken( XML_FOREGROUND );
349 else
350 rStrExpValue = GetXMLToken( XML_BACKGROUND );
352 return true;
355 namespace {
357 class XMLContourModePropHdl_Impl : public XMLPropertyHandler
359 public:
360 virtual bool importXML(
361 const OUString& rStrImpValue,
362 css::uno::Any& rValue,
363 const SvXMLUnitConverter& ) const override;
364 virtual bool exportXML(
365 OUString& rStrExpValue,
366 const css::uno::Any& rValue,
367 const SvXMLUnitConverter& ) const override;
372 bool XMLContourModePropHdl_Impl::importXML(
373 const OUString& rStrImpValue,
374 Any& rValue,
375 const SvXMLUnitConverter& ) const
377 bool bRet = true;
378 bool bVal = false;
379 if( IsXMLToken( rStrImpValue, XML_OUTSIDE ) )
380 bVal = true;
381 else if( ! IsXMLToken( rStrImpValue, XML_FULL ) )
382 bRet = false;
384 if( bRet )
385 rValue <<= bVal;
387 return bRet;
390 bool XMLContourModePropHdl_Impl::exportXML(
391 OUString& rStrExpValue,
392 const Any& rValue,
393 const SvXMLUnitConverter& ) const
395 if( *o3tl::doAccess<bool>(rValue) )
396 rStrExpValue = GetXMLToken( XML_OUTSIDE );
397 else
398 rStrExpValue = GetXMLToken( XML_FULL );
400 return true;
403 namespace {
405 class XMLParagraphOnlyPropHdl_Impl : public XMLPropertyHandler
407 public:
408 virtual bool importXML(
409 const OUString& rStrImpValue,
410 css::uno::Any& rValue,
411 const SvXMLUnitConverter& ) const override;
412 virtual bool exportXML(
413 OUString& rStrExpValue,
414 const css::uno::Any& rValue,
415 const SvXMLUnitConverter& ) const override;
420 bool XMLParagraphOnlyPropHdl_Impl::importXML(
421 const OUString& rStrImpValue,
422 Any& rValue,
423 const SvXMLUnitConverter& ) const
425 bool bRet = true;
426 bool bVal = false;
428 if( ! IsXMLToken( rStrImpValue, XML_NO_LIMIT ) )
430 sal_Int32 nValue = 0;
431 bRet = ::sax::Converter::convertNumber( nValue, rStrImpValue );
432 bVal = 1 == nValue;
435 if( bRet )
436 rValue <<= bVal;
438 return bRet;
441 bool XMLParagraphOnlyPropHdl_Impl::exportXML(
442 OUString& rStrExpValue,
443 const Any& rValue,
444 const SvXMLUnitConverter& ) const
446 if( *o3tl::doAccess<bool>(rValue) )
447 rStrExpValue = GetXMLToken( XML_1 );
448 else
449 rStrExpValue = GetXMLToken( XML_NO_LIMIT );
451 return true;
454 SvXMLEnumMapEntry<WrapTextMode> const pXML_Wrap_Enum[] =
456 { XML_NONE, WrapTextMode_NONE },
457 { XML_RUN_THROUGH, WrapTextMode_THROUGH },
458 { XML_PARALLEL, WrapTextMode_PARALLEL },
459 { XML_DYNAMIC, WrapTextMode_DYNAMIC },
460 { XML_LEFT, WrapTextMode_LEFT },
461 { XML_RIGHT, WrapTextMode_RIGHT },
462 { XML_TOKEN_INVALID, WrapTextMode(0) }
465 namespace {
467 class XMLWrapPropHdl_Impl : public XMLPropertyHandler
469 public:
470 virtual bool importXML(
471 const OUString& rStrImpValue,
472 css::uno::Any& rValue,
473 const SvXMLUnitConverter& ) const override;
474 virtual bool exportXML(
475 OUString& rStrExpValue,
476 const css::uno::Any& rValue,
477 const SvXMLUnitConverter& ) const override;
482 bool XMLWrapPropHdl_Impl::importXML(
483 const OUString& rStrImpValue,
484 Any& rValue,
485 const SvXMLUnitConverter& ) const
487 WrapTextMode nWrap;
488 bool bRet = SvXMLUnitConverter::convertEnum( nWrap, rStrImpValue,
489 pXML_Wrap_Enum );
491 if( bRet )
492 rValue <<= nWrap;
494 return bRet;
497 bool XMLWrapPropHdl_Impl::exportXML(
498 OUString& rStrExpValue,
499 const Any& rValue,
500 const SvXMLUnitConverter& ) const
502 OUStringBuffer aOut;
503 WrapTextMode eVal;
505 rValue >>= eVal;
507 bool bRet = SvXMLUnitConverter::convertEnum( aOut, eVal, pXML_Wrap_Enum, XML_NONE );
509 rStrExpValue = aOut.makeStringAndClear();
511 return bRet;
514 namespace {
516 class XMLFrameProtectPropHdl_Impl : public XMLPropertyHandler
518 const OUString sVal;
519 public:
520 explicit XMLFrameProtectPropHdl_Impl( enum XMLTokenEnum eVal ) :
521 sVal( GetXMLToken(eVal) ) {}
523 virtual bool importXML(
524 const OUString& rStrImpValue,
525 css::uno::Any& rValue,
526 const SvXMLUnitConverter& ) const override;
527 virtual bool exportXML(
528 OUString& rStrExpValue,
529 const css::uno::Any& rValue,
530 const SvXMLUnitConverter& ) const override;
535 bool XMLFrameProtectPropHdl_Impl::importXML(
536 const OUString& rStrImpValue,
537 Any& rValue,
538 const SvXMLUnitConverter& ) const
540 bool bRet = true;
541 bool bVal = false;
542 if( ! IsXMLToken( rStrImpValue, XML_NONE ) )
544 bRet = false;
545 SvXMLTokenEnumerator aTokenEnum( rStrImpValue );
546 std::u16string_view aToken;
547 while( aTokenEnum.getNextToken( aToken ) )
549 bRet = true;
550 if( aToken == sVal )
552 bVal = true;
553 break;
558 if( bRet )
559 rValue <<= bVal;
561 return bRet;
564 bool XMLFrameProtectPropHdl_Impl::exportXML(
565 OUString& rStrExpValue,
566 const Any& rValue,
567 const SvXMLUnitConverter& ) const
569 if( *o3tl::doAccess<bool>(rValue) )
571 if( rStrExpValue.isEmpty() ||
572 IsXMLToken( rStrExpValue, XML_NONE ) )
574 rStrExpValue = sVal;
576 else
578 rStrExpValue += " " + sVal;
581 else if( rStrExpValue.isEmpty() )
583 rStrExpValue = GetXMLToken( XML_NONE );
586 return true;
589 SvXMLEnumMapEntry<TextContentAnchorType> const pXML_Anchor_Enum[] =
591 { XML_CHAR, TextContentAnchorType_AT_CHARACTER },
592 { XML_PAGE, TextContentAnchorType_AT_PAGE },
593 { XML_FRAME, TextContentAnchorType_AT_FRAME },
594 { XML_PARAGRAPH, TextContentAnchorType_AT_PARAGRAPH },
595 { XML_AS_CHAR, TextContentAnchorType_AS_CHARACTER },
596 { XML_TOKEN_INVALID, TextContentAnchorType(0) }
599 bool XMLAnchorTypePropHdl::importXML(
600 const OUString& rStrImpValue,
601 Any& rValue,
602 const SvXMLUnitConverter& ) const
604 TextContentAnchorType nAnchor;
605 bool bRet = SvXMLUnitConverter::convertEnum( nAnchor, rStrImpValue,
606 pXML_Anchor_Enum );
608 if( bRet )
609 rValue <<= nAnchor;
611 return bRet;
614 bool XMLAnchorTypePropHdl::exportXML(
615 OUString& rStrExpValue,
616 const Any& rValue,
617 const SvXMLUnitConverter& ) const
619 OUStringBuffer aOut;
620 TextContentAnchorType eVal;
622 rValue >>= eVal;
624 bool bRet = SvXMLUnitConverter::convertEnum( aOut, eVal, pXML_Anchor_Enum, XML_PARAGRAPH );
626 rStrExpValue = aOut.makeStringAndClear();
628 return bRet;
631 XMLAnchorTypePropHdl::~XMLAnchorTypePropHdl()
635 bool XMLAnchorTypePropHdl::convert( std::string_view rStrImpValue,
636 TextContentAnchorType& rType )
638 TextContentAnchorType nAnchor;
639 bool bRet = SvXMLUnitConverter::convertEnum( nAnchor, rStrImpValue,
640 pXML_Anchor_Enum );
641 if( bRet )
642 rType = nAnchor;
643 return bRet;
646 XMLTextColumnsPropertyHandler::~XMLTextColumnsPropertyHandler ()
650 bool XMLTextColumnsPropertyHandler::equals(
651 const Any& r1,
652 const Any& r2 ) const
654 Reference < XTextColumns > xColumns1;
655 r1 >>= xColumns1;
657 Reference < XTextColumns > xColumns2;
658 r2 >>= xColumns2;
660 if (!xColumns1 || !xColumns2)
661 return (!xColumns1 && !xColumns2);
663 if( xColumns1->getColumnCount() != xColumns2->getColumnCount() ||
664 xColumns1->getReferenceValue() != xColumns2->getReferenceValue() )
665 return false;
667 const Sequence < TextColumn > aColumns1 = xColumns1->getColumns();
668 const Sequence < TextColumn > aColumns2 = xColumns2->getColumns();
670 return std::equal(aColumns1.begin(), aColumns1.end(), aColumns2.begin(), aColumns2.end(),
671 [](const TextColumn& a, const TextColumn& b) {
672 return a.Width == b.Width
673 && a.LeftMargin == b.LeftMargin
674 && a.RightMargin == b.RightMargin;
678 bool XMLTextColumnsPropertyHandler::importXML(
679 const OUString&,
680 Any&,
681 const SvXMLUnitConverter& ) const
683 SAL_WARN( "xmloff", "columns are an element import property" );
684 return false;
687 bool XMLTextColumnsPropertyHandler::exportXML(
688 OUString&,
689 const Any&,
690 const SvXMLUnitConverter& ) const
692 SAL_WARN( "xmloff", "columns are an element export property" );
693 return false;
696 namespace {
698 class XMLHoriMirrorPropHdl_Impl : public XMLPropertyHandler
700 public:
701 virtual bool importXML(
702 const OUString& rStrImpValue,
703 css::uno::Any& rValue,
704 const SvXMLUnitConverter& ) const override;
705 virtual bool exportXML(
706 OUString& rStrExpValue,
707 const css::uno::Any& rValue,
708 const SvXMLUnitConverter& ) const override;
713 bool XMLHoriMirrorPropHdl_Impl::importXML(
714 const OUString& rStrImpValue,
715 Any& rValue,
716 const SvXMLUnitConverter& ) const
718 bool nHoriMirror;
719 bool bRet = SvXMLUnitConverter::convertEnum( nHoriMirror, rStrImpValue,
720 pXML_HoriMirror_Enum );
722 if( bRet )
724 rValue <<= nHoriMirror;
727 return bRet;
730 bool XMLHoriMirrorPropHdl_Impl::exportXML(
731 OUString&,
732 const Any&,
733 const SvXMLUnitConverter& ) const
735 SAL_WARN( "xmloff", "HorMirror property shouldn't be exported" );
737 return false;
740 namespace {
742 class XMLGrfMirrorPropHdl_Impl : public XMLPropertyHandler
744 const OUString sVal;
745 bool bHori;
747 public:
748 XMLGrfMirrorPropHdl_Impl( enum XMLTokenEnum eVal, bool bH ) :
749 sVal( GetXMLToken( eVal ) ),
750 bHori( bH ) {}
752 virtual bool importXML(
753 const OUString& rStrImpValue,
754 css::uno::Any& rValue,
755 const SvXMLUnitConverter& ) const override;
756 virtual bool exportXML(
757 OUString& rStrExpValue,
758 const css::uno::Any& rValue,
759 const SvXMLUnitConverter& ) const override;
764 bool XMLGrfMirrorPropHdl_Impl::importXML(
765 const OUString& rStrImpValue,
766 Any& rValue,
767 const SvXMLUnitConverter& ) const
769 bool bRet = true;
770 bool bVal = false;
771 if( ! IsXMLToken( rStrImpValue, XML_NONE ) )
773 bRet = false;
774 SvXMLTokenEnumerator aTokenEnum( rStrImpValue );
775 std::u16string_view aToken;
776 while( aTokenEnum.getNextToken( aToken ) )
778 bRet = true;
779 if( aToken == sVal ||
780 (bHori && IsXMLToken( aToken, XML_HORIZONTAL ) ) )
782 bVal = true;
783 break;
788 if( bRet )
789 rValue <<= bVal;
791 return bRet;
794 bool XMLGrfMirrorPropHdl_Impl::exportXML(
795 OUString& rStrExpValue,
796 const Any& rValue,
797 const SvXMLUnitConverter& ) const
799 if( *o3tl::doAccess<bool>(rValue) )
801 if( rStrExpValue.isEmpty() ||
802 IsXMLToken( rStrExpValue, XML_NONE ) )
804 rStrExpValue = sVal;
806 else if( bHori &&
807 /* XML_HORIZONTAL_ON_LEFT_PAGES and XML_HORIZONTAL_ON_RIGHT_PAGES
808 are replaced by XML_HORIZONTAL_ON_EVEN and XML_HORIZONTAL_ON_ODD.
809 (#i49139#)
811 ( IsXMLToken( rStrExpValue, XML_HORIZONTAL_ON_EVEN ) ||
812 IsXMLToken( rStrExpValue, XML_HORIZONTAL_ON_ODD ) ))
814 rStrExpValue = GetXMLToken( XML_HORIZONTAL );
816 else
818 rStrExpValue += " " + sVal;
821 else if( rStrExpValue.isEmpty() )
823 rStrExpValue = GetXMLToken( XML_NONE );
826 return true;
829 SvXMLEnumMapEntry<sal_uInt16> const pXML_Emphasize_Enum[] =
831 { XML_NONE, FontEmphasis::NONE },
832 { XML_DOT, FontEmphasis::DOT_ABOVE },
833 { XML_CIRCLE, FontEmphasis::CIRCLE_ABOVE },
834 { XML_DISC, FontEmphasis::DISK_ABOVE },
835 { XML_ACCENT, FontEmphasis::ACCENT_ABOVE },
836 { XML_TOKEN_INVALID, 0 }
839 namespace {
841 class XMLTextEmphasizePropHdl_Impl : public XMLPropertyHandler
843 public:
844 XMLTextEmphasizePropHdl_Impl() {}
846 virtual bool importXML(
847 const OUString& rStrImpValue,
848 css::uno::Any& rValue,
849 const SvXMLUnitConverter& ) const override;
850 virtual bool exportXML(
851 OUString& rStrExpValue,
852 const css::uno::Any& rValue,
853 const SvXMLUnitConverter& ) const override;
858 bool XMLTextEmphasizePropHdl_Impl::importXML(
859 const OUString& rStrImpValue,
860 Any& rValue,
861 const SvXMLUnitConverter& ) const
863 bool bRet = true;
864 sal_uInt16 nVal = FontEmphasis::NONE;
865 bool bBelow = false;
866 bool bHasPos = false, bHasType = false;
867 std::u16string_view aToken;
869 SvXMLTokenEnumerator aTokenEnum( rStrImpValue );
870 while( aTokenEnum.getNextToken( aToken ) )
872 if( !bHasPos && IsXMLToken( aToken, XML_ABOVE ) )
874 bBelow = false;
875 bHasPos = true;
877 else if( !bHasPos && IsXMLToken( aToken, XML_BELOW ) )
879 bBelow = true;
880 bHasPos = true;
882 else if( !bHasType &&
883 SvXMLUnitConverter::convertEnum( nVal, aToken,
884 pXML_Emphasize_Enum ))
886 bHasType = true;
888 else
890 bRet = false;
891 break;
895 if( bRet )
897 if( FontEmphasis::NONE != nVal && bBelow )
898 nVal += 10;
899 rValue <<= static_cast<sal_Int16>(nVal);
902 return bRet;
905 bool XMLTextEmphasizePropHdl_Impl::exportXML(
906 OUString& rStrExpValue,
907 const Any& rValue,
908 const SvXMLUnitConverter& ) const
910 OUStringBuffer aOut( 15 );
911 bool bRet = true;
912 sal_uInt16 nType = sal_uInt16();
913 if( rValue >>= nType )
915 bool bBelow = false;
916 if( nType > 10 )
918 bBelow = true;
919 nType -= 10;
921 bRet = SvXMLUnitConverter::convertEnum( aOut, nType,
922 pXML_Emphasize_Enum,
923 XML_DOT );
924 if( bRet )
926 if( nType != 0 )
928 enum XMLTokenEnum ePos = bBelow ? XML_BELOW : XML_ABOVE;
929 aOut.append( " " + GetXMLToken(ePos) );
931 rStrExpValue = aOut.makeStringAndClear();
935 return bRet;
938 namespace {
940 class XMLTextCombineCharPropHdl_Impl : public XMLPropertyHandler
942 public:
943 XMLTextCombineCharPropHdl_Impl() {}
945 virtual bool importXML(
946 const OUString& rStrImpValue,
947 css::uno::Any& rValue,
948 const SvXMLUnitConverter& ) const override;
949 virtual bool exportXML(
950 OUString& rStrExpValue,
951 const css::uno::Any& rValue,
952 const SvXMLUnitConverter& ) const override;
957 bool XMLTextCombineCharPropHdl_Impl::importXML(
958 const OUString& rStrImpValue,
959 Any& rValue,
960 const SvXMLUnitConverter& ) const
962 if( !rStrImpValue.isEmpty() )
963 rValue <<= rStrImpValue.copy( 0, 1 );
964 else
965 rValue <<= rStrImpValue;
967 return true;
970 bool XMLTextCombineCharPropHdl_Impl::exportXML(
971 OUString& rStrExpValue,
972 const Any& rValue,
973 const SvXMLUnitConverter& ) const
975 rValue >>= rStrExpValue;
977 // #i114107# attribute of type "character": export only if length is 1
978 return (1 == rStrExpValue.getLength());
981 namespace {
983 class XMLTextRelWidthHeightPropHdl_Impl : public XMLPropertyHandler
985 public:
986 XMLTextRelWidthHeightPropHdl_Impl() {}
988 virtual bool importXML(
989 const OUString& rStrImpValue,
990 css::uno::Any& rValue,
991 const SvXMLUnitConverter& ) const override;
992 virtual bool exportXML(
993 OUString& rStrExpValue,
994 const css::uno::Any& rValue,
995 const SvXMLUnitConverter& ) const override;
1000 bool XMLTextRelWidthHeightPropHdl_Impl::importXML(
1001 const OUString& rStrImpValue,
1002 Any& rValue,
1003 const SvXMLUnitConverter& ) const
1005 sal_Int32 nValue;
1006 bool const bRet = ::sax::Converter::convertPercent( nValue, rStrImpValue );
1007 if( bRet )
1008 rValue <<= static_cast<sal_Int16>(nValue);
1010 return bRet;
1013 bool XMLTextRelWidthHeightPropHdl_Impl::exportXML(
1014 OUString& rStrExpValue,
1015 const Any& rValue,
1016 const SvXMLUnitConverter& ) const
1018 bool bRet = false;
1019 sal_Int16 nValue = sal_Int16();
1020 if( (rValue >>= nValue) && nValue > 0 )
1022 OUStringBuffer aOut;
1023 ::sax::Converter::convertPercent( aOut, nValue );
1024 rStrExpValue = aOut.makeStringAndClear();
1026 bRet = true;
1029 return bRet;
1032 namespace {
1034 class XMLTextSyncWidthHeightPropHdl_Impl : public XMLPropertyHandler
1036 const OUString sValue;
1038 public:
1039 explicit XMLTextSyncWidthHeightPropHdl_Impl( enum XMLTokenEnum eValue ) :
1040 sValue( GetXMLToken(eValue) ) {}
1042 virtual bool importXML(
1043 const OUString& rStrImpValue,
1044 css::uno::Any& rValue,
1045 const SvXMLUnitConverter& ) const override;
1046 virtual bool exportXML(
1047 OUString& rStrExpValue,
1048 const css::uno::Any& rValue,
1049 const SvXMLUnitConverter& ) const override;
1054 bool XMLTextSyncWidthHeightPropHdl_Impl::importXML(
1055 const OUString& rStrImpValue,
1056 Any& rValue,
1057 const SvXMLUnitConverter& ) const
1059 rValue <<= (rStrImpValue == sValue);
1061 return true;
1064 bool XMLTextSyncWidthHeightPropHdl_Impl::exportXML(
1065 OUString& rStrExpValue,
1066 const Any& rValue,
1067 const SvXMLUnitConverter& ) const
1069 bool bRet = false;
1070 if( *o3tl::doAccess<bool>(rValue) )
1072 rStrExpValue = sValue;
1073 bRet = true;
1076 return bRet;
1079 namespace {
1081 class XMLTextRotationAnglePropHdl_Impl : public XMLPropertyHandler
1084 public:
1085 XMLTextRotationAnglePropHdl_Impl() {}
1087 virtual bool importXML(
1088 const OUString& rStrImpValue,
1089 css::uno::Any& rValue,
1090 const SvXMLUnitConverter& ) const override;
1091 virtual bool exportXML(
1092 OUString& rStrExpValue,
1093 const css::uno::Any& rValue,
1094 const SvXMLUnitConverter& ) const override;
1099 bool XMLTextRotationAnglePropHdl_Impl::importXML(
1100 const OUString& rStrImpValue,
1101 Any& rValue,
1102 const SvXMLUnitConverter& ) const
1104 sal_Int32 nValue;
1105 bool const bRet = ::sax::Converter::convertNumber( nValue, rStrImpValue );
1106 if( bRet )
1108 nValue = (nValue % 360 );
1109 if( nValue < 0 )
1110 nValue = 360 + nValue;
1111 sal_Int16 nAngle;
1112 if( nValue < 45 || nValue > 315 )
1113 nAngle = 0;
1114 else if( nValue < 180 )
1115 nAngle = 900;
1116 else /* if nValue <= 315 ) */
1117 nAngle = 2700;
1118 rValue <<= nAngle;
1121 return bRet;
1124 bool XMLTextRotationAnglePropHdl_Impl::exportXML(
1125 OUString& rStrExpValue,
1126 const Any& rValue,
1127 const SvXMLUnitConverter& ) const
1129 sal_Int16 nAngle = sal_Int16();
1130 bool bRet = ( rValue >>= nAngle );
1131 if( bRet )
1133 rStrExpValue = OUString::number( nAngle / 10 );
1135 OSL_ENSURE( bRet, "illegal rotation angle" );
1137 return bRet;
1140 namespace {
1142 class XMLNumber8OneBasedHdl : public XMLPropertyHandler
1145 public:
1146 XMLNumber8OneBasedHdl() {}
1148 virtual bool importXML(
1149 const OUString& rStrImpValue,
1150 css::uno::Any& rValue,
1151 const SvXMLUnitConverter& ) const override;
1152 virtual bool exportXML(
1153 OUString& rStrExpValue,
1154 const css::uno::Any& rValue,
1155 const SvXMLUnitConverter& ) const override;
1160 bool XMLNumber8OneBasedHdl::importXML(
1161 const OUString& rStrImpValue,
1162 Any& rValue,
1163 const SvXMLUnitConverter& ) const
1165 sal_Int32 nValue = 0;
1166 bool const bRet = ::sax::Converter::convertNumber(nValue, rStrImpValue);
1167 if( bRet )
1168 rValue <<= static_cast<sal_Int8>( nValue - 1 );
1169 return bRet;
1172 bool XMLNumber8OneBasedHdl::exportXML(
1173 OUString& rStrExpValue,
1174 const Any& rValue,
1175 const SvXMLUnitConverter& ) const
1177 sal_Int8 nValue = sal_Int8();
1178 bool bRet = ( rValue >>= nValue );
1179 if( bRet )
1181 rStrExpValue = OUString::number( nValue + 1 );
1183 return bRet;
1186 namespace {
1188 class XMLGraphicPropertyHandler : public XMLPropertyHandler
1190 public:
1191 XMLGraphicPropertyHandler() {}
1193 virtual bool importXML(const OUString& , uno::Any& , const SvXMLUnitConverter& ) const override
1195 SAL_WARN( "xmloff", "drop caps are an element import property" );
1196 return false;
1199 virtual bool exportXML(OUString& , const uno::Any& , const SvXMLUnitConverter& ) const override
1201 SAL_WARN( "xmloff", "drop caps are an element import property" );
1202 return false;
1205 virtual bool equals(const css::uno::Any& rAny1, const css::uno::Any& rAny2) const override;
1210 bool XMLGraphicPropertyHandler::equals(const Any& rAny1, const Any& rAny2) const
1212 uno::Reference<graphic::XGraphic> xGraphic1;
1213 uno::Reference<graphic::XGraphic> xGraphic2;
1214 rAny1 >>= xGraphic1;
1215 rAny2 >>= xGraphic2;
1216 Graphic aGraphic1(xGraphic1);
1217 Graphic aGraphic2(xGraphic2);
1219 return aGraphic1 == aGraphic2;
1222 static const XMLPropertyHandler *GetPropertyHandler
1223 ( sal_Int32 nType )
1225 const XMLPropertyHandler* pHdl = nullptr;
1226 switch( nType )
1228 case XML_TYPE_TEXT_DROPCAP:
1229 pHdl = new XMLDropCapPropHdl_Impl;
1230 break;
1231 case XML_TYPE_TEXT_WRAP:
1232 pHdl = new XMLWrapPropHdl_Impl;
1233 break;
1234 case XML_TYPE_TEXT_PARAGRAPH_ONLY:
1235 pHdl = new XMLParagraphOnlyPropHdl_Impl;
1236 break;
1237 case XML_TYPE_TEXT_WRAP_OUTSIDE:
1238 pHdl = new XMLContourModePropHdl_Impl;
1239 break;
1240 case XML_TYPE_TEXT_OPAQUE:
1241 pHdl = new XMLOpaquePropHdl_Impl;
1242 break;
1243 case XML_TYPE_TEXT_PROTECT_CONTENT:
1244 pHdl = new XMLFrameProtectPropHdl_Impl( XML_CONTENT );
1245 break;
1246 case XML_TYPE_TEXT_PROTECT_SIZE:
1247 pHdl = new XMLFrameProtectPropHdl_Impl( XML_SIZE );
1248 break;
1249 case XML_TYPE_TEXT_PROTECT_POSITION:
1250 pHdl = new XMLFrameProtectPropHdl_Impl( XML_POSITION );
1251 break;
1252 case XML_TYPE_TEXT_ANCHOR_TYPE:
1253 pHdl = new XMLAnchorTypePropHdl;
1254 break;
1255 case XML_TYPE_TEXT_COLUMNS:
1256 pHdl = new XMLTextColumnsPropertyHandler;
1257 break;
1258 case XML_TYPE_TEXT_HORIZONTAL_POS:
1259 pHdl = new XMLConstantsPropertyHandler( pXML_HoriPos_Enum, XML_TOKEN_INVALID );
1260 break;
1261 case XML_TYPE_TEXT_HORIZONTAL_POS_MIRRORED:
1262 pHdl = new XMLConstantsPropertyHandler( pXML_HoriPosMirrored_Enum, XML_TOKEN_INVALID );
1263 break;
1264 case XML_TYPE_TEXT_HORIZONTAL_REL:
1265 pHdl = new XMLConstantsPropertyHandler( pXML_HoriRel_Enum, XML_TOKEN_INVALID );
1266 break;
1267 case XML_TYPE_TEXT_HORIZONTAL_REL_FRAME:
1268 pHdl = new XMLConstantsPropertyHandler( pXML_HoriRelFrame_Enum, XML_TOKEN_INVALID );
1269 break;
1270 case XML_TYPE_TEXT_HORIZONTAL_MIRROR:
1271 pHdl = new XMLHoriMirrorPropHdl_Impl;
1272 break;
1273 case XML_TYPE_TEXT_VERTICAL_POS_AT_CHAR:
1274 pHdl = new XMLConstantsPropertyHandler( pXML_VertPosAtChar_Enum, XML_TOKEN_INVALID );
1275 break;
1276 case XML_TYPE_TEXT_VERTICAL_REL:
1277 pHdl = new XMLConstantsPropertyHandler( pXML_VertRel_Enum, XML_TOKEN_INVALID );
1278 break;
1279 case XML_TYPE_TEXT_VERTICAL_REL_PAGE:
1280 pHdl = new XMLConstantsPropertyHandler( pXML_VertRelPage_Enum, XML_TOKEN_INVALID );
1281 break;
1282 case XML_TYPE_TEXT_VERTICAL_REL_FRAME:
1283 pHdl = new XMLConstantsPropertyHandler( pXML_VertRelFrame_Enum, XML_TOKEN_INVALID );
1284 break;
1285 case XML_TYPE_TEXT_VERTICAL_REL_AS_CHAR:
1286 pHdl = new XMLConstantsPropertyHandler( pXML_VertRelAsChar_Enum, XML_TOKEN_INVALID );
1287 break;
1288 case XML_TYPE_TEXT_MIRROR_VERTICAL:
1289 pHdl = new XMLGrfMirrorPropHdl_Impl( XML_VERTICAL, false );
1290 break;
1291 case XML_TYPE_TEXT_MIRROR_HORIZONTAL_LEFT:
1292 // XML_HORIZONTAL_ON_LEFT_PAGES is replaced by XML_HORIZONTAL_ON_EVEN. (#i49139#)
1293 pHdl = new XMLGrfMirrorPropHdl_Impl( XML_HORIZONTAL_ON_EVEN, true );
1294 break;
1295 case XML_TYPE_TEXT_MIRROR_HORIZONTAL_RIGHT:
1296 // XML_HORIZONTAL_ON_RIGHT_PAGES is replaced by XML_HORIZONTAL_ON_ODD. (#i49139#)
1297 pHdl = new XMLGrfMirrorPropHdl_Impl( XML_HORIZONTAL_ON_ODD, true );
1298 break;
1299 case XML_TYPE_TEXT_CLIP:
1300 pHdl = new XMLClipPropertyHandler( false );
1301 break;
1302 case XML_TYPE_TEXT_CLIP11:
1303 pHdl = new XMLClipPropertyHandler( true );
1304 break;
1305 case XML_TYPE_TEXT_EMPHASIZE:
1306 pHdl = new XMLTextEmphasizePropHdl_Impl;
1307 break;
1308 case XML_TYPE_TEXT_COMBINE:
1309 pHdl = new XMLNamedBoolPropertyHdl( GetXMLToken( XML_LINES ),
1310 GetXMLToken( XML_NONE ) );
1311 break;
1312 case XML_TYPE_TEXT_COMBINE_CHARACTERS:
1313 pHdl = new XMLNamedBoolPropertyHdl( GetXMLToken( XML_LETTERS ),
1314 GetXMLToken( XML_NONE ) );
1315 break;
1316 case XML_TYPE_TEXT_COMBINECHAR:
1317 pHdl = new XMLTextCombineCharPropHdl_Impl;
1318 break;
1319 case XML_TYPE_TEXT_AUTOSPACE:
1320 pHdl = new XMLNamedBoolPropertyHdl( GetXMLToken( XML_IDEOGRAPH_ALPHA ),
1321 GetXMLToken( XML_NONE ) );
1322 break;
1323 case XML_TYPE_TEXT_PUNCTUATION_WRAP:
1324 pHdl = new XMLNamedBoolPropertyHdl( GetXMLToken( XML_HANGING ),
1325 GetXMLToken( XML_SIMPLE ) );
1326 break;
1327 case XML_TYPE_TEXT_LINE_BREAK:
1328 pHdl = new XMLNamedBoolPropertyHdl( GetXMLToken( XML_STRICT ),
1329 GetXMLToken( XML_NORMAL ) );
1330 break;
1331 case XML_TYPE_TEXT_REL_WIDTH_HEIGHT:
1332 pHdl = new XMLTextRelWidthHeightPropHdl_Impl;
1333 break;
1334 case XML_TYPE_TEXT_SYNC_WIDTH_HEIGHT:
1335 pHdl = new XMLTextSyncWidthHeightPropHdl_Impl( XML_SCALE );
1336 break;
1337 case XML_TYPE_TEXT_SYNC_WIDTH_HEIGHT_MIN:
1338 pHdl = new XMLTextSyncWidthHeightPropHdl_Impl( XML_SCALE_MIN );
1339 break;
1340 case XML_TYPE_TEXT_RUBY_ADJUST:
1341 pHdl = new XMLConstantsPropertyHandler( pXML_RubyAdjust_Enum, XML_TOKEN_INVALID );
1342 break;
1343 case XML_TYPE_TEXT_FONT_RELIEF:
1344 pHdl = new XMLConstantsPropertyHandler( pXML_FontRelief_Enum, XML_TOKEN_INVALID );
1345 break;
1346 case XML_TYPE_TEXT_ROTATION_ANGLE:
1347 pHdl = new XMLTextRotationAnglePropHdl_Impl;
1348 break;
1349 case XML_TYPE_TEXT_ROTATION_SCALE:
1350 pHdl = new XMLNamedBoolPropertyHdl( GetXMLToken( XML_FIXED ),
1351 GetXMLToken( XML_LINE_HEIGHT ) );
1352 break;
1353 case XML_TYPE_TEXT_VERTICAL_ALIGN:
1354 pHdl = new XMLConstantsPropertyHandler( pXML_ParaVerticalAlign_Enum, XML_TOKEN_INVALID );
1355 break;
1356 case XML_TYPE_TEXT_RUBY_POSITION:
1357 pHdl = new XMLConstantsPropertyHandler( pXML_RubyPosition_Enum, XML_TOKEN_INVALID );
1358 break;
1359 case XML_TYPE_TEXT_RUBY_IS_ABOVE:
1360 pHdl = new XMLNamedBoolPropertyHdl(::xmloff::token::XML_ABOVE, ::xmloff::token::XML_BELOW);
1361 break;
1362 // OD 2004-05-05 #i28701#
1363 case XML_TYPE_WRAP_INFLUENCE_ON_POSITION:
1364 pHdl = new XMLConstantsPropertyHandler( pXML_WrapInfluenceOnPosition_Enum,
1365 XML_TOKEN_INVALID );
1366 break;
1367 case XML_TYPE_BORDER_MODEL:
1368 pHdl = new XMLNamedBoolPropertyHdl( xmloff::token::XML_COLLAPSING,
1369 xmloff::token::XML_SEPARATING );
1370 break;
1371 case XML_TYPE_TEXT_LINE_MODE:
1372 pHdl = new XMLNamedBoolPropertyHdl(
1373 ::xmloff::token::XML_SKIP_WHITE_SPACE,
1374 ::xmloff::token::XML_CONTINUOUS);
1375 break;
1376 case XML_TYPE_TEXT_KEEP:
1377 pHdl = new XMLNamedBoolPropertyHdl(
1378 ::xmloff::token::XML_ALWAYS,
1379 ::xmloff::token::XML_AUTO);
1380 break;
1381 case XML_TYPE_TEXT_NKEEP:
1382 pHdl = new XMLNamedBoolPropertyHdl(
1383 ::xmloff::token::XML_AUTO,
1384 ::xmloff::token::XML_ALWAYS);
1385 break;
1386 case XML_TYPE_TEXT_NUMBER8_ONE_BASED:
1387 pHdl = new XMLNumber8OneBasedHdl();
1388 break;
1389 case XML_TYPE_VERTICAL_ALIGN:
1390 pHdl = new XMLConstantsPropertyHandler( pXML_VerticalAlign_Enum, XML_TOKEN_INVALID );
1391 break;
1393 case XML_SW_TYPE_FILLSTYLE:
1394 pHdl = new XMLEnumPropertyHdl( aXML_FillStyle_EnumMap);
1395 break;
1396 case XML_SW_TYPE_FILLBITMAPSIZE:
1397 pHdl = new XMLFillBitmapSizePropertyHandler();
1398 break;
1399 case XML_SW_TYPE_LOGICAL_SIZE:
1400 pHdl = new XMLBitmapLogicalSizePropertyHandler();
1401 break;
1402 case XML_SW_TYPE_BITMAP_REFPOINT:
1403 pHdl = new XMLEnumPropertyHdl( aXML_RefPoint_EnumMap);
1404 break;
1405 case XML_SW_TYPE_BITMAP_MODE:
1406 pHdl = new XMLEnumPropertyHdl( aXML_BitmapMode_EnumMap);
1407 break;
1408 case XML_SW_TYPE_BITMAPREPOFFSETX:
1409 case XML_SW_TYPE_BITMAPREPOFFSETY:
1410 pHdl = new XMLBitmapRepeatOffsetPropertyHandler(XML_SW_TYPE_BITMAPREPOFFSETX == nType);
1411 break;
1412 case XML_TYPE_GRAPHIC:
1413 pHdl = new XMLGraphicPropertyHandler;
1414 break;
1415 case XML_TYPE_COMPLEX_COLOR:
1416 pHdl = new XMLComplexColorHandler;
1417 break;
1418 default:
1420 OSL_ENSURE(false, "XMLPropertyHandler missing (!)");
1421 break;
1425 return pHdl;
1428 XMLTextPropertyHandlerFactory::XMLTextPropertyHandlerFactory()
1432 const XMLPropertyHandler *XMLTextPropertyHandlerFactory::GetPropertyHandler(
1433 sal_Int32 nType ) const
1435 const XMLPropertyHandler *pHdl =
1436 XMLPropertyHandlerFactory::GetPropertyHandler( nType );
1438 if( !pHdl )
1440 const XMLPropertyHandler *pNewHdl = ::GetPropertyHandler( nType );
1442 if( pNewHdl )
1443 PutHdlCache( nType, pNewHdl );
1445 pHdl = pNewHdl;
1448 return pHdl;
1451 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */