update dev300-m58
[ooovba.git] / sw / source / ui / docvw / postit.cxx
blob5bb42c27ab330447ee7d6dd6568057ad0c1b1aba
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 #include <sw_primitivetypes2d.hxx>
121 #include <drawinglayer/primitive2d/primitivetools2d.hxx>
122 #include <drawinglayer/attribute/fillattribute.hxx>
123 #include <drawinglayer/primitive2d/fillgradientprimitive2d.hxx>
124 #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
125 #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
126 #include <drawinglayer/primitive2d/shadowprimitive2d.hxx>
128 using namespace ::com::sun::star;
130 #define METABUTTON_WIDTH 16
131 #define METABUTTON_HEIGHT 18
132 #define METABUTTON_AREA_WIDTH 30
133 #define POSTIT_META_HEIGHT (sal_Int32) 30
134 #define POSTIT_MINIMUMSIZE_WITHOUT_META 50
136 #define POSTIT_SHADOW_BRIGHT Color(180,180,180)
137 #define POSTIT_SHADOW_DARK Color(83,83,83)
139 #define LINEBREAK rtl::OUString::createFromAscii("\n")
140 #define EMPTYSTRING rtl::OUString::createFromAscii("")
142 TYPEINIT0(SwMarginWin);
143 TYPEINIT1(SwPostIt,SwMarginWin);
144 //TYPEINIT1(SwRedComment,SwMarginWin);
146 Color ColorFromAlphaColor(UINT8 aTransparency, Color &aFront, Color &aBack )
148 return Color((UINT8)(aFront.GetRed() * aTransparency/(double)255 + aBack.GetRed() * (1-aTransparency/(double)255)),
149 (UINT8)(aFront.GetGreen() * aTransparency/(double)255 + aBack.GetGreen() * (1-aTransparency/(double)255)),
150 (UINT8)(aFront.GetBlue() * aTransparency/(double)255 + aBack.GetBlue() * (1-aTransparency/(double)255)));
153 /************ PostItTxt **************************************/
154 PostItTxt::PostItTxt(Window* pParent, WinBits nBits) : Window(pParent, nBits), mpOutlinerView(0),mMouseOver(false),mbShowPopup(FALSE)
156 SetHelpId(26276);
157 AddEventListener( LINK( this, PostItTxt, WindowEventListener ) );
158 mpMarginWin = static_cast<SwMarginWin*>(GetParent());
161 PostItTxt::~PostItTxt()
163 RemoveEventListener( LINK( this, PostItTxt, WindowEventListener ) );
166 void PostItTxt::GetFocus()
168 BOOL bLockView = mpMarginWin->DocView()->GetWrtShell().IsViewLocked();
169 mpMarginWin->DocView()->GetWrtShell().LockView( TRUE );
171 if(mpMarginWin && !mpMarginWin->IsPreview())
172 mpMarginWin->Mgr()->SetActivePostIt(mpMarginWin);
173 Window::GetFocus();
174 if (!mMouseOver)
175 Invalidate();
177 mpMarginWin->DocView()->GetWrtShell().LockView( bLockView );
178 mpMarginWin->Mgr()->MakeVisible(mpMarginWin);
181 void PostItTxt::LoseFocus()
183 // write the visible text back into the SwField
184 if ( mpMarginWin )
185 mpMarginWin->UpdateData();
187 Window::LoseFocus();
188 if (!mMouseOver)
189 Invalidate();
192 void PostItTxt::RequestHelp(const HelpEvent &rEvt)
194 USHORT nResId = 0;
195 switch( mpMarginWin->GetStatus() )
197 case SwPostItHelper::INSERTED: nResId = STR_REDLINE_INSERT; break;
198 case SwPostItHelper::DELETED: nResId = STR_REDLINE_DELETE; break;
199 default: nResId = 0;
202 SwContentAtPos aCntntAtPos( SwContentAtPos::SW_REDLINE );
203 if ( nResId && mpMarginWin->DocView()->GetWrtShell().GetContentAtPos( mpMarginWin->GetAnkorRect().Pos(), aCntntAtPos ) )
205 String sTxt;
206 sTxt = SW_RESSTR( nResId );
207 sTxt.AppendAscii( RTL_CONSTASCII_STRINGPARAM(": " ));
208 sTxt += aCntntAtPos.aFnd.pRedl->GetAuthorString();
209 sTxt.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " - " ));
210 sTxt += GetAppLangDateTimeString( aCntntAtPos.aFnd.pRedl->GetTimeStamp() );
211 Help::ShowQuickHelp( this,PixelToLogic(Rectangle(rEvt.GetMousePosPixel(),Size(50,10))),sTxt);
215 void PostItTxt::Paint( const Rectangle& rRect)
217 if ( !Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
219 if (mMouseOver || HasFocus())
220 DrawGradient(Rectangle(Point(0,0),PixelToLogic(GetSizePixel())),
221 Gradient(GRADIENT_LINEAR,mpMarginWin->ColorDark(),mpMarginWin->ColorDark()));
222 else
223 DrawGradient(Rectangle(Point(0,0),PixelToLogic(GetSizePixel())),
224 Gradient(GRADIENT_LINEAR,mpMarginWin->ColorLight(),mpMarginWin->ColorDark()));
227 mpOutlinerView->Paint( rRect );
229 if (mpMarginWin->GetStatus()==SwPostItHelper::DELETED)
231 SetLineColor(static_cast<SwPostIt*>(mpMarginWin)->GetChangeColor());
232 DrawLine(PixelToLogic(GetPosPixel()),PixelToLogic(GetPosPixel()+Point(GetSizePixel().Width(),GetSizePixel().Height())));
233 DrawLine(PixelToLogic(GetPosPixel()+Point(GetSizePixel().Width(),0)),PixelToLogic(GetPosPixel()+Point(0,GetSizePixel().Height())));
237 void PostItTxt::KeyInput( const KeyEvent& rKeyEvt )
239 const KeyCode& rKeyCode = rKeyEvt.GetKeyCode();
240 USHORT nKey = rKeyCode.GetCode();
241 SwView* pView = mpMarginWin->DocView();
242 if ((rKeyCode.IsMod1() && rKeyCode.IsMod2()) && ((nKey == KEY_PAGEUP) || (nKey == KEY_PAGEDOWN)))
243 mpMarginWin->SwitchToPostIt(nKey);
244 else
245 if ((nKey == KEY_ESCAPE) || (rKeyCode.IsMod1() && ((nKey == KEY_PAGEUP) || (nKey == KEY_PAGEDOWN))))
246 mpMarginWin->SwitchToFieldPos();
247 else
248 if (nKey == KEY_INSERT)
250 if (!rKeyCode.IsMod1() && !rKeyCode.IsMod2())
251 mpMarginWin->ToggleInsMode();
253 else
255 //let's make sure we see our note
256 mpMarginWin->Mgr()->MakeVisible(mpMarginWin);
258 long aOldHeight = mpMarginWin->GetPostItTextHeight();
259 bool bDone = false;
261 /// HACK: need to switch off processing of Undo/Redo in Outliner
262 if ( !( (nKey == KEY_Z || nKey == KEY_Y) && rKeyCode.IsMod1()) )
265 SwPostItHelper::SwLayoutStatus aStatus = mpMarginWin->GetStatus();
266 if ( (aStatus!=SwPostItHelper::DELETED) ||
267 ( (aStatus==SwPostItHelper::DELETED) && (!mpMarginWin->Engine()->GetEditEngine().DoesKeyChangeText(rKeyEvt))) )
269 bool bIsProtected = mpMarginWin->IsProtected();
270 if (!bIsProtected || (bIsProtected && !mpMarginWin->Engine()->GetEditEngine().DoesKeyChangeText(rKeyEvt)) )
271 bDone = mpOutlinerView->PostKeyEvent( rKeyEvt );
273 if (bDone)
274 mpMarginWin->ResizeIfNeccessary(aOldHeight,mpMarginWin->GetPostItTextHeight());
275 else
277 // write back data first when showing navigator
278 if ( nKey==KEY_F5 )
279 mpMarginWin->UpdateData();
280 if (!pView->KeyInput(rKeyEvt))
281 Window::KeyInput(rKeyEvt);
285 pView->GetViewFrame()->GetBindings().InvalidateAll(FALSE);
288 void PostItTxt::MouseMove( const MouseEvent& rMEvt )
290 if ( mpOutlinerView )
292 mpOutlinerView->MouseMove( rMEvt );
293 // mba: why does OutlinerView not handle the modifier setting?!
294 // this forces the postit to handle *all* pointer types
295 SetPointer( mpOutlinerView->GetPointer( rMEvt.GetPosPixel() ) );
297 const EditView& aEV = mpOutlinerView->GetEditView();
298 const SvxFieldItem* pItem = aEV.GetFieldUnderMousePointer();
299 if ( pItem )
301 const SvxFieldData* pFld = pItem->GetField();
302 const SvxURLField* pURL = PTR_CAST( SvxURLField, pFld );
303 if ( pURL )
305 String sURL( pURL->GetURL() );
306 SvtSecurityOptions aSecOpts;
307 if ( aSecOpts.IsOptionSet( SvtSecurityOptions::E_CTRLCLICK_HYPERLINK) )
309 sURL.InsertAscii( ": ", 0 );
310 sURL.Insert( ViewShell::GetShellRes()->aHyperlinkClick, 0 );
312 Help::ShowQuickHelp( this,PixelToLogic(Rectangle(GetPosPixel(),Size(50,10))),sURL);
318 void PostItTxt::MouseButtonDown( const MouseEvent& rMEvt )
320 if (mpOutlinerView )
322 SvtSecurityOptions aSecOpts;
323 bool bExecuteMod = aSecOpts.IsOptionSet( SvtSecurityOptions::E_CTRLCLICK_HYPERLINK);
325 if ( !bExecuteMod || (bExecuteMod && rMEvt.GetModifier() == KEY_MOD1))
327 const EditView& aEV = mpOutlinerView->GetEditView();
328 const SvxFieldItem* pItem = aEV.GetFieldUnderMousePointer();
329 if ( pItem )
331 const SvxFieldData* pFld = pItem->GetField();
332 const SvxURLField* pURL = PTR_CAST( SvxURLField, pFld );
333 if ( pURL )
335 mpOutlinerView->MouseButtonDown( rMEvt );
336 SwWrtShell &rSh = mpMarginWin->DocView()->GetWrtShell();
337 String sURL( pURL->GetURL() );
338 String sTarget( pURL->GetTargetFrame() );
339 ::LoadURL( sURL, &rSh, URLLOAD_NOFILTER, &sTarget);
340 return;
346 GrabFocus();
347 if ( mpOutlinerView )
348 mpOutlinerView->MouseButtonDown( rMEvt );
349 mpMarginWin->DocView()->GetViewFrame()->GetBindings().InvalidateAll(FALSE);
352 void PostItTxt::MouseButtonUp( const MouseEvent& rMEvt )
354 if ( mpOutlinerView )
355 mpOutlinerView->MouseButtonUp( rMEvt );
358 IMPL_LINK(PostItTxt, OnlineSpellCallback, SpellCallbackInfo*, pInfo)
360 if ( mpMarginWin && (pInfo->nCommand == SPELLCMD_STARTSPELLDLG) )
361 mpMarginWin->DocView()->GetViewFrame()->GetDispatcher()->Execute( FN_SPELL_GRAMMAR_DIALOG, SFX_CALLMODE_ASYNCHRON);
362 return 0;
365 IMPL_LINK( PostItTxt, Select, Menu*, pSelMenu )
367 mpMarginWin->ExecuteCommand( pSelMenu->GetCurItemId() );
368 return 0;
371 void PostItTxt::Command( const CommandEvent& rCEvt )
373 if ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU )
375 if (!mpMarginWin->IsProtected() &&
376 //if (!mpMarginWin->IsReadOnly() && (mpMarginWin->GetStatus()!=SwPostItHelper::DELETED) &&
377 mpOutlinerView->IsWrongSpelledWordAtPos( rCEvt.GetMousePosPixel(),TRUE ))
379 Link aLink = LINK(this, PostItTxt, OnlineSpellCallback);
380 mpOutlinerView->ExecuteSpellPopup(rCEvt.GetMousePosPixel(),&aLink);
382 else
384 SfxPopupMenuManager* aMgr = mpMarginWin->DocView()->GetViewFrame()->GetDispatcher()->Popup(0, this,&rCEvt.GetMousePosPixel());
385 XubString aText = ((PopupMenu*)aMgr->GetSVMenu())->GetItemText( FN_DELETE_NOTE_AUTHOR );
386 SwRewriter aRewriter;
387 aRewriter.AddRule(UNDO_ARG1, mpMarginWin->GetAuthor());
388 aText = aRewriter.Apply(aText);
389 ((PopupMenu*)aMgr->GetSVMenu())->SetItemText(FN_DELETE_NOTE_AUTHOR,aText);
390 // SwPostItLinkForwarder_Impl aFwd( ((PopupMenu*)aMgr->GetSVMenu())->pSvMenu->GetSelectHdl(), mpPostIt );
391 // ((PopupMenu*)aMgr->GetSVMenu())->pSvMenu->SetSelectHdl( LINK(&aFwd, SwPostItLinkForwarder_Impl, Select) );
393 ((PopupMenu*)aMgr->GetSVMenu())->SetSelectHdl( LINK(this, PostItTxt, Select) );
395 if (rCEvt.IsMouseEvent())
396 ((PopupMenu*)aMgr->GetSVMenu())->Execute(this,rCEvt.GetMousePosPixel());
397 else
399 const Size aSize = GetSizePixel();
400 const Point aPos = Point( aSize.getWidth()/2, aSize.getHeight()/2 );
401 ((PopupMenu*)aMgr->GetSVMenu())->Execute(this,aPos);
403 delete aMgr;
406 else
407 if (rCEvt.GetCommand() == COMMAND_WHEEL)
409 if (mpMarginWin->Scrollbar()->IsVisible())
411 const CommandWheelData* pData = rCEvt.GetWheelData();
412 if (pData->IsShift() || pData->IsMod1() || pData->IsMod2())
414 mpMarginWin->DocView()->HandleWheelCommands(rCEvt);
416 else
418 HandleScrollCommand( rCEvt, 0 , mpMarginWin->Scrollbar());
421 long nLines = pData->GetNotchDelta() * (long)pData->GetScrollLines();
422 if ( ((mpMarginWin->Scrollbar()->GetRange().Min() == mpMarginWin->Scrollbar()->GetThumbPos()) && (nLines > 0)) ||
423 ( (mpMarginWin->Scrollbar()->GetRange().Max() == mpMarginWin->Scrollbar()->GetThumbPos()+mpMarginWin->Scrollbar()->GetVisibleSize()) && (nLines < 0)) )
425 mpMarginWin->DocView()->HandleWheelCommands(rCEvt);
427 else
429 HandleScrollCommand( rCEvt, 0 , mpMarginWin->Scrollbar());
434 else
436 mpMarginWin->DocView()->HandleWheelCommands(rCEvt);
439 else if (rCEvt.GetCommand() == COMMAND_SELECTIONCHANGE)
441 if ( mpOutlinerView )
443 const CommandSelectionChangeData *pData = rCEvt.GetSelectionChangeData();
444 ESelection aSelection = mpOutlinerView->GetEditView().GetSelection();
445 aSelection.nStartPos = sal::static_int_cast<sal_uInt16, ULONG>(pData->GetStart());
446 aSelection.nEndPos = sal::static_int_cast<sal_uInt16, ULONG>(pData->GetEnd());
447 mpOutlinerView->GetEditView().SetSelection(aSelection);
450 else if (rCEvt.GetCommand() == COMMAND_PREPARERECONVERSION)
452 if ( mpOutlinerView && mpOutlinerView->HasSelection() )
454 EditEngine *aEditEngine = mpOutlinerView->GetEditView().GetEditEngine();
455 ESelection aSelection = mpOutlinerView->GetEditView().GetSelection();
456 aSelection.Adjust();
457 if( aSelection.nStartPara != aSelection.nEndPara )
459 xub_StrLen aParaLen = aEditEngine->GetTextLen( aSelection.nStartPara );
460 aSelection.nEndPara = aSelection.nStartPara;
461 aSelection.nEndPos = aParaLen;
462 mpOutlinerView->GetEditView().SetSelection( aSelection );
466 else
468 if ( mpOutlinerView )
469 mpOutlinerView->Command( rCEvt );
470 else
471 Window::Command(rCEvt);
475 void PostItTxt::DataChanged( const DataChangedEvent& aData)
477 Window::DataChanged( aData );
480 XubString PostItTxt::GetSurroundingText() const
482 if( mpOutlinerView )
484 EditEngine *aEditEngine = mpOutlinerView->GetEditView().GetEditEngine();
485 if( mpOutlinerView->HasSelection() )
486 return mpOutlinerView->GetSelected();
487 else
489 ESelection aSelection = mpOutlinerView->GetEditView().GetSelection();
490 XubString aStr = aEditEngine->GetText(aSelection.nStartPara);
491 return aStr;
494 else
495 return XubString::EmptyString();
498 Selection PostItTxt::GetSurroundingTextSelection() const
500 if( mpOutlinerView )
502 if( mpOutlinerView->HasSelection() )
503 return Selection( 0, mpOutlinerView->GetSelected().Len() );
504 else
506 ESelection aSelection = mpOutlinerView->GetEditView().GetSelection();
507 return Selection( aSelection.nStartPos, aSelection.nEndPos );
510 else
511 return Selection( 0, 0 );
514 IMPL_LINK( PostItTxt, WindowEventListener, VclSimpleEvent*, pWinEvent )
516 if ( pWinEvent && pWinEvent->ISA( VclWindowEvent ) )
518 VclWindowEvent *pEvent = (VclWindowEvent*)pWinEvent;
519 if (pEvent->GetId() == VCLEVENT_WINDOW_MOUSEMOVE)
521 MouseEvent* pMouseEvt = (MouseEvent*)pEvent->GetData();
522 if ( pMouseEvt->IsEnterWindow() )
524 mMouseOver = true;
525 if (!mbShowPopup && !HasFocus())
527 mpMarginWin->SetViewState(SS_VIEW);
528 Invalidate();
531 else if ( pMouseEvt->IsLeaveWindow())
533 if (mpMarginWin->IsPreview())
535 //mpMarginWin->doLazyDelete();
537 else
539 mMouseOver = false;
540 if (!mbShowPopup && !HasFocus())
542 mpMarginWin->SetViewState(SS_NORMAL);
543 Invalidate();
549 return sal_True;
552 /************** SwMarginWin***********************************++*/
553 SwMarginWin::SwMarginWin(Window* pParent, WinBits nBits,SwPostItMgr* aMgr,SwPostItBits aBits)
554 : Window(pParent, nBits),
555 mnEventId(0),
556 mpOutlinerView(0),
557 mpOutliner(0),
558 mpPostItTxt(0),
559 mpMeta(0),
560 mpVScrollbar(0),
561 mpAnkor(0),
562 mpShadow(0),
563 mpMgr(aMgr),
564 mbMeta(true),
565 nFlags(aBits),
566 mbMouseOverButton(false),
567 mpButtonPopup(0),
568 mbIsFollow(false)
570 SwEditWin* aWin = static_cast<SwEditWin*>(GetParent());
571 mpView = &aWin->GetView();
573 SdrPaintWindow* pPaintWindow = mpView->GetDrawView()->GetPaintWindow(0);
574 if(pPaintWindow)
576 pOverlayManager = pPaintWindow->GetOverlayManager();
578 mpShadow = new SwPostItShadow(basegfx::B2DPoint(0,0),basegfx::B2DPoint(0,0),Color(0,0,0),SS_NORMAL);
579 mpShadow->setVisible(false);
580 pOverlayManager->add(*mpShadow);
584 SwMarginWin::~SwMarginWin()
586 if (mpOutlinerView)
588 delete mpOutlinerView;
591 if (mpOutliner)
593 delete mpOutliner;
596 if (mpMeta)
598 mpMeta->RemoveEventListener( LINK( mpPostItTxt, PostItTxt, WindowEventListener ) );
599 delete mpMeta;
602 if (mpPostItTxt)
604 delete mpPostItTxt;
607 if (mpVScrollbar)
609 delete mpVScrollbar;
612 if (mpAnkor)
614 if (mpAnkor->getOverlayManager())
616 // remove this object from the chain
617 mpAnkor->getOverlayManager()->remove(*mpAnkor);
619 delete mpAnkor;
622 if (mpShadow)
624 if (mpShadow->getOverlayManager())
626 mpShadow->getOverlayManager()->remove(*mpShadow);
628 delete mpShadow;
631 if (mpButtonPopup)
633 delete mpButtonPopup;
636 if (mnEventId)
637 Application::RemoveUserEvent( mnEventId );
640 void SwMarginWin::Paint( const Rectangle& rRect)
642 Window::Paint(rRect);
644 if (mpMeta->IsVisible() )
646 //draw left over space
647 if ( Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
648 SetFillColor(COL_BLACK);
649 else
650 SetFillColor(mColorDark);
651 SetLineColor();
652 DrawRect(PixelToLogic(Rectangle(Point(mpMeta->GetPosPixel().X()+mpMeta->GetSizePixel().Width(),mpMeta->GetPosPixel().Y()),Size(GetMetaButtonAreaWidth(),mpMeta->GetSizePixel().Height()))));
654 if ( Application::GetSettings().GetStyleSettings().GetHighContrastMode())
656 //draw rect around button
657 SetFillColor(COL_BLACK);
658 SetLineColor(COL_WHITE);
660 else
662 //draw button
663 Gradient aGradient;
664 if (mbMouseOverButton)
665 aGradient = Gradient(GRADIENT_LINEAR,ColorFromAlphaColor(80,mColorAnkor,mColorDark),ColorFromAlphaColor(15,mColorAnkor,mColorDark));
666 else
667 aGradient = Gradient(GRADIENT_LINEAR,ColorFromAlphaColor(15,mColorAnkor,mColorDark),ColorFromAlphaColor(80,mColorAnkor,mColorDark));
668 DrawGradient(mRectMetaButton,aGradient);
669 //draw rect around button
670 SetFillColor();
671 SetLineColor(ColorFromAlphaColor(90,mColorAnkor,mColorDark));
673 DrawRect(mRectMetaButton);
675 if (IsPreview())
677 Font aOldFont( GetFont());
678 Font aFont(aOldFont);
679 Color aCol( COL_BLACK);
680 aFont.SetColor( aCol );
681 aFont.SetHeight(200);
682 aFont.SetWeight(WEIGHT_MEDIUM);
683 SetFont( aFont );
684 DrawText(mRectMetaButton,rtl::OUString::createFromAscii("Edit Note"),TEXT_DRAW_CENTER);
685 SetFont( aOldFont );
687 else
689 //draw arrow
690 if ( Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
691 SetFillColor(COL_WHITE);
692 else
693 SetFillColor(COL_BLACK);
694 SetLineColor();
695 DrawPolygon(Polygon(aPopupTriangle));
700 void SwMarginWin::SetPosSizePixelRect(long nX, long nY,long nWidth, long nHeight,const SwRect &aRect, const long aPageBorder)
702 mbMeta = true;
703 mPosSize = Rectangle(Point(nX,nY),Size(nWidth,nHeight));
704 mAnkorRect = aRect;
705 mPageBorder = aPageBorder;
708 void SwMarginWin::SetSize( const Size& rNewSize )
710 mPosSize.SetSize(rNewSize);
713 void SwMarginWin::SetVirtualPosSize( const Point& aPoint, const Size& aSize)
715 mPosSize = Rectangle(aPoint,aSize);
718 void SwMarginWin::TranslateTopPosition(const long aAmount)
720 mPosSize.Move(0,aAmount);
723 void SwMarginWin::ShowAnkorOnly(const Point &aPoint)
725 HideNote();
726 SetPosAndSize();
727 if (mpAnkor)
729 mpAnkor->SetSixthPosition(basegfx::B2DPoint(aPoint.X(),aPoint.Y()));
730 mpAnkor->SetSeventhPosition(basegfx::B2DPoint(aPoint.X(),aPoint.Y()));
731 mpAnkor->SetAnkorState(AS_ALL);
732 mpAnkor->setVisible(true);
734 if (mpShadow)
735 mpShadow->setVisible(false);
738 void SwMarginWin::InitControls()
740 // actual window which holds the user text
741 mpPostItTxt = new PostItTxt(this, WB_NODIALOGCONTROL);
742 mpPostItTxt->SetPointer(Pointer(POINTER_TEXT));
744 // window control for author and date
745 mpMeta = new MultiLineEdit(this,0);
746 mpMeta->SetReadOnly();
747 mpMeta->SetRightToLeft(Application::GetSettings().GetLayoutRTL());
748 mpMeta->AlwaysDisableInput(true);
749 mpMeta->SetCallHandlersOnInputDisabled(true);
750 mpMeta->AddEventListener( LINK( mpPostItTxt, PostItTxt, WindowEventListener ) );
751 AddEventListener( LINK( mpPostItTxt, PostItTxt, WindowEventListener ) );
753 // we should leave this setting alone, but for this we need a better layout algo
754 // with variable meta size height
755 AllSettings aSettings = mpMeta->GetSettings();
756 StyleSettings aStyleSettings = aSettings.GetStyleSettings();
757 Font aFont = aStyleSettings.GetFieldFont();
758 aFont.SetHeight(8);
759 aStyleSettings.SetFieldFont(aFont);
760 aSettings.SetStyleSettings(aStyleSettings);
761 mpMeta->SetSettings(aSettings);
763 SwDocShell* aShell = mpView->GetDocShell();
764 mpOutliner = new Outliner(&aShell->GetPool(),OUTLINERMODE_TEXTOBJECT);
765 aShell->GetDoc()->SetCalcFieldValueHdl( mpOutliner );
766 // mpOutliner->EnableUndo( FALSE );
767 mpOutliner->SetUpdateMode( TRUE );
768 Rescale();
770 OutputDevice* pDev = aShell->GetDoc()->getReferenceDevice(TRUE);
771 if ( pDev )
773 mpOutliner->SetRefDevice( pDev );
776 mpOutlinerView = new OutlinerView ( mpOutliner, mpPostItTxt );
777 mpOutlinerView->SetBackgroundColor(COL_TRANSPARENT);
778 mpOutliner->InsertView(mpOutlinerView );
779 mpPostItTxt->SetTextView(mpOutlinerView);
780 mpOutlinerView->SetOutputArea( PixelToLogic( Rectangle(0,0,1,1) ) );
782 SfxItemSet item(aShell->GetPool());
783 item.Put(SvxFontHeightItem(200,100,EE_CHAR_FONTHEIGHT));
784 item.Put(SvxFontItem(FAMILY_SWISS,GetSettings().GetStyleSettings().GetFieldFont().GetName(),
785 EMPTYSTRING,PITCH_DONTKNOW,RTL_TEXTENCODING_DONTKNOW,EE_CHAR_FONTINFO));
786 mpOutlinerView->SetAttribs(item);
788 // TODO: ??
789 EEHorizontalTextDirection aDefHoriTextDir = Application::GetSettings().GetLayoutRTL() ? EE_HTEXTDIR_R2L : EE_HTEXTDIR_L2R;
790 mpOutliner->SetDefaultHorizontalTextDirection( aDefHoriTextDir );
792 //create Scrollbars
793 mpVScrollbar = new ScrollBar(this, WB_3DLOOK |WB_VSCROLL|WB_DRAG);
794 mpVScrollbar->EnableNativeWidget(false);
795 mpVScrollbar->EnableRTL( false );
796 mpVScrollbar->SetScrollHdl(LINK(this, SwMarginWin, ScrollHdl));
797 mpVScrollbar->EnableDrag();
798 mpVScrollbar->AddEventListener( LINK( mpPostItTxt, PostItTxt, WindowEventListener ) );
800 const SwViewOption* pVOpt = mpView->GetWrtShellPtr()->GetViewOptions();
801 ULONG nCntrl = mpOutliner->GetControlWord();
802 // TODO: crash when AUTOCOMPLETE enabled
803 nCntrl |= EE_CNTRL_MARKFIELDS | EE_CNTRL_PASTESPECIAL | EE_CNTRL_AUTOCORRECT | EV_CNTRL_AUTOSCROLL | EE_CNTRL_URLSFXEXECUTE; // | EE_CNTRL_AUTOCOMPLETE;
804 if (pVOpt->IsFieldShadings())
805 nCntrl |= EE_CNTRL_MARKFIELDS;
806 else
807 nCntrl &= ~EE_CNTRL_MARKFIELDS;
808 if (pVOpt->IsOnlineSpell())
809 nCntrl |= EE_CNTRL_ONLINESPELLING;
810 else
811 nCntrl &= ~EE_CNTRL_ONLINESPELLING;
812 mpOutliner->SetControlWord(nCntrl);
814 sal_uInt16 aIndex = SW_MOD()->InsertRedlineAuthor(GetAuthor());
815 SetColor(mpMgr->GetColorDark(aIndex),mpMgr->GetColorLight(aIndex),mpMgr->GetColorAnkor(aIndex));
817 CheckMetaText();
818 SetPopup();
819 SetLanguage(GetLanguage());
820 View()->StartSpeller();
821 SetPostItText();
822 Engine()->CompleteOnlineSpelling();
824 mpMeta->Show();
825 mpVScrollbar->Show();
826 mpPostItTxt->Show();
829 void SwMarginWin::CheckMetaText()
831 const LocaleDataWrapper& rLocalData = SvtSysLocale().GetLocaleData();
832 String sMeta = GetAuthor();
833 if (sMeta==String(EMPTYSTRING))
834 sMeta = String(SW_RES(STR_NOAUTHOR));
835 if (sMeta.Len() > 22)
837 sMeta.Erase(20);
838 sMeta = sMeta + rtl::OUString::createFromAscii("...");
840 Date aDate = GetDate();
841 if (aDate==Date())
842 sMeta = sMeta + LINEBREAK + String(SW_RES(STR_POSTIT_TODAY));
843 else
844 if (aDate == Date(Date()-1))
845 sMeta = sMeta + LINEBREAK + String(SW_RES(STR_POSTIT_YESTERDAY));
846 else
847 if (aDate.IsValid() )
848 sMeta = sMeta + LINEBREAK + rLocalData.getDate(aDate);
849 else
850 sMeta = sMeta + LINEBREAK + String(SW_RES(STR_NODATE));
851 if (GetTime()!=0)
852 sMeta = sMeta + rtl::OUString::createFromAscii(" ") + rLocalData.getTime( GetTime(),false );
853 if (mpMeta->GetText() != sMeta)
854 mpMeta->SetText(sMeta);
857 void SwMarginWin::Rescale()
859 MapMode aMode = GetParent()->GetMapMode();
860 aMode.SetOrigin( Point() );
861 //aMode.SetScaleX( aMode.GetScaleX() * Fraction( 8, 10 ) );
862 //aMode.SetScaleY( aMode.GetScaleY() * Fraction( 8, 10 ) );
863 mpOutliner->SetRefMapMode( aMode );
864 SetMapMode( aMode );
865 mpPostItTxt->SetMapMode( aMode );
866 if ( mpMeta )
868 Font aFont( mpMeta->GetSettings().GetStyleSettings().GetFieldFont() );
869 sal_Int32 nHeight = aFont.GetHeight();
870 nHeight = nHeight * aMode.GetScaleY().GetNumerator() / aMode.GetScaleY().GetDenominator();
871 aFont.SetHeight( nHeight );
872 mpMeta->SetControlFont( aFont );
876 void SwMarginWin::SetPosAndSize()
878 bool bChange = false;
880 if (GetSizePixel() != mPosSize.GetSize())
882 bChange = true;
883 SetSizePixel(mPosSize.GetSize());
884 DoResize();
887 if (GetPosPixel().X() != mPosSize.TopLeft().X() || (abs(GetPosPixel().Y() - mPosSize.TopLeft().Y()) > 5) )
889 bChange = true;
890 SetPosPixel(mPosSize.TopLeft());
892 Point aLineStart;
893 Point aLineEnd ;
894 if (mbMarginSide)
896 aLineStart = EditWin()->PixelToLogic( Point(GetPosPixel().X()+GetSizePixel().Width(),GetPosPixel().Y()-1) );
897 aLineEnd = EditWin()->PixelToLogic( Point(GetPosPixel().X(),GetPosPixel().Y()-1) );
899 else
901 aLineStart = EditWin()->PixelToLogic( Point(GetPosPixel().X(),GetPosPixel().Y()-1) );
902 aLineEnd = EditWin()->PixelToLogic( Point(GetPosPixel().X()+GetSizePixel().Width(),GetPosPixel().Y()-1) );
905 if (!IsPreview())
907 if (mpAnkor)
909 mpAnkor->SetAllPosition(basegfx::B2DPoint( mAnkorRect.Left() , mAnkorRect.Bottom() - 5* 15),
910 basegfx::B2DPoint( mAnkorRect.Left()-5*15 , mAnkorRect.Bottom()+5*15),
911 basegfx::B2DPoint( mAnkorRect.Left()+5*15 , mAnkorRect.Bottom()+5*15),
912 basegfx::B2DPoint( mAnkorRect.Left(), mAnkorRect.Bottom()+2*15),
913 basegfx::B2DPoint( mPageBorder ,mAnkorRect.Bottom()+2*15),
914 basegfx::B2DPoint( aLineStart.X(),aLineStart.Y()),
915 basegfx::B2DPoint( aLineEnd.X(),aLineEnd.Y()));
916 mpAnkor->SetHeight(mAnkorRect.Height());
918 else
920 mpAnkor = new SwPostItAnkor(basegfx::B2DPoint( mAnkorRect.Left() , mAnkorRect.Bottom()-5*15),
921 basegfx::B2DPoint( mAnkorRect.Left()-5*15 , mAnkorRect.Bottom()+5*15),
922 basegfx::B2DPoint( mAnkorRect.Left()+5*15 , mAnkorRect.Bottom()+5*15),
923 basegfx::B2DPoint( mAnkorRect.Left(), mAnkorRect.Bottom()+2*15),
924 basegfx::B2DPoint( mPageBorder ,mAnkorRect.Bottom()+2*15),
925 basegfx::B2DPoint( aLineStart.X(),aLineStart.Y()),
926 basegfx::B2DPoint( aLineEnd.X(),aLineEnd.Y()) ,
927 mColorAnkor,
928 false,
929 false);
930 mpAnkor->SetHeight(mAnkorRect.Height());
931 mpAnkor->setVisible(true);
932 mpAnkor->SetAnkorState(AS_TRI);
933 if (HasChildPathFocus())
935 mpAnkor->setLineSolid(true);
937 pOverlayManager->add(*mpAnkor);
941 else
943 if ( mpAnkor && (mpAnkor->getBasePosition() != basegfx::B2DPoint( mAnkorRect.Left() , mAnkorRect.Bottom()-5*15)) )
944 mpAnkor->SetTriPosition(basegfx::B2DPoint( mAnkorRect.Left() , mAnkorRect.Bottom() - 5* 15),
945 basegfx::B2DPoint( mAnkorRect.Left()-5*15 , mAnkorRect.Bottom()+5*15),
946 basegfx::B2DPoint( mAnkorRect.Left()+5*15 , mAnkorRect.Bottom()+5*15),
947 basegfx::B2DPoint( mAnkorRect.Left(), mAnkorRect.Bottom()+2*15),
948 basegfx::B2DPoint( mPageBorder ,mAnkorRect.Bottom()+2*15));
951 if (bChange)
953 Point aStart = EditWin()->PixelToLogic(GetPosPixel()+Point(0,GetSizePixel().Height()));
954 Point aEnd = EditWin()->PixelToLogic(GetPosPixel()+Point(GetSizePixel().Width()-1,GetSizePixel().Height()));
955 mpShadow->SetPosition(basegfx::B2DPoint(aStart.X(),aStart.Y()), basegfx::B2DPoint(aEnd.X(),aEnd.Y()));
958 if (mpMgr->ShowNotes())
960 if (IsFollow() && !HasChildPathFocus())
962 mpAnkor->SetAnkorState(AS_END);
964 else
966 mpAnkor->SetAnkorState(AS_ALL);
967 SwMarginWin* pWin = GetTopReplyNote();
968 if (IsFollow() && pWin )
969 pWin->Ankor()->SetAnkorState(AS_END);
974 void SwMarginWin::DoResize()
976 long aTextHeight = LogicToPixel( mpOutliner->CalcTextSize()).Height();
977 unsigned long aWidth = GetSizePixel().Width();
978 long aHeight = GetSizePixel().Height();
980 if (mbMeta)
982 aHeight -= GetMetaHeight();
983 mpMeta->Show();
984 mpPostItTxt->SetQuickHelpText(EMPTYSTRING);
986 else
988 mpMeta->Hide();
989 mpPostItTxt->SetQuickHelpText(mpMeta->GetText());
992 if ((aTextHeight > aHeight) && !IsPreview())
993 { // we need vertical scrollbars and have to reduce the width
994 aWidth -= GetScrollbarWidth();
995 mpVScrollbar->Show();
997 else
999 mpVScrollbar->Hide();
1002 mpPostItTxt->SetPosSizePixel(0, 0, aWidth, aHeight);
1003 mpMeta->SetPosSizePixel(0,aHeight,GetSizePixel().Width()-GetMetaButtonAreaWidth(),GetMetaHeight());
1004 mpOutliner->SetPaperSize( PixelToLogic( Size(aWidth,aHeight) ) ) ;
1005 mpOutlinerView->SetOutputArea( PixelToLogic( Rectangle(0,0,aWidth,aHeight) ) );
1006 if (!mpVScrollbar->IsVisible())
1007 { // if we do not have a scrollbar anymore, we want to see the complete text
1008 mpOutlinerView->SetVisArea( PixelToLogic( Rectangle(0,0,aWidth,aHeight) ) );
1010 mpVScrollbar->SetPosSizePixel( aWidth, 0, GetScrollbarWidth(), aHeight );
1011 mpVScrollbar->SetVisibleSize( PixelToLogic(Size(0,aHeight)).Height() );
1012 mpVScrollbar->SetPageSize( PixelToLogic(Size(0,aHeight)).Height() * 8 / 10 );
1013 mpVScrollbar->SetLineSize( mpOutliner->GetTextHeight() / 10 );
1014 //mpVScrollbar->SetThumbPos( mpOutlinerView->GetVisArea().Top()+ mpOutlinerView->GetEditView().GetCursor()->GetOffsetY());
1015 SetScrollbar();
1016 mpVScrollbar->SetRange( Range(0, mpOutliner->GetTextHeight()));
1018 //calculate rects for meta- button
1019 const Fraction& fx( GetMapMode().GetScaleX() );
1020 const Fraction& fy( GetMapMode().GetScaleY() );
1022 Point aPos( mpMeta->GetPosPixel());
1023 Point aBase( aPos.X() + aPos.X() + GetSizePixel().Width(), aPos.Y() );
1024 Point aLeft = PixelToLogic( Point( aBase.X() - (METABUTTON_WIDTH+5)*fx.GetNumerator()/fx.GetDenominator(), aBase.Y()+17*fy.GetNumerator()/fx.GetDenominator() ) );
1025 Point aRight = PixelToLogic( Point( aBase.X() - (METABUTTON_WIDTH-1)*fx.GetNumerator()/fx.GetDenominator(), aBase.Y()+17*fy.GetNumerator()/fy.GetDenominator() ) );
1026 Point aBottom = PixelToLogic( Point( aBase.X() - (METABUTTON_WIDTH+2)*fx.GetNumerator()/fx.GetDenominator(), aBase.Y()+20*fy.GetNumerator()/fy.GetDenominator() ) );
1028 //Point aLeft = PixelToLogic(Point(mpMeta->GetPosPixel().X()+mpMeta->GetPosPixel().X()+GetSizePixel().Width()-(GetMetaButtonWidth()+10)+5,mpMeta->GetPosPixel().Y()+17));
1029 //Point aRight = PixelToLogic(Point(mpMeta->GetPosPixel().X()+mpMeta->GetPosPixel().X()+GetSizePixel().Width()-(GetMetaButtonWidth()+10)+11,mpMeta->GetPosPixel().Y()+17));
1030 //Point aBottom = PixelToLogic(Point(mpMeta->GetPosPixel().X()+mpMeta->GetPosPixel().X()+GetSizePixel().Width()-(GetMetaButtonWidth()+10)+8,mpMeta->GetPosPixel().Y()+20));
1032 aPopupTriangle.clear();
1033 aPopupTriangle.append(basegfx::B2DPoint(aLeft.X(),aLeft.Y()));
1034 aPopupTriangle.append(basegfx::B2DPoint(aRight.X(),aRight.Y()));
1035 aPopupTriangle.append(basegfx::B2DPoint(aBottom.X(),aBottom.Y()));
1036 aPopupTriangle.setClosed(true);
1037 if (IsPreview())
1038 mRectMetaButton = PixelToLogic( Rectangle( Point(
1039 aPos.X()+GetSizePixel().Width()-(METABUTTON_WIDTH*4+10)*fx.GetNumerator()/fx.GetDenominator(),
1040 aPos.Y()+5*fy.GetNumerator()/fy.GetDenominator() ),
1041 Size( METABUTTON_WIDTH*4*fx.GetNumerator()/fx.GetDenominator(), METABUTTON_HEIGHT*fy.GetNumerator()/fy.GetDenominator() ) ) );
1042 else
1043 mRectMetaButton = PixelToLogic( Rectangle( Point(
1044 aPos.X()+GetSizePixel().Width()-(METABUTTON_WIDTH+10)*fx.GetNumerator()/fx.GetDenominator(),
1045 aPos.Y()+5*fy.GetNumerator()/fy.GetDenominator() ),
1046 Size( METABUTTON_WIDTH*fx.GetNumerator()/fx.GetDenominator(), METABUTTON_HEIGHT*fy.GetNumerator()/fy.GetDenominator() ) ) );
1049 void SwMarginWin::SetSizePixel( const Size& rNewSize )
1051 Window::SetSizePixel(rNewSize);
1053 if (mpShadow)
1055 Point aStart = EditWin()->PixelToLogic(GetPosPixel()+Point(0,GetSizePixel().Height()));
1056 Point aEnd = EditWin()->PixelToLogic(GetPosPixel()+Point(GetSizePixel().Width()-1,GetSizePixel().Height()));
1057 mpShadow->SetPosition(basegfx::B2DPoint(aStart.X(),aStart.Y()), basegfx::B2DPoint(aEnd.X(),aEnd.Y()));
1061 void SwMarginWin::SetScrollbar()
1063 mpVScrollbar->SetThumbPos( mpOutlinerView->GetVisArea().Top()+ mpOutlinerView->GetEditView().GetCursor()->GetOffsetY());
1066 void SwMarginWin::ResizeIfNeccessary(long aOldHeight, long aNewHeight)
1068 if (aOldHeight != aNewHeight)
1070 //check for lower border or next note
1071 long aBorder = mpMgr->GetNextBorder();
1072 if (aBorder != -1)
1074 if (aNewHeight > GetMinimumSizeWithoutMeta())
1076 long aNewLowerValue = GetPosPixel().Y() + aNewHeight + GetMetaHeight();
1077 if (aNewLowerValue < aBorder)
1078 SetSizePixel(Size(GetSizePixel().Width(),aNewHeight+GetMetaHeight()));
1079 else
1080 SetSizePixel(Size(GetSizePixel().Width(),aBorder - GetPosPixel().Y()));
1081 DoResize();
1082 Invalidate();
1084 else
1086 if (GetSizePixel().Height() != GetMinimumSizeWithoutMeta() + GetMetaHeight())
1087 SetSizePixel(Size(GetSizePixel().Width(),GetMinimumSizeWithoutMeta() + GetMetaHeight()));
1088 DoResize();
1089 Invalidate();
1092 else
1094 DoResize();
1095 Invalidate();
1098 else
1100 SetScrollbar();
1104 void SwMarginWin::SetColor(Color aColorDark,Color aColorLight, Color aColorAnkor)
1106 mColorDark = aColorDark;
1107 mColorLight = aColorLight;
1108 mColorAnkor = aColorAnkor;
1110 if ( !Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
1112 //Wallpaper aWall(Gradient(GRADIENT_LINEAR,mColorLight,mColorDark));
1113 //mpPostItTxt->SetBackground(aWall);
1115 mpMeta->SetControlBackground(mColorDark);
1116 AllSettings aSettings = mpMeta->GetSettings();
1117 StyleSettings aStyleSettings = aSettings.GetStyleSettings();
1118 aStyleSettings.SetFieldTextColor(aColorAnkor);
1119 aSettings.SetStyleSettings(aStyleSettings);
1120 mpMeta->SetSettings(aSettings);
1122 AllSettings aSettings2 = mpVScrollbar->GetSettings();
1123 StyleSettings aStyleSettings2 = aSettings2.GetStyleSettings();
1124 aStyleSettings2.SetButtonTextColor(Color(0,0,0));
1125 //aStyleSettings2.SetLightColor(mColorAnkor);
1126 aStyleSettings2.SetCheckedColor(mColorLight); //hintergund
1127 //aStyleSettings2.SetLightBorderColor(mColorAnkor);
1128 aStyleSettings2.SetShadowColor(mColorAnkor);
1129 aStyleSettings2.SetFaceColor(mColorDark);
1130 aSettings2.SetStyleSettings(aStyleSettings2);
1131 mpVScrollbar->SetSettings(aSettings2);
1135 void SwMarginWin::SetMarginSide(bool aMarginSide)
1137 mbMarginSide = aMarginSide;
1140 void SwMarginWin::SetReadonly(BOOL bSet)
1142 mbReadonly = bSet;
1143 View()->SetReadOnly(bSet);
1146 void SwMarginWin::SetLanguage(const SvxLanguageItem aNewItem)
1148 Engine()->SetModifyHdl( Link() );
1149 ESelection aOld = View()->GetSelection();
1151 ESelection aNewSelection( 0, 0, (USHORT)Engine()->GetParagraphCount()-1, USHRT_MAX );
1152 View()->SetSelection( aNewSelection );
1153 SfxItemSet aEditAttr(View()->GetAttribs());
1154 aEditAttr.Put(aNewItem);
1155 View()->SetAttribs( aEditAttr );
1157 View()->SetSelection(aOld);
1158 Engine()->SetModifyHdl( LINK( this, SwPostIt, ModifyHdl ) );
1160 const SwViewOption* pVOpt = DocView()->GetWrtShellPtr()->GetViewOptions();
1161 ULONG nCntrl = Engine()->GetControlWord();
1162 // turn off
1163 if (!pVOpt->IsOnlineSpell())
1164 nCntrl &= ~EE_CNTRL_ONLINESPELLING;
1165 else
1166 nCntrl &= ~EE_CNTRL_ONLINESPELLING;
1167 Engine()->SetControlWord(nCntrl);
1169 //turn back on
1170 if (pVOpt->IsOnlineSpell())
1171 nCntrl |= EE_CNTRL_ONLINESPELLING;
1172 else
1173 nCntrl &= ~EE_CNTRL_ONLINESPELLING;
1174 Engine()->SetControlWord(nCntrl);
1176 Engine()->CompleteOnlineSpelling();
1177 Invalidate();
1180 void SwMarginWin::DataChanged( const DataChangedEvent& aEvent)
1182 Window::DataChanged( aEvent );
1185 void SwMarginWin::GetFocus()
1187 if (mpPostItTxt)
1188 mpPostItTxt->GrabFocus();
1191 void SwMarginWin::LoseFocus()
1195 void SwMarginWin::ShowNote()
1197 SetPosAndSize();
1198 if (!IsVisible())
1199 Window::Show();
1200 if (mpAnkor && !mpShadow->isVisible())
1201 mpShadow->setVisible(true);
1202 if (mpAnkor && !mpAnkor->isVisible())
1203 mpAnkor->setVisible(true);
1206 void SwMarginWin::HideNote()
1208 if (IsVisible())
1209 Window::Hide();
1210 if (mpAnkor)
1212 if (mpMgr->IsShowAnkor())
1213 mpAnkor->SetAnkorState(AS_TRI);
1214 else
1215 mpAnkor->setVisible(false);
1217 if (mpShadow && mpShadow->isVisible())
1218 mpShadow->setVisible(false);
1221 void SwMarginWin::ActivatePostIt()
1223 mpOutliner->ClearModifyFlag();
1224 mpOutliner->GetUndoManager().Clear();
1226 CheckMetaText();
1227 SetViewState(SS_EDIT);
1228 View()->ShowCursor();
1230 mpOutlinerView->GetEditView().SetInsertMode(mpView->GetWrtShellPtr()->IsInsMode());
1232 if ( !Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
1233 View()->SetBackgroundColor(mColorDark);
1235 // mpPostItTxt->SetBackground(Wallpaper(mColorDark));
1238 void SwMarginWin::DeactivatePostIt()
1240 // remove selection, #i87073#
1241 if (View()->GetEditView().HasSelection())
1243 ESelection aSelection = View()->GetEditView().GetSelection();
1244 aSelection.nEndPara = aSelection.nStartPara;
1245 aSelection.nEndPos = aSelection.nStartPos;
1246 View()->GetEditView().SetSelection(aSelection);
1249 mpOutliner->CompleteOnlineSpelling();
1251 SetViewState(SS_NORMAL);
1252 // write the visible text back into the SwField
1253 UpdateData();
1255 if ( !Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
1256 View()->SetBackgroundColor(COL_TRANSPARENT);
1258 //mpPostItTxt->SetBackground(Gradient(GRADIENT_LINEAR,mColorLight,mColorDark));
1260 if ( !IsProtected() &&
1261 //if (!IsReadOnly() && (GetStatus()!=SwPostItHelper::DELETED) &&
1262 Engine()->GetEditEngine().GetText()==String(EMPTYSTRING) )
1263 mnEventId = Application::PostUserEvent( LINK( this, SwMarginWin, DeleteHdl), 0 );
1266 void SwMarginWin::ToggleInsMode()
1268 if (!mpView->GetWrtShell().IsRedlineOn())
1270 //change outliner
1271 mpOutlinerView->GetEditView().SetInsertMode(!mpOutlinerView->GetEditView().IsInsertMode());
1272 //change documnet
1273 mpView->GetWrtShell().ToggleInsMode();
1274 //update statusbar
1275 SfxBindings &rBnd = mpView->GetViewFrame()->GetBindings();
1276 rBnd.Invalidate(SID_ATTR_INSERT);
1277 rBnd.Update(SID_ATTR_INSERT);
1281 void SwMarginWin::ExecuteCommand(USHORT nSlot)
1283 switch (nSlot)
1285 case FN_POSTIT:
1286 case FN_REPLY:
1288 // if this note is empty, it will be deleted once losing the focus, so no reply, but only a new note
1289 // will be created
1290 SwView* pView = DocView();
1291 if (Engine()->GetEditEngine().GetText() != String(EMPTYSTRING))
1293 OutlinerParaObject* pPara = new OutlinerParaObject(*View()->GetEditView().CreateTextObject());
1294 Mgr()->RegisterAnswer(pPara);
1296 if (Mgr()->GetActivePostIt())
1297 Mgr()->SetActivePostIt(0);
1298 SwitchToFieldPos();
1299 pView->GetViewFrame()->GetDispatcher()->Execute(FN_POSTIT);
1300 break;
1302 case FN_DELETE_COMMENT:
1303 case FN_DELETE_NOTE:
1305 //Delete(); // do not kill the parent of our open popup menu
1306 mnEventId = Application::PostUserEvent( LINK( this, SwMarginWin, DeleteHdl), 0 );
1307 break;
1309 case FN_HIDE_NOTE:
1310 if ( Mgr()->GetActivePostIt() == this )
1312 Mgr()->SetActivePostIt(0);
1313 // put the cursor back into the document
1314 SwitchToFieldPos();
1316 Mgr()->Hide(mpFld);
1317 break;
1319 case FN_DELETE_ALL_NOTES:
1320 case FN_HIDE_ALL_NOTES:
1321 // not possible as slot as this would require that "this" is the active postit
1322 DocView()->GetViewFrame()->GetBindings().Execute( nSlot, 0, 0, SFX_CALLMODE_ASYNCHRON );
1323 break;
1324 case FN_DELETE_NOTE_AUTHOR:
1325 case FN_HIDE_NOTE_AUTHOR:
1327 // not possible as slot as this would require that "this" is the active postit
1328 SfxStringItem aItem( nSlot, GetAuthor() );
1329 const SfxPoolItem* aItems[2];
1330 aItems[0] = &aItem;
1331 aItems[1] = 0;
1332 DocView()->GetViewFrame()->GetBindings().Execute( nSlot, aItems, 0, SFX_CALLMODE_ASYNCHRON );
1334 default:
1335 mpView->GetViewFrame()->GetBindings().Execute( nSlot );
1336 break;
1340 bool SwMarginWin::CalcFollow()
1342 return false;
1345 SwEditWin* SwMarginWin::EditWin()
1347 return &mpView->GetEditWin();
1350 String SwPostIt::GetAuthor()
1352 return mpFld->GetPar1();
1355 Date SwPostIt::GetDate()
1357 return mpFld->GetDate();
1360 Time SwPostIt::GetTime()
1362 return mpFld->GetTime();
1365 long SwMarginWin::GetPostItTextHeight()
1367 return mpOutliner ? LogicToPixel(mpOutliner->CalcTextSize()).Height() : 0;
1370 void SwMarginWin::SwitchToPostIt(USHORT aDirection)
1372 if (mpMgr)
1374 SwMarginWin* pPostIt = mpMgr->GetNextPostIt(aDirection, this);
1375 if (pPostIt)
1376 pPostIt->GrabFocus();
1380 void SwMarginWin::MouseButtonDown( const MouseEvent& /*rMEvt */)
1384 void SwMarginWin::MouseMove( const MouseEvent& rMEvt )
1386 if (mRectMetaButton.IsInside(PixelToLogic(rMEvt.GetPosPixel())))
1388 if (!mbMouseOverButton)
1390 Invalidate(mRectMetaButton);
1391 mbMouseOverButton = true;
1394 else
1396 if (mbMouseOverButton)
1398 Invalidate(mRectMetaButton);
1399 mbMouseOverButton = false;
1404 void SwMarginWin::Delete()
1406 if ( Mgr()->GetActivePostIt() == this)
1408 Mgr()->SetActivePostIt(0);
1409 // if the note is empty, the previous line will send a delete event, but we are already there
1410 if (mnEventId)
1412 Application::RemoveUserEvent( mnEventId );
1413 mnEventId = 0;
1418 IMPL_LINK(SwMarginWin, ScrollHdl, ScrollBar*, pScroll)
1420 long nDiff = View()->GetEditView().GetVisArea().Top() - pScroll->GetThumbPos();
1421 View()->Scroll( 0, nDiff );
1422 return 0;
1425 IMPL_LINK(SwMarginWin, ModifyHdl, void*, pVoid)
1427 // no warnings, please
1428 pVoid=0;
1429 DocView()->GetDocShell()->SetModified(sal_True);
1430 return 0;
1433 IMPL_LINK(SwMarginWin, DeleteHdl, void*, pVoid)
1435 // no warnings, please
1436 pVoid=0;
1437 mnEventId = 0;
1438 Delete();
1439 return 0;
1443 void SwMarginWin::ResetAttributes()
1445 mpOutlinerView->RemoveAttribsKeepLanguages(TRUE);
1446 mpOutliner->RemoveFields(TRUE);
1447 SfxItemSet aSet( mpView->GetDocShell()->GetPool() );
1448 aSet.Put(SvxFontHeightItem(200,100,EE_CHAR_FONTHEIGHT));
1449 mpOutlinerView->SetAttribs(aSet);
1452 sal_Int32 SwMarginWin::GetScrollbarWidth()
1454 return mpView->GetWrtShell().GetViewOptions()->GetZoom() / 10;
1457 sal_Int32 SwMarginWin::GetMetaButtonAreaWidth()
1459 const Fraction& f( GetMapMode().GetScaleX() );
1460 if (IsPreview())
1461 return 3 * METABUTTON_AREA_WIDTH * f.GetNumerator() / f.GetDenominator();
1462 else
1463 return METABUTTON_AREA_WIDTH * f.GetNumerator() / f.GetDenominator();
1466 sal_Int32 SwMarginWin::GetMetaHeight()
1468 const Fraction& f( GetMapMode().GetScaleY() );
1469 return POSTIT_META_HEIGHT * f.GetNumerator() / f.GetDenominator();
1472 sal_Int32 SwMarginWin::GetMinimumSizeWithMeta()
1474 return mpMgr->GetMinimumSizeWithMeta();
1477 sal_Int32 SwMarginWin::GetMinimumSizeWithoutMeta()
1479 const Fraction& f( GetMapMode().GetScaleY() );
1480 return POSTIT_MINIMUMSIZE_WITHOUT_META * f.GetNumerator() / f.GetDenominator();
1483 void SwMarginWin::SetSpellChecking()
1485 const SwViewOption* pVOpt = mpView->GetWrtShellPtr()->GetViewOptions();
1486 ULONG nCntrl = mpOutliner->GetControlWord();
1487 if (pVOpt->IsOnlineSpell())
1488 nCntrl |= EE_CNTRL_ONLINESPELLING;
1489 else
1490 nCntrl &= ~EE_CNTRL_ONLINESPELLING;
1491 mpOutliner->SetControlWord(nCntrl);
1493 mpOutliner->CompleteOnlineSpelling();
1494 Invalidate();
1497 void SwMarginWin::SetViewState(ShadowState bState)
1499 switch (bState)
1501 case SS_EDIT:
1503 if (mpAnkor)
1505 mpAnkor->SetAnkorState(AS_ALL);
1506 SwMarginWin* pWin = GetTopReplyNote();
1507 if (IsFollow() && pWin)
1508 pWin->Ankor()->SetAnkorState(AS_END);
1509 mpAnkor->setLineSolid(true);
1511 if (mpShadow)
1512 mpShadow->SetShadowState(bState);
1513 break;
1515 case SS_VIEW:
1517 if (mpAnkor)
1518 mpAnkor->setLineSolid(true);
1519 if (mpShadow)
1520 mpShadow->SetShadowState(bState);
1521 break;
1523 case SS_NORMAL:
1525 if (mpAnkor)
1527 if (IsFollow())
1529 // if there is no visible parent note, we want to see the complete anchor ??
1530 //if (IsAnyStackParentVisible())
1531 mpAnkor->SetAnkorState(AS_END);
1532 SwMarginWin* pTopWinSelf = GetTopReplyNote();
1533 SwMarginWin* pTopWinActive = mpMgr->GetActivePostIt() ? mpMgr->GetActivePostIt()->GetTopReplyNote() : 0;
1534 if (pTopWinSelf && (pTopWinSelf!=pTopWinActive))
1536 if (pTopWinSelf!=mpMgr->GetActivePostIt())
1537 pTopWinSelf->Ankor()->setLineSolid(false);
1538 pTopWinSelf->Ankor()->SetAnkorState(AS_ALL);
1541 mpAnkor->setLineSolid(false);
1543 if (mpShadow)
1544 mpShadow->SetShadowState(bState);
1545 break;
1550 bool SwMarginWin::IsAnyStackParentVisible()
1552 SwMarginWin* pMarginWin = mpMgr->GetNextPostIt(KEY_PAGEUP, this);
1553 while (pMarginWin)
1555 if (pMarginWin->IsFollow())
1557 pMarginWin = mpMgr->GetNextPostIt(KEY_PAGEUP, pMarginWin);
1558 if (pMarginWin && pMarginWin->IsVisible())
1559 return true;
1561 else
1562 return pMarginWin && pMarginWin->IsVisible() ? true : false;
1564 return false;
1567 SwMarginWin* SwMarginWin::GetTopReplyNote()
1569 SwMarginWin* pTopNote = 0;
1570 SwMarginWin* pMarginWin = mpMgr->GetNextPostIt(KEY_PAGEUP, this);
1571 while (pMarginWin)
1573 pTopNote = pMarginWin;
1574 pMarginWin = pMarginWin->IsFollow() ? mpMgr->GetNextPostIt(KEY_PAGEUP, pMarginWin) : 0;
1576 return pTopNote;
1579 void SwMarginWin::SwitchToFieldPos()
1581 if ( Mgr()->GetActivePostIt() == this )
1582 Mgr()->SetActivePostIt(0);
1583 GotoPos();
1584 sal_uInt32 aCount = MoveCaret();
1585 if (aCount)
1586 DocView()->GetDocShell()->GetWrtShell()->SwCrsrShell::Right(aCount, 0, FALSE);
1587 GrabFocusToDocument();
1590 String SwMarginWin::GetAuthor()
1592 return String(EMPTYSTRING);
1595 Date SwMarginWin::GetDate()
1597 return Date(0);
1600 Time SwMarginWin::GetTime()
1602 return Time(0);
1605 SvxLanguageItem SwMarginWin::GetLanguage(void)
1607 return SvxLanguageItem(SwLangHelper::GetLanguage(DocView()->GetWrtShell(),RES_CHRATR_LANGUAGE),RES_CHRATR_LANGUAGE);
1610 /***** SwPostIt *********************************************/
1611 SwPostIt::SwPostIt( Window* pParent, WinBits nBits, SwFmtFld* aField,SwPostItMgr* aMgr,SwPostItBits aBits)
1612 : SwMarginWin(pParent,nBits,aMgr,aBits),
1613 mpFmtFld(aField),
1614 mpFld( static_cast<SwPostItField*>(aField->GetFld())),
1615 mStatus(SwPostItHelper::INVISIBLE)
1619 void SwPostIt::SetPostItText()
1621 // get text from SwPostItField and insert into our textview
1622 Engine()->SetModifyHdl( Link() );
1623 Engine()->EnableUndo( FALSE );
1624 mpFld = static_cast<SwPostItField*>(mpFmtFld->GetFld());
1625 if( mpFld->GetTextObject() )
1626 Engine()->SetText( *mpFld->GetTextObject() );
1627 else
1629 Engine()->Clear();
1630 SfxItemSet item( DocView()->GetDocShell()->GetPool() );
1631 item.Put(SvxFontHeightItem(200,100,EE_CHAR_FONTHEIGHT));
1632 item.Put(SvxFontItem(FAMILY_SWISS,GetSettings().GetStyleSettings().GetFieldFont().GetName(),
1633 EMPTYSTRING,PITCH_DONTKNOW,RTL_TEXTENCODING_DONTKNOW,EE_CHAR_FONTINFO));
1634 View()->SetAttribs(item);
1635 View()->InsertText(mpFld->GetPar2(),false);
1638 Engine()->ClearModifyFlag();
1639 Engine()->GetUndoManager().Clear();
1640 Engine()->EnableUndo( TRUE );
1641 Engine()->SetModifyHdl( LINK( this, SwPostIt, ModifyHdl ) );
1642 Invalidate();
1645 void SwPostIt::UpdateData()
1647 if ( Engine()->IsModified() )
1649 SwTxtFld* pTxtFld = mpFmtFld->GetTxtFld();
1650 SwPosition aPosition( pTxtFld->GetTxtNode() );
1651 aPosition.nContent = *pTxtFld->GetStart();
1652 SwField* pOldField = mpFld->Copy();
1653 mpFld->SetPar2(Engine()->GetEditEngine().GetText());
1654 mpFld->SetTextObject(Engine()->CreateParaObject());
1655 DocView()->GetDocShell()->GetDoc()->AppendUndo(new SwUndoFieldFromDoc(aPosition, *pOldField, *mpFld, 0, true));
1656 delete pOldField;
1657 // so we get a new layout of notes (ankor position is still the same and we would otherwise not get one)
1658 Mgr()->SetLayout();
1659 DocView()->GetDocShell()->SetModified();
1661 Engine()->ClearModifyFlag();
1662 Engine()->GetUndoManager().Clear();
1665 void SwPostIt::SetChangeTracking(SwPostItHelper::SwLayoutStatus& aStatus,Color aColor)
1667 if ( (mStatus != aStatus) || (mChangeColor != aColor) )
1669 mStatus = aStatus;
1670 mChangeColor = aColor;
1671 Invalidate();
1675 void SwPostIt::Delete()
1677 SwMarginWin::Delete();
1678 // we delete the field directly, the Mgr cleans up the PostIt by listening
1679 DocView()->GetWrtShellPtr()->GotoField(*mpFmtFld);
1680 GrabFocusToDocument();
1681 DocView()->GetWrtShellPtr()->DelRight();
1684 void SwPostIt::GotoPos()
1686 DocView()->GetDocShell()->GetWrtShell()->GotoField(*mpFmtFld);
1689 sal_uInt32 SwPostIt::MoveCaret()
1691 // if this is an answer, do not skip over all following ones, but insert directly behind the current one
1692 // but when just leaving a note, skip all following ones as well to continue typing
1693 return Mgr()->IsAnswer() ? 1 : 1 + CountFollowing();
1696 //returns true, if there is another note right before this note
1697 bool SwPostIt::CalcFollow()
1699 SwTxtFld* pTxtFld = mpFmtFld->GetTxtFld();
1700 SwPosition aPosition( pTxtFld->GetTxtNode() );
1701 aPosition.nContent = *pTxtFld->GetStart();
1702 SwTxtAttr* pTxtAttr = pTxtFld->GetTxtNode().GetTxtAttr( aPosition.nContent.GetIndex()-1,RES_TXTATR_FIELD );
1703 const SwField* pFld = pTxtAttr ? pTxtAttr->GetFld().GetFld() : 0;
1704 return pFld && (pFld->Which()== RES_POSTITFLD);
1707 // counts how many SwPostItField we have right after the current one
1708 sal_uInt32 SwPostIt::CountFollowing()
1710 sal_uInt32 aCount = 1; // we start with 1, so we have to subtract one at the end again
1711 SwTxtFld* pTxtFld = mpFmtFld->GetTxtFld();
1712 SwPosition aPosition( pTxtFld->GetTxtNode() );
1713 aPosition.nContent = *pTxtFld->GetStart();
1715 SwTxtAttr* pTxtAttr = pTxtFld->GetTxtNode().GetTxtAttr( aPosition.nContent.GetIndex()+1,RES_TXTATR_FIELD );
1716 SwField* pFld = pTxtAttr ? const_cast<SwField*>(pTxtAttr->GetFld().GetFld()) : 0;
1717 while (pFld && (pFld->Which()== RES_POSTITFLD))
1719 aCount++;
1720 pTxtAttr = pTxtFld->GetTxtNode().GetTxtAttr( aPosition.nContent.GetIndex() + aCount,RES_TXTATR_FIELD );
1721 pFld = pTxtAttr ? const_cast<SwField*>(pTxtAttr->GetFld().GetFld()) : 0;
1723 return aCount - 1;
1726 void SwPostIt::MouseButtonDown( const MouseEvent& rMEvt )
1728 if (mRectMetaButton.IsInside(PixelToLogic(rMEvt.GetPosPixel())) && rMEvt.IsLeft())
1730 if (IsPreview())
1732 doLazyDelete();
1733 if (Mgr())
1735 SwPostIt* pPostIt = dynamic_cast<SwPostIt*>(Mgr()->GetPostIt(mpFmtFld));
1736 if (pPostIt)
1738 pPostIt->GrabFocus();
1739 Mgr()->MakeVisible(pPostIt);
1744 else
1746 if ( mbReadonly )
1748 mpButtonPopup->EnableItem(FN_REPLY,false);
1749 mpButtonPopup->EnableItem(FN_DELETE_NOTE,false);
1750 mpButtonPopup->EnableItem(FN_DELETE_NOTE_AUTHOR,false);
1751 mpButtonPopup->EnableItem(FN_DELETE_ALL_NOTES,false);
1753 else
1755 if (IsProtected())
1756 mpButtonPopup->EnableItem(FN_DELETE_NOTE,false);
1757 else
1758 mpButtonPopup->EnableItem(FN_DELETE_NOTE,true);
1759 mpButtonPopup->EnableItem(FN_DELETE_NOTE_AUTHOR,true);
1760 mpButtonPopup->EnableItem(FN_DELETE_ALL_NOTES,true);
1762 SvtUserOptions aUserOpt;
1763 String sAuthor;
1764 if( !(sAuthor = aUserOpt.GetFullName()).Len())
1765 if( !(sAuthor = aUserOpt.GetID()).Len() )
1766 sAuthor = String( SW_RES( STR_REDLINE_UNKNOWN_AUTHOR ));
1767 // do not allow to reply to ourself and no answer possible if this note is in a protected section
1768 if ((sAuthor == GetAuthor()) || (IsProtected()))
1769 mpButtonPopup->EnableItem(FN_REPLY,false);
1770 else
1771 mpButtonPopup->EnableItem(FN_REPLY,true);
1773 // show the popup menu and execute the selected command
1774 ExecuteCommand( mpButtonPopup->Execute( this,Rectangle(LogicToPixel(mRectMetaButton.BottomLeft()),LogicToPixel(mRectMetaButton.BottomLeft())),POPUPMENU_EXECUTE_DOWN | POPUPMENU_NOMOUSEUPCLOSE) );
1779 void SwPostIt::SetPopup()
1781 mpButtonPopup = new PopupMenu(SW_RES(MN_ANNOTATION_BUTTON));
1782 //mpButtonPopup->SetMenuFlags(MENU_FLAG_ALWAYSSHOWDISABLEDENTRIES);
1783 XubString aText = mpButtonPopup->GetItemText( FN_DELETE_NOTE_AUTHOR );
1784 SwRewriter aRewriter;
1785 aRewriter.AddRule(UNDO_ARG1,GetAuthor());
1786 aText = aRewriter.Apply(aText);
1787 mpButtonPopup->SetItemText(FN_DELETE_NOTE_AUTHOR,aText);
1790 void SwPostIt::InitAnswer(OutlinerParaObject* pText)
1792 //collect our old meta data
1793 SwMarginWin* pWin = Mgr()->GetNextPostIt(KEY_PAGEUP, this);
1794 const LocaleDataWrapper& rLocalData = SvtSysLocale().GetLocaleData();
1795 String aText = String(SW_RES(STR_REPLY));
1796 SwRewriter aRewriter;
1797 aRewriter.AddRule(UNDO_ARG1, pWin->GetAuthor());
1798 aText = aRewriter.Apply(aText);
1799 aText.Append(String(rtl::OUString::createFromAscii(" (") +
1800 String(rLocalData.getDate( pWin->GetDate())) + rtl::OUString::createFromAscii(", ") +
1801 String(rLocalData.getTime( pWin->GetTime(),false)) + rtl::OUString::createFromAscii("): \"")));
1802 View()->InsertText(aText,false);
1804 // insert old, selected text or "..."
1805 // TOOD: iterate over all paragraphs, not only first one to find out if it is empty
1806 if (pText->GetTextObject().GetText(0) != String(EMPTYSTRING))
1807 View()->GetEditView().InsertText(pText->GetTextObject());
1808 else
1809 View()->InsertText(rtl::OUString::createFromAscii("..."),false);
1810 View()->InsertText(rtl::OUString::createFromAscii("\"\n"),false);
1812 View()->SetSelection(ESelection(0x0,0x0,0xFFFF,0xFFFF));
1813 SfxItemSet aAnswerSet( DocView()->GetDocShell()->GetPool() );
1814 aAnswerSet.Put(SvxFontHeightItem(200,80,EE_CHAR_FONTHEIGHT));
1815 aAnswerSet.Put(SvxPostureItem(ITALIC_NORMAL,EE_CHAR_ITALIC));
1816 View()->SetAttribs(aAnswerSet);
1817 View()->SetSelection(ESelection(0xFFFF,0xFFFF,0xFFFF,0xFFFF));
1819 //remove all attributes and reset our standard ones
1820 View()->GetEditView().RemoveAttribsKeepLanguages(true);
1821 SfxItemSet aNormalSet( DocView()->GetDocShell()->GetPool() );
1822 aNormalSet.Put(SvxFontHeightItem(200,100,EE_CHAR_FONTHEIGHT));
1823 aNormalSet.Put(SvxFontItem(FAMILY_SWISS,GetSettings().GetStyleSettings().GetFieldFont().GetName(),
1824 EMPTYSTRING,PITCH_DONTKNOW,RTL_TEXTENCODING_DONTKNOW,EE_CHAR_FONTINFO));
1825 View()->SetAttribs(aNormalSet);
1826 // lets insert an undo step so the initial text can be easily deleted
1827 // but do not use UpdateData() directly, would set modified state again and reentrance into Mgr
1828 Engine()->SetModifyHdl( Link() );
1829 SwTxtFld* pTxtFld = mpFmtFld->GetTxtFld();
1830 SwPosition aPosition( pTxtFld->GetTxtNode() );
1831 aPosition.nContent = *pTxtFld->GetStart();
1832 SwField* pOldField = mpFld->Copy();
1833 mpFld->SetPar2(Engine()->GetEditEngine().GetText());
1834 mpFld->SetTextObject(Engine()->CreateParaObject());
1835 DocView()->GetDocShell()->GetDoc()->AppendUndo(new SwUndoFieldFromDoc(aPosition, *pOldField, *mpFld, 0, true));
1836 delete pOldField;
1837 Engine()->SetModifyHdl( LINK( this, SwPostIt, ModifyHdl ) );
1838 Engine()->ClearModifyFlag();
1839 Engine()->GetUndoManager().Clear();
1842 SvxLanguageItem SwPostIt::GetLanguage(void)
1844 // set initial language for outliner
1845 USHORT nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( mpFld->GetLanguage() );
1846 USHORT nLangWhichId = 0;
1847 switch (nScriptType)
1849 case SCRIPTTYPE_LATIN : nLangWhichId = EE_CHAR_LANGUAGE ; break;
1850 case SCRIPTTYPE_ASIAN : nLangWhichId = EE_CHAR_LANGUAGE_CJK; break;
1851 case SCRIPTTYPE_COMPLEX : nLangWhichId = EE_CHAR_LANGUAGE_CTL; break;
1852 default: DBG_ERROR("GetLanguage: wrong script tye");
1854 return SvxLanguageItem(mpFld->GetLanguage(),nLangWhichId);
1857 bool SwPostIt::IsProtected()
1859 bool aReturn;
1860 aReturn = mpFmtFld ? (SwMarginWin::IsProtected() || (mStatus==SwPostItHelper::DELETED) ||
1861 mpFmtFld->IsProtect()) : (SwMarginWin::IsProtected() || (mStatus==SwPostItHelper::DELETED));
1862 return aReturn;
1865 /********** SwRedComment**************/
1867 SwRedComment::SwRedComment( Window* pParent, WinBits nBits,SwPostItMgr* aMgr,SwPostItBits aBits,SwRedline* pRed)
1868 : SwMarginWin(pParent,nBits,aMgr,aBits),
1869 pRedline(pRed)
1873 void SwRedComment::SetPopup()
1875 mpButtonPopup = new PopupMenu(SW_RES(MN_REDCOMMENT_BUTTON));
1876 //mpButtonPopup->SetMenuFlags(MENU_FLAG_ALWAYSSHOWDISABLEDENTRIES);
1879 void SwRedComment::UpdateData()
1881 if ( Engine()->IsModified() )
1883 // so we get a new layout of notes (ankor position is still the same and we would otherwise not get one)
1884 Mgr()->SetLayout();
1885 // SetRedline is calling SetModified already
1886 DocView()->GetWrtShell().SetRedlineComment(Engine()->GetEditEngine().GetText());
1888 Engine()->ClearModifyFlag();
1889 Engine()->GetUndoManager().Clear();
1892 void SwRedComment::SetPostItText()
1894 Engine()->SetModifyHdl( Link() );
1895 Engine()->EnableUndo( FALSE );
1897 Engine()->Clear();
1898 SfxItemSet item( DocView()->GetDocShell()->GetPool() );
1899 item.Put(SvxFontHeightItem(200,100,EE_CHAR_FONTHEIGHT));
1900 item.Put(SvxFontItem(FAMILY_SWISS,GetSettings().GetStyleSettings().GetFieldFont().GetName(),
1901 EMPTYSTRING,PITCH_DONTKNOW,RTL_TEXTENCODING_DONTKNOW,EE_CHAR_FONTINFO));
1902 View()->SetAttribs(item);
1903 View()->InsertText(pRedline->GetComment(),false);
1905 Engine()->ClearModifyFlag();
1906 Engine()->GetUndoManager().Clear();
1907 Engine()->EnableUndo( TRUE );
1908 Engine()->SetModifyHdl( LINK( this, SwMarginWin, ModifyHdl ) );
1909 Invalidate();
1912 void SwRedComment::DeactivatePostIt()
1914 SwMarginWin::DeactivatePostIt();
1915 // current Redline is still selected
1916 DocView()->GetWrtShellPtr()->ClearMark();
1919 void SwRedComment::ActivatePostIt()
1921 SwMarginWin::ActivatePostIt();
1923 // do we want the redline selected?
1924 // otherwise, SwRedComment::ActivatePostIt() as well as SwRedComment::DeactivatePostIt()
1925 // can be thrown out completly
1926 DocView()->GetDocShell()->GetWrtShell()->GotoRedline(
1927 DocView()->GetDocShell()->GetWrtShell()->FindRedlineOfData(pRedline->GetRedlineData()),true);
1930 void SwRedComment::MouseButtonDown( const MouseEvent& rMEvt )
1932 if (mRectMetaButton.IsInside(PixelToLogic(rMEvt.GetPosPixel())) && rMEvt.IsLeft())
1934 ExecuteCommand( mpButtonPopup->Execute( this,Rectangle(LogicToPixel(mRectMetaButton.BottomLeft()),LogicToPixel(mRectMetaButton.BottomLeft())),POPUPMENU_EXECUTE_DOWN | POPUPMENU_NOMOUSEUPCLOSE) );
1938 void SwRedComment::Delete()
1940 SwMarginWin::Delete();
1941 // we are not neccessarily on our redline, so let's move there
1942 GotoPos();
1943 DocView()->GetWrtShell().SetRedlineComment(EMPTYSTRING);
1944 DocView()->GetWrtShell().ClearMark();
1945 // so we get a new layout of notes (ankor position is still the same and we would otherwise not get one)
1946 Mgr()->SetLayout();
1947 Mgr()->RemoveItem(pRedline);
1950 void SwRedComment::GotoPos()
1952 DocView()->GetDocShell()->GetWrtShell()->GotoRedline(
1953 DocView()->GetDocShell()->GetWrtShell()->FindRedlineOfData(pRedline->GetRedlineData()));
1956 String SwRedComment::GetAuthor()
1958 return pRedline->GetAuthorString();
1961 Date SwRedComment::GetDate()
1963 return pRedline->GetTimeStamp().GetDate();
1966 Time SwRedComment::GetTime()
1968 return pRedline->GetTimeStamp().GetTime();
1971 bool SwRedComment::IsProtected()
1973 return SwMarginWin::IsProtected() || pRedline->Start()->nNode.GetNode().GetTxtNode()->IsInProtectSect();
1977 //////////////////////////////////////////////////////////////////////////////
1978 // helper SwPostItShadowPrimitive
1980 // Used to allow view-dependent primitive definition. For that purpose, the
1981 // initially created primitive (this one) always has to be view-independent,
1982 // but the decomposition is made view-dependent. Very simple primitive which
1983 // just remembers the discrete data and applies it at decomposition time.
1985 class SwPostItShadowPrimitive : public drawinglayer::primitive2d::DiscreteMetricDependentPrimitive2D
1987 private:
1988 basegfx::B2DPoint maBasePosition;
1989 basegfx::B2DPoint maSecondPosition;
1990 ShadowState maShadowState;
1992 protected:
1993 virtual drawinglayer::primitive2d::Primitive2DSequence createLocalDecomposition(
1994 const drawinglayer::geometry::ViewInformation2D& rViewInformation) const;
1996 public:
1997 SwPostItShadowPrimitive(
1998 const basegfx::B2DPoint& rBasePosition,
1999 const basegfx::B2DPoint& rSecondPosition,
2000 ShadowState aShadowState)
2001 : drawinglayer::primitive2d::DiscreteMetricDependentPrimitive2D(),
2002 maBasePosition(rBasePosition),
2003 maSecondPosition(rSecondPosition),
2004 maShadowState(aShadowState)
2007 // data access
2008 const basegfx::B2DPoint& getBasePosition() const { return maBasePosition; }
2009 const basegfx::B2DPoint& getSecondPosition() const { return maSecondPosition; }
2010 ShadowState getShadowState() const { return maShadowState; }
2012 virtual bool operator==( const drawinglayer::primitive2d::BasePrimitive2D& rPrimitive ) const;
2014 DeclPrimitrive2DIDBlock()
2017 drawinglayer::primitive2d::Primitive2DSequence SwPostItShadowPrimitive::createLocalDecomposition(
2018 const drawinglayer::geometry::ViewInformation2D& /*rViewInformation*/) const
2020 // get logic sizes in object coordinate system
2021 drawinglayer::primitive2d::Primitive2DSequence xRetval;
2022 basegfx::B2DRange aRange(getBasePosition());
2024 switch(maShadowState)
2026 case SS_NORMAL:
2028 aRange.expand(basegfx::B2DTuple(getSecondPosition().getX(), getSecondPosition().getY() + (2.0 * getDiscreteUnit())));
2029 const drawinglayer::attribute::FillGradientAttribute aFillGradientAttribute(
2030 drawinglayer::attribute::GRADIENTSTYLE_LINEAR,
2031 0.0,
2032 0.5,
2033 0.5,
2034 1800.0 * F_PI1800,
2035 basegfx::BColor(230.0/255.0,230.0/255.0,230.0/255.0),
2036 basegfx::BColor(180.0/255.0,180.0/255.0,180.0/255.0),
2039 const drawinglayer::primitive2d::Primitive2DReference xReference(
2040 new drawinglayer::primitive2d::FillGradientPrimitive2D(
2041 aRange,
2042 aFillGradientAttribute));
2044 xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
2045 break;
2047 case SS_VIEW:
2049 aRange.expand(basegfx::B2DTuple(getSecondPosition().getX(), getSecondPosition().getY() + (4.0 * getDiscreteUnit())));
2050 const drawinglayer::attribute::FillGradientAttribute aFillGradientAttribute(
2051 drawinglayer::attribute::GRADIENTSTYLE_LINEAR,
2052 0.0,
2053 0.5,
2054 0.5,
2055 1800.0 * F_PI1800,
2056 basegfx::BColor(230.0/255.0,230.0/255.0,230.0/255.0),
2057 basegfx::BColor(180.0/255.0,180.0/255.0,180.0/255.0),
2060 const drawinglayer::primitive2d::Primitive2DReference xReference(
2061 new drawinglayer::primitive2d::FillGradientPrimitive2D(
2062 aRange,
2063 aFillGradientAttribute));
2065 xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
2066 break;
2068 case SS_EDIT:
2070 aRange.expand(basegfx::B2DTuple(getSecondPosition().getX(), getSecondPosition().getY() + (4.0 * getDiscreteUnit())));
2071 const drawinglayer::attribute::FillGradientAttribute aFillGradientAttribute(
2072 drawinglayer::attribute::GRADIENTSTYLE_LINEAR,
2073 0.0,
2074 0.5,
2075 0.5,
2076 1800.0 * F_PI1800,
2077 basegfx::BColor(230.0/255.0,230.0/255.0,230.0/255.0),
2078 basegfx::BColor(83.0/255.0,83.0/255.0,83.0/255.0),
2081 const drawinglayer::primitive2d::Primitive2DReference xReference(
2082 new drawinglayer::primitive2d::FillGradientPrimitive2D(
2083 aRange,
2084 aFillGradientAttribute));
2086 xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
2087 break;
2089 default:
2091 break;
2095 return xRetval;
2098 bool SwPostItShadowPrimitive::operator==( const drawinglayer::primitive2d::BasePrimitive2D& rPrimitive ) const
2100 if(drawinglayer::primitive2d::DiscreteMetricDependentPrimitive2D::operator==(rPrimitive))
2102 const SwPostItShadowPrimitive& rCompare = static_cast< const SwPostItShadowPrimitive& >(rPrimitive);
2104 return (getBasePosition() == rCompare.getBasePosition()
2105 && getSecondPosition() == rCompare.getSecondPosition()
2106 && getShadowState() == rCompare.getShadowState());
2109 return false;
2112 ImplPrimitrive2DIDBlock(SwPostItShadowPrimitive, PRIMITIVE2D_ID_SWPOSTITSHADOWPRIMITIVE)
2114 /****** SwPostItShadow ***********************************************************/
2115 SwPostItShadow::SwPostItShadow(const basegfx::B2DPoint& rBasePos,const basegfx::B2DPoint& rSecondPosition,
2116 Color aBaseColor,ShadowState aState)
2117 : OverlayObjectWithBasePosition(rBasePos, aBaseColor),
2118 maSecondPosition(rSecondPosition),
2119 mShadowState(aState)
2121 // mbAllowsAnimation = false;
2124 SwPostItShadow::~SwPostItShadow()
2128 drawinglayer::primitive2d::Primitive2DSequence SwPostItShadow::createOverlayObjectPrimitive2DSequence()
2130 const drawinglayer::primitive2d::Primitive2DReference aReference(
2131 new SwPostItShadowPrimitive(
2132 getBasePosition(),
2133 GetSecondPosition(),
2134 GetShadowState()));
2135 return drawinglayer::primitive2d::Primitive2DSequence(&aReference, 1);
2138 void SwPostItShadow::SetShadowState(ShadowState aState)
2140 if (mShadowState != aState)
2142 mShadowState = aState;
2144 objectChange();
2148 void SwPostItShadow::SetPosition(const basegfx::B2DPoint& rPoint1,
2149 const basegfx::B2DPoint& rPoint2)
2151 if(!rPoint1.equal(getBasePosition()) || !rPoint2.equal(GetSecondPosition()))
2153 maBasePosition = rPoint1;
2154 maSecondPosition = rPoint2;
2156 objectChange();
2160 //////////////////////////////////////////////////////////////////////////////
2161 // helper class: Primitive for discrete visualisation
2163 class SwPostItAnkorPrimitive : public drawinglayer::primitive2d::DiscreteMetricDependentPrimitive2D
2165 private:
2166 basegfx::B2DPolygon maTriangle;
2167 basegfx::B2DPolygon maLine;
2168 basegfx::B2DPolygon maLineTop;
2169 AnkorState maAnkorState;
2170 basegfx::BColor maColor;
2172 // discrete line width
2173 double mfLogicLineWidth;
2175 // bitfield
2176 bool mbShadow : 1;
2177 bool mbLineSolid : 1;
2179 protected:
2180 virtual drawinglayer::primitive2d::Primitive2DSequence createLocalDecomposition(
2181 const drawinglayer::geometry::ViewInformation2D& rViewInformation) const;
2183 public:
2184 SwPostItAnkorPrimitive(
2185 const basegfx::B2DPolygon& rTriangle,
2186 const basegfx::B2DPolygon& rLine,
2187 const basegfx::B2DPolygon& rLineTop,
2188 AnkorState aAnkorState,
2189 const basegfx::BColor& rColor,
2190 double fLogicLineWidth,
2191 bool bShadow,
2192 bool bLineSolid)
2193 : drawinglayer::primitive2d::DiscreteMetricDependentPrimitive2D(),
2194 maTriangle(rTriangle),
2195 maLine(rLine),
2196 maLineTop(rLineTop),
2197 maAnkorState(aAnkorState),
2198 maColor(rColor),
2199 mfLogicLineWidth(fLogicLineWidth),
2200 mbShadow(bShadow),
2201 mbLineSolid(bLineSolid)
2204 // data access
2205 const basegfx::B2DPolygon& getTriangle() const { return maTriangle; }
2206 const basegfx::B2DPolygon& getLine() const { return maLine; }
2207 const basegfx::B2DPolygon& getLineTop() const { return maLineTop; }
2208 AnkorState getAnkorState() const { return maAnkorState; }
2209 const basegfx::BColor& getColor() const { return maColor; }
2210 double getLogicLineWidth() const { return mfLogicLineWidth; }
2211 bool getShadow() const { return mbShadow; }
2212 bool getLineSolid() const { return mbLineSolid; }
2214 virtual bool operator==( const drawinglayer::primitive2d::BasePrimitive2D& rPrimitive ) const;
2216 DeclPrimitrive2DIDBlock()
2219 drawinglayer::primitive2d::Primitive2DSequence SwPostItAnkorPrimitive::createLocalDecomposition(
2220 const drawinglayer::geometry::ViewInformation2D& /*rViewInformation*/) const
2222 drawinglayer::primitive2d::Primitive2DSequence aRetval;
2224 if(AS_TRI == getAnkorState() || AS_ALL == getAnkorState() || AS_START == getAnkorState())
2226 // create triangle
2227 const drawinglayer::primitive2d::Primitive2DReference aTriangle(
2228 new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(
2229 basegfx::B2DPolyPolygon(getTriangle()),
2230 getColor()));
2232 drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, aTriangle);
2235 if(AS_ALL == getAnkorState() || AS_START == getAnkorState())
2237 // create line start
2238 const drawinglayer::attribute::LineAttribute aLineAttribute(
2239 getColor(),
2240 getLogicLineWidth() / (basegfx::fTools::equalZero(getDiscreteUnit()) ? 1.0 : getDiscreteUnit()));
2242 if(getLineSolid())
2244 const drawinglayer::primitive2d::Primitive2DReference aSolidLine(
2245 new drawinglayer::primitive2d::PolygonStrokePrimitive2D(
2246 getLine(),
2247 aLineAttribute));
2249 drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, aSolidLine);
2251 else
2253 ::std::vector< double > aDotDashArray;
2254 const double fDistance(3.0 * 15.0);
2255 const double fDashLen(5.0 * 15.0);
2257 aDotDashArray.push_back(fDashLen);
2258 aDotDashArray.push_back(fDistance);
2260 const drawinglayer::attribute::StrokeAttribute aStrokeAttribute(
2261 aDotDashArray,
2262 fDistance + fDashLen);
2264 const drawinglayer::primitive2d::Primitive2DReference aStrokedLine(
2265 new drawinglayer::primitive2d::PolygonStrokePrimitive2D(
2266 getLine(),
2267 aLineAttribute,
2268 aStrokeAttribute));
2270 drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, aStrokedLine);
2274 if(aRetval.hasElements() && getShadow())
2276 // shadow is only for triangle and line start, and in upper left
2277 // and lower right direction, in different colors
2278 const double fColorChange(20.0 / 255.0);
2279 const basegfx::B3DTuple aColorChange(fColorChange, fColorChange, fColorChange);
2280 basegfx::BColor aLighterColor(getColor() + aColorChange);
2281 basegfx::BColor aDarkerColor(getColor() - aColorChange);
2283 aLighterColor.clamp();
2284 aDarkerColor.clamp();
2286 // create shadow sequence
2287 drawinglayer::primitive2d::Primitive2DSequence aShadows(2);
2288 basegfx::B2DHomMatrix aTransform;
2290 aTransform.set(0, 2, -getDiscreteUnit());
2291 aTransform.set(1, 2, -getDiscreteUnit());
2293 aShadows[0] = drawinglayer::primitive2d::Primitive2DReference(
2294 new drawinglayer::primitive2d::ShadowPrimitive2D(
2295 aTransform,
2296 aLighterColor,
2297 aRetval));
2299 aTransform.set(0, 2, getDiscreteUnit());
2300 aTransform.set(1, 2, getDiscreteUnit());
2302 aShadows[1] = drawinglayer::primitive2d::Primitive2DReference(
2303 new drawinglayer::primitive2d::ShadowPrimitive2D(
2304 aTransform,
2305 aDarkerColor,
2306 aRetval));
2308 // add shadow before geometry to make it be proccessed first
2309 const drawinglayer::primitive2d::Primitive2DSequence aTemporary(aRetval);
2311 aRetval = aShadows;
2312 drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(aRetval, aTemporary);
2315 if(AS_ALL == getAnkorState() || AS_END == getAnkorState())
2317 // LineTop has to be created, too, but uses no shadow, so add after
2318 // the other parts are created
2319 const drawinglayer::attribute::LineAttribute aLineAttribute(
2320 getColor(),
2321 getLogicLineWidth() / (basegfx::fTools::equalZero(getDiscreteUnit()) ? 1.0 : getDiscreteUnit()));
2323 const drawinglayer::primitive2d::Primitive2DReference aLineTop(
2324 new drawinglayer::primitive2d::PolygonStrokePrimitive2D(
2325 getLineTop(),
2326 aLineAttribute));
2328 drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, aLineTop);
2331 return aRetval;
2334 bool SwPostItAnkorPrimitive::operator==( const drawinglayer::primitive2d::BasePrimitive2D& rPrimitive ) const
2336 if(drawinglayer::primitive2d::DiscreteMetricDependentPrimitive2D::operator==(rPrimitive))
2338 const SwPostItAnkorPrimitive& rCompare = static_cast< const SwPostItAnkorPrimitive& >(rPrimitive);
2340 return (getTriangle() == rCompare.getTriangle()
2341 && getLine() == rCompare.getLine()
2342 && getLineTop() == rCompare.getLineTop()
2343 && getAnkorState() == rCompare.getAnkorState()
2344 && getColor() == rCompare.getColor()
2345 && getLogicLineWidth() == rCompare.getLogicLineWidth()
2346 && getShadow() == rCompare.getShadow()
2347 && getLineSolid() == rCompare.getLineSolid());
2350 return false;
2353 ImplPrimitrive2DIDBlock(SwPostItAnkorPrimitive, PRIMITIVE2D_ID_SWPOSTITANKORPRIMITIVE)
2355 /****** SwPostItAnkor ***********************************************************/
2357 void SwPostItAnkor::implEnsureGeometry()
2359 if(!maTriangle.count())
2361 maTriangle.append(getBasePosition());
2362 maTriangle.append(GetSecondPosition());
2363 maTriangle.append(GetThirdPosition());
2364 maTriangle.setClosed(true);
2367 if(!maLine.count())
2369 maLine.append(GetFourthPosition());
2370 maLine.append(GetFifthPosition());
2371 maLine.append(GetSixthPosition());
2374 if(!maLineTop.count())
2376 maLineTop.append(GetSixthPosition());
2377 maLineTop.append(GetSeventhPosition());
2381 void SwPostItAnkor::implResetGeometry()
2383 maTriangle.clear();
2384 maLine.clear();
2385 maLineTop.clear();
2388 SwPostItAnkor::SwPostItAnkor(const basegfx::B2DPoint& rBasePos,
2389 const basegfx::B2DPoint& rSecondPos,
2390 const basegfx::B2DPoint& rThirdPos,
2391 const basegfx::B2DPoint& rFourthPos,
2392 const basegfx::B2DPoint& rFifthPos,
2393 const basegfx::B2DPoint& rSixthPos,
2394 const basegfx::B2DPoint& rSeventhPos,
2395 Color aBaseColor,
2396 bool bShadowedEffect,
2397 bool bLineSolid)
2398 : OverlayObjectWithBasePosition(rBasePos, aBaseColor),
2399 maSecondPosition(rSecondPos),
2400 maThirdPosition(rThirdPos),
2401 maFourthPosition(rFourthPos),
2402 maFifthPosition(rFifthPos),
2403 maSixthPosition(rSixthPos),
2404 maSeventhPosition(rSeventhPos),
2405 maTriangle(),
2406 maLine(),
2407 maLineTop(),
2408 mHeight(0),
2409 mAnkorState(AS_ALL),
2410 mbShadowedEffect(bShadowedEffect),
2411 mbLineSolid(bLineSolid)
2413 //mbAllowsAnimation = true;
2416 SwPostItAnkor::~SwPostItAnkor()
2420 drawinglayer::primitive2d::Primitive2DSequence SwPostItAnkor::createOverlayObjectPrimitive2DSequence()
2422 implEnsureGeometry();
2424 const drawinglayer::primitive2d::Primitive2DReference aReference(
2425 new SwPostItAnkorPrimitive(
2426 maTriangle,
2427 maLine,
2428 maLineTop,
2429 GetAnkorState(),
2430 getBaseColor().getBColor(),
2431 ANKORLINE_WIDTH * 15.0,
2432 getShadowedEffect(),
2433 getLineSolid()));
2435 return drawinglayer::primitive2d::Primitive2DSequence(&aReference, 1);
2438 void SwPostItAnkor::SetAllPosition(const basegfx::B2DPoint& rPoint1,
2439 const basegfx::B2DPoint& rPoint2,
2440 const basegfx::B2DPoint& rPoint3,
2441 const basegfx::B2DPoint& rPoint4,
2442 const basegfx::B2DPoint& rPoint5,
2443 const basegfx::B2DPoint& rPoint6,
2444 const basegfx::B2DPoint& rPoint7)
2446 if(rPoint1 != getBasePosition()
2447 || rPoint2 != GetSecondPosition()
2448 || rPoint3 != GetThirdPosition()
2449 || rPoint4 != GetFourthPosition()
2450 || rPoint5 != GetFifthPosition()
2451 || rPoint6 != GetSixthPosition()
2452 || rPoint7 != GetSeventhPosition())
2454 maBasePosition = rPoint1;
2455 maSecondPosition = rPoint2;
2456 maThirdPosition = rPoint3;
2457 maFourthPosition = rPoint4;
2458 maFifthPosition = rPoint5;
2459 maSixthPosition = rPoint6;
2460 maSeventhPosition = rPoint7;
2462 implResetGeometry();
2463 objectChange();
2467 void SwPostItAnkor::SetSixthPosition(const basegfx::B2DPoint& rNew)
2469 if(rNew != maSixthPosition)
2471 maSixthPosition = rNew;
2472 implResetGeometry();
2473 objectChange();
2477 void SwPostItAnkor::SetSeventhPosition(const basegfx::B2DPoint& rNew)
2479 if(rNew != maSeventhPosition)
2481 maSeventhPosition = rNew;
2482 implResetGeometry();
2483 objectChange();
2487 void SwPostItAnkor::SetTriPosition(const basegfx::B2DPoint& rPoint1,const basegfx::B2DPoint& rPoint2,const basegfx::B2DPoint& rPoint3,
2488 const basegfx::B2DPoint& rPoint4,const basegfx::B2DPoint& rPoint5)
2490 if(rPoint1 != getBasePosition()
2491 || rPoint2 != GetSecondPosition()
2492 || rPoint3 != GetThirdPosition()
2493 || rPoint4 != GetFourthPosition()
2494 || rPoint5 != GetFifthPosition())
2496 maBasePosition = rPoint1;
2497 maSecondPosition = rPoint2;
2498 maThirdPosition = rPoint3;
2499 maFourthPosition = rPoint4;
2500 maFifthPosition = rPoint5;
2502 implResetGeometry();
2503 objectChange();
2507 void SwPostItAnkor::setLineSolid(bool bNew)
2509 if(bNew != getLineSolid())
2511 mbLineSolid = bNew;
2512 objectChange();
2516 void SwPostItAnkor::SetAnkorState(AnkorState aState)
2518 if (mAnkorState != aState)
2520 mAnkorState = aState;
2521 objectChange();