diff options
author | Dennis Francis <dennis.francis@collabora.co.uk> | 2017-07-17 12:32:02 +0530 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2017-07-19 20:07:40 +0200 |
commit | 4d783c45062d030d278c076d7817b9589fa77d91 (patch) | |
tree | 7cea34783d8bc026c74f0297e92efaf38218c28e | |
parent | d3d9292a0fb414e6721b2f3b12b7e283caed946d (diff) |
tdf#108881 : do not assume that chart objects always...
...have data ranges associated with it. Empty charts do not
have data ranges. Reverts the part of
c55d52262ea1d5f869a9528fd051ee19e687f1cc
which makes this assumption.
Matching test cases (in uitest) coming up soon in another commit.
Change-Id: I60f0f03a8c937ecfdff95047bdfeeb7733eff4a4
Reviewed-on: https://gerrit.libreoffice.org/40057
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Eike Rathke <erack@redhat.com>
-rw-r--r-- | sc/source/ui/view/drawvie4.cxx | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/sc/source/ui/view/drawvie4.cxx b/sc/source/ui/view/drawvie4.cxx index 6c567dcc080a..d7a2fb9d377c 100644 --- a/sc/source/ui/view/drawvie4.cxx +++ b/sc/source/ui/view/drawvie4.cxx @@ -198,41 +198,44 @@ void getRangeFromErrorBar(const uno::Reference< chart2::XChartDocument >& rChart } } -void getRangeFromOle2Object(const SdrOle2Obj& rObj, std::vector<OUString>& rRangeRep) +bool getRangeFromOle2Object(const SdrOle2Obj& rObj, std::vector<OUString>& rRangeRep) { if (!rObj.IsChart()) // not a chart object. - return; + return false; uno::Reference<embed::XEmbeddedObject> xObj = rObj.GetObjRef(); if (!xObj.is()) - return; + return false; uno::Reference<embed::XComponentSupplier> xCompSupp(xObj, uno::UNO_QUERY); if (!xCompSupp.is()) - return; + return false; uno::Reference<chart2::XChartDocument> xChartDoc(xCompSupp->getComponent(), uno::UNO_QUERY); if (!xChartDoc.is()) - return; + return false; if(xChartDoc->hasInternalDataProvider()) - return; + return true; getRangeFromErrorBar(xChartDoc, rRangeRep); uno::Reference<chart2::data::XDataSource> xDataSource(xChartDoc, uno::UNO_QUERY); if (!xDataSource.is()) - return; + return true; // Get all data sources used in this chart. getRangeFromDataSource(xDataSource, rRangeRep); + + return true; } // Get all cell ranges that are referenced by the selected chart objects. -void getChartSourceRanges(ScDocument* pDoc, const SdrMarkList& rObjs, std::vector<ScRange>& rRanges) +bool getChartSourceRanges(ScDocument* pDoc, const SdrMarkList& rObjs, std::vector<ScRange>& rRanges) { std::vector<OUString> aRangeReps; + bool bAnyOle = false, bRet = false; for (size_t i = 0, n = rObjs.GetMarkCount(); i < n; ++i) { const SdrMark* pMark = rObjs.GetMark(i); @@ -246,7 +249,8 @@ void getChartSourceRanges(ScDocument* pDoc, const SdrMarkList& rObjs, std::vecto switch (pObj->GetObjIdentifier()) { case OBJ_OLE2: - getRangeFromOle2Object(static_cast<const SdrOle2Obj&>(*pObj), aRangeReps); + bRet = getRangeFromOle2Object(static_cast<const SdrOle2Obj&>(*pObj), aRangeReps); + bAnyOle = bAnyOle || bRet; break; case OBJ_GRUP: { @@ -256,7 +260,8 @@ void getChartSourceRanges(ScDocument* pDoc, const SdrMarkList& rObjs, std::vecto if (pSubObj->GetObjIdentifier() != OBJ_OLE2) continue; - getRangeFromOle2Object(static_cast<const SdrOle2Obj&>(*pSubObj), aRangeReps); + bRet = getRangeFromOle2Object(static_cast<const SdrOle2Obj&>(*pSubObj), aRangeReps); + bAnyOle = bAnyOle || bRet; } } @@ -280,6 +285,8 @@ void getChartSourceRanges(ScDocument* pDoc, const SdrMarkList& rObjs, std::vecto else if (aAddr.Parse(*it, pDoc, pDoc->GetAddressConvention()) & ScRefFlags::VALID) rRanges.push_back(aAddr); } + + return bAnyOle; } class InsertTabIndex @@ -351,11 +358,11 @@ void ScDrawView::DoCopy() { const SdrMarkList& rMarkList = GetMarkedObjectList(); std::vector<ScRange> aRanges; - getChartSourceRanges(pDoc, rMarkList, aRanges); + bool bAnyOle = getChartSourceRanges(pDoc, rMarkList, aRanges); // update ScGlobal::xDrawClipDocShellRef - ScDrawLayer::SetGlobalDrawPersist( ScTransferObj::SetDrawClipDoc(!aRanges.empty()) ); - if (ScGlobal::xDrawClipDocShellRef.is()) + ScDrawLayer::SetGlobalDrawPersist( ScTransferObj::SetDrawClipDoc( bAnyOle ) ); + if (ScGlobal::xDrawClipDocShellRef.is() && !aRanges.empty()) { // Copy data referenced by the chart objects to the draw clip // document. We need to do this before GetMarkedObjModel() below. |