LibreOffice Module sc (master) 1
documen5.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
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>
26
27#include <sfx2/objsh.hxx>
28#include <svx/svditer.hxx>
29#include <svx/svdoole2.hxx>
30#include <svtools/embedhlp.hxx>
31
32#include <document.hxx>
33#include <table.hxx>
34#include <drwlayer.hxx>
35#include <chartlis.hxx>
36#include <chartlock.hxx>
37#include <refupdat.hxx>
38
39#include <miscuno.hxx>
40#include <chart2uno.hxx>
41#include <charthelper.hxx>
42
43using namespace ::com::sun::star;
44
45static void lcl_GetChartParameters( const uno::Reference< chart2::XChartDocument >& xChartDoc,
46 OUString& rRanges, chart::ChartDataRowSource& rDataRowSource,
47 bool& rHasCategories, bool& rFirstCellAsLabel )
48{
49 rHasCategories = rFirstCellAsLabel = false; // default if not in sequence
50
51 uno::Reference< chart2::data::XDataReceiver > xReceiver( xChartDoc, uno::UNO_QUERY );
52
53 uno::Reference< chart2::data::XDataSource > xDataSource = xReceiver->getUsedData();
54 uno::Reference< chart2::data::XDataProvider > xProvider = xChartDoc->getDataProvider();
55
56 if ( !xProvider.is() )
57 return;
58
59 const uno::Sequence< beans::PropertyValue > aArgs( xProvider->detectArguments( xDataSource ) );
60
61 for (const beans::PropertyValue& rProp : aArgs)
62 {
63 OUString aPropName(rProp.Name);
64
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 );
73 }
74}
75
76static void lcl_SetChartParameters( const uno::Reference< chart2::data::XDataReceiver >& xReceiver,
77 const OUString& rRanges, chart::ChartDataRowSource eDataRowSource,
78 bool bHasCategories, bool bFirstCellAsLabel )
79{
80 if ( !xReceiver.is() )
81 return;
82
83 uno::Sequence< beans::PropertyValue > aArgs{
84 beans::PropertyValue(
85 "CellRangeRepresentation", -1,
86 uno::Any( rRanges ), beans::PropertyState_DIRECT_VALUE ),
87 beans::PropertyValue(
88 "HasCategories", -1,
89 uno::Any( bHasCategories ), beans::PropertyState_DIRECT_VALUE ),
90 beans::PropertyValue(
91 "FirstCellAsLabel", -1,
92 uno::Any( bFirstCellAsLabel ), beans::PropertyState_DIRECT_VALUE ),
93 beans::PropertyValue(
94 "DataRowSource", -1,
95 uno::Any( eDataRowSource ), beans::PropertyState_DIRECT_VALUE )
96 };
97 xReceiver->setArguments( aArgs );
98}
99
100bool ScDocument::HasChartAtPoint( SCTAB nTab, const Point& rPos, OUString& rName )
101{
102 if (mpDrawLayer && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab])
103 {
104 SdrPage* pPage = mpDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
105 OSL_ENSURE(pPage,"Page ?");
106
107 SdrObjListIter aIter( pPage, SdrIterMode::DeepNoGroups );
108 SdrObject* pObject = aIter.Next();
109 while (pObject)
110 {
111 if ( pObject->GetObjIdentifier() == SdrObjKind::OLE2 &&
112 pObject->GetCurrentBoundRect().Contains(rPos) )
113 {
114 // also Chart-Objects that are not in the Collection
115
116 if (IsChart(pObject))
117 {
118 rName = static_cast<SdrOle2Obj*>(pObject)->GetPersistName();
119 return true;
120 }
121 }
122 pObject = aIter.Next();
123 }
124 }
125
126 rName.clear();
127 return false; // nothing found
128}
129
130void ScDocument::UpdateChartArea( const OUString& rChartName,
131 const ScRange& rNewArea, bool bColHeaders, bool bRowHeaders,
132 bool bAdd )
133{
134 ScRangeListRef aRLR( new ScRangeList(rNewArea) );
135 UpdateChartArea( rChartName, aRLR, bColHeaders, bRowHeaders, bAdd );
136}
137
138uno::Reference< chart2::XChartDocument > ScDocument::GetChartByName( std::u16string_view rChartName )
139{
140 uno::Reference< chart2::XChartDocument > xReturn;
141
142 if (mpDrawLayer)
143 {
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++)
147 {
148 SdrPage* pPage = mpDrawLayer->GetPage(nTab);
149 OSL_ENSURE(pPage,"Page ?");
150
151 SdrObjListIter aIter( pPage, SdrIterMode::DeepNoGroups );
152 SdrObject* pObject = aIter.Next();
153 while (pObject)
154 {
155 if ( pObject->GetObjIdentifier() == SdrObjKind::OLE2 &&
156 static_cast<SdrOle2Obj*>(pObject)->GetPersistName() == rChartName )
157 {
159 return xReturn;
160 }
161 pObject = aIter.Next();
162 }
163 }
164 }
165 return xReturn;
166}
167
168void ScDocument::GetChartRanges( std::u16string_view rChartName, ::std::vector< ScRangeList >& rRangesVector, const ScDocument& rSheetNameDoc )
169{
170 rRangesVector.clear();
171 uno::Reference< chart2::XChartDocument > xChartDoc( GetChartByName( rChartName ) );
172 if ( xChartDoc.is() )
173 {
174 std::vector< OUString > aRangeStrings;
175 ScChartHelper::GetChartRanges( xChartDoc, aRangeStrings );
176 for(const OUString & aRangeString : aRangeStrings)
177 {
178 ScRangeList aRanges;
179 aRanges.Parse( aRangeString, rSheetNameDoc, rSheetNameDoc.GetAddressConvention() );
180 rRangesVector.push_back(aRanges);
181 }
182 }
183}
184
185void ScDocument::SetChartRanges( std::u16string_view rChartName, const ::std::vector< ScRangeList >& rRangesVector )
186{
187 uno::Reference< chart2::XChartDocument > xChartDoc( GetChartByName( rChartName ) );
188 if ( !xChartDoc.is() )
189 return;
190
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++ )
195 {
196 ScRangeList aScRangeList( rRangesVector[nN] );
197 OUString sRangeStr;
198 aScRangeList.Format( sRangeStr, ScRefFlags::RANGE_ABS_3D, *this, GetAddressConvention() );
199 aRangeStringsRange[nN]=sRangeStr;
200 }
201 ScChartHelper::SetChartRanges( xChartDoc, aRangeStrings );
202}
203
204void ScDocument::GetOldChartParameters( std::u16string_view rName,
205 ScRangeList& rRanges, bool& rColHeaders, bool& rRowHeaders )
206{
207 // used for undo of changing chart source area
208
209 if (!mpDrawLayer)
210 return;
211
212 sal_uInt16 nCount = mpDrawLayer->GetPageCount();
213 for (sal_uInt16 nTab=0; nTab<nCount && nTab < static_cast<SCTAB>(maTabs.size()); nTab++)
214 {
215 SdrPage* pPage = mpDrawLayer->GetPage(nTab);
216 OSL_ENSURE(pPage,"Page ?");
217
218 SdrObjListIter aIter( pPage, SdrIterMode::DeepNoGroups );
219 SdrObject* pObject = aIter.Next();
220 while (pObject)
221 {
222 if ( pObject->GetObjIdentifier() == SdrObjKind::OLE2 &&
223 static_cast<SdrOle2Obj*>(pObject)->GetPersistName() == rName )
224 {
225 uno::Reference< chart2::XChartDocument > xChartDoc( ScChartHelper::GetChartFromSdrObject( pObject ) );
226 if ( xChartDoc.is() )
227 {
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 );
233
234 rRanges.Parse( aRangesStr, *this, GetAddressConvention());
235 if ( eDataRowSource == chart::ChartDataRowSource_COLUMNS )
236 {
237 rRowHeaders = bHasCategories;
238 rColHeaders = bFirstCellAsLabel;
239 }
240 else
241 {
242 rColHeaders = bHasCategories;
243 rRowHeaders = bFirstCellAsLabel;
244 }
245 }
246 return;
247 }
248 pObject = aIter.Next();
249 }
250 }
251}
252
253void ScDocument::UpdateChartArea( const OUString& rChartName,
254 const ScRangeListRef& rNewList, bool bColHeaders, bool bRowHeaders,
255 bool bAdd )
256{
257 if (!mpDrawLayer)
258 return;
259
260 for (SCTAB nTab=0; nTab< static_cast<SCTAB>(maTabs.size()) && maTabs[nTab]; nTab++)
261 {
262 SdrPage* pPage = mpDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
263 OSL_ENSURE(pPage,"Page ?");
264
265 SdrObjListIter aIter( pPage, SdrIterMode::DeepNoGroups );
266 SdrObject* pObject = aIter.Next();
267 while (pObject)
268 {
269 if ( pObject->GetObjIdentifier() == SdrObjKind::OLE2 &&
270 static_cast<SdrOle2Obj*>(pObject)->GetPersistName() == rChartName )
271 {
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() )
275 {
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 );
282
283 bool bInternalData = xChartDoc->hasInternalDataProvider();
284
285 if ( bAdd && !bInternalData )
286 {
287 // append to old ranges, keep other settings
288
289 aNewRanges = new ScRangeList;
290 aNewRanges->Parse( aRangesStr, *this, GetAddressConvention());
291 aNewRanges->insert( aNewRanges->begin(), rNewList->begin(), rNewList->end() );
292 }
293 else
294 {
295 // directly use new ranges (only eDataRowSource is used from old settings)
296
297 if ( eDataRowSource == chart::ChartDataRowSource_COLUMNS )
298 {
299 bHasCategories = bRowHeaders;
300 bFirstCellAsLabel = bColHeaders;
301 }
302 else
303 {
304 bHasCategories = bColHeaders;
305 bFirstCellAsLabel = bRowHeaders;
306 }
307 aNewRanges = rNewList;
308 }
309
310 if ( bInternalData && mpShell )
311 {
312 // Calc -> DataProvider
313 uno::Reference< chart2::data::XDataProvider > xDataProvider = new ScChart2DataProvider( this );
314 xReceiver->attachDataProvider( xDataProvider );
315 uno::Reference< util::XNumberFormatsSupplier > xNumberFormatsSupplier(
316 mpShell->GetModel(), uno::UNO_QUERY );
317 xReceiver->attachNumberFormatsSupplier( xNumberFormatsSupplier );
318 }
319
320 OUString sRangeStr;
321 aNewRanges->Format( sRangeStr, ScRefFlags::RANGE_ABS_3D, *this, GetAddressConvention() );
322
323 lcl_SetChartParameters( xReceiver, sRangeStr, eDataRowSource, bHasCategories, bFirstCellAsLabel );
324
325 pChartListenerCollection->ChangeListening( rChartName, aNewRanges );
326
327 return; // do not search anymore
328 }
329 }
330 pObject = aIter.Next();
331 }
332 }
333}
334
335void ScDocument::UpdateChart( const OUString& rChartName )
336{
338 return;
339 uno::Reference< chart2::XChartDocument > xChartDoc( GetChartByName( rChartName ) );
340 if (xChartDoc && (!mpShell || mpShell->IsEnableSetModified()))
341 {
342 try
343 {
344 uno::Reference< util::XModifiable > xModif( xChartDoc, uno::UNO_QUERY_THROW );
346 apTemporaryChartLock->AlsoLockThisChart( uno::Reference< frame::XModel >( xModif, uno::UNO_QUERY ) );
347 xModif->setModified( true );
348 }
349 catch ( uno::Exception& )
350 {
351 }
352 }
353
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 )
358 {
359 pChartListenerCollection->ChangeListening( rChartName, new ScRangeList );
360 }
361}
362
363void ScDocument::RestoreChartListener( const OUString& rName )
364{
366 return;
367
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).
370
371 uno::Reference< embed::XEmbeddedObject > xObject = FindOleObjectByName( rName );
372 if ( !xObject.is() )
373 return;
374
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;
380
381 const uno::Sequence<OUString> aRepresentations( xReceiver->getUsedRangeRepresentations() );
382 ScRangeListRef aRanges = new ScRangeList;
383 for ( const auto& rRepresentation : aRepresentations )
384 {
385 ScRange aRange;
387 if ( aRange.ParseAny( rRepresentation, *this, aDetails ) & ScRefFlags::VALID )
388 aRanges->push_back( aRange );
389 }
390
391 pChartListenerCollection->ChangeListening( rName, aRanges );
392}
393
395 SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
396 SCCOL nCol2, SCROW nRow2, SCTAB nTab2,
397 SCCOL nDx, SCROW nDy, SCTAB nDz )
398{
399 if (!mpDrawLayer)
400 return;
401
403 for (auto const& it : rListeners)
404 {
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 )
411 {
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();
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 )
426 {
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))) )
440 {
441 bDataChanged = true;
442 }
443 }
444 else
445 aNewRLR->push_back( rRange );
446 }
447 if ( bChanged )
448 {
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.
452
453 uno::Reference<embed::XEmbeddedObject> xIPObj =
454 FindOleObjectByName(pChartListener->GetName());
455
457
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() )
463 {
464 try
465 {
466 uno::Reference< chart2::XChartDocument > xChartDoc( xIPObj->getComponent(), uno::UNO_QUERY_THROW );
467 bInternalDataProvider = xChartDoc->hasInternalDataProvider();
468 }
469 catch ( uno::Exception& )
470 {
471 }
472 }
473 if ( bInternalDataProvider )
474 {
475 pChartListener->ChangeListening( aNewRLR, bDataChanged );
476 }
477 else
478 {
479 pChartListener->ChangeListening( new ScRangeList, bDataChanged );
480 }
481 }
482 }
483}
484
485void ScDocument::SetChartRangeList( std::u16string_view rChartName,
486 const ScRangeListRef& rNewRangeListRef )
487{
488 // called from ChartListener
489
490 if (!mpDrawLayer)
491 return;
492
493 for (SCTAB nTab=0; nTab< static_cast<SCTAB>(maTabs.size()) && maTabs[nTab]; nTab++)
494 {
495 SdrPage* pPage = mpDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
496 OSL_ENSURE(pPage,"Page ?");
497
498 SdrObjListIter aIter( pPage, SdrIterMode::DeepNoGroups );
499 SdrObject* pObject = aIter.Next();
500 while (pObject)
501 {
502 if ( pObject->GetObjIdentifier() == SdrObjKind::OLE2 &&
503 static_cast<SdrOle2Obj*>(pObject)->GetPersistName() == rChartName )
504 {
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() )
508 {
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 );
514
515 OUString sRangeStr;
516 rNewRangeListRef->Format( sRangeStr, ScRefFlags::RANGE_ABS_3D, *this, GetAddressConvention() );
517
518 lcl_SetChartParameters( xReceiver, sRangeStr, eDataRowSource, bHasCategories, bFirstCellAsLabel );
519
520 // don't modify pChartListenerCollection here, called from there
521 return;
522 }
523 }
524 pObject = aIter.Next();
525 }
526 }
527}
528
529bool ScDocument::HasData( SCCOL nCol, SCROW nRow, SCTAB nTab )
530{
531 if (ScTable* pTable = FetchTable(nTab) ; pTable && nCol < pTable->GetAllocatedColumnsCount())
532 return pTable->HasData(nCol, nRow);
533 return false;
534}
535
536uno::Reference< embed::XEmbeddedObject >
537 ScDocument::FindOleObjectByName( std::u16string_view rName )
538{
539 if (!mpDrawLayer)
540 return uno::Reference< embed::XEmbeddedObject >();
541
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)
544
545 sal_uInt16 nCount = mpDrawLayer->GetPageCount();
546 for (sal_uInt16 nTab=0; nTab<nCount; nTab++)
547 {
548 SdrPage* pPage = mpDrawLayer->GetPage(nTab);
549 OSL_ENSURE(pPage,"Page ?");
550
551 SdrObjListIter aIter( pPage, SdrIterMode::DeepNoGroups );
552 SdrObject* pObject = aIter.Next();
553 while (pObject)
554 {
555 if ( pObject->GetObjIdentifier() == SdrObjKind::OLE2 )
556 {
557 SdrOle2Obj * pOleObject ( dynamic_cast< SdrOle2Obj * >( pObject ));
558 if( pOleObject &&
559 pOleObject->GetPersistName() == rName )
560 {
561 return pOleObject->GetObjRef();
562 }
563 }
564 pObject = aIter.Next();
565 }
566 }
567
568 return uno::Reference< embed::XEmbeddedObject >();
569}
570
572{
574
576 if (!mpDrawLayer)
577 return;
578
579 for (SCTAB nTab=0; nTab< static_cast<SCTAB>(maTabs.size()); nTab++)
580 {
581 if (!maTabs[nTab])
582 continue;
583
584 SdrPage* pPage = mpDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
585 OSL_ENSURE(pPage,"Page ?");
586
587 if (!pPage)
588 continue;
589
590 SdrObjListIter aIter( pPage, SdrIterMode::DeepNoGroups );
592 pChartListenerCollection->getNonOleObjectNames();
593
594 for (SdrObject* pObject = aIter.Next(); pObject; pObject = aIter.Next())
595 {
596 if ( pObject->GetObjIdentifier() != SdrObjKind::OLE2 )
597 continue;
598
599 OUString aObjName = static_cast<SdrOle2Obj*>(pObject)->GetPersistName();
600 ScChartListener* pListener = pChartListenerCollection->findByName(aObjName);
601
602 if (pListener)
603 pListener->SetUsed(true);
604 else if (rNonOleObjects.count(aObjName) > 0)
605 {
606 // non-chart OLE object -> don't touch
607 }
608 else
609 {
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 );
615
616 // if the object is a chart2::XDataReceiver, we must attach as XDataProvider
617 if( xReceiver.is() &&
619 {
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.
624
625 // data provider
626 // number formats supplier
627
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
631 }
632
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)
637
638 rNonOleObjects.insert(aObjName);
639 }
640 }
641 }
642 // delete all that are not set SetUsed
643 pChartListenerCollection->FreeUnused();
644}
645
646void ScDocument::AddOLEObjectToCollection(const OUString& rName)
647{
650 pChartListenerCollection->getNonOleObjectNames();
651
652 rNonOleObjects.insert(rName);
653}
654
655/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SCTAB Tab() const
Definition: address.hxx:283
SCROW Row() const
Definition: address.hxx:274
SCCOL Col() const
Definition: address.hxx:279
static void GetChartRanges(const css::uno::Reference< css::chart2::XChartDocument > &xChartDoc, std::vector< OUString > &rRanges)
static void SetChartRanges(const css::uno::Reference< css::chart2::XChartDocument > &xChartDoc, const css::uno::Sequence< OUString > &rRanges)
static css::uno::Reference< css::chart2::XChartDocument > GetChartFromSdrObject(const SdrObject *pObject)
std::unordered_set< OUString > StringSetType
Definition: chartlis.hxx:126
std::map< OUString, std::unique_ptr< ScChartListener > > ListenersType
Definition: chartlis.hxx:125
void SetUsed(bool bFlg)
Definition: chartlis.hxx:101
void ChangeListening(const ScRangeListRef &rRangeListRef, bool bDirty)
Definition: chartlis.cxx:282
const OUString & GetName() const
Definition: chartlis.hxx:83
ScRangeListRef GetRangeList() const
Definition: chartlis.cxx:186
css::uno::Reference< css::chart2::XChartDocument > GetChartByName(std::u16string_view rChartName)
Definition: documen5.cxx:138
void AddOLEObjectToCollection(const OUString &rName)
Definition: documen5.cxx:646
bool bInDtorClear
Definition: document.hxx:515
SC_DLLPUBLIC ScTable * FetchTable(SCTAB nTab)
Definition: document.cxx:2509
SC_DLLPUBLIC void UpdateChartListenerCollection()
Definition: documen5.cxx:571
bool bChartListenerCollectionNeedsUpdate
Definition: document.hxx:511
SC_DLLPUBLIC formula::FormulaGrammar::AddressConvention GetAddressConvention() const
Definition: documen3.cxx:492
SC_DLLPUBLIC void GetChartRanges(std::u16string_view rChartName, std::vector< ScRangeList > &rRanges, const ScDocument &rSheetNameDoc)
Definition: documen5.cxx:168
TableContainer maTabs
Definition: document.hxx:378
SC_DLLPUBLIC bool HasData(SCCOL nCol, SCROW nRow, SCTAB nTab)
Definition: documen5.cxx:529
bool PastingDrawFromOtherDoc() const
Definition: document.hxx:2527
static bool IsChart(const SdrObject *pObject)
Definition: documen9.cxx:209
void UpdateChartArea(const OUString &rChartName, const ScRange &rNewArea, bool bColHeaders, bool bRowHeaders, bool bAdd)
Definition: documen5.cxx:130
std::unique_ptr< ScTemporaryChartLock > apTemporaryChartLock
Definition: document.hxx:384
void UpdateChart(const OUString &rName)
Definition: documen5.cxx:335
void UpdateChartRef(UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW nRow1, SCTAB nTab1, SCCOL nCol2, SCROW nRow2, SCTAB nTab2, SCCOL nDx, SCROW nDy, SCTAB nDz)
Definition: documen5.cxx:394
css::uno::Reference< css::embed::XEmbeddedObject > FindOleObjectByName(std::u16string_view rName)
Definition: documen5.cxx:537
void GetOldChartParameters(std::u16string_view rName, ScRangeList &rRanges, bool &rColHeaders, bool &rRowHeaders)
Definition: documen5.cxx:204
void SetChartRanges(std::u16string_view rChartName, const std::vector< ScRangeList > &rRanges)
Definition: documen5.cxx:185
std::unique_ptr< ScDrawLayer > mpDrawLayer
Definition: document.hxx:374
SfxObjectShell * mpShell
Definition: document.hxx:371
bool HasChartAtPoint(SCTAB nTab, const Point &rPos, OUString &rName)
Definition: documen5.cxx:100
void SetChartRangeList(std::u16string_view rChartName, const ScRangeListRef &rNewRangeListRef)
only assigns the new RangeList, no ChartListener or the like
Definition: documen5.cxx:485
void RestoreChartListener(const OUString &rName)
Definition: documen5.cxx:363
std::unique_ptr< ScChartListenerCollection > pChartListenerCollection
Definition: document.hxx:391
void Format(OUString &, ScRefFlags nFlags, const ScDocument &, formula::FormulaGrammar::AddressConvention eConv=formula::FormulaGrammar::CONV_OOO, sal_Unicode cDelimiter=0, bool bFullAddressNotation=false) const
Definition: rangelst.cxx:132
ScRefFlags Parse(std::u16string_view, const ScDocument &, formula::FormulaGrammar::AddressConvention eConv=formula::FormulaGrammar::CONV_OOO, SCTAB nDefaultTab=0, sal_Unicode cDelimiter=0)
Definition: rangelst.cxx:92
ScAddress aEnd
Definition: address.hxx:498
ScRefFlags ParseAny(const OUString &, const ScDocument &, const ScAddress::Details &rDetails=ScAddress::detailsOOOa1)
Definition: address.cxx:1733
ScAddress aStart
Definition: address.hxx:497
static ScRefUpdateRes Update(const ScDocument *pDoc, UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW nRow1, SCTAB nTab1, SCCOL nCol2, SCROW nRow2, SCTAB nTab2, SCCOL nDx, SCROW nDy, SCTAB nDz, SCCOL &theCol1, SCROW &theRow1, SCTAB &theTab1, SCCOL &theCol2, SCROW &theRow2, SCTAB &theTab2)
Definition: refupdat.cxx:188
SCCOL GetAllocatedColumnsCount() const
Definition: table.hxx:1164
static sal_Int32 GetEnumFromAny(const css::uno::Any &aAny)
Definition: miscuno.cxx:161
static bool GetBoolFromAny(const css::uno::Any &aAny)
Definition: miscuno.cxx:139
SdrObject * Next()
css::uno::Reference< css::embed::XEmbeddedObject > const & GetObjRef() const
const OUString & GetPersistName() const
bool IsEnableSetModified() const
css::uno::Reference< css::frame::XModel3 > GetModel() const
static bool TryRunningState(const css::uno::Reference< css::embed::XEmbeddedObject > &)
int nCount
static void lcl_GetChartParameters(const uno::Reference< chart2::XChartDocument > &xChartDoc, OUString &rRanges, chart::ChartDataRowSource &rDataRowSource, bool &rHasCategories, bool &rFirstCellAsLabel)
Definition: documen5.cxx:45
static void lcl_SetChartParameters(const uno::Reference< chart2::data::XDataReceiver > &xReceiver, const OUString &rRanges, chart::ChartDataRowSource eDataRowSource, bool bHasCategories, bool bFirstCellAsLabel)
Definition: documen5.cxx:76
EmbeddedObjectRef * pObject
UpdateRefMode
Definition: global.hxx:301
@ URM_INSDEL
Definition: global.hxx:302
int i
OUString aPropName
ScRefUpdateRes
Definition: refupdat.hxx:30
@ UR_INVALID
Some part of the reference became invalid.
Definition: refupdat.hxx:33
@ UR_NOTHING
Reference not affected, no change at all.
Definition: refupdat.hxx:31
sal_Int16 SCTAB
Definition: types.hxx:22
sal_Int16 SCCOL
Definition: types.hxx:21
sal_Int32 SCROW
Definition: types.hxx:17