[Libreoffice-commits] core.git: 3 commits - editeng/source i18npool/source sw/inc sw/source

Michael Stahl mstahl at redhat.com
Tue Mar 10 16:25:28 PDT 2015


 editeng/source/misc/acorrcfg.cxx      |    2 ++
 i18npool/source/search/textsearch.cxx |   25 +++++++++++++++++++++----
 sw/inc/crsrsh.hxx                     |    6 +++---
 sw/inc/editsh.hxx                     |    6 +++---
 sw/source/uibase/inc/wrtsh.hxx        |    6 +++---
 sw/source/uibase/uiview/viewling.cxx  |   10 +++++-----
 sw/source/uibase/wrtsh/select.cxx     |    4 ++--
 7 files changed, 39 insertions(+), 20 deletions(-)

New commits:
commit d1698027e9f1c4a88b17da7357f257be3cfb7c1a
Author: Michael Stahl <mstahl at redhat.com>
Date:   Tue Mar 10 23:56:55 2015 +0100

    tdf#89867: editeng: fix crash on shutdown after changing AutoCorrect options
    
    Since commit 5bff4b016c4b44f4123e0e6a4fd4c0c4dc0cfa2d the
    SvxAutoCorrCfg::pAutoCorrect is cleared by one terminate() listener but
    then another terminate() listener calls Commit() on all modified
    utl::ConfigItem and these two have a Commit() that does not clear the
    modified flag so they are always modified.
    
    Sadly there's no non-virtual Commit() wrapper that
    calls ClearModified() on the base class...
    
    Change-Id: I9ae220d78bb109c7bf0fdc544754a0686b357115

diff --git a/editeng/source/misc/acorrcfg.cxx b/editeng/source/misc/acorrcfg.cxx
index dce7df4..9ca989c 100644
--- a/editeng/source/misc/acorrcfg.cxx
+++ b/editeng/source/misc/acorrcfg.cxx
@@ -321,6 +321,7 @@ void SvxBaseAutoCorrCfg::Commit()
         }
     }
     PutProperties(aNames, aValues);
+    ClearModified();
 }
 
 void SvxBaseAutoCorrCfg::Notify( const Sequence<OUString>& /* aPropertyNames */)
@@ -640,6 +641,7 @@ void SvxSwAutoCorrCfg::Commit()
         }
     }
     PutProperties(aNames, aValues);
+    ClearModified();
 }
 
 void SvxSwAutoCorrCfg::Notify( const Sequence<OUString>& /* aPropertyNames */ )
commit 9aae521b451269007f03527c83645b8b935eb419
Author: Michael Stahl <mstahl at redhat.com>
Date:   Tue Mar 10 23:19:18 2015 +0100

    i18npool: fix spurious regex ^ matching in TextSearch::searchForward()
    
    Thanks to Eike for finding this:
    
    The anchors ^ and $ now anchor at the selection boundary because the
    only text the regex matcher gets passed is the selected text. This in
    two paragraphs
    
     aaa bbb aaa bbb
     aaa bbb aaa bbb
    
    when the selection spans from the second aaa to the third bbb, for
    "^aaa" finds the second aaa, where previously it found the third aaa at
    the real paragraph start.
    
    This may not be expected by the user, because the behavior of ^ is
    described as "Match at the beginning of a line" (or paragraph in our
    case), which the previous implementation did.
    
    (regression from 806ced87cfe3da72df0d8e4faf5b82535fc7d1b7)
    
    Unfortunately it's not obvious how to implement the same in
    searchBackward().
    
    Change-Id: I07f7a8476b672d9511fa74ca473c32eea427698f

