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.hxx,v $
11 * $Revision: 1.8.84.7 $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
35 #include <postithelper.hxx>
37 #include <vcl/window.hxx>
39 #include <svx/sdr/overlay/overlayobject.hxx>
41 #include <tools/datetime.hxx>
42 #include <tools/date.hxx>
44 #include <vcl/lineinfo.hxx>
45 #include <basegfx/polygon/b2dpolygon.hxx>
46 #include <svx/editstat.hxx>
60 class SvxLanguageItem
;
62 class OutlinerParaObject
;
64 #define ANKORLINE_WIDTH 1
66 enum AnkorState
{AS_ALL
, AS_START
, AS_END
,AS_TRI
};
68 class SwPostItAnkor
: public sdr::overlay::OverlayObjectWithBasePosition
77 basegfx::B2DPoint maSecondPosition
;
78 basegfx::B2DPoint maThirdPosition
;
79 basegfx::B2DPoint maFourthPosition
;
80 basegfx::B2DPoint maFifthPosition
;
81 basegfx::B2DPoint maSixthPosition
;
82 basegfx::B2DPoint maSeventhPosition
;
84 // helpers to fill and reset geometry
85 void implEnsureGeometry();
86 void implResetGeometry();
88 // helpers to paint geometry
89 void implDrawGeometry(OutputDevice
& rOutputDevice
, Color aColor
, double fOffX
, double fOffY
);
90 Color
implBlendColor(const Color aOriginal
, sal_Int16 nChange
);
92 virtual void drawGeometry(OutputDevice
& rOutputDevice
);
93 virtual void createBaseRange(OutputDevice
& rOutputDevice
);
97 basegfx::B2DPolygon maTriangle
;
98 basegfx::B2DPolygon maLine
;
99 basegfx::B2DPolygon maLineTop
;
101 unsigned long mHeight
;
102 bool mbShadowedEffect
;
103 AnkorState mAnkorState
;
106 SwPostItAnkor(const basegfx::B2DPoint
& rBasePos
,
107 const basegfx::B2DPoint
& rSecondPos
,
108 const basegfx::B2DPoint
& rThirdPos
,
109 const basegfx::B2DPoint
& rFourthPos
,
110 const basegfx::B2DPoint
& rFifthPos
,
111 const basegfx::B2DPoint
& rSixthPos
,
112 const basegfx::B2DPoint
& rSeventhPos
,
114 const LineInfo
&aLineInfo
,
115 bool bShadowedEffect
);
116 virtual ~SwPostItAnkor();
118 const basegfx::B2DPoint
& GetSecondPosition() const { return maSecondPosition
; }
119 const basegfx::B2DPoint
& GetThirdPosition() const { return maThirdPosition
; }
120 const basegfx::B2DPoint
& GetFourthPosition() const { return maFourthPosition
; }
121 const basegfx::B2DPoint
& GetFifthPosition() const { return maFifthPosition
; }
122 const basegfx::B2DPoint
& GetSixthPosition() const { return maSixthPosition
; }
123 const basegfx::B2DPoint
& GetSeventhPosition() const { return maSeventhPosition
; }
125 void SetAllPosition(const basegfx::B2DPoint
& rPoint1
, const basegfx::B2DPoint
& rPoint2
, const basegfx::B2DPoint
& rPoint3
,
126 const basegfx::B2DPoint
& rPoint4
, const basegfx::B2DPoint
& rPoint5
, const basegfx::B2DPoint
& rPoint6
, const basegfx::B2DPoint
& rPoint7
);
127 void SetTriPosition(const basegfx::B2DPoint
& rPoint1
,const basegfx::B2DPoint
& rPoint2
,const basegfx::B2DPoint
& rPoint3
,
128 const basegfx::B2DPoint
& rPoint4
,const basegfx::B2DPoint
& rPoint5
);
129 void SetSixthPosition(const basegfx::B2DPoint
& rNew
);
130 void SetSeventhPosition(const basegfx::B2DPoint
& rNew
);
132 void SetLineInfo(const LineInfo
&aLineInfo
);
134 void SetHeight(const unsigned long aHeight
) {mHeight
= aHeight
;};
136 bool getShadowedEffect() const { return mbShadowedEffect
; }
138 void SetAnkorState(AnkorState aState
);
139 AnkorState
GetAnkorState() const {return mAnkorState
;}
140 virtual void Trigger(sal_uInt32 nTime
);
142 //sal_Bool isHit(const basegfx::B2DPoint& rPos, double fTol) const;
143 // transform object coordinates. Transforms maBasePosition
144 // and invalidates on change
145 virtual void transform(const basegfx::B2DHomMatrix
& rMatrix
);
148 enum ShadowState
{SS_NORMAL
, SS_VIEW
, SS_EDIT
};
150 class SwPostItShadow
: public sdr::overlay::OverlayObjectWithBasePosition
153 virtual void drawGeometry(OutputDevice
& rOutputDevice
);
154 virtual void createBaseRange(OutputDevice
& rOutputDevice
);
157 basegfx::B2DPoint maSecondPosition
;
158 ShadowState mShadowState
;
161 SwPostItShadow(const basegfx::B2DPoint
& rBasePos
, const basegfx::B2DPoint
& rSecondPosition
, Color aBaseColor
,ShadowState aState
);
162 virtual ~SwPostItShadow();
164 void SetShadowState(ShadowState aState
);
165 ShadowState
GetShadowState() {return mShadowState
;}
167 const basegfx::B2DPoint
& GetSecondPosition() const { return maSecondPosition
; }
168 void SetSecondPosition(const basegfx::B2DPoint
& rNew
);
169 void SetPosition(const basegfx::B2DPoint
& rPoint1
,const basegfx::B2DPoint
& rPoint2
);
171 virtual void Trigger(sal_uInt32 nTime
);
172 virtual void transform(const basegfx::B2DHomMatrix
& rMatrix
);
175 class PostItTxt
: public Window
178 OutlinerView
* mpOutlinerView
;
179 SwMarginWin
* mpMarginWin
;
185 virtual void Paint( const Rectangle
& rRect
);
186 virtual void KeyInput( const KeyEvent
& rKeyEvt
);
187 virtual void MouseMove( const MouseEvent
& rMEvt
);
188 virtual void MouseButtonDown( const MouseEvent
& rMEvt
);
189 virtual void MouseButtonUp( const MouseEvent
& rMEvt
);
190 virtual void Command( const CommandEvent
& rCEvt
);
191 virtual void DataChanged( const DataChangedEvent
& aData
);
192 virtual void LoseFocus();
193 virtual void RequestHelp(const HelpEvent
&rEvt
);
195 // reconversion /*i94374*/
196 virtual XubString
GetSurroundingText() const;
197 virtual Selection
GetSurroundingTextSelection() const;
199 DECL_LINK( Select
, Menu
* );
202 PostItTxt(Window
* pParent
, WinBits nBits
);
205 virtual void GetFocus();
206 void SetTextView( OutlinerView
* aEditView
) { mpOutlinerView
= aEditView
; }
208 DECL_LINK( WindowEventListener
, VclSimpleEvent
* );
209 DECL_LINK( OnlineSpellCallback
, SpellCallbackInfo
*);
212 typedef sal_Int64 SwPostItBits
;
214 #define PB_Preview ((SwPostItBits)0x00000001)
217 class SwMarginWin
: public Window
222 sdr::overlay::OverlayManager
* pOverlayManager
;
223 OutlinerView
* mpOutlinerView
;
224 Outliner
* mpOutliner
;
225 PostItTxt
* mpPostItTxt
;
226 MultiLineEdit
* mpMeta
;
227 ScrollBar
* mpVScrollbar
;
228 SwPostItAnkor
* mpAnkor
;
229 SwPostItShadow
* mpShadow
;
235 basegfx::B2DPolygon aPopupTriangle
;
241 bool mbMouseOverButton
;
244 PopupMenu
* mpButtonPopup
;
246 Rectangle mRectMetaButton
;
247 virtual void DataChanged( const DataChangedEvent
& aEvent
);
248 virtual void LoseFocus();
249 virtual void MouseButtonDown( const MouseEvent
& rMEvt
);
250 virtual void MouseMove( const MouseEvent
& rMEvt
);
251 virtual void Paint( const Rectangle
& rRect
);
252 virtual void GetFocus();
254 void SetSizePixel( const Size
& rNewSize
);
256 DECL_LINK(ModifyHdl
, void*);
257 DECL_LINK(ScrollHdl
, ScrollBar
*);
258 DECL_LINK(DeleteHdl
, void*);
262 SwMarginWin( Window
* pParent
, WinBits nBits
, SwPostItMgr
* aMgr
,SwPostItBits aBits
);
263 virtual ~SwMarginWin();
265 void SetSize( const Size
& rNewSize
);
266 void SetPosSizePixelRect( long nX
, long nY
,long nWidth
, long nHeight
,const SwRect
&aRect
,const long PageBorder
);
267 void SetPosAndSize();
268 void TranslateTopPosition(const long aAmount
);
269 virtual void CheckMetaText();
271 PostItTxt
* PostItText() { return mpPostItTxt
;}
272 ScrollBar
* Scrollbar() { return mpVScrollbar
;}
273 SwPostItAnkor
* Ankor() { return mpAnkor
;}
274 SwPostItShadow
* Shadow() { return mpShadow
;}
275 OutlinerView
* View() { return mpOutlinerView
;}
276 SwView
* DocView() { return mpView
;}
277 Outliner
* Engine() { return mpOutliner
;}
278 SwPostItMgr
* Mgr() { return mpMgr
; }
280 SwRect
GetAnkorRect() { return mAnkorRect
; }
281 SwEditWin
* EditWin();
283 long GetPostItTextHeight();
285 void SwitchToPostIt(USHORT aDirection
);
286 //void SwitchToPostIt(bool aDirection);
287 virtual void SwitchToFieldPos();
288 virtual sal_uInt32
MoveCaret() { return 0;};
290 virtual void UpdateData() = 0;
291 virtual void SetPostItText() = 0;
292 virtual void Delete();
293 virtual void GotoPos() = 0;
294 virtual void SetPopup() = 0;
296 virtual String
GetAuthor();
297 virtual Date
GetDate();
298 virtual Time
GetTime();
300 void ExecuteCommand(USHORT nSlot
);
304 void ResizeIfNeccessary(long aOldHeight
, long aNewHeight
);
307 void SetVirtualPosSize( const Point
& aPoint
, const Size
& aSize
);
308 const Point
VirtualPos() { return mPosSize
.TopLeft(); }
309 const Size
VirtualSize() { return mPosSize
.GetSize(); }
311 void ShowAnkorOnly(const Point
&aPoint
);
315 void ResetAttributes();
317 void SetMarginSide(bool aMarginSide
);
318 void SetReadonly(BOOL bSet
);
319 BOOL
IsReadOnly() { return mbReadonly
;}
320 bool IsPreview() { return nFlags
& PB_Preview
;}
322 void SetLanguage(const SvxLanguageItem aNewItem
);
323 virtual SvxLanguageItem
GetLanguage(void);
325 void SetColor(Color aColorDark
,Color aColorLight
, Color aColorAnkor
);
326 Color
ColorDark() { return mColorDark
; }
327 Color
ColorLight() { return mColorLight
; }
330 void SetViewState(ShadowState bState
);
332 bool IsFollow() { return mbIsFollow
; }
333 void SetFollow( bool bIsFollow
) { mbIsFollow
= bIsFollow
;};
334 virtual bool CalcFollow();
336 SwMarginWin
* GetTopReplyNote();
337 bool IsAnyStackParentVisible();
339 sal_Int32
GetMetaHeight();
340 sal_Int32
GetMinimumSizeWithMeta();
341 sal_Int32
GetMinimumSizeWithoutMeta();
342 sal_Int32
GetMetaButtonAreaWidth();
343 sal_Int32
GetScrollbarWidth();
345 void SetSpellChecking();
347 void ToggleInsMode();
349 virtual void ActivatePostIt();
350 virtual void DeactivatePostIt();
352 virtual SwPostItHelper::SwLayoutStatus
GetStatus() { return SwPostItHelper::NONE
; }
354 virtual bool IsProtected() {return mbReadonly
;};
357 // implementation for change tracking comments, fully functional, but not yet used
359 class SwRedComment : public SwMarginWin
365 virtual void MouseButtonDown( const MouseEvent& rMEvt );
368 SwRedComment( Window* pParent, WinBits nBits,SwPostItMgr* aMgr,SwPostItBits aBits,SwRedline* pRed);
369 virtual ~SwRedComment() {};
371 virtual void UpdateData();
372 virtual void SetPostItText();
373 virtual void Delete();
374 virtual void GotoPos();
375 virtual void SetPopup();
376 virtual void ActivatePostIt();
377 virtual void DeactivatePostIt();
379 virtual String GetAuthor();
380 virtual Date GetDate();
381 virtual Time GetTime();
383 virtual bool IsProtected();
386 class SwPostIt
: public SwMarginWin
390 SwPostItField
* mpFld
;
391 SwPostItHelper::SwLayoutStatus mStatus
;
395 virtual void MouseButtonDown( const MouseEvent
& rMEvt
);
399 SwPostIt( Window
* pParent
, WinBits nBits
,SwFmtFld
* aField
,SwPostItMgr
* aMgr
,SwPostItBits aBits
);
400 virtual ~SwPostIt() {};
402 virtual void UpdateData();
403 virtual void SetPostItText();
404 virtual void Delete();
405 virtual void GotoPos();
406 virtual void SetPopup();
408 virtual String
GetAuthor();
409 virtual Date
GetDate();
410 virtual Time
GetTime();
412 virtual sal_uInt32
MoveCaret();
414 void SetChangeTracking(SwPostItHelper::SwLayoutStatus
& aStatus
,Color aColor
);
415 virtual SwPostItHelper::SwLayoutStatus
GetStatus() { return mStatus
; }
416 Color
GetChangeColor() { return mChangeColor
; }
418 sal_uInt32
CountFollowing();
419 virtual bool CalcFollow();
420 void InitAnswer(OutlinerParaObject
* pText
);
422 virtual SvxLanguageItem
GetLanguage(void);
424 virtual bool IsProtected();