include/svx/svdpage.hxx       |    2 -
 sd/source/ui/inc/sdxfer.hxx   |    5 ++++
 sd/source/ui/view/sdview2.cxx |    3 ++
 sd/source/ui/view/sdview3.cxx |   48 +++++++++++++++++++++---------------------
 4 files changed, 33 insertions(+), 25 deletions(-)

New commits:
commit 11f7f34b90151b6cb01754a35bad66061322a119
Author:     Andreas Heinisch <andreas.heini...@yahoo.de>
AuthorDate: Thu Mar 20 02:03:36 2025 +0100
Commit:     Andreas Heinisch <andreas.heini...@yahoo.de>
CommitDate: Fri Mar 21 08:52:31 2025 +0100

    tdf#118171 - Snap rectangles of objects without line width
    
    Change-Id: I10d984438826362035add494e0a2431824e36519
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183142
    Reviewed-by: Andreas Heinisch <andreas.heini...@yahoo.de>
    Tested-by: Jenkins

diff --git a/include/svx/svdpage.hxx b/include/svx/svdpage.hxx
index 0ad088889206..3d9c60401544 100644
--- a/include/svx/svdpage.hxx
+++ b/include/svx/svdpage.hxx
@@ -124,7 +124,7 @@ public:
 
     void SetSdrObjListRectsDirty();
 
-    SAL_DLLPRIVATE const tools::Rectangle& GetAllObjSnapRect() const;
+    const tools::Rectangle& GetAllObjSnapRect() const;
     const tools::Rectangle& GetAllObjBoundRect() const;
 
     /// reformat all text objects, e.g. when changing printer
diff --git a/sd/source/ui/inc/sdxfer.hxx b/sd/source/ui/inc/sdxfer.hxx
index b93ef331f1d4..3a1e599856e1 100644
--- a/sd/source/ui/inc/sdxfer.hxx
+++ b/sd/source/ui/inc/sdxfer.hxx
@@ -58,6 +58,10 @@ public:
     void                            SetStartPos( const Point& rStartPos ) { 
maStartPos = rStartPos; }
     const Point&                    GetStartPos() const { return maStartPos; }
 
+    // tdf#118171 - snap rectangles of objects without line width
+    void SetBoundStartPos(const Point& rBoundStartPos) { maBoundStartPos = 
rBoundStartPos; }
+    const Point& GetBoundStartPos() const { return maBoundStartPos; }
+
     void                            SetInternalMove( bool bSet ) { 
mbInternalMove = bSet; }
     bool                            IsInternalMove() const { return 
mbInternalMove; }
 
@@ -126,6 +130,7 @@ private:
     std::unique_ptr<ImageMap>       mpImageMap;
     ::tools::Rectangle                       maVisArea;
     Point                           maStartPos;
+    Point                           maBoundStartPos;
     bool                            mbInternalMove               : 1;
     bool                            mbOwnDocument                : 1;
     bool                            mbOwnView                    : 1;
diff --git a/sd/source/ui/view/sdview2.cxx b/sd/source/ui/view/sdview2.cxx
index b571625484f0..1ed27775501b 100644
--- a/sd/source/ui/view/sdview2.cxx
+++ b/sd/source/ui/view/sdview2.cxx
@@ -92,6 +92,8 @@ css::uno::Reference< css::datatransfer::XTransferable > 
View::CreateClipboardDat
     // #112978# need to use GetAllMarkedBoundRect instead of GetAllMarkedRect 
to get
     // fat lines correctly
     const ::tools::Rectangle                 aMarkRect( 
GetAllMarkedBoundRect() );
+    // tdf#118171 - snap rectangles of objects without line width
+    const ::tools::Rectangle aMarkBoundRect(GetAllMarkedRect());
     std::unique_ptr<TransferableObjectDescriptor> pObjDesc(new 
TransferableObjectDescriptor);
     SdrOle2Obj*                     pSdrOleObj = nullptr;
     SdrPageView*                    pPgView = GetSdrPageView();
@@ -135,6 +137,7 @@ css::uno::Reference< css::datatransfer::XTransferable > 
View::CreateClipboardDat
     pObjDesc->maSize = aMarkRect.GetSize();
 
     pTransferable->SetStartPos( aMarkRect.TopLeft() );
+    pTransferable->SetBoundStartPos(aMarkBoundRect.TopLeft());
     pTransferable->SetObjectDescriptor( std::move(pObjDesc) );
     pTransferable->CopyToClipboard( mpViewSh->GetActiveWindow() );
 