diff --git a/i18npool/source/search/textsearch.cxx b/i18npool/source/search/textsearch.cxx
index 8dda89d..fb1dd25 100644
--- a/i18npool/source/search/textsearch.cxx
+++ b/i18npool/source/search/textsearch.cxx
@@ -242,13 +242,26 @@ SearchResult TextSearch::searchForward( const OUString& searchStr, sal_Int32 sta
         in_str = xTranslit->transliterate( searchStr, startPos, endPos - startPos, offset );
 
         // JP 20.6.2001: also the start and end positions must be corrected!
-        sal_Int32 const newStartPos =
+        sal_Int32 newStartPos =
             (startPos == 0) ? 0 : FindPosInSeq_Impl( offset, startPos );
 
-        sal_Int32 const newEndPos = (endPos < searchStr.getLength())
+        sal_Int32 newEndPos = (endPos < searchStr.getLength())
             ? FindPosInSeq_Impl( offset, endPos )
             : in_str.getLength();
 
+        sal_Int32 nExtraOffset = 0;
+        if (pRegexMatcher && startPos > 0)
+        {
+            // avoid matching ^ here - in_str omits a prefix of the searchStr
+            // this is a really lame way to do it, but ICU only offers
+            // useAnchoringBounds() to disable *both* bounds but what is needed
+            // here is to disable only one bound and respect the other
+            in_str = "X" + in_str;
+            nExtraOffset = 1;
+            newStartPos += nExtraOffset;
+            newEndPos += nExtraOffset;
+        }
+
         sres = (this->*fnForward)( in_str, newStartPos, newEndPos );
 
         // Map offsets back to untransliterated string.
@@ -260,14 +273,14 @@ SearchResult TextSearch::searchForward( const OUString& searchStr, sal_Int32 sta
             const sal_Int32 nGroups = sres.startOffset.getLength();
             for ( sal_Int32 k = 0; k < nGroups; k++ )
             {
-                const sal_Int32 nStart = sres.startOffset[k];
+                const sal_Int32 nStart = sres.startOffset[k] - nExtraOffset;
                 if (startPos > 0 || nStart > 0)
                     sres.startOffset[k] = (nStart < nOffsets ? offset[nStart] : (offset[nOffsets - 1] + 1));
                 // JP 20.6.2001: end is ever exclusive and then don't return
                 //               the position of the next character - return the
                 //               next position behind the last found character!
                 //               "a b c" find "b" must return 2,3 and not 2,4!!!
-                const sal_Int32 nStop = sres.endOffset[k];
+                const sal_Int32 nStop = sres.endOffset[k] - nExtraOffset;
                 if (startPos > 0 || nStop > 0)
                     sres.endOffset[k] = offset[(nStop <= nOffsets ? nStop : nOffsets) - 1] + 1;
             }
@@ -345,6 +358,10 @@ SearchResult TextSearch::searchBackward( const OUString& searchStr, sal_Int32 st
         sal_Int32 const newEndPos =
             (endPos == 0) ? 0 : FindPosInSeq_Impl( offset, endPos );
 
+        // TODO: this would need nExtraOffset handling to avoid $ matching
+        // if (pRegexMatcher && startPos < searchStr.getLength())
+        // but that appears to be impossible with ICU regex
+
         sres = (this->*fnBackward)( in_str, newStartPos, newEndPos );
 
         // Map offsets back to untransliterated string.
commit df1c65b8fa8f7bb13618226745eaff7a8eeffd14
Author: Michael Stahl <mstahl at redhat.com>
Date:   Tue Mar 10 16:29:21 2015 +0100

    sw: s/eEnde/eEnd/
    
    Change-Id: I9ea963d09c2975b8e40856e3ba2d3896be9a1876

diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx
index 13489ce..01f5a8a 100644
--- a/sw/inc/crsrsh.hxx
+++ b/sw/inc/crsrsh.hxx
@@ -376,17 +376,17 @@ public:
 
     sal_uLong Find( const com::sun::star::util::SearchOptions& rSearchOpt,
                 bool bSearchInNotes,
-                SwDocPositions eStart, SwDocPositions eEnde,
+                SwDocPositions eStart, SwDocPositions eEnd,
                 bool& bCancel,
                 FindRanges eRng, bool bReplace = false );
 
     sal_uLong Find( const SwTxtFmtColl& rFmtColl,
-                SwDocPositions eStart, SwDocPositions eEnde,
+                SwDocPositions eStart, SwDocPositions eEnd,
                 bool& bCancel,
                 FindRanges eRng, const SwTxtFmtColl* pReplFmt = 0 );
 
     sal_uLong Find( const SfxItemSet& rSet, bool bNoCollections,
-                SwDocPositions eStart, SwDocPositions eEnde,
+                SwDocPositions eStart, SwDocPositions eEnd,
                 bool& bCancel,
                 FindRanges eRng,
                 const com::sun::star::util::SearchOptions* pSearchOpt = 0,
diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx
index 7c2e9e3..2beeb3d 100644
--- a/sw/inc/editsh.hxx
+++ b/sw/inc/editsh.hxx
@@ -663,7 +663,7 @@ public:
 
     // Linguistics...
     /// Save selections.
-    void HyphStart( SwDocPositions eStart, SwDocPositions eEnde );
+    void HyphStart( SwDocPositions eStart, SwDocPositions eEnd );
 
     /// restore selections.
     void HyphEnd();
@@ -721,7 +721,7 @@ public:
     /// Functions used for spell checking and text conversion.
 
     /// Save selections.
-    void SpellStart( SwDocPositions eStart, SwDocPositions eEnde,
+    void SpellStart( SwDocPositions eStart, SwDocPositions eEnd,
                      SwDocPositions eCurr, SwConversionArgs *pConvArgs = 0 );
 
     /// Restore selections.
@@ -763,7 +763,7 @@ public:
             const Point* pPt, SwRect& rSelectRect );
 
     void IgnoreGrammarErrorAt( SwPaM& rErrorPosition );
-    void SetLinguRange( SwDocPositions eStart, SwDocPositions eEnde );
+    void SetLinguRange( SwDocPositions eStart, SwDocPositions eEnd );
 
     /// @return reference set in document according to given name.
     const SwFmtRefMark* GetRefMark( const OUString& rName ) const;
diff --git a/sw/source/uibase/inc/wrtsh.hxx b/sw/source/uibase/inc/wrtsh.hxx
index e1b312e..2e7c4cd 100644
--- a/sw/source/uibase/inc/wrtsh.hxx
+++ b/sw/source/uibase/inc/wrtsh.hxx
@@ -366,18 +366,18 @@ typedef bool (SwWrtShell:: *FNSimpleMove)();
     // search and replace
     sal_uLong SearchPattern(const com::sun::star::util::SearchOptions& rSearchOpt,
                          bool bSearchInNotes,
-                         SwDocPositions eStart, SwDocPositions eEnde,
+                         SwDocPositions eStart, SwDocPositions eEnd,
                          FindRanges eFlags = FND_IN_BODY,
                          bool bReplace = false );
 
     sal_uLong SearchTempl  (const OUString &rTempl,
-                         SwDocPositions eStart, SwDocPositions eEnde,
+                         SwDocPositions eStart, SwDocPositions eEnd,
                          FindRanges eFlags = FND_IN_BODY,
                          const OUString* pReplTempl = 0 );
 
     sal_uLong SearchAttr   (const SfxItemSet& rFindSet,
                          bool bNoColls,
-                         SwDocPositions eStart,SwDocPositions eEnde,
+                         SwDocPositions eStart, SwDocPositions eEnd,
                          FindRanges eFlags = FND_IN_BODY,
                          const com::sun::star::util::SearchOptions* pSearchOpt = 0,
                          const SfxItemSet* pReplaceSet = 0);
diff --git a/sw/source/uibase/uiview/viewling.cxx b/sw/source/uibase/uiview/viewling.cxx
index 9003e42..13f5478 100644
--- a/sw/source/uibase/uiview/viewling.cxx
+++ b/sw/source/uibase/uiview/viewling.cxx
@@ -272,7 +272,7 @@ void SwView::SpellStart( SvxSpellArea eWhich,
     bool bIsWrapReverse = !pConvArgs && xProp.is() && xProp->getIsWrapReverse();
 
     SwDocPositions eStart = DOCPOS_START;
-    SwDocPositions eEnde  = DOCPOS_END;
+    SwDocPositions eEnd   = DOCPOS_END;
     SwDocPositions eCurr  = DOCPOS_CURR;
     switch ( eWhich )
     {
@@ -296,7 +296,7 @@ void SwView::SpellStart( SvxSpellArea eWhich,
             if( !bIsWrapReverse )
             {
                 if( bEndDone )
-                    eEnde = DOCPOS_CURR;
+                    eEnd = DOCPOS_CURR;
                 eCurr = DOCPOS_START;
             }
             else if( bEndDone )
@@ -306,20 +306,20 @@ void SwView::SpellStart( SvxSpellArea eWhich,
             if( bIsWrapReverse )
             {
                 eStart = DOCPOS_OTHERSTART;
-                eEnde  = DOCPOS_OTHEREND;
+                eEnd  = DOCPOS_OTHEREND;
                 eCurr = DOCPOS_OTHEREND;
             }
             else
             {
                 eStart = DOCPOS_OTHERSTART;
-                eEnde  = DOCPOS_OTHEREND;
+                eEnd  = DOCPOS_OTHEREND;
                 eCurr = DOCPOS_OTHERSTART;
             }
             break;
         default:
             OSL_ENSURE( false, "SpellStart with unknown Area" );
     }
-    m_pWrtShell->SpellStart( eStart, eEnde, eCurr, pConvArgs );
+    m_pWrtShell->SpellStart( eStart, eEnd, eCurr, pConvArgs );
 }
 
 // Error message while Spelling
diff --git a/sw/source/uibase/wrtsh/select.cxx b/sw/source/uibase/wrtsh/select.cxx
index b1ad26d..f438df4 100644
--- a/sw/source/uibase/wrtsh/select.cxx
+++ b/sw/source/uibase/wrtsh/select.cxx
@@ -255,7 +255,7 @@ sal_uLong SwWrtShell::SearchTempl( const OUString &rTempl,
 // search for attributes
 
 sal_uLong SwWrtShell::SearchAttr( const SfxItemSet& rFindSet, bool bNoColls,
-                                SwDocPositions eStart, SwDocPositions eEnde,
+                                SwDocPositions eStart, SwDocPositions eEnd,
                                 FindRanges eFlags, const SearchOptions* pSearchOpt,
                                 const SfxItemSet* pReplaceSet )
 {
@@ -265,7 +265,7 @@ sal_uLong SwWrtShell::SearchAttr( const SfxItemSet& rFindSet, bool bNoColls,
 
     // Searching
     bool bCancel = false;
-    sal_uLong nRet = Find( rFindSet, bNoColls, eStart, eEnde, bCancel, eFlags, pSearchOpt, pReplaceSet);
+    sal_uLong nRet = Find( rFindSet, bNoColls, eStart, eEnd, bCancel, eFlags, pSearchOpt, pReplaceSet);
 
     if(bCancel)
     {


More information about the Libreoffice-commits mailing list