xref: /AOO41X/main/sw/inc/SidebarWin.hxx (revision 54628ca40d27d15cc98fe861da7fff7e60c2f7d6)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _SIDEBARWIN_HXX
25 #define _SIDEBARWIN_HXX
26 
27 #include <postithelper.hxx>
28 #include <SidebarWindowsTypes.hxx>
29 
30 #include <vcl/window.hxx>
31 #include <swrect.hxx>
32 
33 #include <tools/datetime.hxx>
34 #include <tools/date.hxx>
35 
36 #include <vcl/lineinfo.hxx>
37 #include <basegfx/polygon/b2dpolygon.hxx>
38 #include <editeng/editstat.hxx>
39 
40 class SwPostItMgr;
41 class SwPostItField;
42 class OutlinerView;
43 class Outliner;
44 class ScrollBar;
45 class SwEditWin;
46 class SwView;
47 class Edit;
48 class MenuButton;
49 //class SwRedline;
50 class SwFrm;
51 
52 
53 namespace sw { namespace sidebarwindows {
54 
55 class SidebarTxtControl;
56 class AnchorOverlayObject;
57 class ShadowOverlayObject;
58 
59 typedef sal_Int64 SwPostItBits;
60 
61 #define PB_Preview ((SwPostItBits)0x00000001)
62 
63 
64 class SwSidebarWin : public Window
65 {
66     public:
67         SwSidebarWin( SwEditWin& rEditWin,
68                       WinBits nBits,
69                       SwPostItMgr& aMgr,
70                       SwPostItBits aBits,
71                       SwSidebarItem& rSidebarItem );
72         virtual ~SwSidebarWin();
73 
74         void SetSize( const Size& rNewSize );
75         void SetPosSizePixelRect( long nX,
76                                   long nY,
77                                   long nWidth,
78                                   long nHeight,
79                                   const SwRect &aRect,
80                                   const long PageBorder);
81         void SetPosAndSize();
82         void TranslateTopPosition(const long aAmount);
83         virtual void CheckMetaText();
84 
85         inline Point GetAnchorPos() { return mAnchorRect.Pos(); }
86         SwEditWin* EditWin();
87 
88         inline OutlinerView* GetOutlinerView() { return mpOutlinerView;}
89         bool HasScrollbar() const;
90         bool IsScrollbarVisible() const;
91         inline ScrollBar* Scrollbar() { return mpVScrollbar; }
92         inline ::sw::sidebarwindows::AnchorOverlayObject* Anchor() { return mpAnchor;}
93         inline ::sw::sidebarwindows::ShadowOverlayObject* Shadow() { return mpShadow;}
94 
95         long            GetPostItTextHeight();
96 
97         void            SwitchToPostIt(sal_uInt16 aDirection);
98         virtual void    SwitchToFieldPos();
99 
100         virtual sal_uInt32 MoveCaret() = 0;
101 
102         virtual void    UpdateData() = 0;
103         virtual void    SetPostItText() = 0;
104         virtual void    Delete();
105         virtual void    GotoPos() = 0;
106 
107         virtual String  GetAuthor() = 0;
108         virtual Date    GetDate() = 0;
109         virtual Time    GetTime() = 0;
110 
111         void            ExecuteCommand(sal_uInt16 nSlot);
112         void            InitControls();
113         void            HidePostIt();
114         void            DoResize();
115         void            ResizeIfNeccessary(long aOldHeight, long aNewHeight);
116         void            SetScrollbar();
117 
118         void            SetVirtualPosSize( const Point& aPoint, const Size& aSize);
119         const Point     VirtualPos()    { return mPosSize.TopLeft(); }
120         const Size      VirtualSize()   { return mPosSize.GetSize(); }
121 
122         void            ShowAnchorOnly(const Point &aPoint);
123         void            ShowNote();
124         void            HideNote();
125 
126         void            ResetAttributes();
127 
128         void            SetSidebarPosition(sw::sidebarwindows::SidebarPosition eSidebarPosition);
129         void            SetReadonly(sal_Bool bSet);
130         sal_Bool            IsReadOnly()        { return mbReadonly;}
131         bool            IsPreview()         { return nFlags & PB_Preview;}
132 
133         void            SetColor(Color aColorDark,Color aColorLight, Color aColorAnchor);
134         const Color& ColorAnchor() { return mColorAnchor; }
135         const Color& ColorDark() { return mColorDark; }
136         const Color& ColorLight() { return mColorLight; }
137         void            Rescale();
138 
139         void            SetViewState(::sw::sidebarwindows::ViewState bViewState);
140 
141         bool            IsFollow() { return mbIsFollow; }
142         void            SetFollow( bool bIsFollow) { mbIsFollow = bIsFollow; };
143         virtual bool    CalcFollow() = 0;
144 
145 #if 0
146 #endif
147 
148         sal_Int32       GetMetaHeight();
149         sal_Int32       GetMinimumSizeWithMeta();
150         sal_Int32       GetMinimumSizeWithoutMeta();
151         sal_Int32       GetMetaButtonAreaWidth();
152         sal_Int32       GetScrollbarWidth();
153 
154         void            SetSpellChecking();
155 
156         void            ToggleInsMode();
157 
158         virtual void    ActivatePostIt();
159         virtual void    DeactivatePostIt();
160 
161         void SetChangeTracking( const SwPostItHelper::SwLayoutStatus aStatus,
162                                 const Color& aColor);
163         SwPostItHelper::SwLayoutStatus GetLayoutStatus() { return mLayoutStatus; }
164         Color GetChangeColor() { return mChangeColor; }
165 
166         virtual bool    IsProtected() {return mbReadonly;};
167 
168         DECL_LINK( WindowEventListener, VclSimpleEvent* );
169         inline bool IsMouseOverSidebarWin() const { return mbMouseOver; }
170 
171         void SetLanguage(const SvxLanguageItem aNewItem);
172 
173         void ChangeSidebarItem( SwSidebarItem& rSidebarItem );
174         virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
175 
176     protected:
177         virtual void    DataChanged( const DataChangedEvent& aEvent);
178         virtual void    LoseFocus();
179         virtual void    Paint( const Rectangle& rRect);
180         virtual void    GetFocus();
181         virtual MenuButton* CreateMenuButton() = 0;
182 
183         void        SetSizePixel( const Size& rNewSize );
184         SfxItemSet  DefaultItem();
185 
186         DECL_LINK(ModifyHdl, void*);
187         DECL_LINK(ScrollHdl, ScrollBar*);
188         DECL_LINK(DeleteHdl, void*);
189 
190         inline SwView& DocView() { return mrView;}
191         inline SwPostItMgr& Mgr() { return mrMgr; }
192         inline Outliner* Engine() { return mpOutliner;}
193 
194     private:
195         SwSidebarWin*   GetTopReplyNote();
196 
197         virtual SvxLanguageItem GetLanguage(void);
198 
199         SwPostItMgr&    mrMgr;
200         SwView&         mrView;
201         const SwPostItBits nFlags;
202 
203         sal_uLong           mnEventId;
204 
205         OutlinerView*   mpOutlinerView;
206         Outliner*       mpOutliner;
207 
208         sw::sidebarwindows::SidebarTxtControl* mpSidebarTxtControl;
209         ScrollBar*      mpVScrollbar;
210         Edit*           mpMetadataAuthor;
211         Edit*           mpMetadataDate;
212         MenuButton*     mpMenuButton;
213 
214         sw::sidebarwindows::AnchorOverlayObject* mpAnchor;
215         sw::sidebarwindows::ShadowOverlayObject* mpShadow;
216 
217         Color           mColorAnchor;
218         Color           mColorDark;
219         Color           mColorLight;
220         Color           mChangeColor;
221 
222         sw::sidebarwindows::SidebarPosition meSidebarPosition;
223 
224         Rectangle       mPosSize;
225         SwRect          mAnchorRect;
226         long            mPageBorder;
227 
228         bool            mbMouseOver;
229         SwPostItHelper::SwLayoutStatus mLayoutStatus;
230 
231         bool            mbReadonly;
232         bool            mbIsFollow;
233 
234         SwSidebarItem& mrSidebarItem;
235         const SwFrm* mpAnchorFrm;
236 };
237 
238 } } // eof namespace sw::sidebarwindows
239 
240 
241 // implementation for change tracking comments, fully functional, but not yet used
242 /*
243 class SwRedComment : public SwSidebarWin
244 {
245     private:
246         SwRedline*      pRedline;
247 
248     protected:
249         virtual void    MouseButtonDown( const MouseEvent& rMEvt );
250     public:
251         SwRedComment( Window* pParent, WinBits nBits,SwPostItMgr* aMgr,SwPostItBits aBits,SwRedline* pRed);
252         virtual ~SwRedComment() {};
253 
254         virtual void    UpdateData();
255         virtual void    SetPostItText();
256         virtual void    Delete();
257         virtual void    GotoPos();
258         virtual void    SetPopup();
259         virtual void    ActivatePostIt();
260         virtual void    DeactivatePostIt();
261 
262         virtual String  GetAuthor();
263         virtual Date    GetDate();
264         virtual Time    GetTime();
265 
266         virtual bool    IsProtected();
267 };
268 */
269 
270 #endif
271