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