LCOV - code coverage report
Current view: top level - libreoffice/xmloff/source/style - prhdlfac.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 181 199 91.0 %
Date: 2012-12-27 Functions: 6 7 85.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : 
      21             : #include <com/sun/star/drawing/ColorMode.hpp>
      22             : #include <com/sun/star/text/HorizontalAdjust.hpp>
      23             : #include <com/sun/star/text/WritingMode2.hpp>
      24             : 
      25             : #include <tools/debug.hxx>
      26             : 
      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"
      55             : 
      56             : using namespace ::com::sun::star;
      57             : using namespace ::xmloff::token;
      58             : 
      59             : SvXMLEnumMapEntry aXML_ColorMode_EnumMap[] =
      60             : {
      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 }
      66             : };
      67             : 
      68             : SvXMLEnumMapEntry const aXML_HorizontalAdjust_Enum[] =
      69             : {
      70             :     { XML_LEFT,     text::HorizontalAdjust_LEFT },
      71             :     { XML_CENTER,   text::HorizontalAdjust_CENTER },
      72             :     { XML_RIGHT,    text::HorizontalAdjust_RIGHT },
      73             :     { XML_TOKEN_INVALID, 0 }
      74             : };
      75             : 
      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[] =
      80             : {
      81             :     // aXML_WritingDirection_Enum
      82             :     { XML_PAGE,     text::WritingMode2::PAGE },
      83             : 
      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 },
      89             : 
      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 },
      94             : 
      95             :     { XML_TOKEN_INVALID, 0 }
      96             : };
      97             : 
      98             : 
      99             : ///////////////////////////////////////////////////////////////////////////
     100             : //
     101             : // Dtor
     102             : //
     103        2656 : XMLPropertyHandlerFactory::~XMLPropertyHandlerFactory()
     104             : {
     105       58658 :     for( CacheMap::iterator pPos = maHandlerCache.begin(); pPos != maHandlerCache.end(); ++pPos )
     106       57330 :         delete pPos->second;
     107        1328 : }
     108             : 
     109             : ///////////////////////////////////////////////////////////////////////////
     110             : //
     111             : // Interface
     112             : //
     113      116454 : const XMLPropertyHandler* XMLPropertyHandlerFactory::GetPropertyHandler( sal_Int32 nType ) const
     114             : {
     115             :     DBG_ASSERT( (nType & ~((sal_uInt32)MID_FLAG_MASK)) == 0,
     116             :                 "GetPropertyHandler called with flags in type" );
     117      116454 :     return GetBasicHandler( nType );
     118             : }
     119             : 
     120             : ///////////////////////////////////////////////////////////////////////////
     121             : //
     122             : // Helper-methods to create and cache PropertyHandler
     123             : //
     124      116454 : XMLPropertyHandler* XMLPropertyHandlerFactory::GetHdlCache( sal_Int32 nType ) const
     125             : {
     126      116454 :     XMLPropertyHandler* pRet = NULL;
     127             : 
     128      116454 :     if( maHandlerCache.find( nType ) != maHandlerCache.end() )
     129       59124 :         pRet = maHandlerCache.find( nType )->second;
     130             : 
     131      116454 :     return pRet;
     132             : }
     133             : 
     134       57330 : void XMLPropertyHandlerFactory::PutHdlCache( sal_Int32 nType, const XMLPropertyHandler* pHdl ) const
     135             : {
     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       57330 :     ((XMLPropertyHandlerFactory*)this)->maHandlerCache[ nType ] = (XMLPropertyHandler*)pHdl;
     139       57330 : }
     140             : 
     141      116454 : const XMLPropertyHandler* XMLPropertyHandlerFactory::GetBasicHandler( sal_Int32 nType ) const
     142             : {
     143      116454 :     const XMLPropertyHandler* pPropHdl = GetHdlCache( nType );
     144             : 
     145      116454 :     if( !pPropHdl )
     146             :     {
     147       57330 :         pPropHdl = CreatePropertyHandler( nType );
     148             : 
     149       57330 :         if( pPropHdl )
     150       37089 :             PutHdlCache( nType, pPropHdl );
     151             :     }
     152             : 
     153      116454 :     return pPropHdl;
     154             : }
     155             : 
     156       57330 : const XMLPropertyHandler* XMLPropertyHandlerFactory::CreatePropertyHandler( sal_Int32 nType )
     157             : {
     158       57330 :     XMLPropertyHandler* pPropHdl = NULL;
     159             : 
     160       57330 :     switch( nType )
     161             :     {
     162             :         case XML_TYPE_BOOL :
     163        1121 :             pPropHdl = new XMLBoolPropHdl;
     164        1121 :             break;
     165             :         case XML_TYPE_BOOL_FALSE :
     166           0 :             pPropHdl = new XMLBoolFalsePropHdl;
     167           0 :             break;
     168             :         case XML_TYPE_MEASURE :
     169        1029 :             pPropHdl = new XMLMeasurePropHdl( 4 );
     170        1029 :             break;
     171             :         case XML_TYPE_MEASURE8 :
     172           0 :             pPropHdl = new XMLMeasurePropHdl( 1 );
     173           0 :             break;
     174             :         case XML_TYPE_MEASURE16:
     175         139 :             pPropHdl = new XMLMeasurePropHdl( 2 );
     176         139 :             break;
     177             :         case XML_TYPE_PERCENT :
     178         461 :             pPropHdl = new XMLPercentPropHdl( 4 );
     179         461 :             break;
     180             :         case XML_TYPE_PERCENT8 :
     181         212 :             pPropHdl = new XMLPercentPropHdl( 1 );
     182         212 :             break;
     183             :         case XML_TYPE_PERCENT16 :
     184         802 :             pPropHdl = new XMLPercentPropHdl( 2 );
     185         802 :             break;
     186             :         case XML_TYPE_DOUBLE_PERCENT :
     187         278 :             pPropHdl = new XMLDoublePercentPropHdl();
     188         278 :             break;
     189             :         case XML_TYPE_NEG_PERCENT :
     190         109 :             pPropHdl = new XMLNegPercentPropHdl( 4 );
     191         109 :             break;
     192             :         case XML_TYPE_NEG_PERCENT8 :
     193           0 :             pPropHdl = new XMLNegPercentPropHdl( 1 );
     194           0 :             break;
     195             :         case XML_TYPE_NEG_PERCENT16 :
     196         278 :             pPropHdl = new XMLNegPercentPropHdl( 2 );
     197         278 :             break;
     198             :         case XML_TYPE_MEASURE_PX :
     199         278 :             pPropHdl = new XMLMeasurePxPropHdl( 4 );
     200         278 :             break;
     201             :         case XML_TYPE_STRING :
     202        1029 :             pPropHdl = new XMLStringPropHdl;
     203        1029 :             break;
     204             :         case XML_TYPE_COLOR :
     205         637 :             pPropHdl = new XMLColorPropHdl;
     206         637 :             break;
     207             :         case XML_TYPE_HEX :
     208         481 :             pPropHdl = new XMLHexPropHdl;
     209         481 :             break;
     210             :         case XML_TYPE_NUMBER :
     211         557 :             pPropHdl = new XMLNumberPropHdl( 4 );
     212         557 :             break;
     213             :         case XML_TYPE_NUMBER8 :
     214         352 :             pPropHdl = new XMLNumberPropHdl( 1 );
     215         352 :             break;
     216             :         case XML_TYPE_NUMBER16:
     217         540 :             pPropHdl = new XMLNumberPropHdl( 2 );
     218         540 :             break;
     219             :         case XML_TYPE_NUMBER_NONE :
     220           0 :             pPropHdl = new XMLNumberNonePropHdl;
     221           0 :             break;
     222             :         case XML_TYPE_NUMBER8_NONE :
     223           0 :             pPropHdl = new XMLNumberNonePropHdl( 1 );
     224           0 :             break;
     225             :         case XML_TYPE_NUMBER16_NONE :
     226         352 :             pPropHdl = new XMLNumberNonePropHdl( 2 );
     227         352 :             break;
     228             :         case XML_TYPE_DOUBLE :
     229           0 :             pPropHdl = new XMLDoublePropHdl;
     230           0 :             break;
     231             :         case XML_TYPE_NBOOL :
     232           4 :             pPropHdl = new XMLNBoolPropHdl;
     233           4 :             break;
     234             :         case XML_TYPE_COLORTRANSPARENT :
     235         916 :             pPropHdl = new XMLColorTransparentPropHdl;
     236         916 :             break;
     237             :         case XML_TYPE_ISTRANSPARENT :
     238         916 :             pPropHdl = new XMLIsTransparentPropHdl;
     239         916 :             break;
     240             :         case XML_TYPE_COLORAUTO :
     241         577 :             pPropHdl = new XMLColorAutoPropHdl;
     242         577 :             break;
     243             :         case XML_TYPE_ISAUTOCOLOR :
     244         481 :             pPropHdl = new XMLIsAutoColorPropHdl;
     245         481 :             break;
     246             :         case XML_TYPE_BUILDIN_CMP_ONLY :
     247         896 :             pPropHdl = new XMLCompareOnlyPropHdl;
     248         896 :             break;
     249             : 
     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         436 :             pPropHdl = new XMLRectangleMembersHdl( nType );
     255         436 :             break;
     256             : 
     257             :         case XML_TYPE_TEXT_CROSSEDOUT_TYPE:
     258         485 :             pPropHdl = new XMLCrossedOutTypePropHdl ;
     259         485 :             break;
     260             :         case XML_TYPE_TEXT_CROSSEDOUT_STYLE:
     261         485 :             pPropHdl = new XMLCrossedOutStylePropHdl ;
     262         485 :             break;
     263             :         case XML_TYPE_TEXT_CROSSEDOUT_WIDTH:
     264         485 :             pPropHdl = new XMLCrossedOutWidthPropHdl ;
     265         485 :             break;
     266             :         case XML_TYPE_TEXT_CROSSEDOUT_TEXT:
     267         485 :             pPropHdl = new XMLCrossedOutTextPropHdl ;
     268         485 :             break;
     269             :         case XML_TYPE_TEXT_BOOLCROSSEDOUT:
     270             :             pPropHdl = new XMLNamedBoolPropertyHdl(
     271             :                 GetXMLToken(XML_SOLID),
     272           0 :                 GetXMLToken(XML_NONE) );
     273           0 :             break;
     274             :         case XML_TYPE_TEXT_ESCAPEMENT:
     275         481 :             pPropHdl = new XMLEscapementPropHdl;
     276         481 :             break;
     277             :         case XML_TYPE_TEXT_ESCAPEMENT_HEIGHT:
     278         481 :             pPropHdl = new XMLEscapementHeightPropHdl;
     279         481 :             break;
     280             :         case XML_TYPE_TEXT_CASEMAP:
     281         481 :             pPropHdl = new XMLCaseMapPropHdl;
     282         481 :             break;
     283             :         case XML_TYPE_TEXT_CASEMAP_VAR:
     284         481 :             pPropHdl = new XMLCaseMapVariantHdl;
     285         481 :             break;
     286             :         case XML_TYPE_TEXT_FONTFAMILYNAME:
     287         481 :             pPropHdl = new XMLFontFamilyNamePropHdl;
     288         481 :             break;
     289             :         case XML_TYPE_TEXT_FONTFAMILY:
     290         485 :             pPropHdl = new XMLFontFamilyPropHdl;
     291         485 :             break;
     292             :         case XML_TYPE_TEXT_FONTENCODING:
     293         485 :             pPropHdl = new XMLFontEncodingPropHdl;
     294         485 :             break;
     295             :         case XML_TYPE_TEXT_FONTPITCH:
     296         485 :             pPropHdl = new XMLFontPitchPropHdl;
     297         485 :             break;
     298             :         case XML_TYPE_TEXT_KERNING:
     299         481 :             pPropHdl = new XMLKerningPropHdl;
     300         481 :             break;
     301             :         case XML_TYPE_TEXT_POSTURE:
     302         485 :             pPropHdl = new XMLPosturePropHdl;
     303         485 :             break;
     304             :         case XML_TYPE_TEXT_SHADOWED:
     305         481 :             pPropHdl = new XMLShadowedPropHdl;
     306         481 :             break;
     307             :         case XML_TYPE_TEXT_UNDERLINE_TYPE:
     308         485 :             pPropHdl = new XMLUnderlineTypePropHdl;
     309         485 :             break;
     310             :         case XML_TYPE_TEXT_UNDERLINE_STYLE:
     311         485 :             pPropHdl = new XMLUnderlineStylePropHdl;
     312         485 :             break;
     313             :         case XML_TYPE_TEXT_UNDERLINE_WIDTH:
     314         485 :             pPropHdl = new XMLUnderlineWidthPropHdl;
     315         485 :             break;
     316             :         case XML_TYPE_TEXT_UNDERLINE_COLOR:
     317         485 :             pPropHdl = new XMLColorTransparentPropHdl( XML_FONT_COLOR );
     318         485 :             break;
     319             :         case XML_TYPE_TEXT_UNDERLINE_HASCOLOR:
     320             :             pPropHdl = new XMLIsTransparentPropHdl( XML_FONT_COLOR,
     321         481 :                                                      sal_False );
     322         481 :             break;
     323             :         case XML_TYPE_TEXT_OVERLINE_TYPE:
     324         481 :             pPropHdl = new XMLUnderlineTypePropHdl;
     325         481 :             break;
     326             :         case XML_TYPE_TEXT_OVERLINE_STYLE:
     327         481 :             pPropHdl = new XMLUnderlineStylePropHdl;
     328         481 :             break;
     329             :         case XML_TYPE_TEXT_OVERLINE_WIDTH:
     330         481 :             pPropHdl = new XMLUnderlineWidthPropHdl;
     331         481 :             break;
     332             :         case XML_TYPE_TEXT_OVERLINE_COLOR:
     333         481 :             pPropHdl = new XMLColorTransparentPropHdl( XML_FONT_COLOR );
     334         481 :             break;
     335             :         case XML_TYPE_TEXT_OVERLINE_HASCOLOR:
     336             :             pPropHdl = new XMLIsTransparentPropHdl( XML_FONT_COLOR,
     337         481 :                                                      sal_False );
     338         481 :             break;
     339             :         case XML_TYPE_TEXT_WEIGHT:
     340         485 :             pPropHdl = new XMLFontWeightPropHdl;
     341         485 :             break;
     342             :         case XML_TYPE_TEXT_SPLIT:
     343             :             pPropHdl = new XMLNamedBoolPropertyHdl(
     344             :                 GetXMLToken(XML_AUTO),
     345         352 :                 GetXMLToken(XML_ALWAYS) );
     346         352 :             break;
     347             :         case XML_TYPE_TEXT_BREAKBEFORE:
     348         352 :             pPropHdl = new XMLFmtBreakBeforePropHdl;
     349         352 :             break;
     350             :         case XML_TYPE_TEXT_BREAKAFTER:
     351         352 :             pPropHdl = new XMLFmtBreakAfterPropHdl;
     352         352 :             break;
     353             :         case XML_TYPE_TEXT_SHADOW:
     354         660 :             pPropHdl = new XMLShadowPropHdl;
     355         660 :             break;
     356             :         case XML_TYPE_TEXT_ADJUST:
     357         352 :             pPropHdl = new XMLParaAdjustPropHdl;
     358         352 :             break;
     359             :         case XML_TYPE_TEXT_ADJUSTLAST:
     360         352 :             pPropHdl = new XMLLastLineAdjustPropHdl;
     361         352 :             break;
     362             :         case XML_TYPE_CHAR_HEIGHT:
     363         485 :             pPropHdl = new XMLCharHeightHdl;
     364         485 :             break;
     365             :         case XML_TYPE_CHAR_HEIGHT_PROP:
     366         481 :             pPropHdl = new XMLCharHeightPropHdl;
     367         481 :             break;
     368             :         case XML_TYPE_CHAR_HEIGHT_DIFF:
     369         481 :             pPropHdl = new XMLCharHeightDiffHdl;
     370         481 :             break;
     371             :         case XML_TYPE_CHAR_LANGUAGE:
     372         481 :             pPropHdl = new XMLCharLanguageHdl;
     373         481 :             break;
     374             :         case XML_TYPE_CHAR_COUNTRY:
     375         481 :             pPropHdl = new XMLCharCountryHdl;
     376         481 :             break;
     377             :         case XML_TYPE_LINE_SPACE_FIXED:
     378         352 :             pPropHdl = new XMLLineHeightHdl;
     379         352 :             break;
     380             :         case XML_TYPE_LINE_SPACE_MINIMUM:
     381         352 :             pPropHdl = new XMLLineHeightAtLeastHdl;
     382         352 :             break;
     383             :         case XML_TYPE_LINE_SPACE_DISTANCE:
     384         352 :             pPropHdl = new XMLLineSpacingHdl;
     385         352 :             break;
     386             :         case XML_TYPE_BORDER_WIDTH:
     387         660 :             pPropHdl = new XMLBorderWidthHdl;
     388         660 :             break;
     389             :         case XML_TYPE_BORDER:
     390         660 :             pPropHdl = new XMLBorderHdl;
     391         660 :             break;
     392             :         case XML_TYPE_TEXT_TABSTOP:
     393         352 :             pPropHdl = new XMLTabStopPropHdl;
     394         352 :             break;
     395             :         case XML_TYPE_ATTRIBUTE_CONTAINER:
     396         800 :             pPropHdl = new XMLAttributeContainerHandler;
     397         800 :             break;
     398             :         case XML_TYPE_COLOR_MODE:
     399             :             pPropHdl = new XMLEnumPropertyHdl( aXML_ColorMode_EnumMap,
     400         278 :                             ::getCppuType((const drawing::ColorMode*)0) );
     401         278 :             break;
     402             :         case XML_TYPE_DURATION16_MS:
     403         109 :             pPropHdl = new XMLDurationMS16PropHdl_Impl;
     404         109 :             break;
     405             :         case XML_TYPE_TEXT_HORIZONTAL_ADJUST:
     406             :             pPropHdl = new XMLEnumPropertyHdl(
     407             :                 aXML_HorizontalAdjust_Enum,
     408          43 :                 ::getCppuType((const text::HorizontalAdjust*)0) );
     409          43 :             break;
     410             :         case XML_TYPE_TEXT_DRAW_ASPECT:
     411         278 :             pPropHdl = new DrawAspectHdl;
     412         278 :             break;
     413             :         case XML_TYPE_TEXT_WRITING_MODE:
     414             :             pPropHdl = new XMLConstantsPropertyHandler(
     415             :                 &(aXML_WritingDirection_Enum[1]),
     416         139 :                 XML_LR_TB);
     417         139 :             break;
     418             :         case XML_TYPE_TEXT_WRITING_MODE_WITH_DEFAULT:
     419             :             pPropHdl = new XMLConstantsPropertyHandler(
     420             :                 aXML_WritingDirection_Enum,
     421         757 :                 XML_PAGE);
     422         757 :             break;
     423             :         case XML_TYPE_TEXT_HIDDEN_AS_DISPLAY:
     424             :             pPropHdl = new XMLNamedBoolPropertyHdl(
     425             :                 GetXMLToken(XML_NONE),
     426         481 :                 GetXMLToken(XML_TRUE) );
     427         481 :             break;
     428             :         case XML_TYPE_STYLENAME :
     429         504 :             pPropHdl = new XMLStyleNamePropHdl;
     430         504 :             break;
     431             :         case XML_TYPE_NUMBER_NO_ZERO:
     432           0 :             pPropHdl = new XMLNumberWithoutZeroPropHdl( 4 );
     433           0 :             break;
     434             :         case XML_TYPE_NUMBER8_NO_ZERO:
     435           0 :             pPropHdl = new XMLNumberWithoutZeroPropHdl( 1 );
     436           0 :             break;
     437             :         case XML_TYPE_NUMBER16_NO_ZERO:
     438         352 :             pPropHdl = new XMLNumberWithoutZeroPropHdl( 2 );
     439         352 :             break;
     440             :         case XML_TYPE_NUMBER16_AUTO:
     441         352 :             pPropHdl = new XMLNumberWithAutoInsteadZeroPropHdl();
     442         352 :             break;
     443             :     }
     444             : 
     445       57330 :     return pPropHdl;
     446             : }
     447             : 
     448             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10