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 | |
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')
-rw-r--r-- | sw/source/ui/docvw/PostItMgr.cxx | 207 | ||||
-rw-r--r-- | sw/source/ui/docvw/postit.cxx | 69 |
2 files changed, 114 insertions, 162 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(); diff --git a/sw/source/ui/docvw/postit.cxx b/sw/source/ui/docvw/postit.cxx index 48c9258765ad..a7c12f54f100 100644 --- a/sw/source/ui/docvw/postit.cxx +++ b/sw/source/ui/docvw/postit.cxx @@ -720,6 +720,7 @@ void SwMarginWin::ShowAnkorOnly(const Point &aPoint) { mpAnkor->SetSixthPosition(basegfx::B2DPoint(aPoint.X(),aPoint.Y())); mpAnkor->SetSeventhPosition(basegfx::B2DPoint(aPoint.X(),aPoint.Y())); + mpAnkor->SetAnkorState(AS_ALL); mpAnkor->setVisible(true); } if (mpShadow) @@ -729,7 +730,7 @@ void SwMarginWin::ShowAnkorOnly(const Point &aPoint) void SwMarginWin::InitControls() { // actual window which holds the user text - mpPostItTxt = new PostItTxt(this, 0); + mpPostItTxt = new PostItTxt(this, WB_NODIALOGCONTROL); mpPostItTxt->SetPointer(Pointer(POINTER_TEXT)); // window control for author and date @@ -807,9 +808,10 @@ void SwMarginWin::InitControls() CheckMetaText(); SetPopup(); - SetPostItText(); SetLanguage(GetLanguage()); View()->StartSpeller(); + SetPostItText(); + Engine()->CompleteOnlineSpelling(); mpMeta->Show(); mpVScrollbar->Show(); @@ -915,7 +917,8 @@ void SwMarginWin::SetPosAndSize() basegfx::B2DPoint( aLineStart.X(),aLineStart.Y()), basegfx::B2DPoint( aLineEnd.X(),aLineEnd.Y()) , mColorAnkor,LineInfo(LINE_DASH,ANKORLINE_WIDTH*15), false); mpAnkor->SetHeight(mAnkorRect.Height()); - mpAnkor->setVisible(false); + mpAnkor->setVisible(true); + mpAnkor->SetAnkorState(AS_TRI); if (HasChildPathFocus()) mpAnkor->SetLineInfo(LineInfo(LINE_SOLID,ANKORLINE_WIDTH*15)); pOverlayManager->add(*mpAnkor); @@ -938,16 +941,20 @@ void SwMarginWin::SetPosAndSize() Point aEnd = EditWin()->PixelToLogic(GetPosPixel()+Point(GetSizePixel().Width()-1,GetSizePixel().Height())); mpShadow->SetPosition(basegfx::B2DPoint(aStart.X(),aStart.Y()), basegfx::B2DPoint(aEnd.X(),aEnd.Y())); } - if (IsFollow() && !HasChildPathFocus()) - { - mpAnkor->SetAnkorState(AS_END); - } - else + + if (mpMgr->ShowNotes()) { - mpAnkor->SetAnkorState(AS_ALL); - SwMarginWin* pWin = GetTopReplyNote(); - if (IsFollow() && pWin ) - pWin->Ankor()->SetAnkorState(AS_END); + if (IsFollow() && !HasChildPathFocus()) + { + mpAnkor->SetAnkorState(AS_END); + } + else + { + mpAnkor->SetAnkorState(AS_ALL); + SwMarginWin* pWin = GetTopReplyNote(); + if (IsFollow() && pWin ) + pWin->Ankor()->SetAnkorState(AS_END); + } } } @@ -1187,8 +1194,13 @@ void SwMarginWin::HideNote() { if (IsVisible()) Window::Hide(); - if (mpAnkor && mpAnkor->isVisible()) - mpAnkor->setVisible(false); + if (mpAnkor) + { + if (mpMgr->IsShowAnkor()) + mpAnkor->SetAnkorState(AS_TRI); + else + mpAnkor->setVisible(false); + } if (mpShadow && mpShadow->isVisible()) mpShadow->setVisible(false); } @@ -1504,9 +1516,14 @@ void SwMarginWin::SetViewState(ShadowState bState) // if there is no visible parent note, we want to see the complete anchor ?? //if (IsAnyStackParentVisible()) mpAnkor->SetAnkorState(AS_END); - SwMarginWin* pWin = GetTopReplyNote(); - if (pWin) - pWin->Ankor()->SetAnkorState(AS_ALL); + SwMarginWin* pTopWinSelf = GetTopReplyNote(); + SwMarginWin* pTopWinActive = mpMgr->GetActivePostIt() ? mpMgr->GetActivePostIt()->GetTopReplyNote() : 0; + if (pTopWinSelf && (pTopWinSelf!=pTopWinActive)) + { + if (pTopWinSelf!=mpMgr->GetActivePostIt()) + pTopWinSelf->Ankor()->SetLineInfo(LineInfo(LINE_DASH,ANKORLINE_WIDTH*15)); + pTopWinSelf->Ankor()->SetAnkorState(AS_ALL); + } } mpAnkor->SetLineInfo(LineInfo(LINE_DASH,ANKORLINE_WIDTH*15)); } @@ -1546,10 +1563,6 @@ SwMarginWin* SwMarginWin::GetTopReplyNote() return pTopNote; } -void SwMarginWin::SetPostItText() -{ -} - void SwMarginWin::SwitchToFieldPos() { if ( Mgr()->GetActivePostIt() == this ) @@ -1768,8 +1781,11 @@ void SwPostIt::InitAnswer(OutlinerParaObject* pText) //collect our old meta data SwMarginWin* pWin = Mgr()->GetNextPostIt(KEY_PAGEUP, this); const LocaleDataWrapper& rLocalData = SvtSysLocale().GetLocaleData(); - String aText = String((SW_RES(STR_REPLY))); - aText.Append(String(pWin->GetAuthor() + rtl::OUString::createFromAscii(" (") + + String aText = String(SW_RES(STR_REPLY)); + SwRewriter aRewriter; + aRewriter.AddRule(UNDO_ARG1, pWin->GetAuthor()); + aText = aRewriter.Apply(aText); + aText.Append(String(rtl::OUString::createFromAscii(" (") + String(rLocalData.getDate( pWin->GetDate())) + rtl::OUString::createFromAscii(", ") + String(rLocalData.getTime( pWin->GetTime(),false)) + rtl::OUString::createFromAscii("): \""))); View()->InsertText(aText,false); @@ -2105,6 +2121,13 @@ void SwPostItAnkor::implDrawGeometry(OutputDevice& rOutputDevice, Color aColor, switch (mAnkorState) { + case AS_TRI: + { + rOutputDevice.SetLineColor(); + rOutputDevice.SetFillColor(aColor); + rOutputDevice.DrawPolygon(Polygon(aTri)); + break; + } case AS_ALL: { rOutputDevice.SetLineColor(); |