11d2dbeb0SAndrew Rist /************************************************************** 21d2dbeb0SAndrew Rist * 31d2dbeb0SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 41d2dbeb0SAndrew Rist * or more contributor license agreements. See the NOTICE file 51d2dbeb0SAndrew Rist * distributed with this work for additional information 61d2dbeb0SAndrew Rist * regarding copyright ownership. The ASF licenses this file 71d2dbeb0SAndrew Rist * to you under the Apache License, Version 2.0 (the 81d2dbeb0SAndrew Rist * "License"); you may not use this file except in compliance 91d2dbeb0SAndrew Rist * with the License. You may obtain a copy of the License at 101d2dbeb0SAndrew Rist * 111d2dbeb0SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 121d2dbeb0SAndrew Rist * 131d2dbeb0SAndrew Rist * Unless required by applicable law or agreed to in writing, 141d2dbeb0SAndrew Rist * software distributed under the License is distributed on an 151d2dbeb0SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 161d2dbeb0SAndrew Rist * KIND, either express or implied. See the License for the 171d2dbeb0SAndrew Rist * specific language governing permissions and limitations 181d2dbeb0SAndrew Rist * under the License. 191d2dbeb0SAndrew Rist * 201d2dbeb0SAndrew Rist *************************************************************/ 211d2dbeb0SAndrew Rist 221d2dbeb0SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _POSTITMGR_HXX 25cdf0e10cSrcweir #define _POSTITMGR_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <list> 28cdf0e10cSrcweir #include <vector> 29cdf0e10cSrcweir #include <editeng/outlobj.hxx> 30cdf0e10cSrcweir #include <tools/string.hxx> 31cdf0e10cSrcweir #include <tools/link.hxx> 32cdf0e10cSrcweir #include <tools/debug.hxx> 33cdf0e10cSrcweir #include <swrect.hxx> 34cdf0e10cSrcweir #include <unotools/configitem.hxx> 35cdf0e10cSrcweir #include <unotools/options.hxx> 36cdf0e10cSrcweir #include <com/sun/star/util/SearchOptions.hpp> 37cdf0e10cSrcweir #include <com/sun/star/uno/Any.hxx> 38cdf0e10cSrcweir #include <SidebarWindowsTypes.hxx> 39cdf0e10cSrcweir #include <svl/lstner.hxx> 40cdf0e10cSrcweir 41cdf0e10cSrcweir class SwWrtShell; 42cdf0e10cSrcweir class SwDoc; 43cdf0e10cSrcweir class SwView; 44cdf0e10cSrcweir class SwPostItField; 45cdf0e10cSrcweir class SwFmtFld; 46cdf0e10cSrcweir class SwField; 47cdf0e10cSrcweir class SfxBroadcaster; 48cdf0e10cSrcweir class SfxHint; 49cdf0e10cSrcweir class SwEditWin; 50cdf0e10cSrcweir class Color; 51cdf0e10cSrcweir class SvxSearchItem; 52cdf0e10cSrcweir class SvxLanguageItem; 53cdf0e10cSrcweir namespace sw { namespace annotation { 54cdf0e10cSrcweir class SwAnnotationWin; 55cdf0e10cSrcweir }} 56cdf0e10cSrcweir namespace sw { namespace sidebarwindows { 57cdf0e10cSrcweir class SwSidebarWin; 58cdf0e10cSrcweir class SwFrmSidebarWinContainer; 59cdf0e10cSrcweir }} 60cdf0e10cSrcweir class SwSidebarItem; 61cdf0e10cSrcweir class SwFrm; 62cdf0e10cSrcweir class Window; 63cdf0e10cSrcweir 64cdf0e10cSrcweir #define SORT_POS 1 65cdf0e10cSrcweir #define SORT_AUTHOR 2 66cdf0e10cSrcweir #define SORT_DATE 3 67cdf0e10cSrcweir 68cdf0e10cSrcweir #define COL_NOTES_SIDEPANE_ARROW_ENABLED RGB_COLORDATA(0,0,0) 69cdf0e10cSrcweir #define COL_NOTES_SIDEPANE_ARROW_DISABLED RGB_COLORDATA(172,168,153) 70cdf0e10cSrcweir 71cdf0e10cSrcweir typedef std::list<SwSidebarItem*> SwSidebarItem_list; 72cdf0e10cSrcweir typedef std::list<SwSidebarItem*>::iterator SwSidebarItem_iterator; 73cdf0e10cSrcweir 74cdf0e10cSrcweir 75cdf0e10cSrcweir struct SwPostItPageItem 76cdf0e10cSrcweir { 77cdf0e10cSrcweir bool bScrollbar; 78cdf0e10cSrcweir sw::sidebarwindows::SidebarPosition eSidebarPosition; 79cdf0e10cSrcweir long lOffset; 80cdf0e10cSrcweir SwRect mPageRect; 81cdf0e10cSrcweir SwSidebarItem_list* mList; SwPostItPageItemSwPostItPageItem82cdf0e10cSrcweir SwPostItPageItem(): bScrollbar(false),lOffset(0) 83cdf0e10cSrcweir { 84cdf0e10cSrcweir mList = new SwSidebarItem_list; 85cdf0e10cSrcweir } ~SwPostItPageItemSwPostItPageItem86cdf0e10cSrcweir ~SwPostItPageItem() 87cdf0e10cSrcweir { 88cdf0e10cSrcweir mList->clear(); 89cdf0e10cSrcweir delete mList; 90cdf0e10cSrcweir } 91cdf0e10cSrcweir 92cdf0e10cSrcweir }; 93cdf0e10cSrcweir 94cdf0e10cSrcweir struct FieldShadowState 95cdf0e10cSrcweir { 96cdf0e10cSrcweir const SwPostItField* mpShadowFld; 97cdf0e10cSrcweir bool bCursor; 98cdf0e10cSrcweir bool bMouse; FieldShadowStateFieldShadowState99cdf0e10cSrcweir FieldShadowState(): mpShadowFld(0),bCursor(false),bMouse(false) 100cdf0e10cSrcweir { 101cdf0e10cSrcweir } 102cdf0e10cSrcweir }; 103cdf0e10cSrcweir 104cdf0e10cSrcweir class SwNoteProps: public utl::ConfigItem 105cdf0e10cSrcweir { 106cdf0e10cSrcweir private: 107cdf0e10cSrcweir bool bIsShowAnchor; 108cdf0e10cSrcweir public: SwNoteProps()109cdf0e10cSrcweir SwNoteProps() 110cdf0e10cSrcweir : ConfigItem(::rtl::OUString::createFromAscii("Office.Writer/Notes")) 111cdf0e10cSrcweir , bIsShowAnchor(false) 112cdf0e10cSrcweir { 113cdf0e10cSrcweir const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rNames = GetPropertyNames(); 114cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > aValues = GetProperties(rNames); 115cdf0e10cSrcweir const ::com::sun::star::uno::Any* pValues = aValues.getConstArray(); 116cdf0e10cSrcweir DBG_ASSERT(aValues.getLength() == rNames.getLength(), "GetProperties failed"); 117cdf0e10cSrcweir if (aValues.getLength()) 118cdf0e10cSrcweir pValues[0]>>=bIsShowAnchor; 119cdf0e10cSrcweir } 120cdf0e10cSrcweir IsShowAnchor()121cdf0e10cSrcweir bool IsShowAnchor() 122cdf0e10cSrcweir { 123cdf0e10cSrcweir return bIsShowAnchor; 124cdf0e10cSrcweir } GetPropertyNames()125cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString >& GetPropertyNames() 126cdf0e10cSrcweir { 127cdf0e10cSrcweir static ::com::sun::star::uno::Sequence< ::rtl::OUString > aNames; 128cdf0e10cSrcweir if(!aNames.getLength()) 129cdf0e10cSrcweir { 130cdf0e10cSrcweir static const char* aPropNames[] = 131cdf0e10cSrcweir { 132cdf0e10cSrcweir "ShowAnkor" 133cdf0e10cSrcweir }; 134cdf0e10cSrcweir const int nCount = sizeof(aPropNames)/sizeof(const char*); 135cdf0e10cSrcweir aNames.realloc(nCount); 136cdf0e10cSrcweir ::rtl::OUString* pNames = aNames.getArray(); 137cdf0e10cSrcweir for(int i = 0; i < nCount; i++) 138cdf0e10cSrcweir pNames[i] = ::rtl::OUString::createFromAscii(aPropNames[i]); 139cdf0e10cSrcweir } 140cdf0e10cSrcweir return aNames; 141cdf0e10cSrcweir } 142cdf0e10cSrcweir 143cdf0e10cSrcweir virtual void Commit(); 144cdf0e10cSrcweir virtual void Notify( const ::com::sun::star::uno::Sequence< rtl::OUString >& aPropertyNames ); 145cdf0e10cSrcweir }; 146cdf0e10cSrcweir 147cdf0e10cSrcweir class SwPostItMgr: public SfxListener 148cdf0e10cSrcweir { 149cdf0e10cSrcweir private: 150cdf0e10cSrcweir SwView* mpView; 151cdf0e10cSrcweir SwWrtShell* mpWrtShell; 152cdf0e10cSrcweir SwEditWin* mpEditWin; 153cdf0e10cSrcweir std::list< SwSidebarItem*> mvPostItFlds; 154cdf0e10cSrcweir std::vector<SwPostItPageItem*> mPages; 155cdf0e10cSrcweir sal_uLong mnEventId; 156cdf0e10cSrcweir bool mbWaitingForCalcRects; 157cdf0e10cSrcweir sw::sidebarwindows::SwSidebarWin* mpActivePostIt; 158cdf0e10cSrcweir bool mbLayout; 159cdf0e10cSrcweir long mbLayoutHeight; 160cdf0e10cSrcweir long mbLayouting; 161cdf0e10cSrcweir bool mbReadOnly; 162cdf0e10cSrcweir bool mbDeleteNote; 163cdf0e10cSrcweir FieldShadowState mShadowState; 164cdf0e10cSrcweir OutlinerParaObject* mpAnswer; 165cdf0e10cSrcweir bool mbIsShowAnchor; 166cdf0e10cSrcweir 167cdf0e10cSrcweir // data structure to collect the <SwSidebarWin> instances for certain <SwFrm> instances. 168cdf0e10cSrcweir sw::sidebarwindows::SwFrmSidebarWinContainer* mpFrmSidebarWinContainer; 169cdf0e10cSrcweir 170cdf0e10cSrcweir typedef std::list<sw::sidebarwindows::SwSidebarWin*>::iterator SwSidebarWin_iterator; 171cdf0e10cSrcweir 172cdf0e10cSrcweir void AddPostIts(bool bCheckExistance = true,bool bFocus = true); 173cdf0e10cSrcweir //void AddRedlineComments(bool bCheckExistance, bool bFocus); 174cdf0e10cSrcweir void RemoveSidebarWin(); 175cdf0e10cSrcweir void PreparePageContainer(); 176cdf0e10cSrcweir void Scroll(const long lScroll,const unsigned long aPage ); 177cdf0e10cSrcweir void AutoScroll(const sw::sidebarwindows::SwSidebarWin* pPostIt,const unsigned long aPage ); 178cdf0e10cSrcweir bool ScrollbarHit(const unsigned long aPage,const Point &aPoint); 179cdf0e10cSrcweir bool LayoutByPage( std::list<sw::sidebarwindows::SwSidebarWin*> &aVisiblePostItList, 180cdf0e10cSrcweir const Rectangle aBorder, 181cdf0e10cSrcweir long lNeededHeight); 182cdf0e10cSrcweir void CheckForRemovedPostIts(); 183cdf0e10cSrcweir bool ArrowEnabled(sal_uInt16 aDirection,unsigned long aPage) const; 184cdf0e10cSrcweir bool BorderOverPageBorder(unsigned long aPage) const; 185cdf0e10cSrcweir bool HasScrollbars() const; 186cdf0e10cSrcweir void Focus(SfxBroadcaster& rBC); 187cdf0e10cSrcweir 188cdf0e10cSrcweir sal_Int32 GetInitialAnchorDistance() const; 189cdf0e10cSrcweir sal_Int32 GetScrollSize() const; 190cdf0e10cSrcweir sal_Int32 GetSpaceBetween() const; 191cdf0e10cSrcweir void SetReadOnlyState(); 192cdf0e10cSrcweir DECL_LINK( CalcHdl, void*); 193cdf0e10cSrcweir 194cdf0e10cSrcweir sw::sidebarwindows::SwSidebarWin* GetSidebarWin(const SfxBroadcaster* pBroadcaster) const; 195cdf0e10cSrcweir 196cdf0e10cSrcweir void InsertItem( SfxBroadcaster* pItem, bool bCheckExistance, bool bFocus); 197cdf0e10cSrcweir void RemoveItem( SfxBroadcaster* pBroadcast ); 198cdf0e10cSrcweir 199cdf0e10cSrcweir void Sort(const short aType); 200cdf0e10cSrcweir 201cdf0e10cSrcweir public: 202cdf0e10cSrcweir SwPostItMgr(SwView* aDoc); 203cdf0e10cSrcweir ~SwPostItMgr(); 204cdf0e10cSrcweir 205cdf0e10cSrcweir typedef std::list< SwSidebarItem* >::const_iterator const_iterator; begin() const206cdf0e10cSrcweir const_iterator begin() const { return mvPostItFlds.begin(); } end() const207cdf0e10cSrcweir const_iterator end() const { return mvPostItFlds.end(); } 208cdf0e10cSrcweir 209cdf0e10cSrcweir void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); 210cdf0e10cSrcweir 211cdf0e10cSrcweir void LayoutPostIts(); 212cdf0e10cSrcweir bool CalcRects(); 213cdf0e10cSrcweir 214cdf0e10cSrcweir void MakeVisible( const sw::sidebarwindows::SwSidebarWin* pPostIt, 215cdf0e10cSrcweir long aPage = -1); 216cdf0e10cSrcweir 217cdf0e10cSrcweir bool ShowScrollbar(const unsigned long aPage) const; 218cdf0e10cSrcweir bool HasNotes() const ; 219cdf0e10cSrcweir bool ShowNotes() const; IsShowAnchor()220cdf0e10cSrcweir bool IsShowAnchor() { return mbIsShowAnchor;} 221cdf0e10cSrcweir unsigned long GetSidebarWidth(bool bPx = false) const; 222cdf0e10cSrcweir unsigned long GetSidebarBorderWidth(bool bPx = false) const; 223cdf0e10cSrcweir unsigned long GetNoteWidth(); 224cdf0e10cSrcweir 225cdf0e10cSrcweir void PrepareView(bool bIgnoreCount = false); 226cdf0e10cSrcweir 227cdf0e10cSrcweir void CorrectPositions(); 228cdf0e10cSrcweir SetLayout()229cdf0e10cSrcweir void SetLayout() { mbLayout = true; }; 230cdf0e10cSrcweir void Delete(String aAuthor); 231cdf0e10cSrcweir void Delete(); 232cdf0e10cSrcweir 233cdf0e10cSrcweir #if 0 234cdf0e10cSrcweir void Hide( SwPostItField* pPostItField ); 235cdf0e10cSrcweir #endif 236cdf0e10cSrcweir void Hide( const String& rAuthor ); 237cdf0e10cSrcweir void Hide(); 238cdf0e10cSrcweir void Show(); 239cdf0e10cSrcweir 240cdf0e10cSrcweir void Rescale(); 241cdf0e10cSrcweir 242cdf0e10cSrcweir Rectangle GetBottomScrollRect(const unsigned long aPage) const; 243cdf0e10cSrcweir Rectangle GetTopScrollRect(const unsigned long aPage) const; 244cdf0e10cSrcweir 245cdf0e10cSrcweir bool IsHit(const Point &aPointPixel); 246cdf0e10cSrcweir Color GetArrowColor(sal_uInt16 aDirection,unsigned long aPage) const; 247cdf0e10cSrcweir 248cdf0e10cSrcweir sw::annotation::SwAnnotationWin* GetAnnotationWin(const SwPostItField* pFld) const; 249cdf0e10cSrcweir 250cdf0e10cSrcweir sw::sidebarwindows::SwSidebarWin* GetNextPostIt( sal_uInt16 aDirection, 251cdf0e10cSrcweir sw::sidebarwindows::SwSidebarWin* aPostIt); 252cdf0e10cSrcweir long GetNextBorder(); 253cdf0e10cSrcweir GetActiveSidebarWin()254cdf0e10cSrcweir sw::sidebarwindows::SwSidebarWin* GetActiveSidebarWin() { return mpActivePostIt; } 255cdf0e10cSrcweir void SetActiveSidebarWin( sw::sidebarwindows::SwSidebarWin* p); 256cdf0e10cSrcweir bool HasActiveSidebarWin() const; 257cdf0e10cSrcweir bool HasActiveAnnotationWin() const; 258cdf0e10cSrcweir void GrabFocusOnActiveSidebarWin(); 259cdf0e10cSrcweir void UpdateDataOnActiveSidebarWin(); 260cdf0e10cSrcweir void DeleteActiveSidebarWin(); 261cdf0e10cSrcweir void HideActiveSidebarWin(); 262cdf0e10cSrcweir void ToggleInsModeOnActiveSidebarWin(); 263cdf0e10cSrcweir 264cdf0e10cSrcweir sal_Int32 GetMinimumSizeWithMeta() const; 265cdf0e10cSrcweir sal_Int32 GetSidebarScrollerHeight() const; 266cdf0e10cSrcweir 267cdf0e10cSrcweir void SetShadowState(const SwPostItField* pFld,bool bCursor = true); 268cdf0e10cSrcweir 269cdf0e10cSrcweir void SetSpellChecking(); 270cdf0e10cSrcweir 271*3b32dd21SOliver-Rainer Wittmann static Color GetColorDark(sal_uInt16 aAuthorIndex); 272*3b32dd21SOliver-Rainer Wittmann static Color GetColorLight(sal_uInt16 aAuthorIndex); 273*3b32dd21SOliver-Rainer Wittmann static Color GetColorAnchor(sal_uInt16 aAuthorIndex); 274cdf0e10cSrcweir 275cdf0e10cSrcweir RegisterAnswer(OutlinerParaObject * pAnswer)276cdf0e10cSrcweir void RegisterAnswer(OutlinerParaObject* pAnswer) { mpAnswer = pAnswer;} IsAnswer()277cdf0e10cSrcweir OutlinerParaObject* IsAnswer() {return mpAnswer;} 278cdf0e10cSrcweir void CheckMetaText(); 279cdf0e10cSrcweir void StartSpelling(); 280cdf0e10cSrcweir 281cdf0e10cSrcweir sal_uInt16 Replace(SvxSearchItem* pItem); 282cdf0e10cSrcweir sal_uInt16 SearchReplace(const SwFmtFld &pFld, const ::com::sun::star::util::SearchOptions& rSearchOptions,bool bSrchForward); 283cdf0e10cSrcweir sal_uInt16 FinishSearchReplace(const ::com::sun::star::util::SearchOptions& rSearchOptions,bool bSrchForward); 284cdf0e10cSrcweir 285ca62e2c2SSteve Yin // get the PostIt window by index GetPostItCount()286ca62e2c2SSteve Yin sal_Int32 GetPostItCount() {return mvPostItFlds.size();}; 287cdf0e10cSrcweir void AssureStdModeAtShell(); 288cdf0e10cSrcweir 289cdf0e10cSrcweir void ConnectSidebarWinToFrm( const SwFrm& rFrm, 290cdf0e10cSrcweir const SwFmtFld& rFmtFld, 291cdf0e10cSrcweir sw::sidebarwindows::SwSidebarWin& rSidebarWin ); 292cdf0e10cSrcweir void DisconnectSidebarWinFromFrm( const SwFrm& rFrm, 293cdf0e10cSrcweir sw::sidebarwindows::SwSidebarWin& rSidebarWin ); 294cdf0e10cSrcweir bool HasFrmConnectedSidebarWins( const SwFrm& rFrm ); 295cdf0e10cSrcweir Window* GetSidebarWinForFrmByIndex( const SwFrm& rFrm, 296cdf0e10cSrcweir const sal_Int32 nIndex ); 297cdf0e10cSrcweir void GetAllSidebarWinForFrm( const SwFrm& rFrm, 298cdf0e10cSrcweir std::vector< Window* >* pChildren ); 299cdf0e10cSrcweir }; 300cdf0e10cSrcweir 301cdf0e10cSrcweir #endif 302cdf0e10cSrcweir 303cdf0e10cSrcweir 304cdf0e10cSrcweir 305cdf0e10cSrcweir 306