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