From c230e962ca2c876187a028fa14426210b5746a0f Mon Sep 17 00:00:00 2001 From: Oliver-Rainer Wittmann Date: Tue, 12 Jan 2010 10:43:45 +0100 Subject: sw33a11y01: #i88070# refactoring of sidebar window code used for visualization of comments/annotations --- sw/source/ui/docvw/PostItMgr.cxx | 412 ++++++++++++++++++++++----------------- 1 file changed, 231 insertions(+), 181 deletions(-) (limited to 'sw/source/ui/docvw/PostItMgr.cxx') diff --git a/sw/source/ui/docvw/PostItMgr.cxx b/sw/source/ui/docvw/PostItMgr.cxx index 3c32ef04e9e1..0619fb163ec4 100644 --- a/sw/source/ui/docvw/PostItMgr.cxx +++ b/sw/source/ui/docvw/PostItMgr.cxx @@ -35,6 +35,13 @@ #include "PostItMgr.hxx" #include +#include +#include + +#include +#include +#include + #include #include #include @@ -49,7 +56,6 @@ #include #include #include -#include #include #include #include @@ -59,7 +65,7 @@ #include #include -#include +#include #include "cmdid.h" #include @@ -94,6 +100,8 @@ // if we layout more often we stop, this should never happen #define MAX_LOOP_COUNT 50 +using namespace sw::sidebarwindows; + /* bool comp_author( const SwPostItItem* a, const SwPostItItem* b) { @@ -108,7 +116,7 @@ bool comp_date( const SwPostItItem* a, const SwPostItItem* b) // if position is on the same line, sort by x (Left) position, otherwise by y(Bottom) position // if two notes are at the same position, sort by logical node position -bool comp_pos(const SwMarginItem *a, const SwMarginItem *b) +bool comp_pos(const SwSidebarItem *a, const SwSidebarItem *b) { return (a->mPos.Bottom() == b->mPos.Bottom()) ? ( ((a->mPos.Left() == b->mPos.Left()) && (a->GetBroadCaster()->ISA(SwFmtFld) && b->GetBroadCaster()->ISA(SwFmtFld)) ) ? @@ -144,7 +152,7 @@ SwPostItMgr::SwPostItMgr(SwView* pView) // 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); - /* this code can be used once we want redline comments in the margin + /* this code can be used once we want redline comments in the Sidebar AddRedlineComments(false,false); */ // we want to receive stuff like SFX_HINT_DOCCHANGED @@ -160,8 +168,8 @@ SwPostItMgr::~SwPostItMgr() { if ( mnEventId ) Application::RemoveUserEvent( mnEventId ); - // forget about all our margin windows - RemoveMarginWin(); + // forget about all our Sidebar windows + RemoveSidebarWin(); EndListening( *mpView->GetDocShell() ); for(std::vector::iterator i = mPages.begin(); i!= mPages.end() ; i++) @@ -172,15 +180,15 @@ SwPostItMgr::~SwPostItMgr() void SwPostItMgr::CheckForRemovedPostIts() { bool bRemoved = false; - for(std::list::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end(); ) + for(std::list::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end(); ) { - std::list::iterator it = i++; + std::list::iterator it = i++; if ( !(*it)->UseElement() ) { - SwMarginItem* p = (*it); + SwSidebarItem* p = (*it); mvPostItFlds.remove(*it); - if (GetActivePostIt() == p->pPostIt) - SetActivePostIt(0); + if (GetActiveSidebarWin() == p->pPostIt) + SetActiveSidebarWin(0); if (p->pPostIt) delete p->pPostIt; delete p; @@ -208,7 +216,7 @@ void SwPostItMgr::InsertItem(SfxBroadcaster* pItem, bool bCheckExistance, bool b { if (bCheckExistance) { - for(std::list::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + for(std::list::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { if ( (*i)->GetBroadCaster() == pItem ) return; @@ -216,7 +224,7 @@ void SwPostItMgr::InsertItem(SfxBroadcaster* pItem, bool bCheckExistance, bool b } mbLayout = bFocus; if (pItem->ISA(SwFmtFld)) - mvPostItFlds.push_back(new SwPostItItem(static_cast(pItem), true, bFocus) ); + mvPostItFlds.push_back(new SwAnnotationItem(static_cast(pItem), true, bFocus) ); /* else if (pItem->ISA(SwRedline)) @@ -229,13 +237,13 @@ void SwPostItMgr::InsertItem(SfxBroadcaster* pItem, bool bCheckExistance, bool b void SwPostItMgr::RemoveItem( SfxBroadcaster* pBroadcast ) { EndListening(*pBroadcast); - for(std::list::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + for(std::list::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { if ( (*i)->GetBroadCaster() == pBroadcast ) { - SwMarginItem* p = (*i); - if (GetActivePostIt() == p->pPostIt) - SetActivePostIt(0); + SwSidebarItem* p = (*i); + if (GetActiveSidebarWin() == p->pPostIt) + SetActiveSidebarWin(0); mvPostItFlds.remove(*i); delete p->pPostIt; delete p; @@ -383,7 +391,7 @@ void SwPostItMgr::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) case SWFMTFLD_CHANGED: { SwFmtFld* pFmtFld = dynamic_cast(&rBC); - for(std::list::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + for(std::list::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { if ( pFmtFld == (*i)->GetBroadCaster() ) { @@ -400,7 +408,7 @@ void SwPostItMgr::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) case SWFMTFLD_LANGUAGE: { SwFmtFld* pFmtFld = dynamic_cast(&rBC); - for(std::list::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + for(std::list::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { if ( pFmtFld == (*i)->GetBroadCaster() ) { @@ -414,7 +422,8 @@ void SwPostItMgr::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) case SCRIPTTYPE_ASIAN : nLangWhichId = EE_CHAR_LANGUAGE_CJK; break; case SCRIPTTYPE_COMPLEX : nLangWhichId = EE_CHAR_LANGUAGE_CTL; break; } - (*i)->pPostIt->SetLanguage(SvxLanguageItem((*i)->GetFmtFld()->GetFld()->GetLanguage(),nLangWhichId)); + (*i)->pPostIt->SetLanguage( SvxLanguageItem((*i)->GetFmtFld()->GetFld()->GetLanguage(), + nLangWhichId) ); } break; } @@ -433,7 +442,7 @@ void SwPostItMgr::Focus(SfxBroadcaster& rBC) mpView->ExecViewOptions(aRequest); } - for(std::list::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + for(std::list::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { // field to get the focus is the broadcaster if ( &rBC == (*i)->GetBroadCaster() ) @@ -467,9 +476,9 @@ bool SwPostItMgr::CalcRects() PreparePageContainer(); if ( !mvPostItFlds.empty() ) { - for(std::list::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + for(std::list::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { - SwMarginItem* pItem = (*i); + SwSidebarItem* pItem = (*i); if ( !pItem->UseElement() ) { DBG_ERROR("PostIt is not in doc or other wrong use"); @@ -489,7 +498,7 @@ bool SwPostItMgr::CalcRects() pItem->mPos = rInfo.mPosition; pItem->mPagePos = rInfo.mPageFrame; pItem->mFramePos = rInfo.mPagePrtArea; - pItem->bMarginSide = rInfo.mbMarginSide; + pItem->meSidebarPosition = rInfo.meSidebarPosition; pItem->mnPageNumber = rInfo.mnPageNumber; pItem->mRedlineAuthor = rInfo.mRedlineAuthor; } @@ -501,9 +510,9 @@ bool SwPostItMgr::CalcRects() Sort(SORT_POS); // sort the items into the right page vector, so layout can be done by page - for(std::list::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + for(std::list::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { - SwMarginItem* pItem = (*i); + SwSidebarItem* pItem = (*i); if( SwPostItHelper::INVISIBLE == pItem->mLayoutStatus ) { if (pItem->pPostIt) @@ -530,7 +539,7 @@ bool SwPostItMgr::CalcRects() } mPages[aPageNum-1]->mList->push_back(pItem); mPages[aPageNum-1]->mPageRect = pItem->mPagePos; - mPages[aPageNum-1]->bMarginSide = pItem->bMarginSide; + mPages[aPageNum-1]->eSidebarPosition = pItem->meSidebarPosition; } if (!bChange && mpWrtShell->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE)) @@ -559,9 +568,9 @@ bool SwPostItMgr::CalcRects() bool SwPostItMgr::HasScrollbars() const { - for(std::list::const_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + for(std::list::const_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { - if ((*i)->bShow && (*i)->pPostIt && (*i)->pPostIt->Scrollbar()) + if ((*i)->bShow && (*i)->pPostIt && (*i)->pPostIt->HasScrollbar()) return true; } return false; @@ -613,24 +622,24 @@ void SwPostItMgr::LayoutPostIts() // only layout if there are notes on this page if (mPages[n]->mList->size()>0) { - std::list aVisiblePostItList; + std::list aVisiblePostItList; unsigned long lNeededHeight = 0; long mlPageBorder = 0; long mlPageEnd = 0; - for(SwMarginItem_iterator i = mPages[n]->mList->begin(); i!= mPages[n]->mList->end(); i++) + for(SwSidebarItem_iterator i = mPages[n]->mList->begin(); i!= mPages[n]->mList->end(); i++) { - SwMarginItem* pItem = (*i); - SwMarginWin* pPostIt = pItem->pPostIt; + SwSidebarItem* pItem = (*i); + SwSidebarWin* pPostIt = pItem->pPostIt; - if (mPages[n]->bMarginSide) + if (mPages[n]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_LEFT ) { // x value for notes positioning mlPageBorder = mpEditWin->LogicToPixel( Point( mPages[n]->mPageRect.Left(), 0)).X() - GetSidebarWidth(true);// - GetSidebarBorderWidth(true); //bending point mlPageEnd = mpWrtShell->getIDocumentSettingAccess()->get( IDocumentSettingAccess::BROWSE_MODE) ? pItem->mFramePos.Left() : mPages[n]->mPageRect.Left() + 350; } - else + else if (mPages[n]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_RIGHT ) { // x value for notes positioning mlPageBorder = mpEditWin->LogicToPixel( Point(mPages[n]->mPageRect.Right(), 0)).X() + GetSidebarBorderWidth(true); @@ -644,32 +653,40 @@ void SwPostItMgr::LayoutPostIts() long aPostItHeight = 0; if (!pPostIt) { - pPostIt = (*i)->GetMarginWindow(static_cast(&mpView->GetEditWin()),WINDOW_CONTROL|WB_NODIALOGCONTROL,this,0); + pPostIt = (*i)->GetSidebarWindow( mpView->GetEditWin(), + WINDOW_CONTROL|WB_NODIALOGCONTROL, + *this, + 0 ); pPostIt->InitControls(); pPostIt->SetReadonly(mbReadOnly); pItem->pPostIt = pPostIt; if (mpAnswer) { if (pPostIt->CalcFollow()) //do we really have another note in front of this one - static_cast(pPostIt)->InitAnswer(mpAnswer); + static_cast(pPostIt)->InitAnswer(mpAnswer); delete mpAnswer; mpAnswer = 0; } } - if (pItem->pPostIt->ISA(SwPostIt)) - { - static_cast(pPostIt)->SetChangeTracking(pItem->mLayoutStatus,GetColorAnkor(pItem->mRedlineAuthor)); - } - pPostIt->SetMarginSide(mPages[n]->bMarginSide); + pPostIt->SetChangeTracking(pItem->mLayoutStatus,GetColorAnkor(pItem->mRedlineAuthor)); + pPostIt->SetSidebarPosition(mPages[n]->eSidebarPosition); pPostIt->SetFollow(pPostIt->CalcFollow()); - aPostItHeight = ( pPostIt->GetPostItTextHeight() < pPostIt->GetMinimumSizeWithoutMeta() ? pPostIt->GetMinimumSizeWithoutMeta() : pPostIt->GetPostItTextHeight() ) + pPostIt->GetMetaHeight(); - pPostIt->SetPosSizePixelRect( mlPageBorder ,Y-GetInitialAnchorDistance(), GetNoteWidth() ,aPostItHeight,pItem->mPos, mlPageEnd); + aPostItHeight = ( pPostIt->GetPostItTextHeight() < pPostIt->GetMinimumSizeWithoutMeta() + ? pPostIt->GetMinimumSizeWithoutMeta() + : pPostIt->GetPostItTextHeight() ) + + pPostIt->GetMetaHeight(); + pPostIt->SetPosSizePixelRect( mlPageBorder , + Y - GetInitialAnchorDistance(), + GetNoteWidth() , + aPostItHeight, + pItem->mPos, + mlPageEnd ); if (pItem->bFocus) { mbLayout = true; - pPostIt->GrabFocus(); + pPostIt->GrabFocus(); pItem->bFocus = false; } // only the visible postits are used for the final layout @@ -709,7 +726,7 @@ void SwPostItMgr::LayoutPostIts() - 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++) + for(SwSidebarWin_iterator i = aVisiblePostItList.begin(); i!= aVisiblePostItList.end() ; i++) { if (mPages[n]->lOffset != 0) (*i)->TranslateTopPosition(mPages[n]->lOffset); @@ -724,24 +741,28 @@ void SwPostItMgr::LayoutPostIts() { if (mpEditWin->PixelToLogic(Point(0,(*i)->VirtualPos().Y())).Y() < (mPages[n]->mPageRect.Top()+aSidebarheight)) { - if (mPages[n]->bMarginSide) - (*i)->ShowAnkorOnly(Point(mPages[n]->mPageRect.Left(),mPages[n]->mPageRect.Top())); - else - (*i)->ShowAnkorOnly(Point(mPages[n]->mPageRect.Right(),mPages[n]->mPageRect.Top())); + if ( mPages[n]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_LEFT ) + (*i)->ShowAnchorOnly(Point( mPages[n]->mPageRect.Left(), + mPages[n]->mPageRect.Top())); + else if ( mPages[n]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_RIGHT ) + (*i)->ShowAnchorOnly(Point( mPages[n]->mPageRect.Right(), + mPages[n]->mPageRect.Top())); } else { - if (mPages[n]->bMarginSide) - (*i)->ShowAnkorOnly(Point(mPages[n]->mPageRect.Left(),mPages[n]->mPageRect.Bottom())); - else - (*i)->ShowAnkorOnly(Point(mPages[n]->mPageRect.Right(),mPages[n]->mPageRect.Bottom())); + if ( mPages[n]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_LEFT ) + (*i)->ShowAnchorOnly(Point(mPages[n]->mPageRect.Left(), + mPages[n]->mPageRect.Bottom())); + else if ( mPages[n]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_RIGHT ) + (*i)->ShowAnchorOnly(Point(mPages[n]->mPageRect.Right(), + mPages[n]->mPageRect.Bottom())); } 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++) + for(SwSidebarWin_iterator i = aVisiblePostItList.begin(); i!= aVisiblePostItList.end() ; i++) { if ((*i)->HasChildPathFocus()) { @@ -752,7 +773,7 @@ void SwPostItMgr::LayoutPostIts() } else { - for(SwMarginWin_iterator i = aVisiblePostItList.begin(); i!= aVisiblePostItList.end() ; i++) + for(SwSidebarWin_iterator i = aVisiblePostItList.begin(); i!= aVisiblePostItList.end() ; i++) (*i)->SetPosAndSize(); bool bOldScrollbar = mPages[n]->bScrollbar; @@ -771,9 +792,9 @@ void SwPostItMgr::LayoutPostIts() 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++) + for(SwSidebarItem_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { - SwMarginItem* pItem = (*i); + SwSidebarItem* pItem = (*i); if ( !pItem->UseElement() ) { DBG_ERROR("PostIt is not in doc!"); @@ -786,7 +807,7 @@ void SwPostItMgr::LayoutPostIts() (*i)->pPostIt->HideNote(); if ((*i)->pPostIt->HasChildPathFocus()) { - SetActivePostIt(0); + SetActiveSidebarWin(0); (*i)->pPostIt->GrabFocusToDocument(); } } @@ -813,7 +834,7 @@ bool SwPostItMgr::BorderOverPageBorder(unsigned long aPage) const return false; } - SwMarginItem_iterator aItem = mPages[aPage-1]->mList->end(); + SwSidebarItem_iterator aItem = mPages[aPage-1]->mList->end(); --aItem; DBG_ASSERT ((*aItem)->pPostIt,"BorderOverPageBorder: NULL postIt, should never happen"); if ((*aItem)->pPostIt) @@ -836,9 +857,9 @@ void SwPostItMgr::Scroll(const long lScroll,const unsigned long aPage) const bool bOldUp = ArrowEnabled(KEY_PAGEUP,aPage); const bool bOldDown = ArrowEnabled(KEY_PAGEDOWN,aPage); const long aSidebarheight = mpEditWin->PixelToLogic(Size(0,GetSidebarScrollerHeight())).Height(); - for(SwMarginItem_iterator i = mPages[aPage-1]->mList->begin(); i!= mPages[aPage-1]->mList->end(); i++) + for(SwSidebarItem_iterator i = mPages[aPage-1]->mList->begin(); i!= mPages[aPage-1]->mList->end(); i++) { - SwMarginWin* pPostIt = (*i)->pPostIt; + SwSidebarWin* pPostIt = (*i)->pPostIt; // if this is an answer, we should take the normal position and not the real, slightly moved position pPostIt->SetVirtualPosSize(pPostIt->GetPosPixel(),pPostIt->GetSizePixel()); pPostIt->TranslateTopPosition(lScroll); @@ -855,17 +876,17 @@ void SwPostItMgr::Scroll(const long lScroll,const unsigned long aPage) { if ( mpEditWin->PixelToLogic(Point(0,pPostIt->VirtualPos().Y())).Y() < (mPages[aPage-1]->mPageRect.Top()+aSidebarheight)) { - if (mPages[aPage-1]->bMarginSide) - pPostIt->ShowAnkorOnly(Point(mPages[aPage-1]->mPageRect.Left(),mPages[aPage-1]->mPageRect.Top())); - else - pPostIt->ShowAnkorOnly(Point(mPages[aPage-1]->mPageRect.Right(),mPages[aPage-1]->mPageRect.Top())); + if (mPages[aPage-1]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_LEFT) + pPostIt->ShowAnchorOnly(Point(mPages[aPage-1]->mPageRect.Left(),mPages[aPage-1]->mPageRect.Top())); + else if (mPages[aPage-1]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_RIGHT) + pPostIt->ShowAnchorOnly(Point(mPages[aPage-1]->mPageRect.Right(),mPages[aPage-1]->mPageRect.Top())); } else { - if (mPages[aPage-1]->bMarginSide) - pPostIt->ShowAnkorOnly(Point(mPages[aPage-1]->mPageRect.Left(),mPages[aPage-1]->mPageRect.Bottom())); - else - pPostIt->ShowAnkorOnly(Point(mPages[aPage-1]->mPageRect.Right(),mPages[aPage-1]->mPageRect.Bottom())); + if (mPages[aPage-1]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_LEFT) + pPostIt->ShowAnchorOnly(Point(mPages[aPage-1]->mPageRect.Left(),mPages[aPage-1]->mPageRect.Bottom())); + else if (mPages[aPage-1]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_RIGHT) + pPostIt->ShowAnchorOnly(Point(mPages[aPage-1]->mPageRect.Right(),mPages[aPage-1]->mPageRect.Bottom())); } } } @@ -878,7 +899,7 @@ void SwPostItMgr::Scroll(const long lScroll,const unsigned long aPage) } } -void SwPostItMgr::AutoScroll(const SwMarginWin* pPostIt,const unsigned long aPage ) +void SwPostItMgr::AutoScroll(const SwSidebarWin* pPostIt,const unsigned long aPage ) { // otherwise all notes are visible if (mPages[aPage-1]->bScrollbar) @@ -898,7 +919,7 @@ void SwPostItMgr::AutoScroll(const SwMarginWin* pPostIt,const unsigned long aPag } } -void SwPostItMgr::MakeVisible(const SwMarginWin* pPostIt,long aPage ) +void SwPostItMgr::MakeVisible(const SwSidebarWin* pPostIt,long aPage ) { if (aPage == -1) { @@ -907,7 +928,7 @@ void SwPostItMgr::MakeVisible(const SwMarginWin* pPostIt,long aPage ) { if (mPages[n]->mList->size()>0) { - for(SwMarginItem_iterator i = mPages[n]->mList->begin(); i!= mPages[n]->mList->end(); i++) + for(SwSidebarItem_iterator i = mPages[n]->mList->begin(); i!= mPages[n]->mList->end(); i++) { if ((*i)->pPostIt==pPostIt) { @@ -956,7 +977,7 @@ Color SwPostItMgr::GetArrowColor(USHORT aDirection,unsigned long aPage) const } } -bool SwPostItMgr::LayoutByPage(std::list &aVisiblePostItList,const Rectangle aBorder, long lNeededHeight) +bool SwPostItMgr::LayoutByPage(std::list &aVisiblePostItList,const Rectangle aBorder, long lNeededHeight) { /*** General layout idea:***/ // - if we have space left, we always move the current one up, @@ -986,12 +1007,12 @@ bool SwPostItMgr::LayoutByPage(std::list &aVisiblePostItList,const bScrollbars = true; lTopBorder += GetSidebarScrollerHeight() + 10; lBottomBorder -= (GetSidebarScrollerHeight() + 10); - for(SwMarginWin_iterator i = aVisiblePostItList.begin(); i!= aVisiblePostItList.end() ; i++) + for(SwSidebarWin_iterator i = aVisiblePostItList.begin(); i!= aVisiblePostItList.end() ; i++) (*i)->SetSize(Size((*i)->VirtualSize().getWidth(),(*i)->GetMinimumSizeWithMeta())); } else { - for(SwMarginWin_iterator i = aVisiblePostItList.begin(); i!= aVisiblePostItList.end() ; i++) + for(SwSidebarWin_iterator i = aVisiblePostItList.begin(); i!= aVisiblePostItList.end() ; i++) { if ( (*i)->VirtualSize().getHeight() > lAverageHeight) (*i)->SetSize(Size((*i)->VirtualSize().getWidth(),lAverageHeight)); @@ -1008,9 +1029,9 @@ bool SwPostItMgr::LayoutByPage(std::list &aVisiblePostItList,const loop++; bDone = true; lSpaceUsed = lTopBorder + GetSpaceBetween(); - for(SwMarginWin_iterator i = aVisiblePostItList.begin(); i!= aVisiblePostItList.end() ; i++) + for(SwSidebarWin_iterator i = aVisiblePostItList.begin(); i!= aVisiblePostItList.end() ; i++) { - SwMarginWin_iterator aNextPostIt = i; + SwSidebarWin_iterator aNextPostIt = i; ++aNextPostIt; if (aNextPostIt !=aVisiblePostItList.end()) @@ -1029,7 +1050,7 @@ bool SwPostItMgr::LayoutByPage(std::list &aVisiblePostItList,const if ( ((*i)->VirtualPos().Y()- lTranslatePos - GetSpaceBetween()) > lTopBorder) { if ((*aNextPostIt)->IsFollow()) - (*i)->TranslateTopPosition(-1*(lTranslatePos+ANKORLINE_WIDTH)); + (*i)->TranslateTopPosition(-1*(lTranslatePos+ANCHORLINE_WIDTH)); else (*i)->TranslateTopPosition(-1*(lTranslatePos+GetSpaceBetween())); } @@ -1038,7 +1059,7 @@ bool SwPostItMgr::LayoutByPage(std::list &aVisiblePostItList,const long lMoveUp = (*i)->VirtualPos().Y() - lTopBorder; (*i)->TranslateTopPosition(-1* lMoveUp); if ((*aNextPostIt)->IsFollow()) - (*aNextPostIt)->TranslateTopPosition( (lTranslatePos+ANKORLINE_WIDTH) - lMoveUp); + (*aNextPostIt)->TranslateTopPosition( (lTranslatePos+ANCHORLINE_WIDTH) - lMoveUp); else (*aNextPostIt)->TranslateTopPosition( (lTranslatePos+GetSpaceBetween()) - lMoveUp); } @@ -1047,7 +1068,7 @@ bool SwPostItMgr::LayoutByPage(std::list &aVisiblePostItList,const { // no space left, left move the next one down if ((*aNextPostIt)->IsFollow()) - (*aNextPostIt)->TranslateTopPosition(lTranslatePos+ANKORLINE_WIDTH); + (*aNextPostIt)->TranslateTopPosition(lTranslatePos+ANCHORLINE_WIDTH); else (*aNextPostIt)->TranslateTopPosition(lTranslatePos+GetSpaceBetween()); } @@ -1066,14 +1087,14 @@ bool SwPostItMgr::LayoutByPage(std::list &aVisiblePostItList,const } } if (aNextPostIt !=aVisiblePostItList.end() && (*aNextPostIt)->IsFollow()) - lSpaceUsed += (*i)->VirtualSize().Height() + ANKORLINE_WIDTH; + lSpaceUsed += (*i)->VirtualSize().Height() + ANCHORLINE_WIDTH; else lSpaceUsed += (*i)->VirtualSize().Height() + GetSpaceBetween(); } else { //(*i) is the last visible item - SwMarginWin_iterator aPrevPostIt = i; + SwSidebarWin_iterator aPrevPostIt = i; --aPrevPostIt; //lTranslatePos = ( (*aPrevPostIt)->VirtualPos().Y() + (*aPrevPostIt)->VirtualSize().Height() + GetSpaceBetween() ) - (*i)->VirtualPos().Y(); lTranslatePos = ( (*aPrevPostIt)->VirtualPos().Y() + (*aPrevPostIt)->VirtualSize().Height() ) - (*i)->VirtualPos().Y(); @@ -1083,7 +1104,7 @@ bool SwPostItMgr::LayoutByPage(std::list &aVisiblePostItList,const if ( ((*i)->VirtualPos().Y()+ (*i)->VirtualSize().Height()+lTranslatePos) < lBottomBorder) { if ( (*i)->IsFollow() ) - (*i)->TranslateTopPosition(lTranslatePos+ANKORLINE_WIDTH); + (*i)->TranslateTopPosition(lTranslatePos+ANCHORLINE_WIDTH); else (*i)->TranslateTopPosition(lTranslatePos+GetSpaceBetween()); } @@ -1115,7 +1136,7 @@ bool SwPostItMgr::LayoutByPage(std::list &aVisiblePostItList,const else { // only one left, make sure it is not hidden at the top or bottom - SwMarginWin_iterator i = aVisiblePostItList.begin(); + SwSidebarWin_iterator i = aVisiblePostItList.begin(); lTranslatePos = lTopBorder - (*i)->VirtualPos().Y(); if (lTranslatePos>0) { @@ -1168,11 +1189,11 @@ void SwPostItMgr::AddPostIts(bool bCheckExistance, bool bFocus) PrepareView(true); } -void SwPostItMgr::RemoveMarginWin() +void SwPostItMgr::RemoveSidebarWin() { if (!mvPostItFlds.empty()) { - for(std::list::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + for(std::list::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { EndListening( *((*i)->GetBroadCaster()) ); if ((*i)->pPostIt) @@ -1192,8 +1213,10 @@ void SwPostItMgr::RemoveMarginWin() void SwPostItMgr::Delete(String aAuthor) { mpWrtShell->StartAllAction(); - if ( GetActivePostIt() && (GetActivePostIt()->GetAuthor()==aAuthor) ) - SetActivePostIt(0); + if ( HasActiveSidebarWin() && (GetActiveSidebarWin()->GetAuthor()==aAuthor) ) + { + SetActiveSidebarWin(0); + } SwRewriter aRewriter; String aUndoString = SW_RES(STR_DELETE_AUTHOR_NOTES); aUndoString += aAuthor; @@ -1202,7 +1225,7 @@ void SwPostItMgr::Delete(String aAuthor) std::vector aTmp; aTmp.reserve( mvPostItFlds.size() ); - for(std::list::iterator pPostIt = mvPostItFlds.begin(); pPostIt!= mvPostItFlds.end() ; pPostIt++) + for(std::list::iterator pPostIt = mvPostItFlds.begin(); pPostIt!= mvPostItFlds.end() ; pPostIt++) { if ((*pPostIt)->GetFmtFld() && ((*pPostIt)->pPostIt->GetAuthor() == aAuthor) ) aTmp.push_back( (*pPostIt)->GetFmtFld() ); @@ -1212,36 +1235,6 @@ void SwPostItMgr::Delete(String aAuthor) mpWrtShell->GotoField( *(*i) ); mpWrtShell->DelRight(); } - /* - for(std::list::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end(); ) - { - SwPostItItem* pItem = (*i); - SwPostItField* pPostItField = static_cast(pItem->pFmtFld->GetFld()); - if (pPostItField->GetPar1() == aAuthor) - { - // stop listening, we delete ourselves - EndListening( *(pItem->pFmtFld) ); - - // remove reference to yet-to-die postit - if (pItem->pPostIt == GetActivePostIt()) - SetActivePostIt(0); - - // delete the actual SwPostItField - mpWrtShell->GotoField(*pItem->pFmtFld); - mpWrtShell->DelRight(); - i = mvPostItFlds.erase(i); - - // delete visual representation - // lazy delete doesn't work because references to document (mpFmtFld, mpView etc. may be dead before deletion) - delete pItem->pPostIt; - - // delete struct saving the pointers - delete pItem; - } - else - ++i; - } - */ mpWrtShell->EndUndo( UNDO_DELETE ); PrepareView(); mpWrtShell->EndAllAction(); @@ -1253,14 +1246,14 @@ void SwPostItMgr::Delete(String aAuthor) void SwPostItMgr::Delete() { mpWrtShell->StartAllAction(); - SetActivePostIt(0); + SetActiveSidebarWin(0); SwRewriter aRewriter; aRewriter.AddRule(UNDO_ARG1, SW_RES(STR_DELETE_ALL_NOTES) ); mpWrtShell->StartUndo( UNDO_DELETE, &aRewriter ); std::vector aTmp; aTmp.reserve( mvPostItFlds.size() ); - for(std::list::iterator pPostIt = mvPostItFlds.begin(); pPostIt!= mvPostItFlds.end() ; pPostIt++) + for(std::list::iterator pPostIt = mvPostItFlds.begin(); pPostIt!= mvPostItFlds.end() ; pPostIt++) { if ((*pPostIt)->GetFmtFld()) aTmp.push_back( (*pPostIt)->GetFmtFld() ); @@ -1298,7 +1291,7 @@ void SwPostItMgr::Delete() void SwPostItMgr::Hide(SwPostItField* pPostItField ) { - for(std::list::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + for(std::list::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { if ((*i)->GetFmtFld()) { @@ -1317,7 +1310,7 @@ void SwPostItMgr::Hide(SwPostItField* pPostItField ) void SwPostItMgr::Hide( const String& rAuthor ) { - for(SwMarginItem_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + for(SwSidebarItem_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { if ( (*i)->pPostIt && ((*i)->pPostIt->GetAuthor() == rAuthor) ) { @@ -1331,7 +1324,7 @@ void SwPostItMgr::Hide( const String& rAuthor ) void SwPostItMgr::Hide() { - for(SwMarginItem_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + for(SwSidebarItem_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { (*i)->bShow = false; (*i)->pPostIt->HideNote(); @@ -1341,7 +1334,7 @@ void SwPostItMgr::Hide() void SwPostItMgr::Show() { - for(SwMarginItem_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + for(SwSidebarItem_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { (*i)->bShow = true; } @@ -1369,7 +1362,7 @@ void SwPostItMgr::Sort(const short aType) } } -SwMarginWin* SwPostItMgr::GetPostIt(SfxBroadcaster* pBroadcaster) const +SwSidebarWin* SwPostItMgr::GetPostIt(SfxBroadcaster* pBroadcaster) const { for(const_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { @@ -1379,17 +1372,17 @@ SwMarginWin* SwPostItMgr::GetPostIt(SfxBroadcaster* pBroadcaster) const return NULL; } -SwPostIt* SwPostItMgr::GetPostIt(SwPostItField* pFld) const +sw::annotation::SwAnnotationWin* SwPostItMgr::GetPostIt(SwPostItField* pFld) const { for(const_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { if ( (*i)->GetFmtFld() && ((*i)->GetFmtFld()->GetFld() == pFld) ) - return static_cast((*i)->pPostIt); + return dynamic_cast((*i)->pPostIt); } return NULL; } -SwMarginWin* SwPostItMgr::GetPostIt( const SfxBroadcaster* pBroadcaster) const +SwSidebarWin* SwPostItMgr::GetPostIt( const SfxBroadcaster* pBroadcaster) const { for(const_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { @@ -1399,12 +1392,12 @@ SwMarginWin* SwPostItMgr::GetPostIt( const SfxBroadcaster* pBroadcaster) const return NULL; } -SwPostIt* SwPostItMgr::GetPostIt(const SwPostItField* pFld) const +sw::annotation::SwAnnotationWin* SwPostItMgr::GetPostIt(const SwPostItField* pFld) const { for(const_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { if ( (*i)->GetFmtFld() && ((*i)->GetFmtFld()->GetFld() == pFld)) - return static_cast((*i)->pPostIt); + return dynamic_cast((*i)->pPostIt); } return NULL; } @@ -1433,15 +1426,16 @@ bool SwPostItMgr::ShowPreview(const SwField* pFld, SwFmtFld*& pFmtFld) const return false; } -SwMarginWin* SwPostItMgr::GetNextPostIt(USHORT aDirection, SwMarginWin* aPostIt) +SwSidebarWin* SwPostItMgr::GetNextPostIt( USHORT aDirection, + SwSidebarWin* aPostIt ) { if (mvPostItFlds.size()>1) { - for(SwMarginItem_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + for(SwSidebarItem_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { if ( (*i)->pPostIt ==aPostIt) { - SwMarginItem_iterator iNextPostIt = i; + SwSidebarItem_iterator iNextPostIt = i; if (aDirection==KEY_PAGEUP) { if ( iNextPostIt==mvPostItFlds.begin() ) @@ -1474,11 +1468,11 @@ long SwPostItMgr::GetNextBorder() { for (unsigned long n=0;nmList->begin(); b!= mPages[n]->mList->end(); b++) + for(SwSidebarItem_iterator b = mPages[n]->mList->begin(); b!= mPages[n]->mList->end(); b++) { if ((*b)->pPostIt == mpActivePostIt) { - SwMarginItem_iterator aNext = b; + SwSidebarItem_iterator aNext = b; aNext++; bool bFollow = (aNext == mPages[n]->mList->end()) ? false : (*aNext)->pPostIt->IsFollow(); if ( mPages[n]->bScrollbar || bFollow ) @@ -1511,15 +1505,15 @@ void SwPostItMgr::SetShadowState(const SwPostItField* pFld,bool bCursor) { // reset old one if still alive // TODO: does not work properly if mouse and cursor was set - SwPostIt* pOldPostIt = GetPostIt(mShadowState.mpShadowFld); + sw::annotation::SwAnnotationWin* pOldPostIt = GetPostIt(mShadowState.mpShadowFld); if (pOldPostIt && pOldPostIt->Shadow() && (pOldPostIt->Shadow()->GetShadowState() != SS_EDIT)) - pOldPostIt->SetViewState(SS_NORMAL); + pOldPostIt->SetViewState(VS_NORMAL); } //set new one, if it is not currently edited - SwPostIt* pNewPostIt = GetPostIt(pFld); + sw::annotation::SwAnnotationWin* pNewPostIt = GetPostIt(pFld); if (pNewPostIt && pNewPostIt->Shadow() && (pNewPostIt->Shadow()->GetShadowState() != SS_EDIT)) { - pNewPostIt->SetViewState(SS_VIEW); + pNewPostIt->SetViewState(VS_VIEW); //remember our new field mShadowState.mpShadowFld = pFld; mShadowState.bCursor = false; @@ -1542,10 +1536,10 @@ void SwPostItMgr::SetShadowState(const SwPostItField* pFld,bool bCursor) if (!mShadowState.bCursor && !mShadowState.bMouse) { // reset old one if still alive - SwPostIt* pOldPostIt = GetPostIt(mShadowState.mpShadowFld); + sw::annotation::SwAnnotationWin* pOldPostIt = GetPostIt(mShadowState.mpShadowFld); if (pOldPostIt && pOldPostIt->Shadow() && (pOldPostIt->Shadow()->GetShadowState() != SS_EDIT)) { - pOldPostIt->SetViewState(SS_NORMAL); + pOldPostIt->SetViewState(VS_NORMAL); mShadowState.mpShadowFld = 0; } } @@ -1587,8 +1581,9 @@ bool SwPostItMgr::IsHit(const Point &aPointPixel) { Rectangle aRect; DBG_ASSERT(mPages.size()>nPageNum-1,"SwPostitMgr:: page container size wrong"); - aRect = mPages[nPageNum-1]->bMarginSide ? Rectangle(Point(aPageFrm.Left()-GetSidebarWidth()-GetSidebarBorderWidth(),aPageFrm.Top()),Size(GetSidebarWidth(),aPageFrm.Height())) : - Rectangle( Point(aPageFrm.Right()+GetSidebarBorderWidth(),aPageFrm.Top()) , Size(GetSidebarWidth(),aPageFrm.Height())); + aRect = mPages[nPageNum-1]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_LEFT + ? Rectangle(Point(aPageFrm.Left()-GetSidebarWidth()-GetSidebarBorderWidth(),aPageFrm.Top()),Size(GetSidebarWidth(),aPageFrm.Height())) + : Rectangle( Point(aPageFrm.Right()+GetSidebarBorderWidth(),aPageFrm.Top()) , Size(GetSidebarWidth(),aPageFrm.Height())); if (aRect.IsInside(aPoint)) { // we hit the note's sidebar @@ -1605,8 +1600,9 @@ bool SwPostItMgr::IsHit(const Point &aPointPixel) Rectangle SwPostItMgr::GetBottomScrollRect(const unsigned long aPage) const { SwRect aPageRect = mPages[aPage-1]->mPageRect; - Point aPointBottom = mPages[aPage-1]->bMarginSide ? Point(aPageRect.Left() - GetSidebarWidth() - GetSidebarBorderWidth() + mpEditWin->PixelToLogic(Size(2,0)).Width(),aPageRect.Bottom()- mpEditWin->PixelToLogic(Size(0,2+GetSidebarScrollerHeight())).Height()) : - Point(aPageRect.Right() + GetSidebarBorderWidth() + mpEditWin->PixelToLogic(Size(2,0)).Width(),aPageRect.Bottom()- mpEditWin->PixelToLogic(Size(0,2+GetSidebarScrollerHeight())).Height()); + Point aPointBottom = mPages[aPage-1]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_LEFT + ? Point(aPageRect.Left() - GetSidebarWidth() - GetSidebarBorderWidth() + mpEditWin->PixelToLogic(Size(2,0)).Width(),aPageRect.Bottom()- mpEditWin->PixelToLogic(Size(0,2+GetSidebarScrollerHeight())).Height()) + : Point(aPageRect.Right() + GetSidebarBorderWidth() + mpEditWin->PixelToLogic(Size(2,0)).Width(),aPageRect.Bottom()- mpEditWin->PixelToLogic(Size(0,2+GetSidebarScrollerHeight())).Height()); Size aSize(GetSidebarWidth() - mpEditWin->PixelToLogic(Size(4,0)).Width(), mpEditWin->PixelToLogic(Size(0,GetSidebarScrollerHeight())).Height()) ; return Rectangle(aPointBottom,aSize); @@ -1615,8 +1611,9 @@ Rectangle SwPostItMgr::GetBottomScrollRect(const unsigned long aPage) const Rectangle SwPostItMgr::GetTopScrollRect(const unsigned long aPage) const { SwRect aPageRect = mPages[aPage-1]->mPageRect; - Point aPointTop = mPages[aPage-1]->bMarginSide ? Point(aPageRect.Left() - GetSidebarWidth() -GetSidebarBorderWidth()+ mpEditWin->PixelToLogic(Size(2,0)).Width(),aPageRect.Top() + mpEditWin->PixelToLogic(Size(0,2)).Height()) : - Point(aPageRect.Right() + GetSidebarBorderWidth() + mpEditWin->PixelToLogic(Size(2,0)).Width(),aPageRect.Top() + mpEditWin->PixelToLogic(Size(0,2)).Height()); + Point aPointTop = mPages[aPage-1]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_LEFT + ? Point(aPageRect.Left() - GetSidebarWidth() -GetSidebarBorderWidth()+ mpEditWin->PixelToLogic(Size(2,0)).Width(),aPageRect.Top() + mpEditWin->PixelToLogic(Size(0,2)).Height()) + : Point(aPageRect.Right() + GetSidebarBorderWidth() + mpEditWin->PixelToLogic(Size(2,0)).Width(),aPageRect.Top() + mpEditWin->PixelToLogic(Size(0,2)).Height()); Size aSize(GetSidebarWidth() - mpEditWin->PixelToLogic(Size(4,0)).Width(), mpEditWin->PixelToLogic(Size(0,GetSidebarScrollerHeight())).Height()) ; return Rectangle(aPointTop,aSize); } @@ -1626,11 +1623,13 @@ Rectangle SwPostItMgr::GetTopScrollRect(const unsigned long aPage) const bool SwPostItMgr::ScrollbarHit(const unsigned long aPage,const Point &aPoint) { SwRect aPageRect = mPages[aPage-1]->mPageRect; - Point aPointBottom = mPages[aPage-1]->bMarginSide ? Point(aPageRect.Left() - GetSidebarWidth()-GetSidebarBorderWidth() + mpEditWin->PixelToLogic(Size(2,0)).Width(),aPageRect.Bottom()- mpEditWin->PixelToLogic(Size(0,2+GetSidebarScrollerHeight())).Height()) : - Point(aPageRect.Right() + GetSidebarBorderWidth()+ mpEditWin->PixelToLogic(Size(2,0)).Width(),aPageRect.Bottom()- mpEditWin->PixelToLogic(Size(0,2+GetSidebarScrollerHeight())).Height()); + Point aPointBottom = mPages[aPage-1]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_LEFT + ? Point(aPageRect.Left() - GetSidebarWidth()-GetSidebarBorderWidth() + mpEditWin->PixelToLogic(Size(2,0)).Width(),aPageRect.Bottom()- mpEditWin->PixelToLogic(Size(0,2+GetSidebarScrollerHeight())).Height()) + : Point(aPageRect.Right() + GetSidebarBorderWidth()+ mpEditWin->PixelToLogic(Size(2,0)).Width(),aPageRect.Bottom()- mpEditWin->PixelToLogic(Size(0,2+GetSidebarScrollerHeight())).Height()); - Point aPointTop = mPages[aPage-1]->bMarginSide ? Point(aPageRect.Left() - GetSidebarWidth()-GetSidebarBorderWidth()+ mpEditWin->PixelToLogic(Size(2,0)).Width(),aPageRect.Top() + mpEditWin->PixelToLogic(Size(0,2)).Height()) : - Point(aPageRect.Right()+GetSidebarBorderWidth()+ mpEditWin->PixelToLogic(Size(2,0)).Width(),aPageRect.Top() + mpEditWin->PixelToLogic(Size(0,2)).Height()); + Point aPointTop = mPages[aPage-1]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_LEFT + ? Point(aPageRect.Left() - GetSidebarWidth()-GetSidebarBorderWidth()+ mpEditWin->PixelToLogic(Size(2,0)).Width(),aPageRect.Top() + mpEditWin->PixelToLogic(Size(0,2)).Height()) + : Point(aPageRect.Right()+GetSidebarBorderWidth()+ mpEditWin->PixelToLogic(Size(2,0)).Width(),aPageRect.Top() + mpEditWin->PixelToLogic(Size(0,2)).Height()); Rectangle aRectBottom(GetBottomScrollRect(aPage)); Rectangle aRectTop(GetTopScrollRect(aPage)); @@ -1661,8 +1660,8 @@ void SwPostItMgr::CorrectPositions() return; // find first valid note - SwMarginWin *pFirstPostIt = 0; - for(SwMarginItem_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + SwSidebarWin *pFirstPostIt = 0; + for(SwSidebarItem_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { pFirstPostIt = (*i)->pPostIt; if (pFirstPostIt) @@ -1674,22 +1673,22 @@ void SwPostItMgr::CorrectPositions() return; // yeah, I know, if this is a left page it could be wrong, but finding the page and the note is probably not even faster than just doing it - const long aAnkorX = mpEditWin->LogicToPixel( Point((long)(pFirstPostIt->Ankor()->GetSixthPosition().getX()),0)).X(); - const long aAnkorY = mpEditWin->LogicToPixel( Point(0,(long)(pFirstPostIt->Ankor()->GetSixthPosition().getY()))).Y() + 1; + const long aAnkorX = mpEditWin->LogicToPixel( Point((long)(pFirstPostIt->Anchor()->GetSixthPosition().getX()),0)).X(); + const long aAnkorY = mpEditWin->LogicToPixel( Point(0,(long)(pFirstPostIt->Anchor()->GetSixthPosition().getY()))).Y() + 1; if (Point(aAnkorX,aAnkorY) != pFirstPostIt->GetPosPixel()) { long aAnkorPosX = 0; long aAnkorPosY = 0; for (unsigned long n=0;nmList->begin(); i!= mPages[n]->mList->end(); i++) + for(SwSidebarItem_iterator i = mPages[n]->mList->begin(); i!= mPages[n]->mList->end(); i++) { if ((*i)->bShow && (*i)->pPostIt) { - aAnkorPosX = mPages[n]->bMarginSide ? - mpEditWin->LogicToPixel( Point((long)((*i)->pPostIt->Ankor()->GetSeventhPosition().getX()),0)).X() : - mpEditWin->LogicToPixel( Point((long)((*i)->pPostIt->Ankor()->GetSixthPosition().getX()),0)).X(); - aAnkorPosY = mpEditWin->LogicToPixel( Point(0,(long)((*i)->pPostIt->Ankor()->GetSixthPosition().getY()))).Y() + 1; + aAnkorPosX = mPages[n]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_LEFT + ? mpEditWin->LogicToPixel( Point((long)((*i)->pPostIt->Anchor()->GetSeventhPosition().getX()),0)).X() + : mpEditWin->LogicToPixel( Point((long)((*i)->pPostIt->Anchor()->GetSixthPosition().getX()),0)).X(); + aAnkorPosY = mpEditWin->LogicToPixel( Point(0,(long)((*i)->pPostIt->Anchor()->GetSixthPosition().getY()))).Y() + 1; (*i)->pPostIt->SetPosPixel(Point(aAnkorPosX,aAnkorPosY)); } } @@ -1776,14 +1775,14 @@ Color SwPostItMgr::GetColorAnkor(sal_uInt16 aAuthorIndex) return Color(COL_WHITE); } -void SwPostItMgr::SetActivePostIt( SwMarginWin* p) +void SwPostItMgr::SetActiveSidebarWin( SwSidebarWin* p) { if ( p != mpActivePostIt ) { // we need the temp variable so we can set mpActivePostIt before we call DeactivatePostIt // therefore we get a new layout in DOCCHANGED when switching from postit to document, // otherwise, GetActivePostIt() would still hold our old postit - SwMarginWin* pActive = mpActivePostIt; + SwSidebarWin* pActive = mpActivePostIt; mpActivePostIt = p; if (pActive) { @@ -1820,7 +1819,7 @@ IMPL_LINK( SwPostItMgr, CalcHdl, void*, /* pVoid*/ ) void SwPostItMgr::Rescale() { - for(std::list::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + for(std::list::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) if ( (*i)->pPostIt ) (*i)->pPostIt->Rescale(); } @@ -1857,21 +1856,21 @@ sal_Int32 SwPostItMgr::GetSidebarScrollerHeight() const void SwPostItMgr::SetSpellChecking() { - for(std::list::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + for(std::list::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) if ( (*i)->pPostIt ) (*i)->pPostIt->SetSpellChecking(); } void SwPostItMgr::SetReadOnlyState() { - for(std::list::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + for(std::list::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) if ( (*i)->pPostIt ) (*i)->pPostIt->SetReadonly( mbReadOnly ); } void SwPostItMgr::CheckMetaText() { - for(std::list::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + for(std::list::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) if ( (*i)->pPostIt ) (*i)->pPostIt->CheckMetaText(); @@ -1879,45 +1878,45 @@ void SwPostItMgr::CheckMetaText() sal_uInt16 SwPostItMgr::Replace(SvxSearchItem* pItem) { - SwMarginWin* pWin = GetActivePostIt(); - sal_uInt16 aResult = pWin->View()->StartSearchAndReplace( *pItem ); + SwSidebarWin* pWin = GetActiveSidebarWin(); + sal_uInt16 aResult = pWin->GetOutlinerView()->StartSearchAndReplace( *pItem ); if (!aResult) - SetActivePostIt(0); + SetActiveSidebarWin(0); return aResult; } sal_uInt16 SwPostItMgr::FinishSearchReplace(const ::com::sun::star::util::SearchOptions& rSearchOptions, bool bSrchForward) { - SwMarginWin* pWin = GetActivePostIt(); + SwSidebarWin* pWin = GetActiveSidebarWin(); SvxSearchItem aItem(SID_SEARCH_ITEM ); aItem.SetSearchOptions(rSearchOptions); aItem.SetBackward(!bSrchForward); - sal_uInt16 aResult = pWin->View()->StartSearchAndReplace( aItem ); + sal_uInt16 aResult = pWin->GetOutlinerView()->StartSearchAndReplace( aItem ); if (!aResult) - SetActivePostIt(0); + SetActiveSidebarWin(0); return aResult; } sal_uInt16 SwPostItMgr::SearchReplace(const SwFmtFld &pFld, const ::com::sun::star::util::SearchOptions& rSearchOptions, bool bSrchForward) { sal_uInt16 aResult = 0; - SwMarginWin* pWin = GetPostIt(&pFld); + SwSidebarWin* pWin = GetPostIt(&pFld); if (pWin) { - ESelection aOldSelection = pWin->View()->GetSelection(); + ESelection aOldSelection = pWin->GetOutlinerView()->GetSelection(); if (bSrchForward) - pWin->View()->SetSelection(ESelection(0,0,0,0)); + pWin->GetOutlinerView()->SetSelection(ESelection(0,0,0,0)); else - pWin->View()->SetSelection(ESelection(0xFFFF,0xFFFF,0xFFFF,0xFFFF)); + pWin->GetOutlinerView()->SetSelection(ESelection(0xFFFF,0xFFFF,0xFFFF,0xFFFF)); SvxSearchItem aItem(SID_SEARCH_ITEM ); aItem.SetSearchOptions(rSearchOptions); aItem.SetBackward(!bSrchForward); - aResult = pWin->View()->StartSearchAndReplace( aItem ); + aResult = pWin->GetOutlinerView()->StartSearchAndReplace( aItem ); if (!aResult) - pWin->View()->SetSelection(aOldSelection); + pWin->GetOutlinerView()->SetSelection(aOldSelection); else { - SetActivePostIt(pWin); + SetActiveSidebarWin(pWin); MakeVisible(pWin); } } @@ -1948,3 +1947,54 @@ void SwPostItMgr::AssureStdModeAtShell() mpView->StopShellTimer(); } } + +bool SwPostItMgr::HasActiveSidebarWin() const +{ + return mpActivePostIt != 0; +} + +bool SwPostItMgr::HasActiveAnnotationWin() const +{ + return HasActiveSidebarWin() && + dynamic_cast(mpActivePostIt) != 0; +} + +void SwPostItMgr::GrabFocusOnActiveSidebarWin() +{ + if ( HasActiveSidebarWin() ) + { + mpActivePostIt->GrabFocus(); + } +} + +void SwPostItMgr::UpdateDataOnActiveSidebarWin() +{ + if ( HasActiveSidebarWin() ) + { + mpActivePostIt->UpdateData(); + } +} + +void SwPostItMgr::DeleteActiveSidebarWin() +{ + if ( HasActiveSidebarWin() ) + { + mpActivePostIt->Delete(); + } +} + +void SwPostItMgr::HideActiveSidebarWin() +{ + if ( HasActiveSidebarWin() ) + { + mpActivePostIt->Hide(); + } +} + +void SwPostItMgr::ToggleInsModeOnActiveSidebarWin() +{ + if ( HasActiveSidebarWin() ) + { + mpActivePostIt->ToggleInsMode(); + } +} -- cgit From bb1a225066bc5a57f5a194e6f4dfd585a6d5a30e Mon Sep 17 00:00:00 2001 From: Oliver-Rainer Wittmann Date: Tue, 19 Jan 2010 08:57:57 +0100 Subject: sw33a11y01: #i88070# classes and - minor refactoring --- sw/source/ui/docvw/PostItMgr.cxx | 84 +++++++++++++++++----------------------- 1 file changed, 35 insertions(+), 49 deletions(-) (limited to 'sw/source/ui/docvw/PostItMgr.cxx') diff --git a/sw/source/ui/docvw/PostItMgr.cxx b/sw/source/ui/docvw/PostItMgr.cxx index 0619fb163ec4..a20d2daaf5c6 100644 --- a/sw/source/ui/docvw/PostItMgr.cxx +++ b/sw/source/ui/docvw/PostItMgr.cxx @@ -118,12 +118,13 @@ bool comp_date( const SwPostItItem* a, const SwPostItItem* b) // if two notes are at the same position, sort by logical node position bool comp_pos(const SwSidebarItem *a, const SwSidebarItem *b) { - return (a->mPos.Bottom() == b->mPos.Bottom()) ? - ( ((a->mPos.Left() == b->mPos.Left()) && (a->GetBroadCaster()->ISA(SwFmtFld) && b->GetBroadCaster()->ISA(SwFmtFld)) ) ? - *(static_cast(a->GetBroadCaster())->GetTxtFld()->GetStart()) < - *(static_cast(b->GetBroadCaster())->GetTxtFld()->GetStart()) - : a->mPos.Left() < b->mPos.Left() ) - : a->mPos.Bottom() < b->mPos.Bottom(); + return (a->maLayoutInfo.mPosition.Bottom() == b->maLayoutInfo.mPosition.Bottom()) + ? ( ( (a->maLayoutInfo.mPosition.Left() == b->maLayoutInfo.mPosition.Left()) && + (a->GetBroadCaster()->ISA(SwFmtFld) && b->GetBroadCaster()->ISA(SwFmtFld)) ) + ? *(static_cast(a->GetBroadCaster())->GetTxtFld()->GetStart()) < + *(static_cast(b->GetBroadCaster())->GetTxtFld()->GetStart()) + : a->maLayoutInfo.mPosition.Left() < b->maLayoutInfo.mPosition.Left() ) + : a->maLayoutInfo.mPosition.Bottom() < b->maLayoutInfo.mPosition.Bottom(); } SwPostItMgr::SwPostItMgr(SwView* pView) @@ -487,22 +488,18 @@ bool SwPostItMgr::CalcRects() } //save old rect and visible state - SwRect aOldRect(pItem->mPos); + SwRect aOldRect(pItem->maLayoutInfo.mPosition); SwPostItHelper::SwLayoutStatus eOldStatus = pItem->mLayoutStatus; std::vector< SwLayoutInfo > aInfo; SwPosition aPosition = pItem->GetPosition(); pItem->mLayoutStatus = SwPostItHelper::getLayoutInfos( aInfo, aPosition ); if( aInfo.size() ) { - SwLayoutInfo& rInfo = aInfo[0]; - pItem->mPos = rInfo.mPosition; - pItem->mPagePos = rInfo.mPageFrame; - pItem->mFramePos = rInfo.mPagePrtArea; - pItem->meSidebarPosition = rInfo.meSidebarPosition; - pItem->mnPageNumber = rInfo.mnPageNumber; - pItem->mRedlineAuthor = rInfo.mRedlineAuthor; + pItem->maLayoutInfo = aInfo[0]; } - bChange = bChange || (pItem->mPos != aOldRect) || (eOldStatus != pItem->mLayoutStatus); + bChange = bChange || + ( pItem->maLayoutInfo.mPosition != aOldRect ) || + ( eOldStatus != pItem->mLayoutStatus ); } // show notes in right order in navigator @@ -530,7 +527,7 @@ bool SwPostItMgr::CalcRects() } } - const unsigned long aPageNum = pItem->mnPageNumber; + const unsigned long aPageNum = pItem->maLayoutInfo.mnPageNumber; if (aPageNum > mPages.size()) { const unsigned long nNumberOfPages = mPages.size(); @@ -538,8 +535,8 @@ bool SwPostItMgr::CalcRects() mPages.push_back( new SwPostItPageItem()); } mPages[aPageNum-1]->mList->push_back(pItem); - mPages[aPageNum-1]->mPageRect = pItem->mPagePos; - mPages[aPageNum-1]->eSidebarPosition = pItem->meSidebarPosition; + mPages[aPageNum-1]->mPageRect = pItem->maLayoutInfo.mPageFrame; + mPages[aPageNum-1]->eSidebarPosition = pItem->maLayoutInfo.meSidebarPosition; } if (!bChange && mpWrtShell->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE)) @@ -637,19 +634,25 @@ void SwPostItMgr::LayoutPostIts() // x value for notes positioning mlPageBorder = mpEditWin->LogicToPixel( Point( mPages[n]->mPageRect.Left(), 0)).X() - GetSidebarWidth(true);// - GetSidebarBorderWidth(true); //bending point - mlPageEnd = mpWrtShell->getIDocumentSettingAccess()->get( IDocumentSettingAccess::BROWSE_MODE) ? pItem->mFramePos.Left() : mPages[n]->mPageRect.Left() + 350; + mlPageEnd = + mpWrtShell->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE) + ? pItem->maLayoutInfo.mPagePrtArea.Left() + : mPages[n]->mPageRect.Left() + 350; } else if (mPages[n]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_RIGHT ) { // x value for notes positioning mlPageBorder = mpEditWin->LogicToPixel( Point(mPages[n]->mPageRect.Right(), 0)).X() + GetSidebarBorderWidth(true); //bending point - mlPageEnd = mpWrtShell->getIDocumentSettingAccess()->get( IDocumentSettingAccess::BROWSE_MODE) ? pItem->mFramePos.Right() : mPages[n]->mPageRect.Right() - 350; + mlPageEnd = + mpWrtShell->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE) + ? pItem->maLayoutInfo.mPagePrtArea.Right() : + mPages[n]->mPageRect.Right() - 350; } if (pItem->bShow) { - long Y = mpEditWin->LogicToPixel( Point(0,pItem->mPos.Bottom())).Y(); + long Y = mpEditWin->LogicToPixel( Point(0,pItem->maLayoutInfo.mPosition.Bottom())).Y(); long aPostItHeight = 0; if (!pPostIt) { @@ -669,7 +672,9 @@ void SwPostItMgr::LayoutPostIts() } } - pPostIt->SetChangeTracking(pItem->mLayoutStatus,GetColorAnkor(pItem->mRedlineAuthor)); + pPostIt->SetChangeTracking( + pItem->mLayoutStatus, + GetColorAnkor(pItem->maLayoutInfo.mRedlineAuthor)); pPostIt->SetSidebarPosition(mPages[n]->eSidebarPosition); pPostIt->SetFollow(pPostIt->CalcFollow()); aPostItHeight = ( pPostIt->GetPostItTextHeight() < pPostIt->GetMinimumSizeWithoutMeta() @@ -680,7 +685,7 @@ void SwPostItMgr::LayoutPostIts() Y - GetInitialAnchorDistance(), GetNoteWidth() , aPostItHeight, - pItem->mPos, + pItem->maLayoutInfo.mPosition, mlPageEnd ); if (pItem->bFocus) @@ -1362,7 +1367,7 @@ void SwPostItMgr::Sort(const short aType) } } -SwSidebarWin* SwPostItMgr::GetPostIt(SfxBroadcaster* pBroadcaster) const +SwSidebarWin* SwPostItMgr::GetSidebarWin( const SfxBroadcaster* pBroadcaster) const { for(const_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { @@ -1372,27 +1377,7 @@ SwSidebarWin* SwPostItMgr::GetPostIt(SfxBroadcaster* pBroadcaster) const return NULL; } -sw::annotation::SwAnnotationWin* SwPostItMgr::GetPostIt(SwPostItField* pFld) const -{ - for(const_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) - { - if ( (*i)->GetFmtFld() && ((*i)->GetFmtFld()->GetFld() == pFld) ) - return dynamic_cast((*i)->pPostIt); - } - return NULL; -} - -SwSidebarWin* SwPostItMgr::GetPostIt( const SfxBroadcaster* pBroadcaster) const -{ - for(const_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) - { - if ( (*i)->GetBroadCaster() == pBroadcaster) - return (*i)->pPostIt; - } - return NULL; -} - -sw::annotation::SwAnnotationWin* SwPostItMgr::GetPostIt(const SwPostItField* pFld) const +sw::annotation::SwAnnotationWin* SwPostItMgr::GetAnnotationWin(const SwPostItField* pFld) const { for(const_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { @@ -1505,12 +1490,13 @@ void SwPostItMgr::SetShadowState(const SwPostItField* pFld,bool bCursor) { // reset old one if still alive // TODO: does not work properly if mouse and cursor was set - sw::annotation::SwAnnotationWin* pOldPostIt = GetPostIt(mShadowState.mpShadowFld); + sw::annotation::SwAnnotationWin* pOldPostIt = + GetAnnotationWin(mShadowState.mpShadowFld); if (pOldPostIt && pOldPostIt->Shadow() && (pOldPostIt->Shadow()->GetShadowState() != SS_EDIT)) pOldPostIt->SetViewState(VS_NORMAL); } //set new one, if it is not currently edited - sw::annotation::SwAnnotationWin* pNewPostIt = GetPostIt(pFld); + sw::annotation::SwAnnotationWin* pNewPostIt = GetAnnotationWin(pFld); if (pNewPostIt && pNewPostIt->Shadow() && (pNewPostIt->Shadow()->GetShadowState() != SS_EDIT)) { pNewPostIt->SetViewState(VS_VIEW); @@ -1536,7 +1522,7 @@ void SwPostItMgr::SetShadowState(const SwPostItField* pFld,bool bCursor) if (!mShadowState.bCursor && !mShadowState.bMouse) { // reset old one if still alive - sw::annotation::SwAnnotationWin* pOldPostIt = GetPostIt(mShadowState.mpShadowFld); + sw::annotation::SwAnnotationWin* pOldPostIt = GetAnnotationWin(mShadowState.mpShadowFld); if (pOldPostIt && pOldPostIt->Shadow() && (pOldPostIt->Shadow()->GetShadowState() != SS_EDIT)) { pOldPostIt->SetViewState(VS_NORMAL); @@ -1900,7 +1886,7 @@ sal_uInt16 SwPostItMgr::FinishSearchReplace(const ::com::sun::star::util::Search sal_uInt16 SwPostItMgr::SearchReplace(const SwFmtFld &pFld, const ::com::sun::star::util::SearchOptions& rSearchOptions, bool bSrchForward) { sal_uInt16 aResult = 0; - SwSidebarWin* pWin = GetPostIt(&pFld); + SwSidebarWin* pWin = GetSidebarWin(&pFld); if (pWin) { ESelection aOldSelection = pWin->GetOutlinerView()->GetSelection(); -- cgit From 84a72b88e50b60765fadd00c8caa73112a7e5830 Mon Sep 17 00:00:00 2001 From: Oliver-Rainer Wittmann Date: Tue, 2 Feb 2010 15:11:26 +0100 Subject: sw33a11y01: #i88070# - accessible Writer comments - part 1 --- sw/source/ui/docvw/PostItMgr.cxx | 126 ++++++++++++++++++++++++++++++--------- 1 file changed, 97 insertions(+), 29 deletions(-) (limited to 'sw/source/ui/docvw/PostItMgr.cxx') diff --git a/sw/source/ui/docvw/PostItMgr.cxx b/sw/source/ui/docvw/PostItMgr.cxx index a20d2daaf5c6..936fa8d2368e 100644 --- a/sw/source/ui/docvw/PostItMgr.cxx +++ b/sw/source/ui/docvw/PostItMgr.cxx @@ -37,6 +37,7 @@ #include #include +#include #include #include @@ -90,8 +91,8 @@ #include "swevent.hxx" -// distance between ankor Y and initial note position -#define POSTIT_INITIAL_ANKOR_DISTANCE 20 +// distance between Anchor Y and initial note position +#define POSTIT_INITIAL_ANCHOR_DISTANCE 20 //distance between two postits #define POSTIT_SPACE_BETWEEN 8 #define POSTIT_MINIMUMSIZE_WITH_META 60 @@ -114,17 +115,22 @@ bool comp_date( const SwPostItItem* a, const SwPostItItem* b) } */ -// if position is on the same line, sort by x (Left) position, otherwise by y(Bottom) position -// if two notes are at the same position, sort by logical node position -bool comp_pos(const SwSidebarItem *a, const SwSidebarItem *b) +// +bool comp_pos(const SwSidebarItem* a, const SwSidebarItem* b) { - return (a->maLayoutInfo.mPosition.Bottom() == b->maLayoutInfo.mPosition.Bottom()) - ? ( ( (a->maLayoutInfo.mPosition.Left() == b->maLayoutInfo.mPosition.Left()) && - (a->GetBroadCaster()->ISA(SwFmtFld) && b->GetBroadCaster()->ISA(SwFmtFld)) ) - ? *(static_cast(a->GetBroadCaster())->GetTxtFld()->GetStart()) < - *(static_cast(b->GetBroadCaster())->GetTxtFld()->GetStart()) - : a->maLayoutInfo.mPosition.Left() < b->maLayoutInfo.mPosition.Left() ) - : a->maLayoutInfo.mPosition.Bottom() < b->maLayoutInfo.mPosition.Bottom(); + // --> OD 2010-01-19 #i88070# + // sort by anchor position +//// if position is on the same line, sort by x (Left) position, otherwise by y(Bottom) position +//// if two notes are at the same position, sort by logical node position +// return (a->maLayoutInfo.mPosition.Bottom() == b->maLayoutInfo.mPosition.Bottom()) +// ? ( ( (a->maLayoutInfo.mPosition.Left() == b->maLayoutInfo.mPosition.Left()) && +// (a->GetBroadCaster()->ISA(SwFmtFld) && b->GetBroadCaster()->ISA(SwFmtFld)) ) +// ? *(static_cast(a->GetBroadCaster())->GetTxtFld()->GetStart()) < +// *(static_cast(b->GetBroadCaster())->GetTxtFld()->GetStart()) +// : a->maLayoutInfo.mPosition.Left() < b->maLayoutInfo.mPosition.Left() ) +// : a->maLayoutInfo.mPosition.Bottom() < b->maLayoutInfo.mPosition.Bottom(); + return a->GetAnchorPosition() < b->GetAnchorPosition(); + // <-- } SwPostItMgr::SwPostItMgr(SwView* pView) @@ -140,12 +146,14 @@ SwPostItMgr::SwPostItMgr(SwView* pView) , mbReadOnly(mpView->GetDocShell()->IsReadOnly()) , mbDeleteNote(true) , mpAnswer(0) + , mbIsShowAnchor( false ) + , mpFrmSidebarWinContainer( 0 ) { if(!mpView->GetDrawView() ) mpView->GetWrtShell().MakeDrawView(); SwNoteProps aProps; - mpIsShowAnkor = aProps.IsShowAnkor(); + mbIsShowAnchor = aProps.IsShowAnchor(); //make sure we get the colour yellow always, even if not the first one of comments or redlining SW_MOD()->GetRedlineAuthor(); @@ -167,6 +175,8 @@ SwPostItMgr::SwPostItMgr(SwView* pView) SwPostItMgr::~SwPostItMgr() { + delete mpFrmSidebarWinContainer; + if ( mnEventId ) Application::RemoveUserEvent( mnEventId ); // forget about all our Sidebar windows @@ -491,8 +501,10 @@ bool SwPostItMgr::CalcRects() SwRect aOldRect(pItem->maLayoutInfo.mPosition); SwPostItHelper::SwLayoutStatus eOldStatus = pItem->mLayoutStatus; std::vector< SwLayoutInfo > aInfo; - SwPosition aPosition = pItem->GetPosition(); - pItem->mLayoutStatus = SwPostItHelper::getLayoutInfos( aInfo, aPosition ); + { + SwPosition aPosition = pItem->GetAnchorPosition(); + pItem->mLayoutStatus = SwPostItHelper::getLayoutInfos( aInfo, aPosition ); + } if( aInfo.size() ) { pItem->maLayoutInfo = aInfo[0]; @@ -503,7 +515,7 @@ bool SwPostItMgr::CalcRects() } // show notes in right order in navigator - //prevent ankors during layout to overlap, e.g. when moving a frame + //prevent Anchors during layout to overlap, e.g. when moving a frame Sort(SORT_POS); // sort the items into the right page vector, so layout can be done by page @@ -674,7 +686,7 @@ void SwPostItMgr::LayoutPostIts() pPostIt->SetChangeTracking( pItem->mLayoutStatus, - GetColorAnkor(pItem->maLayoutInfo.mRedlineAuthor)); + GetColorAnchor(pItem->maLayoutInfo.mRedlineAuthor)); pPostIt->SetSidebarPosition(mPages[n]->eSidebarPosition); pPostIt->SetFollow(pPostIt->CalcFollow()); aPostItHeight = ( pPostIt->GetPostItTextHeight() < pPostIt->GetMinimumSizeWithoutMeta() @@ -687,6 +699,7 @@ void SwPostItMgr::LayoutPostIts() aPostItHeight, pItem->maLayoutInfo.mPosition, mlPageEnd ); + pPostIt->ChangeSidebarItem( *pItem ); if (pItem->bFocus) { @@ -1659,23 +1672,23 @@ void SwPostItMgr::CorrectPositions() return; // yeah, I know, if this is a left page it could be wrong, but finding the page and the note is probably not even faster than just doing it - const long aAnkorX = mpEditWin->LogicToPixel( Point((long)(pFirstPostIt->Anchor()->GetSixthPosition().getX()),0)).X(); - const long aAnkorY = mpEditWin->LogicToPixel( Point(0,(long)(pFirstPostIt->Anchor()->GetSixthPosition().getY()))).Y() + 1; - if (Point(aAnkorX,aAnkorY) != pFirstPostIt->GetPosPixel()) + const long aAnchorX = mpEditWin->LogicToPixel( Point((long)(pFirstPostIt->Anchor()->GetSixthPosition().getX()),0)).X(); + const long aAnchorY = mpEditWin->LogicToPixel( Point(0,(long)(pFirstPostIt->Anchor()->GetSixthPosition().getY()))).Y() + 1; + if (Point(aAnchorX,aAnchorY) != pFirstPostIt->GetPosPixel()) { - long aAnkorPosX = 0; - long aAnkorPosY = 0; + long aAnchorPosX = 0; + long aAnchorPosY = 0; for (unsigned long n=0;nmList->begin(); i!= mPages[n]->mList->end(); i++) { if ((*i)->bShow && (*i)->pPostIt) { - aAnkorPosX = mPages[n]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_LEFT + aAnchorPosX = mPages[n]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_LEFT ? mpEditWin->LogicToPixel( Point((long)((*i)->pPostIt->Anchor()->GetSeventhPosition().getX()),0)).X() : mpEditWin->LogicToPixel( Point((long)((*i)->pPostIt->Anchor()->GetSixthPosition().getX()),0)).X(); - aAnkorPosY = mpEditWin->LogicToPixel( Point(0,(long)((*i)->pPostIt->Anchor()->GetSixthPosition().getY()))).Y() + 1; - (*i)->pPostIt->SetPosPixel(Point(aAnkorPosX,aAnkorPosY)); + aAnchorPosY = mpEditWin->LogicToPixel( Point(0,(long)((*i)->pPostIt->Anchor()->GetSixthPosition().getY()))).Y() + 1; + (*i)->pPostIt->SetPosPixel(Point(aAnchorPosX,aAnchorPosY)); } } } @@ -1746,16 +1759,16 @@ Color SwPostItMgr::GetColorLight(sal_uInt16 aAuthorIndex) return Color(COL_WHITE); } -Color SwPostItMgr::GetColorAnkor(sal_uInt16 aAuthorIndex) +Color SwPostItMgr::GetColorAnchor(sal_uInt16 aAuthorIndex) { if (!Application::GetSettings().GetStyleSettings().GetHighContrastMode()) { - static const Color aArrayAnkor[] = { + static const Color aArrayAnchor[] = { COL_AUTHOR1_DARK, COL_AUTHOR2_DARK, COL_AUTHOR3_DARK, COL_AUTHOR4_DARK, COL_AUTHOR5_DARK, COL_AUTHOR6_DARK, COL_AUTHOR7_DARK, COL_AUTHOR8_DARK, COL_AUTHOR9_DARK }; - return Color( aArrayAnkor[ aAuthorIndex % (sizeof( aArrayAnkor ) / sizeof( aArrayAnkor[0] ))]); + return Color( aArrayAnchor[ aAuthorIndex % (sizeof( aArrayAnchor ) / sizeof( aArrayAnchor[0] ))]); } else return Color(COL_WHITE); @@ -1813,7 +1826,7 @@ void SwPostItMgr::Rescale() sal_Int32 SwPostItMgr::GetInitialAnchorDistance() const { const Fraction& f( mpEditWin->GetMapMode().GetScaleY() ); - return POSTIT_INITIAL_ANKOR_DISTANCE * f.GetNumerator() / f.GetDenominator(); + return POSTIT_INITIAL_ANCHOR_DISTANCE * f.GetNumerator() / f.GetDenominator(); } sal_Int32 SwPostItMgr::GetSpaceBetween() const @@ -1984,3 +1997,58 @@ void SwPostItMgr::ToggleInsModeOnActiveSidebarWin() mpActivePostIt->ToggleInsMode(); } } + +void SwPostItMgr::ConnectSidebarWinToFrm( const SwFrm& rFrm, + const SwFmtFld& rFmtFld, + SwSidebarWin& rSidebarWin ) +{ + if ( mpFrmSidebarWinContainer == 0 ) + { + mpFrmSidebarWinContainer = new SwFrmSidebarWinContainer(); + } + + mpFrmSidebarWinContainer->insert( rFrm, rFmtFld, rSidebarWin ); +} + +void SwPostItMgr::DisconnectSidebarWinFromFrm( const SwFrm& rFrm, + SwSidebarWin& rSidebarWin ) +{ + if ( mpFrmSidebarWinContainer != 0 ) + { + mpFrmSidebarWinContainer->remove( rFrm, rSidebarWin ); + } +} + +bool SwPostItMgr::HasFrmConnectedSidebarWins( const SwFrm& rFrm ) +{ + bool bRet( false ); + + if ( mpFrmSidebarWinContainer != 0 ) + { + bRet = !mpFrmSidebarWinContainer->empty( rFrm ); + } + + return bRet; +} + +Window* SwPostItMgr::GetSidebarWinForFrmByIndex( const SwFrm& rFrm, + const sal_Int32 nIndex ) +{ + Window* pSidebarWin( 0 ); + + if ( mpFrmSidebarWinContainer != 0 ) + { + pSidebarWin = mpFrmSidebarWinContainer->get( rFrm, nIndex ); + } + + return pSidebarWin; +} + +void SwPostItMgr::GetAllSidebarWinForFrm( const SwFrm& rFrm, + std::vector< Window* >* pChildren ) +{ + if ( mpFrmSidebarWinContainer != 0 ) + { + mpFrmSidebarWinContainer->getAll( rFrm, pChildren ); + } +} -- cgit From 8d5a379f239ee595058a5c4b4d7d81041d3722f1 Mon Sep 17 00:00:00 2001 From: Oliver-Rainer Wittmann Date: Wed, 3 Feb 2010 16:26:18 +0100 Subject: sw33a11y01: #i88070# - accessible Writer comments - fixes and part 2 --- sw/source/ui/docvw/PostItMgr.cxx | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'sw/source/ui/docvw/PostItMgr.cxx') diff --git a/sw/source/ui/docvw/PostItMgr.cxx b/sw/source/ui/docvw/PostItMgr.cxx index 936fa8d2368e..9f2c027c31ba 100644 --- a/sw/source/ui/docvw/PostItMgr.cxx +++ b/sw/source/ui/docvw/PostItMgr.cxx @@ -38,6 +38,7 @@ #include #include #include +#include #include #include @@ -175,8 +176,6 @@ SwPostItMgr::SwPostItMgr(SwView* pView) SwPostItMgr::~SwPostItMgr() { - delete mpFrmSidebarWinContainer; - if ( mnEventId ) Application::RemoveUserEvent( mnEventId ); // forget about all our Sidebar windows @@ -186,6 +185,9 @@ SwPostItMgr::~SwPostItMgr() for(std::vector::iterator i = mPages.begin(); i!= mPages.end() ; i++) delete (*i); mPages.clear(); + + delete mpFrmSidebarWinContainer; + mpFrmSidebarWinContainer = 0; } void SwPostItMgr::CheckForRemovedPostIts() @@ -2007,7 +2009,12 @@ void SwPostItMgr::ConnectSidebarWinToFrm( const SwFrm& rFrm, mpFrmSidebarWinContainer = new SwFrmSidebarWinContainer(); } - mpFrmSidebarWinContainer->insert( rFrm, rFmtFld, rSidebarWin ); + const bool bInserted = mpFrmSidebarWinContainer->insert( rFrm, rFmtFld, rSidebarWin ); + if ( bInserted && + mpWrtShell->GetAccessibleMap() ) + { + mpWrtShell->GetAccessibleMap()->InvalidatePosOrSize( 0, 0, &rSidebarWin, SwRect() ); + } } void SwPostItMgr::DisconnectSidebarWinFromFrm( const SwFrm& rFrm, @@ -2015,7 +2022,12 @@ void SwPostItMgr::DisconnectSidebarWinFromFrm( const SwFrm& rFrm, { if ( mpFrmSidebarWinContainer != 0 ) { - mpFrmSidebarWinContainer->remove( rFrm, rSidebarWin ); + const bool bRemoved = mpFrmSidebarWinContainer->remove( rFrm, rSidebarWin ); + if ( bRemoved && + mpWrtShell->GetAccessibleMap() ) + { + mpWrtShell->GetAccessibleMap()->Dispose( 0, 0, &rSidebarWin ); + } } } -- cgit From 132f28c341e1c801ec13cae01ce39b0917bcdc05 Mon Sep 17 00:00:00 2001 From: Oliver-Rainer Wittmann Date: Wed, 10 Feb 2010 13:53:11 +0100 Subject: sw33a11y01: #i88070# - accessible Writer comments - part 3 --- sw/source/ui/docvw/PostItMgr.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sw/source/ui/docvw/PostItMgr.cxx') diff --git a/sw/source/ui/docvw/PostItMgr.cxx b/sw/source/ui/docvw/PostItMgr.cxx index 9f2c027c31ba..6bf54a516d6d 100644 --- a/sw/source/ui/docvw/PostItMgr.cxx +++ b/sw/source/ui/docvw/PostItMgr.cxx @@ -671,7 +671,7 @@ void SwPostItMgr::LayoutPostIts() if (!pPostIt) { pPostIt = (*i)->GetSidebarWindow( mpView->GetEditWin(), - WINDOW_CONTROL|WB_NODIALOGCONTROL, + WB_DIALOGCONTROL, *this, 0 ); pPostIt->InitControls(); -- cgit