sc/inc/drwlayer.hxx | 3 - sc/source/core/data/drwlayer.cxx | 117 +++++++++++++++++++-------------------- 2 files changed, 60 insertions(+), 60 deletions(-)
New commits: commit 4b862fc40dc61570b7fb79b29066f8ce260e467b Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Sat Mar 2 06:57:53 2024 +0100 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Tue Mar 5 09:31:35 2024 +0100 Simplify a bit Change-Id: I5022d82e556f7cfb09f0dee397d93dd7514a22e5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164202 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164396 diff --git a/sc/inc/drwlayer.hxx b/sc/inc/drwlayer.hxx index 6f1322b4b9d6..6bad650fd445 100644 --- a/sc/inc/drwlayer.hxx +++ b/sc/inc/drwlayer.hxx @@ -215,7 +215,8 @@ public: static ScDrawObjData* GetObjDataTab( SdrObject* pObj, SCTAB nTab ); /** Returns true, if the passed object is the caption of a cell note. */ - static bool IsNoteCaption( SdrObject* pObj ); + static bool IsNoteCaption(const ScDrawObjData* pData); + static bool IsNoteCaption(SdrObject* pObj) { return IsNoteCaption(GetObjData(pObj)); } /** Returns the object data, if the passed object is a cell note caption. */ static ScDrawObjData* GetNoteCaptionData( SdrObject* pObj, SCTAB nTab ); diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx index 04c7c008a4d6..b4fed97fc391 100644 --- a/sc/source/core/data/drwlayer.cxx +++ b/sc/source/core/data/drwlayer.cxx @@ -1788,70 +1788,73 @@ void ScDrawLayer::CopyToClip( ScDocument* pClipDoc, SCTAB nTab, const tools::Rec SdrObjListIter aIter( pSrcPage, SdrIterMode::Flat ); while (SdrObject* pOldObject = aIter.Next()) { + // do not copy internal objects (detective) and note captions + if (pOldObject->GetLayer() == SC_LAYER_INTERN) + continue; + + const ScDrawObjData* pObjData = ScDrawLayer::GetObjData(pOldObject); + if (IsNoteCaption(pObjData)) + continue; + // Catch objects where the object itself is inside the rectangle to be copied. bool bObjectInArea = rRange.Contains(pOldObject->GetCurrentBoundRect()); // Catch objects whose anchor is inside the rectangle to be copied. - const ScDrawObjData* pObjData = ScDrawLayer::GetObjData(pOldObject); - if (pObjData) - bObjectInArea = bObjectInArea || aClipRange.Contains(pObjData->maStart); - - // do not copy internal objects (detective) and note captions - if (bObjectInArea && pOldObject->GetLayer() != SC_LAYER_INTERN - && !IsNoteCaption(pOldObject)) + if (!bObjectInArea && pObjData) + bObjectInArea = aClipRange.Contains(pObjData->maStart); + if (!bObjectInArea) + continue; + + if (!pDestModel) { - if ( !pDestModel ) + pDestModel = pClipDoc->GetDrawLayer(); // does the document already have a drawing layer? + if (!pDestModel) { - pDestModel = pClipDoc->GetDrawLayer(); // does the document already have a drawing layer? - if ( !pDestModel ) - { - // allocate drawing layer in clipboard document only if there are objects to copy + // allocate drawing layer in clipboard document only if there are objects to copy - pClipDoc->InitDrawLayer(); //TODO: create contiguous pages - pDestModel = pClipDoc->GetDrawLayer(); - } - if (pDestModel) - pDestPage = pDestModel->GetPage( static_cast<sal_uInt16>(nTab) ); + pClipDoc->InitDrawLayer(); //TODO: create contiguous pages + pDestModel = pClipDoc->GetDrawLayer(); } + if (pDestModel) + pDestPage = pDestModel->GetPage(static_cast<sal_uInt16>(nTab)); + } - OSL_ENSURE( pDestPage, "no page" ); - if (pDestPage) + OSL_ENSURE(pDestPage, "no page"); + if (pDestPage) + { + // Clone to target SdrModel + rtl::Reference<SdrObject> pNewObject(pOldObject->CloneSdrObject(*pDestModel)); + uno::Reference< chart2::XChartDocument > xOldChart( ScChartHelper::GetChartFromSdrObject( pOldObject ) ); + if(!xOldChart.is())//#i110034# do not move charts as they lose all their data references otherwise { - // Clone to target SdrModel - rtl::Reference<SdrObject> pNewObject(pOldObject->CloneSdrObject(*pDestModel)); - uno::Reference< chart2::XChartDocument > xOldChart( ScChartHelper::GetChartFromSdrObject( pOldObject ) ); - if(!xOldChart.is())//#i110034# do not move charts as they lose all their data references otherwise + if (pObjData) { - if (pObjData) - { - // The object is anchored to cell. The position is determined by the start - // address. Copying into the clipboard does not change the anchor. - // ToDo: Adapt Offset relative to anchor cell size for cell anchored. - // ToDo: Adapt Offset and size for cell-anchored with resize objects. - // ToDo: Exclude object from resize if disallowed at object. - } - else - { - // The object is anchored to page. We make its position so, that the - // cell behind the object will have the same address in clipboard document as - // in source document. So we will be able to reconstruct the original cell - // address from position when pasting the object. - tools::Rectangle aObjRect = pOldObject->GetSnapRect(); - ScRange aPseudoAnchor - = pDoc->GetRange(nTab, aObjRect, true /*bHiddenAsZero*/); - tools::Rectangle aSourceCellRect - = GetCellRect(*pDoc, aPseudoAnchor.aStart, false /*bMergedCell*/); - tools::Rectangle aDestCellRect - = GetCellRect(*pClipDoc, aPseudoAnchor.aStart, false); - Point aMove = aDestCellRect.TopLeft() - aSourceCellRect.TopLeft(); - pNewObject->NbcMove(Size(aMove.getX(), aMove.getY())); - } + // The object is anchored to cell. The position is determined by the start + // address. Copying into the clipboard does not change the anchor. + // ToDo: Adapt Offset relative to anchor cell size for cell anchored. + // ToDo: Adapt Offset and size for cell-anchored with resize objects. + // ToDo: Exclude object from resize if disallowed at object. } + else + { + // The object is anchored to page. We make its position so, that the + // cell behind the object will have the same address in clipboard document as + // in source document. So we will be able to reconstruct the original cell + // address from position when pasting the object. + tools::Rectangle aObjRect = pOldObject->GetSnapRect(); + ScRange aPseudoAnchor = pDoc->GetRange(nTab, aObjRect, true /*bHiddenAsZero*/); + tools::Rectangle aSourceCellRect + = GetCellRect(*pDoc, aPseudoAnchor.aStart, false /*bMergedCell*/); + tools::Rectangle aDestCellRect + = GetCellRect(*pClipDoc, aPseudoAnchor.aStart, false); + Point aMove = aDestCellRect.TopLeft() - aSourceCellRect.TopLeft(); + pNewObject->NbcMove(Size(aMove.getX(), aMove.getY())); + } + } - pDestPage->InsertObject( pNewObject.get() ); + pDestPage->InsertObject(pNewObject.get()); - // no undo needed in clipboard document - // charts are not updated - } + // no undo needed in clipboard document + // charts are not updated } } } @@ -2892,16 +2895,15 @@ ScDrawObjData* ScDrawLayer::GetObjDataTab( SdrObject* pObj, SCTAB nTab ) return pData; } -bool ScDrawLayer::IsNoteCaption( SdrObject* pObj ) +bool ScDrawLayer::IsNoteCaption(const ScDrawObjData* pData) { - ScDrawObjData* pData = pObj ? GetObjData( pObj ) : nullptr; return pData && pData->meType == ScDrawObjData::CellNote; } ScDrawObjData* ScDrawLayer::GetNoteCaptionData( SdrObject* pObj, SCTAB nTab ) { - ScDrawObjData* pData = pObj ? GetObjDataTab( pObj, nTab ) : nullptr; - return (pData && pData->meType == ScDrawObjData::CellNote) ? pData : nullptr; + ScDrawObjData* pData = GetObjDataTab(pObj, nTab); + return IsNoteCaption(pData) ? pData : nullptr; } ScMacroInfo* ScDrawLayer::GetMacroInfo( SdrObject* pObj, bool bCreate ) commit c3b5f1a25a7436841307da79474749830a055490 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Sat Mar 2 06:57:24 2024 +0100 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Tue Mar 5 09:31:26 2024 +0100 Simplify a bit Change-Id: I5909dfc0f19b13d53d370f78a5e2853b95f0c1a9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164201 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164402 diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx index 25dfc5c7d6cc..04c7c008a4d6 100644 --- a/sc/source/core/data/drwlayer.cxx +++ b/sc/source/core/data/drwlayer.cxx @@ -1786,8 +1786,7 @@ void ScDrawLayer::CopyToClip( ScDocument* pClipDoc, SCTAB nTab, const tools::Rec ScRange aClipRange = lcl_getClipRangeFromClipDoc(pClipDoc, nTab); SdrObjListIter aIter( pSrcPage, SdrIterMode::Flat ); - SdrObject* pOldObject = aIter.Next(); - while (pOldObject) + while (SdrObject* pOldObject = aIter.Next()) { // Catch objects where the object itself is inside the rectangle to be copied. bool bObjectInArea = rRange.Contains(pOldObject->GetCurrentBoundRect()); @@ -1854,8 +1853,6 @@ void ScDrawLayer::CopyToClip( ScDocument* pClipDoc, SCTAB nTab, const tools::Rec // charts are not updated } } - - pOldObject = aIter.Next(); } }