Gtk-WARNING gtktreestore.c:1047: Invalid column number 1 added to iter
[LibreOffice.git] / sc / source / core / data / documen5.cxx
blob7e2aa26679ce5fb6434aaf80e24080c7ac73555d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/util/XModifiable.hpp>
21 #include <com/sun/star/chart/ChartDataRowSource.hpp>
22 #include <com/sun/star/chart2/XChartDocument.hpp>
23 #include <com/sun/star/chart2/data/XDataProvider.hpp>
24 #include <com/sun/star/chart2/data/XDataReceiver.hpp>
25 #include <com/sun/star/embed/XEmbeddedObject.hpp>
27 #include <svx/svditer.hxx>
28 #include <svx/svdoole2.hxx>
29 #include <svtools/embedhlp.hxx>
31 #include <document.hxx>
32 #include <docsh.hxx>
33 #include <table.hxx>
34 #include <drwlayer.hxx>
35 #include <chartlis.hxx>
36 #include <chartlock.hxx>
37 #include <refupdat.hxx>
39 #include <miscuno.hxx>
40 #include <chart2uno.hxx>
41 #include <charthelper.hxx>
43 using namespace ::com::sun::star;
45 static void lcl_GetChartParameters( const uno::Reference< chart2::XChartDocument >& xChartDoc,
46 OUString& rRanges, chart::ChartDataRowSource& rDataRowSource,
47 bool& rHasCategories, bool& rFirstCellAsLabel )
49 rHasCategories = rFirstCellAsLabel = false; // default if not in sequence
51 uno::Reference< chart2::data::XDataReceiver > xReceiver( xChartDoc, uno::UNO_QUERY );
53 uno::Reference< chart2::data::XDataSource > xDataSource = xReceiver->getUsedData();
54 uno::Reference< chart2::data::XDataProvider > xProvider = xChartDoc->getDataProvider();
56 if ( !xProvider.is() )
57 return;
59 const uno::Sequence< beans::PropertyValue > aArgs( xProvider->detectArguments( xDataSource ) );
61 for (const beans::PropertyValue& rProp : aArgs)
63 OUString aPropName(rProp.Name);
65 if ( aPropName == "CellRangeRepresentation" )
66 rProp.Value >>= rRanges;
67 else if ( aPropName == "DataRowSource" )
68 rDataRowSource = static_cast<chart::ChartDataRowSource>(ScUnoHelpFunctions::GetEnumFromAny( rProp.Value ));
69 else if ( aPropName == "HasCategories" )
70 rHasCategories = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
71 else if ( aPropName == "FirstCellAsLabel" )
72 rFirstCellAsLabel = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
76 static void lcl_SetChartParameters( const uno::Reference< chart2::data::XDataReceiver >& xReceiver,
77 const OUString& rRanges, chart::ChartDataRowSource eDataRowSource,
78 bool bHasCategories, bool bFirstCellAsLabel )
80 if ( !xReceiver.is() )
81 return;
83 uno::Sequence< beans::PropertyValue > aArgs{
84 beans::PropertyValue(
85 u"CellRangeRepresentation"_ustr, -1,
86 uno::Any( rRanges ), beans::PropertyState_DIRECT_VALUE ),
87 beans::PropertyValue(
88 u"HasCategories"_ustr, -1,
89 uno::Any( bHasCategories ), beans::PropertyState_DIRECT_VALUE ),
90 beans::PropertyValue(
91 u"FirstCellAsLabel"_ustr, -1,
92 uno::Any( bFirstCellAsLabel ), beans::PropertyState_DIRECT_VALUE ),
93 beans::PropertyValue(
94 u"DataRowSource"_ustr, -1,
95 uno::Any( eDataRowSource ), beans::PropertyState_DIRECT_VALUE )
97 xReceiver->setArguments( aArgs );
100 bool ScDocument::HasChartAtPoint( SCTAB nTab, const Point& rPos, OUString& rName )
102 if (mpDrawLayer && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab])
104 SdrPage* pPage = mpDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
105 OSL_ENSURE(pPage,"Page ?");
107 SdrObjListIter aIter( pPage, SdrIterMode::DeepNoGroups );
108 SdrObject* pObject = aIter.Next();
109 while (pObject)
111 if ( pObject->GetObjIdentifier() == SdrObjKind::OLE2 &&
112 pObject->GetCurrentBoundRect().Contains(rPos) )
114 // also Chart-Objects that are not in the Collection
116 if (IsChart(pObject))
118 rName = static_cast<SdrOle2Obj*>(pObject)->GetPersistName();
119 return true;
122 pObject = aIter.Next();
126 rName.clear();
127 return false; // nothing found
130 void ScDocument::UpdateChartArea( const OUString& rChartName,
131 const ScRange& rNewArea, bool bColHeaders, bool bRowHeaders,
132 bool bAdd )
134 ScRangeListRef aRLR( new ScRangeList(rNewArea) );
135 UpdateChartArea( rChartName, aRLR, bColHeaders, bRowHeaders, bAdd );
138 uno::Reference< chart2::XChartDocument > ScDocument::GetChartByName( std::u16string_view rChartName )
140 uno::Reference< chart2::XChartDocument > xReturn;
142 if (mpDrawLayer)
144 sal_uInt16 nCount = mpDrawLayer->GetPageCount();
145 SCTAB nSize = static_cast<SCTAB>(maTabs.size());
146 for (sal_uInt16 nTab=0; nTab<nCount && nTab < nSize; nTab++)
148 SdrPage* pPage = mpDrawLayer->GetPage(nTab);
149 OSL_ENSURE(pPage,"Page ?");
151 SdrObjListIter aIter( pPage, SdrIterMode::DeepNoGroups );
152 SdrObject* pObject = aIter.Next();
153 while (pObject)
155 if ( pObject->GetObjIdentifier() == SdrObjKind::OLE2 &&
156 static_cast<SdrOle2Obj*>(pObject)->GetPersistName() == rChartName )
158 xReturn.set( ScChartHelper::GetChartFromSdrObject( pObject ) );
159 return xReturn;
161 pObject = aIter.Next();
165 return xReturn;
168 void ScDocument::GetChartRanges( std::u16string_view rChartName, ::std::vector< ScRangeList >& rRangesVector, const ScDocument& rSheetNameDoc )
170 rRangesVector.clear();
171 uno::Reference< chart2::XChartDocument > xChartDoc( GetChartByName( rChartName ) );
172 if ( xChartDoc.is() )
174 std::vector< OUString > aRangeStrings;
175 ScChartHelper::GetChartRanges( xChartDoc, aRangeStrings );
176 for(const OUString & aRangeString : aRangeStrings)
178 ScRangeList aRanges;
179 aRanges.Parse( aRangeString, rSheetNameDoc, rSheetNameDoc.GetAddressConvention() );
180 rRangesVector.push_back(aRanges);
185 void ScDocument::SetChartRanges( std::u16string_view rChartName, const ::std::vector< ScRangeList >& rRangesVector )
187 uno::Reference< chart2::XChartDocument > xChartDoc( GetChartByName( rChartName ) );
188 if ( !xChartDoc.is() )
189 return;
191 sal_Int32 nCount = static_cast<sal_Int32>( rRangesVector.size() );
192 uno::Sequence< OUString > aRangeStrings(nCount);
193 auto aRangeStringsRange = asNonConstRange(aRangeStrings);
194 for( sal_Int32 nN=0; nN<nCount; nN++ )
196 const ScRangeList& aScRangeList( rRangesVector[nN] );
197 OUString sRangeStr;
198 aScRangeList.Format( sRangeStr, ScRefFlags::RANGE_ABS_3D, *this, GetAddressConvention() );
199 aRangeStringsRange[nN]=sRangeStr;
201 ScChartHelper::SetChartRanges( xChartDoc, aRangeStrings );
204 void ScDocument::GetOldChartParameters( std::u16string_view rName,
205 ScRangeList& rRanges, bool& rColHeaders, bool& rRowHeaders )
207 // used for undo of changing chart source area
209 if (!mpDrawLayer)
210 return;
212 sal_uInt16 nCount = mpDrawLayer->GetPageCount();
213 for (sal_uInt16 nTab=0; nTab<nCount && nTab < static_cast<SCTAB>(maTabs.size()); nTab++)
215 SdrPage* pPage = mpDrawLayer->GetPage(nTab);
216 OSL_ENSURE(pPage,"Page ?");
218 SdrObjListIter aIter( pPage, SdrIterMode::DeepNoGroups );
219 SdrObject* pObject = aIter.Next();
220 while (pObject)
222 if ( pObject->GetObjIdentifier() == SdrObjKind::OLE2 &&
223 static_cast<SdrOle2Obj*>(pObject)->GetPersistName() == rName )
225 uno::Reference< chart2::XChartDocument > xChartDoc( ScChartHelper::GetChartFromSdrObject( pObject ) );
226 if ( xChartDoc.is() )
228 chart::ChartDataRowSource eDataRowSource = chart::ChartDataRowSource_COLUMNS;
229 bool bHasCategories = false;
230 bool bFirstCellAsLabel = false;
231 OUString aRangesStr;
232 lcl_GetChartParameters( xChartDoc, aRangesStr, eDataRowSource, bHasCategories, bFirstCellAsLabel );
234 rRanges.Parse( aRangesStr, *this, GetAddressConvention());
235 if ( eDataRowSource == chart::ChartDataRowSource_COLUMNS )
237 rRowHeaders = bHasCategories;
238 rColHeaders = bFirstCellAsLabel;
240 else
242 rColHeaders = bHasCategories;
243 rRowHeaders = bFirstCellAsLabel;
246 return;
248 pObject = aIter.Next();
253 void ScDocument::UpdateChartArea( const OUString& rChartName,
254 const ScRangeListRef& rNewList, bool bColHeaders, bool bRowHeaders,
255 bool bAdd )
257 if (!mpDrawLayer)
258 return;
260 for (SCTAB nTab=0; nTab< static_cast<SCTAB>(maTabs.size()) && maTabs[nTab]; nTab++)
262 SdrPage* pPage = mpDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
263 OSL_ENSURE(pPage,"Page ?");
265 SdrObjListIter aIter( pPage, SdrIterMode::DeepNoGroups );
266 SdrObject* pObject = aIter.Next();
267 while (pObject)
269 if ( pObject->GetObjIdentifier() == SdrObjKind::OLE2 &&
270 static_cast<SdrOle2Obj*>(pObject)->GetPersistName() == rChartName )
272 uno::Reference< chart2::XChartDocument > xChartDoc( ScChartHelper::GetChartFromSdrObject( pObject ) );
273 uno::Reference< chart2::data::XDataReceiver > xReceiver( xChartDoc, uno::UNO_QUERY );
274 if ( xChartDoc.is() && xReceiver.is() )
276 ScRangeListRef aNewRanges;
277 chart::ChartDataRowSource eDataRowSource = chart::ChartDataRowSource_COLUMNS;
278 bool bHasCategories = false;
279 bool bFirstCellAsLabel = false;
280 OUString aRangesStr;
281 lcl_GetChartParameters( xChartDoc, aRangesStr, eDataRowSource, bHasCategories, bFirstCellAsLabel );
283 bool bInternalData = xChartDoc->hasInternalDataProvider();
285 if ( bAdd && !bInternalData )
287 // append to old ranges, keep other settings
289 aNewRanges = new ScRangeList;
290 aNewRanges->Parse( aRangesStr, *this, GetAddressConvention());
291 aNewRanges->insert( aNewRanges->begin(), rNewList->begin(), rNewList->end() );
293 else
295 // directly use new ranges (only eDataRowSource is used from old settings)
297 if ( eDataRowSource == chart::ChartDataRowSource_COLUMNS )
299 bHasCategories = bRowHeaders;
300 bFirstCellAsLabel = bColHeaders;
302 else
304 bHasCategories = bColHeaders;
305 bFirstCellAsLabel = bRowHeaders;
307 aNewRanges = rNewList;
310 if ( bInternalData && mpShell )
312 // Calc -> DataProvider
313 uno::Reference< chart2::data::XDataProvider > xDataProvider = new ScChart2DataProvider( this );
314 xReceiver->attachDataProvider( xDataProvider );
315 uno::Reference< util::XNumberFormatsSupplier > xNumberFormatsSupplier(
316 static_cast<cppu::OWeakObject*>(mpShell->GetModel()), uno::UNO_QUERY );
317 xReceiver->attachNumberFormatsSupplier( xNumberFormatsSupplier );
320 OUString sRangeStr;
321 aNewRanges->Format( sRangeStr, ScRefFlags::RANGE_ABS_3D, *this, GetAddressConvention() );
323 lcl_SetChartParameters( xReceiver, sRangeStr, eDataRowSource, bHasCategories, bFirstCellAsLabel );
325 pChartListenerCollection->ChangeListening( rChartName, aNewRanges );
327 return; // do not search anymore
330 pObject = aIter.Next();
335 void ScDocument::UpdateChart( const OUString& rChartName )
337 if (!mpDrawLayer || bInDtorClear)
338 return;
339 uno::Reference< chart2::XChartDocument > xChartDoc( GetChartByName( rChartName ) );
340 if (xChartDoc && (!mpShell || mpShell->IsEnableSetModified()))
344 uno::Reference< util::XModifiable > xModif( xChartDoc, uno::UNO_QUERY_THROW );
345 if (apTemporaryChartLock)
346 apTemporaryChartLock->AlsoLockThisChart( uno::Reference< frame::XModel >( xModif, uno::UNO_QUERY ) );
347 xModif->setModified( true );
349 catch ( uno::Exception& )
354 // After the update, chart keeps track of its own data source ranges,
355 // the listener doesn't need to listen anymore, except the chart has
356 // an internal data provider.
357 if ( !( xChartDoc.is() && xChartDoc->hasInternalDataProvider() ) && pChartListenerCollection )
359 pChartListenerCollection->ChangeListening( rChartName, new ScRangeList );
363 void ScDocument::RestoreChartListener( const OUString& rName )
365 if (!pChartListenerCollection)
366 return;
368 // Read the data ranges from the chart object, and start listening to those ranges again
369 // (called when a chart is saved, because then it might be swapped out and stop listening itself).
371 uno::Reference< embed::XEmbeddedObject > xObject = FindOleObjectByName( rName );
372 if ( !xObject.is() )
373 return;
375 uno::Reference< util::XCloseable > xComponent = xObject->getComponent();
376 uno::Reference< chart2::XChartDocument > xChartDoc( xComponent, uno::UNO_QUERY );
377 uno::Reference< chart2::data::XDataReceiver > xReceiver( xComponent, uno::UNO_QUERY );
378 if ( !xChartDoc.is() || !xReceiver.is() || xChartDoc->hasInternalDataProvider() )
379 return;
381 const uno::Sequence<OUString> aRepresentations( xReceiver->getUsedRangeRepresentations() );
382 ScRangeListRef aRanges = new ScRangeList;
383 for ( const auto& rRepresentation : aRepresentations )
385 ScRange aRange;
386 ScAddress::Details aDetails(GetAddressConvention(), 0, 0);
387 if ( aRange.ParseAny( rRepresentation, *this, aDetails ) & ScRefFlags::VALID )
388 aRanges->push_back( aRange );
391 pChartListenerCollection->ChangeListening( rName, aRanges );
394 void ScDocument::UpdateChartRef( UpdateRefMode eUpdateRefMode,
395 SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
396 SCCOL nCol2, SCROW nRow2, SCTAB nTab2,
397 SCCOL nDx, SCROW nDy, SCTAB nDz )
399 if (!mpDrawLayer)
400 return;
402 ScChartListenerCollection::ListenersType& rListeners = pChartListenerCollection->getListeners();
403 for (auto const& it : rListeners)
405 ScChartListener *const pChartListener = it.second.get();
406 ScRangeListRef aRLR( pChartListener->GetRangeList() );
407 ScRangeListRef aNewRLR( new ScRangeList );
408 bool bChanged = false;
409 bool bDataChanged = false;
410 for ( size_t i = 0, nListSize = aRLR->size(); i < nListSize; ++i )
412 ScRange& rRange = (*aRLR)[i];
413 SCCOL theCol1 = rRange.aStart.Col();
414 SCROW theRow1 = rRange.aStart.Row();
415 SCTAB theTab1 = rRange.aStart.Tab();
416 SCCOL theCol2 = rRange.aEnd.Col();
417 SCROW theRow2 = rRange.aEnd.Row();
418 SCTAB theTab2 = rRange.aEnd.Tab();
419 ScRefUpdateRes eRes = ScRefUpdate::Update(
420 this, eUpdateRefMode,
421 nCol1,nRow1,nTab1, nCol2,nRow2,nTab2,
422 nDx,nDy,nDz,
423 theCol1,theRow1,theTab1,
424 theCol2,theRow2,theTab2 );
425 if ( eRes != UR_NOTHING )
427 bChanged = true;
428 aNewRLR->push_back( ScRange(
429 theCol1, theRow1, theTab1,
430 theCol2, theRow2, theTab2 ));
431 if ( eUpdateRefMode == URM_INSDEL
432 && !bDataChanged
433 && (eRes == UR_INVALID ||
434 ((rRange.aEnd.Col() - rRange.aStart.Col()
435 != theCol2 - theCol1)
436 || (rRange.aEnd.Row() - rRange.aStart.Row()
437 != theRow2 - theRow1)
438 || (rRange.aEnd.Tab() - rRange.aStart.Tab()
439 != theTab2 - theTab1))) )
441 bDataChanged = true;
444 else
445 aNewRLR->push_back( rRange );
447 if ( bChanged )
449 // Force the chart to be loaded now, so it registers itself for UNO events.
450 // UNO broadcasts are done after UpdateChartRef, so the chart will get this
451 // reference change.
453 uno::Reference<embed::XEmbeddedObject> xIPObj =
454 FindOleObjectByName(pChartListener->GetName());
456 (void)svt::EmbeddedObjectRef::TryRunningState( xIPObj );
458 // After the change, chart keeps track of its own data source ranges,
459 // the listener doesn't need to listen anymore, except the chart has
460 // an internal data provider.
461 bool bInternalDataProvider = false;
462 if ( xIPObj.is() )
466 uno::Reference< chart2::XChartDocument > xChartDoc( xIPObj->getComponent(), uno::UNO_QUERY_THROW );
467 bInternalDataProvider = xChartDoc->hasInternalDataProvider();
469 catch ( uno::Exception& )
473 if ( bInternalDataProvider )
475 pChartListener->ChangeListening( aNewRLR, bDataChanged );
477 else
479 pChartListener->ChangeListening( new ScRangeList, bDataChanged );
485 void ScDocument::SetChartRangeList( std::u16string_view rChartName,
486 const ScRangeListRef& rNewRangeListRef )
488 // called from ChartListener
490 if (!mpDrawLayer)
491 return;
493 for (SCTAB nTab=0; nTab< static_cast<SCTAB>(maTabs.size()) && maTabs[nTab]; nTab++)
495 SdrPage* pPage = mpDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
496 OSL_ENSURE(pPage,"Page ?");
498 SdrObjListIter aIter( pPage, SdrIterMode::DeepNoGroups );
499 SdrObject* pObject = aIter.Next();
500 while (pObject)
502 if ( pObject->GetObjIdentifier() == SdrObjKind::OLE2 &&
503 static_cast<SdrOle2Obj*>(pObject)->GetPersistName() == rChartName )
505 uno::Reference< chart2::XChartDocument > xChartDoc( ScChartHelper::GetChartFromSdrObject( pObject ) );
506 uno::Reference< chart2::data::XDataReceiver > xReceiver( xChartDoc, uno::UNO_QUERY );
507 if ( xChartDoc.is() && xReceiver.is() )
509 chart::ChartDataRowSource eDataRowSource = chart::ChartDataRowSource_COLUMNS;
510 bool bHasCategories = false;
511 bool bFirstCellAsLabel = false;
512 OUString aRangesStr;
513 lcl_GetChartParameters( xChartDoc, aRangesStr, eDataRowSource, bHasCategories, bFirstCellAsLabel );
515 OUString sRangeStr;
516 rNewRangeListRef->Format( sRangeStr, ScRefFlags::RANGE_ABS_3D, *this, GetAddressConvention() );
518 lcl_SetChartParameters( xReceiver, sRangeStr, eDataRowSource, bHasCategories, bFirstCellAsLabel );
520 // don't modify pChartListenerCollection here, called from there
521 return;
524 pObject = aIter.Next();
529 bool ScDocument::HasData( SCCOL nCol, SCROW nRow, SCTAB nTab )
531 if (ScTable* pTable = FetchTable(nTab) ; pTable && nCol < pTable->GetAllocatedColumnsCount())
532 return pTable->HasData(nCol, nRow);
533 return false;
536 uno::Reference< embed::XEmbeddedObject >
537 ScDocument::FindOleObjectByName( std::u16string_view rName )
539 if (!mpDrawLayer)
540 return uno::Reference< embed::XEmbeddedObject >();
542 // take the pages here from Draw-Layer, as they might not match with the tables
543 // (e.g. delete Redo of table; Draw-Redo happens before DeleteTab)
545 sal_uInt16 nCount = mpDrawLayer->GetPageCount();
546 for (sal_uInt16 nTab=0; nTab<nCount; nTab++)
548 SdrPage* pPage = mpDrawLayer->GetPage(nTab);
549 OSL_ENSURE(pPage,"Page ?");
551 SdrObjListIter aIter( pPage, SdrIterMode::DeepNoGroups );
552 SdrObject* pObject = aIter.Next();
553 while (pObject)
555 if ( pObject->GetObjIdentifier() == SdrObjKind::OLE2 )
557 SdrOle2Obj * pOleObject ( dynamic_cast< SdrOle2Obj * >( pObject ));
558 if( pOleObject &&
559 pOleObject->GetPersistName() == rName )
561 return pOleObject->GetObjRef();
564 pObject = aIter.Next();
568 return uno::Reference< embed::XEmbeddedObject >();
571 void ScDocument::UpdateChartListenerCollection()
573 assert(pChartListenerCollection);
575 bChartListenerCollectionNeedsUpdate = false;
576 if (!mpDrawLayer)
577 return;
579 for (SCTAB nTab=0; nTab< static_cast<SCTAB>(maTabs.size()); nTab++)
581 if (!maTabs[nTab])
582 continue;
584 SdrPage* pPage = mpDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
585 OSL_ENSURE(pPage,"Page ?");
587 if (!pPage)
588 continue;
590 SdrObjListIter aIter( pPage, SdrIterMode::DeepNoGroups );
591 ScChartListenerCollection::StringSetType& rNonOleObjects =
592 pChartListenerCollection->getNonOleObjectNames();
594 for (SdrObject* pObject = aIter.Next(); pObject; pObject = aIter.Next())
596 if ( pObject->GetObjIdentifier() != SdrObjKind::OLE2 )
597 continue;
599 OUString aObjName = static_cast<SdrOle2Obj*>(pObject)->GetPersistName();
600 ScChartListener* pListener = pChartListenerCollection->findByName(aObjName);
602 if (pListener)
603 pListener->SetUsed(true);
604 else if (rNonOleObjects.count(aObjName) > 0)
606 // non-chart OLE object -> don't touch
608 else
610 uno::Reference< embed::XEmbeddedObject > xIPObj = static_cast<SdrOle2Obj*>(pObject)->GetObjRef();
611 OSL_ENSURE( xIPObj.is(), "No embedded object is given!");
612 uno::Reference< css::chart2::data::XDataReceiver > xReceiver;
613 if( xIPObj.is())
614 xReceiver.set( xIPObj->getComponent(), uno::UNO_QUERY );
616 // if the object is a chart2::XDataReceiver, we must attach as XDataProvider
617 if( xReceiver.is() &&
618 !PastingDrawFromOtherDoc())
620 // NOTE: this currently does not work as we are
621 // unable to set the data. So a chart from the
622 // same document is treated like a chart with
623 // own data for the time being.
625 // data provider
626 // number formats supplier
628 // data ?
629 // how to set?? Defined in XML-file, which is already loaded!!!
630 // => we have to do this stuff here, BEFORE the chart is actually loaded
633 // put into list of other ole objects, so the object doesn't have to
634 // be swapped in the next time UpdateChartListenerCollection is called
635 //TODO: remove names when objects are no longer there?
636 // (object names aren't used again before reloading the document)
638 rNonOleObjects.insert(aObjName);
642 // delete all that are not set SetUsed
643 pChartListenerCollection->FreeUnused();
646 void ScDocument::AddOLEObjectToCollection(const OUString& rName)
648 assert(pChartListenerCollection);
649 ScChartListenerCollection::StringSetType& rNonOleObjects =
650 pChartListenerCollection->getNonOleObjectNames();
652 rNonOleObjects.insert(rName);
655 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */