[Libreoffice-commits] core.git: sc/source
Samuel Mehrbrodt
Samuel.Mehrbrodt at cib.de
Thu Mar 22 15:47:15 UTC 2018
sc/source/core/data/drwlayer.cxx | 54 +++++++++++++++++++++++++++------------
1 file changed, 38 insertions(+), 16 deletions(-)
New commits:
commit d8b7119859897fa98b6588e2426a13fbd51cf3dd
Author: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
Date: Thu Mar 22 09:15:11 2018 +0100
tdf#116510 Copy cell anchored images too when copying cells
Change-Id: Ia64100a00e65b7871c44a9b4700ca86782897a8e
Reviewed-on: https://gerrit.libreoffice.org/51725
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx
index c0bdcde30314..6a476c4d535e 100644
--- a/sc/source/core/data/drwlayer.cxx
+++ b/sc/source/core/data/drwlayer.cxx
@@ -222,6 +222,23 @@ static void lcl_ReverseTwipsToMM( tools::Rectangle& rRect )
rRect.SetBottom( HmmToTwips(rRect.Bottom()) );
}
+static ScRange lcl_getClipRangeFromClipDoc(ScDocument* pClipDoc, SCTAB nClipTab)
+{
+ if (!pClipDoc)
+ return ScRange();
+
+ SCCOL nClipStartX;
+ SCROW nClipStartY;
+ SCCOL nClipEndX;
+ SCROW nClipEndY;
+ pClipDoc->GetClipStart(nClipStartX, nClipStartY);
+ pClipDoc->GetClipArea(nClipEndX, nClipEndY, true);
+ nClipEndX = nClipEndX + nClipStartX;
+ nClipEndY += nClipStartY; // GetClipArea returns the difference
+
+ return ScRange(nClipStartX, nClipStartY, nClipTab, nClipEndX, nClipEndY, nClipTab);
+}
+
ScDrawLayer::ScDrawLayer( ScDocument* pDocument, const OUString& rName ) :
FmFormModel( !utl::ConfigManager::IsFuzzing() ? SvtPathOptions().GetPalettePath() : OUString(),
nullptr, // SfxItemPool* Pool
@@ -1443,8 +1460,18 @@ void ScDrawLayer::CopyToClip( ScDocument* pClipDoc, SCTAB nTab, const tools::Rec
while (pOldObject)
{
tools::Rectangle aObjRect = pOldObject->GetCurrentBoundRect();
+
+ bool bObjectInArea = rRange.IsInside(aObjRect);
+ const ScDrawObjData* pObjData = ScDrawLayer::GetObjData(pOldObject);
+ if (pObjData)
+ {
+ ScRange aClipRange = lcl_getClipRangeFromClipDoc(pClipDoc, nTab);
+ bObjectInArea = bObjectInArea || aClipRange.In(pObjData->maStart);
+ }
+
// do not copy internal objects (detective) and note captions
- if ( rRange.IsInside( aObjRect ) && (pOldObject->GetLayer() != SC_LAYER_INTERN) && !IsNoteCaption( pOldObject ) )
+ if (bObjectInArea && pOldObject->GetLayer() != SC_LAYER_INTERN
+ && !IsNoteCaption(pOldObject))
{
if ( !pDestModel )
{
@@ -1627,7 +1654,16 @@ void ScDrawLayer::CopyFromClip( ScDrawLayer* pClipModel, SCTAB nSourceTab, const
{
tools::Rectangle aObjRect = pOldObject->GetCurrentBoundRect();
// do not copy internal objects (detective) and note captions
- if ( rSourceRange.IsInside( aObjRect ) && (pOldObject->GetLayer() != SC_LAYER_INTERN) && !IsNoteCaption( pOldObject ) )
+
+ SCTAB nClipTab = bRestoreDestTabName ? nDestTab : nSourceTab;
+ ScRange aClipRange = lcl_getClipRangeFromClipDoc(pClipDoc, nClipTab);
+
+ bool bObjectInArea = rSourceRange.IsInside(aObjRect);
+ const ScDrawObjData* pObjData = ScDrawLayer::GetObjData(pOldObject);
+ if (pObjData) // Consider images anchored to the copied cell
+ bObjectInArea = bObjectInArea || aClipRange.In(pObjData->maStart);
+ if (bObjectInArea && (pOldObject->GetLayer() != SC_LAYER_INTERN)
+ && !IsNoteCaption(pOldObject))
{
SdrObject* pNewObject = pOldObject->Clone();
pNewObject->SetModel(this);
@@ -1672,22 +1708,8 @@ void ScDrawLayer::CopyFromClip( ScDrawLayer* pClipModel, SCTAB nSourceTab, const
if( !aRangesVector.empty() )
{
bool bInSourceRange = false;
- ScRange aClipRange;
if ( pClipDoc )
{
- SCCOL nClipStartX;
- SCROW nClipStartY;
- SCCOL nClipEndX;
- SCROW nClipEndY;
- pClipDoc->GetClipStart( nClipStartX, nClipStartY );
- pClipDoc->GetClipArea( nClipEndX, nClipEndY, true );
- nClipEndX = nClipEndX + nClipStartX;
- nClipEndY += nClipStartY; // GetClipArea returns the difference
-
- SCTAB nClipTab = bRestoreDestTabName ? nDestTab : nSourceTab;
- aClipRange = ScRange( nClipStartX, nClipStartY, nClipTab,
- nClipEndX, nClipEndY, nClipTab );
-
bInSourceRange = lcl_IsAllInRange( aRangesVector, aClipRange );
}
More information about the Libreoffice-commits
mailing list