editeng/source/items/paperinf.cxx |   12 +++++++++
 include/editeng/paperinf.hxx      |    4 +++
 include/svx/Border.hxx            |   15 +++++++++++
 include/svx/svdobj.hxx            |    7 +++--
 include/svx/svdpage.hxx           |    5 ---
 sd/source/core/drawdoc2.cxx       |   32 ++++++++++++-------------
 svx/source/svdraw/svdobj.cxx      |   48 ++++++++++++++++++++++----------------
 svx/source/svdraw/svdpage.cxx     |   21 +++++++++-------
 sw/source/core/draw/dcontact.cxx  |    4 ---
 9 files changed, 95 insertions(+), 53 deletions(-)

New commits:
commit a8c8554a22f58b06bde546ef0959a18ec859bedd
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Wed Feb 8 10:42:19 2023 +0900
Commit:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
CommitDate: Sat May 31 08:41:17 2025 +0200

    use Range2DLWrap for "OutRectangle" in SdrObject
    
    Change-Id: I243b44a84bc09991744009ae24ac7657d493c5cf

diff --git a/include/svx/Border.hxx b/include/svx/Border.hxx
index 2c6b251c4c62..cbf697c59f6e 100644
--- a/include/svx/Border.hxx
+++ b/include/svx/Border.hxx
@@ -67,6 +67,12 @@ public:
     tools::Long upperUnit() const { return maUpper.as(meUnit); }
     tools::Long lowerUnit() const { return maLower.as(meUnit); }
 
+    bool operator==(Border const& other) const
+    {
+        return maLeft == other.maLeft && maRight == other.maRight && maUpper 
== other.maUpper
+               && maLower == other.maLower;
+    }
+
     tools::Rectangle toToolsRect() const
     {
         return tools::Rectangle(leftUnit(), upperUnit(), rightUnit(), 
lowerUnit());
diff --git a/include/svx/svdobj.hxx b/include/svx/svdobj.hxx
index 297ee9530a61..7bb597b60415 100644
--- a/include/svx/svdobj.hxx
+++ b/include/svx/svdobj.hxx
@@ -35,6 +35,7 @@
 #include <tools/link.hxx>
 #include <tools/gen.hxx>
 #include <unotools/resmgr.hxx>
+#include <basegfx/units/Range2DLWrap.hxx>
 
 #include <unordered_set>
 
@@ -870,13 +871,15 @@ public:
     void ForceMetricToItemPoolMetric(basegfx::B2DPolyPolygon& rPolyPolygon) 
const noexcept;
 
 protected:
-    const tools::Rectangle& getOutRectangle() const;
+    tools::Rectangle const& getOutRectangle() const;
+    bool isOutRectangleEmpty() const;
     void setOutRectangleConst(tools::Rectangle const& rRectangle) const; // 
need to do something about this
     void setOutRectangle(tools::Rectangle const& rRectangle);
     void resetOutRectangle();
     void moveOutRectangle(sal_Int32 nXDelta, sal_Int32 nYDelta);
 
-    mutable tools::Rectangle m_aOutRect;     // surrounding rectangle for 
Paint (incl. LineWidth, ...)
+    mutable gfx::Range2DLWrap m_aOutterRange; // surrounding rectangle for 
Paint (incl. LineWidth, ...)
+
     Point                       m_aAnchor;      // anchor position (Writer)
     SdrObjUserCall*             m_pUserCall;
     std::unique_ptr<SdrObjPlusData>
diff --git a/include/svx/svdpage.hxx b/include/svx/svdpage.hxx
index df3a32acf086..72c0c4a11ae4 100644
--- a/include/svx/svdpage.hxx
+++ b/include/svx/svdpage.hxx
@@ -522,10 +522,7 @@ public:
         return maBorder;
     }
 
