xref: /aoo42x/main/sw/source/ui/utlui/navipi.cxx (revision dec99bbd)
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 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26 
27 
28 
29 #define NAVIPI_CXX
30 
31 #include <string> // HACK: prevent conflict between STLPORT and Workshop headers
32 #include <tools/list.hxx>
33 #include <svl/urlbmk.hxx>
34 #include <svl/stritem.hxx>
35 #include <svtools/filter.hxx>
36 #include <svl/urihelper.hxx>
37 #include <sot/formats.hxx>
38 #include <sot/filelist.hxx>
39 #include <sfx2/event.hxx>
40 #include <sfx2/imgmgr.hxx>
41 #include <sfx2/dispatch.hxx>
42 #include <sfx2/dockwin.hxx>
43 #include <vcl/toolbox.hxx>
44 #include <swtypes.hxx>	// fuer Pathfinder
45 #include <errhdl.hxx>
46 #include <swmodule.hxx>
47 #ifndef _VIEW_HXX
48 #include <view.hxx>
49 #endif
50 #include <navicfg.hxx>
51 #include <wrtsh.hxx>
52 #ifndef _DOCSH_HXX
53 #include <docsh.hxx>
54 #endif
55 #include <actctrl.hxx>
56 #include <IMark.hxx>
57 #include <navipi.hxx>
58 #include <content.hxx>
59 #include <workctrl.hxx>
60 #include <section.hxx>
61 #include <edtwin.hxx>
62 #include <sfx2/app.hxx>
63 #ifndef _CMDID_H
64 #include <cmdid.h>
65 #endif
66 #ifndef _HELPID_H
67 #include <helpid.h>
68 #endif
69 #ifndef _RIBBAR_HRC
70 #include <ribbar.hrc>
71 #endif
72 #ifndef _NAVIPI_HRC
73 #include <navipi.hrc>
74 #endif
75 #ifndef _UTLUI_HRC
76 #include <utlui.hrc>
77 #endif
78 
79 #include "access.hrc"
80 
81 #include <unomid.h>
82 
83 
84 #define PAGE_CHANGE_TIMEOUT 1000 //Timeout fuer Seitenwechsel
85 
86 #define JUMP_TYPE_TBL 0
87 #define JUMP_TYPE_FRM 1
88 #define JUMP_TYPE_GRF 2
89 #define JUMP_TYPE_REG 3
90 #define JUMP_TYPE_BKM 4
91 
92 // Version fuer Konfiguration
93 
94 #define NAVI_VERSION0	0
95 #define NAVI_VERSION1   1
96 #define NAVI_VERSION2   2 // bIsGlobalActive
97 
98 #define NAVI_CONFIG_VERSION NAVI_VERSION2
99 
100 using namespace ::com::sun::star::uno;
101 using namespace ::com::sun::star::frame;
102 
103 SFX_IMPL_CHILDWINDOW_CONTEXT( SwNavigationChild, SID_NAVIGATOR, SwView )
104 
105 /*------------------------------------------------------------------------
106 	Bechreibung: Steuerzeichen aus dem Outline-Entry filtern
107 ------------------------------------------------------------------------*/
108 
109 void SwNavigationPI::CleanEntry( String& rEntry )
110 {
111 	sal_uInt16 i = rEntry.Len();
112 	if( i )
113 		for( sal_Unicode* pStr = rEntry.GetBufferAccess(); i; --i, ++pStr )
114 			if( *pStr == 10 || *pStr == 9 )
115 				*pStr = 0x20;
116 }
117 /*------------------------------------------------------------------------
118  Beschreibung:	Ausfuehrung der Drag-Operation
119 				mit und ohne Childs
120 ------------------------------------------------------------------------*/
121 
122 void SwNavigationPI::MoveOutline(sal_uInt16 nSource, sal_uInt16 nTarget,
123 													sal_Bool bWithChilds)
124 {
125     SwView *pView = GetCreateView();
126 	SwWrtShell &rSh = pView->GetWrtShell();
127 	if(nTarget < nSource || nTarget == USHRT_MAX)
128 		nTarget ++;
129 	if ( rSh.IsOutlineMovable( nSource ))
130 	{
131 
132 		short nMove = nTarget-nSource; //( nDir<0 ) ? 1 : 0 ;
133 		rSh.GotoOutline(nSource);
134 		if (bWithChilds)
135 			rSh.MakeOutlineSel(nSource, nSource, sal_True);
136 		// Die selektierten Children zaehlen bei der Bewegung vorwaerts nicht mit
137 		sal_uInt16 nLastOutlinePos = rSh.GetOutlinePos(MAXLEVEL);
138 		if(bWithChilds && nMove > 1 &&
139 				nLastOutlinePos < nTarget)
140 		{
141 			if(!rSh.IsCrsrPtAtEnd())
142 				rSh.SwapPam();
143 			nMove -= nLastOutlinePos - nSource;
144 		}
145 		if(!bWithChilds || nMove < 1 || nLastOutlinePos < nTarget )
146 			rSh.MoveOutlinePara( nMove );
147 		rSh.ClearMark();
148 		rSh.GotoOutline( nSource + nMove);
149 		FillBox();
150 	}
151 
152 }
153 
154 
155 /*------------------------------------------------------------------------
156  Beschreibung:	Nach Goto einen Status Rahmenselektion aufheben
157 ------------------------------------------------------------------------*/
158 
159 
160 void lcl_UnSelectFrm(SwWrtShell *pSh)
161 {
162 	if (pSh->IsFrmSelected())
163 	{
164 		pSh->UnSelectFrm();
165 		pSh->LeaveSelFrmMode();
166 	}
167 }
168 
169 /*------------------------------------------------------------------------
170  Beschreibung:	Select der Documentanzeige
171 ------------------------------------------------------------------------*/
172 
173 
174 IMPL_LINK( SwNavigationPI, DocListBoxSelectHdl, ListBox *, pBox )
175 {
176 	int nEntryIdx = pBox->GetSelectEntryPos();
177 	SwView *pView ;
178 	pView = SwModule::GetFirstView();
179 	while (nEntryIdx-- && pView)
180 	{
181 		pView = SwModule::GetNextView(pView);
182 	}
183 	if(!pView)
184 	{
185 		nEntryIdx == 0 ?
186 			aContentTree.ShowHiddenShell():
187 				aContentTree.ShowActualView();
188 
189 
190 	}
191 	else
192 	{
193 		aContentTree.SetConstantShell(pView->GetWrtShellPtr());
194 	}
195 	return 0;
196 }
197 
198 /*------------------------------------------------------------------------
199  Beschreibung:	Fuellen der ListBox fuer Outline Sicht oder Dokumente
200 				Der PI wird auf volle Groesse gesetzt
201 ------------------------------------------------------------------------*/
202 
203 
204 void SwNavigationPI::FillBox()
205 {
206 	if(pContentWrtShell)
207 	{
208 		aContentTree.SetHiddenShell( pContentWrtShell );
209 		aContentTree.Display(  sal_False );
210 	}
211 	else
212 	{
213         SwView *pView = GetCreateView();
214 		if(!pView)
215 		{
216 			aContentTree.SetActiveShell(0);
217 		}
218 		else if( pView != pActContView)
219 		{
220 			SwWrtShell* pWrtShell = pView->GetWrtShellPtr();
221 			aContentTree.SetActiveShell(pWrtShell);
222 		}
223 		else
224 			aContentTree.Display( sal_True );
225 		pActContView = pView;
226 	}
227 }
228 
229 
230 void SwNavigationPI::UsePage(SwWrtShell *pSh)
231 {
232 	if (!pSh)
233 	{
234         SwView *pView = GetCreateView();
235 		pSh = pView ? &pView->GetWrtShell() : 0;
236 		GetPageEdit().SetValue(1);
237 	}
238 	if (pSh)
239 	{
240 		const sal_uInt16 nPageCnt = pSh->GetPageCnt();
241 		sal_uInt16 nPhyPage, nVirPage;
242 		pSh->GetPageNum(nPhyPage, nVirPage);
243 
244 		GetPageEdit().SetMax(nPageCnt);
245 		GetPageEdit().SetLast(nPageCnt);
246 		GetPageEdit().SetValue(nPhyPage);
247 	}
248 }
249 
250 /*------------------------------------------------------------------------
251  Beschreibung:	SelectHandler der Toolboxen
252 ------------------------------------------------------------------------*/
253 
254 
255 IMPL_LINK( SwNavigationPI, ToolBoxSelectHdl, ToolBox *, pBox )
256 {
257     const sal_uInt16 nCurrItemId = pBox->GetCurItemId();
258     SwView *pView = GetCreateView();
259 	if (!pView)
260 		return 1;
261 	SwWrtShell &rSh = pView->GetWrtShell();
262 	//MouseModifier fuer Outline-Move besorgen
263 
264 	//Standard: Unterebenen werden mitgenommen
265 	// mit Ctrl Unterebenen nicht mitnehmen
266 	sal_Bool bOutlineWithChilds  = ( KEY_MOD1 != pBox->GetModifier());
267 	int nFuncId = 0;
268     sal_Bool bFocusToDoc = sal_False;
269     switch (nCurrItemId)
270 	{
271 		case FN_UP:
272 		case FN_DOWN:
273         {
274             // #i75416# move the execution of the search to an asynchronously called static link
275             bool* pbNext = new bool( FN_DOWN == nCurrItemId );
276             Application::PostUserEvent( STATIC_LINK(pView, SwView, MoveNavigationHdl), pbNext );
277         }
278 		break;
279 		case FN_SHOW_ROOT:
280 		{
281 			aContentTree.ToggleToRoot();
282 		}
283 		break;
284 		case FN_SHOW_CONTENT_BOX:
285 		case FN_SELECT_CONTENT:
286             if(pContextWin!=NULL && pContextWin->GetFloatingWindow()!=NULL)
287             {
288                 if(_IsZoomedIn() )
289                 {
290                     _ZoomOut();
291                 }
292                 else
293                 {
294                     _ZoomIn();
295                 }
296             }
297             return sal_True;
298 		//break;
299 		// Funktionen, die eine direkte Aktion ausloesen
300 
301 		case FN_SELECT_FOOTER:
302 		{
303 			rSh.MoveCrsr();
304 			const sal_uInt16 eType = rSh.GetFrmType(0,sal_False);
305 			if (eType & FRMTYPE_FOOTER)
306 			{
307 				if (rSh.EndPg())
308 					nFuncId = FN_END_OF_PAGE;
309 			}
310 			else if (rSh.GotoFooterTxt())
311 				nFuncId = FN_TO_FOOTER;
312             bFocusToDoc = sal_True;
313 		}
314 		break;
315 		case FN_SELECT_HEADER:
316 		{
317 			rSh.MoveCrsr();
318 			const sal_uInt16 eType = rSh.GetFrmType(0,sal_False);
319 			if (eType & FRMTYPE_HEADER)
320 			{
321 				if (rSh.SttPg())
322 					nFuncId = FN_START_OF_PAGE;
323 			}
324 			else if (rSh.GotoHeaderTxt())
325 				nFuncId = FN_TO_HEADER;
326             bFocusToDoc = sal_True;
327         }
328 		break;
329 		case FN_SELECT_FOOTNOTE:
330 		{
331 			rSh.MoveCrsr();
332 			const sal_uInt16 eFrmType = rSh.GetFrmType(0,sal_False);
333 				// aus Fussnote zum Anker springen
334 			if (eFrmType & FRMTYPE_FOOTNOTE)
335 			{
336 				if (rSh.GotoFtnAnchor())
337 					nFuncId = FN_FOOTNOTE_TO_ANCHOR;
338 			}
339 				// andernfalls zuerst zum Fussnotentext springen; geht
340 				// dies nicht, zur naechten Fussnote; geht auch dies
341 				// nicht, zur vorhergehenden Fussnote
342 			else
343 			{
344 				if (rSh.GotoFtnTxt())
345 					nFuncId = FN_FOOTNOTE_TO_ANCHOR;
346 				else if (rSh.GotoNextFtnAnchor())
347 					nFuncId = FN_NEXT_FOOTNOTE;
348 				else if (rSh.GotoPrevFtnAnchor())
349 					nFuncId = FN_PREV_FOOTNOTE;
350 			}
351             bFocusToDoc = sal_True;
352         }
353 		break;
354 
355 		case FN_SELECT_SET_AUTO_BOOKMARK:
356 			MakeMark();
357 		break;
358 		case FN_ITEM_DOWN:
359 		case FN_ITEM_UP:
360 		case FN_ITEM_LEFT:
361 		case FN_ITEM_RIGHT:
362 		case FN_GLOBAL_EDIT:
363 		{
364 			if(IsGlobalMode())
365                 aGlobalTree.ExecCommand(nCurrItemId);
366 			else
367                 aContentTree.ExecCommand(nCurrItemId, bOutlineWithChilds);
368 		}
369 		break;
370 		case FN_GLOBAL_SWITCH:
371 		{
372 			ToggleTree();
373 			pConfig->SetGlobalActive(IsGlobalMode());
374 		}
375 		break;
376 		case FN_GLOBAL_SAVE_CONTENT:
377 		{
378 			sal_Bool bSave = rSh.IsGlblDocSaveLinks();
379 			rSh.SetGlblDocSaveLinks( !bSave );
380 			pBox->CheckItem(FN_GLOBAL_SAVE_CONTENT, !bSave );
381 		}
382 		break;
383 	}
384 
385 	if (nFuncId)
386 	{
387 		lcl_UnSelectFrm(&rSh);
388 	}
389     if(bFocusToDoc)
390         pView->GetEditWin().GrabFocus();
391 	return sal_True;
392 }
393 /*------------------------------------------------------------------------
394  Beschreibung:	ClickHandler der Toolboxen
395 ------------------------------------------------------------------------*/
396 
397 
398 IMPL_LINK( SwNavigationPI, ToolBoxClickHdl, ToolBox *, pBox )
399 {
400     const sal_uInt16 nCurrItemId = pBox->GetCurItemId();
401     switch (nCurrItemId)
402 	{
403 		case FN_GLOBAL_UPDATE:
404 		case FN_GLOBAL_OPEN:
405 		{
406             aGlobalTree.TbxMenuHdl(nCurrItemId, pBox);
407 		}
408 		break;
409 	}
410 
411 	return sal_True;
412 }
413 
414 /*-----------------13.07.04 -------------------
415  ----------------------------------------------*/
416 
417 IMPL_LINK( SwNavigationPI, ToolBoxDropdownClickHdl, ToolBox*, pBox )
418 {
419     const sal_uInt16 nCurrItemId = pBox->GetCurItemId();
420     switch (nCurrItemId)
421     {
422 		case FN_CREATE_NAVIGATION:
423 		{
424             CreateNavigationTool(pBox->GetItemRect(FN_CREATE_NAVIGATION), sal_True);
425         }
426 		break;
427 
428         case FN_DROP_REGION:
429 		{
430             static const char* aHIDs[] =
431             {
432 				HID_NAVI_DRAG_HYP,
433 				HID_NAVI_DRAG_LINK,
434 				HID_NAVI_DRAG_COPY,
435             };
436 			PopupMenu *pMenu = new PopupMenu;
437 			for (sal_uInt16 i = 0; i <= REGION_MODE_EMBEDDED; i++)
438 			{
439 				pMenu->InsertItem( i + 1, aContextArr[i] );
440 				pMenu->SetHelpId(i + 1, aHIDs[i]);
441 			}
442 			pMenu->CheckItem( nRegionMode + 1 );
443 			pMenu->SetSelectHdl(LINK(this, SwNavigationPI, MenuSelectHdl));
444             pBox->SetItemDown( nCurrItemId, sal_True );
445             pMenu->Execute( pBox,
446 					pBox->GetItemRect(FN_DROP_REGION),
447                     POPUPMENU_EXECUTE_DOWN );
448             pBox->SetItemDown( nCurrItemId, sal_False );
449 			pBox->EndSelection();
450 			delete pMenu;
451 			pBox->Invalidate();
452 		}
453 		break;
454 		case FN_OUTLINE_LEVEL:
455 		{
456 			PopupMenu *pMenu = new PopupMenu;
457 			for (sal_uInt16 i = 101; i <= 100 + MAXLEVEL; i++)
458 			{
459 				pMenu->InsertItem( i, String::CreateFromInt32(i - 100) );
460 				pMenu->SetHelpId( i, HID_NAVI_OUTLINES );
461 			}
462 			pMenu->CheckItem( aContentTree.GetOutlineLevel() + 100 );
463 			pMenu->SetSelectHdl(LINK(this, SwNavigationPI, MenuSelectHdl));
464             pBox->SetItemDown( nCurrItemId, sal_True );
465 			pMenu->Execute(	pBox,
466 					pBox->GetItemRect(FN_OUTLINE_LEVEL),
467                     POPUPMENU_EXECUTE_DOWN );
468             pBox->SetItemDown( nCurrItemId, sal_False );
469 			delete pMenu;
470 			pBox->EndSelection();
471 			pBox->Invalidate();
472 		}
473 		break;
474     }
475 	return sal_True;
476 }
477 
478 /*-----------------13.07.04 -------------------
479 --------------------------------------------------*/
480 
481 SwNavHelpToolBox::SwNavHelpToolBox(SwNavigationPI* pParent, const ResId &rResId) :
482 			SwHelpToolBox(pParent, rResId)
483 {}
484 /*-----------------19.06.97 09:09-------------------
485 
486 --------------------------------------------------*/
487 void SwNavHelpToolBox::MouseButtonDown(const MouseEvent &rEvt)
488 {
489 	if(rEvt.GetButtons() == MOUSE_LEFT &&
490 			FN_CREATE_NAVIGATION == GetItemId(rEvt.GetPosPixel()))
491 	{
492         ((SwNavigationPI*)GetParent())->CreateNavigationTool(GetItemRect(FN_CREATE_NAVIGATION), sal_False);
493     }
494 	else
495 		SwHelpToolBox::MouseButtonDown(rEvt);
496 }
497 /* -----------------------------12.03.2002 16:55------------------------------
498 
499  ---------------------------------------------------------------------------*/
500 void SwNavigationPI::CreateNavigationTool(const Rectangle& rRect, sal_Bool bSetFocus)
501 {
502 //    SfxBindings& rBind = GetCreateView()->GetViewFrame()->GetBindings();
503 //    rBind.ENTERREGISTRATIONS();
504     Reference< XFrame > xFrame = GetCreateView()->GetViewFrame()->GetFrame().GetFrameInterface();
505     SwScrollNaviPopup* pPopup = new
506         SwScrollNaviPopup(FN_SCROLL_NAVIGATION,
507                           xFrame );
508 //    rBind.LEAVEREGISTRATIONS();
509 
510     Rectangle aRect(rRect);
511     Point aT1 = aRect.TopLeft();
512     aT1 = pPopup->GetParent()->OutputToScreenPixel(pPopup->GetParent()->AbsoluteScreenToOutputPixel(aContentToolBox.OutputToAbsoluteScreenPixel(aT1)));
513     aRect.SetPos(aT1);
514     pPopup->StartPopupMode(aRect, FLOATWIN_POPUPMODE_RIGHT|FLOATWIN_POPUPMODE_ALLOWTEAROFF);
515     SetPopupWindow( pPopup );
516     if(bSetFocus)
517     {
518         pPopup->EndPopupMode(FLOATWIN_POPUPMODEEND_TEAROFF);
519         pPopup->GrabFocus();
520     }
521 }
522 
523 /*-----------------19.06.97 10:12-------------------
524 
525 --------------------------------------------------*/
526 void  SwNavHelpToolBox::RequestHelp( const HelpEvent& rHEvt )
527 {
528 	sal_uInt16 nItemId = GetItemId(ScreenToOutputPixel(rHEvt.GetMousePosPixel()));
529 	if( FN_UP == nItemId || FN_DOWN == nItemId )
530 	{
531 		SetItemText(nItemId, SwScrollNaviPopup::GetQuickHelpText((FN_DOWN == nItemId)));
532 	}
533 	SwHelpToolBox::RequestHelp(rHEvt);
534 }
535 
536 /*------------------------------------------------------------------------
537  Beschreibung:	Action-Handler Edit; wechselt auf die Seite, wenn
538 				nicht Gliederungssicht angeschaltet ist.
539 ------------------------------------------------------------------------*/
540 
541 
542 IMPL_LINK( SwNavigationPI, EditAction, NumEditAction *, pEdit )
543 {
544     SwView *pView = GetCreateView();
545 	if (pView)
546 	{
547 		if(aPageChgTimer.IsActive())
548 			aPageChgTimer.Stop();
549 		pCreateView->GetWrtShell().GotoPage((sal_uInt16)pEdit->GetValue(), sal_True);
550 		pCreateView->GetEditWin().GrabFocus();
551 		pCreateView->GetViewFrame()->GetBindings().Invalidate(FN_STAT_PAGE);
552 	}
553 	return 0;
554 }
555 
556 /*------------------------------------------------------------------------
557  Beschreibung:	Falls die Seite eingestellt werden kann, wird hier
558 				das Maximum gesetzt.
559 ------------------------------------------------------------------------*/
560 
561 
562 IMPL_LINK( SwNavigationPI, EditGetFocus, NumEditAction *, pEdit )
563 {
564     SwView *pView = GetCreateView();
565 	if (!pView)
566 		return 0;
567 	SwWrtShell &rSh = pView->GetWrtShell();
568 
569 	const sal_uInt16 nPageCnt = rSh.GetPageCnt();
570 	pEdit->SetMax(nPageCnt);
571 	pEdit->SetLast(nPageCnt);
572 	return 0;
573 }
574 
575 /*------------------------------------------------------------------------
576  Beschreibung:
577 ------------------------------------------------------------------------*/
578 
579 sal_Bool SwNavigationPI::Close()
580 {
581 	SfxViewFrame* pVFrame = pCreateView->GetViewFrame();
582 	pVFrame->GetBindings().Invalidate(SID_NAVIGATOR);
583 	pVFrame->GetDispatcher()->Execute(SID_NAVIGATOR);
584 	return sal_True;
585 }
586 
587 /*------------------------------------------------------------------------
588  Beschreibung:	Setzen einer automatischen Marke
589 ------------------------------------------------------------------------*/
590 
591 
592 void SwNavigationPI::MakeMark()
593 {
594     SwView *pView = GetCreateView();
595     if (!pView) return;
596     SwWrtShell &rSh = pView->GetWrtShell();
597     IDocumentMarkAccess* const pMarkAccess = rSh.getIDocumentMarkAccess();
598 
599     // collect and sort navigator reminder names
600     ::std::vector< ::rtl::OUString > vNavMarkNames;
601     for(IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->getAllMarksBegin();
602         ppMark != pMarkAccess->getAllMarksEnd();
603         ppMark++)
604         if( IDocumentMarkAccess::GetType(**ppMark) == IDocumentMarkAccess::NAVIGATOR_REMINDER )
605             vNavMarkNames.push_back(ppMark->get()->GetName());
606     ::std::sort(vNavMarkNames.begin(), vNavMarkNames.end());
607 
608     // we are maxed out and delete one
609     // nAutoMarkIdx rotates through the available MarkNames
610     // this assumes that IDocumentMarkAccess generates Names in ascending order
611     if(vNavMarkNames.size() == MAX_MARKS)
612         pMarkAccess->deleteMark(pMarkAccess->findMark(vNavMarkNames[nAutoMarkIdx]));
613 
614     rSh.SetBookmark(KeyCode(), ::rtl::OUString(), ::rtl::OUString(), IDocumentMarkAccess::NAVIGATOR_REMINDER);
615     SwView::SetActMark( nAutoMarkIdx );
616 
617     if(++nAutoMarkIdx == MAX_MARKS)
618         nAutoMarkIdx = 0;
619 }
620 
621 /*------------------------------------------------------------------------
622  Beschreibung:
623 ------------------------------------------------------------------------*/
624 
625 void SwNavigationPI::GotoPage()
626 {
627 	if (pContextWin && pContextWin->GetFloatingWindow() && pContextWin->GetFloatingWindow()->IsRollUp())
628 		_ZoomIn();
629 	if(IsGlobalMode())
630 		ToggleTree();
631 	UsePage(0);
632 	GetPageEdit().GrabFocus();
633 }
634 
635 /*------------------------------------------------------------------------
636  Beschreibung:
637 ------------------------------------------------------------------------*/
638 
639 void SwNavigationPI::_ZoomOut()
640 {
641 	if (_IsZoomedIn())
642 	{
643 		FloatingWindow* pFloat = pContextWin!=NULL ? pContextWin->GetFloatingWindow() : NULL;
644 		bIsZoomedIn = sal_False;
645 		Size aSz(GetOutputSizePixel());
646 		aSz.Height() = nZoomOut;
647 		Size aMinOutSizePixel = ((SfxDockingWindow*)GetParent())->GetMinOutputSizePixel();
648 		((SfxDockingWindow*)GetParent())->SetMinOutputSizePixel(Size(
649 							aMinOutSizePixel.Width(),nZoomOutInit));
650         if (pFloat != NULL)
651             pFloat->SetOutputSizePixel(aSz);
652 		FillBox();
653 		if(IsGlobalMode())
654 		{
655 			aGlobalTree.ShowTree();
656 		}
657 		else
658 		{
659 			aContentTree.ShowTree();
660 			aDocListBox.Show();
661 		}
662 		SvLBoxEntry* pFirst = aContentTree.FirstSelected();
663 		if(pFirst)
664 			aContentTree.Select(pFirst, sal_True); // toolbox enablen
665 		pConfig->SetSmall( sal_False );
666 		aContentToolBox.CheckItem(FN_SHOW_CONTENT_BOX);
667 	}
668 }
669 
670 /*------------------------------------------------------------------------
671  Beschreibung:
672 ------------------------------------------------------------------------*/
673 
674 void SwNavigationPI::_ZoomIn()
675 {
676     if (pContextWin != NULL)
677     {
678         FloatingWindow* pFloat = pContextWin->GetFloatingWindow();
679         if (pFloat &&
680             (!_IsZoomedIn() || ( pContextWin->GetFloatingWindow()->IsRollUp())))
681         {
682             aContentTree.HideTree();
683             aDocListBox.Hide();
684             aGlobalTree.HideTree();
685             bIsZoomedIn = sal_True;
686             Size aSz(GetOutputSizePixel());
687             if( aSz.Height() > nZoomIn )
688                 nZoomOut = ( short ) aSz.Height();
689 
690             aSz.Height() = nZoomIn;
691             Size aMinOutSizePixel = ((SfxDockingWindow*)GetParent())->GetMinOutputSizePixel();
692             ((SfxDockingWindow*)GetParent())->SetMinOutputSizePixel(Size(
693                     aMinOutSizePixel.Width(), aSz.Height()));
694             pFloat->SetOutputSizePixel(aSz);
695             SvLBoxEntry* pFirst = aContentTree.FirstSelected();
696             if(pFirst)
697                 aContentTree.Select(pFirst, sal_True); // toolbox enablen
698             pConfig->SetSmall( sal_True );
699             aContentToolBox.CheckItem(FN_SHOW_CONTENT_BOX, sal_False);
700         }
701     }
702 }
703 /*------------------------------------------------------------------------
704  Beschreibung:
705 ------------------------------------------------------------------------*/
706 
707 void SwNavigationPI::Resize()
708 {
709 	Window* pParent = GetParent();
710     if( !_IsZoomedIn() )
711     {
712         Size aNewSize (pParent->GetOutputSizePixel());
713 
714         SfxDockingWindow* pDockingParent = dynamic_cast<SfxDockingWindow*>(pParent);
715         if (pDockingParent != NULL)
716         {
717             FloatingWindow* pFloat =  pDockingParent->GetFloatingWindow();
718             //change the minimum width depending on the dock status
719             Size aMinOutSizePixel = pDockingParent->GetMinOutputSizePixel();
720             if( pFloat)
721             {
722                 aNewSize = pFloat->GetOutputSizePixel();
723                 aMinOutSizePixel.Width() = nWishWidth;
724                 aMinOutSizePixel.Height() = _IsZoomedIn() ? nZoomIn : nZoomOutInit;
725             }
726             else
727             {
728                 aMinOutSizePixel.Width() = 0;
729                 aMinOutSizePixel.Height() = 0;
730             }
731             pDockingParent->SetMinOutputSizePixel(aMinOutSizePixel);
732         }
733 
734         const Point aPos = aContentTree.GetPosPixel();
735         Point aLBPos = aDocListBox.GetPosPixel();
736         long nDist = aPos.X();
737         aNewSize.Height() -= (aPos.Y() + aPos.X() + nDocLBIniHeight + nDist);
738         aNewSize.Width() -= 2 * nDist;
739         aLBPos.Y() = aPos.Y() + aNewSize.Height() + nDist;
740         aDocListBox.Show(!aGlobalTree.IsVisible() && aLBPos.Y() > aPos.Y() );
741 
742         Size aDocLBSz = aDocListBox.GetSizePixel();
743         aDocLBSz.Width() = aNewSize.Width();
744         if(aNewSize.Height() < 0)
745             aDocLBSz.Height() = 0;
746         else
747             aDocLBSz.Height() = nDocLBIniHeight;
748         aContentTree.SetSizePixel(aNewSize);
749         // GlobalTree faengt weiter oben an und reicht bis ganz unten
750         aNewSize.Height() += (nDist + nDocLBIniHeight + aPos.Y() - aGlobalTree.GetPosPixel().Y());
751         aGlobalTree.SetSizePixel(aNewSize);
752         aDocListBox.SetPosSizePixel( aLBPos.X(), aLBPos.Y(),
753             aDocLBSz.Width(), aDocLBSz.Height(),
754             WINDOW_POSSIZE_X|WINDOW_POSSIZE_Y|WINDOW_POSSIZE_WIDTH);
755 	}
756 }
757 
758 
759 /*------------------------------------------------------------------------
760  Beschreibung:
761 ------------------------------------------------------------------------*/
762 
763 SwNavigationPI::SwNavigationPI( SfxBindings* _pBindings,
764 								SfxChildWindowContext* pCw,
765 								Window* pParent) :
766 
767 	Window( pParent, SW_RES(DLG_NAVIGATION_PI)),
768     SfxControllerItem( SID_DOCFULLNAME, *_pBindings ),
769 
770     aContentToolBox(this, SW_RES(TB_CONTENT)),
771     aGlobalToolBox(this, SW_RES(TB_GLOBAL)),
772     aContentImageList(SW_RES(IL_CONTENT)),
773     aContentImageListH(SW_RES(ILH_CONTENT)),
774     aContentTree(this, SW_RES(TL_CONTENT)),
775 	aGlobalTree(this, SW_RES(TL_GLOBAL)),
776 	aDocListBox(this, SW_RES(LB_DOCS)),
777 
778     pxObjectShell(0),
779     pContentView(0),
780     pContentWrtShell(0),
781     pActContView(0),
782     pCreateView(0),
783     pPopupWindow(0),
784     pFloatingWindow(0),
785 
786     pContextWin(pCw),
787 
788     pConfig(SW_MOD()->GetNavigationConfig()),
789     rBindings(*_pBindings),
790 
791     nWishWidth(0),
792 	nAutoMarkIdx(1),
793     nRegionMode(REGION_MODE_NONE),
794 
795     bSmallMode(sal_False),
796 	bIsZoomedIn(sal_False),
797 	bPageCtrlsVisible(sal_False),
798     bGlobalMode(sal_False)
799 {
800     GetCreateView();
801     InitImageList();
802 
803 	aContentToolBox.SetHelpId(HID_NAVIGATOR_TOOLBOX );
804 	aGlobalToolBox.SetHelpId(HID_NAVIGATOR_GLOBAL_TOOLBOX);
805 	aDocListBox.SetHelpId(HID_NAVIGATOR_LISTBOX );
806 
807 	nDocLBIniHeight = aDocListBox.GetSizePixel().Height();
808 	nZoomOutInit = nZoomOut = Resource::ReadShortRes();
809 
810 	//NumericField in die Toolbox einfuegen
811 	NumEditAction* pEdit = new NumEditAction(
812 					&aContentToolBox, SW_RES(NF_PAGE ));
813 	pEdit->SetActionHdl(LINK(this, SwNavigationPI, EditAction));
814 	pEdit->SetGetFocusHdl(LINK(this, SwNavigationPI, EditGetFocus));
815 	pEdit->SetAccessibleName(pEdit->GetQuickHelpText());
816 	pEdit->SetUpHdl(LINK(this, SwNavigationPI, PageEditModifyHdl));
817 	pEdit->SetDownHdl(LINK(this, SwNavigationPI, PageEditModifyHdl));
818 
819 	bPageCtrlsVisible = sal_True;
820 
821 //	Rectangle aFirstRect = aContentToolBox.GetItemRect(FN_SHOW_ROOT);
822 //	sal_uInt16 nWidth = 2 * (sal_uInt16)aFirstRect.Left();
823 	//doppelte Separatoren sind nicht erlaubt, also muss
824 	//die passende Groesse anders ermittelt werden
825     Rectangle aFirstRect = aContentToolBox.GetItemRect(FN_SELECT_FOOTNOTE);
826     Rectangle aSecondRect = aContentToolBox.GetItemRect(FN_SELECT_HEADER);
827 	sal_uInt16 nWidth = sal_uInt16(aFirstRect.Left() - aSecondRect.Left());
828 
829     Size aItemWinSize( nWidth , aFirstRect.Bottom() - aFirstRect.Top() );
830 	pEdit->SetSizePixel(aItemWinSize);
831 	aContentToolBox.InsertSeparator(4);
832 	aContentToolBox.InsertWindow( FN_PAGENUMBER, pEdit, 0, 4);
833 	aContentToolBox.InsertSeparator(4);
834 	aContentToolBox.SetHelpId(FN_PAGENUMBER, HID_NAVI_TBX16);
835 	aContentToolBox.ShowItem( FN_PAGENUMBER );
836 
837 	for( sal_uInt16 i = 0; i <= REGION_MODE_EMBEDDED; i++  )
838 	{
839 		aContextArr[i] = SW_RESSTR(ST_HYPERLINK + i);
840 		aStatusArr[i] = SW_RESSTR(ST_STATUS_FIRST + i);
841 	}
842 	aStatusArr[3] = SW_RESSTR(ST_ACTIVE_VIEW);
843 	FreeResource();
844 
845 
846 	const Size& rOutSize =  GetOutputSizePixel();
847 
848 	nZoomIn = (short)rOutSize.Height();
849 
850     // Make sure the toolbox has a size that fits all its contents
851     Size aContentToolboxSize( aContentToolBox.CalcWindowSizePixel() );
852     aContentToolBox.SetOutputSizePixel( aContentToolboxSize );
853 
854     // position listbox below toolbar and add some space
855     long nListboxYPos = aContentToolBox.GetPosPixel().Y() + aContentToolboxSize.Height() + 4;
856 
857 	//Der linke und rechte Rand um die Toolboxen soll gleich sein
858 	nWishWidth = aContentToolboxSize.Width();
859 	nWishWidth += 2 * aContentToolBox.GetPosPixel().X();
860 
861     DockingWindow* pDockingParent = dynamic_cast<DockingWindow*>(pParent);
862     if (pDockingParent != NULL)
863     {
864         FloatingWindow* pFloat =  pDockingParent->GetFloatingWindow();
865         Size aMinSize(pFloat ? nWishWidth : 0, pFloat ? nZoomOutInit : 0);
866         pDockingParent->SetMinOutputSizePixel(aMinSize);
867         SetOutputSizePixel( Size( nWishWidth, nZoomOutInit));
868 
869         SfxDockingWindow* pSfxDockingParent = dynamic_cast<SfxDockingWindow*>(pParent);
870         if (pSfxDockingParent != NULL)
871         {
872             Size aTmpParentSize(pSfxDockingParent->GetSizePixel());
873             if (aTmpParentSize.Width() < aMinSize.Width()
874                 || aTmpParentSize.Height() < aMinSize.Height())
875             {
876                 if (pSfxDockingParent->GetFloatingWindow()
877                     && ! pSfxDockingParent->GetFloatingWindow()->IsRollUp())
878                 {
879                     pSfxDockingParent->SetOutputSizePixel(aMinSize);
880                 }
881             }
882         }
883     }
884 
885     aContentTree.SetPosSizePixel( 0, nListboxYPos, 0, 0, WINDOW_POSSIZE_Y );
886 	aContentTree.SetStyle( aContentTree.GetStyle()|WB_HASBUTTONS|WB_HASBUTTONSATROOT|
887 							WB_CLIPCHILDREN|WB_HSCROLL|WB_FORCE_MAKEVISIBLE );
888     aContentTree.SetSpaceBetweenEntries(3);
889 	aContentTree.SetSelectionMode( SINGLE_SELECTION );
890 	aContentTree.SetDragDropMode( 	SV_DRAGDROP_CTRL_MOVE |
891 									SV_DRAGDROP_CTRL_COPY |
892 									SV_DRAGDROP_ENABLE_TOP );
893 	aContentTree.EnableAsyncDrag(sal_True);
894 	aContentTree.ShowTree();
895 	aContentToolBox.CheckItem(FN_SHOW_CONTENT_BOX, sal_True);
896 
897 // 	TreeListBox fuer Globaldokument
898     aGlobalTree.SetPosSizePixel( 0, nListboxYPos, 0, 0, WINDOW_POSSIZE_Y );
899 	aGlobalTree.SetSelectionMode( MULTIPLE_SELECTION );
900 	aGlobalTree.SetStyle( aGlobalTree.GetStyle()|WB_HASBUTTONS|WB_HASBUTTONSATROOT|
901 								WB_CLIPCHILDREN|WB_HSCROLL );
902 	Size aGlblSize(aGlobalToolBox.CalcWindowSizePixel());
903 	aGlobalToolBox.SetSizePixel(aGlblSize);
904 
905 //	Handler
906 
907 	Link aLk = LINK(this, SwNavigationPI, ToolBoxSelectHdl);
908 	aContentToolBox.SetSelectHdl( aLk );
909 	aGlobalToolBox.SetSelectHdl( aLk );
910 	aDocListBox.SetSelectHdl(LINK(this, SwNavigationPI,
911 													DocListBoxSelectHdl));
912 	aContentToolBox.SetClickHdl( LINK(this, SwNavigationPI, ToolBoxClickHdl) );
913 	aContentToolBox.SetDropdownClickHdl( LINK(this, SwNavigationPI, ToolBoxDropdownClickHdl) );
914 	aGlobalToolBox.SetClickHdl( LINK(this, SwNavigationPI, ToolBoxClickHdl) );
915 	aGlobalToolBox.SetDropdownClickHdl( LINK(this, SwNavigationPI, ToolBoxDropdownClickHdl) );
916 	aGlobalToolBox.CheckItem(FN_GLOBAL_SWITCH, sal_True);
917 
918 	Font aFont(GetFont());
919 	aFont.SetWeight(WEIGHT_NORMAL);
920 	GetPageEdit().SetFont(aFont);
921 	aFont = aContentTree.GetFont();
922 	aFont.SetWeight(WEIGHT_NORMAL);
923 	aContentTree.SetFont(aFont);
924 	aGlobalTree.SetFont(aFont);
925 
926 	StartListening(*SFX_APP());
927     if ( pCreateView )
928         StartListening(*pCreateView);
929     SfxImageManager* pImgMan = SfxImageManager::GetImageManager( SW_MOD() );
930 	pImgMan->RegisterToolBox(&aContentToolBox, SFX_TOOLBOX_CHANGEOUTSTYLE);
931 	pImgMan->RegisterToolBox(&aGlobalToolBox, SFX_TOOLBOX_CHANGEOUTSTYLE);
932 
933     aContentToolBox.SetItemBits( FN_CREATE_NAVIGATION, aContentToolBox.GetItemBits( FN_CREATE_NAVIGATION ) | TIB_DROPDOWNONLY );
934     aContentToolBox.SetItemBits( FN_DROP_REGION, aContentToolBox.GetItemBits( FN_DROP_REGION ) | TIB_DROPDOWNONLY );
935     aContentToolBox.SetItemBits( FN_OUTLINE_LEVEL, aContentToolBox.GetItemBits( FN_OUTLINE_LEVEL ) | TIB_DROPDOWNONLY );
936 
937 	if(IsGlobalDoc())
938 	{
939         SwView *pActView = GetCreateView();
940 		aGlobalToolBox.CheckItem(FN_GLOBAL_SAVE_CONTENT,
941 					pActView->GetWrtShellPtr()->IsGlblDocSaveLinks());
942 		if(pConfig->IsGlobalActive())
943 			ToggleTree();
944         aGlobalTree.GrabFocus();
945     }
946     else
947         aContentTree.GrabFocus();
948 	UsePage(0);
949 	aPageChgTimer.SetTimeoutHdl(LINK(this, SwNavigationPI, ChangePageHdl));
950 	aPageChgTimer.SetTimeout(PAGE_CHANGE_TIMEOUT);
951 
952 	aContentTree.SetAccessibleName(SW_RESSTR(STR_ACCESS_TL_CONTENT));
953 	aGlobalTree.SetAccessibleName(SW_RESSTR(STR_ACCESS_TL_GLOBAL));
954 	aDocListBox.SetAccessibleName(aStatusArr[3]);
955 
956     if (pContextWin == NULL)
957     {
958         // When the context window is missing then the navigator is
959         // displayed in the sidebar.  While the navigator could change
960         // its size, the sidebar can not, and the navigator would just
961         // waste space.  Therefore hide this button.
962         aContentToolBox.RemoveItem(aContentToolBox.GetItemPos(FN_SHOW_CONTENT_BOX));
963     }
964 }
965 
966 /*------------------------------------------------------------------------
967  Beschreibung:
968 ------------------------------------------------------------------------*/
969 
970 SwNavigationPI::~SwNavigationPI()
971 {
972 	if(IsGlobalDoc() && !IsGlobalMode())
973 	{
974         SwView *pView = GetCreateView();
975 		SwWrtShell &rSh = pView->GetWrtShell();
976 		if( !rSh.IsAllProtect() )
977 			pView->GetDocShell()->SetReadOnlyUI(sal_False);
978 	}
979 
980 	EndListening(*SFX_APP());
981 
982     SfxImageManager* pImgMan = SfxImageManager::GetImageManager( SW_MOD() );
983 	pImgMan->ReleaseToolBox(&aContentToolBox);
984 	pImgMan->ReleaseToolBox(&aGlobalToolBox);
985     delete aContentToolBox.GetItemWindow(FN_PAGENUMBER);
986     aContentToolBox.Clear();
987     if(pxObjectShell)
988 	{
989 		if(pxObjectShell->Is())
990 			(*pxObjectShell)->DoClose();
991 		delete pxObjectShell;
992 	}
993     delete pPopupWindow;
994     delete pFloatingWindow;
995 
996     if ( IsBound() )
997         rBindings.Release(*this);
998 }
999 
1000 /*------------------------------------------------------------------------
1001  Beschreibung:
1002 ------------------------------------------------------------------------*/
1003 
1004 void SwNavigationPI::SetPopupWindow( SfxPopupWindow* pWindow )
1005 {
1006     pPopupWindow = pWindow;
1007     pPopupWindow->SetPopupModeEndHdl( LINK( this, SwNavigationPI, PopupModeEndHdl ));
1008     pPopupWindow->SetDeleteLink_Impl( LINK( this, SwNavigationPI, ClosePopupWindow ));
1009 }
1010 
1011 /*------------------------------------------------------------------------
1012  Beschreibung:
1013 ------------------------------------------------------------------------*/
1014 
1015 IMPL_LINK( SwNavigationPI, PopupModeEndHdl, void *, EMPTYARG )
1016 {
1017 	if ( pPopupWindow->IsVisible() )
1018     {
1019         // Replace floating window with popup window and destroy
1020         // floating window instance.
1021         delete pFloatingWindow;
1022         pFloatingWindow = pPopupWindow;
1023         pPopupWindow    = 0;
1024     }
1025     else
1026     {
1027         // Popup window has been closed by the user. No replacement, instance
1028         // will destroy itself.
1029         pPopupWindow = 0;
1030     }
1031 
1032     return 1;
1033 }
1034 
1035 /*------------------------------------------------------------------------
1036  Beschreibung:
1037 ------------------------------------------------------------------------*/
1038 
1039 IMPL_LINK( SwNavigationPI, ClosePopupWindow, SfxPopupWindow *, pWindow )
1040 {
1041     if ( pWindow == pFloatingWindow )
1042         pFloatingWindow = 0;
1043     else
1044         pPopupWindow = 0;
1045 
1046     return 1;
1047 }
1048 
1049 /*------------------------------------------------------------------------
1050  Beschreibung:
1051 ------------------------------------------------------------------------*/
1052 
1053 void SwNavigationPI::StateChanged( sal_uInt16 nSID, SfxItemState /*eState*/,
1054                                             const SfxPoolItem* /*pState*/ )
1055 {
1056 	if(nSID == SID_DOCFULLNAME)
1057 	{
1058         SwView *pActView = GetCreateView();
1059 		if(pActView)
1060 		{
1061 			SwWrtShell* pWrtShell = pActView->GetWrtShellPtr();
1062 			aContentTree.SetActiveShell(pWrtShell);
1063 			sal_Bool bGlobal = IsGlobalDoc();
1064 			aContentToolBox.EnableItem(FN_GLOBAL_SWITCH, bGlobal);
1065 			if( (!bGlobal && IsGlobalMode()) ||
1066 					(!IsGlobalMode() && pConfig->IsGlobalActive()) )
1067 			{
1068 				ToggleTree();
1069 			}
1070 			if(bGlobal)
1071 			{
1072 				aGlobalToolBox.CheckItem(FN_GLOBAL_SAVE_CONTENT, pWrtShell->IsGlblDocSaveLinks());
1073 			}
1074 		}
1075 		else
1076 		{
1077 			aContentTree.SetActiveShell(0);
1078 		}
1079 		UpdateListBox();
1080 	}
1081 }
1082 
1083 /*------------------------------------------------------------------------
1084 	Bechreibung: NumericField aus der Toolbox holen
1085 ------------------------------------------------------------------------*/
1086 
1087 NumEditAction& SwNavigationPI::GetPageEdit()
1088 {
1089 	return *(NumEditAction*)aContentToolBox.GetItemWindow(FN_PAGENUMBER);
1090 }
1091 
1092 /*------------------------------------------------------------------------
1093  Beschreibung:
1094 ------------------------------------------------------------------------*/
1095 
1096 SfxChildAlignment SwNavigationPI::CheckAlignment
1097 	(
1098 		SfxChildAlignment eActAlign,
1099 		SfxChildAlignment eAlign
1100 	)
1101 {
1102 SfxChildAlignment eRetAlign;
1103 
1104 	if(_IsZoomedIn())
1105 		eRetAlign = SFX_ALIGN_NOALIGNMENT;
1106 	else
1107 		switch (eAlign)
1108 		{
1109 			case SFX_ALIGN_BOTTOM:
1110 			case SFX_ALIGN_LOWESTBOTTOM:
1111 			case SFX_ALIGN_HIGHESTBOTTOM:
1112 				eRetAlign = eActAlign;
1113 				break;
1114 
1115 			case SFX_ALIGN_TOP:
1116 			case SFX_ALIGN_HIGHESTTOP:
1117 			case SFX_ALIGN_LOWESTTOP:
1118 			case SFX_ALIGN_LEFT:
1119 			case SFX_ALIGN_RIGHT:
1120 			case SFX_ALIGN_FIRSTLEFT:
1121 			case SFX_ALIGN_LASTLEFT:
1122 			case SFX_ALIGN_FIRSTRIGHT:
1123 			case SFX_ALIGN_LASTRIGHT:
1124 				eRetAlign = eAlign;
1125 				break;
1126 
1127 			default:
1128 				eRetAlign = eAlign;
1129 				break;
1130 		}
1131 	return eRetAlign;
1132 
1133 }
1134 
1135 /*--------------------------------------------------------------------
1136 	Beschreibung: 	Benachrichtigung bei geaenderter DocInfo
1137  --------------------------------------------------------------------*/
1138 
1139 void SwNavigationPI::Notify( SfxBroadcaster& rBrdc, const SfxHint& rHint )
1140 {
1141     if(&rBrdc == pCreateView)
1142     {
1143         if(rHint.ISA(SfxSimpleHint) && ((SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING)
1144         {
1145             pCreateView = 0;
1146         }
1147     }
1148     else
1149     {
1150         if(rHint.ISA(SfxEventHint))
1151         {
1152             if( pxObjectShell &&
1153                         ((SfxEventHint&) rHint).GetEventId() == SFX_EVENT_CLOSEAPP)
1154             {
1155                 DELETEZ(pxObjectShell);
1156             }
1157             else if(((SfxEventHint&) rHint).GetEventId() == SFX_EVENT_OPENDOC)
1158             {
1159 
1160                 SwView *pActView = GetCreateView();
1161                 if(pActView)
1162                 {
1163                     SwWrtShell* pWrtShell = pActView->GetWrtShellPtr();
1164                     aContentTree.SetActiveShell(pWrtShell);
1165                     if(aGlobalTree.IsVisible())
1166                     {
1167                         if(aGlobalTree.Update( sal_False ))
1168                             aGlobalTree.Display();
1169                         else
1170                         // wenn kein Update notwendig, dann zumindest painten
1171                         // wg. der roten Eintraege fuer broken links
1172                             aGlobalTree.Invalidate();
1173                     }
1174                 }
1175             }
1176         }
1177     }
1178 }
1179 
1180 /*--------------------------------------------------------------------
1181 	Beschreibung:
1182  --------------------------------------------------------------------*/
1183 
1184 IMPL_LINK( SwNavigationPI, MenuSelectHdl, Menu *, pMenu )
1185 {
1186 	sal_uInt16 nMenuId = pMenu->GetCurItemId();
1187 	if(nMenuId != USHRT_MAX)
1188 	{
1189 		if(nMenuId < 100)
1190 			SetRegionDropMode( --nMenuId);
1191 		else
1192             aContentTree.SetOutlineLevel( static_cast< sal_uInt8 >(nMenuId - 100) );
1193 	}
1194 	return 0;
1195 }
1196 
1197 
1198 /*--------------------------------------------------------------------
1199 	Beschreibung:
1200  --------------------------------------------------------------------*/
1201 
1202 void SwNavigationPI::UpdateListBox()
1203 {
1204 	aDocListBox.SetUpdateMode(sal_False);
1205 	aDocListBox.Clear();
1206     SwView *pActView = GetCreateView();
1207 	sal_Bool bDisable = pActView == 0;
1208 	SwView *pView = SwModule::GetFirstView();
1209 	sal_uInt16 nCount = 0;
1210 	sal_uInt16 nAct = 0;
1211 	sal_uInt16 nConstPos = 0;
1212 	const SwView* pConstView = aContentTree.IsConstantView() &&
1213 								aContentTree.GetActiveWrtShell() ?
1214 									&aContentTree.GetActiveWrtShell()->GetView():
1215 										0;
1216 	while (pView)
1217 	{
1218         SfxObjectShell* pDoc = pView->GetDocShell();
1219         // pb: #i53333# don't show help pages here
1220         if ( !pDoc->IsHelpDocument() )
1221         {
1222             String sEntry = pDoc->GetTitle();
1223             sEntry += C2S(" (");
1224             if (pView == pActView)
1225             {
1226                 nAct = nCount;
1227                 sEntry += aStatusArr[ST_ACTIVE - ST_STATUS_FIRST];
1228             }
1229             else
1230                 sEntry += aStatusArr[ST_INACTIVE - ST_STATUS_FIRST];
1231             sEntry += ')';
1232             aDocListBox.InsertEntry(sEntry);
1233 
1234 
1235             if (pConstView && pView == pConstView)
1236                 nConstPos = nCount;
1237 
1238             nCount++;
1239         }
1240         pView = SwModule::GetNextView(pView);
1241 	}
1242 	aDocListBox.InsertEntry(aStatusArr[3]); //"Aktives Fenster"
1243 	nCount++;
1244 
1245 	if(aContentTree.GetHiddenWrtShell())
1246 	{
1247 		String sEntry = aContentTree.GetHiddenWrtShell()->GetView().
1248 										GetDocShell()->GetTitle();
1249 		sEntry += C2S(" (");
1250 		sEntry += aStatusArr[ST_HIDDEN - ST_STATUS_FIRST];
1251 		sEntry += ')';
1252 		aDocListBox.InsertEntry(sEntry);
1253 		bDisable = sal_False;
1254 	}
1255 	if(aContentTree.IsActiveView())
1256 	{
1257 		//entweder den Namen des akt. Docs oder "Aktives Dokument"
1258 		sal_uInt16 nTmp = pActView ? nAct : --nCount;
1259 		aDocListBox.SelectEntryPos( nTmp );
1260 	}
1261 	else if(aContentTree.IsHiddenView())
1262 	{
1263 		aDocListBox.SelectEntryPos(nCount);
1264 	}
1265 	else
1266 		aDocListBox.SelectEntryPos(nConstPos);
1267 
1268 	aDocListBox.Enable( !bDisable );
1269 	aDocListBox.SetUpdateMode(sal_True);
1270 }
1271 
1272 /*-----------------16.06.97 15:05-------------------
1273 
1274 --------------------------------------------------*/
1275 
1276 /*------------------------------------------------------------------------
1277 	Beschreibung:
1278 ------------------------------------------------------------------------*/
1279 
1280 IMPL_LINK(SwNavigationPI, DoneLink, SfxPoolItem *, pItem)
1281 {
1282 	const SfxViewFrameItem* pFrameItem = PTR_CAST(SfxViewFrameItem, pItem );
1283 	if( pFrameItem )
1284 	{
1285 		SfxViewFrame* pFrame =  pFrameItem->GetFrame();
1286 		if(pFrame)
1287 		{
1288 			aContentTree.Clear();
1289 			pContentView = PTR_CAST(SwView, pFrame->GetViewShell());
1290 			DBG_ASSERT(pContentView, "keine SwView");
1291 			if(pContentView)
1292 				pContentWrtShell = pContentView->GetWrtShellPtr();
1293 			else
1294 				pContentWrtShell = 0;
1295 			pxObjectShell = new SfxObjectShellLock(pFrame->GetObjectShell());
1296 			FillBox();
1297 			aContentTree.Update();
1298 		}
1299 	}
1300 	return 0;
1301 }
1302 
1303 String SwNavigationPI::CreateDropFileName( TransferableDataHelper& rData )
1304 {
1305 	String sFileName;
1306 	sal_uLong nFmt;
1307 	if( rData.HasFormat( nFmt = FORMAT_FILE_LIST ))
1308 	{
1309 		FileList aFileList;
1310 		rData.GetFileList( nFmt, aFileList );
1311 		sFileName = aFileList.GetFile( 0 );
1312 	}
1313 	else if( rData.HasFormat( nFmt = FORMAT_STRING ) ||
1314 	 		 rData.HasFormat( nFmt = FORMAT_FILE ) ||
1315 			 rData.HasFormat( nFmt = SOT_FORMATSTR_ID_FILENAME ))
1316 		rData.GetString( nFmt, sFileName );
1317 	else if( rData.HasFormat( nFmt = SOT_FORMATSTR_ID_SOLK ) ||
1318  		  	 rData.HasFormat( nFmt = SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK )||
1319  		  	 rData.HasFormat( nFmt = SOT_FORMATSTR_ID_FILECONTENT ) ||
1320  		  	 rData.HasFormat( nFmt = SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR ) ||
1321  		  	 rData.HasFormat( nFmt = SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR ))
1322 	{
1323 		INetBookmark aBkmk( aEmptyStr, aEmptyStr );
1324 		rData.GetINetBookmark( nFmt, aBkmk );
1325 		sFileName = aBkmk.GetURL();
1326 	}
1327 	if( sFileName.Len() )
1328     {
1329         sFileName = INetURLObject( sFileName ).GetMainURL( INetURLObject::NO_DECODE );
1330     }
1331 	return sFileName;
1332 }
1333 
1334 /*------------------------------------------------------------------------
1335 	Beschreibung:
1336 ------------------------------------------------------------------------*/
1337 
1338 sal_Int8 SwNavigationPI::AcceptDrop( const AcceptDropEvent& /*rEvt*/ )
1339 {
1340 	return ( !aContentTree.IsInDrag() &&
1341 		( aContentTree.IsDropFormatSupported( FORMAT_FILE ) ||
1342 		  aContentTree.IsDropFormatSupported( FORMAT_STRING ) ||
1343 		  aContentTree.IsDropFormatSupported( SOT_FORMATSTR_ID_SOLK ) ||
1344  		  aContentTree.IsDropFormatSupported( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK )||
1345  		  aContentTree.IsDropFormatSupported( SOT_FORMATSTR_ID_FILECONTENT ) ||
1346  		  aContentTree.IsDropFormatSupported( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR ) ||
1347  		  aContentTree.IsDropFormatSupported( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR ) ||
1348  		  aContentTree.IsDropFormatSupported( SOT_FORMATSTR_ID_FILENAME )))
1349 		? DND_ACTION_COPY
1350 		: DND_ACTION_NONE;
1351 }
1352 
1353 sal_Int8 SwNavigationPI::ExecuteDrop( const ExecuteDropEvent& rEvt )
1354 {
1355 	TransferableDataHelper aData( rEvt.maDropEvent.Transferable );
1356 	sal_Int8 nRet = DND_ACTION_NONE;
1357 	String sFileName;
1358 	if( !aContentTree.IsInDrag() &&
1359 		0 != (sFileName = SwNavigationPI::CreateDropFileName( aData )).Len() )
1360 	{
1361 		INetURLObject aTemp( sFileName );
1362 		GraphicDescriptor aDesc( aTemp );
1363 		if( !aDesc.Detect() )	// keine Grafiken annehmen
1364 		{
1365 			if( STRING_NOTFOUND == sFileName.Search('#')
1366 				&& (!sContentFileName.Len() || sContentFileName != sFileName ))
1367 			{
1368 				nRet = rEvt.mnAction;
1369 				sFileName.EraseTrailingChars( char(0) );
1370 				sContentFileName = sFileName;
1371 				if(pxObjectShell)
1372 				{
1373 					aContentTree.SetHiddenShell( 0 );
1374 					(*pxObjectShell)->DoClose();
1375 					DELETEZ( pxObjectShell);
1376 				}
1377 				SfxStringItem aFileItem(SID_FILE_NAME, sFileName );
1378 				String sOptions = C2S("HRC");
1379 				SfxStringItem aOptionsItem( SID_OPTIONS, sOptions );
1380 				SfxLinkItem aLink( SID_DONELINK,
1381 									LINK( this, SwNavigationPI, DoneLink ) );
1382 				GetActiveView()->GetViewFrame()->GetDispatcher()->Execute(
1383 							SID_OPENDOC, SFX_CALLMODE_ASYNCHRON,
1384 							&aFileItem, &aOptionsItem, &aLink, 0L );
1385 			}
1386 		}
1387 	}
1388 	return nRet;
1389 }
1390 
1391 /*-----------------27.11.96 13.00-------------------
1392 
1393 --------------------------------------------------*/
1394 
1395 void SwNavigationPI::SetRegionDropMode(sal_uInt16 nNewMode)
1396 {
1397 	nRegionMode = nNewMode;
1398 	pConfig->SetRegionMode( nRegionMode );
1399 
1400     sal_uInt16 nDropId = FN_DROP_REGION;
1401 	if(nRegionMode == REGION_MODE_LINK)
1402         nDropId = FN_DROP_REGION_LINK;
1403 	else if(nRegionMode == REGION_MODE_EMBEDDED)
1404         nDropId = FN_DROP_REGION_COPY;
1405 
1406     ImageList& rImgLst = aContentToolBox.GetSettings().GetStyleSettings().GetHighContrastMode()
1407 				? aContentImageListH : aContentImageList;
1408 
1409     aContentToolBox.SetItemImage( FN_DROP_REGION,
1410                                     rImgLst.GetImage(nDropId));
1411 }
1412 
1413 
1414 /*-----------------12.06.97 09:47-------------------
1415 
1416 --------------------------------------------------*/
1417 
1418 sal_Bool	SwNavigationPI::ToggleTree()
1419 {
1420 	sal_Bool bRet = sal_True;
1421 	sal_Bool bGlobalDoc = IsGlobalDoc();
1422 	if(!IsGlobalMode() && bGlobalDoc)
1423 	{
1424 		SetUpdateMode(sal_False);
1425 		if(_IsZoomedIn())
1426 			_ZoomOut();
1427 		aGlobalTree.ShowTree();
1428 		aGlobalToolBox.Show();
1429 		aContentTree.HideTree();
1430 		aContentToolBox.Hide();
1431 		aDocListBox.Hide();
1432 		SetGlobalMode(sal_True);
1433 		SetUpdateMode(sal_True);
1434 	}
1435 	else
1436 	{
1437 		aGlobalTree.HideTree();
1438 		aGlobalToolBox.Hide();
1439 		if(!_IsZoomedIn())
1440 		{
1441 			aContentTree.ShowTree();
1442 			aContentToolBox.Show();
1443 			aDocListBox.Show();
1444 		}
1445 		bRet = sal_False;
1446 		SetGlobalMode(sal_False);
1447 	}
1448     return bRet;
1449 }
1450 
1451 /*-----------------13.06.97 09:42-------------------
1452 
1453 --------------------------------------------------*/
1454 sal_Bool 	SwNavigationPI::IsGlobalDoc() const
1455 {
1456 	sal_Bool bRet = sal_False;
1457     SwView *pView = GetCreateView();
1458 	if(pView)
1459 	{
1460 		SwWrtShell &rSh = pView->GetWrtShell();
1461 		bRet = rSh.IsGlobalDoc();
1462 	}
1463 	return bRet;
1464 }
1465 /* -----------------26.10.98 08:10-------------------
1466  *
1467  * --------------------------------------------------*/
1468 IMPL_LINK( SwNavigationPI, ChangePageHdl, Timer*, EMPTYARG )
1469 {
1470 	EditAction(&GetPageEdit());
1471 	GetPageEdit().GrabFocus();
1472 	return 0;
1473 }
1474 /* -----------------26.10.98 08:14-------------------
1475  *
1476  * --------------------------------------------------*/
1477 IMPL_LINK( SwNavigationPI, PageEditModifyHdl, Edit*, EMPTYARG )
1478 {
1479 	if(aPageChgTimer.IsActive())
1480 		aPageChgTimer.Stop();
1481 	aPageChgTimer.Start();
1482 	return 0;
1483 }
1484 
1485 /* -----------------------------23.04.01 07:34--------------------------------
1486 
1487  ---------------------------------------------------------------------------*/
1488 SwView*  SwNavigationPI::GetCreateView() const
1489 {
1490     if(!pCreateView)
1491     {
1492         SwView* pView = SwModule::GetFirstView();
1493         while(pView)
1494         {
1495             if(&pView->GetViewFrame()->GetBindings() == &rBindings)
1496             {
1497                 ((SwNavigationPI*)this)->pCreateView = pView;
1498                 ((SwNavigationPI*)this)->StartListening(*pCreateView);
1499                 break;
1500             }
1501             pView = SwModule::GetNextView(pView);
1502         }
1503     }
1504     return pCreateView;
1505 }
1506 
1507 
1508 /*------------------------------------------------------------------------
1509  Beschreibung:
1510 ------------------------------------------------------------------------*/
1511 
1512 SwNavigationChild::SwNavigationChild( Window* pParent,
1513                         sal_uInt16 nId,
1514                         SfxBindings* _pBindings,
1515 						SfxChildWinInfo* pInfo )
1516 	: SfxChildWindowContext( nId )
1517 {
1518     SwNavigationPI* pNavi  = new SwNavigationPI( _pBindings, this, pParent );
1519 	SetWindow( pNavi );
1520     _pBindings->Invalidate(SID_NAVIGATOR);
1521 	String sExtra = pInfo->aExtraString;
1522 
1523 	SwNavigationConfig* pNaviConfig = SW_MOD()->GetNavigationConfig();
1524 
1525     sal_uInt16 nRootType = static_cast< sal_uInt16 >( pNaviConfig->GetRootType() );
1526 	if( nRootType < CONTENT_TYPE_MAX )
1527 	{
1528 		pNavi->aContentTree.SetRootType(nRootType);
1529 		pNavi->aContentToolBox.CheckItem(FN_SHOW_ROOT, sal_True);
1530 	}
1531     pNavi->aContentTree.SetOutlineLevel( static_cast< sal_uInt8 >( pNaviConfig->GetOutlineLevel() ) );
1532     pNavi->SetRegionDropMode( static_cast< sal_uInt16 >( pNaviConfig->GetRegionMode() ) );
1533 
1534 	if(GetFloatingWindow() && pNaviConfig->IsSmall())
1535 	{
1536 		pNavi->_ZoomIn();
1537 	}
1538 }
1539 /* -----------------------------06.05.2002 10:06------------------------------
1540 
1541  ---------------------------------------------------------------------------*/
1542 void SwNavigationPI::DataChanged( const DataChangedEvent& rDCEvt )
1543 {
1544     Window::DataChanged( rDCEvt );
1545     if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
1546          (rDCEvt.GetFlags() & SETTINGS_STYLE) )
1547     {
1548         InitImageList();
1549         const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
1550         Color aBgColor = rStyleSettings.GetFaceColor();
1551         Wallpaper aBack( aBgColor );
1552         SetBackground( aBack );
1553     }
1554 }
1555 /* -----------------------------06.05.2002 10:07------------------------------
1556 
1557  ---------------------------------------------------------------------------*/
1558 void SwNavigationPI::InitImageList()
1559 {
1560     sal_uInt16 k;
1561 
1562     ImageList& rImgLst = aContentToolBox.GetSettings().GetStyleSettings().GetHighContrastMode() ?
1563                 aContentImageListH : aContentImageList;
1564     for( k = 0; k < aContentToolBox.GetItemCount(); k++)
1565 			aContentToolBox.SetItemImage(aContentToolBox.GetItemId(k),
1566                     rImgLst.GetImage(aContentToolBox.GetItemId(k)));
1567 
1568 	for( k = 0; k < aGlobalToolBox.GetItemCount(); k++)
1569 			aGlobalToolBox.SetItemImage(aGlobalToolBox.GetItemId(k),
1570                     rImgLst.GetImage(aGlobalToolBox.GetItemId(k)));
1571 
1572     sal_uInt16 nDropId = FN_DROP_REGION;
1573 	if(nRegionMode == REGION_MODE_LINK)
1574         nDropId = FN_DROP_REGION_LINK;
1575 	else if(nRegionMode == REGION_MODE_EMBEDDED)
1576         nDropId = FN_DROP_REGION_COPY;
1577     aContentToolBox.SetItemImage( FN_DROP_REGION,
1578                                     rImgLst.GetImage(nDropId));
1579 }
1580 
1581