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