diff options
-rw-r--r-- | sw/inc/crsrsh.hxx | 1 | ||||
-rw-r--r-- | sw/inc/editsh.hxx | 7 | ||||
-rw-r--r-- | sw/inc/swcrsr.hxx | 1 | ||||
-rw-r--r-- | sw/source/core/crsr/crstrvl1.cxx | 4 | ||||
-rw-r--r-- | sw/source/core/crsr/swcrsr.cxx | 80 | ||||
-rw-r--r-- | sw/source/core/edit/edlingu.cxx | 58 | ||||
-rwxr-xr-x[-rw-r--r--] | sw/source/filter/ww8/wrtww8.cxx | 24 | ||||
-rw-r--r-- | sw/source/ui/dialog/SwSpellDialogChildWindow.cxx | 146 | ||||
-rw-r--r-- | sw/source/ui/inc/SwSpellDialogChildWindow.hxx | 4 | ||||
-rw-r--r-- | sw/source/ui/inc/view.hxx | 2 | ||||
-rw-r--r-- | sw/source/ui/uiview/viewdraw.cxx | 7 |
11 files changed, 249 insertions, 85 deletions
diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx index bcf511aa2a5b..f60a3d89f9ed 100644 --- a/sw/inc/crsrsh.hxx +++ b/sw/inc/crsrsh.hxx @@ -746,6 +746,7 @@ public: BOOL GoStartSentence(); BOOL GoEndSentence(); BOOL SelectWord( const Point* pPt = 0 ); + BOOL ExpandToSentenceBorders(); // Position vom akt. Cursor erfragen BOOL IsStartWord()const; diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx index b2483f21a75a..3923edb35a2c 100644 --- a/sw/inc/editsh.hxx +++ b/sw/inc/editsh.hxx @@ -743,9 +743,14 @@ public: bool SpellSentence(::svx::SpellPortions& rToFill, bool bIsGrammarCheck ); // make SpellIter start with the current sentence when called next time void PutSpellingToSentenceStart(); + // moves the continuation position to the end of the currently checked sentence + void MoveContinuationPosToEndOfCheckedSentence(); //applies a changed sentence - void ApplyChangedSentence(const ::svx::SpellPortions& rNewPortions, bool bIsGrammarCheck); + void ApplyChangedSentence(const ::svx::SpellPortions& rNewPortions, bool bRecheck); + + // check SwSpellIter data to see if the last sentence got grammar checked + bool HasLastSentenceGotGrammarChecked() const; // Is text conversion active somewhere else? BOOL HasConvIter() const; // Is hyphenation active somewhere else? diff --git a/sw/inc/swcrsr.hxx b/sw/inc/swcrsr.hxx index 6e26a6a3bfcb..294330841388 100644 --- a/sw/inc/swcrsr.hxx +++ b/sw/inc/swcrsr.hxx @@ -162,6 +162,7 @@ public: BOOL GoEndSentence(){return GoSentence(END_SENT);} BOOL GoPrevSentence(){return GoSentence(PREV_SENT);} BOOL GoStartSentence(){return GoSentence(START_SENT);} + BOOL ExpandToSentenceBorders(); virtual BOOL LeftRight( BOOL bLeft, USHORT nCnt, USHORT nMode, BOOL bAllowVisual, BOOL bSkipHidden, BOOL bInsertCrsr ); diff --git a/sw/source/core/crsr/crstrvl1.cxx b/sw/source/core/crsr/crstrvl1.cxx index fcdcd99241f4..6dfccb086b46 100644 --- a/sw/source/core/crsr/crstrvl1.cxx +++ b/sw/source/core/crsr/crstrvl1.cxx @@ -94,4 +94,8 @@ BOOL SwCrsrShell::SelectWord( const Point* pPt ) return pCurCrsr->SelectWord( pPt ); } +BOOL SwCrsrShell::ExpandToSentenceBorders() +{ + return pCurCrsr->ExpandToSentenceBorders(); +} diff --git a/sw/source/core/crsr/swcrsr.cxx b/sw/source/core/crsr/swcrsr.cxx index d8286d007395..fc57e8b38aaf 100644 --- a/sw/source/core/crsr/swcrsr.cxx +++ b/sw/source/core/crsr/swcrsr.cxx @@ -1401,11 +1401,11 @@ BOOL SwCursor::SelectWordWT( sal_Int16 nWordType, const Point* pPt ) } //----------------------------------------------------------------------------- -BOOL SwCursor::GoSentence( SentenceMoveType eMoveType ) + +static String lcl_MaskDeletedRedlines( const SwTxtNode* pTxtNd ) { - BOOL bRet = FALSE; - const SwTxtNode* pTxtNd = GetNode()->GetTxtNode(); - if( pTxtNd && pBreakIt->GetBreakIter().is() ) + String aRes; + if (pTxtNd) { //mask deleted redlines String sNodeText(pTxtNd->GetTxt()); @@ -1430,11 +1430,30 @@ BOOL SwCursor::GoSentence( SentenceMoveType eMoveType ) } } } + aRes = sNodeText; + } + return aRes; +} + +BOOL SwCursor::GoSentence( SentenceMoveType eMoveType ) +{ + BOOL bRet = FALSE; + const SwTxtNode* pTxtNd = GetNode()->GetTxtNode(); + if( pTxtNd && pBreakIt->GetBreakIter().is() ) + { + String sNodeText( lcl_MaskDeletedRedlines( pTxtNd ) ); + SwCrsrSaveState aSave( *this ); xub_StrLen nPtPos = GetPoint()->nContent.GetIndex(); switch ( eMoveType ) { - case END_SENT: + case START_SENT: /* when modifying: see also ExpandToSentenceBorders below! */ + nPtPos = (xub_StrLen)pBreakIt->GetBreakIter()->beginOfSentence( + sNodeText, + nPtPos, pBreakIt->GetLocale( + pTxtNd->GetLang( nPtPos ) )); + break; + case END_SENT: /* when modifying: see also ExpandToSentenceBorders below! */ nPtPos = (xub_StrLen)pBreakIt->GetBreakIter()->endOfSentence( sNodeText, nPtPos, pBreakIt->GetLocale( @@ -1451,12 +1470,6 @@ BOOL SwCursor::GoSentence( SentenceMoveType eMoveType ) ; break; } - case START_SENT: - nPtPos = (xub_StrLen)pBreakIt->GetBreakIter()->beginOfSentence( - sNodeText, - nPtPos, pBreakIt->GetLocale( - pTxtNd->GetLang( nPtPos ) )); - break; case PREV_SENT: nPtPos = (xub_StrLen)pBreakIt->GetBreakIter()->beginOfSentence( sNodeText, @@ -1484,6 +1497,51 @@ BOOL SwCursor::GoSentence( SentenceMoveType eMoveType ) return bRet; } + +BOOL SwCursor::ExpandToSentenceBorders() +{ + BOOL bRes = FALSE; + const SwTxtNode* pStartNd = Start()->nNode.GetNode().GetTxtNode(); + const SwTxtNode* pEndNd = End()->nNode.GetNode().GetTxtNode(); + if (pStartNd && pEndNd && pBreakIt->GetBreakIter().is()) + { + if (!HasMark()) + SetMark(); + + String sStartText( lcl_MaskDeletedRedlines( pStartNd ) ); + String sEndText( pStartNd == pEndNd? sStartText : lcl_MaskDeletedRedlines( pEndNd ) ); + + SwCrsrSaveState aSave( *this ); + xub_StrLen nStartPos = Start()->nContent.GetIndex(); + xub_StrLen nEndPos = End()->nContent.GetIndex(); + + nStartPos = (xub_StrLen)pBreakIt->GetBreakIter()->beginOfSentence( + sStartText, nStartPos, + pBreakIt->GetLocale( pStartNd->GetLang( nStartPos ) ) ); + nEndPos = (xub_StrLen)pBreakIt->GetBreakIter()->endOfSentence( + sEndText, nEndPos, + pBreakIt->GetLocale( pEndNd->GetLang( nEndPos ) ) ); + + // it is allowed to place the PaM just behind the last + // character in the text thus <= ...Len + bool bChanged = false; + if (nStartPos <= pStartNd->GetTxt().Len()) + { + GetMark()->nContent = nStartPos; + bChanged = true; + } + if (nEndPos <= pEndNd->GetTxt().Len()) + { + GetPoint()->nContent = nEndPos; + bChanged = true; + } + if (bChanged && !IsSelOvr()) + bRes = TRUE; + } + return bRes; +} + + BOOL SwTableCursor::LeftRight( BOOL bLeft, USHORT nCnt, USHORT /*nMode*/, BOOL /*bVisualAllowed*/, BOOL /*bSkipHidden*/, BOOL /*bInsertCrsr*/ ) { diff --git a/sw/source/core/edit/edlingu.cxx b/sw/source/core/edit/edlingu.cxx index 02dc1de62901..d99293071048 100644 --- a/sw/source/core/edit/edlingu.cxx +++ b/sw/source/core/edit/edlingu.cxx @@ -136,6 +136,7 @@ class SwSpellIter : public SwLinguIter SpellContentPositions aLastPositions; bool bBackToStartOfSentence; + bool bMoveToEndOfSentence; void CreatePortion(uno::Reference< XSpellAlternatives > xAlt, @@ -147,7 +148,7 @@ class SwSpellIter : public SwLinguIter const SpellContentPositions& rDeletedRedlines); public: SwSpellIter() : - bBackToStartOfSentence(false) {} + bBackToStartOfSentence(false), bMoveToEndOfSentence(false) {} void Start( SwEditShell *pSh, SwDocPositions eStart, SwDocPositions eEnd ); @@ -157,6 +158,7 @@ public: void ToSentenceStart(); const ::svx::SpellPortions GetLastPortions(){ return aLastPortions;} SpellContentPositions GetLastPositions() {return aLastPositions;} + void ContinueAfterThisSentence() { bMoveToEndOfSentence = true; } }; /************************************************************************* @@ -693,6 +695,24 @@ void SwHyphIter::InsertSoftHyph( const xub_StrLen nHyphPos ) // --------------------- Methoden der SwEditShell ------------------------ +bool SwEditShell::HasLastSentenceGotGrammarChecked() const +{ + bool bTextWasGrammarChecked = false; + if (pSpellIter) + { + ::svx::SpellPortions aLastPortions( pSpellIter->GetLastPortions() ); + for (size_t i = 0; i < aLastPortions.size() && !bTextWasGrammarChecked; ++i) + { + // bIsGrammarError is also true if the text was only checked but no + // grammar error was found. (That is if a ProofreadingResult was obtained in + // SwDoc::Spell and in turn bIsGrammarError was set in SwSpellIter::CreatePortion) + if (aLastPortions[i].bIsGrammarError) + bTextWasGrammarChecked = true; + } + } + return bTextWasGrammarChecked; +} + /************************************************************************* * SwEditShell::HasConvIter *************************************************************************/ @@ -1283,7 +1303,20 @@ sal_uInt32 lcl_CountRedlines( /*-- 18.09.2003 15:08:20--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwEditShell::ApplyChangedSentence(const ::svx::SpellPortions& rNewPortions, bool bIsGrammarCheck) + +void SwEditShell::MoveContinuationPosToEndOfCheckedSentence() +{ + // give hint that continuation position for spell/grammar checking is + // at the end of this sentence + if (pSpellIter) + { + pSpellIter->SetCurr( new SwPosition( *pSpellIter->GetCurrX() ) ); + pSpellIter->ContinueAfterThisSentence(); + } +} + + +void SwEditShell::ApplyChangedSentence(const ::svx::SpellPortions& rNewPortions, bool bRecheck) { ASSERT( pSpellIter, "SpellIter missing" ); if(pSpellIter) @@ -1300,9 +1333,14 @@ void SwEditShell::ApplyChangedSentence(const ::svx::SpellPortions& rNewPortions, if(!rLastPortions.size()) return; - SwPaM *pCrsr = GetCrsr(); pDoc->StartUndo( UNDO_OVERWRITE, NULL ); StartAction(); + + SwPaM *pCrsr = GetCrsr(); + // save cursor position (which should be at the end of the current sentence) + // for later restoration + Push(); + sal_uInt32 nRedlinePortions = lcl_CountRedlines(rLastPortions); if((rLastPortions.size() - nRedlinePortions) == rNewPortions.size()) { @@ -1391,16 +1429,24 @@ void SwEditShell::ApplyChangedSentence(const ::svx::SpellPortions& rNewPortions, //set the cursor to the end of the inserted string *pCrsr->Start() = *pCrsr->End(); ++aCurrentNewPortion; - } } - //set the cursor to the end of the new sentence + + // restore cursor to the end of the sentence + // (will work also if the sentence length has changed, + // since cursors get updated automatically!) + Pop( FALSE ); + + // collapse cursor to the end of the modified sentence *pCrsr->Start() = *pCrsr->End(); - if( bIsGrammarCheck) + if (bRecheck) { //in grammar check the current sentence has to be checked again GoStartSentence(); } + // set continuation position for spell/grammar checking to the end of this sentence + pSpellIter->SetCurr( new SwPosition( *pCrsr->Start() ) ); + pDoc->EndUndo( UNDO_OVERWRITE, NULL ); EndAction(); } diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx index 6bf7ecbb8cdf..e7e870930d23 100644..100755 --- a/sw/source/filter/ww8/wrtww8.cxx +++ b/sw/source/filter/ww8/wrtww8.cxx @@ -2433,13 +2433,15 @@ typedef ::std::deque<SwNode *> SwNodeDeque; void MSWordExportBase::WriteText() { -#ifdef DEBUG - ::std::clog << "<WriteText>" << ::std::endl; - ::std::clog << dbg_out(pCurPam->GetDoc()->GetNodes()) << ::std::endl; - - SwNodeHashSet aNodeSet; - SwNodeDeque aNodeDeque; -#endif +// whoever has need of the missing function should go and implement it! +// This damned piece of code always breaks builds... +//#ifdef DEBUG +// ::std::clog << "<WriteText>" << ::std::endl; +// ::std::clog << dbg_out(pCurPam->GetDoc()->GetNodes()) << ::std::endl; +// +// SwNodeHashSet aNodeSet; +// SwNodeDeque aNodeDeque; +//#endif while( pCurPam->GetPoint()->nNode < pCurPam->GetMark()->nNode || ( pCurPam->GetPoint()->nNode == pCurPam->GetMark()->nNode && @@ -2447,6 +2449,9 @@ void MSWordExportBase::WriteText() { SwNode * pNd = pCurPam->GetNode(); +// whoever has need of the missing function should go and implement it! +// This damned piece of code always breaks builds... +#if 0 #ifdef DEBUG if (aNodeSet.find(pNd) == aNodeSet.end()) { @@ -2469,6 +2474,7 @@ void MSWordExportBase::WriteText() ::std::clog << "</nodes></already-done>" << ::std::endl; } #endif +#endif if ( pNd->IsTxtNode() ) SectionBreaksAndFrames( *pNd->GetTxtNode() ); @@ -3722,7 +3728,9 @@ void WW8AttributeOutput::TableNodeInfoInner( ww8::WW8TableNodeInfoInner::Pointer void MSWordExportBase::OutputEndNode( const SwEndNode &rNode ) { #ifdef DEBUG - ::std::clog << "<OutWW8_SwEndNode>" << dbg_out(&rNode) << ::std::endl; +// whoever has need of the missing function should go and implement it! +// This damned piece of code always breaks builds... +// ::std::clog << "<OutWW8_SwEndNode>" << dbg_out(&rNode) << ::std::endl; #endif ww8::WW8TableNodeInfo::Pointer_t pNodeInfo = mpTableInfo->getTableNodeInfo( &rNode ); diff --git a/sw/source/ui/dialog/SwSpellDialogChildWindow.cxx b/sw/source/ui/dialog/SwSpellDialogChildWindow.cxx index 8bf658d504b0..c9e99979e66b 100644 --- a/sw/source/ui/dialog/SwSpellDialogChildWindow.cxx +++ b/sw/source/ui/dialog/SwSpellDialogChildWindow.cxx @@ -32,13 +32,13 @@ #include <vcl/msgbox.hxx> #include <editeng/svxacorr.hxx> #include <editeng/acorrcfg.hxx> -#ifndef _SVX_SVXIDS_HRC #include <svx/svxids.hrc> -#endif #include <sfx2/app.hxx> #include <sfx2/bindings.hxx> #include <sfx2/dispatch.hxx> #include <editeng/unolingu.hxx> +#include <editeng/editeng.hxx> +#include <editeng/editview.hxx> #include <wrtsh.hxx> #include <sfx2/printer.hxx> #include <svx/svdoutl.hxx> @@ -56,9 +56,7 @@ #include <pam.hxx> #include <drawbase.hxx> #include <unotextrange.hxx> -#ifndef _DIALOG_HXX #include <dialog.hrc> -#endif #include <cmdid.h> @@ -202,12 +200,19 @@ SfxChildWinInfo SwSpellDialogChildWindow::GetInfo (void) const -----------------------------------------------------------------------*/ -svx::SpellPortions SwSpellDialogChildWindow::GetNextWrongSentence (void) +svx::SpellPortions SwSpellDialogChildWindow::GetNextWrongSentence(bool bRecheck) { svx::SpellPortions aRet; SwWrtShell* pWrtShell = GetWrtShell_Impl(); if(pWrtShell) { + if (!bRecheck) + { + // first set continuation point for spell/grammar check to the + // end of the current sentence + pWrtShell->MoveContinuationPosToEndOfCheckedSentence(); + } + ShellModes eSelMode = pWrtShell->GetView().GetShellMode(); bool bDrawText = SHELL_MODE_DRAWTEXT == eSelMode; bool bNormalText = @@ -239,7 +244,10 @@ svx::SpellPortions SwSpellDialogChildWindow::GetNextWrongSentence (void) if(!pWrtShell->HasSelection()) pWrtShell->GoStartSentence(); else + { + pWrtShell->ExpandToSentenceBorders(); m_pSpellState->m_bStartedInSelection = true; + } //determine if the selection is outside of the body text bOtherText = !(pWrtShell->GetFrmType(0,sal_True) & FRMTYPE_BODY); m_pSpellState->m_SpellStartPosition = bOtherText ? SPELL_START_OTHER : SPELL_START_BODY; @@ -269,7 +277,24 @@ svx::SpellPortions SwSpellDialogChildWindow::GetNextWrongSentence (void) m_pSpellState->m_SpellStartPosition = SPELL_START_DRAWTEXT; m_pSpellState->m_pStartDrawing = pSdrView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj(); OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView(); - m_pSpellState->m_aStartDrawingSelection = pOLV->GetSelection(); + // start checking at the top of the drawing object + pOLV->SetSelection( ESelection() ); + m_pSpellState->m_aStartDrawingSelection = ESelection(); +/* +Note: spelling in a selection only, or starting in a mid of a drawing object requires +further changes elsewhere. (Especially if it should work in sc and sd as well.) +The code below would only be part of the solution. +(Keeping it a as a comment for the time being) + ESelection aCurSel( pOLV->GetSelection() ); + ESelection aSentenceSel( pOLV->GetEditView().GetEditEngine()->SelectSentence( aCurSel ) ); + if (!aCurSel.HasRange()) + { + aSentenceSel.nEndPara = aSentenceSel.nStartPara; + aSentenceSel.nEndPos = aSentenceSel.nStartPos; + } + pOLV->SetSelection( aSentenceSel ); + m_pSpellState->m_aStartDrawingSelection = aSentenceSel; +*/ } m_pSpellState->m_bInitialCall = false; @@ -316,61 +341,66 @@ svx::SpellPortions SwSpellDialogChildWindow::GetNextWrongSentence (void) //spell inside of the Writer text if(!pWrtShell->SpellSentence(aRet, m_bIsGrammarCheckingOn)) { - //find out which text has been spelled body or other - bOtherText = !(pWrtShell->GetFrmType(0,sal_True) & FRMTYPE_BODY); - if(bOtherText && m_pSpellState->m_bStartedInOther && m_pSpellState->pOtherCursor) + // if there is a selection (within body or header/footer text) + // then spell/grammar checking should not move outside of it. + if (!m_pSpellState->m_bStartedInSelection) { - m_pSpellState->m_bStartedInOther = false; - pWrtShell->SetSelection(*m_pSpellState->pOtherCursor); - pWrtShell->SpellEnd(); - delete m_pSpellState->pOtherCursor; - m_pSpellState->pOtherCursor = 0; - pWrtShell->SpellStart(DOCPOS_OTHERSTART, DOCPOS_CURR, DOCPOS_OTHERSTART, FALSE ); - pWrtShell->SpellSentence(aRet, m_bIsGrammarCheckingOn); - } - if(!aRet.size()) - { - //end spelling - pWrtShell->SpellEnd(); - if(bOtherText) + //find out which text has been spelled body or other + bOtherText = !(pWrtShell->GetFrmType(0,sal_True) & FRMTYPE_BODY); + if(bOtherText && m_pSpellState->m_bStartedInOther && m_pSpellState->pOtherCursor) { - m_pSpellState->m_bOtherSpelled = true; - //has the body been spelled? - if(!m_pSpellState->m_bBodySpelled) + m_pSpellState->m_bStartedInOther = false; + pWrtShell->SetSelection(*m_pSpellState->pOtherCursor); + pWrtShell->SpellEnd(); + delete m_pSpellState->pOtherCursor; + m_pSpellState->pOtherCursor = 0; + pWrtShell->SpellStart(DOCPOS_OTHERSTART, DOCPOS_CURR, DOCPOS_OTHERSTART, FALSE ); + pWrtShell->SpellSentence(aRet, m_bIsGrammarCheckingOn); + } + if(!aRet.size()) + { + //end spelling + pWrtShell->SpellEnd(); + if(bOtherText) { - pWrtShell->SpellStart(DOCPOS_START, DOCPOS_END, DOCPOS_START, FALSE ); - if(!pWrtShell->SpellSentence(aRet, m_bIsGrammarCheckingOn)) + m_pSpellState->m_bOtherSpelled = true; + //has the body been spelled? + if(!m_pSpellState->m_bBodySpelled) { - m_pSpellState->m_bBodySpelled = true; - pWrtShell->SpellEnd(); + pWrtShell->SpellStart(DOCPOS_START, DOCPOS_END, DOCPOS_START, FALSE ); + if(!pWrtShell->SpellSentence(aRet, m_bIsGrammarCheckingOn)) + { + m_pSpellState->m_bBodySpelled = true; + pWrtShell->SpellEnd(); + } } } + else + { + m_pSpellState->m_bBodySpelled = true; + if(!m_pSpellState->m_bOtherSpelled && pWrtShell->HasOtherCnt()) + { + pWrtShell->SpellStart(DOCPOS_OTHERSTART, DOCPOS_OTHEREND, DOCPOS_OTHERSTART, FALSE ); + if(!pWrtShell->SpellSentence(aRet, m_bIsGrammarCheckingOn)) + { + pWrtShell->SpellEnd(); + m_pSpellState->m_bOtherSpelled = true; + } + } + else + m_pSpellState->m_bOtherSpelled = true; + } } - else + + //search for a draw text object that contains error and spell it + if(!aRet.size() && + (m_pSpellState->m_bDrawingsSpelled || + !FindNextDrawTextError_Impl(*pWrtShell) || !SpellDrawText_Impl(*pWrtShell, aRet))) { - m_pSpellState->m_bBodySpelled = true; - if(!m_pSpellState->m_bOtherSpelled && pWrtShell->HasOtherCnt()) - { - pWrtShell->SpellStart(DOCPOS_OTHERSTART, DOCPOS_OTHEREND, DOCPOS_OTHERSTART, FALSE ); - if(!pWrtShell->SpellSentence(aRet, m_bIsGrammarCheckingOn)) - { - pWrtShell->SpellEnd(); - m_pSpellState->m_bOtherSpelled = true; - } - } - else - m_pSpellState->m_bOtherSpelled = true; + lcl_LeaveDrawText(*pWrtShell); + m_pSpellState->m_bDrawingsSpelled = true; } } - - //search for a draw text object that contains error and spell it - if(!aRet.size() && - (m_pSpellState->m_bDrawingsSpelled || - !FindNextDrawTextError_Impl(*pWrtShell) || !SpellDrawText_Impl(*pWrtShell, aRet))) - { - lcl_LeaveDrawText(*pWrtShell); - m_pSpellState->m_bDrawingsSpelled = true; - } } } // now only the rest of the body text can be spelled - @@ -430,7 +460,7 @@ svx::SpellPortions SwSpellDialogChildWindow::GetNextWrongSentence (void) /*-- 09.09.2003 10:39:40--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwSpellDialogChildWindow::ApplyChangedSentence(const svx::SpellPortions& rChanged) +void SwSpellDialogChildWindow::ApplyChangedSentence(const svx::SpellPortions& rChanged, bool bRecheck) { SwWrtShell* pWrtShell = GetWrtShell_Impl(); DBG_ASSERT(!m_pSpellState->m_bInitialCall, "ApplyChangedSentence in initial call or after resume"); @@ -443,13 +473,19 @@ void SwSpellDialogChildWindow::ApplyChangedSentence(const svx::SpellPortions& rC SHELL_MODE_LIST_TEXT == eSelMode || SHELL_MODE_TABLE_LIST_TEXT == eSelMode || SHELL_MODE_TEXT == eSelMode; + + // evaluate if the same sentence should be rechecked or not. + // Sentences that got grammar checked should always be rechecked in order + // to detect possible errors that get introduced with the changes + bRecheck |= pWrtShell->HasLastSentenceGotGrammarChecked(); + if(bNormalText) - pWrtShell->ApplyChangedSentence(rChanged, m_bIsGrammarCheckingOn); + pWrtShell->ApplyChangedSentence(rChanged, bRecheck); else if(bDrawText ) { SdrView* pDrView = pWrtShell->GetDrawView(); SdrOutliner *pOutliner = pDrView->GetTextEditOutliner(); - pOutliner->ApplyChangedSentence(pDrView->GetTextEditOutlinerView()->GetEditView(), rChanged, m_bIsGrammarCheckingOn); + pOutliner->ApplyChangedSentence(pDrView->GetTextEditOutlinerView()->GetEditView(), rChanged, bRecheck); } } } @@ -847,7 +883,7 @@ bool SwSpellDialogChildWindow::FindNextDrawTextError_Impl(SwWrtShell& rSh) Point aTmp( 0,0 ); rSh.SelectObj( aTmp, 0, pTextObj ); SdrPageView* pPV = pDrView->GetSdrPageView(); - rView.BeginTextEdit( pTextObj, pPV, &rView.GetEditWin(), FALSE ); + rView.BeginTextEdit( pTextObj, pPV, &rView.GetEditWin(), FALSE, TRUE ); rView.AttrChangedNotify(&rSh); bNextDoc = true; } diff --git a/sw/source/ui/inc/SwSpellDialogChildWindow.hxx b/sw/source/ui/inc/SwSpellDialogChildWindow.hxx index 3ab86b3469d7..dd3e7e2dce9b 100644 --- a/sw/source/ui/inc/SwSpellDialogChildWindow.hxx +++ b/sw/source/ui/inc/SwSpellDialogChildWindow.hxx @@ -48,8 +48,8 @@ class SwSpellDialogChildWindow void LockFocusNotification(bool bLock); protected: - virtual svx::SpellPortions GetNextWrongSentence (void); - virtual void ApplyChangedSentence(const svx::SpellPortions& rChanged); + virtual svx::SpellPortions GetNextWrongSentence(bool bRecheck); + virtual void ApplyChangedSentence(const svx::SpellPortions& rChanged, bool bRecheck); virtual void AddAutoCorrection(const String& rOld, const String& rNew, LanguageType eLanguage); virtual bool HasAutoCorrection(); virtual bool HasGrammarChecking(); diff --git a/sw/source/ui/inc/view.hxx b/sw/source/ui/inc/view.hxx index 7cff88c897cc..1a950f98032c 100644 --- a/sw/source/ui/inc/view.hxx +++ b/sw/source/ui/inc/view.hxx @@ -574,7 +574,7 @@ public: BOOL HasDrwObj(SdrObject *pSdrObj) const; BOOL HasOnlyObj(SdrObject *pSdrObj, UINT32 eObjInventor) const; BOOL BeginTextEdit( SdrObject* pObj, SdrPageView* pPV=NULL, - Window* pWin=NULL, BOOL bIsNewObj=FALSE); + Window* pWin=NULL, bool bIsNewObj=false, bool bSetSelectionToStart=false ); void StateTabWin(SfxItemSet&); diff --git a/sw/source/ui/uiview/viewdraw.cxx b/sw/source/ui/uiview/viewdraw.cxx index fe38c56f29e5..d9b8ab2c297b 100644 --- a/sw/source/ui/uiview/viewdraw.cxx +++ b/sw/source/ui/uiview/viewdraw.cxx @@ -520,7 +520,8 @@ sal_Bool SwView::EnterDrawTextMode(const Point& aDocPos) /****************************************************************************** * Beschreibung: DrawTextEditMode einschalten ******************************************************************************/ -sal_Bool SwView::BeginTextEdit(SdrObject* pObj, SdrPageView* pPV, Window* pWin, sal_Bool bIsNewObj) +sal_Bool SwView::BeginTextEdit(SdrObject* pObj, SdrPageView* pPV, Window* pWin, + bool bIsNewObj, bool bSetSelectionToStart) { SwWrtShell *pSh = &GetWrtShell(); SdrView *pSdrView = pSh->GetDrawView(); @@ -606,7 +607,11 @@ sal_Bool SwView::BeginTextEdit(SdrObject* pObj, SdrPageView* pPV, Window* pWin, Color aBackground(pSh->GetShapeBackgrd()); pView->SetBackgroundColor(aBackground); } + + // editing should start at the end of text, spell checking at the beginning ... ESelection aNewSelection(EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND, EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND); + if (bSetSelectionToStart) + aNewSelection = ESelection(); pView->SetSelection(aNewSelection); } |