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 SwFrm; 50 51 namespace sw { namespace overlay { 52 class OverlayRanges; 53 }} 54 55 namespace sw { namespace sidebarwindows { 56 57 class SidebarTxtControl; 58 class AnchorOverlayObject; 59 class ShadowOverlayObject; 60 61 typedef sal_Int64 SwPostItBits; 62 63 #define PB_Preview ((SwPostItBits)0x00000001) 64 65 66 class SwSidebarWin : public Window 67 { 68 public: 69 SwSidebarWin( SwEditWin& rEditWin, 70 WinBits nBits, 71 SwPostItMgr& aMgr, 72 SwPostItBits aBits, 73 SwSidebarItem& rSidebarItem ); 74 virtual ~SwSidebarWin(); 75 76 void SetSize( const Size& rNewSize ); 77 void SetPosSizePixelRect( long nX, 78 long nY, 79 long nWidth, 80 long nHeight, 81 const SwRect& aAnchorRect, 82 const long PageBorder); 83 void SetPosAndSize(); 84 void TranslateTopPosition(const long aAmount); 85 virtual void CheckMetaText(); 86 GetAnchorPos()87 inline Point GetAnchorPos() { return mAnchorRect.Pos(); } 88 SwEditWin* EditWin(); 89 GetOutlinerView()90 inline OutlinerView* GetOutlinerView() { return mpOutlinerView;} 91 bool HasScrollbar() const; 92 bool IsScrollbarVisible() const; Scrollbar()93 inline ScrollBar* Scrollbar() { return mpVScrollbar; } Anchor()94 inline ::sw::sidebarwindows::AnchorOverlayObject* Anchor() { return mpAnchor;} Shadow()95 inline ::sw::sidebarwindows::ShadowOverlayObject* Shadow() { return mpShadow;} TextRange()96 inline ::sw::overlay::OverlayRanges* TextRange() { return mpTextRangeOverlay;} 97 98 long GetPostItTextHeight(); 99 100 void SwitchToPostIt(sal_uInt16 aDirection); 101 virtual void SwitchToFieldPos(); 102 103 virtual sal_uInt32 MoveCaret() = 0; 104 105 virtual void UpdateData() = 0; 106 virtual void SetPostItText() = 0; 107 virtual void Delete(); 108 virtual void GotoPos() = 0; 109 110 virtual String GetAuthor() = 0; 111 virtual Date GetDate() = 0; 112 virtual Time GetTime() = 0; 113 114 void ExecuteCommand(sal_uInt16 nSlot); 115 void InitControls(); 116 void HidePostIt(); 117 void DoResize(); 118 void ResizeIfNeccessary(long aOldHeight, long aNewHeight); 119 void SetScrollbar(); 120 121 void SetVirtualPosSize( const Point& aPoint, const Size& aSize); VirtualPos()122 const Point VirtualPos() { return mPosSize.TopLeft(); } VirtualSize()123 const Size VirtualSize() { return mPosSize.GetSize(); } 124 125 void ShowAnchorOnly(const Point &aPoint); 126 void ShowNote(); 127 void HideNote(); 128 129 void ResetAttributes(); 130 131 void SetSidebarPosition(sw::sidebarwindows::SidebarPosition eSidebarPosition); 132 void SetReadonly(sal_Bool bSet); IsReadOnly()133 sal_Bool IsReadOnly() 134 { 135 return mbReadonly; 136 } IsPreview()137 bool IsPreview() 138 { 139 return nFlags & PB_Preview; 140 } 141 142 void SetColor(Color aColorDark,Color aColorLight, Color aColorAnchor); ColorAnchor()143 const Color& ColorAnchor() { return mColorAnchor; } ColorDark()144 const Color& ColorDark() { return mColorDark; } ColorLight()145 const Color& ColorLight() { return mColorLight; } 146 void Rescale(); 147 148 void SetViewState(::sw::sidebarwindows::ViewState bViewState); 149 IsFollow()150 bool IsFollow() { return mbIsFollow; } SetFollow(bool bIsFollow)151 void SetFollow( bool bIsFollow) { mbIsFollow = bIsFollow; }; 152 virtual bool CalcFollow() = 0; 153 154 sal_Int32 GetMetaHeight(); 155 sal_Int32 GetMinimumSizeWithMeta(); 156 sal_Int32 GetMinimumSizeWithoutMeta(); 157 sal_Int32 GetMetaButtonAreaWidth(); 158 sal_Int32 GetScrollbarWidth(); 159 160 void SetSpellChecking(); 161 162 void ToggleInsMode(); 163 164 virtual void ActivatePostIt(); 165 virtual void DeactivatePostIt(); 166 167 void SetChangeTracking( const SwPostItHelper::SwLayoutStatus aStatus, 168 const Color& aColor); GetLayoutStatus()169 SwPostItHelper::SwLayoutStatus GetLayoutStatus() { return mLayoutStatus; } GetChangeColor()170 Color GetChangeColor() { return mChangeColor; } 171 IsProtected()172 virtual bool IsProtected() 173 { 174 return mbReadonly; 175 } 176 177 DECL_LINK( WindowEventListener, VclSimpleEvent* ); IsMouseOverSidebarWin() const178 inline bool IsMouseOverSidebarWin() const { return mbMouseOver; } 179 180 void SetLanguage(const SvxLanguageItem aNewItem); 181 182 void ChangeSidebarItem( SwSidebarItem& rSidebarItem ); 183 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible(); 184 185 protected: 186 virtual void DataChanged( const DataChangedEvent& aEvent); 187 virtual void LoseFocus(); 188 virtual void Paint( const Rectangle& rRect); 189 virtual void GetFocus(); 190 virtual MenuButton* CreateMenuButton() = 0; 191 192 void SetSizePixel( const Size& rNewSize ); 193 SfxItemSet DefaultItem(); 194 195 DECL_LINK(ModifyHdl, void*); 196 DECL_LINK(ScrollHdl, ScrollBar*); 197 DECL_LINK(DeleteHdl, void*); 198 DocView()199 inline SwView& DocView() { return mrView;} Mgr()200 inline SwPostItMgr& Mgr() { return mrMgr; } Engine()201 inline Outliner* Engine() { return mpOutliner;} 202 203 private: 204 SwSidebarWin* GetTopReplyNote(); 205 206 virtual SvxLanguageItem GetLanguage(void); 207 208 SwPostItMgr& mrMgr; 209 SwView& mrView; 210 const SwPostItBits nFlags; 211 212 sal_uLong mnEventId; 213 214 OutlinerView* mpOutlinerView; 215 Outliner* mpOutliner; 216 217 sw::sidebarwindows::SidebarTxtControl* mpSidebarTxtControl; 218 ScrollBar* mpVScrollbar; 219 Edit* mpMetadataAuthor; 220 Edit* mpMetadataDate; 221 MenuButton* mpMenuButton; 222 223 sw::sidebarwindows::AnchorOverlayObject* mpAnchor; 224 sw::sidebarwindows::ShadowOverlayObject* mpShadow; 225 sw::overlay::OverlayRanges* mpTextRangeOverlay; 226 227 Color mColorAnchor; 228 Color mColorDark; 229 Color mColorLight; 230 Color mChangeColor; 231 232 sw::sidebarwindows::SidebarPosition meSidebarPosition; 233 234 Rectangle mPosSize; 235 SwRect mAnchorRect; 236 long mPageBorder; 237 238 bool mbMouseOver; 239 SwPostItHelper::SwLayoutStatus mLayoutStatus; 240 241 bool mbReadonly; 242 bool mbIsFollow; 243 244 SwSidebarItem& mrSidebarItem; 245 const SwFrm* mpAnchorFrm; 246 }; 247 248 } } // eof namespace sw::sidebarwindows 249 250 251 // implementation for change tracking comments, fully functional, but not yet used 252 /* 253 class SwRedComment : public SwSidebarWin 254 { 255 private: 256 SwRedline* pRedline; 257 258 protected: 259 virtual void MouseButtonDown( const MouseEvent& rMEvt ); 260 public: 261 SwRedComment( Window* pParent, WinBits nBits,SwPostItMgr* aMgr,SwPostItBits aBits,SwRedline* pRed); 262 virtual ~SwRedComment() {}; 263 264 virtual void UpdateData(); 265 virtual void SetPostItText(); 266 virtual void Delete(); 267 virtual void GotoPos(); 268 virtual void SetPopup(); 269 virtual void ActivatePostIt(); 270 virtual void DeactivatePostIt(); 271 272 virtual String GetAuthor(); 273 virtual Date GetDate(); 274 virtual Time GetTime(); 275 276 virtual bool IsProtected(); 277 }; 278 */ 279 280 #endif 281