summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorOliver-Rainer Wittmann <od@openoffice.org>2010-01-19 08:57:57 +0100
committerOliver-Rainer Wittmann <od@openoffice.org>2010-01-19 08:57:57 +0100
commitbb1a225066bc5a57f5a194e6f4dfd585a6d5a30e (patch)
tree98db82aa078d78b8b049cba8bae7dded4fd1aa13 /sw
parentfa9e08d540d9221d7b86c558016edf2e08381d9b (diff)
sw33a11y01: #i88070# classes <SwPostItMgr> and <SwPostItHelper> - minor refactoring
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/PostItMgr.hxx18
-rw-r--r--sw/inc/postithelper.hxx32
-rw-r--r--sw/source/core/fields/postithelper.cxx1
-rw-r--r--sw/source/ui/docvw/PostItMgr.cxx84
4 files changed, 63 insertions, 72 deletions
diff --git a/sw/inc/PostItMgr.hxx b/sw/inc/PostItMgr.hxx
index ffde2b8af901..8b2e85945989 100644
--- a/sw/inc/PostItMgr.hxx
+++ b/sw/inc/PostItMgr.hxx
@@ -188,7 +188,14 @@ class SwPostItMgr: public SfxListener
sal_Int32 GetSpaceBetween() const;
void SetReadOnlyState();
DECL_LINK( CalcHdl, void*);
- protected:
+
+ sw::sidebarwindows::SwSidebarWin* GetSidebarWin(const SfxBroadcaster* pBroadcaster) const;
+ sw::annotation::SwAnnotationWin* GetAnnotationWin(const SwPostItField* pFld) const;
+
+ void InsertItem( SfxBroadcaster* pItem, bool bCheckExistance, bool bFocus);
+ void RemoveItem( SfxBroadcaster* pBroadcast );
+
+ void Sort(const short aType);
public:
SwPostItMgr(SwView* aDoc);
@@ -198,8 +205,6 @@ class SwPostItMgr: public SfxListener
const_iterator begin() const { return mvPostItFlds.begin(); }
const_iterator end() const { return mvPostItFlds.end(); }
- void InsertItem( SfxBroadcaster* pItem, bool bCheckExistance, bool bFocus);
- void RemoveItem( SfxBroadcaster* pBroadcast );
void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
void LayoutPostIts();
@@ -220,8 +225,6 @@ class SwPostItMgr: public SfxListener
void CorrectPositions();
- void Sort(const short aType);
-
void SetLayout() { mbLayout = true; };
void Delete(String aAuthor);
void Delete();
@@ -256,11 +259,6 @@ class SwPostItMgr: public SfxListener
sal_Int32 GetMinimumSizeWithMeta() const;
sal_Int32 GetSidebarScrollerHeight() const;
- sw::sidebarwindows::SwSidebarWin* GetPostIt(const SfxBroadcaster* pBroadcaster) const;
- sw::sidebarwindows::SwSidebarWin* GetPostIt(SfxBroadcaster* pBroadcaster) const;
- sw::annotation::SwAnnotationWin* GetPostIt(const SwPostItField* pFld) const;
- sw::annotation::SwAnnotationWin* GetPostIt(SwPostItField* pFld) const;
-
void SetShadowState(const SwPostItField* pFld,bool bCursor = true);
void SetSpellChecking();
diff --git a/sw/inc/postithelper.hxx b/sw/inc/postithelper.hxx
index 56ebe94228e2..5d9d58ed75d7 100644
--- a/sw/inc/postithelper.hxx
+++ b/sw/inc/postithelper.hxx
@@ -54,12 +54,23 @@ typedef sal_Int64 SwPostItBits;
struct SwLayoutInfo
{
+ SwFrm* mpAssociatedFrm;
SwRect mPosition;
SwRect mPageFrame;
SwRect mPagePrtArea;
unsigned long mnPageNumber;
sw::sidebarwindows::SidebarPosition meSidebarPosition;
USHORT mRedlineAuthor;
+
+ SwLayoutInfo()
+ : mpAssociatedFrm(0)
+ , mPosition()
+ , mPageFrame()
+ , mPagePrtArea()
+ , mnPageNumber(1)
+ , meSidebarPosition(sw::sidebarwindows::SIDEBAR_NONE)
+ , mRedlineAuthor(0)
+ {}
};
namespace SwPostItHelper
@@ -82,22 +93,17 @@ public:
sw::sidebarwindows::SwSidebarWin* pPostIt;
bool bShow;
bool bFocus;
- sw::sidebarwindows::SidebarPosition meSidebarPosition;
- SwRect mPos;
- SwRect mFramePos;
- SwRect mPagePos;
- unsigned long mnPageNumber;
+
SwPostItHelper::SwLayoutStatus mLayoutStatus;
- USHORT mRedlineAuthor;
+ SwLayoutInfo maLayoutInfo;
+
SwSidebarItem( const bool aShow,
const bool aFocus)
- : pPostIt(0),
- bShow(aShow),
- bFocus(aFocus),
- meSidebarPosition(sw::sidebarwindows::SIDEBAR_NONE),
- mnPageNumber(1),
- mLayoutStatus( SwPostItHelper::INVISIBLE ),
- mRedlineAuthor(0)
+ : pPostIt(0)
+ , bShow(aShow)
+ , bFocus(aFocus)
+ , mLayoutStatus( SwPostItHelper::INVISIBLE )
+ , maLayoutInfo()
{}
virtual ~SwSidebarItem(){}
virtual SwPosition GetPosition() = 0;
diff --git a/sw/source/core/fields/postithelper.cxx b/sw/source/core/fields/postithelper.cxx
index c688fccd0a80..aada9ea05397 100644
--- a/sw/source/core/fields/postithelper.cxx
+++ b/sw/source/core/fields/postithelper.cxx
@@ -71,6 +71,7 @@ SwPostItHelper::SwLayoutStatus SwPostItHelper::getLayoutInfos( std::vector< SwLa
{
SwLayoutInfo aInfo;
pTxtFrm->GetCharRect( aInfo.mPosition, rPos, 0 );
+ aInfo.mpAssociatedFrm = pTxtFrm;
aInfo.mPageFrame = pPage->Frm();
aInfo.mPagePrtArea = pPage->Prt();
aInfo.mPagePrtArea.Pos() += aInfo.mPageFrame.Pos();
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<SwFmtFld*>(a->GetBroadCaster())->GetTxtFld()->GetStart()) <
- *(static_cast<SwFmtFld*>(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<SwFmtFld*>(a->GetBroadCaster())->GetTxtFld()->GetStart()) <
+ *(static_cast<SwFmtFld*>(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<sw::annotation::SwAnnotationWin*>((*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();