LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/xmloff/source/style - prhdlfac.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 183 199 92.0 %
Date: 2013-07-09 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       12250 : XMLPropertyHandlerFactory::~XMLPropertyHandlerFactory()
     104             : {
     105      251216 :     for( CacheMap::iterator pPos = maHandlerCache.begin(); pPos != maHandlerCache.end(); ++pPos )
     106      245091 :         delete pPos->second;
     107        6125 : }
     108             : 
     109             : ///////////////////////////////////////////////////////////////////////////
     110             : //
     111             : // Interface
     112             : //
     113      495942 : 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      495942 :     return GetBasicHandler( nType );
     118             : }
     119             : 
     120             : ///////////////////////////////////////////////////////////////////////////
     121             : //
     122             : // Helper-methods to create and cache PropertyHandler
     123             : //
     124      495942 : XMLPropertyHandler* XMLPropertyHandlerFactory::GetHdlCache( sal_Int32 nType ) const
     125             : {
     126      495942 :     XMLPropertyHandler* pRet = NULL;
     127             : 
     128      495942 :     if( maHandlerCache.find( nType ) != maHandlerCache.end() )
     129      250041 :         pRet = maHandlerCache.find( nType )->second;
     130             : 
     131      495942 :     return pRet;
     132             : }
     133             : 
     134      245901 : 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      245901 :     ((XMLPropertyHandlerFactory*)this)->maHandlerCache[ nType ] = (XMLPropertyHandler*)pHdl;
     139      245901 : }
     140             : 
     141      495942 : const XMLPropertyHandler* XMLPropertyHandlerFactory::GetBasicHandler( sal_Int32 nType ) const
     142             : {
     143      495942 :     const XMLPropertyHandler* pPropHdl = GetHdlCache( nType );
     144             : 
     145      495942 :     if( !pPropHdl )
     146             :     {
     147      245901 :         pPropHdl = CreatePropertyHandler( nType );
     148             : 
     149      245901 :         if( pPropHdl )
     150      156855 :             PutHdlCache( nType, pPropHdl );
     151             :     }
     152             : 
     153      495942 :     return pPropHdl;
     154             : }
     155             : 
     156      245901 : const XMLPropertyHandler* XMLPropertyHandlerFactory::CreatePropertyHandler( sal_Int32 nType )
     157             : {
     158      245901 :     XMLPropertyHandler* pPropHdl = NULL;
     159             : 
     160      245901 :     switch( nType )
     161             :     {
     162             :         case XML_TYPE_BOOL :
     163        4805 :             pPropHdl = new XMLBoolPropHdl;
     164        4805 :             break;
     165             :         case XML_TYPE_BOOL_FALSE :
     166           0 :             pPropHdl = new XMLBoolFalsePropHdl;
     167           0 :             break;
     168             :         case XML_TYPE_MEASURE :
     169        4604 :             pPropHdl = new XMLMeasurePropHdl( 4 );
     170        4604 :             break;
     171             :         case XML_TYPE_MEASURE8 :
     172           0 :             pPropHdl = new XMLMeasurePropHdl( 1 );
     173           0 :             break;
     174             :         case XML_TYPE_MEASURE16:
     175         672 :             pPropHdl = new XMLMeasurePropHdl( 2 );
     176         672 :             break;
     177             :         case XML_TYPE_PERCENT :
     178        2018 :             pPropHdl = new XMLPercentPropHdl( 4 );
     179        2018 :             break;
     180             :         case XML_TYPE_PERCENT8 :
     181         835 :             pPropHdl = new XMLPercentPropHdl( 1 );
     182         835 :             break;
     183             :         case XML_TYPE_PERCENT16 :
     184        3351 :             pPropHdl = new XMLPercentPropHdl( 2 );
     185        3351 :             break;
     186             :         case XML_TYPE_DOUBLE_PERCENT :
     187        1261 :             pPropHdl = new XMLDoublePercentPropHdl();
     188        1261 :             break;
     189             :         case XML_TYPE_NEG_PERCENT :
     190         580 :             pPropHdl = new XMLNegPercentPropHdl( 4 );
     191         580 :             break;
     192             :         case XML_TYPE_NEG_PERCENT8 :
     193           0 :             pPropHdl = new XMLNegPercentPropHdl( 1 );
     194           0 :             break;
     195             :         case XML_TYPE_NEG_PERCENT16 :
     196        1261 :             pPropHdl = new XMLNegPercentPropHdl( 2 );
     197        1261 :             break;
     198             :         case XML_TYPE_MEASURE_PX :
     199        1261 :             pPropHdl = new XMLMeasurePxPropHdl( 4 );
     200        1261 :             break;
     201             :         case XML_TYPE_STRING :
     202        4431 :             pPropHdl = new XMLStringPropHdl;
     203        4431 :             break;
     204             :         case XML_TYPE_COLOR :
     205        2885 :             pPropHdl = new XMLColorPropHdl;
     206        2885 :             break;
     207             :         case XML_TYPE_HEX :
     208        1936 :             pPropHdl = new XMLHexPropHdl;
     209        1936 :             break;
     210             :         case XML_TYPE_NUMBER :
     211        2575 :             pPropHdl = new XMLNumberPropHdl( 4 );
     212        2575 :             break;
     213             :         case XML_TYPE_NUMBER8 :
     214        1438 :             pPropHdl = new XMLNumberPropHdl( 1 );
     215        1438 :             break;
     216             :         case XML_TYPE_NUMBER16:
     217        2368 :             pPropHdl = new XMLNumberPropHdl( 2 );
     218        2368 :             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        1438 :             pPropHdl = new XMLNumberNonePropHdl( 2 );
     227        1438 :             break;
     228             :         case XML_TYPE_DOUBLE :
     229          39 :             pPropHdl = new XMLDoublePropHdl;
     230          39 :             break;
     231             :         case XML_TYPE_NBOOL :
     232          33 :             pPropHdl = new XMLNBoolPropHdl;
     233          33 :             break;
     234             :         case XML_TYPE_COLORTRANSPARENT :
     235        3597 :             pPropHdl = new XMLColorTransparentPropHdl;
     236        3597 :             break;
     237             :         case XML_TYPE_ISTRANSPARENT :
     238        3597 :             pPropHdl = new XMLIsTransparentPropHdl;
     239        3597 :             break;
     240             :         case XML_TYPE_COLORAUTO :
     241        2272 :             pPropHdl = new XMLColorAutoPropHdl;
     242        2272 :             break;
     243             :         case XML_TYPE_ISAUTOCOLOR :
     244        1936 :             pPropHdl = new XMLIsAutoColorPropHdl;
     245        1936 :             break;
     246             :         case XML_TYPE_BUILDIN_CMP_ONLY :
     247        3679 :             pPropHdl = new XMLCompareOnlyPropHdl;
     248        3679 :             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        2320 :             pPropHdl = new XMLRectangleMembersHdl( nType );
     255        2320 :             break;
     256             : 
     257             :         case XML_TYPE_TEXT_CROSSEDOUT_TYPE:
     258        2151 :             pPropHdl = new XMLCrossedOutTypePropHdl ;
     259        2151 :             break;
     260             :         case XML_TYPE_TEXT_CROSSEDOUT_STYLE:
     261        2151 :             pPropHdl = new XMLCrossedOutStylePropHdl ;
     262        2151 :             break;
     263             :         case XML_TYPE_TEXT_CROSSEDOUT_WIDTH:
     264        2151 :             pPropHdl = new XMLCrossedOutWidthPropHdl ;
     265        2151 :             break;
     266             :         case XML_TYPE_TEXT_CROSSEDOUT_TEXT:
     267        2151 :             pPropHdl = new XMLCrossedOutTextPropHdl ;
     268        2151 :             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        1936 :             pPropHdl = new XMLEscapementPropHdl;
     276        1936 :             break;
     277             :         case XML_TYPE_TEXT_ESCAPEMENT_HEIGHT:
     278        1936 :             pPropHdl = new XMLEscapementHeightPropHdl;
     279        1936 :             break;
     280             :         case XML_TYPE_TEXT_CASEMAP:
     281        1936 :             pPropHdl = new XMLCaseMapPropHdl;
     282        1936 :             break;
     283             :         case XML_TYPE_TEXT_CASEMAP_VAR:
     284        1936 :             pPropHdl = new XMLCaseMapVariantHdl;
     285        1936 :             break;
     286             :         case XML_TYPE_TEXT_FONTFAMILYNAME:
     287        1936 :             pPropHdl = new XMLFontFamilyNamePropHdl;
     288        1936 :             break;
     289             :         case XML_TYPE_TEXT_FONTFAMILY:
     290        2151 :             pPropHdl = new XMLFontFamilyPropHdl;
     291        2151 :             break;
     292             :         case XML_TYPE_TEXT_FONTENCODING:
     293        2151 :             pPropHdl = new XMLFontEncodingPropHdl;
     294        2151 :             break;
     295             :         case XML_TYPE_TEXT_FONTPITCH:
     296        2151 :             pPropHdl = new XMLFontPitchPropHdl;
     297        2151 :             break;
     298             :         case XML_TYPE_TEXT_KERNING:
     299        1936 :             pPropHdl = new XMLKerningPropHdl;
     300        1936 :             break;
     301             :         case XML_TYPE_TEXT_POSTURE:
     302        2151 :             pPropHdl = new XMLPosturePropHdl;
     303        2151 :             break;
     304             :         case XML_TYPE_TEXT_SHADOWED:
     305        1936 :             pPropHdl = new XMLShadowedPropHdl;
     306        1936 :             break;
     307             :         case XML_TYPE_TEXT_UNDERLINE_TYPE:
     308        2151 :             pPropHdl = new XMLUnderlineTypePropHdl;
     309        2151 :             break;
     310             :         case XML_TYPE_TEXT_UNDERLINE_STYLE:
     311        2151 :             pPropHdl = new XMLUnderlineStylePropHdl;
     312        2151 :             break;
     313             :         case XML_TYPE_TEXT_UNDERLINE_WIDTH:
     314        2151 :             pPropHdl = new XMLUnderlineWidthPropHdl;
     315        2151 :             break;
     316             :         case XML_TYPE_TEXT_UNDERLINE_COLOR:
     317        2151 :             pPropHdl = new XMLColorTransparentPropHdl( XML_FONT_COLOR );
     318        2151 :             break;
     319             :         case XML_TYPE_TEXT_UNDERLINE_HASCOLOR:
     320             :             pPropHdl = new XMLIsTransparentPropHdl( XML_FONT_COLOR,
     321        2118 :                                                      sal_False );
     322        2118 :             break;
     323             :         case XML_TYPE_TEXT_OVERLINE_TYPE:
     324        1936 :             pPropHdl = new XMLUnderlineTypePropHdl;
     325        1936 :             break;
     326             :         case XML_TYPE_TEXT_OVERLINE_STYLE:
     327        1936 :             pPropHdl = new XMLUnderlineStylePropHdl;
     328        1936 :             break;
     329             :         case XML_TYPE_TEXT_OVERLINE_WIDTH:
     330        1936 :             pPropHdl = new XMLUnderlineWidthPropHdl;
     331        1936 :             break;
     332             :         case XML_TYPE_TEXT_OVERLINE_COLOR:
     333        1936 :             pPropHdl = new XMLColorTransparentPropHdl( XML_FONT_COLOR );
     334        1936 :             break;
     335             :         case XML_TYPE_TEXT_OVERLINE_HASCOLOR:
     336             :             pPropHdl = new XMLIsTransparentPropHdl( XML_FONT_COLOR,
     337        1936 :                                                      sal_False );
     338        1936 :             break;
     339             :         case XML_TYPE_TEXT_WEIGHT:
     340        2151 :             pPropHdl = new XMLFontWeightPropHdl;
     341        2151 :             break;
     342             :         case XML_TYPE_TEXT_SPLIT:
     343             :             pPropHdl = new XMLNamedBoolPropertyHdl(
     344             :                 GetXMLToken(XML_AUTO),
     345        1438 :                 GetXMLToken(XML_ALWAYS) );
     346        1438 :             break;
     347             :         case XML_TYPE_TEXT_BREAKBEFORE:
     348        1438 :             pPropHdl = new XMLFmtBreakBeforePropHdl;
     349        1438 :             break;
     350             :         case XML_TYPE_TEXT_BREAKAFTER:
     351        1438 :             pPropHdl = new XMLFmtBreakAfterPropHdl;
     352        1438 :             break;
     353             :         case XML_TYPE_TEXT_SHADOW:
     354        2609 :             pPropHdl = new XMLShadowPropHdl;
     355        2609 :             break;
     356             :         case XML_TYPE_TEXT_ADJUST:
     357        1438 :             pPropHdl = new XMLParaAdjustPropHdl;
     358        1438 :             break;
     359             :         case XML_TYPE_TEXT_ADJUSTLAST:
     360        1438 :             pPropHdl = new XMLLastLineAdjustPropHdl;
     361        1438 :             break;
     362             :         case XML_TYPE_CHAR_HEIGHT:
     363        1969 :             pPropHdl = new XMLCharHeightHdl;
     364        1969 :             break;
     365             :         case XML_TYPE_CHAR_HEIGHT_PROP:
     366        1936 :             pPropHdl = new XMLCharHeightPropHdl;
     367        1936 :             break;
     368             :         case XML_TYPE_CHAR_HEIGHT_DIFF:
     369        1936 :             pPropHdl = new XMLCharHeightDiffHdl;
     370        1936 :             break;
     371             :         case XML_TYPE_CHAR_LANGUAGE:
     372        1936 :             pPropHdl = new XMLCharLanguageHdl;
     373        1936 :             break;
     374             :         case XML_TYPE_CHAR_COUNTRY:
     375        1936 :             pPropHdl = new XMLCharCountryHdl;
     376        1936 :             break;
     377             :         case XML_TYPE_LINE_SPACE_FIXED:
     378        1438 :             pPropHdl = new XMLLineHeightHdl;
     379        1438 :             break;
     380             :         case XML_TYPE_LINE_SPACE_MINIMUM:
     381        1438 :             pPropHdl = new XMLLineHeightAtLeastHdl;
     382        1438 :             break;
     383             :         case XML_TYPE_LINE_SPACE_DISTANCE:
     384        1438 :             pPropHdl = new XMLLineSpacingHdl;
     385        1438 :             break;
     386             :         case XML_TYPE_BORDER_WIDTH:
     387        2609 :             pPropHdl = new XMLBorderWidthHdl;
     388        2609 :             break;
     389             :         case XML_TYPE_BORDER:
     390        2609 :             pPropHdl = new XMLBorderHdl;
     391        2609 :             break;
     392             :         case XML_TYPE_TEXT_TABSTOP:
     393        1438 :             pPropHdl = new XMLTabStopPropHdl;
     394        1438 :             break;
     395             :         case XML_TYPE_ATTRIBUTE_CONTAINER:
     396        3268 :             pPropHdl = new XMLAttributeContainerHandler;
     397        3268 :             break;
     398             :         case XML_TYPE_COLOR_MODE:
     399             :             pPropHdl = new XMLEnumPropertyHdl( aXML_ColorMode_EnumMap,
     400        1261 :                             ::getCppuType((const drawing::ColorMode*)0) );
     401        1261 :             break;
     402             :         case XML_TYPE_DURATION16_MS:
     403         580 :             pPropHdl = new XMLDurationMS16PropHdl_Impl;
     404         580 :             break;
     405             :         case XML_TYPE_TEXT_HORIZONTAL_ADJUST:
     406             :             pPropHdl = new XMLEnumPropertyHdl(
     407             :                 aXML_HorizontalAdjust_Enum,
     408         154 :                 ::getCppuType((const text::HorizontalAdjust*)0) );
     409         154 :             break;
     410             :         case XML_TYPE_TEXT_DRAW_ASPECT:
     411        1261 :             pPropHdl = new DrawAspectHdl;
     412        1261 :             break;
     413             :         case XML_TYPE_TEXT_WRITING_MODE:
     414             :             pPropHdl = new XMLConstantsPropertyHandler(
     415             :                 &(aXML_WritingDirection_Enum[1]),
     416         490 :                 XML_LR_TB);
     417         490 :             break;
     418             :         case XML_TYPE_TEXT_WRITING_MODE_WITH_DEFAULT:
     419             :             pPropHdl = new XMLConstantsPropertyHandler(
     420             :                 aXML_WritingDirection_Enum,
     421        3189 :                 XML_PAGE);
     422        3189 :             break;
     423             :         case XML_TYPE_TEXT_HIDDEN_AS_DISPLAY:
     424             :             pPropHdl = new XMLNamedBoolPropertyHdl(
     425             :                 GetXMLToken(XML_NONE),
     426        1936 :                 GetXMLToken(XML_TRUE) );
     427        1936 :             break;
     428             :         case XML_TYPE_STYLENAME :
     429        2853 :             pPropHdl = new XMLStyleNamePropHdl;
     430        2853 :             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        1438 :             pPropHdl = new XMLNumberWithoutZeroPropHdl( 2 );
     439        1438 :             break;
     440             :         case XML_TYPE_NUMBER16_AUTO:
     441        1438 :             pPropHdl = new XMLNumberWithAutoInsteadZeroPropHdl();
     442        1438 :             break;
     443             :     }
     444             : 
     445      245901 :     return pPropHdl;
     446             : }
     447             : 
     448             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10