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