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 #ifndef _POSTITHELPER_HXX 24 #define _POSTITHELPER_HXX 25 26 #include <swrect.hxx> 27 #include <fmtfld.hxx> 28 #include <redline.hxx> 29 #include <vector> 30 #include <vcl/window.hxx> 31 #include <SidebarWindowsTypes.hxx> 32 #include <svl/brdcst.hxx> 33 34 class SwTxtFld; 35 class SwRootFrm; 36 class SwPostIt; 37 class String; 38 class SwPostItMgr; 39 class SwEditWin; 40 namespace sw { namespace sidebarwindows { 41 class SwSidebarWin; 42 } } 43 44 struct SwPosition; 45 46 typedef sal_Int64 SwPostItBits; 47 48 struct SwLayoutInfo 49 { 50 const SwFrm* mpAnchorFrm; 51 SwRect mPosition; 52 53 // optional start of the annotation 54 sal_uLong mnStartNodeIdx; 55 xub_StrLen mnStartContent; 56 57 SwRect mPageFrame; 58 SwRect mPagePrtArea; 59 unsigned long mnPageNumber; 60 61 sw::sidebarwindows::SidebarPosition meSidebarPosition; 62 63 sal_uInt16 mRedlineAuthor; 64 SwLayoutInfoSwLayoutInfo65 SwLayoutInfo() 66 : mpAnchorFrm(0) 67 , mPosition() 68 , mnStartNodeIdx( 0 ) 69 , mnStartContent( STRING_NOTFOUND ) 70 , mPageFrame() 71 , mPagePrtArea() 72 , mnPageNumber(1) 73 , meSidebarPosition(sw::sidebarwindows::SIDEBAR_NONE) 74 , mRedlineAuthor(0) 75 {} 76 }; 77 78 namespace SwPostItHelper 79 { 80 enum SwLayoutStatus 81 { 82 INVISIBLE, VISIBLE, INSERTED, DELETED, NONE, HIDDEN 83 }; 84 85 SwLayoutStatus getLayoutInfos( 86 SwLayoutInfo& o_rInfo, 87 const SwPosition& rAnchorPos, 88 const SwPosition* pAnnotationStartPos = NULL ); 89 90 long getLayoutHeight( const SwRootFrm* pRoot ); 91 void setSidebarChanged( SwRootFrm* pRoot, bool bBrowseMode ); 92 unsigned long getPageInfo( SwRect& rPageFrm, const SwRootFrm* , const Point& ); 93 } 94 95 class SwSidebarItem 96 { 97 public: 98 sw::sidebarwindows::SwSidebarWin* pPostIt; 99 bool bShow; 100 bool bFocus; 101 102 SwPostItHelper::SwLayoutStatus mLayoutStatus; 103 SwLayoutInfo maLayoutInfo; 104 SwSidebarItem(const bool aShow,const bool aFocus)105 SwSidebarItem( const bool aShow, 106 const bool aFocus) 107 : pPostIt(0) 108 , bShow(aShow) 109 , bFocus(aFocus) 110 , mLayoutStatus( SwPostItHelper::INVISIBLE ) 111 , maLayoutInfo() 112 { 113 } 114 ~SwSidebarItem()115 virtual ~SwSidebarItem() 116 { 117 } 118 119 virtual SwPosition GetAnchorPosition() const = 0; 120 virtual bool UseElement() = 0; 121 virtual const SwFmtFld& GetFmtFld() const = 0; 122 virtual const SfxBroadcaster* GetBroadCaster() const = 0; 123 virtual sw::sidebarwindows::SwSidebarWin* GetSidebarWindow( SwEditWin& rEditWin, 124 WinBits nBits, 125 SwPostItMgr& aMgr, 126 SwPostItBits aBits) = 0; 127 }; 128 /* 129 class SwRedCommentItem: public SwSidebarItem 130 { 131 private: 132 SwRedline* pRedline; 133 public: 134 135 SwRedCommentItem( SwRedline* pRed, bool aShow, bool aFocus) 136 : SwSidebarItem(aShow,aFocus), 137 pRedline(pRed) {} 138 virtual ~SwRedCommentItem() {} 139 virtual SwPosition GetAnchorPosition() const; 140 virtual bool UseElement(); 141 virtual SwFmtFld* GetFmtFld() const {return 0; } 142 virtual SfxBroadcaster* GetBroadCaster() const { return dynamic_cast<SfxBroadcaster *> (pRedline); } 143 virtual sw::sidebarwindows::SwSidebarWin* GetSidebarWindow( SwEditWin& rEditWin, 144 WinBits nBits, 145 SwPostItMgr& aMgr, 146 SwPostItBits aBits); 147 }; 148 */ 149 150 class SwAnnotationItem: public SwSidebarItem 151 { 152 public: SwAnnotationItem(SwFmtFld & rFmtFld,const bool bShow,const bool bFocus)153 SwAnnotationItem( 154 SwFmtFld& rFmtFld, 155 const bool bShow, 156 const bool bFocus) 157 : SwSidebarItem( bShow, bFocus ) 158 , mrFmtFld( rFmtFld ) 159 { 160 } 161 ~SwAnnotationItem()162 virtual ~SwAnnotationItem() 163 { 164 } 165 166 virtual SwPosition GetAnchorPosition() const; 167 virtual bool UseElement(); GetFmtFld() const168 virtual const SwFmtFld& GetFmtFld() const 169 { 170 return mrFmtFld; 171 } GetBroadCaster() const172 virtual const SfxBroadcaster* GetBroadCaster() const 173 { 174 return dynamic_cast<const SfxBroadcaster *> (&mrFmtFld); 175 } 176 virtual sw::sidebarwindows::SwSidebarWin* GetSidebarWindow( 177 SwEditWin& rEditWin, 178 WinBits nBits, 179 SwPostItMgr& aMgr, 180 SwPostItBits aBits ); 181 182 private: 183 SwFmtFld& mrFmtFld; 184 }; 185 186 #endif // _POSTITHELPER_HXX 187