editeng/inc/TextPortion.hxx         |  147 ++++++++++++++++++++++++++++++++++++
 editeng/inc/editdoc.hxx             |  124 ------------------------------
 editeng/source/editeng/editdoc.cxx  |   26 ------
 editeng/source/editeng/impedit.hxx  |   10 +-
 editeng/source/editeng/impedit3.cxx |    1 
 5 files changed, 155 insertions(+), 153 deletions(-)

New commits:
commit 629f55de24aca6eed7cb3bb8ad2bd8f4a6593d46
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Fri Dec 22 20:04:01 2023 +0900
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Fri Dec 29 02:42:21 2023 +0100

    editeng: simplify FormatterFontMetric
    
    We don't really need a custom constructor and default values can
    now be set directly.
    
    Change-Id: I7e8aabf2c60d3b63abf1764bbff512685803f71e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161349
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>

diff --git a/editeng/source/editeng/impedit.hxx 
b/editeng/source/editeng/impedit.hxx
index 89339b11dc3e..4b2000083106 100644
--- a/editeng/source/editeng/impedit.hxx
+++ b/editeng/source/editeng/impedit.hxx
@@ -181,11 +181,13 @@ struct ConvInfo
 
 struct FormatterFontMetric
 {
-    sal_uInt16 nMaxAscent;
-    sal_uInt16 nMaxDescent;
+    sal_uInt16 nMaxAscent = 0;
+    sal_uInt16 nMaxDescent = 0;
 
-    FormatterFontMetric() : nMaxAscent(0), nMaxDescent(0) { /* nMinLeading = 
0xFFFF; */ }
-    sal_uInt16  GetHeight() const       { return nMaxAscent+nMaxDescent; }
+    sal_uInt16 GetHeight() const
+    {
+        return nMaxAscent + nMaxDescent;
+    }
 };
 
 class IdleFormattter : public Idle
commit 1958805f61612a7b23f1c5c2d532be4d5dc24a2a
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Sat Dec 9 15:26:34 2023 +0900
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Fri Dec 29 02:42:14 2023 +0100

    editeng: move TextPortion to own header file
    
    Change-Id: I54d0bbad4ef142705191672319774f26abf3e735
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161348
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>

