1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: glbltree.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
35 #define _SVSTDARR_STRINGSDTOR
36 #include <svtools/svstdarr.hxx>
38 #ifndef _MSGBOX_HXX //autogen
39 #include <vcl/msgbox.hxx>
41 #include <svtools/stritem.hxx>
42 #include <sfx2/fcontnr.hxx>
43 #include <svx/linkmgr.hxx>
44 #include <sfx2/dispatch.hxx>
45 #include <svtools/urihelper.hxx>
46 #include <sfx2/docfile.hxx>
47 #ifndef _HELP_HXX //autogen
48 #include <vcl/help.hxx>
50 #include <sot/filelist.hxx>
51 #include <svtools/eitem.hxx>
52 #include <svtools/urlbmk.hxx>
53 #include <svtools/filter.hxx>
54 #include <sfx2/docinsert.hxx>
55 #include <sfx2/filedlghelper.hxx>
57 #include <sfx2/app.hxx>
58 #include <swmodule.hxx>
67 #include <content.hxx>
68 #include <edglbldc.hxx>
69 #include <section.hxx>
74 #include <navicont.hxx>
91 #include <comcore.hrc>
93 #include <globals.hrc>
94 #include "swabstdlg.hxx"
96 using namespace ::com::sun::star::uno
;
97 using ::rtl::OUString
;
100 // Kontextmenue fuer GlobalTree
101 #define CTX_INSERT_ANY_INDEX 10
102 //#define CTX_INSERT_CNTIDX 11
103 //#define CTX_INSERT_USRIDX 12
104 #define CTX_INSERT_FILE 11
105 #define CTX_INSERT_NEW_FILE 12
106 #define CTX_INSERT_TEXT 13
108 #define CTX_UPDATE_SEL 20
109 #define CTX_UPDATE_INDEX 21
110 #define CTX_UPDATE_LINK 22
111 #define CTX_UPDATE_ALL 23
117 #define CTX_EDIT_LINK 5
119 #define GLOBAL_UPDATE_TIMEOUT 2000
121 // Flags fuer PopupMenu-enable/disable
122 #define ENABLE_INSERT_IDX 0x0001
123 #define ENABLE_INSERT_FILE 0x0002
124 #define ENABLE_INSERT_TEXT 0x0004
125 #define ENABLE_EDIT 0x0008
126 #define ENABLE_DELETE 0x0010
127 #define ENABLE_UPDATE 0x0020
128 #define ENABLE_UPDATE_SEL 0x0040
129 #define ENABLE_EDIT_LINK 0x0080
131 // TabPos nach links schieben
132 #define GLBL_TABPOS_SUB 5
134 const SfxObjectShell
* SwGlobalTree::pShowShell
= 0;
135 static const USHORT __FAR_DATA aHelpForMenu
[] =
138 HID_GLBLTREE_UPDATE
, //CTX_UPDATE
139 HID_GLBLTREE_INSERT
, //CTX_INSERT
140 HID_GLBLTREE_EDIT
, //CTX_EDIT
141 HID_GLBLTREE_DEL
, //CTX_DELETE
142 HID_GLBLTREE_EDIT_LINK
, //CTX_EDIT_LINK
147 HID_GLBLTREE_INS_IDX
, //CTX_INSERT_ANY_INDEX
148 HID_GLBLTREE_INS_FILE
, //CTX_INSERT_FILE
149 HID_GLBLTREE_INS_NEW_FILE
, //CTX_INSERT_NEW_FILE
150 HID_GLBLTREE_INS_TEXT
, //CTX_INSERT_TEXT
157 HID_GLBLTREE_UPD_SEL
, //CTX_UPDATE_SEL
158 HID_GLBLTREE_UPD_IDX
, //CTX_UPDATE_INDEX
159 HID_GLBLTREE_UPD_LINK
, //CTX_UPDATE_LINK
160 HID_GLBLTREEUPD_ALL
//CTX_UPDATE_ALL
163 /************************************************************************/
165 /************************************************************************/
166 /* -----------------------------24.08.00 12:04--------------------------------
168 ---------------------------------------------------------------------------*/
169 class SwGlobalFrameListener_Impl
: public SfxListener
173 SwGlobalFrameListener_Impl(SfxViewFrame
& rFrame
) :
176 StartListening(rFrame
);
179 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
);
181 BOOL
IsValid() const {return bValid
;}
183 /* -----------------------------24.08.00 12:05--------------------------------
185 ---------------------------------------------------------------------------*/
186 void SwGlobalFrameListener_Impl::Notify( SfxBroadcaster
& /*rBC*/, const SfxHint
& rHint
)
188 if( rHint
.ISA(SfxSimpleHint
) &&
189 (((SfxSimpleHint
&) rHint
).GetId() == SFX_HINT_DYING
))
193 /*-----------------12.06.97 09:38-------------------
195 --------------------------------------------------*/
196 SwGlobalTree::SwGlobalTree(Window
* pParent
, const ResId
& rResId
) :
198 SvTreeListBox(pParent
, rResId
),
200 pActiveShell ( NULL
),
201 pEmphasisEntry ( NULL
),
203 pSwGlblDocContents ( NULL
),
204 pDefParentWin ( NULL
),
205 pDocContent ( NULL
),
206 pDocInserter ( NULL
),
208 bIsInternalDrag ( FALSE
),
209 bLastEntryEmphasis ( FALSE
),
210 bIsImageListInitialized ( FALSE
)
213 SetDragDropMode(SV_DRAGDROP_APP_COPY
|
214 SV_DRAGDROP_CTRL_MOVE
|
215 SV_DRAGDROP_ENABLE_TOP
);
217 aUpdateTimer
.SetTimeout(GLOBAL_UPDATE_TIMEOUT
);
218 aUpdateTimer
.SetTimeoutHdl(LINK(this, SwGlobalTree
, Timeout
));
219 aUpdateTimer
.Start();
220 for(USHORT i
= 0; i
< GLOBAL_CONTEXT_COUNT
; i
++)
222 aContextStrings
[i
] = SW_RESSTR(i
+ ST_GLOBAL_CONTEXT_FIRST
);
224 SetHelpId(HID_NAVIGATOR_GLOB_TREELIST
);
226 SetDoubleClickHdl(LINK(this, SwGlobalTree
, DoubleClickHdl
));
227 EnableContextMenuHandling();
230 /*-----------------12.06.97 09:38-------------------
232 --------------------------------------------------*/
233 SwGlobalTree::~SwGlobalTree()
235 delete pSwGlblDocContents
;
239 /*-----------------12.06.97 09:38-------------------
241 --------------------------------------------------*/
242 sal_Int8
SwGlobalTree::ExecuteDrop( const ExecuteDropEvent
& rEvt
)
244 sal_Int8 nRet
= DND_ACTION_NONE
;
245 SvLBoxEntry
* pLast
= (SvLBoxEntry
*)LastVisible();
248 ImplShowTargetEmphasis( Prev(pEmphasisEntry
), FALSE
);
251 else if(bLastEntryEmphasis
&& pLast
)
253 ImplShowTargetEmphasis( pLast
, FALSE
);
256 SvLBoxEntry
* pDropEntry
= bLastEntryEmphasis
? 0 : GetEntry(rEvt
.maPosPixel
);
257 if( bIsInternalDrag
)
259 SvLBoxEntry
* pDummy
= 0;
260 ULONG nInsertionPos
= LIST_APPEND
;
261 NotifyMoving( pDropEntry
, pDDSource
, pDummy
, nInsertionPos
);
265 TransferableDataHelper
aData( rEvt
.maDropEvent
.Transferable
);
268 const SwGlblDocContent
* pCnt
= pDropEntry
?
269 (const SwGlblDocContent
*)pDropEntry
->GetUserData() :
271 if( aData
.HasFormat( FORMAT_FILE_LIST
))
273 nRet
= rEvt
.mnAction
;
274 SwGlblDocContents
* pTempContents
= new SwGlblDocContents
;
275 int nAbsContPos
= pDropEntry
?
276 (int) GetModel()->GetAbsPos(pDropEntry
):
278 USHORT nEntryCount
= (USHORT
)GetEntryCount();
282 aData
.GetFileList( FORMAT_FILE_LIST
, aFileList
);
283 for ( USHORT n
= (USHORT
)aFileList
.Count(); n
--; )
285 sFileName
= aFileList
.GetFile(n
);
286 InsertRegion(pCnt
, &sFileName
);
287 // nach dem Einfuegen muss die Liste der Contents neu
288 // geholt werden, um nicht auf einem alten Content zu
292 pActiveShell
->GetGlobalDocContent(*pTempContents
);
293 // wenn das file erfolgreich eingefuegt wurde,
294 // dann muss auch der naechste Content geholt werden
295 if(nEntryCount
< pTempContents
->Count())
299 pCnt
= pTempContents
->GetObject( static_cast< USHORT
>(nAbsContPos
) );
303 delete pTempContents
;
305 else if( 0 != (sFileName
=
306 SwNavigationPI::CreateDropFileName( aData
)).Len())
308 INetURLObject
aTemp(sFileName
);
309 GraphicDescriptor
aDesc(aTemp
);
310 if( !aDesc
.Detect() ) // keine Grafiken annehmen
312 nRet
= rEvt
.mnAction
;
313 InsertRegion(pCnt
, &sFileName
);
317 bLastEntryEmphasis
= FALSE
;
321 /*-----------------12.06.97 09:38-------------------
323 --------------------------------------------------*/
324 sal_Int8
SwGlobalTree::AcceptDrop( const AcceptDropEvent
& rEvt
)
326 sal_Int8 nRet
= rEvt
.mnAction
;
329 GetDropTarget( rEvt
.maPosPixel
);
330 SvLBoxEntry
* pLast
= (SvLBoxEntry
*)LastVisible();
335 ImplShowTargetEmphasis( Prev(pEmphasisEntry
), FALSE
);
338 else if(bLastEntryEmphasis
&& pLast
)
340 ImplShowTargetEmphasis( pLast
, FALSE
);
342 bLastEntryEmphasis
= FALSE
;
346 SvLBoxEntry
* pDropEntry
= GetEntry( rEvt
.maPosPixel
);
349 if( pDDSource
!= pDropEntry
)
350 nRet
= rEvt
.mnAction
;
352 else if( IsDropFormatSupported( FORMAT_FILE
) ||
353 IsDropFormatSupported( FORMAT_STRING
) ||
354 IsDropFormatSupported( FORMAT_FILE_LIST
) ||
355 IsDropFormatSupported( SOT_FORMATSTR_ID_SOLK
) ||
356 IsDropFormatSupported( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK
)||
357 IsDropFormatSupported( SOT_FORMATSTR_ID_FILECONTENT
) ||
358 IsDropFormatSupported( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR
) ||
359 IsDropFormatSupported( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR
) ||
360 IsDropFormatSupported( SOT_FORMATSTR_ID_FILENAME
))
361 nRet
= DND_ACTION_LINK
;
363 if(pEmphasisEntry
&& pEmphasisEntry
!= pDropEntry
)
364 ImplShowTargetEmphasis( Prev(pEmphasisEntry
), FALSE
);
365 else if(pLast
&& bLastEntryEmphasis
&& pDropEntry
)
367 ImplShowTargetEmphasis( pLast
, FALSE
);
368 bLastEntryEmphasis
= FALSE
;
372 ImplShowTargetEmphasis( Prev(pDropEntry
), DND_ACTION_NONE
!= nRet
);
375 ImplShowTargetEmphasis( pLast
, DND_ACTION_NONE
!= nRet
);
376 bLastEntryEmphasis
= TRUE
;
378 pEmphasisEntry
= pDropEntry
;
382 /*-----------------12.06.97 09:38-------------------
384 --------------------------------------------------*/
385 PopupMenu
* SwGlobalTree::CreateContextMenu()
389 !pActiveShell
->GetView().GetDocShell()->IsReadOnly())
391 USHORT nEnableFlags
= GetEnableFlags();
392 pPop
= new PopupMenu
;
393 PopupMenu
* pSubPop1
= new PopupMenu
;
394 PopupMenu
* pSubPop2
= new PopupMenu
;
396 for (USHORT i
= CTX_UPDATE_SEL
; i
<= CTX_UPDATE_ALL
; i
++)
398 pSubPop2
->InsertItem( i
, aContextStrings
[ST_UPDATE_SEL
- ST_GLOBAL_CONTEXT_FIRST
- CTX_UPDATE_SEL
+ i
] );
399 pSubPop2
->SetHelpId(i
, aHelpForMenu
[i
]);
401 pSubPop2
->EnableItem(CTX_UPDATE_SEL
, 0 != (nEnableFlags
& ENABLE_UPDATE_SEL
));
403 pSubPop1
->InsertItem(CTX_INSERT_ANY_INDEX
, aContextStrings
[ST_INDEX
- ST_GLOBAL_CONTEXT_FIRST
]);
404 pSubPop1
->SetHelpId(CTX_INSERT_ANY_INDEX
, aHelpForMenu
[CTX_INSERT_ANY_INDEX
]);
405 pSubPop1
->InsertItem(CTX_INSERT_FILE
, aContextStrings
[ST_FILE
- ST_GLOBAL_CONTEXT_FIRST
]);
406 pSubPop1
->SetHelpId(CTX_INSERT_FILE
, aHelpForMenu
[CTX_INSERT_FILE
]);
407 pSubPop1
->InsertItem(CTX_INSERT_NEW_FILE
, aContextStrings
[ST_NEW_FILE
- ST_GLOBAL_CONTEXT_FIRST
]);
408 pSubPop1
->SetHelpId(CTX_INSERT_NEW_FILE
, aHelpForMenu
[CTX_INSERT_NEW_FILE
]);
409 pSubPop1
->InsertItem(CTX_INSERT_TEXT
, aContextStrings
[ST_TEXT
- ST_GLOBAL_CONTEXT_FIRST
]);
410 pSubPop1
->SetHelpId(CTX_INSERT_TEXT
, aHelpForMenu
[CTX_INSERT_TEXT
]);
413 pPop
->InsertItem(CTX_UPDATE
, aContextStrings
[ST_UPDATE
- ST_GLOBAL_CONTEXT_FIRST
]);
414 pPop
->SetHelpId(CTX_UPDATE
, aHelpForMenu
[CTX_UPDATE
]);
415 pPop
->InsertItem(CTX_EDIT
, aContextStrings
[ST_EDIT_CONTENT
- ST_GLOBAL_CONTEXT_FIRST
]);
416 pPop
->SetHelpId(CTX_EDIT
, aHelpForMenu
[CTX_EDIT
]);
417 if(nEnableFlags
&ENABLE_EDIT_LINK
)
419 pPop
->InsertItem(CTX_EDIT_LINK
, aContextStrings
[ST_EDIT_LINK
- ST_GLOBAL_CONTEXT_FIRST
]);
420 pPop
->SetHelpId(CTX_EDIT_LINK
, aHelpForMenu
[CTX_EDIT_LINK
]);
422 pPop
->InsertItem(CTX_INSERT
, aContextStrings
[ST_INSERT
- ST_GLOBAL_CONTEXT_FIRST
]);
423 pPop
->SetHelpId(CTX_INSERT
, aHelpForMenu
[CTX_INSERT
]);
424 pPop
->InsertSeparator() ;
425 pPop
->InsertItem(CTX_DELETE
, aContextStrings
[ST_DELETE
- ST_GLOBAL_CONTEXT_FIRST
]);
426 pPop
->SetHelpId(CTX_DELETE
, aHelpForMenu
[CTX_DELETE
]);
429 pSubPop1
->EnableItem(CTX_INSERT_ANY_INDEX
, 0 != (nEnableFlags
& ENABLE_INSERT_IDX
));
430 pSubPop1
->EnableItem(CTX_INSERT_TEXT
, 0 != (nEnableFlags
& ENABLE_INSERT_TEXT
));
431 pSubPop1
->EnableItem(CTX_INSERT_FILE
, 0 != (nEnableFlags
& ENABLE_INSERT_FILE
));
432 pSubPop1
->EnableItem(CTX_INSERT_NEW_FILE
, 0 != (nEnableFlags
& ENABLE_INSERT_FILE
));
434 pPop
->EnableItem(CTX_UPDATE
, 0 != (nEnableFlags
& ENABLE_UPDATE
));
435 pPop
->EnableItem(CTX_INSERT
, 0 != (nEnableFlags
& ENABLE_INSERT_IDX
));
436 pPop
->EnableItem(CTX_EDIT
, 0 != (nEnableFlags
& ENABLE_EDIT
));
437 pPop
->EnableItem(CTX_DELETE
, 0 != (nEnableFlags
& ENABLE_DELETE
));
440 pPop
->SetPopupMenu( CTX_INSERT
, pSubPop1
);
441 pPop
->SetPopupMenu( CTX_UPDATE
, pSubPop2
);
445 /*-----------------16.06.97 10:41-------------------
447 --------------------------------------------------*/
448 void SwGlobalTree::TbxMenuHdl(USHORT nTbxId
, ToolBox
* pBox
)
450 USHORT nEnableFlags
= GetEnableFlags();
451 if(FN_GLOBAL_OPEN
== nTbxId
)
453 PopupMenu
*pMenu
= new PopupMenu
;
454 for (USHORT i
= CTX_INSERT_ANY_INDEX
; i
<= CTX_INSERT_TEXT
; i
++)
456 pMenu
->InsertItem( i
, aContextStrings
[ST_INDEX
- ST_GLOBAL_CONTEXT_FIRST
- CTX_INSERT_ANY_INDEX
+ i
] );
457 pMenu
->SetHelpId(i
, aHelpForMenu
[i
] );
459 pMenu
->EnableItem(CTX_INSERT_ANY_INDEX
, 0 != (nEnableFlags
& ENABLE_INSERT_IDX
));
460 // pMenu->EnableItem(CTX_INSERT_CNTIDX, 0 != (nEnableFlags & ENABLE_INSERT_IDX ));
461 // pMenu->EnableItem(CTX_INSERT_USRIDX, 0 != (nEnableFlags & ENABLE_INSERT_IDX ));
462 pMenu
->EnableItem(CTX_INSERT_TEXT
, 0 != (nEnableFlags
& ENABLE_INSERT_TEXT
));
463 pMenu
->EnableItem(CTX_INSERT_FILE
, 0 != (nEnableFlags
& ENABLE_INSERT_FILE
));
464 pMenu
->EnableItem(CTX_INSERT_NEW_FILE
, 0 != (nEnableFlags
& ENABLE_INSERT_FILE
));
465 pMenu
->SetSelectHdl(LINK(this, SwGlobalTree
, PopupHdl
));
466 pMenu
->Execute( pBox
, pBox
->GetItemRect(nTbxId
).BottomLeft());
468 pBox
->EndSelection();
471 else if(FN_GLOBAL_UPDATE
== nTbxId
)
473 PopupMenu
*pMenu
= new PopupMenu
;
474 for (USHORT i
= CTX_UPDATE_SEL
; i
<= CTX_UPDATE_ALL
; i
++)
476 pMenu
->InsertItem( i
, aContextStrings
[ST_UPDATE_SEL
- ST_GLOBAL_CONTEXT_FIRST
- CTX_UPDATE_SEL
+ i
] );
477 pMenu
->SetHelpId(i
, aHelpForMenu
[i
] );
479 pMenu
->EnableItem(CTX_UPDATE_SEL
, 0 != (nEnableFlags
& ENABLE_UPDATE_SEL
));
480 pMenu
->SetSelectHdl(LINK(this, SwGlobalTree
, PopupHdl
));
481 pMenu
->Execute( pBox
, pBox
->GetItemRect(nTbxId
).BottomLeft());
483 pBox
->EndSelection();
487 /*-----------------16.06.97 11:02-------------------
489 --------------------------------------------------*/
490 USHORT
SwGlobalTree::GetEnableFlags() const
492 SvLBoxEntry
* pEntry
= FirstSelected();
493 USHORT nSelCount
= (USHORT
)GetSelectionCount();
494 USHORT nEntryCount
= (USHORT
)GetEntryCount();
495 SvLBoxEntry
* pPrevEntry
= pEntry
? Prev(pEntry
) : 0;
498 if(nSelCount
== 1 || !nEntryCount
)
499 nRet
|= ENABLE_INSERT_IDX
|ENABLE_INSERT_FILE
;
503 if( ((SwGlblDocContent
*)pEntry
->GetUserData())->GetType() != GLBLDOC_UNKNOWN
&&
504 (!pPrevEntry
|| ((SwGlblDocContent
*)pPrevEntry
->GetUserData())->GetType() != GLBLDOC_UNKNOWN
))
505 nRet
|= ENABLE_INSERT_TEXT
;
506 if( GLBLDOC_SECTION
== ((SwGlblDocContent
*)pEntry
->GetUserData())->GetType() )
507 nRet
|= ENABLE_EDIT_LINK
;
509 else if(!nEntryCount
)
511 nRet
|= ENABLE_INSERT_TEXT
;
514 nRet
|= ENABLE_UPDATE
|ENABLE_DELETE
;
516 nRet
|= ENABLE_UPDATE_SEL
;
520 /*-----------------12.06.97 09:38-------------------
522 --------------------------------------------------*/
523 void SwGlobalTree::RequestHelp( const HelpEvent
& rHEvt
)
528 if( rHEvt
.GetMode() & HELPMODE_QUICK
)
530 Point
aPos( ScreenToOutputPixel( rHEvt
.GetMousePosPixel() ));
531 SvLBoxEntry
* pEntry
= GetEntry( aPos
);
532 const SwGlblDocContent
* pCont
= pEntry
?
533 (const SwGlblDocContent
*)pEntry
->GetUserData() : 0;
534 if( pCont
&& GLBLDOC_SECTION
== pCont
->GetType())
538 SvLBoxItem
* pItem
= GetItem( pEntry
, aPos
.X(), &pTab
);
539 if(pItem
&& SV_ITEM_ID_LBOXSTRING
== pItem
->IsA())
541 const SwSection
* pSect
= pCont
->GetSection();
542 String sEntry
= pSect
->GetLinkFileName().GetToken(0, sfx2::cTokenSeperator
);
543 if(!pSect
->IsConnectFlag())
544 sEntry
.Insert(aContextStrings
[ST_BROKEN_LINK
- ST_GLOBAL_CONTEXT_FIRST
], 0 );
545 Point aEntryPos
= GetEntryPosition( pEntry
);
547 aEntryPos
.X() = GetTabPos( pEntry
, pTab
);
548 Size
aSize( pItem
->GetSize( this, pEntry
) );
550 if((aEntryPos
.X() + aSize
.Width()) > GetSizePixel().Width())
551 aSize
.Width() = GetSizePixel().Width() - aEntryPos
.X();
553 aEntryPos
= OutputToScreenPixel(aEntryPos
);
554 Rectangle
aItemRect( aEntryPos
, aSize
);
555 if(Help::IsBalloonHelpEnabled())
557 aEntryPos
.X() += aSize
.Width();
558 Help::ShowBalloon( this, aEntryPos
, aItemRect
, sEntry
);
561 Help::ShowQuickHelp( this, aItemRect
, sEntry
,
562 QUICKHELP_LEFT
|QUICKHELP_VCENTER
);
568 SvTreeListBox::RequestHelp(rHEvt
);
570 /*-----------------16.06.97 16:15-------------------
572 --------------------------------------------------*/
573 void SwGlobalTree::SelectHdl()
576 USHORT nSelCount
= (USHORT
)GetSelectionCount();
577 SvLBoxEntry
* pSel
= FirstSelected();
578 USHORT nAbsPos
= pSel
? (USHORT
)GetModel()->GetAbsPos(pSel
) : 0;
579 SwNavigationPI
* pNavi
= GetParentWindow();
580 BOOL bReadonly
= !pActiveShell
||
581 pActiveShell
->GetView().GetDocShell()->IsReadOnly();
582 pNavi
->aGlobalToolBox
.EnableItem(FN_GLOBAL_EDIT
, nSelCount
== 1 && !bReadonly
);
583 pNavi
->aGlobalToolBox
.EnableItem(FN_GLOBAL_OPEN
, nSelCount
<= 1 && !bReadonly
);
584 pNavi
->aGlobalToolBox
.EnableItem(FN_GLOBAL_UPDATE
, GetEntryCount() > 0 && !bReadonly
);
585 pNavi
->aGlobalToolBox
.EnableItem(FN_ITEM_UP
,
586 nSelCount
== 1 && nAbsPos
&& !bReadonly
);
587 pNavi
->aGlobalToolBox
.EnableItem(FN_ITEM_DOWN
,
588 nSelCount
== 1 && nAbsPos
< ((USHORT
)GetEntryCount()) - 1 && !bReadonly
);
591 /*-----------------16.06.97 16:15-------------------
593 --------------------------------------------------*/
594 void SwGlobalTree::DeselectHdl()
599 /*-----------------17.06.97 13:11-------------------
601 --------------------------------------------------*/
602 DragDropMode
SwGlobalTree::NotifyStartDrag( TransferDataContainer
& ,
603 SvLBoxEntry
* pEntry
)
605 bIsInternalDrag
= TRUE
;
607 return SV_DRAGDROP_CTRL_MOVE
;
610 /*-----------------21.06.97 12:44-------------------
612 --------------------------------------------------*/
613 long SwGlobalTree::GetTabPos( SvLBoxEntry
*, SvLBoxTab
* pTab
)
615 return pTab
->GetPos() - GLBL_TABPOS_SUB
;
618 /*-----------------12.06.97 09:38-------------------
620 --------------------------------------------------*/
621 BOOL
SwGlobalTree::NotifyMoving( SvLBoxEntry
* pTarget
,
622 SvLBoxEntry
* pSource
,
627 SvTreeList
* _pModel
= GetModel();
628 USHORT nSource
= (USHORT
) _pModel
->GetAbsPos(pSource
);
629 USHORT nDest
= pTarget
? (USHORT
) _pModel
->GetAbsPos(pTarget
) : pSwGlblDocContents
->Count();
631 if( pActiveShell
->MoveGlobalDocContent(
632 *pSwGlblDocContents
, nSource
, nSource
+ 1, nDest
) &&
637 /*-----------------12.06.97 09:39-------------------
639 --------------------------------------------------*/
640 BOOL
SwGlobalTree::NotifyCopying( SvLBoxEntry
* /*pTarget*/,
641 SvLBoxEntry
* /*pEntry*/,
642 SvLBoxEntry
*& /*rpNewParent*/,
643 ULONG
& /*rNewChildPos*/
648 /*-----------------12.06.97 09:39-------------------
650 --------------------------------------------------*/
651 BOOL
SwGlobalTree::NotifyAcceptDrop( SvLBoxEntry
* pEntry
)
655 /*-----------------12.06.97 09:39-------------------
657 --------------------------------------------------*/
658 void SwGlobalTree::StartDrag( sal_Int8 nAction
, const Point
& rPt
)
660 if( 1 == GetSelectionCount() )
661 SvTreeListBox::StartDrag( nAction
, rPt
);
663 /*-----------------12.06.97 09:39-------------------
665 --------------------------------------------------*/
666 void SwGlobalTree::DragFinished( sal_Int8 nAction
)
668 SvTreeListBox::DragFinished( nAction
);
669 bIsInternalDrag
= FALSE
;
672 /***************************************************************************
673 Beschreibung: Wird ein Ctrl+DoubleClick in einen freien Bereich ausgefuehrt,
674 * dann soll die Basisfunktion des Controls gerufen werden
675 ***************************************************************************/
676 void SwGlobalTree::MouseButtonDown( const MouseEvent
& rMEvt
)
678 Point
aPos( rMEvt
.GetPosPixel());
679 SvLBoxEntry
* pEntry
= GetEntry( aPos
, TRUE
);
680 if( !pEntry
&& rMEvt
.IsLeft() && rMEvt
.IsMod1() && (rMEvt
.GetClicks() % 2) == 0)
681 Control::MouseButtonDown( rMEvt
);
683 SvTreeListBox::MouseButtonDown( rMEvt
);
686 /*-----------------12.06.97 13:08-------------------
688 --------------------------------------------------*/
689 void SwGlobalTree::GetFocus()
693 SvTreeListBox::GetFocus();
696 /*-----------------12.06.97 12:34-------------------
698 --------------------------------------------------*/
699 void SwGlobalTree::KeyInput(const KeyEvent
& rKEvt
)
701 const KeyCode aCode
= rKEvt
.GetKeyCode();
702 if(aCode
.GetCode() == KEY_RETURN
)
704 switch(aCode
.GetModifier())
708 GetParentWindow()->ToggleTree();
713 SvTreeListBox::KeyInput(rKEvt
);
716 /*-----------------17.06.97 11:59-------------------
718 --------------------------------------------------*/
719 void SwGlobalTree::Clear()
722 SvTreeListBox::Clear();
724 /*-----------------12.06.97 12:38-------------------
726 --------------------------------------------------*/
727 void SwGlobalTree::Display(BOOL bOnlyUpdateUserData
)
729 if(!bIsImageListInitialized
)
731 USHORT nResId
= GetDisplayBackground().GetColor().IsDark() ? IMG_NAVI_ENTRYBMPH
: IMG_NAVI_ENTRYBMP
;
732 aEntryImages
= ImageList(SW_RES(nResId
));
733 bIsImageListInitialized
= TRUE
;
735 USHORT nCount
= pSwGlblDocContents
->Count();
736 if(bOnlyUpdateUserData
&& GetEntryCount() == pSwGlblDocContents
->Count())
738 SvLBoxEntry
* pEntry
= First();
739 for( USHORT i
= 0; i
< nCount
; i
++)
741 SwGlblDocContentPtr pCont
= pSwGlblDocContents
->GetObject(i
);
742 pEntry
->SetUserData(pCont
);
743 pEntry
= Next(pEntry
);
748 SetUpdateMode( FALSE
);
749 SvLBoxEntry
* pOldSelEntry
= FirstSelected();
750 String sEntryName
; // Name des Eintrags
751 USHORT nSelPos
= USHRT_MAX
;
754 sEntryName
= GetEntryText(pOldSelEntry
);
755 nSelPos
= (USHORT
)GetModel()->GetAbsPos(pOldSelEntry
);
758 if(!pSwGlblDocContents
)
761 SvLBoxEntry
* pSelEntry
= 0;
762 for( USHORT i
= 0; i
< nCount
; i
++)
764 SwGlblDocContentPtr pCont
= pSwGlblDocContents
->GetObject(i
);
767 switch( pCont
->GetType() )
769 case GLBLDOC_UNKNOWN
:
771 sEntry
= aContextStrings
[ST_TEXT
- ST_GLOBAL_CONTEXT_FIRST
];
772 aImage
= aEntryImages
.GetImage(SID_SW_START
+ GLOBAL_CONTENT_TEXT
);
775 case GLBLDOC_TOXBASE
:
777 const SwTOXBase
* pBase
= pCont
->GetTOX();
778 sEntry
= pBase
->GetTitle();
779 aImage
= aEntryImages
.GetImage(SID_SW_START
+ CONTENT_TYPE_INDEX
);
782 case GLBLDOC_SECTION
:
784 const SwSection
* pSect
= pCont
->GetSection();
785 sEntry
= pSect
->GetName();
786 aImage
= aEntryImages
.GetImage(SID_SW_START
+ CONTENT_TYPE_REGION
);
790 SvLBoxEntry
* pEntry
= InsertEntry(sEntry
, aImage
, aImage
,
791 0, FALSE
, LIST_APPEND
, pCont
);
792 if(sEntry
== sEntryName
)
801 else if(nSelPos
!= USHRT_MAX
&& nSelPos
< nCount
)
803 Select(GetEntry(nSelPos
));
809 SetUpdateMode( TRUE
);
813 /*-----------------13.06.97 10:32-------------------
815 --------------------------------------------------*/
816 void SwGlobalTree::InsertRegion( const SwGlblDocContent
* pCont
, const String
* pFileName
)
818 Sequence
< OUString
> aFileNames
;
821 pDefParentWin
= Application::GetDefDialogParent();
822 Application::SetDefDialogParent( this );
825 pDocInserter
= new ::sfx2::DocumentInserter( 0, String::CreateFromAscii("swriter"), true );
826 pDocInserter
->StartExecuteModal( LINK( this, SwGlobalTree
, DialogClosedHdl
) );
828 else if ( pFileName
->Len() )
830 aFileNames
.realloc(1);
831 INetURLObject aFileName
;
832 aFileName
.SetSmartURL( *pFileName
);
833 aFileNames
.getArray()[0] = aFileName
.GetMainURL( INetURLObject::NO_DECODE
);
834 InsertRegion( pCont
, aFileNames
);
838 /*-----------------18.06.97 12:42-------------------
840 --------------------------------------------------*/
841 void SwGlobalTree::EditContent(const SwGlblDocContent
* pCont
)
844 switch( pCont
->GetType() )
846 case GLBLDOC_UNKNOWN
:
847 pActiveShell
->GetView().GetEditWin().GrabFocus();
849 case GLBLDOC_TOXBASE
:
851 const SwTOXBase
* pBase
= pCont
->GetTOX();
853 nSlot
= FN_INSERT_MULTI_TOX
;
856 case GLBLDOC_SECTION
:
869 pActiveShell
->GetView().GetViewFrame()->GetDispatcher()->Execute(nSlot
);
875 /*-----------------13.06.97 14:22-------------------
877 --------------------------------------------------*/
878 IMPL_LINK( SwGlobalTree
, PopupHdl
, Menu
* , pMenu
)
880 ExcecuteContextMenuAction( pMenu
->GetCurItemId());
883 /* -----------------26.08.2003 11:57-----------------
885 --------------------------------------------------*/
886 void SwGlobalTree::ExcecuteContextMenuAction( USHORT nSelectedPopupEntry
)
887 //IMPL_LINK( SwGlobalTree, PopupHdl, Menu* , pMenu)
889 // USHORT nId = pMenu->GetCurItemId();
890 SvLBoxEntry
* pEntry
= FirstSelected();
891 SwGlblDocContent
* pCont
= pEntry
? (SwGlblDocContent
*)pEntry
->GetUserData() : 0;
892 // wird waehrend des Dialogs ein RequestHelp gerufen,
893 // dann geht der Content verloren. Deshalb wird hier eine
894 // Kopie angelegt, in der nur die DocPos richtig gesetzt ist.
895 SwGlblDocContent
* pContCopy
= 0;
897 pContCopy
= new SwGlblDocContent(pCont
->GetDocPos());
898 SfxDispatcher
& rDispatch
= *pActiveShell
->GetView().GetViewFrame()->GetDispatcher();
900 bool bDeleteContentCopy
= true;
901 switch( nSelectedPopupEntry
)
905 // zwei Durchlaeufe: zuerst die Bereiche, dann die Verzeichnisse
907 SvLBoxEntry
* pSelEntry
= FirstSelected();
910 SwGlblDocContent
* pContent
= (SwGlblDocContent
*)pSelEntry
->GetUserData();
911 if(GLBLDOC_SECTION
== pContent
->GetType() &&
912 pContent
->GetSection()->IsConnected())
914 ((SwSection
*)pContent
->GetSection())->UpdateNow();
917 pSelEntry
= NextSelected(pSelEntry
);
919 pSelEntry
= FirstSelected();
922 SwGlblDocContent
* pContent
= (SwGlblDocContent
*)pSelEntry
->GetUserData();
923 if(GLBLDOC_TOXBASE
== pContent
->GetType())
924 pActiveShell
->UpdateTableOf(*pContent
->GetTOX());
925 pSelEntry
= NextSelected(pSelEntry
);
930 case CTX_UPDATE_INDEX
:
932 nSlot
= FN_UPDATE_TOX
;
935 case CTX_UPDATE_LINK
:
938 pActiveShell
->GetLinkManager().UpdateAllLinks(TRUE
);
939 if(CTX_UPDATE_ALL
== nSelectedPopupEntry
)
940 nSlot
= FN_UPDATE_TOX
;
946 DBG_ASSERT(pCont
, "Edit ohne Entry ? " );
952 DBG_ASSERT(pCont
, "Edit ohne Entry ? " );
953 SfxStringItem
aName(FN_EDIT_REGION
, pCont
->GetSection()->GetName());
954 rDispatch
.Execute(FN_EDIT_REGION
, SFX_CALLMODE_ASYNCHRON
, &aName
, 0L);
959 // sind mehrere Eintraege selektiert, dann muss nach jedem delete
960 // das Array neu gefuellt werden. Damit man sich nichts merken muss,
961 // beginnt das Loeschen am Ende
962 SvLBoxEntry
* pSelEntry
= LastSelected();
963 SwGlblDocContents
* pTempContents
= 0;
964 pActiveShell
->StartAction();
967 pActiveShell
->DeleteGlobalDocContent(
968 pTempContents
? *pTempContents
: *pSwGlblDocContents
,
969 (USHORT
)GetModel()->GetAbsPos(pSelEntry
));
970 pSelEntry
= PrevSelected(pSelEntry
);
973 pTempContents
= new SwGlblDocContents
;
974 pActiveShell
->GetGlobalDocContent(*pTempContents
);
977 delete pTempContents
;
978 pActiveShell
->EndAction();
982 case CTX_INSERT_ANY_INDEX
:
983 // case CTX_INSERT_CNTIDX:
984 // case CTX_INSERT_USRIDX:
988 SfxItemSet
aSet(pActiveShell
->GetView().GetPool(),
990 RES_BACKGROUND
, RES_BACKGROUND
,
991 RES_FRM_SIZE
, RES_FRM_SIZE
,
992 SID_ATTR_PAGE_SIZE
, SID_ATTR_PAGE_SIZE
,
993 RES_LR_SPACE
, RES_LR_SPACE
,
994 FN_PARAM_TOX_TYPE
, FN_PARAM_TOX_TYPE
,
997 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
998 DBG_ASSERT(pFact
, "Dialogdiet fail!");
999 AbstractMultiTOXTabDialog
* pDlg
= pFact
->CreateMultiTOXTabDialog( DLG_MULTI_TOX
,
1005 DBG_ASSERT(pDlg
, "Dialogdiet fail!");
1006 if(RET_OK
== pDlg
->Execute())
1008 SwTOXDescription
& rDesc
= pDlg
->GetTOXDescription(
1009 pDlg
->GetCurrentTOXType());
1010 SwTOXMgr
aMgr(pActiveShell
);
1011 SwTOXBase
* pToInsert
= 0;
1012 if(aMgr
.UpdateOrInsertTOX(rDesc
, &pToInsert
, pDlg
->GetOutputItemSet()))
1013 pActiveShell
->InsertGlobalDocContent( *pContCopy
, *pToInsert
);
1020 case CTX_INSERT_FILE
:
1022 bDeleteContentCopy
= false;
1023 pDocContent
= pContCopy
;
1024 InsertRegion( pContCopy
);
1028 case CTX_INSERT_NEW_FILE
:
1030 SfxViewFrame
* pGlobFrm
= pActiveShell
->GetView().GetViewFrame();
1031 SwGlobalFrameListener_Impl
aFrmListener(*pGlobFrm
);
1033 ULONG nEntryPos
= pEntry
? GetModel()->GetAbsPos(pEntry
) : (ULONG
)-1;
1034 // neues Dok anlegen
1035 SfxStringItem
aFactory(SID_NEWDOCDIRECT
,
1036 SwDocShell::Factory().GetFilterContainer()->GetName());
1038 const SfxFrameItem
* pItem
= (SfxFrameItem
*)
1039 rDispatch
.Execute(SID_NEWDOCDIRECT
,
1040 SFX_CALLMODE_SYNCHRON
, &aFactory
, 0L);
1043 SfxFrame
* pFrm
= pItem
? pItem
->GetFrame() : 0;
1044 SfxViewFrame
* pFrame
= pFrm
? pFrm
->GetCurrentViewFrame() : 0;
1047 const SfxBoolItem
* pBool
= (const SfxBoolItem
*)
1048 pFrame
->GetDispatcher()->Execute(
1049 SID_SAVEASDOC
, SFX_CALLMODE_SYNCHRON
);
1050 SfxObjectShell
& rObj
= *pFrame
->GetObjectShell();
1051 const SfxMedium
* pMedium
= rObj
.GetMedium();
1052 String
sNewFile(pMedium
->GetURLObject().GetMainURL(INetURLObject::DECODE_TO_IURI
));
1053 // Bereich mit dem Dok-Namen einfuegen
1054 // eigenes Dok in den Vordergrund
1056 if(aFrmListener
.IsValid() && sNewFile
.Len())
1059 // durch das Update sind die Eintraege invalid
1060 if(nEntryPos
!= (ULONG
)-1)
1064 Select(GetModel()->GetEntryAtAbsPos(nEntryPos
));
1065 pEntry
= FirstSelected();
1066 pCont
= pEntry
? (SwGlblDocContent
*)pEntry
->GetUserData() : 0;
1073 if(pBool
->GetValue())
1075 InsertRegion(pCont
, &sNewFile
);
1079 pFrame
->GetDispatcher()->Execute(SID_CLOSEWIN
,
1080 SFX_CALLMODE_SYNCHRON
);
1090 case CTX_INSERT_TEXT
:
1093 pActiveShell
->InsertGlobalDocContent(*pCont
);
1096 pActiveShell
->SplitNode(); // leeres Dokument
1097 pActiveShell
->Up( FALSE
, 1 );
1099 pActiveShell
->GetView().GetEditWin().GrabFocus();
1106 // hier passiert nichts
1111 rDispatch
.Execute(nSlot
);
1114 if ( bDeleteContentCopy
)
1117 bDeleteContentCopy
= true;
1121 /*-----------------16.06.97 07:57-------------------
1123 --------------------------------------------------*/
1124 IMPL_LINK( SwGlobalTree
, Timeout
, Timer
*, EMPTYARG
)
1126 if(!HasFocus() && Update( FALSE
))
1131 /*-----------------13.06.97 16:56-------------------
1133 --------------------------------------------------*/
1134 void SwGlobalTree::GotoContent(const SwGlblDocContent
* pCont
)
1136 pActiveShell
->EnterStdMode();
1138 switch( pCont
->GetType() )
1140 case GLBLDOC_UNKNOWN
:
1141 pActiveShell
->GotoGlobalDocContent(*pCont
);
1143 case GLBLDOC_TOXBASE
:
1145 String sName
= pCont
->GetTOX()->GetTOXName();
1146 if (!pActiveShell
->GotoNextTOXBase(&sName
))
1147 pActiveShell
->GotoPrevTOXBase(&sName
);
1150 case GLBLDOC_SECTION
:
1155 /*-----------------16.06.97 07:42-------------------
1157 --------------------------------------------------*/
1158 void SwGlobalTree::ShowTree()
1160 aUpdateTimer
.Start();
1161 SvTreeListBox::Show();
1163 /*-----------------16.06.97 07:42-------------------
1165 --------------------------------------------------*/
1166 void SwGlobalTree::HideTree()
1168 aUpdateTimer
.Stop();
1169 SvTreeListBox::Hide();
1171 /*-----------------18.06.97 10:02-------------------
1173 --------------------------------------------------*/
1174 void SwGlobalTree::ExecCommand(USHORT nCmd
)
1176 SvLBoxEntry
* pEntry
= FirstSelected();
1177 DBG_ASSERT(pEntry
, "gleich knallt's");
1178 if(FN_GLOBAL_EDIT
== nCmd
)
1180 const SwGlblDocContent
* pCont
= (const SwGlblDocContent
*)
1181 pEntry
->GetUserData();
1186 if(GetSelectionCount() == 1)
1189 USHORT nSource
= (USHORT
)GetModel()->GetAbsPos(pEntry
);
1190 USHORT nDest
= nSource
;
1195 USHORT nEntryCount
= (USHORT
)GetEntryCount();
1196 bMove
= nEntryCount
> nSource
+ 1;
1203 bMove
= 0 != nSource
;
1208 if( bMove
&& pActiveShell
->MoveGlobalDocContent(
1209 *pSwGlblDocContents
, nSource
, nSource
+ 1, nDest
) &&
1216 /*-----------------16.06.97 07:43-------------------
1218 --------------------------------------------------*/
1219 BOOL
SwGlobalTree::Update(BOOL bHard
)
1221 SwView
* pActView
= GetParentWindow()->GetCreateView();
1223 if(pActView
&& pActView
->GetWrtShellPtr())
1225 const SwWrtShell
* pOldShell
= pActiveShell
;
1226 pActiveShell
= pActView
->GetWrtShellPtr();
1227 if(pActiveShell
!= pOldShell
)
1229 delete pSwGlblDocContents
;
1230 pSwGlblDocContents
= 0;
1232 if(!pSwGlblDocContents
)
1234 pSwGlblDocContents
= new SwGlblDocContents
;
1236 pActiveShell
->GetGlobalDocContent(*pSwGlblDocContents
);
1241 SwGlblDocContents
* pTempContents
= new SwGlblDocContents
;
1242 pActiveShell
->GetGlobalDocContent(*pTempContents
);
1243 if(pTempContents
->Count() != pSwGlblDocContents
->Count() ||
1244 pTempContents
->Count() != GetEntryCount())
1251 for(USHORT i
= 0; i
< pTempContents
->Count() && !bCopy
; i
++)
1253 SwGlblDocContent
* pLeft
= pTempContents
->GetObject(i
);
1254 SwGlblDocContent
* pRight
= pSwGlblDocContents
->GetObject(i
);
1255 GlobalDocContentType eType
= pLeft
->GetType();
1256 SvLBoxEntry
* pEntry
= GetEntry(i
);
1257 String sTemp
= GetEntryText(pEntry
);
1258 if(eType
!= pRight
->GetType() ||
1259 eType
== GLBLDOC_SECTION
&&
1260 pLeft
->GetSection()->GetName() != sTemp
||
1261 eType
== GLBLDOC_TOXBASE
&& pLeft
->GetTOX()->GetTitle() != sTemp
)
1262 bCopy
= bRet
= TRUE
;
1269 pSwGlblDocContents
->DeleteAndDestroy(0, pSwGlblDocContents
->Count());
1270 for( i
= 0; i
< pTempContents
->Count(); i
++)
1272 pSwGlblDocContents
->Insert(pTempContents
->GetObject(i
));
1274 for( i
= pTempContents
->Count(); i
; i
--)
1275 pTempContents
->Remove(i
- 1);
1278 delete pTempContents
;
1285 if(pSwGlblDocContents
)
1286 pSwGlblDocContents
->DeleteAndDestroy(0, pSwGlblDocContents
->Count());
1288 // hier muss noch eine Veraenderungspruefung rein!
1292 /*-----------------25.06.97 16:20-------------------
1294 --------------------------------------------------*/
1295 void SwGlobalTree::OpenDoc(const SwGlblDocContent
* pCont
)
1297 String
sFileName(pCont
->GetSection()->GetLinkFileName().GetToken(0,
1298 sfx2::cTokenSeperator
));
1299 BOOL bFound
= FALSE
;
1300 const SfxObjectShell
* pCurr
= SfxObjectShell::GetFirst();
1301 while( !bFound
&& pCurr
)
1303 if(pCurr
->GetMedium() &&
1304 String(pCurr
->GetMedium()->GetURLObject().GetMainURL(INetURLObject::DECODE_TO_IURI
)) == sFileName
)
1307 SwGlobalTree::SetShowShell(pCurr
);
1308 Application::PostUserEvent( STATIC_LINK(
1309 this, SwGlobalTree
, ShowFrameHdl
) );
1313 pCurr
= SfxObjectShell::GetNext(*pCurr
);
1317 SfxStringItem
aURL(SID_FILE_NAME
,
1319 SfxBoolItem
aReadOnly(SID_DOC_READONLY
, FALSE
);
1320 SfxStringItem
aTargetFrameName( SID_TARGETNAME
, String::CreateFromAscii("_blank") );
1321 SfxStringItem
aReferer(SID_REFERER
, pActiveShell
->GetView().GetDocShell()->GetTitle());
1322 pActiveShell
->GetView().GetViewFrame()->GetDispatcher()->
1323 Execute(SID_OPENDOC
, SFX_CALLMODE_ASYNCHRON
,
1324 &aURL
, &aReadOnly
, &aReferer
, &aTargetFrameName
, 0L);
1328 /*-----------------25.06.97 16:08-------------------
1330 --------------------------------------------------*/
1331 IMPL_LINK( SwGlobalTree
, DoubleClickHdl
, SwGlobalTree
*, EMPTYARG
)
1333 SvLBoxEntry
* pEntry
= GetCurEntry();
1334 SwGlblDocContent
* pCont
= (SwGlblDocContent
*)pEntry
->GetUserData();
1335 if(pCont
->GetType() == GLBLDOC_SECTION
)
1340 pActiveShell
->GetView().GetEditWin().GrabFocus();
1345 /*-----------------07.10.97 08:09-------------------
1347 --------------------------------------------------*/
1348 IMPL_STATIC_LINK_NOINSTANCE(SwGlobalTree
, ShowFrameHdl
, SwGlobalTree
*, EMPTYARG
)
1350 if(SwGlobalTree::GetShowShell())
1351 SfxViewFrame::GetFirst(SwGlobalTree::GetShowShell())->ToTop();
1352 SwGlobalTree::SetShowShell(0);
1355 /* -----------------04.11.98 10:43-------------------
1357 * --------------------------------------------------*/
1358 void SwGlobalTree::InitEntry(SvLBoxEntry
* pEntry
,
1359 const XubString
& rStr
,const Image
& rImg1
,const Image
& rImg2
,
1360 SvLBoxButtonKind eButtonKind
)
1362 USHORT nColToHilite
= 1; //0==Bitmap;1=="Spalte1";2=="Spalte2"
1363 SvTreeListBox::InitEntry( pEntry
, rStr
, rImg1
, rImg2
, eButtonKind
);
1364 SvLBoxString
* pCol
= (SvLBoxString
*)pEntry
->GetItem( nColToHilite
);
1365 SwLBoxString
* pStr
= new SwLBoxString( pEntry
, 0, pCol
->GetText() );
1366 pEntry
->ReplaceItem( pStr
, nColToHilite
);
1368 /* -----------------04.11.98 10:39-------------------
1370 * --------------------------------------------------*/
1372 void SwLBoxString::Paint( const Point
& rPos
, SvLBox
& rDev
, USHORT nFlags
,
1373 SvLBoxEntry
* pEntry
)
1375 SwGlblDocContent
* pCont
= (SwGlblDocContent
*)pEntry
->GetUserData();
1376 const SwSection
* pSect
;
1377 if(pCont
->GetType() == GLBLDOC_SECTION
&&
1378 !(pSect
= pCont
->GetSection())->IsConnectFlag() )
1380 Font
aOldFont( rDev
.GetFont());
1381 Font
aFont(aOldFont
);
1382 Color
aCol( COL_LIGHTRED
);
1383 aFont
.SetColor( aCol
);
1384 rDev
.SetFont( aFont
);
1385 rDev
.DrawText( rPos
, GetText() );
1386 rDev
.SetFont( aOldFont
);
1389 SvLBoxString::Paint( rPos
, rDev
, nFlags
, pEntry
);
1391 /* -----------------------------06.05.2002 10:20------------------------------
1393 ---------------------------------------------------------------------------*/
1394 void SwGlobalTree::DataChanged( const DataChangedEvent
& rDCEvt
)
1396 if ( (rDCEvt
.GetType() == DATACHANGED_SETTINGS
) &&
1397 (rDCEvt
.GetFlags() & SETTINGS_STYLE
) )
1399 USHORT nResId
= GetDisplayBackground().GetColor().IsDark() ? IMG_NAVI_ENTRYBMPH
: IMG_NAVI_ENTRYBMP
;
1400 aEntryImages
= ImageList(SW_RES(nResId
));
1403 SvTreeListBox::DataChanged( rDCEvt
);
1406 void SwGlobalTree::InsertRegion( const SwGlblDocContent
* _pContent
, const Sequence
< OUString
>& _rFiles
)
1408 sal_Int32 nFiles
= _rFiles
.getLength();
1414 SvLBoxEntry
* pLast
= (SvLBoxEntry
*)LastVisible();
1415 _pContent
= (SwGlblDocContent
*)pLast
->GetUserData();
1418 String sFilePassword
;
1419 USHORT nEntryCount
= (USHORT
)GetEntryCount();
1420 const OUString
* pFileNames
= _rFiles
.getConstArray();
1421 SwWrtShell
& rSh
= GetParentWindow()->GetCreateView()->GetWrtShell();
1423 // after insertion of the first new content the 'pCont' parameter becomes invalid
1424 // find the index of the 'anchor' content to always use a current anchor content
1425 USHORT nAnchorContent
= pSwGlblDocContents
->Count() - 1;
1428 for( USHORT nContent
= 0; nContent
< pSwGlblDocContents
->Count(); ++nContent
)
1430 if( *_pContent
== *pSwGlblDocContents
->GetObject( nContent
) )
1432 nAnchorContent
= nContent
;
1437 SwGlblDocContents aTempContents
;
1438 for ( sal_Int32 nFile
= 0; nFile
< nFiles
; ++nFile
)
1440 //update the global document content after each inserted document
1441 rSh
.GetGlobalDocContent(aTempContents
);
1442 SwGlblDocContent
* pAnchorContent
= 0;
1443 DBG_ASSERT(aTempContents
.Count() > (nAnchorContent
+ nFile
), "invalid anchor content -> last insertion failed");
1444 if ( aTempContents
.Count() > (nAnchorContent
+ nFile
) )
1445 pAnchorContent
= aTempContents
.GetObject(nAnchorContent
+ (USHORT
)nFile
);
1447 pAnchorContent
= aTempContents
.GetObject(aTempContents
.Count() - 1);
1448 String
sFileName(pFileNames
[nFile
]);
1449 INetURLObject aFileUrl
;
1450 aFileUrl
.SetSmartURL( sFileName
);
1451 String
sSectionName(String(aFileUrl
.GetLastName(
1452 INetURLObject::DECODE_UNAMBIGUOUS
)).GetToken(0,
1453 sfx2::cTokenSeperator
));
1454 USHORT nSectCount
= rSh
.GetSectionFmtCount();
1455 String
sTempSectionName(sSectionName
);
1456 USHORT nAddNumber
= 0;
1458 // evtl : und Index anhaengen, wenn der Bereichsname schon vergeben ist
1459 while ( nCount
< nSectCount
)
1461 const SwSectionFmt
& rFmt
= rSh
.GetSectionFmt(nCount
);
1462 if ( rFmt
.GetSection()->GetName() == sTempSectionName
&& rFmt
.IsInNodesArr() )
1466 sTempSectionName
= sSectionName
;
1467 sTempSectionName
+= ':';
1468 sTempSectionName
+= String::CreateFromInt32( nAddNumber
);
1475 sSectionName
= sTempSectionName
;
1477 SwSection
aSection(CONTENT_SECTION
, sSectionName
);
1478 aSection
.SetProtect(TRUE
);
1479 aSection
.SetHidden(FALSE
);
1481 aSection
.SetLinkFileName(sFileName
);
1482 aSection
.SetType( FILE_LINK_SECTION
);
1483 aSection
.SetLinkFilePassWd( sFilePassword
);
1485 rSh
.InsertGlobalDocContent( *pAnchorContent
, aSection
);
1490 rSh
.MoveGlobalDocContent(
1491 *pSwGlblDocContents
, nEntryCount
, nEntryCount
+ (USHORT
)nFiles
, nEntryCount
- (USHORT
)nFiles
);
1499 IMPL_LINK( SwGlobalTree
, DialogClosedHdl
, sfx2::FileDialogHelper
*, _pFileDlg
)
1501 Application::SetDefDialogParent( pDefParentWin
);
1502 if ( ERRCODE_NONE
== _pFileDlg
->GetError() )
1504 SfxMediumList
* pMedList
= pDocInserter
->CreateMediumList();
1507 Sequence
< OUString
>aFileNames( pMedList
->Count() );
1508 OUString
* pFileNames
= aFileNames
.getArray();
1509 SfxMedium
* pMed
= pMedList
->First();
1513 String sFileName
= pMed
->GetURLObject().GetMainURL( INetURLObject::NO_DECODE
);
1514 sFileName
+= sfx2::cTokenSeperator
;
1515 sFileName
+= pMed
->GetFilter()->GetFilterName();
1516 sFileName
+= sfx2::cTokenSeperator
;
1517 pFileNames
[nPos
++] = sFileName
;
1518 pMed
= pMedList
->Next();
1521 InsertRegion( pDocContent
, aFileNames
);
1522 DELETEZ( pDocContent
);