diff options
author | Jens-Heiner Rechtien <hr@openoffice.org> | 2009-01-02 15:51:45 +0000 |
---|---|---|
committer | Jens-Heiner Rechtien <hr@openoffice.org> | 2009-01-02 15:51:45 +0000 |
commit | 19f251c29311c23f071cc02fdaa6efd6917922a0 (patch) | |
tree | dcdd660d7eab7c6622efd45ac1baef869fd71c0f /sw/source/ui/docvw | |
parent | 16160041500efcc4cc8ad9b77e7c6aa90c0d1acc (diff) |
CWS-TOOLING: integrate CWS notes7
2008-12-29 19:45:08 +0100 mod r265824 : CWS-TOOLING: rebase CWS notes7 to trunk@265758 (milestone: DEV300:m38)
2008-12-16 14:54:42 +0100 mod r265544 : #i97239#
2008-12-16 14:53:18 +0100 mod r265543 : #i97239#
2008-12-16 13:36:43 +0100 mod r265537 : 96602
2008-12-13 13:02:54 +0100 mba r265452 : warning fixed
2008-12-13 08:20:21 +0100 mod r265448 : search inside notes
2008-12-13 00:11:47 +0100 mod r265447 : search inside notes
2008-12-13 00:11:09 +0100 mod r265446 : search inside notes
2008-12-13 00:10:52 +0100 mod r265445 : search inside notes
2008-12-12 19:39:14 +0100 mod r265439 : search inside notes
2008-12-12 19:02:44 +0100 mod r265438 : search inside notes
2008-12-12 16:42:07 +0100 mba r265431 : #i80135#: search in notes
2008-12-12 16:11:54 +0100 mba r265429 : #i80135#: search in notes
2008-12-12 16:11:02 +0100 mba r265428 : #i80135#: search in notes
2008-12-11 20:24:20 +0100 pb r265358 : fix: #i80135# fixes for aNotesBtn
2008-12-11 20:23:19 +0100 pb r265357 : fix: #i80135# fixes for aNotesBtn
2008-12-11 07:42:17 +0100 pb r265241 : fix: #i80135# CB_NOTES added
2008-12-11 07:40:36 +0100 pb r265240 : fix: #i80135# CB_NOTES added
2008-12-11 07:32:03 +0100 pb r265239 : fix: #i80135# CheckBox aNotesBtn added
2008-12-11 07:24:45 +0100 pb r265238 : fix: #i80135# CheckBox aNotesBtn added
2008-12-10 15:41:31 +0100 mod r265198 : crash using replies
2008-12-10 15:21:23 +0100 mod r265195 : crash using replies
2008-12-10 13:45:14 +0100 mba r265181 : warning fixed
2008-12-10 13:26:45 +0100 mba r265178 : warning fixed
2008-12-10 11:48:23 +0100 mba r265162 : fixed compilation error on Linux
2008-12-03 18:39:07 +0100 mod r264806 : we don't get the Ctrl-Alt-N on mac inside a note, let's do the whole reply thing using the shell, cleaner anyway
2008-12-03 17:13:59 +0100 mod r264802 : search dialog can be started and closed when focus is inside a note
2008-12-03 00:07:08 +0100 mod r264733 : search inside notes
2008-12-02 18:06:08 +0100 mod r264729 : WaE
2008-12-02 15:01:26 +0100 mod r264703 : WaE
2008-12-02 00:20:14 +0100 mod r264644 : WaE
2008-12-01 10:06:14 +0100 mod r264587 : WaE
2008-12-01 01:28:34 +0100 mod r264585 : WaE
2008-11-30 22:51:19 +0100 mod r264584 : search inside notes
2008-11-30 17:03:04 +0100 mod r264583 : search inside notes
2008-11-28 16:30:05 +0100 mod r264560 : #i96602#
2008-11-28 16:14:50 +0100 mod r264559 : test
2008-11-28 16:11:37 +0100 mod r264558 : test
2008-11-17 17:46:10 +0100 mod r263735 : WaE
2008-11-17 17:45:56 +0100 mod r263734 : WaE
2008-11-17 17:37:35 +0100 mod r263733 : revert manual fix for icu
2008-11-17 15:03:55 +0100 mod r263726 : manual fix for icu
2008-11-17 11:17:49 +0100 mod r263707 : manual fix for icu
2008-11-14 15:51:19 +0100 mod r263679 : fix
2008-11-14 14:48:02 +0100 mod r263676 : some more cleanup, redline comments not in the margin for 3.1
2008-11-14 08:37:07 +0100 mod r263664 : end of line missing
2008-11-13 18:36:53 +0100 mod r263660 : WaE
2008-11-13 18:20:04 +0100 mod r263659 : #i94374#
2008-11-13 15:51:28 +0100 mod r263648 : CWS-TOOLING: rebase CWS notes7 to trunk@263288 (milestone: DEV300:m35)
2008-11-13 08:33:19 +0100 mod r263622 : typos
2008-11-02 23:18:19 +0100 mod r263278 : changes notes, replies
2008-11-01 11:48:35 +0100 mod r262873 : replies, comments
2008-11-01 11:44:57 +0100 mod r262872 : notes search button
2008-10-10 14:34:34 +0200 mod r262150 : migration from cvs to svn
2008-10-10 14:33:39 +0200 mod r262149 : migration from cvs to svn
Diffstat (limited to 'sw/source/ui/docvw')
-rw-r--r-- | sw/source/ui/docvw/PostItMgr.cxx | 728 | ||||
-rw-r--r-- | sw/source/ui/docvw/docvw.hrc | 7 | ||||
-rw-r--r-- | sw/source/ui/docvw/docvw.src | 17 | ||||
-rw-r--r-- | sw/source/ui/docvw/edtwin.cxx | 1 | ||||
-rw-r--r-- | sw/source/ui/docvw/edtwin2.cxx | 5 | ||||
-rw-r--r-- | sw/source/ui/docvw/postit.cxx | 1249 |
6 files changed, 1357 insertions, 650 deletions
diff --git a/sw/source/ui/docvw/PostItMgr.cxx b/sw/source/ui/docvw/PostItMgr.cxx index 617d5519ad99..edabcf30f1f1 100644 --- a/sw/source/ui/docvw/PostItMgr.cxx +++ b/sw/source/ui/docvw/PostItMgr.cxx @@ -8,7 +8,7 @@ * * $RCSfile: PostItMgr.cxx,v $ * - * $Revision: 1.12 $ + * $Revision: 1.12.34.10 $ * * This file is part of OpenOffice.org. * @@ -35,12 +35,10 @@ #include "PostItMgr.hxx" #include <postithelper.hxx> -#include <svtools/smplhint.hxx> - #include <vcl/svapp.hxx> #include <vcl/scrbar.hxx> +#include <vcl/outdev.hxx> -#include <swmodule.hxx> #include <viewopt.hxx> #include <view.hxx> @@ -54,6 +52,8 @@ #include <postit.hxx> #include <txtfld.hxx> #include <ndtxt.hxx> +#include <redline.hxx> +#include <docary.hxx> #include <SwRewriter.hxx> #include <undobj.hxx> #include <tools/color.hxx> @@ -65,24 +65,22 @@ #include <undobj.hxx> #include <sfx2/request.hxx> - #include <sfx2/event.hxx> +#include <sfx2/srchitem.hxx> + #include <svtools/languageoptions.hxx> #include <svtools/langtab.hxx> +#include <svtools/smplhint.hxx> #include <svx/eeitem.hxx> #include <svx/langitem.hxx> -#include <svx/srchitem.hxx> #include <svx/outliner.hxx> -#include <vcl/outdev.hxx> - #include <i18npool/mslangid.hxx> #include <i18npool/lang.h> #include "swevent.hxx" -#include <sfx2/event.hxx> // distance between ankor Y and initial note position #define POSTIT_INITIAL_ANKOR_DISTANCE 20 @@ -94,6 +92,7 @@ // if we layout more often we stop, this should never happen #define MAX_LOOP_COUNT 50 +/* bool comp_author( const SwPostItItem* a, const SwPostItItem* b) { return a->pFmtFld->GetFld()->GetPar1() < b->pFmtFld->GetFld()->GetPar1(); @@ -103,25 +102,19 @@ bool comp_date( const SwPostItItem* a, const SwPostItItem* b) { return static_cast<SwPostItField*>(a->pFmtFld->GetFld())->GetDate() < static_cast<SwPostItField*>(b->pFmtFld->GetFld())->GetDate(); } +*/ -bool comp_pos(const SwPostItItem *a, const SwPostItItem *b) -{ - // if notes are on the same line, sort by x position, otherwise by y position - return (a->mPos.Bottom() == b->mPos.Bottom()) ? a->mPos.Left() < b->mPos.Left() : a->mPos.Bottom() < b->mPos.Bottom(); -} - -/* -bool comp_id(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) { - #define TXTFLD pFmtFld->GetTxtFld() - if (a->TXTFLD->GetTxtNode().FindFlyStartNode() || b->TXTFLD->GetTxtNode().FindFlyStartNode() || - a->TXTFLD->GetTxtNode().FindHeaderStartNode() || a->TXTFLD->GetTxtNode().FindFooterStartNode() || - b->TXTFLD->GetTxtNode().FindHeaderStartNode() || b->TXTFLD->GetTxtNode().FindFooterStartNode()) - return (a->mPos.Bottom() == b->mPos.Bottom()) ? a->mPos.Left() < b->mPos.Left() : a->mPos.Bottom() < b->mPos.Bottom(); - else - return ((*a->TXTFLD->GetPosition()) < (*b->TXTFLD->GetPosition())); + 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(); } -*/ SwPostItMgr::SwPostItMgr(SwView* pView) : mpView(pView) @@ -135,12 +128,18 @@ SwPostItMgr::SwPostItMgr(SwView* pView) , mbLayouting(false) , mbReadOnly(mpView->GetDocShell()->IsReadOnly()) , mbDeleteNote(true) + , mpAnswer(0) { if(!mpView->GetDrawView() ) mpView->GetWrtShell().MakeDrawView(); - // collect all PostIts that exist after loading the document + + // 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 + AddRedlineComments(false,false); + */ + // we want to receive stuff like SFX_HINT_DOCCHANGED StartListening(*mpView->GetDocShell()); if (!mvPostItFlds.empty() && ShowNotes()) { @@ -153,8 +152,8 @@ SwPostItMgr::~SwPostItMgr() { if ( mnEventId ) Application::RemoveUserEvent( mnEventId ); - // forget about all PostItFields - RemovePostIts(); + // forget about all our margin windows + RemoveMarginWin(); EndListening( *mpView->GetDocShell() ); for(std::vector<SwPostItPageItem*>::iterator i = mPages.begin(); i!= mPages.end() ; i++) @@ -165,12 +164,12 @@ SwPostItMgr::~SwPostItMgr() void SwPostItMgr::CheckForRemovedPostIts() { bool bRemoved = false; - for(std::list<SwPostItItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end(); ) + for(std::list<SwMarginItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end(); ) { - std::list<SwPostItItem*>::iterator it = i++; - if ( !(*it)->pFmtFld->IsFldInDoc() ) + std::list<SwMarginItem*>::iterator it = i++; + if ( !(*it)->UseElement() ) { - SwPostItItem* p = (*it); + SwMarginItem* p = (*it); mvPostItFlds.remove(*it); if (p->pPostIt) delete p->pPostIt; @@ -195,38 +194,46 @@ void SwPostItMgr::CheckForRemovedPostIts() } } -void SwPostItMgr::InsertFld(SwFmtFld* aField, bool bCheckExistance, bool bFocus) +void SwPostItMgr::InsertItem(SfxBroadcaster* pItem, bool bCheckExistance, bool bFocus) { if (bCheckExistance) { - for(std::list<SwPostItItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + for(std::list<SwMarginItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { - if ( (*i)->pFmtFld == aField ) + if ( (*i)->GetBroadCaster() == pItem ) return; } } mbLayout = bFocus; - mvPostItFlds.push_back(new SwPostItItem(aField, true, bFocus) ); - // listen for removal of field - StartListening( *aField ); + if (pItem->ISA(SwFmtFld)) + mvPostItFlds.push_back(new SwPostItItem(static_cast<SwFmtFld*>(pItem), true, bFocus) ); + /* + else + if (pItem->ISA(SwRedline)) + mvPostItFlds.push_back(new SwRedCommentItem( static_cast<SwRedline*>(pItem), true, bFocus)) ; + */ + DBG_ASSERT(pItem->ISA(SwFmtFld) /*|| pItem->ISA(SwRedline)*/,"Mgr::InsertItem: seems like new stuff was added"); + StartListening(*pItem); } -void SwPostItMgr::RemoveFld( SfxBroadcaster* pFld ) +void SwPostItMgr::RemoveItem( SfxBroadcaster* pBroadcast ) { - for(std::list<SwPostItItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + EndListening(*pBroadcast); + for(std::list<SwMarginItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { - if ( (*i)->pFmtFld == pFld ) + if ( (*i)->GetBroadCaster() == pBroadcast ) { - SwPostItItem* p = (*i); - mvPostItFlds.remove(*i); + SwMarginItem* p = (*i); if (GetActivePostIt() == p->pPostIt) SetActivePostIt(0); + mvPostItFlds.remove(*i); delete p->pPostIt; delete p; break; } } mbLayout = true; + PrepareView(); } void SwPostItMgr::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) @@ -282,13 +289,39 @@ void SwPostItMgr::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) { // field to be removed is the broadcaster DBG_ERROR("Notification for removed SwFmtFld was not sent!"); - RemoveFld(&rBC); - PrepareView(); + RemoveItem(&rBC); } break; } } } + /* + else if ( rHint.IsA(TYPE(SwRedlineHint) ) ) + { + SwRedline* pRedline = const_cast<SwRedline*>(((SwRedlineHint&)rHint).GetRedline()); + switch ( ((SwRedlineHint&)rHint).Which() ) + { + case SWREDLINE_INSERTED : + { + bool bEmpty = !HasNotes(); + InsertItem( pRedline, true, false ); + if (bEmpty && !mvPostItFlds.empty()) + PrepareView(true); + break; + } + case SWREDLINE_REMOVED: + { + RemoveItem(pRedline); + break; + } + case SWREDLINE_FOCUS: + { + Focus(rBC); + break; + } + } + } + */ else if ( rHint.IsA(TYPE(SwFmtFldHint) ) ) { SwFmtFld* pFld = const_cast <SwFmtFld*>( ((SwFmtFldHint&)rHint).GetField() ); @@ -301,12 +334,11 @@ void SwPostItMgr::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) AddPostIts(true); break; } - // get field to be inserted from hint if ( pFld->IsFldInDoc() ) { - bool bEmpty = mvPostItFlds.empty(); - InsertFld( pFld, true, false ); + bool bEmpty = !HasNotes(); + InsertItem( pFld, true, false ); if (bEmpty && !mvPostItFlds.empty()) PrepareView(true); } @@ -324,47 +356,21 @@ void SwPostItMgr::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) CheckForRemovedPostIts(); break; } - - // get field to be removed from hint - EndListening( *pFld ); - RemoveFld(pFld); - PrepareView(); + RemoveItem(pFld); } break; } case SWFMTFLD_FOCUS: { - if (!mpWrtShell->GetViewOptions()->IsPostIts()) - { - SfxRequest aRequest(mpView->GetViewFrame(),FN_VIEW_NOTES); - mpView->ExecViewOptions(aRequest); - } - // field to get the focus is the broadcaster, SwFmtFld in Hint may be NULL - SwFmtFld* pFmtFld = dynamic_cast<SwFmtFld*>(&rBC); - for(std::list<SwPostItItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) - { - if ( pFmtFld == (*i)->pFmtFld ) - { - if ((*i)->pPostIt) - { - (*i)->pPostIt->GrabFocus(); - MakeVisible((*i)->pPostIt); - } - else - { - // when the layout algorithm starts, this postit is created and receives focus - (*i)->bFocus = true; - } - } - } + Focus(rBC); break; } case SWFMTFLD_CHANGED: { SwFmtFld* pFmtFld = dynamic_cast<SwFmtFld*>(&rBC); - for(std::list<SwPostItItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + for(std::list<SwMarginItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { - if ( pFmtFld == (*i)->pFmtFld ) + if ( pFmtFld == (*i)->GetBroadCaster() ) { if ((*i)->pPostIt) (*i)->pPostIt->SetPostItText(); @@ -376,13 +382,13 @@ void SwPostItMgr::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) case SWFMTFLD_LANGUAGE: { SwFmtFld* pFmtFld = dynamic_cast<SwFmtFld*>(&rBC); - for(std::list<SwPostItItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + for(std::list<SwMarginItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { - if ( pFmtFld == (*i)->pFmtFld ) + if ( pFmtFld == (*i)->GetBroadCaster() ) { if ((*i)->pPostIt) { - USHORT nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( (*i)->pFmtFld->GetFld()->GetLanguage() ); + USHORT nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( (*i)->GetFmtFld()->GetFld()->GetLanguage() ); USHORT nLangWhichId = 0; switch (nScriptType) { @@ -390,7 +396,7 @@ 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)->pFmtFld->GetFld()->GetLanguage(),nLangWhichId)); + (*i)->pPostIt->SetLanguage(SvxLanguageItem((*i)->GetFmtFld()->GetFld()->GetLanguage(),nLangWhichId)); } break; } @@ -401,6 +407,33 @@ void SwPostItMgr::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) } } +void SwPostItMgr::Focus(SfxBroadcaster& rBC) +{ + if (!mpWrtShell->GetViewOptions()->IsPostIts()) + { + SfxRequest aRequest(mpView->GetViewFrame(),FN_VIEW_NOTES); + mpView->ExecViewOptions(aRequest); + } + + for(std::list<SwMarginItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + { + // field to get the focus is the broadcaster + if ( &rBC == (*i)->GetBroadCaster() ) + { + if ((*i)->pPostIt) + { + (*i)->pPostIt->GrabFocus(); + MakeVisible((*i)->pPostIt); + } + else + { + // when the layout algorithm starts, this postit is created and receives focus + (*i)->bFocus = true; + } + } + } +} + bool SwPostItMgr::CalcRects() { if (!ShowNotes()) @@ -419,12 +452,12 @@ bool SwPostItMgr::CalcRects() PreparePageContainer(); if ( !mvPostItFlds.empty() ) { - for(std::list<SwPostItItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + for(std::list<SwMarginItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { - SwPostItItem* pItem = (*i); - if ( !pItem->pFmtFld->IsFldInDoc() ) + SwMarginItem* pItem = (*i); + if ( !pItem->UseElement() ) { - DBG_ERROR("PostIt is not in doc!"); + DBG_ERROR("PostIt is not in doc or other wrong use"); bRepair = true; continue; } @@ -432,12 +465,12 @@ bool SwPostItMgr::CalcRects() //save old rect and visible state SwRect aOldRect(pItem->mPos); SwPostItHelper::SwLayoutStatus eOldStatus = pItem->mLayoutStatus; - if( pItem->pFmtFld ) + std::vector< SwLayoutInfo > aInfo; + //pItem->mLayoutStatus = SwPostItHelper::getLayoutInfos( aInfo, pItem->pFmtFld->GetTxtFld() ); + SwPosition aPosition = pItem->GetPosition(); + pItem->mLayoutStatus = SwPostItHelper::getLayoutInfos( aInfo, aPosition ); + if( aInfo.size() ) { - std::vector< SwLayoutInfo > aInfo; - pItem->mLayoutStatus = SwPostItHelper::getLayoutInfos( aInfo, pItem->pFmtFld->GetTxtFld() ); - if( aInfo.size() ) - { SwLayoutInfo& rInfo = aInfo[0]; pItem->mPos = rInfo.mPosition; pItem->mPagePos = rInfo.mPageFrame; @@ -445,7 +478,6 @@ bool SwPostItMgr::CalcRects() pItem->bMarginSide = rInfo.mbMarginSide; pItem->mnPageNumber = rInfo.mnPageNumber; pItem->mRedlineAuthor = rInfo.mRedlineAuthor; - } } bChange = bChange || (pItem->mPos != aOldRect) || (eOldStatus != pItem->mLayoutStatus); } @@ -455,11 +487,25 @@ bool SwPostItMgr::CalcRects() Sort(SORT_POS); // sort the items into the right page vector, so layout can be done by page - for(std::list<SwPostItItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + for(std::list<SwMarginItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { - SwPostItItem* pItem = (*i); + SwMarginItem* pItem = (*i); if( SwPostItHelper::INVISIBLE == pItem->mLayoutStatus ) + { + if (pItem->pPostIt) + pItem->pPostIt->HideNote(); continue; + } + + if( SwPostItHelper::HIDDEN == pItem->mLayoutStatus ) + { + if (!mpWrtShell->GetViewOptions()->IsShowHiddenChar()) + { + if (pItem->pPostIt) + pItem->pPostIt->HideNote(); + continue; + } + } const unsigned long aPageNum = pItem->mnPageNumber; if (aPageNum > mPages.size()) @@ -499,7 +545,7 @@ bool SwPostItMgr::CalcRects() bool SwPostItMgr::HasScrollbars() const { - for(std::list<SwPostItItem*>::const_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + for(std::list<SwMarginItem*>::const_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { if ((*i)->bShow && (*i)->pPostIt && (*i)->pPostIt->Scrollbar()) return true; @@ -554,16 +600,15 @@ void SwPostItMgr::LayoutPostIts() // only layout if there are notes on this page if (mPages[n]->mList->size()>0) { - std::list<SwPostIt*> aVisiblePostItList; + std::list<SwMarginWin*> aVisiblePostItList; unsigned long lNeededHeight = 0; long mlPageBorder = 0; long mlPageEnd = 0; - for(SwPostItItem_iterator i = mPages[n]->mList->begin(); i!= mPages[n]->mList->end(); i++) + for(SwMarginItem_iterator i = mPages[n]->mList->begin(); i!= mPages[n]->mList->end(); i++) { - SwPostItItem* pItem = (*i); - SwFmtFld* pFmtFld = pItem->pFmtFld; - SwPostIt* pPostIt = pItem->pPostIt; + SwMarginItem* pItem = (*i); + SwMarginWin* pPostIt = pItem->pPostIt; if (mPages[n]->bMarginSide) { @@ -586,13 +631,25 @@ void SwPostItMgr::LayoutPostIts() long aPostItHeight = 0; if (!pPostIt) { - pPostIt = new SwPostIt(static_cast<Window*>(&mpView->GetEditWin()),WINDOW_CONTROL,pFmtFld,this,0); + pPostIt = (*i)->GetMarginWindow(static_cast<Window*>(&mpView->GetEditWin()),WINDOW_CONTROL,this,0); + pPostIt->InitControls(); pPostIt->SetReadonly(mbReadOnly); - SetColors(pPostIt,static_cast<SwPostItField*>(pFmtFld->GetFld())); pItem->pPostIt = pPostIt; + if (mpAnswer) + { + if (pPostIt->CalcFollow()) //do we really have another note in front of this one + static_cast<SwPostIt*>(pPostIt)->InitAnswer(mpAnswer); + delete mpAnswer; + mpAnswer = 0; + } + } + + if (pItem->pPostIt->ISA(SwPostIt)) + { + static_cast<SwPostIt*>(pPostIt)->SetChangeTracking(pItem->mLayoutStatus,GetColorAnkor(pItem->mRedlineAuthor)); } - pPostIt->SetChangeTracking(pItem->mLayoutStatus,GetColorAnkor(pItem->mRedlineAuthor)); pPostIt->SetMarginSide(mPages[n]->bMarginSide); + 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); @@ -604,7 +661,7 @@ void SwPostItMgr::LayoutPostIts() } // only the visible postits are used for the final layout aVisiblePostItList.push_back(pPostIt); - lNeededHeight += aPostItHeight+GetSpaceBetween(); + lNeededHeight += pPostIt->IsFollow() ? aPostItHeight : aPostItHeight+GetSpaceBetween(); } else // we don't want to see it { @@ -636,7 +693,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(SwPostIt_iterator i = aVisiblePostItList.begin(); i!= aVisiblePostItList.end() ; i++) + for(SwMarginWin_iterator i = aVisiblePostItList.begin(); i!= aVisiblePostItList.end() ; i++) { if (mPages[n]->lOffset != 0) (*i)->TranslateTopPosition(mPages[n]->lOffset); @@ -651,7 +708,6 @@ 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 @@ -668,7 +724,7 @@ void SwPostItMgr::LayoutPostIts() } } // do some magic so we really see the focused note - for(SwPostIt_iterator i = aVisiblePostItList.begin(); i!= aVisiblePostItList.end() ; i++) + for(SwMarginWin_iterator i = aVisiblePostItList.begin(); i!= aVisiblePostItList.end() ; i++) { if ((*i)->HasChildPathFocus()) { @@ -694,10 +750,10 @@ void SwPostItMgr::LayoutPostIts() else { // we do not want to see the notes anymore -> Options-Writer-View-Notes bool bRepair = false; - for(SwPostItItem_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + for(SwMarginItem_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { - SwPostItItem* pItem = (*i); - if ( !pItem->pFmtFld->IsFldInDoc() ) + SwMarginItem* pItem = (*i); + if ( !pItem->UseElement() ) { DBG_ERROR("PostIt is not in doc!"); bRepair = true; @@ -730,7 +786,7 @@ bool SwPostItMgr::BorderOverPageBorder(unsigned long aPage) const return false; } - SwPostItItem_iterator aItem = mPages[aPage-1]->mList->end(); + SwMarginItem_iterator aItem = mPages[aPage-1]->mList->end(); --aItem; DBG_ASSERT ((*aItem)->pPostIt,"BorderOverPageBorder: NULL postIt, should never happen"); if ((*aItem)->pPostIt) @@ -753,9 +809,10 @@ 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(SwPostItItem_iterator i = mPages[aPage-1]->mList->begin(); i!= mPages[aPage-1]->mList->end(); i++) + for(SwMarginItem_iterator i = mPages[aPage-1]->mList->begin(); i!= mPages[aPage-1]->mList->end(); i++) { - SwPostIt* pPostIt = (*i)->pPostIt; + SwMarginWin* 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); @@ -794,7 +851,7 @@ void SwPostItMgr::Scroll(const long lScroll,const unsigned long aPage) } } -void SwPostItMgr::AutoScroll(const SwPostIt* pPostIt,const unsigned long aPage ) +void SwPostItMgr::AutoScroll(const SwMarginWin* pPostIt,const unsigned long aPage ) { // otherwise all notes are visible if (mPages[aPage-1]->bScrollbar) @@ -814,7 +871,7 @@ void SwPostItMgr::AutoScroll(const SwPostIt* pPostIt,const unsigned long aPage ) } } -void SwPostItMgr::MakeVisible(const SwPostIt* pPostIt,long aPage ) +void SwPostItMgr::MakeVisible(const SwMarginWin* pPostIt,long aPage ) { if (aPage == -1) { @@ -823,7 +880,7 @@ void SwPostItMgr::MakeVisible(const SwPostIt* pPostIt,long aPage ) { if (mPages[n]->mList->size()>0) { - for(SwPostItItem_iterator i = mPages[n]->mList->begin(); i!= mPages[n]->mList->end(); i++) + for(SwMarginItem_iterator i = mPages[n]->mList->begin(); i!= mPages[n]->mList->end(); i++) { if ((*i)->pPostIt==pPostIt) { @@ -872,7 +929,7 @@ Color SwPostItMgr::GetArrowColor(USHORT aDirection,unsigned long aPage) const } } -bool SwPostItMgr::LayoutByPage(std::list<SwPostIt*> &aVisiblePostItList,const Rectangle aBorder, long lNeededHeight) +bool SwPostItMgr::LayoutByPage(std::list<SwMarginWin*> &aVisiblePostItList,const Rectangle aBorder, long lNeededHeight) { /*** General layout idea:***/ // - if we have space left, we always move the current one up, @@ -893,44 +950,27 @@ bool SwPostItMgr::LayoutByPage(std::list<SwPostIt*> &aVisiblePostItList,const Re bool bScrollbars = false; // do all neccessary resizings - /* if (lVisibleHeight < lNeededHeight) { - // resize the one we showed bigger on purpose and recalculate lNeededHeight - lNeededHeight = 0; - unsigned long aPostItHeight = 0; - for(SwPostIt_iterator i = aVisiblePostItList.begin(); i!= aVisiblePostItList.end() ; i++) + // ok, now we have to really resize and adding scrollbars + const long lAverageHeight = (lVisibleHeight - aVisiblePostItList.size()*GetSpaceBetween()) / aVisiblePostItList.size(); + if (lAverageHeight<GetMinimumSizeWithMeta()) { - aPostItHeight = ( (*i)->GetTextHeight()==0 ? 30 : (*i)->GetTextHeight() ) + (*i)->GetMetaHeight(); - if ((*i)->GetTextHeight() < (*i)->GetMinimumSizeWithoutMeta()) - (*i)->SetSizePixel(Size((*i)->GetSizePixel().getWidth(), aPostItHeight)); - lNeededHeight += aPostItHeight+POSTIT_SPACE_BETWEEN; + bScrollbars = true; + lTopBorder += GetSidebarScrollerHeight() + 10; + lBottomBorder -= (GetSidebarScrollerHeight() + 10); + for(SwMarginWin_iterator i = aVisiblePostItList.begin(); i!= aVisiblePostItList.end() ; i++) + (*i)->SetSize(Size((*i)->VirtualSize().getWidth(),(*i)->GetMinimumSizeWithMeta())); } - // do we still need to resize now? - */ - if (lVisibleHeight < lNeededHeight) + else { - // ok, now we have to really resize and adding scrollbars - const long lAverageHeight = (lVisibleHeight - aVisiblePostItList.size()*GetSpaceBetween()) / aVisiblePostItList.size(); - if (lAverageHeight<GetMinimumSizeWithMeta()) + for(SwMarginWin_iterator i = aVisiblePostItList.begin(); i!= aVisiblePostItList.end() ; i++) { - bScrollbars = true; - lTopBorder += GetSidebarScrollerHeight() + 10; - lBottomBorder -= (GetSidebarScrollerHeight() + 10); - - for(SwPostIt_iterator i = aVisiblePostItList.begin(); i!= aVisiblePostItList.end() ; i++) - (*i)->SetSize(Size((*i)->VirtualSize().getWidth(),(*i)->GetMinimumSizeWithMeta())); - } - else - { - for(SwPostIt_iterator i = aVisiblePostItList.begin(); i!= aVisiblePostItList.end() ; i++) - { - if ( (*i)->VirtualSize().getHeight() > lAverageHeight) - (*i)->SetSize(Size((*i)->VirtualSize().getWidth(),lAverageHeight)); - } + if ( (*i)->VirtualSize().getHeight() > lAverageHeight) + (*i)->SetSize(Size((*i)->VirtualSize().getWidth(),lAverageHeight)); } } - //} + } //start the real layout so nothing overlaps anymore if (aVisiblePostItList.size()>1) @@ -941,9 +981,9 @@ bool SwPostItMgr::LayoutByPage(std::list<SwPostIt*> &aVisiblePostItList,const Re loop++; bDone = true; lSpaceUsed = lTopBorder + GetSpaceBetween(); - for(SwPostIt_iterator i = aVisiblePostItList.begin(); i!= aVisiblePostItList.end() ; i++) + for(SwMarginWin_iterator i = aVisiblePostItList.begin(); i!= aVisiblePostItList.end() ; i++) { - SwPostIt_iterator aNextPostIt = i; + SwMarginWin_iterator aNextPostIt = i; ++aNextPostIt; if (aNextPostIt !=aVisiblePostItList.end()) @@ -961,19 +1001,28 @@ bool SwPostItMgr::LayoutByPage(std::list<SwPostIt*> &aVisiblePostItList,const Re // we have space left, so let's move the current one up if ( ((*i)->VirtualPos().Y()- lTranslatePos - GetSpaceBetween()) > lTopBorder) { - (*i)->TranslateTopPosition(-1*(lTranslatePos+GetSpaceBetween())); + if ((*aNextPostIt)->IsFollow()) + (*i)->TranslateTopPosition(-1*(lTranslatePos+ANKORLINE_WIDTH)); + else + (*i)->TranslateTopPosition(-1*(lTranslatePos+GetSpaceBetween())); } else { long lMoveUp = (*i)->VirtualPos().Y() - lTopBorder; (*i)->TranslateTopPosition(-1* lMoveUp); - (*aNextPostIt)->TranslateTopPosition( (lTranslatePos+GetSpaceBetween()) - lMoveUp); + if ((*aNextPostIt)->IsFollow()) + (*aNextPostIt)->TranslateTopPosition( (lTranslatePos+ANKORLINE_WIDTH) - lMoveUp); + else + (*aNextPostIt)->TranslateTopPosition( (lTranslatePos+GetSpaceBetween()) - lMoveUp); } } else { // no space left, left move the next one down - (*aNextPostIt)->TranslateTopPosition(lTranslatePos+GetSpaceBetween()); + if ((*aNextPostIt)->IsFollow()) + (*aNextPostIt)->TranslateTopPosition(lTranslatePos+ANKORLINE_WIDTH); + else + (*aNextPostIt)->TranslateTopPosition(lTranslatePos+GetSpaceBetween()); } } else @@ -989,20 +1038,27 @@ bool SwPostItMgr::LayoutByPage(std::list<SwPostIt*> &aVisiblePostItList,const Re } } } - lSpaceUsed += (*i)->VirtualSize().Height() + GetSpaceBetween(); + if (aNextPostIt !=aVisiblePostItList.end() && (*aNextPostIt)->IsFollow()) + lSpaceUsed += (*i)->VirtualSize().Height() + ANKORLINE_WIDTH; + else + lSpaceUsed += (*i)->VirtualSize().Height() + GetSpaceBetween(); } else { //(*i) is the last visible item - SwPostIt_iterator aPrevPostIt = i; + SwMarginWin_iterator aPrevPostIt = i; --aPrevPostIt; - lTranslatePos = ( (*aPrevPostIt)->VirtualPos().Y() + (*aPrevPostIt)->VirtualSize().Height() + GetSpaceBetween() ) - (*i)->VirtualPos().Y(); + //lTranslatePos = ( (*aPrevPostIt)->VirtualPos().Y() + (*aPrevPostIt)->VirtualSize().Height() + GetSpaceBetween() ) - (*i)->VirtualPos().Y(); + lTranslatePos = ( (*aPrevPostIt)->VirtualPos().Y() + (*aPrevPostIt)->VirtualSize().Height() ) - (*i)->VirtualPos().Y(); if (lTranslatePos > 0) { bDone = false; if ( ((*i)->VirtualPos().Y()+ (*i)->VirtualSize().Height()+lTranslatePos) < lBottomBorder) { - (*i)->TranslateTopPosition(lTranslatePos+GetSpaceBetween()); + if ( (*i)->IsFollow() ) + (*i)->TranslateTopPosition(lTranslatePos+ANKORLINE_WIDTH); + else + (*i)->TranslateTopPosition(lTranslatePos+GetSpaceBetween()); } else { @@ -1032,7 +1088,7 @@ bool SwPostItMgr::LayoutByPage(std::list<SwPostIt*> &aVisiblePostItList,const Re else { // only one left, make sure it is not hidden at the top or bottom - SwPostIt_iterator i = aVisiblePostItList.begin(); + SwMarginWin_iterator i = aVisiblePostItList.begin(); lTranslatePos = lTopBorder - (*i)->VirtualPos().Y(); if (lTranslatePos>0) { @@ -1047,6 +1103,22 @@ bool SwPostItMgr::LayoutByPage(std::list<SwPostIt*> &aVisiblePostItList,const Re return bScrollbars; } +/* +void SwPostItMgr::AddRedlineComments(bool bCheckExistance, bool bFocus) +{ + bool bEmpty = mvPostItFlds.empty(); + const SwRedlineTbl& aTable = mpView->GetDocShell()->GetDoc()->GetRedlineTbl(); + for( USHORT i = 0; i < aTable.Count(); ++i ) + { + SwRedline* pRedline = const_cast<SwRedline*>((aTable)[i]); + if ( pRedline->GetComment() != String(rtl::OUString::createFromAscii("")) ) + InsertItem(pRedline, bCheckExistance, bFocus); + } + if (bEmpty && !mvPostItFlds.empty()) + PrepareView(true); + } + */ + void SwPostItMgr::AddPostIts(bool bCheckExistance, bool bFocus) { bool bEmpty = mvPostItFlds.empty(); @@ -1059,7 +1131,7 @@ void SwPostItMgr::AddPostIts(bool bCheckExistance, bool bFocus) if ( pSwFmtFld->GetTxtFld()) { if ( pSwFmtFld->IsFldInDoc() ) - InsertFld(pSwFmtFld,bCheckExistance,bFocus); + InsertItem(pSwFmtFld,bCheckExistance,bFocus); } pFirst = aIter++; } @@ -1069,15 +1141,14 @@ void SwPostItMgr::AddPostIts(bool bCheckExistance, bool bFocus) PrepareView(true); } -void SwPostItMgr::RemovePostIts() +void SwPostItMgr::RemoveMarginWin() { if (!mvPostItFlds.empty()) { - for(std::list<SwPostItItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + for(std::list<SwMarginItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { - EndListening( *((*i)->pFmtFld) ); - SwPostIt* pPostIt = (*i)->pPostIt; - delete pPostIt; + EndListening( *((*i)->GetBroadCaster()) ); + delete (*i)->pPostIt; delete (*i); } mvPostItFlds.clear(); @@ -1087,12 +1158,14 @@ void SwPostItMgr::RemovePostIts() PreparePageContainer(); } -// copy to new vector, otherwise RemoveFld would operate and delete stuff on mvPostItFlds as well -// RemoveFld will clean up the core field and visible postit if neccessary +// copy to new vector, otherwise RemoveItem would operate and delete stuff on mvPostItFlds as well +// RemoveItem will clean up the core field and visible postit if neccessary // we cannot just delete everything as before, as postits could move into change tracking void SwPostItMgr::Delete(String aAuthor) { mpWrtShell->StartAllAction(); + if ( GetActivePostIt() && (GetActivePostIt()->GetAuthor()==aAuthor) ) + SetActivePostIt(0); SwRewriter aRewriter; String aUndoString = SW_RES(STR_DELETE_AUTHOR_NOTES); aUndoString += aAuthor; @@ -1101,11 +1174,10 @@ void SwPostItMgr::Delete(String aAuthor) std::vector<SwFmtFld*> aTmp; aTmp.reserve( mvPostItFlds.size() ); - for(std::list<SwPostItItem*>::iterator pPostIt = mvPostItFlds.begin(); pPostIt!= mvPostItFlds.end() ; pPostIt++) + for(std::list<SwMarginItem*>::iterator pPostIt = mvPostItFlds.begin(); pPostIt!= mvPostItFlds.end() ; pPostIt++) { - SwPostItField* pPostItField = static_cast<SwPostItField*>((*pPostIt)->pFmtFld->GetFld()); - if (pPostItField->GetPar1() == aAuthor) - aTmp.push_back( (*pPostIt)->pFmtFld ); + if ((*pPostIt)->GetFmtFld() && ((*pPostIt)->pPostIt->GetAuthor() == aAuthor) ) + aTmp.push_back( (*pPostIt)->GetFmtFld() ); } for(std::vector<SwFmtFld*>::iterator i = aTmp.begin(); i!= aTmp.end() ; i++) { @@ -1160,8 +1232,11 @@ void SwPostItMgr::Delete() std::vector<SwFmtFld*> aTmp; aTmp.reserve( mvPostItFlds.size() ); - for(std::list<SwPostItItem*>::iterator pPostIt = mvPostItFlds.begin(); pPostIt!= mvPostItFlds.end() ; pPostIt++) - aTmp.push_back( (*pPostIt)->pFmtFld ); + for(std::list<SwMarginItem*>::iterator pPostIt = mvPostItFlds.begin(); pPostIt!= mvPostItFlds.end() ; pPostIt++) + { + if ((*pPostIt)->GetFmtFld()) + aTmp.push_back( (*pPostIt)->GetFmtFld() ); + } for(std::vector<SwFmtFld*>::iterator i = aTmp.begin(); i!= aTmp.end() ; i++) { mpWrtShell->GotoField( *(*i) ); @@ -1195,14 +1270,17 @@ void SwPostItMgr::Delete() void SwPostItMgr::Hide(SwPostItField* pPostItField ) { - for(std::list<SwPostItItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + for(std::list<SwMarginItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { - SwPostItField* pField = static_cast<SwPostItField*>((*i)->pFmtFld->GetFld()); - if (pPostItField==pField) + if ((*i)->GetFmtFld()) { - (*i)->bShow = false; - (*i)->pPostIt->HideNote(); - break; + SwPostItField* pField = static_cast<SwPostItField*>((*i)->GetFmtFld()->GetFld()); + if (pPostItField==pField) + { + (*i)->bShow = false; + (*i)->pPostIt->HideNote(); + break; + } } } @@ -1211,10 +1289,9 @@ void SwPostItMgr::Hide(SwPostItField* pPostItField ) void SwPostItMgr::Hide( const String& rAuthor ) { - for(std::list<SwPostItItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + for(SwMarginItem_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { - SwPostItField* pPostItField = static_cast<SwPostItField*>((*i)->pFmtFld->GetFld()); - if ( rAuthor == pPostItField->GetPar1() ) + if ( (*i)->pPostIt && ((*i)->pPostIt->GetAuthor() == rAuthor) ) { (*i)->bShow = false; (*i)->pPostIt->HideNote(); @@ -1226,7 +1303,7 @@ void SwPostItMgr::Hide( const String& rAuthor ) void SwPostItMgr::Hide() { - for(SwPostItItem_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + for(SwMarginItem_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { (*i)->bShow = false; (*i)->pPostIt->HideNote(); @@ -1236,7 +1313,7 @@ void SwPostItMgr::Hide() void SwPostItMgr::Show() { - for(SwPostItItem_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + for(SwMarginItem_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { (*i)->bShow = true; } @@ -1251,23 +1328,24 @@ void SwPostItMgr::Sort(const short aType) { case SORT_POS: mvPostItFlds.sort(comp_pos); - //mvPostItFlds.sort(comp_id); break; + /* case SORT_AUTHOR: mvPostItFlds.sort(comp_author); break; case SORT_DATE: mvPostItFlds.sort(comp_date); break; + */ } } } -SwPostIt* SwPostItMgr::GetPostIt(SwFmtFld* pFld) const +SwMarginWin* SwPostItMgr::GetPostIt(SfxBroadcaster* pBroadcaster) const { for(const_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { - if ( (*i)->pFmtFld ==pFld) + if ( (*i)->GetBroadCaster() == pBroadcaster) return (*i)->pPostIt; } return NULL; @@ -1277,17 +1355,17 @@ SwPostIt* SwPostItMgr::GetPostIt(SwPostItField* pFld) const { for(const_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { - if ( (*i)->pFmtFld->GetFld() == pFld) - return (*i)->pPostIt; + if ( (*i)->GetFmtFld() && ((*i)->GetFmtFld()->GetFld() == pFld) ) + return static_cast<SwPostIt*>((*i)->pPostIt); } return NULL; } -SwPostIt* SwPostItMgr::GetPostIt( const SwFmtFld* pFld) const +SwMarginWin* SwPostItMgr::GetPostIt( const SfxBroadcaster* pBroadcaster) const { for(const_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { - if ( (*i)->pFmtFld ==pFld) + if ( (*i)->GetBroadCaster() == pBroadcaster) return (*i)->pPostIt; } return NULL; @@ -1297,8 +1375,8 @@ SwPostIt* SwPostItMgr::GetPostIt(const SwPostItField* pFld) const { for(const_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { - if ( (*i)->pFmtFld->GetFld() == pFld) - return (*i)->pPostIt; + if ( (*i)->GetFmtFld() && ((*i)->GetFmtFld()->GetFld() == pFld)) + return static_cast<SwPostIt*>((*i)->pPostIt); } return NULL; } @@ -1311,9 +1389,9 @@ bool SwPostItMgr::ShowPreview(const SwField* pFld, SwFmtFld*& pFmtFld) const { for(const_iterator i = mPages[n]->mList->begin(); i!= mPages[n]->mList->end(); i++) { - if ((*i)->pFmtFld->GetFld()==pFld) + if ( (*i)->GetFmtFld() && ((*i)->GetFmtFld()->GetFld()==pFld) ) { - pFmtFld = (*i)->pFmtFld; + pFmtFld = (*i)->GetFmtFld(); const long aSidebarheight = mPages[n]->bScrollbar ? mpEditWin->PixelToLogic(Size(0,GetSidebarScrollerHeight())).Height() : 0; bool bTopPage = mpEditWin->PixelToLogic(Point(0,(*i)->pPostIt->GetPosPixel().Y())).Y() >= (mPages[n]->mPageRect.Top()+aSidebarheight); bool bBottomPage = mpEditWin->PixelToLogic(Point(0,(*i)->pPostIt->GetPosPixel().Y()+(*i)->pPostIt->GetSizePixel().Height())).Y() <= (mPages[n]->mPageRect.Bottom()-aSidebarheight); @@ -1327,57 +1405,34 @@ bool SwPostItMgr::ShowPreview(const SwField* pFld, SwFmtFld*& pFmtFld) const return false; } -SwPostIt* SwPostItMgr::GetNextPostIt(USHORT aDirection, SwPostIt* aPostIt) +SwMarginWin* SwPostItMgr::GetNextPostIt(USHORT aDirection, SwMarginWin* aPostIt) { if (mvPostItFlds.size()>1) { - for(SwPostItItem_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + for(SwMarginItem_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { if ( (*i)->pPostIt ==aPostIt) { - SwPostItItem_iterator iNextPostIt = i; - /* - const Rectangle &aVisRect = mpView->GetVisArea(); - bool bVisible = false; - bool bDone = false; - - while (!bDone) + SwMarginItem_iterator iNextPostIt = i; + if (aDirection==KEY_PAGEUP) { - */ - if (aDirection==KEY_PAGEUP) + if ( iNextPostIt==mvPostItFlds.begin() ) { - if ( iNextPostIt==mvPostItFlds.begin() ) - { - //iNextPostIt = mvPostItFlds.end(); - return NULL; - } - --iNextPostIt; + return NULL; } - else + --iNextPostIt; + } + else + { + iNextPostIt++; + if ( iNextPostIt==mvPostItFlds.end() ) { - iNextPostIt++; - if ( iNextPostIt==mvPostItFlds.end() ) - { - return NULL; - //iNextPostIt = mvPostItFlds.begin(); - } - } - // lets quit, we are back at the beginng - if ( (*iNextPostIt)->pPostIt==aPostIt) return NULL; - - //bVisible = (*iNextPostIt)->pFmtFld->GetTxtFld()->GetTxtNode().IsInVisibleArea(); - //bVisible = bVisible && ((*iNextPostIt)->mPos.Bottom() < aVisRect.Bottom()) && ((*iNextPostIt)->mPos.Bottom() > aVisRect.Top()); - - /* - const bool bBottom = mpEditWin->PixelToLogic(Point(0,(*iNextPostIt)->pPostIt->GetPosPixel().Y()+(*iNextPostIt)->pPostIt->GetSizePixel().Height())).Y() <= aVisRect.Bottom(); - const bool bTop = mpEditWin->PixelToLogic(Point(0,(*iNextPostIt)->pPostIt->GetPosPixel().Y())).Y() >= aVisRect.Top(); - bVisible = bBottom && bTop; - - bDone = bVisible && (*iNextPostIt)->bShow; - + } } - */ + // lets quit, we are back at the beginng + if ( (*iNextPostIt)->pPostIt==aPostIt) + return NULL; return (*iNextPostIt)->pPostIt; } } @@ -1391,27 +1446,24 @@ long SwPostItMgr::GetNextBorder() { for (unsigned long n=0;n<mPages.size();n++) { - for(SwPostItItem_iterator b = mPages[n]->mList->begin(); b!= mPages[n]->mList->end(); b++) + for(SwMarginItem_iterator b = mPages[n]->mList->begin(); b!= mPages[n]->mList->end(); b++) { if ((*b)->pPostIt == mpActivePostIt) { - if (mPages[n]->bScrollbar) + SwMarginItem_iterator aNext = b; + aNext++; + bool bFollow = (aNext == mPages[n]->mList->end()) ? false : (*aNext)->pPostIt->IsFollow(); + if ( mPages[n]->bScrollbar || bFollow ) { return -1; } else { //if this is the last item, return the bottom border otherwise the next item - SwPostItItem_iterator aNext = b; - aNext++; if (aNext == mPages[n]->mList->end()) - { return mpEditWin->LogicToPixel(Point(0,mPages[n]->mPageRect.Bottom())).Y() - GetSpaceBetween(); - } else - { return (*aNext)->pPostIt->GetPosPixel().Y() - GetSpaceBetween(); - } } } } @@ -1421,17 +1473,6 @@ long SwPostItMgr::GetNextBorder() return -1; } -SwFmtFld* SwPostItMgr::GetFmtFld(SwPostIt* mpPostIt) const -{ - for(const_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) - { - if ( (*i)->pPostIt == mpPostIt) - return (*i)->pFmtFld; - } - DBG_WARNING("SwPostItMgr::GetFmtFld(): PostIt not found, something major must have gone wrong here"); - return NULL; -} - void SwPostItMgr::SetShadowState(const SwPostItField* pFld,bool bCursor) { if (pFld) @@ -1444,13 +1485,13 @@ void SwPostItMgr::SetShadowState(const SwPostItField* pFld,bool bCursor) // TODO: does not work properly if mouse and cursor was set SwPostIt* pOldPostIt = GetPostIt(mShadowState.mpShadowFld); if (pOldPostIt && pOldPostIt->Shadow() && (pOldPostIt->Shadow()->GetShadowState() != SS_EDIT)) - pOldPostIt->SetShadowState(SS_NORMAL); + pOldPostIt->SetViewState(SS_NORMAL); } //set new one, if it is not currently edited SwPostIt* pNewPostIt = GetPostIt(pFld); if (pNewPostIt && pNewPostIt->Shadow() && (pNewPostIt->Shadow()->GetShadowState() != SS_EDIT)) { - pNewPostIt->SetShadowState(SS_VIEW); + pNewPostIt->SetViewState(SS_VIEW); //remember our new field mShadowState.mpShadowFld = pFld; mShadowState.bCursor = false; @@ -1476,7 +1517,7 @@ void SwPostItMgr::SetShadowState(const SwPostItField* pFld,bool bCursor) SwPostIt* pOldPostIt = GetPostIt(mShadowState.mpShadowFld); if (pOldPostIt && pOldPostIt->Shadow() && (pOldPostIt->Shadow()->GetShadowState() != SS_EDIT)) { - pOldPostIt->SetShadowState(SS_NORMAL); + pOldPostIt->SetViewState(SS_NORMAL); mShadowState.mpShadowFld = 0; } } @@ -1486,13 +1527,15 @@ void SwPostItMgr::SetShadowState(const SwPostItField* pFld,bool bCursor) void SwPostItMgr::PrepareView(bool bIgnoreCount) { - if (mvPostItFlds.empty() || bIgnoreCount) + if (!HasNotes() || bIgnoreCount) { - mpEditWin->Invalidate(); + mpWrtShell->StartAllAction(); + //mpEditWin->Invalidate(); // really not needed anymore?? SwRootFrm* pLayout = mpWrtShell->GetLayout(); if ( pLayout ) SwPostItHelper::setSidebarChanged( pLayout, mpWrtShell->getIDocumentSettingAccess()->get( IDocumentSettingAccess::BROWSE_MODE ) ); + mpWrtShell->EndAllAction(); } } @@ -1586,12 +1629,12 @@ bool SwPostItMgr::ScrollbarHit(const unsigned long aPage,const Point &aPoint) void SwPostItMgr::CorrectPositions() { - if ( mbWaitingForCalcRects || mbLayouting || mvPostItFlds.empty()) + if ( mbWaitingForCalcRects || mbLayouting || mvPostItFlds.empty() ) return; // find first valid note - SwPostIt *pFirstPostIt = 0; - for(SwPostItItem_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + SwMarginWin *pFirstPostIt = 0; + for(SwMarginItem_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { pFirstPostIt = (*i)->pPostIt; if (pFirstPostIt) @@ -1611,7 +1654,7 @@ void SwPostItMgr::CorrectPositions() long aAnkorPosY = 0; for (unsigned long n=0;n<mPages.size();n++) { - for(SwPostItItem_iterator i = mPages[n]->mList->begin(); i!= mPages[n]->mList->end(); i++) + for(SwMarginItem_iterator i = mPages[n]->mList->begin(); i!= mPages[n]->mList->end(); i++) { if ((*i)->bShow && (*i)->pPostIt) { @@ -1635,7 +1678,6 @@ bool SwPostItMgr::ShowNotes() const bool SwPostItMgr::HasNotes() const { - //we just want to know if there are notes, no matter if visible or not return !mvPostItFlds.empty(); } @@ -1706,20 +1748,14 @@ Color SwPostItMgr::GetColorAnkor(sal_uInt16 aAuthorIndex) return Color(COL_WHITE); } -void SwPostItMgr::SetColors(SwPostIt* pPostIt,SwPostItField* pFld) -{ - sal_uInt16 aIndex = SW_MOD()->InsertRedlineAuthor(pFld->GetPar1()); - pPostIt->SetColor(GetColorDark(aIndex),GetColorLight(aIndex),GetColorAnkor(aIndex)); -} - -void SwPostItMgr::SetActivePostIt( SwPostIt* p) +void SwPostItMgr::SetActivePostIt( SwMarginWin* 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 - SwPostIt* pActive = mpActivePostIt; + SwMarginWin* pActive = mpActivePostIt; mpActivePostIt = p; if (pActive) { @@ -1728,7 +1764,7 @@ void SwPostItMgr::SetActivePostIt( SwPostIt* p) } if (mpActivePostIt) { - mpWrtShell->GotoField( *mpActivePostIt->Field() ); + mpActivePostIt->GotoPos(); mpView->AttrChangedNotify(0); mpActivePostIt->ActivatePostIt(); } @@ -1741,6 +1777,7 @@ IMPL_LINK( SwPostItMgr, CalcHdl, void*, /* pVoid*/ ) if ( mbLayouting ) { DBG_ERROR("Reentrance problem in Layout Manager!"); + mbWaitingForCalcRects = false; return 0; } @@ -1755,7 +1792,7 @@ IMPL_LINK( SwPostItMgr, CalcHdl, void*, /* pVoid*/ ) void SwPostItMgr::Rescale() { - for(std::list<SwPostItItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + for(std::list<SwMarginItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) if ( (*i)->pPostIt ) (*i)->pPostIt->Rescale(); } @@ -1792,14 +1829,159 @@ sal_Int32 SwPostItMgr::GetSidebarScrollerHeight() const void SwPostItMgr::SetSpellChecking() { - for(std::list<SwPostItItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + for(std::list<SwMarginItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) if ( (*i)->pPostIt ) (*i)->pPostIt->SetSpellChecking(); } void SwPostItMgr::SetReadOnlyState() { - for(std::list<SwPostItItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) + for(std::list<SwMarginItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) if ( (*i)->pPostIt ) (*i)->pPostIt->SetReadonly( mbReadOnly ); } + +void SwPostItMgr::StartSearchAndReplace(const SvxSearchItem& rSearchItem) +{ + 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; + + */ +} + +sal_uInt16 SwPostItMgr::Replace(SvxSearchItem* pItem) +{ + SwMarginWin* pWin = GetActivePostIt(); + sal_uInt16 aResult = pWin->View()->StartSearchAndReplace( *pItem ); + if (!aResult) + SetActivePostIt(0); + return aResult; +} + + +sal_uInt16 SwPostItMgr::FinishSearchReplace(const ::com::sun::star::util::SearchOptions& rSearchOptions, bool bSrchForward) +{ + SwMarginWin* pWin = GetActivePostIt(); + SvxSearchItem aItem(SID_SEARCH_ITEM ); + aItem.SetSearchOptions(rSearchOptions); + aItem.SetBackward(!bSrchForward); + sal_uInt16 aResult = pWin->View()->StartSearchAndReplace( aItem ); + if (!aResult) + SetActivePostIt(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); + if (pWin) + { + ESelection aOldSelection = pWin->View()->GetSelection(); + if (bSrchForward) + pWin->View()->SetSelection(ESelection(0,0,0,0)); + else + pWin->View()->SetSelection(ESelection(0xFFFF,0xFFFF,0xFFFF,0xFFFF)); + SvxSearchItem aItem(SID_SEARCH_ITEM ); + aItem.SetSearchOptions(rSearchOptions); + aItem.SetBackward(!bSrchForward); + aResult = pWin->View()->StartSearchAndReplace( aItem ); + if (!aResult) + pWin->View()->SetSelection(aOldSelection); + else + { + SetActivePostIt(pWin); + MakeVisible(pWin); + } + } + return aResult; +} diff --git a/sw/source/ui/docvw/docvw.hrc b/sw/source/ui/docvw/docvw.hrc index 38d562f100e2..afb599e64c6c 100644 --- a/sw/source/ui/docvw/docvw.hrc +++ b/sw/source/ui/docvw/docvw.hrc @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: docvw.hrc,v $ - * $Revision: 1.11 $ + * $Revision: 1.11.190.1 $ * * This file is part of OpenOffice.org. * @@ -90,6 +90,11 @@ #define STR_DELETE_ALL_NOTES (RC_DOCVW_BEGIN + 24) #define STR_DELETE_AUTHOR_NOTES (RC_DOCVW_BEGIN + 25) +#define STR_NODATE (RC_DOCVW_BEGIN + 26) +#define STR_NOAUTHOR (RC_DOCVW_BEGIN + 27) + +#define STR_REPLY (RC_DOCVW_BEGIN + 28) + #define MSG_READONLY_CONTENT (RC_DOCVW_BEGIN + 1) #define DOCVW_ACT_END STR_SMARTTAG_CLICK diff --git a/sw/source/ui/docvw/docvw.src b/sw/source/ui/docvw/docvw.src index 963bfe29160f..de4305bc730e 100644 --- a/sw/source/ui/docvw/docvw.src +++ b/sw/source/ui/docvw/docvw.src @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: docvw.src,v $ - * $Revision: 1.52 $ + * $Revision: 1.52.140.1 $ * * This file is part of OpenOffice.org. * @@ -323,3 +323,18 @@ String STR_DELETE_AUTHOR_NOTES Text [ en-US ] = "Notes by " ; }; +String STR_NODATE +{ + Text [ en-US ] = "(no date)" ; +}; + +String STR_NOAUTHOR +{ + Text [ en-US ] = "(no author)" ; +}; + +String STR_REPLY +{ + Text [ en-US ] = "Reply to $1" ; +}; + diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx index d600a7e21ea0..c53253ee7115 100644 --- a/sw/source/ui/docvw/edtwin.cxx +++ b/sw/source/ui/docvw/edtwin.cxx @@ -3779,6 +3779,7 @@ void SwEditWin::MouseMove(const MouseEvent& _rMEvt) break; } //#i6193#, change ui if mouse is over SwPostItField + // TODO: do the same thing for redlines SW_REDLINE SwRect aFldRect; SwContentAtPos aCntntAtPos( SwContentAtPos::SW_FIELD); if( rSh.GetContentAtPos( aDocPt, aCntntAtPos, FALSE, &aFldRect ) ) diff --git a/sw/source/ui/docvw/edtwin2.cxx b/sw/source/ui/docvw/edtwin2.cxx index 4a654ff6aabb..6f397520be2c 100644 --- a/sw/source/ui/docvw/edtwin2.cxx +++ b/sw/source/ui/docvw/edtwin2.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: edtwin2.cxx,v $ - * $Revision: 1.32 $ + * $Revision: 1.31.130.3 $ * * This file is part of OpenOffice.org. * @@ -97,7 +97,7 @@ /*-------------------------------------------------------------------- Beschreibung: KeyEvents --------------------------------------------------------------------*/ -static void lcl_GetRedlineHelp( const SwRedline& rRedl, String& rTxt, BOOL bBalloon ) +static void lcl_GetRedlineHelp( const SwRedline& rRedl, String& rTxt, BOOL /*bBalloon*/ ) { USHORT nResId = 0; switch( rRedl.GetType() ) @@ -301,6 +301,7 @@ void SwEditWin::RequestHelp(const HelpEvent &rEvt) if (pMgr->ShowPreview(pFld,pSwFmtFld)) { SwPostIt* pPostIt = new SwPostIt(static_cast<Window*>(this),0,pSwFmtFld,pMgr,PB_Preview); + pPostIt->InitControls(); pPostIt->SetReadonly(true); pMgr->SetColors(pPostIt,static_cast<SwPostItField*>(pSwFmtFld->GetFld())); pPostIt->SetVirtualPosSize(rEvt.GetMousePosPixel(),Size(180,70)); diff --git a/sw/source/ui/docvw/postit.cxx b/sw/source/ui/docvw/postit.cxx index 08cba6066892..fbcf8cfe4977 100644 --- a/sw/source/ui/docvw/postit.cxx +++ b/sw/source/ui/docvw/postit.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: postit.cxx,v $ - * $Revision: 1.10 $ + * $Revision: 1.8.42.11 $ * * This file is part of OpenOffice.org. * @@ -35,19 +35,15 @@ #include <popup.hrc> #include <docvw.hrc> +#include <app.hrc> #include <hintids.hxx> #include "viewopt.hxx" #include "cmdid.h" -#include <vcl/help.hxx> -#include <vcl/scrbar.hxx> -#include <vcl/button.hxx> -#include <vcl/svapp.hxx> -#include <vcl/gradient.hxx> #include <tools/poly.hxx> // Polygon -#include <vcl/salbtype.hxx> // FRound +#include <svx/postitem.hxx> #include <svx/fontitem.hxx> #include <svx/eeitem.hxx> #include <svx/fhgtitem.hxx> @@ -68,17 +64,20 @@ #include <svx/editstat.hxx> //EditEngine flags #include <svx/outliner.hxx> #include <svx/editeng.hxx> +#include <svx/editobj.hxx> #include <svx/unolingu.hxx> -#include <svtools/languageoptions.hxx> #include <svtools/langtab.hxx> #include <svtools/slstitm.hxx> #include <svtools/securityoptions.hxx> +#include <svtools/useroptions.hxx> +#include <svtools/languageoptions.hxx> #include <svtools/zforlist.hxx> #include <svtools/svmedit.hxx> #include <linguistic/lngprops.hxx> +#include <sfx2/request.hxx> #include <sfx2/viewfrm.hxx> #include <sfx2/bindings.hxx> #include <sfx2/dispatch.hxx> @@ -86,6 +85,12 @@ #include <vcl/vclenum.hxx> #include <vcl/edit.hxx> +#include <vcl/help.hxx> +#include <vcl/scrbar.hxx> +#include <vcl/button.hxx> +#include <vcl/svapp.hxx> +#include <vcl/gradient.hxx> +#include <vcl/salbtype.hxx> // FRound #include <basegfx/matrix/b2dhommatrix.hxx> #include <basegfx/tuple/b2dtuple.hxx> @@ -100,16 +105,20 @@ #include <shellres.hxx> #include <fmtfld.hxx> #include <wrtsh.hxx> +#include <textsh.hxx> #include <doc.hxx> #include <txtfld.hxx> #include <redline.hxx> #include <uitool.hxx> #include <SwUndoField.hxx> #include <editsh.hxx> +#include <swmodule.hxx> +#include <node.hxx> +#include <ndtxt.hxx> +#include <langhelper.hxx> using namespace ::com::sun::star; -#define ANKORLINE_WIDTH 1 #define METABUTTON_WIDTH 16 #define METABUTTON_HEIGHT 18 #define METABUTTON_AREA_WIDTH 30 @@ -119,6 +128,13 @@ using namespace ::com::sun::star; #define POSTIT_SHADOW_BRIGHT Color(180,180,180) #define POSTIT_SHADOW_DARK Color(83,83,83) +#define LINEBREAK rtl::OUString::createFromAscii("\n") +#define EMPTYSTRING rtl::OUString::createFromAscii("") + +TYPEINIT0(SwMarginWin); +TYPEINIT1(SwPostIt,SwMarginWin); +//TYPEINIT1(SwRedComment,SwMarginWin); + Color ColorFromAlphaColor(UINT8 aTransparency, Color &aFront, Color &aBack ) { return Color((UINT8)(aFront.GetRed() * aTransparency/(double)255 + aBack.GetRed() * (1-aTransparency/(double)255)), @@ -131,7 +147,7 @@ PostItTxt::PostItTxt(Window* pParent, WinBits nBits) : Window(pParent, nBits), m { SetHelpId(26276); AddEventListener( LINK( this, PostItTxt, WindowEventListener ) ); - mpPostIt = static_cast<SwPostIt*>(GetParent()); + mpMarginWin = static_cast<SwMarginWin*>(GetParent()); } PostItTxt::~PostItTxt() @@ -141,24 +157,24 @@ PostItTxt::~PostItTxt() void PostItTxt::GetFocus() { - BOOL bLockView = mpPostIt->DocView()->GetWrtShell().IsViewLocked(); - mpPostIt->DocView()->GetWrtShell().LockView( TRUE ); + BOOL bLockView = mpMarginWin->DocView()->GetWrtShell().IsViewLocked(); + mpMarginWin->DocView()->GetWrtShell().LockView( TRUE ); - if(mpPostIt && !mpPostIt->IsPreview()) - mpPostIt->Mgr()->SetActivePostIt(mpPostIt); + if(mpMarginWin && !mpMarginWin->IsPreview()) + mpMarginWin->Mgr()->SetActivePostIt(mpMarginWin); Window::GetFocus(); if (!mMouseOver) Invalidate(); - mpPostIt->DocView()->GetWrtShell().LockView( bLockView ); - mpPostIt->Mgr()->MakeVisible(mpPostIt); + mpMarginWin->DocView()->GetWrtShell().LockView( bLockView ); + mpMarginWin->Mgr()->MakeVisible(mpMarginWin); } void PostItTxt::LoseFocus() { // write the visible text back into the SwField - if ( mpPostIt ) - mpPostIt->UpdateData(); + if ( mpMarginWin ) + mpMarginWin->UpdateData(); Window::LoseFocus(); if (!mMouseOver) @@ -168,7 +184,7 @@ void PostItTxt::LoseFocus() void PostItTxt::RequestHelp(const HelpEvent &rEvt) { USHORT nResId = 0; - switch( mpPostIt->GetStatus() ) + switch( mpMarginWin->GetStatus() ) { case SwPostItHelper::INSERTED: nResId = STR_REDLINE_INSERT; break; case SwPostItHelper::DELETED: nResId = STR_REDLINE_DELETE; break; @@ -176,7 +192,7 @@ void PostItTxt::RequestHelp(const HelpEvent &rEvt) } SwContentAtPos aCntntAtPos( SwContentAtPos::SW_REDLINE ); - if ( nResId && mpPostIt->DocView()->GetWrtShell().GetContentAtPos( mpPostIt->GetAnkorRect().Pos(), aCntntAtPos ) ) + if ( nResId && mpMarginWin->DocView()->GetWrtShell().GetContentAtPos( mpMarginWin->GetAnkorRect().Pos(), aCntntAtPos ) ) { String sTxt; sTxt = SW_RESSTR( nResId ); @@ -194,17 +210,17 @@ void PostItTxt::Paint( const Rectangle& rRect) { if (mMouseOver || HasFocus()) DrawGradient(Rectangle(Point(0,0),PixelToLogic(GetSizePixel())), - Gradient(GRADIENT_LINEAR,mpPostIt->ColorDark(),mpPostIt->ColorDark())); + Gradient(GRADIENT_LINEAR,mpMarginWin->ColorDark(),mpMarginWin->ColorDark())); else DrawGradient(Rectangle(Point(0,0),PixelToLogic(GetSizePixel())), - Gradient(GRADIENT_LINEAR,mpPostIt->ColorLight(),mpPostIt->ColorDark())); + Gradient(GRADIENT_LINEAR,mpMarginWin->ColorLight(),mpMarginWin->ColorDark())); } mpOutlinerView->Paint( rRect ); - if (mpPostIt->GetStatus()==SwPostItHelper::DELETED) + if (mpMarginWin->GetStatus()==SwPostItHelper::DELETED) { - SetLineColor(mpPostIt->GetChangeColor()); + SetLineColor(static_cast<SwPostIt*>(mpMarginWin)->GetChangeColor()); DrawLine(PixelToLogic(GetPosPixel()),PixelToLogic(GetPosPixel()+Point(GetSizePixel().Width(),GetSizePixel().Height()))); DrawLine(PixelToLogic(GetPosPixel()+Point(GetSizePixel().Width(),0)),PixelToLogic(GetPosPixel()+Point(0,GetSizePixel().Height()))); } @@ -214,60 +230,45 @@ void PostItTxt::KeyInput( const KeyEvent& rKeyEvt ) { const KeyCode& rKeyCode = rKeyEvt.GetKeyCode(); USHORT nKey = rKeyCode.GetCode(); - SwView* pView = mpPostIt->DocView(); - - if ( (nKey== KEY_N) && rKeyCode.IsMod1() && rKeyCode.IsMod2()) - { - if ( mpPostIt->Mgr()->GetActivePostIt() == mpPostIt ) - mpPostIt->Mgr()->SetActivePostIt(0); - mpPostIt->SwitchToFieldPos(); - } - else + SwView* pView = mpMarginWin->DocView(); if ((rKeyCode.IsMod1() && rKeyCode.IsMod2()) && ((nKey == KEY_PAGEUP) || (nKey == KEY_PAGEDOWN))) - { - mpPostIt->SwitchToPostIt(nKey); - } + mpMarginWin->SwitchToPostIt(nKey); else if ((nKey == KEY_ESCAPE) || (rKeyCode.IsMod1() && ((nKey == KEY_PAGEUP) || (nKey == KEY_PAGEDOWN)))) - { - if ( mpPostIt->Mgr()->GetActivePostIt() == mpPostIt ) - mpPostIt->Mgr()->SetActivePostIt(0); - if (!mpPostIt->IsReadOnly() && (mpPostIt->GetStatus()!=SwPostItHelper::DELETED) && - mpPostIt->Engine()->GetEditEngine().GetText()==String(::rtl::OUString::createFromAscii(""))) - mpPostIt->Delete(); - else - mpPostIt->SwitchToFieldPos(); - } + mpMarginWin->SwitchToFieldPos(); else if (nKey == KEY_INSERT) { if (!rKeyCode.IsMod1() && !rKeyCode.IsMod2()) - mpPostIt->ToggleInsMode(); + mpMarginWin->ToggleInsMode(); } else { //let's make sure we see our note - mpPostIt->Mgr()->MakeVisible(mpPostIt); + mpMarginWin->Mgr()->MakeVisible(mpMarginWin); - long aOldHeight = mpPostIt->GetPostItTextHeight(); + long aOldHeight = mpMarginWin->GetPostItTextHeight(); bool bDone = false; /// HACK: need to switch off processing of Undo/Redo in Outliner if ( !( (nKey == KEY_Z || nKey == KEY_Y) && rKeyCode.IsMod1()) ) { - SwPostItHelper::SwLayoutStatus aStatus = mpPostIt->GetStatus(); + /* + SwPostItHelper::SwLayoutStatus aStatus = mpMarginWin->GetStatus(); if ( (aStatus!=SwPostItHelper::DELETED) || - ( (aStatus==SwPostItHelper::DELETED) && (!mpPostIt->Engine()->GetEditEngine().DoesKeyChangeText(rKeyEvt))) ) + ( (aStatus==SwPostItHelper::DELETED) && (!mpMarginWin->Engine()->GetEditEngine().DoesKeyChangeText(rKeyEvt))) ) + */ + bool bIsProtected = mpMarginWin->IsProtected(); + if (!bIsProtected || (bIsProtected && !mpMarginWin->Engine()->GetEditEngine().DoesKeyChangeText(rKeyEvt)) ) bDone = mpOutlinerView->PostKeyEvent( rKeyEvt ); } if (bDone) - mpPostIt->ResizeIfNeccessary(aOldHeight,mpPostIt->GetPostItTextHeight()); + mpMarginWin->ResizeIfNeccessary(aOldHeight,mpMarginWin->GetPostItTextHeight()); else { - // write back data first when saving or showing navigator - //otherwise new content could be lost - if ( (rKeyCode.IsMod1() && nKey== KEY_S) || (nKey==KEY_F5) ) - mpPostIt->UpdateData(); + // write back data first when showing navigator + if ( nKey==KEY_F5 ) + mpMarginWin->UpdateData(); if (!pView->KeyInput(rKeyEvt)) Window::KeyInput(rKeyEvt); } @@ -324,7 +325,7 @@ void PostItTxt::MouseButtonDown( const MouseEvent& rMEvt ) if ( pURL ) { mpOutlinerView->MouseButtonDown( rMEvt ); - SwWrtShell &rSh = mpPostIt->DocView()->GetWrtShell(); + SwWrtShell &rSh = mpMarginWin->DocView()->GetWrtShell(); String sURL( pURL->GetURL() ); String sTarget( pURL->GetTargetFrame() ); ::LoadURL( sURL, &rSh, URLLOAD_NOFILTER, &sTarget); @@ -337,7 +338,7 @@ void PostItTxt::MouseButtonDown( const MouseEvent& rMEvt ) GrabFocus(); if ( mpOutlinerView ) mpOutlinerView->MouseButtonDown( rMEvt ); - mpPostIt->DocView()->GetViewFrame()->GetBindings().InvalidateAll(FALSE); + mpMarginWin->DocView()->GetViewFrame()->GetBindings().InvalidateAll(FALSE); } void PostItTxt::MouseButtonUp( const MouseEvent& rMEvt ) @@ -348,14 +349,14 @@ void PostItTxt::MouseButtonUp( const MouseEvent& rMEvt ) IMPL_LINK(PostItTxt, OnlineSpellCallback, SpellCallbackInfo*, pInfo) { - if (mpPostIt && pInfo->nCommand == SPELLCMD_STARTSPELLDLG) - mpPostIt->DocView()->GetViewFrame()->GetDispatcher()->Execute( FN_SPELL_GRAMMAR_DIALOG, SFX_CALLMODE_ASYNCHRON); + if ( mpMarginWin && (pInfo->nCommand == SPELLCMD_STARTSPELLDLG) ) + mpMarginWin->DocView()->GetViewFrame()->GetDispatcher()->Execute( FN_SPELL_GRAMMAR_DIALOG, SFX_CALLMODE_ASYNCHRON); return 0; } IMPL_LINK( PostItTxt, Select, Menu*, pSelMenu ) { - mpPostIt->ExecuteCommand( pSelMenu->GetCurItemId() ); + mpMarginWin->ExecuteCommand( pSelMenu->GetCurItemId() ); return 0; } @@ -363,7 +364,8 @@ void PostItTxt::Command( const CommandEvent& rCEvt ) { if ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU ) { - if (!mpPostIt->IsReadOnly() && (mpPostIt->GetStatus()!=SwPostItHelper::DELETED) && + if (!mpMarginWin->IsProtected() && + //if (!mpMarginWin->IsReadOnly() && (mpMarginWin->GetStatus()!=SwPostItHelper::DELETED) && mpOutlinerView->IsWrongSpelledWordAtPos( rCEvt.GetMousePosPixel(),TRUE )) { Link aLink = LINK(this, PostItTxt, OnlineSpellCallback); @@ -371,10 +373,10 @@ void PostItTxt::Command( const CommandEvent& rCEvt ) } else { - SfxPopupMenuManager* aMgr = mpPostIt->DocView()->GetViewFrame()->GetDispatcher()->Popup(0, this,&rCEvt.GetMousePosPixel()); + SfxPopupMenuManager* aMgr = mpMarginWin->DocView()->GetViewFrame()->GetDispatcher()->Popup(0, this,&rCEvt.GetMousePosPixel()); XubString aText = ((PopupMenu*)aMgr->GetSVMenu())->GetItemText( FN_DELETE_NOTE_AUTHOR ); SwRewriter aRewriter; - aRewriter.AddRule(UNDO_ARG1, mpPostIt->GetAuthor()); + aRewriter.AddRule(UNDO_ARG1, mpMarginWin->GetAuthor()); aText = aRewriter.Apply(aText); ((PopupMenu*)aMgr->GetSVMenu())->SetItemText(FN_DELETE_NOTE_AUTHOR,aText); // SwPostItLinkForwarder_Impl aFwd( ((PopupMenu*)aMgr->GetSVMenu())->pSvMenu->GetSelectHdl(), mpPostIt ); @@ -396,34 +398,63 @@ void PostItTxt::Command( const CommandEvent& rCEvt ) else if (rCEvt.GetCommand() == COMMAND_WHEEL) { - if (mpPostIt->Scrollbar()->IsVisible()) + if (mpMarginWin->Scrollbar()->IsVisible()) { const CommandWheelData* pData = rCEvt.GetWheelData(); if (pData->IsShift() || pData->IsMod1() || pData->IsMod2()) { - mpPostIt->DocView()->HandleWheelCommands(rCEvt); + mpMarginWin->DocView()->HandleWheelCommands(rCEvt); } else { - HandleScrollCommand( rCEvt, 0 , mpPostIt->Scrollbar()); + HandleScrollCommand( rCEvt, 0 , mpMarginWin->Scrollbar()); /* long nLines = pData->GetNotchDelta() * (long)pData->GetScrollLines(); - if ( ((mpPostIt->Scrollbar()->GetRange().Min() == mpPostIt->Scrollbar()->GetThumbPos()) && (nLines > 0)) || - ( (mpPostIt->Scrollbar()->GetRange().Max() == mpPostIt->Scrollbar()->GetThumbPos()+mpPostIt->Scrollbar()->GetVisibleSize()) && (nLines < 0)) ) + if ( ((mpMarginWin->Scrollbar()->GetRange().Min() == mpMarginWin->Scrollbar()->GetThumbPos()) && (nLines > 0)) || + ( (mpMarginWin->Scrollbar()->GetRange().Max() == mpMarginWin->Scrollbar()->GetThumbPos()+mpMarginWin->Scrollbar()->GetVisibleSize()) && (nLines < 0)) ) { - mpPostIt->DocView()->HandleWheelCommands(rCEvt); + mpMarginWin->DocView()->HandleWheelCommands(rCEvt); } else { - HandleScrollCommand( rCEvt, 0 , mpPostIt->Scrollbar()); + HandleScrollCommand( rCEvt, 0 , mpMarginWin->Scrollbar()); } */ } } else { - mpPostIt->DocView()->HandleWheelCommands(rCEvt); + mpMarginWin->DocView()->HandleWheelCommands(rCEvt); + } + } + else + if (rCEvt.GetCommand() == COMMAND_SELECTIONCHANGE) + { + if ( mpOutlinerView ) + { + const CommandSelectionChangeData *pData = rCEvt.GetSelectionChangeData(); + ESelection aSelection = mpOutlinerView->GetEditView().GetSelection(); + aSelection.nStartPos = pData->GetStart(); + aSelection.nEndPos = pData->GetEnd(); + mpOutlinerView->GetEditView().SetSelection(aSelection); + } + } + else + if (rCEvt.GetCommand() == COMMAND_PREPARERECONVERSION) + { + if ( mpOutlinerView && mpOutlinerView->HasSelection() ) + { + EditEngine *aEditEngine = mpOutlinerView->GetEditView().GetEditEngine(); + ESelection aSelection = mpOutlinerView->GetEditView().GetSelection(); + aSelection.Adjust(); + if( aSelection.nStartPara != aSelection.nEndPara ) + { + xub_StrLen aParaLen = aEditEngine->GetTextLen( aSelection.nStartPara ); + aSelection.nEndPara = aSelection.nStartPara; + aSelection.nEndPos = aParaLen; + mpOutlinerView->GetEditView().SetSelection( aSelection ); + } } } else @@ -440,6 +471,40 @@ void PostItTxt::DataChanged( const DataChangedEvent& aData) Window::DataChanged( aData ); } +XubString PostItTxt::GetSurroundingText() const +{ + if( mpOutlinerView ) + { + EditEngine *aEditEngine = mpOutlinerView->GetEditView().GetEditEngine(); + if( mpOutlinerView->HasSelection() ) + return mpOutlinerView->GetSelected(); + else + { + ESelection aSelection = mpOutlinerView->GetEditView().GetSelection(); + XubString aStr = aEditEngine->GetText(aSelection.nStartPara); + return aStr; + } + } + else + return XubString::EmptyString(); +} + +Selection PostItTxt::GetSurroundingTextSelection() const +{ + if( mpOutlinerView ) + { + if( mpOutlinerView->HasSelection() ) + return Selection( 0, mpOutlinerView->GetSelected().Len() ); + else + { + ESelection aSelection = mpOutlinerView->GetEditView().GetSelection(); + return Selection( aSelection.nStartPos, aSelection.nEndPos ); + } + } + else + return Selection( 0, 0 ); +} + IMPL_LINK( PostItTxt, WindowEventListener, VclSimpleEvent*, pWinEvent ) { if ( pWinEvent && pWinEvent->ISA( VclWindowEvent ) ) @@ -453,22 +518,22 @@ IMPL_LINK( PostItTxt, WindowEventListener, VclSimpleEvent*, pWinEvent ) mMouseOver = true; if (!mbShowPopup && !HasFocus()) { - mpPostIt->SetShadowState(SS_VIEW); + mpMarginWin->SetViewState(SS_VIEW); Invalidate(); } } else if ( pMouseEvt->IsLeaveWindow()) { - if (mpPostIt->IsPreview()) + if (mpMarginWin->IsPreview()) { - //mpPostIt->doLazyDelete(); + //mpMarginWin->doLazyDelete(); } else { mMouseOver = false; if (!mbShowPopup && !HasFocus()) { - mpPostIt->SetShadowState(SS_NORMAL); + mpMarginWin->SetViewState(SS_NORMAL); Invalidate(); } } @@ -477,23 +542,23 @@ IMPL_LINK( PostItTxt, WindowEventListener, VclSimpleEvent*, pWinEvent ) } return sal_True; } - - -/******* SwPostIt **************************************/ -SwPostIt::SwPostIt( Window* pParent, WinBits nBits, SwFmtFld* aField,SwPostItMgr* aMgr,SwPostItBits aBits) : Window(pParent, nBits), +/************** SwMarginWin***********************************++*/ +SwMarginWin::SwMarginWin(Window* pParent, WinBits nBits,SwPostItMgr* aMgr,SwPostItBits aBits) +: Window(pParent, nBits), + mnEventId(0), mpOutlinerView(0), mpOutliner(0), mpPostItTxt(0), mpMeta(0), mpVScrollbar(0), - mpFmtFld(aField), - mpFld( static_cast<SwPostItField*>(aField->GetFld())), mpAnkor(0), mpShadow(0), mpMgr(aMgr), mbMeta(true), - mpButtonPopup(new PopupMenu(SW_RES(MN_ANNOTATION_BUTTON))), - nFlags(aBits) + nFlags(aBits), + mbMouseOverButton(false), + mpButtonPopup(0), + mbIsFollow(false) { SwEditWin* aWin = static_cast<SwEditWin*>(GetParent()); mpView = &aWin->GetView(); @@ -507,38 +572,9 @@ SwPostIt::SwPostIt( Window* pParent, WinBits nBits, SwFmtFld* aField,SwPostItMgr mpShadow->setVisible(false); pOverlayManager->add(*mpShadow); } - - InitControls(); - SetPostItText(); } -void SwPostIt::SetPostItText() -{ - // get text from SwPostItField and insert into our textview - mpOutliner->SetModifyHdl( Link() ); - mpOutliner->EnableUndo( FALSE ); - mpFld = static_cast<SwPostItField*>(mpFmtFld->GetFld()); - if( mpFld->GetTextObject() ) - mpOutliner->SetText( *mpFld->GetTextObject() ); - else - { - mpOutliner->Clear(); - SfxItemSet item( mpView->GetDocShell()->GetPool() ); - item.Put(SvxFontHeightItem(200,100,EE_CHAR_FONTHEIGHT)); - item.Put(SvxFontItem(FAMILY_SWISS,GetSettings().GetStyleSettings().GetFieldFont().GetName(), - rtl::OUString::createFromAscii(""),PITCH_DONTKNOW,RTL_TEXTENCODING_DONTKNOW,EE_CHAR_FONTINFO)); - mpOutlinerView->SetAttribs(item); - mpOutlinerView->InsertText(mpFld->GetPar2(),false); - } - - mpOutliner->ClearModifyFlag(); - mpOutliner->GetUndoManager().Clear(); - mpOutliner->EnableUndo( TRUE ); - mpOutliner->SetModifyHdl( LINK( this, SwPostIt, ModifyHdl ) ); - Invalidate(); -} - -SwPostIt::~SwPostIt() +SwMarginWin::~SwMarginWin() { if (mpOutlinerView) { @@ -589,9 +625,12 @@ SwPostIt::~SwPostIt() { delete mpButtonPopup; } + + if (mnEventId) + Application::RemoveUserEvent( mnEventId ); } -void SwPostIt::Paint( const Rectangle& rRect) +void SwMarginWin::Paint( const Rectangle& rRect) { Window::Paint(rRect); @@ -614,7 +653,11 @@ void SwPostIt::Paint( const Rectangle& rRect) else { //draw button - Gradient aGradient(GRADIENT_LINEAR,ColorFromAlphaColor(15,mColorAnkor,mColorDark),ColorFromAlphaColor(80,mColorAnkor,mColorDark)); + Gradient aGradient; + if (mbMouseOverButton) + aGradient = Gradient(GRADIENT_LINEAR,ColorFromAlphaColor(80,mColorAnkor,mColorDark),ColorFromAlphaColor(15,mColorAnkor,mColorDark)); + else + aGradient = Gradient(GRADIENT_LINEAR,ColorFromAlphaColor(15,mColorAnkor,mColorDark),ColorFromAlphaColor(80,mColorAnkor,mColorDark)); DrawGradient(mRectMetaButton,aGradient); //draw rect around button SetFillColor(); @@ -647,7 +690,7 @@ void SwPostIt::Paint( const Rectangle& rRect) } } -void SwPostIt::SetPosSizePixelRect(long nX, long nY,long nWidth, long nHeight,const SwRect &aRect, const long aPageBorder) +void SwMarginWin::SetPosSizePixelRect(long nX, long nY,long nWidth, long nHeight,const SwRect &aRect, const long aPageBorder) { mbMeta = true; mPosSize = Rectangle(Point(nX,nY),Size(nWidth,nHeight)); @@ -655,22 +698,22 @@ void SwPostIt::SetPosSizePixelRect(long nX, long nY,long nWidth, long nHeight,co mPageBorder = aPageBorder; } -void SwPostIt::SetSize( const Size& rNewSize ) +void SwMarginWin::SetSize( const Size& rNewSize ) { mPosSize.SetSize(rNewSize); } -void SwPostIt::SetVirtualPosSize( const Point& aPoint, const Size& aSize) +void SwMarginWin::SetVirtualPosSize( const Point& aPoint, const Size& aSize) { mPosSize = Rectangle(aPoint,aSize); } -void SwPostIt::TranslateTopPosition(const long aAmount) +void SwMarginWin::TranslateTopPosition(const long aAmount) { mPosSize.Move(0,aAmount); } -void SwPostIt::ShowAnkorOnly(const Point &aPoint) +void SwMarginWin::ShowAnkorOnly(const Point &aPoint) { HideNote(); SetPosAndSize(); @@ -680,12 +723,13 @@ void SwPostIt::ShowAnkorOnly(const Point &aPoint) mpAnkor->SetSeventhPosition(basegfx::B2DPoint(aPoint.X(),aPoint.Y())); mpAnkor->setVisible(true); } + if (mpShadow) + mpShadow->setVisible(false); } -void SwPostIt::InitControls() +void SwMarginWin::InitControls() { // actual window which holds the user text - //mpPostItTxt = new PostItTxt(this, 0x00000100); mpPostItTxt = new PostItTxt(this, 0); mpPostItTxt->SetPointer(Pointer(POINTER_TEXT)); @@ -708,8 +752,6 @@ void SwPostIt::InitControls() aSettings.SetStyleSettings(aStyleSettings); mpMeta->SetSettings(aSettings); - CheckMetaText(); - SwDocShell* aShell = mpView->GetDocShell(); mpOutliner = new Outliner(&aShell->GetPool(),OUTLINERMODE_TEXTOBJECT); aShell->GetDoc()->SetCalcFieldValueHdl( mpOutliner ); @@ -732,7 +774,7 @@ void SwPostIt::InitControls() SfxItemSet item(aShell->GetPool()); item.Put(SvxFontHeightItem(200,100,EE_CHAR_FONTHEIGHT)); item.Put(SvxFontItem(FAMILY_SWISS,GetSettings().GetStyleSettings().GetFieldFont().GetName(), - rtl::OUString::createFromAscii(""),PITCH_DONTKNOW,RTL_TEXTENCODING_DONTKNOW,EE_CHAR_FONTINFO)); + EMPTYSTRING,PITCH_DONTKNOW,RTL_TEXTENCODING_DONTKNOW,EE_CHAR_FONTINFO)); mpOutlinerView->SetAttribs(item); // TODO: ?? @@ -743,12 +785,10 @@ void SwPostIt::InitControls() mpVScrollbar = new ScrollBar(this, WB_3DLOOK |WB_VSCROLL|WB_DRAG); mpVScrollbar->EnableNativeWidget(false); mpVScrollbar->EnableRTL( false ); - mpVScrollbar->SetScrollHdl(LINK(this, SwPostIt, ScrollHdl)); + mpVScrollbar->SetScrollHdl(LINK(this, SwMarginWin, ScrollHdl)); mpVScrollbar->EnableDrag(); mpVScrollbar->AddEventListener( LINK( mpPostItTxt, PostItTxt, WindowEventListener ) ); - mpButtonPopup->SetMenuFlags(MENU_FLAG_ALWAYSSHOWDISABLEDENTRIES); - const SwViewOption* pVOpt = mpView->GetWrtShellPtr()->GetViewOptions(); ULONG nCntrl = mpOutliner->GetControlWord(); // TODO: crash when AUTOCOMPLETE enabled @@ -763,64 +803,49 @@ void SwPostIt::InitControls() nCntrl &= ~EE_CNTRL_ONLINESPELLING; mpOutliner->SetControlWord(nCntrl); - XubString aText = mpButtonPopup->GetItemText( FN_DELETE_NOTE_AUTHOR ); - SwRewriter aRewriter; - aRewriter.AddRule(UNDO_ARG1,GetAuthor()); - aText = aRewriter.Apply(aText); - mpButtonPopup->SetItemText(FN_DELETE_NOTE_AUTHOR,aText); - - // TODO: why does this not work? - //mpOutliner->SetDefaultLanguage(mpFld->GetLanguage()); + sal_uInt16 aIndex = SW_MOD()->InsertRedlineAuthor(GetAuthor()); + SetColor(mpMgr->GetColorDark(aIndex),mpMgr->GetColorLight(aIndex),mpMgr->GetColorAnkor(aIndex)); - // set initial language for outliner - USHORT nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( mpFld->GetLanguage() ); - USHORT nLangWhichId = 0; - switch (nScriptType) - { - case SCRIPTTYPE_LATIN : nLangWhichId = EE_CHAR_LANGUAGE ; break; - case SCRIPTTYPE_ASIAN : nLangWhichId = EE_CHAR_LANGUAGE_CJK; break; - case SCRIPTTYPE_COMPLEX : nLangWhichId = EE_CHAR_LANGUAGE_CTL; break; - } - SetLanguage(SvxLanguageItem(mpFld->GetLanguage(),nLangWhichId)); - mpOutlinerView->StartSpeller(); + CheckMetaText(); + SetPopup(); + SetPostItText(); + SetLanguage(GetLanguage()); + View()->StartSpeller(); mpMeta->Show(); mpVScrollbar->Show(); mpPostItTxt->Show(); } -void SwPostIt::CheckMetaText() +void SwMarginWin::CheckMetaText() { - /* - String sDateTime; - SvNumberFormatter* pNumFormatter = mpView->GetDocShell()->GetDoc()->GetNumberFormatter(); - const ULONG nFormatDate = pNumFormatter->GetStandardFormat( NUMBERFORMAT_DATETIME , Application::GetSettings().GetLanguage()); - const DateTime aDateTime( mpFld->GetDate(), mpFld->GetTime()); - pNumFormatter->GetOutputString( aDateTime - DateTime( *pNumFormatter->GetNullDate()), nFormatDate, sDateTime, &pColor ); - */ const LocaleDataWrapper& rLocalData = SvtSysLocale().GetLocaleData(); - String sMeta = mpFld->GetPar1(); + String sMeta = GetAuthor(); + if (sMeta==String(EMPTYSTRING)) + sMeta = String(SW_RES(STR_NOAUTHOR)); if (sMeta.Len() > 22) { sMeta.Erase(20); sMeta = sMeta + rtl::OUString::createFromAscii("..."); } - bool bValidTimeStamp = true; - if (mpFld->GetDate()==Date()) - sMeta = sMeta + rtl::OUString::createFromAscii("\n") + String(SW_RES(STR_POSTIT_TODAY)); - else if (mpFld->GetDate()==Date(Date()-1)) - sMeta = sMeta + rtl::OUString::createFromAscii("\n") + String(SW_RES(STR_POSTIT_YESTERDAY)); - else if (mpFld->GetDate().IsValid()) - sMeta = sMeta + rtl::OUString::createFromAscii("\n") + rLocalData.getDate(mpFld->GetDate()); + Date aDate = GetDate(); + if (aDate==Date()) + sMeta = sMeta + LINEBREAK + String(SW_RES(STR_POSTIT_TODAY)); else - bValidTimeStamp = false; - if (bValidTimeStamp) - sMeta = sMeta + rtl::OUString::createFromAscii(" ") + rLocalData.getTime(mpFld->GetTime(), false); + if (aDate == Date(Date()-1)) + sMeta = sMeta + LINEBREAK + String(SW_RES(STR_POSTIT_YESTERDAY)); + else + if (aDate.IsValid() ) + sMeta = sMeta + LINEBREAK + rLocalData.getDate(aDate); + else + sMeta = sMeta + LINEBREAK + String(SW_RES(STR_NODATE)); + if (GetTime()!=0) + sMeta = sMeta + rtl::OUString::createFromAscii(" ") + rLocalData.getTime( GetTime(),false ); if (mpMeta->GetText() != sMeta) mpMeta->SetText(sMeta); } -void SwPostIt::Rescale() +void SwMarginWin::Rescale() { MapMode aMode = GetParent()->GetMapMode(); aMode.SetOrigin( Point() ); @@ -839,7 +864,7 @@ void SwPostIt::Rescale() } } -void SwPostIt::SetPosAndSize() +void SwMarginWin::SetPosAndSize() { bool bChange = false; @@ -914,9 +939,20 @@ void SwPostIt::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 + { + mpAnkor->SetAnkorState(AS_ALL); + SwMarginWin* pWin = GetTopReplyNote(); + if (IsFollow() && pWin ) + pWin->Ankor()->SetAnkorState(AS_END); + } } -void SwPostIt::DoResize() +void SwMarginWin::DoResize() { long aTextHeight = LogicToPixel( mpOutliner->CalcTextSize()).Height(); unsigned long aWidth = GetSizePixel().Width(); @@ -926,7 +962,7 @@ void SwPostIt::DoResize() { aHeight -= GetMetaHeight(); mpMeta->Show(); - mpPostItTxt->SetQuickHelpText(rtl::OUString::createFromAscii("")); + mpPostItTxt->SetQuickHelpText(EMPTYSTRING); } else { @@ -991,7 +1027,7 @@ void SwPostIt::DoResize() Size( METABUTTON_WIDTH*fx.GetNumerator()/fx.GetDenominator(), METABUTTON_HEIGHT*fy.GetNumerator()/fy.GetDenominator() ) ) ); } -void SwPostIt::SetSizePixel( const Size& rNewSize ) +void SwMarginWin::SetSizePixel( const Size& rNewSize ) { Window::SetSizePixel(rNewSize); @@ -1003,12 +1039,12 @@ void SwPostIt::SetSizePixel( const Size& rNewSize ) } } -void SwPostIt::SetScrollbar() +void SwMarginWin::SetScrollbar() { mpVScrollbar->SetThumbPos( mpOutlinerView->GetVisArea().Top()+ mpOutlinerView->GetEditView().GetCursor()->GetOffsetY()); } -void SwPostIt::ResizeIfNeccessary(long aOldHeight, long aNewHeight) +void SwMarginWin::ResizeIfNeccessary(long aOldHeight, long aNewHeight) { if (aOldHeight != aNewHeight) { @@ -1029,16 +1065,15 @@ void SwPostIt::ResizeIfNeccessary(long aOldHeight, long aNewHeight) else { if (GetSizePixel().Height() != GetMinimumSizeWithoutMeta() + GetMetaHeight()) - { SetSizePixel(Size(GetSizePixel().Width(),GetMinimumSizeWithoutMeta() + GetMetaHeight())); - DoResize(); - Invalidate(); - } + DoResize(); + Invalidate(); } } else { - SetScrollbar(); + DoResize(); + Invalidate(); } } else @@ -1047,7 +1082,7 @@ void SwPostIt::ResizeIfNeccessary(long aOldHeight, long aNewHeight) } } -void SwPostIt::SetColor(Color aColorDark,Color aColorLight, Color aColorAnkor) +void SwMarginWin::SetColor(Color aColorDark,Color aColorLight, Color aColorAnkor) { mColorDark = aColorDark; mColorLight = aColorLight; @@ -1078,104 +1113,94 @@ void SwPostIt::SetColor(Color aColorDark,Color aColorLight, Color aColorAnkor) } } -void SwPostIt::SetChangeTracking(SwPostItHelper::SwLayoutStatus& aStatus,Color aColor) -{ - if ( (mStatus != aStatus) || (mChangeColor != aColor) ) - { - mStatus = aStatus; - mChangeColor = aColor; - Invalidate(); - } -} - -void SwPostIt::SetMarginSide(bool aMarginSide) +void SwMarginWin::SetMarginSide(bool aMarginSide) { mbMarginSide = aMarginSide; } -void SwPostIt::SetReadonly(BOOL bSet) +void SwMarginWin::SetReadonly(BOOL bSet) { mbReadonly = bSet; View()->SetReadOnly(bSet); } -void SwPostIt::SetLanguage(const SvxLanguageItem aNewItem) +void SwMarginWin::SetLanguage(const SvxLanguageItem aNewItem) { - mpOutliner->SetModifyHdl( Link() ); - ESelection aOld = mpOutlinerView->GetSelection(); + Engine()->SetModifyHdl( Link() ); + ESelection aOld = View()->GetSelection(); - ESelection aNewSelection( 0, 0, (USHORT)mpOutliner->GetParagraphCount()-1, USHRT_MAX ); - mpOutlinerView->SetSelection( aNewSelection ); - SfxItemSet aEditAttr(mpOutlinerView->GetAttribs()); + ESelection aNewSelection( 0, 0, (USHORT)Engine()->GetParagraphCount()-1, USHRT_MAX ); + View()->SetSelection( aNewSelection ); + SfxItemSet aEditAttr(View()->GetAttribs()); aEditAttr.Put(aNewItem); - mpOutlinerView->SetAttribs( aEditAttr ); + View()->SetAttribs( aEditAttr ); - mpOutlinerView->SetSelection(aOld); - mpOutliner->SetModifyHdl( LINK( this, SwPostIt, ModifyHdl ) ); + View()->SetSelection(aOld); + Engine()->SetModifyHdl( LINK( this, SwPostIt, ModifyHdl ) ); - const SwViewOption* pVOpt = mpView->GetWrtShellPtr()->GetViewOptions(); - ULONG nCntrl = mpOutliner->GetControlWord(); + const SwViewOption* pVOpt = DocView()->GetWrtShellPtr()->GetViewOptions(); + ULONG nCntrl = Engine()->GetControlWord(); // turn off if (!pVOpt->IsOnlineSpell()) nCntrl &= ~EE_CNTRL_ONLINESPELLING; else nCntrl &= ~EE_CNTRL_ONLINESPELLING; - mpOutliner->SetControlWord(nCntrl); + Engine()->SetControlWord(nCntrl); //turn back on if (pVOpt->IsOnlineSpell()) nCntrl |= EE_CNTRL_ONLINESPELLING; else nCntrl &= ~EE_CNTRL_ONLINESPELLING; - mpOutliner->SetControlWord(nCntrl); + Engine()->SetControlWord(nCntrl); - mpOutliner->CompleteOnlineSpelling(); + Engine()->CompleteOnlineSpelling(); Invalidate(); } -void SwPostIt::DataChanged( const DataChangedEvent& aEvent) +void SwMarginWin::DataChanged( const DataChangedEvent& aEvent) { Window::DataChanged( aEvent ); } -void SwPostIt::GetFocus() +void SwMarginWin::GetFocus() { if (mpPostItTxt) mpPostItTxt->GrabFocus(); } -void SwPostIt::LoseFocus() +void SwMarginWin::LoseFocus() { } -void SwPostIt::ShowNote() +void SwMarginWin::ShowNote() { SetPosAndSize(); if (!IsVisible()) Window::Show(); - if (mpAnkor) - mpAnkor->setVisible(true); - if (mpShadow) + if (mpAnkor && !mpShadow->isVisible()) mpShadow->setVisible(true); + if (mpAnkor && !mpAnkor->isVisible()) + mpAnkor->setVisible(true); } -void SwPostIt::HideNote() +void SwMarginWin::HideNote() { if (IsVisible()) Window::Hide(); - if (mpAnkor) + if (mpAnkor && mpAnkor->isVisible()) mpAnkor->setVisible(false); - if (mpShadow) + if (mpShadow && mpShadow->isVisible()) mpShadow->setVisible(false); } -void SwPostIt::ActivatePostIt() +void SwMarginWin::ActivatePostIt() { mpOutliner->ClearModifyFlag(); mpOutliner->GetUndoManager().Clear(); CheckMetaText(); - SetShadowState(SS_EDIT); + SetViewState(SS_EDIT); View()->ShowCursor(); mpOutlinerView->GetEditView().SetInsertMode(mpView->GetWrtShellPtr()->IsInsMode()); @@ -1186,7 +1211,7 @@ void SwPostIt::ActivatePostIt() // mpPostItTxt->SetBackground(Wallpaper(mColorDark)); } -void SwPostIt::DeactivatePostIt() +void SwMarginWin::DeactivatePostIt() { // remove selection, #i87073# if (View()->GetEditView().HasSelection()) @@ -1199,7 +1224,7 @@ void SwPostIt::DeactivatePostIt() mpOutliner->CompleteOnlineSpelling(); - SetShadowState(SS_NORMAL); + SetViewState(SS_NORMAL); // write the visible text back into the SwField UpdateData(); @@ -1207,187 +1232,191 @@ void SwPostIt::DeactivatePostIt() View()->SetBackgroundColor(COL_TRANSPARENT); //mpPostItTxt->SetBackground(Gradient(GRADIENT_LINEAR,mColorLight,mColorDark)); + + if ( !IsProtected() && + //if (!IsReadOnly() && (GetStatus()!=SwPostItHelper::DELETED) && + Engine()->GetEditEngine().GetText()==String(EMPTYSTRING) ) + mnEventId = Application::PostUserEvent( LINK( this, SwMarginWin, DeleteHdl), 0 ); } -void SwPostIt::UpdateData() +void SwMarginWin::ToggleInsMode() { - if ( mpOutliner->IsModified() ) + if (!mpView->GetWrtShell().IsRedlineOn()) { - SwPosition * pPos = mpFmtFld->GetTxtFld()->GetPosition(); - if ( pPos ) - { - SwField* pOldField = mpFld->Copy(); - mpFld->SetPar2(mpOutliner->GetEditEngine().GetText()); - mpFld->SetTextObject(mpOutliner->CreateParaObject()); - mpView->GetDocShell()->GetDoc()->AppendUndo(new SwUndoFieldFromDoc(*pPos, *pOldField, *mpFld, 0, true)); - delete pOldField; - delete pPos; - // so we get a new layout of notes (ankor position is still the same and we would otherwise not get one) - mpMgr->SetLayout(); - mpView->GetDocShell()->SetModified(); - } + //change outliner + mpOutlinerView->GetEditView().SetInsertMode(!mpOutlinerView->GetEditView().IsInsertMode()); + //change documnet + mpView->GetWrtShell().ToggleInsMode(); + //update statusbar + SfxBindings &rBnd = mpView->GetViewFrame()->GetBindings(); + rBnd.Invalidate(SID_ATTR_INSERT); + rBnd.Update(SID_ATTR_INSERT); } - mpOutliner->ClearModifyFlag(); - mpOutliner->GetUndoManager().Clear(); } -void SwPostIt::ToggleInsMode() +void SwMarginWin::ExecuteCommand(USHORT nSlot) { - //change outliner - mpOutlinerView->GetEditView().SetInsertMode(!mpOutlinerView->GetEditView().IsInsertMode()); - //change documnet - mpView->GetWrtShell().ToggleInsMode(); - //update statusbar - SfxBindings &rBnd = mpView->GetViewFrame()->GetBindings(); - rBnd.Invalidate(SID_ATTR_INSERT); - rBnd.Update(SID_ATTR_INSERT); + switch (nSlot) + { + case FN_POSTIT: + case FN_REPLY: + { + // if this note is empty, it will be deleted once losing the focus, so no reply, but only a new note + // will be created + SwView* pView = DocView(); + if (Engine()->GetEditEngine().GetText() != String(EMPTYSTRING)) + { + OutlinerParaObject* pPara = new OutlinerParaObject(*View()->GetEditView().CreateTextObject()); + Mgr()->RegisterAnswer(pPara); + } + if (Mgr()->GetActivePostIt()) + Mgr()->SetActivePostIt(0); + SwitchToFieldPos(); + pView->GetViewFrame()->GetDispatcher()->Execute(FN_POSTIT); + break; + } + case FN_DELETE_COMMENT: + case FN_DELETE_NOTE: + + //Delete(); // do not kill the parent of our open popup menu + mnEventId = Application::PostUserEvent( LINK( this, SwMarginWin, DeleteHdl), 0 ); + break; + /* + case FN_HIDE_NOTE: + if ( Mgr()->GetActivePostIt() == this ) + { + Mgr()->SetActivePostIt(0); + // put the cursor back into the document + SwitchToFieldPos(); + } + Mgr()->Hide(mpFld); + break; + */ + case FN_DELETE_ALL_NOTES: + case FN_HIDE_ALL_NOTES: + // not possible as slot as this would require that "this" is the active postit + DocView()->GetViewFrame()->GetBindings().Execute( nSlot, 0, 0, SFX_CALLMODE_ASYNCHRON ); + break; + case FN_DELETE_NOTE_AUTHOR: + case FN_HIDE_NOTE_AUTHOR: + { + // not possible as slot as this would require that "this" is the active postit + SfxStringItem aItem( nSlot, GetAuthor() ); + const SfxPoolItem* aItems[2]; + aItems[0] = &aItem; + aItems[1] = 0; + DocView()->GetViewFrame()->GetBindings().Execute( nSlot, aItems, 0, SFX_CALLMODE_ASYNCHRON ); + } + default: + mpView->GetViewFrame()->GetBindings().Execute( nSlot ); + break; + } } -void SwPostIt::Delete() +bool SwMarginWin::CalcFollow() { - if ( Mgr()->GetActivePostIt() == this) - Mgr()->SetActivePostIt(0); - // we delete the field directly, the Mgr cleans up the PostIt by listening - mpView->GetWrtShellPtr()->GotoField(*mpFmtFld); - mpView->GetWrtShellPtr()->DelRight(); + return false; } -SwEditWin* SwPostIt::EditWin() +SwEditWin* SwMarginWin::EditWin() { return &mpView->GetEditWin(); } -String SwPostIt::GetAuthor() const +String SwPostIt::GetAuthor() { return mpFld->GetPar1(); } -long SwPostIt::GetPostItTextHeight() +Date SwPostIt::GetDate() { - return mpOutliner ? LogicToPixel(mpOutliner->CalcTextSize()).Height() : 0; + return mpFld->GetDate(); } -/* -void SwPostIt::SwitchToPostIt(bool aDirection) +Time SwPostIt::GetTime() { - if (aDirection) - SwitchToPostIt(KEY_PAGEDOWN); - else - SwitchToPostIt(KEY_PAGEUP); + return mpFld->GetTime(); } -*/ -void SwPostIt::SwitchToPostIt(USHORT aDirection) + +long SwMarginWin::GetPostItTextHeight() +{ + return mpOutliner ? LogicToPixel(mpOutliner->CalcTextSize()).Height() : 0; +} + +void SwMarginWin::SwitchToPostIt(USHORT aDirection) { if (mpMgr) { - SwPostIt* pPostIt = mpMgr->GetNextPostIt(aDirection, this); + SwMarginWin* pPostIt = mpMgr->GetNextPostIt(aDirection, this); if (pPostIt) pPostIt->GrabFocus(); } } -void SwPostIt::MouseButtonDown( const MouseEvent& rMEvt ) +void SwMarginWin::MouseButtonDown( const MouseEvent& /*rMEvt */) { - if (mRectMetaButton.IsInside(PixelToLogic(rMEvt.GetPosPixel())) && rMEvt.IsLeft()) +} + +void SwMarginWin::MouseMove( const MouseEvent& rMEvt ) +{ + if (mRectMetaButton.IsInside(PixelToLogic(rMEvt.GetPosPixel()))) { - if (IsPreview()) + if (!mbMouseOverButton) { - doLazyDelete(); - if (mpMgr) - { - SwPostIt* pPostIt = mpMgr->GetPostIt(mpFmtFld); - if (pPostIt) - { - pPostIt->GrabFocus(); - mpMgr->MakeVisible(pPostIt); - } - } - + Invalidate(mRectMetaButton); + mbMouseOverButton = true; } - else + } + else + { + if (mbMouseOverButton) { - if ( mbReadonly ) - { - mpButtonPopup->EnableItem(FN_DELETE_NOTE,false); - mpButtonPopup->EnableItem(FN_DELETE_NOTE_AUTHOR,false); - mpButtonPopup->EnableItem(FN_DELETE_ALL_NOTES,false); - } - else - { - if (mStatus==SwPostItHelper::DELETED) - mpButtonPopup->EnableItem(FN_DELETE_NOTE,false); - else - mpButtonPopup->EnableItem(FN_DELETE_NOTE,true); - mpButtonPopup->EnableItem(FN_DELETE_NOTE_AUTHOR,true); - mpButtonPopup->EnableItem(FN_DELETE_ALL_NOTES,true); - } - - ExecuteCommand( mpButtonPopup->Execute( this,Rectangle(LogicToPixel(mRectMetaButton.BottomLeft()),LogicToPixel(mRectMetaButton.BottomLeft())),POPUPMENU_EXECUTE_DOWN | POPUPMENU_NOMOUSEUPCLOSE) ); + Invalidate(mRectMetaButton); + mbMouseOverButton = false; } } } -void SwPostIt::ExecuteCommand(USHORT nSlot) +void SwMarginWin::Delete() { - switch (nSlot) + if ( Mgr()->GetActivePostIt() == this) { - case FN_DELETE_NOTE: - Delete(); - break; - case FN_HIDE_NOTE: - if ( mpMgr->GetActivePostIt() == this ) - { - mpMgr->SetActivePostIt(0); - // put the cursor back into the document - SwitchToFieldPos(); - } - mpMgr->Hide(mpFld); - break; - case FN_DELETE_ALL_NOTES: - case FN_HIDE_ALL_NOTES: - // not possible as slot as this would require that "this" is the active postit - mpView->GetViewFrame()->GetBindings().Execute( nSlot, 0, 0, SFX_CALLMODE_ASYNCHRON ); - break; - case FN_DELETE_NOTE_AUTHOR: - case FN_HIDE_NOTE_AUTHOR: + Mgr()->SetActivePostIt(0); + // if the note is empty, the previous line will send a delete event, but we are already there + if (mnEventId) { - // not possible as slot as this would require that "this" is the active postit - SfxStringItem aItem( nSlot, mpFld->GetPar1() ); - const SfxPoolItem* aItems[2]; - aItems[0] = &aItem; - aItems[1] = 0; - mpView->GetViewFrame()->GetBindings().Execute( nSlot, aItems, 0, SFX_CALLMODE_ASYNCHRON ); + Application::RemoveUserEvent( mnEventId ); + mnEventId = 0; } - default: - mpView->GetViewFrame()->GetBindings().Execute( nSlot ); - break; } } -void SwPostIt::SwitchToFieldPos(bool bAfter) +IMPL_LINK(SwMarginWin, ScrollHdl, ScrollBar*, pScroll) { - mpView->GetDocShell()->GetWrtShell()->GotoField(*mpFmtFld); - if (bAfter) - mpView->GetDocShell()->GetWrtShell()->SwCrsrShell::Right(1, 0, FALSE); - GrabFocusToDocument(); + long nDiff = View()->GetEditView().GetVisArea().Top() - pScroll->GetThumbPos(); + View()->Scroll( 0, nDiff ); + return 0; } -IMPL_LINK(SwPostIt, ScrollHdl, ScrollBar*, pScroll) +IMPL_LINK(SwMarginWin, ModifyHdl, void*, pVoid) { - long nDiff = View()->GetEditView().GetVisArea().Top() - pScroll->GetThumbPos(); - View()->Scroll( 0, nDiff ); + // no warnings, please + pVoid=0; + DocView()->GetDocShell()->SetModified(sal_True); return 0; } -IMPL_LINK(SwPostIt, ModifyHdl, void*, pVoid) +IMPL_LINK(SwMarginWin, DeleteHdl, void*, pVoid) { // no warnings, please pVoid=0; - mpView->GetDocShell()->SetModified(sal_True); + mnEventId = 0; + Delete(); return 0; } -void SwPostIt::ResetAttributes() + +void SwMarginWin::ResetAttributes() { mpOutlinerView->RemoveAttribsKeepLanguages(TRUE); mpOutliner->RemoveFields(TRUE); @@ -1396,12 +1425,12 @@ void SwPostIt::ResetAttributes() mpOutlinerView->SetAttribs(aSet); } -sal_Int32 SwPostIt::GetScrollbarWidth() +sal_Int32 SwMarginWin::GetScrollbarWidth() { return mpView->GetWrtShell().GetViewOptions()->GetZoom() / 10; } -sal_Int32 SwPostIt::GetMetaButtonAreaWidth() +sal_Int32 SwMarginWin::GetMetaButtonAreaWidth() { const Fraction& f( GetMapMode().GetScaleX() ); if (IsPreview()) @@ -1410,24 +1439,24 @@ sal_Int32 SwPostIt::GetMetaButtonAreaWidth() return METABUTTON_AREA_WIDTH * f.GetNumerator() / f.GetDenominator(); } -sal_Int32 SwPostIt::GetMetaHeight() +sal_Int32 SwMarginWin::GetMetaHeight() { const Fraction& f( GetMapMode().GetScaleY() ); return POSTIT_META_HEIGHT * f.GetNumerator() / f.GetDenominator(); } -sal_Int32 SwPostIt::GetMinimumSizeWithMeta() +sal_Int32 SwMarginWin::GetMinimumSizeWithMeta() { return mpMgr->GetMinimumSizeWithMeta(); } -sal_Int32 SwPostIt::GetMinimumSizeWithoutMeta() +sal_Int32 SwMarginWin::GetMinimumSizeWithoutMeta() { const Fraction& f( GetMapMode().GetScaleY() ); return POSTIT_MINIMUMSIZE_WITHOUT_META * f.GetNumerator() / f.GetDenominator(); } -void SwPostIt::SetSpellChecking() +void SwMarginWin::SetSpellChecking() { const SwViewOption* pVOpt = mpView->GetWrtShellPtr()->GetViewOptions(); ULONG nCntrl = mpOutliner->GetControlWord(); @@ -1441,16 +1470,22 @@ void SwPostIt::SetSpellChecking() Invalidate(); } -void SwPostIt::SetShadowState(ShadowState bState) +void SwMarginWin::SetViewState(ShadowState bState) { switch (bState) { case SS_EDIT: { - if ( Ankor() ) - Ankor()->SetLineInfo(LineInfo(LINE_SOLID,ANKORLINE_WIDTH*15)); - if ( Shadow() ) - Shadow()->SetShadowState(SS_EDIT); + if (mpAnkor) + { + mpAnkor->SetAnkorState(AS_ALL); + SwMarginWin* pWin = GetTopReplyNote(); + if (IsFollow() && pWin) + pWin->Ankor()->SetAnkorState(AS_END); + mpAnkor->SetLineInfo(LineInfo(LINE_SOLID,ANKORLINE_WIDTH*15)); + } + if (mpShadow) + mpShadow->SetShadowState(bState); break; } case SS_VIEW: @@ -1458,24 +1493,466 @@ void SwPostIt::SetShadowState(ShadowState bState) if (mpAnkor) mpAnkor->SetLineInfo(LineInfo(LINE_SOLID,ANKORLINE_WIDTH*15)); if (mpShadow) - mpShadow->SetShadowState(SS_VIEW); + mpShadow->SetShadowState(bState); break; } case SS_NORMAL: { if (mpAnkor) + { + if (IsFollow()) + { + // 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); + } mpAnkor->SetLineInfo(LineInfo(LINE_DASH,ANKORLINE_WIDTH*15)); + } if (mpShadow) - mpShadow->SetShadowState(SS_NORMAL); + mpShadow->SetShadowState(bState); break; } } } -/****** SwPostItShadow ***********************************************************/ +bool SwMarginWin::IsAnyStackParentVisible() +{ + SwMarginWin* pMarginWin = mpMgr->GetNextPostIt(KEY_PAGEUP, this); + while (pMarginWin) + { + if (pMarginWin->IsFollow()) + { + pMarginWin = mpMgr->GetNextPostIt(KEY_PAGEUP, pMarginWin); + if (pMarginWin && pMarginWin->IsVisible()) + return true; + } + else + return pMarginWin && pMarginWin->IsVisible() ? true : false; + } + return false; +} + +SwMarginWin* SwMarginWin::GetTopReplyNote() +{ + SwMarginWin* pTopNote = 0; + SwMarginWin* pMarginWin = mpMgr->GetNextPostIt(KEY_PAGEUP, this); + while (pMarginWin) + { + pTopNote = pMarginWin; + pMarginWin = pMarginWin->IsFollow() ? mpMgr->GetNextPostIt(KEY_PAGEUP, pMarginWin) : 0; + } + return pTopNote; +} + +void SwMarginWin::SetPostItText() +{ +} + +void SwMarginWin::SwitchToFieldPos() +{ + if ( Mgr()->GetActivePostIt() == this ) + Mgr()->SetActivePostIt(0); + GotoPos(); + sal_uInt32 aCount = MoveCaret(); + if (aCount) + DocView()->GetDocShell()->GetWrtShell()->SwCrsrShell::Right(aCount, 0, FALSE); + GrabFocusToDocument(); +} + +String SwMarginWin::GetAuthor() +{ + return String(EMPTYSTRING); +} + +Date SwMarginWin::GetDate() +{ + return Date(0); +} + +Time SwMarginWin::GetTime() +{ + return Time(0); +} + +SvxLanguageItem SwMarginWin::GetLanguage(void) +{ + return SvxLanguageItem(SwLangHelper::GetLanguage(DocView()->GetWrtShell(),RES_CHRATR_LANGUAGE),RES_CHRATR_LANGUAGE); +} + +/***** SwPostIt *********************************************/ +SwPostIt::SwPostIt( Window* pParent, WinBits nBits, SwFmtFld* aField,SwPostItMgr* aMgr,SwPostItBits aBits) + : SwMarginWin(pParent,nBits,aMgr,aBits), + mpFmtFld(aField), + mpFld( static_cast<SwPostItField*>(aField->GetFld())), + mStatus(SwPostItHelper::INVISIBLE) +{ +} + +void SwPostIt::SetPostItText() +{ + // get text from SwPostItField and insert into our textview + Engine()->SetModifyHdl( Link() ); + Engine()->EnableUndo( FALSE ); + mpFld = static_cast<SwPostItField*>(mpFmtFld->GetFld()); + if( mpFld->GetTextObject() ) + Engine()->SetText( *mpFld->GetTextObject() ); + else + { + Engine()->Clear(); + SfxItemSet item( DocView()->GetDocShell()->GetPool() ); + item.Put(SvxFontHeightItem(200,100,EE_CHAR_FONTHEIGHT)); + item.Put(SvxFontItem(FAMILY_SWISS,GetSettings().GetStyleSettings().GetFieldFont().GetName(), + EMPTYSTRING,PITCH_DONTKNOW,RTL_TEXTENCODING_DONTKNOW,EE_CHAR_FONTINFO)); + View()->SetAttribs(item); + View()->InsertText(mpFld->GetPar2(),false); + } + Engine()->ClearModifyFlag(); + Engine()->GetUndoManager().Clear(); + Engine()->EnableUndo( TRUE ); + Engine()->SetModifyHdl( LINK( this, SwPostIt, ModifyHdl ) ); + Invalidate(); +} + +void SwPostIt::UpdateData() +{ + if ( Engine()->IsModified() ) + { + SwPosition * pPos = mpFmtFld->GetTxtFld()->GetPosition(); + if ( pPos ) + { + SwField* pOldField = mpFld->Copy(); + mpFld->SetPar2(Engine()->GetEditEngine().GetText()); + mpFld->SetTextObject(Engine()->CreateParaObject()); + DocView()->GetDocShell()->GetDoc()->AppendUndo(new SwUndoFieldFromDoc(*pPos, *pOldField, *mpFld, 0, true)); + delete pOldField; + delete pPos; + // so we get a new layout of notes (ankor position is still the same and we would otherwise not get one) + Mgr()->SetLayout(); + DocView()->GetDocShell()->SetModified(); + } + } + Engine()->ClearModifyFlag(); + Engine()->GetUndoManager().Clear(); +} + +void SwPostIt::SetChangeTracking(SwPostItHelper::SwLayoutStatus& aStatus,Color aColor) +{ + if ( (mStatus != aStatus) || (mChangeColor != aColor) ) + { + mStatus = aStatus; + mChangeColor = aColor; + Invalidate(); + } +} + +void SwPostIt::Delete() +{ + SwMarginWin::Delete(); + // we delete the field directly, the Mgr cleans up the PostIt by listening + DocView()->GetWrtShellPtr()->GotoField(*mpFmtFld); + GrabFocusToDocument(); + DocView()->GetWrtShellPtr()->DelRight(); +} + +void SwPostIt::GotoPos() +{ + DocView()->GetDocShell()->GetWrtShell()->GotoField(*mpFmtFld); +} + +sal_uInt32 SwPostIt::MoveCaret() +{ + // if this is an answer, do not skip over all following ones, but insert directly behind the current one + // but when just leaving a note, skip all following ones as well to continue typing + return Mgr()->IsAnswer() ? 1 : 1 + CountFollowing(); +} + +//returns true, if there is another note right before this note +bool SwPostIt::CalcFollow() +{ + SwPosition * pPos = mpFmtFld->GetTxtFld()->GetPosition(); + const SwTxtNode* pTxtNd = pPos->nNode.GetNode().GetTxtNode(); + SwTxtAttr* pTxtAttr = pTxtNd ? pTxtNd->GetTxtAttr( pPos->nContent.GetIndex()-1,RES_TXTATR_FIELD ) : 0; + const SwField* pFld = pTxtAttr ? pTxtAttr->GetFld().GetFld() : 0; + delete pPos; + return pFld && (pFld->Which()== RES_POSTITFLD); +} + +// counts how many SwPostItField we have right after the current one +sal_uInt32 SwPostIt::CountFollowing() +{ + sal_uInt32 aCount = 1; // we start with 1, so we have to subtract one at the end again + SwPosition * pPos = mpFmtFld->GetTxtFld()->GetPosition(); + const SwTxtNode* pTxtNd = pPos->nNode.GetNode().GetTxtNode(); + + SwTxtAttr* pTxtAttr = pTxtNd ? pTxtNd->GetTxtAttr( pPos->nContent.GetIndex()+1,RES_TXTATR_FIELD ) : 0; + SwField* pFld = pTxtAttr ? const_cast<SwField*>(pTxtAttr->GetFld().GetFld()) : 0; + while (pFld && (pFld->Which()== RES_POSTITFLD)) + { + aCount++; + pTxtAttr = pTxtNd ? pTxtNd->GetTxtAttr( pPos->nContent.GetIndex() + aCount,RES_TXTATR_FIELD ) : 0; + pFld = pTxtAttr ? const_cast<SwField*>(pTxtAttr->GetFld().GetFld()) : 0; + } + delete pPos; + return aCount - 1; +} + +void SwPostIt::MouseButtonDown( const MouseEvent& rMEvt ) +{ + if (mRectMetaButton.IsInside(PixelToLogic(rMEvt.GetPosPixel())) && rMEvt.IsLeft()) + { + if (IsPreview()) + { + doLazyDelete(); + if (Mgr()) + { + SwPostIt* pPostIt = dynamic_cast<SwPostIt*>(Mgr()->GetPostIt(mpFmtFld)); + if (pPostIt) + { + pPostIt->GrabFocus(); + Mgr()->MakeVisible(pPostIt); + } + } + + } + else + { + if ( mbReadonly ) + { + mpButtonPopup->EnableItem(FN_REPLY,false); + mpButtonPopup->EnableItem(FN_DELETE_NOTE,false); + mpButtonPopup->EnableItem(FN_DELETE_NOTE_AUTHOR,false); + mpButtonPopup->EnableItem(FN_DELETE_ALL_NOTES,false); + } + else + { + if (IsProtected()) + mpButtonPopup->EnableItem(FN_DELETE_NOTE,false); + else + mpButtonPopup->EnableItem(FN_DELETE_NOTE,true); + mpButtonPopup->EnableItem(FN_DELETE_NOTE_AUTHOR,true); + mpButtonPopup->EnableItem(FN_DELETE_ALL_NOTES,true); + } + SvtUserOptions aUserOpt; + String sAuthor; + if( !(sAuthor = aUserOpt.GetFullName()).Len()) + if( !(sAuthor = aUserOpt.GetID()).Len() ) + sAuthor = String( SW_RES( STR_REDLINE_UNKNOWN_AUTHOR )); + // do not allow to reply to ourself and no answer possible if this note is in a protected section + if ((sAuthor == GetAuthor()) || (IsProtected())) + mpButtonPopup->EnableItem(FN_REPLY,false); + else + mpButtonPopup->EnableItem(FN_REPLY,true); + + // show the popup menu and execute the selected command + ExecuteCommand( mpButtonPopup->Execute( this,Rectangle(LogicToPixel(mRectMetaButton.BottomLeft()),LogicToPixel(mRectMetaButton.BottomLeft())),POPUPMENU_EXECUTE_DOWN | POPUPMENU_NOMOUSEUPCLOSE) ); + } + } +} + +void SwPostIt::SetPopup() +{ + mpButtonPopup = new PopupMenu(SW_RES(MN_ANNOTATION_BUTTON)); + //mpButtonPopup->SetMenuFlags(MENU_FLAG_ALWAYSSHOWDISABLEDENTRIES); + XubString aText = mpButtonPopup->GetItemText( FN_DELETE_NOTE_AUTHOR ); + SwRewriter aRewriter; + aRewriter.AddRule(UNDO_ARG1,GetAuthor()); + aText = aRewriter.Apply(aText); + mpButtonPopup->SetItemText(FN_DELETE_NOTE_AUTHOR,aText); +} + +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(rLocalData.getDate( pWin->GetDate())) + rtl::OUString::createFromAscii(", ") + + String(rLocalData.getTime( pWin->GetTime(),false)) + rtl::OUString::createFromAscii("): \""))); + View()->InsertText(aText,false); + + // insert old, selected text or "..." + // TOOD: iterate over all paragraphs, not only first one to find out if it is empty + if (pText->GetTextObject().GetText(0) != String(EMPTYSTRING)) + View()->GetEditView().InsertText(pText->GetTextObject()); + else + View()->InsertText(rtl::OUString::createFromAscii("..."),false); + View()->InsertText(rtl::OUString::createFromAscii("\"\n"),false); + + View()->SetSelection(ESelection(0x0,0x0,0xFFFF,0xFFFF)); + SfxItemSet aAnswerSet( DocView()->GetDocShell()->GetPool() ); + aAnswerSet.Put(SvxFontHeightItem(200,80,EE_CHAR_FONTHEIGHT)); + aAnswerSet.Put(SvxPostureItem(ITALIC_NORMAL,EE_CHAR_ITALIC)); + View()->SetAttribs(aAnswerSet); + View()->SetSelection(ESelection(0xFFFF,0xFFFF,0xFFFF,0xFFFF)); + + //remove all attributes and reset our standard ones + View()->GetEditView().RemoveAttribsKeepLanguages(true); + SfxItemSet aNormalSet( DocView()->GetDocShell()->GetPool() ); + aNormalSet.Put(SvxFontHeightItem(200,100,EE_CHAR_FONTHEIGHT)); + aNormalSet.Put(SvxFontItem(FAMILY_SWISS,GetSettings().GetStyleSettings().GetFieldFont().GetName(), + EMPTYSTRING,PITCH_DONTKNOW,RTL_TEXTENCODING_DONTKNOW,EE_CHAR_FONTINFO)); + View()->SetAttribs(aNormalSet); + // lets insert an undo step so the initial text can be easily deleted + // but do not use UpdateData() directly, would set modified state again and reentrance into Mgr + Engine()->SetModifyHdl( Link() ); + SwPosition * pPos = mpFmtFld->GetTxtFld()->GetPosition(); + if ( pPos ) + { + SwField* pOldField = mpFld->Copy(); + mpFld->SetPar2(Engine()->GetEditEngine().GetText()); + mpFld->SetTextObject(Engine()->CreateParaObject()); + DocView()->GetDocShell()->GetDoc()->AppendUndo(new SwUndoFieldFromDoc(*pPos, *pOldField, *mpFld, 0, true)); + delete pOldField; + delete pPos; + } + Engine()->SetModifyHdl( LINK( this, SwPostIt, ModifyHdl ) ); + Engine()->ClearModifyFlag(); + Engine()->GetUndoManager().Clear(); +} + +SvxLanguageItem SwPostIt::GetLanguage(void) +{ + // set initial language for outliner + USHORT nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( mpFld->GetLanguage() ); + USHORT nLangWhichId = 0; + switch (nScriptType) + { + case SCRIPTTYPE_LATIN : nLangWhichId = EE_CHAR_LANGUAGE ; break; + case SCRIPTTYPE_ASIAN : nLangWhichId = EE_CHAR_LANGUAGE_CJK; break; + case SCRIPTTYPE_COMPLEX : nLangWhichId = EE_CHAR_LANGUAGE_CTL; break; + default: DBG_ERROR("GetLanguage: wrong script tye"); + } + return SvxLanguageItem(mpFld->GetLanguage(),nLangWhichId); +} + +bool SwPostIt::IsProtected() +{ + bool aReturn; + aReturn = mpFmtFld ? (SwMarginWin::IsProtected() || (mStatus==SwPostItHelper::DELETED) || + mpFmtFld->IsProtect()) : (SwMarginWin::IsProtected() || (mStatus==SwPostItHelper::DELETED)); + return aReturn; +} + +/********** SwRedComment**************/ +/* +SwRedComment::SwRedComment( Window* pParent, WinBits nBits,SwPostItMgr* aMgr,SwPostItBits aBits,SwRedline* pRed) + : SwMarginWin(pParent,nBits,aMgr,aBits), + pRedline(pRed) +{ +} + +void SwRedComment::SetPopup() +{ + mpButtonPopup = new PopupMenu(SW_RES(MN_REDCOMMENT_BUTTON)); + //mpButtonPopup->SetMenuFlags(MENU_FLAG_ALWAYSSHOWDISABLEDENTRIES); +} + +void SwRedComment::UpdateData() +{ + if ( Engine()->IsModified() ) + { + // so we get a new layout of notes (ankor position is still the same and we would otherwise not get one) + Mgr()->SetLayout(); + // SetRedline is calling SetModified already + DocView()->GetWrtShell().SetRedlineComment(Engine()->GetEditEngine().GetText()); + } + Engine()->ClearModifyFlag(); + Engine()->GetUndoManager().Clear(); +} + +void SwRedComment::SetPostItText() +{ + Engine()->SetModifyHdl( Link() ); + Engine()->EnableUndo( FALSE ); + + Engine()->Clear(); + SfxItemSet item( DocView()->GetDocShell()->GetPool() ); + item.Put(SvxFontHeightItem(200,100,EE_CHAR_FONTHEIGHT)); + item.Put(SvxFontItem(FAMILY_SWISS,GetSettings().GetStyleSettings().GetFieldFont().GetName(), + EMPTYSTRING,PITCH_DONTKNOW,RTL_TEXTENCODING_DONTKNOW,EE_CHAR_FONTINFO)); + View()->SetAttribs(item); + View()->InsertText(pRedline->GetComment(),false); + + Engine()->ClearModifyFlag(); + Engine()->GetUndoManager().Clear(); + Engine()->EnableUndo( TRUE ); + Engine()->SetModifyHdl( LINK( this, SwMarginWin, ModifyHdl ) ); + Invalidate(); +} + +void SwRedComment::DeactivatePostIt() +{ + SwMarginWin::DeactivatePostIt(); + // current Redline is still selected + DocView()->GetWrtShellPtr()->ClearMark(); +} + +void SwRedComment::ActivatePostIt() +{ + SwMarginWin::ActivatePostIt(); + + // do we want the redline selected? + // otherwise, SwRedComment::ActivatePostIt() as well as SwRedComment::DeactivatePostIt() + // can be thrown out completly + DocView()->GetDocShell()->GetWrtShell()->GotoRedline( + DocView()->GetDocShell()->GetWrtShell()->FindRedlineOfData(pRedline->GetRedlineData()),true); +} + +void SwRedComment::MouseButtonDown( const MouseEvent& rMEvt ) +{ + if (mRectMetaButton.IsInside(PixelToLogic(rMEvt.GetPosPixel())) && rMEvt.IsLeft()) + { + ExecuteCommand( mpButtonPopup->Execute( this,Rectangle(LogicToPixel(mRectMetaButton.BottomLeft()),LogicToPixel(mRectMetaButton.BottomLeft())),POPUPMENU_EXECUTE_DOWN | POPUPMENU_NOMOUSEUPCLOSE) ); + } +} + +void SwRedComment::Delete() +{ + SwMarginWin::Delete(); + // we are not neccessarily on our redline, so let's move there + GotoPos(); + DocView()->GetWrtShell().SetRedlineComment(EMPTYSTRING); + DocView()->GetWrtShell().ClearMark(); + // so we get a new layout of notes (ankor position is still the same and we would otherwise not get one) + Mgr()->SetLayout(); + Mgr()->RemoveItem(pRedline); +} + +void SwRedComment::GotoPos() +{ + DocView()->GetDocShell()->GetWrtShell()->GotoRedline( + DocView()->GetDocShell()->GetWrtShell()->FindRedlineOfData(pRedline->GetRedlineData())); +} + +String SwRedComment::GetAuthor() +{ + return pRedline->GetAuthorString(); +} + +Date SwRedComment::GetDate() +{ + return pRedline->GetTimeStamp().GetDate(); +} + +Time SwRedComment::GetTime() +{ + return pRedline->GetTimeStamp().GetTime(); +} + +bool SwRedComment::IsProtected() +{ + return SwMarginWin::IsProtected() || pRedline->Start()->nNode.GetNode().GetTxtNode()->IsInProtectSect(); +} +*/ + +/****** SwPostItShadow ***********************************************************/ SwPostItShadow::SwPostItShadow(const basegfx::B2DPoint& rBasePos,const basegfx::B2DPoint& rSecondPosition, - Color aBaseColor,ShadowState aState) + Color aBaseColor,ShadowState aState) : OverlayObjectWithBasePosition(rBasePos, aBaseColor), maSecondPosition(rSecondPosition), mShadowState(aState) @@ -1627,26 +2104,42 @@ void SwPostItAnkor::implDrawGeometry(OutputDevice& rOutputDevice, Color aColor, aLin.transform(aTranslate); } - // draw triangle - rOutputDevice.SetLineColor(); - rOutputDevice.SetFillColor(aColor); - rOutputDevice.DrawPolygon(Polygon(aTri)); - - /* - basegfx::B2DHomMatrix aMatrix; - aMatrix.translate(-aTri.getB2DPoint(0).getX(),-aTri.getB2DPoint(0).getY()); - aMatrix.scale(1.0, -1.0); - aMatrix.translate(aTri.getB2DPoint(0).getX(),aTri.getB2DPoint(0).getY()); - aMatrix.translate(0,(mHeight*-1) + 13 * 15 ); - aTri.transform(aMatrix); - rOutputDevice.DrawPolygon(Polygon(aTri)); - */ - - // draw line - rOutputDevice.SetLineColor(aColor); - rOutputDevice.SetFillColor(); - rOutputDevice.DrawPolyLine(Polygon(aLin), mLineInfo); - rOutputDevice.DrawPolyLine(aLinTop,LineInfo(LINE_SOLID,ANKORLINE_WIDTH*15)); + switch (mAnkorState) + { + case AS_ALL: + { + rOutputDevice.SetLineColor(); + rOutputDevice.SetFillColor(aColor); + //rOutputDevice.DrawTransparent(Polygon(aTri), 50); + rOutputDevice.DrawPolygon(Polygon(aTri)); + + // draw line + rOutputDevice.SetLineColor(aColor); + rOutputDevice.SetFillColor(); + rOutputDevice.DrawPolyLine(Polygon(aLin), mLineInfo); + rOutputDevice.DrawPolyLine(aLinTop,LineInfo(LINE_SOLID,ANKORLINE_WIDTH*15)); + break; + } + case AS_START: + { + rOutputDevice.SetLineColor(); + rOutputDevice.SetFillColor(aColor); + rOutputDevice.DrawPolygon(Polygon(aTri)); + // draw line + rOutputDevice.SetLineColor(aColor); + rOutputDevice.SetFillColor(); + rOutputDevice.DrawPolyLine(Polygon(aLin), mLineInfo); + break; + } + case AS_END: + { + // draw line + rOutputDevice.SetLineColor(aColor); + rOutputDevice.SetFillColor(); + rOutputDevice.DrawPolyLine(aLinTop,LineInfo(LINE_SOLID,ANKORLINE_WIDTH*15)); + break; + } + } } Color SwPostItAnkor::implBlendColor(const Color aOriginal, sal_Int16 nChange) @@ -1703,7 +2196,8 @@ SwPostItAnkor::SwPostItAnkor(const basegfx::B2DPoint& rBasePos, maLineTop(), mLineInfo(aLineInfo), mHeight(0), - mbShadowedEffect(bShadowedEffect) + mbShadowedEffect(bShadowedEffect), + mAnkorState(AS_ALL) { if (mLineInfo.GetStyle()==LINE_DASH) { @@ -1881,3 +2375,12 @@ void SwPostItAnkor::SetLineInfo(const LineInfo &aLineInfo) objectChange(); } } + +void SwPostItAnkor::SetAnkorState(AnkorState aState) +{ + if (mAnkorState != aState) + { + mAnkorState = aState; + objectChange(); + } +} |