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