[Libreoffice-commits] core.git: 3 commits - editeng/Library_editeng.mk editeng/source include/editeng

Kohei Yoshida kohei.yoshida at gmail.com
Wed Aug 28 13:13:00 PDT 2013


 editeng/Library_editeng.mk               |    1 
 editeng/source/editeng/editdoc.cxx       |   42 +++---
 editeng/source/editeng/editdoc.hxx       |    9 -
 editeng/source/editeng/editobj.cxx       |   29 ++--
 editeng/source/editeng/editobj2.hxx      |    9 -
 editeng/source/editeng/edtspell.cxx      |  190 +++++++++++++++----------------
 editeng/source/editeng/edtspell.hxx      |   57 ++++-----
 editeng/source/editeng/impedit2.cxx      |   18 +-
 editeng/source/editeng/impedit3.cxx      |   11 -
 editeng/source/editeng/impedit4.cxx      |    1 
 editeng/source/editeng/misspellrange.cxx |   19 +++
 include/editeng/misspellrange.hxx        |   30 ++++
 12 files changed, 237 insertions(+), 179 deletions(-)

New commits:
commit 1e3c5948c35cd0b2178b1cf204709ed36c6123c7
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Wed Aug 28 15:55:56 2013 -0400

    Expose misspelled range container outside edit engine.
    
    Change-Id: I04c87c5299559932733c88a317808241fd1755d4

diff --git a/editeng/Library_editeng.mk b/editeng/Library_editeng.mk
index 94e841b..9a1ca71 100644
--- a/editeng/Library_editeng.mk
+++ b/editeng/Library_editeng.mk
@@ -60,6 +60,7 @@ $(eval $(call gb_Library_add_exception_objects,editeng,\
     editeng/source/editeng/impedit3 \
     editeng/source/editeng/impedit4 \
     editeng/source/editeng/impedit5 \
+    editeng/source/editeng/misspellrange \
     editeng/source/editeng/section \
     editeng/source/editeng/textconv \
     editeng/source/items/borderline \
diff --git a/editeng/source/editeng/edtspell.cxx b/editeng/source/editeng/edtspell.cxx
index 3331ab3..6d7bcd1 100644
--- a/editeng/source/editeng/edtspell.cxx
+++ b/editeng/source/editeng/edtspell.cxx
@@ -196,89 +196,89 @@ void EditSpellWrapper::CheckSpellTo()
     }
 }
 
-sal_uInt16 WrongList::Valid = std::numeric_limits<sal_uInt16>::max();
+size_t WrongList::Valid = std::numeric_limits<size_t>::max();
 
-WrongList::WrongList() : nInvalidStart(0), nInvalidEnd(Valid) {}
+WrongList::WrongList() : mnInvalidStart(0), mnInvalidEnd(Valid) {}
 
 WrongList::WrongList(const WrongList& r) :
     maRanges(r.maRanges),
-    nInvalidStart(r.nInvalidStart),
-    nInvalidEnd(r.nInvalidEnd) {}
+    mnInvalidStart(r.mnInvalidStart),
+    mnInvalidEnd(r.mnInvalidEnd) {}
 
 WrongList::~WrongList() {}
 
 bool WrongList::IsValid() const
 {
-    return nInvalidStart == Valid;
+    return mnInvalidStart == Valid;
 }
 
 void WrongList::SetValid()
 {
-    nInvalidStart = Valid;
-    nInvalidEnd = 0;
+    mnInvalidStart = Valid;
+    mnInvalidEnd = 0;
 }
 
-void WrongList::SetInvalidRange( sal_uInt16 nStart, sal_uInt16 nEnd )
+void WrongList::SetInvalidRange( size_t nStart, size_t nEnd )
 {
-    if (nInvalidStart == Valid || nStart < nInvalidStart)
-        nInvalidStart = nStart;
+    if (mnInvalidStart == Valid || nStart < mnInvalidStart)
+        mnInvalidStart = nStart;
 
-    if (nInvalidEnd < nEnd)
-        nInvalidEnd = nEnd;
+    if (mnInvalidEnd < nEnd)
+        mnInvalidEnd = nEnd;
 }
 
-void WrongList::ResetInvalidRange( sal_uInt16 nStart, sal_uInt16 nEnd )
+void WrongList::ResetInvalidRange( size_t nStart, size_t nEnd )
 {
-    nInvalidStart = nStart;
-    nInvalidEnd = nEnd;
+    mnInvalidStart = nStart;
+    mnInvalidEnd = nEnd;
 }
 
