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/embed/XEmbeddedObject.hpp>
22 #include <com/sun/star/awt/Size.hpp>
23 #include <com/sun/star/beans/PropertyAttribute.hpp>
24 #include <com/sun/star/chart2/data/XDataReceiver.hpp>
25 #include <com/sun/star/chart/ChartDataRowSource.hpp>
26 #include <com/sun/star/chart2/XChartDocument.hpp>
27 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
28 #include <com/sun/star/table/CellRangeAddress.hpp>
30 #include <osl/diagnose.h>
31 #include <svx/svditer.hxx>
32 #include <svx/svdoole2.hxx>
33 #include <svx/svdpage.hxx>
34 #include <svx/svdundo.hxx>
35 #include <unotools/moduleoptions.hxx>
36 #include <comphelper/classids.hxx>
37 #include <toolkit/helper/vclunohelper.hxx>
38 #include <tools/globname.hxx>
39 #include <svtools/embedhlp.hxx>
41 #include <vcl/svapp.hxx>
43 #include <ChartTools.hxx>
44 #include <chartuno.hxx>
45 #include <miscuno.hxx>
47 #include <drwlayer.hxx>
48 #include <undodat.hxx>
49 #include <chartlis.hxx>
50 #include <chart2uno.hxx>
51 #include <convuno.hxx>
55 #define PROP_HANDLE_RELATED_CELLRANGES 1
57 SC_SIMPLE_SERVICE_INFO( ScChartObj
, u
"ScChartObj"_ustr
, u
"com.sun.star.table.TableChart"_ustr
)
58 SC_SIMPLE_SERVICE_INFO( ScChartsObj
, u
"ScChartsObj"_ustr
, u
"com.sun.star.table.TableCharts"_ustr
)
60 ScChartsObj::ScChartsObj(ScDocShell
* pDocSh
, SCTAB nT
) :
64 pDocShell
->GetDocument().AddUnoObject(*this);
67 ScChartsObj::~ScChartsObj()
72 pDocShell
->GetDocument().RemoveUnoObject(*this);
75 void ScChartsObj::Notify( SfxBroadcaster
&, const SfxHint
& rHint
)
79 if ( rHint
.GetId() == SfxHintId::Dying
)
85 rtl::Reference
<ScChartObj
> ScChartsObj::GetObjectByIndex_Impl(tools::Long nIndex
) const
91 ScDocument
& rDoc
= pDocShell
->GetDocument();
92 ScDrawLayer
* pDrawLayer
= rDoc
.GetDrawLayer();
95 SdrPage
* pPage
= pDrawLayer
->GetPage(static_cast<sal_uInt16
>(nTab
));
96 OSL_ENSURE(pPage
, "Page not found");
100 SdrObjListIter
aIter( pPage
, SdrIterMode::DeepNoGroups
);
101 SdrObject
* pObject
= aIter
.Next();
104 if ( pObject
->GetObjIdentifier() == SdrObjKind::OLE2
&& ScDocument::IsChart(pObject
) )
106 if ( nPos
== nIndex
)
108 uno::Reference
< embed::XEmbeddedObject
> xObj
= static_cast<SdrOle2Obj
*>(pObject
)->GetObjRef();
110 aName
= pDocShell
->GetEmbeddedObjectContainer().GetEmbeddedObjectName( xObj
);
111 break; // stop searching
115 pObject
= aIter
.Next();
120 if (!aName
.isEmpty())
121 return new ScChartObj( pDocShell
, nTab
, aName
);
127 rtl::Reference
<ScChartObj
> ScChartsObj::GetObjectByName_Impl(const OUString
& aName
) const
129 if (sc::tools::findChartsByName(pDocShell
, nTab
, aName
, sc::tools::ChartSourceType::CELL_RANGE
))
130 return new ScChartObj( pDocShell
, nTab
, aName
);
131 if (sc::tools::findChartsByName(pDocShell
, nTab
, aName
, sc::tools::ChartSourceType::PIVOT_TABLE
))
132 return new ScChartObj( pDocShell
, nTab
, aName
);
138 void SAL_CALL
ScChartsObj::addNewByName( const OUString
& rName
,
139 const awt::Rectangle
& aRect
,
140 const uno::Sequence
<table::CellRangeAddress
>& aRanges
,
141 sal_Bool bColumnHeaders
, sal_Bool bRowHeaders
)
143 SolarMutexGuard aGuard
;
147 ScDocument
& rDoc
= pDocShell
->GetDocument();
148 ScDrawLayer
* pModel
= pDocShell
->MakeDrawLayer();
149 SdrPage
* pPage
= pModel
->GetPage(static_cast<sal_uInt16
>(nTab
));
150 OSL_ENSURE(pPage
,"addChart: no Page");
154 // chart can't be inserted if any ole object with that name exists on any table
155 // (empty string: generate valid name)
157 OUString aName
= rName
;
159 if ( !aName
.isEmpty() && pModel
->GetNamedObject( aName
, SdrObjKind::OLE2
, nDummy
) )
161 // object exists - only RuntimeException is specified
162 throw uno::RuntimeException();
165 ScRangeList
* pList
= new ScRangeList
;
166 for (const table::CellRangeAddress
& rRange
: aRanges
)
168 ScRange
aRange( static_cast<SCCOL
>(rRange
.StartColumn
), rRange
.StartRow
, rRange
.Sheet
,
169 static_cast<SCCOL
>(rRange
.EndColumn
), rRange
.EndRow
, rRange
.Sheet
);
170 pList
->push_back( aRange
);
172 ScRangeListRef
xNewRanges( pList
);
174 uno::Reference
< embed::XEmbeddedObject
> xObj
;
175 if ( SvtModuleOptions().IsChartInstalled() )
176 xObj
= pDocShell
->GetEmbeddedObjectContainer().CreateEmbeddedObject( SvGlobalName( SO3_SCH_CLASSID
).GetByteSequence(), aName
);
181 //! error/exception, if empty/invalid ???
182 Point
aRectPos( aRect
.X
, aRect
.Y
);
183 bool bLayoutRTL
= rDoc
.IsLayoutRTL( nTab
);
184 if ( ( aRectPos
.X() < 0 && !bLayoutRTL
) || ( aRectPos
.X() > 0 && bLayoutRTL
) )
187 if (aRectPos
.Y() < 0)
190 Size
aRectSize( aRect
.Width
, aRect
.Height
);
191 if (aRectSize
.Width() <= 0)
192 aRectSize
.setWidth( 5000 ); // default size
194 if (aRectSize
.Height() <= 0)
195 aRectSize
.setHeight( 5000 );
196 tools::Rectangle
aInsRect( aRectPos
, aRectSize
);
198 sal_Int64
nAspect(embed::Aspects::MSOLE_CONTENT
);
199 MapUnit
aMapUnit(VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj
->getMapUnit( nAspect
) ));
200 Size
aSize(aInsRect
.GetSize());
201 aSize
= OutputDevice::LogicToLogic( aSize
, MapMode( MapUnit::Map100thMM
), MapMode( aMapUnit
) );
203 aSz
.Width
= aSize
.Width();
204 aSz
.Height
= aSize
.Height();
206 // Calc -> DataProvider
207 uno::Reference
< chart2::data::XDataProvider
> xDataProvider
= new
208 ScChart2DataProvider( &rDoc
);
209 // Chart -> DataReceiver
210 uno::Reference
< chart2::data::XDataReceiver
> xReceiver
;
212 xReceiver
.set( xObj
->getComponent(), uno::UNO_QUERY
);
215 // Range in UI representation.
217 xNewRanges
->Format(sRangeStr
, ScRefFlags::RANGE_ABS_3D
, rDoc
, rDoc
.GetAddressConvention());
220 if( !sRangeStr
.isEmpty() )
221 xReceiver
->attachDataProvider( xDataProvider
);
225 uno::Reference
< util::XNumberFormatsSupplier
> xNumberFormatsSupplier( cppu::getXWeak(pDocShell
->GetModel()), uno::UNO_QUERY
);
226 xReceiver
->attachNumberFormatsSupplier( xNumberFormatsSupplier
);
229 uno::Sequence
< beans::PropertyValue
> aArgs
{
230 beans::PropertyValue(
231 u
"CellRangeRepresentation"_ustr
, -1,
232 uno::Any( sRangeStr
), beans::PropertyState_DIRECT_VALUE
),
233 beans::PropertyValue(
234 u
"HasCategories"_ustr
, -1,
235 uno::Any( bRowHeaders
), beans::PropertyState_DIRECT_VALUE
),
236 beans::PropertyValue(
237 u
"FirstCellAsLabel"_ustr
, -1,
238 uno::Any( bColumnHeaders
), beans::PropertyState_DIRECT_VALUE
),
239 beans::PropertyValue(
240 u
"DataRowSource"_ustr
, -1,
241 uno::Any( chart::ChartDataRowSource_COLUMNS
), beans::PropertyState_DIRECT_VALUE
)
243 xReceiver
->setArguments( aArgs
);
246 ScChartListener
* pChartListener
=
247 new ScChartListener( aName
, rDoc
, xNewRanges
);
248 rDoc
.GetChartListenerCollection()->insert( pChartListener
);
249 pChartListener
->StartListeningTo();
251 rtl::Reference
<SdrOle2Obj
> pObj
= new SdrOle2Obj(
253 ::svt::EmbeddedObjectRef(xObj
, embed::Aspects::MSOLE_CONTENT
),
259 xObj
->setVisualAreaSize( nAspect
, aSz
);
261 // #i121334# This call will change the chart's default background fill from white to transparent.
262 // Add here again if this is wanted (see task description for details)
263 // ChartHelper::AdaptDefaultsForChart( xObj );
265 pPage
->InsertObject( pObj
.get() );
266 pModel
->AddUndo( std::make_unique
<SdrUndoInsertObj
>( *pObj
) );
269 void SAL_CALL
ScChartsObj::removeByName( const OUString
& aName
)
271 SolarMutexGuard aGuard
;
272 SdrOle2Obj
* pObj
= sc::tools::findChartsByName(pDocShell
, nTab
, aName
, sc::tools::ChartSourceType::CELL_RANGE
);
275 ScDocument
& rDoc
= pDocShell
->GetDocument();
276 rDoc
.GetChartListenerCollection()->removeByName(aName
);
277 ScDrawLayer
* pModel
= rDoc
.GetDrawLayer(); // is not zero
278 SdrPage
* pPage
= pModel
->GetPage(static_cast<sal_uInt16
>(nTab
)); // is not zero
280 pModel
->AddUndo( std::make_unique
<SdrUndoDelObj
>( *pObj
) );
281 pPage
->RemoveObject( pObj
->GetOrdNum() );
287 // XEnumerationAccess
289 uno::Reference
<container::XEnumeration
> SAL_CALL
ScChartsObj::createEnumeration()
291 SolarMutexGuard aGuard
;
292 return new ScIndexEnumeration(this, u
"com.sun.star.table.TableChartsEnumeration"_ustr
);
297 sal_Int32 SAL_CALL
ScChartsObj::getCount()
299 SolarMutexGuard aGuard
;
300 sal_Int32 nCount
= 0;
303 ScDocument
& rDoc
= pDocShell
->GetDocument();
304 ScDrawLayer
* pDrawLayer
= rDoc
.GetDrawLayer();
307 SdrPage
* pPage
= pDrawLayer
->GetPage(static_cast<sal_uInt16
>(nTab
));
308 OSL_ENSURE(pPage
, "Page not found");
311 SdrObjListIter
aIter( pPage
, SdrIterMode::DeepNoGroups
);
312 SdrObject
* pObject
= aIter
.Next();
315 if ( pObject
->GetObjIdentifier() == SdrObjKind::OLE2
&& ScDocument::IsChart(pObject
) )
317 pObject
= aIter
.Next();
325 uno::Any SAL_CALL
ScChartsObj::getByIndex( sal_Int32 nIndex
)
327 SolarMutexGuard aGuard
;
328 uno::Reference
<table::XTableChart
> xChart(GetObjectByIndex_Impl(nIndex
));
330 throw lang::IndexOutOfBoundsException();
332 return uno::Any(xChart
);
335 uno::Type SAL_CALL
ScChartsObj::getElementType()
337 return cppu::UnoType
<table::XTableChart
>::get();
340 sal_Bool SAL_CALL
ScChartsObj::hasElements()
342 SolarMutexGuard aGuard
;
343 return getCount() != 0;
346 uno::Any SAL_CALL
ScChartsObj::getByName( const OUString
& aName
)
348 SolarMutexGuard aGuard
;
349 uno::Reference
<table::XTableChart
> xChart(GetObjectByName_Impl(aName
));
351 throw container::NoSuchElementException();
353 return uno::Any(xChart
);
356 uno::Sequence
<OUString
> SAL_CALL
ScChartsObj::getElementNames()
358 SolarMutexGuard aGuard
;
361 ScDocument
& rDoc
= pDocShell
->GetDocument();
363 tools::Long nCount
= getCount();
364 uno::Sequence
<OUString
> aSeq(nCount
);
365 OUString
* pAry
= aSeq
.getArray();
367 tools::Long nPos
= 0;
368 ScDrawLayer
* pDrawLayer
= rDoc
.GetDrawLayer();
371 SdrPage
* pPage
= pDrawLayer
->GetPage(static_cast<sal_uInt16
>(nTab
));
372 OSL_ENSURE(pPage
, "Page not found");
375 SdrObjListIter
aIter( pPage
, SdrIterMode::DeepNoGroups
);
376 SdrObject
* pObject
= aIter
.Next();
379 if ( pObject
->GetObjIdentifier() == SdrObjKind::OLE2
&& ScDocument::IsChart(pObject
) )
382 uno::Reference
< embed::XEmbeddedObject
> xObj
= static_cast<SdrOle2Obj
*>(pObject
)->GetObjRef();
384 aName
= pDocShell
->GetEmbeddedObjectContainer().GetEmbeddedObjectName( xObj
);
386 OSL_ENSURE(nPos
<nCount
, "oops, miscounted?");
387 pAry
[nPos
++] = aName
;
389 pObject
= aIter
.Next();
393 OSL_ENSURE(nPos
==nCount
, "hey, miscounted?");
400 sal_Bool SAL_CALL
ScChartsObj::hasByName( const OUString
& aName
)
402 SolarMutexGuard aGuard
;
403 SdrOle2Obj
* aOle2Obj
= sc::tools::findChartsByName(pDocShell
, nTab
, aName
,
404 sc::tools::ChartSourceType::CELL_RANGE
);
405 return aOle2Obj
!= nullptr;
408 ScChartObj::ScChartObj(ScDocShell
* pDocSh
, SCTAB nT
, OUString aN
)
411 ,aChartName(std::move( aN
))
413 pDocShell
->GetDocument().AddUnoObject(*this);
415 registerPropertyNoMember( u
"RelatedCellRanges"_ustr
,
416 PROP_HANDLE_RELATED_CELLRANGES
, beans::PropertyAttribute::MAYBEVOID
,
417 cppu::UnoType
<uno::Sequence
<table::CellRangeAddress
>>::get(),
418 css::uno::Any(uno::Sequence
<table::CellRangeAddress
>()) );
421 ScChartObj::~ScChartObj()
426 pDocShell
->GetDocument().RemoveUnoObject(*this);
429 void ScChartObj::Notify( SfxBroadcaster
&, const SfxHint
& rHint
)
433 if ( rHint
.GetId() == SfxHintId::Dying
)
439 void ScChartObj::GetData_Impl( ScRangeListRef
& rRanges
, bool& rColHeaders
, bool& rRowHeaders
) const
445 ScDocument
& rDoc
= pDocShell
->GetDocument();
446 uno::Reference
< chart2::XChartDocument
> xChartDoc( rDoc
.GetChartByName( aChartName
) );
449 uno::Reference
< chart2::data::XDataReceiver
> xReceiver( xChartDoc
, uno::UNO_QUERY
);
450 uno::Reference
< chart2::data::XDataProvider
> xProvider
= xChartDoc
->getDataProvider();
451 if( xReceiver
.is() && xProvider
.is() )
453 const uno::Sequence
< beans::PropertyValue
> aArgs( xProvider
->detectArguments( xReceiver
->getUsedData() ) );
456 chart::ChartDataRowSource eDataRowSource
= chart::ChartDataRowSource_COLUMNS
;
457 bool bHasCategories
=false;
458 bool bFirstCellAsLabel
=false;
459 for (const beans::PropertyValue
& rProp
: aArgs
)
461 OUString
aPropName(rProp
.Name
);
463 if (aPropName
== "CellRangeRepresentation")
464 rProp
.Value
>>= aRanges
;
465 else if (aPropName
== "DataRowSource")
466 eDataRowSource
= static_cast<chart::ChartDataRowSource
>(ScUnoHelpFunctions::GetEnumFromAny( rProp
.Value
));
467 else if (aPropName
== "HasCategories")
468 bHasCategories
= ScUnoHelpFunctions::GetBoolFromAny( rProp
.Value
);
469 else if (aPropName
== "FirstCellAsLabel")
470 bFirstCellAsLabel
= ScUnoHelpFunctions::GetBoolFromAny( rProp
.Value
);
473 if( chart::ChartDataRowSource_COLUMNS
== eDataRowSource
)
475 rColHeaders
=bFirstCellAsLabel
;
476 rRowHeaders
=bHasCategories
;
480 rColHeaders
=bHasCategories
;
481 rRowHeaders
=bFirstCellAsLabel
;
483 // Range in UI representation.
484 rRanges
->Parse( aRanges
, rDoc
, rDoc
.GetAddressConvention());
497 void ScChartObj::Update_Impl( const ScRangeListRef
& rRanges
, bool bColHeaders
, bool bRowHeaders
)
501 ScDocument
& rDoc
= pDocShell
->GetDocument();
502 bool bUndo(rDoc
.IsUndoEnabled());
506 pDocShell
->GetUndoManager()->AddUndoAction(
507 std::make_unique
<ScUndoChartData
>( pDocShell
, aChartName
, rRanges
, bColHeaders
, bRowHeaders
, false ) );
509 rDoc
.UpdateChartArea( aChartName
, rRanges
, bColHeaders
, bRowHeaders
, false );
513 // ::comphelper::OPropertySetHelper
515 ::cppu::IPropertyArrayHelper
& ScChartObj::getInfoHelper()
517 return *ScChartObj_PABase::getArrayHelper();
520 void ScChartObj::setFastPropertyValue_NoBroadcast( std::unique_lock
<std::mutex
>& /*rGuard*/, sal_Int32 nHandle
, const uno::Any
& rValue
)
524 case PROP_HANDLE_RELATED_CELLRANGES
:
526 uno::Sequence
< table::CellRangeAddress
> aCellRanges
;
527 if ( rValue
>>= aCellRanges
)
529 ScRangeListRef rRangeList
= new ScRangeList();
530 for (table::CellRangeAddress
const& aCellRange
: aCellRanges
)
533 ScUnoConversion::FillScRange( aRange
, aCellRange
);
534 rRangeList
->push_back( aRange
);
538 ScChartListenerCollection
* pCollection
= pDocShell
->GetDocument().GetChartListenerCollection();
541 pCollection
->ChangeListening( aChartName
, rRangeList
);
552 void ScChartObj::getFastPropertyValue( std::unique_lock
<std::mutex
>& /*rGuard*/, uno::Any
& rValue
, sal_Int32 nHandle
) const
556 case PROP_HANDLE_RELATED_CELLRANGES
:
560 ScDocument
& rDoc
= pDocShell
->GetDocument();
562 ScChartListenerCollection
* pCollection
= rDoc
.GetChartListenerCollection();
566 ScChartListener
* pListener
= pCollection
->findByName(aChartName
);
570 const ScRangeListRef xRangeList
= pListener
->GetRangeList();
571 if (!xRangeList
.is())
574 size_t nCount
= xRangeList
->size();
575 uno::Sequence
<table::CellRangeAddress
> aCellRanges(nCount
);
576 table::CellRangeAddress
* pCellRanges
= aCellRanges
.getArray();
577 for (size_t i
= 0; i
< nCount
; ++i
)
579 ScRange
const & rRange
= (*xRangeList
)[i
];
580 table::CellRangeAddress aCellRange
;
581 ScUnoConversion::FillApiRange(aCellRange
, rRange
);
582 pCellRanges
[i
] = aCellRange
;
584 rValue
<<= aCellRanges
;
592 // ::comphelper::OPropertyArrayUsageHelper
594 ::cppu::IPropertyArrayHelper
* ScChartObj::createArrayHelper() const
596 uno::Sequence
< beans::Property
> aProps
;
597 describeProperties( aProps
);
598 return new ::cppu::OPropertyArrayHelper( aProps
);
603 IMPLEMENT_FORWARD_XINTERFACE2( ScChartObj
, ScChartObj_Base
, ScChartObj_PBase
)
607 IMPLEMENT_FORWARD_XTYPEPROVIDER2( ScChartObj
, ScChartObj_Base
, ScChartObj_PBase
)
611 sal_Bool SAL_CALL
ScChartObj::getHasColumnHeaders()
613 SolarMutexGuard aGuard
;
614 ScRangeListRef xRanges
= new ScRangeList
;
615 bool bColHeaders
, bRowHeaders
;
616 GetData_Impl( xRanges
, bColHeaders
, bRowHeaders
);
620 void SAL_CALL
ScChartObj::setHasColumnHeaders( sal_Bool bHasColumnHeaders
)
622 SolarMutexGuard aGuard
;
623 ScRangeListRef xRanges
= new ScRangeList
;
624 bool bOldColHeaders
, bOldRowHeaders
;
625 GetData_Impl( xRanges
, bOldColHeaders
, bOldRowHeaders
);
626 if ( bOldColHeaders
!= bool(bHasColumnHeaders
) )
627 Update_Impl( xRanges
, bHasColumnHeaders
, bOldRowHeaders
);
630 sal_Bool SAL_CALL
ScChartObj::getHasRowHeaders()
632 SolarMutexGuard aGuard
;
633 ScRangeListRef xRanges
= new ScRangeList
;
634 bool bColHeaders
, bRowHeaders
;
635 GetData_Impl( xRanges
, bColHeaders
, bRowHeaders
);
639 void SAL_CALL
ScChartObj::setHasRowHeaders( sal_Bool bHasRowHeaders
)
641 SolarMutexGuard aGuard
;
642 ScRangeListRef xRanges
= new ScRangeList
;
643 bool bOldColHeaders
, bOldRowHeaders
;
644 GetData_Impl( xRanges
, bOldColHeaders
, bOldRowHeaders
);
645 if ( bOldRowHeaders
!= bool(bHasRowHeaders
) )
646 Update_Impl( xRanges
, bOldColHeaders
, bHasRowHeaders
);
649 uno::Sequence
<table::CellRangeAddress
> SAL_CALL
ScChartObj::getRanges()
651 SolarMutexGuard aGuard
;
652 ScRangeListRef xRanges
= new ScRangeList
;
653 bool bColHeaders
, bRowHeaders
;
654 GetData_Impl( xRanges
, bColHeaders
, bRowHeaders
);
657 size_t nCount
= xRanges
->size();
659 table::CellRangeAddress aRangeAddress
;
660 uno::Sequence
<table::CellRangeAddress
> aSeq(nCount
);
661 table::CellRangeAddress
* pAry
= aSeq
.getArray();
662 for (size_t i
= 0; i
< nCount
; i
++)
664 ScRange
const & rRange
= (*xRanges
)[i
];
666 aRangeAddress
.Sheet
= rRange
.aStart
.Tab();
667 aRangeAddress
.StartColumn
= rRange
.aStart
.Col();
668 aRangeAddress
.StartRow
= rRange
.aStart
.Row();
669 aRangeAddress
.EndColumn
= rRange
.aEnd
.Col();
670 aRangeAddress
.EndRow
= rRange
.aEnd
.Row();
672 pAry
[i
] = aRangeAddress
;
677 OSL_FAIL("ScChartObj::getRanges: no Ranges");
678 return uno::Sequence
<table::CellRangeAddress
>();
681 void SAL_CALL
ScChartObj::setRanges( const uno::Sequence
<table::CellRangeAddress
>& aRanges
)
683 SolarMutexGuard aGuard
;
684 ScRangeListRef xOldRanges
= new ScRangeList
;
685 bool bColHeaders
, bRowHeaders
;
686 GetData_Impl( xOldRanges
, bColHeaders
, bRowHeaders
);
688 ScRangeList
* pList
= new ScRangeList
;
689 for (const table::CellRangeAddress
& rRange
: aRanges
)
691 ScRange
aRange( static_cast<SCCOL
>(rRange
.StartColumn
), rRange
.StartRow
, rRange
.Sheet
,
692 static_cast<SCCOL
>(rRange
.EndColumn
), rRange
.EndRow
, rRange
.Sheet
);
693 pList
->push_back( aRange
);
695 ScRangeListRef
xNewRanges( pList
);
697 if ( !xOldRanges
.is() || *xOldRanges
!= *xNewRanges
)
698 Update_Impl( xNewRanges
, bColHeaders
, bRowHeaders
);
701 // XEmbeddedObjectSupplier
703 uno::Reference
<lang::XComponent
> SAL_CALL
ScChartObj::getEmbeddedObject()
705 SolarMutexGuard aGuard
;
706 SdrOle2Obj
* pObject
= sc::tools::findChartsByName(pDocShell
, nTab
, aChartName
,
707 sc::tools::ChartSourceType::CELL_RANGE
);
708 if ( pObject
&& svt::EmbeddedObjectRef::TryRunningState( pObject
->GetObjRef() ) )
710 //TODO/LATER: is it OK that something is returned for *all* objects, not only own objects?
711 return uno::Reference
< lang::XComponent
> ( pObject
->GetObjRef()->getComponent(), uno::UNO_QUERY
);
719 OUString SAL_CALL
ScChartObj::getName()
721 SolarMutexGuard aGuard
;
725 void SAL_CALL
ScChartObj::setName( const OUString
& /* aName */ )
727 throw uno::RuntimeException(); // name cannot be changed
732 uno::Reference
< beans::XPropertySetInfo
> ScChartObj::getPropertySetInfo()
734 return createPropertySetInfo( getInfoHelper() ) ;
737 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */