diff options
-rw-r--r-- | starmath/inc/starmath.hrc | 2 | ||||
-rwxr-xr-x | starmath/source/smres.src | 4 | ||||
-rwxr-xr-x[-rw-r--r--] | starmath/source/view.cxx | 2 | ||||
-rw-r--r-- | sw/inc/undobj.hxx | 6 | ||||
-rw-r--r-- | sw/source/core/attr/cellatr.cxx | 11 | ||||
-rw-r--r-- | sw/source/core/doc/docedt.cxx | 33 | ||||
-rw-r--r-- | sw/source/core/txtnode/txtedt.cxx | 271 | ||||
-rw-r--r-- | sw/source/core/undo/makefile.mk | 1 | ||||
-rw-r--r-- | sw/source/core/undo/unovwr.cxx | 136 | ||||
-rw-r--r-- | sw/source/core/unocore/unotbl.cxx | 9 | ||||
-rw-r--r-- | sw/source/ui/uiview/pview.cxx | 2 | ||||
-rw-r--r-- | sw/source/ui/uiview/srcview.cxx | 2 | ||||
-rw-r--r-- | sw/source/ui/uiview/view0.cxx | 2 | ||||
-rw-r--r-- | sw/source/ui/web/wview.cxx | 2 |
14 files changed, 344 insertions, 139 deletions
diff --git a/starmath/inc/starmath.hrc b/starmath/inc/starmath.hrc index 7d11b64aa0..34838682b0 100644 --- a/starmath/inc/starmath.hrc +++ b/starmath/inc/starmath.hrc @@ -107,7 +107,7 @@ #define RID_READSYMBOLERROR (RID_APP_START + 203) #define RID_NOMATHTYPEFACEWARNING (RID_APP_START + 204) #define RID_OBJECTNAME (RID_APP_START + 501) -#define RID_VIEWNAME (RID_APP_START + 502) + // free #define RID_UNDOEDITNAME (RID_APP_START + 503) #define RID_UNDOFORMATNAME (RID_APP_START + 504) #define RID_APPICO (RID_APP_START + 601) diff --git a/starmath/source/smres.src b/starmath/source/smres.src index 5761f1beb6..7270427e0b 100755 --- a/starmath/source/smres.src +++ b/starmath/source/smres.src @@ -1379,10 +1379,6 @@ String RID_OBJECTNAME { Text = "SMath3" ; }; -String RID_VIEWNAME -{ - Text = "StarMath" ; -}; String RID_UNDOEDITNAME { Text = "Edit" ; diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx index 0d9ea5812c..1e6e59ad17 100644..100755 --- a/starmath/source/view.cxx +++ b/starmath/source/view.cxx @@ -749,7 +749,7 @@ SFX_IMPL_INTERFACE(SmViewShell, SfxViewShell, SmResId(0)) } -SFX_IMPL_VIEWFACTORY(SmViewShell, SmResId(RID_VIEWNAME)) +SFX_IMPL_NAMED_VIEWFACTORY(SmViewShell, "Default") { SFX_VIEW_REGISTRATION(SmDocShell); } diff --git a/sw/inc/undobj.hxx b/sw/inc/undobj.hxx index 0fe4953bba..c05cfcd9bb 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/attr/cellatr.cxx b/sw/source/core/attr/cellatr.cxx index 7285d1520d..0cf721f208 100644 --- a/sw/source/core/attr/cellatr.cxx +++ b/sw/source/core/attr/cellatr.cxx @@ -28,9 +28,10 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" +#include <float.h> +#include <rtl/math.hxx> -#include <float.h> #include <hintids.hxx> // fuer RES_.. #include <cellatr.hxx> #include <calc.hxx> @@ -249,8 +250,12 @@ SwTblBoxValue::SwTblBoxValue( const double nVal ) int SwTblBoxValue::operator==( const SfxPoolItem& rAttr ) const { - ASSERT( SfxPoolItem::operator==( rAttr ), "keine gleichen Attribute" ); - return nValue == ((SwTblBoxValue&)rAttr).nValue; + ASSERT(SfxPoolItem::operator==(rAttr), "SwTblBoxValue: item not equal"); + SwTblBoxValue const& rOther( static_cast<SwTblBoxValue const&>(rAttr) ); + // items with NaN should be equal to enable pooling + return ::rtl::math::isNan(nValue) + ? ::rtl::math::isNan(rOther.nValue) + : (nValue == rOther.nValue); } diff --git a/sw/source/core/doc/docedt.cxx b/sw/source/core/doc/docedt.cxx index 08fc9681bf..6413ef7e0d 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 e3f5fdcae8..19af8908fa 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/makefile.mk b/sw/source/core/undo/makefile.mk index d6e6766a0f..c381761adb 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 = \ diff --git a/sw/source/core/undo/unovwr.cxx b/sw/source/core/undo/unovwr.cxx index 22f9db9706..744767ffcb 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 ) diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 9dd21a4e88..a9658fc7bc 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -1009,12 +1009,9 @@ void SwXCell::setFormula(const OUString& rFormula) throw( uno::RuntimeException double SwXCell::getValue(void) throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - double fRet = lcl_getValue( *this ); - //lcl_getValue was changed thus it can return nan values, - //so I make this additional nan check here to not change the behaviour - //but maybe it would even be more correct to just return nan here? ... todo? - if( ::rtl::math::isNan( fRet ) ) - fRet = 0.0; + + double const fRet = lcl_getValue( *this ); + // #i112652# a table cell may contain NaN as a value, do not filter that return fRet; } /*-- 11.12.98 10:56:26--------------------------------------------------- diff --git a/sw/source/ui/uiview/pview.cxx b/sw/source/ui/uiview/pview.cxx index 6f10283478..4aaa2fd56c 100644 --- a/sw/source/ui/uiview/pview.cxx +++ b/sw/source/ui/uiview/pview.cxx @@ -108,7 +108,7 @@ using namespace ::com::sun::star; -SFX_IMPL_VIEWFACTORY(SwPagePreView, SW_RES(STR_NONAME)) +SFX_IMPL_NAMED_VIEWFACTORY(SwPagePreView, "PrintPreview") { SFX_VIEW_REGISTRATION(SwDocShell); SFX_VIEW_REGISTRATION(SwWebDocShell); diff --git a/sw/source/ui/uiview/srcview.cxx b/sw/source/ui/uiview/srcview.cxx index d418216a39..47067385dc 100644 --- a/sw/source/ui/uiview/srcview.cxx +++ b/sw/source/ui/uiview/srcview.cxx @@ -125,7 +125,7 @@ using ::com::sun::star::util::SearchOptions; -SFX_IMPL_VIEWFACTORY(SwSrcView, SW_RES(STR_NONAME)) +SFX_IMPL_NAMED_VIEWFACTORY(SwSrcView, "SourceView") { SFX_VIEW_REGISTRATION(SwWebDocShell); } diff --git a/sw/source/ui/uiview/view0.cxx b/sw/source/ui/uiview/view0.cxx index f3e1253572..98b9589afa 100644 --- a/sw/source/ui/uiview/view0.cxx +++ b/sw/source/ui/uiview/view0.cxx @@ -105,7 +105,7 @@ using ::rtl::OUString; #include <unomid.h> -SFX_IMPL_VIEWFACTORY(SwView, SW_RES(STR_NONAME)) +SFX_IMPL_NAMED_VIEWFACTORY(SwView, "Default") { if ( SvtModuleOptions().IsWriter() ) { diff --git a/sw/source/ui/web/wview.cxx b/sw/source/ui/web/wview.cxx index 6899f6dedc..8fa1fc0bb7 100644 --- a/sw/source/ui/web/wview.cxx +++ b/sw/source/ui/web/wview.cxx @@ -93,7 +93,7 @@ #include <swslots.hxx> -SFX_IMPL_VIEWFACTORY(SwWebView, SW_RES(STR_NONAME)) +SFX_IMPL_NAMED_VIEWFACTORY(SwWebView, "Default") { SFX_VIEW_REGISTRATION(SwWebDocShell); } |