diff --git a/editeng/inc/TextPortion.hxx b/editeng/inc/TextPortion.hxx
new file mode 100644
index 000000000000..e5560f260326
--- /dev/null
+++ b/editeng/inc/TextPortion.hxx
@@ -0,0 +1,147 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#pragma once
+
+#include "editattr.hxx"
+#include "edtspell.hxx"
+#include "eerdll2.hxx"
+#include <editeng/svxfont.hxx>
+#include <editeng/EPaM.hxx>
+#include <svl/itemset.hxx>
+#include <svl/style.hxx>
+#include <svl/itempool.hxx>
+#include <svl/languageoptions.hxx>
+#include <tools/lineend.hxx>
+#include <o3tl/typed_flags_set.hxx>
+
+#include <vector>
+
+enum class PortionKind
+{
+    TEXT = 0,
+    TAB = 1,
+    LINEBREAK = 2,
+    FIELD = 3,
+    HYPHENATOR = 4
+};
+
+enum class AsianCompressionFlags
+{
+    Normal = 0x00,
+    Kana = 0x01,
+    PunctuationLeft = 0x02,
+    PunctuationRight = 0x04,
+};
+namespace o3tl
+{
+template <> struct typed_flags<AsianCompressionFlags> : 
is_typed_flags<AsianCompressionFlags, 0x07>
+{
+};
+}
+
+struct ExtraPortionInfo
+{
+    ExtraPortionInfo() {}
+
+    tools::Long nOrgWidth = 0;
+    tools::Long nWidthFullCompression = 0;
+
+    tools::Long nPortionOffsetX = 0;
+
+    sal_uInt16 nMaxCompression100thPercent = 0;
+
+    AsianCompressionFlags nAsianCompressionTypes = 
AsianCompressionFlags::Normal;
+    bool bFirstCharIsRightPunktuation = false;
+    bool bCompressed = false;
+
+    std::unique_ptr<sal_Int32[]> pOrgDXArray;
+    std::vector<sal_Int32> lineBreaksList;
+
+    void SaveOrgDXArray(const sal_Int32* pDXArray, sal_Int32 nLen)
+    {
+        if (pDXArray)
+        {
+            pOrgDXArray.reset(new sal_Int32[nLen]);
+            memcpy(pOrgDXArray.get(), pDXArray, nLen * sizeof(sal_Int32));
+        }
+        else
+            pOrgDXArray.reset();
+    }
+};
+
+class TextPortion
+{
+private:
+    std::unique_ptr<ExtraPortionInfo> xExtraInfos;
+    sal_Int32 nLen;
+    Size aOutSz = Size(-1, -1);
+    PortionKind nKind = PortionKind::TEXT;
+    sal_uInt8 nRightToLeftLevel = 0;
+    sal_Unicode nExtraValue = 0;
+
+public:
+    TextPortion(sal_Int32 nL)
+        : nLen(nL)
+    {
+    }
+
+    TextPortion(const TextPortion& r)
+        : nLen(r.nLen)
+        , aOutSz(r.aOutSz)
+        , nKind(r.nKind)
+        , nRightToLeftLevel(r.nRightToLeftLevel)
+        , nExtraValue(r.nExtraValue)
+    {
+    }
+
+    sal_Int32 GetLen() const { return nLen; }
+    void SetLen(sal_Int32 nL) { nLen = nL; }
+
+    void setWidth(tools::Long nWidth) { aOutSz.setWidth(nWidth); }
+
+    void setHeight(tools::Long nHeight) { aOutSz.setHeight(nHeight); }
+
+    void adjustSize(tools::Long nDeltaX, tools::Long nDeltaY)
+    {
+        if (nDeltaX != 0)
+            aOutSz.AdjustWidth(nDeltaX);
+        if (nDeltaY != 0)
+            aOutSz.AdjustHeight(nDeltaY);
+    }
+
+    void SetSize(const Size& rSize) { aOutSz = rSize; }
+
+    const Size& GetSize() const { return aOutSz; }
+
+    void SetKind(PortionKind n) { nKind = n; }
+    PortionKind GetKind() const { return nKind; }
+
+    void SetRightToLeftLevel(sal_uInt8 n) { nRightToLeftLevel = n; }
+    sal_uInt8 GetRightToLeftLevel() const { return nRightToLeftLevel; }
+    bool IsRightToLeft() const { return (nRightToLeftLevel & 1); }
+
+    sal_Unicode GetExtraValue() const { return nExtraValue; }
+    void SetExtraValue(sal_Unicode n) { nExtraValue = n; }
+
+    ExtraPortionInfo* GetExtraInfos() const { return xExtraInfos.get(); }
+    void SetExtraInfos(ExtraPortionInfo* p) { xExtraInfos.reset(p); }
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/editeng/inc/editdoc.hxx b/editeng/inc/editdoc.hxx
index 565012ad97cc..240bcbfc9e37 100644
--- a/editeng/inc/editdoc.hxx
+++ b/editeng/inc/editdoc.hxx
@@ -30,6 +30,7 @@
 #include <svl/languageoptions.hxx>
 #include <tools/lineend.hxx>
 #include <o3tl/typed_flags_set.hxx>
+#include "TextPortion.hxx"
 
 #include <cstddef>
 #include <memory>
@@ -301,133 +302,10 @@ public:
     bool operator !() const { return !pNode && !nIndex; }
 };
 
-enum class PortionKind
-{
-    TEXT        = 0,
-    TAB         = 1,
-    LINEBREAK   = 2,
-    FIELD       = 3,
-    HYPHENATOR  = 4
-};
-
 enum class DeleteMode {
     Simple, RestOfWord, RestOfContent
 };
 
