diff options
author | Oliver Bolte <obo@openoffice.org> | 2009-02-13 14:09:50 +0000 |
---|---|---|
committer | Oliver Bolte <obo@openoffice.org> | 2009-02-13 14:09:50 +0000 |
commit | 02280bac14369d1fb3cea6e3b8d342ca56f96493 (patch) | |
tree | 999eeda1c1ebc8eb390665c0b95f08d9c7cc8885 /sw/source/ui/docvw/PostItMgr.cxx | |
parent | 19203faa44439b953d670ca169d1f1900e937463 (diff) |
CWS-TOOLING: integrate CWS notes8
2009-01-23 17:44:41 +0100 mba r266842 : #i98275#: start speller before setting text
2009-01-23 10:19:47 +0100 mod r266776 : minor cleanup
2009-01-22 16:45:38 +0100 mod r266742 : no looping through notes while saving
2009-01-22 16:40:55 +0100 mod r266741 : #i98055#
2009-01-22 15:56:27 +0100 os r266731 : #98358# dummy strings now hidden
2009-01-22 09:31:16 +0100 mod r266713 : correct hiding and layout order
2009-01-22 09:21:23 +0100 mod r266712 : need a speller
2009-01-21 17:21:33 +0100 mod r266691 : notes config
2009-01-21 17:18:23 +0100 mod r266690 : fix for editing states
2009-01-21 17:18:14 +0100 mod r266689 : fix for editing states
2009-01-20 14:15:16 +0100 mod r266578 : undo fix, mba will fix it by importing the props
2009-01-20 00:36:01 +0100 mod r266537 : do not show ankor of top reply note if we are still inside a note inside the same stack
2009-01-20 00:33:48 +0100 mod r266536 : fix typo which does not need to be translated
2009-01-20 00:17:19 +0100 mod r266535 : correct replacment of reply text
2009-01-19 23:36:12 +0100 mod r266534 : #i97693#
2009-01-19 23:32:26 +0100 mod r266533 : #i97380#
2009-01-19 23:30:05 +0100 mod r266532 : #i97380#
2009-01-19 23:21:35 +0100 mod r266531 : #i97299#
Diffstat (limited to 'sw/source/ui/docvw/PostItMgr.cxx')
-rw-r--r-- | sw/source/ui/docvw/PostItMgr.cxx | 207 |
1 files changed, 68 insertions, 139 deletions
diff --git a/sw/source/ui/docvw/PostItMgr.cxx b/sw/source/ui/docvw/PostItMgr.cxx index edabcf30f1f1..7a63ad665aef 100644 --- a/sw/source/ui/docvw/PostItMgr.cxx +++ b/sw/source/ui/docvw/PostItMgr.cxx @@ -58,6 +58,7 @@ #include <undobj.hxx> #include <tools/color.hxx> +#include <swmodule.hxx> #include <docvw.hrc> #include "cmdid.h" @@ -133,6 +134,12 @@ SwPostItMgr::SwPostItMgr(SwView* pView) if(!mpView->GetDrawView() ) mpView->GetWrtShell().MakeDrawView(); + SwNoteProps aProps; + mpIsShowAnkor = aProps.IsShowAnkor(); + + //make sure we get the colour yellow always, even if not the first one of comments or redlining + SW_MOD()->GetRedlineAuthor(); + // collect all PostIts and redline comments that exist after loading the document // don't check for existance for any of them, don't focus them AddPostIts(false,false); @@ -141,7 +148,7 @@ SwPostItMgr::SwPostItMgr(SwView* pView) */ // we want to receive stuff like SFX_HINT_DOCCHANGED StartListening(*mpView->GetDocShell()); - if (!mvPostItFlds.empty() && ShowNotes()) + if (!mvPostItFlds.empty()) { mbWaitingForCalcRects = true; mnEventId = Application::PostUserEvent( LINK( this, SwPostItMgr, CalcHdl), 0 ); @@ -171,6 +178,8 @@ void SwPostItMgr::CheckForRemovedPostIts() { SwMarginItem* p = (*it); mvPostItFlds.remove(*it); + if (GetActivePostIt() == p->pPostIt) + SetActivePostIt(0); if (p->pPostIt) delete p->pPostIt; delete p; @@ -243,7 +252,7 @@ void SwPostItMgr::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) sal_uInt32 nId = ((SfxEventHint&)rHint).GetEventId(); if ( nId == SW_EVENT_LAYOUT_FINISHED ) { - if ( !mbWaitingForCalcRects && ShowNotes() && !mvPostItFlds.empty()) + if ( !mbWaitingForCalcRects && !mvPostItFlds.empty()) { mbWaitingForCalcRects = true; mnEventId = Application::PostUserEvent( LINK( this, SwPostItMgr, CalcHdl), 0 ); @@ -269,7 +278,7 @@ void SwPostItMgr::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) { if ( mpView->GetDocShell() == &rBC ) { - if ( !mbWaitingForCalcRects && ShowNotes() && !mvPostItFlds.empty()) + if ( !mbWaitingForCalcRects && !mvPostItFlds.empty()) { mbWaitingForCalcRects = true; mnEventId = Application::PostUserEvent( LINK( this, SwPostItMgr, CalcHdl), 0 ); @@ -436,9 +445,6 @@ void SwPostItMgr::Focus(SfxBroadcaster& rBC) bool SwPostItMgr::CalcRects() { - if (!ShowNotes()) - return false; - if ( mnEventId ) { // if CalcRects() was forced and an event is still pending: remove it @@ -466,8 +472,7 @@ bool SwPostItMgr::CalcRects() SwRect aOldRect(pItem->mPos); SwPostItHelper::SwLayoutStatus eOldStatus = pItem->mLayoutStatus; std::vector< SwLayoutInfo > aInfo; - //pItem->mLayoutStatus = SwPostItHelper::getLayoutInfos( aInfo, pItem->pFmtFld->GetTxtFld() ); - SwPosition aPosition = pItem->GetPosition(); + SwPosition aPosition = pItem->GetPosition(); pItem->mLayoutStatus = SwPostItHelper::getLayoutInfos( aInfo, aPosition ); if( aInfo.size() ) { @@ -588,8 +593,7 @@ void SwPostItMgr::LayoutPostIts() if ( !mvPostItFlds.empty() && !mbWaitingForCalcRects ) { mbLayouting = true; - if (ShowNotes()) - { + //loop over all pages and do the layout // - create SwPostIt if neccessary // - place SwPostIts on their initial position @@ -631,7 +635,7 @@ void SwPostItMgr::LayoutPostIts() long aPostItHeight = 0; if (!pPostIt) { - pPostIt = (*i)->GetMarginWindow(static_cast<Window*>(&mpView->GetEditWin()),WINDOW_CONTROL,this,0); + pPostIt = (*i)->GetMarginWindow(static_cast<Window*>(&mpView->GetEditWin()),WINDOW_CONTROL|WB_NODIALOGCONTROL,this,0); pPostIt->InitControls(); pPostIt->SetReadonly(mbReadOnly); pItem->pPostIt = pPostIt; @@ -644,7 +648,7 @@ void SwPostItMgr::LayoutPostIts() } } - if (pItem->pPostIt->ISA(SwPostIt)) + if (pItem->pPostIt->ISA(SwPostIt)) { static_cast<SwPostIt*>(pPostIt)->SetChangeTracking(pItem->mLayoutStatus,GetColorAnkor(pItem->mRedlineAuthor)); } @@ -656,7 +660,7 @@ void SwPostItMgr::LayoutPostIts() if (pItem->bFocus) { mbLayout = true; - pPostIt->GrabFocus(); + pPostIt->GrabFocus(); pItem->bFocus = false; } // only the visible postits are used for the final layout @@ -670,10 +674,13 @@ void SwPostItMgr::LayoutPostIts() } } - if (aVisiblePostItList.size()>0) + if ((aVisiblePostItList.size()>0) && ShowNotes()) { bool bOldScrollbar = mPages[n]->bScrollbar; - mPages[n]->bScrollbar = LayoutByPage(aVisiblePostItList, mPages[n]->mPageRect.SVRect(), lNeededHeight); + if (ShowNotes()) + mPages[n]->bScrollbar = LayoutByPage(aVisiblePostItList, mPages[n]->mPageRect.SVRect(), lNeededHeight); + else + mPages[n]->bScrollbar = false; if (!mPages[n]->bScrollbar) { mPages[n]->lOffset = 0; @@ -689,9 +696,9 @@ void SwPostItMgr::LayoutPostIts() bUpdate = (bOldScrollbar != mPages[n]->bScrollbar) || bUpdate; const long aSidebarheight = mPages[n]->bScrollbar ? mpEditWin->PixelToLogic(Size(0,GetSidebarScrollerHeight())).Height() : 0; /* - TODO - - enlarge all notes till GetNextBorder(), as we resized to average value before - */ + TODO + - enlarge all notes till GetNextBorder(), as we resized to average value before + */ //lets hide the ones which overlap the page for(SwMarginWin_iterator i = aVisiblePostItList.begin(); i!= aVisiblePostItList.end() ; i++) { @@ -723,16 +730,26 @@ void SwPostItMgr::LayoutPostIts() DBG_ASSERT(mPages[n]->bScrollbar,"SwPostItMgr::LayoutByPage(): note overlaps, but bScrollbar is not true"); } } + // do some magic so we really see the focused note for(SwMarginWin_iterator i = aVisiblePostItList.begin(); i!= aVisiblePostItList.end() ; i++) { - if ((*i)->HasChildPathFocus()) + if ((*i)->HasChildPathFocus()) { MakeVisible((*i),n+1); break; } } } + else + { + for(SwMarginWin_iterator i = aVisiblePostItList.begin(); i!= aVisiblePostItList.end() ; i++) + (*i)->SetPosAndSize(); + + bool bOldScrollbar = mPages[n]->bScrollbar; + mPages[n]->bScrollbar = false; + bUpdate = (bOldScrollbar != mPages[n]->bScrollbar) || bUpdate; + } aVisiblePostItList.clear(); } else @@ -742,38 +759,39 @@ void SwPostItMgr::LayoutPostIts() } } - // notes scrollbar is otherwise not drawn correctly for some cases - // scrollbar area is enough - if (bUpdate) - mpEditWin->Invalidate(); - } - else - { // we do not want to see the notes anymore -> Options-Writer-View-Notes - bool bRepair = false; - for(SwMarginItem_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) - { - SwMarginItem* pItem = (*i); - if ( !pItem->UseElement() ) + if (!ShowNotes()) + { // we do not want to see the notes anymore -> Options-Writer-View-Notes + bool bRepair = false; + for(SwMarginItem_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { - DBG_ERROR("PostIt is not in doc!"); - bRepair = true; - continue; - } + SwMarginItem* pItem = (*i); + if ( !pItem->UseElement() ) + { + DBG_ERROR("PostIt is not in doc!"); + bRepair = true; + continue; + } - if ((*i)->pPostIt) - { - (*i)->pPostIt->HideNote(); - if ((*i)->pPostIt->HasChildPathFocus()) + if ((*i)->pPostIt) { - SetActivePostIt(0); - (*i)->pPostIt->GrabFocusToDocument(); + (*i)->pPostIt->HideNote(); + if ((*i)->pPostIt->HasChildPathFocus()) + { + SetActivePostIt(0); + (*i)->pPostIt->GrabFocusToDocument(); + } } } + + if ( bRepair ) + CheckForRemovedPostIts(); } - if ( bRepair ) - CheckForRemovedPostIts(); - } + + // notes scrollbar is otherwise not drawn correctly for some cases + // scrollbar area is enough + if (bUpdate) + mpEditWin->Invalidate(); mbLayouting = false; } } @@ -1148,7 +1166,8 @@ void SwPostItMgr::RemoveMarginWin() for(std::list<SwMarginItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { EndListening( *((*i)->GetBroadCaster()) ); - delete (*i)->pPostIt; + if ((*i)->pPostIt) + delete (*i)->pPostIt; delete (*i); } mvPostItFlds.clear(); @@ -1841,101 +1860,12 @@ void SwPostItMgr::SetReadOnlyState() (*i)->pPostIt->SetReadonly( mbReadOnly ); } -void SwPostItMgr::StartSearchAndReplace(const SvxSearchItem& rSearchItem) +void SwPostItMgr::CheckMetaText() { - for(std::list<SwMarginItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) - if ( (*i)->pPostIt ) - { - ESelection aOldSelection = (*i)->pPostIt->View()->GetSelection(); - (*i)->pPostIt->View()->SetSelection(ESelection(0,0,0,0)); - if (!(*i)->pPostIt->View()->StartSearchAndReplace( rSearchItem )) - (*i)->pPostIt->View()->SetSelection(aOldSelection); - /* if ((*i)->pPostIt->View()->StartSearchAndReplace( rSearchItem )) - (*i)->pPostIt->GrabFocus(); - return; - */ - } - - /* - 673 BOOL bFromStart, - 674 BOOL bApi, - 675 BOOL bRecursive) - 676 { - 677 ExtTextView* pTextView = aEditWin.GetTextView(); - 678 TextSelection aSel; - 679 TextPaM aPaM; - 680 - 681 BOOL bForward = !rSearchItem.GetBackward(); - 682 BOOL bAtStart = pTextView->GetSelection() == TextSelection( aPaM, aPaM ); - 683 - 684 if( !bForward ) - 685 aPaM = TextPaM( (ULONG)-1, (USHORT)-1 ); - 686 - 687 if( bFromStart ) - 688 { - 689 aSel = pTextView->GetSelection(); - 690 pTextView->SetSelection( TextSelection( aPaM, aPaM )); - 691 } - 692 - 693 SearchOptions aSearchOpt( rSearchItem.GetSearchOptions() ); - 694 aSearchOpt.Locale = SvxCreateLocale( - 695 static_cast< LanguageType >( GetAppLanguage() ) ); - 696 - 697 USHORT nFound; - 698 BOOL bAll = FALSE; - 699 switch( rSearchItem.GetCommand() ) - 700 { - 701 case SVX_SEARCHCMD_FIND: - 702 case SVX_SEARCHCMD_FIND_ALL: - 703 nFound = pTextView->Search( aSearchOpt, bForward ); - 704 break; - 705 - 706 case SVX_SEARCHCMD_REPLACE_ALL: bAll = TRUE; - 707 case SVX_SEARCHCMD_REPLACE: - 708 nFound = pTextView->Replace( aSearchOpt, bAll, bForward ); - 709 break; - 710 - 711 default: - 712 nFound = 0; - 713 } - 714 - 715 if( !nFound ) - 716 { - 717 BOOL bNotFoundMessage = FALSE; - 718 if(!bRecursive) - 719 { - 720 if(!bFromStart) - 721 { - 722 bNotFoundMessage = bAtStart; - 723 } - 724 else - 725 { - 726 bNotFoundMessage = TRUE; - 727 pTextView->SetSelection( aSel ); - 728 } - 729 } - 730 else if(bAtStart) - 731 { - 732 bNotFoundMessage = TRUE; - 733 } - 734 - 735 - 736 if(!bApi) - 737 if(bNotFoundMessage) - 738 { - 739 InfoBox( 0, SW_RES(MSG_NOT_FOUND)).Execute(); - 740 } - 741 else if(!bRecursive && RET_YES == - 742 QueryBox(0, SW_RES( bForward ? MSG_SEARCH_END - 743 : MSG_SEARCH_START)).Execute()) - 744 { - 745 pTextView->SetSelection( TextSelection( aPaM, aPaM ) ); - 746 StartSearchAndReplace( rSearchItem, FALSE, FALSE, TRUE ); - 747 } - 748 } - 749 return nFound; + for(std::list<SwMarginItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + if ( (*i)->pPostIt ) + (*i)->pPostIt->CheckMetaText(); - */ } sal_uInt16 SwPostItMgr::Replace(SvxSearchItem* pItem) @@ -1947,7 +1877,6 @@ sal_uInt16 SwPostItMgr::Replace(SvxSearchItem* pItem) return aResult; } - sal_uInt16 SwPostItMgr::FinishSearchReplace(const ::com::sun::star::util::SearchOptions& rSearchOptions, bool bSrchForward) { SwMarginWin* pWin = GetActivePostIt(); |