-    virtual void setBorder(svx::Border const& rBorder)
-    {
-        maBorder = rBorder;
-    }
+    virtual void setBorder(svx::Border const& rBorder);
 
     virtual void  SetBorder(sal_Int32 nLeft, sal_Int32 nUpper, sal_Int32 
nRight, sal_Int32 Lower);
     virtual void  SetLeftBorder(sal_Int32 nBorder);
diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx
index 4eb5146a0c0e..06900bb082f2 100644
--- a/svx/source/svdraw/svdobj.cxx
+++ b/svx/source/svdraw/svdobj.cxx
@@ -32,6 +32,7 @@
 #include <basegfx/polygon/b2dpolygontools.hxx>
 #include <basegfx/polygon/b2dpolypolygoncutter.hxx>
 #include <basegfx/polygon/b2dpolypolygontools.hxx>
+#include <basegfx/units/Range2DLWrap.hxx>
 #include <basegfx/range/b2drange.hxx>
 #include <drawinglayer/processor2d/contourextractor2d.hxx>
 #include <drawinglayer/processor2d/linegeometryextractor2d.hxx>
@@ -952,13 +953,9 @@ void SdrObject::SetNavigationPosition (const sal_uInt32 
nNewPosition)
 // GetCurrentBoundRect().
 const tools::Rectangle& SdrObject::GetCurrentBoundRect() const
 {
-    auto const& rRectangle = getOutRectangle();
-    if (rRectangle.IsEmpty())
-    {
-        const_cast< SdrObject* >(this)->RecalcBoundRect();
-    }
-
-    return rRectangle;
+    if (isOutRectangleEmpty())
+        const_cast<SdrObject*>(this)->RecalcBoundRect();
+    return getOutRectangle();
 }
 
 // To have a possibility to get the last calculated BoundRect e.g for producing
@@ -996,13 +993,12 @@ void SdrObject::RecalcBoundRect()
 
     if (!aRange.isEmpty())
     {
-        tools::Rectangle aNewRectangle(
-            tools::Long(floor(aRange.getMinX())),
-            tools::Long(floor(aRange.getMinY())),
-            tools::Long(ceil(aRange.getMaxX())),
-            tools::Long(ceil(aRange.getMaxY())));
-        setOutRectangle(aNewRectangle);
-        return;
+        const basegfx::B2DRange aRoundedRange(
+            std::floor(aRange.getMinX()),
+            std::floor(aRange.getMinY()),
+            std::ceil(aRange.getMaxX()),
+            std::ceil(aRange.getMaxY()));
+        m_aOutterRange = gfx::Range2DLWrap::create(aRoundedRange, 
getSdrModelFromSdrObject().getUnit());
     }
 }
 