-void WrongList::TextInserted( sal_uInt16 nPos, sal_uInt16 nLength, bool bPosIsSep )
+void WrongList::TextInserted( size_t nPos, size_t nLength, bool bPosIsSep )
 {
     if (IsValid())
     {
-        nInvalidStart = nPos;
-        nInvalidEnd = nPos + nLength;
+        mnInvalidStart = nPos;
+        mnInvalidEnd = nPos + nLength;
     }
     else
     {
-        if ( nInvalidStart > nPos )
-            nInvalidStart = nPos;
-        if ( nInvalidEnd >= nPos )
-            nInvalidEnd = nInvalidEnd + nLength;
+        if ( mnInvalidStart > nPos )
+            mnInvalidStart = nPos;
+        if ( mnInvalidEnd >= nPos )
+            mnInvalidEnd = mnInvalidEnd + nLength;
         else
-            nInvalidEnd = nPos + nLength;
+            mnInvalidEnd = nPos + nLength;
     }
 
     for (size_t i = 0, n = maRanges.size(); i < n; ++i)
     {
-        WrongRange& rWrong = maRanges[i];
+        editeng::MisspellRange& rWrong = maRanges[i];
         bool bRefIsValid = true;
-        if (rWrong.nEnd >= nPos)
+        if (rWrong.mnEnd >= nPos)
         {
             // Move all Wrongs after the insert position...
-            if (rWrong.nStart > nPos)
+            if (rWrong.mnStart > nPos)
             {
-                rWrong.nStart += nLength;
-                rWrong.nEnd += nLength;
+                rWrong.mnStart += nLength;
+                rWrong.mnEnd += nLength;
             }
             // 1: Starts before and goes until nPos...
-            else if (rWrong.nEnd == nPos)
+            else if (rWrong.mnEnd == nPos)
             {
                 // Should be halted at a blank!
                 if ( !bPosIsSep )
-                    rWrong.nEnd += nLength;
+                    rWrong.mnEnd += nLength;
             }
             // 2: Starts before and goes until after nPos...
-            else if ((rWrong.nStart < nPos) && (rWrong.nEnd > nPos))
+            else if ((rWrong.mnStart < nPos) && (rWrong.mnEnd > nPos))
             {
-                rWrong.nEnd += nLength;
+                rWrong.mnEnd += nLength;
                 // When a separator remove and re-examine the Wrong
                 if ( bPosIsSep )
                 {
                     // Split Wrong...
-                    WrongRange aNewWrong(rWrong.nStart, nPos);
-                    rWrong.nStart = nPos + 1;
+                    editeng::MisspellRange aNewWrong(rWrong.mnStart, nPos);
+                    rWrong.mnStart = nPos + 1;
                     maRanges.insert(maRanges.begin() + i, aNewWrong);
                     // Reference no longer valid after Insert, the other
                     // was inserted in front of this position
@@ -287,76 +287,76 @@ void WrongList::TextInserted( sal_uInt16 nPos, sal_uInt16 nLength, bool bPosIsSe
                 }
             }
             // 3: Attribute starts at position ..
-            else if (rWrong.nStart == nPos)
+            else if (rWrong.mnStart == nPos)
             {
-                rWrong.nEnd += nLength;
+                rWrong.mnEnd += nLength;
                 if ( bPosIsSep )
-                    ++(rWrong.nStart);
+                    ++(rWrong.mnStart);
             }
         }
-        SAL_WARN_IF(bRefIsValid && rWrong.nStart >= rWrong.nEnd, "editeng",
-                "TextInserted, WrongRange: Start >= End?!");
+        SAL_WARN_IF(bRefIsValid && rWrong.mnStart >= rWrong.mnEnd, "editeng",
+                "TextInserted, editeng::MisspellRange: Start >= End?!");
         (void)bRefIsValid;
     }
 
     SAL_WARN_IF(DbgIsBuggy(), "editeng", "InsertWrong: WrongList broken!");
 }
 
-void WrongList::TextDeleted( sal_uInt16 nPos, sal_uInt16 nLength )
+void WrongList::TextDeleted( size_t nPos, size_t nLength )
 {
-    sal_uInt16 nEndPos = nPos + nLength;
+    size_t nEndPos = nPos + nLength;
     if (IsValid())
     {
         sal_uInt16 nNewInvalidStart = nPos ? nPos - 1 : 0;
-        nInvalidStart = nNewInvalidStart;
-        nInvalidEnd = nNewInvalidStart + 1;
+        mnInvalidStart = nNewInvalidStart;
+        mnInvalidEnd = nNewInvalidStart + 1;
     }
     else
     {
-        if ( nInvalidStart > nPos )
-            nInvalidStart = nPos;
-        if ( nInvalidEnd > nPos )
+        if ( mnInvalidStart > nPos )
+            mnInvalidStart = nPos;
+        if ( mnInvalidEnd > nPos )
         {
-            if (nInvalidEnd > nEndPos)
-                nInvalidEnd = nInvalidEnd - nLength;
+            if (mnInvalidEnd > nEndPos)
+                mnInvalidEnd = mnInvalidEnd - nLength;
             else
-                nInvalidEnd = nPos+1;
+                mnInvalidEnd = nPos+1;
         }
     }
 
     for (WrongList::iterator i = begin(); i != end(); )
     {
         bool bDelWrong = false;
-        if (i->nEnd >= nPos)
+        if (i->mnEnd >= nPos)
         {
             // Move all Wrongs after the insert position...
-            if (i->nStart >= nEndPos)
+            if (i->mnStart >= nEndPos)
             {
-                i->nStart -= nLength;
-                i->nEnd -= nLength;
+                i->mnStart -= nLength;
+                i->mnEnd -= nLength;
             }
             // 1. Delete Internal Wrongs ...
-            else if (i->nStart >= nPos && i->nEnd <= nEndPos)
+            else if (i->mnStart >= nPos && i->mnEnd <= nEndPos)
             {
                 bDelWrong = true;
             }
             // 2. Wrong begins before, ends inside or behind it ...
-            else if (i->nStart <= nPos && i->nEnd > nPos)
+            else if (i->mnStart <= nPos && i->mnEnd > nPos)
             {
-                if (i->nEnd <= nEndPos)   // ends inside
-                    i->nEnd = nPos;
+                if (i->mnEnd <= nEndPos)   // ends inside
+                    i->mnEnd = nPos;
                 else
-                    i->nEnd -= nLength; // ends after
+                    i->mnEnd -= nLength; // ends after
             }
             // 3. Wrong begins inside, ending after ...
-            else if (i->nStart >= nPos && i->nEnd > nEndPos)
+            else if (i->mnStart >= nPos && i->mnEnd > nEndPos)
             {
-                i->nStart = nEndPos - nLength;
-                i->nEnd -= nLength;
+                i->mnStart = nEndPos - nLength;
+                i->mnEnd -= nLength;
             }
         }
-        SAL_WARN_IF(i->nStart >= i->nEnd, "editeng",
-                "TextDeleted, WrongRange: Start >= End?!");
+        SAL_WARN_IF(i->mnStart >= i->mnEnd, "editeng",
+                "TextDeleted, editeng::MisspellRange: Start >= End?!");
         if ( bDelWrong )
         {
             i = maRanges.erase(i);
@@ -370,7 +370,7 @@ void WrongList::TextDeleted( sal_uInt16 nPos, sal_uInt16 nLength )
     SAL_WARN_IF(DbgIsBuggy(), "editeng", "TextDeleted: WrongList broken!");
 }
 
-bool WrongList::NextWrong( sal_uInt16& rnStart, sal_uInt16& rnEnd ) const
+bool WrongList::NextWrong( size_t& rnStart, size_t& rnEnd ) const
 {
     /*
         rnStart get the start position, is possibly adjusted wrt. Wrong start
@@ -378,56 +378,56 @@ bool WrongList::NextWrong( sal_uInt16& rnStart, sal_uInt16& rnEnd ) const
     */
     for (WrongList::const_iterator i = begin(); i != end(); ++i)
     {
-        if ( i->nEnd > rnStart )
+        if (i->mnEnd > rnStart)
         {
-            rnStart = i->nStart;
-            rnEnd = i->nEnd;
+            rnStart = i->mnStart;
+            rnEnd = i->mnEnd;
             return true;
         }
     }
     return false;
 }
 
-bool WrongList::HasWrong( sal_uInt16 nStart, sal_uInt16 nEnd ) const
+bool WrongList::HasWrong( size_t nStart, size_t nEnd ) const
 {
     for (WrongList::const_iterator i = begin(); i != end(); ++i)
     {
-        if (i->nStart == nStart && i->nEnd == nEnd)
+        if (i->mnStart == nStart && i->mnEnd == nEnd)
             return true;
-        else if ( i->nStart >= nStart )
+        else if (i->mnStart >= nStart)
             break;
     }
     return false;
 }
 
-bool WrongList::HasAnyWrong( sal_uInt16 nStart, sal_uInt16 nEnd ) const
+bool WrongList::HasAnyWrong( size_t nStart, size_t nEnd ) const
 {
     for (WrongList::const_iterator i = begin(); i != end(); ++i)
     {
-        if (i->nEnd >= nStart && i->nStart < nEnd)
+        if (i->mnEnd >= nStart && i->mnStart < nEnd)
             return true;
-        else if (i->nStart >= nEnd)
+        else if (i->mnStart >= nEnd)
             break;
     }
     return false;
 }
 
-void WrongList::ClearWrongs( sal_uInt16 nStart, sal_uInt16 nEnd,
+void WrongList::ClearWrongs( size_t nStart, size_t nEnd,
             const ContentNode* pNode )
 {
     for (WrongList::iterator i = begin(); i != end(); )
     {
-        if (i->nEnd > nStart && i->nStart < nEnd)
+        if (i->mnEnd > nStart && i->mnStart < nEnd)
         {
-            if (i->nEnd > nEnd) // Runs out
+            if (i->mnEnd > nEnd) // Runs out
             {
-                i->nStart = nEnd;
+                i->mnStart = nEnd;
                 // Blanks?
-                while (i->nStart < pNode->Len() &&
-                       (pNode->GetChar(i->nStart) == ' ' ||
-                        pNode->IsFeature(i->nStart)))
+                while (i->mnStart < pNode->Len() &&
+                       (pNode->GetChar(i->mnStart) == ' ' ||
+                        pNode->IsFeature(i->mnStart)))
                 {
-                    ++(i->nStart);
+                    ++i->mnStart;
                 }
                 ++i;
             }
@@ -446,12 +446,12 @@ void WrongList::ClearWrongs( sal_uInt16 nStart, sal_uInt16 nEnd,
     SAL_WARN_IF(DbgIsBuggy(), "editeng", "ClearWrongs: WrongList broken!");
 }
 
-void WrongList::InsertWrong( sal_uInt16 nStart, sal_uInt16 nEnd )
+void WrongList::InsertWrong( size_t nStart, size_t nEnd )
 {
     WrongList::iterator nPos = end();
     for (WrongList::iterator i = begin(); i != end(); ++i)
     {
-        if (i->nStart >= nStart )
+        if (i->mnStart >= nStart)
         {
             nPos = i;
             {
@@ -459,18 +459,18 @@ void WrongList::InsertWrong( sal_uInt16 nStart, sal_uInt16 nEnd )
                 // and runs along, but not that there are several ranges ...
                 // Exactly in the range is no one allowed to be, otherwise this
                 // Method can not be called!
-                SAL_WARN_IF((i->nStart != nStart || i->nEnd <= nEnd) && i->nStart <= nEnd, "editeng", "InsertWrong: RangeMismatch!");
-                if (i->nStart == nStart && i->nEnd > nEnd)
-                    i->nStart = nEnd + 1;
+                SAL_WARN_IF((i->mnStart != nStart || i->mnEnd <= nEnd) && i->mnStart <= nEnd, "editeng", "InsertWrong: RangeMismatch!");
+                if (i->mnStart == nStart && i->mnEnd > nEnd)
+                    i->mnStart = nEnd + 1;
             }
             break;
         }
     }
 
     if (nPos != maRanges.end())
-        maRanges.insert(nPos, WrongRange(nStart, nEnd));
+        maRanges.insert(nPos, editeng::MisspellRange(nStart, nEnd));
     else
-        maRanges.push_back(WrongRange(nStart, nEnd));
+        maRanges.push_back(editeng::MisspellRange(nStart, nEnd));
 
     SAL_WARN_IF(DbgIsBuggy(), "editeng", "InsertWrong: WrongList broken!");
 }
@@ -478,7 +478,7 @@ void WrongList::InsertWrong( sal_uInt16 nStart, sal_uInt16 nEnd )
 void WrongList::MarkWrongsInvalid()
 {
     if (!maRanges.empty())
-        SetInvalidRange(maRanges.front().nStart, maRanges.back().nEnd);
+        SetInvalidRange(maRanges.front().mnStart, maRanges.back().mnEnd);
 }
 
 WrongList* WrongList::Clone() const
@@ -500,7 +500,7 @@ bool WrongList::operator==(const WrongList& rCompare) const
 
     for (; rCA != maRanges.end(); ++rCA, ++rCB)
     {
-        if(rCA->nStart != rCB->nStart || rCA->nEnd != rCB->nEnd)
+        if(rCA->mnStart != rCB->mnStart || rCA->mnEnd != rCB->mnEnd)
             return false;
     }
 
@@ -512,17 +512,17 @@ bool WrongList::empty() const
     return maRanges.empty();
 }
 
-void WrongList::push_back(const WrongRange& rRange)
+void WrongList::push_back(const editeng::MisspellRange& rRange)
 {
     maRanges.push_back(rRange);
 }
 
-WrongRange& WrongList::back()
+editeng::MisspellRange& WrongList::back()
 {
     return maRanges.back();
 }
 
-const WrongRange& WrongList::back() const
+const editeng::MisspellRange& WrongList::back() const
 {
     return maRanges.back();
 }
@@ -556,10 +556,10 @@ bool WrongList::DbgIsBuggy() const
         for (WrongList::const_iterator j = i + 1; !bError && (j != end()); ++j)
         {
             // 1) Start before, End after the second Start
-            if (i->nStart <= j->nStart && i->nEnd >= j->nStart)
+            if (i->mnStart <= j->mnStart && i->mnEnd >= j->mnStart)
                 bError = true;
             // 2) Start after the second Start, but still before the second End
-            else if (i->nStart >= j->nStart && i->nStart <= j->nEnd)
+            else if (i->mnStart >= j->mnStart && i->mnStart <= j->mnEnd)
                 bError = true;
         }
     }
diff --git a/editeng/source/editeng/edtspell.hxx b/editeng/source/editeng/edtspell.hxx
index 642bcfa..c79c2ac 100644
--- a/editeng/source/editeng/edtspell.hxx
+++ b/editeng/source/editeng/edtspell.hxx
@@ -25,6 +25,7 @@
 #include <editeng/splwrap.hxx>
 #include <editeng/svxacorr.hxx>
 #include <editeng/svxenum.hxx>
+#include "editeng/misspellrange.hxx"
 #include <tools/link.hxx>
 #include <vcl/outdev.hxx>
 
@@ -64,50 +65,44 @@ public:
 
 };
 
-
-struct WrongRange
-{
-    sal_uInt16 nStart;
-    sal_uInt16 nEnd;
-
-    WrongRange( sal_uInt16 nS, sal_uInt16 nE ) { nStart = nS; nEnd = nE; }
-};
-
+/**
+ * Keeps track of misspelled ranges in paragraph.
+ */
 class WrongList
 {
-    static sal_uInt16 Valid;
+    static size_t Valid;
 
-    std::vector<WrongRange> maRanges;
-    sal_uInt16  nInvalidStart;
-    sal_uInt16  nInvalidEnd;
+    std::vector<editeng::MisspellRange> maRanges;
+    size_t mnInvalidStart;
+    size_t mnInvalidEnd;
 
     bool DbgIsBuggy() const;
 
 public:
-    typedef std::vector<WrongRange>::iterator iterator;
-    typedef std::vector<WrongRange>::const_iterator const_iterator;
+    typedef std::vector<editeng::MisspellRange>::iterator iterator;
+    typedef std::vector<editeng::MisspellRange>::const_iterator const_iterator;
 
     WrongList();
     WrongList(const WrongList& r);
     ~WrongList();
 
     bool IsValid() const;
-    void    SetValid();
-    void SetInvalidRange( sal_uInt16 nStart, sal_uInt16 nEnd );
-    void ResetInvalidRange( sal_uInt16 nStart, sal_uInt16 nEnd );
+    void SetValid();
+    void SetInvalidRange( size_t nStart, size_t nEnd );
+    void ResetInvalidRange( size_t nStart, size_t nEnd );
 
-    sal_uInt16  GetInvalidStart() const { return nInvalidStart; }
-    sal_uInt16  GetInvalidEnd() const   { return nInvalidEnd; }
+    size_t GetInvalidStart() const { return mnInvalidStart; }
+    size_t GetInvalidEnd() const   { return mnInvalidEnd; }
 
-    void TextInserted( sal_uInt16 nPos, sal_uInt16 nLength, bool bPosIsSep );
-    void TextDeleted( sal_uInt16 nPos, sal_uInt16 nLength );
+    void TextInserted( size_t nPos, size_t nLength, bool bPosIsSep );
+    void TextDeleted( size_t nPos, size_t nLength );
 
-    void InsertWrong( sal_uInt16 nStart, sal_uInt16 nEnd );
-    bool NextWrong( sal_uInt16& rnStart, sal_uInt16& rnEnd ) const;
-    bool HasWrong( sal_uInt16 nStart, sal_uInt16 nEnd ) const;
-    bool HasAnyWrong( sal_uInt16 nStart, sal_uInt16 nEnd ) const;
-    void    ClearWrongs( sal_uInt16 nStart, sal_uInt16 nEnd, const ContentNode* pNode );
-    void    MarkWrongsInvalid();
+    void InsertWrong( size_t nStart, size_t nEnd );
+    bool NextWrong( size_t& rnStart, size_t& rnEnd ) const;
+    bool HasWrong( size_t nStart, size_t nEnd ) const;
+    bool HasAnyWrong( size_t nStart, size_t nEnd ) const;
+    void ClearWrongs( size_t nStart, size_t nEnd, const ContentNode* pNode );
+    void MarkWrongsInvalid();
 
     WrongList*  Clone() const;
 
@@ -115,9 +110,9 @@ public:
     bool operator==(const WrongList& rCompare) const;
 
     bool empty() const;
-    void push_back(const WrongRange& rRange);
-    WrongRange& back();
-    const WrongRange& back() const;
+    void push_back(const editeng::MisspellRange& rRange);
+    editeng::MisspellRange& back();
+    const editeng::MisspellRange& back() const;
 
     iterator begin();
     iterator end();
diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx
index c8b56f1..3a5fb7e 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -2235,10 +2235,10 @@ EditPaM ImpEditEngine::ImpConnectParagraphs( ContentNode* pLeft, ContentNode* pR
         WrongList* pRWrongs = pRight->GetWrongList();
         for (WrongList::iterator i = pRWrongs->begin(); i < pRWrongs->end(); ++i)
         {
-            if (i->nStart != 0)   // Not a subsequent
+            if (i->mnStart != 0)   // Not a subsequent
             {
-                i->nStart = i->nStart + nEnd;
-                i->nEnd = i->nEnd + nEnd;
+                i->mnStart = i->mnStart + nEnd;
+                i->mnEnd = i->mnEnd + nEnd;
                 pLeft->GetWrongList()->push_back(*i);
             }
         }
@@ -2821,15 +2821,15 @@ EditPaM ImpEditEngine::ImpInsertParaBreak( EditPaM& rPaM, bool bKeepEndingAttrib
         {
             // Correct only if really a word gets overlapped in the process of
             // Spell checking
-            if (i->nStart > nEnd)
+            if (i->mnStart > nEnd)
             {
                 pRWrongs->push_back(*i);
-                WrongRange& rRWrong = pRWrongs->back();
-                rRWrong.nStart = rRWrong.nStart - nEnd;
-                rRWrong.nEnd = rRWrong.nEnd - nEnd;
+                editeng::MisspellRange& rRWrong = pRWrongs->back();
+                rRWrong.mnStart = rRWrong.mnStart - nEnd;
+                rRWrong.mnEnd = rRWrong.mnEnd - nEnd;
             }
-            else if (i->nStart < nEnd && i->nEnd > nEnd)
-                i->nEnd = nEnd;
+            else if (i->mnStart < nEnd && i->mnEnd > nEnd)
+                i->mnEnd = nEnd;
         }
         sal_uInt16 nInv = nEnd ? nEnd-1 : nEnd;
         if ( nEnd )
diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx
index f2579f8..a3c68f5 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -169,8 +169,8 @@ static void lcl_DrawRedLines(
         else
             nStyle = WAVE_FLAT;
 
-        sal_uInt16 nEnd, nStart = nIndex;
-        sal_Bool bWrong = pWrongs->NextWrong( nStart, nEnd );
+        size_t nEnd, nStart = nIndex;
+        bool bWrong = pWrongs->NextWrong( nStart, nEnd );
         while ( bWrong )
         {
             if ( nStart >= nMaxEnd )
@@ -225,7 +225,7 @@ static void lcl_DrawRedLines(
             if ( nEnd < nMaxEnd )
                 bWrong = pWrongs->NextWrong( nStart, nEnd );
             else
-                bWrong = sal_False;
+                bWrong = false;
         }
     }
 }
@@ -3232,9 +3232,8 @@ void ImpEditEngine::Paint( OutputDevice* pOutDev, Rectangle aClipRect, Point aSt
 
                                         if(pWrongs && !pWrongs->empty())
                                         {
-                                            sal_uInt16 nStart(nIndex);
-                                            sal_uInt16 nEnd(0);
-                                            sal_Bool bWrong(pWrongs->NextWrong(nStart, nEnd));
+                                            size_t nStart = nIndex, nEnd = 0;
+                                            bool bWrong = pWrongs->NextWrong(nStart, nEnd);
                                             const sal_uInt16 nMaxEnd(nIndex + pTextPortion->GetLen());
 
                                             while(bWrong)
diff --git a/editeng/source/editeng/misspellrange.cxx b/editeng/source/editeng/misspellrange.cxx
new file mode 100644
index 0000000..0136705
--- /dev/null
+++ b/editeng/source/editeng/misspellrange.cxx
@@ -0,0 +1,19 @@
+/* -*- 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/.
+ */
+
+#include "editeng/misspellrange.hxx"
+
+namespace editeng {
+
+MisspellRange::MisspellRange() : mnStart(0), mnEnd(0) {}
+MisspellRange::MisspellRange(size_t nStart, size_t nEnd) : mnStart(nStart), mnEnd(nEnd) {}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/editeng/misspellrange.hxx b/include/editeng/misspellrange.hxx
new file mode 100644
index 0000000..103b58a
--- /dev/null
+++ b/include/editeng/misspellrange.hxx
@@ -0,0 +1,30 @@
+/* -*- 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/.
+ */
+
+#ifndef EDITENG_MISSPELLRANGE_HXX
+#define EDITENG_MISSPELLRANGE_HXX
+
+#include "editeng/editengdllapi.h"
+
+namespace editeng {
+
+struct EDITENG_DLLPUBLIC MisspellRange
+{
+    size_t mnStart;
+    size_t mnEnd;
+
+    MisspellRange();
+    MisspellRange(size_t nStart, size_t nEnd);
+};
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit ea59b6f5b922839e82f21727ab4d6c5d78176c0b
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Wed Aug 28 15:20:54 2013 -0400

    const correct-ness.
    
    Change-Id: If5c203844d245f370ac6fdb52c779561fb5f165f

diff --git a/editeng/source/editeng/editobj.cxx b/editeng/source/editeng/editobj.cxx
index b730e72..7d4b765 100644
--- a/editeng/source/editeng/editobj.cxx
+++ b/editeng/source/editeng/editobj.cxx
@@ -148,7 +148,7 @@ ContentInfo::~ContentInfo()
     aAttribs.clear();
 }
 
-WrongList* ContentInfo::GetWrongList() const
+const WrongList* ContentInfo::GetWrongList() const
 {
     return mpWrongs.get();
 }
diff --git a/editeng/source/editeng/editobj2.hxx b/editeng/source/editeng/editobj2.hxx
index 801abe8..c67fc8e 100644
--- a/editeng/source/editeng/editobj2.hxx
+++ b/editeng/source/editeng/editobj2.hxx
@@ -149,7 +149,7 @@ public:
     SfxItemSet&         GetParaAttribs()    { return aParaAttribs; }
     SfxStyleFamily&     GetFamily()         { return eFamily; }
 
-    WrongList* GetWrongList() const;
+    const WrongList* GetWrongList() const;
     void SetWrongList( WrongList* p );
     bool operator==( const ContentInfo& rCompare ) const;
     bool operator!=( const ContentInfo& rCompare ) const;
commit 97001b1e48ba663dce111d413bdcea0727061572
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Wed Aug 28 15:05:08 2013 -0400

    Use smart pointers for these.
    
    Change-Id: I1a1e38dd36b2144a3e6b96886a56a11a023c47fe

diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx
index 65de34a3..8cd17b7 100644
--- a/editeng/source/editeng/editdoc.cxx
+++ b/editeng/source/editeng/editdoc.cxx
@@ -1299,20 +1299,17 @@ sal_Bool operator != ( const EditPaM& r1,  const EditPaM& r2  )
 ContentNode::ContentNode( SfxItemPool& rPool ) : aContentAttribs( rPool )
 {
     DBG_CTOR( EE_ContentNode, 0 );
-    pWrongList = NULL;
 }
 
 ContentNode::ContentNode( const XubString& rStr, const ContentAttribs& rContentAttribs ) :
     maString(rStr), aContentAttribs(rContentAttribs)
 {
     DBG_CTOR( EE_ContentNode, 0 );
-    pWrongList = NULL;
 }
 
 ContentNode::~ContentNode()
 {
     DBG_DTOR( EE_ContentNode, 0 );
-    delete pWrongList;
 }
 
 void ContentNode::ExpandAttribs( sal_uInt16 nIndex, sal_uInt16 nNew, SfxItemPool& rItemPool )
@@ -1440,10 +1437,10 @@ void ContentNode::ExpandAttribs( sal_uInt16 nIndex, sal_uInt16 nNew, SfxItemPool
     if ( bResort )
         aCharAttribList.ResortAttribs();
 
-    if ( pWrongList )
+    if (mpWrongList)
     {
         bool bSep = ( maString.GetChar( nIndex ) == ' ' ) || IsFeature( nIndex );
-        pWrongList->TextInserted( nIndex, nNew, bSep );
+        mpWrongList->TextInserted( nIndex, nNew, bSep );
     }
 
 #if OSL_DEBUG_LEVEL > 2
@@ -1531,8 +1528,8 @@ void ContentNode::CollapsAttribs( sal_uInt16 nIndex, sal_uInt16 nDeleted, SfxIte
     if ( bResort )
         aCharAttribList.ResortAttribs();
 
-    if ( pWrongList )
-        pWrongList->TextDeleted( nIndex, nDeleted );
+    if (mpWrongList)
+        mpWrongList->TextDeleted(nIndex, nDeleted);
 
 #if OSL_DEBUG_LEVEL > 2
     OSL_ENSURE( CheckOrderedList( aCharAttribList.GetAttribs(), sal_True ), "Collaps: Start list distorted" );
@@ -1680,12 +1677,6 @@ void ContentNode::SetStyleSheet( SfxStyleSheet* pS, sal_Bool bRecalcFont )
         CreateDefFont();
 }
 
-void ContentNode::DestroyWrongList()
-{
-    delete pWrongList;
-    pWrongList = NULL;
-}
-
 bool ContentNode::IsFeature( sal_uInt16 nPos ) const
 {
     return maString.GetChar(nPos) == CH_FEATURE;
@@ -1741,16 +1732,31 @@ sal_Unicode ContentNode::GetChar(sal_uInt16 nPos) const
     return maString.GetChar(nPos);
 }
 
-void ContentNode::CreateWrongList()
+WrongList* ContentNode::GetWrongList()
+{
+    return mpWrongList.get();
+}
+
+const WrongList* ContentNode::GetWrongList() const
 {
-    DBG_ASSERT( !pWrongList, "WrongList already exist!" );
-    pWrongList = new WrongList;
+    return mpWrongList.get();
 }
 
 void ContentNode::SetWrongList( WrongList* p )
 {
-    DBG_ASSERT( !pWrongList, "WrongList already exist!" );
-    pWrongList = p;
+    DBG_ASSERT(!mpWrongList, "WrongList already exist!");
+    mpWrongList.reset(p);
+}
+
+void ContentNode::CreateWrongList()
+{
+    DBG_ASSERT(!mpWrongList, "WrongList already exist!");
+    mpWrongList.reset(new WrongList);
+}
+
+void ContentNode::DestroyWrongList()
+{
+    mpWrongList.reset();
 }
 
 ContentAttribs::ContentAttribs( SfxItemPool& rPool ) :
diff --git a/editeng/source/editeng/editdoc.hxx b/editeng/source/editeng/editdoc.hxx
index 485d976..1a6d1d0 100644
--- a/editeng/source/editeng/editdoc.hxx
+++ b/editeng/source/editeng/editdoc.hxx
@@ -34,6 +34,7 @@
 
 #include <boost/ptr_container/ptr_vector.hpp>
 #include <boost/noncopyable.hpp>
+#include <boost/scoped_ptr.hpp>
 
 class ImpEditEngine;
 class SvxTabStop;
@@ -258,7 +259,7 @@ private:
     XubString maString;
     ContentAttribs  aContentAttribs;
     CharAttribList  aCharAttribList;
-    WrongList*      pWrongList;
+    boost::scoped_ptr<WrongList> mpWrongList;
 
 public:
                     ContentNode( SfxItemPool& rItemPool );
@@ -282,9 +283,9 @@ public:
 
     void            CreateDefFont();
 
-    WrongList*      GetWrongList()          { return pWrongList; }
-    const WrongList* GetWrongList() const { return pWrongList; }
-    void            SetWrongList( WrongList* p );
+    WrongList* GetWrongList();
+    const WrongList* GetWrongList() const;
+    void SetWrongList( WrongList* p );
 
     void            CreateWrongList();
     void            DestroyWrongList();
diff --git a/editeng/source/editeng/editobj.cxx b/editeng/source/editeng/editobj.cxx
index 0a67009..b730e72 100644
--- a/editeng/source/editeng/editobj.cxx
+++ b/editeng/source/editeng/editobj.cxx
@@ -112,22 +112,21 @@ const XParaPortion& XParaPortionList::operator [](size_t i) const
     return maList[i];
 }
 
-ContentInfo::ContentInfo( SfxItemPool& rPool ) : aParaAttribs( rPool, EE_PARA_START, EE_CHAR_END )
+ContentInfo::ContentInfo( SfxItemPool& rPool ) :
+    eFamily(SFX_STYLE_FAMILY_PARA),
+    aParaAttribs(rPool, EE_PARA_START, EE_CHAR_END)
 {
-    eFamily = SFX_STYLE_FAMILY_PARA;
-    pWrongs = NULL;
 }
 
 // the real Copy constructor is nonsens, since I have to work with another Pool!
-ContentInfo::ContentInfo( const ContentInfo& rCopyFrom, SfxItemPool& rPoolToUse )
-    : aParaAttribs( rPoolToUse, EE_PARA_START, EE_CHAR_END )
-    , pWrongs(0)
+ContentInfo::ContentInfo( const ContentInfo& rCopyFrom, SfxItemPool& rPoolToUse ) :
+    aText(rCopyFrom.aText),
+    aStyle(rCopyFrom.aStyle),
+    eFamily(rCopyFrom.eFamily),
+    aParaAttribs(rPoolToUse, EE_PARA_START, EE_CHAR_END)
 {
     // this should ensure that the Items end up in the correct Pool!
     aParaAttribs.Set( rCopyFrom.GetParaAttribs() );
-    aText = rCopyFrom.GetText();
-    aStyle = rCopyFrom.GetStyle();
-    eFamily = rCopyFrom.GetFamily();
 
     for (size_t i = 0; i < rCopyFrom.aAttribs.size(); ++i)
     {
@@ -138,7 +137,7 @@ ContentInfo::ContentInfo( const ContentInfo& rCopyFrom, SfxItemPool& rPoolToUse
     }
 
     if ( rCopyFrom.GetWrongList() )
-        pWrongs = rCopyFrom.GetWrongList()->Clone();
+        mpWrongs.reset(rCopyFrom.GetWrongList()->Clone());
 }
 
 ContentInfo::~ContentInfo()
@@ -147,8 +146,16 @@ ContentInfo::~ContentInfo()
     for (; it != itEnd; ++it)
         aParaAttribs.GetPool()->Remove(*it->GetItem());
     aAttribs.clear();
+}
 
-    delete pWrongs;
+WrongList* ContentInfo::GetWrongList() const
+{
+    return mpWrongs.get();
+}
+
+void ContentInfo::SetWrongList( WrongList* p )
+{
+    mpWrongs.reset(p);
 }
 
 // #i102062#
diff --git a/editeng/source/editeng/editobj2.hxx b/editeng/source/editeng/editobj2.hxx
index 8d7fd6d..801abe8 100644
--- a/editeng/source/editeng/editobj2.hxx
+++ b/editeng/source/editeng/editobj2.hxx
@@ -27,6 +27,7 @@
 
 #include <boost/ptr_container/ptr_vector.hpp>
 #include <boost/noncopyable.hpp>
+#include <boost/scoped_ptr.hpp>
 
 namespace editeng {
 
@@ -114,7 +115,7 @@ public:
 
 };
 
-class ContentInfo
+class ContentInfo : boost::noncopyable
 {
     friend class EditTextObjectImpl;
 public:
@@ -127,7 +128,7 @@ private:
     XEditAttributesType aAttribs;
     SfxStyleFamily      eFamily;
     SfxItemSet          aParaAttribs;
-    WrongList*          pWrongs;
+    boost::scoped_ptr<WrongList> mpWrongs;
 
                         ContentInfo( SfxItemPool& rPool );
                         ContentInfo( const ContentInfo& rCopyFrom, SfxItemPool& rPoolToUse  );
@@ -148,8 +149,8 @@ public:
     SfxItemSet&         GetParaAttribs()    { return aParaAttribs; }
     SfxStyleFamily&     GetFamily()         { return eFamily; }
 
-    WrongList*          GetWrongList() const            { return pWrongs; }
-    void                SetWrongList( WrongList* p )    { pWrongs = p; }
+    WrongList* GetWrongList() const;
+    void SetWrongList( WrongList* p );
     bool operator==( const ContentInfo& rCompare ) const;
     bool operator!=( const ContentInfo& rCompare ) const;
 
diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx
index 3b5bac3..004bdcb 100644
--- a/editeng/source/editeng/impedit4.cxx
+++ b/editeng/source/editeng/impedit4.cxx
@@ -1373,7 +1373,6 @@ EditSelection ImpEditEngine::InsertTextObject( const EditTextObject& rTextObject
 
         if ( bNewContent && GetStatus().DoOnlineSpelling() && pC->GetWrongList() )
         {
-            aPaM.GetNode()->DestroyWrongList(); // otherwise MLK, if list exists...
             aPaM.GetNode()->SetWrongList( pC->GetWrongList()->Clone() );
         }
 


More information about the Libreoffice-commits mailing list