xref: /AOO41X/main/sw/source/ui/utlui/navipi.cxx (revision 74e40a03f2c1022f33631d433936ec88e91a20bd)
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 
SFX_IMPL_CHILDWINDOW_CONTEXT(SwNavigationChild,SID_NAVIGATOR,SwView)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 
MoveOutline(sal_uInt16 nSource,sal_uInt16 nTarget,sal_Bool bWithChilds)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 
lcl_UnSelectFrm(SwWrtShell * pSh)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 
IMPL_LINK(SwNavigationPI,DocListBoxSelectHdl,ListBox *,pBox)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 
FillBox()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 
UsePage(SwWrtShell * pSh)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 
IMPL_LINK(SwNavigationPI,ToolBoxSelectHdl,ToolBox *,pBox)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 
IMPL_LINK(SwNavigationPI,ToolBoxClickHdl,ToolBox *,pBox)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 
IMPL_LINK(SwNavigationPI,ToolBoxDropdownClickHdl,ToolBox *,pBox)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 
SwNavHelpToolBox(SwNavigationPI * pParent,const ResId & rResId)481 SwNavHelpToolBox::SwNavHelpToolBox(SwNavigationPI* pParent, const ResId &rResId) :
482             SwHelpToolBox(pParent, rResId)
483 {}
484 /*-----------------19.06.97 09:09-------------------
485 
486 --------------------------------------------------*/
MouseButtonDown(const MouseEvent & rEvt)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  ---------------------------------------------------------------------------*/
CreateNavigationTool(const Rectangle & rRect,sal_Bool bSetFocus)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 --------------------------------------------------*/
RequestHelp(const HelpEvent & rHEvt)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 
IMPL_LINK(SwNavigationPI,EditAction,NumEditAction *,pEdit)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 
IMPL_LINK(SwNavigationPI,EditGetFocus,NumEditAction *,pEdit)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 
Close()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 
MakeMark()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 
GotoPage()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 
_ZoomOut()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 
_ZoomIn()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 
Resize()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 
SwNavigationPI(SfxBindings * _pBindings,SfxChildWindowContext * pCw,Window * pParent)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     aDocListBox.SetDropDownLineCount(9);
807 
808     nDocLBIniHeight = aDocListBox.GetSizePixel().Height();
809     nZoomOutInit = nZoomOut = Resource::ReadShortRes();
810 
811     //NumericField in die Toolbox einfuegen
812     NumEditAction* pEdit = new NumEditAction(
813                     &aContentToolBox, SW_RES(NF_PAGE ));
814     pEdit->SetActionHdl(LINK(this, SwNavigationPI, EditAction));
815     pEdit->SetGetFocusHdl(LINK(this, SwNavigationPI, EditGetFocus));
816     pEdit->SetAccessibleName(pEdit->GetQuickHelpText());
817     pEdit->SetUpHdl(LINK(this, SwNavigationPI, PageEditModifyHdl));
818     pEdit->SetDownHdl(LINK(this, SwNavigationPI, PageEditModifyHdl));
819 
820     bPageCtrlsVisible = sal_True;
821 
822 //  Rectangle aFirstRect = aContentToolBox.GetItemRect(FN_SHOW_ROOT);
823 //  sal_uInt16 nWidth = 2 * (sal_uInt16)aFirstRect.Left();
824     //doppelte Separatoren sind nicht erlaubt, also muss
825     //die passende Groesse anders ermittelt werden
826     Rectangle aFirstRect = aContentToolBox.GetItemRect(FN_SELECT_FOOTNOTE);
827     Rectangle aSecondRect = aContentToolBox.GetItemRect(FN_SELECT_HEADER);
828     sal_uInt16 nWidth = sal_uInt16(aFirstRect.Left() - aSecondRect.Left());
829 
830     Size aItemWinSize( nWidth , aFirstRect.Bottom() - aFirstRect.Top() );
831     pEdit->SetSizePixel(aItemWinSize);
832     aContentToolBox.InsertSeparator(4);
833     aContentToolBox.InsertWindow( FN_PAGENUMBER, pEdit, 0, 4);
834     aContentToolBox.InsertSeparator(4);
835     aContentToolBox.SetHelpId(FN_PAGENUMBER, HID_NAVI_TBX16);
836     aContentToolBox.ShowItem( FN_PAGENUMBER );
837 
838     for( sal_uInt16 i = 0; i <= REGION_MODE_EMBEDDED; i++  )
839     {
840         aContextArr[i] = SW_RESSTR(ST_HYPERLINK + i);
841         aStatusArr[i] = SW_RESSTR(ST_STATUS_FIRST + i);
842     }
843     aStatusArr[3] = SW_RESSTR(ST_ACTIVE_VIEW);
844     FreeResource();
845 
846 
847     const Size& rOutSize =  GetOutputSizePixel();
848 
849     nZoomIn = (short)rOutSize.Height();
850 
851     // Make sure the toolbox has a size that fits all its contents
852     Size aContentToolboxSize( aContentToolBox.CalcWindowSizePixel() );
853     aContentToolBox.SetOutputSizePixel( aContentToolboxSize );
854 
855     // position listbox below toolbar and add some space
856     long nListboxYPos = aContentToolBox.GetPosPixel().Y() + aContentToolboxSize.Height() + 4;
857 
858     //Der linke und rechte Rand um die Toolboxen soll gleich sein
859     nWishWidth = aContentToolboxSize.Width();
860     nWishWidth += 2 * aContentToolBox.GetPosPixel().X();
861 
862     DockingWindow* pDockingParent = dynamic_cast<DockingWindow*>(pParent);
863     if (pDockingParent != NULL)
864     {
865         FloatingWindow* pFloat =  pDockingParent->GetFloatingWindow();
866         Size aMinSize(pFloat ? nWishWidth : 0, pFloat ? nZoomOutInit : 0);
867         pDockingParent->SetMinOutputSizePixel(aMinSize);
868         SetOutputSizePixel( Size( nWishWidth, nZoomOutInit));
869 
870         SfxDockingWindow* pSfxDockingParent = dynamic_cast<SfxDockingWindow*>(pParent);
871         if (pSfxDockingParent != NULL)
872         {
873             Size aTmpParentSize(pSfxDockingParent->GetSizePixel());
874             if (aTmpParentSize.Width() < aMinSize.Width()
875                 || aTmpParentSize.Height() < aMinSize.Height())
876             {
877                 if (pSfxDockingParent->GetFloatingWindow()
878                     && ! pSfxDockingParent->GetFloatingWindow()->IsRollUp())
879                 {
880                     pSfxDockingParent->SetOutputSizePixel(aMinSize);
881                 }
882             }
883         }
884     }
885 
886     aContentTree.SetPosSizePixel( 0, nListboxYPos, 0, 0, WINDOW_POSSIZE_Y );
887     aContentTree.SetStyle( aContentTree.GetStyle()|WB_HASBUTTONS|WB_HASBUTTONSATROOT|
888                             WB_CLIPCHILDREN|WB_HSCROLL|WB_FORCE_MAKEVISIBLE );
889     aContentTree.SetSpaceBetweenEntries(3);
890     aContentTree.SetSelectionMode( SINGLE_SELECTION );
891     aContentTree.SetDragDropMode(   SV_DRAGDROP_CTRL_MOVE |
892                                     SV_DRAGDROP_CTRL_COPY |
893                                     SV_DRAGDROP_ENABLE_TOP );
894     aContentTree.EnableAsyncDrag(sal_True);
895     aContentTree.ShowTree();
896     aContentToolBox.CheckItem(FN_SHOW_CONTENT_BOX, sal_True);
897 
898 //  TreeListBox fuer Globaldokument
899     aGlobalTree.SetPosSizePixel( 0, nListboxYPos, 0, 0, WINDOW_POSSIZE_Y );
900     aGlobalTree.SetSelectionMode( MULTIPLE_SELECTION );
901     aGlobalTree.SetStyle( aGlobalTree.GetStyle()|WB_HASBUTTONS|WB_HASBUTTONSATROOT|
902                                 WB_CLIPCHILDREN|WB_HSCROLL );
903     Size aGlblSize(aGlobalToolBox.CalcWindowSizePixel());
904     aGlobalToolBox.SetSizePixel(aGlblSize);
905 
906 //  Handler
907 
908     Link aLk = LINK(this, SwNavigationPI, ToolBoxSelectHdl);
909     aContentToolBox.SetSelectHdl( aLk );
910     aGlobalToolBox.SetSelectHdl( aLk );
911     aDocListBox.SetSelectHdl(LINK(this, SwNavigationPI,
912                                                     DocListBoxSelectHdl));
913     aContentToolBox.SetClickHdl( LINK(this, SwNavigationPI, ToolBoxClickHdl) );
914     aContentToolBox.SetDropdownClickHdl( LINK(this, SwNavigationPI, ToolBoxDropdownClickHdl) );
915     aGlobalToolBox.SetClickHdl( LINK(this, SwNavigationPI, ToolBoxClickHdl) );
916     aGlobalToolBox.SetDropdownClickHdl( LINK(this, SwNavigationPI, ToolBoxDropdownClickHdl) );
917     aGlobalToolBox.CheckItem(FN_GLOBAL_SWITCH, sal_True);
918 
919     Font aFont(GetFont());
920     aFont.SetWeight(WEIGHT_NORMAL);
921     GetPageEdit().SetFont(aFont);
922     aFont = aContentTree.GetFont();
923     aFont.SetWeight(WEIGHT_NORMAL);
924     aContentTree.SetFont(aFont);
925     aGlobalTree.SetFont(aFont);
926 
927     StartListening(*SFX_APP());
928     if ( pCreateView )
929         StartListening(*pCreateView);
930     SfxImageManager* pImgMan = SfxImageManager::GetImageManager( SW_MOD() );
931     pImgMan->RegisterToolBox(&aContentToolBox, SFX_TOOLBOX_CHANGEOUTSTYLE);
932     pImgMan->RegisterToolBox(&aGlobalToolBox, SFX_TOOLBOX_CHANGEOUTSTYLE);
933 
934     aContentToolBox.SetItemBits( FN_CREATE_NAVIGATION, aContentToolBox.GetItemBits( FN_CREATE_NAVIGATION ) | TIB_DROPDOWNONLY );
935     aContentToolBox.SetItemBits( FN_DROP_REGION, aContentToolBox.GetItemBits( FN_DROP_REGION ) | TIB_DROPDOWNONLY );
936     aContentToolBox.SetItemBits( FN_OUTLINE_LEVEL, aContentToolBox.GetItemBits( FN_OUTLINE_LEVEL ) | TIB_DROPDOWNONLY );
937 
938     if(IsGlobalDoc())
939     {
940         SwView *pActView = GetCreateView();
941         aGlobalToolBox.CheckItem(FN_GLOBAL_SAVE_CONTENT,
942                     pActView->GetWrtShellPtr()->IsGlblDocSaveLinks());
943         if(pConfig->IsGlobalActive())
944             ToggleTree();
945         aGlobalTree.GrabFocus();
946     }
947     else
948         aContentTree.GrabFocus();
949     UsePage(0);
950     aPageChgTimer.SetTimeoutHdl(LINK(this, SwNavigationPI, ChangePageHdl));
951     aPageChgTimer.SetTimeout(PAGE_CHANGE_TIMEOUT);
952 
953     aContentTree.SetAccessibleName(SW_RESSTR(STR_ACCESS_TL_CONTENT));
954     aGlobalTree.SetAccessibleName(SW_RESSTR(STR_ACCESS_TL_GLOBAL));
955     aDocListBox.SetAccessibleName(aStatusArr[3]);
956 
957     if (pContextWin == NULL)
958     {
959         // When the context window is missing then the navigator is
960         // displayed in the sidebar.  While the navigator could change
961         // its size, the sidebar can not, and the navigator would just
962         // waste space.  Therefore hide this button.
963         aContentToolBox.RemoveItem(aContentToolBox.GetItemPos(FN_SHOW_CONTENT_BOX));
964     }
965 }
966 
967 /*------------------------------------------------------------------------
968  Beschreibung:
969 ------------------------------------------------------------------------*/
970 
~SwNavigationPI()971 SwNavigationPI::~SwNavigationPI()
972 {
973     if(IsGlobalDoc() && !IsGlobalMode())
974     {
975         SwView *pView = GetCreateView();
976         SwWrtShell &rSh = pView->GetWrtShell();
977         if( !rSh.IsAllProtect() )
978             pView->GetDocShell()->SetReadOnlyUI(sal_False);
979     }
980 
981     EndListening(*SFX_APP());
982 
983     SfxImageManager* pImgMan = SfxImageManager::GetImageManager( SW_MOD() );
984     pImgMan->ReleaseToolBox(&aContentToolBox);
985     pImgMan->ReleaseToolBox(&aGlobalToolBox);
986     delete aContentToolBox.GetItemWindow(FN_PAGENUMBER);
987     aContentToolBox.Clear();
988     if(pxObjectShell)
989     {
990         if(pxObjectShell->Is())
991             (*pxObjectShell)->DoClose();
992         delete pxObjectShell;
993     }
994     delete pPopupWindow;
995     delete pFloatingWindow;
996 
997     if ( IsBound() )
998         rBindings.Release(*this);
999 }
1000 
1001 /*------------------------------------------------------------------------
1002  Beschreibung:
1003 ------------------------------------------------------------------------*/
1004 
SetPopupWindow(SfxPopupWindow * pWindow)1005 void SwNavigationPI::SetPopupWindow( SfxPopupWindow* pWindow )
1006 {
1007     pPopupWindow = pWindow;
1008     pPopupWindow->SetPopupModeEndHdl( LINK( this, SwNavigationPI, PopupModeEndHdl ));
1009     pPopupWindow->SetDeleteLink_Impl( LINK( this, SwNavigationPI, ClosePopupWindow ));
1010 }
1011 
1012 /*------------------------------------------------------------------------
1013  Beschreibung:
1014 ------------------------------------------------------------------------*/
1015 
IMPL_LINK(SwNavigationPI,PopupModeEndHdl,void *,EMPTYARG)1016 IMPL_LINK( SwNavigationPI, PopupModeEndHdl, void *, EMPTYARG )
1017 {
1018     if ( pPopupWindow->IsVisible() )
1019     {
1020         // Replace floating window with popup window and destroy
1021         // floating window instance.
1022         delete pFloatingWindow;
1023         pFloatingWindow = pPopupWindow;
1024         pPopupWindow    = 0;
1025     }
1026     else
1027     {
1028         // Popup window has been closed by the user. No replacement, instance
1029         // will destroy itself.
1030         pPopupWindow = 0;
1031     }
1032 
1033     return 1;
1034 }
1035 
1036 /*------------------------------------------------------------------------
1037  Beschreibung:
1038 ------------------------------------------------------------------------*/
1039 
IMPL_LINK(SwNavigationPI,ClosePopupWindow,SfxPopupWindow *,pWindow)1040 IMPL_LINK( SwNavigationPI, ClosePopupWindow, SfxPopupWindow *, pWindow )
1041 {
1042     if ( pWindow == pFloatingWindow )
1043         pFloatingWindow = 0;
1044     else
1045         pPopupWindow = 0;
1046 
1047     return 1;
1048 }
1049 
1050 /*------------------------------------------------------------------------
1051  Beschreibung:
1052 ------------------------------------------------------------------------*/
1053 
StateChanged(sal_uInt16 nSID,SfxItemState,const SfxPoolItem *)1054 void SwNavigationPI::StateChanged( sal_uInt16 nSID, SfxItemState /*eState*/,
1055                                             const SfxPoolItem* /*pState*/ )
1056 {
1057     if(nSID == SID_DOCFULLNAME)
1058     {
1059         SwView *pActView = GetCreateView();
1060         if(pActView)
1061         {
1062             SwWrtShell* pWrtShell = pActView->GetWrtShellPtr();
1063             aContentTree.SetActiveShell(pWrtShell);
1064             sal_Bool bGlobal = IsGlobalDoc();
1065             aContentToolBox.EnableItem(FN_GLOBAL_SWITCH, bGlobal);
1066             if( (!bGlobal && IsGlobalMode()) ||
1067                     (!IsGlobalMode() && pConfig->IsGlobalActive()) )
1068             {
1069                 ToggleTree();
1070             }
1071             if(bGlobal)
1072             {
1073                 aGlobalToolBox.CheckItem(FN_GLOBAL_SAVE_CONTENT, pWrtShell->IsGlblDocSaveLinks());
1074             }
1075         }
1076         else
1077         {
1078             aContentTree.SetActiveShell(0);
1079         }
1080         UpdateListBox();
1081     }
1082 }
1083 
1084 /*------------------------------------------------------------------------
1085     Bechreibung: NumericField aus der Toolbox holen
1086 ------------------------------------------------------------------------*/
1087 
GetPageEdit()1088 NumEditAction& SwNavigationPI::GetPageEdit()
1089 {
1090     return *(NumEditAction*)aContentToolBox.GetItemWindow(FN_PAGENUMBER);
1091 }
1092 
1093 /*------------------------------------------------------------------------
1094  Beschreibung:
1095 ------------------------------------------------------------------------*/
1096 
CheckAlignment(SfxChildAlignment eActAlign,SfxChildAlignment eAlign)1097 SfxChildAlignment SwNavigationPI::CheckAlignment
1098     (
1099         SfxChildAlignment eActAlign,
1100         SfxChildAlignment eAlign
1101     )
1102 {
1103 SfxChildAlignment eRetAlign;
1104 
1105     if(_IsZoomedIn())
1106         eRetAlign = SFX_ALIGN_NOALIGNMENT;
1107     else
1108         switch (eAlign)
1109         {
1110             case SFX_ALIGN_BOTTOM:
1111             case SFX_ALIGN_LOWESTBOTTOM:
1112             case SFX_ALIGN_HIGHESTBOTTOM:
1113                 eRetAlign = eActAlign;
1114                 break;
1115 
1116             case SFX_ALIGN_TOP:
1117             case SFX_ALIGN_HIGHESTTOP:
1118             case SFX_ALIGN_LOWESTTOP:
1119             case SFX_ALIGN_LEFT:
1120             case SFX_ALIGN_RIGHT:
1121             case SFX_ALIGN_FIRSTLEFT:
1122             case SFX_ALIGN_LASTLEFT:
1123             case SFX_ALIGN_FIRSTRIGHT:
1124             case SFX_ALIGN_LASTRIGHT:
1125                 eRetAlign = eAlign;
1126                 break;
1127 
1128             default:
1129                 eRetAlign = eAlign;
1130                 break;
1131         }
1132     return eRetAlign;
1133 
1134 }
1135 
1136 /*--------------------------------------------------------------------
1137     Beschreibung:   Benachrichtigung bei geaenderter DocInfo
1138  --------------------------------------------------------------------*/
1139 
Notify(SfxBroadcaster & rBrdc,const SfxHint & rHint)1140 void SwNavigationPI::Notify( SfxBroadcaster& rBrdc, const SfxHint& rHint )
1141 {
1142     if(&rBrdc == pCreateView)
1143     {
1144         if(rHint.ISA(SfxSimpleHint) && ((SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING)
1145         {
1146             pCreateView = 0;
1147         }
1148     }
1149     else
1150     {
1151         if(rHint.ISA(SfxEventHint))
1152         {
1153             if( pxObjectShell &&
1154                         ((SfxEventHint&) rHint).GetEventId() == SFX_EVENT_CLOSEAPP)
1155             {
1156                 DELETEZ(pxObjectShell);
1157             }
1158             else if(((SfxEventHint&) rHint).GetEventId() == SFX_EVENT_OPENDOC)
1159             {
1160 
1161                 SwView *pActView = GetCreateView();
1162                 if(pActView)
1163                 {
1164                     SwWrtShell* pWrtShell = pActView->GetWrtShellPtr();
1165                     aContentTree.SetActiveShell(pWrtShell);
1166                     if(aGlobalTree.IsVisible())
1167                     {
1168                         if(aGlobalTree.Update( sal_False ))
1169                             aGlobalTree.Display();
1170                         else
1171                         // wenn kein Update notwendig, dann zumindest painten
1172                         // wg. der roten Eintraege fuer broken links
1173                             aGlobalTree.Invalidate();
1174                     }
1175                 }
1176             }
1177         }
1178     }
1179 }
1180 
1181 /*--------------------------------------------------------------------
1182     Beschreibung:
1183  --------------------------------------------------------------------*/
1184 
IMPL_LINK(SwNavigationPI,MenuSelectHdl,Menu *,pMenu)1185 IMPL_LINK( SwNavigationPI, MenuSelectHdl, Menu *, pMenu )
1186 {
1187     sal_uInt16 nMenuId = pMenu->GetCurItemId();
1188     if(nMenuId != USHRT_MAX)
1189     {
1190         if(nMenuId < 100)
1191             SetRegionDropMode( --nMenuId);
1192         else
1193             aContentTree.SetOutlineLevel( static_cast< sal_uInt8 >(nMenuId - 100) );
1194     }
1195     return 0;
1196 }
1197 
1198 
1199 /*--------------------------------------------------------------------
1200     Beschreibung:
1201  --------------------------------------------------------------------*/
1202 
UpdateListBox()1203 void SwNavigationPI::UpdateListBox()
1204 {
1205     aDocListBox.SetUpdateMode(sal_False);
1206     aDocListBox.Clear();
1207     SwView *pActView = GetCreateView();
1208     sal_Bool bDisable = pActView == 0;
1209     SwView *pView = SwModule::GetFirstView();
1210     sal_uInt16 nCount = 0;
1211     sal_uInt16 nAct = 0;
1212     sal_uInt16 nConstPos = 0;
1213     const SwView* pConstView = aContentTree.IsConstantView() &&
1214                                 aContentTree.GetActiveWrtShell() ?
1215                                     &aContentTree.GetActiveWrtShell()->GetView():
1216                                         0;
1217     while (pView)
1218     {
1219         SfxObjectShell* pDoc = pView->GetDocShell();
1220         // pb: #i53333# don't show help pages here
1221         if ( !pDoc->IsHelpDocument() )
1222         {
1223             String sEntry = pDoc->GetTitle();
1224             sEntry += C2S(" (");
1225             if (pView == pActView)
1226             {
1227                 nAct = nCount;
1228                 sEntry += aStatusArr[ST_ACTIVE - ST_STATUS_FIRST];
1229             }
1230             else
1231                 sEntry += aStatusArr[ST_INACTIVE - ST_STATUS_FIRST];
1232             sEntry += ')';
1233             aDocListBox.InsertEntry(sEntry);
1234 
1235 
1236             if (pConstView && pView == pConstView)
1237                 nConstPos = nCount;
1238 
1239             nCount++;
1240         }
1241         pView = SwModule::GetNextView(pView);
1242     }
1243     aDocListBox.InsertEntry(aStatusArr[3]); //"Aktives Fenster"
1244     nCount++;
1245 
1246     if(aContentTree.GetHiddenWrtShell())
1247     {
1248         String sEntry = aContentTree.GetHiddenWrtShell()->GetView().
1249                                         GetDocShell()->GetTitle();
1250         sEntry += C2S(" (");
1251         sEntry += aStatusArr[ST_HIDDEN - ST_STATUS_FIRST];
1252         sEntry += ')';
1253         aDocListBox.InsertEntry(sEntry);
1254         bDisable = sal_False;
1255     }
1256     if(aContentTree.IsActiveView())
1257     {
1258         //entweder den Namen des akt. Docs oder "Aktives Dokument"
1259         sal_uInt16 nTmp = pActView ? nAct : --nCount;
1260         aDocListBox.SelectEntryPos( nTmp );
1261     }
1262     else if(aContentTree.IsHiddenView())
1263     {
1264         aDocListBox.SelectEntryPos(nCount);
1265     }
1266     else
1267         aDocListBox.SelectEntryPos(nConstPos);
1268 
1269     aDocListBox.Enable( !bDisable );
1270     aDocListBox.SetUpdateMode(sal_True);
1271 }
1272 
1273 /*-----------------16.06.97 15:05-------------------
1274 
1275 --------------------------------------------------*/
1276 
1277 /*------------------------------------------------------------------------
1278     Beschreibung:
1279 ------------------------------------------------------------------------*/
1280 
IMPL_LINK(SwNavigationPI,DoneLink,SfxPoolItem *,pItem)1281 IMPL_LINK(SwNavigationPI, DoneLink, SfxPoolItem *, pItem)
1282 {
1283     const SfxViewFrameItem* pFrameItem = PTR_CAST(SfxViewFrameItem, pItem );
1284     if( pFrameItem )
1285     {
1286         SfxViewFrame* pFrame =  pFrameItem->GetFrame();
1287         if(pFrame)
1288         {
1289             aContentTree.Clear();
1290             pContentView = PTR_CAST(SwView, pFrame->GetViewShell());
1291             DBG_ASSERT(pContentView, "keine SwView");
1292             if(pContentView)
1293                 pContentWrtShell = pContentView->GetWrtShellPtr();
1294             else
1295                 pContentWrtShell = 0;
1296             pxObjectShell = new SfxObjectShellLock(pFrame->GetObjectShell());
1297             FillBox();
1298             aContentTree.Update();
1299         }
1300     }
1301     return 0;
1302 }
1303 
CreateDropFileName(TransferableDataHelper & rData)1304 String SwNavigationPI::CreateDropFileName( TransferableDataHelper& rData )
1305 {
1306     String sFileName;
1307     sal_uLong nFmt;
1308     if( rData.HasFormat( nFmt = FORMAT_FILE_LIST ))
1309     {
1310         FileList aFileList;
1311         rData.GetFileList( nFmt, aFileList );
1312         sFileName = aFileList.GetFile( 0 );
1313     }
1314     else if( rData.HasFormat( nFmt = FORMAT_STRING ) ||
1315              rData.HasFormat( nFmt = FORMAT_FILE ) ||
1316              rData.HasFormat( nFmt = SOT_FORMATSTR_ID_FILENAME ))
1317         rData.GetString( nFmt, sFileName );
1318     else if( rData.HasFormat( nFmt = SOT_FORMATSTR_ID_SOLK ) ||
1319              rData.HasFormat( nFmt = SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK )||
1320              rData.HasFormat( nFmt = SOT_FORMATSTR_ID_FILECONTENT ) ||
1321              rData.HasFormat( nFmt = SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR ) ||
1322              rData.HasFormat( nFmt = SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR ))
1323     {
1324         INetBookmark aBkmk( aEmptyStr, aEmptyStr );
1325         rData.GetINetBookmark( nFmt, aBkmk );
1326         sFileName = aBkmk.GetURL();
1327     }
1328     if( sFileName.Len() )
1329     {
1330         sFileName = INetURLObject( sFileName ).GetMainURL( INetURLObject::NO_DECODE );
1331     }
1332     return sFileName;
1333 }
1334 
1335 /*------------------------------------------------------------------------
1336     Beschreibung:
1337 ------------------------------------------------------------------------*/
1338 
AcceptDrop(const AcceptDropEvent &)1339 sal_Int8 SwNavigationPI::AcceptDrop( const AcceptDropEvent& /*rEvt*/ )
1340 {
1341     return ( !aContentTree.IsInDrag() &&
1342         ( aContentTree.IsDropFormatSupported( FORMAT_FILE ) ||
1343           aContentTree.IsDropFormatSupported( FORMAT_STRING ) ||
1344           aContentTree.IsDropFormatSupported( SOT_FORMATSTR_ID_SOLK ) ||
1345           aContentTree.IsDropFormatSupported( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK )||
1346           aContentTree.IsDropFormatSupported( SOT_FORMATSTR_ID_FILECONTENT ) ||
1347           aContentTree.IsDropFormatSupported( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR ) ||
1348           aContentTree.IsDropFormatSupported( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR ) ||
1349           aContentTree.IsDropFormatSupported( SOT_FORMATSTR_ID_FILENAME )))
1350         ? DND_ACTION_COPY
1351         : DND_ACTION_NONE;
1352 }
1353 
ExecuteDrop(const ExecuteDropEvent & rEvt)1354 sal_Int8 SwNavigationPI::ExecuteDrop( const ExecuteDropEvent& rEvt )
1355 {
1356     TransferableDataHelper aData( rEvt.maDropEvent.Transferable );
1357     sal_Int8 nRet = DND_ACTION_NONE;
1358     String sFileName;
1359     if( !aContentTree.IsInDrag() &&
1360         0 != (sFileName = SwNavigationPI::CreateDropFileName( aData )).Len() )
1361     {
1362         INetURLObject aTemp( sFileName );
1363         GraphicDescriptor aDesc( aTemp );
1364         if( !aDesc.Detect() )   // keine Grafiken annehmen
1365         {
1366             if( STRING_NOTFOUND == sFileName.Search('#')
1367                 && (!sContentFileName.Len() || sContentFileName != sFileName ))
1368             {
1369                 nRet = rEvt.mnAction;
1370                 sFileName.EraseTrailingChars( char(0) );
1371                 sContentFileName = sFileName;
1372                 if(pxObjectShell)
1373                 {
1374                     aContentTree.SetHiddenShell( 0 );
1375                     (*pxObjectShell)->DoClose();
1376                     DELETEZ( pxObjectShell);
1377                 }
1378                 SfxStringItem aFileItem(SID_FILE_NAME, sFileName );
1379                 String sOptions = C2S("HRC");
1380                 SfxStringItem aOptionsItem( SID_OPTIONS, sOptions );
1381                 SfxLinkItem aLink( SID_DONELINK,
1382                                     LINK( this, SwNavigationPI, DoneLink ) );
1383                 GetActiveView()->GetViewFrame()->GetDispatcher()->Execute(
1384                             SID_OPENDOC, SFX_CALLMODE_ASYNCHRON,
1385                             &aFileItem, &aOptionsItem, &aLink, 0L );
1386             }
1387         }
1388     }
1389     return nRet;
1390 }
1391 
1392 /*-----------------27.11.96 13.00-------------------
1393 
1394 --------------------------------------------------*/
1395 
SetRegionDropMode(sal_uInt16 nNewMode)1396 void SwNavigationPI::SetRegionDropMode(sal_uInt16 nNewMode)
1397 {
1398     nRegionMode = nNewMode;
1399     pConfig->SetRegionMode( nRegionMode );
1400 
1401     sal_uInt16 nDropId = FN_DROP_REGION;
1402     if(nRegionMode == REGION_MODE_LINK)
1403         nDropId = FN_DROP_REGION_LINK;
1404     else if(nRegionMode == REGION_MODE_EMBEDDED)
1405         nDropId = FN_DROP_REGION_COPY;
1406 
1407     ImageList& rImgLst = aContentToolBox.GetSettings().GetStyleSettings().GetHighContrastMode()
1408                 ? aContentImageListH : aContentImageList;
1409 
1410     aContentToolBox.SetItemImage( FN_DROP_REGION,
1411                                     rImgLst.GetImage(nDropId));
1412 }
1413 
1414 
1415 /*-----------------12.06.97 09:47-------------------
1416 
1417 --------------------------------------------------*/
1418 
ToggleTree()1419 sal_Bool    SwNavigationPI::ToggleTree()
1420 {
1421     sal_Bool bRet = sal_True;
1422     sal_Bool bGlobalDoc = IsGlobalDoc();
1423     if(!IsGlobalMode() && bGlobalDoc)
1424     {
1425         SetUpdateMode(sal_False);
1426         if(_IsZoomedIn())
1427             _ZoomOut();
1428         aGlobalTree.ShowTree();
1429         aGlobalToolBox.Show();
1430         aContentTree.HideTree();
1431         aContentToolBox.Hide();
1432         aDocListBox.Hide();
1433         SetGlobalMode(sal_True);
1434         SetUpdateMode(sal_True);
1435     }
1436     else
1437     {
1438         aGlobalTree.HideTree();
1439         aGlobalToolBox.Hide();
1440         if(!_IsZoomedIn())
1441         {
1442             aContentTree.ShowTree();
1443             aContentToolBox.Show();
1444             aDocListBox.Show();
1445         }
1446         bRet = sal_False;
1447         SetGlobalMode(sal_False);
1448     }
1449     return bRet;
1450 }
1451 
1452 /*-----------------13.06.97 09:42-------------------
1453 
1454 --------------------------------------------------*/
IsGlobalDoc() const1455 sal_Bool    SwNavigationPI::IsGlobalDoc() const
1456 {
1457     sal_Bool bRet = sal_False;
1458     SwView *pView = GetCreateView();
1459     if(pView)
1460     {
1461         SwWrtShell &rSh = pView->GetWrtShell();
1462         bRet = rSh.IsGlobalDoc();
1463     }
1464     return bRet;
1465 }
1466 /* -----------------26.10.98 08:10-------------------
1467  *
1468  * --------------------------------------------------*/
IMPL_LINK(SwNavigationPI,ChangePageHdl,Timer *,EMPTYARG)1469 IMPL_LINK( SwNavigationPI, ChangePageHdl, Timer*, EMPTYARG )
1470 {
1471     EditAction(&GetPageEdit());
1472     GetPageEdit().GrabFocus();
1473     return 0;
1474 }
1475 /* -----------------26.10.98 08:14-------------------
1476  *
1477  * --------------------------------------------------*/
IMPL_LINK(SwNavigationPI,PageEditModifyHdl,Edit *,EMPTYARG)1478 IMPL_LINK( SwNavigationPI, PageEditModifyHdl, Edit*, EMPTYARG )
1479 {
1480     if(aPageChgTimer.IsActive())
1481         aPageChgTimer.Stop();
1482     aPageChgTimer.Start();
1483     return 0;
1484 }
1485 
1486 /* -----------------------------23.04.01 07:34--------------------------------
1487 
1488  ---------------------------------------------------------------------------*/
GetCreateView() const1489 SwView*  SwNavigationPI::GetCreateView() const
1490 {
1491     if(!pCreateView)
1492     {
1493         SwView* pView = SwModule::GetFirstView();
1494         while(pView)
1495         {
1496             if(&pView->GetViewFrame()->GetBindings() == &rBindings)
1497             {
1498                 ((SwNavigationPI*)this)->pCreateView = pView;
1499                 ((SwNavigationPI*)this)->StartListening(*pCreateView);
1500                 break;
1501             }
1502             pView = SwModule::GetNextView(pView);
1503         }
1504     }
1505     return pCreateView;
1506 }
1507 
1508 
1509 /*------------------------------------------------------------------------
1510  Beschreibung:
1511 ------------------------------------------------------------------------*/
1512 
SwNavigationChild(Window * pParent,sal_uInt16 nId,SfxBindings * _pBindings,SfxChildWinInfo * pInfo)1513 SwNavigationChild::SwNavigationChild( Window* pParent,
1514                         sal_uInt16 nId,
1515                         SfxBindings* _pBindings,
1516                         SfxChildWinInfo* pInfo )
1517     : SfxChildWindowContext( nId )
1518 {
1519     SwNavigationPI* pNavi  = new SwNavigationPI( _pBindings, this, pParent );
1520     SetWindow( pNavi );
1521     _pBindings->Invalidate(SID_NAVIGATOR);
1522     String sExtra = pInfo->aExtraString;
1523 
1524     SwNavigationConfig* pNaviConfig = SW_MOD()->GetNavigationConfig();
1525 
1526     sal_uInt16 nRootType = static_cast< sal_uInt16 >( pNaviConfig->GetRootType() );
1527     if( nRootType < CONTENT_TYPE_MAX )
1528     {
1529         pNavi->aContentTree.SetRootType(nRootType);
1530         pNavi->aContentToolBox.CheckItem(FN_SHOW_ROOT, sal_True);
1531     }
1532     pNavi->aContentTree.SetOutlineLevel( static_cast< sal_uInt8 >( pNaviConfig->GetOutlineLevel() ) );
1533     pNavi->SetRegionDropMode( static_cast< sal_uInt16 >( pNaviConfig->GetRegionMode() ) );
1534 
1535     if(GetFloatingWindow() && pNaviConfig->IsSmall())
1536     {
1537         pNavi->_ZoomIn();
1538     }
1539 }
1540 /* -----------------------------06.05.2002 10:06------------------------------
1541 
1542  ---------------------------------------------------------------------------*/
DataChanged(const DataChangedEvent & rDCEvt)1543 void SwNavigationPI::DataChanged( const DataChangedEvent& rDCEvt )
1544 {
1545     Window::DataChanged( rDCEvt );
1546     if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
1547          (rDCEvt.GetFlags() & SETTINGS_STYLE) )
1548     {
1549         InitImageList();
1550         const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
1551         Color aBgColor = rStyleSettings.GetFaceColor();
1552         Wallpaper aBack( aBgColor );
1553         SetBackground( aBack );
1554     }
1555 }
1556 /* -----------------------------06.05.2002 10:07------------------------------
1557 
1558  ---------------------------------------------------------------------------*/
InitImageList()1559 void SwNavigationPI::InitImageList()
1560 {
1561     sal_uInt16 k;
1562 
1563     ImageList& rImgLst = aContentToolBox.GetSettings().GetStyleSettings().GetHighContrastMode() ?
1564                 aContentImageListH : aContentImageList;
1565     for( k = 0; k < aContentToolBox.GetItemCount(); k++)
1566             aContentToolBox.SetItemImage(aContentToolBox.GetItemId(k),
1567                     rImgLst.GetImage(aContentToolBox.GetItemId(k)));
1568 
1569     for( k = 0; k < aGlobalToolBox.GetItemCount(); k++)
1570             aGlobalToolBox.SetItemImage(aGlobalToolBox.GetItemId(k),
1571                     rImgLst.GetImage(aGlobalToolBox.GetItemId(k)));
1572 
1573     sal_uInt16 nDropId = FN_DROP_REGION;
1574     if(nRegionMode == REGION_MODE_LINK)
1575         nDropId = FN_DROP_REGION_LINK;
1576     else if(nRegionMode == REGION_MODE_EMBEDDED)
1577         nDropId = FN_DROP_REGION_COPY;
1578     aContentToolBox.SetItemImage( FN_DROP_REGION,
1579                                     rImgLst.GetImage(nDropId));
1580 }
1581 
1582