@@ -3181,27 +3177,41 @@ void 
SdrObject::ForceMetricToItemPoolMetric(basegfx::B2DPolyPolygon& rPolyPolygo
 
 const tools::Rectangle& SdrObject::getOutRectangle() const
 {
-    return m_aOutRect;
+    return m_aOutterRange.toToolsRect();
+}
+
+bool SdrObject::isOutRectangleEmpty() const
+{
+    return getOutRectangle().IsEmpty();
 }
 
 void SdrObject::setOutRectangleConst(tools::Rectangle const& rRectangle) const
 {
-    m_aOutRect = rRectangle;
+    auto eUnit = getSdrModelFromSdrObject().getUnit();
+    m_aOutterRange = gfx::Range2DLWrap::create(rRectangle, eUnit);
 }
 
 void SdrObject::setOutRectangle(tools::Rectangle const& rRectangle)
 {
-    m_aOutRect = rRectangle;
+    auto eUnit = getSdrModelFromSdrObject().getUnit();
+    m_aOutterRange = gfx::Range2DLWrap::create(rRectangle, eUnit);
 }
 
 void SdrObject::resetOutRectangle()
 {
-    m_aOutRect = tools::Rectangle();
+    m_aOutterRange.reset();
 }
 
 void SdrObject::moveOutRectangle(sal_Int32 nXDelta, sal_Int32 nYDelta)
 {
-    m_aOutRect.Move(nXDelta, nYDelta);
+    if (nXDelta == 0 && nYDelta == 0)
+        return;
+
+    auto eUnit = getSdrModelFromSdrObject().getUnit();
+    auto xDelta = gfx::Length::from(eUnit, nXDelta);
+    auto yDelta = gfx::Length::from(eUnit, nYDelta);
+
+    m_aOutterRange.shift(xDelta, yDelta);
 }
 
 E3dScene* DynCastE3dScene(SdrObject* pObj)
diff --git a/svx/source/svdraw/svdpage.cxx b/svx/source/svdraw/svdpage.cxx
index f5d4ed57c4fa..6ca2cac9eeef 100644
--- a/svx/source/svdraw/svdpage.cxx
+++ b/svx/source/svdraw/svdpage.cxx
@@ -1431,16 +1431,11 @@ rtl::Reference<SdrPage> SdrPage::CloneSdrPage(SdrModel& 
rTargetModel) const
 
 void SdrPage::setSize(gfx::Size2DLWrap const& rSize)
 {
-    bool bChanged = false;
-
-    if (maSize != rSize)
-    {
-        maSize = rSize;
-        bChanged = true;
-    }
+    if (maSize == rSize)
+        return;
 
-    if (bChanged)
-        SetChanged();
+    maSize = rSize;
+    SetChanged();
 }
 
 void SdrPage::SetOrientation(Orientation eOri)
@@ -1464,6 +1459,14 @@ Orientation SdrPage::GetOrientation() const
     return Orientation::Portrait;
 }
 
+void SdrPage::setBorder(svx::Border const& rBorder)
+{
+    if (maBorder == rBorder)
+        return;
+
+    maBorder = rBorder;
+    SetChanged();
+}
 
 void  SdrPage::SetBorder(sal_Int32 nLeft, sal_Int32 nUpper, sal_Int32 nRight, 
sal_Int32 nLower)
 {
diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx
index 7b735e37439b..44a4de33e203 100644
--- a/sw/source/core/draw/dcontact.cxx
+++ b/sw/source/core/draw/dcontact.cxx
@@ -2463,10 +2463,8 @@ void SwDrawVirtObj::NbcSetAnchorPos(const Point& rPnt)
 
 const tools::Rectangle& SwDrawVirtObj::GetCurrentBoundRect() const
 {
-    if (getOutRectangle().IsEmpty())
-    {
+    if (isOutRectangleEmpty())
         const_cast<SwDrawVirtObj*>(this)->RecalcBoundRect();
-    }
 
     return getOutRectangle();
 }
commit 181d6f15320e1f74e074d99feaad1cb193e78daf
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Wed Oct 26 20:21:37 2022 +0200
Commit:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
CommitDate: Sat May 31 08:36:11 2025 +0200

    svx: change PaperInfo to return gfx::Length paper sizes
    
    Change-Id: Ie99a748ab9282893a852278be9793f7379522541

diff --git a/editeng/source/items/paperinf.cxx 
b/editeng/source/items/paperinf.cxx
index 86401e63f387..47dd992b4f02 100644
--- a/editeng/source/items/paperinf.cxx
+++ b/editeng/source/items/paperinf.cxx
@@ -39,6 +39,12 @@ Size SvxPaperInfo::GetPaperSize( Paper ePaper, MapUnit eUnit 
)
         : OutputDevice::LogicToLogic(aRet, MapMode(MapUnit::Map100thMM), 
MapMode(eUnit));
 }
 
