[Libreoffice-commits] core.git: 2 commits - include/svx sw/inc sw/source

Tomaž Vajngerl (via logerrit) logerrit at kemper.freedesktop.org
Wed Aug 11 07:18:44 UTC 2021


 include/svx/svdglue.hxx              |  174 +++++++++++++++++++++++++----------
 sw/inc/swtypes.hxx                   |    3 
 sw/source/uibase/dochdl/swdtflvr.cxx |   21 ++--
 3 files changed, 141 insertions(+), 57 deletions(-)

New commits:
commit 4cb9b2b3e9bd61ab630aa16d9e382a3b90deb77d
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Wed Aug 11 12:32:27 2021 +0900
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Wed Aug 11 09:18:25 2021 +0200

    svx: cleanup formatting of svdglue.hxx
    
    Change-Id: I4aa4d25a5097813feeb7d6ebb654b9b0ce0c1c14
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120302
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/include/svx/svdglue.hxx b/include/svx/svdglue.hxx
index bddaf349c4a8..1bca84ca319f 100644
--- a/include/svx/svdglue.hxx
+++ b/include/svx/svdglue.hxx
@@ -78,70 +78,150 @@ class SVXCORE_DLLPUBLIC SdrGluePoint {
     bool bReallyAbsolute:1; // temp for transformations on the reference object
     bool bUserDefined:1; // #i38892#
 public:
-    SdrGluePoint(): nEscDir(SdrEscapeDirection::SMART),nId(0),nAlign(SdrAlign::NONE),bNoPercent(false),bReallyAbsolute(false),bUserDefined(true) {}
-    SdrGluePoint(const Point& rNewPos): aPos(rNewPos),nEscDir(SdrEscapeDirection::SMART),nId(0),nAlign(SdrAlign::NONE),bNoPercent(false),bReallyAbsolute(false),bUserDefined(true) {}
-    const Point& GetPos() const                             { return aPos; }
-    void         SetPos(const Point& rNewPos)               { aPos=rNewPos; }
-    SdrEscapeDirection GetEscDir() const                          { return nEscDir; }
-    void         SetEscDir(SdrEscapeDirection nNewEsc)                  { nEscDir=nNewEsc; }
-    sal_uInt16   GetId() const                              { return nId; }
-    void         SetId(sal_uInt16 nNewId)                       { nId=nNewId; }
-    bool         IsPercent() const                          { return !bNoPercent; }
-    void         SetPercent(bool bOn)                   { bNoPercent  = !bOn; }
+    SdrGluePoint()
+        : nEscDir(SdrEscapeDirection::SMART)
+        , nId(0)
+        , nAlign(SdrAlign::NONE)
+        , bNoPercent(false)
+        , bReallyAbsolute(false)
+        , bUserDefined(true)
+    {}
+    SdrGluePoint(const Point& rNewPos)
+        : aPos(rNewPos)
+        , nEscDir(SdrEscapeDirection::SMART)
+        , nId(0)
+        , nAlign(SdrAlign::NONE)
+        , bNoPercent(false)
+        , bReallyAbsolute(false)
+        , bUserDefined(true)
+    {}
+    const Point& GetPos() const
+    {
+        return aPos;
+    }
+    void SetPos(const Point& rNewPos)
+    {
+        aPos = rNewPos;
+    }
+    SdrEscapeDirection GetEscDir() const
+    {
+        return nEscDir;
+    }
+    void SetEscDir(SdrEscapeDirection nNewEsc)
+    {
+        nEscDir = nNewEsc;
+    }
+    sal_uInt16   GetId() const
+    {
+        return nId;
+    }
+    void SetId(sal_uInt16 nNewId)
+    {
+        nId = nNewId;
+    }
+    bool IsPercent() const
+    {
+        return !bNoPercent;
+    }
+    void SetPercent(bool bOn)
+    {
+        bNoPercent  = !bOn;
+    }
     // temp for transformations on the reference object
-    void         SetReallyAbsolute(bool bOn, const SdrObject& rObj);
+    void SetReallyAbsolute(bool bOn, const SdrObject& rObj);
 
     // #i38892#
-    bool         IsUserDefined() const                      { return bUserDefined; }
-    void         SetUserDefined(bool bNew)              { bUserDefined = bNew; }
-
-    SdrAlign     GetAlign() const                           { return nAlign; }
-    void         SetAlign(SdrAlign nAlg)                    { nAlign=nAlg; }
-    SdrAlign     GetHorzAlign() const                       { return nAlign & static_cast<SdrAlign>(0x00FF); }
-    void         SetHorzAlign(SdrAlign nAlg)                { assert((nAlg & static_cast<SdrAlign>(0xFF00)) == SdrAlign::NONE); nAlign = SdrAlign(nAlign & static_cast<SdrAlign>(0xFF00)) | (nAlg & static_cast<SdrAlign>(0x00FF)); }
-    SdrAlign     GetVertAlign() const                       { return nAlign & static_cast<SdrAlign>(0xFF00); }
-    void         SetVertAlign(SdrAlign nAlg)                { assert((nAlg & static_cast<SdrAlign>(0x00FF)) == SdrAlign::NONE); nAlign = SdrAlign(nAlign & static_cast<SdrAlign>(0x00FF)) | (nAlg & static_cast<SdrAlign>(0xFF00)); }
-    bool         IsHit(const Point& rPnt, const OutputDevice& rOut, const SdrObject* pObj) const;
-    void         Invalidate(vcl::Window& rWin, const SdrObject* pObj) const;
-    Point        GetAbsolutePos(const SdrObject& rObj) const;
-    void         SetAbsolutePos(const Point& rNewPos, const SdrObject& rObj);
-    Degree100    GetAlignAngle() const;
-    void         SetAlignAngle(Degree100 nAngle);
-    static Degree100  EscDirToAngle(SdrEscapeDirection nEsc);
+    bool IsUserDefined() const
+    {
+        return bUserDefined;
+    }
+    void SetUserDefined(bool bNew)
+    {
+        bUserDefined = bNew;
+    }
+
+    SdrAlign GetAlign() const
+    {
+        return nAlign;
+    }
+    void SetAlign(SdrAlign nAlg)
+    {
+        nAlign = nAlg;
+    }
+    SdrAlign GetHorzAlign() const
+    {
+        return nAlign & static_cast<SdrAlign>(0x00FF);
+    }
+    void SetHorzAlign(SdrAlign nAlg)
+    {
+        assert((nAlg & static_cast<SdrAlign>(0xFF00)) == SdrAlign::NONE);
+        nAlign = SdrAlign(nAlign & static_cast<SdrAlign>(0xFF00)) | (nAlg & static_cast<SdrAlign>(0x00FF));
+    }
+    SdrAlign GetVertAlign() const
+    {
+        return nAlign & static_cast<SdrAlign>(0xFF00);
+    }
+    void SetVertAlign(SdrAlign nAlg)
+    {
+        assert((nAlg & static_cast<SdrAlign>(0x00FF)) == SdrAlign::NONE);
+        nAlign = SdrAlign(nAlign & static_cast<SdrAlign>(0x00FF)) | (nAlg & static_cast<SdrAlign>(0xFF00));
+    }
+
+    bool IsHit(const Point& rPnt, const OutputDevice& rOut, const SdrObject* pObj) const;
+    void Invalidate(vcl::Window& rWin, const SdrObject* pObj) const;
+    Point GetAbsolutePos(const SdrObject& rObj) const;
+    void SetAbsolutePos(const Point& rNewPos, const SdrObject& rObj);
+    Degree100 GetAlignAngle() const;
+    void SetAlignAngle(Degree100 nAngle);
+    static Degree100 EscDirToAngle(SdrEscapeDirection nEsc);
     static SdrEscapeDirection EscAngleToDir(Degree100 nAngle);
-    void         Rotate(const Point& rRef, Degree100 nAngle, double sn, double cs, const SdrObject* pObj);
-    void         Mirror(const Point& rRef1, const Point& rRef2, Degree100 nAngle, const SdrObject* pObj);
-    void         Shear (const Point& rRef, double tn, bool bVShear, const SdrObject* pObj);
+    void Rotate(const Point& rRef, Degree100 nAngle, double sn, double cs, const SdrObject* pObj);
+    void Mirror(const Point& rRef1, const Point& rRef2, Degree100 nAngle, const SdrObject* pObj);
+    void Shear (const Point& rRef, double tn, bool bVShear, const SdrObject* pObj);
 };
 
 #define SDRGLUEPOINT_NOTFOUND 0xFFFF
 
