1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: prhdlfac.cxx,v $
10 * $Revision: 1.30.68.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmloff.hxx"
33 #include <com/sun/star/drawing/ColorMode.hpp>
34 #include <com/sun/star/text/HorizontalAdjust.hpp>
35 #include <com/sun/star/text/WritingMode2.hpp>
36 #include <tools/debug.hxx>
37 #include <xmloff/prhdlfac.hxx>
38 #include <xmloff/xmltypes.hxx>
39 #include <xmloff/xmltoken.hxx>
40 #include "xmlbahdl.hxx"
41 #include <xmloff/NamedBoolPropertyHdl.hxx>
42 #include <xmloff/XMLConstantsPropertyHandler.hxx>
43 #include "cdouthdl.hxx"
44 #include "csmaphdl.hxx"
45 #ifndef _XMLOFF_PROPERTYHANDLER_FONTTYPES_HXX
46 #include "fonthdl.hxx"
48 #include "kernihdl.hxx"
49 #include <postuhdl.hxx>
50 #include "shadwhdl.hxx"
51 #include "shdwdhdl.hxx"
52 #include "undlihdl.hxx"
53 #include "weighhdl.hxx"
54 #include "breakhdl.hxx"
55 #include <adjushdl.hxx>
56 #include <escphdl.hxx>
57 #include <chrhghdl.hxx>
58 #include <chrlohdl.hxx>
59 #include <lspachdl.hxx>
60 #include <bordrhdl.hxx>
61 #include <tabsthdl.hxx>
62 #include <xmloff/EnumPropertyHdl.hxx>
63 #include "AttributeContainerHandler.hxx"
64 #include "durationhdl.hxx"
65 #include "XMLRectangleMembersHandler.hxx"
66 #include "DrawAspectHdl.hxx"
68 using namespace ::com::sun::star
;
69 using namespace ::xmloff::token
;
71 SvXMLEnumMapEntry aXML_ColorMode_EnumMap
[] =
73 { XML_GREYSCALE
, drawing::ColorMode_GREYS
},
74 { XML_MONO
, drawing::ColorMode_MONO
},
75 { XML_WATERMARK
, drawing::ColorMode_WATERMARK
},
76 { XML_STANDARD
, drawing::ColorMode_STANDARD
},
77 { XML_TOKEN_INVALID
, 0 }
80 SvXMLEnumMapEntry __READONLY_DATA aXML_HorizontalAdjust_Enum
[] =
82 { XML_LEFT
, text::HorizontalAdjust_LEFT
},
83 { XML_CENTER
, text::HorizontalAdjust_CENTER
},
84 { XML_RIGHT
, text::HorizontalAdjust_RIGHT
},
85 { XML_TOKEN_INVALID
, 0 }
88 // aXML_WritingDirection_Enum is used with and without 'page'
89 // attribute, so you'll find uses of aXML_WritingDirection_Enum
90 // directly, as well as &(aXML_WritingDirection_Enum[1])
91 SvXMLEnumMapEntry __READONLY_DATA aXML_WritingDirection_Enum
[] =
93 // aXML_WritingDirection_Enum
94 { XML_PAGE
, text::WritingMode2::PAGE
},
96 // &(aXML_WritingDirection_Enum[1])
97 { XML_LR_TB
, text::WritingMode2::LR_TB
},
98 { XML_RL_TB
, text::WritingMode2::RL_TB
},
99 { XML_TB_RL
, text::WritingMode2::TB_RL
},
100 { XML_TB_LR
, text::WritingMode2::TB_LR
},
102 // alternative names of the above, as accepted by XSL
103 { XML_LR
, text::WritingMode2::LR_TB
},
104 { XML_RL
, text::WritingMode2::RL_TB
},
105 { XML_TB
, text::WritingMode2::TB_RL
},
107 { XML_TOKEN_INVALID
, 0 }
111 ///////////////////////////////////////////////////////////////////////////
115 XMLPropertyHandlerFactory::~XMLPropertyHandlerFactory()
117 for( CacheMap::iterator pPos
= maHandlerCache
.begin(); pPos
!= maHandlerCache
.end(); pPos
++ )
121 ///////////////////////////////////////////////////////////////////////////
125 const XMLPropertyHandler
* XMLPropertyHandlerFactory::GetPropertyHandler( sal_Int32 nType
) const
127 DBG_ASSERT( (nType
& ~((sal_uInt32
)MID_FLAG_MASK
)) == 0,
128 "GetPropertyHandler called with flags in type" );
129 return GetBasicHandler( nType
);
132 ///////////////////////////////////////////////////////////////////////////
134 // Helper-methods to create and cache PropertyHandler
136 XMLPropertyHandler
* XMLPropertyHandlerFactory::GetHdlCache( sal_Int32 nType
) const
138 XMLPropertyHandler
* pRet
= NULL
;
140 if( maHandlerCache
.find( nType
) != maHandlerCache
.end() )
141 pRet
= maHandlerCache
.find( nType
)->second
;
146 void XMLPropertyHandlerFactory::PutHdlCache( sal_Int32 nType
, const XMLPropertyHandler
* pHdl
) const
148 // Don't be wondered about the following construct. The sense is to be able to provide a const-
149 // method as class-interface.
150 ((XMLPropertyHandlerFactory
*)this)->maHandlerCache
[ nType
] = (XMLPropertyHandler
*)pHdl
;
153 const XMLPropertyHandler
* XMLPropertyHandlerFactory::GetBasicHandler( sal_Int32 nType
) const
155 const XMLPropertyHandler
* pPropHdl
= GetHdlCache( nType
);
159 pPropHdl
= CreatePropertyHandler( nType
);
162 PutHdlCache( nType
, pPropHdl
);
168 const XMLPropertyHandler
* XMLPropertyHandlerFactory::CreatePropertyHandler( sal_Int32 nType
)
170 XMLPropertyHandler
* pPropHdl
= NULL
;
175 pPropHdl
= new XMLBoolPropHdl
;
177 case XML_TYPE_MEASURE
:
178 pPropHdl
= new XMLMeasurePropHdl( 4 );
180 case XML_TYPE_MEASURE8
:
181 pPropHdl
= new XMLMeasurePropHdl( 1 );
183 case XML_TYPE_MEASURE16
:
184 pPropHdl
= new XMLMeasurePropHdl( 2 );
186 case XML_TYPE_PERCENT
:
187 pPropHdl
= new XMLPercentPropHdl( 4 );
189 case XML_TYPE_PERCENT8
:
190 pPropHdl
= new XMLPercentPropHdl( 1 );
192 case XML_TYPE_PERCENT16
:
193 pPropHdl
= new XMLPercentPropHdl( 2 );
195 case XML_TYPE_DOUBLE_PERCENT
:
196 pPropHdl
= new XMLDoublePercentPropHdl();
198 case XML_TYPE_NEG_PERCENT
:
199 pPropHdl
= new XMLNegPercentPropHdl( 4 );
201 case XML_TYPE_NEG_PERCENT8
:
202 pPropHdl
= new XMLNegPercentPropHdl( 1 );
204 case XML_TYPE_NEG_PERCENT16
:
205 pPropHdl
= new XMLNegPercentPropHdl( 2 );
207 case XML_TYPE_MEASURE_PX
:
208 pPropHdl
= new XMLMeasurePxPropHdl( 4 );
210 case XML_TYPE_STRING
:
211 pPropHdl
= new XMLStringPropHdl
;
213 case XML_TYPE_COLOR
:
214 pPropHdl
= new XMLColorPropHdl
;
216 case XML_TYPE_NUMBER
:
217 pPropHdl
= new XMLNumberPropHdl( 4 );
219 case XML_TYPE_NUMBER8
:
220 pPropHdl
= new XMLNumberPropHdl( 1 );
222 case XML_TYPE_NUMBER16
:
223 pPropHdl
= new XMLNumberPropHdl( 2 );
225 case XML_TYPE_NUMBER_NONE
:
226 pPropHdl
= new XMLNumberNonePropHdl
;
228 case XML_TYPE_NUMBER8_NONE
:
229 pPropHdl
= new XMLNumberNonePropHdl( 1 );
231 case XML_TYPE_NUMBER16_NONE
:
232 pPropHdl
= new XMLNumberNonePropHdl( 2 );
234 case XML_TYPE_DOUBLE
:
235 pPropHdl
= new XMLDoublePropHdl
;
237 case XML_TYPE_NBOOL
:
238 pPropHdl
= new XMLNBoolPropHdl
;
240 case XML_TYPE_COLORTRANSPARENT
:
241 pPropHdl
= new XMLColorTransparentPropHdl
;
243 case XML_TYPE_ISTRANSPARENT
:
244 pPropHdl
= new XMLIsTransparentPropHdl
;
246 case XML_TYPE_COLORAUTO
:
247 pPropHdl
= new XMLColorAutoPropHdl
;
249 case XML_TYPE_ISAUTOCOLOR
:
250 pPropHdl
= new XMLIsAutoColorPropHdl
;
252 case XML_TYPE_BUILDIN_CMP_ONLY
:
253 pPropHdl
= new XMLCompareOnlyPropHdl
;
256 case XML_TYPE_RECTANGLE_LEFT
:
257 case XML_TYPE_RECTANGLE_TOP
:
258 case XML_TYPE_RECTANGLE_WIDTH
:
259 case XML_TYPE_RECTANGLE_HEIGHT
:
260 pPropHdl
= new XMLRectangleMembersHdl( nType
);
263 case XML_TYPE_TEXT_CROSSEDOUT_TYPE
:
264 pPropHdl
= new XMLCrossedOutTypePropHdl
;
266 case XML_TYPE_TEXT_CROSSEDOUT_STYLE
:
267 pPropHdl
= new XMLCrossedOutStylePropHdl
;
269 case XML_TYPE_TEXT_CROSSEDOUT_WIDTH
:
270 pPropHdl
= new XMLCrossedOutWidthPropHdl
;
272 case XML_TYPE_TEXT_CROSSEDOUT_TEXT
:
273 pPropHdl
= new XMLCrossedOutTextPropHdl
;
275 case XML_TYPE_TEXT_BOOLCROSSEDOUT
:
276 pPropHdl
= new XMLNamedBoolPropertyHdl(
277 GetXMLToken(XML_SOLID
),
278 GetXMLToken(XML_NONE
) );
280 case XML_TYPE_TEXT_ESCAPEMENT
:
281 pPropHdl
= new XMLEscapementPropHdl
;
283 case XML_TYPE_TEXT_ESCAPEMENT_HEIGHT
:
284 pPropHdl
= new XMLEscapementHeightPropHdl
;
286 case XML_TYPE_TEXT_CASEMAP
:
287 pPropHdl
= new XMLCaseMapPropHdl
;
289 case XML_TYPE_TEXT_CASEMAP_VAR
:
290 pPropHdl
= new XMLCaseMapVariantHdl
;
292 case XML_TYPE_TEXT_FONTFAMILYNAME
:
293 pPropHdl
= new XMLFontFamilyNamePropHdl
;
295 case XML_TYPE_TEXT_FONTFAMILY
:
296 pPropHdl
= new XMLFontFamilyPropHdl
;
298 case XML_TYPE_TEXT_FONTENCODING
:
299 pPropHdl
= new XMLFontEncodingPropHdl
;
301 case XML_TYPE_TEXT_FONTPITCH
:
302 pPropHdl
= new XMLFontPitchPropHdl
;
304 case XML_TYPE_TEXT_KERNING
:
305 pPropHdl
= new XMLKerningPropHdl
;
307 case XML_TYPE_TEXT_POSTURE
:
308 pPropHdl
= new XMLPosturePropHdl
;
310 case XML_TYPE_TEXT_SHADOWED
:
311 pPropHdl
= new XMLShadowedPropHdl
;
313 case XML_TYPE_TEXT_UNDERLINE_TYPE
:
314 pPropHdl
= new XMLUnderlineTypePropHdl
;
316 case XML_TYPE_TEXT_UNDERLINE_STYLE
:
317 pPropHdl
= new XMLUnderlineStylePropHdl
;
319 case XML_TYPE_TEXT_UNDERLINE_WIDTH
:
320 pPropHdl
= new XMLUnderlineWidthPropHdl
;
322 case XML_TYPE_TEXT_UNDERLINE_COLOR
:
323 pPropHdl
= new XMLColorTransparentPropHdl( XML_FONT_COLOR
);
325 case XML_TYPE_TEXT_UNDERLINE_HASCOLOR
:
326 pPropHdl
= new XMLIsTransparentPropHdl( XML_FONT_COLOR
,
329 case XML_TYPE_TEXT_OVERLINE_TYPE
:
330 pPropHdl
= new XMLUnderlineTypePropHdl
;
332 case XML_TYPE_TEXT_OVERLINE_STYLE
:
333 pPropHdl
= new XMLUnderlineStylePropHdl
;
335 case XML_TYPE_TEXT_OVERLINE_WIDTH
:
336 pPropHdl
= new XMLUnderlineWidthPropHdl
;
338 case XML_TYPE_TEXT_OVERLINE_COLOR
:
339 pPropHdl
= new XMLColorTransparentPropHdl( XML_FONT_COLOR
);
341 case XML_TYPE_TEXT_OVERLINE_HASCOLOR
:
342 pPropHdl
= new XMLIsTransparentPropHdl( XML_FONT_COLOR
,
345 case XML_TYPE_TEXT_WEIGHT
:
346 pPropHdl
= new XMLFontWeightPropHdl
;
348 case XML_TYPE_TEXT_SPLIT
:
349 pPropHdl
= new XMLNamedBoolPropertyHdl(
350 GetXMLToken(XML_AUTO
),
351 GetXMLToken(XML_ALWAYS
) );
353 case XML_TYPE_TEXT_BREAKBEFORE
:
354 pPropHdl
= new XMLFmtBreakBeforePropHdl
;
356 case XML_TYPE_TEXT_BREAKAFTER
:
357 pPropHdl
= new XMLFmtBreakAfterPropHdl
;
359 case XML_TYPE_TEXT_SHADOW
:
360 pPropHdl
= new XMLShadowPropHdl
;
362 case XML_TYPE_TEXT_ADJUST
:
363 pPropHdl
= new XMLParaAdjustPropHdl
;
365 case XML_TYPE_TEXT_ADJUSTLAST
:
366 pPropHdl
= new XMLLastLineAdjustPropHdl
;
368 case XML_TYPE_CHAR_HEIGHT
:
369 pPropHdl
= new XMLCharHeightHdl
;
371 case XML_TYPE_CHAR_HEIGHT_PROP
:
372 pPropHdl
= new XMLCharHeightPropHdl
;
374 case XML_TYPE_CHAR_HEIGHT_DIFF
:
375 pPropHdl
= new XMLCharHeightDiffHdl
;
377 case XML_TYPE_CHAR_LANGUAGE
:
378 pPropHdl
= new XMLCharLanguageHdl
;
380 case XML_TYPE_CHAR_COUNTRY
:
381 pPropHdl
= new XMLCharCountryHdl
;
383 case XML_TYPE_LINE_SPACE_FIXED
:
384 pPropHdl
= new XMLLineHeightHdl
;
386 case XML_TYPE_LINE_SPACE_MINIMUM
:
387 pPropHdl
= new XMLLineHeightAtLeastHdl
;
389 case XML_TYPE_LINE_SPACE_DISTANCE
:
390 pPropHdl
= new XMLLineSpacingHdl
;
392 case XML_TYPE_BORDER_WIDTH
:
393 pPropHdl
= new XMLBorderWidthHdl
;
395 case XML_TYPE_BORDER
:
396 pPropHdl
= new XMLBorderHdl
;
398 case XML_TYPE_TEXT_TABSTOP
:
399 pPropHdl
= new XMLTabStopPropHdl
;
401 case XML_TYPE_ATTRIBUTE_CONTAINER
:
402 pPropHdl
= new XMLAttributeContainerHandler
;
404 case XML_TYPE_COLOR_MODE
:
405 pPropHdl
= new XMLEnumPropertyHdl( aXML_ColorMode_EnumMap
,
406 ::getCppuType((const drawing::ColorMode
*)0) );
408 case XML_TYPE_DURATION16_MS
:
409 pPropHdl
= new XMLDurationMS16PropHdl_Impl
;
411 case XML_TYPE_TEXT_HORIZONTAL_ADJUST
:
412 pPropHdl
= new XMLEnumPropertyHdl(
413 aXML_HorizontalAdjust_Enum
,
414 ::getCppuType((const text::HorizontalAdjust
*)0) );
416 case XML_TYPE_TEXT_DRAW_ASPECT
:
417 pPropHdl
= new DrawAspectHdl
;
419 case XML_TYPE_TEXT_WRITING_MODE
:
420 pPropHdl
= new XMLConstantsPropertyHandler(
421 &(aXML_WritingDirection_Enum
[1]),
424 case XML_TYPE_TEXT_WRITING_MODE_WITH_DEFAULT
:
425 pPropHdl
= new XMLConstantsPropertyHandler(
426 aXML_WritingDirection_Enum
,
429 case XML_TYPE_TEXT_HIDDEN_AS_DISPLAY
:
430 pPropHdl
= new XMLNamedBoolPropertyHdl(
431 GetXMLToken(XML_NONE
),
432 GetXMLToken(XML_TRUE
) );
434 case XML_TYPE_STYLENAME
:
435 pPropHdl
= new XMLStyleNamePropHdl
;
437 case XML_TYPE_NUMBER_NO_ZERO
:
438 pPropHdl
= new XMLNumberWithoutZeroPropHdl( 4 );
440 case XML_TYPE_NUMBER8_NO_ZERO
:
441 pPropHdl
= new XMLNumberWithoutZeroPropHdl( 1 );
443 case XML_TYPE_NUMBER16_NO_ZERO
:
444 pPropHdl
= new XMLNumberWithoutZeroPropHdl( 2 );
446 case XML_TYPE_NUMBER16_AUTO
:
447 pPropHdl
= new XMLNumberWithAutoInsteadZeroPropHdl();