1*b3f79822SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*b3f79822SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*b3f79822SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*b3f79822SAndrew Rist * distributed with this work for additional information 6*b3f79822SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*b3f79822SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*b3f79822SAndrew Rist * "License"); you may not use this file except in compliance 9*b3f79822SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*b3f79822SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*b3f79822SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*b3f79822SAndrew Rist * software distributed under the License is distributed on an 15*b3f79822SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*b3f79822SAndrew Rist * KIND, either express or implied. See the License for the 17*b3f79822SAndrew Rist * specific language governing permissions and limitations 18*b3f79822SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*b3f79822SAndrew Rist *************************************************************/ 21*b3f79822SAndrew Rist 22*b3f79822SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_sc.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir 28cdf0e10cSrcweir #include <com/sun/star/embed/Aspects.hpp> 29cdf0e10cSrcweir #include <com/sun/star/awt/Size.hpp> 30cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp> 31cdf0e10cSrcweir #include <com/sun/star/chart2/data/XDataReceiver.hpp> 32cdf0e10cSrcweir #include <com/sun/star/chart/ChartDataRowSource.hpp> 33cdf0e10cSrcweir #include <com/sun/star/chart2/XChartDocument.hpp> 34cdf0e10cSrcweir #include <com/sun/star/embed/Aspects.hpp> 35cdf0e10cSrcweir #include <com/sun/star/table/CellRangeAddress.hpp> 36cdf0e10cSrcweir 37cdf0e10cSrcweir #include <svx/svditer.hxx> 38cdf0e10cSrcweir #include <svx/svdoole2.hxx> 39cdf0e10cSrcweir #include <svx/svdpage.hxx> 40cdf0e10cSrcweir #include <svx/svdundo.hxx> 41cdf0e10cSrcweir #include <sfx2/app.hxx> 42cdf0e10cSrcweir #include <unotools/moduleoptions.hxx> 43cdf0e10cSrcweir #include <sot/clsids.hxx> 44cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx> 45cdf0e10cSrcweir 46cdf0e10cSrcweir #include "chartuno.hxx" 47cdf0e10cSrcweir #include "miscuno.hxx" 48cdf0e10cSrcweir #include "docsh.hxx" 49cdf0e10cSrcweir #include "drwlayer.hxx" 50cdf0e10cSrcweir #include "undodat.hxx" 51cdf0e10cSrcweir #include "chartarr.hxx" 52cdf0e10cSrcweir #include "chartlis.hxx" 53cdf0e10cSrcweir #include "unoguard.hxx" 54cdf0e10cSrcweir #include "chart2uno.hxx" 55cdf0e10cSrcweir #include "convuno.hxx" 56cdf0e10cSrcweir 57cdf0e10cSrcweir using namespace com::sun::star; 58cdf0e10cSrcweir 59cdf0e10cSrcweir #define PROP_HANDLE_RELATED_CELLRANGES 1 60cdf0e10cSrcweir 61cdf0e10cSrcweir //------------------------------------------------------------------------ 62cdf0e10cSrcweir 63cdf0e10cSrcweir SC_SIMPLE_SERVICE_INFO( ScChartObj, "ScChartObj", "com.sun.star.table.TableChart" ) 64cdf0e10cSrcweir SC_SIMPLE_SERVICE_INFO( ScChartsObj, "ScChartsObj", "com.sun.star.table.TableCharts" ) 65cdf0e10cSrcweir 66cdf0e10cSrcweir //------------------------------------------------------------------------ 67cdf0e10cSrcweir 68cdf0e10cSrcweir SdrOle2Obj* lcl_FindChartObj( ScDocShell* pDocShell, SCTAB nTab, const String& rName ) 69cdf0e10cSrcweir { 70cdf0e10cSrcweir if (pDocShell) 71cdf0e10cSrcweir { 72cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 73cdf0e10cSrcweir ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer(); 74cdf0e10cSrcweir if (pDrawLayer) 75cdf0e10cSrcweir { 76cdf0e10cSrcweir SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab)); 77cdf0e10cSrcweir DBG_ASSERT(pPage, "Page nicht gefunden"); 78cdf0e10cSrcweir if (pPage) 79cdf0e10cSrcweir { 80cdf0e10cSrcweir SdrObjListIter aIter( *pPage, IM_DEEPNOGROUPS ); 81cdf0e10cSrcweir SdrObject* pObject = aIter.Next(); 82cdf0e10cSrcweir while (pObject) 83cdf0e10cSrcweir { 84cdf0e10cSrcweir if ( pObject->GetObjIdentifier() == OBJ_OLE2 && pDoc->IsChart(pObject) ) 85cdf0e10cSrcweir { 86cdf0e10cSrcweir uno::Reference < embed::XEmbeddedObject > xObj = ((SdrOle2Obj*)pObject)->GetObjRef(); 87cdf0e10cSrcweir if ( xObj.is() ) 88cdf0e10cSrcweir { 89cdf0e10cSrcweir String aObjName = pDocShell->GetEmbeddedObjectContainer().GetEmbeddedObjectName( xObj ); 90cdf0e10cSrcweir if ( aObjName == rName ) 91cdf0e10cSrcweir return (SdrOle2Obj*)pObject; 92cdf0e10cSrcweir } 93cdf0e10cSrcweir } 94cdf0e10cSrcweir pObject = aIter.Next(); 95cdf0e10cSrcweir } 96cdf0e10cSrcweir } 97cdf0e10cSrcweir } 98cdf0e10cSrcweir } 99cdf0e10cSrcweir return NULL; 100cdf0e10cSrcweir } 101cdf0e10cSrcweir 102cdf0e10cSrcweir //------------------------------------------------------------------------ 103cdf0e10cSrcweir 104cdf0e10cSrcweir ScChartsObj::ScChartsObj(ScDocShell* pDocSh, SCTAB nT) : 105cdf0e10cSrcweir pDocShell( pDocSh ), 106cdf0e10cSrcweir nTab( nT ) 107cdf0e10cSrcweir { 108cdf0e10cSrcweir pDocShell->GetDocument()->AddUnoObject(*this); 109cdf0e10cSrcweir } 110cdf0e10cSrcweir 111cdf0e10cSrcweir ScChartsObj::~ScChartsObj() 112cdf0e10cSrcweir { 113cdf0e10cSrcweir if (pDocShell) 114cdf0e10cSrcweir pDocShell->GetDocument()->RemoveUnoObject(*this); 115cdf0e10cSrcweir } 116cdf0e10cSrcweir 117cdf0e10cSrcweir void ScChartsObj::Notify( SfxBroadcaster&, const SfxHint& rHint ) 118cdf0e10cSrcweir { 119cdf0e10cSrcweir //! Referenz-Update 120cdf0e10cSrcweir 121cdf0e10cSrcweir if ( rHint.ISA( SfxSimpleHint ) && 122cdf0e10cSrcweir ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING ) 123cdf0e10cSrcweir { 124cdf0e10cSrcweir pDocShell = NULL; // ungueltig geworden 125cdf0e10cSrcweir } 126cdf0e10cSrcweir } 127cdf0e10cSrcweir 128cdf0e10cSrcweir ScChartObj* ScChartsObj::GetObjectByIndex_Impl(long nIndex) const 129cdf0e10cSrcweir { 130cdf0e10cSrcweir String aName; 131cdf0e10cSrcweir if ( pDocShell ) 132cdf0e10cSrcweir { 133cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 134cdf0e10cSrcweir ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer(); 135cdf0e10cSrcweir if (pDrawLayer) 136cdf0e10cSrcweir { 137cdf0e10cSrcweir SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab)); 138cdf0e10cSrcweir DBG_ASSERT(pPage, "Page nicht gefunden"); 139cdf0e10cSrcweir if (pPage) 140cdf0e10cSrcweir { 141cdf0e10cSrcweir long nPos = 0; 142cdf0e10cSrcweir SdrObjListIter aIter( *pPage, IM_DEEPNOGROUPS ); 143cdf0e10cSrcweir SdrObject* pObject = aIter.Next(); 144cdf0e10cSrcweir while (pObject) 145cdf0e10cSrcweir { 146cdf0e10cSrcweir if ( pObject->GetObjIdentifier() == OBJ_OLE2 && pDoc->IsChart(pObject) ) 147cdf0e10cSrcweir { 148cdf0e10cSrcweir if ( nPos == nIndex ) 149cdf0e10cSrcweir { 150cdf0e10cSrcweir uno::Reference < embed::XEmbeddedObject > xObj = ((SdrOle2Obj*)pObject)->GetObjRef(); 151cdf0e10cSrcweir if ( xObj.is() ) 152cdf0e10cSrcweir aName = pDocShell->GetEmbeddedObjectContainer().GetEmbeddedObjectName( xObj ); 153cdf0e10cSrcweir break; // nicht weitersuchen 154cdf0e10cSrcweir } 155cdf0e10cSrcweir ++nPos; 156cdf0e10cSrcweir } 157cdf0e10cSrcweir pObject = aIter.Next(); 158cdf0e10cSrcweir } 159cdf0e10cSrcweir } 160cdf0e10cSrcweir } 161cdf0e10cSrcweir } 162cdf0e10cSrcweir 163cdf0e10cSrcweir if (aName.Len()) 164cdf0e10cSrcweir return new ScChartObj( pDocShell, nTab, aName ); 165cdf0e10cSrcweir return NULL; 166cdf0e10cSrcweir } 167cdf0e10cSrcweir 168cdf0e10cSrcweir ScChartObj* ScChartsObj::GetObjectByName_Impl(const rtl::OUString& aName) const 169cdf0e10cSrcweir { 170cdf0e10cSrcweir String aNameString(aName); 171cdf0e10cSrcweir if ( lcl_FindChartObj( pDocShell, nTab, aNameString ) ) 172cdf0e10cSrcweir return new ScChartObj( pDocShell, nTab, aNameString ); 173cdf0e10cSrcweir return NULL; 174cdf0e10cSrcweir } 175cdf0e10cSrcweir 176cdf0e10cSrcweir // XTableCharts 177cdf0e10cSrcweir 178cdf0e10cSrcweir void SAL_CALL ScChartsObj::addNewByName( const rtl::OUString& aName, 179cdf0e10cSrcweir const awt::Rectangle& aRect, 180cdf0e10cSrcweir const uno::Sequence<table::CellRangeAddress>& aRanges, 181cdf0e10cSrcweir sal_Bool bColumnHeaders, sal_Bool bRowHeaders ) 182cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException) 183cdf0e10cSrcweir { 184cdf0e10cSrcweir ScUnoGuard aGuard; 185cdf0e10cSrcweir if (!pDocShell) 186cdf0e10cSrcweir return; 187cdf0e10cSrcweir 188cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 189cdf0e10cSrcweir ScDrawLayer* pModel = pDocShell->MakeDrawLayer(); 190cdf0e10cSrcweir SdrPage* pPage = pModel->GetPage(static_cast<sal_uInt16>(nTab)); 191cdf0e10cSrcweir DBG_ASSERT(pPage,"addChart: keine Page"); 192cdf0e10cSrcweir if (!pPage || !pDoc) 193cdf0e10cSrcweir return; 194cdf0e10cSrcweir 195cdf0e10cSrcweir // chart can't be inserted if any ole object with that name exists on any table 196cdf0e10cSrcweir // (empty string: generate valid name) 197cdf0e10cSrcweir 198cdf0e10cSrcweir String aNameString(aName); 199cdf0e10cSrcweir SCTAB nDummy; 200cdf0e10cSrcweir if ( aNameString.Len() && pModel->GetNamedObject( aNameString, OBJ_OLE2, nDummy ) ) 201cdf0e10cSrcweir { 202cdf0e10cSrcweir // object exists - only RuntimeException is specified 203cdf0e10cSrcweir throw uno::RuntimeException(); 204cdf0e10cSrcweir } 205cdf0e10cSrcweir 206cdf0e10cSrcweir ScRangeList* pList = new ScRangeList; 207cdf0e10cSrcweir sal_uInt16 nRangeCount = (sal_uInt16)aRanges.getLength(); 208cdf0e10cSrcweir if (nRangeCount) 209cdf0e10cSrcweir { 210cdf0e10cSrcweir const table::CellRangeAddress* pAry = aRanges.getConstArray(); 211cdf0e10cSrcweir for (sal_uInt16 i=0; i<nRangeCount; i++) 212cdf0e10cSrcweir { 213cdf0e10cSrcweir ScRange aRange( static_cast<SCCOL>(pAry[i].StartColumn), pAry[i].StartRow, pAry[i].Sheet, 214cdf0e10cSrcweir static_cast<SCCOL>(pAry[i].EndColumn), pAry[i].EndRow, pAry[i].Sheet ); 215cdf0e10cSrcweir pList->Append( aRange ); 216cdf0e10cSrcweir } 217cdf0e10cSrcweir } 218cdf0e10cSrcweir ScRangeListRef xNewRanges( pList ); 219cdf0e10cSrcweir 220cdf0e10cSrcweir uno::Reference < embed::XEmbeddedObject > xObj; 221cdf0e10cSrcweir ::rtl::OUString aTmp( aNameString ); 222cdf0e10cSrcweir if ( SvtModuleOptions().IsChart() ) 223cdf0e10cSrcweir xObj = pDocShell->GetEmbeddedObjectContainer().CreateEmbeddedObject( SvGlobalName( SO3_SCH_CLASSID ).GetByteSequence(), aTmp ); 224cdf0e10cSrcweir if ( xObj.is() ) 225cdf0e10cSrcweir { 226cdf0e10cSrcweir String aObjName = aTmp; // wirklich eingefuegter Name... 227cdf0e10cSrcweir 228cdf0e10cSrcweir // Rechteck anpassen 229cdf0e10cSrcweir //! Fehler/Exception, wenn leer/ungueltig ??? 230cdf0e10cSrcweir Point aRectPos( aRect.X, aRect.Y ); 231cdf0e10cSrcweir bool bLayoutRTL = pDoc->IsLayoutRTL( nTab ); 232cdf0e10cSrcweir if ( ( aRectPos.X() < 0 && !bLayoutRTL ) || ( aRectPos.X() > 0 && bLayoutRTL ) ) aRectPos.X() = 0; 233cdf0e10cSrcweir if (aRectPos.Y() < 0) aRectPos.Y() = 0; 234cdf0e10cSrcweir Size aRectSize( aRect.Width, aRect.Height ); 235cdf0e10cSrcweir if (aRectSize.Width() <= 0) aRectSize.Width() = 5000; // Default-Groesse 236cdf0e10cSrcweir if (aRectSize.Height() <= 0) aRectSize.Height() = 5000; 237cdf0e10cSrcweir Rectangle aInsRect( aRectPos, aRectSize ); 238cdf0e10cSrcweir 239cdf0e10cSrcweir sal_Int64 nAspect(embed::Aspects::MSOLE_CONTENT); 240cdf0e10cSrcweir MapUnit aMapUnit(VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( nAspect ) )); 241cdf0e10cSrcweir Size aSize(aInsRect.GetSize()); 242cdf0e10cSrcweir aSize = Window::LogicToLogic( aSize, MapMode( MAP_100TH_MM ), MapMode( aMapUnit ) ); 243cdf0e10cSrcweir awt::Size aSz; 244cdf0e10cSrcweir aSz.Width = aSize.Width(); 245cdf0e10cSrcweir aSz.Height = aSize.Height(); 246cdf0e10cSrcweir 247cdf0e10cSrcweir // Calc -> DataProvider 248cdf0e10cSrcweir uno::Reference< chart2::data::XDataProvider > xDataProvider = new 249cdf0e10cSrcweir ScChart2DataProvider( pDoc ); 250cdf0e10cSrcweir // Chart -> DataReceiver 251cdf0e10cSrcweir uno::Reference< chart2::data::XDataReceiver > xReceiver; 252cdf0e10cSrcweir uno::Reference< embed::XComponentSupplier > xCompSupp( xObj, uno::UNO_QUERY ); 253cdf0e10cSrcweir if( xCompSupp.is()) 254cdf0e10cSrcweir xReceiver.set( xCompSupp->getComponent(), uno::UNO_QUERY ); 255cdf0e10cSrcweir if( xReceiver.is()) 256cdf0e10cSrcweir { 257cdf0e10cSrcweir String sRangeStr; 258cdf0e10cSrcweir xNewRanges->Format(sRangeStr, SCR_ABS_3D, pDoc); 259cdf0e10cSrcweir 260cdf0e10cSrcweir // connect 261cdf0e10cSrcweir if( sRangeStr.Len() ) 262cdf0e10cSrcweir xReceiver->attachDataProvider( xDataProvider ); 263cdf0e10cSrcweir else 264cdf0e10cSrcweir sRangeStr = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM( "all" ) ); 265cdf0e10cSrcweir 266cdf0e10cSrcweir uno::Reference< util::XNumberFormatsSupplier > xNumberFormatsSupplier( pDocShell->GetModel(), uno::UNO_QUERY ); 267cdf0e10cSrcweir xReceiver->attachNumberFormatsSupplier( xNumberFormatsSupplier ); 268cdf0e10cSrcweir 269cdf0e10cSrcweir // set arguments 270cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > aArgs( 4 ); 271cdf0e10cSrcweir aArgs[0] = beans::PropertyValue( 272cdf0e10cSrcweir ::rtl::OUString::createFromAscii("CellRangeRepresentation"), -1, 273cdf0e10cSrcweir uno::makeAny( ::rtl::OUString( sRangeStr )), beans::PropertyState_DIRECT_VALUE ); 274cdf0e10cSrcweir aArgs[1] = beans::PropertyValue( 275cdf0e10cSrcweir ::rtl::OUString::createFromAscii("HasCategories"), -1, 276cdf0e10cSrcweir uno::makeAny( bRowHeaders ), beans::PropertyState_DIRECT_VALUE ); 277cdf0e10cSrcweir aArgs[2] = beans::PropertyValue( 278cdf0e10cSrcweir ::rtl::OUString::createFromAscii("FirstCellAsLabel"), -1, 279cdf0e10cSrcweir uno::makeAny( bColumnHeaders ), beans::PropertyState_DIRECT_VALUE ); 280cdf0e10cSrcweir aArgs[3] = beans::PropertyValue( 281cdf0e10cSrcweir ::rtl::OUString::createFromAscii("DataRowSource"), -1, 282cdf0e10cSrcweir uno::makeAny( chart::ChartDataRowSource_COLUMNS ), beans::PropertyState_DIRECT_VALUE ); 283cdf0e10cSrcweir xReceiver->setArguments( aArgs ); 284cdf0e10cSrcweir } 285cdf0e10cSrcweir 286cdf0e10cSrcweir ScChartListener* pChartListener = 287cdf0e10cSrcweir new ScChartListener( aObjName, pDoc, xNewRanges ); 288cdf0e10cSrcweir pDoc->GetChartListenerCollection()->Insert( pChartListener ); 289cdf0e10cSrcweir pChartListener->StartListeningTo(); 290cdf0e10cSrcweir 291cdf0e10cSrcweir SdrOle2Obj* pObj = new SdrOle2Obj( ::svt::EmbeddedObjectRef( xObj, embed::Aspects::MSOLE_CONTENT ), aObjName, aInsRect ); 292cdf0e10cSrcweir 293cdf0e10cSrcweir // set VisArea 294cdf0e10cSrcweir if( xObj.is()) 295cdf0e10cSrcweir xObj->setVisualAreaSize( nAspect, aSz ); 296cdf0e10cSrcweir 297cdf0e10cSrcweir pPage->InsertObject( pObj ); 298cdf0e10cSrcweir pModel->AddUndo( new SdrUndoNewObj( *pObj ) ); 299cdf0e10cSrcweir 300cdf0e10cSrcweir // Dies veranlaesst Chart zum sofortigen Update 301cdf0e10cSrcweir //SvData aEmpty; 302cdf0e10cSrcweir //aIPObj->SendDataChanged( aEmpty ); 303cdf0e10cSrcweir } 304cdf0e10cSrcweir } 305cdf0e10cSrcweir 306cdf0e10cSrcweir void SAL_CALL ScChartsObj::removeByName( const rtl::OUString& aName ) 307cdf0e10cSrcweir throw(uno::RuntimeException) 308cdf0e10cSrcweir { 309cdf0e10cSrcweir ScUnoGuard aGuard; 310cdf0e10cSrcweir String aNameString(aName); 311cdf0e10cSrcweir SdrOle2Obj* pObj = lcl_FindChartObj( pDocShell, nTab, aNameString ); 312cdf0e10cSrcweir if (pObj) 313cdf0e10cSrcweir { 314cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 315cdf0e10cSrcweir ScDrawLayer* pModel = pDoc->GetDrawLayer(); // ist nicht 0 316cdf0e10cSrcweir SdrPage* pPage = pModel->GetPage(static_cast<sal_uInt16>(nTab)); // ist nicht 0 317cdf0e10cSrcweir 318cdf0e10cSrcweir pModel->AddUndo( new SdrUndoDelObj( *pObj ) ); 319cdf0e10cSrcweir pPage->RemoveObject( pObj->GetOrdNum() ); 320cdf0e10cSrcweir 321cdf0e10cSrcweir //! Notify etc.??? 322cdf0e10cSrcweir } 323cdf0e10cSrcweir } 324cdf0e10cSrcweir 325cdf0e10cSrcweir // XEnumerationAccess 326cdf0e10cSrcweir 327cdf0e10cSrcweir uno::Reference<container::XEnumeration> SAL_CALL ScChartsObj::createEnumeration() 328cdf0e10cSrcweir throw(uno::RuntimeException) 329cdf0e10cSrcweir { 330cdf0e10cSrcweir ScUnoGuard aGuard; 331cdf0e10cSrcweir return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.table.TableChartsEnumeration"))); 332cdf0e10cSrcweir } 333cdf0e10cSrcweir 334cdf0e10cSrcweir // XIndexAccess 335cdf0e10cSrcweir 336cdf0e10cSrcweir sal_Int32 SAL_CALL ScChartsObj::getCount() throw(uno::RuntimeException) 337cdf0e10cSrcweir { 338cdf0e10cSrcweir ScUnoGuard aGuard; 339cdf0e10cSrcweir sal_Int32 nCount = 0; 340cdf0e10cSrcweir if ( pDocShell ) 341cdf0e10cSrcweir { 342cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 343cdf0e10cSrcweir ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer(); 344cdf0e10cSrcweir if (pDrawLayer) 345cdf0e10cSrcweir { 346cdf0e10cSrcweir SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab)); 347cdf0e10cSrcweir DBG_ASSERT(pPage, "Page nicht gefunden"); 348cdf0e10cSrcweir if (pPage) 349cdf0e10cSrcweir { 350cdf0e10cSrcweir SdrObjListIter aIter( *pPage, IM_DEEPNOGROUPS ); 351cdf0e10cSrcweir SdrObject* pObject = aIter.Next(); 352cdf0e10cSrcweir while (pObject) 353cdf0e10cSrcweir { 354cdf0e10cSrcweir if ( pObject->GetObjIdentifier() == OBJ_OLE2 && pDoc->IsChart(pObject) ) 355cdf0e10cSrcweir ++nCount; 356cdf0e10cSrcweir pObject = aIter.Next(); 357cdf0e10cSrcweir } 358cdf0e10cSrcweir } 359cdf0e10cSrcweir } 360cdf0e10cSrcweir } 361cdf0e10cSrcweir return nCount; 362cdf0e10cSrcweir } 363cdf0e10cSrcweir 364cdf0e10cSrcweir uno::Any SAL_CALL ScChartsObj::getByIndex( sal_Int32 nIndex ) 365cdf0e10cSrcweir throw(lang::IndexOutOfBoundsException, 366cdf0e10cSrcweir lang::WrappedTargetException, uno::RuntimeException) 367cdf0e10cSrcweir { 368cdf0e10cSrcweir ScUnoGuard aGuard; 369cdf0e10cSrcweir uno::Reference<table::XTableChart> xChart(GetObjectByIndex_Impl(nIndex)); 370cdf0e10cSrcweir if (xChart.is()) 371cdf0e10cSrcweir return uno::makeAny(xChart); 372cdf0e10cSrcweir else 373cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(); 374cdf0e10cSrcweir // return uno::Any(); 375cdf0e10cSrcweir } 376cdf0e10cSrcweir 377cdf0e10cSrcweir uno::Type SAL_CALL ScChartsObj::getElementType() throw(uno::RuntimeException) 378cdf0e10cSrcweir { 379cdf0e10cSrcweir ScUnoGuard aGuard; 380cdf0e10cSrcweir return getCppuType((uno::Reference<table::XTableChart>*)0); 381cdf0e10cSrcweir } 382cdf0e10cSrcweir 383cdf0e10cSrcweir sal_Bool SAL_CALL ScChartsObj::hasElements() throw(uno::RuntimeException) 384cdf0e10cSrcweir { 385cdf0e10cSrcweir ScUnoGuard aGuard; 386cdf0e10cSrcweir return getCount() != 0; 387cdf0e10cSrcweir } 388cdf0e10cSrcweir 389cdf0e10cSrcweir uno::Any SAL_CALL ScChartsObj::getByName( const rtl::OUString& aName ) 390cdf0e10cSrcweir throw(container::NoSuchElementException, 391cdf0e10cSrcweir lang::WrappedTargetException, uno::RuntimeException) 392cdf0e10cSrcweir { 393cdf0e10cSrcweir ScUnoGuard aGuard; 394cdf0e10cSrcweir uno::Reference<table::XTableChart> xChart(GetObjectByName_Impl(aName)); 395cdf0e10cSrcweir if (xChart.is()) 396cdf0e10cSrcweir return uno::makeAny(xChart); 397cdf0e10cSrcweir else 398cdf0e10cSrcweir throw container::NoSuchElementException(); 399cdf0e10cSrcweir // return uno::Any(); 400cdf0e10cSrcweir } 401cdf0e10cSrcweir 402cdf0e10cSrcweir uno::Sequence<rtl::OUString> SAL_CALL ScChartsObj::getElementNames() throw(uno::RuntimeException) 403cdf0e10cSrcweir { 404cdf0e10cSrcweir ScUnoGuard aGuard; 405cdf0e10cSrcweir if (pDocShell) 406cdf0e10cSrcweir { 407cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 408cdf0e10cSrcweir 409cdf0e10cSrcweir long nCount = getCount(); 410cdf0e10cSrcweir uno::Sequence<rtl::OUString> aSeq(nCount); 411cdf0e10cSrcweir rtl::OUString* pAry = aSeq.getArray(); 412cdf0e10cSrcweir 413cdf0e10cSrcweir long nPos = 0; 414cdf0e10cSrcweir ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer(); 415cdf0e10cSrcweir if (pDrawLayer) 416cdf0e10cSrcweir { 417cdf0e10cSrcweir SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab)); 418cdf0e10cSrcweir DBG_ASSERT(pPage, "Page nicht gefunden"); 419cdf0e10cSrcweir if (pPage) 420cdf0e10cSrcweir { 421cdf0e10cSrcweir SdrObjListIter aIter( *pPage, IM_DEEPNOGROUPS ); 422cdf0e10cSrcweir SdrObject* pObject = aIter.Next(); 423cdf0e10cSrcweir while (pObject) 424cdf0e10cSrcweir { 425cdf0e10cSrcweir if ( pObject->GetObjIdentifier() == OBJ_OLE2 && pDoc->IsChart(pObject) ) 426cdf0e10cSrcweir { 427cdf0e10cSrcweir String aName; 428cdf0e10cSrcweir uno::Reference < embed::XEmbeddedObject > xObj = ((SdrOle2Obj*)pObject)->GetObjRef(); 429cdf0e10cSrcweir if ( xObj.is() ) 430cdf0e10cSrcweir aName = pDocShell->GetEmbeddedObjectContainer().GetEmbeddedObjectName( xObj ); 431cdf0e10cSrcweir 432cdf0e10cSrcweir DBG_ASSERT(nPos<nCount, "huch, verzaehlt?"); 433cdf0e10cSrcweir pAry[nPos++] = aName; 434cdf0e10cSrcweir } 435cdf0e10cSrcweir pObject = aIter.Next(); 436cdf0e10cSrcweir } 437cdf0e10cSrcweir } 438cdf0e10cSrcweir } 439cdf0e10cSrcweir DBG_ASSERT(nPos==nCount, "nanu, verzaehlt?"); 440cdf0e10cSrcweir 441cdf0e10cSrcweir return aSeq; 442cdf0e10cSrcweir } 443cdf0e10cSrcweir return uno::Sequence<rtl::OUString>(0); 444cdf0e10cSrcweir } 445cdf0e10cSrcweir 446cdf0e10cSrcweir sal_Bool SAL_CALL ScChartsObj::hasByName( const rtl::OUString& aName ) 447cdf0e10cSrcweir throw(uno::RuntimeException) 448cdf0e10cSrcweir { 449cdf0e10cSrcweir ScUnoGuard aGuard; 450cdf0e10cSrcweir String aNameString(aName); 451cdf0e10cSrcweir return ( lcl_FindChartObj( pDocShell, nTab, aNameString ) != NULL ); 452cdf0e10cSrcweir } 453cdf0e10cSrcweir 454cdf0e10cSrcweir //------------------------------------------------------------------------ 455cdf0e10cSrcweir 456cdf0e10cSrcweir ScChartObj::ScChartObj(ScDocShell* pDocSh, SCTAB nT, const String& rN) 457cdf0e10cSrcweir :ScChartObj_Base( m_aMutex ) 458cdf0e10cSrcweir ,ScChartObj_PBase( ScChartObj_Base::rBHelper ) 459cdf0e10cSrcweir ,pDocShell( pDocSh ) 460cdf0e10cSrcweir ,nTab( nT ) 461cdf0e10cSrcweir ,aChartName( rN ) 462cdf0e10cSrcweir { 463cdf0e10cSrcweir pDocShell->GetDocument()->AddUnoObject(*this); 464cdf0e10cSrcweir 465cdf0e10cSrcweir uno::Sequence< table::CellRangeAddress > aInitialPropValue; 466cdf0e10cSrcweir registerPropertyNoMember( ::rtl::OUString::createFromAscii( "RelatedCellRanges" ), 467cdf0e10cSrcweir PROP_HANDLE_RELATED_CELLRANGES, beans::PropertyAttribute::MAYBEVOID, 468cdf0e10cSrcweir ::getCppuType( &aInitialPropValue ), &aInitialPropValue ); 469cdf0e10cSrcweir } 470cdf0e10cSrcweir 471cdf0e10cSrcweir ScChartObj::~ScChartObj() 472cdf0e10cSrcweir { 473cdf0e10cSrcweir if (pDocShell) 474cdf0e10cSrcweir pDocShell->GetDocument()->RemoveUnoObject(*this); 475cdf0e10cSrcweir } 476cdf0e10cSrcweir 477cdf0e10cSrcweir void ScChartObj::Notify( SfxBroadcaster&, const SfxHint& rHint ) 478cdf0e10cSrcweir { 479cdf0e10cSrcweir //! Referenz-Update 480cdf0e10cSrcweir 481cdf0e10cSrcweir if ( rHint.ISA( SfxSimpleHint ) && 482cdf0e10cSrcweir ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING ) 483cdf0e10cSrcweir { 484cdf0e10cSrcweir pDocShell = NULL; // ungueltig geworden 485cdf0e10cSrcweir } 486cdf0e10cSrcweir } 487cdf0e10cSrcweir 488cdf0e10cSrcweir void ScChartObj::GetData_Impl( ScRangeListRef& rRanges, bool& rColHeaders, bool& rRowHeaders ) const 489cdf0e10cSrcweir { 490cdf0e10cSrcweir bool bFound = false; 491cdf0e10cSrcweir ScDocument* pDoc = (pDocShell? pDocShell->GetDocument(): 0); 492cdf0e10cSrcweir 493cdf0e10cSrcweir if( pDoc ) 494cdf0e10cSrcweir { 495cdf0e10cSrcweir uno::Reference< chart2::XChartDocument > xChartDoc( pDoc->GetChartByName( aChartName ) ); 496cdf0e10cSrcweir if( xChartDoc.is() ) 497cdf0e10cSrcweir { 498cdf0e10cSrcweir uno::Reference< chart2::data::XDataReceiver > xReceiver( xChartDoc, uno::UNO_QUERY ); 499cdf0e10cSrcweir uno::Reference< chart2::data::XDataProvider > xProvider = xChartDoc->getDataProvider(); 500cdf0e10cSrcweir if( xReceiver.is() && xProvider.is() ) 501cdf0e10cSrcweir { 502cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > aArgs( xProvider->detectArguments( xReceiver->getUsedData() ) ); 503cdf0e10cSrcweir 504cdf0e10cSrcweir rtl::OUString aRanges; 505cdf0e10cSrcweir chart::ChartDataRowSource eDataRowSource = chart::ChartDataRowSource_COLUMNS; 506cdf0e10cSrcweir bool bHasCategories=false; 507cdf0e10cSrcweir bool bFirstCellAsLabel=false; 508cdf0e10cSrcweir const beans::PropertyValue* pPropArray = aArgs.getConstArray(); 509cdf0e10cSrcweir long nPropCount = aArgs.getLength(); 510cdf0e10cSrcweir for (long i = 0; i < nPropCount; i++) 511cdf0e10cSrcweir { 512cdf0e10cSrcweir const beans::PropertyValue& rProp = pPropArray[i]; 513cdf0e10cSrcweir String aPropName(rProp.Name); 514cdf0e10cSrcweir 515cdf0e10cSrcweir if (aPropName.EqualsAscii( "CellRangeRepresentation" )) 516cdf0e10cSrcweir rProp.Value >>= aRanges; 517cdf0e10cSrcweir else if (aPropName.EqualsAscii( "DataRowSource" )) 518cdf0e10cSrcweir eDataRowSource = (chart::ChartDataRowSource)ScUnoHelpFunctions::GetEnumFromAny( rProp.Value ); 519cdf0e10cSrcweir else if (aPropName.EqualsAscii( "HasCategories" )) 520cdf0e10cSrcweir bHasCategories = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value ); 521cdf0e10cSrcweir else if (aPropName.EqualsAscii( "FirstCellAsLabel" )) 522cdf0e10cSrcweir bFirstCellAsLabel = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value ); 523cdf0e10cSrcweir } 524cdf0e10cSrcweir 525cdf0e10cSrcweir if( chart::ChartDataRowSource_COLUMNS == eDataRowSource ) 526cdf0e10cSrcweir { 527cdf0e10cSrcweir rColHeaders=bFirstCellAsLabel; 528cdf0e10cSrcweir rRowHeaders=bHasCategories; 529cdf0e10cSrcweir } 530cdf0e10cSrcweir else 531cdf0e10cSrcweir { 532cdf0e10cSrcweir rColHeaders=bHasCategories; 533cdf0e10cSrcweir rRowHeaders=bFirstCellAsLabel; 534cdf0e10cSrcweir } 535cdf0e10cSrcweir rRanges->Parse( aRanges, pDoc); 536cdf0e10cSrcweir } 537cdf0e10cSrcweir bFound = true; 538cdf0e10cSrcweir } 539cdf0e10cSrcweir } 540cdf0e10cSrcweir if( !bFound ) 541cdf0e10cSrcweir { 542cdf0e10cSrcweir rRanges = 0; 543cdf0e10cSrcweir rColHeaders = false; 544cdf0e10cSrcweir rRowHeaders = false; 545cdf0e10cSrcweir } 546cdf0e10cSrcweir } 547cdf0e10cSrcweir 548cdf0e10cSrcweir void ScChartObj::Update_Impl( const ScRangeListRef& rRanges, bool bColHeaders, bool bRowHeaders ) 549cdf0e10cSrcweir { 550cdf0e10cSrcweir if (pDocShell) 551cdf0e10cSrcweir { 552cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 553cdf0e10cSrcweir sal_Bool bUndo(pDoc->IsUndoEnabled()); 554cdf0e10cSrcweir 555cdf0e10cSrcweir if (bUndo) 556cdf0e10cSrcweir { 557cdf0e10cSrcweir pDocShell->GetUndoManager()->AddUndoAction( 558cdf0e10cSrcweir new ScUndoChartData( pDocShell, aChartName, rRanges, bColHeaders, bRowHeaders, sal_False ) ); 559cdf0e10cSrcweir } 560cdf0e10cSrcweir pDoc->UpdateChartArea( aChartName, rRanges, bColHeaders, bRowHeaders, sal_False ); 561cdf0e10cSrcweir } 562cdf0e10cSrcweir } 563cdf0e10cSrcweir 564cdf0e10cSrcweir // ::comphelper::OPropertySetHelper 565cdf0e10cSrcweir 566cdf0e10cSrcweir ::cppu::IPropertyArrayHelper& ScChartObj::getInfoHelper() 567cdf0e10cSrcweir { 568cdf0e10cSrcweir return *ScChartObj_PABase::getArrayHelper(); 569cdf0e10cSrcweir } 570cdf0e10cSrcweir 571cdf0e10cSrcweir void ScChartObj::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const uno::Any& rValue ) throw (uno::Exception) 572cdf0e10cSrcweir { 573cdf0e10cSrcweir switch ( nHandle ) 574cdf0e10cSrcweir { 575cdf0e10cSrcweir case PROP_HANDLE_RELATED_CELLRANGES: 576cdf0e10cSrcweir { 577cdf0e10cSrcweir uno::Sequence< table::CellRangeAddress > aCellRanges; 578cdf0e10cSrcweir if ( rValue >>= aCellRanges ) 579cdf0e10cSrcweir { 580cdf0e10cSrcweir ScRangeListRef rRangeList = new ScRangeList(); 581cdf0e10cSrcweir const table::CellRangeAddress* pCellRanges = aCellRanges.getArray(); 582cdf0e10cSrcweir sal_Int32 nCount = aCellRanges.getLength(); 583cdf0e10cSrcweir for ( sal_Int32 i = 0; i < nCount; ++i ) 584cdf0e10cSrcweir { 585cdf0e10cSrcweir table::CellRangeAddress aCellRange = pCellRanges[ i ]; 586cdf0e10cSrcweir ScRange aRange; 587cdf0e10cSrcweir ScUnoConversion::FillScRange( aRange, aCellRange ); 588cdf0e10cSrcweir rRangeList->Append( aRange ); 589cdf0e10cSrcweir } 590cdf0e10cSrcweir ScDocument* pDoc = ( pDocShell ? pDocShell->GetDocument() : NULL ); 591cdf0e10cSrcweir ScChartListenerCollection* pCollection = ( pDoc ? pDoc->GetChartListenerCollection() : NULL ); 592cdf0e10cSrcweir if ( pCollection ) 593cdf0e10cSrcweir { 594cdf0e10cSrcweir pCollection->ChangeListening( aChartName, rRangeList ); 595cdf0e10cSrcweir } 596cdf0e10cSrcweir } 597cdf0e10cSrcweir } 598cdf0e10cSrcweir break; 599cdf0e10cSrcweir default: 600cdf0e10cSrcweir { 601cdf0e10cSrcweir } 602cdf0e10cSrcweir break; 603cdf0e10cSrcweir } 604cdf0e10cSrcweir } 605cdf0e10cSrcweir 606cdf0e10cSrcweir void ScChartObj::getFastPropertyValue( uno::Any& rValue, sal_Int32 nHandle ) const 607cdf0e10cSrcweir { 608cdf0e10cSrcweir switch ( nHandle ) 609cdf0e10cSrcweir { 610cdf0e10cSrcweir case PROP_HANDLE_RELATED_CELLRANGES: 611cdf0e10cSrcweir { 612cdf0e10cSrcweir ScDocument* pDoc = ( pDocShell ? pDocShell->GetDocument() : NULL ); 613cdf0e10cSrcweir if ( pDoc ) 614cdf0e10cSrcweir { 615cdf0e10cSrcweir ScRange aEmptyRange; 616cdf0e10cSrcweir sal_uInt16 nIndex = 0; 617cdf0e10cSrcweir ScChartListener aSearcher( aChartName, pDoc, aEmptyRange ); 618cdf0e10cSrcweir ScChartListenerCollection* pCollection = pDoc->GetChartListenerCollection(); 619cdf0e10cSrcweir if ( pCollection && pCollection->Search( &aSearcher, nIndex ) ) 620cdf0e10cSrcweir { 621cdf0e10cSrcweir ScChartListener* pListener = static_cast< ScChartListener* >( pCollection->At( nIndex ) ); 622cdf0e10cSrcweir if ( pListener ) 623cdf0e10cSrcweir { 624cdf0e10cSrcweir const ScRangeListRef& rRangeList = pListener->GetRangeList(); 625cdf0e10cSrcweir if ( rRangeList.Is() ) 626cdf0e10cSrcweir { 627cdf0e10cSrcweir sal_uLong nCount = rRangeList->Count(); 628cdf0e10cSrcweir uno::Sequence< table::CellRangeAddress > aCellRanges( nCount ); 629cdf0e10cSrcweir table::CellRangeAddress* pCellRanges = aCellRanges.getArray(); 630cdf0e10cSrcweir for ( sal_uInt16 i = 0; i < nCount; ++i ) 631cdf0e10cSrcweir { 632cdf0e10cSrcweir ScRange aRange( *rRangeList->GetObject( i ) ); 633cdf0e10cSrcweir table::CellRangeAddress aCellRange; 634cdf0e10cSrcweir ScUnoConversion::FillApiRange( aCellRange, aRange ); 635cdf0e10cSrcweir pCellRanges[ i ] = aCellRange; 636cdf0e10cSrcweir } 637cdf0e10cSrcweir rValue <<= aCellRanges; 638cdf0e10cSrcweir } 639cdf0e10cSrcweir } 640cdf0e10cSrcweir } 641cdf0e10cSrcweir } 642cdf0e10cSrcweir } 643cdf0e10cSrcweir break; 644cdf0e10cSrcweir default: 645cdf0e10cSrcweir { 646cdf0e10cSrcweir } 647cdf0e10cSrcweir break; 648cdf0e10cSrcweir } 649cdf0e10cSrcweir } 650cdf0e10cSrcweir 651cdf0e10cSrcweir // ::comphelper::OPropertyArrayUsageHelper 652cdf0e10cSrcweir 653cdf0e10cSrcweir ::cppu::IPropertyArrayHelper* ScChartObj::createArrayHelper() const 654cdf0e10cSrcweir { 655cdf0e10cSrcweir uno::Sequence< beans::Property > aProps; 656cdf0e10cSrcweir describeProperties( aProps ); 657cdf0e10cSrcweir return new ::cppu::OPropertyArrayHelper( aProps ); 658cdf0e10cSrcweir } 659cdf0e10cSrcweir 660cdf0e10cSrcweir // XInterface 661cdf0e10cSrcweir 662cdf0e10cSrcweir IMPLEMENT_FORWARD_XINTERFACE2( ScChartObj, ScChartObj_Base, ScChartObj_PBase ) 663cdf0e10cSrcweir 664cdf0e10cSrcweir // XTypeProvider 665cdf0e10cSrcweir 666cdf0e10cSrcweir IMPLEMENT_FORWARD_XTYPEPROVIDER2( ScChartObj, ScChartObj_Base, ScChartObj_PBase ) 667cdf0e10cSrcweir 668cdf0e10cSrcweir // XComponent 669cdf0e10cSrcweir 670cdf0e10cSrcweir void ScChartObj::disposing() 671cdf0e10cSrcweir { 672cdf0e10cSrcweir ScChartObj_Base::disposing(); 673cdf0e10cSrcweir } 674cdf0e10cSrcweir 675cdf0e10cSrcweir // XTableChart 676cdf0e10cSrcweir 677cdf0e10cSrcweir sal_Bool SAL_CALL ScChartObj::getHasColumnHeaders() throw(uno::RuntimeException) 678cdf0e10cSrcweir { 679cdf0e10cSrcweir ScUnoGuard aGuard; 680cdf0e10cSrcweir ScRangeListRef xRanges = new ScRangeList; 681cdf0e10cSrcweir bool bColHeaders, bRowHeaders; 682cdf0e10cSrcweir GetData_Impl( xRanges, bColHeaders, bRowHeaders ); 683cdf0e10cSrcweir return bColHeaders; 684cdf0e10cSrcweir } 685cdf0e10cSrcweir 686cdf0e10cSrcweir void SAL_CALL ScChartObj::setHasColumnHeaders( sal_Bool bHasColumnHeaders ) 687cdf0e10cSrcweir throw(uno::RuntimeException) 688cdf0e10cSrcweir { 689cdf0e10cSrcweir ScUnoGuard aGuard; 690cdf0e10cSrcweir ScRangeListRef xRanges = new ScRangeList; 691cdf0e10cSrcweir bool bOldColHeaders, bOldRowHeaders; 692cdf0e10cSrcweir GetData_Impl( xRanges, bOldColHeaders, bOldRowHeaders ); 693cdf0e10cSrcweir if ( bOldColHeaders != (bHasColumnHeaders != sal_False) ) 694cdf0e10cSrcweir Update_Impl( xRanges, bHasColumnHeaders, bOldRowHeaders ); 695cdf0e10cSrcweir } 696cdf0e10cSrcweir 697cdf0e10cSrcweir sal_Bool SAL_CALL ScChartObj::getHasRowHeaders() throw(uno::RuntimeException) 698cdf0e10cSrcweir { 699cdf0e10cSrcweir ScUnoGuard aGuard; 700cdf0e10cSrcweir ScRangeListRef xRanges = new ScRangeList; 701cdf0e10cSrcweir bool bColHeaders, bRowHeaders; 702cdf0e10cSrcweir GetData_Impl( xRanges, bColHeaders, bRowHeaders ); 703cdf0e10cSrcweir return bRowHeaders; 704cdf0e10cSrcweir } 705cdf0e10cSrcweir 706cdf0e10cSrcweir void SAL_CALL ScChartObj::setHasRowHeaders( sal_Bool bHasRowHeaders ) 707cdf0e10cSrcweir throw(uno::RuntimeException) 708cdf0e10cSrcweir { 709cdf0e10cSrcweir ScUnoGuard aGuard; 710cdf0e10cSrcweir ScRangeListRef xRanges = new ScRangeList; 711cdf0e10cSrcweir bool bOldColHeaders, bOldRowHeaders; 712cdf0e10cSrcweir GetData_Impl( xRanges, bOldColHeaders, bOldRowHeaders ); 713cdf0e10cSrcweir if ( bOldRowHeaders != (bHasRowHeaders != sal_False) ) 714cdf0e10cSrcweir Update_Impl( xRanges, bOldColHeaders, bHasRowHeaders ); 715cdf0e10cSrcweir } 716cdf0e10cSrcweir 717cdf0e10cSrcweir uno::Sequence<table::CellRangeAddress> SAL_CALL ScChartObj::getRanges() throw(uno::RuntimeException) 718cdf0e10cSrcweir { 719cdf0e10cSrcweir ScUnoGuard aGuard; 720cdf0e10cSrcweir ScRangeListRef xRanges = new ScRangeList; 721cdf0e10cSrcweir bool bColHeaders, bRowHeaders; 722cdf0e10cSrcweir GetData_Impl( xRanges, bColHeaders, bRowHeaders ); 723cdf0e10cSrcweir if ( xRanges.Is() ) 724cdf0e10cSrcweir { 725cdf0e10cSrcweir sal_uLong nCount = xRanges->Count(); 726cdf0e10cSrcweir 727cdf0e10cSrcweir table::CellRangeAddress aRangeAddress; 728cdf0e10cSrcweir uno::Sequence<table::CellRangeAddress> aSeq(nCount); 729cdf0e10cSrcweir table::CellRangeAddress* pAry = aSeq.getArray(); 730cdf0e10cSrcweir for (sal_uInt16 i=0; i<nCount; i++) 731cdf0e10cSrcweir { 732cdf0e10cSrcweir ScRange aRange(*xRanges->GetObject(i)); 733cdf0e10cSrcweir 734cdf0e10cSrcweir aRangeAddress.Sheet = aRange.aStart.Tab(); 735cdf0e10cSrcweir aRangeAddress.StartColumn = aRange.aStart.Col(); 736cdf0e10cSrcweir aRangeAddress.StartRow = aRange.aStart.Row(); 737cdf0e10cSrcweir aRangeAddress.EndColumn = aRange.aEnd.Col(); 738cdf0e10cSrcweir aRangeAddress.EndRow = aRange.aEnd.Row(); 739cdf0e10cSrcweir 740cdf0e10cSrcweir pAry[i] = aRangeAddress; 741cdf0e10cSrcweir } 742cdf0e10cSrcweir return aSeq; 743cdf0e10cSrcweir } 744cdf0e10cSrcweir 745cdf0e10cSrcweir DBG_ERROR("ScChartObj::getRanges: keine Ranges"); 746cdf0e10cSrcweir return uno::Sequence<table::CellRangeAddress>(); 747cdf0e10cSrcweir } 748cdf0e10cSrcweir 749cdf0e10cSrcweir void SAL_CALL ScChartObj::setRanges( const uno::Sequence<table::CellRangeAddress>& aRanges ) 750cdf0e10cSrcweir throw(uno::RuntimeException) 751cdf0e10cSrcweir { 752cdf0e10cSrcweir ScUnoGuard aGuard; 753cdf0e10cSrcweir ScRangeListRef xOldRanges = new ScRangeList; 754cdf0e10cSrcweir bool bColHeaders, bRowHeaders; 755cdf0e10cSrcweir GetData_Impl( xOldRanges, bColHeaders, bRowHeaders ); 756cdf0e10cSrcweir 757cdf0e10cSrcweir ScRangeList* pList = new ScRangeList; 758cdf0e10cSrcweir sal_uInt16 nRangeCount = (sal_uInt16)aRanges.getLength(); 759cdf0e10cSrcweir if (nRangeCount) 760cdf0e10cSrcweir { 761cdf0e10cSrcweir const table::CellRangeAddress* pAry = aRanges.getConstArray(); 762cdf0e10cSrcweir for (sal_uInt16 i=0; i<nRangeCount; i++) 763cdf0e10cSrcweir { 764cdf0e10cSrcweir ScRange aRange( static_cast<SCCOL>(pAry[i].StartColumn), pAry[i].StartRow, pAry[i].Sheet, 765cdf0e10cSrcweir static_cast<SCCOL>(pAry[i].EndColumn), pAry[i].EndRow, pAry[i].Sheet ); 766cdf0e10cSrcweir pList->Append( aRange ); 767cdf0e10cSrcweir } 768cdf0e10cSrcweir } 769cdf0e10cSrcweir ScRangeListRef xNewRanges( pList ); 770cdf0e10cSrcweir 771cdf0e10cSrcweir if ( !xOldRanges.Is() || *xOldRanges != *xNewRanges ) 772cdf0e10cSrcweir Update_Impl( xNewRanges, bColHeaders, bRowHeaders ); 773cdf0e10cSrcweir } 774cdf0e10cSrcweir 775cdf0e10cSrcweir // XEmbeddedObjectSupplier 776cdf0e10cSrcweir 777cdf0e10cSrcweir uno::Reference<lang::XComponent> SAL_CALL ScChartObj::getEmbeddedObject() throw(uno::RuntimeException) 778cdf0e10cSrcweir { 779cdf0e10cSrcweir ScUnoGuard aGuard; 780cdf0e10cSrcweir SdrOle2Obj* pObject = lcl_FindChartObj( pDocShell, nTab, aChartName ); 781cdf0e10cSrcweir if ( pObject && svt::EmbeddedObjectRef::TryRunningState( pObject->GetObjRef() ) ) 782cdf0e10cSrcweir { 783cdf0e10cSrcweir //TODO/LATER: is it OK that something is returned for *all* objects, not only own objects? 784cdf0e10cSrcweir return uno::Reference < lang::XComponent > ( pObject->GetObjRef()->getComponent(), uno::UNO_QUERY ); 785cdf0e10cSrcweir } 786cdf0e10cSrcweir 787cdf0e10cSrcweir return NULL; 788cdf0e10cSrcweir } 789cdf0e10cSrcweir 790cdf0e10cSrcweir // XNamed 791cdf0e10cSrcweir 792cdf0e10cSrcweir rtl::OUString SAL_CALL ScChartObj::getName() throw(uno::RuntimeException) 793cdf0e10cSrcweir { 794cdf0e10cSrcweir ScUnoGuard aGuard; 795cdf0e10cSrcweir return aChartName; 796cdf0e10cSrcweir } 797cdf0e10cSrcweir 798cdf0e10cSrcweir void SAL_CALL ScChartObj::setName( const rtl::OUString& /* aName */ ) throw(uno::RuntimeException) 799cdf0e10cSrcweir { 800cdf0e10cSrcweir ScUnoGuard aGuard; 801cdf0e10cSrcweir throw uno::RuntimeException(); // name cannot be changed 802cdf0e10cSrcweir } 803cdf0e10cSrcweir 804cdf0e10cSrcweir // XPropertySet 805cdf0e10cSrcweir 806cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > ScChartObj::getPropertySetInfo() throw (uno::RuntimeException) 807cdf0e10cSrcweir { 808cdf0e10cSrcweir return createPropertySetInfo( getInfoHelper() ) ; 809cdf0e10cSrcweir } 810cdf0e10cSrcweir 811cdf0e10cSrcweir //------------------------------------------------------------------------ 812cdf0e10cSrcweir 813cdf0e10cSrcweir 814cdf0e10cSrcweir 815