1*1d2dbeb0SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*1d2dbeb0SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*1d2dbeb0SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*1d2dbeb0SAndrew Rist * distributed with this work for additional information 6*1d2dbeb0SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*1d2dbeb0SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*1d2dbeb0SAndrew Rist * "License"); you may not use this file except in compliance 9*1d2dbeb0SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*1d2dbeb0SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*1d2dbeb0SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*1d2dbeb0SAndrew Rist * software distributed under the License is distributed on an 15*1d2dbeb0SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*1d2dbeb0SAndrew Rist * KIND, either express or implied. See the License for the 17*1d2dbeb0SAndrew Rist * specific language governing permissions and limitations 18*1d2dbeb0SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*1d2dbeb0SAndrew Rist *************************************************************/ 21*1d2dbeb0SAndrew Rist 22*1d2dbeb0SAndrew Rist 23cdf0e10cSrcweir #ifndef _CONTTREE_HXX 24cdf0e10cSrcweir #define _CONTTREE_HXX 25cdf0e10cSrcweir 26cdf0e10cSrcweir #include <svtools/svtreebx.hxx> 27cdf0e10cSrcweir #include "swcont.hxx" 28cdf0e10cSrcweir 29cdf0e10cSrcweir class SwWrtShell; 30cdf0e10cSrcweir class SwContentType; 31cdf0e10cSrcweir class SwNavigationPI; 32cdf0e10cSrcweir class SwNavigationConfig; 33cdf0e10cSrcweir class Menu; 34cdf0e10cSrcweir class ToolBox; 35cdf0e10cSrcweir class SwGlblDocContents; 36cdf0e10cSrcweir class SwGlblDocContent; 37cdf0e10cSrcweir class SfxObjectShell; 38cdf0e10cSrcweir 39cdf0e10cSrcweir 40cdf0e10cSrcweir #define EDIT_MODE_EDIT 0 41cdf0e10cSrcweir #define EDIT_MODE_UPD_IDX 1 42cdf0e10cSrcweir #define EDIT_MODE_RMV_IDX 2 43cdf0e10cSrcweir #define EDIT_UNPROTECT_TABLE 3 44cdf0e10cSrcweir #define EDIT_MODE_DELETE 4 45cdf0e10cSrcweir #define EDIT_MODE_RENAME 5 46cdf0e10cSrcweir 47cdf0e10cSrcweir //---------------------------------------------------------------------------- 48cdf0e10cSrcweir //---------------------------------------------------------------------------- 49cdf0e10cSrcweir 50cdf0e10cSrcweir class SwContentTree : public SvTreeListBox 51cdf0e10cSrcweir { 52cdf0e10cSrcweir ImageList aEntryImages; 53cdf0e10cSrcweir String sSpace; 54cdf0e10cSrcweir AutoTimer aUpdTimer; 55cdf0e10cSrcweir 56cdf0e10cSrcweir SwContentType* aActiveContentArr[CONTENT_TYPE_MAX]; 57cdf0e10cSrcweir SwContentType* aHiddenContentArr[CONTENT_TYPE_MAX]; 58cdf0e10cSrcweir String aContextStrings[CONTEXT_COUNT + 1]; 59cdf0e10cSrcweir String sRemoveIdx; 60cdf0e10cSrcweir String sUpdateIdx; 61cdf0e10cSrcweir String sUnprotTbl; 62cdf0e10cSrcweir String sRename; 63cdf0e10cSrcweir String sReadonlyIdx; 64cdf0e10cSrcweir String sInvisible; 65cdf0e10cSrcweir String sPostItShow; 66cdf0e10cSrcweir String sPostItHide; 67cdf0e10cSrcweir String sPostItDelete; 68cdf0e10cSrcweir 69cdf0e10cSrcweir SwWrtShell* pHiddenShell; // gedropptes Doc 70cdf0e10cSrcweir SwWrtShell* pActiveShell; // die aktive oder eine konst. offene View 71cdf0e10cSrcweir SwNavigationConfig* pConfig; 72cdf0e10cSrcweir 73cdf0e10cSrcweir sal_Int32 nActiveBlock; 74cdf0e10cSrcweir sal_uInt16 nHiddenBlock; 75cdf0e10cSrcweir sal_uInt16 nRootType; 76cdf0e10cSrcweir sal_uInt16 nLastSelType; 77cdf0e10cSrcweir sal_uInt8 nOutlineLevel; 78cdf0e10cSrcweir 79cdf0e10cSrcweir sal_Bool bIsActive :1; 80cdf0e10cSrcweir sal_Bool bIsConstant :1; 81cdf0e10cSrcweir sal_Bool bIsHidden :1; 82cdf0e10cSrcweir sal_Bool bDocChgdInDragging :1; 83cdf0e10cSrcweir sal_Bool bIsInternalDrag :1; 84cdf0e10cSrcweir sal_Bool bIsRoot :1; 85cdf0e10cSrcweir sal_Bool bIsIdleClear :1; 86cdf0e10cSrcweir sal_Bool bIsLastReadOnly :1; 87cdf0e10cSrcweir sal_Bool bIsOutlineMoveable :1; 88cdf0e10cSrcweir sal_Bool bViewHasChanged :1; 89cdf0e10cSrcweir sal_Bool bIsImageListInitialized : 1; 90cdf0e10cSrcweir 91cdf0e10cSrcweir static sal_Bool bIsInDrag; 92cdf0e10cSrcweir 93cdf0e10cSrcweir void FindActiveTypeAndRemoveUserData(); 94cdf0e10cSrcweir 95cdf0e10cSrcweir using SvLBox::ExecuteDrop; 96cdf0e10cSrcweir using SvTreeListBox::EditEntry; 97cdf0e10cSrcweir using SvListView::Expand; 98cdf0e10cSrcweir using SvListView::Collapse; 99cdf0e10cSrcweir using SvListView::Select; 100cdf0e10cSrcweir 101cdf0e10cSrcweir protected: 102cdf0e10cSrcweir // virtual void Command( const CommandEvent& rCEvt ); 103cdf0e10cSrcweir virtual void RequestHelp( const HelpEvent& rHEvt ); 104cdf0e10cSrcweir virtual void InitEntry(SvLBoxEntry*,const XubString&,const Image&,const Image&,SvLBoxButtonKind); 105cdf0e10cSrcweir virtual void DataChanged( const DataChangedEvent& rDCEvt ); 106cdf0e10cSrcweir 107cdf0e10cSrcweir SwNavigationPI* GetParentWindow(){return 108cdf0e10cSrcweir (SwNavigationPI*)Window::GetParent();} 109cdf0e10cSrcweir 110cdf0e10cSrcweir virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel ); 111cdf0e10cSrcweir virtual void DragFinished( sal_Int8 ); 112cdf0e10cSrcweir virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ); 113cdf0e10cSrcweir 114cdf0e10cSrcweir virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ); 115cdf0e10cSrcweir 116cdf0e10cSrcweir sal_Bool FillTransferData( TransferDataContainer& rTransfer, 117cdf0e10cSrcweir sal_Int8& rDragMode ); 118cdf0e10cSrcweir sal_Bool HasContentChanged(); 119cdf0e10cSrcweir 120cdf0e10cSrcweir virtual DragDropMode NotifyStartDrag( TransferDataContainer& rData, 121cdf0e10cSrcweir SvLBoxEntry* ); 122cdf0e10cSrcweir virtual sal_Bool NotifyAcceptDrop( SvLBoxEntry* ); 123cdf0e10cSrcweir 124cdf0e10cSrcweir virtual sal_Bool NotifyMoving( SvLBoxEntry* pTarget, 125cdf0e10cSrcweir SvLBoxEntry* pEntry, 126cdf0e10cSrcweir SvLBoxEntry*& rpNewParent, 127cdf0e10cSrcweir sal_uLong& rNewChildPos 128cdf0e10cSrcweir ); 129cdf0e10cSrcweir virtual sal_Bool NotifyCopying( SvLBoxEntry* pTarget, 130cdf0e10cSrcweir SvLBoxEntry* pEntry, 131cdf0e10cSrcweir SvLBoxEntry*& rpNewParent, 132cdf0e10cSrcweir sal_uLong& rNewChildPos 133cdf0e10cSrcweir ); 134cdf0e10cSrcweir virtual void MouseButtonDown( const MouseEvent& rMEvt ); 135cdf0e10cSrcweir 136cdf0e10cSrcweir void EditEntry( SvLBoxEntry* pEntry, sal_uInt8 nMode ); 137cdf0e10cSrcweir 138cdf0e10cSrcweir void GotoContent(SwContent* pCnt); 139cdf0e10cSrcweir static void SetInDrag(sal_Bool bSet) {bIsInDrag = bSet;} 140cdf0e10cSrcweir 141cdf0e10cSrcweir virtual PopupMenu* CreateContextMenu( void ); 142cdf0e10cSrcweir virtual void ExcecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry ); 143cdf0e10cSrcweir 144cdf0e10cSrcweir public: 145cdf0e10cSrcweir SwContentTree(Window* pParent, const ResId& rResId); 146cdf0e10cSrcweir ~SwContentTree(); 147cdf0e10cSrcweir 148cdf0e10cSrcweir sal_Bool ToggleToRoot(); 149cdf0e10cSrcweir sal_Bool IsRoot() const {return bIsRoot;} 150cdf0e10cSrcweir sal_uInt16 GetRootType() const {return nRootType;} 151cdf0e10cSrcweir void SetRootType(sal_uInt16 nType); 152cdf0e10cSrcweir void Display( sal_Bool bActiveView ); 153cdf0e10cSrcweir void Clear(); 154cdf0e10cSrcweir void SetHiddenShell(SwWrtShell* pSh); 155cdf0e10cSrcweir void ShowHiddenShell(); 156cdf0e10cSrcweir void ShowActualView(); 157cdf0e10cSrcweir void SetActiveShell(SwWrtShell* pSh); 158cdf0e10cSrcweir void SetConstantShell(SwWrtShell* pSh); 159cdf0e10cSrcweir 160cdf0e10cSrcweir SwWrtShell* GetWrtShell() 161cdf0e10cSrcweir {return bIsActive||bIsConstant ? 162cdf0e10cSrcweir pActiveShell : 163cdf0e10cSrcweir pHiddenShell;} 164cdf0e10cSrcweir 165cdf0e10cSrcweir static sal_Bool IsInDrag() {return bIsInDrag;} 166cdf0e10cSrcweir sal_Bool IsInternalDrag() const {return bIsInternalDrag != 0;} 167cdf0e10cSrcweir 168cdf0e10cSrcweir sal_Int32 GetActiveBlock() const {return nActiveBlock;} 169cdf0e10cSrcweir 170cdf0e10cSrcweir sal_uInt8 GetOutlineLevel()const {return nOutlineLevel;} 171cdf0e10cSrcweir void SetOutlineLevel(sal_uInt8 nSet); 172cdf0e10cSrcweir 173cdf0e10cSrcweir sal_Bool Expand( SvLBoxEntry* pParent ); 174cdf0e10cSrcweir 175cdf0e10cSrcweir sal_Bool Collapse( SvLBoxEntry* pParent ); 176cdf0e10cSrcweir 177cdf0e10cSrcweir void ExecCommand(sal_uInt16 nCmd, sal_Bool bModifier); 178cdf0e10cSrcweir 179cdf0e10cSrcweir void ShowTree(); 180cdf0e10cSrcweir void HideTree(); 181cdf0e10cSrcweir 182cdf0e10cSrcweir sal_Bool IsConstantView() {return bIsConstant;} 183cdf0e10cSrcweir sal_Bool IsActiveView() {return bIsActive;} 184cdf0e10cSrcweir sal_Bool IsHiddenView() {return bIsHidden;} 185cdf0e10cSrcweir 186cdf0e10cSrcweir const SwWrtShell* GetActiveWrtShell() {return pActiveShell;} 187cdf0e10cSrcweir SwWrtShell* GetHiddenWrtShell() {return pHiddenShell;} 188cdf0e10cSrcweir 189cdf0e10cSrcweir DECL_LINK( ContentDoubleClickHdl, SwContentTree * ); 190cdf0e10cSrcweir // DECL_LINK( PopupHdl, Menu* ); 191cdf0e10cSrcweir DECL_LINK( TimerUpdate, Timer * ); 192cdf0e10cSrcweir 193cdf0e10cSrcweir virtual long GetTabPos( SvLBoxEntry*, SvLBoxTab* ); 194cdf0e10cSrcweir virtual void RequestingChilds( SvLBoxEntry* pParent ); 195cdf0e10cSrcweir virtual void GetFocus(); 196cdf0e10cSrcweir virtual void KeyInput(const KeyEvent& rKEvt); 197cdf0e10cSrcweir 198cdf0e10cSrcweir virtual sal_Bool Select( SvLBoxEntry* pEntry, sal_Bool bSelect=sal_True ); 199cdf0e10cSrcweir }; 200cdf0e10cSrcweir 201cdf0e10cSrcweir 202cdf0e10cSrcweir //---------------------------------------------------------------------------- 203cdf0e10cSrcweir // TreeListBox fuer Globaldokumente 204cdf0e10cSrcweir //---------------------------------------------------------------------------- 205cdf0e10cSrcweir 206cdf0e10cSrcweir class SwLBoxString : public SvLBoxString 207cdf0e10cSrcweir { 208cdf0e10cSrcweir public: 209cdf0e10cSrcweir 210cdf0e10cSrcweir SwLBoxString( SvLBoxEntry* pEntry, sal_uInt16 nFlags, 211cdf0e10cSrcweir const String& rStr ) : SvLBoxString(pEntry,nFlags,rStr) 212cdf0e10cSrcweir { 213cdf0e10cSrcweir } 214cdf0e10cSrcweir 215cdf0e10cSrcweir virtual void Paint( const Point& rPos, SvLBox& rDev, sal_uInt16 nFlags, 216cdf0e10cSrcweir SvLBoxEntry* pEntry); 217cdf0e10cSrcweir }; 218cdf0e10cSrcweir 219cdf0e10cSrcweir namespace sfx2 { class DocumentInserter; } 220cdf0e10cSrcweir namespace sfx2 { class FileDialogHelper; } 221cdf0e10cSrcweir 222cdf0e10cSrcweir class SwGlobalTree : public SvTreeListBox 223cdf0e10cSrcweir { 224cdf0e10cSrcweir private: 225cdf0e10cSrcweir AutoTimer aUpdateTimer; 226cdf0e10cSrcweir String aContextStrings[GLOBAL_CONTEXT_COUNT]; 227cdf0e10cSrcweir 228cdf0e10cSrcweir ImageList aEntryImages; 229cdf0e10cSrcweir 230cdf0e10cSrcweir SwWrtShell* pActiveShell; // 231cdf0e10cSrcweir SvLBoxEntry* pEmphasisEntry; // Drag'n Drop-Emphasis 232cdf0e10cSrcweir SvLBoxEntry* pDDSource; // Quelle beim DnD 233cdf0e10cSrcweir SwGlblDocContents* pSwGlblDocContents; // Array mit sortierten Inhalten 234cdf0e10cSrcweir 235cdf0e10cSrcweir Window* pDefParentWin; 236cdf0e10cSrcweir SwGlblDocContent* pDocContent; 237cdf0e10cSrcweir sfx2::DocumentInserter* pDocInserter; 238cdf0e10cSrcweir 239cdf0e10cSrcweir sal_Bool bIsInternalDrag :1; 240cdf0e10cSrcweir sal_Bool bLastEntryEmphasis :1; // Drag'n Drop 241cdf0e10cSrcweir sal_Bool bIsImageListInitialized : 1; 242cdf0e10cSrcweir 243cdf0e10cSrcweir static const SfxObjectShell* pShowShell; 244cdf0e10cSrcweir 245cdf0e10cSrcweir void InsertRegion( const SwGlblDocContent* _pContent, 246cdf0e10cSrcweir const com::sun::star::uno::Sequence< ::rtl::OUString >& _rFiles ); 247cdf0e10cSrcweir 248cdf0e10cSrcweir DECL_LINK( DialogClosedHdl, sfx2::FileDialogHelper* ); 249cdf0e10cSrcweir 250cdf0e10cSrcweir using SvLBox::DoubleClickHdl; 251cdf0e10cSrcweir using SvLBox::ExecuteDrop; 252cdf0e10cSrcweir using Window::Update; 253cdf0e10cSrcweir 254cdf0e10cSrcweir protected: 255cdf0e10cSrcweir 256cdf0e10cSrcweir virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ); 257cdf0e10cSrcweir 258cdf0e10cSrcweir virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ); 259cdf0e10cSrcweir 260cdf0e10cSrcweir virtual void DataChanged( const DataChangedEvent& rDCEvt ); 261cdf0e10cSrcweir 262cdf0e10cSrcweir virtual void RequestHelp( const HelpEvent& rHEvt ); 263cdf0e10cSrcweir 264cdf0e10cSrcweir virtual long GetTabPos( SvLBoxEntry*, SvLBoxTab* ); 265cdf0e10cSrcweir virtual sal_Bool NotifyMoving( SvLBoxEntry* pTarget, 266cdf0e10cSrcweir SvLBoxEntry* pEntry, 267cdf0e10cSrcweir SvLBoxEntry*& rpNewParent, 268cdf0e10cSrcweir sal_uLong& rNewChildPos 269cdf0e10cSrcweir ); 270cdf0e10cSrcweir virtual sal_Bool NotifyCopying( SvLBoxEntry* pTarget, 271cdf0e10cSrcweir SvLBoxEntry* pEntry, 272cdf0e10cSrcweir SvLBoxEntry*& rpNewParent, 273cdf0e10cSrcweir sal_uLong& rNewChildPos 274cdf0e10cSrcweir ); 275cdf0e10cSrcweir 276cdf0e10cSrcweir virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel ); 277cdf0e10cSrcweir virtual void DragFinished( sal_Int8 ); 278cdf0e10cSrcweir virtual DragDropMode NotifyStartDrag( TransferDataContainer& rData, 279cdf0e10cSrcweir SvLBoxEntry* ); 280cdf0e10cSrcweir virtual sal_Bool NotifyAcceptDrop( SvLBoxEntry* ); 281cdf0e10cSrcweir 282cdf0e10cSrcweir virtual void MouseButtonDown( const MouseEvent& rMEvt ); 283cdf0e10cSrcweir virtual void KeyInput(const KeyEvent& rKEvt); 284cdf0e10cSrcweir virtual void GetFocus(); 285cdf0e10cSrcweir virtual void SelectHdl(); 286cdf0e10cSrcweir virtual void DeselectHdl(); 287cdf0e10cSrcweir virtual void InitEntry(SvLBoxEntry*,const XubString&,const Image&,const Image&,SvLBoxButtonKind); 288cdf0e10cSrcweir 289cdf0e10cSrcweir void Clear(); 290cdf0e10cSrcweir 291cdf0e10cSrcweir DECL_LINK( PopupHdl, Menu* ); 292cdf0e10cSrcweir DECL_LINK( Timeout, Timer* ); 293cdf0e10cSrcweir DECL_LINK( DoubleClickHdl, SwGlobalTree * ); 294cdf0e10cSrcweir 295cdf0e10cSrcweir sal_Bool IsInternalDrag() const {return bIsInternalDrag != 0;} 296cdf0e10cSrcweir SwNavigationPI* GetParentWindow() 297cdf0e10cSrcweir { return (SwNavigationPI*)Window::GetParent(); } 298cdf0e10cSrcweir 299cdf0e10cSrcweir void OpenDoc(const SwGlblDocContent*); 300cdf0e10cSrcweir void GotoContent(const SwGlblDocContent*); 301cdf0e10cSrcweir sal_uInt16 GetEnableFlags() const; 302cdf0e10cSrcweir 303cdf0e10cSrcweir static const SfxObjectShell* GetShowShell() {return pShowShell;} 304cdf0e10cSrcweir static void SetShowShell(const SfxObjectShell*pSet) {pShowShell = pSet;} 305cdf0e10cSrcweir DECL_STATIC_LINK(SwGlobalTree, ShowFrameHdl, SwGlobalTree*); 306cdf0e10cSrcweir 307cdf0e10cSrcweir virtual PopupMenu* CreateContextMenu( void ); 308cdf0e10cSrcweir virtual void ExcecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry ); 309cdf0e10cSrcweir 310cdf0e10cSrcweir public: 311cdf0e10cSrcweir SwGlobalTree(Window* pParent, const ResId& rResId); 312cdf0e10cSrcweir virtual ~SwGlobalTree(); 313cdf0e10cSrcweir 314cdf0e10cSrcweir void TbxMenuHdl(sal_uInt16 nTbxId, ToolBox* pBox); 315cdf0e10cSrcweir void InsertRegion( const SwGlblDocContent* pCont, 316cdf0e10cSrcweir const String* pFileName = 0 ); 317cdf0e10cSrcweir void EditContent(const SwGlblDocContent* pCont ); 318cdf0e10cSrcweir 319cdf0e10cSrcweir void ShowTree(); 320cdf0e10cSrcweir void HideTree(); 321cdf0e10cSrcweir 322cdf0e10cSrcweir void ExecCommand(sal_uInt16 nCmd); 323cdf0e10cSrcweir 324cdf0e10cSrcweir void Display(sal_Bool bOnlyUpdateUserData = sal_False); 325cdf0e10cSrcweir 326cdf0e10cSrcweir sal_Bool Update(sal_Bool bHard); 327cdf0e10cSrcweir }; 328cdf0e10cSrcweir 329cdf0e10cSrcweir #endif 330cdf0e10cSrcweir 331