1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <com/sun/star/drawing/ColorMode.hpp>
22 #include <com/sun/star/text/HorizontalAdjust.hpp>
23 #include <com/sun/star/text/WritingMode2.hpp>
25 #include <tools/debug.hxx>
27 #include <xmloff/prhdlfac.hxx>
28 #include <xmloff/xmltypes.hxx>
29 #include <xmloff/xmltoken.hxx>
30 #include "xmlbahdl.hxx"
31 #include <xmloff/NamedBoolPropertyHdl.hxx>
32 #include <xmloff/XMLConstantsPropertyHandler.hxx>
33 #include "cdouthdl.hxx"
34 #include "csmaphdl.hxx"
35 #include "fonthdl.hxx"
36 #include "kernihdl.hxx"
37 #include <postuhdl.hxx>
38 #include "shadwhdl.hxx"
39 #include "shdwdhdl.hxx"
40 #include "undlihdl.hxx"
41 #include "weighhdl.hxx"
42 #include "breakhdl.hxx"
43 #include <adjushdl.hxx>
44 #include <escphdl.hxx>
45 #include <chrhghdl.hxx>
46 #include <chrlohdl.hxx>
47 #include <lspachdl.hxx>
48 #include <bordrhdl.hxx>
49 #include <tabsthdl.hxx>
50 #include <xmloff/EnumPropertyHdl.hxx>
51 #include "AttributeContainerHandler.hxx"
52 #include "durationhdl.hxx"
53 #include "XMLRectangleMembersHandler.hxx"
54 #include "DrawAspectHdl.hxx"
56 using namespace ::com::sun::star
;
57 using namespace ::xmloff::token
;
59 SvXMLEnumMapEntry aXML_ColorMode_EnumMap
[] =
61 { XML_GREYSCALE
, drawing::ColorMode_GREYS
},
62 { XML_MONO
, drawing::ColorMode_MONO
},
63 { XML_WATERMARK
, drawing::ColorMode_WATERMARK
},
64 { XML_STANDARD
, drawing::ColorMode_STANDARD
},
65 { XML_TOKEN_INVALID
, 0 }
68 SvXMLEnumMapEntry
const aXML_HorizontalAdjust_Enum
[] =
70 { XML_LEFT
, text::HorizontalAdjust_LEFT
},
71 { XML_CENTER
, text::HorizontalAdjust_CENTER
},
72 { XML_RIGHT
, text::HorizontalAdjust_RIGHT
},
73 { XML_TOKEN_INVALID
, 0 }
76 // aXML_WritingDirection_Enum is used with and without 'page'
77 // attribute, so you'll find uses of aXML_WritingDirection_Enum
78 // directly, as well as &(aXML_WritingDirection_Enum[1])
79 SvXMLEnumMapEntry
const aXML_WritingDirection_Enum
[] =
81 // aXML_WritingDirection_Enum
82 { XML_PAGE
, text::WritingMode2::PAGE
},
84 // &(aXML_WritingDirection_Enum[1])
85 { XML_LR_TB
, text::WritingMode2::LR_TB
},
86 { XML_RL_TB
, text::WritingMode2::RL_TB
},
87 { XML_TB_RL
, text::WritingMode2::TB_RL
},
88 { XML_TB_LR
, text::WritingMode2::TB_LR
},
90 // alternative names of the above, as accepted by XSL
91 { XML_LR
, text::WritingMode2::LR_TB
},
92 { XML_RL
, text::WritingMode2::RL_TB
},
93 { XML_TB
, text::WritingMode2::TB_RL
},
95 { XML_TOKEN_INVALID
, 0 }
99 ///////////////////////////////////////////////////////////////////////////
103 XMLPropertyHandlerFactory::~XMLPropertyHandlerFactory()
105 for( CacheMap::iterator pPos
= maHandlerCache
.begin(); pPos
!= maHandlerCache
.end(); ++pPos
)
109 ///////////////////////////////////////////////////////////////////////////
113 const XMLPropertyHandler
* XMLPropertyHandlerFactory::GetPropertyHandler( sal_Int32 nType
) const
115 DBG_ASSERT( (nType
& ~((sal_uInt32
)MID_FLAG_MASK
)) == 0,
116 "GetPropertyHandler called with flags in type" );
117 return GetBasicHandler( nType
);
120 ///////////////////////////////////////////////////////////////////////////
122 // Helper-methods to create and cache PropertyHandler
124 XMLPropertyHandler
* XMLPropertyHandlerFactory::GetHdlCache( sal_Int32 nType
) const
126 XMLPropertyHandler
* pRet
= NULL
;
128 if( maHandlerCache
.find( nType
) != maHandlerCache
.end() )
129 pRet
= maHandlerCache
.find( nType
)->second
;
134 void XMLPropertyHandlerFactory::PutHdlCache( sal_Int32 nType
, const XMLPropertyHandler
* pHdl
) const
136 // Don't be wondered about the following construct. The sense is to be able to provide a const-
137 // method as class-interface.
138 ((XMLPropertyHandlerFactory
*)this)->maHandlerCache
[ nType
] = (XMLPropertyHandler
*)pHdl
;
141 const XMLPropertyHandler
* XMLPropertyHandlerFactory::GetBasicHandler( sal_Int32 nType
) const
143 const XMLPropertyHandler
* pPropHdl
= GetHdlCache( nType
);
147 pPropHdl
= CreatePropertyHandler( nType
);
150 PutHdlCache( nType
, pPropHdl
);
156 const XMLPropertyHandler
* XMLPropertyHandlerFactory::CreatePropertyHandler( sal_Int32 nType
)
158 XMLPropertyHandler
* pPropHdl
= NULL
;
163 pPropHdl
= new XMLBoolPropHdl
;
165 case XML_TYPE_BOOL_FALSE
:
166 pPropHdl
= new XMLBoolFalsePropHdl
;
168 case XML_TYPE_MEASURE
:
169 pPropHdl
= new XMLMeasurePropHdl( 4 );
171 case XML_TYPE_MEASURE8
:
172 pPropHdl
= new XMLMeasurePropHdl( 1 );
174 case XML_TYPE_MEASURE16
:
175 pPropHdl
= new XMLMeasurePropHdl( 2 );
177 case XML_TYPE_PERCENT
:
178 pPropHdl
= new XMLPercentPropHdl( 4 );
180 case XML_TYPE_PERCENT8
:
181 pPropHdl
= new XMLPercentPropHdl( 1 );
183 case XML_TYPE_PERCENT16
:
184 pPropHdl
= new XMLPercentPropHdl( 2 );
186 case XML_TYPE_DOUBLE_PERCENT
:
187 pPropHdl
= new XMLDoublePercentPropHdl();
189 case XML_TYPE_NEG_PERCENT
:
190 pPropHdl
= new XMLNegPercentPropHdl( 4 );
192 case XML_TYPE_NEG_PERCENT8
:
193 pPropHdl
= new XMLNegPercentPropHdl( 1 );
195 case XML_TYPE_NEG_PERCENT16
:
196 pPropHdl
= new XMLNegPercentPropHdl( 2 );
198 case XML_TYPE_MEASURE_PX
:
199 pPropHdl
= new XMLMeasurePxPropHdl( 4 );
201 case XML_TYPE_STRING
:
202 pPropHdl
= new XMLStringPropHdl
;
204 case XML_TYPE_COLOR
:
205 pPropHdl
= new XMLColorPropHdl
;
208 pPropHdl
= new XMLHexPropHdl
;
210 case XML_TYPE_NUMBER
:
211 pPropHdl
= new XMLNumberPropHdl( 4 );
213 case XML_TYPE_NUMBER8
:
214 pPropHdl
= new XMLNumberPropHdl( 1 );
216 case XML_TYPE_NUMBER16
:
217 pPropHdl
= new XMLNumberPropHdl( 2 );
219 case XML_TYPE_NUMBER_NONE
:
220 pPropHdl
= new XMLNumberNonePropHdl
;
222 case XML_TYPE_NUMBER8_NONE
:
223 pPropHdl
= new XMLNumberNonePropHdl( 1 );
225 case XML_TYPE_NUMBER16_NONE
:
226 pPropHdl
= new XMLNumberNonePropHdl( 2 );
228 case XML_TYPE_DOUBLE
:
229 pPropHdl
= new XMLDoublePropHdl
;
231 case XML_TYPE_NBOOL
:
232 pPropHdl
= new XMLNBoolPropHdl
;
234 case XML_TYPE_COLORTRANSPARENT
:
235 pPropHdl
= new XMLColorTransparentPropHdl
;
237 case XML_TYPE_ISTRANSPARENT
:
238 pPropHdl
= new XMLIsTransparentPropHdl
;
240 case XML_TYPE_COLORAUTO
:
241 pPropHdl
= new XMLColorAutoPropHdl
;
243 case XML_TYPE_ISAUTOCOLOR
:
244 pPropHdl
= new XMLIsAutoColorPropHdl
;
246 case XML_TYPE_BUILDIN_CMP_ONLY
:
247 pPropHdl
= new XMLCompareOnlyPropHdl
;
250 case XML_TYPE_RECTANGLE_LEFT
:
251 case XML_TYPE_RECTANGLE_TOP
:
252 case XML_TYPE_RECTANGLE_WIDTH
:
253 case XML_TYPE_RECTANGLE_HEIGHT
:
254 pPropHdl
= new XMLRectangleMembersHdl( nType
);
257 case XML_TYPE_TEXT_CROSSEDOUT_TYPE
:
258 pPropHdl
= new XMLCrossedOutTypePropHdl
;
260 case XML_TYPE_TEXT_CROSSEDOUT_STYLE
:
261 pPropHdl
= new XMLCrossedOutStylePropHdl
;
263 case XML_TYPE_TEXT_CROSSEDOUT_WIDTH
:
264 pPropHdl
= new XMLCrossedOutWidthPropHdl
;
266 case XML_TYPE_TEXT_CROSSEDOUT_TEXT
:
267 pPropHdl
= new XMLCrossedOutTextPropHdl
;
269 case XML_TYPE_TEXT_BOOLCROSSEDOUT
:
270 pPropHdl
= new XMLNamedBoolPropertyHdl(
271 GetXMLToken(XML_SOLID
),
272 GetXMLToken(XML_NONE
) );
274 case XML_TYPE_TEXT_ESCAPEMENT
:
275 pPropHdl
= new XMLEscapementPropHdl
;
277 case XML_TYPE_TEXT_ESCAPEMENT_HEIGHT
:
278 pPropHdl
= new XMLEscapementHeightPropHdl
;
280 case XML_TYPE_TEXT_CASEMAP
:
281 pPropHdl
= new XMLCaseMapPropHdl
;
283 case XML_TYPE_TEXT_CASEMAP_VAR
:
284 pPropHdl
= new XMLCaseMapVariantHdl
;
286 case XML_TYPE_TEXT_FONTFAMILYNAME
:
287 pPropHdl
= new XMLFontFamilyNamePropHdl
;
289 case XML_TYPE_TEXT_FONTFAMILY
:
290 pPropHdl
= new XMLFontFamilyPropHdl
;
292 case XML_TYPE_TEXT_FONTENCODING
:
293 pPropHdl
= new XMLFontEncodingPropHdl
;
295 case XML_TYPE_TEXT_FONTPITCH
:
296 pPropHdl
= new XMLFontPitchPropHdl
;
298 case XML_TYPE_TEXT_KERNING
:
299 pPropHdl
= new XMLKerningPropHdl
;
301 case XML_TYPE_TEXT_POSTURE
:
302 pPropHdl
= new XMLPosturePropHdl
;
304 case XML_TYPE_TEXT_SHADOWED
:
305 pPropHdl
= new XMLShadowedPropHdl
;
307 case XML_TYPE_TEXT_UNDERLINE_TYPE
:
308 pPropHdl
= new XMLUnderlineTypePropHdl
;
310 case XML_TYPE_TEXT_UNDERLINE_STYLE
:
311 pPropHdl
= new XMLUnderlineStylePropHdl
;
313 case XML_TYPE_TEXT_UNDERLINE_WIDTH
:
314 pPropHdl
= new XMLUnderlineWidthPropHdl
;
316 case XML_TYPE_TEXT_UNDERLINE_COLOR
:
317 pPropHdl
= new XMLColorTransparentPropHdl( XML_FONT_COLOR
);
319 case XML_TYPE_TEXT_UNDERLINE_HASCOLOR
:
320 pPropHdl
= new XMLIsTransparentPropHdl( XML_FONT_COLOR
,
323 case XML_TYPE_TEXT_OVERLINE_TYPE
:
324 pPropHdl
= new XMLUnderlineTypePropHdl
;
326 case XML_TYPE_TEXT_OVERLINE_STYLE
:
327 pPropHdl
= new XMLUnderlineStylePropHdl
;
329 case XML_TYPE_TEXT_OVERLINE_WIDTH
:
330 pPropHdl
= new XMLUnderlineWidthPropHdl
;
332 case XML_TYPE_TEXT_OVERLINE_COLOR
:
333 pPropHdl
= new XMLColorTransparentPropHdl( XML_FONT_COLOR
);
335 case XML_TYPE_TEXT_OVERLINE_HASCOLOR
:
336 pPropHdl
= new XMLIsTransparentPropHdl( XML_FONT_COLOR
,
339 case XML_TYPE_TEXT_WEIGHT
:
340 pPropHdl
= new XMLFontWeightPropHdl
;
342 case XML_TYPE_TEXT_SPLIT
:
343 pPropHdl
= new XMLNamedBoolPropertyHdl(
344 GetXMLToken(XML_AUTO
),
345 GetXMLToken(XML_ALWAYS
) );
347 case XML_TYPE_TEXT_BREAKBEFORE
:
348 pPropHdl
= new XMLFmtBreakBeforePropHdl
;
350 case XML_TYPE_TEXT_BREAKAFTER
:
351 pPropHdl
= new XMLFmtBreakAfterPropHdl
;
353 case XML_TYPE_TEXT_SHADOW
:
354 pPropHdl
= new XMLShadowPropHdl
;
356 case XML_TYPE_TEXT_ADJUST
:
357 pPropHdl
= new XMLParaAdjustPropHdl
;
359 case XML_TYPE_TEXT_ADJUSTLAST
:
360 pPropHdl
= new XMLLastLineAdjustPropHdl
;
362 case XML_TYPE_CHAR_HEIGHT
:
363 pPropHdl
= new XMLCharHeightHdl
;
365 case XML_TYPE_CHAR_HEIGHT_PROP
:
366 pPropHdl
= new XMLCharHeightPropHdl
;
368 case XML_TYPE_CHAR_HEIGHT_DIFF
:
369 pPropHdl
= new XMLCharHeightDiffHdl
;
371 case XML_TYPE_CHAR_LANGUAGE
:
372 pPropHdl
= new XMLCharLanguageHdl
;
374 case XML_TYPE_CHAR_COUNTRY
:
375 pPropHdl
= new XMLCharCountryHdl
;
377 case XML_TYPE_LINE_SPACE_FIXED
:
378 pPropHdl
= new XMLLineHeightHdl
;
380 case XML_TYPE_LINE_SPACE_MINIMUM
:
381 pPropHdl
= new XMLLineHeightAtLeastHdl
;
383 case XML_TYPE_LINE_SPACE_DISTANCE
:
384 pPropHdl
= new XMLLineSpacingHdl
;
386 case XML_TYPE_BORDER_WIDTH
:
387 pPropHdl
= new XMLBorderWidthHdl
;
389 case XML_TYPE_BORDER
:
390 pPropHdl
= new XMLBorderHdl
;
392 case XML_TYPE_TEXT_TABSTOP
:
393 pPropHdl
= new XMLTabStopPropHdl
;
395 case XML_TYPE_ATTRIBUTE_CONTAINER
:
396 pPropHdl
= new XMLAttributeContainerHandler
;
398 case XML_TYPE_COLOR_MODE
:
399 pPropHdl
= new XMLEnumPropertyHdl( aXML_ColorMode_EnumMap
,
400 ::getCppuType((const drawing::ColorMode
*)0) );
402 case XML_TYPE_DURATION16_MS
:
403 pPropHdl
= new XMLDurationMS16PropHdl_Impl
;
405 case XML_TYPE_TEXT_HORIZONTAL_ADJUST
:
406 pPropHdl
= new XMLEnumPropertyHdl(
407 aXML_HorizontalAdjust_Enum
,
408 ::getCppuType((const text::HorizontalAdjust
*)0) );
410 case XML_TYPE_TEXT_DRAW_ASPECT
:
411 pPropHdl
= new DrawAspectHdl
;
413 case XML_TYPE_TEXT_WRITING_MODE
:
414 pPropHdl
= new XMLConstantsPropertyHandler(
415 &(aXML_WritingDirection_Enum
[1]),
418 case XML_TYPE_TEXT_WRITING_MODE_WITH_DEFAULT
:
419 pPropHdl
= new XMLConstantsPropertyHandler(
420 aXML_WritingDirection_Enum
,
423 case XML_TYPE_TEXT_HIDDEN_AS_DISPLAY
:
424 pPropHdl
= new XMLNamedBoolPropertyHdl(
425 GetXMLToken(XML_NONE
),
426 GetXMLToken(XML_TRUE
) );
428 case XML_TYPE_STYLENAME
:
429 pPropHdl
= new XMLStyleNamePropHdl
;
431 case XML_TYPE_NUMBER_NO_ZERO
:
432 pPropHdl
= new XMLNumberWithoutZeroPropHdl( 4 );
434 case XML_TYPE_NUMBER8_NO_ZERO
:
435 pPropHdl
= new XMLNumberWithoutZeroPropHdl( 1 );
437 case XML_TYPE_NUMBER16_NO_ZERO
:
438 pPropHdl
= new XMLNumberWithoutZeroPropHdl( 2 );
440 case XML_TYPE_NUMBER16_AUTO
:
441 pPropHdl
= new XMLNumberWithAutoInsteadZeroPropHdl();
448 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */