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"
34 #include <PostItMgr.hxx>
40 #include <hintids.hxx>
41 #include "viewopt.hxx"
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>
104 #include <viewsh.hxx>
106 #include <shellres.hxx>
107 #include <fmtfld.hxx>
109 #include <textsh.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>
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
)
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
);
178 mpMarginWin
->DocView()->GetWrtShell().LockView( bLockView
);
179 mpMarginWin
->Mgr()->MakeVisible(mpMarginWin
);
182 void PostItTxt::LoseFocus()
184 // write the visible text back into the SwField
186 mpMarginWin
->UpdateData();
193 void PostItTxt::RequestHelp(const HelpEvent
&rEvt
)
196 switch( mpMarginWin
->GetStatus() )
198 case SwPostItHelper::INSERTED
: nResId
= STR_REDLINE_INSERT
; break;
199 case SwPostItHelper::DELETED
: nResId
= STR_REDLINE_DELETE
; break;
203 SwContentAtPos
aCntntAtPos( SwContentAtPos::SW_REDLINE
);
204 if ( nResId
&& mpMarginWin
->DocView()->GetWrtShell().GetContentAtPos( mpMarginWin
->GetAnkorRect().Pos(), aCntntAtPos
) )
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()));
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
);
246 if ((nKey
== KEY_ESCAPE
) || (rKeyCode
.IsMod1() && ((nKey
== KEY_PAGEUP
) || (nKey
== KEY_PAGEDOWN
))))
247 mpMarginWin
->SwitchToFieldPos();
249 if (nKey
== KEY_INSERT
)
251 if (!rKeyCode
.IsMod1() && !rKeyCode
.IsMod2())
252 mpMarginWin
->ToggleInsMode();
256 //let's make sure we see our note
257 mpMarginWin
->Mgr()->MakeVisible(mpMarginWin
);
259 long aOldHeight
= mpMarginWin
->GetPostItTextHeight();
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
);
274 InfoBox( this, SW_RES( MSG_READONLY_CONTENT
)).Execute();
277 mpMarginWin
->ResizeIfNeccessary(aOldHeight
,mpMarginWin
->GetPostItTextHeight());
280 // write back data first when showing navigator
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();
304 const SvxFieldData
* pFld
= pItem
->GetField();
305 const SvxURLField
* pURL
= PTR_CAST( SvxURLField
, pFld
);
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
)
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();
334 const SvxFieldData
* pFld
= pItem
->GetField();
335 const SvxURLField
* pURL
= PTR_CAST( SvxURLField
, pFld
);
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
);
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
);
368 IMPL_LINK( PostItTxt
, Select
, Menu
*, pSelMenu
)
370 mpMarginWin
->ExecuteCommand( pSelMenu
->GetCurItemId() );
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
);
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());
402 const Size aSize
= GetSizePixel();
403 const Point aPos
= Point( aSize
.getWidth()/2, aSize
.getHeight()/2 );
404 ((PopupMenu
*)aMgr
->GetSVMenu())->Execute(this,aPos
);
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
);
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);
432 HandleScrollCommand( rCEvt, 0 , mpMarginWin->Scrollbar());
439 mpMarginWin
->DocView()->HandleWheelCommands(rCEvt
);
444 if ( mpOutlinerView
)
445 mpOutlinerView
->Command( rCEvt
);
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() )
467 if (!mbShowPopup
&& !HasFocus())
469 mpMarginWin
->SetViewState(SS_VIEW
);
473 else if ( pMouseEvt
->IsLeaveWindow())
475 if (mpMarginWin
->IsPreview())
477 //mpMarginWin->doLazyDelete();
482 if (!mbShowPopup
&& !HasFocus())
484 mpMarginWin
->SetViewState(SS_NORMAL
);
494 XubString
PostItTxt::GetSurroundingText() const
497 return mpOutlinerView
->GetSurroundingText();
499 return XubString::EmptyString();
502 Selection
PostItTxt::GetSurroundingTextSelection() const
505 return mpOutlinerView
->GetSurroundingTextSelection();
507 return Selection( 0, 0 );
510 /************** SwMarginWin***********************************++*/
511 SwMarginWin::SwMarginWin(Window
* pParent
, WinBits nBits
,SwPostItMgr
* aMgr
,SwPostItBits aBits
)
512 : Window(pParent
, nBits
),
524 mbMouseOverButton(false),
528 SwEditWin
* aWin
= static_cast<SwEditWin
*>(GetParent());
529 mpView
= &aWin
->GetView();
531 SdrPaintWindow
* pPaintWindow
= mpView
->GetDrawView()->GetPaintWindow(0);
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()
546 delete mpOutlinerView
;
556 mpMeta
->RemoveEventListener( LINK( mpPostItTxt
, PostItTxt
, WindowEventListener
) );
572 if (mpAnkor
->getOverlayManager())
574 // remove this object from the chain
575 mpAnkor
->getOverlayManager()->remove(*mpAnkor
);
582 if (mpShadow
->getOverlayManager())
584 mpShadow
->getOverlayManager()->remove(*mpShadow
);
591 delete mpButtonPopup
;
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
);
608 SetFillColor(mColorDark
);
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
);
622 if (mbMouseOverButton
)
623 aGradient
= Gradient(GRADIENT_LINEAR
,ColorFromAlphaColor(80,mColorAnkor
,mColorDark
),ColorFromAlphaColor(15,mColorAnkor
,mColorDark
));
625 aGradient
= Gradient(GRADIENT_LINEAR
,ColorFromAlphaColor(15,mColorAnkor
,mColorDark
),ColorFromAlphaColor(80,mColorAnkor
,mColorDark
));
626 DrawGradient(mRectMetaButton
,aGradient
);
627 //draw rect around button
629 SetLineColor(ColorFromAlphaColor(90,mColorAnkor
,mColorDark
));
631 DrawRect(mRectMetaButton
);
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
);
642 DrawText(mRectMetaButton
,rtl::OUString::createFromAscii("Edit Note"),TEXT_DRAW_CENTER
);
648 if ( Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
649 SetFillColor(COL_WHITE
);
651 SetFillColor(COL_BLACK
);
653 DrawPolygon(Polygon(aPopupTriangle
));
658 void SwMarginWin::SetPosSizePixelRect(long nX
, long nY
,long nWidth
, long nHeight
,const SwRect
&aRect
, const long aPageBorder
)
661 mPosSize
= Rectangle(Point(nX
,nY
),Size(nWidth
,nHeight
));
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
)
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);
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
));
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();
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
);
737 OutputDevice
* pDev
= aShell
->GetDoc()->getReferenceDevice(TRUE
);
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());
752 EEHorizontalTextDirection aDefHoriTextDir
= Application::GetSettings().GetLayoutRTL() ? EE_HTEXTDIR_R2L
: EE_HTEXTDIR_L2R
;
753 mpOutliner
->SetDefaultHorizontalTextDirection( aDefHoriTextDir
);
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
;
770 nCntrl
&= ~EE_CNTRL_MARKFIELDS
;
771 if (pVOpt
->IsOnlineSpell())
772 nCntrl
|= EE_CNTRL_ONLINESPELLING
;
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
));
782 SetLanguage(GetLanguage());
783 View()->StartSpeller();
785 Engine()->CompleteOnlineSpelling();
788 mpVScrollbar
->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)
801 sMeta
= sMeta
+ rtl::OUString::createFromAscii("...");
803 Date aDate
= GetDate();
805 sMeta
= sMeta
+ LINEBREAK
+ String(SW_RES(STR_POSTIT_TODAY
));
807 if (aDate
== Date(Date()-1))
808 sMeta
= sMeta
+ LINEBREAK
+ String(SW_RES(STR_POSTIT_YESTERDAY
));
810 if (aDate
.IsValid() )
811 sMeta
= sMeta
+ LINEBREAK
+ rLocalData
.getDate(aDate
);
813 sMeta
= sMeta
+ LINEBREAK
+ String(SW_RES(STR_NODATE
));
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
);
828 mpPostItTxt
->SetMapMode( aMode
);
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())
846 SetSizePixel(mPosSize
.GetSize());
850 if (GetPosPixel().X() != mPosSize
.TopLeft().X() || (abs(GetPosPixel().Y() - mPosSize
.TopLeft().Y()) > 5) )
853 SetPosPixel(mPosSize
.TopLeft());
859 aLineStart
= EditWin()->PixelToLogic( Point(GetPosPixel().X()+GetSizePixel().Width(),GetPosPixel().Y()-1) );
860 aLineEnd
= EditWin()->PixelToLogic( Point(GetPosPixel().X(),GetPosPixel().Y()-1) );
864 aLineStart
= EditWin()->PixelToLogic( Point(GetPosPixel().X(),GetPosPixel().Y()-1) );
865 aLineEnd
= EditWin()->PixelToLogic( Point(GetPosPixel().X()+GetSizePixel().Width(),GetPosPixel().Y()-1) );
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());
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()) ,
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
);
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));
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
);
929 mpAnkor
->SetAnkorState(AS_ALL
);
930 SwMarginWin
* pWin
= GetTopReplyNote();
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();
945 aHeight
-= GetMetaHeight();
947 mpPostItTxt
->SetQuickHelpText(EMPTYSTRING
);
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();
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
);
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 );
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);
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() ) ) );
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
);
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();
1042 if (aNewHeight
> GetMinimumSizeWithoutMeta())
1044 long aNewLowerValue
= GetPosPixel().Y() + aNewHeight
+ GetMetaHeight();
1045 if (aNewLowerValue
< aBorder
)
1046 SetSizePixel(Size(GetSizePixel().Width(),aNewHeight
+GetMetaHeight()));
1048 SetSizePixel(Size(GetSizePixel().Width(),aBorder
- GetPosPixel().Y()));
1054 if (GetSizePixel().Height() != GetMinimumSizeWithoutMeta() + GetMetaHeight())
1055 SetSizePixel(Size(GetSizePixel().Width(),GetMinimumSizeWithoutMeta() + GetMetaHeight()));
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
)
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();
1131 if (!pVOpt
->IsOnlineSpell())
1132 nCntrl
&= ~EE_CNTRL_ONLINESPELLING
;
1134 nCntrl
&= ~EE_CNTRL_ONLINESPELLING
;
1135 Engine()->SetControlWord(nCntrl
);
1138 if (pVOpt
->IsOnlineSpell())
1139 nCntrl
|= EE_CNTRL_ONLINESPELLING
;
1141 nCntrl
&= ~EE_CNTRL_ONLINESPELLING
;
1142 Engine()->SetControlWord(nCntrl
);
1144 Engine()->CompleteOnlineSpelling();
1148 void SwMarginWin::DataChanged( const DataChangedEvent
& aEvent
)
1150 Window::DataChanged( aEvent
);
1153 void SwMarginWin::GetFocus()
1156 mpPostItTxt
->GrabFocus();
1159 void SwMarginWin::LoseFocus()
1163 void SwMarginWin::ShowNote()
1168 if (mpAnkor
&& !mpShadow
->isVisible())
1169 mpShadow
->setVisible(true);
1170 if (mpAnkor
&& !mpAnkor
->isVisible())
1171 mpAnkor
->setVisible(true);
1174 void SwMarginWin::HideNote()
1180 if (mpMgr
->IsShowAnkor())
1181 mpAnkor
->SetAnkorState(AS_TRI
);
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();
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
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())
1241 mpOutlinerView
->GetEditView().SetInsertMode(!mpOutlinerView
->GetEditView().IsInsertMode());
1243 mpView
->GetWrtShell().ToggleInsMode();
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();
1260 // if this note is empty, it will be deleted once losing the focus, so no reply, but only a new note
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);
1271 pView
->GetViewFrame()->GetDispatcher()->Execute(FN_POSTIT
);
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 );
1282 if ( Mgr()->GetActivePostIt() == this )
1284 Mgr()->SetActivePostIt(0);
1285 // put the cursor back into the document
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
);
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];
1304 DocView()->GetViewFrame()->GetBindings().Execute( nSlot
, aItems
, 0, SFX_CALLMODE_ASYNCHRON
);
1307 mpView
->GetViewFrame()->GetBindings().Execute( nSlot
);
1312 bool SwMarginWin::CalcFollow()
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
)
1346 SwMarginWin
* pPostIt
= mpMgr
->GetNextPostIt(aDirection
, this);
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;
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
1384 Application::RemoveUserEvent( mnEventId
);
1390 IMPL_LINK(SwMarginWin
, ScrollHdl
, ScrollBar
*, pScroll
)
1392 long nDiff
= View()->GetEditView().GetVisArea().Top() - pScroll
->GetThumbPos();
1393 View()->Scroll( 0, nDiff
);
1397 IMPL_LINK(SwMarginWin
, ModifyHdl
, void*, pVoid
)
1399 // no warnings, please
1401 DocView()->GetDocShell()->SetModified(sal_True
);
1405 IMPL_LINK(SwMarginWin
, DeleteHdl
, void*, pVoid
)
1407 // no warnings, please
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() );
1431 return 3 * METABUTTON_AREA_WIDTH
* f
.GetNumerator() / f
.GetDenominator();
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
;
1460 nCntrl
&= ~EE_CNTRL_ONLINESPELLING
;
1461 mpOutliner
->SetControlWord(nCntrl
);
1463 mpOutliner
->CompleteOnlineSpelling();
1467 void SwMarginWin::SetViewState(ShadowState bState
)
1475 mpAnkor
->SetAnkorState(AS_ALL
);
1476 SwMarginWin
* pWin
= GetTopReplyNote();
1478 pWin
->Ankor()->SetAnkorState(AS_END
);
1479 mpAnkor
->setLineSolid(true);
1482 mpShadow
->SetShadowState(bState
);
1488 mpAnkor
->setLineSolid(true);
1490 mpShadow
->SetShadowState(bState
);
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);
1514 mpShadow
->SetShadowState(bState
);
1520 bool SwMarginWin::IsAnyStackParentVisible()
1522 SwMarginWin
* pMarginWin
= mpMgr
->GetNextPostIt(KEY_PAGEUP
, this);
1525 if (pMarginWin
->IsFollow())
1527 pMarginWin
= mpMgr
->GetNextPostIt(KEY_PAGEUP
, pMarginWin
);
1528 if (pMarginWin
&& pMarginWin
->IsVisible())
1532 return pMarginWin
&& pMarginWin
->IsVisible() ? true : false;
1537 SwMarginWin
* SwMarginWin::GetTopReplyNote()
1539 SwMarginWin
* pTopNote
= 0;
1540 SwMarginWin
* pMarginWin
= IsFollow() ? mpMgr
->GetNextPostIt(KEY_PAGEUP
, this) : 0;
1543 pTopNote
= pMarginWin
;
1544 pMarginWin
= pMarginWin
->IsFollow() ? mpMgr
->GetNextPostIt(KEY_PAGEUP
, pMarginWin
) : 0;
1549 void SwMarginWin::SwitchToFieldPos()
1551 if ( Mgr()->GetActivePostIt() == this )
1552 Mgr()->SetActivePostIt(0);
1554 sal_uInt32 aCount
= MoveCaret();
1556 DocView()->GetDocShell()->GetWrtShell()->SwCrsrShell::Right(aCount
, 0, FALSE
);
1557 GrabFocusToDocument();
1560 String
SwMarginWin::GetAuthor()
1562 return String(EMPTYSTRING
);
1565 Date
SwMarginWin::GetDate()
1570 Time
SwMarginWin::GetTime()
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
),
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() );
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
) );
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));
1623 // so we get a new layout of notes (anchor position is still the same and we would otherwise not get one)
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
) )
1638 mChangeColor
= aColor
;
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
))
1690 pTxtAttr
= pTxtFld
->GetTxtNode().GetTxtAttrForCharAt(
1691 aPosition
.nContent
.GetIndex() + aCount
, RES_TXTATR_FIELD
);
1692 pFld
= pTxtAttr
? const_cast<SwField
*>(pTxtAttr
->GetFld().GetFld()) : 0;
1697 void SwPostIt::MouseButtonDown( const MouseEvent
& rMEvt
)
1699 if (mRectMetaButton
.IsInside(PixelToLogic(rMEvt
.GetPosPixel())) && rMEvt
.IsLeft())
1706 SwPostIt
* pPostIt
= dynamic_cast<SwPostIt
*>(Mgr()->GetPostIt(mpFmtFld
));
1709 pPostIt
->GrabFocus();
1710 Mgr()->MakeVisible(pPostIt
);
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);
1727 mpButtonPopup
->EnableItem(FN_DELETE_NOTE
,false);
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
;
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);
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());
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));
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()
1827 aReturn
= mpFmtFld
? (SwMarginWin::IsProtected() || (mStatus
==SwPostItHelper::DELETED
) ||
1828 mpFmtFld
->IsProtect()) : (SwMarginWin::IsProtected() || (mStatus
==SwPostItHelper::DELETED
));
1832 /********** SwRedComment**************/
1834 SwRedComment::SwRedComment( Window* pParent, WinBits nBits,SwPostItMgr* aMgr,SwPostItBits aBits,SwRedline* pRed)
1835 : SwMarginWin(pParent,nBits,aMgr,aBits),
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)
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 );
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 ) );
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
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)
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
1951 basegfx::B2DPoint maBasePosition
;
1952 basegfx::B2DPoint maSecondPosition
;
1953 ShadowState maShadowState
;
1956 virtual drawinglayer::primitive2d::Primitive2DSequence
createLocalDecomposition(
1957 const drawinglayer::geometry::ViewInformation2D
& rViewInformation
) const;
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
)
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
)
1991 aRange
.expand(basegfx::B2DTuple(getSecondPosition().getX(), getSecondPosition().getY() + (2.0 * getDiscreteUnit())));
1992 const drawinglayer::attribute::FillGradientAttribute
aFillGradientAttribute(
1993 drawinglayer::attribute::GRADIENTSTYLE_LINEAR
,
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(
2005 aFillGradientAttribute
));
2007 xRetval
= drawinglayer::primitive2d::Primitive2DSequence(&xReference
, 1);
2012 aRange
.expand(basegfx::B2DTuple(getSecondPosition().getX(), getSecondPosition().getY() + (4.0 * getDiscreteUnit())));
2013 const drawinglayer::attribute::FillGradientAttribute
aFillGradientAttribute(
2014 drawinglayer::attribute::GRADIENTSTYLE_LINEAR
,
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(
2026 aFillGradientAttribute
));
2028 xRetval
= drawinglayer::primitive2d::Primitive2DSequence(&xReference
, 1);
2033 aRange
.expand(basegfx::B2DTuple(getSecondPosition().getX(), getSecondPosition().getY() + (4.0 * getDiscreteUnit())));
2034 const drawinglayer::attribute::FillGradientAttribute
aFillGradientAttribute(
2035 drawinglayer::attribute::GRADIENTSTYLE_LINEAR
,
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(
2047 aFillGradientAttribute
));
2049 xRetval
= drawinglayer::primitive2d::Primitive2DSequence(&xReference
, 1);
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());
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(
2096 GetSecondPosition(),
2098 return drawinglayer::primitive2d::Primitive2DSequence(&aReference
, 1);
2101 void SwPostItShadow::SetShadowState(ShadowState aState
)
2103 if (mShadowState
!= aState
)
2105 mShadowState
= aState
;
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
;
2123 //////////////////////////////////////////////////////////////////////////////
2124 // helper class: Primitive for discrete visualisation
2126 class SwPostItAnkorPrimitive
: public drawinglayer::primitive2d::DiscreteMetricDependentPrimitive2D
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
;
2140 bool mbLineSolid
: 1;
2143 virtual drawinglayer::primitive2d::Primitive2DSequence
createLocalDecomposition(
2144 const drawinglayer::geometry::ViewInformation2D
& rViewInformation
) const;
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
,
2156 : drawinglayer::primitive2d::DiscreteMetricDependentPrimitive2D(),
2157 maTriangle(rTriangle
),
2159 maLineTop(rLineTop
),
2160 maAnkorState(aAnkorState
),
2162 mfLogicLineWidth(fLogicLineWidth
),
2164 mbLineSolid(bLineSolid
)
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())
2190 const drawinglayer::primitive2d::Primitive2DReference
aTriangle(
2191 new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(
2192 basegfx::B2DPolyPolygon(getTriangle()),
2195 drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(aRetval
, aTriangle
);
2198 if(AS_ALL
== getAnkorState() || AS_START
== getAnkorState())
2200 // create line start
2201 const drawinglayer::attribute::LineAttribute
aLineAttribute(
2203 getLogicLineWidth() / (basegfx::fTools::equalZero(getDiscreteUnit()) ? 1.0 : getDiscreteUnit()));
2207 const drawinglayer::primitive2d::Primitive2DReference
aSolidLine(
2208 new drawinglayer::primitive2d::PolygonStrokePrimitive2D(
2212 drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(aRetval
, aSolidLine
);
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(
2225 fDistance
+ fDashLen
);
2227 const drawinglayer::primitive2d::Primitive2DReference
aStrokedLine(
2228 new drawinglayer::primitive2d::PolygonStrokePrimitive2D(
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(
2262 aTransform
.set(0, 2, getDiscreteUnit());
2263 aTransform
.set(1, 2, getDiscreteUnit());
2265 aShadows
[1] = drawinglayer::primitive2d::Primitive2DReference(
2266 new drawinglayer::primitive2d::ShadowPrimitive2D(
2271 // add shadow before geometry to make it be proccessed first
2272 const drawinglayer::primitive2d::Primitive2DSequence
aTemporary(aRetval
);
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(
2284 getLogicLineWidth() / (basegfx::fTools::equalZero(getDiscreteUnit()) ? 1.0 : getDiscreteUnit()));
2286 const drawinglayer::primitive2d::Primitive2DReference
aLineTop(
2287 new drawinglayer::primitive2d::PolygonStrokePrimitive2D(
2291 drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(aRetval
, aLineTop
);
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());
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);
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()
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
,
2359 bool bShadowedEffect
,
2361 : OverlayObjectWithBasePosition(rBasePos
, aBaseColor
),
2362 maSecondPosition(rSecondPos
),
2363 maThirdPosition(rThirdPos
),
2364 maFourthPosition(rFourthPos
),
2365 maFifthPosition(rFifthPos
),
2366 maSixthPosition(rSixthPos
),
2367 maSeventhPosition(rSeventhPos
),
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(
2393 getBaseColor().getBColor(),
2394 ANKORLINE_WIDTH
* 15.0,
2395 getShadowedEffect(),
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();
2430 void SwPostItAnkor::SetSixthPosition(const basegfx::B2DPoint
& rNew
)
2432 if(rNew
!= maSixthPosition
)
2434 maSixthPosition
= rNew
;
2435 implResetGeometry();
2440 void SwPostItAnkor::SetSeventhPosition(const basegfx::B2DPoint
& rNew
)
2442 if(rNew
!= maSeventhPosition
)
2444 maSeventhPosition
= rNew
;
2445 implResetGeometry();
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();
2470 void SwPostItAnkor::setLineSolid(bool bNew
)
2472 if(bNew
!= getLineSolid())
2479 void SwPostItAnkor::SetAnkorState(AnkorState aState
)
2481 if (mAnkorState
!= aState
)
2483 mAnkorState
= aState
;