+gfx::Size2DLWrap SvxPaperInfo::getPaperSize(Paper ePaper)
+{
+    PaperInfo aInfo(ePaper);
+    return { gfx::Length::hmm(aInfo.getWidth()), 
gfx::Length::hmm(aInfo.getHeight()) };
+}
+
 /*------------------------------------------------------------------------
  Description:   Return the paper size of the printer, aligned to our
                 own sizes. If no Printer is set in the system, A4 portrait
@@ -108,6 +114,12 @@ Size SvxPaperInfo::GetDefaultPaperSize( MapUnit eUnit )
         : OutputDevice::LogicToLogic(aRet, MapMode(MapUnit::Map100thMM), 
MapMode(eUnit));
 }
 
+gfx::Size2DLWrap SvxPaperInfo::getDefaultPaperSize()
+{
+    PaperInfo aInfo(PaperInfo::getSystemDefaultPaper());
+    return { gfx::Length::hmm(aInfo.getWidth()), 
gfx::Length::hmm(aInfo.getHeight()) };
+}
+
 /*------------------------------------------------------------------------
  Description:   String representation for the SV-defines of paper size
 ------------------------------------------------------------------------*/
diff --git a/include/editeng/paperinf.hxx b/include/editeng/paperinf.hxx
index 2ccc8fbf96fa..0d12100e5903 100644
--- a/include/editeng/paperinf.hxx
+++ b/include/editeng/paperinf.hxx
@@ -25,6 +25,7 @@
 #include <tools/mapunit.hxx>
 #include <i18nutil/paper.hxx>
 #include <tools/gen.hxx>
+#include <basegfx/units/Size2DLWrap.hxx>
 #include <editeng/editengdllapi.h>
 
 // forward ---------------------------------------------------------------
@@ -42,6 +43,9 @@ public:
     static Paper    GetSvxPaper( const Size &rSize, MapUnit eUnit );
     static tools::Long     GetSloppyPaperDimension( tools::Long nSize );
     static OUString GetName( Paper ePaper );
+
+    static gfx::Size2DLWrap getPaperSize(Paper ePaper);
+    static gfx::Size2DLWrap getDefaultPaperSize();
 };
 
 // INLINE -----------------------------------------------------------------
diff --git a/include/svx/Border.hxx b/include/svx/Border.hxx
index abf93e6013f4..2c6b251c4c62 100644
--- a/include/svx/Border.hxx
+++ b/include/svx/Border.hxx
@@ -43,6 +43,15 @@ public:
     {
     }
 
+    Border(gfx::Length const& nLeft, gfx::Length const& nUpper, gfx::Length 
const& nRight,
+           gfx::Length const& nLower)
+        : maLeft(nLeft)
+        , maRight(nRight)
+        , maUpper(nUpper)
+        , maLower(nLower)
+    {
+    }
+
     gfx::Length const& left() const { return maLeft; }
     gfx::Length const& right() const { return maRight; }
     gfx::Length const& upper() const { return maUpper; }
