1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <com/sun/star/embed/Aspects.hpp>
21 #include <com/sun/star/awt/Size.hpp>
22 #include <com/sun/star/beans/PropertyAttribute.hpp>
23 #include <com/sun/star/chart2/data/XDataReceiver.hpp>
24 #include <com/sun/star/chart/ChartDataRowSource.hpp>
25 #include <com/sun/star/chart2/XChartDocument.hpp>
26 #include <com/sun/star/table/CellRangeAddress.hpp>
28 #include <svx/svditer.hxx>
29 #include <svx/svdoole2.hxx>
30 #include <svx/svdpage.hxx>
31 #include <svx/svdundo.hxx>
32 #include <sfx2/app.hxx>
33 #include <unotools/moduleoptions.hxx>
34 #include <comphelper/classids.hxx>
35 #include <toolkit/helper/vclunohelper.hxx>
36 #include <svx/charthelper.hxx>
37 #include <svtools/embedhlp.hxx>
39 #include "chartuno.hxx"
40 #include "miscuno.hxx"
42 #include "drwlayer.hxx"
43 #include "undodat.hxx"
44 #include "chartarr.hxx"
45 #include "chartlis.hxx"
46 #include "chart2uno.hxx"
47 #include "convuno.hxx"
49 using namespace com::sun::star
;
51 #define PROP_HANDLE_RELATED_CELLRANGES 1
53 SC_SIMPLE_SERVICE_INFO( ScChartObj
, "ScChartObj", "com.sun.star.table.TableChart" )
54 SC_SIMPLE_SERVICE_INFO( ScChartsObj
, "ScChartsObj", "com.sun.star.table.TableCharts" )
56 static SdrOle2Obj
* lcl_FindChartObj( ScDocShell
* pDocShell
, SCTAB nTab
, const OUString
& rName
)
60 ScDocument
& rDoc
= pDocShell
->GetDocument();
61 ScDrawLayer
* pDrawLayer
= rDoc
.GetDrawLayer();
64 SdrPage
* pPage
= pDrawLayer
->GetPage(static_cast<sal_uInt16
>(nTab
));
65 OSL_ENSURE(pPage
, "Page nicht gefunden");
68 SdrObjListIter
aIter( *pPage
, IM_DEEPNOGROUPS
);
69 SdrObject
* pObject
= aIter
.Next();
72 if ( pObject
->GetObjIdentifier() == OBJ_OLE2
&& ScDocument::IsChart(pObject
) )
74 uno::Reference
< embed::XEmbeddedObject
> xObj
= static_cast<SdrOle2Obj
*>(pObject
)->GetObjRef();
77 OUString aObjName
= pDocShell
->GetEmbeddedObjectContainer().GetEmbeddedObjectName( xObj
);
78 if ( aObjName
== rName
)
79 return static_cast<SdrOle2Obj
*>(pObject
);
82 pObject
= aIter
.Next();
90 ScChartsObj::ScChartsObj(ScDocShell
* pDocSh
, SCTAB nT
) :
94 pDocShell
->GetDocument().AddUnoObject(*this);
97 ScChartsObj::~ScChartsObj()
102 pDocShell
->GetDocument().RemoveUnoObject(*this);
105 void ScChartsObj::Notify( SfxBroadcaster
&, const SfxHint
& rHint
)
109 const SfxSimpleHint
* pSimpleHint
= dynamic_cast<const SfxSimpleHint
*>(&rHint
);
110 if ( pSimpleHint
&& pSimpleHint
->GetId() == SFX_HINT_DYING
)
112 pDocShell
= NULL
; // ungueltig geworden
116 ScChartObj
* ScChartsObj::GetObjectByIndex_Impl(long nIndex
) const
121 ScDocument
& rDoc
= pDocShell
->GetDocument();
122 ScDrawLayer
* pDrawLayer
= rDoc
.GetDrawLayer();
125 SdrPage
* pPage
= pDrawLayer
->GetPage(static_cast<sal_uInt16
>(nTab
));
126 OSL_ENSURE(pPage
, "Page nicht gefunden");
130 SdrObjListIter
aIter( *pPage
, IM_DEEPNOGROUPS
);
131 SdrObject
* pObject
= aIter
.Next();
134 if ( pObject
->GetObjIdentifier() == OBJ_OLE2
&& ScDocument::IsChart(pObject
) )
136 if ( nPos
== nIndex
)
138 uno::Reference
< embed::XEmbeddedObject
> xObj
= static_cast<SdrOle2Obj
*>(pObject
)->GetObjRef();
140 aName
= pDocShell
->GetEmbeddedObjectContainer().GetEmbeddedObjectName( xObj
);
141 break; // nicht weitersuchen
145 pObject
= aIter
.Next();
151 if (!aName
.isEmpty())
152 return new ScChartObj( pDocShell
, nTab
, aName
);
156 ScChartObj
* ScChartsObj::GetObjectByName_Impl(const OUString
& aName
) const
158 if ( lcl_FindChartObj( pDocShell
, nTab
, aName
) )
159 return new ScChartObj( pDocShell
, nTab
, aName
);
165 void SAL_CALL
ScChartsObj::addNewByName( const OUString
& rName
,
166 const awt::Rectangle
& aRect
,
167 const uno::Sequence
<table::CellRangeAddress
>& aRanges
,
168 sal_Bool bColumnHeaders
, sal_Bool bRowHeaders
)
169 throw(::com::sun::star::uno::RuntimeException
,
172 SolarMutexGuard aGuard
;
176 ScDocument
& rDoc
= pDocShell
->GetDocument();
177 ScDrawLayer
* pModel
= pDocShell
->MakeDrawLayer();
178 SdrPage
* pPage
= pModel
->GetPage(static_cast<sal_uInt16
>(nTab
));
179 OSL_ENSURE(pPage
,"addChart: keine Page");
183 // chart can't be inserted if any ole object with that name exists on any table
184 // (empty string: generate valid name)
186 OUString aName
= rName
;
188 if ( !aName
.isEmpty() && pModel
->GetNamedObject( aName
, OBJ_OLE2
, nDummy
) )
190 // object exists - only RuntimeException is specified
191 throw uno::RuntimeException();
194 ScRangeList
* pList
= new ScRangeList
;
195 sal_Int32 nRangeCount
= aRanges
.getLength();
198 const table::CellRangeAddress
* pAry
= aRanges
.getConstArray();
199 for (sal_Int32 i
=0; i
<nRangeCount
; i
++)
201 ScRange
aRange( static_cast<SCCOL
>(pAry
[i
].StartColumn
), pAry
[i
].StartRow
, pAry
[i
].Sheet
,
202 static_cast<SCCOL
>(pAry
[i
].EndColumn
), pAry
[i
].EndRow
, pAry
[i
].Sheet
);
203 pList
->Append( aRange
);
206 ScRangeListRef
xNewRanges( pList
);
208 uno::Reference
< embed::XEmbeddedObject
> xObj
;
209 if ( SvtModuleOptions().IsChart() )
210 xObj
= pDocShell
->GetEmbeddedObjectContainer().CreateEmbeddedObject( SvGlobalName( SO3_SCH_CLASSID
).GetByteSequence(), aName
);
214 //! Fehler/Exception, wenn leer/ungueltig ???
215 Point
aRectPos( aRect
.X
, aRect
.Y
);
216 bool bLayoutRTL
= rDoc
.IsLayoutRTL( nTab
);
217 if ( ( aRectPos
.X() < 0 && !bLayoutRTL
) || ( aRectPos
.X() > 0 && bLayoutRTL
) )
220 if (aRectPos
.Y() < 0)
223 Size
aRectSize( aRect
.Width
, aRect
.Height
);
224 if (aRectSize
.Width() <= 0)
225 aRectSize
.Width() = 5000; // Default-Groesse
227 if (aRectSize
.Height() <= 0)
228 aRectSize
.Height() = 5000;
229 Rectangle
aInsRect( aRectPos
, aRectSize
);
231 sal_Int64
nAspect(embed::Aspects::MSOLE_CONTENT
);
232 MapUnit
aMapUnit(VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj
->getMapUnit( nAspect
) ));
233 Size
aSize(aInsRect
.GetSize());
234 aSize
= vcl::Window::LogicToLogic( aSize
, MapMode( MAP_100TH_MM
), MapMode( aMapUnit
) );
236 aSz
.Width
= aSize
.Width();
237 aSz
.Height
= aSize
.Height();
239 // Calc -> DataProvider
240 uno::Reference
< chart2::data::XDataProvider
> xDataProvider
= new
241 ScChart2DataProvider( &rDoc
);
242 // Chart -> DataReceiver
243 uno::Reference
< chart2::data::XDataReceiver
> xReceiver
;
244 uno::Reference
< embed::XComponentSupplier
> xCompSupp( xObj
, uno::UNO_QUERY
);
246 xReceiver
.set( xCompSupp
->getComponent(), uno::UNO_QUERY
);
250 xNewRanges
->Format(sRangeStr
, SCR_ABS_3D
, &rDoc
);
253 if( !sRangeStr
.isEmpty() )
254 xReceiver
->attachDataProvider( xDataProvider
);
258 uno::Reference
< util::XNumberFormatsSupplier
> xNumberFormatsSupplier( pDocShell
->GetModel(), uno::UNO_QUERY
);
259 xReceiver
->attachNumberFormatsSupplier( xNumberFormatsSupplier
);
262 uno::Sequence
< beans::PropertyValue
> aArgs( 4 );
263 aArgs
[0] = beans::PropertyValue(
264 OUString("CellRangeRepresentation"), -1,
265 uno::makeAny( OUString( sRangeStr
)), beans::PropertyState_DIRECT_VALUE
);
266 aArgs
[1] = beans::PropertyValue(
267 OUString("HasCategories"), -1,
268 uno::makeAny( bRowHeaders
), beans::PropertyState_DIRECT_VALUE
);
269 aArgs
[2] = beans::PropertyValue(
270 OUString("FirstCellAsLabel"), -1,
271 uno::makeAny( bColumnHeaders
), beans::PropertyState_DIRECT_VALUE
);
272 aArgs
[3] = beans::PropertyValue(
273 OUString("DataRowSource"), -1,
274 uno::makeAny( chart::ChartDataRowSource_COLUMNS
), beans::PropertyState_DIRECT_VALUE
);
275 xReceiver
->setArguments( aArgs
);
278 ScChartListener
* pChartListener
=
279 new ScChartListener( aName
, &rDoc
, xNewRanges
);
280 rDoc
.GetChartListenerCollection()->insert( pChartListener
);
281 pChartListener
->StartListeningTo();
283 SdrOle2Obj
* pObj
= new SdrOle2Obj( ::svt::EmbeddedObjectRef( xObj
, embed::Aspects::MSOLE_CONTENT
), aName
, aInsRect
);
287 xObj
->setVisualAreaSize( nAspect
, aSz
);
289 // #i121334# This call will change the chart's default background fill from white to transparent.
290 // Add here again if this is wanted (see task description for details)
291 // ChartHelper::AdaptDefaultsForChart( xObj );
293 pPage
->InsertObject( pObj
);
294 pModel
->AddUndo( new SdrUndoInsertObj( *pObj
) );
298 void SAL_CALL
ScChartsObj::removeByName( const OUString
& aName
)
299 throw(uno::RuntimeException
, std::exception
)
301 SolarMutexGuard aGuard
;
302 SdrOle2Obj
* pObj
= lcl_FindChartObj( pDocShell
, nTab
, aName
);
305 ScDocument
& rDoc
= pDocShell
->GetDocument();
306 rDoc
.GetChartListenerCollection()->removeByName(aName
);
307 ScDrawLayer
* pModel
= rDoc
.GetDrawLayer(); // ist nicht 0
308 SdrPage
* pPage
= pModel
->GetPage(static_cast<sal_uInt16
>(nTab
)); // ist nicht 0
310 pModel
->AddUndo( new SdrUndoDelObj( *pObj
) );
311 pPage
->RemoveObject( pObj
->GetOrdNum() );
317 // XEnumerationAccess
319 uno::Reference
<container::XEnumeration
> SAL_CALL
ScChartsObj::createEnumeration()
320 throw(uno::RuntimeException
, std::exception
)
322 SolarMutexGuard aGuard
;
323 return new ScIndexEnumeration(this, OUString("com.sun.star.table.TableChartsEnumeration"));
328 sal_Int32 SAL_CALL
ScChartsObj::getCount() throw(uno::RuntimeException
, std::exception
)
330 SolarMutexGuard aGuard
;
331 sal_Int32 nCount
= 0;
334 ScDocument
& rDoc
= pDocShell
->GetDocument();
335 ScDrawLayer
* pDrawLayer
= rDoc
.GetDrawLayer();
338 SdrPage
* pPage
= pDrawLayer
->GetPage(static_cast<sal_uInt16
>(nTab
));
339 OSL_ENSURE(pPage
, "Page nicht gefunden");
342 SdrObjListIter
aIter( *pPage
, IM_DEEPNOGROUPS
);
343 SdrObject
* pObject
= aIter
.Next();
346 if ( pObject
->GetObjIdentifier() == OBJ_OLE2
&& ScDocument::IsChart(pObject
) )
348 pObject
= aIter
.Next();
356 uno::Any SAL_CALL
ScChartsObj::getByIndex( sal_Int32 nIndex
)
357 throw(lang::IndexOutOfBoundsException
,
358 lang::WrappedTargetException
, uno::RuntimeException
, std::exception
)
360 SolarMutexGuard aGuard
;
361 uno::Reference
<table::XTableChart
> xChart(GetObjectByIndex_Impl(nIndex
));
363 return uno::makeAny(xChart
);
365 throw lang::IndexOutOfBoundsException();
368 uno::Type SAL_CALL
ScChartsObj::getElementType() throw(uno::RuntimeException
, std::exception
)
370 SolarMutexGuard aGuard
;
371 return cppu::UnoType
<table::XTableChart
>::get();
374 sal_Bool SAL_CALL
ScChartsObj::hasElements() throw(uno::RuntimeException
, std::exception
)
376 SolarMutexGuard aGuard
;
377 return getCount() != 0;
380 uno::Any SAL_CALL
ScChartsObj::getByName( const OUString
& aName
)
381 throw(container::NoSuchElementException
,
382 lang::WrappedTargetException
, uno::RuntimeException
, std::exception
)
384 SolarMutexGuard aGuard
;
385 uno::Reference
<table::XTableChart
> xChart(GetObjectByName_Impl(aName
));
387 return uno::makeAny(xChart
);
389 throw container::NoSuchElementException();
392 uno::Sequence
<OUString
> SAL_CALL
ScChartsObj::getElementNames() throw(uno::RuntimeException
, std::exception
)
394 SolarMutexGuard aGuard
;
397 ScDocument
& rDoc
= pDocShell
->GetDocument();
399 long nCount
= getCount();
400 uno::Sequence
<OUString
> aSeq(nCount
);
401 OUString
* pAry
= aSeq
.getArray();
404 ScDrawLayer
* pDrawLayer
= rDoc
.GetDrawLayer();
407 SdrPage
* pPage
= pDrawLayer
->GetPage(static_cast<sal_uInt16
>(nTab
));
408 OSL_ENSURE(pPage
, "Page nicht gefunden");
411 SdrObjListIter
aIter( *pPage
, IM_DEEPNOGROUPS
);
412 SdrObject
* pObject
= aIter
.Next();
415 if ( pObject
->GetObjIdentifier() == OBJ_OLE2
&& ScDocument::IsChart(pObject
) )
418 uno::Reference
< embed::XEmbeddedObject
> xObj
= static_cast<SdrOle2Obj
*>(pObject
)->GetObjRef();
420 aName
= pDocShell
->GetEmbeddedObjectContainer().GetEmbeddedObjectName( xObj
);
422 OSL_ENSURE(nPos
<nCount
, "huch, verzaehlt?");
423 pAry
[nPos
++] = aName
;
425 pObject
= aIter
.Next();
429 OSL_ENSURE(nPos
==nCount
, "nanu, verzaehlt?");
433 return uno::Sequence
<OUString
>(0);
436 sal_Bool SAL_CALL
ScChartsObj::hasByName( const OUString
& aName
)
437 throw(uno::RuntimeException
, std::exception
)
439 SolarMutexGuard aGuard
;
440 return ( lcl_FindChartObj( pDocShell
, nTab
, aName
) != NULL
);
443 ScChartObj::ScChartObj(ScDocShell
* pDocSh
, SCTAB nT
, const OUString
& rN
)
444 :ScChartObj_Base( m_aMutex
)
445 ,ScChartObj_PBase( ScChartObj_Base::rBHelper
)
450 pDocShell
->GetDocument().AddUnoObject(*this);
452 uno::Sequence
< table::CellRangeAddress
> aInitialPropValue
;
453 registerPropertyNoMember( OUString( "RelatedCellRanges" ),
454 PROP_HANDLE_RELATED_CELLRANGES
, beans::PropertyAttribute::MAYBEVOID
,
455 cppu::UnoType
<decltype(aInitialPropValue
)>::get(), &aInitialPropValue
);
458 ScChartObj::~ScChartObj()
463 pDocShell
->GetDocument().RemoveUnoObject(*this);
466 void ScChartObj::Notify( SfxBroadcaster
&, const SfxHint
& rHint
)
470 const SfxSimpleHint
* pSimpleHint
= dynamic_cast<const SfxSimpleHint
*>(&rHint
);
471 if ( pSimpleHint
&& pSimpleHint
->GetId() == SFX_HINT_DYING
)
473 pDocShell
= NULL
; // ungueltig geworden
477 void ScChartObj::GetData_Impl( ScRangeListRef
& rRanges
, bool& rColHeaders
, bool& rRowHeaders
) const
483 ScDocument
& rDoc
= pDocShell
->GetDocument();
484 uno::Reference
< chart2::XChartDocument
> xChartDoc( rDoc
.GetChartByName( aChartName
) );
487 uno::Reference
< chart2::data::XDataReceiver
> xReceiver( xChartDoc
, uno::UNO_QUERY
);
488 uno::Reference
< chart2::data::XDataProvider
> xProvider
= xChartDoc
->getDataProvider();
489 if( xReceiver
.is() && xProvider
.is() )
491 uno::Sequence
< beans::PropertyValue
> aArgs( xProvider
->detectArguments( xReceiver
->getUsedData() ) );
494 chart::ChartDataRowSource eDataRowSource
= chart::ChartDataRowSource_COLUMNS
;
495 bool bHasCategories
=false;
496 bool bFirstCellAsLabel
=false;
497 const beans::PropertyValue
* pPropArray
= aArgs
.getConstArray();
498 long nPropCount
= aArgs
.getLength();
499 for (long i
= 0; i
< nPropCount
; i
++)
501 const beans::PropertyValue
& rProp
= pPropArray
[i
];
502 OUString
aPropName(rProp
.Name
);
504 if (aPropName
== "CellRangeRepresentation")
505 rProp
.Value
>>= aRanges
;
506 else if (aPropName
== "DataRowSource")
507 eDataRowSource
= (chart::ChartDataRowSource
)ScUnoHelpFunctions::GetEnumFromAny( rProp
.Value
);
508 else if (aPropName
== "HasCategories")
509 bHasCategories
= ScUnoHelpFunctions::GetBoolFromAny( rProp
.Value
);
510 else if (aPropName
== "FirstCellAsLabel")
511 bFirstCellAsLabel
= ScUnoHelpFunctions::GetBoolFromAny( rProp
.Value
);
514 if( chart::ChartDataRowSource_COLUMNS
== eDataRowSource
)
516 rColHeaders
=bFirstCellAsLabel
;
517 rRowHeaders
=bHasCategories
;
521 rColHeaders
=bHasCategories
;
522 rRowHeaders
=bFirstCellAsLabel
;
524 rRanges
->Parse( aRanges
, &rDoc
);
537 void ScChartObj::Update_Impl( const ScRangeListRef
& rRanges
, bool bColHeaders
, bool bRowHeaders
)
541 ScDocument
& rDoc
= pDocShell
->GetDocument();
542 bool bUndo(rDoc
.IsUndoEnabled());
546 pDocShell
->GetUndoManager()->AddUndoAction(
547 new ScUndoChartData( pDocShell
, aChartName
, rRanges
, bColHeaders
, bRowHeaders
, false ) );
549 rDoc
.UpdateChartArea( aChartName
, rRanges
, bColHeaders
, bRowHeaders
, false );
553 // ::comphelper::OPropertySetHelper
555 ::cppu::IPropertyArrayHelper
& ScChartObj::getInfoHelper()
557 return *ScChartObj_PABase::getArrayHelper();
560 void ScChartObj::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle
, const uno::Any
& rValue
)
561 throw (uno::Exception
, std::exception
)
565 case PROP_HANDLE_RELATED_CELLRANGES
:
567 uno::Sequence
< table::CellRangeAddress
> aCellRanges
;
568 if ( rValue
>>= aCellRanges
)
570 ScRangeListRef rRangeList
= new ScRangeList();
571 const table::CellRangeAddress
* pCellRanges
= aCellRanges
.getArray();
572 sal_Int32 nCount
= aCellRanges
.getLength();
573 for ( sal_Int32 i
= 0; i
< nCount
; ++i
)
575 table::CellRangeAddress aCellRange
= pCellRanges
[ i
];
577 ScUnoConversion::FillScRange( aRange
, aCellRange
);
578 rRangeList
->Append( aRange
);
582 ScChartListenerCollection
* pCollection
= pDocShell
->GetDocument().GetChartListenerCollection();
585 pCollection
->ChangeListening( aChartName
, rRangeList
);
596 void ScChartObj::getFastPropertyValue( uno::Any
& rValue
, sal_Int32 nHandle
) const
600 case PROP_HANDLE_RELATED_CELLRANGES
:
604 ScDocument
& rDoc
= pDocShell
->GetDocument();
606 ScChartListenerCollection
* pCollection
= rDoc
.GetChartListenerCollection();
610 ScChartListener
* pListener
= pCollection
->findByName(aChartName
);
614 const ScRangeListRef
& rRangeList
= pListener
->GetRangeList();
615 if (!rRangeList
.Is())
618 size_t nCount
= rRangeList
->size();
619 uno::Sequence
<table::CellRangeAddress
> aCellRanges(nCount
);
620 table::CellRangeAddress
* pCellRanges
= aCellRanges
.getArray();
621 for (size_t i
= 0; i
< nCount
; ++i
)
623 ScRange
aRange(*(*rRangeList
)[i
]);
624 table::CellRangeAddress aCellRange
;
625 ScUnoConversion::FillApiRange(aCellRange
, aRange
);
626 pCellRanges
[i
] = aCellRange
;
628 rValue
<<= aCellRanges
;
636 // ::comphelper::OPropertyArrayUsageHelper
638 ::cppu::IPropertyArrayHelper
* ScChartObj::createArrayHelper() const
640 uno::Sequence
< beans::Property
> aProps
;
641 describeProperties( aProps
);
642 return new ::cppu::OPropertyArrayHelper( aProps
);
647 IMPLEMENT_FORWARD_XINTERFACE2( ScChartObj
, ScChartObj_Base
, ScChartObj_PBase
)
651 IMPLEMENT_FORWARD_XTYPEPROVIDER2( ScChartObj
, ScChartObj_Base
, ScChartObj_PBase
)
655 void ScChartObj::disposing()
657 ScChartObj_Base::disposing();
662 sal_Bool SAL_CALL
ScChartObj::getHasColumnHeaders() throw(uno::RuntimeException
, std::exception
)
664 SolarMutexGuard aGuard
;
665 ScRangeListRef xRanges
= new ScRangeList
;
666 bool bColHeaders
, bRowHeaders
;
667 GetData_Impl( xRanges
, bColHeaders
, bRowHeaders
);
671 void SAL_CALL
ScChartObj::setHasColumnHeaders( sal_Bool bHasColumnHeaders
)
672 throw(uno::RuntimeException
,
675 SolarMutexGuard aGuard
;
676 ScRangeListRef xRanges
= new ScRangeList
;
677 bool bOldColHeaders
, bOldRowHeaders
;
678 GetData_Impl( xRanges
, bOldColHeaders
, bOldRowHeaders
);
679 if ( bOldColHeaders
!= bool(bHasColumnHeaders
) )
680 Update_Impl( xRanges
, bHasColumnHeaders
, bOldRowHeaders
);
683 sal_Bool SAL_CALL
ScChartObj::getHasRowHeaders() throw(uno::RuntimeException
, std::exception
)
685 SolarMutexGuard aGuard
;
686 ScRangeListRef xRanges
= new ScRangeList
;
687 bool bColHeaders
, bRowHeaders
;
688 GetData_Impl( xRanges
, bColHeaders
, bRowHeaders
);
692 void SAL_CALL
ScChartObj::setHasRowHeaders( sal_Bool bHasRowHeaders
)
693 throw(uno::RuntimeException
, std::exception
)
695 SolarMutexGuard aGuard
;
696 ScRangeListRef xRanges
= new ScRangeList
;
697 bool bOldColHeaders
, bOldRowHeaders
;
698 GetData_Impl( xRanges
, bOldColHeaders
, bOldRowHeaders
);
699 if ( bOldRowHeaders
!= bool(bHasRowHeaders
) )
700 Update_Impl( xRanges
, bOldColHeaders
, bHasRowHeaders
);
703 uno::Sequence
<table::CellRangeAddress
> SAL_CALL
ScChartObj::getRanges() throw(uno::RuntimeException
, std::exception
)
705 SolarMutexGuard aGuard
;
706 ScRangeListRef xRanges
= new ScRangeList
;
707 bool bColHeaders
, bRowHeaders
;
708 GetData_Impl( xRanges
, bColHeaders
, bRowHeaders
);
711 size_t nCount
= xRanges
->size();
713 table::CellRangeAddress aRangeAddress
;
714 uno::Sequence
<table::CellRangeAddress
> aSeq(nCount
);
715 table::CellRangeAddress
* pAry
= aSeq
.getArray();
716 for (size_t i
= 0; i
< nCount
; i
++)
718 ScRange
aRange( *(*xRanges
)[i
] );
720 aRangeAddress
.Sheet
= aRange
.aStart
.Tab();
721 aRangeAddress
.StartColumn
= aRange
.aStart
.Col();
722 aRangeAddress
.StartRow
= aRange
.aStart
.Row();
723 aRangeAddress
.EndColumn
= aRange
.aEnd
.Col();
724 aRangeAddress
.EndRow
= aRange
.aEnd
.Row();
726 pAry
[i
] = aRangeAddress
;
731 OSL_FAIL("ScChartObj::getRanges: keine Ranges");
732 return uno::Sequence
<table::CellRangeAddress
>();
735 void SAL_CALL
ScChartObj::setRanges( const uno::Sequence
<table::CellRangeAddress
>& aRanges
)
736 throw(uno::RuntimeException
, std::exception
)
738 SolarMutexGuard aGuard
;
739 ScRangeListRef xOldRanges
= new ScRangeList
;
740 bool bColHeaders
, bRowHeaders
;
741 GetData_Impl( xOldRanges
, bColHeaders
, bRowHeaders
);
743 ScRangeList
* pList
= new ScRangeList
;
744 sal_uInt16 nRangeCount
= (sal_uInt16
)aRanges
.getLength();
747 const table::CellRangeAddress
* pAry
= aRanges
.getConstArray();
748 for (sal_uInt16 i
=0; i
<nRangeCount
; i
++)
750 ScRange
aRange( static_cast<SCCOL
>(pAry
[i
].StartColumn
), pAry
[i
].StartRow
, pAry
[i
].Sheet
,
751 static_cast<SCCOL
>(pAry
[i
].EndColumn
), pAry
[i
].EndRow
, pAry
[i
].Sheet
);
752 pList
->Append( aRange
);
755 ScRangeListRef
xNewRanges( pList
);
757 if ( !xOldRanges
.Is() || *xOldRanges
!= *xNewRanges
)
758 Update_Impl( xNewRanges
, bColHeaders
, bRowHeaders
);
761 // XEmbeddedObjectSupplier
763 uno::Reference
<lang::XComponent
> SAL_CALL
ScChartObj::getEmbeddedObject() throw(uno::RuntimeException
, std::exception
)
765 SolarMutexGuard aGuard
;
766 SdrOle2Obj
* pObject
= lcl_FindChartObj( pDocShell
, nTab
, aChartName
);
767 if ( pObject
&& svt::EmbeddedObjectRef::TryRunningState( pObject
->GetObjRef() ) )
769 //TODO/LATER: is it OK that something is returned for *all* objects, not only own objects?
770 return uno::Reference
< lang::XComponent
> ( pObject
->GetObjRef()->getComponent(), uno::UNO_QUERY
);
778 OUString SAL_CALL
ScChartObj::getName() throw(uno::RuntimeException
, std::exception
)
780 SolarMutexGuard aGuard
;
784 void SAL_CALL
ScChartObj::setName( const OUString
& /* aName */ ) throw(uno::RuntimeException
, std::exception
)
786 SolarMutexGuard aGuard
;
787 throw uno::RuntimeException(); // name cannot be changed
792 uno::Reference
< beans::XPropertySetInfo
> ScChartObj::getPropertySetInfo() throw (uno::RuntimeException
, std::exception
)
794 return createPropertySetInfo( getInfoHelper() ) ;
797 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */