bump product version to 4.1.6.2
[LibreOffice.git] / xmloff / source / style / prhdlfac.cxx
blobc6bb25f049a41f510234ca0da20e5b9053a7c29e
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 ///////////////////////////////////////////////////////////////////////////
101 // Dtor
103 XMLPropertyHandlerFactory::~XMLPropertyHandlerFactory()
105 for( CacheMap::iterator pPos = maHandlerCache.begin(); pPos != maHandlerCache.end(); ++pPos )
106 delete pPos->second;
109 ///////////////////////////////////////////////////////////////////////////
111 // Interface
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;
131 return pRet;
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 );
145 if( !pPropHdl )
147 pPropHdl = CreatePropertyHandler( nType );
149 if( pPropHdl )
150 PutHdlCache( nType, pPropHdl );
153 return pPropHdl;
156 const XMLPropertyHandler* XMLPropertyHandlerFactory::CreatePropertyHandler( sal_Int32 nType )
158 XMLPropertyHandler* pPropHdl = NULL;
160 switch( nType )
162 case XML_TYPE_BOOL :
163 pPropHdl = new XMLBoolPropHdl;
164 break;
165 case XML_TYPE_BOOL_FALSE :
166 pPropHdl = new XMLBoolFalsePropHdl;
167 break;
168 case XML_TYPE_MEASURE :
169 pPropHdl = new XMLMeasurePropHdl( 4 );
170 break;
171 case XML_TYPE_MEASURE8 :
172 pPropHdl = new XMLMeasurePropHdl( 1 );
173 break;
174 case XML_TYPE_MEASURE16:
175 pPropHdl = new XMLMeasurePropHdl( 2 );
176 break;
177 case XML_TYPE_PERCENT :
178 pPropHdl = new XMLPercentPropHdl( 4 );
179 break;
180 case XML_TYPE_PERCENT8 :
181 pPropHdl = new XMLPercentPropHdl( 1 );
182 break;
183 case XML_TYPE_PERCENT16 :
184 pPropHdl = new XMLPercentPropHdl( 2 );
185 break;
186 case XML_TYPE_DOUBLE_PERCENT :
187 pPropHdl = new XMLDoublePercentPropHdl();
188 break;
189 case XML_TYPE_NEG_PERCENT :
190 pPropHdl = new XMLNegPercentPropHdl( 4 );
191 break;
192 case XML_TYPE_NEG_PERCENT8 :
193 pPropHdl = new XMLNegPercentPropHdl( 1 );
194 break;
195 case XML_TYPE_NEG_PERCENT16 :
196 pPropHdl = new XMLNegPercentPropHdl( 2 );
197 break;
198 case XML_TYPE_MEASURE_PX :
199 pPropHdl = new XMLMeasurePxPropHdl( 4 );
200 break;
201 case XML_TYPE_STRING :
202 pPropHdl = new XMLStringPropHdl;
203 break;
204 case XML_TYPE_COLOR :
205 pPropHdl = new XMLColorPropHdl;
206 break;
207 case XML_TYPE_HEX :
208 pPropHdl = new XMLHexPropHdl;
209 break;
210 case XML_TYPE_NUMBER :
211 pPropHdl = new XMLNumberPropHdl( 4 );
212 break;
213 case XML_TYPE_NUMBER8 :
214 pPropHdl = new XMLNumberPropHdl( 1 );
215 break;
216 case XML_TYPE_NUMBER16:
217 pPropHdl = new XMLNumberPropHdl( 2 );
218 break;
219 case XML_TYPE_NUMBER_NONE :
220 pPropHdl = new XMLNumberNonePropHdl;
221 break;
222 case XML_TYPE_NUMBER8_NONE :
223 pPropHdl = new XMLNumberNonePropHdl( 1 );
224 break;
225 case XML_TYPE_NUMBER16_NONE :
226 pPropHdl = new XMLNumberNonePropHdl( 2 );
227 break;
228 case XML_TYPE_DOUBLE :
229 pPropHdl = new XMLDoublePropHdl;
230 break;
231 case XML_TYPE_NBOOL :
232 pPropHdl = new XMLNBoolPropHdl;
233 break;
234 case XML_TYPE_COLORTRANSPARENT :
235 pPropHdl = new XMLColorTransparentPropHdl;
236 break;
237 case XML_TYPE_ISTRANSPARENT :
238 pPropHdl = new XMLIsTransparentPropHdl;
239 break;
240 case XML_TYPE_COLORAUTO :
241 pPropHdl = new XMLColorAutoPropHdl;
242 break;
243 case XML_TYPE_ISAUTOCOLOR :
244 pPropHdl = new XMLIsAutoColorPropHdl;
245 break;
246 case XML_TYPE_BUILDIN_CMP_ONLY :
247 pPropHdl = new XMLCompareOnlyPropHdl;
248 break;
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 );
255 break;
257 case XML_TYPE_TEXT_CROSSEDOUT_TYPE:
258 pPropHdl = new XMLCrossedOutTypePropHdl ;
259 break;
260 case XML_TYPE_TEXT_CROSSEDOUT_STYLE:
261 pPropHdl = new XMLCrossedOutStylePropHdl ;
262 break;
263 case XML_TYPE_TEXT_CROSSEDOUT_WIDTH:
264 pPropHdl = new XMLCrossedOutWidthPropHdl ;
265 break;
266 case XML_TYPE_TEXT_CROSSEDOUT_TEXT:
267 pPropHdl = new XMLCrossedOutTextPropHdl ;
268 break;
269 case XML_TYPE_TEXT_BOOLCROSSEDOUT:
270 pPropHdl = new XMLNamedBoolPropertyHdl(
271 GetXMLToken(XML_SOLID),
272 GetXMLToken(XML_NONE) );
273 break;
274 case XML_TYPE_TEXT_ESCAPEMENT:
275 pPropHdl = new XMLEscapementPropHdl;
276 break;
277 case XML_TYPE_TEXT_ESCAPEMENT_HEIGHT:
278 pPropHdl = new XMLEscapementHeightPropHdl;
279 break;
280 case XML_TYPE_TEXT_CASEMAP:
281 pPropHdl = new XMLCaseMapPropHdl;
282 break;
283 case XML_TYPE_TEXT_CASEMAP_VAR:
284 pPropHdl = new XMLCaseMapVariantHdl;
285 break;
286 case XML_TYPE_TEXT_FONTFAMILYNAME:
287 pPropHdl = new XMLFontFamilyNamePropHdl;
288 break;
289 case XML_TYPE_TEXT_FONTFAMILY:
290 pPropHdl = new XMLFontFamilyPropHdl;
291 break;
292 case XML_TYPE_TEXT_FONTENCODING:
293 pPropHdl = new XMLFontEncodingPropHdl;
294 break;
295 case XML_TYPE_TEXT_FONTPITCH:
296 pPropHdl = new XMLFontPitchPropHdl;
297 break;
298 case XML_TYPE_TEXT_KERNING:
299 pPropHdl = new XMLKerningPropHdl;
300 break;
301 case XML_TYPE_TEXT_POSTURE:
302 pPropHdl = new XMLPosturePropHdl;
303 break;
304 case XML_TYPE_TEXT_SHADOWED:
305 pPropHdl = new XMLShadowedPropHdl;
306 break;
307 case XML_TYPE_TEXT_UNDERLINE_TYPE:
308 pPropHdl = new XMLUnderlineTypePropHdl;
309 break;
310 case XML_TYPE_TEXT_UNDERLINE_STYLE:
311 pPropHdl = new XMLUnderlineStylePropHdl;
312 break;
313 case XML_TYPE_TEXT_UNDERLINE_WIDTH:
314 pPropHdl = new XMLUnderlineWidthPropHdl;
315 break;
316 case XML_TYPE_TEXT_UNDERLINE_COLOR:
317 pPropHdl = new XMLColorTransparentPropHdl( XML_FONT_COLOR );
318 break;
319 case XML_TYPE_TEXT_UNDERLINE_HASCOLOR:
320 pPropHdl = new XMLIsTransparentPropHdl( XML_FONT_COLOR,
321 sal_False );
322 break;
323 case XML_TYPE_TEXT_OVERLINE_TYPE:
324 pPropHdl = new XMLUnderlineTypePropHdl;
325 break;
326 case XML_TYPE_TEXT_OVERLINE_STYLE:
327 pPropHdl = new XMLUnderlineStylePropHdl;
328 break;
329 case XML_TYPE_TEXT_OVERLINE_WIDTH:
330 pPropHdl = new XMLUnderlineWidthPropHdl;
331 break;
332 case XML_TYPE_TEXT_OVERLINE_COLOR:
333 pPropHdl = new XMLColorTransparentPropHdl( XML_FONT_COLOR );
334 break;
335 case XML_TYPE_TEXT_OVERLINE_HASCOLOR:
336 pPropHdl = new XMLIsTransparentPropHdl( XML_FONT_COLOR,
337 sal_False );
338 break;
339 case XML_TYPE_TEXT_WEIGHT:
340 pPropHdl = new XMLFontWeightPropHdl;
341 break;
342 case XML_TYPE_TEXT_SPLIT:
343 pPropHdl = new XMLNamedBoolPropertyHdl(
344 GetXMLToken(XML_AUTO),
345 GetXMLToken(XML_ALWAYS) );
346 break;
347 case XML_TYPE_TEXT_BREAKBEFORE:
348 pPropHdl = new XMLFmtBreakBeforePropHdl;
349 break;
350 case XML_TYPE_TEXT_BREAKAFTER:
351 pPropHdl = new XMLFmtBreakAfterPropHdl;
352 break;
353 case XML_TYPE_TEXT_SHADOW:
354 pPropHdl = new XMLShadowPropHdl;
355 break;
356 case XML_TYPE_TEXT_ADJUST:
357 pPropHdl = new XMLParaAdjustPropHdl;
358 break;
359 case XML_TYPE_TEXT_ADJUSTLAST:
360 pPropHdl = new XMLLastLineAdjustPropHdl;
361 break;
362 case XML_TYPE_CHAR_HEIGHT:
363 pPropHdl = new XMLCharHeightHdl;
364 break;
365 case XML_TYPE_CHAR_HEIGHT_PROP:
366 pPropHdl = new XMLCharHeightPropHdl;
367 break;
368 case XML_TYPE_CHAR_HEIGHT_DIFF:
369 pPropHdl = new XMLCharHeightDiffHdl;
370 break;
371 case XML_TYPE_CHAR_LANGUAGE:
372 pPropHdl = new XMLCharLanguageHdl;
373 break;
374 case XML_TYPE_CHAR_COUNTRY:
375 pPropHdl = new XMLCharCountryHdl;
376 break;
377 case XML_TYPE_LINE_SPACE_FIXED:
378 pPropHdl = new XMLLineHeightHdl;
379 break;
380 case XML_TYPE_LINE_SPACE_MINIMUM:
381 pPropHdl = new XMLLineHeightAtLeastHdl;
382 break;
383 case XML_TYPE_LINE_SPACE_DISTANCE:
384 pPropHdl = new XMLLineSpacingHdl;
385 break;
386 case XML_TYPE_BORDER_WIDTH:
387 pPropHdl = new XMLBorderWidthHdl;
388 break;
389 case XML_TYPE_BORDER:
390 pPropHdl = new XMLBorderHdl;
391 break;
392 case XML_TYPE_TEXT_TABSTOP:
393 pPropHdl = new XMLTabStopPropHdl;
394 break;
395 case XML_TYPE_ATTRIBUTE_CONTAINER:
396 pPropHdl = new XMLAttributeContainerHandler;
397 break;
398 case XML_TYPE_COLOR_MODE:
399 pPropHdl = new XMLEnumPropertyHdl( aXML_ColorMode_EnumMap,
400 ::getCppuType((const drawing::ColorMode*)0) );
401 break;
402 case XML_TYPE_DURATION16_MS:
403 pPropHdl = new XMLDurationMS16PropHdl_Impl;
404 break;
405 case XML_TYPE_TEXT_HORIZONTAL_ADJUST:
406 pPropHdl = new XMLEnumPropertyHdl(
407 aXML_HorizontalAdjust_Enum,
408 ::getCppuType((const text::HorizontalAdjust*)0) );
409 break;
410 case XML_TYPE_TEXT_DRAW_ASPECT:
411 pPropHdl = new DrawAspectHdl;
412 break;
413 case XML_TYPE_TEXT_WRITING_MODE:
414 pPropHdl = new XMLConstantsPropertyHandler(
415 &(aXML_WritingDirection_Enum[1]),
416 XML_LR_TB);
417 break;
418 case XML_TYPE_TEXT_WRITING_MODE_WITH_DEFAULT:
419 pPropHdl = new XMLConstantsPropertyHandler(
420 aXML_WritingDirection_Enum,
421 XML_PAGE);
422 break;
423 case XML_TYPE_TEXT_HIDDEN_AS_DISPLAY:
424 pPropHdl = new XMLNamedBoolPropertyHdl(
425 GetXMLToken(XML_NONE),
426 GetXMLToken(XML_TRUE) );
427 break;
428 case XML_TYPE_STYLENAME :
429 pPropHdl = new XMLStyleNamePropHdl;
430 break;
431 case XML_TYPE_NUMBER_NO_ZERO:
432 pPropHdl = new XMLNumberWithoutZeroPropHdl( 4 );
433 break;
434 case XML_TYPE_NUMBER8_NO_ZERO:
435 pPropHdl = new XMLNumberWithoutZeroPropHdl( 1 );
436 break;
437 case XML_TYPE_NUMBER16_NO_ZERO:
438 pPropHdl = new XMLNumberWithoutZeroPropHdl( 2 );
439 break;
440 case XML_TYPE_NUMBER16_AUTO:
441 pPropHdl = new XMLNumberWithAutoInsteadZeroPropHdl();
442 break;
445 return pPropHdl;
448 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */