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