update dev300-m58
[ooovba.git] / sw / source / ui / utlui / navipi.cxx
blobf9989ee2734f81d4a40acd447b24d3e995ca6c74
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: navipi.cxx,v $
10 * $Revision: 1.46 $
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"
36 #define NAVIPI_CXX
38 #include <string> // HACK: prevent conflict between STLPORT and Workshop headers
39 #include <tools/list.hxx>
40 #include <svtools/urlbmk.hxx>
41 #include <svtools/stritem.hxx>
42 #include <svtools/filter.hxx>
43 #include <svtools/urihelper.hxx>
44 #include <sot/formats.hxx>
45 #include <sot/filelist.hxx>
46 #include <sfx2/event.hxx>
47 #include <sfx2/imgmgr.hxx>
48 #include <sfx2/dispatch.hxx>
49 #include <sfx2/dockwin.hxx>
50 #include <vcl/toolbox.hxx>
51 #include <swtypes.hxx> // fuer Pathfinder
52 #include <errhdl.hxx>
53 #include <swmodule.hxx>
54 #ifndef _VIEW_HXX
55 #include <view.hxx>
56 #endif
57 #include <navicfg.hxx>
58 #include <wrtsh.hxx>
59 #ifndef _DOCSH_HXX
60 #include <docsh.hxx>
61 #endif
62 #include <actctrl.hxx>
63 #include <IMark.hxx>
64 #include <navipi.hxx>
65 #include <content.hxx>
66 #include <workctrl.hxx>
67 #include <section.hxx>
68 #include <edtwin.hxx>
69 #include <sfx2/app.hxx>
70 #ifndef _CMDID_H
71 #include <cmdid.h>
72 #endif
73 #ifndef _HELPID_H
74 #include <helpid.h>
75 #endif
76 #ifndef _RIBBAR_HRC
77 #include <ribbar.hrc>
78 #endif
79 #ifndef _NAVIPI_HRC
80 #include <navipi.hrc>
81 #endif
82 #ifndef _UTLUI_HRC
83 #include <utlui.hrc>
84 #endif
86 #include <unomid.h>
89 #define PAGE_CHANGE_TIMEOUT 1000 //Timeout fuer Seitenwechsel
91 #define JUMP_TYPE_TBL 0
92 #define JUMP_TYPE_FRM 1
93 #define JUMP_TYPE_GRF 2
94 #define JUMP_TYPE_REG 3
95 #define JUMP_TYPE_BKM 4
97 // Version fuer Konfiguration
99 #define NAVI_VERSION0 0
100 #define NAVI_VERSION1 1
101 #define NAVI_VERSION2 2 // bIsGlobalActive
103 #define NAVI_CONFIG_VERSION NAVI_VERSION2
105 using namespace ::com::sun::star::uno;
106 using namespace ::com::sun::star::frame;
108 SFX_IMPL_CHILDWINDOW_CONTEXT( SwNavigationChild, SID_NAVIGATOR, SwView )
110 /*------------------------------------------------------------------------
111 Bechreibung: Steuerzeichen aus dem Outline-Entry filtern
112 ------------------------------------------------------------------------*/
114 void SwNavigationPI::CleanEntry( String& rEntry )
116 USHORT i = rEntry.Len();
117 if( i )
118 for( sal_Unicode* pStr = rEntry.GetBufferAccess(); i; --i, ++pStr )
119 if( *pStr == 10 || *pStr == 9 )
120 *pStr = 0x20;
122 /*------------------------------------------------------------------------
123 Beschreibung: Ausfuehrung der Drag-Operation
124 mit und ohne Childs
125 ------------------------------------------------------------------------*/
127 void SwNavigationPI::MoveOutline(USHORT nSource, USHORT nTarget,
128 BOOL bWithChilds)
130 SwView *pView = GetCreateView();
131 SwWrtShell &rSh = pView->GetWrtShell();
132 if(nTarget < nSource || nTarget == USHRT_MAX)
133 nTarget ++;
134 if ( rSh.IsOutlineMovable( nSource ))
137 short nMove = nTarget-nSource; //( nDir<0 ) ? 1 : 0 ;
138 rSh.GotoOutline(nSource);
139 if (bWithChilds)
140 rSh.MakeOutlineSel(nSource, nSource, TRUE);
141 // Die selektierten Children zaehlen bei der Bewegung vorwaerts nicht mit
142 USHORT nLastOutlinePos = rSh.GetOutlinePos(MAXLEVEL);
143 if(bWithChilds && nMove > 1 &&
144 nLastOutlinePos < nTarget)
146 if(!rSh.IsCrsrPtAtEnd())
147 rSh.SwapPam();
148 nMove -= nLastOutlinePos - nSource;
150 if(!bWithChilds || nMove < 1 || nLastOutlinePos < nTarget )
151 rSh.MoveOutlinePara( nMove );
152 rSh.ClearMark();
153 rSh.GotoOutline( nSource + nMove);
154 FillBox();
160 /*------------------------------------------------------------------------
161 Beschreibung: Nach Goto einen Status Rahmenselektion aufheben
162 ------------------------------------------------------------------------*/
165 void lcl_UnSelectFrm(SwWrtShell *pSh)
167 if (pSh->IsFrmSelected())
169 pSh->UnSelectFrm();
170 pSh->LeaveSelFrmMode();
174 /*------------------------------------------------------------------------
175 Beschreibung: Select der Documentanzeige
176 ------------------------------------------------------------------------*/
179 IMPL_LINK( SwNavigationPI, DocListBoxSelectHdl, ListBox *, pBox )
181 int nEntryIdx = pBox->GetSelectEntryPos();
182 SwView *pView ;
183 pView = SwModule::GetFirstView();
184 while (nEntryIdx-- && pView)
186 pView = SwModule::GetNextView(pView);
188 if(!pView)
190 nEntryIdx == 0 ?
191 aContentTree.ShowHiddenShell():
192 aContentTree.ShowActualView();
196 else
198 aContentTree.SetConstantShell(pView->GetWrtShellPtr());
200 return 0;
203 /*------------------------------------------------------------------------
204 Beschreibung: Fuellen der ListBox fuer Outline Sicht oder Dokumente
205 Der PI wird auf volle Groesse gesetzt
206 ------------------------------------------------------------------------*/
209 void SwNavigationPI::FillBox()
211 if(pContentWrtShell)
213 aContentTree.SetHiddenShell( pContentWrtShell );
214 aContentTree.Display( FALSE );
216 else
218 SwView *pView = GetCreateView();
219 if(!pView)
221 aContentTree.SetActiveShell(0);
223 else if( pView != pActContView)
225 SwWrtShell* pWrtShell = pView->GetWrtShellPtr();
226 aContentTree.SetActiveShell(pWrtShell);
228 else
229 aContentTree.Display( TRUE );
230 pActContView = pView;
235 void SwNavigationPI::UsePage(SwWrtShell *pSh)
237 if (!pSh)
239 SwView *pView = GetCreateView();
240 pSh = pView ? &pView->GetWrtShell() : 0;
241 GetPageEdit().SetValue(1);
243 if (pSh)
245 const USHORT nPageCnt = pSh->GetPageCnt();
246 USHORT nPhyPage, nVirPage;
247 pSh->GetPageNum(nPhyPage, nVirPage);
249 GetPageEdit().SetMax(nPageCnt);
250 GetPageEdit().SetLast(nPageCnt);
251 GetPageEdit().SetValue(nPhyPage);
255 /*------------------------------------------------------------------------
256 Beschreibung: SelectHandler der Toolboxen
257 ------------------------------------------------------------------------*/
260 IMPL_LINK( SwNavigationPI, ToolBoxSelectHdl, ToolBox *, pBox )
262 const USHORT nCurrItemId = pBox->GetCurItemId();
263 SwView *pView = GetCreateView();
264 if (!pView)
265 return 1;
266 SwWrtShell &rSh = pView->GetWrtShell();
267 //MouseModifier fuer Outline-Move besorgen
269 //Standard: Unterebenen werden mitgenommen
270 // mit Ctrl Unterebenen nicht mitnehmen
271 BOOL bOutlineWithChilds = ( KEY_MOD1 != pBox->GetModifier());
272 int nFuncId = 0;
273 BOOL bFocusToDoc = FALSE;
274 switch (nCurrItemId)
276 case FN_UP:
277 case FN_DOWN:
279 // #i75416# move the execution of the search to an asynchronously called static link
280 bool* pbNext = new bool( FN_DOWN == nCurrItemId );
281 Application::PostUserEvent( STATIC_LINK(pView, SwView, MoveNavigationHdl), pbNext );
283 break;
284 case FN_SHOW_ROOT:
286 aContentTree.ToggleToRoot();
288 break;
289 case FN_SHOW_CONTENT_BOX:
290 case FN_SELECT_CONTENT:
291 if(pContextWin->GetFloatingWindow())
293 if(_IsZoomedIn() )
295 _ZoomOut();
297 else
299 _ZoomIn();
302 return TRUE;
303 //break;
304 // Funktionen, die eine direkte Aktion ausloesen
306 case FN_SELECT_FOOTER:
308 rSh.MoveCrsr();
309 const USHORT eType = rSh.GetFrmType(0,FALSE);
310 if (eType & FRMTYPE_FOOTER)
312 if (rSh.EndPg())
313 nFuncId = FN_END_OF_PAGE;
315 else if (rSh.GotoFooterTxt())
316 nFuncId = FN_TO_FOOTER;
317 bFocusToDoc = TRUE;
319 break;
320 case FN_SELECT_HEADER:
322 rSh.MoveCrsr();
323 const USHORT eType = rSh.GetFrmType(0,FALSE);
324 if (eType & FRMTYPE_HEADER)
326 if (rSh.SttPg())
327 nFuncId = FN_START_OF_PAGE;
329 else if (rSh.GotoHeaderTxt())
330 nFuncId = FN_TO_HEADER;
331 bFocusToDoc = TRUE;
333 break;
334 case FN_SELECT_FOOTNOTE:
336 rSh.MoveCrsr();
337 const USHORT eFrmType = rSh.GetFrmType(0,FALSE);
338 // aus Fussnote zum Anker springen
339 if (eFrmType & FRMTYPE_FOOTNOTE)
341 if (rSh.GotoFtnAnchor())
342 nFuncId = FN_FOOTNOTE_TO_ANCHOR;
344 // andernfalls zuerst zum Fussnotentext springen; geht
345 // dies nicht, zur naechten Fussnote; geht auch dies
346 // nicht, zur vorhergehenden Fussnote
347 else
349 if (rSh.GotoFtnTxt())
350 nFuncId = FN_FOOTNOTE_TO_ANCHOR;
351 else if (rSh.GotoNextFtnAnchor())
352 nFuncId = FN_NEXT_FOOTNOTE;
353 else if (rSh.GotoPrevFtnAnchor())
354 nFuncId = FN_PREV_FOOTNOTE;
356 bFocusToDoc = TRUE;
358 break;
360 case FN_SELECT_SET_AUTO_BOOKMARK:
361 MakeMark();
362 break;
363 case FN_ITEM_DOWN:
364 case FN_ITEM_UP:
365 case FN_ITEM_LEFT:
366 case FN_ITEM_RIGHT:
367 case FN_GLOBAL_EDIT:
369 if(IsGlobalMode())
370 aGlobalTree.ExecCommand(nCurrItemId);
371 else
372 aContentTree.ExecCommand(nCurrItemId, bOutlineWithChilds);
374 break;
375 case FN_GLOBAL_SWITCH:
377 ToggleTree();
378 pConfig->SetGlobalActive(IsGlobalMode());
380 break;
381 case FN_GLOBAL_SAVE_CONTENT:
383 BOOL bSave = rSh.IsGlblDocSaveLinks();
384 rSh.SetGlblDocSaveLinks( !bSave );
385 pBox->CheckItem(FN_GLOBAL_SAVE_CONTENT, !bSave );
387 break;
390 if (nFuncId)
392 lcl_UnSelectFrm(&rSh);
394 if(bFocusToDoc)
395 pView->GetEditWin().GrabFocus();
396 return TRUE;
398 /*------------------------------------------------------------------------
399 Beschreibung: ClickHandler der Toolboxen
400 ------------------------------------------------------------------------*/
403 IMPL_LINK( SwNavigationPI, ToolBoxClickHdl, ToolBox *, pBox )
405 const USHORT nCurrItemId = pBox->GetCurItemId();
406 switch (nCurrItemId)
408 case FN_GLOBAL_UPDATE:
409 case FN_GLOBAL_OPEN:
411 aGlobalTree.TbxMenuHdl(nCurrItemId, pBox);
413 break;
416 return TRUE;
419 /*-----------------13.07.04 -------------------
420 ----------------------------------------------*/
422 IMPL_LINK( SwNavigationPI, ToolBoxDropdownClickHdl, ToolBox*, pBox )
424 const USHORT nCurrItemId = pBox->GetCurItemId();
425 switch (nCurrItemId)
427 case FN_CREATE_NAVIGATION:
429 CreateNavigationTool(pBox->GetItemRect(FN_CREATE_NAVIGATION), TRUE);
431 break;
433 case FN_DROP_REGION:
435 PopupMenu *pMenu = new PopupMenu;
436 for (USHORT i = 0; i <= REGION_MODE_EMBEDDED; i++)
438 pMenu->InsertItem( i + 1, aContextArr[i] );
439 pMenu->SetHelpId(i + 1, HID_NAVI_DRAG_HYP + i);
440 /*HID_NAVI_DRAG_HYP
441 HID_NAVI_DRAG_LINK
442 HID_NAVI_DRAG_COPY */
444 pMenu->CheckItem( nRegionMode + 1 );
445 pMenu->SetSelectHdl(LINK(this, SwNavigationPI, MenuSelectHdl));
446 pBox->SetItemDown( nCurrItemId, TRUE );
447 pMenu->Execute( pBox,
448 pBox->GetItemRect(FN_DROP_REGION),
449 POPUPMENU_EXECUTE_DOWN );
450 pBox->SetItemDown( nCurrItemId, FALSE );
451 pBox->EndSelection();
452 delete pMenu;
453 pBox->Invalidate();
455 break;
456 case FN_OUTLINE_LEVEL:
458 PopupMenu *pMenu = new PopupMenu;
459 for (USHORT i = 101; i <= 100 + MAXLEVEL; i++)
461 pMenu->InsertItem( i, String::CreateFromInt32(i - 100) );
462 pMenu->SetHelpId( i, HID_NAVI_OUTLINES );
464 pMenu->CheckItem( aContentTree.GetOutlineLevel() + 100 );
465 pMenu->SetSelectHdl(LINK(this, SwNavigationPI, MenuSelectHdl));
466 pBox->SetItemDown( nCurrItemId, TRUE );
467 pMenu->Execute( pBox,
468 pBox->GetItemRect(FN_OUTLINE_LEVEL),
469 POPUPMENU_EXECUTE_DOWN );
470 pBox->SetItemDown( nCurrItemId, FALSE );
471 delete pMenu;
472 pBox->EndSelection();
473 pBox->Invalidate();
475 break;
477 return TRUE;
480 /*-----------------13.07.04 -------------------
481 --------------------------------------------------*/
483 SwNavHelpToolBox::SwNavHelpToolBox(SwNavigationPI* pParent, const ResId &rResId) :
484 SwHelpToolBox(pParent, rResId)
486 /*-----------------19.06.97 09:09-------------------
488 --------------------------------------------------*/
489 void SwNavHelpToolBox::MouseButtonDown(const MouseEvent &rEvt)
491 if(rEvt.GetButtons() == MOUSE_LEFT &&
492 FN_CREATE_NAVIGATION == GetItemId(rEvt.GetPosPixel()))
494 ((SwNavigationPI*)GetParent())->CreateNavigationTool(GetItemRect(FN_CREATE_NAVIGATION), FALSE);
496 else
497 SwHelpToolBox::MouseButtonDown(rEvt);
499 /* -----------------------------12.03.2002 16:55------------------------------
501 ---------------------------------------------------------------------------*/
502 void SwNavigationPI::CreateNavigationTool(const Rectangle& rRect, BOOL bSetFocus)
504 // SfxBindings& rBind = GetCreateView()->GetViewFrame()->GetBindings();
505 // rBind.ENTERREGISTRATIONS();
506 Reference< XFrame > xFrame = GetCreateView()->GetViewFrame()->GetFrame()->GetFrameInterface();
507 SwScrollNaviPopup* pPopup = new
508 SwScrollNaviPopup(FN_SCROLL_NAVIGATION,
509 xFrame );
510 // rBind.LEAVEREGISTRATIONS();
512 Rectangle aRect(rRect);
513 Point aT1 = aRect.TopLeft();
514 aT1 = pPopup->GetParent()->OutputToScreenPixel(pPopup->GetParent()->AbsoluteScreenToOutputPixel(aContentToolBox.OutputToAbsoluteScreenPixel(aT1)));
515 aRect.SetPos(aT1);
516 pPopup->StartPopupMode(aRect, FLOATWIN_POPUPMODE_RIGHT|FLOATWIN_POPUPMODE_ALLOWTEAROFF);
517 SetPopupWindow( pPopup );
518 if(bSetFocus)
520 pPopup->EndPopupMode(FLOATWIN_POPUPMODEEND_TEAROFF);
521 pPopup->GrabFocus();
525 /*-----------------19.06.97 10:12-------------------
527 --------------------------------------------------*/
528 void SwNavHelpToolBox::RequestHelp( const HelpEvent& rHEvt )
530 USHORT nItemId = GetItemId(ScreenToOutputPixel(rHEvt.GetMousePosPixel()));
531 if( FN_UP == nItemId || FN_DOWN == nItemId )
533 SetItemText(nItemId, SwScrollNaviPopup::GetQuickHelpText((FN_DOWN == nItemId)));
535 SwHelpToolBox::RequestHelp(rHEvt);
538 /*------------------------------------------------------------------------
539 Beschreibung: Action-Handler Edit; wechselt auf die Seite, wenn
540 nicht Gliederungssicht angeschaltet ist.
541 ------------------------------------------------------------------------*/
544 IMPL_LINK( SwNavigationPI, EditAction, NumEditAction *, pEdit )
546 SwView *pView = GetCreateView();
547 if (pView)
549 if(aPageChgTimer.IsActive())
550 aPageChgTimer.Stop();
551 pCreateView->GetWrtShell().GotoPage((USHORT)pEdit->GetValue(), TRUE);
552 pCreateView->GetEditWin().GrabFocus();
553 pCreateView->GetViewFrame()->GetBindings().Invalidate(FN_STAT_PAGE);
555 return 0;
558 /*------------------------------------------------------------------------
559 Beschreibung: Falls die Seite eingestellt werden kann, wird hier
560 das Maximum gesetzt.
561 ------------------------------------------------------------------------*/
564 IMPL_LINK( SwNavigationPI, EditGetFocus, NumEditAction *, pEdit )
566 SwView *pView = GetCreateView();
567 if (!pView)
568 return 0;
569 SwWrtShell &rSh = pView->GetWrtShell();
571 const USHORT nPageCnt = rSh.GetPageCnt();
572 pEdit->SetMax(nPageCnt);
573 pEdit->SetLast(nPageCnt);
574 return 0;
577 /*------------------------------------------------------------------------
578 Beschreibung:
579 ------------------------------------------------------------------------*/
581 BOOL SwNavigationPI::Close()
583 SfxViewFrame* pVFrame = pCreateView->GetViewFrame();
584 pVFrame->GetBindings().Invalidate(SID_NAVIGATOR);
585 pVFrame->GetDispatcher()->Execute(SID_NAVIGATOR);
586 return TRUE;
589 /*------------------------------------------------------------------------
590 Beschreibung: Setzen einer automatischen Marke
591 ------------------------------------------------------------------------*/
594 void SwNavigationPI::MakeMark()
596 SwView *pView = GetCreateView();
597 if (!pView) return;
598 SwWrtShell &rSh = pView->GetWrtShell();
599 IDocumentMarkAccess* const pMarkAccess = rSh.getIDocumentMarkAccess();
601 // collect and sort navigator reminder names
602 ::std::vector< ::rtl::OUString > vNavMarkNames;
603 for(IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->getMarksBegin();
604 ppMark != pMarkAccess->getMarksEnd();
605 ppMark++)
606 if( IDocumentMarkAccess::GetType(**ppMark) == IDocumentMarkAccess::NAVIGATOR_REMINDER )
607 vNavMarkNames.push_back(ppMark->get()->GetName());
608 ::std::sort(vNavMarkNames.begin(), vNavMarkNames.end());
610 // we are maxed out and delete one
611 // nAutoMarkIdx rotates through the available MarkNames
612 // this assumes that IDocumentMarkAccess generates Names in ascending order
613 if(vNavMarkNames.size() == MAX_MARKS)
614 pMarkAccess->deleteMark(pMarkAccess->findMark(vNavMarkNames[nAutoMarkIdx]));
616 rSh.SetBookmark(KeyCode(), ::rtl::OUString(), ::rtl::OUString(), IDocumentMarkAccess::NAVIGATOR_REMINDER);
617 SwView::SetActMark( nAutoMarkIdx );
619 if(++nAutoMarkIdx == MAX_MARKS)
620 nAutoMarkIdx = 0;
623 /*------------------------------------------------------------------------
624 Beschreibung:
625 ------------------------------------------------------------------------*/
627 void SwNavigationPI::GotoPage()
629 if ( pContextWin->GetFloatingWindow() && pContextWin->GetFloatingWindow()->IsRollUp())
630 _ZoomIn();
631 if(IsGlobalMode())
632 ToggleTree();
633 UsePage(0);
634 GetPageEdit().GrabFocus();
637 /*------------------------------------------------------------------------
638 Beschreibung:
639 ------------------------------------------------------------------------*/
641 void SwNavigationPI::_ZoomOut()
643 if (_IsZoomedIn())
645 FloatingWindow* pFloat = pContextWin->GetFloatingWindow();
646 bIsZoomedIn = FALSE;
647 Size aSz(GetOutputSizePixel());
648 aSz.Height() = nZoomOut;
649 Size aMinOutSizePixel = ((SfxDockingWindow*)GetParent())->GetMinOutputSizePixel();
650 ((SfxDockingWindow*)GetParent())->SetMinOutputSizePixel(Size(
651 aMinOutSizePixel.Width(),nZoomOutInit));
652 pFloat->SetOutputSizePixel(aSz);
653 FillBox();
654 if(IsGlobalMode())
656 aGlobalTree.ShowTree();
658 else
660 aContentTree.ShowTree();
661 aDocListBox.Show();
663 SvLBoxEntry* pFirst = aContentTree.FirstSelected();
664 if(pFirst)
665 aContentTree.Select(pFirst, TRUE); // toolbox enablen
666 pConfig->SetSmall( FALSE );
667 aContentToolBox.CheckItem(FN_SHOW_CONTENT_BOX);
671 /*------------------------------------------------------------------------
672 Beschreibung:
673 ------------------------------------------------------------------------*/
675 void SwNavigationPI::_ZoomIn()
677 FloatingWindow* pFloat = pContextWin->GetFloatingWindow();
678 if (pFloat &&
679 (!_IsZoomedIn() || ( pContextWin->GetFloatingWindow()->IsRollUp())))
681 aContentTree.HideTree();
682 aDocListBox.Hide();
683 aGlobalTree.HideTree();
684 bIsZoomedIn = TRUE;
685 Size aSz(GetOutputSizePixel());
686 if( aSz.Height() > nZoomIn )
687 nZoomOut = ( short ) aSz.Height();
689 aSz.Height() = nZoomIn;
690 Size aMinOutSizePixel = ((SfxDockingWindow*)GetParent())->GetMinOutputSizePixel();
691 ((SfxDockingWindow*)GetParent())->SetMinOutputSizePixel(Size(
692 aMinOutSizePixel.Width(), aSz.Height()));
693 pFloat->SetOutputSizePixel(aSz);
694 SvLBoxEntry* pFirst = aContentTree.FirstSelected();
695 if(pFirst)
696 aContentTree.Select(pFirst, TRUE); // toolbox enablen
697 pConfig->SetSmall( TRUE );
698 aContentToolBox.CheckItem(FN_SHOW_CONTENT_BOX, FALSE);
701 /*------------------------------------------------------------------------
702 Beschreibung:
703 ------------------------------------------------------------------------*/
705 void SwNavigationPI::Resize()
707 Window* pParent = GetParent();
708 FloatingWindow* pFloat = ((DockingWindow*)pParent)->GetFloatingWindow();
709 Size aNewSize;
710 if( !_IsZoomedIn() )
712 //change the minimum width depending on the dock status
713 Size aMinOutSizePixel = ((SfxDockingWindow*)pParent)->GetMinOutputSizePixel();
714 if( pFloat)
716 aNewSize = pFloat->GetOutputSizePixel();
717 aMinOutSizePixel.Width() = nWishWidth;
718 aMinOutSizePixel.Height() = _IsZoomedIn() ? nZoomIn : nZoomOutInit;
720 else
722 aNewSize = pParent->GetOutputSizePixel();
723 aMinOutSizePixel.Width() = 0;
724 aMinOutSizePixel.Height() = 0;
726 ((SfxDockingWindow*)GetParent())->SetMinOutputSizePixel(aMinOutSizePixel);
728 const Point aPos = aContentTree.GetPosPixel();
729 Point aLBPos = aDocListBox.GetPosPixel();
730 long nDist = aPos.X();
731 aNewSize.Height() -= (aPos.Y() + aPos.X() + nDocLBIniHeight + nDist);
732 aNewSize.Width() -= 2 * nDist;
733 aLBPos.Y() = aPos.Y() + aNewSize.Height() + nDist;
734 aDocListBox.Show(!aGlobalTree.IsVisible() && aLBPos.Y() > aPos.Y() );
736 Size aDocLBSz = aDocListBox.GetSizePixel();
737 aDocLBSz.Width() = aNewSize.Width();
738 if(aNewSize.Height() < 0)
739 aDocLBSz.Height() = 0;
740 else
741 aDocLBSz.Height() = nDocLBIniHeight;
742 aContentTree.SetSizePixel(aNewSize);
743 // GlobalTree faengt weiter oben an und reicht bis ganz unten
744 aNewSize.Height() += (nDist + nDocLBIniHeight + aPos.Y() - aGlobalTree.GetPosPixel().Y());
745 aGlobalTree.SetSizePixel(aNewSize);
746 aDocListBox.SetPosSizePixel( aLBPos.X(), aLBPos.Y(),
747 aDocLBSz.Width(), aDocLBSz.Height(),
748 WINDOW_POSSIZE_X|WINDOW_POSSIZE_Y|WINDOW_POSSIZE_WIDTH);
754 /*------------------------------------------------------------------------
755 Beschreibung:
756 ------------------------------------------------------------------------*/
758 SwNavigationPI::SwNavigationPI( SfxBindings* _pBindings,
759 SfxChildWindowContext* pCw,
760 Window* pParent) :
762 Window( pParent, SW_RES(DLG_NAVIGATION_PI)),
763 SfxControllerItem( SID_DOCFULLNAME, *_pBindings ),
765 aContentToolBox(this, SW_RES(TB_CONTENT)),
766 aGlobalToolBox(this, SW_RES(TB_GLOBAL)),
767 aContentImageList(SW_RES(IL_CONTENT)),
768 aContentImageListH(SW_RES(ILH_CONTENT)),
769 aContentTree(this, SW_RES(TL_CONTENT)),
770 aGlobalTree(this, SW_RES(TL_GLOBAL)),
771 aDocListBox(this, SW_RES(LB_DOCS)),
773 pxObjectShell(0),
774 pContentView(0),
775 pContentWrtShell(0),
776 pActContView(0),
777 pCreateView(0),
778 pPopupWindow(0),
779 pFloatingWindow(0),
781 pContextWin(pCw),
783 pConfig(SW_MOD()->GetNavigationConfig()),
784 rBindings(*_pBindings),
786 nWishWidth(0),
787 nAutoMarkIdx(1),
788 nRegionMode(REGION_MODE_NONE),
790 bSmallMode(FALSE),
791 bIsZoomedIn(FALSE),
792 bPageCtrlsVisible(FALSE),
793 bGlobalMode(FALSE)
795 GetCreateView();
796 InitImageList();
798 aContentToolBox.SetHelpId(HID_NAVIGATOR_TOOLBOX );
799 aGlobalToolBox.SetHelpId(HID_NAVIGATOR_GLOBAL_TOOLBOX);
800 aDocListBox.SetHelpId(HID_NAVIGATOR_LISTBOX );
802 nDocLBIniHeight = aDocListBox.GetSizePixel().Height();
803 nZoomOutInit = nZoomOut = Resource::ReadShortRes();
805 //NumericField in die Toolbox einfuegen
806 NumEditAction* pEdit = new NumEditAction(
807 &aContentToolBox, SW_RES(NF_PAGE ));
808 pEdit->SetActionHdl(LINK(this, SwNavigationPI, EditAction));
809 pEdit->SetGetFocusHdl(LINK(this, SwNavigationPI, EditGetFocus));
810 pEdit->SetModifyHdl(LINK(this, SwNavigationPI, PageEditModifyHdl));
812 bPageCtrlsVisible = TRUE;
814 // Rectangle aFirstRect = aContentToolBox.GetItemRect(FN_SHOW_ROOT);
815 // USHORT nWidth = 2 * (USHORT)aFirstRect.Left();
816 //doppelte Separatoren sind nicht erlaubt, also muss
817 //die passende Groesse anders ermittelt werden
818 Rectangle aFirstRect = aContentToolBox.GetItemRect(FN_SELECT_FOOTNOTE);
819 Rectangle aSecondRect = aContentToolBox.GetItemRect(FN_SELECT_HEADER);
820 USHORT nWidth = USHORT(aFirstRect.Left() - aSecondRect.Left());
822 Size aItemWinSize( nWidth , aFirstRect.Bottom() - aFirstRect.Top() );
823 pEdit->SetSizePixel(aItemWinSize);
824 aContentToolBox.InsertSeparator(4);
825 aContentToolBox.InsertWindow( FN_PAGENUMBER, pEdit, 0, 4);
826 aContentToolBox.InsertSeparator(4);
827 aContentToolBox.SetHelpId(FN_PAGENUMBER, HID_NAVI_TBX16);
828 aContentToolBox.ShowItem( FN_PAGENUMBER );
830 for( USHORT i = 0; i <= REGION_MODE_EMBEDDED; i++ )
832 aContextArr[i] = SW_RESSTR(ST_HYPERLINK + i);
833 aStatusArr[i] = SW_RESSTR(ST_STATUS_FIRST + i);
835 aStatusArr[3] = SW_RESSTR(ST_ACTIVE_VIEW);
836 FreeResource();
839 const Size& rOutSize = GetOutputSizePixel();
841 nZoomIn = (short)rOutSize.Height();
843 // Make sure the toolbox has a size that fits all its contents
844 Size aContentToolboxSize( aContentToolBox.CalcWindowSizePixel() );
845 aContentToolBox.SetOutputSizePixel( aContentToolboxSize );
847 // position listbox below toolbar and add some space
848 long nListboxYPos = aContentToolBox.GetPosPixel().Y() + aContentToolboxSize.Height() + 4;
850 //Der linke und rechte Rand um die Toolboxen soll gleich sein
851 nWishWidth = aContentToolboxSize.Width();
852 nWishWidth += 2 * aContentToolBox.GetPosPixel().X();
854 FloatingWindow* pFloat = ((DockingWindow*)pParent)->GetFloatingWindow();
855 Size aMinSize(pFloat ? nWishWidth : 0, pFloat ? nZoomOutInit : 0);
856 ((SfxDockingWindow*)pParent)->SetMinOutputSizePixel(aMinSize);
857 SetOutputSizePixel( Size( nWishWidth, nZoomOutInit));
858 Size aTmpParentSize(((SfxDockingWindow*)pParent)->GetSizePixel());
861 aTmpParentSize.Width() < aMinSize.Width() ||
862 aTmpParentSize.Height() < aMinSize.Height()
865 ((SfxDockingWindow*)pParent)->GetFloatingWindow() &&
866 !((SfxDockingWindow*)pParent)->GetFloatingWindow()->IsRollUp()
868 ((SfxDockingWindow*)pParent)->SetOutputSizePixel(aMinSize);
870 aContentTree.SetPosSizePixel( 0, nListboxYPos, 0, 0, WINDOW_POSSIZE_Y );
871 aContentTree.SetWindowBits( WB_HASBUTTONS|WB_HASBUTTONSATROOT|
872 WB_CLIPCHILDREN|WB_HSCROLL|WB_FORCE_MAKEVISIBLE );
873 aContentTree.SetSpaceBetweenEntries(3);
874 aContentTree.SetSelectionMode( SINGLE_SELECTION );
875 aContentTree.SetDragDropMode( SV_DRAGDROP_CTRL_MOVE |
876 SV_DRAGDROP_CTRL_COPY |
877 SV_DRAGDROP_ENABLE_TOP );
878 aContentTree.EnableAsyncDrag(TRUE);
879 aContentTree.ShowTree();
880 aContentToolBox.CheckItem(FN_SHOW_CONTENT_BOX, TRUE);
882 // TreeListBox fuer Globaldokument
883 aGlobalTree.SetPosSizePixel( 0, nListboxYPos, 0, 0, WINDOW_POSSIZE_Y );
884 aGlobalTree.SetSelectionMode( MULTIPLE_SELECTION );
885 aGlobalTree.SetWindowBits( WB_HASBUTTONS|WB_HASBUTTONSATROOT|
886 WB_CLIPCHILDREN|WB_HSCROLL );
887 Size aGlblSize(aGlobalToolBox.CalcWindowSizePixel());
888 aGlobalToolBox.SetSizePixel(aGlblSize);
890 // Handler
892 Link aLk = LINK(this, SwNavigationPI, ToolBoxSelectHdl);
893 aContentToolBox.SetSelectHdl( aLk );
894 aGlobalToolBox.SetSelectHdl( aLk );
895 aDocListBox.SetSelectHdl(LINK(this, SwNavigationPI,
896 DocListBoxSelectHdl));
897 aContentToolBox.SetClickHdl( LINK(this, SwNavigationPI, ToolBoxClickHdl) );
898 aContentToolBox.SetDropdownClickHdl( LINK(this, SwNavigationPI, ToolBoxDropdownClickHdl) );
899 aGlobalToolBox.SetClickHdl( LINK(this, SwNavigationPI, ToolBoxClickHdl) );
900 aGlobalToolBox.SetDropdownClickHdl( LINK(this, SwNavigationPI, ToolBoxDropdownClickHdl) );
901 aGlobalToolBox.CheckItem(FN_GLOBAL_SWITCH, TRUE);
903 Font aFont(GetFont());
904 aFont.SetWeight(WEIGHT_NORMAL);
905 GetPageEdit().SetFont(aFont);
906 aFont = aContentTree.GetFont();
907 aFont.SetWeight(WEIGHT_NORMAL);
908 aContentTree.SetFont(aFont);
909 aGlobalTree.SetFont(aFont);
911 StartListening(*SFX_APP());
912 if ( pCreateView )
913 StartListening(*pCreateView);
914 SfxImageManager* pImgMan = SfxImageManager::GetImageManager( SW_MOD() );
915 pImgMan->RegisterToolBox(&aContentToolBox, SFX_TOOLBOX_CHANGEOUTSTYLE);
916 pImgMan->RegisterToolBox(&aGlobalToolBox, SFX_TOOLBOX_CHANGEOUTSTYLE);
918 aContentToolBox.SetItemBits( FN_CREATE_NAVIGATION, aContentToolBox.GetItemBits( FN_CREATE_NAVIGATION ) | TIB_DROPDOWNONLY );
919 aContentToolBox.SetItemBits( FN_DROP_REGION, aContentToolBox.GetItemBits( FN_DROP_REGION ) | TIB_DROPDOWNONLY );
920 aContentToolBox.SetItemBits( FN_OUTLINE_LEVEL, aContentToolBox.GetItemBits( FN_OUTLINE_LEVEL ) | TIB_DROPDOWNONLY );
922 if(IsGlobalDoc())
924 SwView *pActView = GetCreateView();
925 aGlobalToolBox.CheckItem(FN_GLOBAL_SAVE_CONTENT,
926 pActView->GetWrtShellPtr()->IsGlblDocSaveLinks());
927 if(pConfig->IsGlobalActive())
928 ToggleTree();
929 aGlobalTree.GrabFocus();
931 else
932 aContentTree.GrabFocus();
933 UsePage(0);
934 aPageChgTimer.SetTimeoutHdl(LINK(this, SwNavigationPI, ChangePageHdl));
935 aPageChgTimer.SetTimeout(PAGE_CHANGE_TIMEOUT);
938 /*------------------------------------------------------------------------
939 Beschreibung:
940 ------------------------------------------------------------------------*/
942 SwNavigationPI::~SwNavigationPI()
944 if(IsGlobalDoc() && !IsGlobalMode())
946 SwView *pView = GetCreateView();
947 SwWrtShell &rSh = pView->GetWrtShell();
948 if( !rSh.IsAllProtect() )
949 pView->GetDocShell()->SetReadOnlyUI(FALSE);
952 EndListening(*SFX_APP());
954 SfxImageManager* pImgMan = SfxImageManager::GetImageManager( SW_MOD() );
955 pImgMan->ReleaseToolBox(&aContentToolBox);
956 pImgMan->ReleaseToolBox(&aGlobalToolBox);
957 delete aContentToolBox.GetItemWindow(FN_PAGENUMBER);
958 aContentToolBox.Clear();
959 if(pxObjectShell)
961 if(pxObjectShell->Is())
962 (*pxObjectShell)->DoClose();
963 delete pxObjectShell;
965 delete pPopupWindow;
966 delete pFloatingWindow;
968 if ( IsBound() )
969 rBindings.Release(*this);
972 /*------------------------------------------------------------------------
973 Beschreibung:
974 ------------------------------------------------------------------------*/
976 void SwNavigationPI::SetPopupWindow( SfxPopupWindow* pWindow )
978 pPopupWindow = pWindow;
979 pPopupWindow->SetPopupModeEndHdl( LINK( this, SwNavigationPI, PopupModeEndHdl ));
980 pPopupWindow->SetDeleteLink_Impl( LINK( this, SwNavigationPI, ClosePopupWindow ));
983 /*------------------------------------------------------------------------
984 Beschreibung:
985 ------------------------------------------------------------------------*/
987 IMPL_LINK( SwNavigationPI, PopupModeEndHdl, void *, EMPTYARG )
989 if ( pPopupWindow->IsVisible() )
991 // Replace floating window with popup window and destroy
992 // floating window instance.
993 delete pFloatingWindow;
994 pFloatingWindow = pPopupWindow;
995 pPopupWindow = 0;
997 else
999 // Popup window has been closed by the user. No replacement, instance
1000 // will destroy itself.
1001 pPopupWindow = 0;
1004 return 1;
1007 /*------------------------------------------------------------------------
1008 Beschreibung:
1009 ------------------------------------------------------------------------*/
1011 IMPL_LINK( SwNavigationPI, ClosePopupWindow, SfxPopupWindow *, pWindow )
1013 if ( pWindow == pFloatingWindow )
1014 pFloatingWindow = 0;
1015 else
1016 pPopupWindow = 0;
1018 return 1;
1021 /*------------------------------------------------------------------------
1022 Beschreibung:
1023 ------------------------------------------------------------------------*/
1025 void SwNavigationPI::StateChanged( USHORT nSID, SfxItemState /*eState*/,
1026 const SfxPoolItem* /*pState*/ )
1028 if(nSID == SID_DOCFULLNAME)
1030 SwView *pActView = GetCreateView();
1031 if(pActView)
1033 SwWrtShell* pWrtShell = pActView->GetWrtShellPtr();
1034 aContentTree.SetActiveShell(pWrtShell);
1035 BOOL bGlobal = IsGlobalDoc();
1036 aContentToolBox.EnableItem(FN_GLOBAL_SWITCH, bGlobal);
1037 if(!bGlobal && IsGlobalMode() ||
1038 !IsGlobalMode() && pConfig->IsGlobalActive())
1040 ToggleTree();
1042 if(bGlobal)
1044 aGlobalToolBox.CheckItem(FN_GLOBAL_SAVE_CONTENT, pWrtShell->IsGlblDocSaveLinks());
1047 else
1049 aContentTree.SetActiveShell(0);
1051 UpdateListBox();
1055 /*------------------------------------------------------------------------
1056 Bechreibung: NumericField aus der Toolbox holen
1057 ------------------------------------------------------------------------*/
1059 NumEditAction& SwNavigationPI::GetPageEdit()
1061 return *(NumEditAction*)aContentToolBox.GetItemWindow(FN_PAGENUMBER);
1064 /*------------------------------------------------------------------------
1065 Beschreibung:
1066 ------------------------------------------------------------------------*/
1068 SfxChildAlignment SwNavigationPI::CheckAlignment
1070 SfxChildAlignment eActAlign,
1071 SfxChildAlignment eAlign
1074 SfxChildAlignment eRetAlign;
1076 if(_IsZoomedIn())
1077 eRetAlign = SFX_ALIGN_NOALIGNMENT;
1078 else
1079 switch (eAlign)
1081 case SFX_ALIGN_BOTTOM:
1082 case SFX_ALIGN_LOWESTBOTTOM:
1083 case SFX_ALIGN_HIGHESTBOTTOM:
1084 eRetAlign = eActAlign;
1085 break;
1087 case SFX_ALIGN_TOP:
1088 case SFX_ALIGN_HIGHESTTOP:
1089 case SFX_ALIGN_LOWESTTOP:
1090 case SFX_ALIGN_LEFT:
1091 case SFX_ALIGN_RIGHT:
1092 case SFX_ALIGN_FIRSTLEFT:
1093 case SFX_ALIGN_LASTLEFT:
1094 case SFX_ALIGN_FIRSTRIGHT:
1095 case SFX_ALIGN_LASTRIGHT:
1096 eRetAlign = eAlign;
1097 break;
1099 default:
1100 eRetAlign = eAlign;
1101 break;
1103 return eRetAlign;
1107 /*--------------------------------------------------------------------
1108 Beschreibung: Benachrichtigung bei geaenderter DocInfo
1109 --------------------------------------------------------------------*/
1111 void SwNavigationPI::Notify( SfxBroadcaster& rBrdc, const SfxHint& rHint )
1113 if(&rBrdc == pCreateView)
1115 if(rHint.ISA(SfxSimpleHint) && ((SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING)
1117 pCreateView = 0;
1120 else
1122 if(rHint.ISA(SfxEventHint))
1124 if( pxObjectShell &&
1125 ((SfxEventHint&) rHint).GetEventId() == SFX_EVENT_CLOSEAPP)
1127 DELETEZ(pxObjectShell);
1129 else if(((SfxEventHint&) rHint).GetEventId() == SFX_EVENT_OPENDOC)
1132 SwView *pActView = GetCreateView();
1133 if(pActView)
1135 SwWrtShell* pWrtShell = pActView->GetWrtShellPtr();
1136 aContentTree.SetActiveShell(pWrtShell);
1137 if(aGlobalTree.IsVisible())
1139 if(aGlobalTree.Update( FALSE ))
1140 aGlobalTree.Display();
1141 else
1142 // wenn kein Update notwendig, dann zumindest painten
1143 // wg. der roten Eintraege fuer broken links
1144 aGlobalTree.Invalidate();
1152 /*--------------------------------------------------------------------
1153 Beschreibung:
1154 --------------------------------------------------------------------*/
1156 IMPL_LINK( SwNavigationPI, MenuSelectHdl, Menu *, pMenu )
1158 USHORT nMenuId = pMenu->GetCurItemId();
1159 if(nMenuId != USHRT_MAX)
1161 if(nMenuId < 100)
1162 SetRegionDropMode( --nMenuId);
1163 else
1164 aContentTree.SetOutlineLevel( static_cast< BYTE >(nMenuId - 100) );
1166 return 0;
1170 /*--------------------------------------------------------------------
1171 Beschreibung:
1172 --------------------------------------------------------------------*/
1174 void SwNavigationPI::UpdateListBox()
1176 aDocListBox.SetUpdateMode(FALSE);
1177 aDocListBox.Clear();
1178 SwView *pActView = GetCreateView();
1179 BOOL bDisable = pActView == 0;
1180 SwView *pView = SwModule::GetFirstView();
1181 USHORT nCount = 0;
1182 USHORT nAct = 0;
1183 USHORT nConstPos = 0;
1184 const SwView* pConstView = aContentTree.IsConstantView() &&
1185 aContentTree.GetActiveWrtShell() ?
1186 &aContentTree.GetActiveWrtShell()->GetView():
1188 while (pView)
1190 SfxObjectShell* pDoc = pView->GetDocShell();
1191 // pb: #i53333# don't show help pages here
1192 if ( !pDoc->IsHelpDocument() )
1194 String sEntry = pDoc->GetTitle();
1195 sEntry += C2S(" (");
1196 if (pView == pActView)
1198 nAct = nCount;
1199 sEntry += aStatusArr[ST_ACTIVE - ST_STATUS_FIRST];
1201 else
1202 sEntry += aStatusArr[ST_INACTIVE - ST_STATUS_FIRST];
1203 sEntry += ')';
1204 aDocListBox.InsertEntry(sEntry);
1207 if (pConstView && pView == pConstView)
1208 nConstPos = nCount;
1210 nCount++;
1212 pView = SwModule::GetNextView(pView);
1214 aDocListBox.InsertEntry(aStatusArr[3]); //"Aktives Fenster"
1215 nCount++;
1217 if(aContentTree.GetHiddenWrtShell())
1219 String sEntry = aContentTree.GetHiddenWrtShell()->GetView().
1220 GetDocShell()->GetTitle();
1221 sEntry += C2S(" (");
1222 sEntry += aStatusArr[ST_HIDDEN - ST_STATUS_FIRST];
1223 sEntry += ')';
1224 aDocListBox.InsertEntry(sEntry);
1225 bDisable = FALSE;
1227 if(aContentTree.IsActiveView())
1229 //entweder den Namen des akt. Docs oder "Aktives Dokument"
1230 USHORT nTmp = pActView ? nAct : --nCount;
1231 aDocListBox.SelectEntryPos( nTmp );
1233 else if(aContentTree.IsHiddenView())
1235 aDocListBox.SelectEntryPos(nCount);
1237 else
1238 aDocListBox.SelectEntryPos(nConstPos);
1240 aDocListBox.Enable( !bDisable );
1241 aDocListBox.SetUpdateMode(TRUE);
1244 /*-----------------16.06.97 15:05-------------------
1246 --------------------------------------------------*/
1248 /*------------------------------------------------------------------------
1249 Beschreibung:
1250 ------------------------------------------------------------------------*/
1252 IMPL_LINK(SwNavigationPI, DoneLink, SfxPoolItem *, pItem)
1254 const SfxViewFrameItem* pFrameItem = PTR_CAST(SfxViewFrameItem, pItem );
1255 if( pFrameItem )
1257 SfxViewFrame* pFrame = pFrameItem->GetFrame();
1258 if(pFrame)
1260 aContentTree.Clear();
1261 pContentView = PTR_CAST(SwView, pFrame->GetViewShell());
1262 DBG_ASSERT(pContentView, "keine SwView");
1263 if(pContentView)
1264 pContentWrtShell = pContentView->GetWrtShellPtr();
1265 else
1266 pContentWrtShell = 0;
1267 pxObjectShell = new SfxObjectShellLock(pFrame->GetObjectShell());
1268 FillBox();
1269 aContentTree.Update();
1272 return 0;
1275 String SwNavigationPI::CreateDropFileName( TransferableDataHelper& rData )
1277 String sFileName;
1278 ULONG nFmt;
1279 if( rData.HasFormat( nFmt = FORMAT_FILE_LIST ))
1281 FileList aFileList;
1282 rData.GetFileList( nFmt, aFileList );
1283 sFileName = aFileList.GetFile( 0 );
1285 else if( rData.HasFormat( nFmt = FORMAT_STRING ) ||
1286 rData.HasFormat( nFmt = FORMAT_FILE ) ||
1287 rData.HasFormat( nFmt = SOT_FORMATSTR_ID_FILENAME ))
1288 rData.GetString( nFmt, sFileName );
1289 else if( rData.HasFormat( nFmt = SOT_FORMATSTR_ID_SOLK ) ||
1290 rData.HasFormat( nFmt = SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK )||
1291 rData.HasFormat( nFmt = SOT_FORMATSTR_ID_FILECONTENT ) ||
1292 rData.HasFormat( nFmt = SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR ) ||
1293 rData.HasFormat( nFmt = SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR ))
1295 INetBookmark aBkmk( aEmptyStr, aEmptyStr );
1296 rData.GetINetBookmark( nFmt, aBkmk );
1297 sFileName = aBkmk.GetURL();
1299 if( sFileName.Len() )
1301 sFileName = INetURLObject( sFileName ).GetMainURL( INetURLObject::NO_DECODE );
1303 return sFileName;
1306 /*------------------------------------------------------------------------
1307 Beschreibung:
1308 ------------------------------------------------------------------------*/
1310 sal_Int8 SwNavigationPI::AcceptDrop( const AcceptDropEvent& /*rEvt*/ )
1312 return ( !aContentTree.IsInDrag() &&
1313 ( aContentTree.IsDropFormatSupported( FORMAT_FILE ) ||
1314 aContentTree.IsDropFormatSupported( FORMAT_STRING ) ||
1315 aContentTree.IsDropFormatSupported( SOT_FORMATSTR_ID_SOLK ) ||
1316 aContentTree.IsDropFormatSupported( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK )||
1317 aContentTree.IsDropFormatSupported( SOT_FORMATSTR_ID_FILECONTENT ) ||
1318 aContentTree.IsDropFormatSupported( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR ) ||
1319 aContentTree.IsDropFormatSupported( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR ) ||
1320 aContentTree.IsDropFormatSupported( SOT_FORMATSTR_ID_FILENAME )))
1321 ? DND_ACTION_COPY
1322 : DND_ACTION_NONE;
1325 sal_Int8 SwNavigationPI::ExecuteDrop( const ExecuteDropEvent& rEvt )
1327 TransferableDataHelper aData( rEvt.maDropEvent.Transferable );
1328 sal_Int8 nRet = DND_ACTION_NONE;
1329 String sFileName;
1330 if( !aContentTree.IsInDrag() &&
1331 0 != (sFileName = SwNavigationPI::CreateDropFileName( aData )).Len() )
1333 INetURLObject aTemp( sFileName );
1334 GraphicDescriptor aDesc( aTemp );
1335 if( !aDesc.Detect() ) // keine Grafiken annehmen
1337 if( STRING_NOTFOUND == sFileName.Search('#')
1338 && (!sContentFileName.Len() || sContentFileName != sFileName ))
1340 nRet = rEvt.mnAction;
1341 sFileName.EraseTrailingChars( char(0) );
1342 sContentFileName = sFileName;
1343 if(pxObjectShell)
1345 aContentTree.SetHiddenShell( 0 );
1346 (*pxObjectShell)->DoClose();
1347 DELETEZ( pxObjectShell);
1349 SfxStringItem aFileItem(SID_FILE_NAME, sFileName );
1350 String sOptions = C2S("HRC");
1351 SfxStringItem aOptionsItem( SID_OPTIONS, sOptions );
1352 SfxLinkItem aLink( SID_DONELINK,
1353 LINK( this, SwNavigationPI, DoneLink ) );
1354 GetActiveView()->GetViewFrame()->GetDispatcher()->Execute(
1355 SID_OPENDOC, SFX_CALLMODE_ASYNCHRON,
1356 &aFileItem, &aOptionsItem, &aLink, 0L );
1360 return nRet;
1363 /*-----------------27.11.96 13.00-------------------
1365 --------------------------------------------------*/
1367 void SwNavigationPI::SetRegionDropMode(USHORT nNewMode)
1369 nRegionMode = nNewMode;
1370 pConfig->SetRegionMode( nRegionMode );
1372 USHORT nDropId = FN_DROP_REGION;
1373 if(nRegionMode == REGION_MODE_LINK)
1374 nDropId = FN_DROP_REGION_LINK;
1375 else if(nRegionMode == REGION_MODE_EMBEDDED)
1376 nDropId = FN_DROP_REGION_COPY;
1378 ImageList& rImgLst = aContentToolBox.GetDisplayBackground().GetColor().IsDark()
1379 ? aContentImageListH : aContentImageList;
1381 aContentToolBox.SetItemImage( FN_DROP_REGION,
1382 rImgLst.GetImage(nDropId));
1386 /*-----------------12.06.97 09:47-------------------
1388 --------------------------------------------------*/
1390 BOOL SwNavigationPI::ToggleTree()
1392 BOOL bRet = TRUE;
1393 BOOL bGlobalDoc = IsGlobalDoc();
1394 if(!IsGlobalMode() && bGlobalDoc)
1396 SetUpdateMode(FALSE);
1397 if(_IsZoomedIn())
1398 _ZoomOut();
1399 aGlobalTree.ShowTree();
1400 aGlobalToolBox.Show();
1401 aContentTree.HideTree();
1402 aContentToolBox.Hide();
1403 aDocListBox.Hide();
1404 SetGlobalMode(TRUE);
1405 SetUpdateMode(TRUE);
1407 else
1409 aGlobalTree.HideTree();
1410 aGlobalToolBox.Hide();
1411 if(!_IsZoomedIn())
1413 aContentTree.ShowTree();
1414 aContentToolBox.Show();
1415 aDocListBox.Show();
1417 bRet = FALSE;
1418 SetGlobalMode(FALSE);
1420 return bRet;
1423 /*-----------------13.06.97 09:42-------------------
1425 --------------------------------------------------*/
1426 BOOL SwNavigationPI::IsGlobalDoc() const
1428 BOOL bRet = FALSE;
1429 SwView *pView = GetCreateView();
1430 if(pView)
1432 SwWrtShell &rSh = pView->GetWrtShell();
1433 bRet = rSh.IsGlobalDoc();
1435 return bRet;
1437 /* -----------------26.10.98 08:10-------------------
1439 * --------------------------------------------------*/
1440 IMPL_LINK( SwNavigationPI, ChangePageHdl, Timer*, EMPTYARG )
1442 EditAction(&GetPageEdit());
1443 GetPageEdit().GrabFocus();
1444 return 0;
1446 /* -----------------26.10.98 08:14-------------------
1448 * --------------------------------------------------*/
1449 IMPL_LINK( SwNavigationPI, PageEditModifyHdl, Edit*, EMPTYARG )
1451 if(aPageChgTimer.IsActive())
1452 aPageChgTimer.Stop();
1453 aPageChgTimer.Start();
1454 return 0;
1457 /* -----------------------------23.04.01 07:34--------------------------------
1459 ---------------------------------------------------------------------------*/
1460 SwView* SwNavigationPI::GetCreateView() const
1462 if(!pCreateView)
1464 SwView* pView = SwModule::GetFirstView();
1465 while(pView)
1467 if(&pView->GetViewFrame()->GetBindings() == &rBindings)
1469 ((SwNavigationPI*)this)->pCreateView = pView;
1470 ((SwNavigationPI*)this)->StartListening(*pCreateView);
1471 break;
1473 pView = SwModule::GetNextView(pView);
1476 return pCreateView;
1480 /*------------------------------------------------------------------------
1481 Beschreibung:
1482 ------------------------------------------------------------------------*/
1484 SwNavigationChild::SwNavigationChild( Window* pParent,
1485 USHORT nId,
1486 SfxBindings* _pBindings,
1487 SfxChildWinInfo* pInfo )
1488 : SfxChildWindowContext( nId )
1490 SwNavigationPI* pNavi = new SwNavigationPI( _pBindings, this, pParent );
1491 SetWindow( pNavi );
1492 _pBindings->Invalidate(SID_NAVIGATOR);
1493 String sExtra = pInfo->aExtraString;
1495 SwNavigationConfig* pNaviConfig = SW_MOD()->GetNavigationConfig();
1497 USHORT nRootType = static_cast< USHORT >( pNaviConfig->GetRootType() );
1498 if( nRootType < CONTENT_TYPE_MAX )
1500 pNavi->aContentTree.SetRootType(nRootType);
1501 pNavi->aContentToolBox.CheckItem(FN_SHOW_ROOT, TRUE);
1503 pNavi->aContentTree.SetOutlineLevel( static_cast< BYTE >( pNaviConfig->GetOutlineLevel() ) );
1504 pNavi->SetRegionDropMode( static_cast< USHORT >( pNaviConfig->GetRegionMode() ) );
1506 if(GetFloatingWindow() && pNaviConfig->IsSmall())
1508 pNavi->_ZoomIn();
1511 /* -----------------------------06.05.2002 10:06------------------------------
1513 ---------------------------------------------------------------------------*/
1514 void SwNavigationPI::DataChanged( const DataChangedEvent& rDCEvt )
1516 Window::DataChanged( rDCEvt );
1517 if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
1518 (rDCEvt.GetFlags() & SETTINGS_STYLE) )
1520 InitImageList();
1521 const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
1522 Color aBgColor = rStyleSettings.GetFaceColor();
1523 Wallpaper aBack( aBgColor );
1524 SetBackground( aBack );
1527 /* -----------------------------06.05.2002 10:07------------------------------
1529 ---------------------------------------------------------------------------*/
1530 void SwNavigationPI::InitImageList()
1532 USHORT k;
1534 ImageList& rImgLst = aContentToolBox.GetDisplayBackground().GetColor().IsDark() ?
1535 aContentImageListH : aContentImageList;
1536 for( k = 0; k < aContentToolBox.GetItemCount(); k++)
1537 aContentToolBox.SetItemImage(aContentToolBox.GetItemId(k),
1538 rImgLst.GetImage(aContentToolBox.GetItemId(k)));
1540 for( k = 0; k < aGlobalToolBox.GetItemCount(); k++)
1541 aGlobalToolBox.SetItemImage(aGlobalToolBox.GetItemId(k),
1542 rImgLst.GetImage(aGlobalToolBox.GetItemId(k)));
1544 USHORT nDropId = FN_DROP_REGION;
1545 if(nRegionMode == REGION_MODE_LINK)
1546 nDropId = FN_DROP_REGION_LINK;
1547 else if(nRegionMode == REGION_MODE_EMBEDDED)
1548 nDropId = FN_DROP_REGION_COPY;
1549 aContentToolBox.SetItemImage( FN_DROP_REGION,
1550 rImgLst.GetImage(nDropId));