update ooo310-m15
[ooovba.git] / sw / source / ui / docvw / postit.cxx
bloba26a777cb1c9791ef9140faf06a06fb9e000ebff
1 /************************************************************************* *
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: postit.cxx,v $
10 * $Revision: 1.8.42.11 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
32 #include "precompiled_sw.hxx"
33 #include <postit.hxx>
34 #include <PostItMgr.hxx>
36 #include <popup.hrc>
37 #include <docvw.hrc>
38 #include <app.hrc>
40 #include <hintids.hxx>
41 #include "viewopt.hxx"
42 #include "cmdid.h"
44 #include <tools/poly.hxx> // Polygon
46 #include <svx/postitem.hxx>
47 #include <svx/fontitem.hxx>
48 #include <svx/eeitem.hxx>
49 #include <svx/fhgtitem.hxx>
50 #include <svx/bulitem.hxx>
51 #include <svx/udlnitem.hxx>
52 #include <svx/shdditem.hxx>
53 #include <svx/wghtitem.hxx>
54 #include <svx/colritem.hxx>
55 #include <svx/flditem.hxx>
56 #include <svx/frmdir.hxx>
57 #include <svx/frmdiritem.hxx>
58 #include <svx/langitem.hxx>
59 #include <svx/adjitem.hxx>
60 #include <svx/editview.hxx>
61 #include <svx/svdview.hxx>
62 #include <svx/sdrpaintwindow.hxx>
63 #include <svx/sdr/overlay/overlaymanager.hxx>
64 #include <svx/editstat.hxx> //EditEngine flags
65 #include <svx/outliner.hxx>
66 #include <svx/editeng.hxx>
67 #include <svx/editobj.hxx>
68 #include <svx/unolingu.hxx>
70 #include <svtools/langtab.hxx>
71 #include <svtools/slstitm.hxx>
72 #include <svtools/securityoptions.hxx>
73 #include <svtools/useroptions.hxx>
74 #include <svtools/languageoptions.hxx>
75 #include <svtools/zforlist.hxx>
76 #include <svtools/svmedit.hxx>
78 #include <linguistic/lngprops.hxx>
80 #include <sfx2/request.hxx>
81 #include <sfx2/viewfrm.hxx>
82 #include <sfx2/bindings.hxx>
83 #include <sfx2/dispatch.hxx>
84 #include <sfx2/mnumgr.hxx>
86 #include <vcl/vclenum.hxx>
87 #include <vcl/edit.hxx>
88 #include <vcl/help.hxx>
89 #include <vcl/scrbar.hxx>
90 #include <vcl/button.hxx>
91 #include <vcl/svapp.hxx>
92 #include <vcl/gradient.hxx>
93 #include <vcl/salbtype.hxx> // FRound
95 #include <basegfx/matrix/b2dhommatrix.hxx>
96 #include <basegfx/tuple/b2dtuple.hxx>
97 #include <basegfx/polygon/b2dpolygontools.hxx>
99 #include <swrect.hxx>
100 #include <docufld.hxx> // SwPostItField
101 #include <edtwin.hxx>
102 #include <view.hxx>
103 #include <viewsh.hxx>
104 #include <docsh.hxx>
105 #include <shellres.hxx>
106 #include <fmtfld.hxx>
107 #include <wrtsh.hxx>
108 #include <textsh.hxx>
109 #include <doc.hxx>
110 #include <txtfld.hxx>
111 #include <redline.hxx>
112 #include <uitool.hxx>
113 #include <SwUndoField.hxx>
114 #include <editsh.hxx>
115 #include <swmodule.hxx>
116 #include <node.hxx>
117 #include <ndtxt.hxx>
118 #include <langhelper.hxx>
120 using namespace ::com::sun::star;
122 #define METABUTTON_WIDTH 16
123 #define METABUTTON_HEIGHT 18
124 #define METABUTTON_AREA_WIDTH 30
125 #define POSTIT_META_HEIGHT (sal_Int32) 30
126 #define POSTIT_MINIMUMSIZE_WITHOUT_META 50
128 #define POSTIT_SHADOW_BRIGHT Color(180,180,180)
129 #define POSTIT_SHADOW_DARK Color(83,83,83)
131 #define LINEBREAK rtl::OUString::createFromAscii("\n")
132 #define EMPTYSTRING rtl::OUString::createFromAscii("")
134 TYPEINIT0(SwMarginWin);
135 TYPEINIT1(SwPostIt,SwMarginWin);
136 //TYPEINIT1(SwRedComment,SwMarginWin);
138 Color ColorFromAlphaColor(UINT8 aTransparency, Color &aFront, Color &aBack )
140 return Color((UINT8)(aFront.GetRed() * aTransparency/(double)255 + aBack.GetRed() * (1-aTransparency/(double)255)),
141 (UINT8)(aFront.GetGreen() * aTransparency/(double)255 + aBack.GetGreen() * (1-aTransparency/(double)255)),
142 (UINT8)(aFront.GetBlue() * aTransparency/(double)255 + aBack.GetBlue() * (1-aTransparency/(double)255)));
145 /************ PostItTxt **************************************/
146 PostItTxt::PostItTxt(Window* pParent, WinBits nBits) : Window(pParent, nBits), mpOutlinerView(0),mMouseOver(false),mbShowPopup(FALSE)
148 SetHelpId(26276);
149 AddEventListener( LINK( this, PostItTxt, WindowEventListener ) );
150 mpMarginWin = static_cast<SwMarginWin*>(GetParent());
153 PostItTxt::~PostItTxt()
155 RemoveEventListener( LINK( this, PostItTxt, WindowEventListener ) );
158 void PostItTxt::GetFocus()
160 BOOL bLockView = mpMarginWin->DocView()->GetWrtShell().IsViewLocked();
161 mpMarginWin->DocView()->GetWrtShell().LockView( TRUE );
163 if(mpMarginWin && !mpMarginWin->IsPreview())
164 mpMarginWin->Mgr()->SetActivePostIt(mpMarginWin);
165 Window::GetFocus();
166 if (!mMouseOver)
167 Invalidate();
169 mpMarginWin->DocView()->GetWrtShell().LockView( bLockView );
170 mpMarginWin->Mgr()->MakeVisible(mpMarginWin);
173 void PostItTxt::LoseFocus()
175 // write the visible text back into the SwField
176 if ( mpMarginWin )
177 mpMarginWin->UpdateData();
179 Window::LoseFocus();
180 if (!mMouseOver)
181 Invalidate();
184 void PostItTxt::RequestHelp(const HelpEvent &rEvt)
186 USHORT nResId = 0;
187 switch( mpMarginWin->GetStatus() )
189 case SwPostItHelper::INSERTED: nResId = STR_REDLINE_INSERT; break;
190 case SwPostItHelper::DELETED: nResId = STR_REDLINE_DELETE; break;
191 default: nResId = 0;
194 SwContentAtPos aCntntAtPos( SwContentAtPos::SW_REDLINE );
195 if ( nResId && mpMarginWin->DocView()->GetWrtShell().GetContentAtPos( mpMarginWin->GetAnkorRect().Pos(), aCntntAtPos ) )
197 String sTxt;
198 sTxt = SW_RESSTR( nResId );
199 sTxt.AppendAscii( RTL_CONSTASCII_STRINGPARAM(": " ));
200 sTxt += aCntntAtPos.aFnd.pRedl->GetAuthorString();
201 sTxt.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " - " ));
202 sTxt += GetAppLangDateTimeString( aCntntAtPos.aFnd.pRedl->GetTimeStamp() );
203 Help::ShowQuickHelp( this,PixelToLogic(Rectangle(rEvt.GetMousePosPixel(),Size(50,10))),sTxt);
207 void PostItTxt::Paint( const Rectangle& rRect)
209 if ( !Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
211 if (mMouseOver || HasFocus())
212 DrawGradient(Rectangle(Point(0,0),PixelToLogic(GetSizePixel())),
213 Gradient(GRADIENT_LINEAR,mpMarginWin->ColorDark(),mpMarginWin->ColorDark()));
214 else
215 DrawGradient(Rectangle(Point(0,0),PixelToLogic(GetSizePixel())),
216 Gradient(GRADIENT_LINEAR,mpMarginWin->ColorLight(),mpMarginWin->ColorDark()));
219 mpOutlinerView->Paint( rRect );
221 if (mpMarginWin->GetStatus()==SwPostItHelper::DELETED)
223 SetLineColor(static_cast<SwPostIt*>(mpMarginWin)->GetChangeColor());
224 DrawLine(PixelToLogic(GetPosPixel()),PixelToLogic(GetPosPixel()+Point(GetSizePixel().Width(),GetSizePixel().Height())));
225 DrawLine(PixelToLogic(GetPosPixel()+Point(GetSizePixel().Width(),0)),PixelToLogic(GetPosPixel()+Point(0,GetSizePixel().Height())));
229 void PostItTxt::KeyInput( const KeyEvent& rKeyEvt )
231 const KeyCode& rKeyCode = rKeyEvt.GetKeyCode();
232 USHORT nKey = rKeyCode.GetCode();
233 SwView* pView = mpMarginWin->DocView();
234 if ((rKeyCode.IsMod1() && rKeyCode.IsMod2()) && ((nKey == KEY_PAGEUP) || (nKey == KEY_PAGEDOWN)))
235 mpMarginWin->SwitchToPostIt(nKey);
236 else
237 if ((nKey == KEY_ESCAPE) || (rKeyCode.IsMod1() && ((nKey == KEY_PAGEUP) || (nKey == KEY_PAGEDOWN))))
238 mpMarginWin->SwitchToFieldPos();
239 else
240 if (nKey == KEY_INSERT)
242 if (!rKeyCode.IsMod1() && !rKeyCode.IsMod2())
243 mpMarginWin->ToggleInsMode();
245 else
247 //let's make sure we see our note
248 mpMarginWin->Mgr()->MakeVisible(mpMarginWin);
250 long aOldHeight = mpMarginWin->GetPostItTextHeight();
251 bool bDone = false;
253 /// HACK: need to switch off processing of Undo/Redo in Outliner
254 if ( !( (nKey == KEY_Z || nKey == KEY_Y) && rKeyCode.IsMod1()) )
257 SwPostItHelper::SwLayoutStatus aStatus = mpMarginWin->GetStatus();
258 if ( (aStatus!=SwPostItHelper::DELETED) ||
259 ( (aStatus==SwPostItHelper::DELETED) && (!mpMarginWin->Engine()->GetEditEngine().DoesKeyChangeText(rKeyEvt))) )
261 bool bIsProtected = mpMarginWin->IsProtected();
262 if (!bIsProtected || (bIsProtected && !mpMarginWin->Engine()->GetEditEngine().DoesKeyChangeText(rKeyEvt)) )
263 bDone = mpOutlinerView->PostKeyEvent( rKeyEvt );
265 if (bDone)
266 mpMarginWin->ResizeIfNeccessary(aOldHeight,mpMarginWin->GetPostItTextHeight());
267 else
269 // write back data first when showing navigator
270 if ( nKey==KEY_F5 )
271 mpMarginWin->UpdateData();
272 if (!pView->KeyInput(rKeyEvt))
273 Window::KeyInput(rKeyEvt);
277 pView->GetViewFrame()->GetBindings().InvalidateAll(FALSE);
280 void PostItTxt::MouseMove( const MouseEvent& rMEvt )
282 if ( mpOutlinerView )
284 mpOutlinerView->MouseMove( rMEvt );
285 // mba: why does OutlinerView not handle the modifier setting?!
286 // this forces the postit to handle *all* pointer types
287 SetPointer( mpOutlinerView->GetPointer( rMEvt.GetPosPixel() ) );
289 const EditView& aEV = mpOutlinerView->GetEditView();
290 const SvxFieldItem* pItem = aEV.GetFieldUnderMousePointer();
291 if ( pItem )
293 const SvxFieldData* pFld = pItem->GetField();
294 const SvxURLField* pURL = PTR_CAST( SvxURLField, pFld );
295 if ( pURL )
297 String sURL( pURL->GetURL() );
298 SvtSecurityOptions aSecOpts;
299 if ( aSecOpts.IsOptionSet( SvtSecurityOptions::E_CTRLCLICK_HYPERLINK) )
301 sURL.InsertAscii( ": ", 0 );
302 sURL.Insert( ViewShell::GetShellRes()->aHyperlinkClick, 0 );
304 Help::ShowQuickHelp( this,PixelToLogic(Rectangle(GetPosPixel(),Size(50,10))),sURL);
310 void PostItTxt::MouseButtonDown( const MouseEvent& rMEvt )
312 if (mpOutlinerView )
314 SvtSecurityOptions aSecOpts;
315 bool bExecuteMod = aSecOpts.IsOptionSet( SvtSecurityOptions::E_CTRLCLICK_HYPERLINK);
317 if ( !bExecuteMod || (bExecuteMod && rMEvt.GetModifier() == KEY_MOD1))
319 const EditView& aEV = mpOutlinerView->GetEditView();
320 const SvxFieldItem* pItem = aEV.GetFieldUnderMousePointer();
321 if ( pItem )
323 const SvxFieldData* pFld = pItem->GetField();
324 const SvxURLField* pURL = PTR_CAST( SvxURLField, pFld );
325 if ( pURL )
327 mpOutlinerView->MouseButtonDown( rMEvt );
328 SwWrtShell &rSh = mpMarginWin->DocView()->GetWrtShell();
329 String sURL( pURL->GetURL() );
330 String sTarget( pURL->GetTargetFrame() );
331 ::LoadURL( sURL, &rSh, URLLOAD_NOFILTER, &sTarget);
332 return;
338 GrabFocus();
339 if ( mpOutlinerView )
340 mpOutlinerView->MouseButtonDown( rMEvt );
341 mpMarginWin->DocView()->GetViewFrame()->GetBindings().InvalidateAll(FALSE);
344 void PostItTxt::MouseButtonUp( const MouseEvent& rMEvt )
346 if ( mpOutlinerView )
347 mpOutlinerView->MouseButtonUp( rMEvt );
350 IMPL_LINK(PostItTxt, OnlineSpellCallback, SpellCallbackInfo*, pInfo)
352 if ( mpMarginWin && (pInfo->nCommand == SPELLCMD_STARTSPELLDLG) )
353 mpMarginWin->DocView()->GetViewFrame()->GetDispatcher()->Execute( FN_SPELL_GRAMMAR_DIALOG, SFX_CALLMODE_ASYNCHRON);
354 return 0;
357 IMPL_LINK( PostItTxt, Select, Menu*, pSelMenu )
359 mpMarginWin->ExecuteCommand( pSelMenu->GetCurItemId() );
360 return 0;
363 void PostItTxt::Command( const CommandEvent& rCEvt )
365 if ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU )
367 if (!mpMarginWin->IsProtected() &&
368 //if (!mpMarginWin->IsReadOnly() && (mpMarginWin->GetStatus()!=SwPostItHelper::DELETED) &&
369 mpOutlinerView->IsWrongSpelledWordAtPos( rCEvt.GetMousePosPixel(),TRUE ))
371 Link aLink = LINK(this, PostItTxt, OnlineSpellCallback);
372 mpOutlinerView->ExecuteSpellPopup(rCEvt.GetMousePosPixel(),&aLink);
374 else
376 SfxPopupMenuManager* aMgr = mpMarginWin->DocView()->GetViewFrame()->GetDispatcher()->Popup(0, this,&rCEvt.GetMousePosPixel());
377 XubString aText = ((PopupMenu*)aMgr->GetSVMenu())->GetItemText( FN_DELETE_NOTE_AUTHOR );
378 SwRewriter aRewriter;
379 aRewriter.AddRule(UNDO_ARG1, mpMarginWin->GetAuthor());
380 aText = aRewriter.Apply(aText);
381 ((PopupMenu*)aMgr->GetSVMenu())->SetItemText(FN_DELETE_NOTE_AUTHOR,aText);
382 // SwPostItLinkForwarder_Impl aFwd( ((PopupMenu*)aMgr->GetSVMenu())->pSvMenu->GetSelectHdl(), mpPostIt );
383 // ((PopupMenu*)aMgr->GetSVMenu())->pSvMenu->SetSelectHdl( LINK(&aFwd, SwPostItLinkForwarder_Impl, Select) );
385 ((PopupMenu*)aMgr->GetSVMenu())->SetSelectHdl( LINK(this, PostItTxt, Select) );
387 if (rCEvt.IsMouseEvent())
388 ((PopupMenu*)aMgr->GetSVMenu())->Execute(this,rCEvt.GetMousePosPixel());
389 else
391 const Size aSize = GetSizePixel();
392 const Point aPos = Point( aSize.getWidth()/2, aSize.getHeight()/2 );
393 ((PopupMenu*)aMgr->GetSVMenu())->Execute(this,aPos);
395 delete aMgr;
398 else
399 if (rCEvt.GetCommand() == COMMAND_WHEEL)
401 if (mpMarginWin->Scrollbar()->IsVisible())
403 const CommandWheelData* pData = rCEvt.GetWheelData();
404 if (pData->IsShift() || pData->IsMod1() || pData->IsMod2())
406 mpMarginWin->DocView()->HandleWheelCommands(rCEvt);
408 else
410 HandleScrollCommand( rCEvt, 0 , mpMarginWin->Scrollbar());
413 long nLines = pData->GetNotchDelta() * (long)pData->GetScrollLines();
414 if ( ((mpMarginWin->Scrollbar()->GetRange().Min() == mpMarginWin->Scrollbar()->GetThumbPos()) && (nLines > 0)) ||
415 ( (mpMarginWin->Scrollbar()->GetRange().Max() == mpMarginWin->Scrollbar()->GetThumbPos()+mpMarginWin->Scrollbar()->GetVisibleSize()) && (nLines < 0)) )
417 mpMarginWin->DocView()->HandleWheelCommands(rCEvt);
419 else
421 HandleScrollCommand( rCEvt, 0 , mpMarginWin->Scrollbar());
426 else
428 mpMarginWin->DocView()->HandleWheelCommands(rCEvt);
431 else if (rCEvt.GetCommand() == COMMAND_SELECTIONCHANGE)
433 if ( mpOutlinerView )
435 const CommandSelectionChangeData *pData = rCEvt.GetSelectionChangeData();
436 ESelection aSelection = mpOutlinerView->GetEditView().GetSelection();
437 aSelection.nStartPos = sal::static_int_cast<sal_uInt16, ULONG>(pData->GetStart());
438 aSelection.nEndPos = sal::static_int_cast<sal_uInt16, ULONG>(pData->GetEnd());
439 mpOutlinerView->GetEditView().SetSelection(aSelection);
442 else if (rCEvt.GetCommand() == COMMAND_PREPARERECONVERSION)
444 if ( mpOutlinerView && mpOutlinerView->HasSelection() )
446 EditEngine *aEditEngine = mpOutlinerView->GetEditView().GetEditEngine();
447 ESelection aSelection = mpOutlinerView->GetEditView().GetSelection();
448 aSelection.Adjust();
449 if( aSelection.nStartPara != aSelection.nEndPara )
451 xub_StrLen aParaLen = aEditEngine->GetTextLen( aSelection.nStartPara );
452 aSelection.nEndPara = aSelection.nStartPara;
453 aSelection.nEndPos = aParaLen;
454 mpOutlinerView->GetEditView().SetSelection( aSelection );
458 else
460 if ( mpOutlinerView )
461 mpOutlinerView->Command( rCEvt );
462 else
463 Window::Command(rCEvt);
467 void PostItTxt::DataChanged( const DataChangedEvent& aData)
469 Window::DataChanged( aData );
472 XubString PostItTxt::GetSurroundingText() const
474 if( mpOutlinerView )
476 EditEngine *aEditEngine = mpOutlinerView->GetEditView().GetEditEngine();
477 if( mpOutlinerView->HasSelection() )
478 return mpOutlinerView->GetSelected();
479 else
481 ESelection aSelection = mpOutlinerView->GetEditView().GetSelection();
482 XubString aStr = aEditEngine->GetText(aSelection.nStartPara);
483 return aStr;
486 else
487 return XubString::EmptyString();
490 Selection PostItTxt::GetSurroundingTextSelection() const
492 if( mpOutlinerView )
494 if( mpOutlinerView->HasSelection() )
495 return Selection( 0, mpOutlinerView->GetSelected().Len() );
496 else
498 ESelection aSelection = mpOutlinerView->GetEditView().GetSelection();
499 return Selection( aSelection.nStartPos, aSelection.nEndPos );
502 else
503 return Selection( 0, 0 );
506 IMPL_LINK( PostItTxt, WindowEventListener, VclSimpleEvent*, pWinEvent )
508 if ( pWinEvent && pWinEvent->ISA( VclWindowEvent ) )
510 VclWindowEvent *pEvent = (VclWindowEvent*)pWinEvent;
511 if (pEvent->GetId() == VCLEVENT_WINDOW_MOUSEMOVE)
513 MouseEvent* pMouseEvt = (MouseEvent*)pEvent->GetData();
514 if ( pMouseEvt->IsEnterWindow() )
516 mMouseOver = true;
517 if (!mbShowPopup && !HasFocus())
519 mpMarginWin->SetViewState(SS_VIEW);
520 Invalidate();
523 else if ( pMouseEvt->IsLeaveWindow())
525 if (mpMarginWin->IsPreview())
527 //mpMarginWin->doLazyDelete();
529 else
531 mMouseOver = false;
532 if (!mbShowPopup && !HasFocus())
534 mpMarginWin->SetViewState(SS_NORMAL);
535 Invalidate();
541 return sal_True;
544 /************** SwMarginWin***********************************++*/
545 SwMarginWin::SwMarginWin(Window* pParent, WinBits nBits,SwPostItMgr* aMgr,SwPostItBits aBits)
546 : Window(pParent, nBits),
547 mnEventId(0),
548 mpOutlinerView(0),
549 mpOutliner(0),
550 mpPostItTxt(0),
551 mpMeta(0),
552 mpVScrollbar(0),
553 mpAnkor(0),
554 mpShadow(0),
555 mpMgr(aMgr),
556 mbMeta(true),
557 nFlags(aBits),
558 mbMouseOverButton(false),
559 mpButtonPopup(0),
560 mbIsFollow(false)
562 SwEditWin* aWin = static_cast<SwEditWin*>(GetParent());
563 mpView = &aWin->GetView();
565 SdrPaintWindow* pPaintWindow = mpView->GetDrawView()->GetPaintWindow(0);
566 if(pPaintWindow)
568 pOverlayManager = pPaintWindow->GetOverlayManager();
570 mpShadow = new SwPostItShadow(basegfx::B2DPoint(0,0),basegfx::B2DPoint(0,0),Color(0,0,0),SS_NORMAL);
571 mpShadow->setVisible(false);
572 pOverlayManager->add(*mpShadow);
576 SwMarginWin::~SwMarginWin()
578 if (mpOutlinerView)
580 delete mpOutlinerView;
583 if (mpOutliner)
585 delete mpOutliner;
588 if (mpMeta)
590 mpMeta->RemoveEventListener( LINK( mpPostItTxt, PostItTxt, WindowEventListener ) );
591 delete mpMeta;
594 if (mpPostItTxt)
596 delete mpPostItTxt;
599 if (mpVScrollbar)
601 delete mpVScrollbar;
604 if (mpAnkor)
606 if (mpAnkor->getOverlayManager())
608 // remove this object from the chain
609 mpAnkor->getOverlayManager()->remove(*mpAnkor);
611 delete mpAnkor;
614 if (mpShadow)
616 if (mpShadow->getOverlayManager())
618 mpShadow->getOverlayManager()->remove(*mpShadow);
620 delete mpShadow;
623 if (mpButtonPopup)
625 delete mpButtonPopup;
628 if (mnEventId)
629 Application::RemoveUserEvent( mnEventId );
632 void SwMarginWin::Paint( const Rectangle& rRect)
634 Window::Paint(rRect);
636 if (mpMeta->IsVisible() )
638 //draw left over space
639 if ( Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
640 SetFillColor(COL_BLACK);
641 else
642 SetFillColor(mColorDark);
643 SetLineColor();
644 DrawRect(PixelToLogic(Rectangle(Point(mpMeta->GetPosPixel().X()+mpMeta->GetSizePixel().Width(),mpMeta->GetPosPixel().Y()),Size(GetMetaButtonAreaWidth(),mpMeta->GetSizePixel().Height()))));
646 if ( Application::GetSettings().GetStyleSettings().GetHighContrastMode())
648 //draw rect around button
649 SetFillColor(COL_BLACK);
650 SetLineColor(COL_WHITE);
652 else
654 //draw button
655 Gradient aGradient;
656 if (mbMouseOverButton)
657 aGradient = Gradient(GRADIENT_LINEAR,ColorFromAlphaColor(80,mColorAnkor,mColorDark),ColorFromAlphaColor(15,mColorAnkor,mColorDark));
658 else
659 aGradient = Gradient(GRADIENT_LINEAR,ColorFromAlphaColor(15,mColorAnkor,mColorDark),ColorFromAlphaColor(80,mColorAnkor,mColorDark));
660 DrawGradient(mRectMetaButton,aGradient);
661 //draw rect around button
662 SetFillColor();
663 SetLineColor(ColorFromAlphaColor(90,mColorAnkor,mColorDark));
665 DrawRect(mRectMetaButton);
667 if (IsPreview())
669 Font aOldFont( GetFont());
670 Font aFont(aOldFont);
671 Color aCol( COL_BLACK);
672 aFont.SetColor( aCol );
673 aFont.SetHeight(200);
674 aFont.SetWeight(WEIGHT_MEDIUM);
675 SetFont( aFont );
676 DrawText(mRectMetaButton,rtl::OUString::createFromAscii("Edit Note"),TEXT_DRAW_CENTER);
677 SetFont( aOldFont );
679 else
681 //draw arrow
682 if ( Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
683 SetFillColor(COL_WHITE);
684 else
685 SetFillColor(COL_BLACK);
686 SetLineColor();
687 DrawPolygon(Polygon(aPopupTriangle));
692 void SwMarginWin::SetPosSizePixelRect(long nX, long nY,long nWidth, long nHeight,const SwRect &aRect, const long aPageBorder)
694 mbMeta = true;
695 mPosSize = Rectangle(Point(nX,nY),Size(nWidth,nHeight));
696 mAnkorRect = aRect;
697 mPageBorder = aPageBorder;
700 void SwMarginWin::SetSize( const Size& rNewSize )
702 mPosSize.SetSize(rNewSize);
705 void SwMarginWin::SetVirtualPosSize( const Point& aPoint, const Size& aSize)
707 mPosSize = Rectangle(aPoint,aSize);
710 void SwMarginWin::TranslateTopPosition(const long aAmount)
712 mPosSize.Move(0,aAmount);
715 void SwMarginWin::ShowAnkorOnly(const Point &aPoint)
717 HideNote();
718 SetPosAndSize();
719 if (mpAnkor)
721 mpAnkor->SetSixthPosition(basegfx::B2DPoint(aPoint.X(),aPoint.Y()));
722 mpAnkor->SetSeventhPosition(basegfx::B2DPoint(aPoint.X(),aPoint.Y()));
723 mpAnkor->SetAnkorState(AS_ALL);
724 mpAnkor->setVisible(true);
726 if (mpShadow)
727 mpShadow->setVisible(false);
730 void SwMarginWin::InitControls()
732 // actual window which holds the user text
733 mpPostItTxt = new PostItTxt(this, WB_NODIALOGCONTROL);
734 mpPostItTxt->SetPointer(Pointer(POINTER_TEXT));
736 // window control for author and date
737 mpMeta = new MultiLineEdit(this,0);
738 mpMeta->SetReadOnly();
739 mpMeta->SetRightToLeft(Application::GetSettings().GetLayoutRTL());
740 mpMeta->AlwaysDisableInput(true);
741 mpMeta->SetCallHandlersOnInputDisabled(true);
742 mpMeta->AddEventListener( LINK( mpPostItTxt, PostItTxt, WindowEventListener ) );
743 AddEventListener( LINK( mpPostItTxt, PostItTxt, WindowEventListener ) );
745 // we should leave this setting alone, but for this we need a better layout algo
746 // with variable meta size height
747 AllSettings aSettings = mpMeta->GetSettings();
748 StyleSettings aStyleSettings = aSettings.GetStyleSettings();
749 Font aFont = aStyleSettings.GetFieldFont();
750 aFont.SetHeight(8);
751 aStyleSettings.SetFieldFont(aFont);
752 aSettings.SetStyleSettings(aStyleSettings);
753 mpMeta->SetSettings(aSettings);
755 SwDocShell* aShell = mpView->GetDocShell();
756 mpOutliner = new Outliner(&aShell->GetPool(),OUTLINERMODE_TEXTOBJECT);
757 aShell->GetDoc()->SetCalcFieldValueHdl( mpOutliner );
758 // mpOutliner->EnableUndo( FALSE );
759 mpOutliner->SetUpdateMode( TRUE );
760 Rescale();
762 OutputDevice* pDev = aShell->GetDoc()->getReferenceDevice(TRUE);
763 if ( pDev )
765 mpOutliner->SetRefDevice( pDev );
768 mpOutlinerView = new OutlinerView ( mpOutliner, mpPostItTxt );
769 mpOutlinerView->SetBackgroundColor(COL_TRANSPARENT);
770 mpOutliner->InsertView(mpOutlinerView );
771 mpPostItTxt->SetTextView(mpOutlinerView);
772 mpOutlinerView->SetOutputArea( PixelToLogic( Rectangle(0,0,1,1) ) );
774 SfxItemSet item(aShell->GetPool());
775 item.Put(SvxFontHeightItem(200,100,EE_CHAR_FONTHEIGHT));
776 item.Put(SvxFontItem(FAMILY_SWISS,GetSettings().GetStyleSettings().GetFieldFont().GetName(),
777 EMPTYSTRING,PITCH_DONTKNOW,RTL_TEXTENCODING_DONTKNOW,EE_CHAR_FONTINFO));
778 mpOutlinerView->SetAttribs(item);
780 // TODO: ??
781 EEHorizontalTextDirection aDefHoriTextDir = Application::GetSettings().GetLayoutRTL() ? EE_HTEXTDIR_R2L : EE_HTEXTDIR_L2R;
782 mpOutliner->SetDefaultHorizontalTextDirection( aDefHoriTextDir );
784 //create Scrollbars
785 mpVScrollbar = new ScrollBar(this, WB_3DLOOK |WB_VSCROLL|WB_DRAG);
786 mpVScrollbar->EnableNativeWidget(false);
787 mpVScrollbar->EnableRTL( false );
788 mpVScrollbar->SetScrollHdl(LINK(this, SwMarginWin, ScrollHdl));
789 mpVScrollbar->EnableDrag();
790 mpVScrollbar->AddEventListener( LINK( mpPostItTxt, PostItTxt, WindowEventListener ) );
792 const SwViewOption* pVOpt = mpView->GetWrtShellPtr()->GetViewOptions();
793 ULONG nCntrl = mpOutliner->GetControlWord();
794 // TODO: crash when AUTOCOMPLETE enabled
795 nCntrl |= EE_CNTRL_MARKFIELDS | EE_CNTRL_PASTESPECIAL | EE_CNTRL_AUTOCORRECT | EV_CNTRL_AUTOSCROLL | EE_CNTRL_URLSFXEXECUTE; // | EE_CNTRL_AUTOCOMPLETE;
796 if (pVOpt->IsFieldShadings())
797 nCntrl |= EE_CNTRL_MARKFIELDS;
798 else
799 nCntrl &= ~EE_CNTRL_MARKFIELDS;
800 if (pVOpt->IsOnlineSpell())
801 nCntrl |= EE_CNTRL_ONLINESPELLING;
802 else
803 nCntrl &= ~EE_CNTRL_ONLINESPELLING;
804 mpOutliner->SetControlWord(nCntrl);
806 sal_uInt16 aIndex = SW_MOD()->InsertRedlineAuthor(GetAuthor());
807 SetColor(mpMgr->GetColorDark(aIndex),mpMgr->GetColorLight(aIndex),mpMgr->GetColorAnkor(aIndex));
809 CheckMetaText();
810 SetPopup();
811 SetLanguage(GetLanguage());
812 View()->StartSpeller();
813 SetPostItText();
814 Engine()->CompleteOnlineSpelling();
816 mpMeta->Show();
817 mpVScrollbar->Show();
818 mpPostItTxt->Show();
821 void SwMarginWin::CheckMetaText()
823 const LocaleDataWrapper& rLocalData = SvtSysLocale().GetLocaleData();
824 String sMeta = GetAuthor();
825 if (sMeta==String(EMPTYSTRING))
826 sMeta = String(SW_RES(STR_NOAUTHOR));
827 if (sMeta.Len() > 22)
829 sMeta.Erase(20);
830 sMeta = sMeta + rtl::OUString::createFromAscii("...");
832 Date aDate = GetDate();
833 if (aDate==Date())
834 sMeta = sMeta + LINEBREAK + String(SW_RES(STR_POSTIT_TODAY));
835 else
836 if (aDate == Date(Date()-1))
837 sMeta = sMeta + LINEBREAK + String(SW_RES(STR_POSTIT_YESTERDAY));
838 else
839 if (aDate.IsValid() )
840 sMeta = sMeta + LINEBREAK + rLocalData.getDate(aDate);
841 else
842 sMeta = sMeta + LINEBREAK + String(SW_RES(STR_NODATE));
843 if (GetTime()!=0)
844 sMeta = sMeta + rtl::OUString::createFromAscii(" ") + rLocalData.getTime( GetTime(),false );
845 if (mpMeta->GetText() != sMeta)
846 mpMeta->SetText(sMeta);
849 void SwMarginWin::Rescale()
851 MapMode aMode = GetParent()->GetMapMode();
852 aMode.SetOrigin( Point() );
853 //aMode.SetScaleX( aMode.GetScaleX() * Fraction( 8, 10 ) );
854 //aMode.SetScaleY( aMode.GetScaleY() * Fraction( 8, 10 ) );
855 mpOutliner->SetRefMapMode( aMode );
856 SetMapMode( aMode );
857 mpPostItTxt->SetMapMode( aMode );
858 if ( mpMeta )
860 Font aFont( mpMeta->GetSettings().GetStyleSettings().GetFieldFont() );
861 sal_Int32 nHeight = aFont.GetHeight();
862 nHeight = nHeight * aMode.GetScaleY().GetNumerator() / aMode.GetScaleY().GetDenominator();
863 aFont.SetHeight( nHeight );
864 mpMeta->SetControlFont( aFont );
868 void SwMarginWin::SetPosAndSize()
870 bool bChange = false;
872 if (GetSizePixel() != mPosSize.GetSize())
874 bChange = true;
875 SetSizePixel(mPosSize.GetSize());
876 DoResize();
879 if (GetPosPixel().X() != mPosSize.TopLeft().X() || (abs(GetPosPixel().Y() - mPosSize.TopLeft().Y()) > 5) )
881 bChange = true;
882 SetPosPixel(mPosSize.TopLeft());
884 Point aLineStart;
885 Point aLineEnd ;
886 if (mbMarginSide)
888 aLineStart = EditWin()->PixelToLogic( Point(GetPosPixel().X()+GetSizePixel().Width(),GetPosPixel().Y()-1) );
889 aLineEnd = EditWin()->PixelToLogic( Point(GetPosPixel().X(),GetPosPixel().Y()-1) );
891 else
893 aLineStart = EditWin()->PixelToLogic( Point(GetPosPixel().X(),GetPosPixel().Y()-1) );
894 aLineEnd = EditWin()->PixelToLogic( Point(GetPosPixel().X()+GetSizePixel().Width(),GetPosPixel().Y()-1) );
897 if (!IsPreview())
899 if (mpAnkor)
901 mpAnkor->SetAllPosition(basegfx::B2DPoint( mAnkorRect.Left() , mAnkorRect.Bottom() - 5* 15),
902 basegfx::B2DPoint( mAnkorRect.Left()-5*15 , mAnkorRect.Bottom()+5*15),
903 basegfx::B2DPoint( mAnkorRect.Left()+5*15 , mAnkorRect.Bottom()+5*15),
904 basegfx::B2DPoint( mAnkorRect.Left(), mAnkorRect.Bottom()+2*15),
905 basegfx::B2DPoint( mPageBorder ,mAnkorRect.Bottom()+2*15),
906 basegfx::B2DPoint( aLineStart.X(),aLineStart.Y()),
907 basegfx::B2DPoint( aLineEnd.X(),aLineEnd.Y()));
908 mpAnkor->SetHeight(mAnkorRect.Height());
910 else
912 mpAnkor = new SwPostItAnkor(basegfx::B2DPoint( mAnkorRect.Left() , mAnkorRect.Bottom()-5*15),
913 basegfx::B2DPoint( mAnkorRect.Left()-5*15 , mAnkorRect.Bottom()+5*15),
914 basegfx::B2DPoint( mAnkorRect.Left()+5*15 , mAnkorRect.Bottom()+5*15),
915 basegfx::B2DPoint( mAnkorRect.Left(), mAnkorRect.Bottom()+2*15),
916 basegfx::B2DPoint( mPageBorder ,mAnkorRect.Bottom()+2*15),
917 basegfx::B2DPoint( aLineStart.X(),aLineStart.Y()),
918 basegfx::B2DPoint( aLineEnd.X(),aLineEnd.Y()) , mColorAnkor,LineInfo(LINE_DASH,ANKORLINE_WIDTH*15), false);
919 mpAnkor->SetHeight(mAnkorRect.Height());
920 mpAnkor->setVisible(true);
921 mpAnkor->SetAnkorState(AS_TRI);
922 if (HasChildPathFocus())
923 mpAnkor->SetLineInfo(LineInfo(LINE_SOLID,ANKORLINE_WIDTH*15));
924 pOverlayManager->add(*mpAnkor);
928 else
930 if ( mpAnkor && (mpAnkor->getBasePosition() != basegfx::B2DPoint( mAnkorRect.Left() , mAnkorRect.Bottom()-5*15)) )
931 mpAnkor->SetTriPosition(basegfx::B2DPoint( mAnkorRect.Left() , mAnkorRect.Bottom() - 5* 15),
932 basegfx::B2DPoint( mAnkorRect.Left()-5*15 , mAnkorRect.Bottom()+5*15),
933 basegfx::B2DPoint( mAnkorRect.Left()+5*15 , mAnkorRect.Bottom()+5*15),
934 basegfx::B2DPoint( mAnkorRect.Left(), mAnkorRect.Bottom()+2*15),
935 basegfx::B2DPoint( mPageBorder ,mAnkorRect.Bottom()+2*15));
938 if (bChange)
940 Point aStart = EditWin()->PixelToLogic(GetPosPixel()+Point(0,GetSizePixel().Height()));
941 Point aEnd = EditWin()->PixelToLogic(GetPosPixel()+Point(GetSizePixel().Width()-1,GetSizePixel().Height()));
942 mpShadow->SetPosition(basegfx::B2DPoint(aStart.X(),aStart.Y()), basegfx::B2DPoint(aEnd.X(),aEnd.Y()));
945 if (mpMgr->ShowNotes())
947 if (IsFollow() && !HasChildPathFocus())
949 mpAnkor->SetAnkorState(AS_END);
951 else
953 mpAnkor->SetAnkorState(AS_ALL);
954 SwMarginWin* pWin = GetTopReplyNote();
955 if (IsFollow() && pWin )
956 pWin->Ankor()->SetAnkorState(AS_END);
961 void SwMarginWin::DoResize()
963 long aTextHeight = LogicToPixel( mpOutliner->CalcTextSize()).Height();
964 unsigned long aWidth = GetSizePixel().Width();
965 long aHeight = GetSizePixel().Height();
967 if (mbMeta)
969 aHeight -= GetMetaHeight();
970 mpMeta->Show();
971 mpPostItTxt->SetQuickHelpText(EMPTYSTRING);
973 else
975 mpMeta->Hide();
976 mpPostItTxt->SetQuickHelpText(mpMeta->GetText());
979 if ((aTextHeight > aHeight) && !IsPreview())
980 { // we need vertical scrollbars and have to reduce the width
981 aWidth -= GetScrollbarWidth();
982 mpVScrollbar->Show();
984 else
986 mpVScrollbar->Hide();
989 mpPostItTxt->SetPosSizePixel(0, 0, aWidth, aHeight);
990 mpMeta->SetPosSizePixel(0,aHeight,GetSizePixel().Width()-GetMetaButtonAreaWidth(),GetMetaHeight());
991 mpOutliner->SetPaperSize( PixelToLogic( Size(aWidth,aHeight) ) ) ;
992 mpOutlinerView->SetOutputArea( PixelToLogic( Rectangle(0,0,aWidth,aHeight) ) );
993 if (!mpVScrollbar->IsVisible())
994 { // if we do not have a scrollbar anymore, we want to see the complete text
995 mpOutlinerView->SetVisArea( PixelToLogic( Rectangle(0,0,aWidth,aHeight) ) );
997 mpVScrollbar->SetPosSizePixel( aWidth, 0, GetScrollbarWidth(), aHeight );
998 mpVScrollbar->SetVisibleSize( PixelToLogic(Size(0,aHeight)).Height() );
999 mpVScrollbar->SetPageSize( PixelToLogic(Size(0,aHeight)).Height() * 8 / 10 );
1000 mpVScrollbar->SetLineSize( mpOutliner->GetTextHeight() / 10 );
1001 //mpVScrollbar->SetThumbPos( mpOutlinerView->GetVisArea().Top()+ mpOutlinerView->GetEditView().GetCursor()->GetOffsetY());
1002 SetScrollbar();
1003 mpVScrollbar->SetRange( Range(0, mpOutliner->GetTextHeight()));
1005 //calculate rects for meta- button
1006 const Fraction& fx( GetMapMode().GetScaleX() );
1007 const Fraction& fy( GetMapMode().GetScaleY() );
1009 Point aPos( mpMeta->GetPosPixel());
1010 Point aBase( aPos.X() + aPos.X() + GetSizePixel().Width(), aPos.Y() );
1011 Point aLeft = PixelToLogic( Point( aBase.X() - (METABUTTON_WIDTH+5)*fx.GetNumerator()/fx.GetDenominator(), aBase.Y()+17*fy.GetNumerator()/fx.GetDenominator() ) );
1012 Point aRight = PixelToLogic( Point( aBase.X() - (METABUTTON_WIDTH-1)*fx.GetNumerator()/fx.GetDenominator(), aBase.Y()+17*fy.GetNumerator()/fy.GetDenominator() ) );
1013 Point aBottom = PixelToLogic( Point( aBase.X() - (METABUTTON_WIDTH+2)*fx.GetNumerator()/fx.GetDenominator(), aBase.Y()+20*fy.GetNumerator()/fy.GetDenominator() ) );
1015 //Point aLeft = PixelToLogic(Point(mpMeta->GetPosPixel().X()+mpMeta->GetPosPixel().X()+GetSizePixel().Width()-(GetMetaButtonWidth()+10)+5,mpMeta->GetPosPixel().Y()+17));
1016 //Point aRight = PixelToLogic(Point(mpMeta->GetPosPixel().X()+mpMeta->GetPosPixel().X()+GetSizePixel().Width()-(GetMetaButtonWidth()+10)+11,mpMeta->GetPosPixel().Y()+17));
1017 //Point aBottom = PixelToLogic(Point(mpMeta->GetPosPixel().X()+mpMeta->GetPosPixel().X()+GetSizePixel().Width()-(GetMetaButtonWidth()+10)+8,mpMeta->GetPosPixel().Y()+20));
1019 aPopupTriangle.clear();
1020 aPopupTriangle.append(basegfx::B2DPoint(aLeft.X(),aLeft.Y()));
1021 aPopupTriangle.append(basegfx::B2DPoint(aRight.X(),aRight.Y()));
1022 aPopupTriangle.append(basegfx::B2DPoint(aBottom.X(),aBottom.Y()));
1023 aPopupTriangle.setClosed(true);
1024 if (IsPreview())
1025 mRectMetaButton = PixelToLogic( Rectangle( Point(
1026 aPos.X()+GetSizePixel().Width()-(METABUTTON_WIDTH*4+10)*fx.GetNumerator()/fx.GetDenominator(),
1027 aPos.Y()+5*fy.GetNumerator()/fy.GetDenominator() ),
1028 Size( METABUTTON_WIDTH*4*fx.GetNumerator()/fx.GetDenominator(), METABUTTON_HEIGHT*fy.GetNumerator()/fy.GetDenominator() ) ) );
1029 else
1030 mRectMetaButton = PixelToLogic( Rectangle( Point(
1031 aPos.X()+GetSizePixel().Width()-(METABUTTON_WIDTH+10)*fx.GetNumerator()/fx.GetDenominator(),
1032 aPos.Y()+5*fy.GetNumerator()/fy.GetDenominator() ),
1033 Size( METABUTTON_WIDTH*fx.GetNumerator()/fx.GetDenominator(), METABUTTON_HEIGHT*fy.GetNumerator()/fy.GetDenominator() ) ) );
1036 void SwMarginWin::SetSizePixel( const Size& rNewSize )
1038 Window::SetSizePixel(rNewSize);
1040 if (mpShadow)
1042 Point aStart = EditWin()->PixelToLogic(GetPosPixel()+Point(0,GetSizePixel().Height()));
1043 Point aEnd = EditWin()->PixelToLogic(GetPosPixel()+Point(GetSizePixel().Width()-1,GetSizePixel().Height()));
1044 mpShadow->SetPosition(basegfx::B2DPoint(aStart.X(),aStart.Y()), basegfx::B2DPoint(aEnd.X(),aEnd.Y()));
1048 void SwMarginWin::SetScrollbar()
1050 mpVScrollbar->SetThumbPos( mpOutlinerView->GetVisArea().Top()+ mpOutlinerView->GetEditView().GetCursor()->GetOffsetY());
1053 void SwMarginWin::ResizeIfNeccessary(long aOldHeight, long aNewHeight)
1055 if (aOldHeight != aNewHeight)
1057 //check for lower border or next note
1058 long aBorder = mpMgr->GetNextBorder();
1059 if (aBorder != -1)
1061 if (aNewHeight > GetMinimumSizeWithoutMeta())
1063 long aNewLowerValue = GetPosPixel().Y() + aNewHeight + GetMetaHeight();
1064 if (aNewLowerValue < aBorder)
1065 SetSizePixel(Size(GetSizePixel().Width(),aNewHeight+GetMetaHeight()));
1066 else
1067 SetSizePixel(Size(GetSizePixel().Width(),aBorder - GetPosPixel().Y()));
1068 DoResize();
1069 Invalidate();
1071 else
1073 if (GetSizePixel().Height() != GetMinimumSizeWithoutMeta() + GetMetaHeight())
1074 SetSizePixel(Size(GetSizePixel().Width(),GetMinimumSizeWithoutMeta() + GetMetaHeight()));
1075 DoResize();
1076 Invalidate();
1079 else
1081 DoResize();
1082 Invalidate();
1085 else
1087 SetScrollbar();
1091 void SwMarginWin::SetColor(Color aColorDark,Color aColorLight, Color aColorAnkor)
1093 mColorDark = aColorDark;
1094 mColorLight = aColorLight;
1095 mColorAnkor = aColorAnkor;
1097 if ( !Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
1099 //Wallpaper aWall(Gradient(GRADIENT_LINEAR,mColorLight,mColorDark));
1100 //mpPostItTxt->SetBackground(aWall);
1102 mpMeta->SetControlBackground(mColorDark);
1103 AllSettings aSettings = mpMeta->GetSettings();
1104 StyleSettings aStyleSettings = aSettings.GetStyleSettings();
1105 aStyleSettings.SetFieldTextColor(aColorAnkor);
1106 aSettings.SetStyleSettings(aStyleSettings);
1107 mpMeta->SetSettings(aSettings);
1109 AllSettings aSettings2 = mpVScrollbar->GetSettings();
1110 StyleSettings aStyleSettings2 = aSettings2.GetStyleSettings();
1111 aStyleSettings2.SetButtonTextColor(Color(0,0,0));
1112 //aStyleSettings2.SetLightColor(mColorAnkor);
1113 aStyleSettings2.SetCheckedColor(mColorLight); //hintergund
1114 //aStyleSettings2.SetLightBorderColor(mColorAnkor);
1115 aStyleSettings2.SetShadowColor(mColorAnkor);
1116 aStyleSettings2.SetFaceColor(mColorDark);
1117 aSettings2.SetStyleSettings(aStyleSettings2);
1118 mpVScrollbar->SetSettings(aSettings2);
1122 void SwMarginWin::SetMarginSide(bool aMarginSide)
1124 mbMarginSide = aMarginSide;
1127 void SwMarginWin::SetReadonly(BOOL bSet)
1129 mbReadonly = bSet;
1130 View()->SetReadOnly(bSet);
1133 void SwMarginWin::SetLanguage(const SvxLanguageItem aNewItem)
1135 Engine()->SetModifyHdl( Link() );
1136 ESelection aOld = View()->GetSelection();
1138 ESelection aNewSelection( 0, 0, (USHORT)Engine()->GetParagraphCount()-1, USHRT_MAX );
1139 View()->SetSelection( aNewSelection );
1140 SfxItemSet aEditAttr(View()->GetAttribs());
1141 aEditAttr.Put(aNewItem);
1142 View()->SetAttribs( aEditAttr );
1144 View()->SetSelection(aOld);
1145 Engine()->SetModifyHdl( LINK( this, SwPostIt, ModifyHdl ) );
1147 const SwViewOption* pVOpt = DocView()->GetWrtShellPtr()->GetViewOptions();
1148 ULONG nCntrl = Engine()->GetControlWord();
1149 // turn off
1150 if (!pVOpt->IsOnlineSpell())
1151 nCntrl &= ~EE_CNTRL_ONLINESPELLING;
1152 else
1153 nCntrl &= ~EE_CNTRL_ONLINESPELLING;
1154 Engine()->SetControlWord(nCntrl);
1156 //turn back on
1157 if (pVOpt->IsOnlineSpell())
1158 nCntrl |= EE_CNTRL_ONLINESPELLING;
1159 else
1160 nCntrl &= ~EE_CNTRL_ONLINESPELLING;
1161 Engine()->SetControlWord(nCntrl);
1163 Engine()->CompleteOnlineSpelling();
1164 Invalidate();
1167 void SwMarginWin::DataChanged( const DataChangedEvent& aEvent)
1169 Window::DataChanged( aEvent );
1172 void SwMarginWin::GetFocus()
1174 if (mpPostItTxt)
1175 mpPostItTxt->GrabFocus();
1178 void SwMarginWin::LoseFocus()
1182 void SwMarginWin::ShowNote()
1184 SetPosAndSize();
1185 if (!IsVisible())
1186 Window::Show();
1187 if (mpAnkor && !mpShadow->isVisible())
1188 mpShadow->setVisible(true);
1189 if (mpAnkor && !mpAnkor->isVisible())
1190 mpAnkor->setVisible(true);
1193 void SwMarginWin::HideNote()
1195 if (IsVisible())
1196 Window::Hide();
1197 if (mpAnkor)
1199 if (mpMgr->IsShowAnkor())
1200 mpAnkor->SetAnkorState(AS_TRI);
1201 else
1202 mpAnkor->setVisible(false);
1204 if (mpShadow && mpShadow->isVisible())
1205 mpShadow->setVisible(false);
1208 void SwMarginWin::ActivatePostIt()
1210 mpOutliner->ClearModifyFlag();
1211 mpOutliner->GetUndoManager().Clear();
1213 CheckMetaText();
1214 SetViewState(SS_EDIT);
1215 View()->ShowCursor();
1217 mpOutlinerView->GetEditView().SetInsertMode(mpView->GetWrtShellPtr()->IsInsMode());
1219 if ( !Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
1220 View()->SetBackgroundColor(mColorDark);
1222 // mpPostItTxt->SetBackground(Wallpaper(mColorDark));
1225 void SwMarginWin::DeactivatePostIt()
1227 // remove selection, #i87073#
1228 if (View()->GetEditView().HasSelection())
1230 ESelection aSelection = View()->GetEditView().GetSelection();
1231 aSelection.nEndPara = aSelection.nStartPara;
1232 aSelection.nEndPos = aSelection.nStartPos;
1233 View()->GetEditView().SetSelection(aSelection);
1236 mpOutliner->CompleteOnlineSpelling();
1238 SetViewState(SS_NORMAL);
1239 // write the visible text back into the SwField
1240 UpdateData();
1242 if ( !Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
1243 View()->SetBackgroundColor(COL_TRANSPARENT);
1245 //mpPostItTxt->SetBackground(Gradient(GRADIENT_LINEAR,mColorLight,mColorDark));
1247 if ( !IsProtected() &&
1248 //if (!IsReadOnly() && (GetStatus()!=SwPostItHelper::DELETED) &&
1249 Engine()->GetEditEngine().GetText()==String(EMPTYSTRING) )
1250 mnEventId = Application::PostUserEvent( LINK( this, SwMarginWin, DeleteHdl), 0 );
1253 void SwMarginWin::ToggleInsMode()
1255 if (!mpView->GetWrtShell().IsRedlineOn())
1257 //change outliner
1258 mpOutlinerView->GetEditView().SetInsertMode(!mpOutlinerView->GetEditView().IsInsertMode());
1259 //change documnet
1260 mpView->GetWrtShell().ToggleInsMode();
1261 //update statusbar
1262 SfxBindings &rBnd = mpView->GetViewFrame()->GetBindings();
1263 rBnd.Invalidate(SID_ATTR_INSERT);
1264 rBnd.Update(SID_ATTR_INSERT);
1268 void SwMarginWin::ExecuteCommand(USHORT nSlot)
1270 switch (nSlot)
1272 case FN_POSTIT:
1273 case FN_REPLY:
1275 // if this note is empty, it will be deleted once losing the focus, so no reply, but only a new note
1276 // will be created
1277 SwView* pView = DocView();
1278 if (Engine()->GetEditEngine().GetText() != String(EMPTYSTRING))
1280 OutlinerParaObject* pPara = new OutlinerParaObject(*View()->GetEditView().CreateTextObject());
1281 Mgr()->RegisterAnswer(pPara);
1283 if (Mgr()->GetActivePostIt())
1284 Mgr()->SetActivePostIt(0);
1285 SwitchToFieldPos();
1286 pView->GetViewFrame()->GetDispatcher()->Execute(FN_POSTIT);
1287 break;
1289 case FN_DELETE_COMMENT:
1290 case FN_DELETE_NOTE:
1292 //Delete(); // do not kill the parent of our open popup menu
1293 mnEventId = Application::PostUserEvent( LINK( this, SwMarginWin, DeleteHdl), 0 );
1294 break;
1296 case FN_HIDE_NOTE:
1297 if ( Mgr()->GetActivePostIt() == this )
1299 Mgr()->SetActivePostIt(0);
1300 // put the cursor back into the document
1301 SwitchToFieldPos();
1303 Mgr()->Hide(mpFld);
1304 break;
1306 case FN_DELETE_ALL_NOTES:
1307 case FN_HIDE_ALL_NOTES:
1308 // not possible as slot as this would require that "this" is the active postit
1309 DocView()->GetViewFrame()->GetBindings().Execute( nSlot, 0, 0, SFX_CALLMODE_ASYNCHRON );
1310 break;
1311 case FN_DELETE_NOTE_AUTHOR:
1312 case FN_HIDE_NOTE_AUTHOR:
1314 // not possible as slot as this would require that "this" is the active postit
1315 SfxStringItem aItem( nSlot, GetAuthor() );
1316 const SfxPoolItem* aItems[2];
1317 aItems[0] = &aItem;
1318 aItems[1] = 0;
1319 DocView()->GetViewFrame()->GetBindings().Execute( nSlot, aItems, 0, SFX_CALLMODE_ASYNCHRON );
1321 default:
1322 mpView->GetViewFrame()->GetBindings().Execute( nSlot );
1323 break;
1327 bool SwMarginWin::CalcFollow()
1329 return false;
1332 SwEditWin* SwMarginWin::EditWin()
1334 return &mpView->GetEditWin();
1337 String SwPostIt::GetAuthor()
1339 return mpFld->GetPar1();
1342 Date SwPostIt::GetDate()
1344 return mpFld->GetDate();
1347 Time SwPostIt::GetTime()
1349 return mpFld->GetTime();
1352 long SwMarginWin::GetPostItTextHeight()
1354 return mpOutliner ? LogicToPixel(mpOutliner->CalcTextSize()).Height() : 0;
1357 void SwMarginWin::SwitchToPostIt(USHORT aDirection)
1359 if (mpMgr)
1361 SwMarginWin* pPostIt = mpMgr->GetNextPostIt(aDirection, this);
1362 if (pPostIt)
1363 pPostIt->GrabFocus();
1367 void SwMarginWin::MouseButtonDown( const MouseEvent& /*rMEvt */)
1371 void SwMarginWin::MouseMove( const MouseEvent& rMEvt )
1373 if (mRectMetaButton.IsInside(PixelToLogic(rMEvt.GetPosPixel())))
1375 if (!mbMouseOverButton)
1377 Invalidate(mRectMetaButton);
1378 mbMouseOverButton = true;
1381 else
1383 if (mbMouseOverButton)
1385 Invalidate(mRectMetaButton);
1386 mbMouseOverButton = false;
1391 void SwMarginWin::Delete()
1393 if ( Mgr()->GetActivePostIt() == this)
1395 Mgr()->SetActivePostIt(0);
1396 // if the note is empty, the previous line will send a delete event, but we are already there
1397 if (mnEventId)
1399 Application::RemoveUserEvent( mnEventId );
1400 mnEventId = 0;
1405 IMPL_LINK(SwMarginWin, ScrollHdl, ScrollBar*, pScroll)
1407 long nDiff = View()->GetEditView().GetVisArea().Top() - pScroll->GetThumbPos();
1408 View()->Scroll( 0, nDiff );
1409 return 0;
1412 IMPL_LINK(SwMarginWin, ModifyHdl, void*, pVoid)
1414 // no warnings, please
1415 pVoid=0;
1416 DocView()->GetDocShell()->SetModified(sal_True);
1417 return 0;
1420 IMPL_LINK(SwMarginWin, DeleteHdl, void*, pVoid)
1422 // no warnings, please
1423 pVoid=0;
1424 mnEventId = 0;
1425 Delete();
1426 return 0;
1430 void SwMarginWin::ResetAttributes()
1432 mpOutlinerView->RemoveAttribsKeepLanguages(TRUE);
1433 mpOutliner->RemoveFields(TRUE);
1434 SfxItemSet aSet( mpView->GetDocShell()->GetPool() );
1435 aSet.Put(SvxFontHeightItem(200,100,EE_CHAR_FONTHEIGHT));
1436 mpOutlinerView->SetAttribs(aSet);
1439 sal_Int32 SwMarginWin::GetScrollbarWidth()
1441 return mpView->GetWrtShell().GetViewOptions()->GetZoom() / 10;
1444 sal_Int32 SwMarginWin::GetMetaButtonAreaWidth()
1446 const Fraction& f( GetMapMode().GetScaleX() );
1447 if (IsPreview())
1448 return 3 * METABUTTON_AREA_WIDTH * f.GetNumerator() / f.GetDenominator();
1449 else
1450 return METABUTTON_AREA_WIDTH * f.GetNumerator() / f.GetDenominator();
1453 sal_Int32 SwMarginWin::GetMetaHeight()
1455 const Fraction& f( GetMapMode().GetScaleY() );
1456 return POSTIT_META_HEIGHT * f.GetNumerator() / f.GetDenominator();
1459 sal_Int32 SwMarginWin::GetMinimumSizeWithMeta()
1461 return mpMgr->GetMinimumSizeWithMeta();
1464 sal_Int32 SwMarginWin::GetMinimumSizeWithoutMeta()
1466 const Fraction& f( GetMapMode().GetScaleY() );
1467 return POSTIT_MINIMUMSIZE_WITHOUT_META * f.GetNumerator() / f.GetDenominator();
1470 void SwMarginWin::SetSpellChecking()
1472 const SwViewOption* pVOpt = mpView->GetWrtShellPtr()->GetViewOptions();
1473 ULONG nCntrl = mpOutliner->GetControlWord();
1474 if (pVOpt->IsOnlineSpell())
1475 nCntrl |= EE_CNTRL_ONLINESPELLING;
1476 else
1477 nCntrl &= ~EE_CNTRL_ONLINESPELLING;
1478 mpOutliner->SetControlWord(nCntrl);
1480 mpOutliner->CompleteOnlineSpelling();
1481 Invalidate();
1484 void SwMarginWin::SetViewState(ShadowState bState)
1486 switch (bState)
1488 case SS_EDIT:
1490 if (mpAnkor)
1492 mpAnkor->SetAnkorState(AS_ALL);
1493 SwMarginWin* pWin = GetTopReplyNote();
1494 if (IsFollow() && pWin)
1495 pWin->Ankor()->SetAnkorState(AS_END);
1496 mpAnkor->SetLineInfo(LineInfo(LINE_SOLID,ANKORLINE_WIDTH*15));
1498 if (mpShadow)
1499 mpShadow->SetShadowState(bState);
1500 break;
1502 case SS_VIEW:
1504 if (mpAnkor)
1505 mpAnkor->SetLineInfo(LineInfo(LINE_SOLID,ANKORLINE_WIDTH*15));
1506 if (mpShadow)
1507 mpShadow->SetShadowState(bState);
1508 break;
1510 case SS_NORMAL:
1512 if (mpAnkor)
1514 if (IsFollow())
1516 // if there is no visible parent note, we want to see the complete anchor ??
1517 //if (IsAnyStackParentVisible())
1518 mpAnkor->SetAnkorState(AS_END);
1519 SwMarginWin* pTopWinSelf = GetTopReplyNote();
1520 SwMarginWin* pTopWinActive = mpMgr->GetActivePostIt() ? mpMgr->GetActivePostIt()->GetTopReplyNote() : 0;
1521 if (pTopWinSelf && (pTopWinSelf!=pTopWinActive))
1523 if (pTopWinSelf!=mpMgr->GetActivePostIt())
1524 pTopWinSelf->Ankor()->SetLineInfo(LineInfo(LINE_DASH,ANKORLINE_WIDTH*15));
1525 pTopWinSelf->Ankor()->SetAnkorState(AS_ALL);
1528 mpAnkor->SetLineInfo(LineInfo(LINE_DASH,ANKORLINE_WIDTH*15));
1530 if (mpShadow)
1531 mpShadow->SetShadowState(bState);
1532 break;
1537 bool SwMarginWin::IsAnyStackParentVisible()
1539 SwMarginWin* pMarginWin = mpMgr->GetNextPostIt(KEY_PAGEUP, this);
1540 while (pMarginWin)
1542 if (pMarginWin->IsFollow())
1544 pMarginWin = mpMgr->GetNextPostIt(KEY_PAGEUP, pMarginWin);
1545 if (pMarginWin && pMarginWin->IsVisible())
1546 return true;
1548 else
1549 return pMarginWin && pMarginWin->IsVisible() ? true : false;
1551 return false;
1554 SwMarginWin* SwMarginWin::GetTopReplyNote()
1556 SwMarginWin* pTopNote = 0;
1557 SwMarginWin* pMarginWin = mpMgr->GetNextPostIt(KEY_PAGEUP, this);
1558 while (pMarginWin)
1560 pTopNote = pMarginWin;
1561 pMarginWin = pMarginWin->IsFollow() ? mpMgr->GetNextPostIt(KEY_PAGEUP, pMarginWin) : 0;
1563 return pTopNote;
1566 void SwMarginWin::SwitchToFieldPos()
1568 if ( Mgr()->GetActivePostIt() == this )
1569 Mgr()->SetActivePostIt(0);
1570 GotoPos();
1571 sal_uInt32 aCount = MoveCaret();
1572 if (aCount)
1573 DocView()->GetDocShell()->GetWrtShell()->SwCrsrShell::Right(aCount, 0, FALSE);
1574 GrabFocusToDocument();
1577 String SwMarginWin::GetAuthor()
1579 return String(EMPTYSTRING);
1582 Date SwMarginWin::GetDate()
1584 return Date(0);
1587 Time SwMarginWin::GetTime()
1589 return Time(0);
1592 SvxLanguageItem SwMarginWin::GetLanguage(void)
1594 return SvxLanguageItem(SwLangHelper::GetLanguage(DocView()->GetWrtShell(),RES_CHRATR_LANGUAGE),RES_CHRATR_LANGUAGE);
1597 /***** SwPostIt *********************************************/
1598 SwPostIt::SwPostIt( Window* pParent, WinBits nBits, SwFmtFld* aField,SwPostItMgr* aMgr,SwPostItBits aBits)
1599 : SwMarginWin(pParent,nBits,aMgr,aBits),
1600 mpFmtFld(aField),
1601 mpFld( static_cast<SwPostItField*>(aField->GetFld())),
1602 mStatus(SwPostItHelper::INVISIBLE)
1606 void SwPostIt::SetPostItText()
1608 // get text from SwPostItField and insert into our textview
1609 Engine()->SetModifyHdl( Link() );
1610 Engine()->EnableUndo( FALSE );
1611 mpFld = static_cast<SwPostItField*>(mpFmtFld->GetFld());
1612 if( mpFld->GetTextObject() )
1613 Engine()->SetText( *mpFld->GetTextObject() );
1614 else
1616 Engine()->Clear();
1617 SfxItemSet item( DocView()->GetDocShell()->GetPool() );
1618 item.Put(SvxFontHeightItem(200,100,EE_CHAR_FONTHEIGHT));
1619 item.Put(SvxFontItem(FAMILY_SWISS,GetSettings().GetStyleSettings().GetFieldFont().GetName(),
1620 EMPTYSTRING,PITCH_DONTKNOW,RTL_TEXTENCODING_DONTKNOW,EE_CHAR_FONTINFO));
1621 View()->SetAttribs(item);
1622 View()->InsertText(mpFld->GetPar2(),false);
1625 Engine()->ClearModifyFlag();
1626 Engine()->GetUndoManager().Clear();
1627 Engine()->EnableUndo( TRUE );
1628 Engine()->SetModifyHdl( LINK( this, SwPostIt, ModifyHdl ) );
1629 Invalidate();
1632 void SwPostIt::UpdateData()
1634 if ( Engine()->IsModified() )
1636 SwPosition * pPos = mpFmtFld->GetTxtFld()->GetPosition();
1637 if ( pPos )
1639 SwField* pOldField = mpFld->Copy();
1640 mpFld->SetPar2(Engine()->GetEditEngine().GetText());
1641 mpFld->SetTextObject(Engine()->CreateParaObject());
1642 DocView()->GetDocShell()->GetDoc()->AppendUndo(new SwUndoFieldFromDoc(*pPos, *pOldField, *mpFld, 0, true));
1643 delete pOldField;
1644 delete pPos;
1645 // so we get a new layout of notes (ankor position is still the same and we would otherwise not get one)
1646 Mgr()->SetLayout();
1647 DocView()->GetDocShell()->SetModified();
1650 Engine()->ClearModifyFlag();
1651 Engine()->GetUndoManager().Clear();
1654 void SwPostIt::SetChangeTracking(SwPostItHelper::SwLayoutStatus& aStatus,Color aColor)
1656 if ( (mStatus != aStatus) || (mChangeColor != aColor) )
1658 mStatus = aStatus;
1659 mChangeColor = aColor;
1660 Invalidate();
1664 void SwPostIt::Delete()
1666 SwMarginWin::Delete();
1667 // we delete the field directly, the Mgr cleans up the PostIt by listening
1668 DocView()->GetWrtShellPtr()->GotoField(*mpFmtFld);
1669 GrabFocusToDocument();
1670 DocView()->GetWrtShellPtr()->DelRight();
1673 void SwPostIt::GotoPos()
1675 DocView()->GetDocShell()->GetWrtShell()->GotoField(*mpFmtFld);
1678 sal_uInt32 SwPostIt::MoveCaret()
1680 // if this is an answer, do not skip over all following ones, but insert directly behind the current one
1681 // but when just leaving a note, skip all following ones as well to continue typing
1682 return Mgr()->IsAnswer() ? 1 : 1 + CountFollowing();
1685 //returns true, if there is another note right before this note
1686 bool SwPostIt::CalcFollow()
1688 SwPosition * pPos = mpFmtFld->GetTxtFld()->GetPosition();
1689 const SwTxtNode* pTxtNd = pPos->nNode.GetNode().GetTxtNode();
1690 SwTxtAttr* pTxtAttr = pTxtNd ? pTxtNd->GetTxtAttr( pPos->nContent.GetIndex()-1,RES_TXTATR_FIELD ) : 0;
1691 const SwField* pFld = pTxtAttr ? pTxtAttr->GetFld().GetFld() : 0;
1692 delete pPos;
1693 return pFld && (pFld->Which()== RES_POSTITFLD);
1696 // counts how many SwPostItField we have right after the current one
1697 sal_uInt32 SwPostIt::CountFollowing()
1699 sal_uInt32 aCount = 1; // we start with 1, so we have to subtract one at the end again
1700 SwPosition * pPos = mpFmtFld->GetTxtFld()->GetPosition();
1701 const SwTxtNode* pTxtNd = pPos->nNode.GetNode().GetTxtNode();
1703 SwTxtAttr* pTxtAttr = pTxtNd ? pTxtNd->GetTxtAttr( pPos->nContent.GetIndex()+1,RES_TXTATR_FIELD ) : 0;
1704 SwField* pFld = pTxtAttr ? const_cast<SwField*>(pTxtAttr->GetFld().GetFld()) : 0;
1705 while (pFld && (pFld->Which()== RES_POSTITFLD))
1707 aCount++;
1708 pTxtAttr = pTxtNd ? pTxtNd->GetTxtAttr( pPos->nContent.GetIndex() + aCount,RES_TXTATR_FIELD ) : 0;
1709 pFld = pTxtAttr ? const_cast<SwField*>(pTxtAttr->GetFld().GetFld()) : 0;
1711 delete pPos;
1712 return aCount - 1;
1715 void SwPostIt::MouseButtonDown( const MouseEvent& rMEvt )
1717 if (mRectMetaButton.IsInside(PixelToLogic(rMEvt.GetPosPixel())) && rMEvt.IsLeft())
1719 if (IsPreview())
1721 doLazyDelete();
1722 if (Mgr())
1724 SwPostIt* pPostIt = dynamic_cast<SwPostIt*>(Mgr()->GetPostIt(mpFmtFld));
1725 if (pPostIt)
1727 pPostIt->GrabFocus();
1728 Mgr()->MakeVisible(pPostIt);
1733 else
1735 if ( mbReadonly )
1737 mpButtonPopup->EnableItem(FN_REPLY,false);
1738 mpButtonPopup->EnableItem(FN_DELETE_NOTE,false);
1739 mpButtonPopup->EnableItem(FN_DELETE_NOTE_AUTHOR,false);
1740 mpButtonPopup->EnableItem(FN_DELETE_ALL_NOTES,false);
1742 else
1744 if (IsProtected())
1745 mpButtonPopup->EnableItem(FN_DELETE_NOTE,false);
1746 else
1747 mpButtonPopup->EnableItem(FN_DELETE_NOTE,true);
1748 mpButtonPopup->EnableItem(FN_DELETE_NOTE_AUTHOR,true);
1749 mpButtonPopup->EnableItem(FN_DELETE_ALL_NOTES,true);
1751 SvtUserOptions aUserOpt;
1752 String sAuthor;
1753 if( !(sAuthor = aUserOpt.GetFullName()).Len())
1754 if( !(sAuthor = aUserOpt.GetID()).Len() )
1755 sAuthor = String( SW_RES( STR_REDLINE_UNKNOWN_AUTHOR ));
1756 // do not allow to reply to ourself and no answer possible if this note is in a protected section
1757 if ((sAuthor == GetAuthor()) || (IsProtected()))
1758 mpButtonPopup->EnableItem(FN_REPLY,false);
1759 else
1760 mpButtonPopup->EnableItem(FN_REPLY,true);
1762 // show the popup menu and execute the selected command
1763 ExecuteCommand( mpButtonPopup->Execute( this,Rectangle(LogicToPixel(mRectMetaButton.BottomLeft()),LogicToPixel(mRectMetaButton.BottomLeft())),POPUPMENU_EXECUTE_DOWN | POPUPMENU_NOMOUSEUPCLOSE) );
1768 void SwPostIt::SetPopup()
1770 mpButtonPopup = new PopupMenu(SW_RES(MN_ANNOTATION_BUTTON));
1771 //mpButtonPopup->SetMenuFlags(MENU_FLAG_ALWAYSSHOWDISABLEDENTRIES);
1772 XubString aText = mpButtonPopup->GetItemText( FN_DELETE_NOTE_AUTHOR );
1773 SwRewriter aRewriter;
1774 aRewriter.AddRule(UNDO_ARG1,GetAuthor());
1775 aText = aRewriter.Apply(aText);
1776 mpButtonPopup->SetItemText(FN_DELETE_NOTE_AUTHOR,aText);
1779 void SwPostIt::InitAnswer(OutlinerParaObject* pText)
1781 //collect our old meta data
1782 SwMarginWin* pWin = Mgr()->GetNextPostIt(KEY_PAGEUP, this);
1783 const LocaleDataWrapper& rLocalData = SvtSysLocale().GetLocaleData();
1784 String aText = String(SW_RES(STR_REPLY));
1785 SwRewriter aRewriter;
1786 aRewriter.AddRule(UNDO_ARG1, pWin->GetAuthor());
1787 aText = aRewriter.Apply(aText);
1788 aText.Append(String(rtl::OUString::createFromAscii(" (") +
1789 String(rLocalData.getDate( pWin->GetDate())) + rtl::OUString::createFromAscii(", ") +
1790 String(rLocalData.getTime( pWin->GetTime(),false)) + rtl::OUString::createFromAscii("): \"")));
1791 View()->InsertText(aText,false);
1793 // insert old, selected text or "..."
1794 // TOOD: iterate over all paragraphs, not only first one to find out if it is empty
1795 if (pText->GetTextObject().GetText(0) != String(EMPTYSTRING))
1796 View()->GetEditView().InsertText(pText->GetTextObject());
1797 else
1798 View()->InsertText(rtl::OUString::createFromAscii("..."),false);
1799 View()->InsertText(rtl::OUString::createFromAscii("\"\n"),false);
1801 View()->SetSelection(ESelection(0x0,0x0,0xFFFF,0xFFFF));
1802 SfxItemSet aAnswerSet( DocView()->GetDocShell()->GetPool() );
1803 aAnswerSet.Put(SvxFontHeightItem(200,80,EE_CHAR_FONTHEIGHT));
1804 aAnswerSet.Put(SvxPostureItem(ITALIC_NORMAL,EE_CHAR_ITALIC));
1805 View()->SetAttribs(aAnswerSet);
1806 View()->SetSelection(ESelection(0xFFFF,0xFFFF,0xFFFF,0xFFFF));
1808 //remove all attributes and reset our standard ones
1809 View()->GetEditView().RemoveAttribsKeepLanguages(true);
1810 SfxItemSet aNormalSet( DocView()->GetDocShell()->GetPool() );
1811 aNormalSet.Put(SvxFontHeightItem(200,100,EE_CHAR_FONTHEIGHT));
1812 aNormalSet.Put(SvxFontItem(FAMILY_SWISS,GetSettings().GetStyleSettings().GetFieldFont().GetName(),
1813 EMPTYSTRING,PITCH_DONTKNOW,RTL_TEXTENCODING_DONTKNOW,EE_CHAR_FONTINFO));
1814 View()->SetAttribs(aNormalSet);
1815 // lets insert an undo step so the initial text can be easily deleted
1816 // but do not use UpdateData() directly, would set modified state again and reentrance into Mgr
1817 Engine()->SetModifyHdl( Link() );
1818 SwPosition * pPos = mpFmtFld->GetTxtFld()->GetPosition();
1819 if ( pPos )
1821 SwField* pOldField = mpFld->Copy();
1822 mpFld->SetPar2(Engine()->GetEditEngine().GetText());
1823 mpFld->SetTextObject(Engine()->CreateParaObject());
1824 DocView()->GetDocShell()->GetDoc()->AppendUndo(new SwUndoFieldFromDoc(*pPos, *pOldField, *mpFld, 0, true));
1825 delete pOldField;
1826 delete pPos;
1828 Engine()->SetModifyHdl( LINK( this, SwPostIt, ModifyHdl ) );
1829 Engine()->ClearModifyFlag();
1830 Engine()->GetUndoManager().Clear();
1833 SvxLanguageItem SwPostIt::GetLanguage(void)
1835 // set initial language for outliner
1836 USHORT nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( mpFld->GetLanguage() );
1837 USHORT nLangWhichId = 0;
1838 switch (nScriptType)
1840 case SCRIPTTYPE_LATIN : nLangWhichId = EE_CHAR_LANGUAGE ; break;
1841 case SCRIPTTYPE_ASIAN : nLangWhichId = EE_CHAR_LANGUAGE_CJK; break;
1842 case SCRIPTTYPE_COMPLEX : nLangWhichId = EE_CHAR_LANGUAGE_CTL; break;
1843 default: DBG_ERROR("GetLanguage: wrong script tye");
1845 return SvxLanguageItem(mpFld->GetLanguage(),nLangWhichId);
1848 bool SwPostIt::IsProtected()
1850 bool aReturn;
1851 aReturn = mpFmtFld ? (SwMarginWin::IsProtected() || (mStatus==SwPostItHelper::DELETED) ||
1852 mpFmtFld->IsProtect()) : (SwMarginWin::IsProtected() || (mStatus==SwPostItHelper::DELETED));
1853 return aReturn;
1856 /********** SwRedComment**************/
1858 SwRedComment::SwRedComment( Window* pParent, WinBits nBits,SwPostItMgr* aMgr,SwPostItBits aBits,SwRedline* pRed)
1859 : SwMarginWin(pParent,nBits,aMgr,aBits),
1860 pRedline(pRed)
1864 void SwRedComment::SetPopup()
1866 mpButtonPopup = new PopupMenu(SW_RES(MN_REDCOMMENT_BUTTON));
1867 //mpButtonPopup->SetMenuFlags(MENU_FLAG_ALWAYSSHOWDISABLEDENTRIES);
1870 void SwRedComment::UpdateData()
1872 if ( Engine()->IsModified() )
1874 // so we get a new layout of notes (ankor position is still the same and we would otherwise not get one)
1875 Mgr()->SetLayout();
1876 // SetRedline is calling SetModified already
1877 DocView()->GetWrtShell().SetRedlineComment(Engine()->GetEditEngine().GetText());
1879 Engine()->ClearModifyFlag();
1880 Engine()->GetUndoManager().Clear();
1883 void SwRedComment::SetPostItText()
1885 Engine()->SetModifyHdl( Link() );
1886 Engine()->EnableUndo( FALSE );
1888 Engine()->Clear();
1889 SfxItemSet item( DocView()->GetDocShell()->GetPool() );
1890 item.Put(SvxFontHeightItem(200,100,EE_CHAR_FONTHEIGHT));
1891 item.Put(SvxFontItem(FAMILY_SWISS,GetSettings().GetStyleSettings().GetFieldFont().GetName(),
1892 EMPTYSTRING,PITCH_DONTKNOW,RTL_TEXTENCODING_DONTKNOW,EE_CHAR_FONTINFO));
1893 View()->SetAttribs(item);
1894 View()->InsertText(pRedline->GetComment(),false);
1896 Engine()->ClearModifyFlag();
1897 Engine()->GetUndoManager().Clear();
1898 Engine()->EnableUndo( TRUE );
1899 Engine()->SetModifyHdl( LINK( this, SwMarginWin, ModifyHdl ) );
1900 Invalidate();
1903 void SwRedComment::DeactivatePostIt()
1905 SwMarginWin::DeactivatePostIt();
1906 // current Redline is still selected
1907 DocView()->GetWrtShellPtr()->ClearMark();
1910 void SwRedComment::ActivatePostIt()
1912 SwMarginWin::ActivatePostIt();
1914 // do we want the redline selected?
1915 // otherwise, SwRedComment::ActivatePostIt() as well as SwRedComment::DeactivatePostIt()
1916 // can be thrown out completly
1917 DocView()->GetDocShell()->GetWrtShell()->GotoRedline(
1918 DocView()->GetDocShell()->GetWrtShell()->FindRedlineOfData(pRedline->GetRedlineData()),true);
1921 void SwRedComment::MouseButtonDown( const MouseEvent& rMEvt )
1923 if (mRectMetaButton.IsInside(PixelToLogic(rMEvt.GetPosPixel())) && rMEvt.IsLeft())
1925 ExecuteCommand( mpButtonPopup->Execute( this,Rectangle(LogicToPixel(mRectMetaButton.BottomLeft()),LogicToPixel(mRectMetaButton.BottomLeft())),POPUPMENU_EXECUTE_DOWN | POPUPMENU_NOMOUSEUPCLOSE) );
1929 void SwRedComment::Delete()
1931 SwMarginWin::Delete();
1932 // we are not neccessarily on our redline, so let's move there
1933 GotoPos();
1934 DocView()->GetWrtShell().SetRedlineComment(EMPTYSTRING);
1935 DocView()->GetWrtShell().ClearMark();
1936 // so we get a new layout of notes (ankor position is still the same and we would otherwise not get one)
1937 Mgr()->SetLayout();
1938 Mgr()->RemoveItem(pRedline);
1941 void SwRedComment::GotoPos()
1943 DocView()->GetDocShell()->GetWrtShell()->GotoRedline(
1944 DocView()->GetDocShell()->GetWrtShell()->FindRedlineOfData(pRedline->GetRedlineData()));
1947 String SwRedComment::GetAuthor()
1949 return pRedline->GetAuthorString();
1952 Date SwRedComment::GetDate()
1954 return pRedline->GetTimeStamp().GetDate();
1957 Time SwRedComment::GetTime()
1959 return pRedline->GetTimeStamp().GetTime();
1962 bool SwRedComment::IsProtected()
1964 return SwMarginWin::IsProtected() || pRedline->Start()->nNode.GetNode().GetTxtNode()->IsInProtectSect();
1968 /****** SwPostItShadow ***********************************************************/
1969 SwPostItShadow::SwPostItShadow(const basegfx::B2DPoint& rBasePos,const basegfx::B2DPoint& rSecondPosition,
1970 Color aBaseColor,ShadowState aState)
1971 : OverlayObjectWithBasePosition(rBasePos, aBaseColor),
1972 maSecondPosition(rSecondPosition),
1973 mShadowState(aState)
1975 // mbAllowsAnimation = sal_True;
1978 SwPostItShadow::~SwPostItShadow()
1982 void SwPostItShadow::Trigger(sal_uInt32 /*nTime*/)
1986 void SwPostItShadow::drawGeometry(OutputDevice& rOutputDevice)
1988 rOutputDevice.SetLineColor();
1989 rOutputDevice.SetFillColor();
1991 const Fraction& f( rOutputDevice.GetMapMode().GetScaleY() );
1992 sal_Int32 aBigHeight( 4 * f.GetNumerator() / f.GetDenominator());
1993 sal_Int32 aSmallHeight( 2 * f.GetNumerator() / f.GetDenominator());
1995 const Point aStart(FRound(getBasePosition().getX()), FRound(getBasePosition().getY()));
1996 const Point aEndSmall(FRound(GetSecondPosition().getX()), FRound(GetSecondPosition().getY() + rOutputDevice.PixelToLogic(Size(0,aSmallHeight)).Height()));
1997 const Point aEndBig(FRound(GetSecondPosition().getX()), FRound(GetSecondPosition().getY() + rOutputDevice.PixelToLogic(Size(0,aBigHeight)).Height()));
1998 Rectangle aSmallRectangle(aStart, aEndSmall);
1999 Rectangle aBigRectangle(aStart, aEndBig);
2001 switch(mShadowState)
2003 case SS_NORMAL:
2005 Gradient aGradient(GRADIENT_LINEAR,Color(230,230,230),POSTIT_SHADOW_BRIGHT);
2006 aGradient.SetAngle(1800);
2007 rOutputDevice.DrawGradient(aSmallRectangle, aGradient);
2008 break;
2010 case SS_VIEW:
2012 Gradient aGradient(GRADIENT_LINEAR,Color(230,230,230),POSTIT_SHADOW_BRIGHT);
2013 aGradient.SetAngle(1800);
2014 rOutputDevice.DrawGradient(aBigRectangle, aGradient);
2015 break;
2017 case SS_EDIT:
2019 Gradient aGradient(GRADIENT_LINEAR,Color(230,230,230),POSTIT_SHADOW_DARK);
2020 aGradient.SetAngle(1800);
2021 rOutputDevice.DrawGradient(aBigRectangle, aGradient);
2022 break;
2024 default:
2026 break;
2031 void SwPostItShadow::createBaseRange(OutputDevice& rOutputDevice)
2033 maBaseRange.reset();
2035 const Fraction& f( rOutputDevice.GetMapMode().GetScaleY() );
2036 sal_Int32 aBigHeight( 4 * f.GetNumerator() / f.GetDenominator());
2038 Rectangle aRect(Point(FRound(getBasePosition().getX()),FRound(getBasePosition().getY())),
2039 Point(FRound(GetSecondPosition().getX()),FRound(GetSecondPosition().getY()+rOutputDevice.PixelToLogic(Size(0,aBigHeight)).Height())));
2040 maBaseRange.expand(basegfx::B2DPoint(aRect.Left(), aRect.Top()));
2041 maBaseRange.expand(basegfx::B2DPoint(aRect.Right(), aRect.Bottom()));
2044 void SwPostItShadow::SetShadowState(ShadowState aState)
2046 if (mShadowState != aState)
2048 mShadowState = aState;
2049 objectChange();
2053 void SwPostItShadow::SetPosition(const basegfx::B2DPoint& rPoint1,
2054 const basegfx::B2DPoint& rPoint2)
2056 maBasePosition = rPoint1;
2057 maSecondPosition = rPoint2;
2059 objectChange();
2061 void SwPostItShadow::transform(const basegfx::B2DHomMatrix& rMatrix)
2063 if(!rMatrix.isIdentity())
2065 // transform base position
2066 OverlayObjectWithBasePosition::transform(rMatrix);
2067 maSecondPosition = rMatrix * GetSecondPosition();
2068 objectChange();
2072 /****** SwPostItAnkor ***********************************************************/
2074 void SwPostItAnkor::implEnsureGeometry()
2076 if(!maTriangle.count())
2078 maTriangle.append(getBasePosition());
2079 maTriangle.append(GetSecondPosition());
2080 maTriangle.append(GetThirdPosition());
2081 maTriangle.setClosed(true);
2084 if(!maLine.count())
2086 maLine.append(GetFourthPosition());
2087 maLine.append(GetFifthPosition());
2088 maLine.append(GetSixthPosition());
2091 if(!maLineTop.count())
2093 maLineTop.append(GetSixthPosition());
2094 maLineTop.append(GetSeventhPosition());
2098 void SwPostItAnkor::implResetGeometry()
2100 maTriangle.clear();
2101 maLine.clear();
2102 maLineTop.clear();
2105 void SwPostItAnkor::implDrawGeometry(OutputDevice& rOutputDevice, Color aColor, double fOffX, double fOffY)
2107 basegfx::B2DPolygon aTri(maTriangle);
2108 basegfx::B2DPolygon aLin(maLine);
2109 const Polygon aLinTop(maLineTop);
2111 if(0.0 != fOffX || 0.0 != fOffY)
2113 // transform polygons
2114 basegfx::B2DHomMatrix aTranslate;
2115 aTranslate.set(0, 2, fOffX);
2116 aTranslate.set(1, 2, fOffY);
2118 aTri.transform(aTranslate);
2119 aLin.transform(aTranslate);
2122 switch (mAnkorState)
2124 case AS_TRI:
2126 rOutputDevice.SetLineColor();
2127 rOutputDevice.SetFillColor(aColor);
2128 rOutputDevice.DrawPolygon(Polygon(aTri));
2129 break;
2131 case AS_ALL:
2133 rOutputDevice.SetLineColor();
2134 rOutputDevice.SetFillColor(aColor);
2135 //rOutputDevice.DrawTransparent(Polygon(aTri), 50);
2136 rOutputDevice.DrawPolygon(Polygon(aTri));
2138 // draw line
2139 rOutputDevice.SetLineColor(aColor);
2140 rOutputDevice.SetFillColor();
2141 rOutputDevice.DrawPolyLine(Polygon(aLin), mLineInfo);
2142 rOutputDevice.DrawPolyLine(aLinTop,LineInfo(LINE_SOLID,ANKORLINE_WIDTH*15));
2143 break;
2145 case AS_START:
2147 rOutputDevice.SetLineColor();
2148 rOutputDevice.SetFillColor(aColor);
2149 rOutputDevice.DrawPolygon(Polygon(aTri));
2150 // draw line
2151 rOutputDevice.SetLineColor(aColor);
2152 rOutputDevice.SetFillColor();
2153 rOutputDevice.DrawPolyLine(Polygon(aLin), mLineInfo);
2154 break;
2156 case AS_END:
2158 // draw line
2159 rOutputDevice.SetLineColor(aColor);
2160 rOutputDevice.SetFillColor();
2161 rOutputDevice.DrawPolyLine(aLinTop,LineInfo(LINE_SOLID,ANKORLINE_WIDTH*15));
2162 break;
2167 Color SwPostItAnkor::implBlendColor(const Color aOriginal, sal_Int16 nChange)
2169 if(0 != nChange)
2171 sal_Int16 nR(aOriginal.GetRed() + nChange);
2172 sal_Int16 nG(aOriginal.GetGreen() + nChange);
2173 sal_Int16 nB(aOriginal.GetBlue() + nChange);
2175 // truncate R, G and B
2176 if(nR > 0xff)
2177 nR = 0xff;
2178 else if(nR < 0)
2179 nR = 0;
2181 if(nG > 0xff)
2182 nG = 0xff;
2183 else if(nG < 0)
2184 nG = 0;
2186 if(nB > 0xff)
2187 nB = 0xff;
2188 else if(nB < 0)
2189 nB = 0;
2191 return Color((sal_uInt8)nR, (sal_uInt8)nG, (sal_uInt8)nB);
2193 else
2195 return aOriginal;
2199 SwPostItAnkor::SwPostItAnkor(const basegfx::B2DPoint& rBasePos,
2200 const basegfx::B2DPoint& rSecondPos,
2201 const basegfx::B2DPoint& rThirdPos,
2202 const basegfx::B2DPoint& rFourthPos,
2203 const basegfx::B2DPoint& rFifthPos,
2204 const basegfx::B2DPoint& rSixthPos,
2205 const basegfx::B2DPoint& rSeventhPos,
2206 Color aBaseColor,
2207 const LineInfo &aLineInfo,
2208 bool bShadowedEffect)
2209 : OverlayObjectWithBasePosition(rBasePos, aBaseColor),
2210 maSecondPosition(rSecondPos),
2211 maThirdPosition(rThirdPos),
2212 maFourthPosition(rFourthPos),
2213 maFifthPosition(rFifthPos),
2214 maSixthPosition(rSixthPos),
2215 maSeventhPosition(rSeventhPos),
2216 maTriangle(),
2217 maLine(),
2218 maLineTop(),
2219 mLineInfo(aLineInfo),
2220 mHeight(0),
2221 mbShadowedEffect(bShadowedEffect),
2222 mAnkorState(AS_ALL)
2224 if (mLineInfo.GetStyle()==LINE_DASH)
2226 mLineInfo.SetDistance( 3 * 15);
2227 mLineInfo.SetDashLen( 5 * 15);
2228 mLineInfo.SetDashCount(100);
2230 //mbAllowsAnimation = sal_True;
2233 SwPostItAnkor::~SwPostItAnkor()
2237 void SwPostItAnkor::Trigger(sal_uInt32 /*nTime*/)
2241 void SwPostItAnkor::drawGeometry(OutputDevice& rOutputDevice)
2243 implEnsureGeometry();
2245 if(getShadowedEffect())
2247 // calculate one pixel offset
2248 const basegfx::B2DVector aOnePixelOffset(rOutputDevice.GetInverseViewTransformation() * basegfx::B2DVector(1.0, 1.0));
2249 const Color aLighterColor(implBlendColor(getBaseColor(), 20));
2250 const Color aDarkerColor(implBlendColor(getBaseColor(), -20));
2252 // draw top-left
2253 implDrawGeometry(rOutputDevice, aLighterColor, -aOnePixelOffset.getX(), -aOnePixelOffset.getY());
2255 // draw bottom-right
2256 implDrawGeometry(rOutputDevice, aDarkerColor, aOnePixelOffset.getX(), aOnePixelOffset.getY());
2259 // draw original
2260 implDrawGeometry(rOutputDevice, getBaseColor(), 0.0, 0.0);
2263 void SwPostItAnkor::createBaseRange(OutputDevice& rOutputDevice)
2265 // get range from geometry
2266 implEnsureGeometry();
2267 maBaseRange = basegfx::tools::getRange(maTriangle);
2268 maBaseRange.expand(basegfx::tools::getRange(maLine));
2269 maBaseRange.expand(basegfx::tools::getRange(maLineTop));
2272 basegfx::B2DHomMatrix aMatrix;
2273 aMatrix.translate(-maTriangle.getB2DPoint(0).getX(),-maTriangle.getB2DPoint(0).getY());
2274 aMatrix.scale(1.0,-1.0);
2275 aMatrix.translate(maTriangle.getB2DPoint(0).getX(),maTriangle.getB2DPoint(0).getY());
2276 aMatrix.translate(0,(mHeight*-1) + 13 * 15 );
2277 basegfx::B2DRange MyRange(basegfx::tools::getRange(maTriangle));
2278 MyRange.transform(aMatrix);
2279 maBaseRange.expand(MyRange);
2282 // expand range for thick lines and shadowed geometry
2283 double fExpand(0.0);
2285 // take fat line into account
2286 if(0 != mLineInfo.GetWidth())
2288 // expand range for logic half line width
2289 fExpand += static_cast< double >(mLineInfo.GetWidth()) / 2.0;
2292 // take shadowed into account
2293 if(getShadowedEffect())
2295 const basegfx::B2DVector aOnePixelOffset(rOutputDevice.GetInverseViewTransformation() * basegfx::B2DVector(1.0, 1.0));
2296 fExpand += ::std::max(aOnePixelOffset.getX(), aOnePixelOffset.getY());
2299 if(0.0 != fExpand)
2301 maBaseRange.grow(fExpand);
2306 void SwPostItAnkor::SetAllPosition(const basegfx::B2DPoint& rPoint1,
2307 const basegfx::B2DPoint& rPoint2,
2308 const basegfx::B2DPoint& rPoint3,
2309 const basegfx::B2DPoint& rPoint4,
2310 const basegfx::B2DPoint& rPoint5,
2311 const basegfx::B2DPoint& rPoint6,
2312 const basegfx::B2DPoint& rPoint7)
2314 maBasePosition = rPoint1;
2315 maSecondPosition = rPoint2;
2316 maThirdPosition = rPoint3;
2317 maFourthPosition = rPoint4;
2318 maFifthPosition = rPoint5;
2319 maSixthPosition = rPoint6;
2320 maSeventhPosition = rPoint7;
2322 implResetGeometry();
2323 objectChange();
2326 void SwPostItAnkor::SetSixthPosition(const basegfx::B2DPoint& rNew)
2328 if(rNew != maSixthPosition)
2330 maSixthPosition = rNew;
2331 implResetGeometry();
2332 objectChange();
2336 void SwPostItAnkor::SetSeventhPosition(const basegfx::B2DPoint& rNew)
2338 if(rNew != maSeventhPosition)
2340 maSeventhPosition = rNew;
2341 implResetGeometry();
2342 objectChange();
2346 void SwPostItAnkor::SetTriPosition(const basegfx::B2DPoint& rPoint1,const basegfx::B2DPoint& rPoint2,const basegfx::B2DPoint& rPoint3,
2347 const basegfx::B2DPoint& rPoint4,const basegfx::B2DPoint& rPoint5)
2349 maBasePosition = rPoint1;
2350 maSecondPosition = rPoint2;
2351 maThirdPosition = rPoint3;
2352 maFourthPosition = rPoint4;
2353 maFifthPosition = rPoint5;
2355 implResetGeometry();
2356 objectChange();
2359 void SwPostItAnkor::transform(const basegfx::B2DHomMatrix& rMatrix)
2361 if(!rMatrix.isIdentity())
2363 // transform base position
2364 OverlayObjectWithBasePosition::transform(rMatrix);
2366 maSecondPosition = rMatrix * GetSecondPosition();
2367 maThirdPosition = rMatrix * GetThirdPosition();
2368 maFourthPosition = rMatrix * GetFourthPosition();
2369 maFifthPosition = rMatrix * GetFifthPosition();
2370 maSixthPosition = rMatrix * GetSixthPosition();
2371 maSeventhPosition = rMatrix * GetSeventhPosition();
2373 implResetGeometry();
2374 objectChange();
2378 void SwPostItAnkor::SetLineInfo(const LineInfo &aLineInfo)
2380 if (aLineInfo != mLineInfo)
2382 mLineInfo = aLineInfo;
2383 if (mLineInfo.GetStyle()==LINE_DASH)
2385 mLineInfo.SetDistance( 3 * 15);
2386 mLineInfo.SetDashLen( 5 * 15);
2387 mLineInfo.SetDashCount(100);
2389 //remove and add overlayobject, so it is the last one inside the manager to draw
2390 //therefore this line is on top
2391 sdr::overlay::OverlayManager* pMgr = getOverlayManager();
2392 if (pMgr)
2394 pMgr->remove(*this);
2395 pMgr->add(*this);
2397 objectChange();
2401 void SwPostItAnkor::SetAnkorState(AnkorState aState)
2403 if (mAnkorState != aState)
2405 mAnkorState = aState;
2406 objectChange();