LCOV - code coverage report
Current view: top level - sc/source/filter/oox - drawingfragment.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 118 353 33.4 %
Date: 2012-08-25 Functions: 20 30 66.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 87 656 13.3 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include "drawingfragment.hxx"
      30                 :            : 
      31                 :            : #include <com/sun/star/beans/PropertyValue.hpp>
      32                 :            : #include <com/sun/star/container/XNameReplace.hpp>
      33                 :            : #include <com/sun/star/document/XEventsSupplier.hpp>
      34                 :            : #include <com/sun/star/drawing/XControlShape.hpp>
      35                 :            : #include <com/sun/star/script/ScriptEventDescriptor.hpp>
      36                 :            : #include <com/sun/star/script/XEventAttacherManager.hpp>
      37                 :            : #include <rtl/strbuf.hxx>
      38                 :            : #include "oox/drawingml/connectorshapecontext.hxx"
      39                 :            : #include "oox/drawingml/graphicshapecontext.hxx"
      40                 :            : #include "oox/helper/attributelist.hxx"
      41                 :            : #include "oox/helper/propertyset.hxx"
      42                 :            : #include "oox/vml/vmlshape.hxx"
      43                 :            : #include "oox/vml/vmlshapecontainer.hxx"
      44                 :            : #include "formulaparser.hxx"
      45                 :            : #include "stylesbuffer.hxx"
      46                 :            : #include "themebuffer.hxx"
      47                 :            : #include "unitconverter.hxx"
      48                 :            : 
      49                 :            : namespace oox {
      50                 :            : namespace xls {
      51                 :            : 
      52                 :            : using ::rtl::OUString;
      53                 :            : 
      54                 :            : // ============================================================================
      55                 :            : 
      56                 :            : using namespace ::com::sun::star::awt;
      57                 :            : using namespace ::com::sun::star::beans;
      58                 :            : using namespace ::com::sun::star::container;
      59                 :            : using namespace ::com::sun::star::document;
      60                 :            : using namespace ::com::sun::star::drawing;
      61                 :            : using namespace ::com::sun::star::script;
      62                 :            : using namespace ::com::sun::star::table;
      63                 :            : using namespace ::com::sun::star::uno;
      64                 :            : using namespace ::com::sun::star::xml::sax;
      65                 :            : using namespace ::oox::core;
      66                 :            : using namespace ::oox::drawingml;
      67                 :            : using namespace ::oox::ole;
      68                 :            : 
      69                 :            : using ::rtl::OStringBuffer;
      70                 :            : using ::rtl::OUString;
      71                 :            : using ::rtl::OUStringToOString;
      72                 :            : // no using's for ::oox::vml, that may clash with ::oox::drawingml types
      73                 :            : 
      74                 :            : // ============================================================================
      75                 :            : 
      76                 :          0 : ShapeMacroAttacher::ShapeMacroAttacher( const OUString& rMacroName, const Reference< XShape >& rxShape ) :
      77                 :            :     VbaMacroAttacherBase( rMacroName ),
      78                 :          0 :     mxShape( rxShape )
      79                 :            : {
      80                 :          0 : }
      81                 :            : 
      82                 :          0 : void ShapeMacroAttacher::attachMacro( const OUString& rMacroUrl )
      83                 :            : {
      84                 :            :     try
      85                 :            :     {
      86         [ #  # ]:          0 :         Reference< XEventsSupplier > xSupplier( mxShape, UNO_QUERY_THROW );
      87 [ #  # ][ #  # ]:          0 :         Reference< XNameReplace > xEvents( xSupplier->getEvents(), UNO_SET_THROW );
                 [ #  # ]
      88         [ #  # ]:          0 :         Sequence< PropertyValue > aEventProps( 2 );
      89 [ #  # ][ #  # ]:          0 :         aEventProps[ 0 ].Name = CREATE_OUSTRING( "EventType" );
      90 [ #  # ][ #  # ]:          0 :         aEventProps[ 0 ].Value <<= CREATE_OUSTRING( "Script" );
                 [ #  # ]
      91 [ #  # ][ #  # ]:          0 :         aEventProps[ 1 ].Name = CREATE_OUSTRING( "Script" );
      92 [ #  # ][ #  # ]:          0 :         aEventProps[ 1 ].Value <<= rMacroUrl;
      93 [ #  # ][ #  # ]:          0 :         xEvents->replaceByName( CREATE_OUSTRING( "OnClick" ), Any( aEventProps ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
      94                 :            :     }
      95                 :          0 :     catch( Exception& )
      96                 :            :     {
      97                 :            :     }
      98                 :          0 : }
      99                 :            : 
     100                 :            : // ============================================================================
     101                 :            : 
     102                 :          0 : Shape::Shape( const WorksheetHelper& rHelper, const AttributeList& rAttribs, const sal_Char* pcServiceName ) :
     103                 :            :     ::oox::drawingml::Shape( pcServiceName ),
     104         [ #  # ]:          0 :     WorksheetHelper( rHelper )
     105                 :            : {
     106         [ #  # ]:          0 :     OUString aMacro = rAttribs.getXString( XML_macro, OUString() );
     107         [ #  # ]:          0 :     if( !aMacro.isEmpty() )
     108 [ #  # ][ #  # ]:          0 :         maMacroName = getFormulaParser().importMacroName( aMacro );
     109                 :          0 : }
     110                 :            : 
     111                 :          0 : void Shape::finalizeXShape( XmlFilterBase& rFilter, const Reference< XShapes >& rxShapes )
     112                 :            : {
     113 [ #  # ][ #  # ]:          0 :     if( !maMacroName.isEmpty() && mxShape.is() )
                 [ #  # ]
     114                 :            :     {
     115 [ #  # ][ #  # ]:          0 :         VbaMacroAttacherRef xAttacher( new ShapeMacroAttacher( maMacroName, mxShape ) );
                 [ #  # ]
     116 [ #  # ][ #  # ]:          0 :         getBaseFilter().getVbaProject().registerMacroAttacher( xAttacher );
         [ #  # ][ #  # ]
     117                 :            :     }
     118                 :          0 :     ::oox::drawingml::Shape::finalizeXShape( rFilter, rxShapes );
     119                 :          0 : }
     120                 :            : 
     121                 :            : // ============================================================================
     122                 :            : 
     123                 :          0 : GroupShapeContext::GroupShapeContext( ContextHandler& rParent,
     124                 :            :         const WorksheetHelper& rHelper, const ShapePtr& rxParentShape, const ShapePtr& rxShape ) :
     125                 :            :     ShapeGroupContext( rParent, rxParentShape, rxShape ),
     126 [ #  # ][ #  # ]:          0 :     WorksheetHelper( rHelper )
         [ #  # ][ #  # ]
     127                 :            : {
     128                 :          0 : }
     129                 :            : 
     130                 :          0 : /*static*/ ContextHandlerRef GroupShapeContext::createShapeContext( ContextHandler& rParent,
     131                 :            :         const WorksheetHelper& rHelper, sal_Int32 nElement, const AttributeList& rAttribs,
     132                 :            :         const ShapePtr& rxParentShape, ShapePtr* pxShape )
     133                 :            : {
     134   [ #  #  #  #  :          0 :     switch( nElement )
                   #  # ]
     135                 :            :     {
     136                 :            :         case XDR_TOKEN( sp ):
     137                 :            :         {
     138 [ #  # ][ #  # ]:          0 :             ShapePtr xShape( new Shape( rHelper, rAttribs, "com.sun.star.drawing.CustomShape" ) );
                 [ #  # ]
     139 [ #  # ][ #  # ]:          0 :             if( pxShape ) *pxShape = xShape;
     140 [ #  # ][ #  # ]:          0 :             return new ShapeContext( rParent, rxParentShape, xShape );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     141                 :            :         }
     142                 :            :         case XDR_TOKEN( cxnSp ):
     143                 :            :         {
     144 [ #  # ][ #  # ]:          0 :             ShapePtr xShape( new Shape( rHelper, rAttribs, "com.sun.star.drawing.ConnectorShape" ) );
                 [ #  # ]
     145 [ #  # ][ #  # ]:          0 :             if( pxShape ) *pxShape = xShape;
     146 [ #  # ][ #  # ]:          0 :             return new ConnectorShapeContext( rParent, rxParentShape, xShape );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     147                 :            :         }
     148                 :            :         case XDR_TOKEN( pic ):
     149                 :            :         {
     150 [ #  # ][ #  # ]:          0 :             ShapePtr xShape( new Shape( rHelper, rAttribs, "com.sun.star.drawing.GraphicObjectShape" ) );
                 [ #  # ]
     151 [ #  # ][ #  # ]:          0 :             if( pxShape ) *pxShape = xShape;
     152 [ #  # ][ #  # ]:          0 :             return new GraphicShapeContext( rParent, rxParentShape, xShape );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     153                 :            :         }
     154                 :            :         case XDR_TOKEN( graphicFrame ):
     155                 :            :         {
     156 [ #  # ][ #  # ]:          0 :             ShapePtr xShape( new Shape( rHelper, rAttribs, "com.sun.star.drawing.GraphicObjectShape" ) );
                 [ #  # ]
     157 [ #  # ][ #  # ]:          0 :             if( pxShape ) *pxShape = xShape;
     158 [ #  # ][ #  # ]:          0 :             return new GraphicalObjectFrameContext( rParent, rxParentShape, xShape, rHelper.getSheetType() != SHEETTYPE_CHARTSHEET );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     159                 :            :         }
     160                 :            :         case XDR_TOKEN( grpSp ):
     161                 :            :         {
     162 [ #  # ][ #  # ]:          0 :             ShapePtr xShape( new Shape( rHelper, rAttribs, "com.sun.star.drawing.GroupShape" ) );
                 [ #  # ]
     163 [ #  # ][ #  # ]:          0 :             if( pxShape ) *pxShape = xShape;
     164 [ #  # ][ #  # ]:          0 :             return new GroupShapeContext( rParent, rHelper, rxParentShape, xShape );
     165                 :            :         }
     166                 :            :     }
     167                 :          0 :     return 0;
     168                 :            : }
     169                 :            : 
     170                 :          0 : Reference< XFastContextHandler > SAL_CALL GroupShapeContext::createFastChildContext(
     171                 :            :         sal_Int32 nElement, const Reference< XFastAttributeList >& rxAttribs ) throw (SAXException, RuntimeException)
     172                 :            : {
     173 [ #  # ][ #  # ]:          0 :     ContextHandlerRef xContext = createShapeContext( *this, *this, nElement, AttributeList( rxAttribs ), mpGroupShapePtr );
                 [ #  # ]
     174 [ #  # ][ #  # ]:          0 :     return xContext.get() ? xContext.get() : ShapeGroupContext::createFastChildContext( nElement, rxAttribs );
         [ #  # ][ #  # ]
     175                 :            : }
     176                 :            : 
     177                 :            : // ============================================================================
     178                 :            : 
     179                 :          6 : DrawingFragment::DrawingFragment( const WorksheetHelper& rHelper, const OUString& rFragmentPath ) :
     180                 :            :     WorksheetFragmentBase( rHelper, rFragmentPath ),
     181 [ +  - ][ +  - ]:          6 :     mxDrawPage( rHelper.getDrawPage(), UNO_QUERY )
                 [ +  - ]
     182                 :            : {
     183                 :            :     OSL_ENSURE( mxDrawPage.is(), "DrawingFragment::DrawingFragment - missing drawing page" );
     184                 :          6 : }
     185                 :            : 
     186                 :          6 : ContextHandlerRef DrawingFragment::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
     187                 :            : {
     188   [ +  -  -  -  :          6 :     switch( getCurrentElement() )
                      - ]
     189                 :            :     {
     190                 :            :         case XML_ROOT_CONTEXT:
     191         [ +  - ]:          6 :             if( nElement == XDR_TOKEN( wsDr ) ) return this;
     192                 :          0 :         break;
     193                 :            : 
     194                 :            :         case XDR_TOKEN( wsDr ):
     195         [ #  # ]:          0 :             switch( nElement )
     196                 :            :             {
     197                 :            :                 case XDR_TOKEN( absoluteAnchor ):
     198                 :            :                 case XDR_TOKEN( oneCellAnchor ):
     199                 :            :                 case XDR_TOKEN( twoCellAnchor ):
     200         [ #  # ]:          0 :                     mxAnchor.reset( new ShapeAnchor( *this ) );
     201                 :          0 :                     mxAnchor->importAnchor( nElement, rAttribs );
     202                 :          0 :                     return this;
     203                 :            :             }
     204                 :          0 :         break;
     205                 :            : 
     206                 :            :         case XDR_TOKEN( absoluteAnchor ):
     207                 :            :         case XDR_TOKEN( oneCellAnchor ):
     208                 :            :         case XDR_TOKEN( twoCellAnchor ):
     209                 :            :         {
     210   [ #  #  #  #  :          0 :             switch( nElement )
                      # ]
     211                 :            :             {
     212                 :            :                 case XDR_TOKEN( from ):
     213                 :          0 :                 case XDR_TOKEN( to ):           return this;
     214                 :            : 
     215         [ #  # ]:          0 :                 case XDR_TOKEN( pos ):          if( mxAnchor.get() ) mxAnchor->importPos( rAttribs );           break;
     216         [ #  # ]:          0 :                 case XDR_TOKEN( ext ):          if( mxAnchor.get() ) mxAnchor->importExt( rAttribs );           break;
     217         [ #  # ]:          0 :                 case XDR_TOKEN( clientData ):   if( mxAnchor.get() ) mxAnchor->importClientData( rAttribs );    break;
     218                 :            : 
     219         [ #  # ]:          0 :                 default:                        return GroupShapeContext::createShapeContext( *this, *this, nElement, rAttribs, ShapePtr(), &mxShape );
     220                 :            :             }
     221                 :            :         }
     222                 :          0 :         break;
     223                 :            : 
     224                 :            :         case XDR_TOKEN( from ):
     225                 :            :         case XDR_TOKEN( to ):
     226         [ #  # ]:          0 :             switch( nElement )
     227                 :            :             {
     228                 :            :                 case XDR_TOKEN( col ):
     229                 :            :                 case XDR_TOKEN( row ):
     230                 :            :                 case XDR_TOKEN( colOff ):
     231                 :          0 :                 case XDR_TOKEN( rowOff ):       return this;    // collect index in onCharacters()
     232                 :            :             }
     233                 :          0 :         break;
     234                 :            :     }
     235                 :          6 :     return 0;
     236                 :            : }
     237                 :            : 
     238                 :          0 : void DrawingFragment::onCharacters( const OUString& rChars )
     239                 :            : {
     240         [ #  # ]:          0 :     switch( getCurrentElement() )
     241                 :            :     {
     242                 :            :         case XDR_TOKEN( col ):
     243                 :            :         case XDR_TOKEN( row ):
     244                 :            :         case XDR_TOKEN( colOff ):
     245                 :            :         case XDR_TOKEN( rowOff ):
     246         [ #  # ]:          0 :             if( mxAnchor.get() ) mxAnchor->setCellPos( getCurrentElement(), getParentElement(), rChars );
     247                 :          0 :         break;
     248                 :            :     }
     249                 :          0 : }
     250                 :            : 
     251                 :         12 : void DrawingFragment::onEndElement()
     252                 :            : {
     253         [ -  + ]:         12 :     switch( getCurrentElement() )
     254                 :            :     {
     255                 :            :         case XDR_TOKEN( absoluteAnchor ):
     256                 :            :         case XDR_TOKEN( oneCellAnchor ):
     257                 :            :         case XDR_TOKEN( twoCellAnchor ):
     258 [ #  # ][ #  # ]:          0 :             if( mxDrawPage.is() && mxShape.get() && mxAnchor.get() )
         [ #  # ][ #  # ]
     259                 :            :             {
     260                 :            :                 // Rotation is decided by orientation of shape determined
     261                 :            :                 // by the anchor position given by 'twoCellAnchor'
     262 [ #  # ][ #  # ]:          0 :                 if ( getCurrentElement() == XDR_TOKEN( twoCellAnchor ) )
     263                 :          0 :                     mxShape->setRotation(0);
     264 [ #  # ][ #  # ]:          0 :                 EmuRectangle aShapeRectEmu = mxAnchor->calcAnchorRectEmu( getDrawPageSize() );
     265 [ #  # ][ #  # ]:          0 :                 if( (aShapeRectEmu.X >= 0) && (aShapeRectEmu.Y >= 0) && (aShapeRectEmu.Width >= 0) && (aShapeRectEmu.Height >= 0) )
         [ #  # ][ #  # ]
     266                 :            :                 {
     267                 :            :                     // TODO: DrawingML implementation expects 32-bit coordinates for EMU rectangles (change that to EmuRectangle)
     268                 :            :                     Rectangle aShapeRectEmu32(
     269         [ #  # ]:          0 :                         getLimitedValue< sal_Int32, sal_Int64 >( aShapeRectEmu.X, 0, SAL_MAX_INT32 ),
     270         [ #  # ]:          0 :                         getLimitedValue< sal_Int32, sal_Int64 >( aShapeRectEmu.Y, 0, SAL_MAX_INT32 ),
     271         [ #  # ]:          0 :                         getLimitedValue< sal_Int32, sal_Int64 >( aShapeRectEmu.Width, 0, SAL_MAX_INT32 ),
     272         [ #  # ]:          0 :                         getLimitedValue< sal_Int32, sal_Int64 >( aShapeRectEmu.Height, 0, SAL_MAX_INT32 ) );
     273                 :            : 
     274                 :            :                     // Make sure to set the position and size *before* calling addShape().
     275                 :          0 :                     mxShape->setPosition(Point(aShapeRectEmu.X, aShapeRectEmu.Y));
     276                 :          0 :                     mxShape->setSize(Size(aShapeRectEmu.Width, aShapeRectEmu.Height));
     277                 :            : 
     278         [ #  # ]:          0 :                     basegfx::B2DHomMatrix aTransformation;
     279 [ #  # ][ #  # ]:          0 :                     mxShape->addShape( getOoxFilter(), &getTheme(), mxDrawPage, aTransformation, &aShapeRectEmu32 );
         [ #  # ][ #  # ]
     280                 :            : 
     281                 :            :                     /*  Collect all shape positions in the WorksheetHelper base
     282                 :            :                         class. But first, scale EMUs to 1/100 mm. */
     283                 :            :                     Rectangle aShapeRectHmm(
     284 [ #  # ][ #  # ]:          0 :                         convertEmuToHmm( aShapeRectEmu.X ), convertEmuToHmm( aShapeRectEmu.Y ),
     285 [ #  # ][ #  # ]:          0 :                         convertEmuToHmm( aShapeRectEmu.Width ), convertEmuToHmm( aShapeRectEmu.Height ) );
     286 [ #  # ][ #  # ]:          0 :                     extendShapeBoundingBox( aShapeRectHmm );
     287                 :            :                 }
     288                 :            :             }
     289                 :          0 :             mxShape.reset();
     290                 :          0 :             mxAnchor.reset();
     291                 :          0 :         break;
     292                 :            :     }
     293                 :         12 : }
     294                 :            : 
     295                 :            : // ============================================================================
     296                 :            : // VML
     297                 :            : // ============================================================================
     298                 :            : 
     299                 :            : namespace {
     300                 :            : 
     301                 :            : class VmlFindNoteFunc
     302                 :            : {
     303                 :            : public:
     304                 :            :     explicit            VmlFindNoteFunc( const CellAddress& rPos );
     305                 :            :     bool                operator()( const ::oox::vml::ShapeBase& rShape ) const;
     306                 :            : 
     307                 :            : private:
     308                 :            :     sal_Int32           mnCol;
     309                 :            :     sal_Int32           mnRow;
     310                 :            : };
     311                 :            : 
     312                 :            : // ----------------------------------------------------------------------------
     313                 :            : 
     314                 :          3 : VmlFindNoteFunc::VmlFindNoteFunc( const CellAddress& rPos ) :
     315                 :            :     mnCol( rPos.Column ),
     316                 :          3 :     mnRow( rPos.Row )
     317                 :            : {
     318                 :          3 : }
     319                 :            : 
     320                 :          3 : bool VmlFindNoteFunc::operator()( const ::oox::vml::ShapeBase& rShape ) const
     321                 :            : {
     322                 :          3 :     const ::oox::vml::ClientData* pClientData = rShape.getClientData();
     323 [ +  - ][ +  - ]:          3 :     return pClientData && (pClientData->mnCol == mnCol) && (pClientData->mnRow == mnRow);
                 [ +  - ]
     324                 :            : }
     325                 :            : 
     326                 :            : } // namespace
     327                 :            : 
     328                 :            : // ============================================================================
     329                 :            : 
     330                 :          0 : VmlControlMacroAttacher::VmlControlMacroAttacher( const OUString& rMacroName,
     331                 :            :         const Reference< XIndexContainer >& rxCtrlFormIC, sal_Int32 nCtrlIndex, sal_Int32 nCtrlType, sal_Int32 nDropStyle ) :
     332                 :            :     VbaMacroAttacherBase( rMacroName ),
     333                 :            :     mxCtrlFormIC( rxCtrlFormIC ),
     334                 :            :     mnCtrlIndex( nCtrlIndex ),
     335                 :            :     mnCtrlType( nCtrlType ),
     336                 :          0 :     mnDropStyle( nDropStyle )
     337                 :            : {
     338                 :          0 : }
     339                 :            : 
     340                 :          0 : void VmlControlMacroAttacher::attachMacro( const OUString& rMacroUrl )
     341                 :            : {
     342                 :          0 :     ScriptEventDescriptor aEventDesc;
     343         [ #  # ]:          0 :     aEventDesc.ScriptType = CREATE_OUSTRING( "Script" );
     344                 :          0 :     aEventDesc.ScriptCode = rMacroUrl;
     345                 :            : 
     346                 :            :     // editable drop downs are treated like edit boxes
     347 [ #  # ][ #  # ]:          0 :     bool bEditDropDown = (mnCtrlType == XML_Drop) && (mnDropStyle == XML_ComboEdit);
     348         [ #  # ]:          0 :     sal_Int32 nCtrlType = bEditDropDown ? XML_Edit : mnCtrlType;
     349                 :            : 
     350   [ #  #  #  #  :          0 :     switch( nCtrlType )
                   #  # ]
     351                 :            :     {
     352                 :            :         case XML_Button:
     353                 :            :         case XML_Checkbox:
     354                 :            :         case XML_Radio:
     355         [ #  # ]:          0 :             aEventDesc.ListenerType = CREATE_OUSTRING( "XActionListener" );
     356         [ #  # ]:          0 :             aEventDesc.EventMethod = CREATE_OUSTRING( "actionPerformed" );
     357                 :          0 :         break;
     358                 :            :         case XML_Label:
     359                 :            :         case XML_GBox:
     360                 :            :         case XML_Dialog:
     361         [ #  # ]:          0 :             aEventDesc.ListenerType = CREATE_OUSTRING( "XMouseListener" );
     362         [ #  # ]:          0 :             aEventDesc.EventMethod = CREATE_OUSTRING( "mouseReleased" );
     363                 :          0 :         break;
     364                 :            :         case XML_Edit:
     365         [ #  # ]:          0 :             aEventDesc.ListenerType = CREATE_OUSTRING( "XTextListener" );
     366         [ #  # ]:          0 :             aEventDesc.EventMethod = CREATE_OUSTRING( "textChanged" );
     367                 :          0 :         break;
     368                 :            :         case XML_Spin:
     369                 :            :         case XML_Scroll:
     370         [ #  # ]:          0 :             aEventDesc.ListenerType = CREATE_OUSTRING( "XAdjustmentListener" );
     371         [ #  # ]:          0 :             aEventDesc.EventMethod = CREATE_OUSTRING( "adjustmentValueChanged" );
     372                 :          0 :         break;
     373                 :            :         case XML_List:
     374                 :            :         case XML_Drop:
     375         [ #  # ]:          0 :             aEventDesc.ListenerType = CREATE_OUSTRING( "XChangeListener" );
     376         [ #  # ]:          0 :             aEventDesc.EventMethod = CREATE_OUSTRING( "changed" );
     377                 :          0 :         break;
     378                 :            :         default:
     379                 :            :             OSL_ENSURE( false, "VmlControlMacroAttacher::attachMacro - unexpected object type" );
     380                 :          0 :             return;
     381                 :            :     }
     382                 :            : 
     383                 :            :     try
     384                 :            :     {
     385         [ #  # ]:          0 :         Reference< XEventAttacherManager > xEventMgr( mxCtrlFormIC, UNO_QUERY_THROW );
     386 [ #  # ][ #  # ]:          0 :         xEventMgr->registerScriptEvent( mnCtrlIndex, aEventDesc );
                 [ #  # ]
     387                 :            :     }
     388         [ #  # ]:          0 :     catch( Exception& )
     389                 :            :     {
     390         [ #  # ]:          0 :     }
     391                 :            : }
     392                 :            : 
     393                 :            : // ============================================================================
     394                 :            : 
     395                 :         60 : VmlDrawing::VmlDrawing( const WorksheetHelper& rHelper ) :
     396         [ +  - ]:         60 :     ::oox::vml::Drawing( rHelper.getOoxFilter(), rHelper.getDrawPage(), ::oox::vml::VMLDRAWING_EXCEL ),
     397                 :            :     WorksheetHelper( rHelper ),
     398 [ +  - ][ +  - ]:        120 :     maControlConv( rHelper.getBaseFilter().getModel(), rHelper.getBaseFilter().getGraphicHelper() )
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     399                 :            : {
     400                 :            :     // default font for legacy listboxes and dropdowns: Tahoma, 8pt
     401 [ +  - ][ +  - ]:         60 :     maListBoxFont.moName = CREATE_OUSTRING( "Tahoma" );
     402 [ +  - ][ +  - ]:         60 :     maListBoxFont.moColor = CREATE_OUSTRING( "auto" );
     403         [ +  - ]:         60 :     maListBoxFont.monSize = 160;
     404                 :         60 : }
     405                 :            : 
     406                 :          3 : const ::oox::vml::ShapeBase* VmlDrawing::getNoteShape( const CellAddress& rPos ) const
     407                 :            : {
     408         [ +  - ]:          3 :     return getShapes().findShape( VmlFindNoteFunc( rPos ) );
     409                 :            : }
     410                 :            : 
     411                 :          6 : bool VmlDrawing::isShapeSupported( const ::oox::vml::ShapeBase& rShape ) const
     412                 :            : {
     413                 :          6 :     const ::oox::vml::ClientData* pClientData = rShape.getClientData();
     414 [ +  + ][ +  - ]:          6 :     return !pClientData || (pClientData->mnObjType != XML_Note);
     415                 :            : }
     416                 :            : 
     417                 :          3 : OUString VmlDrawing::getShapeBaseName( const ::oox::vml::ShapeBase& rShape ) const
     418                 :            : {
     419         [ +  - ]:          3 :     if( const ::oox::vml::ClientData* pClientData = rShape.getClientData() )
     420                 :            :     {
     421   [ -  +  -  -  :          3 :         switch( pClientData->mnObjType )
          -  -  -  -  -  
             -  -  -  -  
                      - ]
     422                 :            :         {
     423                 :          0 :             case XML_Button:    return CREATE_OUSTRING( "Button" );
     424                 :          3 :             case XML_Checkbox:  return CREATE_OUSTRING( "Check Box" );
     425                 :          0 :             case XML_Dialog:    return CREATE_OUSTRING( "Dialog Frame" );
     426                 :          0 :             case XML_Drop:      return CREATE_OUSTRING( "Drop Down" );
     427                 :          0 :             case XML_Edit:      return CREATE_OUSTRING( "Edit Box" );
     428                 :          0 :             case XML_GBox:      return CREATE_OUSTRING( "Group Box" );
     429                 :          0 :             case XML_Label:     return CREATE_OUSTRING( "Label" );
     430                 :          0 :             case XML_List:      return CREATE_OUSTRING( "List Box" );
     431                 :          0 :             case XML_Note:      return CREATE_OUSTRING( "Comment" );
     432 [ #  # ][ #  # ]:          0 :             case XML_Pict:      return (pClientData->mbDde || getOleObjectInfo( rShape.getShapeId() )) ? CREATE_OUSTRING( "Object" ) : CREATE_OUSTRING( "Picture" );
     433                 :          0 :             case XML_Radio:     return CREATE_OUSTRING( "Option Button" );
     434                 :          0 :             case XML_Scroll:    return CREATE_OUSTRING( "Scroll Bar" );
     435                 :          0 :             case XML_Spin:      return CREATE_OUSTRING( "Spinner" );
     436                 :            :         }
     437                 :            :     }
     438                 :          3 :     return ::oox::vml::Drawing::getShapeBaseName( rShape );
     439                 :            : }
     440                 :            : 
     441                 :          6 : bool VmlDrawing::convertClientAnchor( Rectangle& orShapeRect, const OUString& rShapeAnchor ) const
     442                 :            : {
     443         [ -  + ]:          6 :     if( rShapeAnchor.isEmpty() )
     444                 :          0 :         return false;
     445         [ +  - ]:          6 :     ShapeAnchor aAnchor( *this );
     446         [ +  - ]:          6 :     aAnchor.importVmlAnchor( rShapeAnchor );
     447 [ +  - ][ +  - ]:          6 :     orShapeRect = aAnchor.calcAnchorRectHmm( getDrawPageSize() );
     448 [ +  - ][ +  - ]:          6 :     return (orShapeRect.Width >= 0) && (orShapeRect.Height >= 0);
                 [ +  - ]
     449                 :            : }
     450                 :            : 
     451                 :          3 : Reference< XShape > VmlDrawing::createAndInsertClientXShape( const ::oox::vml::ShapeBase& rShape,
     452                 :            :         const Reference< XShapes >& rxShapes, const Rectangle& rShapeRect ) const
     453                 :            : {
     454                 :            :     // simulate the legacy drawing controls with OLE form controls
     455         [ +  - ]:          3 :     OUString aShapeName = rShape.getShapeName();
     456                 :          3 :     const ::oox::vml::ClientData* pClientData = rShape.getClientData();
     457 [ +  - ][ +  - ]:          3 :     if( !aShapeName.isEmpty() && pClientData )
                 [ +  - ]
     458                 :            :     {
     459                 :          3 :         Rectangle aShapeRect = rShapeRect;
     460                 :          3 :         const ::oox::vml::TextBox* pTextBox = rShape.getTextBox();
     461         [ +  - ]:          3 :         EmbeddedControl aControl( aShapeName );
     462   [ -  -  -  -  :          3 :         switch( pClientData->mnObjType )
          +  -  -  -  -  
                -  -  - ]
     463                 :            :         {
     464                 :            :             case XML_Button:
     465                 :            :             {
     466         [ #  # ]:          0 :                 AxCommandButtonModel& rAxModel = aControl.createModel< AxCommandButtonModel >();
     467         [ #  # ]:          0 :                 convertControlText( rAxModel.maFontData, rAxModel.mnTextColor, rAxModel.maCaption, pTextBox, pClientData->mnTextHAlign );
     468                 :          0 :                 rAxModel.mnFlags = AX_FLAGS_ENABLED | AX_FLAGS_OPAQUE | AX_FLAGS_WORDWRAP;
     469                 :          0 :                 rAxModel.mnVerticalAlign = pClientData->mnTextVAlign;
     470                 :            :             }
     471                 :          0 :             break;
     472                 :            : 
     473                 :            :             case XML_Label:
     474                 :            :             {
     475         [ #  # ]:          0 :                 AxLabelModel& rAxModel = aControl.createModel< AxLabelModel >();
     476         [ #  # ]:          0 :                 convertControlText( rAxModel.maFontData, rAxModel.mnTextColor, rAxModel.maCaption, pTextBox, pClientData->mnTextHAlign );
     477                 :          0 :                 rAxModel.mnFlags = AX_FLAGS_ENABLED | AX_FLAGS_WORDWRAP;
     478                 :          0 :                 rAxModel.mnBorderStyle = AX_BORDERSTYLE_NONE;
     479                 :          0 :                 rAxModel.mnSpecialEffect = AX_SPECIALEFFECT_FLAT;
     480                 :          0 :                 rAxModel.mnVerticalAlign = pClientData->mnTextVAlign;
     481                 :            :             }
     482                 :          0 :             break;
     483                 :            : 
     484                 :            :             case XML_Edit:
     485                 :            :             {
     486 [ #  # ][ #  # ]:          0 :                 bool bNumeric = (pClientData->mnVTEdit == ::oox::vml::VML_CLIENTDATA_INTEGER) || (pClientData->mnVTEdit == ::oox::vml::VML_CLIENTDATA_NUMBER);
     487                 :            :                 AxMorphDataModelBase& rAxModel = bNumeric ?
     488         [ #  # ]:          0 :                     static_cast< AxMorphDataModelBase& >( aControl.createModel< AxNumericFieldModel >() ) :
     489 [ #  # ][ #  # ]:          0 :                     static_cast< AxMorphDataModelBase& >( aControl.createModel< AxTextBoxModel >() );
     490         [ #  # ]:          0 :                 convertControlText( rAxModel.maFontData, rAxModel.mnTextColor, rAxModel.maValue, pTextBox, pClientData->mnTextHAlign );
     491                 :          0 :                 setFlag( rAxModel.mnFlags, AX_FLAGS_MULTILINE, pClientData->mbMultiLine );
     492                 :          0 :                 setFlag( rAxModel.mnScrollBars, AX_SCROLLBAR_VERTICAL, pClientData->mbVScroll );
     493         [ #  # ]:          0 :                 if( pClientData->mbSecretEdit )
     494                 :          0 :                     rAxModel.mnPasswordChar = '*';
     495                 :            :             }
     496                 :          0 :             break;
     497                 :            : 
     498                 :            :             case XML_GBox:
     499                 :            :             {
     500         [ #  # ]:          0 :                 AxFrameModel& rAxModel = aControl.createModel< AxFrameModel >();
     501         [ #  # ]:          0 :                 convertControlText( rAxModel.maFontData, rAxModel.mnTextColor, rAxModel.maCaption, pTextBox, pClientData->mnTextHAlign );
     502         [ #  # ]:          0 :                 rAxModel.mnBorderStyle = pClientData->mbNo3D ? AX_BORDERSTYLE_SINGLE : AX_BORDERSTYLE_NONE;
     503         [ #  # ]:          0 :                 rAxModel.mnSpecialEffect = pClientData->mbNo3D ? AX_SPECIALEFFECT_FLAT : AX_SPECIALEFFECT_BUMPED;
     504                 :            : 
     505                 :            :                 /*  Move top border of groupbox up by half font height, because
     506                 :            :                     Excel specifies Y position of the groupbox border line
     507                 :            :                     instead the top border of the caption text. */
     508 [ #  # ][ #  # ]:          0 :                 if( const ::oox::vml::TextFontModel* pFontModel = pTextBox ? pTextBox->getFirstFont() : 0 )
                 [ #  # ]
     509                 :            :                 {
     510 [ #  # ][ #  # ]:          0 :                     sal_Int32 nFontHeightHmm = getUnitConverter().scaleToMm100( pFontModel->monSize.get( 160 ), UNIT_TWIP );
     511         [ #  # ]:          0 :                     sal_Int32 nYDiff = ::std::min< sal_Int32 >( nFontHeightHmm / 2, aShapeRect.Y );
     512                 :          0 :                     aShapeRect.Y -= nYDiff;
     513                 :          0 :                     aShapeRect.Height += nYDiff;
     514                 :            :                 }
     515                 :            :             }
     516                 :          0 :             break;
     517                 :            : 
     518                 :            :             case XML_Checkbox:
     519                 :            :             {
     520         [ +  - ]:          3 :                 AxCheckBoxModel& rAxModel = aControl.createModel< AxCheckBoxModel >();
     521         [ +  - ]:          3 :                 convertControlText( rAxModel.maFontData, rAxModel.mnTextColor, rAxModel.maCaption, pTextBox, pClientData->mnTextHAlign );
     522         [ +  - ]:          3 :                 convertControlBackground( rAxModel, rShape );
     523                 :          3 :                 rAxModel.maValue = OUString::valueOf( pClientData->mnChecked );
     524         [ +  - ]:          3 :                 rAxModel.mnSpecialEffect = pClientData->mbNo3D ? AX_SPECIALEFFECT_FLAT : AX_SPECIALEFFECT_SUNKEN;
     525                 :          3 :                 rAxModel.mnVerticalAlign = pClientData->mnTextVAlign;
     526 [ +  - ][ -  + ]:          3 :                 bool bTriState = (pClientData->mnChecked != ::oox::vml::VML_CLIENTDATA_UNCHECKED) && (pClientData->mnChecked != ::oox::vml::VML_CLIENTDATA_CHECKED);
     527         [ -  + ]:          3 :                 rAxModel.mnMultiSelect = bTriState ? AX_SELCTION_MULTI : AX_SELCTION_SINGLE;
     528                 :            :             }
     529                 :          3 :             break;
     530                 :            : 
     531                 :            :             case XML_Radio:
     532                 :            :             {
     533         [ #  # ]:          0 :                 AxOptionButtonModel& rAxModel = aControl.createModel< AxOptionButtonModel >();
     534         [ #  # ]:          0 :                 convertControlText( rAxModel.maFontData, rAxModel.mnTextColor, rAxModel.maCaption, pTextBox, pClientData->mnTextHAlign );
     535         [ #  # ]:          0 :                 convertControlBackground( rAxModel, rShape );
     536                 :          0 :                 rAxModel.maValue = OUString::valueOf( pClientData->mnChecked );
     537         [ #  # ]:          0 :                 rAxModel.mnSpecialEffect = pClientData->mbNo3D ? AX_SPECIALEFFECT_FLAT : AX_SPECIALEFFECT_SUNKEN;
     538                 :          0 :                 rAxModel.mnVerticalAlign = pClientData->mnTextVAlign;
     539                 :            :             }
     540                 :          0 :             break;
     541                 :            : 
     542                 :            :             case XML_List:
     543                 :            :             {
     544         [ #  # ]:          0 :                 AxListBoxModel& rAxModel = aControl.createModel< AxListBoxModel >();
     545         [ #  # ]:          0 :                 convertControlFontData( rAxModel.maFontData, rAxModel.mnTextColor, maListBoxFont );
     546         [ #  # ]:          0 :                 rAxModel.mnBorderStyle = pClientData->mbNo3D2 ? AX_BORDERSTYLE_SINGLE : AX_BORDERSTYLE_NONE;
     547         [ #  # ]:          0 :                 rAxModel.mnSpecialEffect = pClientData->mbNo3D2 ? AX_SPECIALEFFECT_FLAT : AX_SPECIALEFFECT_SUNKEN;
     548   [ #  #  #  # ]:          0 :                 switch( pClientData->mnSelType )
     549                 :            :                 {
     550                 :          0 :                     case XML_Single:    rAxModel.mnMultiSelect = AX_SELCTION_SINGLE;    break;
     551                 :          0 :                     case XML_Multi:     rAxModel.mnMultiSelect = AX_SELCTION_MULTI;     break;
     552                 :          0 :                     case XML_Extend:    rAxModel.mnMultiSelect = AX_SELCTION_EXTENDED;  break;
     553                 :            :                 }
     554                 :            :             }
     555                 :          0 :             break;
     556                 :            : 
     557                 :            :             case XML_Drop:
     558                 :            :             {
     559         [ #  # ]:          0 :                 AxComboBoxModel& rAxModel = aControl.createModel< AxComboBoxModel >();
     560         [ #  # ]:          0 :                 convertControlFontData( rAxModel.maFontData, rAxModel.mnTextColor, maListBoxFont );
     561                 :          0 :                 rAxModel.mnDisplayStyle = AX_DISPLAYSTYLE_DROPDOWN;
     562                 :          0 :                 rAxModel.mnShowDropButton = AX_SHOWDROPBUTTON_ALWAYS;
     563         [ #  # ]:          0 :                 rAxModel.mnBorderStyle = pClientData->mbNo3D2 ? AX_BORDERSTYLE_SINGLE : AX_BORDERSTYLE_NONE;
     564         [ #  # ]:          0 :                 rAxModel.mnSpecialEffect = pClientData->mbNo3D2 ? AX_SPECIALEFFECT_FLAT : AX_SPECIALEFFECT_SUNKEN;
     565                 :          0 :                 rAxModel.mnListRows = pClientData->mnDropLines;
     566                 :            :             }
     567                 :          0 :             break;
     568                 :            : 
     569                 :            :             case XML_Spin:
     570                 :            :             {
     571         [ #  # ]:          0 :                 AxSpinButtonModel& rAxModel = aControl.createModel< AxSpinButtonModel >();
     572                 :          0 :                 rAxModel.mnMin = pClientData->mnMin;
     573                 :          0 :                 rAxModel.mnMax = pClientData->mnMax;
     574                 :          0 :                 rAxModel.mnPosition = pClientData->mnVal;
     575                 :          0 :                 rAxModel.mnSmallChange = pClientData->mnInc;
     576                 :            :             }
     577                 :          0 :             break;
     578                 :            : 
     579                 :            :             case XML_Scroll:
     580                 :            :             {
     581         [ #  # ]:          0 :                 AxScrollBarModel& rAxModel = aControl.createModel< AxScrollBarModel >();
     582                 :          0 :                 rAxModel.mnMin = pClientData->mnMin;
     583                 :          0 :                 rAxModel.mnMax = pClientData->mnMax;
     584                 :          0 :                 rAxModel.mnPosition = pClientData->mnVal;
     585                 :          0 :                 rAxModel.mnSmallChange = pClientData->mnInc;
     586                 :          0 :                 rAxModel.mnLargeChange = pClientData->mnPage;
     587                 :            :             }
     588                 :          0 :             break;
     589                 :            : 
     590                 :            :             case XML_Dialog:
     591                 :            :             {
     592                 :            :                 // fake with a group box
     593         [ #  # ]:          0 :                 AxFrameModel& rAxModel = aControl.createModel< AxFrameModel >();
     594         [ #  # ]:          0 :                 convertControlText( rAxModel.maFontData, rAxModel.mnTextColor, rAxModel.maCaption, pTextBox, XML_Left );
     595                 :          0 :                 rAxModel.mnBorderStyle = AX_BORDERSTYLE_SINGLE;
     596                 :          0 :                 rAxModel.mnSpecialEffect = AX_SPECIALEFFECT_FLAT;
     597                 :            :             }
     598                 :          0 :             break;
     599                 :            :         }
     600                 :            : 
     601 [ +  - ][ +  - ]:          3 :         if( ControlModelBase* pAxModel = aControl.getModel() )
     602                 :            :         {
     603                 :            :             // create the control shape
     604                 :          3 :             pAxModel->maSize.first = aShapeRect.Width;
     605                 :          3 :             pAxModel->maSize.second = aShapeRect.Height;
     606                 :          3 :             sal_Int32 nCtrlIndex = -1;
     607         [ +  - ]:          3 :             Reference< XShape > xShape = createAndInsertXControlShape( aControl, rxShapes, aShapeRect, nCtrlIndex );
     608                 :            : 
     609                 :            :             // control shape macro
     610 [ +  - ][ +  - ]:          3 :             if( xShape.is() && (nCtrlIndex >= 0) && !pClientData->maFmlaMacro.isEmpty() )
         [ -  + ][ -  + ]
     611                 :            :             {
     612 [ #  # ][ #  # ]:          0 :                 OUString aMacroName = getFormulaParser().importMacroName( pClientData->maFmlaMacro );
     613         [ #  # ]:          0 :                 if( !aMacroName.isEmpty() )
     614                 :            :                 {
     615 [ #  # ][ #  # ]:          0 :                     Reference< XIndexContainer > xFormIC = getControlForm().getXForm();
     616 [ #  # ][ #  # ]:          0 :                     VbaMacroAttacherRef xAttacher( new VmlControlMacroAttacher( aMacroName, xFormIC, nCtrlIndex, pClientData->mnObjType, pClientData->mnDropStyle ) );
                 [ #  # ]
     617 [ #  # ][ #  # ]:          0 :                     getBaseFilter().getVbaProject().registerMacroAttacher( xAttacher );
         [ #  # ][ #  # ]
     618                 :          0 :                 }
     619                 :            :             }
     620                 :            : 
     621                 :          3 :             return xShape;
     622 [ +  - ][ -  + ]:          3 :         }
     623                 :            :     }
     624                 :            : 
     625                 :          3 :     return Reference< XShape >();
     626                 :            : }
     627                 :            : 
     628                 :          3 : void VmlDrawing::notifyXShapeInserted( const Reference< XShape >& rxShape,
     629                 :            :         const Rectangle& rShapeRect, const ::oox::vml::ShapeBase& rShape, bool bGroupChild )
     630                 :            : {
     631                 :            :     // collect all shape positions in the WorksheetHelper base class (but not children of group shapes)
     632         [ +  - ]:          3 :     if( !bGroupChild )
     633                 :          3 :         extendShapeBoundingBox( rShapeRect );
     634                 :            : 
     635                 :            :     // convert settings from VML client data
     636         [ +  - ]:          3 :     if( const ::oox::vml::ClientData* pClientData = rShape.getClientData() )
     637                 :            :     {
     638                 :            :         // specific settings for embedded form controls
     639                 :            :         try
     640                 :            :         {
     641         [ +  - ]:          3 :             Reference< XControlShape > xCtrlShape( rxShape, UNO_QUERY_THROW );
     642 [ +  - ][ +  - ]:          3 :             Reference< XControlModel > xCtrlModel( xCtrlShape->getControl(), UNO_SET_THROW );
                 [ +  - ]
     643         [ +  - ]:          3 :             PropertySet aPropSet( xCtrlModel );
     644                 :            : 
     645                 :            :             // printable
     646         [ +  - ]:          3 :             aPropSet.setProperty( PROP_Printable, pClientData->mbPrintObject );
     647                 :            : 
     648                 :            :             // control source links
     649 [ +  - ][ -  + ]:          3 :             if( !pClientData->maFmlaLink.isEmpty() || !pClientData->maFmlaRange.isEmpty() )
                 [ -  + ]
     650 [ #  # ][ #  # ]:          3 :                 maControlConv.bindToSources( xCtrlModel, pClientData->maFmlaLink, pClientData->maFmlaRange, getSheetIndex() );
         [ +  - ][ #  # ]
     651                 :            :         }
     652                 :          0 :         catch( Exception& )
     653                 :            :         {
     654                 :            :         }
     655                 :            :     }
     656                 :          3 : }
     657                 :            : 
     658                 :            : // private --------------------------------------------------------------------
     659                 :            : 
     660                 :          3 : sal_uInt32 VmlDrawing::convertControlTextColor( const OUString& rTextColor ) const
     661                 :            : {
     662                 :            :     // color attribute not present or 'auto' - use passed default color
     663 [ +  - ][ -  + ]:          3 :     if( rTextColor.isEmpty() || rTextColor.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "auto" ) ) )
                 [ -  + ]
     664                 :          0 :         return AX_SYSCOLOR_WINDOWTEXT;
     665                 :            : 
     666         [ +  - ]:          3 :     if( rTextColor[ 0 ] == '#' )
     667                 :            :     {
     668                 :            :         // RGB colors in the format '#RRGGBB'
     669         [ +  - ]:          3 :         if( rTextColor.getLength() == 7 )
     670         [ +  - ]:          3 :             return OleHelper::encodeOleColor( rTextColor.copy( 1 ).toInt32( 16 ) );
     671                 :            : 
     672                 :            :         // RGB colors in the format '#RGB'
     673         [ #  # ]:          0 :         if( rTextColor.getLength() == 4 )
     674                 :            :         {
     675                 :          0 :             sal_Int32 nR = rTextColor.copy( 1, 1 ).toInt32( 16 ) * 0x11;
     676                 :          0 :             sal_Int32 nG = rTextColor.copy( 2, 1 ).toInt32( 16 ) * 0x11;
     677                 :          0 :             sal_Int32 nB = rTextColor.copy( 3, 1 ).toInt32( 16 ) * 0x11;
     678                 :          0 :             return OleHelper::encodeOleColor( (nR << 16) | (nG << 8) | nB );
     679                 :            :         }
     680                 :            : 
     681                 :            :         OSL_ENSURE( false, OStringBuffer( "VmlDrawing::convertControlTextColor - invalid color name '" ).
     682                 :            :             append( OUStringToOString( rTextColor, RTL_TEXTENCODING_ASCII_US ) ).append( '\'' ).getStr() );
     683                 :          0 :         return AX_SYSCOLOR_WINDOWTEXT;
     684                 :            :     }
     685                 :            : 
     686                 :          0 :     const GraphicHelper& rGraphicHelper = getBaseFilter().getGraphicHelper();
     687                 :            : 
     688                 :            :     /*  Predefined color names or system color names (resolve to RGB to detect
     689                 :            :         valid color name). */
     690                 :          0 :     sal_Int32 nColorToken = AttributeConversion::decodeToken( rTextColor );
     691                 :          0 :     sal_Int32 nRgbValue = Color::getVmlPresetColor( nColorToken, API_RGB_TRANSPARENT );
     692         [ #  # ]:          0 :     if( nRgbValue == API_RGB_TRANSPARENT )
     693                 :          0 :         nRgbValue = rGraphicHelper.getSystemColor( nColorToken, API_RGB_TRANSPARENT );
     694         [ #  # ]:          0 :     if( nRgbValue != API_RGB_TRANSPARENT )
     695                 :          0 :         return OleHelper::encodeOleColor( nRgbValue );
     696                 :            : 
     697                 :            :     // try palette color
     698                 :          3 :     return OleHelper::encodeOleColor( rGraphicHelper.getPaletteColor( rTextColor.toInt32() ) );
     699                 :            : }
     700                 :            : 
     701                 :          3 : void VmlDrawing::convertControlFontData( AxFontData& rAxFontData, sal_uInt32& rnOleTextColor, const ::oox::vml::TextFontModel& rFontModel ) const
     702                 :            : {
     703         [ +  - ]:          3 :     if( rFontModel.moName.has() )
     704                 :          3 :         rAxFontData.maFontName = rFontModel.moName.get();
     705                 :            : 
     706                 :            :     // font height: convert from twips to points, then to internal representation of AX controls
     707         [ +  - ]:          3 :     rAxFontData.setHeightPoints( static_cast< sal_Int16 >( (rFontModel.monSize.get( 200 ) + 10) / 20 ) );
     708                 :            : 
     709                 :            :     // font effects
     710                 :          3 :     rAxFontData.mnFontEffects = 0;
     711                 :          3 :     setFlag( rAxFontData.mnFontEffects, AX_FONTDATA_BOLD, rFontModel.mobBold.get( false ) );
     712                 :          3 :     setFlag( rAxFontData.mnFontEffects, AX_FONTDATA_ITALIC, rFontModel.mobItalic.get( false ) );
     713                 :          3 :     setFlag( rAxFontData.mnFontEffects, AX_FONTDATA_STRIKEOUT, rFontModel.mobStrikeout.get( false ) );
     714                 :          3 :     sal_Int32 nUnderline = rFontModel.monUnderline.get( XML_none );
     715                 :          3 :     setFlag( rAxFontData.mnFontEffects, AX_FONTDATA_UNDERLINE, nUnderline != XML_none );
     716                 :          3 :     rAxFontData.mbDblUnderline = nUnderline == XML_double;
     717                 :            : 
     718                 :            :     // font color
     719         [ +  - ]:          3 :     rnOleTextColor = convertControlTextColor( rFontModel.moColor.get( OUString() ) );
     720                 :          3 : }
     721                 :            : 
     722                 :          3 : void VmlDrawing::convertControlText( AxFontData& rAxFontData, sal_uInt32& rnOleTextColor,
     723                 :            :         OUString& rCaption, const ::oox::vml::TextBox* pTextBox, sal_Int32 nTextHAlign ) const
     724                 :            : {
     725         [ +  - ]:          3 :     if( pTextBox )
     726                 :            :     {
     727                 :          3 :         rCaption = pTextBox->getText();
     728         [ +  - ]:          3 :         if( const ::oox::vml::TextFontModel* pFontModel = pTextBox->getFirstFont() )
     729                 :          3 :             convertControlFontData( rAxFontData, rnOleTextColor, *pFontModel );
     730                 :            :     }
     731                 :            : 
     732   [ +  -  -  - ]:          3 :     switch( nTextHAlign )
     733                 :            :     {
     734                 :          3 :         case XML_Left:      rAxFontData.mnHorAlign = AX_FONTDATA_LEFT;      break;
     735                 :          0 :         case XML_Center:    rAxFontData.mnHorAlign = AX_FONTDATA_CENTER;    break;
     736                 :          0 :         case XML_Right:     rAxFontData.mnHorAlign = AX_FONTDATA_RIGHT;     break;
     737                 :          0 :         default:            rAxFontData.mnHorAlign = AX_FONTDATA_LEFT;
     738                 :            :     }
     739                 :          3 : }
     740                 :            : 
     741                 :          3 : void VmlDrawing::convertControlBackground( AxMorphDataModelBase& rAxModel, const ::oox::vml::ShapeBase& rShape ) const
     742                 :            : {
     743                 :          3 :     const ::oox::vml::FillModel& rFillModel = rShape.getTypeModel().maFillModel;
     744                 :          3 :     bool bHasFill = rFillModel.moFilled.get( true );
     745                 :          3 :     setFlag( rAxModel.mnFlags, AX_FLAGS_OPAQUE, bHasFill );
     746         [ -  + ]:          3 :     if( bHasFill )
     747                 :            :     {
     748 [ #  # ][ #  # ]:          0 :         const GraphicHelper& rGraphicHelper = getBaseFilter().getGraphicHelper();
     749         [ #  # ]:          0 :         sal_Int32 nSysWindowColor = rGraphicHelper.getSystemColor( XML_window, API_RGB_WHITE );
     750         [ #  # ]:          0 :         ::oox::drawingml::Color aColor = ::oox::vml::ConversionHelper::decodeColor( rGraphicHelper, rFillModel.moColor, rFillModel.moOpacity, nSysWindowColor );
     751         [ #  # ]:          0 :         sal_Int32 nRgbValue = aColor.getColor( rGraphicHelper );
     752 [ #  # ][ #  # ]:          0 :         rAxModel.mnBackColor = OleHelper::encodeOleColor( nRgbValue );
     753                 :            :     }
     754                 :          3 : }
     755                 :            : 
     756                 :            : // ============================================================================
     757                 :            : 
     758                 :          6 : VmlDrawingFragment::VmlDrawingFragment( const WorksheetHelper& rHelper, const OUString& rFragmentPath ) :
     759                 :          6 :     ::oox::vml::DrawingFragment( rHelper.getOoxFilter(), rFragmentPath, rHelper.getVmlDrawing() ),
     760         [ +  - ]:          6 :     WorksheetHelper( rHelper )
     761                 :            : {
     762                 :          6 : }
     763                 :            : 
     764                 :          6 : void VmlDrawingFragment::finalizeImport()
     765                 :            : {
     766                 :          6 :     ::oox::vml::DrawingFragment::finalizeImport();
     767                 :          6 :     getVmlDrawing().convertAndInsert();
     768                 :          6 : }
     769                 :            : 
     770                 :            : // ============================================================================
     771                 :            : 
     772                 :            : } // namespace xls
     773 [ +  - ][ +  - ]:         24 : } // namespace oox
     774                 :            : 
     775                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10