LCOV - code coverage report
Current view: top level - oox/source/vml - vmlshapecontext.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 293 0.0 %
Date: 2014-04-14 Functions: 0 32 0.0 %
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             : #include "oox/vml/vmlshapecontext.hxx"
      21             : 
      22             : #include "oox/core/xmlfilterbase.hxx"
      23             : #include "oox/vml/vmldrawing.hxx"
      24             : #include "oox/vml/vmlshape.hxx"
      25             : #include "oox/vml/vmlshapecontainer.hxx"
      26             : #include "oox/vml/vmltextboxcontext.hxx"
      27             : 
      28             : namespace oox {
      29             : namespace vml {
      30             : 
      31             : 
      32             : 
      33             : using namespace ::com::sun::star;
      34             : 
      35             : using ::oox::core::ContextHandler2;
      36             : using ::oox::core::ContextHandler2Helper;
      37             : using ::oox::core::ContextHandlerRef;
      38             : 
      39             : 
      40             : 
      41             : namespace {
      42             : 
      43             : /** Returns the boolean value from the specified VML attribute (if present).
      44             :  */
      45           0 : OptValue< bool > lclDecodeBool( const AttributeList& rAttribs, sal_Int32 nToken )
      46             : {
      47           0 :     OptValue< OUString > oValue = rAttribs.getString( nToken );
      48           0 :     if( oValue.has() ) return OptValue< bool >( ConversionHelper::decodeBool( oValue.get() ) );
      49           0 :     return OptValue< bool >();
      50             : }
      51             : 
      52             : /** Returns the percentage value from the specified VML attribute (if present).
      53             :     The value will be normalized (1.0 is returned for 100%).
      54             :  */
      55           0 : OptValue< double > lclDecodePercent( const AttributeList& rAttribs, sal_Int32 nToken, double fDefValue )
      56             : {
      57           0 :     OptValue< OUString > oValue = rAttribs.getString( nToken );
      58           0 :     if( oValue.has() ) return OptValue< double >( ConversionHelper::decodePercent( oValue.get(), fDefValue ) );
      59           0 :     return OptValue< double >();
      60             : }
      61             : 
      62             : /** #119750# Special method for opacity; it *should* be a percentage value, but there are cases
      63             :     where a value relative to 0xffff (65536) is used, ending with an 'f'
      64             :  */
      65           0 : OptValue< double > lclDecodeOpacity( const AttributeList& rAttribs, sal_Int32 nToken, double fDefValue )
      66             : {
      67           0 :     OptValue< OUString > oValue = rAttribs.getString( nToken );
      68           0 :     double fRetval(fDefValue);
      69             : 
      70           0 :     if( oValue.has() )
      71             :     {
      72           0 :         const OUString aString(oValue.get());
      73           0 :         const sal_Int32 nLength(aString.getLength());
      74             : 
      75           0 :         if(nLength > 0)
      76             :         {
      77           0 :             if(aString.endsWith("f"))
      78             :             {
      79           0 :                 fRetval = std::max(0.0, std::min(1.0, aString.toDouble() / 65536.0));
      80             :             }
      81             :             else
      82             :             {
      83           0 :                 fRetval = ConversionHelper::decodePercent( aString, fDefValue );
      84             :             }
      85           0 :         }
      86             :     }
      87             : 
      88           0 :     return OptValue< double >(fRetval);
      89             : }
      90             : 
      91             : /** Returns the integer value pair from the specified VML attribute (if present).
      92             :  */
      93           0 : OptValue< Int32Pair > lclDecodeInt32Pair( const AttributeList& rAttribs, sal_Int32 nToken )
      94             : {
      95           0 :     OptValue< OUString > oValue = rAttribs.getString( nToken );
      96           0 :     OptValue< Int32Pair > oRetValue;
      97           0 :     if( oValue.has() )
      98             :     {
      99           0 :         OUString aValue1, aValue2;
     100           0 :         ConversionHelper::separatePair( aValue1, aValue2, oValue.get(), ',' );
     101           0 :         oRetValue = Int32Pair( aValue1.toInt32(), aValue2.toInt32() );
     102             :     }
     103           0 :     return oRetValue;
     104             : }
     105             : 
     106             : /** Returns the percentage pair from the specified VML attribute (if present).
     107             :  */
     108           0 : OptValue< DoublePair > lclDecodePercentPair( const AttributeList& rAttribs, sal_Int32 nToken )
     109             : {
     110           0 :     OptValue< OUString > oValue = rAttribs.getString( nToken );
     111           0 :     OptValue< DoublePair > oRetValue;
     112           0 :     if( oValue.has() )
     113             :     {
     114           0 :         OUString aValue1, aValue2;
     115           0 :         ConversionHelper::separatePair( aValue1, aValue2, oValue.get(), ',' );
     116           0 :         oRetValue = DoublePair(
     117           0 :             ConversionHelper::decodePercent( aValue1, 0.0 ),
     118           0 :             ConversionHelper::decodePercent( aValue2, 0.0 ) );
     119             :     }
     120           0 :     return oRetValue;
     121             : }
     122             : 
     123             : /** Returns the boolean value from the passed string of an attribute in the x:
     124             :     namespace (VML for spreadsheets). Supported values: f, t, False, True.
     125             :     @param bDefaultForEmpty  Default value for the empty string.
     126             :  */
     127           0 : bool lclDecodeVmlxBool( const OUString& rValue, bool bDefaultForEmpty )
     128             : {
     129           0 :     if( rValue.isEmpty() ) return bDefaultForEmpty;
     130           0 :     sal_Int32 nToken = AttributeConversion::decodeToken( rValue );
     131             :     // anything else than 't' or 'True' is considered to be false, as specified
     132           0 :     return (nToken == XML_t) || (nToken == XML_True);
     133             : }
     134             : 
     135             : } // namespace
     136             : 
     137             : 
     138             : 
     139           0 : ShapeLayoutContext::ShapeLayoutContext( ContextHandler2Helper& rParent, Drawing& rDrawing ) :
     140             :     ContextHandler2( rParent ),
     141           0 :     mrDrawing( rDrawing )
     142             : {
     143           0 : }
     144             : 
     145             : 
     146           0 : ContextHandlerRef ShapeLayoutContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
     147             : {
     148           0 :     switch( nElement )
     149             :     {
     150             :         case O_TOKEN( idmap ):
     151             :         {
     152           0 :             OUString aBlockIds = rAttribs.getString( XML_data, OUString() );
     153           0 :             sal_Int32 nIndex = 0;
     154           0 :             while( nIndex >= 0 )
     155             :             {
     156           0 :                 OUString aToken = aBlockIds.getToken( 0, ' ', nIndex ).trim();
     157           0 :                 if( !aToken.isEmpty() )
     158           0 :                     mrDrawing.registerBlockId( aToken.toInt32() );
     159           0 :             }
     160             :         }
     161           0 :         break;
     162             :     }
     163           0 :     return 0;
     164             : }
     165             : 
     166             : 
     167             : 
     168           0 : ClientDataContext::ClientDataContext( ContextHandler2Helper& rParent,
     169             :         ClientData& rClientData, const AttributeList& rAttribs ) :
     170             :     ContextHandler2( rParent ),
     171           0 :     mrClientData( rClientData )
     172             : {
     173           0 :     mrClientData.mnObjType = rAttribs.getToken( XML_ObjectType, XML_TOKEN_INVALID );
     174           0 : }
     175             : 
     176           0 : ContextHandlerRef ClientDataContext::onCreateContext( sal_Int32 /*nElement*/, const AttributeList& /*rAttribs*/ )
     177             : {
     178           0 :     if( isRootElement() )
     179             :     {
     180           0 :         maElementText = OUString();
     181           0 :         return this;
     182             :     }
     183           0 :     return 0;
     184             : }
     185             : 
     186           0 : void ClientDataContext::onCharacters( const OUString& rChars )
     187             : {
     188             :     /*  Empty but existing elements have special meaning, e.g. 'true'. Collect
     189             :         existing text and convert it in onEndElement(). */
     190           0 :     maElementText = rChars;
     191           0 : }
     192             : 
     193           0 : void ClientDataContext::onEndElement()
     194             : {
     195           0 :     switch( getCurrentElement() )
     196             :     {
     197           0 :         case VMLX_TOKEN( Anchor ):      mrClientData.maAnchor = maElementText;                                          break;
     198           0 :         case VMLX_TOKEN( FmlaMacro ):   mrClientData.maFmlaMacro = maElementText;                                       break;
     199           0 :         case VMLX_TOKEN( FmlaPict ):    mrClientData.maFmlaPict = maElementText;                                        break;
     200           0 :         case VMLX_TOKEN( FmlaLink ):    mrClientData.maFmlaLink = maElementText;                                        break;
     201           0 :         case VMLX_TOKEN( FmlaRange ):   mrClientData.maFmlaRange = maElementText;                                       break;
     202           0 :         case VMLX_TOKEN( FmlaGroup ):   mrClientData.maFmlaGroup = maElementText;                                       break;
     203           0 :         case VMLX_TOKEN( TextHAlign ):  mrClientData.mnTextHAlign = AttributeConversion::decodeToken( maElementText );  break;
     204           0 :         case VMLX_TOKEN( TextVAlign ):  mrClientData.mnTextVAlign = AttributeConversion::decodeToken( maElementText );  break;
     205           0 :         case VMLX_TOKEN( Column ):      mrClientData.mnCol = maElementText.toInt32();                                   break;
     206           0 :         case VMLX_TOKEN( Row ):         mrClientData.mnRow = maElementText.toInt32();                                   break;
     207           0 :         case VMLX_TOKEN( Checked ):     mrClientData.mnChecked = maElementText.toInt32();                               break;
     208           0 :         case VMLX_TOKEN( DropStyle ):   mrClientData.mnDropStyle = AttributeConversion::decodeToken( maElementText );   break;
     209           0 :         case VMLX_TOKEN( DropLines ):   mrClientData.mnDropLines = maElementText.toInt32();                             break;
     210           0 :         case VMLX_TOKEN( Val ):         mrClientData.mnVal = maElementText.toInt32();                                   break;
     211           0 :         case VMLX_TOKEN( Min ):         mrClientData.mnMin = maElementText.toInt32();                                   break;
     212           0 :         case VMLX_TOKEN( Max ):         mrClientData.mnMax = maElementText.toInt32();                                   break;
     213           0 :         case VMLX_TOKEN( Inc ):         mrClientData.mnInc = maElementText.toInt32();                                   break;
     214           0 :         case VMLX_TOKEN( Page ):        mrClientData.mnPage = maElementText.toInt32();                                  break;
     215           0 :         case VMLX_TOKEN( SelType ):     mrClientData.mnSelType = AttributeConversion::decodeToken( maElementText );     break;
     216           0 :         case VMLX_TOKEN( VTEdit ):      mrClientData.mnVTEdit = maElementText.toInt32();                                break;
     217           0 :         case VMLX_TOKEN( PrintObject ): mrClientData.mbPrintObject = lclDecodeVmlxBool( maElementText, true );          break;
     218           0 :         case VMLX_TOKEN( Visible ):     mrClientData.mbVisible = lclDecodeVmlxBool( maElementText, true );              break;
     219           0 :         case VMLX_TOKEN( DDE ):         mrClientData.mbDde = lclDecodeVmlxBool( maElementText, true );                  break;
     220           0 :         case VMLX_TOKEN( NoThreeD ):    mrClientData.mbNo3D = lclDecodeVmlxBool( maElementText, true );                 break;
     221           0 :         case VMLX_TOKEN( NoThreeD2 ):   mrClientData.mbNo3D2 = lclDecodeVmlxBool( maElementText, true );                break;
     222           0 :         case VMLX_TOKEN( MultiLine ):   mrClientData.mbMultiLine = lclDecodeVmlxBool( maElementText, true );            break;
     223           0 :         case VMLX_TOKEN( VScroll ):     mrClientData.mbVScroll = lclDecodeVmlxBool( maElementText, true );              break;
     224           0 :         case VMLX_TOKEN( SecretEdit ):  mrClientData.mbSecretEdit = lclDecodeVmlxBool( maElementText, true );           break;
     225             :     }
     226           0 : }
     227             : 
     228             : 
     229             : 
     230           0 : ShapeContextBase::ShapeContextBase( ContextHandler2Helper& rParent ) :
     231           0 :     ContextHandler2( rParent )
     232             : {
     233           0 : }
     234             : 
     235           0 : ContextHandlerRef ShapeContextBase::createShapeContext( ContextHandler2Helper& rParent,
     236             :         ShapeContainer& rShapes, sal_Int32 nElement, const AttributeList& rAttribs )
     237             : {
     238           0 :     switch( nElement )
     239             :     {
     240             :         case O_TOKEN( shapelayout ):
     241           0 :             return new ShapeLayoutContext( rParent, rShapes.getDrawing() );
     242             : 
     243             :         case VML_TOKEN( shapetype ):
     244           0 :             return new ShapeTypeContext( rParent, rShapes.createShapeType(), rAttribs );
     245             :         case VML_TOKEN( group ):
     246           0 :             return new GroupShapeContext( rParent, rShapes.createShape< GroupShape >(), rAttribs );
     247             :         case VML_TOKEN( shape ):
     248           0 :             if (rAttribs.hasAttribute(XML_path))
     249           0 :                 return new ShapeContext( rParent, rShapes.createShape< BezierShape >(), rAttribs );
     250             :             else
     251           0 :                 return new ShapeContext( rParent, rShapes.createShape< ComplexShape >(), rAttribs );
     252             :         case VML_TOKEN( rect ):
     253           0 :             return new RectangleShapeContext( rParent, rAttribs, rShapes.createShape< RectangleShape >() );
     254             :         case VML_TOKEN( roundrect ):
     255           0 :             return new ShapeContext( rParent, rShapes.createShape< RectangleShape >(), rAttribs );
     256             :         case VML_TOKEN( oval ):
     257           0 :             return new ShapeContext( rParent, rShapes.createShape< EllipseShape >(), rAttribs );
     258             :         case VML_TOKEN( polyline ):
     259           0 :             return new ShapeContext( rParent, rShapes.createShape< PolyLineShape >(), rAttribs );
     260             :         case VML_TOKEN( line ):
     261           0 :             return new ShapeContext( rParent, rShapes.createShape< LineShape >(), rAttribs );
     262             :         case VML_TOKEN( curve ):
     263           0 :             return new ShapeContext( rParent, rShapes.createShape< BezierShape >(), rAttribs );
     264             : 
     265             :         // TODO:
     266             :         case VML_TOKEN( arc ):
     267             :         case VML_TOKEN( diagram ):
     268             :         case VML_TOKEN( image ):
     269           0 :             return new ShapeContext( rParent, rShapes.createShape< ComplexShape >(), rAttribs );
     270             :     }
     271           0 :     return 0;
     272             : }
     273             : 
     274             : 
     275             : 
     276           0 : ShapeTypeContext::ShapeTypeContext( ContextHandler2Helper& rParent, ShapeType& rShapeType, const AttributeList& rAttribs ) :
     277             :     ShapeContextBase( rParent ),
     278           0 :     mrTypeModel( rShapeType.getTypeModel() )
     279             : {
     280             :     // shape identifier and shape name
     281           0 :     bool bHasOspid = rAttribs.hasAttribute( O_TOKEN( spid ) );
     282           0 :     mrTypeModel.maShapeId = rAttribs.getXString( bHasOspid ? O_TOKEN( spid ) : XML_id, OUString() );
     283             :     OSL_ENSURE( !mrTypeModel.maShapeId.isEmpty(), "ShapeTypeContext::ShapeTypeContext - missing shape identifier" );
     284             :     // if the o:spid attribute exists, the id attribute contains the user-defined shape name
     285           0 :     if( bHasOspid )
     286           0 :         mrTypeModel.maShapeName = rAttribs.getXString( XML_id, OUString() );
     287             :     // builtin shape type identifier
     288           0 :     mrTypeModel.moShapeType = rAttribs.getInteger( O_TOKEN( spt ) );
     289             : 
     290             :     // coordinate system position/size, CSS style
     291           0 :     mrTypeModel.moCoordPos = lclDecodeInt32Pair( rAttribs, XML_coordorigin );
     292           0 :     mrTypeModel.moCoordSize = lclDecodeInt32Pair( rAttribs, XML_coordsize );
     293           0 :     setStyle( rAttribs.getString( XML_style, OUString() ) );
     294           0 :     if( lclDecodeBool( rAttribs, O_TOKEN( hr )).get( false ))
     295             :     {   // MSO's handling of o:hr width is nowhere near what the spec says:
     296             :         // - o:hrpct is not in % but in 0.1%
     297             :         // - if o:hrpct is not given, 100% width is assumed
     298             :         // - given width is used only if explicit o:hrpct="0" is given
     299           0 :         OUString hrpct = rAttribs.getString( O_TOKEN( hrpct ), "1000" );
     300           0 :         if( hrpct != "0" )
     301           0 :             mrTypeModel.maWidth = OUString::number( hrpct.toInt32() / 10 ) + "%";
     302             :     }
     303             : 
     304             :     // stroke settings (may be overridden by v:stroke element later)
     305           0 :     mrTypeModel.maStrokeModel.moStroked = lclDecodeBool( rAttribs, XML_stroked );
     306           0 :     mrTypeModel.maStrokeModel.moColor = rAttribs.getString( XML_strokecolor );
     307           0 :     mrTypeModel.maStrokeModel.moWeight = rAttribs.getString( XML_strokeweight );
     308             : 
     309             :     // fill settings (may be overridden by v:fill element later)
     310           0 :     mrTypeModel.maFillModel.moFilled = lclDecodeBool( rAttribs, XML_filled );
     311           0 :     mrTypeModel.maFillModel.moColor = rAttribs.getString( XML_fillcolor );
     312             : 
     313             :     // For roundrect we may have a arcsize attribute to read
     314           0 :     mrTypeModel.maArcsize = rAttribs.getString( XML_arcsize,OUString( ) );
     315             :     // editas
     316           0 :     mrTypeModel.maEditAs = rAttribs.getString(XML_editas, OUString());
     317           0 : }
     318             : 
     319           0 : ContextHandlerRef ShapeTypeContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
     320             : {
     321           0 :     if( isRootElement() ) switch( nElement )
     322             :     {
     323             :         case VML_TOKEN( stroke ):
     324           0 :             mrTypeModel.maStrokeModel.moStroked.assignIfUsed( lclDecodeBool( rAttribs, XML_on ) );
     325           0 :             mrTypeModel.maStrokeModel.maStartArrow.moArrowType = rAttribs.getToken( XML_startarrow );
     326           0 :             mrTypeModel.maStrokeModel.maStartArrow.moArrowWidth = rAttribs.getToken( XML_startarrowwidth );
     327           0 :             mrTypeModel.maStrokeModel.maStartArrow.moArrowLength = rAttribs.getToken( XML_startarrowlength );
     328           0 :             mrTypeModel.maStrokeModel.maEndArrow.moArrowType = rAttribs.getToken( XML_endarrow );
     329           0 :             mrTypeModel.maStrokeModel.maEndArrow.moArrowWidth = rAttribs.getToken( XML_endarrowwidth );
     330           0 :             mrTypeModel.maStrokeModel.maEndArrow.moArrowLength = rAttribs.getToken( XML_endarrowlength );
     331           0 :             mrTypeModel.maStrokeModel.moColor.assignIfUsed( rAttribs.getString( XML_color ) );
     332           0 :             mrTypeModel.maStrokeModel.moOpacity = lclDecodeOpacity( rAttribs, XML_opacity, 1.0 );
     333           0 :             mrTypeModel.maStrokeModel.moWeight.assignIfUsed( rAttribs.getString( XML_weight ) );
     334           0 :             mrTypeModel.maStrokeModel.moDashStyle = rAttribs.getString( XML_dashstyle );
     335           0 :             mrTypeModel.maStrokeModel.moLineStyle = rAttribs.getToken( XML_linestyle );
     336           0 :             mrTypeModel.maStrokeModel.moEndCap = rAttribs.getToken( XML_endcap );
     337           0 :             mrTypeModel.maStrokeModel.moJoinStyle = rAttribs.getToken( XML_joinstyle );
     338           0 :         break;
     339             :         case VML_TOKEN( fill ):
     340           0 :             mrTypeModel.maFillModel.moFilled.assignIfUsed( lclDecodeBool( rAttribs, XML_on ) );
     341           0 :             mrTypeModel.maFillModel.moColor.assignIfUsed( rAttribs.getString( XML_color ) );
     342           0 :             mrTypeModel.maFillModel.moOpacity = lclDecodeOpacity( rAttribs, XML_opacity, 1.0 );
     343           0 :             mrTypeModel.maFillModel.moColor2 = rAttribs.getString( XML_color2 );
     344           0 :             mrTypeModel.maFillModel.moOpacity2 = lclDecodeOpacity( rAttribs, XML_opacity2, 1.0 );
     345           0 :             mrTypeModel.maFillModel.moType = rAttribs.getToken( XML_type );
     346           0 :             mrTypeModel.maFillModel.moAngle = rAttribs.getInteger( XML_angle );
     347           0 :             mrTypeModel.maFillModel.moFocus = lclDecodePercent( rAttribs, XML_focus, 0.0 );
     348           0 :             mrTypeModel.maFillModel.moFocusPos = lclDecodePercentPair( rAttribs, XML_focusposition );
     349           0 :             mrTypeModel.maFillModel.moFocusSize = lclDecodePercentPair( rAttribs, XML_focussize );
     350           0 :             mrTypeModel.maFillModel.moBitmapPath = decodeFragmentPath( rAttribs, O_TOKEN( relid ) );
     351           0 :             mrTypeModel.maFillModel.moRotate = lclDecodeBool( rAttribs, XML_rotate );
     352           0 :         break;
     353             :         case VML_TOKEN( imagedata ):
     354             :         {
     355             :             // shapes in docx use r:id for the relationship id
     356             :             // in xlsx it they use o:relid
     357           0 :             bool bHasORelId = rAttribs.hasAttribute( O_TOKEN( relid ) );
     358           0 :             mrTypeModel.moGraphicPath = decodeFragmentPath( rAttribs, bHasORelId ? O_TOKEN( relid ) : R_TOKEN( id ) );
     359           0 :             mrTypeModel.moGraphicTitle = rAttribs.getString( O_TOKEN( title ) );
     360             :         }
     361           0 :         break;
     362             :         case NMSP_vmlWord | XML_wrap:
     363           0 :             mrTypeModel.moWrapAnchorX = rAttribs.getString(XML_anchorx);
     364           0 :             mrTypeModel.moWrapAnchorY = rAttribs.getString(XML_anchory);
     365           0 :             mrTypeModel.moWrapType = rAttribs.getString(XML_type);
     366           0 :             mrTypeModel.moWrapSide = rAttribs.getString(XML_side);
     367           0 :         break;
     368             :         case VML_TOKEN( shadow ):
     369             :         {
     370           0 :             mrTypeModel.maShadowModel.mbHasShadow = true;
     371           0 :             mrTypeModel.maShadowModel.moShadowOn.assignIfUsed(lclDecodeBool(rAttribs, XML_on));
     372           0 :             mrTypeModel.maShadowModel.moColor.assignIfUsed(rAttribs.getString(XML_color));
     373           0 :             mrTypeModel.maShadowModel.moOffset.assignIfUsed(rAttribs.getString(XML_offset));
     374           0 :             mrTypeModel.maShadowModel.moOpacity = lclDecodePercent(rAttribs, XML_opacity, 1.0);
     375             :         }
     376           0 :         break;
     377             :         case VML_TOKEN( textpath ):
     378           0 :             mrTypeModel.maTextpathModel.moString.assignIfUsed(rAttribs.getString(XML_string));
     379           0 :         break;
     380             :     }
     381           0 :     return 0;
     382             : }
     383             : 
     384           0 : OptValue< OUString > ShapeTypeContext::decodeFragmentPath( const AttributeList& rAttribs, sal_Int32 nToken ) const
     385             : {
     386           0 :     OptValue< OUString > oFragmentPath;
     387           0 :     OptValue< OUString > oRelId = rAttribs.getString( nToken );
     388           0 :     if( oRelId.has() )
     389           0 :         oFragmentPath = getFragmentPathFromRelId( oRelId.get() );
     390           0 :     return oFragmentPath;
     391             : }
     392             : 
     393           0 : void ShapeTypeContext::setStyle( const OUString& rStyle )
     394             : {
     395           0 :     sal_Int32 nIndex = 0;
     396           0 :     while( nIndex >= 0 )
     397             :     {
     398           0 :         OUString aName, aValue;
     399           0 :         if( ConversionHelper::separatePair( aName, aValue, rStyle.getToken( 0, ';', nIndex ), ':' ) )
     400             :         {
     401           0 :                  if( aName == "position" )      mrTypeModel.maPosition = aValue;
     402           0 :             else if( aName == "z-index" )        mrTypeModel.maZIndex = aValue;
     403           0 :             else if( aName == "left" )           mrTypeModel.maLeft = aValue;
     404           0 :             else if( aName == "top" )            mrTypeModel.maTop = aValue;
     405           0 :             else if( aName == "width" )          mrTypeModel.maWidth = aValue;
     406           0 :             else if( aName == "height" )         mrTypeModel.maHeight = aValue;
     407           0 :             else if( aName == "margin-left" )    mrTypeModel.maMarginLeft = aValue;
     408           0 :             else if( aName == "margin-top" )     mrTypeModel.maMarginTop = aValue;
     409           0 :             else if( aName == "mso-position-vertical-relative" )  mrTypeModel.maPositionVerticalRelative = aValue;
     410           0 :             else if( aName == "mso-position-horizontal-relative" )  mrTypeModel.maPositionHorizontalRelative = aValue;
     411           0 :             else if( aName == "mso-position-horizontal" ) mrTypeModel.maPositionHorizontal = aValue;
     412           0 :             else if( aName == "mso-position-vertical" ) mrTypeModel.maPositionVertical = aValue;
     413           0 :             else if( aName == "mso-width-percent" ) mrTypeModel.maWidthPercent = aValue;
     414           0 :             else if( aName == "mso-width-relative" ) mrTypeModel.maWidthRelative = aValue;
     415           0 :             else if( aName == "mso-height-percent" ) mrTypeModel.maHeightPercent = aValue;
     416           0 :             else if( aName == "mso-height-relative" ) mrTypeModel.maHeightRelative = aValue;
     417           0 :             else if( aName == "mso-fit-shape-to-text" )           mrTypeModel.mbAutoHeight = true;
     418           0 :             else if( aName == "rotation" )       mrTypeModel.maRotation = aValue;
     419           0 :             else if( aName == "flip" )       mrTypeModel.maFlip = aValue;
     420           0 :             else if( aName.equalsAscii( "visibility" ) )
     421           0 :                 mrTypeModel.mbVisible = !aValue.equalsAscii( "hidden" );
     422           0 :             else if( aName == "mso-wrap-style" ) mrTypeModel.maWrapStyle = aValue;
     423           0 :             else if ( aName == "v-text-anchor" ) mrTypeModel.maVTextAnchor = aValue;
     424           0 :             else if ( aName == "mso-wrap-distance-left" ) mrTypeModel.maWrapDistanceLeft = aValue;
     425           0 :             else if ( aName == "mso-wrap-distance-right" ) mrTypeModel.maWrapDistanceRight = aValue;
     426           0 :             else if ( aName == "mso-wrap-distance-top" ) mrTypeModel.maWrapDistanceTop = aValue;
     427           0 :             else if ( aName == "mso-wrap-distance-bottom" ) mrTypeModel.maWrapDistanceBottom = aValue;
     428             :         }
     429           0 :     }
     430           0 : }
     431             : 
     432             : 
     433             : 
     434           0 : ShapeContext::ShapeContext( ContextHandler2Helper& rParent, ShapeBase& rShape, const AttributeList& rAttribs ) :
     435             :     ShapeTypeContext( rParent, rShape, rAttribs ),
     436             :     mrShape( rShape ),
     437           0 :     mrShapeModel( rShape.getShapeModel() )
     438             : {
     439             :     // collect shape specific attributes
     440           0 :     mrShapeModel.maType = rAttribs.getXString( XML_type, OUString() );
     441             :     // polyline path
     442           0 :     setPoints( rAttribs.getString( XML_points, OUString() ) );
     443             :     // line start and end positions
     444           0 :     setFrom(rAttribs.getString(XML_from, OUString()));
     445           0 :     setTo(rAttribs.getString(XML_to, OUString()));
     446           0 :     setControl1(rAttribs.getString(XML_control1, OUString()));
     447           0 :     setControl2(rAttribs.getString(XML_control2, OUString()));
     448           0 :     setVmlPath(rAttribs.getString(XML_path, OUString()));
     449           0 : }
     450             : 
     451           0 : ContextHandlerRef ShapeContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
     452             : {
     453             :     // Excel specific shape client data
     454           0 :     if( isRootElement() ) switch( nElement )
     455             :     {
     456             :         case VML_TOKEN( textbox ):
     457           0 :             if (getParentElement() != VML_TOKEN( group ))
     458             :             {
     459             :                 // Custom shape in Writer with a textbox are transformed into a frame
     460           0 :                 dynamic_cast<SimpleShape&>( mrShape ).setService(
     461           0 :                         "com.sun.star.text.TextFrame");
     462             :             }
     463           0 :             else if (getCurrentElement() == VML_TOKEN(rect))
     464             :                 // Transform only rectangles into a TextShape inside a groupshape.
     465           0 :                 dynamic_cast<SimpleShape&>(mrShape).setService("com.sun.star.drawing.TextShape");
     466           0 :             return new TextBoxContext( *this, mrShapeModel.createTextBox(mrShape.getTypeModel()), rAttribs,
     467           0 :                 mrShape.getDrawing().getFilter().getGraphicHelper());
     468             :         case VMLX_TOKEN( ClientData ):
     469           0 :             return new ClientDataContext( *this, mrShapeModel.createClientData(), rAttribs );
     470             :         case VMLPPT_TOKEN( textdata ):
     471             :             // Force RectangleShape, this is ugly :(
     472             :             // and is there because of the lines above which change it to TextFrame
     473           0 :             dynamic_cast< SimpleShape& >( mrShape ).setService(
     474           0 :                     "com.sun.star.drawing.RectangleShape");
     475           0 :             mrShapeModel.maLegacyDiagramPath = getFragmentPathFromRelId(rAttribs.getString(XML_id, OUString()));
     476           0 :             break;
     477             :     }
     478             :     // handle remaining stuff in base class
     479           0 :     return ShapeTypeContext::onCreateContext( nElement, rAttribs );
     480             : }
     481             : 
     482           0 : void ShapeContext::setPoints( const OUString& rPoints )
     483             : {
     484           0 :     mrShapeModel.maPoints.clear();
     485           0 :     sal_Int32 nIndex = 0;
     486             : 
     487           0 :     while( nIndex >= 0 )
     488             :     {
     489           0 :         sal_Int32 nX = rPoints.getToken( 0, ',', nIndex ).toInt32();
     490           0 :         sal_Int32 nY = rPoints.getToken( 0, ',', nIndex ).toInt32();
     491           0 :         mrShapeModel.maPoints.push_back( awt::Point( nX, nY ) );
     492             :     }
     493           0 : }
     494             : 
     495           0 : void ShapeContext::setFrom( const OUString& rPoints )
     496             : {
     497           0 :     if (!rPoints.isEmpty())
     498           0 :         mrShapeModel.maFrom = rPoints;
     499           0 : }
     500             : 
     501           0 : void ShapeContext::setTo( const OUString& rPoints )
     502             : {
     503           0 :     if (!rPoints.isEmpty())
     504           0 :         mrShapeModel.maTo = rPoints;
     505           0 : }
     506             : 
     507           0 : void ShapeContext::setControl1( const OUString& rPoints )
     508             : {
     509           0 :     if (!rPoints.isEmpty())
     510           0 :         mrShapeModel.maControl1 = rPoints;
     511           0 : }
     512             : 
     513           0 : void ShapeContext::setControl2( const OUString& rPoints )
     514             : {
     515           0 :     if (!rPoints.isEmpty())
     516           0 :         mrShapeModel.maControl2 = rPoints;
     517           0 : }
     518           0 : void ShapeContext::setVmlPath( const OUString& rPath )
     519             : {
     520           0 :     if (!rPath.isEmpty())
     521           0 :         mrShapeModel.maVmlPath = rPath;
     522           0 : }
     523             : 
     524             : 
     525             : 
     526             : 
     527           0 : GroupShapeContext::GroupShapeContext( ContextHandler2Helper& rParent, GroupShape& rShape, const AttributeList& rAttribs ) :
     528             :     ShapeContext( rParent, rShape, rAttribs ),
     529           0 :     mrShapes( rShape.getChildren() )
     530             : {
     531           0 : }
     532             : 
     533           0 : ContextHandlerRef GroupShapeContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
     534             : {
     535             :     // try to create a context of an embedded shape
     536           0 :     ContextHandlerRef xContext = createShapeContext( *this, mrShapes, nElement, rAttribs );
     537             :     // handle remaining stuff of this shape in base class
     538           0 :     return xContext.get() ? xContext : ShapeContext::onCreateContext( nElement, rAttribs );
     539             : }
     540             : 
     541             : 
     542             : 
     543           0 : RectangleShapeContext::RectangleShapeContext( ContextHandler2Helper& rParent, const AttributeList& rAttribs, RectangleShape& rShape ) :
     544           0 :     ShapeContext( rParent, rShape, rAttribs )
     545             : {
     546           0 : }
     547             : 
     548           0 : ContextHandlerRef RectangleShapeContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
     549             : {
     550             :     // The parent class's context is fine
     551           0 :     return ShapeContext::onCreateContext( nElement, rAttribs );
     552             : }
     553             : 
     554             : 
     555             : } // namespace vml
     556           0 : } // namespace oox
     557             : 
     558             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10