[ooo-build-commit] .: 9 commits - sw/inc sw/source

Jan Holesovsky kendy at kemper.freedesktop.org
Wed Sep 8 08:38:16 PDT 2010


 sw/inc/undobj.hxx                 |    6 
 sw/source/core/doc/docedt.cxx     |   33 +++-
 sw/source/core/txtnode/txtedt.cxx |  271 +++++++++++++++++++++++++++++++++-----
 sw/source/core/undo/makefile.mk   |    1 
 sw/source/core/undo/unovwr.cxx    |  136 ++++++++-----------
 sw/source/ui/lingu/olmenu.cxx     |    2 
 6 files changed, 328 insertions(+), 121 deletions(-)

New commits:
commit 290f7aba51f626e259764487fec8795ef6b4043a
Merge: d3ae4c6... 4937fcb...
Author: Jan Holesovsky <kendy at suse.cz>
Date:   Wed Sep 8 11:34:21 2010 +0200

    Merge commit 'ooo/OOO330_m7'

commit d3ae4c683dda23722661cad8b5992586d2883bd0
Merge: e0b0ca3... 17b62cb...
Author: Jan Holesovsky <kendy at suse.cz>
Date:   Tue Sep 7 09:33:10 2010 +0200

    Merge commit 'ooo/OOO330_m6'

commit 4937fcb1c4fa15194c01a79c57523d9a9333c710
Merge: 17b62cb... 3274d37...
Author: Kurt Zenker <kz at openoffice.org>
Date:   Fri Sep 3 14:39:55 2010 +0200

    CWS-TOOLING: integrate CWS fs33a

commit 17b62cb5acad25dc82a95a40d545e6af6a185f55
Author: obo <obo at openoffice.org>
Date:   Fri Aug 27 13:02:34 2010 +0200

    masterfix OOO330: #i10000# new exception file unovwr.cxx

diff --git a/sw/source/core/undo/makefile.mk b/sw/source/core/undo/makefile.mk
index d6e6766..c381761 100644
--- a/sw/source/core/undo/makefile.mk
+++ b/sw/source/core/undo/makefile.mk
@@ -49,6 +49,7 @@ EXCEPTIONSFILES = \
         $(SLO)$/unattr.obj \
         $(SLO)$/undobj.obj \
         $(SLO)$/undraw.obj \
+        $(SLO)$/unovwr.obj \
         $(SLO)$/untbl.obj
 
 SLOFILES =	\
commit a3019ec68acb22c8f590ee104fd6e7aad20c4778
Merge: aa24f45... 631d42d...
Author: Ivo Hinkelmann <ihi at openoffice.org>
Date:   Wed Aug 25 14:19:19 2010 +0200

    CWS-TOOLING: integrate CWS sw33bf08

commit 631d42da043d690b931e3750176a3a295b376c7e
Author: Thomas Lange [tl] <tl at openoffice.org>
Date:   Tue Aug 17 16:46:36 2010 +0200

    cws sw33bf08: #i113584#, #i113587# transliteration fixed

diff --git a/sw/inc/undobj.hxx b/sw/inc/undobj.hxx
index 0fe4953..c05cfcd 100644
--- a/sw/inc/undobj.hxx
+++ b/sw/inc/undobj.hxx
@@ -27,9 +27,7 @@
 #ifndef SW_UNDOBJ_HXX
 #define SW_UNDOBJ_HXX
 
-// --> OD 2006-11-01 #130889#
 #include <vector>
-// <--
 #include <memory>
 
 #include <boost/shared_ptr.hpp>
@@ -1718,7 +1716,7 @@ public:
 struct _UndoTransliterate_Data;
 class SwUndoTransliterate : public SwUndo, public SwUndRng
 {
-    _UndoTransliterate_Data *pData, *pLastData;
+    std::vector< _UndoTransliterate_Data * >    aChanges;
     sal_uInt32 nType;
 
 public:
@@ -1732,7 +1730,7 @@ public:
 
     void AddChanges( SwTxtNode& rTNd, xub_StrLen nStart, xub_StrLen nLen,
                      ::com::sun::star::uno::Sequence <sal_Int32>& rOffsets );
-    BOOL HasData() const {return 0 != pData; }
+    BOOL HasData() const { return aChanges.size() > 0; }
 };
 
 //--------------------------------------------------------------------