diff --git a/sd/source/core/drawdoc2.cxx b/sd/source/core/drawdoc2.cxx
index f865737eed67..518ecf02aa18 100644
--- a/sd/source/core/drawdoc2.cxx
+++ b/sd/source/core/drawdoc2.cxx
@@ -566,7 +566,7 @@ void SdDrawDocument::CreateFirstPages( SdDrawDocument const 
* pRefDocument /* =
         return;
 
     // #i57181# Paper size depends on Language, like in Writer
-    Size aDefSize = SvxPaperInfo::GetDefaultPaperSize( MapUnit::Map100thMM );
+    gfx::Size2DLWrap aDefaultSize = SvxPaperInfo::getDefaultPaperSize();
 
     // Insert handout page
     rtl::Reference<SdPage> pHandoutPage = AllocSdPage(false);
@@ -583,8 +583,8 @@ void SdDrawDocument::CreateFirstPages( SdDrawDocument const 
* pRefDocument /* =
     }
     else
     {
-        pHandoutPage->setToolsSize(aDefSize);
-        pHandoutPage->SetBorder(0, 0, 0, 0);
+        pHandoutPage->setSize(aDefaultSize);
+        pHandoutPage->setBorder(svx::Border());
     }
 
     pHandoutPage->SetPageKind(PageKind::Handout);
@@ -620,7 +620,7 @@ void SdDrawDocument::CreateFirstPages( SdDrawDocument const 
* pRefDocument /* =
         else if (meDocType == DocumentType::Draw)
         {
             // Draw: always use default size with margins
-            pPage->setToolsSize(aDefSize);
+            pPage->setSize(aDefaultSize);
 
             SfxPrinter* pPrinter = mpDocSh->GetPrinter(false);
             if (pPrinter && pPrinter->IsValid())
@@ -630,12 +630,12 @@ void SdDrawDocument::CreateFirstPages( SdDrawDocument 
const * pRefDocument /* =
                 aPageOffset -= pPrinter->PixelToLogic( Point() );
                 ::tools::Long nOffset = !aPageOffset.X() && !aPageOffset.Y() ? 
0 : PRINT_OFFSET;
 
-                sal_uLong nTop    = aPageOffset.Y();
-                sal_uLong nLeft   = aPageOffset.X();
-                sal_uLong nBottom = std::max(::tools::Long(aDefSize.Height() - 
aOutSize.Height() - nTop + nOffset), ::tools::Long(0));
-                sal_uLong nRight  = std::max(::tools::Long(aDefSize.Width() - 
aOutSize.Width() - nLeft + nOffset), ::tools::Long(0));
+                gfx::Length nTop    = gfx::Length::hmm(aPageOffset.Y());
+                gfx::Length nLeft   = gfx::Length::hmm(aPageOffset.X());
+                gfx::Length nBottom = 
gfx::Length::hmm(std::max(::tools::Long(aDefaultSize.getHeight().as_hmm() - 
aOutSize.Height() - aPageOffset.Y() + nOffset), tools::Long(0)));
+                gfx::Length nRight  = 
gfx::Length::hmm(std::max(::tools::Long(aDefaultSize.getWidth().as_hmm() - 
aOutSize.Width() - aPageOffset.X() + nOffset), tools::Long(0)));
 
-                pPage->SetBorder(nLeft, nTop, nRight, nBottom);
+                pPage->setBorder(svx::Border(nLeft, nTop, nRight, nBottom));
             }
             else
             {
@@ -644,14 +644,14 @@ void SdDrawDocument::CreateFirstPages( SdDrawDocument 
const * pRefDocument /* =
                 // This has to be kept synchronized with the border
                 // width set in the
                 // SvxPageDescPage::PaperSizeSelect_Impl callback.
-                pPage->SetBorder(1000, 1000, 1000, 1000);
+                pPage->setBorder(svx::Border(1000_hmm, 1000_hmm, 1000_hmm, 
1000_hmm));
             }
         }
         else
         {
             // Impress: always use screen format, landscape.
-            Size aSize = SvxPaperInfo::GetPaperSize(PAPER_SCREEN_16_9, 
MapUnit::Map100thMM);
-            pPage->setToolsSize(Size(aSize.Height(), aSize.Width()));
+            gfx::Size2DLWrap aSize = 
SvxPaperInfo::getPaperSize(PAPER_SCREEN_16_9);
+            pPage->setSize({ aSize.getHeight(), aSize.getWidth() });
             pPage->setBorder(svx::Border());
         }
 
@@ -686,16 +686,16 @@ void SdDrawDocument::CreateFirstPages( SdDrawDocument 
const * pRefDocument /* =
     else
     {
         // Always use portrait format
-        if (aDefSize.Height() >= aDefSize.Width())
+        if (aDefaultSize.getHeight() >= aDefaultSize.getWidth())
         {
-            pNotesPage->setToolsSize(aDefSize);
+            pNotesPage->setSize(aDefaultSize);
         }
         else
         {
-            pNotesPage->setToolsSize(Size(aDefSize.Height(), 
aDefSize.Width()));
+            pNotesPage->setSize({ aDefaultSize.getHeight(), 
aDefaultSize.getWidth() });
         }
 
-        pNotesPage->SetBorder(0, 0, 0, 0);
+        pNotesPage->setBorder(svx::Border());
     }
     pNotesPage->SetPageKind(PageKind::Notes);
     InsertPage(pNotesPage.get(), 2);

Reply via email to