LCOV - code coverage report
Current view: top level - sc/source/filter/xcl97 - xcl97esc.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 206 0.5 %
Date: 2012-08-25 Functions: 2 26 7.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 2 318 0.6 %

           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                 :            : 
      30                 :            : #include <com/sun/star/awt/XControlModel.hpp>
      31                 :            : #include <com/sun/star/embed/XClassifiedObject.hpp>
      32                 :            : #include <com/sun/star/form/XFormsSupplier.hpp>
      33                 :            : #include <com/sun/star/script/ScriptEventDescriptor.hpp>
      34                 :            : #include <com/sun/star/script/XEventAttacherManager.hpp>
      35                 :            : 
      36                 :            : #include <svx/svdpage.hxx>
      37                 :            : #include <editeng/outlobj.hxx>
      38                 :            : #include <svx/svdotext.hxx>
      39                 :            : #include <svx/svdobj.hxx>
      40                 :            : #include <svx/svdoole2.hxx>
      41                 :            : #include <svx/unoapi.hxx>
      42                 :            : #include <svx/fmglob.hxx>
      43                 :            : #include <vcl/outdev.hxx>
      44                 :            : #include <unotools/tempfile.hxx>
      45                 :            : #include <unotools/ucbstreamhelper.hxx>
      46                 :            : #include <svx/sdasitm.hxx>
      47                 :            : #include <sfx2/docfile.hxx>
      48                 :            : 
      49                 :            : #include <sot/exchange.hxx>
      50                 :            : #include "xeescher.hxx"
      51                 :            : 
      52                 :            : #include "global.hxx"
      53                 :            : #include "document.hxx"
      54                 :            : #include "drwlayer.hxx"
      55                 :            : #include "xecontent.hxx"
      56                 :            : #include <editeng/flditem.hxx>
      57                 :            : #include "userdat.hxx"
      58                 :            : #include "xcl97rec.hxx"
      59                 :            : #include "xehelper.hxx"
      60                 :            : #include "xechart.hxx"
      61                 :            : #include "xcl97esc.hxx"
      62                 :            : 
      63                 :            : using ::rtl::OUString;
      64                 :            : using ::com::sun::star::uno::Any;
      65                 :            : using ::com::sun::star::uno::Exception;
      66                 :            : using ::com::sun::star::uno::Reference;
      67                 :            : using ::com::sun::star::uno::Sequence;
      68                 :            : using ::com::sun::star::uno::UNO_QUERY;
      69                 :            : using ::com::sun::star::uno::UNO_QUERY_THROW;
      70                 :            : using ::com::sun::star::container::XIndexAccess;
      71                 :            : using ::com::sun::star::embed::XClassifiedObject;
      72                 :            : using ::com::sun::star::drawing::XShape;
      73                 :            : using ::com::sun::star::awt::XControlModel;
      74                 :            : using ::com::sun::star::form::XFormsSupplier;
      75                 :            : using ::com::sun::star::script::ScriptEventDescriptor;
      76                 :            : using ::com::sun::star::script::XEventAttacherManager;
      77                 :            : 
      78                 :            : // ============================================================================
      79                 :            : 
      80                 :          0 : XclEscherExGlobal::XclEscherExGlobal( const XclExpRoot& rRoot ) :
      81         [ #  # ]:          0 :     XclExpRoot( rRoot )
      82                 :            : {
      83         [ #  # ]:          0 :     SetBaseURI( GetMedium().GetBaseURL( true ) );
      84                 :          0 : }
      85                 :            : 
      86                 :          0 : SvStream* XclEscherExGlobal::ImplQueryPictureStream()
      87                 :            : {
      88         [ #  # ]:          0 :     mxPicTempFile.reset( new ::utl::TempFile );
      89         [ #  # ]:          0 :     if( mxPicTempFile->IsValid() )
      90                 :            :     {
      91                 :          0 :         mxPicTempFile->EnableKillingFile();
      92         [ #  # ]:          0 :         mxPicStrm.reset( ::utl::UcbStreamHelper::CreateStream( mxPicTempFile->GetURL(), STREAM_STD_READWRITE ) );
      93                 :          0 :         mxPicStrm->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
      94                 :            :     }
      95                 :          0 :     return mxPicStrm.get();
      96                 :            : }
      97                 :            : 
      98                 :            : // ============================================================================
      99                 :            : 
     100                 :          0 : XclEscherEx::XclEscherEx( const XclExpRoot& rRoot, XclExpObjectManager& rObjMgr, SvStream& rStrm, const XclEscherEx* pParent ) :
     101         [ #  # ]:          0 :     EscherEx( pParent ? pParent->mxGlobal : EscherExGlobalRef( new XclEscherExGlobal( rRoot ) ), &rStrm ),
     102                 :            :     XclExpRoot( rRoot ),
     103                 :            :     mrObjMgr( rObjMgr ),
     104                 :            :     pCurrXclObj( NULL ),
     105                 :            :     pCurrAppData( NULL ),
     106         [ #  # ]:          0 :     pTheClientData( new XclEscherClientData ),
     107                 :            :     pAdditionalText( NULL ),
     108                 :            :     nAdditionalText( 0 ),
     109                 :            :     mnNextKey( 0 ),
     110 [ #  # ][ #  # ]:          0 :     mbIsRootDff( pParent == 0 )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     111                 :            : {
     112         [ #  # ]:          0 :     InsertPersistOffset( mnNextKey, 0 );
     113                 :          0 : }
     114                 :            : 
     115                 :            : 
     116         [ #  # ]:          0 : XclEscherEx::~XclEscherEx()
     117                 :            : {
     118                 :            :     OSL_ENSURE( !aStack.empty(), "~XclEscherEx: stack not empty" );
     119         [ #  # ]:          0 :     DeleteCurrAppData();
     120 [ #  # ][ #  # ]:          0 :     delete pTheClientData;
     121         [ #  # ]:          0 : }
     122                 :            : 
     123                 :            : 
     124                 :          0 : sal_uInt32 XclEscherEx::InitNextDffFragment()
     125                 :            : {
     126                 :            :     /*  Current value of mnNextKey will be used by caller to refer to the
     127                 :            :         starting point of the DFF fragment. The key exists already in the
     128                 :            :         PersistTable (has been inserted by c'tor of previous call of
     129                 :            :         InitNextDffFragment(), has been updated by UpdateDffFragmentEnd(). */
     130                 :          0 :     sal_uInt32 nPersistKey = mnNextKey;
     131                 :            : 
     132                 :            :     /*  Prepare the next key that is used by caller as end point of the DFF
     133                 :            :         fragment. Will be updated by caller when writing to the DFF stream,
     134                 :            :         using the UpdateDffFragmentEnd() function. This is needed to find DFF
     135                 :            :         data written by the SVX base class implementation without interaction,
     136                 :            :         e.g. the solver container that will be written after the last shape. */
     137                 :          0 :     ++mnNextKey;
     138                 :          0 :     InsertPersistOffset( mnNextKey, mpOutStrm->Tell() );
     139                 :            : 
     140                 :          0 :     return nPersistKey;
     141                 :            : }
     142                 :            : 
     143                 :          0 : void XclEscherEx::UpdateDffFragmentEnd()
     144                 :            : {
     145                 :            :     // update existing fragment key with new stream position
     146                 :          0 :     ReplacePersistOffset( mnNextKey, mpOutStrm->Tell() );
     147                 :          0 : }
     148                 :            : 
     149                 :          0 : sal_uInt32 XclEscherEx::GetDffFragmentPos( sal_uInt32 nFragmentKey )
     150                 :            : {
     151                 :            :     /*  TODO: this function is non-const because PersistTable::PtGetOffsetByID()
     152                 :            :         is non-const due to tools/List usage. */
     153                 :          0 :     return GetPersistOffset( nFragmentKey );
     154                 :            : }
     155                 :            : 
     156                 :          0 : sal_uInt32 XclEscherEx::GetDffFragmentSize( sal_uInt32 nFragmentKey )
     157                 :            : {
     158                 :            :     /*  TODO: this function is non-const because PersistTable::PtGetOffsetByID()
     159                 :            :         is non-const due to tools/List usage. */
     160                 :          0 :     return GetDffFragmentPos( nFragmentKey + 1 ) - GetDffFragmentPos( nFragmentKey );
     161                 :            : }
     162                 :            : 
     163                 :          0 : bool XclEscherEx::HasPendingDffData()
     164                 :            : {
     165                 :            :     /*  TODO: this function is non-const because PersistTable::PtGetOffsetByID()
     166                 :            :         is non-const due to tools/List usage. */
     167                 :          0 :     return GetDffFragmentPos( mnNextKey ) < GetStreamPos();
     168                 :            : }
     169                 :            : 
     170                 :          0 : XclExpDffAnchorBase* XclEscherEx::CreateDffAnchor( const SdrObject& rSdrObj ) const
     171                 :            : {
     172                 :            :     // the object manager creates the correct anchor type according to context
     173                 :          0 :     XclExpDffAnchorBase* pAnchor = mrObjMgr.CreateDffAnchor();
     174                 :            :     // pass the drawing object, that will calculate the anchor position
     175                 :          0 :     pAnchor->SetSdrObject( rSdrObj );
     176                 :          0 :     return pAnchor;
     177                 :            : }
     178                 :            : 
     179                 :            : namespace {
     180                 :            : 
     181                 :          0 : bool lcl_IsFontwork( const SdrObject* pObj )
     182                 :            : {
     183                 :          0 :     bool bIsFontwork = false;
     184 [ #  # ][ #  # ]:          0 :     if( pObj->GetObjIdentifier() == OBJ_CUSTOMSHAPE )
     185                 :            :     {
     186         [ #  # ]:          0 :         const OUString aTextPath = CREATE_OUSTRING( "TextPath" );
     187                 :            :         SdrCustomShapeGeometryItem& rGeometryItem = (SdrCustomShapeGeometryItem&)
     188         [ #  # ]:          0 :             pObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY );
     189 [ #  # ][ #  # ]:          0 :         if( Any* pAny = rGeometryItem.GetPropertyValueByName( aTextPath, aTextPath ) )
     190                 :          0 :             *pAny >>= bIsFontwork;
     191                 :            :     }
     192                 :          0 :     return bIsFontwork;
     193                 :            : }
     194                 :            : 
     195                 :            : } // namespace
     196                 :            : 
     197                 :          0 : EscherExHostAppData* XclEscherEx::StartShape( const Reference< XShape >& rxShape, const Rectangle* pChildAnchor )
     198                 :            : {
     199         [ #  # ]:          0 :     if ( nAdditionalText )
     200                 :          0 :         nAdditionalText++;
     201                 :          0 :     sal_Bool bInGroup = ( pCurrXclObj != NULL );
     202         [ #  # ]:          0 :     if ( bInGroup )
     203                 :            :     {   // stacked recursive group object
     204         [ #  # ]:          0 :         if ( !pCurrAppData->IsStackedGroup() )
     205                 :            :         {   //! UpdateDffFragmentEnd only once
     206                 :          0 :             pCurrAppData->SetStackedGroup( sal_True );
     207                 :          0 :             UpdateDffFragmentEnd();
     208                 :            :         }
     209                 :            :     }
     210         [ #  # ]:          0 :     aStack.push( std::make_pair( pCurrXclObj, pCurrAppData ) );
     211                 :          0 :     pCurrAppData = new XclEscherHostAppData;
     212                 :          0 :     SdrObject* pObj = GetSdrObjectFromXShape( rxShape );
     213         [ #  # ]:          0 :     if ( !pObj )
     214         [ #  # ]:          0 :         pCurrXclObj = new XclObjAny( mrObjMgr, rxShape );  // just what is it?!?
     215                 :            :     else
     216                 :            :     {
     217                 :          0 :         pCurrXclObj = NULL;
     218                 :          0 :         sal_uInt16 nObjType = pObj->GetObjIdentifier();
     219                 :            : 
     220         [ #  # ]:          0 :         if( nObjType == OBJ_OLE2 )
     221                 :            :         {
     222                 :            :             // no OLE objects in embedded drawings (chart shapes)
     223         [ #  # ]:          0 :             if( mbIsRootDff )
     224                 :            :             {
     225                 :            :                 //! not-const because GetObjRef may load the OLE object
     226 [ #  # ][ #  # ]:          0 :                 Reference < XClassifiedObject > xObj( ((SdrOle2Obj*)pObj)->GetObjRef(), UNO_QUERY );
     227         [ #  # ]:          0 :                 if ( xObj.is() )
     228                 :            :                 {
     229 [ #  # ][ #  # ]:          0 :                     SvGlobalName aObjClsId( xObj->getClassID() );
         [ #  # ][ #  # ]
     230 [ #  # ][ #  # ]:          0 :                     if ( SotExchange::IsChart( aObjClsId ) )
     231                 :            :                     {   // yes, it's a chart diagram
     232 [ #  # ][ #  # ]:          0 :                         mrObjMgr.AddObj( new XclExpChartObj( mrObjMgr, rxShape, pChildAnchor ) );
                 [ #  # ]
     233                 :          0 :                         pCurrXclObj = NULL;     // no metafile or whatsoever
     234                 :            :                     }
     235                 :            :                     else    // metafile and OLE object
     236 [ #  # ][ #  # ]:          0 :                         pCurrXclObj = new XclObjOle( mrObjMgr, *pObj );
                 [ #  # ]
     237                 :            :                 }
     238                 :            :                 else    // just a metafile
     239 [ #  # ][ #  # ]:          0 :                     pCurrXclObj = new XclObjAny( mrObjMgr, rxShape );
     240                 :            :             }
     241                 :            :             else
     242         [ #  # ]:          0 :                 pCurrXclObj = new XclObjAny( mrObjMgr, rxShape );
     243                 :            :         }
     244         [ #  # ]:          0 :         else if( nObjType == OBJ_UNO )
     245                 :            :         {
     246                 :            : #if EXC_EXP_OCX_CTRL
     247                 :            :             // no ActiveX controls in embedded drawings (chart shapes)
     248                 :            :             if( mbIsRootDff )
     249                 :            :                 pCurrXclObj = CreateCtrlObj( rxShape, pChildAnchor );
     250                 :            : #else
     251         [ #  # ]:          0 :             pCurrXclObj = CreateCtrlObj( rxShape, pChildAnchor );
     252                 :            : #endif
     253         [ #  # ]:          0 :             if( !pCurrXclObj )
     254         [ #  # ]:          0 :                 pCurrXclObj = new XclObjAny( mrObjMgr, rxShape );   // just a metafile
     255                 :            :         }
     256         [ #  # ]:          0 :         else if( !ScDrawLayer::IsNoteCaption( pObj ) )
     257                 :            :         {
     258                 :            :             // ignore permanent note shapes
     259                 :            :             // #i12190# do not ignore callouts (do not filter by object type ID)
     260                 :          0 :             pCurrXclObj = ShapeInteractionHelper::CreateShapeObj( mrObjMgr, rxShape );
     261                 :          0 :             ShapeInteractionHelper::PopulateShapeInteractionInfo( mrObjMgr, rxShape, *pCurrAppData );
     262                 :            :         }
     263                 :            :     }
     264         [ #  # ]:          0 :     if ( pCurrXclObj )
     265                 :            :     {
     266         [ #  # ]:          0 :         if ( !mrObjMgr.AddObj( pCurrXclObj ) )
     267                 :            :         {   // maximum count reached, object got deleted
     268                 :          0 :             pCurrXclObj = NULL;
     269                 :            :         }
     270                 :            :         else
     271                 :            :         {
     272                 :          0 :             pCurrAppData->SetClientData( pTheClientData );
     273         [ #  # ]:          0 :             if ( nAdditionalText == 0 )
     274                 :            :             {
     275         [ #  # ]:          0 :                 if ( pObj )
     276                 :            :                 {
     277         [ #  # ]:          0 :                     if ( !bInGroup )
     278                 :            :                     {
     279                 :            :                         /*  Create a dummy anchor carrying the flags. Real
     280                 :            :                             coordinates are calculated later in virtual call of
     281                 :            :                             WriteData(EscherEx&,const Rectangle&). */
     282                 :          0 :                         XclExpDffAnchorBase* pAnchor = mrObjMgr.CreateDffAnchor();
     283                 :          0 :                         pAnchor->SetFlags( *pObj );
     284                 :          0 :                         pCurrAppData->SetClientAnchor( pAnchor );
     285                 :            :                     }
     286 [ #  # ][ #  # ]:          0 :                     const SdrTextObj* pTextObj = PTR_CAST( SdrTextObj, pObj );
     287 [ #  # ][ #  # ]:          0 :                     if( pTextObj && !lcl_IsFontwork( pTextObj ) && (pObj->GetObjIdentifier() != OBJ_CAPTION) )
         [ #  # ][ #  # ]
     288                 :            :                     {
     289                 :          0 :                         const OutlinerParaObject* pParaObj = pTextObj->GetOutlinerParaObject();
     290         [ #  # ]:          0 :                         if( pParaObj )
     291                 :            :                             pCurrAppData->SetClientTextbox(
     292         [ #  # ]:          0 :                                 new XclEscherClientTextbox( GetRoot(), *pTextObj, pCurrXclObj ) );
     293                 :            :                     }
     294                 :            :                 }
     295                 :            :                 else
     296                 :            :                 {
     297         [ #  # ]:          0 :                     if ( !bInGroup )
     298                 :          0 :                         pCurrAppData->SetClientAnchor( mrObjMgr.CreateDffAnchor() );
     299                 :            :                 }
     300                 :            :             }
     301         [ #  # ]:          0 :             else if ( nAdditionalText == 3 )
     302                 :            :             {
     303         [ #  # ]:          0 :                 if ( pAdditionalText )
     304                 :            :                 {
     305                 :          0 :                     pAdditionalText->SetXclObj( pCurrXclObj );
     306                 :          0 :                     pCurrAppData->SetClientTextbox( pAdditionalText );
     307                 :            :                 }
     308                 :            :             }
     309                 :            :         }
     310                 :            :     }
     311         [ #  # ]:          0 :     if ( !pCurrXclObj )
     312                 :          0 :         pCurrAppData->SetDontWriteShape( sal_True );
     313                 :          0 :     return pCurrAppData;
     314                 :            : }
     315                 :            : 
     316                 :            : 
     317                 :          0 : void XclEscherEx::EndShape( sal_uInt16 nShapeType, sal_uInt32 nShapeID )
     318                 :            : {
     319                 :            :     // own escher data created? -> never delete such objects
     320 [ #  # ][ #  # ]:          0 :     bool bOwnEscher = pCurrXclObj && pCurrXclObj->IsOwnEscher();
     321                 :            : 
     322                 :            :     // post process the current object - not for objects with own escher data
     323 [ #  # ][ #  # ]:          0 :     if( pCurrXclObj && !bOwnEscher )
     324                 :            :     {
     325                 :            :         // escher data of last shape not written? -> delete it from object list
     326         [ #  # ]:          0 :         if( nShapeID == 0 )
     327                 :            :         {
     328                 :          0 :             XclObj* pLastObj = mrObjMgr.RemoveLastObj();
     329                 :            :             OSL_ENSURE( pLastObj == pCurrXclObj, "XclEscherEx::EndShape - wrong object" );
     330         [ #  # ]:          0 :             DELETEZ( pLastObj );
     331                 :          0 :             pCurrXclObj = 0;
     332                 :            :         }
     333                 :            : 
     334         [ #  # ]:          0 :         if( pCurrXclObj )
     335                 :            :         {
     336                 :            :             // set shape type
     337         [ #  # ]:          0 :             if ( pCurrAppData->IsStackedGroup() )
     338                 :          0 :                 pCurrXclObj->SetEscherShapeTypeGroup();
     339                 :            :             else
     340                 :            :             {
     341                 :          0 :                 pCurrXclObj->SetEscherShapeType( nShapeType );
     342                 :          0 :                 UpdateDffFragmentEnd();
     343                 :            :             }
     344                 :            :         }
     345                 :            :     }
     346                 :            : 
     347                 :            :     // get next object from stack
     348                 :          0 :     DeleteCurrAppData();
     349         [ #  # ]:          0 :     if (aStack.empty())
     350                 :            :     {
     351                 :          0 :         pCurrXclObj = NULL;
     352                 :          0 :         pCurrAppData = NULL;
     353                 :            :     }
     354                 :            :     else
     355                 :            :     {
     356                 :          0 :         pCurrXclObj = aStack.top().first;
     357                 :          0 :         pCurrAppData = aStack.top().second;
     358                 :          0 :         aStack.pop();
     359                 :            :     }
     360         [ #  # ]:          0 :     if( nAdditionalText == 3 )
     361                 :          0 :         nAdditionalText = 0;
     362                 :          0 : }
     363                 :            : 
     364                 :            : 
     365                 :          0 : EscherExHostAppData* XclEscherEx::EnterAdditionalTextGroup()
     366                 :            : {
     367                 :          0 :     nAdditionalText = 1;
     368                 :          0 :     pAdditionalText = (XclEscherClientTextbox*) pCurrAppData->GetClientTextbox();
     369                 :          0 :     pCurrAppData->SetClientTextbox( NULL );
     370                 :          0 :     return pCurrAppData;
     371                 :            : }
     372                 :            : 
     373                 :          0 : void XclEscherEx::EndDocument()
     374                 :            : {
     375         [ #  # ]:          0 :     if( mbIsRootDff )
     376                 :          0 :         Flush( static_cast< XclEscherExGlobal& >( *mxGlobal ).GetPictureStream() );
     377                 :            : 
     378                 :            :     // seek back DFF stream to prepare saving the MSODRAWING[GROUP] records
     379                 :          0 :     mpOutStrm->Seek( 0 );
     380                 :          0 : }
     381                 :            : 
     382                 :            : #if EXC_EXP_OCX_CTRL
     383                 :            : 
     384                 :            : XclExpOcxControlObj* XclEscherEx::CreateCtrlObj( Reference< XShape > xShape, const Rectangle* pChildAnchor )
     385                 :            : {
     386                 :            :     ::std::auto_ptr< XclExpOcxControlObj > xOcxCtrl;
     387                 :            : 
     388                 :            :     Reference< XControlModel > xCtrlModel = XclControlHelper::GetControlModel( xShape );
     389                 :            :     if( xCtrlModel.is() )
     390                 :            :     {
     391                 :            :         // output stream
     392                 :            :         if( !mxCtlsStrm.Is() )
     393                 :            :             mxCtlsStrm = OpenStream( EXC_STREAM_CTLS );
     394                 :            :         if( mxCtlsStrm.Is() )
     395                 :            :         {
     396                 :            :             String aClassName;
     397                 :            :             sal_uInt32 nStrmStart = static_cast< sal_uInt32 >( mxCtlsStrm->Tell() );
     398                 :            : 
     399                 :            :             // writes from xCtrlModel into mxCtlsStrm, raw class name returned in aClassName
     400                 :            :             if( SvxMSConvertOCXControls::WriteOCXExcelKludgeStream( mxCtlsStrm, xCtrlModel, xShape->getSize(), aClassName ) )
     401                 :            :             {
     402                 :            :                 sal_uInt32 nStrmSize = static_cast< sal_uInt32 >( mxCtlsStrm->Tell() - nStrmStart );
     403                 :            :                 // adjust the class name to "Forms.***.1"
     404                 :            :                 aClassName.InsertAscii( "Forms.", 0 ).AppendAscii( ".1" );
     405                 :            :                 xOcxCtrl.reset( new XclExpOcxControlObj( mrObjMgr, xShape, pChildAnchor, aClassName, nStrmStart, nStrmSize ) );
     406                 :            :             }
     407                 :            :         }
     408                 :            :     }
     409                 :            :     return xOcxCtrl.release();
     410                 :            : }
     411                 :            : 
     412                 :            : #else
     413                 :            : 
     414                 :          0 : XclExpTbxControlObj* XclEscherEx::CreateCtrlObj( Reference< XShape > xShape, const Rectangle* pChildAnchor )
     415                 :            : {
     416 [ #  # ][ #  # ]:          0 :     ::std::auto_ptr< XclExpTbxControlObj > xTbxCtrl( new XclExpTbxControlObj( mrObjMgr, xShape, pChildAnchor ) );
     417         [ #  # ]:          0 :     if( xTbxCtrl->GetObjType() == EXC_OBJTYPE_UNKNOWN )
     418                 :          0 :         xTbxCtrl.reset();
     419                 :            : 
     420         [ #  # ]:          0 :     if( xTbxCtrl.get() )
     421                 :            :     {
     422                 :            :         // find attached macro
     423         [ #  # ]:          0 :         Reference< XControlModel > xCtrlModel = XclControlHelper::GetControlModel( xShape );
     424         [ #  # ]:          0 :         ConvertTbxMacro( *xTbxCtrl, xCtrlModel );
     425                 :            :     }
     426         [ #  # ]:          0 :     return xTbxCtrl.release();
     427                 :            : }
     428                 :            : 
     429                 :          0 : void XclEscherEx::ConvertTbxMacro( XclExpTbxControlObj& rTbxCtrlObj, Reference< XControlModel > xCtrlModel )
     430                 :            : {
     431                 :          0 :     SdrPage* pSdrPage = GetSdrPage( GetCurrScTab() );
     432 [ #  # ][ #  # ]:          0 :     if( xCtrlModel.is() && GetDocShell() && pSdrPage ) try
         [ #  # ][ #  # ]
     433                 :            :     {
     434 [ #  # ][ #  # ]:          0 :         Reference< XFormsSupplier > xFormsSupplier( pSdrPage->getUnoPage(), UNO_QUERY_THROW );
     435 [ #  # ][ #  # ]:          0 :         Reference< XIndexAccess > xFormsIA( xFormsSupplier->getForms(), UNO_QUERY_THROW );
                 [ #  # ]
     436                 :            : 
     437                 :            :         // 1) try to find the index of the processed control in the form
     438                 :            : 
     439                 :          0 :         Reference< XIndexAccess > xFormIA;  // needed in step 2) below
     440                 :          0 :         sal_Int32 nFoundIdx = -1;
     441                 :            : 
     442                 :            :         // search all existing forms in the draw page
     443 [ #  # ][ #  # ]:          0 :         for( sal_Int32 nFormIdx = 0, nFormCount = xFormsIA->getCount();
         [ #  # ][ #  # ]
                 [ #  # ]
     444                 :            :                 (nFoundIdx < 0) && (nFormIdx < nFormCount); ++nFormIdx )
     445                 :            :         {
     446                 :            :             // get the XIndexAccess interface of the form with index nFormIdx
     447 [ #  # ][ #  # ]:          0 :             if( xFormIA.set( xFormsIA->getByIndex( nFormIdx ), UNO_QUERY ) )
         [ #  # ][ #  # ]
     448                 :            :             {
     449                 :            :                 // search all elements (controls) of the current form by index
     450 [ #  # ][ #  # ]:          0 :                 for( sal_Int32 nCtrlIdx = 0, nCtrlCount = xFormIA->getCount();
         [ #  # ][ #  # ]
                 [ #  # ]
     451                 :            :                         (nFoundIdx < 0) && (nCtrlIdx < nCtrlCount); ++nCtrlIdx )
     452                 :            :                 {
     453                 :            :                     // compare implementation pointers of the control models
     454 [ #  # ][ #  # ]:          0 :                     Reference< XControlModel > xCurrModel( xFormIA->getByIndex( nCtrlIdx ), UNO_QUERY );
                 [ #  # ]
     455 [ #  # ][ #  # ]:          0 :                     if( xCtrlModel.get() == xCurrModel.get() )
                 [ #  # ]
     456                 :          0 :                         nFoundIdx = nCtrlIdx;
     457                 :          0 :                 }
     458                 :            :             }
     459                 :            :         }
     460                 :            : 
     461                 :            :         // 2) try to find an attached macro
     462                 :            : 
     463 [ #  # ][ #  # ]:          0 :         if( xFormIA.is() && (nFoundIdx >= 0) )
                 [ #  # ]
     464                 :            :         {
     465         [ #  # ]:          0 :             Reference< XEventAttacherManager > xEventMgr( xFormIA, UNO_QUERY_THROW );
     466                 :            :             // loop over all events attached to the found control
     467 [ #  # ][ #  # ]:          0 :             const Sequence< ScriptEventDescriptor > aEventSeq( xEventMgr->getScriptEvents( nFoundIdx ) );
     468                 :          0 :             bool bFound = false;
     469 [ #  # ][ #  # ]:          0 :             for( sal_Int32 nEventIdx = 0, nEventCount = aEventSeq.getLength();
                 [ #  # ]
     470                 :          0 :                     !bFound && (nEventIdx < nEventCount); ++nEventIdx )
     471                 :            :             {
     472                 :            :                 // try to set the event data at the Excel control object, returns true on success
     473         [ #  # ]:          0 :                 bFound = rTbxCtrlObj.SetMacroLink( aEventSeq[ nEventIdx ] );
     474         [ #  # ]:          0 :             }
     475         [ #  # ]:          0 :         }
     476                 :            :     }
     477                 :          0 :     catch( Exception& )
     478                 :            :     {
     479                 :            :     }
     480                 :          0 : }
     481                 :            : 
     482                 :            : #endif
     483                 :            : 
     484                 :          0 : void XclEscherEx::DeleteCurrAppData()
     485                 :            : {
     486         [ #  # ]:          0 :     if ( pCurrAppData )
     487                 :            :     {
     488         [ #  # ]:          0 :         delete pCurrAppData->GetClientAnchor();
     489                 :            : //      delete pCurrAppData->GetClientData();
     490         [ #  # ]:          0 :         delete pCurrAppData->GetClientTextbox();
     491         [ #  # ]:          0 :     delete pCurrAppData->GetInteractionInfo();
     492                 :          0 :         delete pCurrAppData;
     493                 :            :     }
     494                 :          0 : }
     495                 :            : 
     496                 :            : // ============================================================================
     497                 :            : 
     498                 :            : // --- class XclEscherClientData -------------------------------------
     499                 :            : 
     500                 :          0 : void XclEscherClientData::WriteData( EscherEx& rEx ) const
     501                 :            : {   // actual data is in the following OBJ record
     502                 :          0 :     rEx.AddAtom( 0, ESCHER_ClientData );
     503                 :          0 : }
     504                 :            : 
     505                 :            : 
     506                 :            : // --- class XclEscherClientTextbox -------------------------------------
     507                 :            : 
     508                 :          0 : XclEscherClientTextbox::XclEscherClientTextbox( const XclExpRoot& rRoot,
     509                 :            :             const SdrTextObj& rObj, XclObj* pObj )
     510                 :            :         :
     511                 :            :         XclExpRoot( rRoot ),
     512                 :            :         rTextObj( rObj ),
     513         [ #  # ]:          0 :         pXclObj( pObj )
     514                 :            : {
     515                 :          0 : }
     516                 :            : 
     517                 :            : 
     518                 :          0 : void XclEscherClientTextbox::WriteData( EscherEx& /*rEx*/ ) const
     519                 :            : {
     520                 :          0 :     pXclObj->SetText( GetRoot(), rTextObj );
     521                 :          0 : }
     522                 :            : 
     523                 :            : XclExpShapeObj*
     524                 :          0 : ShapeInteractionHelper::CreateShapeObj( XclExpObjectManager& rObjMgr, const Reference< XShape >& xShape )
     525                 :            : {
     526 [ #  # ][ #  # ]:          0 :     return new XclExpShapeObj( rObjMgr, xShape );
     527                 :            : }
     528                 :            : 
     529                 :            : void
     530                 :          0 : ShapeInteractionHelper::PopulateShapeInteractionInfo( XclExpObjectManager& rObjMgr, const Reference< XShape >& xShape, EscherExHostAppData& rHostAppData )
     531                 :            : {
     532                 :            :    try
     533                 :            :    {
     534                 :          0 :       SvMemoryStream* pMemStrm = NULL;
     535                 :          0 :       rtl::OUString sHyperLink;
     536                 :          0 :       rtl::OUString sMacro;
     537 [ #  # ][ #  # ]:          0 :       if ( ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( ::GetSdrObjectFromXShape( xShape ) ) )
     538                 :            :       {
     539                 :          0 :          sHyperLink = pInfo->GetHlink();
     540                 :          0 :          sMacro = pInfo->GetMacro();
     541                 :            :       }
     542         [ #  # ]:          0 :       if (  !sHyperLink.isEmpty() )
     543                 :            :       {
     544 [ #  # ][ #  # ]:          0 :          pMemStrm = new SvMemoryStream();
     545         [ #  # ]:          0 :          XclExpStream tmpStream( *pMemStrm, rObjMgr.GetRoot() );
     546                 :          0 :          ScAddress dummyAddress;
     547         [ #  # ]:          0 :          SvxURLField aUrlField;
     548                 :          0 :          aUrlField.SetURL( sHyperLink );
     549         [ #  # ]:          0 :          XclExpHyperlink hExpHlink( rObjMgr.GetRoot(), aUrlField, dummyAddress );
     550 [ #  # ][ #  # ]:          0 :          hExpHlink.WriteEmbeddedData( tmpStream );
         [ #  # ][ #  # ]
     551                 :            :       }
     552 [ #  # ][ #  # ]:          0 :       if ( !sHyperLink.isEmpty() || !sMacro.isEmpty() )
                 [ #  # ]
     553 [ #  # ][ #  # ]:          0 :           rHostAppData.SetInteractionInfo( new InteractionInfo( pMemStrm, true ) );
                 [ #  # ]
     554                 :            :    }
     555                 :          0 :    catch( Exception& )
     556                 :            :    {
     557                 :            :    }
     558 [ +  - ][ +  - ]:         24 : }
     559                 :            : 
     560                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10