update dev300-m57
[ooovba.git] / sw / inc / postit.hxx
blob37584791c76f8de40a01eb4b5bc1cbcc5ec26c62
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 ************************************************************************/
32 #ifndef _POSTIT_HXX
33 #define _POSTIT_HXX
35 #include <postithelper.hxx>
37 #include <vcl/window.hxx>
38 #include <swrect.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>
48 class SwPostItMgr;
49 class SwPostItField;
50 class SwFmtFld;
51 class OutlinerView;
52 class Outliner;
53 class ScrollBar;
54 class SwEditWin;
55 class SwView;
56 class SwPostIt;
57 class Edit;
58 class MultiLineEdit;
59 class PopupMenu;
60 class SvxLanguageItem;
61 class SwRedline;
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
70 protected:
71 /* 6------------7
72 1 /
73 /4\ ---------------5
74 2 - 3
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 // geometry creation for OverlayObject
89 virtual drawinglayer::primitive2d::Primitive2DSequence createOverlayObjectPrimitive2DSequence();
91 private:
92 // object's geometry
93 basegfx::B2DPolygon maTriangle;
94 basegfx::B2DPolygon maLine;
95 basegfx::B2DPolygon maLineTop;
96 unsigned long mHeight;
97 AnkorState mAnkorState;
99 // bitfield
100 unsigned mbShadowedEffect : 1;
101 unsigned mbLineSolid : 1;
103 public:
104 SwPostItAnkor(const basegfx::B2DPoint& rBasePos,
105 const basegfx::B2DPoint& rSecondPos,
106 const basegfx::B2DPoint& rThirdPos,
107 const basegfx::B2DPoint& rFourthPos,
108 const basegfx::B2DPoint& rFifthPos,
109 const basegfx::B2DPoint& rSixthPos,
110 const basegfx::B2DPoint& rSeventhPos,
111 Color aBaseColor,
112 bool bShadowedEffect,
113 bool bLineSolid);
114 virtual ~SwPostItAnkor();
116 const basegfx::B2DPoint& GetSecondPosition() const { return maSecondPosition; }
117 const basegfx::B2DPoint& GetThirdPosition() const { return maThirdPosition; }
118 const basegfx::B2DPoint& GetFourthPosition() const { return maFourthPosition; }
119 const basegfx::B2DPoint& GetFifthPosition() const { return maFifthPosition; }
120 const basegfx::B2DPoint& GetSixthPosition() const { return maSixthPosition; }
121 const basegfx::B2DPoint& GetSeventhPosition() const { return maSeventhPosition; }
123 void SetAllPosition(const basegfx::B2DPoint& rPoint1, const basegfx::B2DPoint& rPoint2, const basegfx::B2DPoint& rPoint3,
124 const basegfx::B2DPoint& rPoint4, const basegfx::B2DPoint& rPoint5, const basegfx::B2DPoint& rPoint6, const basegfx::B2DPoint& rPoint7);
125 void SetTriPosition(const basegfx::B2DPoint& rPoint1,const basegfx::B2DPoint& rPoint2,const basegfx::B2DPoint& rPoint3,
126 const basegfx::B2DPoint& rPoint4,const basegfx::B2DPoint& rPoint5);
127 void SetSixthPosition(const basegfx::B2DPoint& rNew);
128 void SetSeventhPosition(const basegfx::B2DPoint& rNew);
130 bool getLineSolid() const { return mbLineSolid; }
131 void setLineSolid(bool bNew);
133 void SetHeight(const unsigned long aHeight) {mHeight = aHeight;};
135 bool getShadowedEffect() const { return mbShadowedEffect; }
137 void SetAnkorState(AnkorState aState);
138 AnkorState GetAnkorState() const {return mAnkorState;}
141 enum ShadowState {SS_NORMAL, SS_VIEW, SS_EDIT};
143 class SwPostItShadow: public sdr::overlay::OverlayObjectWithBasePosition
145 protected:
146 // geometry creation for OverlayObject
147 virtual drawinglayer::primitive2d::Primitive2DSequence createOverlayObjectPrimitive2DSequence();
149 private:
150 basegfx::B2DPoint maSecondPosition;
151 ShadowState mShadowState;
153 public:
154 SwPostItShadow(const basegfx::B2DPoint& rBasePos, const basegfx::B2DPoint& rSecondPosition, Color aBaseColor,ShadowState aState);
155 virtual ~SwPostItShadow();
157 void SetShadowState(ShadowState aState);
158 ShadowState GetShadowState() {return mShadowState;}
160 const basegfx::B2DPoint& GetSecondPosition() const { return maSecondPosition; }
161 void SetSecondPosition(const basegfx::B2DPoint& rNew);
162 void SetPosition(const basegfx::B2DPoint& rPoint1,const basegfx::B2DPoint& rPoint2);
165 class PostItTxt : public Window
167 private:
168 OutlinerView* mpOutlinerView;
169 SwMarginWin* mpMarginWin;
171 bool mMouseOver;
172 BOOL mbShowPopup;
174 protected:
175 virtual void Paint( const Rectangle& rRect);
176 virtual void KeyInput( const KeyEvent& rKeyEvt );
177 virtual void MouseMove( const MouseEvent& rMEvt );
178 virtual void MouseButtonDown( const MouseEvent& rMEvt );
179 virtual void MouseButtonUp( const MouseEvent& rMEvt );
180 virtual void Command( const CommandEvent& rCEvt );
181 virtual void DataChanged( const DataChangedEvent& aData);
182 virtual void LoseFocus();
183 virtual void RequestHelp(const HelpEvent &rEvt);
185 // reconversion /*i94374*/
186 virtual XubString GetSurroundingText() const;
187 virtual Selection GetSurroundingTextSelection() const;
189 DECL_LINK( Select, Menu* );
191 public:
192 PostItTxt(Window* pParent, WinBits nBits);
193 ~PostItTxt();
195 virtual void GetFocus();
196 void SetTextView( OutlinerView* aEditView ) { mpOutlinerView = aEditView; }
198 DECL_LINK( WindowEventListener, VclSimpleEvent* );
199 DECL_LINK( OnlineSpellCallback, SpellCallbackInfo*);
202 typedef sal_Int64 SwPostItBits;
204 #define PB_Preview ((SwPostItBits)0x00000001)
207 class SwMarginWin : public Window
209 private:
210 ULONG mnEventId;
211 SwView* mpView;
212 sdr::overlay::OverlayManager* pOverlayManager;
213 OutlinerView* mpOutlinerView;
214 Outliner* mpOutliner;
215 PostItTxt* mpPostItTxt;
216 MultiLineEdit* mpMeta;
217 ScrollBar* mpVScrollbar;
218 SwPostItAnkor* mpAnkor;
219 SwPostItShadow* mpShadow;
220 SwPostItMgr* mpMgr;
221 bool mbMeta;
222 Color mColorAnkor;
223 Color mColorDark;
224 Color mColorLight;
225 basegfx::B2DPolygon aPopupTriangle;
226 bool mbMarginSide;
227 Rectangle mPosSize;
228 SwRect mAnkorRect;
229 long mPageBorder;
230 SwPostItBits nFlags;
231 bool mbMouseOverButton;
232 protected:
233 bool mbReadonly;
234 PopupMenu* mpButtonPopup;
235 bool mbIsFollow;
236 Rectangle mRectMetaButton;
237 virtual void DataChanged( const DataChangedEvent& aEvent);
238 virtual void LoseFocus();
239 virtual void MouseButtonDown( const MouseEvent& rMEvt );
240 virtual void MouseMove( const MouseEvent& rMEvt );
241 virtual void Paint( const Rectangle& rRect);
242 virtual void GetFocus();
244 void SetSizePixel( const Size& rNewSize );
246 DECL_LINK(ModifyHdl, void*);
247 DECL_LINK(ScrollHdl, ScrollBar*);
248 DECL_LINK(DeleteHdl, void*);
250 public:
251 TYPEINFO();
252 SwMarginWin( Window* pParent, WinBits nBits, SwPostItMgr* aMgr,SwPostItBits aBits);
253 virtual ~SwMarginWin();
255 void SetSize( const Size& rNewSize );
256 void SetPosSizePixelRect( long nX, long nY,long nWidth, long nHeight,const SwRect &aRect,const long PageBorder);
257 void SetPosAndSize();
258 void TranslateTopPosition(const long aAmount);
259 virtual void CheckMetaText();
261 PostItTxt* PostItText() { return mpPostItTxt;}
262 ScrollBar* Scrollbar() { return mpVScrollbar;}
263 SwPostItAnkor* Ankor() { return mpAnkor;}
264 SwPostItShadow* Shadow() { return mpShadow;}
265 OutlinerView* View() { return mpOutlinerView;}
266 SwView* DocView() { return mpView;}
267 Outliner* Engine() { return mpOutliner;}
268 SwPostItMgr* Mgr() { return mpMgr; }
270 SwRect GetAnkorRect() { return mAnkorRect; }
271 SwEditWin* EditWin();
273 long GetPostItTextHeight();
275 void SwitchToPostIt(USHORT aDirection);
276 //void SwitchToPostIt(bool aDirection);
277 virtual void SwitchToFieldPos();
278 virtual sal_uInt32 MoveCaret() { return 0;};
280 virtual void UpdateData() = 0;
281 virtual void SetPostItText() = 0;
282 virtual void Delete();
283 virtual void GotoPos() = 0;
284 virtual void SetPopup() = 0;
286 virtual String GetAuthor();
287 virtual Date GetDate();
288 virtual Time GetTime();
290 void ExecuteCommand(USHORT nSlot);
291 void InitControls();
292 void HidePostIt();
293 void DoResize();
294 void ResizeIfNeccessary(long aOldHeight, long aNewHeight);
295 void SetScrollbar();
297 void SetVirtualPosSize( const Point& aPoint, const Size& aSize);
298 const Point VirtualPos() { return mPosSize.TopLeft(); }
299 const Size VirtualSize() { return mPosSize.GetSize(); }
301 void ShowAnkorOnly(const Point &aPoint);
302 void ShowNote();
303 void HideNote();
305 void ResetAttributes();
307 void SetMarginSide(bool aMarginSide);
308 void SetReadonly(BOOL bSet);
309 BOOL IsReadOnly() { return mbReadonly;}
310 bool IsPreview() { return nFlags & PB_Preview;}
312 void SetLanguage(const SvxLanguageItem aNewItem);
313 virtual SvxLanguageItem GetLanguage(void);
315 void SetColor(Color aColorDark,Color aColorLight, Color aColorAnkor);
316 Color ColorDark() { return mColorDark; }
317 Color ColorLight() { return mColorLight; }
318 void Rescale();
320 void SetViewState(ShadowState bState);
322 bool IsFollow() { return mbIsFollow; }
323 void SetFollow( bool bIsFollow) { mbIsFollow = bIsFollow;};
324 virtual bool CalcFollow();
326 SwMarginWin* GetTopReplyNote();
327 bool IsAnyStackParentVisible();
329 sal_Int32 GetMetaHeight();
330 sal_Int32 GetMinimumSizeWithMeta();
331 sal_Int32 GetMinimumSizeWithoutMeta();
332 sal_Int32 GetMetaButtonAreaWidth();
333 sal_Int32 GetScrollbarWidth();
335 void SetSpellChecking();
337 void ToggleInsMode();
339 virtual void ActivatePostIt();
340 virtual void DeactivatePostIt();
342 virtual SwPostItHelper::SwLayoutStatus GetStatus() { return SwPostItHelper::NONE; }
344 virtual bool IsProtected() {return mbReadonly;};
347 // implementation for change tracking comments, fully functional, but not yet used
349 class SwRedComment : public SwMarginWin
351 private:
352 SwRedline* pRedline;
354 protected:
355 virtual void MouseButtonDown( const MouseEvent& rMEvt );
356 public:
357 TYPEINFO();
358 SwRedComment( Window* pParent, WinBits nBits,SwPostItMgr* aMgr,SwPostItBits aBits,SwRedline* pRed);
359 virtual ~SwRedComment() {};
361 virtual void UpdateData();
362 virtual void SetPostItText();
363 virtual void Delete();
364 virtual void GotoPos();
365 virtual void SetPopup();
366 virtual void ActivatePostIt();
367 virtual void DeactivatePostIt();
369 virtual String GetAuthor();
370 virtual Date GetDate();
371 virtual Time GetTime();
373 virtual bool IsProtected();
376 class SwPostIt : public SwMarginWin
378 private:
379 SwFmtFld* mpFmtFld;
380 SwPostItField* mpFld;
381 SwPostItHelper::SwLayoutStatus mStatus;
382 Color mChangeColor;
384 protected:
385 virtual void MouseButtonDown( const MouseEvent& rMEvt );
387 public:
388 TYPEINFO();
389 SwPostIt( Window* pParent, WinBits nBits,SwFmtFld* aField,SwPostItMgr* aMgr,SwPostItBits aBits);
390 virtual ~SwPostIt() {};
392 virtual void UpdateData();
393 virtual void SetPostItText();
394 virtual void Delete();
395 virtual void GotoPos();
396 virtual void SetPopup();
398 virtual String GetAuthor();
399 virtual Date GetDate();
400 virtual Time GetTime();
402 virtual sal_uInt32 MoveCaret();
404 void SetChangeTracking(SwPostItHelper::SwLayoutStatus& aStatus,Color aColor);
405 virtual SwPostItHelper::SwLayoutStatus GetStatus() { return mStatus; }
406 Color GetChangeColor() { return mChangeColor; }
408 sal_uInt32 CountFollowing();
409 virtual bool CalcFollow();
410 void InitAnswer(OutlinerParaObject* pText);
412 virtual SvxLanguageItem GetLanguage(void);
414 virtual bool IsProtected();
417 #endif