diff --git a/sw/source/core/doc/docedt.cxx b/sw/source/core/doc/docedt.cxx
index 08fc968..6413ef7 100644
--- a/sw/source/core/doc/docedt.cxx
+++ b/sw/source/core/doc/docedt.cxx
@@ -38,6 +38,7 @@
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/i18n/WordType.hdl>
 #include <unotools/charclass.hxx>
+#include <unotools/transliterationwrapper.hxx>
 #include <fmtanchr.hxx>
 #include <fmtcntnt.hxx>
 #include <fmtpdsc.hxx>
@@ -72,6 +73,8 @@
 #include <unoflatpara.hxx>
 #include <SwGrammarMarkUp.hxx>
 
+#include <vector>
+
 using ::rtl::OUString;
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::linguistic2;
@@ -2653,8 +2656,9 @@ bool SwDoc::DelFullPara( SwPaM& rPam )
 }
 
 
-void SwDoc::TransliterateText( const SwPaM& rPaM,
-                                utl::TransliterationWrapper& rTrans )
+void SwDoc::TransliterateText( 
+    const SwPaM& rPaM,
+    utl::TransliterationWrapper& rTrans )
 {
     SwUndoTransliterate* pUndo;
     if( DoesUndo() )
@@ -2663,15 +2667,17 @@ void SwDoc::TransliterateText( const SwPaM& rPaM,
         pUndo = 0;
 
     const SwPosition* pStt = rPaM.Start(),
-                    * pEnd = pStt == rPaM.GetPoint() ? rPaM.GetMark()
-                                                     : rPaM.GetPoint();
-    ULONG nSttNd = pStt->nNode.GetIndex(), nEndNd = pEnd->nNode.GetIndex();
+                       * pEnd = rPaM.End();
+    ULONG nSttNd = pStt->nNode.GetIndex(), 
+          nEndNd = pEnd->nNode.GetIndex();
     xub_StrLen nSttCnt = pStt->nContent.GetIndex(),
                nEndCnt = pEnd->nContent.GetIndex();
 
     SwTxtNode* pTNd = pStt->nNode.GetNode().GetTxtNode();
-    if( pStt == pEnd && pTNd )			        // no region ?
+    if( pStt == pEnd && pTNd )  // no selection? 
     {
+        // set current word as 'area of effect'
+
         Boundary aBndry;
         if( pBreakIt->GetBreakIter().is() )
             aBndry = pBreakIt->GetBreakIter()->getWordBoundary(
@@ -2687,21 +2693,24 @@ void SwDoc::TransliterateText( const SwPaM& rPaM,
         }
     }
 
-    if( nSttNd != nEndNd )
+    if( nSttNd != nEndNd )  // is more than one text node involved?
     {
+        // iterate over all effected text nodes, the first and the last one
+        // may be incomplete because the selection starts and/or ends there
+
         SwNodeIndex aIdx( pStt->nNode );
         if( nSttCnt )
         {
             aIdx++;
             if( pTNd )
-                pTNd->TransliterateText( rTrans, nSttCnt,
-                                            pTNd->GetTxt().Len(), pUndo );
+                pTNd->TransliterateText( rTrans, nSttCnt, pTNd->GetTxt().Len(), pUndo );
         }
 
         for( ; aIdx.GetIndex() < nEndNd; aIdx++ )
+        {
             if( 0 != ( pTNd = aIdx.GetNode().GetTxtNode() ))
-                pTNd->TransliterateText( rTrans, 0, pTNd->GetTxt().Len(),
-                                        pUndo );
+                pTNd->TransliterateText( rTrans, 0, pTNd->GetTxt().Len(), pUndo );
+        }
 
         if( nEndCnt && 0 != ( pTNd = pEnd->nNode.GetNode().GetTxtNode() ))
             pTNd->TransliterateText( rTrans, 0, nEndCnt, pUndo );
@@ -2721,6 +2730,8 @@ void SwDoc::TransliterateText( const SwPaM& rPaM,
     }
     SetModified();
 }
+
+
 #define MAX_REDLINE_COUNT	250
 // -----------------------------------------------------------------------------
 void SwDoc::checkRedlining(RedlineMode_t& _rReadlineMode)
diff --git a/sw/source/core/txtnode/txtedt.cxx b/sw/source/core/txtnode/txtedt.cxx
index e3f5fdc..19af890 100644
--- a/sw/source/core/txtnode/txtedt.cxx
+++ b/sw/source/core/txtnode/txtedt.cxx
@@ -36,6 +36,7 @@
     #include <time.h> 			// clock()
     #include <tools/stream.hxx>
 #endif
+
 #include <hintids.hxx>
 #include <vcl/svapp.hxx>
 #include <svl/itemiter.hxx>
@@ -46,9 +47,6 @@
 #include <editeng/hangulhanja.hxx>
 #include <SwSmartTagMgr.hxx>
 #include <linguistic/lngprops.hxx>
-#include <com/sun/star/beans/XPropertySet.hpp>
-#include <com/sun/star/i18n/WordType.hdl>
-#include <com/sun/star/i18n/ScriptType.hdl>
 #include <unotools/transliterationwrapper.hxx>
 #include <unotools/charclass.hxx>
 #include <dlelstnr.hxx>
@@ -86,6 +84,15 @@
 
 #include <unomid.h>
 
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/i18n/WordType.hdl>
+#include <com/sun/star/i18n/ScriptType.hdl>
+#include <com/sun/star/i18n/TransliterationModules.hpp>
+#include <com/sun/star/i18n/TransliterationModulesExtra.hpp>
+
+#include <vector>
+
+
 using rtl::OUString;
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::frame;
@@ -1578,49 +1585,247 @@ void SwLinguStatistik::Flush()
 
 #endif
 
+
+struct TransliterationChgData
+{
+    xub_StrLen              nStart;
+    xub_StrLen              nLen;
+    String                  sChanged;
+    Sequence< sal_Int32 >   aOffsets;
+};
+
 // change text to Upper/Lower/Hiragana/Katagana/...
-void SwTxtNode::TransliterateText( utl::TransliterationWrapper& rTrans,
-        xub_StrLen nStt, xub_StrLen nEnd, SwUndoTransliterate* pUndo )
+void SwTxtNode::TransliterateText( 
+    utl::TransliterationWrapper& rTrans,
+    xub_StrLen nStt, xub_StrLen nEnd, 
+    SwUndoTransliterate* pUndo )
 {
-    if( nStt < nEnd )
+    if (nStt < nEnd && pBreakIt->GetBreakIter().is())
     {
-        SwLanguageIterator* pIter;
-        if( rTrans.needLanguageForTheMode() )
-            pIter = new SwLanguageIterator( *this, nStt );
-        else
-            pIter = 0;
+        // since we don't use Hiragana/Katakana or half-width/full-width transliterations here
+        // it is fine to use ANYWORD_IGNOREWHITESPACES. (ANY_WORD btw is broken and will 
+        // occasionaly miss words in consecutive sentences). Also with ANYWORD_IGNOREWHITESPACES
+        // text like 'just-in-time' will be converted to 'Just-In-Time' which seems to be the
+        // proper thing to do.
+        const sal_Int16 nWordType = WordType::ANYWORD_IGNOREWHITESPACES;
+
+        //! In order to have less trouble with changing text size, e.g. because
+        //! of ligatures or � (German small sz) being resolved, we need to process 
+        //! the text replacements from end to start. 
+        //! This way the offsets for the yet to be changed words will be 
+        //! left unchanged by the already replaced text. 
+        //! For this we temporarily save the changes to be done in this vector
+        std::vector< TransliterationChgData >   aChanges;
+        TransliterationChgData                  aChgData;
+
+        if (rTrans.getType() == (sal_uInt32)TransliterationModulesExtra::TITLE_CASE)
+        {
+            // for 'capitalize every word' we need to iterate over each word
+
+            Boundary aSttBndry;
+            Boundary aEndBndry;
+            aSttBndry = pBreakIt->GetBreakIter()->getWordBoundary(
+                        GetTxt(), nStt,
+                        pBreakIt->GetLocale( GetLang( nStt ) ),
+                        nWordType,
+                        TRUE /*prefer forward direction*/);
+            aEndBndry = pBreakIt->GetBreakIter()->getWordBoundary(
+                        GetTxt(), nEnd,
+                        pBreakIt->GetLocale( GetLang( nEnd ) ),
+                        nWordType,
+                        FALSE /*prefer backward direction*/);
+
+            // prevent backtracking to the previous word if selection is at word boundary
+            if (aSttBndry.endPos <= nStt)
+            {
+                aSttBndry = pBreakIt->GetBreakIter()->nextWord(
+                        GetTxt(), aSttBndry.endPos,
+                        pBreakIt->GetLocale( GetLang( aSttBndry.endPos ) ),
+                        nWordType);
+            }
+            // prevent advancing to the next word if selection is at word boundary
+            if (aEndBndry.startPos >= nEnd)
+            {
+                aEndBndry = pBreakIt->GetBreakIter()->previousWord(
+                        GetTxt(), aEndBndry.startPos,
+                        pBreakIt->GetLocale( GetLang( aEndBndry.startPos ) ),
+                        nWordType);
+            }
 
-        xub_StrLen nEndPos;
-        sal_uInt16 nLang;
-        do {
-            if( pIter )
+            Boundary aCurWordBndry( aSttBndry );
+            while (aCurWordBndry.startPos <= aEndBndry.startPos)
             {
-                nLang = pIter->GetLanguage();
-                nEndPos = pIter->GetChgPos();
-                if( nEndPos > nEnd )
-                    nEndPos = nEnd;
+                nStt = (xub_StrLen)aCurWordBndry.startPos;
+                nEnd = (xub_StrLen)aCurWordBndry.endPos;
+                sal_Int32 nLen = nEnd - nStt;
+                DBG_ASSERT( nLen > 0, "invalid word length of 0" );
+#if OSL_DEBUG_LEVEL > 1
+                String aText( GetTxt().Copy( nStt, nLen ) );
+#endif
+
+                Sequence <sal_Int32> aOffsets;
+                String sChgd( rTrans.transliterate( GetTxt(), GetLang( nStt ), nStt, nLen, &aOffsets ));
+
+                if (!m_Text.Equals( sChgd, nStt, nLen ))
+                {
+                    aChgData.nStart     = nStt;
+                    aChgData.nLen       = nLen;
+                    aChgData.sChanged   = sChgd;
+                    aChgData.aOffsets   = aOffsets;
+                    aChanges.push_back( aChgData );
+                }
+
+                aCurWordBndry = pBreakIt->GetBreakIter()->nextWord(
+                        GetTxt(), nEnd,
+                        pBreakIt->GetLocale( GetLang( nEnd ) ),
+                        nWordType);
             }
-            else
+        }
+        else if (rTrans.getType() == (sal_uInt32)TransliterationModulesExtra::SENTENCE_CASE)
+        {
+            // for 'sentence case' we need to iterate sentence by sentence
+
+            sal_Int32 nLastStart = pBreakIt->GetBreakIter()->beginOfSentence( 
+                    GetTxt(), nEnd, 
+                    pBreakIt->GetLocale( GetLang( nEnd ) ) );
+            sal_Int32 nLastEnd = pBreakIt->GetBreakIter()->endOfSentence( 
+                    GetTxt(), nLastStart, 
+                    pBreakIt->GetLocale( GetLang( nLastStart ) ) );
+            
+            // extend nStt, nEnd to the current sentence boundaries
+            sal_Int32 nCurrentStart = pBreakIt->GetBreakIter()->beginOfSentence( 
+                    GetTxt(), nStt, 
+                    pBreakIt->GetLocale( GetLang( nStt ) ) );
+            sal_Int32 nCurrentEnd = pBreakIt->GetBreakIter()->endOfSentence( 
+                    GetTxt(), nCurrentStart, 
+                    pBreakIt->GetLocale( GetLang( nCurrentStart ) ) );
+
+            // prevent backtracking to the previous sentence if selection starts at end of a sentence
+            if (nCurrentEnd <= nStt)
+            {
+                // now nCurrentStart is probably located on a non-letter word. (unless we
+                // are in Asian text with no spaces...)
+                // Thus to get the real sentence start we should locate the next real word, 
+                // that is one found by DICTIONARY_WORD
+                i18n::Boundary aBndry = pBreakIt->GetBreakIter()->nextWord( 
+                        GetTxt(), nCurrentEnd,
+                        pBreakIt->GetLocale( GetLang( nCurrentEnd ) ),
+                        i18n::WordType::DICTIONARY_WORD);
+
+                // now get new current sentence boundaries
+                nCurrentStart = pBreakIt->GetBreakIter()->beginOfSentence( 
+                        GetTxt(), aBndry.startPos, 
+                        pBreakIt->GetLocale( GetLang( aBndry.startPos) ) );
+                nCurrentEnd = pBreakIt->GetBreakIter()->endOfSentence( 
+                        GetTxt(), nCurrentStart, 
+                        pBreakIt->GetLocale( GetLang( nCurrentStart) ) );
+            }
+            // prevent advancing to the next sentence if selection ends at start of a sentence
+            if (nLastStart >= nEnd)
             {
-                nLang = LANGUAGE_SYSTEM;
-                nEndPos = nEnd;
+                // now nCurrentStart is probably located on a non-letter word. (unless we
+                // are in Asian text with no spaces...)
+                // Thus to get the real sentence start we should locate the previous real word, 
+                // that is one found by DICTIONARY_WORD
+                i18n::Boundary aBndry = pBreakIt->GetBreakIter()->previousWord( 
+                        GetTxt(), nLastStart, 
+                        pBreakIt->GetLocale( GetLang( nLastStart) ),
+                        i18n::WordType::DICTIONARY_WORD);
+                nLastEnd = pBreakIt->GetBreakIter()->endOfSentence( 
+                        GetTxt(), aBndry.startPos, 
+                        pBreakIt->GetLocale( GetLang( aBndry.startPos) ) );
+                if (nCurrentEnd > nLastEnd)
+                    nCurrentEnd = nLastEnd;
             }
-            xub_StrLen nLen = nEndPos - nStt;
 
-            Sequence <sal_Int32> aOffsets;
-            String sChgd( rTrans.transliterate( m_Text, nLang, nStt, nLen,
-                                                &aOffsets ));
-            if( !m_Text.Equals( sChgd, nStt, nLen ) )
+            while (nCurrentStart < nLastEnd)
             {
-                if ( pUndo )
+                sal_Int32 nLen = nCurrentEnd - nCurrentStart;
+                DBG_ASSERT( nLen > 0, "invalid word length of 0" );
+#if OSL_DEBUG_LEVEL > 1
+                String aText( GetTxt().Copy( nCurrentStart, nLen ) );
+#endif
+
+                Sequence <sal_Int32> aOffsets;
+                String sChgd( rTrans.transliterate( GetTxt(), 
+                        GetLang( nCurrentStart ), nCurrentStart, nLen, &aOffsets ));
+
+                if (!m_Text.Equals( sChgd, nStt, nLen ))
                 {
-                    pUndo->AddChanges( *this, nStt, nLen, aOffsets );
+                    aChgData.nStart     = nCurrentStart;
+                    aChgData.nLen       = nLen;
+                    aChgData.sChanged   = sChgd;
+                    aChgData.aOffsets   = aOffsets;
+                    aChanges.push_back( aChgData );
                 }
-                ReplaceTextOnly( nStt, nLen, sChgd, aOffsets );
+
+                Boundary aFirstWordBndry;
+                aFirstWordBndry = pBreakIt->GetBreakIter()->nextWord(
+                        GetTxt(), nCurrentEnd,
+                        pBreakIt->GetLocale( GetLang( nCurrentEnd ) ),
+                        nWordType);
+                nCurrentStart = aFirstWordBndry.startPos;
+                nCurrentEnd = pBreakIt->GetBreakIter()->endOfSentence( 
+                        GetTxt(), nCurrentStart, 
+                        pBreakIt->GetLocale( GetLang( nCurrentStart ) ) );
             }
-            nStt = nEndPos;
-        } while( nEndPos < nEnd && pIter && pIter->Next() );
-        delete pIter;
+        }
+        else
+        {
+            // here we may transliterate over complete language portions...
+
+            SwLanguageIterator* pIter;
+            if( rTrans.needLanguageForTheMode() )
+                pIter = new SwLanguageIterator( *this, nStt );
+            else
+                pIter = 0;
+
+            xub_StrLen nEndPos;
+            sal_uInt16 nLang;
+            do {
+                if( pIter )
+                {
+                    nLang = pIter->GetLanguage();
+                    nEndPos = pIter->GetChgPos();
+                    if( nEndPos > nEnd )
+                        nEndPos = nEnd;
+                }
+                else
+                {
+                    nLang = LANGUAGE_SYSTEM;
+                    nEndPos = nEnd;
+                }
+                xub_StrLen nLen = nEndPos - nStt;
+
+                Sequence <sal_Int32> aOffsets;
+                String sChgd( rTrans.transliterate( m_Text, nLang, nStt, nLen, &aOffsets ));
+
+                if (!m_Text.Equals( sChgd, nStt, nLen ))
+                {
+                    aChgData.nStart     = nStt;
+                    aChgData.nLen       = nLen;
+                    aChgData.sChanged   = sChgd;
+                    aChgData.aOffsets   = aOffsets;
+                    aChanges.push_back( aChgData );
+                }
+
+                nStt = nEndPos;
+            } while( nEndPos < nEnd && pIter && pIter->Next() );
+            delete pIter;
+        }
+
+        if (aChanges.size() > 0)
+        {
+            // now apply the changes from end to start to leave the offsets of the
+            // yet unchanged text parts remain the same.
+            for (size_t i = 0; i < aChanges.size(); ++i)
+            {
+                TransliterationChgData &rData = aChanges[ aChanges.size() - 1 - i ];
+                if (pUndo)
+                    pUndo->AddChanges( *this, rData.nStart, rData.nLen, rData.aOffsets );
+                ReplaceTextOnly( rData.nStart, rData.nLen, rData.sChanged, rData.aOffsets );
+            }
+        }
     }
 }
 
diff --git a/sw/source/core/undo/unovwr.cxx b/sw/source/core/undo/unovwr.cxx
index 22f9db9..744767f 100644
--- a/sw/source/core/undo/unovwr.cxx
+++ b/sw/source/core/undo/unovwr.cxx
@@ -352,16 +352,14 @@ SwRewriter SwUndoOverwrite::GetRewriter() const
 
 struct _UndoTransliterate_Data
 {
-    String sText;
-    _UndoTransliterate_Data* pNext;
-    SwHistory* pHistory;
-    Sequence <sal_Int32>* pOffsets;
-    ULONG nNdIdx;
-    xub_StrLen nStart, nLen;
-
-    _UndoTransliterate_Data( ULONG nNd, xub_StrLen nStt, xub_StrLen nStrLen,
-                                const String& rTxt )
-        : sText( rTxt ), pNext( 0 ), pHistory( 0 ), pOffsets( 0 ),
+    String          sText;
+    SwHistory*      pHistory;
+    Sequence< sal_Int32 >*  pOffsets;
+    ULONG           nNdIdx;
+    xub_StrLen      nStart, nLen;
+
+    _UndoTransliterate_Data( ULONG nNd, xub_StrLen nStt, xub_StrLen nStrLen, const String& rTxt )
+        : sText( rTxt ), pHistory( 0 ), pOffsets( 0 ),
         nNdIdx( nNd ), nStart( nStt ), nLen( nStrLen )
     {}
     ~_UndoTransliterate_Data() { delete pOffsets; delete pHistory; }
@@ -369,22 +367,17 @@ struct _UndoTransliterate_Data
     void SetChangeAtNode( SwDoc& rDoc );
 };
 
-SwUndoTransliterate::SwUndoTransliterate( const SwPaM& rPam,
-                            const utl::TransliterationWrapper& rTrans )
-    : SwUndo( UNDO_TRANSLITERATE ), SwUndRng( rPam ),
-    pData( 0 ), pLastData( 0 ), nType( rTrans.getType() )
+SwUndoTransliterate::SwUndoTransliterate( 
+    const SwPaM& rPam,
+    const utl::TransliterationWrapper& rTrans )
+    : SwUndo( UNDO_TRANSLITERATE ), SwUndRng( rPam ), nType( rTrans.getType() )
 {
 }
 
 SwUndoTransliterate::~SwUndoTransliterate()
 {
-    _UndoTransliterate_Data* pD = pData;
-    while( pD )
-    {
-        pData = pD;
-        pD = pD->pNext;
-        delete pData;
-    }
+    for (size_t i = 0; i < aChanges.size();  ++i)
+        delete aChanges[i];
 }
 
 void SwUndoTransliterate::Undo( SwUndoIter& rUndoIter )
@@ -393,8 +386,12 @@ void SwUndoTransliterate::Undo( SwUndoIter& rUndoIter )
     BOOL bUndo = rDoc.DoesUndo();
     rDoc.DoUndo( FALSE );
 
-    for( _UndoTransliterate_Data* pD = pData; pD; pD = pD->pNext )
-        pD->SetChangeAtNode( rDoc );
+    // since the changes were added to the vector from the end of the string/node towards
+    // the start, we need to revert them from the start towards the end now to keep the 
+    // offset information of the undo data in sync with the changing text.
+    // Thus we need to iterate from the end of the vector to the start
+    for (sal_Int32 i = aChanges.size() - 1; i >= 0;  --i)
+        aChanges[i]->SetChangeAtNode( rDoc );
 
     rDoc.DoUndo( bUndo );
     SetPaM( rUndoIter, TRUE );
@@ -413,8 +410,7 @@ void SwUndoTransliterate::Repeat( SwUndoIter& rUndoIter )
     SwPaM& rPam = *rUndoIter.pAktPam;
     SwDoc& rDoc = rUndoIter.GetDoc();
 
-    utl::TransliterationWrapper aTrans(
-                        ::comphelper::getProcessServiceFactory(), nType );
+    utl::TransliterationWrapper aTrans( ::comphelper::getProcessServiceFactory(), nType );
     rDoc.TransliterateText( rPam, aTrans );
 
     rUndoIter.pLastUndoObj = this;
@@ -428,67 +424,63 @@ void SwUndoTransliterate::AddChanges( SwTxtNode& rTNd,
     _UndoTransliterate_Data* pNew = new _UndoTransliterate_Data(
                         rTNd.GetIndex(), nStart, (xub_StrLen)nOffsLen,
                         rTNd.GetTxt().Copy( nStart, nLen ));
-    if( pData )
-        pLastData->pNext = pNew;
-    else
-        pData = pNew;
-    pLastData = pNew;
+
+    aChanges.push_back( pNew );
 
     const sal_Int32* pOffsets = rOffsets.getConstArray();
     // where did we need less memory ?
     const sal_Int32* p = pOffsets;
     for( long n = 0; n < nOffsLen; ++n, ++p )
-        if( *p != ( nStart + n ))
+    if( *p != ( nStart + n ))
+    {
+        // create the Offset array
+        pNew->pOffsets = new Sequence <sal_Int32> ( nLen );
+        sal_Int32* pIdx = pNew->pOffsets->getArray();
+        p = pOffsets;
+        long nMyOff, nNewVal = nStart;
+        for( n = 0, nMyOff = nStart; n < nOffsLen; ++p, ++n, ++nMyOff )
         {
-            // create the Offset array
-            pNew->pOffsets = new Sequence <sal_Int32> ( nLen );
-            sal_Int32* pIdx = pNew->pOffsets->getArray();
-            p = pOffsets;
-            long nMyOff, nNewVal = nStart;
-            for( n = 0, nMyOff = nStart; n < nOffsLen; ++p, ++n, ++nMyOff )
+            if( *p < nMyOff )
             {
-                if( *p < nMyOff )
-                {
-                    // something is deleted
-                    nMyOff = *p;
-                    *(pIdx-1) = nNewVal++;
-                }
-                else if( *p > nMyOff )
-                {
-                    for( ; *p > nMyOff; ++nMyOff )
-                        *pIdx++ = nNewVal;
-                    --nMyOff;
-                    --n;
-                    --p;
-                }
-                else
-                    *pIdx++ = nNewVal++;
+                // something is deleted
+                nMyOff = *p;
+                *(pIdx-1) = nNewVal++;
             }
-
-            // and then we need to save the attributes/bookmarks
-            // but this data must moved every time to the last in the chain!
-            _UndoTransliterate_Data* pD = pData;
-            while( pD != pNew )
+            else if( *p > nMyOff )
             {
-                if( pD->nNdIdx == pNew->nNdIdx && pD->pHistory )
-                {
-                    // same node and have a history?
-                    pNew->pHistory = pD->pHistory;
-                    pD->pHistory = 0;
-                    break;		    // more can't exist
-                }
-                pD = pD->pNext;
+                for( ; *p > nMyOff; ++nMyOff )
+                    *pIdx++ = nNewVal;
+                --nMyOff;
+                --n;
+                --p;
             }
+            else
+                *pIdx++ = nNewVal++;
+        }
 
-            if( !pNew->pHistory )
+        // and then we need to save the attributes/bookmarks
+        // but this data must moved every time to the last in the chain!
+        for (size_t i = 0; i + 1 < aChanges.size(); ++i)    // check all changes but not the current one
+        {
+            _UndoTransliterate_Data* pD = aChanges[i];
+            if( pD->nNdIdx == pNew->nNdIdx && pD->pHistory )
             {
-                pNew->pHistory = new SwHistory;
-                SwRegHistory aRHst( rTNd, pNew->pHistory );
-                pNew->pHistory->CopyAttr( rTNd.GetpSwpHints(),
-                        pNew->nNdIdx, 0, rTNd.GetTxt().Len(), false );
+                // same node and have a history?
+                pNew->pHistory = pD->pHistory;
+                pD->pHistory = 0;
+                break;		    // more can't exist
             }
-            break;
         }
+
+        if( !pNew->pHistory )
+        {
+            pNew->pHistory = new SwHistory;
+            SwRegHistory aRHst( rTNd, pNew->pHistory );
+            pNew->pHistory->CopyAttr( rTNd.GetpSwpHints(),
+                    pNew->nNdIdx, 0, rTNd.GetTxt().Len(), false );
+        }
+        break;
+    }
 }
 
 void _UndoTransliterate_Data::SetChangeAtNode( SwDoc& rDoc )
commit 3274d37826fc2613aa5061a985d1aab476e3a6fc
Author: Frank Schoenheit [fs] <frank.schoenheit at oracle.com>
Date:   Fri Aug 13 23:34:21 2010 +0200

    fs33a: make compile in non-pro build (removed seemingly dead assertion)

diff --git a/sw/source/ui/lingu/olmenu.cxx b/sw/source/ui/lingu/olmenu.cxx
index 87d5c00..933959d 100644
--- a/sw/source/ui/lingu/olmenu.cxx
+++ b/sw/source/ui/lingu/olmenu.cxx
@@ -823,7 +823,7 @@ void SwSpellPopup::Execute( USHORT nId )
     else if (MN_DICTIONARIES_START <= nId && nId <= MN_DICTIONARIES_END)
     {
             OUString aWord( xSpellAlt->getWord() );
-            DBG_ASSERT( nDicIdx < aDics.getLength(), "dictionary index out of range" );
+            //DBG_ASSERT( nDicIdx < aDics.getLength(), "dictionary index out of range" );
             
             PopupMenu *pMenu = GetPopupMenu(MN_ADD_TO_DIC);
             String aDicName ( pMenu->GetItemText(nId) );
commit 013feef7fc5add0b3468b2c3d11bea8d4f830174
Merge: db3cc71... aa24f45...
Author: Frank Schoenheit [fs] <frank.schoenheit at oracle.com>
Date:   Fri Aug 13 12:04:35 2010 +0200

    fs33a: merge after pulling OOO330.m4's change sets

commit db3cc711f90a781bc8cd82a90d872f6e281ae205
Merge: e1a0f88... 80200b9...
Author: Frank Schoenheit [fs] <frank.schoenheit at oracle.com>
Date:   Tue Aug 10 14:53:21 2010 +0200

    merging in latest changes from OOO330(m3)

diff --cc sw/sdi/swriter.sdi
index c27ac20,aae7ec7..aae7ec7
mode 100644,100755..100644
--- a/sw/sdi/swriter.sdi
+++ b/sw/sdi/swriter.sdi
diff --cc sw/source/ui/app/docsh.cxx
index 22a8213,5a1b860..5a1b860
mode 100644,100755..100644
--- a/sw/source/ui/app/docsh.cxx
+++ b/sw/source/ui/app/docsh.cxx
diff --cc sw/source/ui/uiview/view2.cxx
index 6bba177,224ab55..224ab55
mode 100644,100755..100644
--- a/sw/source/ui/uiview/view2.cxx
+++ b/sw/source/ui/uiview/view2.cxx
diff --cc sw/source/ui/uiview/viewstat.cxx
index ff452ef,20821d5..20821d5
mode 100644,100755..100644
--- a/sw/source/ui/uiview/viewstat.cxx
+++ b/sw/source/ui/uiview/viewstat.cxx


More information about the ooo-build-commit mailing list