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