diff --git a/sd/source/ui/view/sdview3.cxx b/sd/source/ui/view/sdview3.cxx
index 37455c28b1bb..fa3d7c3d2e8a 100644
--- a/sd/source/ui/view/sdview3.cxx
+++ b/sd/source/ui/view/sdview3.cxx
@@ -652,11 +652,11 @@ bool View::InsertData( const TransferableDataHelper& 
rDataHelper,
 
             pWorkPage->SetSdrObjListRectsDirty();
 
-            // #i120393# Clipboard data uses full object geometry range
-            const Size aSize( pWorkPage->GetAllObjBoundRect().GetSize() );
+            // tdf#118171 - snap rectangles of objects without line width
+            const Size aSize(pWorkPage->GetAllObjSnapRect().GetSize());
 
-            maDropPos.setX( pOwnData->GetStartPos().X() + ( aSize.Width() >> 1 
) );
-            maDropPos.setY( pOwnData->GetStartPos().Y() + ( aSize.Height() >> 
1 ) );
+            maDropPos.setX( pOwnData->GetBoundStartPos().X() + ( aSize.Width() 
>> 1 ) );
+            maDropPos.setY( pOwnData->GetBoundStartPos().Y() + ( 
aSize.Height() >> 1 ) );
 
             // delete pages, that are not of any interest for us
             for( ::tools::Long i = pWorkModel->GetPageCount() - 1; i >= 0; i-- 
)
@@ -838,11 +838,11 @@ bool View::InsertData( const TransferableDataHelper& 
rDataHelper,
 
                     if( pOwnData )
                     {
-                        // #i120393# Clipboard data uses full object geometry 
range
-                        const Size aSize( 
pWorkPage->GetAllObjBoundRect().GetSize() );
+                        // tdf#118171 - snap rectangles of objects without 
line width
+                        const Size 
aSize(pWorkPage->GetAllObjSnapRect().GetSize());
 
-                        maDropPos.setX( pOwnData->GetStartPos().X() + ( 
aSize.Width() >> 1 ) );
-                        maDropPos.setY( pOwnData->GetStartPos().Y() + ( 
aSize.Height() >> 1 ) );
+                        maDropPos.setX( pOwnData->GetBoundStartPos().X() + ( 
aSize.Width() >> 1 ) );
+                        maDropPos.setY( pOwnData->GetBoundStartPos().Y() + ( 
aSize.Height() >> 1 ) );
                     }
 
                     bReturn = Paste(*pModel, maDropPos, pPage, nPasteOptions);
@@ -912,11 +912,11 @@ bool View::InsertData( const TransferableDataHelper& 
rDataHelper,
 
                     if( pOwnData )
                     {
-                        // #i120393# Clipboard data uses full object geometry 
range
-                        const Size aSize( 
pWorkPage->GetAllObjBoundRect().GetSize() );
+                        // tdf#118171 - snap rectangles of objects without 
line width
+                        const Size 
aSize(pWorkPage->GetAllObjSnapRect().GetSize());
 
-                        maDropPos.setX( pOwnData->GetStartPos().X() + ( 
aSize.Width() >> 1 ) );
-                        maDropPos.setY( pOwnData->GetStartPos().Y() + ( 
aSize.Height() >> 1 ) );
+                        maDropPos.setX( pOwnData->GetBoundStartPos().X() + ( 
aSize.Width() >> 1 ) );
+                        maDropPos.setY( pOwnData->GetBoundStartPos().Y() + ( 
aSize.Height() >> 1 ) );
                     }
 
                     // delete pages, that are not of any interest for us
@@ -1238,11 +1238,11 @@ bool View::InsertData( const TransferableDataHelper& 
rDataHelper,
 
                 pWorkPage->SetSdrObjListRectsDirty();
 
-                // #i120393# Clipboard data uses full object geometry range
-                const Size aSize( pWorkPage->GetAllObjBoundRect().GetSize() );
+                // tdf#118171 - snap rectangles of objects without line width
+                const Size aSize(pWorkPage->GetAllObjSnapRect().GetSize());
 
-                aInsertPos.setX( pOwnData->GetStartPos().X() + ( aSize.Width() 
>> 1 ) );
-                aInsertPos.setY( pOwnData->GetStartPos().Y() + ( 
aSize.Height() >> 1 ) );
+                aInsertPos.setX( pOwnData->GetBoundStartPos().X() + ( 
aSize.Width() >> 1 ) );
+                aInsertPos.setY( pOwnData->GetBoundStartPos().Y() + ( 
aSize.Height() >> 1 ) );
             }
 
             // restrict movement to WorkArea
@@ -1270,11 +1270,11 @@ bool View::InsertData( const TransferableDataHelper& 
rDataHelper,
 
             pWorkPage->SetSdrObjListRectsDirty();
 
-            // #i120393# Clipboard data uses full object geometry range
-            const Size aSize( pWorkPage->GetAllObjBoundRect().GetSize() );
+            // tdf#118171 - snap rectangles of objects without line width
+            const Size aSize(pWorkPage->GetAllObjSnapRect().GetSize());
 
-            aInsertPos.setX( pOwnData->GetStartPos().X() + ( aSize.Width() >> 
1 ) );
-            aInsertPos.setY( pOwnData->GetStartPos().Y() + ( aSize.Height() >> 
1 ) );
+            aInsertPos.setX( pOwnData->GetBoundStartPos().X() + ( 
aSize.Width() >> 1 ) );
+            aInsertPos.setY( pOwnData->GetBoundStartPos().Y() + ( 
aSize.Height() >> 1 ) );
         }
 
         bReturn = InsertMetaFile( rDataHelper, aInsertPos, pImageMap.get(), 
nFormat == SotClipboardFormatId::NONE );
@@ -1319,11 +1319,11 @@ bool View::InsertData( const TransferableDataHelper& 
rDataHelper,
 
                 pWorkPage->SetSdrObjListRectsDirty();
 
-                // #i120393# Clipboard data uses full object geometry range
-                const Size aSize( pWorkPage->GetAllObjBoundRect().GetSize() );
+                // tdf#118171 - snap rectangles of objects without line width
+                const Size aSize(pWorkPage->GetAllObjSnapRect().GetSize());
 
-                aInsertPos.setX( pOwnData->GetStartPos().X() + ( aSize.Width() 
>> 1 ) );
-                aInsertPos.setY( pOwnData->GetStartPos().Y() + ( 
aSize.Height() >> 1 ) );
+                aInsertPos.setX( pOwnData->GetBoundStartPos().X() + ( 
aSize.Width() >> 1 ) );
+                aInsertPos.setY( pOwnData->GetBoundStartPos().Y() + ( 
aSize.Height() >> 1 ) );
             }
 
             // restrict movement to WorkArea

Reply via email to