-enum class AsianCompressionFlags {
-    Normal            = 0x00,
-    Kana              = 0x01,
-    PunctuationLeft   = 0x02,
-    PunctuationRight  = 0x04,
-};
-namespace o3tl {
-    template<> struct typed_flags<AsianCompressionFlags> : 
is_typed_flags<AsianCompressionFlags, 0x07> {};
-}
-
-
-
-// struct ExtraPortionInfos
-
-struct ExtraPortionInfo
-{
-    tools::Long    nOrgWidth;
-    tools::Long    nWidthFullCompression;
-
-    tools::Long    nPortionOffsetX;
-
-    sal_uInt16  nMaxCompression100thPercent;
-
-    AsianCompressionFlags nAsianCompressionTypes;
-    bool    bFirstCharIsRightPunktuation;
-    bool    bCompressed;
-
-    std::unique_ptr<sal_Int32[]> pOrgDXArray;
-    std::vector< sal_Int32 > lineBreaksList;
-
-
-            ExtraPortionInfo();
-            ~ExtraPortionInfo();
-
-    void    SaveOrgDXArray( const sal_Int32* pDXArray, sal_Int32 nLen );
-};
-
-
-
-class TextPortion
-{
-private:
-    std::unique_ptr<ExtraPortionInfo> xExtraInfos;
-    sal_Int32           nLen;
-    Size                aOutSz;
-    PortionKind         nKind;
-    sal_uInt8           nRightToLeftLevel;
-    sal_Unicode         nExtraValue;
-
-
-public:
-                TextPortion( sal_Int32 nL )
-                : nLen( nL )
-                , aOutSz( -1, -1 )
-                , nKind( PortionKind::TEXT )
-                , nRightToLeftLevel( 0 )
-                , nExtraValue( 0 )
-                {
-                }
-
-                TextPortion( const TextPortion& r )
-                : nLen( r.nLen )
-                , aOutSz( r.aOutSz )
-                , nKind( r.nKind )
-                , nRightToLeftLevel( r.nRightToLeftLevel )
-                , nExtraValue( r.nExtraValue )
-                {
-                }
-
-
-    sal_Int32      GetLen() const              { return nLen; }
-    void           SetLen( sal_Int32 nL )         { nLen = nL; }
-
-    void setWidth(tools::Long nWidth)
-    {
-        aOutSz.setWidth(nWidth);
-    }
-
-    void setHeight(tools::Long nHeight)
-    {
-        aOutSz.setHeight(nHeight);
-    }
-
-    void adjustSize(tools::Long nDeltaX, tools::Long nDeltaY)
-    {
-        if (nDeltaX != 0)
-            aOutSz.AdjustWidth(nDeltaX);
-        if (nDeltaY != 0)
-            aOutSz.AdjustHeight(nDeltaY);
-    }
-
-    void SetSize(const Size& rSize)
-    {
-        aOutSz = rSize;
-    }
-
-    const Size&    GetSize() const             { return aOutSz; }
-
-    void           SetKind(PortionKind n)      { nKind = n; }
-    PortionKind    GetKind() const             { return nKind; }
-
-    void           SetRightToLeftLevel( sal_uInt8 n ) { nRightToLeftLevel = n; 
}
-    sal_uInt8      GetRightToLeftLevel() const { return nRightToLeftLevel; }
-    bool           IsRightToLeft() const       { return (nRightToLeftLevel&1); 
}
-
-    sal_Unicode    GetExtraValue() const       { return nExtraValue; }
-    void           SetExtraValue( sal_Unicode n )  { nExtraValue = n; }
-
-    ExtraPortionInfo*   GetExtraInfos() const { return xExtraInfos.get(); }
-    void                SetExtraInfos( ExtraPortionInfo* p ) { 
xExtraInfos.reset(p); }
-};
-
-
-
 class TextPortionList
 {
     typedef std::vector<std::unique_ptr<TextPortion> > PortionsType;
diff --git a/editeng/source/editeng/editdoc.cxx 
b/editeng/source/editeng/editdoc.cxx
index d892bd1c3a25..0856a594f7ae 100644
--- a/editeng/source/editeng/editdoc.cxx
+++ b/editeng/source/editeng/editdoc.cxx
@@ -480,32 +480,6 @@ sal_Int32 TextPortionList::GetStartPos(sal_Int32 nPortion)
     return nPos;
 }
 
-ExtraPortionInfo::ExtraPortionInfo()
-: nOrgWidth(0)
-, nWidthFullCompression(0)
-, nPortionOffsetX(0)
-, nMaxCompression100thPercent(0)
-, nAsianCompressionTypes(AsianCompressionFlags::Normal)
-, bFirstCharIsRightPunktuation(false)
-, bCompressed(false)
-{
-}
-
-ExtraPortionInfo::~ExtraPortionInfo()
-{
-}
-
-void ExtraPortionInfo::SaveOrgDXArray( const sal_Int32* pDXArray, sal_Int32 
nLen )
-{
-    if (pDXArray)
-    {
-        pOrgDXArray.reset(new sal_Int32[nLen]);
-        memcpy( pOrgDXArray.get(), pDXArray, nLen * sizeof(sal_Int32) );
-    }
-    else
-        pOrgDXArray.reset();
-}
-
 ParaPortion::ParaPortion( ContentNode* pN ) :
     pNode(pN),
     nHeight(0),
diff --git a/editeng/source/editeng/impedit3.cxx 
b/editeng/source/editeng/impedit3.cxx
index 01b2d52b3fa7..84332897736b 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -46,6 +46,7 @@
 #include <editeng/charscaleitem.hxx>
 #include <editeng/numitem.hxx>
 #include <outleeng.hxx>
+#include <TextPortion.hxx>
 
 #include <svtools/colorcfg.hxx>
 #include <svl/ctloptions.hxx>

Reply via email to