-class SVXCORE_DLLPUBLIC SdrGluePointList {
+class SVXCORE_DLLPUBLIC SdrGluePointList
+{
     std::vector<SdrGluePoint> aList;
 public:
     SdrGluePointList() {};
-    SdrGluePointList(const SdrGluePointList& rSrcList) { *this=rSrcList; }
+    SdrGluePointList(const SdrGluePointList& rSrcList)
+    {
+        *this = rSrcList;
+    }
 
-    SdrGluePointList&   operator=(const SdrGluePointList& rSrcList);
-    sal_uInt16          GetCount() const                                    { return sal_uInt16(aList.size()); }
+    SdrGluePointList& operator=(const SdrGluePointList& rSrcList);
+    sal_uInt16 GetCount() const
+    {
+        return sal_uInt16(aList.size());
+    }
     // At insert, the object (GluePoint) automatically gets an ID assigned.
     // Return value is the index of the new GluePoint in the list.
-    sal_uInt16          Insert(const SdrGluePoint& rGP);
-    void                Delete(sal_uInt16 nPos)
+    sal_uInt16 Insert(const SdrGluePoint& rGP);
+    void Delete(sal_uInt16 nPos)
     {
-        aList.erase(aList.begin()+nPos);
+        aList.erase(aList.begin() + nPos);
     }
-    SdrGluePoint&       operator[](sal_uInt16 nPos)                             { return aList[nPos]; }
-    const SdrGluePoint& operator[](sal_uInt16 nPos) const                       { return aList[nPos]; }
-    sal_uInt16          FindGluePoint(sal_uInt16 nId) const;
-    sal_uInt16          HitTest(const Point& rPnt, const OutputDevice& rOut, const SdrObject* pObj) const;
-    void                Invalidate(vcl::Window& rWin, const SdrObject* pObj) const;
+    SdrGluePoint& operator[](sal_uInt16 nPos)
+    {
+        return aList[nPos];
+    }
+    const SdrGluePoint& operator[](sal_uInt16 nPos) const
+    {
+        return aList[nPos];
+    }
+    sal_uInt16 FindGluePoint(sal_uInt16 nId) const;
+    sal_uInt16 HitTest(const Point& rPnt, const OutputDevice& rOut, const SdrObject* pObj) const;
+    void Invalidate(vcl::Window& rWin, const SdrObject* pObj) const;
+
     // temp for transformations on the reference object
-    void                SetReallyAbsolute(bool bOn, const SdrObject& rObj);
-    void                Rotate(const Point& rRef, Degree100 nAngle, double sn, double cs, const SdrObject* pObj);
-    void                Mirror(const Point& rRef1, const Point& rRef2, const SdrObject* pObj);
-    void                Mirror(const Point& rRef1, const Point& rRef2, Degree100 nAngle, const SdrObject* pObj);
-    void                Shear (const Point& rRef, double tn, bool bVShear, const SdrObject* pObj);
+    void SetReallyAbsolute(bool bOn, const SdrObject& rObj);
+    void Rotate(const Point& rRef, Degree100 nAngle, double sn, double cs, const SdrObject* pObj);
+    void Mirror(const Point& rRef1, const Point& rRef2, const SdrObject* pObj);
+    void Mirror(const Point& rRef1, const Point& rRef2, Degree100 nAngle, const SdrObject* pObj);
+    void Shear(const Point& rRef, double tn, bool bVShear, const SdrObject* pObj);
 };
 
 
commit 0d356f93e4d5ca073a6e866168f76103c60c6a45
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Sun Jul 25 21:17:24 2021 +0900
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Wed Aug 11 09:18:11 2021 +0200

    sw: preserve the value in original units to minimize conv. error
    
    Not really an big issue but let's preserve the values in original
    units as long as we can without conversion so that the error is
    minimal.
    
    Change-Id: I96981eaecac74b591803dbc93e487c1d106ab23c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119490
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/sw/inc/swtypes.hxx b/sw/inc/swtypes.hxx
index a091a538d9a9..64ac704d6ff6 100644
--- a/sw/inc/swtypes.hxx
+++ b/sw/inc/swtypes.hxx
@@ -71,7 +71,8 @@ constexpr SwTwips DEF_GUTTER_WIDTH = o3tl::toTwips(3, o3tl::Length::mm);
 constexpr SwTwips MIN_BORDER_DIST = 28; // ~0.5mm
 
 // Minimal document border: 20mm.
-constexpr SwTwips lMinBorder = o3tl::toTwips(20, o3tl::Length::mm); // ~20mm
+constexpr tools::Long lMinBorderInMm(20);
+constexpr SwTwips lMinBorder = o3tl::toTwips(lMinBorderInMm, o3tl::Length::mm);
 
 // Margin left and above document.
 // Half of it is gap between the pages.
diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx
index 338a11b24b84..b66f251e55c7 100644
--- a/sw/source/uibase/dochdl/swdtflvr.cxx
+++ b/sw/source/uibase/dochdl/swdtflvr.cxx
@@ -134,10 +134,15 @@
 
 #include <memory>
 
-constexpr tools::Long constOleWidth = 11905 - 2 * lMinBorder;
-constexpr tools::Long constOleHeight = o3tl::toTwips(3, o3tl::Length::cm);
+/* default (A4 format) width of 210mm - 2 * border size (border on both sides) */
+constexpr tools::Long constOleWidthInMm = 210 - 2 * lMinBorderInMm;
 
-#define OLESIZE constOleWidth, constOleHeight
+constexpr Size constOleSize100mm(
+    constOleWidthInMm * 100, // convert from mm to 100mm
+    30 // 3 cm
+);
+
+constexpr Size constOleSizeTwip = o3tl::convert(constOleSize100mm, o3tl::Length::mm100, o3tl::Length::twip);
 
 constexpr sal_uInt32 SWTRANSFER_OBJECTTYPE_DRAWMODEL = 0x00000001;
 constexpr sal_uInt32 SWTRANSFER_OBJECTTYPE_HTML      = 0x00000002;
@@ -343,7 +348,7 @@ void SwTransferable::InitOle( SfxObjectShell* pDoc )
 {
     //set OleVisArea. Upper left corner of the page and size of
     //RealSize in Twips.
-    const Size aSz( OLESIZE );
+    const Size aSz(constOleSizeTwip);
     SwRect aVis( Point( DOCUMENTBORDER, DOCUMENTBORDER ), aSz );
     pDoc->SetVisArea( aVis.SVRect() );
 }
@@ -1158,8 +1163,7 @@ int SwTransferable::PrepareForCopy( bool bIsCut )
         //ObjectDescriptor was already filly from the old DocShell.
         //Now adjust it. Thus in GetData the first query can still
         //be answered with delayed rendering.
-        Size aSz( OLESIZE );
-        m_aObjDesc.maSize = o3tl::convert(aSz, o3tl::Length::twip, o3tl::Length::mm100);
+        m_aObjDesc.maSize = constOleSize100mm;
 
         PrepareOLE( m_aObjDesc );
 #if HAVE_FEATURE_DESKTOP
@@ -1261,8 +1265,7 @@ bool SwTransferable::CopyGlossary( SwTextBlocks& rGlossary, const OUString& rStr
     //ObjectDescriptor was already filled from the old DocShell.
     //Now adjust it. Thus in GetData the first query can still
     //be answered with delayed rendering.
-    Size aSz( OLESIZE );
-    m_aObjDesc.maSize = o3tl::convert(aSz, o3tl::Length::twip, o3tl::Length::mm100);
+    m_aObjDesc.maSize = constOleSize100mm;
 
     PrepareOLE( m_aObjDesc );
     AddFormat( SotClipboardFormatId::OBJECTDESCRIPTOR );
@@ -3624,7 +3627,7 @@ void SwTransferable::SetDataForDragAndDrop( const Point& rSttPos )
         //Now adjust it. Thus in GetData the first query can still
         //be answered with delayed rendering.
         m_aObjDesc.maDragStartPos = rSttPos;
-        m_aObjDesc.maSize = o3tl::convert(Size( OLESIZE ), o3tl::Length::twip, o3tl::Length::mm100);
+        m_aObjDesc.maSize = constOleSize100mm;
 
         PrepareOLE( m_aObjDesc );
         AddFormat( SotClipboardFormatId::OBJECTDESCRIPTOR );


More information about the Libreoffice-commits mailing list