LCOV - code coverage report
Current view: top level - sc/source/ui/unoobj - shapeuno.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 503 762 66.0 %
Date: 2015-06-13 12:38:46 Functions: 50 70 71.4 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <sal/config.h>
      21             : 
      22             : #include <comphelper/sequence.hxx>
      23             : #include <svtools/unoevent.hxx>
      24             : #include <svtools/unoimap.hxx>
      25             : #include <svx/svdobj.hxx>
      26             : #include <vcl/svapp.hxx>
      27             : #include <svx/unoshape.hxx>
      28             : #include <editeng/unofield.hxx>
      29             : #include <svx/shapepropertynotifier.hxx>
      30             : #include <toolkit/helper/convert.hxx>
      31             : #include <cppuhelper/implbase2.hxx>
      32             : #include <cppuhelper/supportsservice.hxx>
      33             : 
      34             : #include <com/sun/star/drawing/XShape.hpp>
      35             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      36             : 
      37             : #include "shapeuno.hxx"
      38             : #include "miscuno.hxx"
      39             : #include "cellsuno.hxx"
      40             : #include "textuno.hxx"
      41             : #include "fielduno.hxx"
      42             : #include "docsh.hxx"
      43             : #include "drwlayer.hxx"
      44             : #include "userdat.hxx"
      45             : #include "unonames.hxx"
      46             : 
      47             : using namespace ::com::sun::star;
      48             : 
      49         329 : static const SfxItemPropertyMapEntry* lcl_GetShapeMap()
      50             : {
      51             :     static const SfxItemPropertyMapEntry aShapeMap_Impl[] =
      52             :     {
      53          16 :         {OUString(SC_UNONAME_ANCHOR), 0, cppu::UnoType<uno::XInterface>::get(), 0, 0 },
      54          16 :         {OUString(SC_UNONAME_HORIPOS), 0, cppu::UnoType<sal_Int32>::get(), 0, 0 },
      55          16 :         {OUString(SC_UNONAME_IMAGEMAP), 0, cppu::UnoType<container::XIndexContainer>::get(), 0, 0 },
      56          16 :         {OUString(SC_UNONAME_VERTPOS), 0, cppu::UnoType<sal_Int32>::get(), 0, 0 },
      57          16 :         {OUString(SC_UNONAME_MOVEPROTECT), 0, cppu::UnoType<sal_Bool>::get(), 0, 0 },
      58             :         // #i66550 HLINK_FOR_SHAPES
      59          16 :         {OUString(SC_UNONAME_HYPERLINK), 0, cppu::UnoType<OUString>::get(), 0, 0 },
      60          16 :         {OUString(SC_UNONAME_URL), 0, cppu::UnoType<OUString>::get(), 0, 0 },
      61             :         { OUString(), 0, css::uno::Type(), 0, 0 }
      62         457 :     };
      63         329 :     return aShapeMap_Impl;
      64             : }
      65             : 
      66           8 : const SvEventDescription* ScShapeObj::GetSupportedMacroItems()
      67             : {
      68             :     static const SvEventDescription aMacroDescriptionsImpl[] =
      69             :     {
      70             :         { 0, NULL }
      71             :     };
      72           8 :     return aMacroDescriptionsImpl;
      73             : }
      74             : // #i66550 HLINK_FOR_SHAPES
      75          35 : ScMacroInfo* ScShapeObj_getShapeHyperMacroInfo( ScShapeObj* pShape, bool bCreate = false )
      76             : {
      77          35 :         if( pShape )
      78          35 :             if( SdrObject* pObj = pShape->GetSdrObject() )
      79          35 :                 return ScDrawLayer::GetMacroInfo( pObj, bCreate );
      80           0 :         return 0;
      81             : }
      82             : 
      83             : namespace
      84             : {
      85         278 :     void lcl_initializeNotifier( SdrObject& _rSdrObj, ::cppu::OWeakObject& _rShape )
      86             :     {
      87         278 :         svx::PPropertyValueProvider pProvider( new svx::PropertyValueProvider( _rShape, "Anchor" ) );
      88         278 :         _rSdrObj.getShapePropertyChangeNotifier().registerProvider( svx::eSpreadsheetAnchor, pProvider );
      89         278 :     }
      90             : }
      91             : 
      92         549 : ScShapeObj::ScShapeObj( uno::Reference<drawing::XShape>& xShape ) :
      93             :       pShapePropertySet(NULL),
      94             :       pShapePropertyState(NULL),
      95             :       bIsTextShape(false),
      96             :       bIsNoteCaption(false),
      97         549 :       bInitializedNotifier(false)
      98             : {
      99         549 :     osl_atomic_increment( &m_refCount );
     100             : 
     101             :     {
     102         549 :         mxShapeAgg = uno::Reference<uno::XAggregation>( xShape, uno::UNO_QUERY );
     103             :         // extra block to force deletion of the temporary before setDelegator
     104             :     }
     105             : 
     106         549 :     if (mxShapeAgg.is())
     107             :     {
     108         549 :         xShape = NULL;      // during setDelegator, mxShapeAgg must be the only ref
     109             : 
     110         549 :         mxShapeAgg->setDelegator( static_cast<cppu::OWeakObject*>(this) );
     111             : 
     112         549 :         xShape.set(uno::Reference<drawing::XShape>( mxShapeAgg, uno::UNO_QUERY ));
     113             : 
     114         549 :         bIsTextShape = ( SvxUnoTextBase::getImplementation( mxShapeAgg ) != NULL );
     115             :     }
     116             : 
     117             :     {
     118         549 :         SdrObject* pObj = GetSdrObject();
     119         549 :         if ( pObj )
     120             :         {
     121         278 :             bIsNoteCaption = ScDrawLayer::IsNoteCaption( pObj );
     122         278 :             lcl_initializeNotifier( *pObj, *this );
     123         278 :             bInitializedNotifier = true;
     124             :         }
     125             :     }
     126             : 
     127         549 :     osl_atomic_decrement( &m_refCount );
     128         549 : }
     129             : 
     130        1088 : ScShapeObj::~ScShapeObj()
     131             : {
     132             : //  if (mxShapeAgg.is())
     133             : //      mxShapeAgg->setDelegator(uno::Reference<uno::XInterface>());
     134        1088 : }
     135             : 
     136             : // XInterface
     137             : 
     138       15734 : uno::Any SAL_CALL ScShapeObj::queryInterface( const uno::Type& rType )
     139             :                                                 throw(uno::RuntimeException, std::exception)
     140             : {
     141       15734 :     uno::Any aRet = ScShapeObj_Base::queryInterface( rType );
     142             : 
     143       15734 :     if ( !aRet.hasValue() && bIsTextShape )
     144        5840 :         aRet = ScShapeObj_TextBase::queryInterface( rType );
     145             : 
     146       15734 :     if ( !aRet.hasValue() && bIsNoteCaption )
     147          61 :         aRet = ScShapeObj_ChildBase::queryInterface( rType );
     148             : 
     149       15734 :     if ( !aRet.hasValue() && mxShapeAgg.is() )
     150        6877 :         aRet = mxShapeAgg->queryAggregation( rType );
     151             : 
     152       15734 :     return aRet;
     153             : }
     154             : 
     155      179957 : void SAL_CALL ScShapeObj::acquire() throw()
     156             : {
     157      179957 :         OWeakObject::acquire();
     158      179957 : }
     159             : 
     160      179899 : void SAL_CALL ScShapeObj::release() throw()
     161             : {
     162      179899 :         OWeakObject::release();
     163      179899 : }
     164             : 
     165        4055 : void ScShapeObj::GetShapePropertySet()
     166             : {
     167             :     // #i61908# Store the result of queryAggregation in a member.
     168             :     // The reference in mxShapeAgg is kept for this object's lifetime, so the pointer is always valid.
     169             : 
     170        4055 :     if (!pShapePropertySet)
     171             :     {
     172         364 :         uno::Reference<beans::XPropertySet> xProp;
     173         364 :         if ( mxShapeAgg.is() )
     174         364 :             mxShapeAgg->queryAggregation( cppu::UnoType<beans::XPropertySet>::get()) >>= xProp;
     175         364 :         pShapePropertySet = xProp.get();
     176             :     }
     177        4055 : }
     178             : 
     179        2222 : void ScShapeObj::GetShapePropertyState()
     180             : {
     181             :     // #i61908# Store the result of queryAggregation in a member.
     182             :     // The reference in mxShapeAgg is kept for this object's lifetime, so the pointer is always valid.
     183             : 
     184        2222 :     if (!pShapePropertyState)
     185             :     {
     186          28 :         uno::Reference<beans::XPropertyState> xState;
     187          28 :         if ( mxShapeAgg.is() )
     188          28 :             mxShapeAgg->queryAggregation( cppu::UnoType<beans::XPropertyState>::get()) >>= xState;
     189          28 :         pShapePropertyState = xState.get();
     190             :     }
     191        2222 : }
     192             : 
     193         231 : static uno::Reference<lang::XComponent> lcl_GetComponent( const uno::Reference<uno::XAggregation>& xAgg )
     194             : {
     195         231 :     uno::Reference<lang::XComponent> xRet;
     196         231 :     if ( xAgg.is() )
     197         231 :         xAgg->queryAggregation( cppu::UnoType<lang::XComponent>::get()) >>= xRet;
     198         231 :     return xRet;
     199             : }
     200             : 
     201           2 : static uno::Reference<text::XText> lcl_GetText( const uno::Reference<uno::XAggregation>& xAgg )
     202             : {
     203           2 :     uno::Reference<text::XText> xRet;
     204           2 :     if ( xAgg.is() )
     205           2 :         xAgg->queryAggregation( cppu::UnoType<text::XText>::get()) >>= xRet;
     206           2 :     return xRet;
     207             : }
     208             : 
     209         110 : static uno::Reference<text::XSimpleText> lcl_GetSimpleText( const uno::Reference<uno::XAggregation>& xAgg )
     210             : {
     211         110 :     uno::Reference<text::XSimpleText> xRet;
     212         110 :     if ( xAgg.is() )
     213         110 :         xAgg->queryAggregation( cppu::UnoType<text::XSimpleText>::get()) >>= xRet;
     214         110 :     return xRet;
     215             : }
     216             : 
     217          69 : static uno::Reference<text::XTextRange> lcl_GetTextRange( const uno::Reference<uno::XAggregation>& xAgg )
     218             : {
     219          69 :     uno::Reference<text::XTextRange> xRet;
     220          69 :     if ( xAgg.is() )
     221          69 :         xAgg->queryAggregation( cppu::UnoType<text::XTextRange>::get()) >>= xRet;
     222          69 :     return xRet;
     223             : }
     224             : 
     225             : //  XPropertySet
     226             : 
     227        1462 : uno::Reference<beans::XPropertySetInfo> SAL_CALL ScShapeObj::getPropertySetInfo()
     228             :                                                         throw(uno::RuntimeException, std::exception)
     229             : {
     230        1462 :     SolarMutexGuard aGuard;
     231             : 
     232             :     // #i61527# cache property set info for this object
     233        1462 :     if ( !mxPropSetInfo.is() )
     234             :     {
     235             :         //  mix own and aggregated properties:
     236         329 :         GetShapePropertySet();
     237         329 :         if (pShapePropertySet)
     238             :         {
     239         329 :             uno::Reference<beans::XPropertySetInfo> xAggInfo(pShapePropertySet->getPropertySetInfo());
     240         658 :             const uno::Sequence<beans::Property> aPropSeq(xAggInfo->getProperties());
     241         658 :             mxPropSetInfo.set(new SfxExtItemPropertySetInfo( lcl_GetShapeMap(), aPropSeq ));
     242             :         }
     243             :     }
     244        1462 :     return mxPropSetInfo;
     245             : }
     246             : 
     247          18 : static bool lcl_GetPageNum( SdrPage* pPage, SdrModel& rModel, SCTAB& rNum )
     248             : {
     249          18 :     sal_uInt16 nCount = rModel.GetPageCount();
     250          18 :     for (sal_uInt16 i=0; i<nCount; i++)
     251          18 :         if ( rModel.GetPage(i) == pPage )
     252             :         {
     253          18 :             rNum = static_cast<SCTAB>(i);
     254          18 :             return true;
     255             :         }
     256             : 
     257           0 :     return false;
     258             : }
     259             : 
     260          13 : static bool lcl_GetCaptionPoint( uno::Reference< drawing::XShape >& xShape, awt::Point& rCaptionPoint )
     261             : {
     262          13 :     bool bReturn = false;
     263          13 :     OUString sType(xShape->getShapeType());
     264          13 :     bool bCaptionShape( sType == "com.sun.star.drawing.CaptionShape" );
     265          13 :     if (bCaptionShape)
     266             :     {
     267           0 :         uno::Reference < beans::XPropertySet > xShapeProp (xShape, uno::UNO_QUERY);
     268           0 :         if (xShapeProp.is())
     269             :         {
     270           0 :             xShapeProp->getPropertyValue("CaptionPoint") >>= rCaptionPoint;
     271           0 :             bReturn = true;
     272           0 :         }
     273             :     }
     274          13 :     return bReturn;
     275             : }
     276             : 
     277           7 : static ScRange lcl_GetAnchorCell( uno::Reference< drawing::XShape >& xShape, ScDocument* pDoc, SCTAB nTab,
     278             :                           awt::Point& rUnoPoint, awt::Size& rUnoSize, awt::Point& rCaptionPoint )
     279             : {
     280           7 :     ScRange aReturn;
     281           7 :     rUnoPoint = xShape->getPosition();
     282           7 :     bool bCaptionShape(lcl_GetCaptionPoint(xShape, rCaptionPoint));
     283           7 :     if (pDoc->IsNegativePage(nTab))
     284             :     {
     285           0 :         rUnoSize = xShape->getSize();
     286           0 :         rUnoPoint.X += rUnoSize.Width; // the right top point is base
     287           0 :         if (bCaptionShape)
     288             :         {
     289           0 :             if (rCaptionPoint.X > 0 && rCaptionPoint.X > rUnoSize.Width)
     290           0 :                 rUnoPoint.X += rCaptionPoint.X - rUnoSize.Width;
     291           0 :             if (rCaptionPoint.Y < 0)
     292           0 :                 rUnoPoint.Y += rCaptionPoint.Y;
     293             :         }
     294           0 :         aReturn = pDoc->GetRange( nTab, Rectangle( VCLPoint(rUnoPoint), VCLPoint(rUnoPoint) ));
     295             :     }
     296             :     else
     297             :     {
     298           7 :         if (bCaptionShape)
     299             :         {
     300           0 :             if (rCaptionPoint.X < 0)
     301           0 :                 rUnoPoint.X += rCaptionPoint.X;
     302           0 :             if (rCaptionPoint.Y < 0)
     303           0 :                 rUnoPoint.Y += rCaptionPoint.Y;
     304             :         }
     305           7 :         aReturn = pDoc->GetRange( nTab, Rectangle( VCLPoint(rUnoPoint), VCLPoint(rUnoPoint) ));
     306             :     }
     307             : 
     308           7 :     return aReturn;
     309             : }
     310             : 
     311           7 : static awt::Point lcl_GetRelativePos( uno::Reference< drawing::XShape >& xShape, ScDocument* pDoc, SCTAB nTab, ScRange& rRange,
     312             :                               awt::Size& rUnoSize, awt::Point& rCaptionPoint)
     313             : {
     314           7 :     awt::Point aUnoPoint;
     315           7 :     rRange = lcl_GetAnchorCell(xShape, pDoc, nTab, aUnoPoint, rUnoSize, rCaptionPoint);
     316           7 :     Rectangle aRect(pDoc->GetMMRect( rRange.aStart.Col(), rRange.aStart.Row(), rRange.aEnd.Col(), rRange.aEnd.Row(), rRange.aStart.Tab() ));
     317           7 :     Point aPoint = pDoc->IsNegativePage(nTab) ? aRect.TopRight() : aRect.TopLeft();
     318           7 :     aUnoPoint.X -= aPoint.X();
     319           7 :     aUnoPoint.Y -= aPoint.Y();
     320           7 :     return aUnoPoint;
     321             : }
     322             : 
     323        3665 : void SAL_CALL ScShapeObj::setPropertyValue(const OUString& aPropertyName, const uno::Any& aValue)
     324             :     throw(beans::UnknownPropertyException, beans::PropertyVetoException,
     325             :           lang::IllegalArgumentException, lang::WrappedTargetException,
     326             :           uno::RuntimeException, std::exception)
     327             : {
     328        3665 :     SolarMutexGuard aGuard;
     329        7330 :     OUString aNameString(aPropertyName);
     330             : 
     331        3665 :     if ( aNameString == SC_UNONAME_ANCHOR )
     332             :     {
     333           1 :         uno::Reference<sheet::XCellRangeAddressable> xRangeAdd(aValue, uno::UNO_QUERY);
     334           1 :         if (xRangeAdd.is())
     335             :         {
     336           1 :             SdrObject *pObj = GetSdrObject();
     337           1 :             if (pObj)
     338             :             {
     339           1 :                 ScDrawLayer* pModel = static_cast<ScDrawLayer*>(pObj->GetModel());
     340           1 :                 SdrPage* pPage = pObj->GetPage();
     341           1 :                 if ( pModel && pPage )
     342             :                 {
     343           1 :                     ScDocument* pDoc = pModel->GetDocument();
     344           1 :                     if ( pDoc )
     345             :                     {
     346           1 :                         SfxObjectShell* pObjSh = pDoc->GetDocumentShell();
     347           1 :                         if ( pObjSh && pObjSh->ISA(ScDocShell) )
     348             :                         {
     349           1 :                             ScDocShell* pDocSh = static_cast<ScDocShell*>(pObjSh);
     350             : 
     351           1 :                             SCTAB nTab = 0;
     352           1 :                             if ( lcl_GetPageNum( pPage, *pModel, nTab ) )
     353             :                             {
     354           1 :                                 table::CellRangeAddress aAddress = xRangeAdd->getRangeAddress();
     355           1 :                                 if (nTab == aAddress.Sheet)
     356             :                                 {
     357             :                                     Rectangle aRect(pDoc->GetMMRect( static_cast<SCCOL>(aAddress.StartColumn), static_cast<SCROW>(aAddress.StartRow),
     358           1 :                                         static_cast<SCCOL>(aAddress.EndColumn), static_cast<SCROW>(aAddress.EndRow), aAddress.Sheet ));
     359           1 :                                     awt::Point aRelPoint;
     360           1 :                                     uno::Reference<drawing::XShape> xShape( mxShapeAgg, uno::UNO_QUERY );
     361           1 :                                     if (xShape.is())
     362             :                                     {
     363           1 :                                         Point aPoint;
     364           1 :                                         Point aEndPoint;
     365           1 :                                         if (pDoc->IsNegativePage(nTab))
     366             :                                         {
     367           0 :                                             aPoint = aRect.TopRight();
     368           0 :                                             aEndPoint = aRect.BottomLeft();
     369             :                                         }
     370             :                                         else
     371             :                                         {
     372           1 :                                             aPoint = aRect.TopLeft();
     373           1 :                                             aEndPoint = aRect.BottomRight();
     374             :                                         }
     375           1 :                                         awt::Size aUnoSize;
     376           1 :                                         awt::Point aCaptionPoint;
     377           1 :                                         ScRange aRange;
     378           1 :                                         aRelPoint = lcl_GetRelativePos( xShape, pDoc, nTab, aRange, aUnoSize, aCaptionPoint );
     379           1 :                                         awt::Point aUnoPoint(aRelPoint);
     380             : 
     381           1 :                                         aUnoPoint.X += aPoint.X();
     382           1 :                                         aUnoPoint.Y += aPoint.Y();
     383             : 
     384           1 :                                         if ( aUnoPoint.Y > aEndPoint.Y() )
     385           0 :                                             aUnoPoint.Y = aEndPoint.Y() - 2;
     386           1 :                                         if (pDoc->IsNegativePage(nTab))
     387             :                                         {
     388           0 :                                             if ( aUnoPoint.X < aEndPoint.X() )
     389           0 :                                                 aUnoPoint.X = aEndPoint.X() + 2;
     390           0 :                                             aUnoPoint.X -= aUnoSize.Width;
     391             :                                             // remove difference to caption point
     392           0 :                                             if (aCaptionPoint.X > 0 && aCaptionPoint.X > aUnoSize.Width)
     393           0 :                                                 aUnoPoint.X -= aCaptionPoint.X - aUnoSize.Width;
     394             :                                         }
     395             :                                         else
     396             :                                         {
     397           1 :                                             if ( aUnoPoint.X > aEndPoint.X() )
     398           0 :                                                 aUnoPoint.X = aEndPoint.X() - 2;
     399           1 :                                             if (aCaptionPoint.X < 0)
     400           0 :                                                 aUnoPoint.X -= aCaptionPoint.X;
     401             :                                         }
     402           1 :                                         if (aCaptionPoint.Y < 0)
     403           0 :                                             aUnoPoint.Y -= aCaptionPoint.Y;
     404             : 
     405           1 :                                         xShape->setPosition(aUnoPoint);
     406           1 :                                         pDocSh->SetModified();
     407             :                                     }
     408             : 
     409           1 :                                     if (aAddress.StartRow != aAddress.EndRow) //should be a Spreadsheet
     410             :                                     {
     411             :                                         OSL_ENSURE(aAddress.StartRow == 0 && aAddress.EndRow == MAXROW &&
     412             :                                             aAddress.StartColumn == 0 && aAddress.EndColumn == MAXCOL, "here should be a XSpreadsheet");
     413           0 :                                         ScDrawLayer::SetPageAnchored(*pObj);
     414             :                                     }
     415             :                                     else
     416             :                                     {
     417             :                                         OSL_ENSURE(aAddress.StartRow == aAddress.EndRow &&
     418             :                                             aAddress.StartColumn == aAddress.EndColumn, "here should be a XCell");
     419           1 :                                         ScDrawObjData aAnchor;
     420           1 :                                         aAnchor.maStart = ScAddress(aAddress.StartColumn, aAddress.StartRow, aAddress.Sheet);
     421           1 :                                         aAnchor.maStartOffset = Point(aRelPoint.X, aRelPoint.Y);
     422             :                                         //Uno sets the Anchor in terms of the unorotated shape, not much we can do
     423             :                                         //about that since uno also displays the shape geometry in terms of the unrotated
     424             :                                         //shape. #TODO think about changing the anchoring behaviour here too
     425             :                                         //Currently we've only got a start anchor, not an end-anchor, so generate that now
     426           1 :                                         ScDrawLayer::UpdateCellAnchorFromPositionEnd(*pObj, aAnchor, *pDoc, aAddress.Sheet);
     427           1 :                                         ScDrawLayer::SetCellAnchored(*pObj, aAnchor);
     428           1 :                                     }
     429             :                                 }
     430             :                             }
     431             :                         }
     432             :                     }
     433             :                 }
     434             :             }
     435             :         }
     436             :         else
     437           0 :             throw lang::IllegalArgumentException("only XCell or XSpreadsheet objects allowed", static_cast<cppu::OWeakObject*>(this), 0);
     438             :     }
     439        3664 :     else if ( aNameString == SC_UNONAME_IMAGEMAP )
     440             :     {
     441           0 :         SdrObject* pObj = GetSdrObject();
     442           0 :         if ( pObj )
     443             :         {
     444           0 :             ImageMap aImageMap;
     445           0 :             uno::Reference< uno::XInterface > xImageMapInt(aValue, uno::UNO_QUERY);
     446             : 
     447           0 :             if( !xImageMapInt.is() || !SvUnoImageMap_fillImageMap( xImageMapInt, aImageMap ) )
     448           0 :                 throw lang::IllegalArgumentException();
     449             : 
     450           0 :             ScIMapInfo* pIMapInfo = ScDrawLayer::GetIMapInfo(pObj);
     451           0 :             if( pIMapInfo )
     452             :             {
     453             :                 // replace existing image map
     454           0 :                 pIMapInfo->SetImageMap( aImageMap );
     455             :             }
     456             :             else
     457             :             {
     458             :                 // insert new user data with image map
     459           0 :                 pObj->AppendUserData(new ScIMapInfo(aImageMap) );
     460           0 :             }
     461             :         }
     462             :     }
     463        3664 :     else if ( aNameString == SC_UNONAME_HORIPOS )
     464             :     {
     465           1 :         sal_Int32 nPos = 0;
     466           1 :         if (aValue >>= nPos)
     467             :         {
     468           1 :             SdrObject *pObj = GetSdrObject();
     469           1 :             if (pObj)
     470             :             {
     471           1 :                 ScDrawLayer* pModel = static_cast<ScDrawLayer*>(pObj->GetModel());
     472           1 :                 SdrPage* pPage = pObj->GetPage();
     473           1 :                 if ( pModel && pPage )
     474             :                 {
     475           1 :                     SCTAB nTab = 0;
     476           1 :                     if ( lcl_GetPageNum( pPage, *pModel, nTab ) )
     477             :                     {
     478           1 :                         ScDocument* pDoc = pModel->GetDocument();
     479           1 :                         if ( pDoc )
     480             :                         {
     481           1 :                             SfxObjectShell* pObjSh = pDoc->GetDocumentShell();
     482           1 :                             if ( pObjSh && pObjSh->ISA(ScDocShell) )
     483             :                             {
     484           1 :                                 ScDocShell* pDocSh = static_cast<ScDocShell*>(pObjSh);
     485           1 :                                 uno::Reference<drawing::XShape> xShape( mxShapeAgg, uno::UNO_QUERY );
     486           1 :                                 if (xShape.is())
     487             :                                 {
     488           1 :                                     if (ScDrawLayer::GetAnchorType(*pObj) == SCA_PAGE)
     489             :                                     {
     490           0 :                                         awt::Point aPoint(xShape->getPosition());
     491           0 :                                         awt::Size aSize(xShape->getSize());
     492           0 :                                         awt::Point aCaptionPoint;
     493           0 :                                         if (pDoc->IsNegativePage(nTab))
     494             :                                         {
     495           0 :                                             nPos *= -1;
     496           0 :                                             nPos -= aSize.Width;
     497             :                                         }
     498           0 :                                         if (lcl_GetCaptionPoint(xShape, aCaptionPoint))
     499             :                                         {
     500           0 :                                             if (pDoc->IsNegativePage(nTab))
     501             :                                             {
     502           0 :                                                 if (aCaptionPoint.X > 0 && aCaptionPoint.X > aSize.Width)
     503           0 :                                                     nPos -= aCaptionPoint.X - aSize.Width;
     504             :                                             }
     505             :                                             else
     506             :                                             {
     507           0 :                                                 if (aCaptionPoint.X < 0)
     508           0 :                                                     nPos -= aCaptionPoint.X;
     509             :                                             }
     510             :                                         }
     511           0 :                                         aPoint.X = nPos;
     512           0 :                                         xShape->setPosition(aPoint);
     513           0 :                                         pDocSh->SetModified();
     514             :                                     }
     515           1 :                                     else if (ScDrawLayer::GetAnchorType(*pObj) == SCA_CELL)
     516             :                                     {
     517           1 :                                         awt::Size aUnoSize;
     518           1 :                                         awt::Point aCaptionPoint;
     519           1 :                                         ScRange aRange;
     520           1 :                                         awt::Point aUnoPoint(lcl_GetRelativePos( xShape, pDoc, nTab, aRange, aUnoSize, aCaptionPoint ));
     521           1 :                                         Rectangle aRect(pDoc->GetMMRect( aRange.aStart.Col(), aRange.aStart.Row(), aRange.aEnd.Col(), aRange.aEnd.Row(), aRange.aStart.Tab() ));
     522           1 :                                         if (pDoc->IsNegativePage(nTab))
     523             :                                         {
     524           0 :                                             aUnoPoint.X = -nPos;
     525           0 :                                             Point aPoint(aRect.TopRight());
     526           0 :                                             Point aEndPoint(aRect.BottomLeft());
     527           0 :                                             aUnoPoint.X += aPoint.X();
     528           0 :                                             if (aUnoPoint.X < aEndPoint.X())
     529           0 :                                                 aUnoPoint.X = aEndPoint.X() + 2;
     530           0 :                                             aUnoPoint.X -= aUnoSize.Width;
     531           0 :                                             if (aCaptionPoint.X > 0 && aCaptionPoint.X > aUnoSize.Width)
     532           0 :                                                 aUnoPoint.X -= aCaptionPoint.X - aUnoSize.Width;
     533             :                                         }
     534             :                                         else
     535             :                                         {
     536           1 :                                             aUnoPoint.X = nPos;
     537           1 :                                             Point aPoint(aRect.TopLeft());
     538           1 :                                             Point aEndPoint(aRect.BottomRight());
     539           1 :                                             aUnoPoint.X += aPoint.X();
     540           1 :                                             if (aUnoPoint.X > aEndPoint.X())
     541           0 :                                                 aUnoPoint.X = aEndPoint.X() - 2;
     542           1 :                                             if (aCaptionPoint.X < 0)
     543           0 :                                                 aUnoPoint.X -= aCaptionPoint.X;
     544             :                                         }
     545           1 :                                         aUnoPoint.Y = xShape->getPosition().Y;
     546           1 :                                         xShape->setPosition(aUnoPoint);
     547           1 :                                         pDocSh->SetModified();
     548             :                                     }
     549             :                                     else
     550             :                                     {
     551             :                                         OSL_FAIL("unknown anchor type");
     552             :                                     }
     553           1 :                                 }
     554             :                             }
     555             :                         }
     556             :                     }
     557             :                 }
     558             :             }
     559             :         }
     560             :     }
     561        3663 :     else if ( aNameString == SC_UNONAME_VERTPOS )
     562             :     {
     563           1 :         sal_Int32 nPos = 0;
     564           1 :         if (aValue >>= nPos)
     565             :         {
     566           1 :             SdrObject *pObj = GetSdrObject();
     567           1 :             if (pObj)
     568             :             {
     569           1 :                 ScDrawLayer* pModel = static_cast<ScDrawLayer*>(pObj->GetModel());
     570           1 :                 SdrPage* pPage = pObj->GetPage();
     571           1 :                 if ( pModel && pPage )
     572             :                 {
     573           1 :                     SCTAB nTab = 0;
     574           1 :                     if ( lcl_GetPageNum( pPage, *pModel, nTab ) )
     575             :                     {
     576           1 :                         ScDocument* pDoc = pModel->GetDocument();
     577           1 :                         if ( pDoc )
     578             :                         {
     579           1 :                             SfxObjectShell* pObjSh = pDoc->GetDocumentShell();
     580           1 :                             if ( pObjSh && pObjSh->ISA(ScDocShell) )
     581             :                             {
     582           1 :                                 ScDocShell* pDocSh = static_cast<ScDocShell*>(pObjSh);
     583           1 :                                 uno::Reference<drawing::XShape> xShape( mxShapeAgg, uno::UNO_QUERY );
     584           1 :                                 if (xShape.is())
     585             :                                 {
     586           1 :                                     if (ScDrawLayer::GetAnchorType(*pObj) == SCA_PAGE)
     587             :                                     {
     588           0 :                                         awt::Point aPoint = xShape->getPosition();
     589           0 :                                         awt::Point aCaptionPoint;
     590           0 :                                         if (lcl_GetCaptionPoint(xShape, aCaptionPoint))
     591             :                                         {
     592           0 :                                             if (aCaptionPoint.Y < 0)
     593           0 :                                                 nPos -= aCaptionPoint.Y;
     594             :                                         }
     595           0 :                                         aPoint.Y = nPos;
     596           0 :                                         xShape->setPosition(aPoint);
     597           0 :                                         pDocSh->SetModified();
     598             :                                     }
     599           1 :                                     else if (ScDrawLayer::GetAnchorType(*pObj) == SCA_CELL)
     600             :                                     {
     601           1 :                                         awt::Size aUnoSize;
     602           1 :                                         awt::Point aCaptionPoint;
     603           1 :                                         ScRange aRange;
     604           1 :                                         awt::Point aUnoPoint(lcl_GetRelativePos( xShape, pDoc, nTab, aRange, aUnoSize, aCaptionPoint ));
     605           1 :                                         Rectangle aRect(pDoc->GetMMRect( aRange.aStart.Col(), aRange.aStart.Row(), aRange.aEnd.Col(), aRange.aEnd.Row(), aRange.aStart.Tab() ));
     606           1 :                                         Point aPoint(aRect.TopRight());
     607           1 :                                         Point aEndPoint(aRect.BottomLeft());
     608           1 :                                         aUnoPoint.Y = nPos;
     609           1 :                                         aUnoPoint.Y += aPoint.Y();
     610           1 :                                         if (aUnoPoint.Y > aEndPoint.Y())
     611           1 :                                             aUnoPoint.Y = aEndPoint.Y() - 2;
     612           1 :                                         if (aCaptionPoint.Y < 0)
     613           0 :                                             aUnoPoint.Y -= aCaptionPoint.Y;
     614           1 :                                         aUnoPoint.X = xShape->getPosition().X;
     615           1 :                                         xShape->setPosition(aUnoPoint);
     616           1 :                                         pDocSh->SetModified();
     617             :                                     }
     618             :                                     else
     619             :                                     {
     620             :                                         OSL_FAIL("unknown anchor type");
     621             :                                     }
     622           1 :                                 }
     623             :                             }
     624             :                         }
     625             :                     }
     626             :                 }
     627             :             }
     628             :         }
     629             :     }
     630        7324 :     else if  ( aNameString == SC_UNONAME_HYPERLINK ||
     631        3662 :                aNameString == SC_UNONAME_URL )
     632             :     {
     633           3 :         OUString sHlink;
     634           3 :         ScMacroInfo* pInfo = ScShapeObj_getShapeHyperMacroInfo(this, true);
     635           3 :         if ( ( aValue >>= sHlink ) && pInfo )
     636           3 :             pInfo->SetHlink( sHlink );
     637             :     }
     638        3659 :     else if ( aNameString == SC_UNONAME_MOVEPROTECT )
     639             :     {
     640           3 :         if( SdrObject* pObj = this->GetSdrObject() )
     641             :         {
     642           3 :             bool aProt = false;
     643           3 :             if( aValue >>= aProt )
     644           3 :                 pObj->SetMoveProtect( aProt );
     645             :         }
     646             :     }
     647             :     else
     648             :     {
     649        3656 :         GetShapePropertySet();
     650        3656 :         if (pShapePropertySet)
     651        3656 :             pShapePropertySet->setPropertyValue( aPropertyName, aValue );
     652        3665 :     }
     653        3582 : }
     654             : 
     655        2190 : uno::Any SAL_CALL ScShapeObj::getPropertyValue( const OUString& aPropertyName )
     656             :     throw(beans::UnknownPropertyException, lang::WrappedTargetException,
     657             :           uno::RuntimeException, std::exception)
     658             : {
     659        2190 :     SolarMutexGuard aGuard;
     660        4380 :     OUString aNameString = aPropertyName;
     661             : 
     662        2190 :     uno::Any aAny;
     663        2190 :     if ( aNameString == SC_UNONAME_ANCHOR )
     664             :     {
     665           5 :         SdrObject *pObj = GetSdrObject();
     666           5 :         if (pObj)
     667             :         {
     668           5 :             ScDrawLayer* pModel = static_cast<ScDrawLayer*>(pObj->GetModel());
     669           5 :             SdrPage* pPage = pObj->GetPage();
     670           5 :             if ( pModel && pPage )
     671             :             {
     672           5 :                 ScDocument* pDoc = pModel->GetDocument();
     673           5 :                 if ( pDoc )
     674             :                 {
     675           5 :                     SCTAB nTab = 0;
     676           5 :                     if ( lcl_GetPageNum( pPage, *pModel, nTab ) )
     677             :                     {
     678           5 :                         SfxObjectShell* pObjSh = pDoc->GetDocumentShell();
     679           5 :                         if ( pObjSh && pObjSh->ISA(ScDocShell) )
     680             :                         {
     681           5 :                             ScDocShell* pDocSh = static_cast<ScDocShell*>(pObjSh);
     682           5 :                             uno::Reference< uno::XInterface > xAnchor;
     683           5 :                             if (ScDrawObjData *pAnchor = ScDrawLayer::GetObjDataTab(pObj, nTab))
     684           1 :                                 xAnchor.set(static_cast<cppu::OWeakObject*>(new ScCellObj( pDocSh, pAnchor->maStart)));
     685             :                             else
     686           4 :                                 xAnchor.set(static_cast<cppu::OWeakObject*>(new ScTableSheetObj( pDocSh, nTab )));
     687           5 :                             aAny <<= xAnchor;
     688             :                         }
     689             :                     }
     690             :                 }
     691             :             }
     692             :         }
     693             :     }
     694        2185 :     else if ( aNameString == SC_UNONAME_IMAGEMAP )
     695             :     {
     696           5 :         uno::Reference< uno::XInterface > xImageMap;
     697           5 :         SdrObject* pObj = GetSdrObject();
     698           5 :         if ( pObj )
     699             :         {
     700           5 :             ScIMapInfo* pIMapInfo = ScDrawLayer::GetIMapInfo(GetSdrObject());
     701           5 :             if( pIMapInfo )
     702             :             {
     703           0 :                 const ImageMap& rIMap = pIMapInfo->GetImageMap();
     704           0 :                 xImageMap.set(SvUnoImageMap_createInstance( rIMap, GetSupportedMacroItems() ));
     705             :             }
     706             :             else
     707           5 :                 xImageMap = SvUnoImageMap_createInstance( GetSupportedMacroItems() );
     708             :         }
     709           5 :         aAny <<= uno::Reference< container::XIndexContainer >::query( xImageMap );
     710             :     }
     711        2180 :     else if ( aNameString == SC_UNONAME_HORIPOS )
     712             :     {
     713           5 :         SdrObject *pObj = GetSdrObject();
     714           5 :         if (pObj)
     715             :         {
     716           5 :             ScDrawLayer* pModel = static_cast<ScDrawLayer*>(pObj->GetModel());
     717           5 :             SdrPage* pPage = pObj->GetPage();
     718           5 :             if ( pModel && pPage )
     719             :             {
     720           5 :                 ScDocument* pDoc = pModel->GetDocument();
     721           5 :                 if ( pDoc )
     722             :                 {
     723           5 :                     SCTAB nTab = 0;
     724           5 :                     if ( lcl_GetPageNum( pPage, *pModel, nTab ) )
     725             :                     {
     726           5 :                         uno::Reference<drawing::XShape> xShape( mxShapeAgg, uno::UNO_QUERY );
     727           5 :                         if (xShape.is())
     728             :                         {
     729           5 :                             if (ScDrawLayer::GetAnchorType(*pObj) == SCA_CELL)
     730             :                             {
     731           2 :                                 awt::Size aUnoSize;
     732           2 :                                 awt::Point aCaptionPoint;
     733           2 :                                 ScRange aRange;
     734           2 :                                 awt::Point aUnoPoint(lcl_GetRelativePos( xShape, pDoc, nTab, aRange, aUnoSize, aCaptionPoint ));
     735           2 :                                 if (pDoc->IsNegativePage(nTab))
     736           0 :                                     aUnoPoint.X *= -1;
     737           2 :                                 aAny <<= aUnoPoint.X;
     738             :                             }
     739             :                             else
     740             :                             {
     741           3 :                                 awt::Point aCaptionPoint;
     742           3 :                                 awt::Point aUnoPoint(xShape->getPosition());
     743           3 :                                 awt::Size aUnoSize(xShape->getSize());
     744           3 :                                 if (pDoc->IsNegativePage(nTab))
     745             :                                 {
     746           1 :                                     aUnoPoint.X *= -1;
     747           1 :                                     aUnoPoint.X -= aUnoSize.Width;
     748             :                                 }
     749           3 :                                 if (lcl_GetCaptionPoint(xShape, aCaptionPoint))
     750             :                                 {
     751           0 :                                     if (pDoc->IsNegativePage(nTab))
     752             :                                     {
     753           0 :                                         if (aCaptionPoint.X > 0 && aCaptionPoint.X > aUnoSize.Width)
     754           0 :                                             aUnoPoint.X -= aCaptionPoint.X - aUnoSize.Width;
     755             :                                     }
     756             :                                     else
     757             :                                     {
     758           0 :                                         if (aCaptionPoint.X < 0)
     759           0 :                                             aUnoPoint.X += aCaptionPoint.X;
     760             :                                     }
     761             :                                 }
     762           3 :                                 aAny <<= aUnoPoint.X;
     763             :                             }
     764           5 :                         }
     765             :                     }
     766             :                 }
     767             :             }
     768             :         }
     769             :     }
     770        2175 :     else if ( aNameString ==  SC_UNONAME_VERTPOS )
     771             :     {
     772           5 :         SdrObject *pObj = GetSdrObject();
     773           5 :         if (pObj)
     774             :         {
     775           5 :             ScDrawLayer* pModel = static_cast<ScDrawLayer*>(pObj->GetModel());
     776           5 :             SdrPage* pPage = pObj->GetPage();
     777           5 :             if ( pModel && pPage )
     778             :             {
     779           5 :                 ScDocument* pDoc = pModel->GetDocument();
     780           5 :                 if ( pDoc )
     781             :                 {
     782           5 :                     SCTAB nTab = 0;
     783           5 :                     if ( lcl_GetPageNum( pPage, *pModel, nTab ) )
     784             :                     {
     785           5 :                         uno::Reference<drawing::XShape> xShape( mxShapeAgg, uno::UNO_QUERY );
     786           5 :                         if (xShape.is())
     787             :                         {
     788           5 :                             uno::Reference< uno::XInterface > xAnchor;
     789           5 :                             if (ScDrawLayer::GetAnchorType(*pObj) == SCA_CELL)
     790             :                             {
     791           2 :                                 awt::Size aUnoSize;
     792           2 :                                 awt::Point aCaptionPoint;
     793           2 :                                 ScRange aRange;
     794           2 :                                 awt::Point aUnoPoint(lcl_GetRelativePos( xShape, pDoc, nTab, aRange, aUnoSize, aCaptionPoint ));
     795             : 
     796           2 :                                 aAny <<= aUnoPoint.Y;
     797             :                             }
     798             :                             else
     799             :                             {
     800           3 :                                 awt::Point aUnoPoint(xShape->getPosition());
     801           3 :                                 awt::Point aCaptionPoint;
     802           3 :                                 if (lcl_GetCaptionPoint(xShape, aCaptionPoint))
     803             :                                 {
     804           0 :                                     if (aCaptionPoint.Y < 0)
     805           0 :                                         aUnoPoint.Y += aCaptionPoint.Y;
     806             :                                 }
     807           3 :                                 aAny <<= aUnoPoint.Y;
     808           5 :                             }
     809           5 :                         }
     810             :                     }
     811             :                 }
     812             :             }
     813             :         }
     814             :     }
     815        4331 :     else if ( aNameString == SC_UNONAME_HYPERLINK ||
     816        2161 :               aNameString == SC_UNONAME_URL )
     817             :     {
     818          19 :         OUString sHlink;
     819          19 :         if ( ScMacroInfo* pInfo = ScShapeObj_getShapeHyperMacroInfo(this) )
     820           3 :             sHlink = pInfo->GetHlink();
     821          19 :         aAny <<= sHlink;
     822             :     }
     823        2151 :     else if ( aNameString == SC_UNONAME_MOVEPROTECT )
     824             :     {
     825          15 :         bool aProt = false;
     826          15 :         if ( SdrObject* pObj = this->GetSdrObject() )
     827          15 :             aProt = pObj->IsMoveProtect();
     828          15 :         aAny <<= aProt;
     829             :     }
     830             :     else
     831             :     {
     832        2136 :         if(!pShapePropertySet) //performance consideration
     833          70 :             GetShapePropertySet();
     834        2136 :         if (pShapePropertySet)
     835        2136 :             aAny = pShapePropertySet->getPropertyValue( aPropertyName );
     836             :     }
     837             : 
     838        4380 :     return aAny;
     839             : }
     840             : 
     841           0 : void SAL_CALL ScShapeObj::addPropertyChangeListener( const OUString& aPropertyName,
     842             :                             const uno::Reference<beans::XPropertyChangeListener>& aListener)
     843             :                             throw(beans::UnknownPropertyException,
     844             :                                     lang::WrappedTargetException, uno::RuntimeException, std::exception)
     845             : {
     846           0 :     SolarMutexGuard aGuard;
     847             : 
     848           0 :     GetShapePropertySet();
     849           0 :     if (pShapePropertySet)
     850           0 :         pShapePropertySet->addPropertyChangeListener( aPropertyName, aListener );
     851             : 
     852           0 :     if ( !bInitializedNotifier )
     853             :     {
     854             :         // here's the latest chance to initialize the property notification at the SdrObject
     855             :         // (in the ctor, where we also attempt to do this, we do not necessarily have
     856             :         // and SdrObject, yet)
     857           0 :         SdrObject* pObj = GetSdrObject();
     858             :         OSL_ENSURE( pObj, "ScShapeObj::addPropertyChangeListener: no SdrObject -> no property change notification!" );
     859           0 :         if ( pObj )
     860           0 :             lcl_initializeNotifier( *pObj, *this );
     861           0 :         bInitializedNotifier = true;
     862           0 :     }
     863           0 : }
     864             : 
     865           0 : void SAL_CALL ScShapeObj::removePropertyChangeListener( const OUString& aPropertyName,
     866             :                             const uno::Reference<beans::XPropertyChangeListener>& aListener)
     867             :                             throw(beans::UnknownPropertyException,
     868             :                                     lang::WrappedTargetException, uno::RuntimeException, std::exception)
     869             : {
     870           0 :     SolarMutexGuard aGuard;
     871             : 
     872           0 :     GetShapePropertySet();
     873           0 :     if (pShapePropertySet)
     874           0 :         pShapePropertySet->removePropertyChangeListener( aPropertyName, aListener );
     875           0 : }
     876             : 
     877           0 : void SAL_CALL ScShapeObj::addVetoableChangeListener( const OUString& aPropertyName,
     878             :                             const uno::Reference<beans::XVetoableChangeListener>& aListener)
     879             :                             throw(beans::UnknownPropertyException,
     880             :                                 lang::WrappedTargetException, uno::RuntimeException, std::exception)
     881             : {
     882           0 :     SolarMutexGuard aGuard;
     883             : 
     884           0 :     GetShapePropertySet();
     885           0 :     if (pShapePropertySet)
     886           0 :         pShapePropertySet->addVetoableChangeListener( aPropertyName, aListener );
     887           0 : }
     888             : 
     889           0 : void SAL_CALL ScShapeObj::removeVetoableChangeListener( const OUString& aPropertyName,
     890             :                             const uno::Reference<beans::XVetoableChangeListener>& aListener)
     891             :                             throw(beans::UnknownPropertyException,
     892             :                                 lang::WrappedTargetException, uno::RuntimeException, std::exception)
     893             : {
     894           0 :     SolarMutexGuard aGuard;
     895             : 
     896           0 :     GetShapePropertySet();
     897           0 :     if (pShapePropertySet)
     898           0 :         pShapePropertySet->removeVetoableChangeListener( aPropertyName, aListener );
     899           0 : }
     900             : 
     901             : //  XPropertyState
     902             : 
     903        2222 : beans::PropertyState SAL_CALL ScShapeObj::getPropertyState( const OUString& aPropertyName )
     904             :                                 throw(beans::UnknownPropertyException, uno::RuntimeException, std::exception)
     905             : {
     906        2222 :     SolarMutexGuard aGuard;
     907        4444 :     OUString aNameString(aPropertyName);
     908             : 
     909        2222 :     beans::PropertyState eRet = beans::PropertyState_DIRECT_VALUE;
     910        2222 :     if ( aNameString == SC_UNONAME_IMAGEMAP )
     911             :     {
     912             :         // ImageMap is always "direct"
     913             :     }
     914        2222 :     else if ( aNameString == SC_UNONAME_ANCHOR )
     915             :     {
     916             :         // Anchor is always "direct"
     917             :     }
     918        2222 :     else if ( aNameString == SC_UNONAME_HORIPOS )
     919             :     {
     920             :         // HoriPos is always "direct"
     921             :     }
     922        2222 :     else if ( aNameString == SC_UNONAME_VERTPOS )
     923             :     {
     924             :         // VertPos is always "direct"
     925             :     }
     926             :     else
     927             :     {
     928        2222 :         GetShapePropertyState();
     929        2222 :         if (pShapePropertyState)
     930        2222 :             eRet = pShapePropertyState->getPropertyState( aPropertyName );
     931             :     }
     932             : 
     933        4444 :     return eRet;
     934             : }
     935             : 
     936          30 : uno::Sequence<beans::PropertyState> SAL_CALL ScShapeObj::getPropertyStates(
     937             :                                 const uno::Sequence<OUString>& aPropertyNames )
     938             :                             throw(beans::UnknownPropertyException, uno::RuntimeException, std::exception)
     939             : {
     940          30 :     SolarMutexGuard aGuard;
     941             : 
     942             :     //  simple loop to get own and aggregated states
     943             : 
     944          30 :     const OUString* pNames = aPropertyNames.getConstArray();
     945          30 :     uno::Sequence<beans::PropertyState> aRet(aPropertyNames.getLength());
     946          30 :     beans::PropertyState* pStates = aRet.getArray();
     947        2237 :     for(sal_Int32 i = 0; i < aPropertyNames.getLength(); i++)
     948        2207 :         pStates[i] = getPropertyState(pNames[i]);
     949          30 :     return aRet;
     950             : }
     951             : 
     952           0 : void SAL_CALL ScShapeObj::setPropertyToDefault( const OUString& aPropertyName )
     953             :     throw (beans::UnknownPropertyException, uno::RuntimeException,
     954             :            std::exception)
     955             : {
     956           0 :     SolarMutexGuard aGuard;
     957           0 :     OUString aNameString(aPropertyName);
     958             : 
     959           0 :     if ( aNameString == SC_UNONAME_IMAGEMAP )
     960             :     {
     961           0 :         SdrObject* pObj = GetSdrObject();
     962           0 :         if ( pObj )
     963             :         {
     964           0 :             ScIMapInfo* pIMapInfo = ScDrawLayer::GetIMapInfo(pObj);
     965           0 :             if( pIMapInfo )
     966             :             {
     967           0 :                 ImageMap aEmpty;
     968           0 :                 pIMapInfo->SetImageMap( aEmpty );   // replace with empty image map
     969             :             }
     970             :             else
     971             :             {
     972             :                 // nothing to do (no need to insert user data for an empty map)
     973             :             }
     974             :         }
     975             :     }
     976             :     else
     977             :     {
     978           0 :         GetShapePropertyState();
     979           0 :         if (pShapePropertyState)
     980           0 :             pShapePropertyState->setPropertyToDefault( aPropertyName );
     981           0 :     }
     982           0 : }
     983             : 
     984           0 : uno::Any SAL_CALL ScShapeObj::getPropertyDefault( const OUString& aPropertyName )
     985             :                                 throw(beans::UnknownPropertyException, lang::WrappedTargetException,
     986             :                                         uno::RuntimeException, std::exception)
     987             : {
     988           0 :     SolarMutexGuard aGuard;
     989           0 :     OUString aNameString = aPropertyName;
     990             : 
     991           0 :     uno::Any aAny;
     992           0 :     if ( aNameString == SC_UNONAME_IMAGEMAP )
     993             :     {
     994             :         //  default: empty ImageMap
     995           0 :         uno::Reference< uno::XInterface > xImageMap(SvUnoImageMap_createInstance( GetSupportedMacroItems() ));
     996           0 :         aAny <<= uno::Reference< container::XIndexContainer >::query( xImageMap );
     997             :     }
     998             :     else
     999             :     {
    1000           0 :         GetShapePropertyState();
    1001           0 :         if (pShapePropertyState)
    1002           0 :             aAny = pShapePropertyState->getPropertyDefault( aPropertyName );
    1003             :     }
    1004             : 
    1005           0 :     return aAny;
    1006             : }
    1007             : 
    1008             : // XTextContent
    1009             : 
    1010           0 : void SAL_CALL ScShapeObj::attach( const uno::Reference<text::XTextRange>& /* xTextRange */ )
    1011             :                                 throw(lang::IllegalArgumentException, uno::RuntimeException, std::exception)
    1012             : {
    1013           0 :     SolarMutexGuard aGuard;
    1014             : 
    1015           0 :     throw lang::IllegalArgumentException();     // anchor cannot be changed
    1016             : }
    1017             : 
    1018           0 : uno::Reference<text::XTextRange> SAL_CALL ScShapeObj::getAnchor()
    1019             :     throw(uno::RuntimeException, std::exception)
    1020             : {
    1021           0 :     SolarMutexGuard aGuard;
    1022             : 
    1023           0 :     uno::Reference<text::XTextRange> xRet;
    1024             : 
    1025           0 :     SdrObject* pObj = GetSdrObject();
    1026           0 :     if( pObj )
    1027             :     {
    1028           0 :         ScDrawLayer* pModel = static_cast<ScDrawLayer*>(pObj->GetModel());
    1029           0 :         SdrPage* pPage = pObj->GetPage();
    1030           0 :         if ( pModel )
    1031             :         {
    1032           0 :             ScDocument* pDoc = pModel->GetDocument();
    1033           0 :             if ( pDoc )
    1034             :             {
    1035           0 :                 SfxObjectShell* pObjSh = pDoc->GetDocumentShell();
    1036           0 :                 if ( pObjSh && pObjSh->ISA(ScDocShell) )
    1037             :                 {
    1038           0 :                     ScDocShell* pDocSh = static_cast<ScDocShell*>(pObjSh);
    1039             : 
    1040           0 :                     SCTAB nTab = 0;
    1041           0 :                     if ( lcl_GetPageNum( pPage, *pModel, nTab ) )
    1042             :                     {
    1043           0 :                         Point aPos(pObj->GetCurrentBoundRect().TopLeft());
    1044           0 :                         ScRange aRange(pDoc->GetRange( nTab, Rectangle( aPos, aPos ) ));
    1045             : 
    1046             :                         //  anchor is always the cell
    1047             : 
    1048           0 :                         xRet.set(new ScCellObj( pDocSh, aRange.aStart ));
    1049             :                     }
    1050             :                 }
    1051             :             }
    1052             :         }
    1053             :     }
    1054             : 
    1055           0 :     return xRet;
    1056             : }
    1057             : 
    1058             : // XComponent
    1059             : 
    1060           9 : void SAL_CALL ScShapeObj::dispose() throw(uno::RuntimeException, std::exception)
    1061             : {
    1062           9 :     SolarMutexGuard aGuard;
    1063             : 
    1064          18 :     uno::Reference<lang::XComponent> xAggComp(lcl_GetComponent(mxShapeAgg));
    1065           9 :     if ( xAggComp.is() )
    1066          18 :         xAggComp->dispose();
    1067           9 : }
    1068             : 
    1069         111 : void SAL_CALL ScShapeObj::addEventListener(
    1070             :                         const uno::Reference<lang::XEventListener>& xListener )
    1071             :                                                     throw(uno::RuntimeException, std::exception)
    1072             : {
    1073         111 :     SolarMutexGuard aGuard;
    1074             : 
    1075         222 :     uno::Reference<lang::XComponent> xAggComp(lcl_GetComponent(mxShapeAgg));
    1076         111 :     if ( xAggComp.is() )
    1077         222 :         xAggComp->addEventListener(xListener);
    1078         111 : }
    1079             : 
    1080         111 : void SAL_CALL ScShapeObj::removeEventListener(
    1081             :                         const uno::Reference<lang::XEventListener>& xListener )
    1082             :                                                     throw(uno::RuntimeException, std::exception)
    1083             : {
    1084         111 :     SolarMutexGuard aGuard;
    1085             : 
    1086         222 :     uno::Reference<lang::XComponent> xAggComp(lcl_GetComponent(mxShapeAgg));
    1087         111 :     if ( xAggComp.is() )
    1088         222 :         xAggComp->removeEventListener(xListener);
    1089         111 : }
    1090             : 
    1091             : // XText
    1092             : // (special handling for ScCellFieldObj)
    1093             : 
    1094           3 : static void lcl_CopyOneProperty( beans::XPropertySet& rDest, beans::XPropertySet& rSource, const sal_Char* pName )
    1095             : {
    1096           3 :     OUString aNameStr(OUString::createFromAscii(pName));
    1097             :     try
    1098             :     {
    1099           3 :         rDest.setPropertyValue( aNameStr, rSource.getPropertyValue( aNameStr ) );
    1100             :     }
    1101           3 :     catch (uno::Exception&)
    1102             :     {
    1103             :         OSL_FAIL("Exception in text field");
    1104           3 :     }
    1105           3 : }
    1106             : 
    1107           1 : void SAL_CALL ScShapeObj::insertTextContent( const uno::Reference<text::XTextRange>& xRange,
    1108             :                                                 const uno::Reference<text::XTextContent>& xContent,
    1109             :                                                 sal_Bool bAbsorb )
    1110             :                                     throw(lang::IllegalArgumentException, uno::RuntimeException, std::exception)
    1111             : {
    1112           1 :     SolarMutexGuard aGuard;
    1113             : 
    1114           2 :     uno::Reference<text::XTextContent> xEffContent;
    1115             : 
    1116           1 :     ScEditFieldObj* pCellField = ScEditFieldObj::getImplementation( xContent );
    1117           1 :     if ( pCellField )
    1118             :     {
    1119             :         //  createInstance("TextField.URL") from the document creates a ScCellFieldObj.
    1120             :         //  To insert it into drawing text, a SvxUnoTextField is needed instead.
    1121             :         //  The ScCellFieldObj object is left in non-inserted state.
    1122             : 
    1123           1 :         SvxUnoTextField* pDrawField = new SvxUnoTextField( text::textfield::Type::URL );
    1124           1 :         xEffContent.set(pDrawField);
    1125           1 :         lcl_CopyOneProperty( *pDrawField, *pCellField, SC_UNONAME_URL );
    1126           1 :         lcl_CopyOneProperty( *pDrawField, *pCellField, SC_UNONAME_REPR );
    1127           1 :         lcl_CopyOneProperty( *pDrawField, *pCellField, SC_UNONAME_TARGET );
    1128             :     }
    1129             :     else
    1130           0 :         xEffContent.set(xContent);
    1131             : 
    1132           2 :     uno::Reference<text::XText> xAggText(lcl_GetText(mxShapeAgg));
    1133           1 :     if ( xAggText.is() )
    1134           2 :         xAggText->insertTextContent( xRange, xEffContent, bAbsorb );
    1135           1 : }
    1136             : 
    1137           1 : void SAL_CALL ScShapeObj::removeTextContent( const uno::Reference<text::XTextContent>& xContent )
    1138             :                                 throw(container::NoSuchElementException, uno::RuntimeException, std::exception)
    1139             : {
    1140           1 :     SolarMutexGuard aGuard;
    1141             : 
    1142             :     //  ScCellFieldObj can't be used here.
    1143             : 
    1144           2 :     uno::Reference<text::XText> xAggText(lcl_GetText(mxShapeAgg));
    1145           1 :     if ( xAggText.is() )
    1146           2 :         xAggText->removeTextContent( xContent );
    1147           1 : }
    1148             : 
    1149             : // XSimpleText (parent of XText)
    1150             : // Use own SvxUnoTextCursor subclass - everything is just passed to aggregated object
    1151             : 
    1152          66 : uno::Reference<text::XTextCursor> SAL_CALL ScShapeObj::createTextCursor()
    1153             :                                                     throw(uno::RuntimeException, std::exception)
    1154             : {
    1155          66 :     SolarMutexGuard aGuard;
    1156             : 
    1157          66 :     if ( mxShapeAgg.is() )
    1158             :     {
    1159             :         //  ScDrawTextCursor must be used to ensure the ScShapeObj is returned by getText
    1160             : 
    1161          66 :         SvxUnoTextBase* pText = SvxUnoTextBase::getImplementation( mxShapeAgg );
    1162          66 :         if (pText)
    1163          66 :             return new ScDrawTextCursor( this, *pText );
    1164             :     }
    1165             : 
    1166           0 :     return uno::Reference<text::XTextCursor>();
    1167             : }
    1168             : 
    1169          67 : uno::Reference<text::XTextCursor> SAL_CALL ScShapeObj::createTextCursorByRange(
    1170             :                                     const uno::Reference<text::XTextRange>& aTextPosition )
    1171             :                                                     throw(uno::RuntimeException, std::exception)
    1172             : {
    1173          67 :     SolarMutexGuard aGuard;
    1174             : 
    1175          67 :     if ( mxShapeAgg.is() && aTextPosition.is() )
    1176             :     {
    1177             :         //  ScDrawTextCursor must be used to ensure the ScShapeObj is returned by getText
    1178             : 
    1179          67 :         SvxUnoTextBase* pText = SvxUnoTextBase::getImplementation( mxShapeAgg );
    1180          67 :         SvxUnoTextRangeBase* pRange = SvxUnoTextRangeBase::getImplementation( aTextPosition );
    1181          67 :         if ( pText && pRange )
    1182             :         {
    1183          67 :             SvxUnoTextCursor* pCursor = new ScDrawTextCursor( this, *pText );
    1184          67 :             uno::Reference<text::XTextCursor> xCursor( pCursor );
    1185          67 :             pCursor->SetSelection( pRange->GetSelection() );
    1186          67 :             return xCursor;
    1187             :         }
    1188             :     }
    1189             : 
    1190           0 :     return uno::Reference<text::XTextCursor>();
    1191             : }
    1192             : 
    1193          41 : void SAL_CALL ScShapeObj::insertString( const uno::Reference<text::XTextRange>& xRange,
    1194             :                                         const OUString& aString, sal_Bool bAbsorb )
    1195             :                                     throw(uno::RuntimeException, std::exception)
    1196             : {
    1197          41 :     SolarMutexGuard aGuard;
    1198             : 
    1199          82 :     uno::Reference<text::XSimpleText> xAggSimpleText(lcl_GetSimpleText(mxShapeAgg));
    1200          41 :     if ( xAggSimpleText.is() )
    1201          41 :         xAggSimpleText->insertString( xRange, aString, bAbsorb );
    1202             :     else
    1203          41 :         throw uno::RuntimeException();
    1204          41 : }
    1205             : 
    1206          69 : void SAL_CALL ScShapeObj::insertControlCharacter( const uno::Reference<text::XTextRange>& xRange,
    1207             :                                                 sal_Int16 nControlCharacter, sal_Bool bAbsorb )
    1208             :                                     throw(lang::IllegalArgumentException, uno::RuntimeException, std::exception)
    1209             : {
    1210          69 :     SolarMutexGuard aGuard;
    1211             : 
    1212         138 :     uno::Reference<text::XSimpleText> xAggSimpleText(lcl_GetSimpleText(mxShapeAgg));
    1213          69 :     if ( xAggSimpleText.is() )
    1214          69 :         xAggSimpleText->insertControlCharacter( xRange, nControlCharacter, bAbsorb );
    1215             :     else
    1216          69 :         throw uno::RuntimeException();
    1217          69 : }
    1218             : 
    1219             : // XTextRange
    1220             : // (parent of XSimpleText)
    1221             : 
    1222           0 : uno::Reference<text::XText> SAL_CALL ScShapeObj::getText() throw(uno::RuntimeException, std::exception)
    1223             : {
    1224           0 :     SolarMutexGuard aGuard;
    1225           0 :     return this;
    1226             : }
    1227             : 
    1228           0 : uno::Reference<text::XTextRange> SAL_CALL ScShapeObj::getStart() throw(uno::RuntimeException, std::exception)
    1229             : {
    1230           0 :     SolarMutexGuard aGuard;
    1231             : 
    1232           0 :     uno::Reference<text::XTextRange> xAggTextRange(lcl_GetTextRange(mxShapeAgg));
    1233           0 :     if ( xAggTextRange.is() )
    1234           0 :         return xAggTextRange->getStart();
    1235             :     else
    1236           0 :         throw uno::RuntimeException();
    1237             : 
    1238             : //    return uno::Reference<text::XTextRange>();
    1239             : }
    1240             : 
    1241           0 : uno::Reference<text::XTextRange> SAL_CALL ScShapeObj::getEnd() throw(uno::RuntimeException, std::exception)
    1242             : {
    1243           0 :     SolarMutexGuard aGuard;
    1244             : 
    1245           0 :     uno::Reference<text::XTextRange> xAggTextRange(lcl_GetTextRange(mxShapeAgg));
    1246           0 :     if ( xAggTextRange.is() )
    1247           0 :         return xAggTextRange->getEnd();
    1248             :     else
    1249           0 :         throw uno::RuntimeException();
    1250             : 
    1251             : //    return uno::Reference<text::XTextRange>();
    1252             : }
    1253             : 
    1254          66 : OUString SAL_CALL ScShapeObj::getString() throw(uno::RuntimeException, std::exception)
    1255             : {
    1256          66 :     SolarMutexGuard aGuard;
    1257             : 
    1258         132 :     uno::Reference<text::XTextRange> xAggTextRange(lcl_GetTextRange(mxShapeAgg));
    1259          66 :     if ( xAggTextRange.is() )
    1260         132 :         return xAggTextRange->getString();
    1261             :     else
    1262          66 :         throw uno::RuntimeException();
    1263             : 
    1264             : //    return OUString();
    1265             : }
    1266             : 
    1267           3 : void SAL_CALL ScShapeObj::setString( const OUString& aText ) throw(uno::RuntimeException, std::exception)
    1268             : {
    1269           3 :     SolarMutexGuard aGuard;
    1270             : 
    1271           6 :     uno::Reference<text::XTextRange> xAggTextRange(lcl_GetTextRange(mxShapeAgg));
    1272           3 :     if ( xAggTextRange.is() )
    1273           3 :         xAggTextRange->setString( aText );
    1274             :     else
    1275           3 :         throw uno::RuntimeException();
    1276           3 : }
    1277             : 
    1278             : // XChild
    1279             : 
    1280           0 : uno::Reference< uno::XInterface > SAL_CALL ScShapeObj::getParent() throw (uno::RuntimeException, std::exception)
    1281             : {
    1282           0 :     SolarMutexGuard aGuard;
    1283             : 
    1284             :     // receive cell position from caption object (parent of a note caption is the note cell)
    1285           0 :     SdrObject* pObj = GetSdrObject();
    1286           0 :     if( pObj )
    1287             :     {
    1288           0 :         ScDrawLayer* pModel = static_cast<ScDrawLayer*>(pObj->GetModel());
    1289           0 :         SdrPage* pPage = pObj->GetPage();
    1290           0 :         if ( pModel )
    1291             :         {
    1292           0 :             ScDocument* pDoc = pModel->GetDocument();
    1293           0 :             if ( pDoc )
    1294             :             {
    1295           0 :                 SfxObjectShell* pObjSh = pDoc->GetDocumentShell();
    1296           0 :                 if ( pObjSh && pObjSh->ISA(ScDocShell) )
    1297             :                 {
    1298           0 :                     ScDocShell* pDocSh = static_cast<ScDocShell*>(pObjSh);
    1299             : 
    1300           0 :                     SCTAB nTab = 0;
    1301           0 :                     if ( lcl_GetPageNum( pPage, *pModel, nTab ) )
    1302             :                     {
    1303           0 :                         const ScDrawObjData* pCaptData = ScDrawLayer::GetNoteCaptionData( pObj, nTab );
    1304           0 :                         if( pCaptData )
    1305           0 :                             return static_cast< ::cppu::OWeakObject* >( new ScCellObj( pDocSh, pCaptData->maStart ) );
    1306             :                     }
    1307             :                 }
    1308             :             }
    1309             :         }
    1310             :     }
    1311             : 
    1312           0 :     return 0;
    1313             : }
    1314             : 
    1315           0 : void SAL_CALL ScShapeObj::setParent( const uno::Reference< uno::XInterface >& ) throw (lang::NoSupportException, uno::RuntimeException, std::exception)
    1316             : {
    1317           0 :     throw lang::NoSupportException();
    1318             : }
    1319             : 
    1320             : // XTypeProvider
    1321             : 
    1322           0 : uno::Sequence<uno::Type> SAL_CALL ScShapeObj::getTypes() throw(uno::RuntimeException, std::exception)
    1323             : {
    1324           0 :     uno::Sequence< uno::Type > aBaseTypes( ScShapeObj_Base::getTypes() );
    1325             : 
    1326           0 :     uno::Sequence< uno::Type > aTextTypes;
    1327           0 :     if ( bIsTextShape )
    1328           0 :         aTextTypes = ScShapeObj_TextBase::getTypes();
    1329             : 
    1330           0 :     uno::Reference<lang::XTypeProvider> xBaseProvider;
    1331           0 :     if ( mxShapeAgg.is() )
    1332           0 :         mxShapeAgg->queryAggregation( cppu::UnoType<lang::XTypeProvider>::get()) >>= xBaseProvider;
    1333             :     OSL_ENSURE( xBaseProvider.is(), "ScShapeObj: No XTypeProvider from aggregated shape!" );
    1334             : 
    1335           0 :     uno::Sequence< uno::Type > aAggTypes;
    1336           0 :     if( xBaseProvider.is() )
    1337           0 :         aAggTypes = xBaseProvider->getTypes();
    1338             : 
    1339           0 :     return ::comphelper::concatSequences( aBaseTypes, aTextTypes, aAggTypes );
    1340             : }
    1341             : 
    1342           0 : uno::Sequence<sal_Int8> SAL_CALL ScShapeObj::getImplementationId()
    1343             :                                                     throw(uno::RuntimeException, std::exception)
    1344             : {
    1345           0 :     return css::uno::Sequence<sal_Int8>();
    1346             : }
    1347             : 
    1348         630 : SdrObject* ScShapeObj::GetSdrObject() const throw()
    1349             : {
    1350         630 :     if(mxShapeAgg.is())
    1351             :     {
    1352         630 :         SvxShape* pShape = SvxShape::getImplementation( mxShapeAgg );
    1353         630 :         if(pShape)
    1354         630 :             return pShape->GetSdrObject();
    1355             :     }
    1356             : 
    1357           0 :     return NULL;
    1358             : }
    1359             : 
    1360             : #define SC_EVENTACC_ONCLICK     "OnClick"
    1361             : #define SC_EVENTACC_SCRIPT      "Script"
    1362             : #define SC_EVENTACC_EVENTTYPE   "EventType"
    1363             : 
    1364             : typedef ::cppu::WeakImplHelper1< container::XNameReplace > ShapeUnoEventAcess_BASE;
    1365          26 : class ShapeUnoEventAccessImpl : public ShapeUnoEventAcess_BASE
    1366             : {
    1367             : private:
    1368             :     ScShapeObj* mpShape;
    1369             : 
    1370          13 :     ScMacroInfo* getInfo( bool bCreate = false )
    1371             :     {
    1372          13 :         return ScShapeObj_getShapeHyperMacroInfo( mpShape, bCreate );
    1373             :     }
    1374             : 
    1375             : public:
    1376          13 :     ShapeUnoEventAccessImpl( ScShapeObj* pShape ): mpShape( pShape )
    1377             :     {
    1378          13 :     }
    1379             : 
    1380             :     // XNameReplace
    1381           0 :     virtual void SAL_CALL replaceByName( const OUString& aName, const uno::Any& aElement )
    1382             :         throw (lang::IllegalArgumentException, container::NoSuchElementException,
    1383             :                lang::WrappedTargetException, uno::RuntimeException,
    1384             :                std::exception) SAL_OVERRIDE
    1385             :     {
    1386           0 :         if ( !hasByName( aName ) )
    1387           0 :             throw container::NoSuchElementException();
    1388           0 :         uno::Sequence< beans::PropertyValue > aProperties;
    1389           0 :         aElement >>= aProperties;
    1390           0 :         const beans::PropertyValue* pProperties = aProperties.getConstArray();
    1391           0 :         const sal_Int32 nCount = aProperties.getLength();
    1392             :         sal_Int32 nIndex;
    1393           0 :         bool isEventType = false;
    1394           0 :         for( nIndex = 0; nIndex < nCount; nIndex++, pProperties++ )
    1395             :         {
    1396           0 :             if ( pProperties->Name == SC_EVENTACC_EVENTTYPE )
    1397             :             {
    1398           0 :                 isEventType = true;
    1399           0 :                 continue;
    1400             :             }
    1401           0 :             if ( isEventType && (pProperties->Name == SC_EVENTACC_SCRIPT) )
    1402             :             {
    1403           0 :                 OUString sValue;
    1404           0 :                 if ( pProperties->Value >>= sValue )
    1405             :                 {
    1406           0 :                     ScMacroInfo* pInfo = getInfo( true );
    1407             :                     OSL_ENSURE( pInfo, "shape macro info could not be created!" );
    1408           0 :                     if ( !pInfo )
    1409           0 :                         break;
    1410           0 :                     if ( pProperties->Name == SC_EVENTACC_SCRIPT )
    1411           0 :                         pInfo->SetMacro( sValue );
    1412             :                     else
    1413           0 :                         pInfo->SetHlink( sValue );
    1414           0 :                 }
    1415             :             }
    1416           0 :         }
    1417           0 :     }
    1418             : 
    1419             :     // XNameAccess
    1420          13 :     virtual uno::Any SAL_CALL getByName( const OUString& aName )
    1421             :         throw (container::NoSuchElementException, lang::WrappedTargetException,
    1422             :                uno::RuntimeException, std::exception) SAL_OVERRIDE
    1423             :     {
    1424          13 :         uno::Sequence< beans::PropertyValue > aProperties;
    1425          13 :         ScMacroInfo* pInfo = getInfo();
    1426             : 
    1427          13 :         if ( aName == SC_EVENTACC_ONCLICK )
    1428             :         {
    1429          13 :             if ( pInfo && !pInfo->GetMacro().isEmpty() )
    1430             :             {
    1431           0 :                 aProperties.realloc( 2 );
    1432           0 :                 aProperties[ 0 ].Name = SC_EVENTACC_EVENTTYPE;
    1433           0 :                 aProperties[ 0 ].Value <<= OUString(SC_EVENTACC_SCRIPT);
    1434           0 :                 aProperties[ 1 ].Name = SC_EVENTACC_SCRIPT;
    1435           0 :                 aProperties[ 1 ].Value <<= pInfo->GetMacro();
    1436             :             }
    1437             :         }
    1438             :         else
    1439             :         {
    1440           0 :             throw container::NoSuchElementException();
    1441             :         }
    1442             : 
    1443          13 :         return uno::Any( aProperties );
    1444             :     }
    1445             : 
    1446           0 :     virtual uno::Sequence< OUString > SAL_CALL getElementNames() throw(uno::RuntimeException, std::exception) SAL_OVERRIDE
    1447             :     {
    1448           0 :         uno::Sequence< OUString > aSeq( 1 );
    1449           0 :         aSeq[ 0 ] = SC_EVENTACC_ONCLICK;
    1450           0 :         return aSeq;
    1451             :     }
    1452             : 
    1453          13 :     virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) throw(uno::RuntimeException, std::exception) SAL_OVERRIDE
    1454             :     {
    1455          13 :         return aName == SC_EVENTACC_ONCLICK;
    1456             :     }
    1457             : 
    1458             :     // XElementAccess
    1459           0 :     virtual uno::Type SAL_CALL getElementType() throw(uno::RuntimeException, std::exception) SAL_OVERRIDE
    1460             :     {
    1461           0 :         return cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get();
    1462             :     }
    1463             : 
    1464           0 :     virtual sal_Bool SAL_CALL hasElements() throw(uno::RuntimeException, std::exception) SAL_OVERRIDE
    1465             :     {
    1466             :         // elements are always present (but contained property sequences may be empty)
    1467           0 :         return sal_True;
    1468             :     }
    1469             : };
    1470             : 
    1471             : ::uno::Reference< container::XNameReplace > SAL_CALL
    1472          13 : ScShapeObj::getEvents(  ) throw(uno::RuntimeException, std::exception)
    1473             : {
    1474          13 :     return new ShapeUnoEventAccessImpl( this );
    1475             : }
    1476             : 
    1477           0 : OUString SAL_CALL ScShapeObj::getImplementationName(  ) throw (uno::RuntimeException, std::exception)
    1478             : {
    1479           0 :     return OUString( "com.sun.star.comp.sc.ScShapeObj" );
    1480             : }
    1481             : 
    1482          12 : sal_Bool SAL_CALL ScShapeObj::supportsService( const OUString& _ServiceName ) throw (uno::RuntimeException, std::exception)
    1483             : {
    1484          12 :     return cppu::supportsService(this, _ServiceName);
    1485             : }
    1486             : 
    1487          12 : uno::Sequence< OUString > SAL_CALL ScShapeObj::getSupportedServiceNames(  ) throw (uno::RuntimeException, std::exception)
    1488             : {
    1489          12 :     uno::Reference<lang::XServiceInfo> xSI;
    1490          12 :     if ( mxShapeAgg.is() )
    1491          12 :         mxShapeAgg->queryAggregation( cppu::UnoType<lang::XServiceInfo>::get() ) >>= xSI;
    1492             : 
    1493          12 :     uno::Sequence< OUString > aSupported;
    1494          12 :     if ( xSI.is() )
    1495          12 :         aSupported = xSI->getSupportedServiceNames();
    1496             : 
    1497          12 :     aSupported.realloc( aSupported.getLength() + 1 );
    1498          12 :     aSupported[ aSupported.getLength() - 1 ] = "com.sun.star.sheet.Shape";
    1499             : 
    1500          12 :     if( bIsNoteCaption )
    1501             :     {
    1502           4 :         aSupported.realloc( aSupported.getLength() + 1 );
    1503           4 :         aSupported[ aSupported.getLength() - 1 ] = "com.sun.star.sheet.CellAnnotationShape";
    1504             :     }
    1505             : 
    1506          12 :     return aSupported;
    1507         156 : }
    1508             : 
    1509             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11