Update ooo320-m1
[ooovba.git] / sw / source / ui / docvw / postit.cxx
blob157a6e19979592b5d1762d38821f00b4d585ec92
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
94 #include <vcl/msgbox.hxx>
96 #include <basegfx/matrix/b2dhommatrix.hxx>
97 #include <basegfx/tuple/b2dtuple.hxx>
98 #include <basegfx/polygon/b2dpolygontools.hxx>
100 #include <swrect.hxx>
101 #include <docufld.hxx> // SwPostItField
102 #include <edtwin.hxx>
103 #include <view.hxx>
104 #include <viewsh.hxx>
105 #include <docsh.hxx>
106 #include <shellres.hxx>
107 #include <fmtfld.hxx>
108 #include <wrtsh.hxx>
109 #include <textsh.hxx>
110 #include <doc.hxx>
111 #include <txtfld.hxx>
112 #include <redline.hxx>
113 #include <uitool.hxx>
114 #include <SwUndoField.hxx>
115 #include <editsh.hxx>
116 #include <swmodule.hxx>
117 #include <node.hxx>
118 #include <ndtxt.hxx>
119 #include <langhelper.hxx>
121 #include <sw_primitivetypes2d.hxx>
122 #include <drawinglayer/primitive2d/primitivetools2d.hxx>
123 #include <drawinglayer/attribute/fillattribute.hxx>
124 #include <drawinglayer/primitive2d/fillgradientprimitive2d.hxx>
125 #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
126 #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
127 #include <drawinglayer/primitive2d/shadowprimitive2d.hxx>
129 using namespace ::com::sun::star;
131 #define METABUTTON_WIDTH 16
132 #define METABUTTON_HEIGHT 18
133 #define METABUTTON_AREA_WIDTH 30
134 #define POSTIT_META_HEIGHT (sal_Int32) 30
135 #define POSTIT_MINIMUMSIZE_WITHOUT_META 50
137 #define POSTIT_SHADOW_BRIGHT Color(180,180,180)
138 #define POSTIT_SHADOW_DARK Color(83,83,83)
140 #define LINEBREAK rtl::OUString::createFromAscii("\n")
141 #define EMPTYSTRING rtl::OUString::createFromAscii("")
143 TYPEINIT0(SwMarginWin);
144 TYPEINIT1(SwPostIt,SwMarginWin);
145 //TYPEINIT1(SwRedComment,SwMarginWin);
147 Color ColorFromAlphaColor(UINT8 aTransparency, Color &aFront, Color &aBack )
149 return Color((UINT8)(aFront.GetRed() * aTransparency/(double)255 + aBack.GetRed() * (1-aTransparency/(double)255)),
150 (UINT8)(aFront.GetGreen() * aTransparency/(double)255 + aBack.GetGreen() * (1-aTransparency/(double)255)),
151 (UINT8)(aFront.GetBlue() * aTransparency/(double)255 + aBack.GetBlue() * (1-aTransparency/(double)255)));
154 /************ PostItTxt **************************************/
155 PostItTxt::PostItTxt(Window* pParent, WinBits nBits) : Window(pParent, nBits), mpOutlinerView(0),mMouseOver(false),mbShowPopup(FALSE)
157 SetHelpId(26276);
158 AddEventListener( LINK( this, PostItTxt, WindowEventListener ) );
159 mpMarginWin = static_cast<SwMarginWin*>(GetParent());
162 PostItTxt::~PostItTxt()
164 RemoveEventListener( LINK( this, PostItTxt, WindowEventListener ) );
167 void PostItTxt::GetFocus()
169 BOOL bLockView = mpMarginWin->DocView()->GetWrtShell().IsViewLocked();
170 mpMarginWin->DocView()->GetWrtShell().LockView( TRUE );
172 if(mpMarginWin && !mpMarginWin->IsPreview())
173 mpMarginWin->Mgr()->SetActivePostIt(mpMarginWin);
174 Window::GetFocus();
175 if (!mMouseOver)
176 Invalidate();
178 mpMarginWin->DocView()->GetWrtShell().LockView( bLockView );
179 mpMarginWin->Mgr()->MakeVisible(mpMarginWin);
182 void PostItTxt::LoseFocus()
184 // write the visible text back into the SwField
185 if ( mpMarginWin )
186 mpMarginWin->UpdateData();
188 Window::LoseFocus();
189 if (!mMouseOver)
190 Invalidate();
193 void PostItTxt::RequestHelp(const HelpEvent &rEvt)
195 USHORT nResId = 0;
196 switch( mpMarginWin->GetStatus() )
198 case SwPostItHelper::INSERTED: nResId = STR_REDLINE_INSERT; break;
199 case SwPostItHelper::DELETED: nResId = STR_REDLINE_DELETE; break;
200 default: nResId = 0;
203 SwContentAtPos aCntntAtPos( SwContentAtPos::SW_REDLINE );
204 if ( nResId && mpMarginWin->DocView()->GetWrtShell().GetContentAtPos( mpMarginWin->GetAnkorRect().Pos(), aCntntAtPos ) )
206 String sTxt;
207 sTxt = SW_RESSTR( nResId );
208 sTxt.AppendAscii( RTL_CONSTASCII_STRINGPARAM(": " ));
209 sTxt += aCntntAtPos.aFnd.pRedl->GetAuthorString();
210 sTxt.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " - " ));
211 sTxt += GetAppLangDateTimeString( aCntntAtPos.aFnd.pRedl->GetTimeStamp() );
212 Help::ShowQuickHelp( this,PixelToLogic(Rectangle(rEvt.GetMousePosPixel(),Size(50,10))),sTxt);
216 void PostItTxt::Paint( const Rectangle& rRect)
218 if ( !Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
220 if (mMouseOver || HasFocus())
221 DrawGradient(Rectangle(Point(0,0),PixelToLogic(GetSizePixel())),
222 Gradient(GRADIENT_LINEAR,mpMarginWin->ColorDark(),mpMarginWin->ColorDark()));
223 else
224 DrawGradient(Rectangle(Point(0,0),PixelToLogic(GetSizePixel())),
225 Gradient(GRADIENT_LINEAR,mpMarginWin->ColorLight(),mpMarginWin->ColorDark()));
228 mpOutlinerView->Paint( rRect );
230 if (mpMarginWin->GetStatus()==SwPostItHelper::DELETED)
232 SetLineColor(static_cast<SwPostIt*>(mpMarginWin)->GetChangeColor());
233 DrawLine(PixelToLogic(GetPosPixel()),PixelToLogic(GetPosPixel()+Point(GetSizePixel().Width(),GetSizePixel().Height())));
234 DrawLine(PixelToLogic(GetPosPixel()+Point(GetSizePixel().Width(),0)),PixelToLogic(GetPosPixel()+Point(0,GetSizePixel().Height())));
238 void PostItTxt::KeyInput( const KeyEvent& rKeyEvt )
240 const KeyCode& rKeyCode = rKeyEvt.GetKeyCode();
241 USHORT nKey = rKeyCode.GetCode();
242 SwView* pView = mpMarginWin->DocView();
243 if ((rKeyCode.IsMod1() && rKeyCode.IsMod2()) && ((nKey == KEY_PAGEUP) || (nKey == KEY_PAGEDOWN)))
244 mpMarginWin->SwitchToPostIt(nKey);
245 else
246 if ((nKey == KEY_ESCAPE) || (rKeyCode.IsMod1() && ((nKey == KEY_PAGEUP) || (nKey == KEY_PAGEDOWN))))
247 mpMarginWin->SwitchToFieldPos();
248 else
249 if (nKey == KEY_INSERT)
251 if (!rKeyCode.IsMod1() && !rKeyCode.IsMod2())
252 mpMarginWin->ToggleInsMode();
254 else
256 //let's make sure we see our note
257 mpMarginWin->Mgr()->MakeVisible(mpMarginWin);
259 long aOldHeight = mpMarginWin->GetPostItTextHeight();
260 bool bDone = false;
262 /// HACK: need to switch off processing of Undo/Redo in Outliner
263 if ( !( (nKey == KEY_Z || nKey == KEY_Y) && rKeyCode.IsMod1()) )
266 SwPostItHelper::SwLayoutStatus aStatus = mpMarginWin->GetStatus();
267 if ( (aStatus!=SwPostItHelper::DELETED) ||
268 ( (aStatus==SwPostItHelper::DELETED) && (!mpMarginWin->Engine()->GetEditEngine().DoesKeyChangeText(rKeyEvt))) )
270 bool bIsProtected = mpMarginWin->IsProtected();
271 if (!bIsProtected || (bIsProtected && !mpMarginWin->Engine()->GetEditEngine().DoesKeyChangeText(rKeyEvt)) )
272 bDone = mpOutlinerView->PostKeyEvent( rKeyEvt );
273 else
274 InfoBox( this, SW_RES( MSG_READONLY_CONTENT )).Execute();
276 if (bDone)
277 mpMarginWin->ResizeIfNeccessary(aOldHeight,mpMarginWin->GetPostItTextHeight());
278 else
280 // write back data first when showing navigator
281 if ( nKey==KEY_F5 )
282 mpMarginWin->UpdateData();
283 if (!pView->KeyInput(rKeyEvt))
284 Window::KeyInput(rKeyEvt);
288 pView->GetViewFrame()->GetBindings().InvalidateAll(FALSE);
291 void PostItTxt::MouseMove( const MouseEvent& rMEvt )
293 if ( mpOutlinerView )
295 mpOutlinerView->MouseMove( rMEvt );
296 // mba: why does OutlinerView not handle the modifier setting?!
297 // this forces the postit to handle *all* pointer types
298 SetPointer( mpOutlinerView->GetPointer( rMEvt.GetPosPixel() ) );
300 const EditView& aEV = mpOutlinerView->GetEditView();
301 const SvxFieldItem* pItem = aEV.GetFieldUnderMousePointer();
302 if ( pItem )
304 const SvxFieldData* pFld = pItem->GetField();
305 const SvxURLField* pURL = PTR_CAST( SvxURLField, pFld );
306 if ( pURL )
308 String sURL( pURL->GetURL() );
309 SvtSecurityOptions aSecOpts;
310 if ( aSecOpts.IsOptionSet( SvtSecurityOptions::E_CTRLCLICK_HYPERLINK) )
312 sURL.InsertAscii( ": ", 0 );
313 sURL.Insert( ViewShell::GetShellRes()->aHyperlinkClick, 0 );
315 Help::ShowQuickHelp( this,PixelToLogic(Rectangle(GetPosPixel(),Size(50,10))),sURL);
321 void PostItTxt::MouseButtonDown( const MouseEvent& rMEvt )
323 if (mpOutlinerView )
325 SvtSecurityOptions aSecOpts;
326 bool bExecuteMod = aSecOpts.IsOptionSet( SvtSecurityOptions::E_CTRLCLICK_HYPERLINK);
328 if ( !bExecuteMod || (bExecuteMod && rMEvt.GetModifier() == KEY_MOD1))
330 const EditView& aEV = mpOutlinerView->GetEditView();
331 const SvxFieldItem* pItem = aEV.GetFieldUnderMousePointer();
332 if ( pItem )
334 const SvxFieldData* pFld = pItem->GetField();
335 const SvxURLField* pURL = PTR_CAST( SvxURLField, pFld );
336 if ( pURL )
338 mpOutlinerView->MouseButtonDown( rMEvt );
339 SwWrtShell &rSh = mpMarginWin->DocView()->GetWrtShell();
340 String sURL( pURL->GetURL() );
341 String sTarget( pURL->GetTargetFrame() );
342 ::LoadURL( sURL, &rSh, URLLOAD_NOFILTER, &sTarget);
343 return;
349 GrabFocus();
350 if ( mpOutlinerView )
351 mpOutlinerView->MouseButtonDown( rMEvt );
352 mpMarginWin->DocView()->GetViewFrame()->GetBindings().InvalidateAll(FALSE);
355 void PostItTxt::MouseButtonUp( const MouseEvent& rMEvt )
357 if ( mpOutlinerView )
358 mpOutlinerView->MouseButtonUp( rMEvt );
361 IMPL_LINK(PostItTxt, OnlineSpellCallback, SpellCallbackInfo*, pInfo)
363 if ( mpMarginWin && (pInfo->nCommand == SPELLCMD_STARTSPELLDLG) )
364 mpMarginWin->DocView()->GetViewFrame()->GetDispatcher()->Execute( FN_SPELL_GRAMMAR_DIALOG, SFX_CALLMODE_ASYNCHRON);
365 return 0;
368 IMPL_LINK( PostItTxt, Select, Menu*, pSelMenu )
370 mpMarginWin->ExecuteCommand( pSelMenu->GetCurItemId() );
371 return 0;
374 void PostItTxt::Command( const CommandEvent& rCEvt )
376 if ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU )
378 if (!mpMarginWin->IsProtected() &&
379 //if (!mpMarginWin->IsReadOnly() && (mpMarginWin->GetStatus()!=SwPostItHelper::DELETED) &&
380 mpOutlinerView->IsWrongSpelledWordAtPos( rCEvt.GetMousePosPixel(),TRUE ))
382 Link aLink = LINK(this, PostItTxt, OnlineSpellCallback);
383 mpOutlinerView->ExecuteSpellPopup(rCEvt.GetMousePosPixel(),&aLink);
385 else
387 SfxPopupMenuManager* aMgr = mpMarginWin->DocView()->GetViewFrame()->GetDispatcher()->Popup(0, this,&rCEvt.GetMousePosPixel());
388 XubString aText = ((PopupMenu*)aMgr->GetSVMenu())->GetItemText( FN_DELETE_NOTE_AUTHOR );
389 SwRewriter aRewriter;
390 aRewriter.AddRule(UNDO_ARG1, mpMarginWin->GetAuthor());
391 aText = aRewriter.Apply(aText);
392 ((PopupMenu*)aMgr->GetSVMenu())->SetItemText(FN_DELETE_NOTE_AUTHOR,aText);
393 // SwPostItLinkForwarder_Impl aFwd( ((PopupMenu*)aMgr->GetSVMenu())->pSvMenu->GetSelectHdl(), mpPostIt );
394 // ((PopupMenu*)aMgr->GetSVMenu())->pSvMenu->SetSelectHdl( LINK(&aFwd, SwPostItLinkForwarder_Impl, Select) );
396 ((PopupMenu*)aMgr->GetSVMenu())->SetSelectHdl( LINK(this, PostItTxt, Select) );
398 if (rCEvt.IsMouseEvent())
399 ((PopupMenu*)aMgr->GetSVMenu())->Execute(this,rCEvt.GetMousePosPixel());
400 else
402 const Size aSize = GetSizePixel();
403 const Point aPos = Point( aSize.getWidth()/2, aSize.getHeight()/2 );
404 ((PopupMenu*)aMgr->GetSVMenu())->Execute(this,aPos);
406 delete aMgr;
409 else
410 if (rCEvt.GetCommand() == COMMAND_WHEEL)
412 if (mpMarginWin->Scrollbar()->IsVisible())
414 const CommandWheelData* pData = rCEvt.GetWheelData();
415 if (pData->IsShift() || pData->IsMod1() || pData->IsMod2())
417 mpMarginWin->DocView()->HandleWheelCommands(rCEvt);
419 else
421 HandleScrollCommand( rCEvt, 0 , mpMarginWin->Scrollbar());
424 long nLines = pData->GetNotchDelta() * (long)pData->GetScrollLines();
425 if ( ((mpMarginWin->Scrollbar()->GetRange().Min() == mpMarginWin->Scrollbar()->GetThumbPos()) && (nLines > 0)) ||
426 ( (mpMarginWin->Scrollbar()->GetRange().Max() == mpMarginWin->Scrollbar()->GetThumbPos()+mpMarginWin->Scrollbar()->GetVisibleSize()) && (nLines < 0)) )
428 mpMarginWin->DocView()->HandleWheelCommands(rCEvt);
430 else
432 HandleScrollCommand( rCEvt, 0 , mpMarginWin->Scrollbar());
437 else
439 mpMarginWin->DocView()->HandleWheelCommands(rCEvt);
442 else
444 if ( mpOutlinerView )
445 mpOutlinerView->Command( rCEvt );
446 else
447 Window::Command(rCEvt);
451 void PostItTxt::DataChanged( const DataChangedEvent& aData)
453 Window::DataChanged( aData );
456 IMPL_LINK( PostItTxt, WindowEventListener, VclSimpleEvent*, pWinEvent )
458 if ( pWinEvent && pWinEvent->ISA( VclWindowEvent ) )
460 VclWindowEvent *pEvent = (VclWindowEvent*)pWinEvent;
461 if (pEvent->GetId() == VCLEVENT_WINDOW_MOUSEMOVE)
463 MouseEvent* pMouseEvt = (MouseEvent*)pEvent->GetData();
464 if ( pMouseEvt->IsEnterWindow() )
466 mMouseOver = true;
467 if (!mbShowPopup && !HasFocus())
469 mpMarginWin->SetViewState(SS_VIEW);
470 Invalidate();
473 else if ( pMouseEvt->IsLeaveWindow())
475 if (mpMarginWin->IsPreview())
477 //mpMarginWin->doLazyDelete();
479 else
481 mMouseOver = false;
482 if (!mbShowPopup && !HasFocus())
484 mpMarginWin->SetViewState(SS_NORMAL);
485 Invalidate();
491 return sal_True;
494 XubString PostItTxt::GetSurroundingText() const
496 if( mpOutlinerView )
497 return mpOutlinerView->GetSurroundingText();
498 else
499 return XubString::EmptyString();
502 Selection PostItTxt::GetSurroundingTextSelection() const
504 if( mpOutlinerView )
505 return mpOutlinerView->GetSurroundingTextSelection();
506 else
507 return Selection( 0, 0 );
510 /************** SwMarginWin***********************************++*/
511 SwMarginWin::SwMarginWin(Window* pParent, WinBits nBits,SwPostItMgr* aMgr,SwPostItBits aBits)
512 : Window(pParent, nBits),
513 mnEventId(0),
514 mpOutlinerView(0),
515 mpOutliner(0),
516 mpPostItTxt(0),
517 mpMeta(0),
518 mpVScrollbar(0),
519 mpAnkor(0),
520 mpShadow(0),
521 mpMgr(aMgr),
522 mbMeta(true),
523 nFlags(aBits),
524 mbMouseOverButton(false),
525 mpButtonPopup(0),
526 mbIsFollow(false)
528 SwEditWin* aWin = static_cast<SwEditWin*>(GetParent());
529 mpView = &aWin->GetView();
531 SdrPaintWindow* pPaintWindow = mpView->GetDrawView()->GetPaintWindow(0);
532 if(pPaintWindow)
534 pOverlayManager = pPaintWindow->GetOverlayManager();
536 mpShadow = new SwPostItShadow(basegfx::B2DPoint(0,0),basegfx::B2DPoint(0,0),Color(0,0,0),SS_NORMAL);
537 mpShadow->setVisible(false);
538 pOverlayManager->add(*mpShadow);
542 SwMarginWin::~SwMarginWin()
544 if (mpOutlinerView)
546 delete mpOutlinerView;
549 if (mpOutliner)
551 delete mpOutliner;
554 if (mpMeta)
556 mpMeta->RemoveEventListener( LINK( mpPostItTxt, PostItTxt, WindowEventListener ) );
557 delete mpMeta;
560 if (mpPostItTxt)
562 delete mpPostItTxt;
565 if (mpVScrollbar)
567 delete mpVScrollbar;
570 if (mpAnkor)
572 if (mpAnkor->getOverlayManager())
574 // remove this object from the chain
575 mpAnkor->getOverlayManager()->remove(*mpAnkor);
577 delete mpAnkor;
580 if (mpShadow)
582 if (mpShadow->getOverlayManager())
584 mpShadow->getOverlayManager()->remove(*mpShadow);
586 delete mpShadow;
589 if (mpButtonPopup)
591 delete mpButtonPopup;
594 if (mnEventId)
595 Application::RemoveUserEvent( mnEventId );
598 void SwMarginWin::Paint( const Rectangle& rRect)
600 Window::Paint(rRect);
602 if (mpMeta->IsVisible() )
604 //draw left over space
605 if ( Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
606 SetFillColor(COL_BLACK);
607 else
608 SetFillColor(mColorDark);
609 SetLineColor();
610 DrawRect(PixelToLogic(Rectangle(Point(mpMeta->GetPosPixel().X()+mpMeta->GetSizePixel().Width(),mpMeta->GetPosPixel().Y()),Size(GetMetaButtonAreaWidth(),mpMeta->GetSizePixel().Height()))));
612 if ( Application::GetSettings().GetStyleSettings().GetHighContrastMode())
614 //draw rect around button
615 SetFillColor(COL_BLACK);
616 SetLineColor(COL_WHITE);
618 else
620 //draw button
621 Gradient aGradient;
622 if (mbMouseOverButton)
623 aGradient = Gradient(GRADIENT_LINEAR,ColorFromAlphaColor(80,mColorAnkor,mColorDark),ColorFromAlphaColor(15,mColorAnkor,mColorDark));
624 else
625 aGradient = Gradient(GRADIENT_LINEAR,ColorFromAlphaColor(15,mColorAnkor,mColorDark),ColorFromAlphaColor(80,mColorAnkor,mColorDark));
626 DrawGradient(mRectMetaButton,aGradient);
627 //draw rect around button
628 SetFillColor();
629 SetLineColor(ColorFromAlphaColor(90,mColorAnkor,mColorDark));
631 DrawRect(mRectMetaButton);
633 if (IsPreview())
635 Font aOldFont( GetFont());
636 Font aFont(aOldFont);
637 Color aCol( COL_BLACK);
638 aFont.SetColor( aCol );
639 aFont.SetHeight(200);
640 aFont.SetWeight(WEIGHT_MEDIUM);
641 SetFont( aFont );
642 DrawText(mRectMetaButton,rtl::OUString::createFromAscii("Edit Note"),TEXT_DRAW_CENTER);
643 SetFont( aOldFont );
645 else
647 //draw arrow
648 if ( Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
649 SetFillColor(COL_WHITE);
650 else
651 SetFillColor(COL_BLACK);
652 SetLineColor();
653 DrawPolygon(Polygon(aPopupTriangle));
658 void SwMarginWin::SetPosSizePixelRect(long nX, long nY,long nWidth, long nHeight,const SwRect &aRect, const long aPageBorder)
660 mbMeta = true;
661 mPosSize = Rectangle(Point(nX,nY),Size(nWidth,nHeight));
662 mAnkorRect = aRect;
663 mPageBorder = aPageBorder;
666 void SwMarginWin::SetSize( const Size& rNewSize )
668 mPosSize.SetSize(rNewSize);
671 void SwMarginWin::SetVirtualPosSize( const Point& aPoint, const Size& aSize)
673 mPosSize = Rectangle(aPoint,aSize);
676 void SwMarginWin::TranslateTopPosition(const long aAmount)
678 mPosSize.Move(0,aAmount);
681 void SwMarginWin::ShowAnkorOnly(const Point &aPoint)
683 HideNote();
684 SetPosAndSize();
685 if (mpAnkor)
687 mpAnkor->SetSixthPosition(basegfx::B2DPoint(aPoint.X(),aPoint.Y()));
688 mpAnkor->SetSeventhPosition(basegfx::B2DPoint(aPoint.X(),aPoint.Y()));
689 mpAnkor->SetAnkorState(AS_ALL);
690 mpAnkor->setVisible(true);
692 if (mpShadow)
693 mpShadow->setVisible(false);
696 SfxItemSet SwMarginWin::DefaultItem()
698 SfxItemSet aItem( mpView->GetDocShell()->GetPool() );
699 aItem.Put(SvxFontHeightItem(200,100,EE_CHAR_FONTHEIGHT));
700 aItem.Put(SvxFontItem(FAMILY_SWISS,GetSettings().GetStyleSettings().GetFieldFont().GetName(),
701 EMPTYSTRING,PITCH_DONTKNOW,RTL_TEXTENCODING_DONTKNOW,EE_CHAR_FONTINFO));
702 return aItem;
705 void SwMarginWin::InitControls()
707 // actual window which holds the user text
708 mpPostItTxt = new PostItTxt(this, WB_NODIALOGCONTROL);
709 mpPostItTxt->SetPointer(Pointer(POINTER_TEXT));
711 // window control for author and date
712 mpMeta = new MultiLineEdit(this,0);
713 mpMeta->SetReadOnly();
714 mpMeta->SetRightToLeft(Application::GetSettings().GetLayoutRTL());
715 mpMeta->AlwaysDisableInput(true);
716 mpMeta->SetCallHandlersOnInputDisabled(true);
717 mpMeta->AddEventListener( LINK( mpPostItTxt, PostItTxt, WindowEventListener ) );
718 AddEventListener( LINK( mpPostItTxt, PostItTxt, WindowEventListener ) );
720 // we should leave this setting alone, but for this we need a better layout algo
721 // with variable meta size height
722 AllSettings aSettings = mpMeta->GetSettings();
723 StyleSettings aStyleSettings = aSettings.GetStyleSettings();
724 Font aFont = aStyleSettings.GetFieldFont();
725 aFont.SetHeight(8);
726 aStyleSettings.SetFieldFont(aFont);
727 aSettings.SetStyleSettings(aStyleSettings);
728 mpMeta->SetSettings(aSettings);
730 SwDocShell* aShell = mpView->GetDocShell();
731 mpOutliner = new Outliner(&aShell->GetPool(),OUTLINERMODE_TEXTOBJECT);
732 aShell->GetDoc()->SetCalcFieldValueHdl( mpOutliner );
733 // mpOutliner->EnableUndo( FALSE );
734 mpOutliner->SetUpdateMode( TRUE );
735 Rescale();
737 OutputDevice* pDev = aShell->GetDoc()->getReferenceDevice(TRUE);
738 if ( pDev )
740 mpOutliner->SetRefDevice( pDev );
743 mpOutlinerView = new OutlinerView ( mpOutliner, mpPostItTxt );
744 mpOutlinerView->SetBackgroundColor(COL_TRANSPARENT);
745 mpOutliner->InsertView(mpOutlinerView );
746 mpPostItTxt->SetTextView(mpOutlinerView);
747 mpOutlinerView->SetOutputArea( PixelToLogic( Rectangle(0,0,1,1) ) );
749 mpOutlinerView->SetAttribs(DefaultItem());
751 // TODO: ??
752 EEHorizontalTextDirection aDefHoriTextDir = Application::GetSettings().GetLayoutRTL() ? EE_HTEXTDIR_R2L : EE_HTEXTDIR_L2R;
753 mpOutliner->SetDefaultHorizontalTextDirection( aDefHoriTextDir );
755 //create Scrollbars
756 mpVScrollbar = new ScrollBar(this, WB_3DLOOK |WB_VSCROLL|WB_DRAG);
757 mpVScrollbar->EnableNativeWidget(false);
758 mpVScrollbar->EnableRTL( false );
759 mpVScrollbar->SetScrollHdl(LINK(this, SwMarginWin, ScrollHdl));
760 mpVScrollbar->EnableDrag();
761 mpVScrollbar->AddEventListener( LINK( mpPostItTxt, PostItTxt, WindowEventListener ) );
763 const SwViewOption* pVOpt = mpView->GetWrtShellPtr()->GetViewOptions();
764 ULONG nCntrl = mpOutliner->GetControlWord();
765 // TODO: crash when AUTOCOMPLETE enabled
766 nCntrl |= EE_CNTRL_MARKFIELDS | EE_CNTRL_PASTESPECIAL | EE_CNTRL_AUTOCORRECT | EV_CNTRL_AUTOSCROLL | EE_CNTRL_URLSFXEXECUTE; // | EE_CNTRL_AUTOCOMPLETE;
767 if (pVOpt->IsFieldShadings())
768 nCntrl |= EE_CNTRL_MARKFIELDS;
769 else
770 nCntrl &= ~EE_CNTRL_MARKFIELDS;
771 if (pVOpt->IsOnlineSpell())
772 nCntrl |= EE_CNTRL_ONLINESPELLING;
773 else
774 nCntrl &= ~EE_CNTRL_ONLINESPELLING;
775 mpOutliner->SetControlWord(nCntrl);
777 sal_uInt16 aIndex = SW_MOD()->InsertRedlineAuthor(GetAuthor());
778 SetColor(mpMgr->GetColorDark(aIndex),mpMgr->GetColorLight(aIndex),mpMgr->GetColorAnkor(aIndex));
780 CheckMetaText();
781 SetPopup();
782 SetLanguage(GetLanguage());
783 View()->StartSpeller();
784 SetPostItText();
785 Engine()->CompleteOnlineSpelling();
787 mpMeta->Show();
788 mpVScrollbar->Show();
789 mpPostItTxt->Show();
792 void SwMarginWin::CheckMetaText()
794 const LocaleDataWrapper& rLocalData = SvtSysLocale().GetLocaleData();
795 String sMeta = GetAuthor();
796 if (sMeta==String(EMPTYSTRING))
797 sMeta = String(SW_RES(STR_NOAUTHOR));
798 if (sMeta.Len() > 22)
800 sMeta.Erase(20);
801 sMeta = sMeta + rtl::OUString::createFromAscii("...");
803 Date aDate = GetDate();
804 if (aDate==Date())
805 sMeta = sMeta + LINEBREAK + String(SW_RES(STR_POSTIT_TODAY));
806 else
807 if (aDate == Date(Date()-1))
808 sMeta = sMeta + LINEBREAK + String(SW_RES(STR_POSTIT_YESTERDAY));
809 else
810 if (aDate.IsValid() )
811 sMeta = sMeta + LINEBREAK + rLocalData.getDate(aDate);
812 else
813 sMeta = sMeta + LINEBREAK + String(SW_RES(STR_NODATE));
814 if (GetTime()!=0)
815 sMeta = sMeta + rtl::OUString::createFromAscii(" ") + rLocalData.getTime( GetTime(),false );
816 if (mpMeta->GetText() != sMeta)
817 mpMeta->SetText(sMeta);
820 void SwMarginWin::Rescale()
822 MapMode aMode = GetParent()->GetMapMode();
823 aMode.SetOrigin( Point() );
824 //aMode.SetScaleX( aMode.GetScaleX() * Fraction( 8, 10 ) );
825 //aMode.SetScaleY( aMode.GetScaleY() * Fraction( 8, 10 ) );
826 mpOutliner->SetRefMapMode( aMode );
827 SetMapMode( aMode );
828 mpPostItTxt->SetMapMode( aMode );
829 if ( mpMeta )
831 Font aFont( mpMeta->GetSettings().GetStyleSettings().GetFieldFont() );
832 sal_Int32 nHeight = aFont.GetHeight();
833 nHeight = nHeight * aMode.GetScaleY().GetNumerator() / aMode.GetScaleY().GetDenominator();
834 aFont.SetHeight( nHeight );
835 mpMeta->SetControlFont( aFont );
839 void SwMarginWin::SetPosAndSize()
841 bool bChange = false;
843 if (GetSizePixel() != mPosSize.GetSize())
845 bChange = true;
846 SetSizePixel(mPosSize.GetSize());
847 DoResize();
850 if (GetPosPixel().X() != mPosSize.TopLeft().X() || (abs(GetPosPixel().Y() - mPosSize.TopLeft().Y()) > 5) )
852 bChange = true;
853 SetPosPixel(mPosSize.TopLeft());
855 Point aLineStart;
856 Point aLineEnd ;
857 if (mbMarginSide)
859 aLineStart = EditWin()->PixelToLogic( Point(GetPosPixel().X()+GetSizePixel().Width(),GetPosPixel().Y()-1) );
860 aLineEnd = EditWin()->PixelToLogic( Point(GetPosPixel().X(),GetPosPixel().Y()-1) );
862 else
864 aLineStart = EditWin()->PixelToLogic( Point(GetPosPixel().X(),GetPosPixel().Y()-1) );
865 aLineEnd = EditWin()->PixelToLogic( Point(GetPosPixel().X()+GetSizePixel().Width(),GetPosPixel().Y()-1) );
868 if (!IsPreview())
870 if (mpAnkor)
872 mpAnkor->SetAllPosition(basegfx::B2DPoint( mAnkorRect.Left() , mAnkorRect.Bottom() - 5* 15),
873 basegfx::B2DPoint( mAnkorRect.Left()-5*15 , mAnkorRect.Bottom()+5*15),
874 basegfx::B2DPoint( mAnkorRect.Left()+5*15 , mAnkorRect.Bottom()+5*15),
875 basegfx::B2DPoint( mAnkorRect.Left(), mAnkorRect.Bottom()+2*15),
876 basegfx::B2DPoint( mPageBorder ,mAnkorRect.Bottom()+2*15),
877 basegfx::B2DPoint( aLineStart.X(),aLineStart.Y()),
878 basegfx::B2DPoint( aLineEnd.X(),aLineEnd.Y()));
879 mpAnkor->SetHeight(mAnkorRect.Height());
881 else
883 mpAnkor = new SwPostItAnkor(basegfx::B2DPoint( mAnkorRect.Left() , mAnkorRect.Bottom()-5*15),
884 basegfx::B2DPoint( mAnkorRect.Left()-5*15 , mAnkorRect.Bottom()+5*15),
885 basegfx::B2DPoint( mAnkorRect.Left()+5*15 , mAnkorRect.Bottom()+5*15),
886 basegfx::B2DPoint( mAnkorRect.Left(), mAnkorRect.Bottom()+2*15),
887 basegfx::B2DPoint( mPageBorder ,mAnkorRect.Bottom()+2*15),
888 basegfx::B2DPoint( aLineStart.X(),aLineStart.Y()),
889 basegfx::B2DPoint( aLineEnd.X(),aLineEnd.Y()) ,
890 mColorAnkor,
891 false,
892 false);
893 mpAnkor->SetHeight(mAnkorRect.Height());
894 mpAnkor->setVisible(true);
895 mpAnkor->SetAnkorState(AS_TRI);
896 if (HasChildPathFocus())
898 mpAnkor->setLineSolid(true);
900 pOverlayManager->add(*mpAnkor);
904 else
906 if ( mpAnkor && (mpAnkor->getBasePosition() != basegfx::B2DPoint( mAnkorRect.Left() , mAnkorRect.Bottom()-5*15)) )
907 mpAnkor->SetTriPosition(basegfx::B2DPoint( mAnkorRect.Left() , mAnkorRect.Bottom() - 5* 15),
908 basegfx::B2DPoint( mAnkorRect.Left()-5*15 , mAnkorRect.Bottom()+5*15),
909 basegfx::B2DPoint( mAnkorRect.Left()+5*15 , mAnkorRect.Bottom()+5*15),
910 basegfx::B2DPoint( mAnkorRect.Left(), mAnkorRect.Bottom()+2*15),
911 basegfx::B2DPoint( mPageBorder ,mAnkorRect.Bottom()+2*15));
914 if (bChange)
916 Point aStart = EditWin()->PixelToLogic(GetPosPixel()+Point(0,GetSizePixel().Height()));
917 Point aEnd = EditWin()->PixelToLogic(GetPosPixel()+Point(GetSizePixel().Width()-1,GetSizePixel().Height()));
918 mpShadow->SetPosition(basegfx::B2DPoint(aStart.X(),aStart.Y()), basegfx::B2DPoint(aEnd.X(),aEnd.Y()));
921 if (mpMgr->ShowNotes())
923 if (IsFollow() && !HasChildPathFocus())
925 mpAnkor->SetAnkorState(AS_END);
927 else
929 mpAnkor->SetAnkorState(AS_ALL);
930 SwMarginWin* pWin = GetTopReplyNote();
931 if (pWin)
932 pWin->Ankor()->SetAnkorState(AS_END);
937 void SwMarginWin::DoResize()
939 long aTextHeight = LogicToPixel( mpOutliner->CalcTextSize()).Height();
940 long aHeight = GetSizePixel().Height();
941 unsigned long aWidth = GetSizePixel().Width();
943 if (mbMeta)
945 aHeight -= GetMetaHeight();
946 mpMeta->Show();
947 mpPostItTxt->SetQuickHelpText(EMPTYSTRING);
949 else
951 mpMeta->Hide();
952 mpPostItTxt->SetQuickHelpText(mpMeta->GetText());
955 if ((aTextHeight > aHeight) && !IsPreview())
956 { // we need vertical scrollbars and have to reduce the width
957 aWidth -= GetScrollbarWidth();
958 mpVScrollbar->Show();
960 else
962 mpVScrollbar->Hide();
965 mpMeta->SetPosSizePixel(0,aHeight,GetSizePixel().Width()-GetMetaButtonAreaWidth(),GetMetaHeight());
966 mpOutliner->SetPaperSize( PixelToLogic( Size(aWidth,aHeight) ) ) ;
967 mpOutlinerView->SetOutputArea( PixelToLogic( Rectangle(0,0,aWidth,aHeight) ) );
968 if (!mpVScrollbar->IsVisible())
969 { // if we do not have a scrollbar anymore, we want to see the complete text
970 mpOutlinerView->SetVisArea( PixelToLogic( Rectangle(0,0,aWidth,aHeight) ) );
973 if (!Application::GetSettings().GetLayoutRTL())
975 mpPostItTxt->SetPosSizePixel(0, 0, aWidth, aHeight);
976 mpVScrollbar->SetPosSizePixel( aWidth, 0, GetScrollbarWidth(), aHeight);
978 else
980 mpPostItTxt->SetPosSizePixel((aTextHeight > aHeight) && !IsPreview() ? GetScrollbarWidth() : 0 , 0, aWidth, aHeight);
981 mpVScrollbar->SetPosSizePixel( 0, 0, GetScrollbarWidth(), aHeight);
984 mpVScrollbar->SetVisibleSize( PixelToLogic(Size(0,aHeight)).Height() );
985 mpVScrollbar->SetPageSize( PixelToLogic(Size(0,aHeight)).Height() * 8 / 10 );
986 mpVScrollbar->SetLineSize( mpOutliner->GetTextHeight() / 10 );
987 SetScrollbar();
988 mpVScrollbar->SetRange( Range(0, mpOutliner->GetTextHeight()));
990 //calculate rects for meta- button
991 const Fraction& fx( GetMapMode().GetScaleX() );
992 const Fraction& fy( GetMapMode().GetScaleY() );
994 Point aPos( mpMeta->GetPosPixel());
995 Point aBase( aPos.X() + aPos.X() + GetSizePixel().Width(), aPos.Y() );
996 Point aLeft = PixelToLogic( Point( aBase.X() - (METABUTTON_WIDTH+5)*fx.GetNumerator()/fx.GetDenominator(), aBase.Y()+17*fy.GetNumerator()/fx.GetDenominator() ) );
997 Point aRight = PixelToLogic( Point( aBase.X() - (METABUTTON_WIDTH-1)*fx.GetNumerator()/fx.GetDenominator(), aBase.Y()+17*fy.GetNumerator()/fy.GetDenominator() ) );
998 Point aBottom = PixelToLogic( Point( aBase.X() - (METABUTTON_WIDTH+2)*fx.GetNumerator()/fx.GetDenominator(), aBase.Y()+20*fy.GetNumerator()/fy.GetDenominator() ) );
1000 aPopupTriangle.clear();
1001 aPopupTriangle.append(basegfx::B2DPoint(aLeft.X(),aLeft.Y()));
1002 aPopupTriangle.append(basegfx::B2DPoint(aRight.X(),aRight.Y()));
1003 aPopupTriangle.append(basegfx::B2DPoint(aBottom.X(),aBottom.Y()));
1004 aPopupTriangle.setClosed(true);
1005 if (IsPreview())
1006 mRectMetaButton = PixelToLogic( Rectangle( Point(
1007 aPos.X()+GetSizePixel().Width()-(METABUTTON_WIDTH*4+10)*fx.GetNumerator()/fx.GetDenominator(),
1008 aPos.Y()+5*fy.GetNumerator()/fy.GetDenominator() ),
1009 Size( METABUTTON_WIDTH*4*fx.GetNumerator()/fx.GetDenominator(), METABUTTON_HEIGHT*fy.GetNumerator()/fy.GetDenominator() ) ) );
1010 else
1011 mRectMetaButton = PixelToLogic( Rectangle( Point(
1012 aPos.X()+GetSizePixel().Width()-(METABUTTON_WIDTH+10)*fx.GetNumerator()/fx.GetDenominator(),
1013 aPos.Y()+5*fy.GetNumerator()/fy.GetDenominator() ),
1014 Size( METABUTTON_WIDTH*fx.GetNumerator()/fx.GetDenominator(), METABUTTON_HEIGHT*fy.GetNumerator()/fy.GetDenominator() ) ) );
1017 void SwMarginWin::SetSizePixel( const Size& rNewSize )
1019 Window::SetSizePixel(rNewSize);
1021 if (mpShadow)
1023 Point aStart = EditWin()->PixelToLogic(GetPosPixel()+Point(0,GetSizePixel().Height()));
1024 Point aEnd = EditWin()->PixelToLogic(GetPosPixel()+Point(GetSizePixel().Width()-1,GetSizePixel().Height()));
1025 mpShadow->SetPosition(basegfx::B2DPoint(aStart.X(),aStart.Y()), basegfx::B2DPoint(aEnd.X(),aEnd.Y()));
1029 void SwMarginWin::SetScrollbar()
1031 mpVScrollbar->SetThumbPos( mpOutlinerView->GetVisArea().Top()+ mpOutlinerView->GetEditView().GetCursor()->GetOffsetY());
1034 void SwMarginWin::ResizeIfNeccessary(long aOldHeight, long aNewHeight)
1036 if (aOldHeight != aNewHeight)
1038 //check for lower border or next note
1039 long aBorder = mpMgr->GetNextBorder();
1040 if (aBorder != -1)
1042 if (aNewHeight > GetMinimumSizeWithoutMeta())
1044 long aNewLowerValue = GetPosPixel().Y() + aNewHeight + GetMetaHeight();
1045 if (aNewLowerValue < aBorder)
1046 SetSizePixel(Size(GetSizePixel().Width(),aNewHeight+GetMetaHeight()));
1047 else
1048 SetSizePixel(Size(GetSizePixel().Width(),aBorder - GetPosPixel().Y()));
1049 DoResize();
1050 Invalidate();
1052 else
1054 if (GetSizePixel().Height() != GetMinimumSizeWithoutMeta() + GetMetaHeight())
1055 SetSizePixel(Size(GetSizePixel().Width(),GetMinimumSizeWithoutMeta() + GetMetaHeight()));
1056 DoResize();
1057 Invalidate();
1060 else
1062 DoResize();
1063 Invalidate();
1066 else
1068 SetScrollbar();
1072 void SwMarginWin::SetColor(Color aColorDark,Color aColorLight, Color aColorAnkor)
1074 mColorDark = aColorDark;
1075 mColorLight = aColorLight;
1076 mColorAnkor = aColorAnkor;
1078 if ( !Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
1080 //Wallpaper aWall(Gradient(GRADIENT_LINEAR,mColorLight,mColorDark));
1081 //mpPostItTxt->SetBackground(aWall);
1083 mpMeta->SetControlBackground(mColorDark);
1084 AllSettings aSettings = mpMeta->GetSettings();
1085 StyleSettings aStyleSettings = aSettings.GetStyleSettings();
1086 aStyleSettings.SetFieldTextColor(aColorAnkor);
1087 aSettings.SetStyleSettings(aStyleSettings);
1088 mpMeta->SetSettings(aSettings);
1090 AllSettings aSettings2 = mpVScrollbar->GetSettings();
1091 StyleSettings aStyleSettings2 = aSettings2.GetStyleSettings();
1092 aStyleSettings2.SetButtonTextColor(Color(0,0,0));
1093 //aStyleSettings2.SetLightColor(mColorAnkor);
1094 aStyleSettings2.SetCheckedColor(mColorLight); //hintergund
1095 //aStyleSettings2.SetLightBorderColor(mColorAnkor);
1096 aStyleSettings2.SetShadowColor(mColorAnkor);
1097 aStyleSettings2.SetFaceColor(mColorDark);
1098 aSettings2.SetStyleSettings(aStyleSettings2);
1099 mpVScrollbar->SetSettings(aSettings2);
1103 void SwMarginWin::SetMarginSide(bool aMarginSide)
1105 mbMarginSide = aMarginSide;
1108 void SwMarginWin::SetReadonly(BOOL bSet)
1110 mbReadonly = bSet;
1111 View()->SetReadOnly(bSet);
1114 void SwMarginWin::SetLanguage(const SvxLanguageItem aNewItem)
1116 Engine()->SetModifyHdl( Link() );
1117 ESelection aOld = View()->GetSelection();
1119 ESelection aNewSelection( 0, 0, (USHORT)Engine()->GetParagraphCount()-1, USHRT_MAX );
1120 View()->SetSelection( aNewSelection );
1121 SfxItemSet aEditAttr(View()->GetAttribs());
1122 aEditAttr.Put(aNewItem);
1123 View()->SetAttribs( aEditAttr );
1125 View()->SetSelection(aOld);
1126 Engine()->SetModifyHdl( LINK( this, SwPostIt, ModifyHdl ) );
1128 const SwViewOption* pVOpt = DocView()->GetWrtShellPtr()->GetViewOptions();
1129 ULONG nCntrl = Engine()->GetControlWord();
1130 // turn off
1131 if (!pVOpt->IsOnlineSpell())
1132 nCntrl &= ~EE_CNTRL_ONLINESPELLING;
1133 else
1134 nCntrl &= ~EE_CNTRL_ONLINESPELLING;
1135 Engine()->SetControlWord(nCntrl);
1137 //turn back on
1138 if (pVOpt->IsOnlineSpell())
1139 nCntrl |= EE_CNTRL_ONLINESPELLING;
1140 else
1141 nCntrl &= ~EE_CNTRL_ONLINESPELLING;
1142 Engine()->SetControlWord(nCntrl);
1144 Engine()->CompleteOnlineSpelling();
1145 Invalidate();
1148 void SwMarginWin::DataChanged( const DataChangedEvent& aEvent)
1150 Window::DataChanged( aEvent );
1153 void SwMarginWin::GetFocus()
1155 if (mpPostItTxt)
1156 mpPostItTxt->GrabFocus();
1159 void SwMarginWin::LoseFocus()
1163 void SwMarginWin::ShowNote()
1165 SetPosAndSize();
1166 if (!IsVisible())
1167 Window::Show();
1168 if (mpAnkor && !mpShadow->isVisible())
1169 mpShadow->setVisible(true);
1170 if (mpAnkor && !mpAnkor->isVisible())
1171 mpAnkor->setVisible(true);
1174 void SwMarginWin::HideNote()
1176 if (IsVisible())
1177 Window::Hide();
1178 if (mpAnkor)
1180 if (mpMgr->IsShowAnkor())
1181 mpAnkor->SetAnkorState(AS_TRI);
1182 else
1183 mpAnkor->setVisible(false);
1185 if (mpShadow && mpShadow->isVisible())
1186 mpShadow->setVisible(false);
1189 void SwMarginWin::ActivatePostIt()
1191 mpMgr->AssureStdModeAtShell();
1193 mpOutliner->ClearModifyFlag();
1194 mpOutliner->GetUndoManager().Clear();
1196 CheckMetaText();
1197 SetViewState(SS_EDIT);
1198 View()->ShowCursor();
1200 mpOutlinerView->GetEditView().SetInsertMode(mpView->GetWrtShellPtr()->IsInsMode());
1202 if ( !Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
1203 View()->SetBackgroundColor(mColorDark);
1205 // mpPostItTxt->SetBackground(Wallpaper(mColorDark));
1208 void SwMarginWin::DeactivatePostIt()
1210 // remove selection, #i87073#
1211 if (View()->GetEditView().HasSelection())
1213 ESelection aSelection = View()->GetEditView().GetSelection();
1214 aSelection.nEndPara = aSelection.nStartPara;
1215 aSelection.nEndPos = aSelection.nStartPos;
1216 View()->GetEditView().SetSelection(aSelection);
1219 mpOutliner->CompleteOnlineSpelling();
1221 SetViewState(SS_NORMAL);
1222 // write the visible text back into the SwField
1223 UpdateData();
1225 if ( !Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
1226 View()->SetBackgroundColor(COL_TRANSPARENT);
1228 //mpPostItTxt->SetBackground(Gradient(GRADIENT_LINEAR,mColorLight,mColorDark));
1230 if ( !IsProtected() &&
1231 //if (!IsReadOnly() && (GetStatus()!=SwPostItHelper::DELETED) &&
1232 Engine()->GetEditEngine().GetText()==String(EMPTYSTRING) )
1233 mnEventId = Application::PostUserEvent( LINK( this, SwMarginWin, DeleteHdl), 0 );
1236 void SwMarginWin::ToggleInsMode()
1238 if (!mpView->GetWrtShell().IsRedlineOn())
1240 //change outliner
1241 mpOutlinerView->GetEditView().SetInsertMode(!mpOutlinerView->GetEditView().IsInsertMode());
1242 //change documnet
1243 mpView->GetWrtShell().ToggleInsMode();
1244 //update statusbar
1245 SfxBindings &rBnd = mpView->GetViewFrame()->GetBindings();
1246 rBnd.Invalidate(SID_ATTR_INSERT);
1247 rBnd.Update(SID_ATTR_INSERT);
1251 void SwMarginWin::ExecuteCommand(USHORT nSlot)
1253 mpMgr->AssureStdModeAtShell();
1255 switch (nSlot)
1257 case FN_POSTIT:
1258 case FN_REPLY:
1260 // if this note is empty, it will be deleted once losing the focus, so no reply, but only a new note
1261 // will be created
1262 SwView* pView = DocView();
1263 if (Engine()->GetEditEngine().GetText() != String(EMPTYSTRING))
1265 OutlinerParaObject* pPara = new OutlinerParaObject(*View()->GetEditView().CreateTextObject());
1266 Mgr()->RegisterAnswer(pPara);
1268 if (Mgr()->GetActivePostIt())
1269 Mgr()->SetActivePostIt(0);
1270 SwitchToFieldPos();
1271 pView->GetViewFrame()->GetDispatcher()->Execute(FN_POSTIT);
1272 break;
1274 case FN_DELETE_COMMENT:
1275 case FN_DELETE_NOTE:
1277 //Delete(); // do not kill the parent of our open popup menu
1278 mnEventId = Application::PostUserEvent( LINK( this, SwMarginWin, DeleteHdl), 0 );
1279 break;
1281 case FN_HIDE_NOTE:
1282 if ( Mgr()->GetActivePostIt() == this )
1284 Mgr()->SetActivePostIt(0);
1285 // put the cursor back into the document
1286 SwitchToFieldPos();
1288 Mgr()->Hide(mpFld);
1289 break;
1291 case FN_DELETE_ALL_NOTES:
1292 case FN_HIDE_ALL_NOTES:
1293 // not possible as slot as this would require that "this" is the active postit
1294 DocView()->GetViewFrame()->GetBindings().Execute( nSlot, 0, 0, SFX_CALLMODE_ASYNCHRON );
1295 break;
1296 case FN_DELETE_NOTE_AUTHOR:
1297 case FN_HIDE_NOTE_AUTHOR:
1299 // not possible as slot as this would require that "this" is the active postit
1300 SfxStringItem aItem( nSlot, GetAuthor() );
1301 const SfxPoolItem* aItems[2];
1302 aItems[0] = &aItem;
1303 aItems[1] = 0;
1304 DocView()->GetViewFrame()->GetBindings().Execute( nSlot, aItems, 0, SFX_CALLMODE_ASYNCHRON );
1306 default:
1307 mpView->GetViewFrame()->GetBindings().Execute( nSlot );
1308 break;
1312 bool SwMarginWin::CalcFollow()
1314 return false;
1317 SwEditWin* SwMarginWin::EditWin()
1319 return &mpView->GetEditWin();
1322 String SwPostIt::GetAuthor()
1324 return mpFld->GetPar1();
1327 Date SwPostIt::GetDate()
1329 return mpFld->GetDate();
1332 Time SwPostIt::GetTime()
1334 return mpFld->GetTime();
1337 long SwMarginWin::GetPostItTextHeight()
1339 return mpOutliner ? LogicToPixel(mpOutliner->CalcTextSize()).Height() : 0;
1342 void SwMarginWin::SwitchToPostIt(USHORT aDirection)
1344 if (mpMgr)
1346 SwMarginWin* pPostIt = mpMgr->GetNextPostIt(aDirection, this);
1347 if (pPostIt)
1348 pPostIt->GrabFocus();
1352 void SwMarginWin::MouseButtonDown( const MouseEvent& /*rMEvt */)
1356 void SwMarginWin::MouseMove( const MouseEvent& rMEvt )
1358 if (mRectMetaButton.IsInside(PixelToLogic(rMEvt.GetPosPixel())))
1360 if (!mbMouseOverButton)
1362 Invalidate(mRectMetaButton);
1363 mbMouseOverButton = true;
1366 else
1368 if (mbMouseOverButton)
1370 Invalidate(mRectMetaButton);
1371 mbMouseOverButton = false;
1376 void SwMarginWin::Delete()
1378 if ( Mgr()->GetActivePostIt() == this)
1380 Mgr()->SetActivePostIt(0);
1381 // if the note is empty, the previous line will send a delete event, but we are already there
1382 if (mnEventId)
1384 Application::RemoveUserEvent( mnEventId );
1385 mnEventId = 0;
1390 IMPL_LINK(SwMarginWin, ScrollHdl, ScrollBar*, pScroll)
1392 long nDiff = View()->GetEditView().GetVisArea().Top() - pScroll->GetThumbPos();
1393 View()->Scroll( 0, nDiff );
1394 return 0;
1397 IMPL_LINK(SwMarginWin, ModifyHdl, void*, pVoid)
1399 // no warnings, please
1400 pVoid=0;
1401 DocView()->GetDocShell()->SetModified(sal_True);
1402 return 0;
1405 IMPL_LINK(SwMarginWin, DeleteHdl, void*, pVoid)
1407 // no warnings, please
1408 pVoid=0;
1409 mnEventId = 0;
1410 Delete();
1411 return 0;
1415 void SwMarginWin::ResetAttributes()
1417 mpOutlinerView->RemoveAttribsKeepLanguages(TRUE);
1418 mpOutliner->RemoveFields(TRUE);
1419 mpOutlinerView->SetAttribs(DefaultItem());
1422 sal_Int32 SwMarginWin::GetScrollbarWidth()
1424 return mpView->GetWrtShell().GetViewOptions()->GetZoom() / 10;
1427 sal_Int32 SwMarginWin::GetMetaButtonAreaWidth()
1429 const Fraction& f( GetMapMode().GetScaleX() );
1430 if (IsPreview())
1431 return 3 * METABUTTON_AREA_WIDTH * f.GetNumerator() / f.GetDenominator();
1432 else
1433 return METABUTTON_AREA_WIDTH * f.GetNumerator() / f.GetDenominator();
1436 sal_Int32 SwMarginWin::GetMetaHeight()
1438 const Fraction& f( GetMapMode().GetScaleY() );
1439 return POSTIT_META_HEIGHT * f.GetNumerator() / f.GetDenominator();
1442 sal_Int32 SwMarginWin::GetMinimumSizeWithMeta()
1444 return mpMgr->GetMinimumSizeWithMeta();
1447 sal_Int32 SwMarginWin::GetMinimumSizeWithoutMeta()
1449 const Fraction& f( GetMapMode().GetScaleY() );
1450 return POSTIT_MINIMUMSIZE_WITHOUT_META * f.GetNumerator() / f.GetDenominator();
1453 void SwMarginWin::SetSpellChecking()
1455 const SwViewOption* pVOpt = mpView->GetWrtShellPtr()->GetViewOptions();
1456 ULONG nCntrl = mpOutliner->GetControlWord();
1457 if (pVOpt->IsOnlineSpell())
1458 nCntrl |= EE_CNTRL_ONLINESPELLING;
1459 else
1460 nCntrl &= ~EE_CNTRL_ONLINESPELLING;
1461 mpOutliner->SetControlWord(nCntrl);
1463 mpOutliner->CompleteOnlineSpelling();
1464 Invalidate();
1467 void SwMarginWin::SetViewState(ShadowState bState)
1469 switch (bState)
1471 case SS_EDIT:
1473 if (mpAnkor)
1475 mpAnkor->SetAnkorState(AS_ALL);
1476 SwMarginWin* pWin = GetTopReplyNote();
1477 if (pWin)
1478 pWin->Ankor()->SetAnkorState(AS_END);
1479 mpAnkor->setLineSolid(true);
1481 if (mpShadow)
1482 mpShadow->SetShadowState(bState);
1483 break;
1485 case SS_VIEW:
1487 if (mpAnkor)
1488 mpAnkor->setLineSolid(true);
1489 if (mpShadow)
1490 mpShadow->SetShadowState(bState);
1491 break;
1493 case SS_NORMAL:
1495 if (mpAnkor)
1497 if (IsFollow())
1499 // if there is no visible parent note, we want to see the complete anchor ??
1500 //if (IsAnyStackParentVisible())
1501 mpAnkor->SetAnkorState(AS_END);
1502 SwMarginWin* pTopWinSelf = GetTopReplyNote();
1503 SwMarginWin* pTopWinActive = mpMgr->GetActivePostIt() ? mpMgr->GetActivePostIt()->GetTopReplyNote() : 0;
1504 if (pTopWinSelf && (pTopWinSelf!=pTopWinActive))
1506 if (pTopWinSelf!=mpMgr->GetActivePostIt())
1507 pTopWinSelf->Ankor()->setLineSolid(false);
1508 pTopWinSelf->Ankor()->SetAnkorState(AS_ALL);
1511 mpAnkor->setLineSolid(false);
1513 if (mpShadow)
1514 mpShadow->SetShadowState(bState);
1515 break;
1520 bool SwMarginWin::IsAnyStackParentVisible()
1522 SwMarginWin* pMarginWin = mpMgr->GetNextPostIt(KEY_PAGEUP, this);
1523 while (pMarginWin)
1525 if (pMarginWin->IsFollow())
1527 pMarginWin = mpMgr->GetNextPostIt(KEY_PAGEUP, pMarginWin);
1528 if (pMarginWin && pMarginWin->IsVisible())
1529 return true;
1531 else
1532 return pMarginWin && pMarginWin->IsVisible() ? true : false;
1534 return false;
1537 SwMarginWin* SwMarginWin::GetTopReplyNote()
1539 SwMarginWin* pTopNote = 0;
1540 SwMarginWin* pMarginWin = IsFollow() ? mpMgr->GetNextPostIt(KEY_PAGEUP, this) : 0;
1541 while (pMarginWin)
1543 pTopNote = pMarginWin;
1544 pMarginWin = pMarginWin->IsFollow() ? mpMgr->GetNextPostIt(KEY_PAGEUP, pMarginWin) : 0;
1546 return pTopNote;
1549 void SwMarginWin::SwitchToFieldPos()
1551 if ( Mgr()->GetActivePostIt() == this )
1552 Mgr()->SetActivePostIt(0);
1553 GotoPos();
1554 sal_uInt32 aCount = MoveCaret();
1555 if (aCount)
1556 DocView()->GetDocShell()->GetWrtShell()->SwCrsrShell::Right(aCount, 0, FALSE);
1557 GrabFocusToDocument();
1560 String SwMarginWin::GetAuthor()
1562 return String(EMPTYSTRING);
1565 Date SwMarginWin::GetDate()
1567 return Date(0);
1570 Time SwMarginWin::GetTime()
1572 return Time(0);
1575 SvxLanguageItem SwMarginWin::GetLanguage(void)
1577 return SvxLanguageItem(SwLangHelper::GetLanguage(DocView()->GetWrtShell(),RES_CHRATR_LANGUAGE),RES_CHRATR_LANGUAGE);
1580 /***** SwPostIt *********************************************/
1581 SwPostIt::SwPostIt( Window* pParent, WinBits nBits, SwFmtFld* aField,SwPostItMgr* aMgr,SwPostItBits aBits)
1582 : SwMarginWin(pParent,nBits,aMgr,aBits),
1583 mpFmtFld(aField),
1584 mpFld( static_cast<SwPostItField*>(aField->GetFld())),
1585 mStatus(SwPostItHelper::INVISIBLE)
1589 void SwPostIt::SetPostItText()
1591 // get text from SwPostItField and insert into our textview
1592 Engine()->SetModifyHdl( Link() );
1593 Engine()->EnableUndo( FALSE );
1594 mpFld = static_cast<SwPostItField*>(mpFmtFld->GetFld());
1595 if( mpFld->GetTextObject() )
1596 Engine()->SetText( *mpFld->GetTextObject() );
1597 else
1599 Engine()->Clear();
1600 View()->SetAttribs(DefaultItem());
1601 View()->InsertText(mpFld->GetPar2(),false);
1604 Engine()->ClearModifyFlag();
1605 Engine()->GetUndoManager().Clear();
1606 Engine()->EnableUndo( TRUE );
1607 Engine()->SetModifyHdl( LINK( this, SwPostIt, ModifyHdl ) );
1608 Invalidate();
1611 void SwPostIt::UpdateData()
1613 if ( Engine()->IsModified() )
1615 SwTxtFld* pTxtFld = mpFmtFld->GetTxtFld();
1616 SwPosition aPosition( pTxtFld->GetTxtNode() );
1617 aPosition.nContent = *pTxtFld->GetStart();
1618 SwField* pOldField = mpFld->Copy();
1619 mpFld->SetPar2(Engine()->GetEditEngine().GetText());
1620 mpFld->SetTextObject(Engine()->CreateParaObject());
1621 DocView()->GetDocShell()->GetDoc()->AppendUndo(new SwUndoFieldFromDoc(aPosition, *pOldField, *mpFld, 0, true));
1622 delete pOldField;
1623 // so we get a new layout of notes (anchor position is still the same and we would otherwise not get one)
1624 Mgr()->SetLayout();
1625 // #i98686# if we have several views, all notes should update their text
1626 mpFmtFld->Broadcast(SwFmtFldHint( 0, SWFMTFLD_CHANGED));
1627 DocView()->GetDocShell()->SetModified();
1629 Engine()->ClearModifyFlag();
1630 Engine()->GetUndoManager().Clear();
1633 void SwPostIt::SetChangeTracking(SwPostItHelper::SwLayoutStatus& aStatus,Color aColor)
1635 if ( (mStatus != aStatus) || (mChangeColor != aColor) )
1637 mStatus = aStatus;
1638 mChangeColor = aColor;
1639 Invalidate();
1643 void SwPostIt::Delete()
1645 SwMarginWin::Delete();
1646 // we delete the field directly, the Mgr cleans up the PostIt by listening
1647 DocView()->GetWrtShellPtr()->GotoField(*mpFmtFld);
1648 GrabFocusToDocument();
1649 DocView()->GetWrtShellPtr()->DelRight();
1652 void SwPostIt::GotoPos()
1654 DocView()->GetDocShell()->GetWrtShell()->GotoField(*mpFmtFld);
1657 sal_uInt32 SwPostIt::MoveCaret()
1659 // if this is an answer, do not skip over all following ones, but insert directly behind the current one
1660 // but when just leaving a note, skip all following ones as well to continue typing
1661 return Mgr()->IsAnswer() ? 1 : 1 + CountFollowing();
1664 //returns true, if there is another note right before this note
1665 bool SwPostIt::CalcFollow()
1667 SwTxtFld* pTxtFld = mpFmtFld->GetTxtFld();
1668 SwPosition aPosition( pTxtFld->GetTxtNode() );
1669 aPosition.nContent = *pTxtFld->GetStart();
1670 SwTxtAttr * const pTxtAttr = pTxtFld->GetTxtNode().GetTxtAttrForCharAt(
1671 aPosition.nContent.GetIndex() - 1, RES_TXTATR_FIELD );
1672 const SwField* pFld = pTxtAttr ? pTxtAttr->GetFld().GetFld() : 0;
1673 return pFld && (pFld->Which()== RES_POSTITFLD);
1676 // counts how many SwPostItField we have right after the current one
1677 sal_uInt32 SwPostIt::CountFollowing()
1679 sal_uInt32 aCount = 1; // we start with 1, so we have to subtract one at the end again
1680 SwTxtFld* pTxtFld = mpFmtFld->GetTxtFld();
1681 SwPosition aPosition( pTxtFld->GetTxtNode() );
1682 aPosition.nContent = *pTxtFld->GetStart();
1684 SwTxtAttr * pTxtAttr = pTxtFld->GetTxtNode().GetTxtAttrForCharAt(
1685 aPosition.nContent.GetIndex() + 1, RES_TXTATR_FIELD );
1686 SwField* pFld = pTxtAttr ? const_cast<SwField*>(pTxtAttr->GetFld().GetFld()) : 0;
1687 while (pFld && (pFld->Which()== RES_POSTITFLD))
1689 aCount++;
1690 pTxtAttr = pTxtFld->GetTxtNode().GetTxtAttrForCharAt(
1691 aPosition.nContent.GetIndex() + aCount, RES_TXTATR_FIELD );
1692 pFld = pTxtAttr ? const_cast<SwField*>(pTxtAttr->GetFld().GetFld()) : 0;
1694 return aCount - 1;
1697 void SwPostIt::MouseButtonDown( const MouseEvent& rMEvt )
1699 if (mRectMetaButton.IsInside(PixelToLogic(rMEvt.GetPosPixel())) && rMEvt.IsLeft())
1701 if (IsPreview())
1703 doLazyDelete();
1704 if (Mgr())
1706 SwPostIt* pPostIt = dynamic_cast<SwPostIt*>(Mgr()->GetPostIt(mpFmtFld));
1707 if (pPostIt)
1709 pPostIt->GrabFocus();
1710 Mgr()->MakeVisible(pPostIt);
1715 else
1717 if ( mbReadonly )
1719 mpButtonPopup->EnableItem(FN_REPLY,false);
1720 mpButtonPopup->EnableItem(FN_DELETE_NOTE,false);
1721 mpButtonPopup->EnableItem(FN_DELETE_NOTE_AUTHOR,false);
1722 mpButtonPopup->EnableItem(FN_DELETE_ALL_NOTES,false);
1724 else
1726 if (IsProtected())
1727 mpButtonPopup->EnableItem(FN_DELETE_NOTE,false);
1728 else
1729 mpButtonPopup->EnableItem(FN_DELETE_NOTE,true);
1730 mpButtonPopup->EnableItem(FN_DELETE_NOTE_AUTHOR,true);
1731 mpButtonPopup->EnableItem(FN_DELETE_ALL_NOTES,true);
1733 SvtUserOptions aUserOpt;
1734 String sAuthor;
1735 if( !(sAuthor = aUserOpt.GetFullName()).Len())
1736 if( !(sAuthor = aUserOpt.GetID()).Len() )
1737 sAuthor = String( SW_RES( STR_REDLINE_UNKNOWN_AUTHOR ));
1738 // do not allow to reply to ourself and no answer possible if this note is in a protected section
1739 if ((sAuthor == GetAuthor()) || (IsProtected()))
1740 mpButtonPopup->EnableItem(FN_REPLY,false);
1741 else
1742 mpButtonPopup->EnableItem(FN_REPLY,true);
1744 // show the popup menu and execute the selected command
1745 ExecuteCommand( mpButtonPopup->Execute( this,Rectangle(LogicToPixel(mRectMetaButton.BottomLeft()),LogicToPixel(mRectMetaButton.BottomLeft())),POPUPMENU_EXECUTE_DOWN | POPUPMENU_NOMOUSEUPCLOSE) );
1750 void SwPostIt::SetPopup()
1752 mpButtonPopup = new PopupMenu(SW_RES(MN_ANNOTATION_BUTTON));
1753 //mpButtonPopup->SetMenuFlags(MENU_FLAG_ALWAYSSHOWDISABLEDENTRIES);
1754 XubString aText = mpButtonPopup->GetItemText( FN_DELETE_NOTE_AUTHOR );
1755 SwRewriter aRewriter;
1756 aRewriter.AddRule(UNDO_ARG1,GetAuthor());
1757 aText = aRewriter.Apply(aText);
1758 mpButtonPopup->SetItemText(FN_DELETE_NOTE_AUTHOR,aText);
1761 void SwPostIt::InitAnswer(OutlinerParaObject* pText)
1763 //collect our old meta data
1764 SwMarginWin* pWin = Mgr()->GetNextPostIt(KEY_PAGEUP, this);
1765 const LocaleDataWrapper& rLocalData = SvtSysLocale().GetLocaleData();
1766 String aText = String(SW_RES(STR_REPLY));
1767 SwRewriter aRewriter;
1768 aRewriter.AddRule(UNDO_ARG1, pWin->GetAuthor());
1769 aText = aRewriter.Apply(aText);
1770 aText.Append(String(rtl::OUString::createFromAscii(" (") +
1771 String(rLocalData.getDate( pWin->GetDate())) + rtl::OUString::createFromAscii(", ") +
1772 String(rLocalData.getTime( pWin->GetTime(),false)) + rtl::OUString::createFromAscii("): \"")));
1773 View()->InsertText(aText,false);
1775 // insert old, selected text or "..."
1776 // TOOD: iterate over all paragraphs, not only first one to find out if it is empty
1777 if (pText->GetTextObject().GetText(0) != String(EMPTYSTRING))
1778 View()->GetEditView().InsertText(pText->GetTextObject());
1779 else
1780 View()->InsertText(rtl::OUString::createFromAscii("..."),false);
1781 View()->InsertText(rtl::OUString::createFromAscii("\"\n"),false);
1783 View()->SetSelection(ESelection(0x0,0x0,0xFFFF,0xFFFF));
1784 SfxItemSet aAnswerSet( DocView()->GetDocShell()->GetPool() );
1785 aAnswerSet.Put(SvxFontHeightItem(200,80,EE_CHAR_FONTHEIGHT));
1786 aAnswerSet.Put(SvxPostureItem(ITALIC_NORMAL,EE_CHAR_ITALIC));
1787 View()->SetAttribs(aAnswerSet);
1788 View()->SetSelection(ESelection(0xFFFF,0xFFFF,0xFFFF,0xFFFF));
1790 //remove all attributes and reset our standard ones
1791 View()->GetEditView().RemoveAttribsKeepLanguages(true);
1792 View()->SetAttribs(DefaultItem());
1793 // lets insert an undo step so the initial text can be easily deleted
1794 // but do not use UpdateData() directly, would set modified state again and reentrance into Mgr
1795 Engine()->SetModifyHdl( Link() );
1796 SwTxtFld* pTxtFld = mpFmtFld->GetTxtFld();
1797 SwPosition aPosition( pTxtFld->GetTxtNode() );
1798 aPosition.nContent = *pTxtFld->GetStart();
1799 SwField* pOldField = mpFld->Copy();
1800 mpFld->SetPar2(Engine()->GetEditEngine().GetText());
1801 mpFld->SetTextObject(Engine()->CreateParaObject());
1802 DocView()->GetDocShell()->GetDoc()->AppendUndo(new SwUndoFieldFromDoc(aPosition, *pOldField, *mpFld, 0, true));
1803 delete pOldField;
1804 Engine()->SetModifyHdl( LINK( this, SwPostIt, ModifyHdl ) );
1805 Engine()->ClearModifyFlag();
1806 Engine()->GetUndoManager().Clear();
1809 SvxLanguageItem SwPostIt::GetLanguage(void)
1811 // set initial language for outliner
1812 USHORT nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( mpFld->GetLanguage() );
1813 USHORT nLangWhichId = 0;
1814 switch (nScriptType)
1816 case SCRIPTTYPE_LATIN : nLangWhichId = EE_CHAR_LANGUAGE ; break;
1817 case SCRIPTTYPE_ASIAN : nLangWhichId = EE_CHAR_LANGUAGE_CJK; break;
1818 case SCRIPTTYPE_COMPLEX : nLangWhichId = EE_CHAR_LANGUAGE_CTL; break;
1819 default: DBG_ERROR("GetLanguage: wrong script tye");
1821 return SvxLanguageItem(mpFld->GetLanguage(),nLangWhichId);
1824 bool SwPostIt::IsProtected()
1826 bool aReturn;
1827 aReturn = mpFmtFld ? (SwMarginWin::IsProtected() || (mStatus==SwPostItHelper::DELETED) ||
1828 mpFmtFld->IsProtect()) : (SwMarginWin::IsProtected() || (mStatus==SwPostItHelper::DELETED));
1829 return aReturn;
1832 /********** SwRedComment**************/
1834 SwRedComment::SwRedComment( Window* pParent, WinBits nBits,SwPostItMgr* aMgr,SwPostItBits aBits,SwRedline* pRed)
1835 : SwMarginWin(pParent,nBits,aMgr,aBits),
1836 pRedline(pRed)
1840 void SwRedComment::SetPopup()
1842 mpButtonPopup = new PopupMenu(SW_RES(MN_REDCOMMENT_BUTTON));
1843 //mpButtonPopup->SetMenuFlags(MENU_FLAG_ALWAYSSHOWDISABLEDENTRIES);
1846 void SwRedComment::UpdateData()
1848 if ( Engine()->IsModified() )
1850 // so we get a new layout of notes (ankor position is still the same and we would otherwise not get one)
1851 Mgr()->SetLayout();
1852 // SetRedline is calling SetModified already
1853 DocView()->GetWrtShell().SetRedlineComment(Engine()->GetEditEngine().GetText());
1855 Engine()->ClearModifyFlag();
1856 Engine()->GetUndoManager().Clear();
1859 void SwRedComment::SetPostItText()
1861 Engine()->SetModifyHdl( Link() );
1862 Engine()->EnableUndo( FALSE );
1864 Engine()->Clear();
1865 View()->SetAttribs(DefaultItem());
1866 View()->InsertText(pRedline->GetComment(),false);
1868 Engine()->ClearModifyFlag();
1869 Engine()->GetUndoManager().Clear();
1870 Engine()->EnableUndo( TRUE );
1871 Engine()->SetModifyHdl( LINK( this, SwMarginWin, ModifyHdl ) );
1872 Invalidate();
1875 void SwRedComment::DeactivatePostIt()
1877 SwMarginWin::DeactivatePostIt();
1878 // current Redline is still selected
1879 DocView()->GetWrtShellPtr()->ClearMark();
1882 void SwRedComment::ActivatePostIt()
1884 SwMarginWin::ActivatePostIt();
1886 // do we want the redline selected?
1887 // otherwise, SwRedComment::ActivatePostIt() as well as SwRedComment::DeactivatePostIt()
1888 // can be thrown out completly
1889 DocView()->GetDocShell()->GetWrtShell()->GotoRedline(
1890 DocView()->GetDocShell()->GetWrtShell()->FindRedlineOfData(pRedline->GetRedlineData()),true);
1893 void SwRedComment::MouseButtonDown( const MouseEvent& rMEvt )
1895 if (mRectMetaButton.IsInside(PixelToLogic(rMEvt.GetPosPixel())) && rMEvt.IsLeft())
1897 ExecuteCommand( mpButtonPopup->Execute( this,Rectangle(LogicToPixel(mRectMetaButton.BottomLeft()),LogicToPixel(mRectMetaButton.BottomLeft())),POPUPMENU_EXECUTE_DOWN | POPUPMENU_NOMOUSEUPCLOSE) );
1901 void SwRedComment::Delete()
1903 SwMarginWin::Delete();
1904 // we are not neccessarily on our redline, so let's move there
1905 GotoPos();
1906 DocView()->GetWrtShell().SetRedlineComment(EMPTYSTRING);
1907 DocView()->GetWrtShell().ClearMark();
1908 // so we get a new layout of notes (ankor position is still the same and we would otherwise not get one)
1909 Mgr()->SetLayout();
1910 Mgr()->RemoveItem(pRedline);
1913 void SwRedComment::GotoPos()
1915 DocView()->GetDocShell()->GetWrtShell()->GotoRedline(
1916 DocView()->GetDocShell()->GetWrtShell()->FindRedlineOfData(pRedline->GetRedlineData()));
1919 String SwRedComment::GetAuthor()
1921 return pRedline->GetAuthorString();
1924 Date SwRedComment::GetDate()
1926 return pRedline->GetTimeStamp().GetDate();
1929 Time SwRedComment::GetTime()
1931 return pRedline->GetTimeStamp().GetTime();
1934 bool SwRedComment::IsProtected()
1936 return SwMarginWin::IsProtected() || pRedline->Start()->nNode.GetNode().GetTxtNode()->IsInProtectSect();
1940 //////////////////////////////////////////////////////////////////////////////
1941 // helper SwPostItShadowPrimitive
1943 // Used to allow view-dependent primitive definition. For that purpose, the
1944 // initially created primitive (this one) always has to be view-independent,
1945 // but the decomposition is made view-dependent. Very simple primitive which
1946 // just remembers the discrete data and applies it at decomposition time.
1948 class SwPostItShadowPrimitive : public drawinglayer::primitive2d::DiscreteMetricDependentPrimitive2D
1950 private:
1951 basegfx::B2DPoint maBasePosition;
1952 basegfx::B2DPoint maSecondPosition;
1953 ShadowState maShadowState;
1955 protected:
1956 virtual drawinglayer::primitive2d::Primitive2DSequence createLocalDecomposition(
1957 const drawinglayer::geometry::ViewInformation2D& rViewInformation) const;
1959 public:
1960 SwPostItShadowPrimitive(
1961 const basegfx::B2DPoint& rBasePosition,
1962 const basegfx::B2DPoint& rSecondPosition,
1963 ShadowState aShadowState)
1964 : drawinglayer::primitive2d::DiscreteMetricDependentPrimitive2D(),
1965 maBasePosition(rBasePosition),
1966 maSecondPosition(rSecondPosition),
1967 maShadowState(aShadowState)
1970 // data access
1971 const basegfx::B2DPoint& getBasePosition() const { return maBasePosition; }
1972 const basegfx::B2DPoint& getSecondPosition() const { return maSecondPosition; }
1973 ShadowState getShadowState() const { return maShadowState; }
1975 virtual bool operator==( const drawinglayer::primitive2d::BasePrimitive2D& rPrimitive ) const;
1977 DeclPrimitrive2DIDBlock()
1980 drawinglayer::primitive2d::Primitive2DSequence SwPostItShadowPrimitive::createLocalDecomposition(
1981 const drawinglayer::geometry::ViewInformation2D& /*rViewInformation*/) const
1983 // get logic sizes in object coordinate system
1984 drawinglayer::primitive2d::Primitive2DSequence xRetval;
1985 basegfx::B2DRange aRange(getBasePosition());
1987 switch(maShadowState)
1989 case SS_NORMAL:
1991 aRange.expand(basegfx::B2DTuple(getSecondPosition().getX(), getSecondPosition().getY() + (2.0 * getDiscreteUnit())));
1992 const drawinglayer::attribute::FillGradientAttribute aFillGradientAttribute(
1993 drawinglayer::attribute::GRADIENTSTYLE_LINEAR,
1994 0.0,
1995 0.5,
1996 0.5,
1997 1800.0 * F_PI1800,
1998 basegfx::BColor(230.0/255.0,230.0/255.0,230.0/255.0),
1999 basegfx::BColor(180.0/255.0,180.0/255.0,180.0/255.0),
2002 const drawinglayer::primitive2d::Primitive2DReference xReference(
2003 new drawinglayer::primitive2d::FillGradientPrimitive2D(
2004 aRange,
2005 aFillGradientAttribute));
2007 xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
2008 break;
2010 case SS_VIEW:
2012 aRange.expand(basegfx::B2DTuple(getSecondPosition().getX(), getSecondPosition().getY() + (4.0 * getDiscreteUnit())));
2013 const drawinglayer::attribute::FillGradientAttribute aFillGradientAttribute(
2014 drawinglayer::attribute::GRADIENTSTYLE_LINEAR,
2015 0.0,
2016 0.5,
2017 0.5,
2018 1800.0 * F_PI1800,
2019 basegfx::BColor(230.0/255.0,230.0/255.0,230.0/255.0),
2020 basegfx::BColor(180.0/255.0,180.0/255.0,180.0/255.0),
2023 const drawinglayer::primitive2d::Primitive2DReference xReference(
2024 new drawinglayer::primitive2d::FillGradientPrimitive2D(
2025 aRange,
2026 aFillGradientAttribute));
2028 xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
2029 break;
2031 case SS_EDIT:
2033 aRange.expand(basegfx::B2DTuple(getSecondPosition().getX(), getSecondPosition().getY() + (4.0 * getDiscreteUnit())));
2034 const drawinglayer::attribute::FillGradientAttribute aFillGradientAttribute(
2035 drawinglayer::attribute::GRADIENTSTYLE_LINEAR,
2036 0.0,
2037 0.5,
2038 0.5,
2039 1800.0 * F_PI1800,
2040 basegfx::BColor(230.0/255.0,230.0/255.0,230.0/255.0),
2041 basegfx::BColor(83.0/255.0,83.0/255.0,83.0/255.0),
2044 const drawinglayer::primitive2d::Primitive2DReference xReference(
2045 new drawinglayer::primitive2d::FillGradientPrimitive2D(
2046 aRange,
2047 aFillGradientAttribute));
2049 xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
2050 break;
2052 default:
2054 break;
2058 return xRetval;
2061 bool SwPostItShadowPrimitive::operator==( const drawinglayer::primitive2d::BasePrimitive2D& rPrimitive ) const
2063 if(drawinglayer::primitive2d::DiscreteMetricDependentPrimitive2D::operator==(rPrimitive))
2065 const SwPostItShadowPrimitive& rCompare = static_cast< const SwPostItShadowPrimitive& >(rPrimitive);
2067 return (getBasePosition() == rCompare.getBasePosition()
2068 && getSecondPosition() == rCompare.getSecondPosition()
2069 && getShadowState() == rCompare.getShadowState());
2072 return false;
2075 ImplPrimitrive2DIDBlock(SwPostItShadowPrimitive, PRIMITIVE2D_ID_SWPOSTITSHADOWPRIMITIVE)
2077 /****** SwPostItShadow ***********************************************************/
2078 SwPostItShadow::SwPostItShadow(const basegfx::B2DPoint& rBasePos,const basegfx::B2DPoint& rSecondPosition,
2079 Color aBaseColor,ShadowState aState)
2080 : OverlayObjectWithBasePosition(rBasePos, aBaseColor),
2081 maSecondPosition(rSecondPosition),
2082 mShadowState(aState)
2084 // mbAllowsAnimation = false;
2087 SwPostItShadow::~SwPostItShadow()
2091 drawinglayer::primitive2d::Primitive2DSequence SwPostItShadow::createOverlayObjectPrimitive2DSequence()
2093 const drawinglayer::primitive2d::Primitive2DReference aReference(
2094 new SwPostItShadowPrimitive(
2095 getBasePosition(),
2096 GetSecondPosition(),
2097 GetShadowState()));
2098 return drawinglayer::primitive2d::Primitive2DSequence(&aReference, 1);
2101 void SwPostItShadow::SetShadowState(ShadowState aState)
2103 if (mShadowState != aState)
2105 mShadowState = aState;
2107 objectChange();
2111 void SwPostItShadow::SetPosition(const basegfx::B2DPoint& rPoint1,
2112 const basegfx::B2DPoint& rPoint2)
2114 if(!rPoint1.equal(getBasePosition()) || !rPoint2.equal(GetSecondPosition()))
2116 maBasePosition = rPoint1;
2117 maSecondPosition = rPoint2;
2119 objectChange();
2123 //////////////////////////////////////////////////////////////////////////////
2124 // helper class: Primitive for discrete visualisation
2126 class SwPostItAnkorPrimitive : public drawinglayer::primitive2d::DiscreteMetricDependentPrimitive2D
2128 private:
2129 basegfx::B2DPolygon maTriangle;
2130 basegfx::B2DPolygon maLine;
2131 basegfx::B2DPolygon maLineTop;
2132 AnkorState maAnkorState;
2133 basegfx::BColor maColor;
2135 // discrete line width
2136 double mfLogicLineWidth;
2138 // bitfield
2139 bool mbShadow : 1;
2140 bool mbLineSolid : 1;
2142 protected:
2143 virtual drawinglayer::primitive2d::Primitive2DSequence createLocalDecomposition(
2144 const drawinglayer::geometry::ViewInformation2D& rViewInformation) const;
2146 public:
2147 SwPostItAnkorPrimitive(
2148 const basegfx::B2DPolygon& rTriangle,
2149 const basegfx::B2DPolygon& rLine,
2150 const basegfx::B2DPolygon& rLineTop,
2151 AnkorState aAnkorState,
2152 const basegfx::BColor& rColor,
2153 double fLogicLineWidth,
2154 bool bShadow,
2155 bool bLineSolid)
2156 : drawinglayer::primitive2d::DiscreteMetricDependentPrimitive2D(),
2157 maTriangle(rTriangle),
2158 maLine(rLine),
2159 maLineTop(rLineTop),
2160 maAnkorState(aAnkorState),
2161 maColor(rColor),
2162 mfLogicLineWidth(fLogicLineWidth),
2163 mbShadow(bShadow),
2164 mbLineSolid(bLineSolid)
2167 // data access
2168 const basegfx::B2DPolygon& getTriangle() const { return maTriangle; }
2169 const basegfx::B2DPolygon& getLine() const { return maLine; }
2170 const basegfx::B2DPolygon& getLineTop() const { return maLineTop; }
2171 AnkorState getAnkorState() const { return maAnkorState; }
2172 const basegfx::BColor& getColor() const { return maColor; }
2173 double getLogicLineWidth() const { return mfLogicLineWidth; }
2174 bool getShadow() const { return mbShadow; }
2175 bool getLineSolid() const { return mbLineSolid; }
2177 virtual bool operator==( const drawinglayer::primitive2d::BasePrimitive2D& rPrimitive ) const;
2179 DeclPrimitrive2DIDBlock()
2182 drawinglayer::primitive2d::Primitive2DSequence SwPostItAnkorPrimitive::createLocalDecomposition(
2183 const drawinglayer::geometry::ViewInformation2D& /*rViewInformation*/) const
2185 drawinglayer::primitive2d::Primitive2DSequence aRetval;
2187 if(AS_TRI == getAnkorState() || AS_ALL == getAnkorState() || AS_START == getAnkorState())
2189 // create triangle
2190 const drawinglayer::primitive2d::Primitive2DReference aTriangle(
2191 new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(
2192 basegfx::B2DPolyPolygon(getTriangle()),
2193 getColor()));
2195 drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, aTriangle);
2198 if(AS_ALL == getAnkorState() || AS_START == getAnkorState())
2200 // create line start
2201 const drawinglayer::attribute::LineAttribute aLineAttribute(
2202 getColor(),
2203 getLogicLineWidth() / (basegfx::fTools::equalZero(getDiscreteUnit()) ? 1.0 : getDiscreteUnit()));
2205 if(getLineSolid())
2207 const drawinglayer::primitive2d::Primitive2DReference aSolidLine(
2208 new drawinglayer::primitive2d::PolygonStrokePrimitive2D(
2209 getLine(),
2210 aLineAttribute));
2212 drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, aSolidLine);
2214 else
2216 ::std::vector< double > aDotDashArray;
2217 const double fDistance(3.0 * 15.0);
2218 const double fDashLen(5.0 * 15.0);
2220 aDotDashArray.push_back(fDashLen);
2221 aDotDashArray.push_back(fDistance);
2223 const drawinglayer::attribute::StrokeAttribute aStrokeAttribute(
2224 aDotDashArray,
2225 fDistance + fDashLen);
2227 const drawinglayer::primitive2d::Primitive2DReference aStrokedLine(
2228 new drawinglayer::primitive2d::PolygonStrokePrimitive2D(
2229 getLine(),
2230 aLineAttribute,
2231 aStrokeAttribute));
2233 drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, aStrokedLine);
2237 if(aRetval.hasElements() && getShadow())
2239 // shadow is only for triangle and line start, and in upper left
2240 // and lower right direction, in different colors
2241 const double fColorChange(20.0 / 255.0);
2242 const basegfx::B3DTuple aColorChange(fColorChange, fColorChange, fColorChange);
2243 basegfx::BColor aLighterColor(getColor() + aColorChange);
2244 basegfx::BColor aDarkerColor(getColor() - aColorChange);
2246 aLighterColor.clamp();
2247 aDarkerColor.clamp();
2249 // create shadow sequence
2250 drawinglayer::primitive2d::Primitive2DSequence aShadows(2);
2251 basegfx::B2DHomMatrix aTransform;
2253 aTransform.set(0, 2, -getDiscreteUnit());
2254 aTransform.set(1, 2, -getDiscreteUnit());
2256 aShadows[0] = drawinglayer::primitive2d::Primitive2DReference(
2257 new drawinglayer::primitive2d::ShadowPrimitive2D(
2258 aTransform,
2259 aLighterColor,
2260 aRetval));
2262 aTransform.set(0, 2, getDiscreteUnit());
2263 aTransform.set(1, 2, getDiscreteUnit());
2265 aShadows[1] = drawinglayer::primitive2d::Primitive2DReference(
2266 new drawinglayer::primitive2d::ShadowPrimitive2D(
2267 aTransform,
2268 aDarkerColor,
2269 aRetval));
2271 // add shadow before geometry to make it be proccessed first
2272 const drawinglayer::primitive2d::Primitive2DSequence aTemporary(aRetval);
2274 aRetval = aShadows;
2275 drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(aRetval, aTemporary);
2278 if(AS_ALL == getAnkorState() || AS_END == getAnkorState())
2280 // LineTop has to be created, too, but uses no shadow, so add after
2281 // the other parts are created
2282 const drawinglayer::attribute::LineAttribute aLineAttribute(
2283 getColor(),
2284 getLogicLineWidth() / (basegfx::fTools::equalZero(getDiscreteUnit()) ? 1.0 : getDiscreteUnit()));
2286 const drawinglayer::primitive2d::Primitive2DReference aLineTop(
2287 new drawinglayer::primitive2d::PolygonStrokePrimitive2D(
2288 getLineTop(),
2289 aLineAttribute));
2291 drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, aLineTop);
2294 return aRetval;
2297 bool SwPostItAnkorPrimitive::operator==( const drawinglayer::primitive2d::BasePrimitive2D& rPrimitive ) const
2299 if(drawinglayer::primitive2d::DiscreteMetricDependentPrimitive2D::operator==(rPrimitive))
2301 const SwPostItAnkorPrimitive& rCompare = static_cast< const SwPostItAnkorPrimitive& >(rPrimitive);
2303 return (getTriangle() == rCompare.getTriangle()
2304 && getLine() == rCompare.getLine()
2305 && getLineTop() == rCompare.getLineTop()
2306 && getAnkorState() == rCompare.getAnkorState()
2307 && getColor() == rCompare.getColor()
2308 && getLogicLineWidth() == rCompare.getLogicLineWidth()
2309 && getShadow() == rCompare.getShadow()
2310 && getLineSolid() == rCompare.getLineSolid());
2313 return false;
2316 ImplPrimitrive2DIDBlock(SwPostItAnkorPrimitive, PRIMITIVE2D_ID_SWPOSTITANKORPRIMITIVE)
2318 /****** SwPostItAnkor ***********************************************************/
2320 void SwPostItAnkor::implEnsureGeometry()
2322 if(!maTriangle.count())
2324 maTriangle.append(getBasePosition());
2325 maTriangle.append(GetSecondPosition());
2326 maTriangle.append(GetThirdPosition());
2327 maTriangle.setClosed(true);
2330 if(!maLine.count())
2332 maLine.append(GetFourthPosition());
2333 maLine.append(GetFifthPosition());
2334 maLine.append(GetSixthPosition());
2337 if(!maLineTop.count())
2339 maLineTop.append(GetSixthPosition());
2340 maLineTop.append(GetSeventhPosition());
2344 void SwPostItAnkor::implResetGeometry()
2346 maTriangle.clear();
2347 maLine.clear();
2348 maLineTop.clear();
2351 SwPostItAnkor::SwPostItAnkor(const basegfx::B2DPoint& rBasePos,
2352 const basegfx::B2DPoint& rSecondPos,
2353 const basegfx::B2DPoint& rThirdPos,
2354 const basegfx::B2DPoint& rFourthPos,
2355 const basegfx::B2DPoint& rFifthPos,
2356 const basegfx::B2DPoint& rSixthPos,
2357 const basegfx::B2DPoint& rSeventhPos,
2358 Color aBaseColor,
2359 bool bShadowedEffect,
2360 bool bLineSolid)
2361 : OverlayObjectWithBasePosition(rBasePos, aBaseColor),
2362 maSecondPosition(rSecondPos),
2363 maThirdPosition(rThirdPos),
2364 maFourthPosition(rFourthPos),
2365 maFifthPosition(rFifthPos),
2366 maSixthPosition(rSixthPos),
2367 maSeventhPosition(rSeventhPos),
2368 maTriangle(),
2369 maLine(),
2370 maLineTop(),
2371 mHeight(0),
2372 mAnkorState(AS_ALL),
2373 mbShadowedEffect(bShadowedEffect),
2374 mbLineSolid(bLineSolid)
2376 //mbAllowsAnimation = true;
2379 SwPostItAnkor::~SwPostItAnkor()
2383 drawinglayer::primitive2d::Primitive2DSequence SwPostItAnkor::createOverlayObjectPrimitive2DSequence()
2385 implEnsureGeometry();
2387 const drawinglayer::primitive2d::Primitive2DReference aReference(
2388 new SwPostItAnkorPrimitive(
2389 maTriangle,
2390 maLine,
2391 maLineTop,
2392 GetAnkorState(),
2393 getBaseColor().getBColor(),
2394 ANKORLINE_WIDTH * 15.0,
2395 getShadowedEffect(),
2396 getLineSolid()));
2398 return drawinglayer::primitive2d::Primitive2DSequence(&aReference, 1);
2401 void SwPostItAnkor::SetAllPosition(const basegfx::B2DPoint& rPoint1,
2402 const basegfx::B2DPoint& rPoint2,
2403 const basegfx::B2DPoint& rPoint3,
2404 const basegfx::B2DPoint& rPoint4,
2405 const basegfx::B2DPoint& rPoint5,
2406 const basegfx::B2DPoint& rPoint6,
2407 const basegfx::B2DPoint& rPoint7)
2409 if(rPoint1 != getBasePosition()
2410 || rPoint2 != GetSecondPosition()
2411 || rPoint3 != GetThirdPosition()
2412 || rPoint4 != GetFourthPosition()
2413 || rPoint5 != GetFifthPosition()
2414 || rPoint6 != GetSixthPosition()
2415 || rPoint7 != GetSeventhPosition())
2417 maBasePosition = rPoint1;
2418 maSecondPosition = rPoint2;
2419 maThirdPosition = rPoint3;
2420 maFourthPosition = rPoint4;
2421 maFifthPosition = rPoint5;
2422 maSixthPosition = rPoint6;
2423 maSeventhPosition = rPoint7;
2425 implResetGeometry();
2426 objectChange();
2430 void SwPostItAnkor::SetSixthPosition(const basegfx::B2DPoint& rNew)
2432 if(rNew != maSixthPosition)
2434 maSixthPosition = rNew;
2435 implResetGeometry();
2436 objectChange();
2440 void SwPostItAnkor::SetSeventhPosition(const basegfx::B2DPoint& rNew)
2442 if(rNew != maSeventhPosition)
2444 maSeventhPosition = rNew;
2445 implResetGeometry();
2446 objectChange();
2450 void SwPostItAnkor::SetTriPosition(const basegfx::B2DPoint& rPoint1,const basegfx::B2DPoint& rPoint2,const basegfx::B2DPoint& rPoint3,
2451 const basegfx::B2DPoint& rPoint4,const basegfx::B2DPoint& rPoint5)
2453 if(rPoint1 != getBasePosition()
2454 || rPoint2 != GetSecondPosition()
2455 || rPoint3 != GetThirdPosition()
2456 || rPoint4 != GetFourthPosition()
2457 || rPoint5 != GetFifthPosition())
2459 maBasePosition = rPoint1;
2460 maSecondPosition = rPoint2;
2461 maThirdPosition = rPoint3;
2462 maFourthPosition = rPoint4;
2463 maFifthPosition = rPoint5;
2465 implResetGeometry();
2466 objectChange();
2470 void SwPostItAnkor::setLineSolid(bool bNew)
2472 if(bNew != getLineSolid())
2474 mbLineSolid = bNew;
2475 objectChange();
2479 void SwPostItAnkor::SetAnkorState(AnkorState aState)
2481 if (mAnkorState != aState)
2483 mAnkorState = aState;
2484 objectChange();