Author: orw Date: Fri Jun 21 08:59:33 2013 New Revision: 1495337 URL: http://svn.apache.org/r1495337 Log: 121435: Change Tracking - Accept and Reject dialog - on accessing redline by index assure that index has valid value
Modified: openoffice/trunk/main/sw/source/ui/misc/redlndlg.cxx Modified: openoffice/trunk/main/sw/source/ui/misc/redlndlg.cxx URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sw/source/ui/misc/redlndlg.cxx?rev=1495337&r1=1495336&r2=1495337&view=diff ============================================================================== --- openoffice/trunk/main/sw/source/ui/misc/redlndlg.cxx (original) +++ openoffice/trunk/main/sw/source/ui/misc/redlndlg.cxx Fri Jun 21 08:59:33 2013 @@ -350,7 +350,7 @@ void SwRedlineAcceptDlg::InitAuthors() pFilterPage->ClearAuthors(); String sParent; - sal_uInt16 nCount = pSh->GetRedlineCount(); + const sal_uInt16 nRedlineCount = pSh->GetRedlineCount(); bOnlyFormatedRedlines = sal_True; bHasReadonlySel = sal_False; @@ -358,7 +358,7 @@ void SwRedlineAcceptDlg::InitAuthors() sal_uInt16 i; // Autoren ermitteln - for ( i = 0; i < nCount; i++) + for ( i = 0; i < nRedlineCount; i++) { const SwRedline& rRedln = pSh->GetRedline(i); @@ -390,15 +390,19 @@ void SwRedlineAcceptDlg::InitAuthors() sal_Bool bEnable = pTable->GetEntryCount() != 0 && !pSh->getIDocumentRedlineAccess()->GetRedlinePassword().getLength(); sal_Bool bSel = pTable->FirstSelected() != 0; - SvLBoxEntry* pSelEntry = pTable->FirstSelected(); - while (pSelEntry) - { - sal_uInt16 nPos = GetRedlinePos(*pSelEntry); - const SwRedline& rRedln = pSh->GetRedline( nPos ); - - bIsNotFormated |= nsRedlineType_t::REDLINE_FORMAT != rRedln.GetType(); - pSelEntry = pTable->NextSelected(pSelEntry); - } + { + SvLBoxEntry* pSelEntry = pTable->FirstSelected(); + while (pSelEntry) + { + const sal_uInt16 nPos = GetRedlinePos(*pSelEntry); + if ( nPos < nRedlineCount ) + { + const SwRedline& rRedln = pSh->GetRedline( nPos ); + bIsNotFormated |= nsRedlineType_t::REDLINE_FORMAT != rRedln.GetType(); + } + pSelEntry = pTable->NextSelected(pSelEntry); + } + } pTPView->EnableAccept( bEnable && bSel ); pTPView->EnableReject( bEnable && bIsNotFormated && bSel ); @@ -823,7 +827,7 @@ void SwRedlineAcceptDlg::InsertParents(s sal_uInt16 nAutoFmt = HasRedlineAutoFmt() ? nsRedlineType_t::REDLINE_FORM_AUTOFMT : 0; String sParent; - sal_uInt16 nCount = pSh->GetRedlineCount(); + const sal_uInt16 nCount = pSh->GetRedlineCount(); nEnd = Min((sal_uInt16)nEnd, (sal_uInt16)(nCount - 1)); // Handelt auch nEnd=USHRT_MAX (bis zum Ende) ab if (nEnd == USHRT_MAX) @@ -949,7 +953,7 @@ void SwRedlineAcceptDlg::CallAcceptRejec aIter != aEnd; aIter++ ) { - sal_uInt16 nPosition = GetRedlinePos( **aIter ); + const sal_uInt16 nPosition = GetRedlinePos( **aIter ); if( nPosition != USHRT_MAX ) (pSh->*FnAccRej)( nPosition ); } @@ -1102,7 +1106,6 @@ IMPL_LINK( SwRedlineAcceptDlg, GotoHdl, sal_Bool bIsNotFormated = sal_False; sal_Bool bSel = sal_False; -// sal_Bool bReadonlySel = sal_False; //#98883# don't select redlines while the dialog is not focussed //#107938# But not only ask pTable if it has the focus. To move @@ -1135,32 +1138,28 @@ IMPL_LINK( SwRedlineAcceptDlg, GotoHdl, else bSel = sal_True; - // #98864# find the selected redline (ignore, if the redline is already gone) - sal_uInt16 nPos = GetRedlinePos(*pActEntry); - if( nPos != USHRT_MAX ) - { - - const SwRedline& rRedln = pSh->GetRedline( nPos ); - bIsNotFormated |= nsRedlineType_t::REDLINE_FORMAT != rRedln.GetType(); - -//JP 27.9.2001: make no sense if we handle readonly sections -// if( !bReadonlySel && rRedln.HasReadonlySel() ) -// bReadonlySel = sal_True; - - if (pSh->GotoRedline(nPos, sal_True)) - { - pSh->SetInSelect(); - pSh->EnterAddMode(); - } - } + // #98864# find the selected redline (ignore, if the redline is already gone) + const sal_uInt16 nPos = GetRedlinePos(*pActEntry); + if ( nPos < pSh->GetRedlineCount() ) + { + + const SwRedline& rRedln = pSh->GetRedline( nPos ); + bIsNotFormated |= nsRedlineType_t::REDLINE_FORMAT != rRedln.GetType(); + + if (pSh->GotoRedline(nPos, sal_True)) + { + pSh->SetInSelect(); + pSh->EnterAddMode(); + } + } pSelEntry = pActEntry = pTable->NextSelected(pSelEntry); - } + } - pSh->LeaveAddMode(); - pSh->EndAction(); - pSh->SetCareWin(NULL); - } + pSh->LeaveAddMode(); + pSh->EndAction(); + pSh->SetCareWin(NULL); + } sal_Bool bEnable = !pSh->getIDocumentRedlineAccess()->GetRedlinePassword().getLength(); pTPView->EnableAccept( bEnable && bSel /*&& !bReadonlySel*/ ); pTPView->EnableReject( bEnable && bSel && bIsNotFormated /*&& !bReadonlySel*/ ); @@ -1192,7 +1191,7 @@ IMPL_LINK( SwRedlineAcceptDlg, CommandHd if (pTable->GetParent(pEntry)) pTopEntry = pTable->GetParent(pEntry); - sal_uInt16 nPos = GetRedlinePos(*pTopEntry); + const sal_uInt16 nPos = GetRedlinePos(*pTopEntry); // Bei geschuetzten Bereichen kommentieren disablen if ((pRed = pSh->GotoRedline(nPos, sal_True)) != 0) @@ -1226,87 +1225,91 @@ IMPL_LINK( SwRedlineAcceptDlg, CommandHd sal_uInt16 nRet = aPopup.Execute(pTable, aCEvt.GetMousePosPixel()); - switch( nRet ) - { - case MN_EDIT_COMMENT: - { - String sComment; - if (pEntry) - { - if (pTable->GetParent(pEntry)) - pEntry = pTable->GetParent(pEntry); - - sal_uInt16 nPos = GetRedlinePos(*pEntry); - const SwRedline &rRedline = pSh->GetRedline(nPos); - + switch( nRet ) + { + case MN_EDIT_COMMENT: + { + String sComment; + if (pEntry) + { + if (pTable->GetParent(pEntry)) + pEntry = pTable->GetParent(pEntry); + + const sal_uInt16 nPos = GetRedlinePos(*pEntry); + if ( nPos >= pSh->GetRedlineCount() ) + { + break; + } + const SwRedline &rRedline = pSh->GetRedline(nPos); + + + /* enable again once we have redline comments in the margin + sComment = rRedline.GetComment(); + if ( sComment == String(::rtl::OUString::createFromAscii("")) ) + GetActiveView()->GetDocShell()->Broadcast(SwRedlineHint(&rRedline,SWREDLINE_INSERTED)); + const_cast<SwRedline&>(rRedline).Broadcast(SwRedlineHint(&rRedline,SWREDLINE_FOCUS)); + */ - /* enable again once we have redline comments in the margin - sComment = rRedline.GetComment(); - if ( sComment == String(::rtl::OUString::createFromAscii("")) ) - GetActiveView()->GetDocShell()->Broadcast(SwRedlineHint(&rRedline,SWREDLINE_INSERTED)); - const_cast<SwRedline&>(rRedline).Broadcast(SwRedlineHint(&rRedline,SWREDLINE_FOCUS)); - */ - - sComment = rRedline.GetComment(); - SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + sComment = rRedline.GetComment(); + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); DBG_ASSERT(pFact, "Dialogdiet fail!"); - ::DialogGetRanges fnGetRange = pFact->GetDialogGetRangesFunc( RID_SVXDLG_POSTIT ); + ::DialogGetRanges fnGetRange = pFact->GetDialogGetRangesFunc( RID_SVXDLG_POSTIT ); DBG_ASSERT(fnGetRange, "Dialogdiet fail! GetRanges()"); - SfxItemSet aSet( pSh->GetAttrPool(), fnGetRange() ); + SfxItemSet aSet( pSh->GetAttrPool(), fnGetRange() ); - aSet.Put(SvxPostItTextItem(sComment.ConvertLineEnd(), SID_ATTR_POSTIT_TEXT)); - aSet.Put(SvxPostItAuthorItem(rRedline.GetAuthorString(), SID_ATTR_POSTIT_AUTHOR)); + aSet.Put(SvxPostItTextItem(sComment.ConvertLineEnd(), SID_ATTR_POSTIT_TEXT)); + aSet.Put(SvxPostItAuthorItem(rRedline.GetAuthorString(), SID_ATTR_POSTIT_AUTHOR)); - aSet.Put(SvxPostItDateItem( GetAppLangDateTimeString( - rRedline.GetRedlineData().GetTimeStamp() ), - SID_ATTR_POSTIT_DATE )); + aSet.Put(SvxPostItDateItem( GetAppLangDateTimeString( + rRedline.GetRedlineData().GetTimeStamp() ), + SID_ATTR_POSTIT_DATE )); AbstractSvxPostItDialog* pDlg = pFact->CreateSvxPostItDialog( pParentDlg, aSet, sal_False ); DBG_ASSERT(pDlg, "Dialogdiet fail!"); - pDlg->HideAuthor(); + pDlg->HideAuthor(); - sal_uInt16 nResId = 0; - switch( rRedline.GetType() ) - { - case nsRedlineType_t::REDLINE_INSERT: - nResId = STR_REDLINE_INSERTED; - break; - case nsRedlineType_t::REDLINE_DELETE: - nResId = STR_REDLINE_DELETED; - break; - case nsRedlineType_t::REDLINE_FORMAT: - nResId = STR_REDLINE_FORMATED; - break; - case nsRedlineType_t::REDLINE_TABLE: - nResId = STR_REDLINE_TABLECHG; - break; + sal_uInt16 nResId = 0; + switch( rRedline.GetType() ) + { + case nsRedlineType_t::REDLINE_INSERT: + nResId = STR_REDLINE_INSERTED; + break; + case nsRedlineType_t::REDLINE_DELETE: + nResId = STR_REDLINE_DELETED; + break; + case nsRedlineType_t::REDLINE_FORMAT: + nResId = STR_REDLINE_FORMATED; + break; + case nsRedlineType_t::REDLINE_TABLE: + nResId = STR_REDLINE_TABLECHG; + break; default:;//prevent warning - } - String sTitle(SW_RES(STR_REDLINE_COMMENT)); - if( nResId ) - sTitle += SW_RESSTR( nResId ); - pDlg->SetText(sTitle); - - pSh->SetCareWin(pDlg->GetWindow()); - - if ( pDlg->Execute() == RET_OK ) - { - const SfxItemSet* pOutSet = pDlg->GetOutputItemSet(); - String sMsg(((const SvxPostItTextItem&)pOutSet->Get(SID_ATTR_POSTIT_TEXT)).GetValue()); - - // Kommentar einfuegen bzw aendern - pSh->SetRedlineComment(sMsg); - sMsg.SearchAndReplaceAll((sal_Unicode)_LF,(sal_Unicode)' '); - pTable->SetEntryText(sMsg, pEntry, 3); - } - - delete pDlg; - pSh->SetCareWin(NULL); - } + } + String sTitle(SW_RES(STR_REDLINE_COMMENT)); + if( nResId ) + sTitle += SW_RESSTR( nResId ); + pDlg->SetText(sTitle); + + pSh->SetCareWin(pDlg->GetWindow()); + + if ( pDlg->Execute() == RET_OK ) + { + const SfxItemSet* pOutSet = pDlg->GetOutputItemSet(); + String sMsg(((const SvxPostItTextItem&)pOutSet->Get(SID_ATTR_POSTIT_TEXT)).GetValue()); + + // Kommentar einfuegen bzw aendern + pSh->SetRedlineComment(sMsg); + sMsg.SearchAndReplaceAll((sal_Unicode)_LF,(sal_Unicode)' '); + pTable->SetEntryText(sMsg, pEntry, 3); + } + + delete pDlg; + pSh->SetCareWin(NULL); + } - } - break; + } + break; case MN_SORT_ACTION: case MN_SORT_AUTHOR: