Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <string>
21 : #include <comphelper/string.hxx>
22 : #include <svl/urlbmk.hxx>
23 : #include <svl/stritem.hxx>
24 : #include <vcl/graphicfilter.hxx>
25 : #include <svl/urihelper.hxx>
26 : #include <sot/formats.hxx>
27 : #include <sot/filelist.hxx>
28 : #include <sfx2/event.hxx>
29 : #include <sfx2/imgmgr.hxx>
30 : #include <sfx2/dispatch.hxx>
31 : #include <sfx2/dockwin.hxx>
32 : #include <vcl/toolbox.hxx>
33 : #include <swtypes.hxx> // for pathfinder
34 : #include <swmodule.hxx>
35 : #include <view.hxx>
36 : #include <navicfg.hxx>
37 : #include <wrtsh.hxx>
38 : #include <docsh.hxx>
39 : #include <actctrl.hxx>
40 : #include <IMark.hxx>
41 : #include <navipi.hxx>
42 : #include <content.hxx>
43 : #include <workctrl.hxx>
44 : #include <section.hxx>
45 : #include <edtwin.hxx>
46 : #include <sfx2/app.hxx>
47 : #include <cmdid.h>
48 : #include <helpid.h>
49 : #include <ribbar.hrc>
50 : #include <navipi.hrc>
51 : #include <utlui.hrc>
52 :
53 : #include "access.hrc"
54 :
55 : #include <unomid.h>
56 :
57 : #define PAGE_CHANGE_TIMEOUT 1000
58 :
59 : using namespace ::com::sun::star::uno;
60 : using namespace ::com::sun::star::frame;
61 :
62 33 : SFX_IMPL_CHILDWINDOW_CONTEXT( SwNavigationChild, SID_NAVIGATOR, SwView )
63 :
64 : // Filter the control characters out of the Outline-Entry
65 :
66 0 : void SwNavigationPI::CleanEntry( String& rEntry )
67 : {
68 0 : sal_uInt16 i = rEntry.Len();
69 0 : if( i )
70 0 : for( sal_Unicode* pStr = rEntry.GetBufferAccess(); i; --i, ++pStr )
71 0 : if( *pStr == 10 || *pStr == 9 )
72 0 : *pStr = 0x20;
73 0 : }
74 :
75 : // Execution of the drag operation with and without the children.
76 :
77 0 : void SwNavigationPI::MoveOutline(sal_uInt16 nSource, sal_uInt16 nTarget,
78 : bool bWithChildren)
79 : {
80 0 : SwView *pView = GetCreateView();
81 0 : SwWrtShell &rSh = pView->GetWrtShell();
82 0 : if(nTarget < nSource || nTarget == USHRT_MAX)
83 0 : nTarget ++;
84 0 : if ( rSh.IsOutlineMovable( nSource ))
85 : {
86 :
87 0 : short nMove = nTarget-nSource; //( nDir<0 ) ? 1 : 0 ;
88 0 : rSh.GotoOutline(nSource);
89 0 : if (bWithChildren)
90 0 : rSh.MakeOutlineSel(nSource, nSource, sal_True);
91 : // While moving, the selected children does not counting.
92 0 : sal_uInt16 nLastOutlinePos = rSh.GetOutlinePos(MAXLEVEL);
93 0 : if(bWithChildren && nMove > 1 &&
94 : nLastOutlinePos < nTarget)
95 : {
96 0 : if(!rSh.IsCrsrPtAtEnd())
97 0 : rSh.SwapPam();
98 0 : nMove -= nLastOutlinePos - nSource;
99 : }
100 0 : if(!bWithChildren || nMove < 1 || nLastOutlinePos < nTarget )
101 0 : rSh.MoveOutlinePara( nMove );
102 0 : rSh.ClearMark();
103 0 : rSh.GotoOutline( nSource + nMove);
104 0 : FillBox();
105 : }
106 :
107 0 : }
108 :
109 : // After goto cancel the status frame selection
110 :
111 0 : static void lcl_UnSelectFrm(SwWrtShell *pSh)
112 : {
113 0 : if (pSh->IsFrmSelected())
114 : {
115 0 : pSh->UnSelectFrm();
116 0 : pSh->LeaveSelFrmMode();
117 : }
118 0 : }
119 :
120 : // Select the document view
121 :
122 0 : IMPL_LINK( SwNavigationPI, DocListBoxSelectHdl, ListBox *, pBox )
123 : {
124 0 : int nEntryIdx = pBox->GetSelectEntryPos();
125 : SwView *pView ;
126 0 : pView = SwModule::GetFirstView();
127 0 : while (nEntryIdx-- && pView)
128 : {
129 0 : pView = SwModule::GetNextView(pView);
130 : }
131 0 : if(!pView)
132 : {
133 : nEntryIdx == 0 ?
134 0 : aContentTree.ShowHiddenShell():
135 0 : aContentTree.ShowActualView();
136 :
137 :
138 : }
139 : else
140 : {
141 0 : aContentTree.SetConstantShell(pView->GetWrtShellPtr());
142 : }
143 0 : return 0;
144 : }
145 :
146 : // Filling of the list box for outline view or documents
147 : // The PI will be set to full size
148 :
149 0 : void SwNavigationPI::FillBox()
150 : {
151 0 : if(pContentWrtShell)
152 : {
153 0 : aContentTree.SetHiddenShell( pContentWrtShell );
154 0 : aContentTree.Display( sal_False );
155 : }
156 : else
157 : {
158 0 : SwView *pView = GetCreateView();
159 0 : if(!pView)
160 : {
161 0 : aContentTree.SetActiveShell(0);
162 : }
163 0 : else if( pView != pActContView)
164 : {
165 0 : SwWrtShell* pWrtShell = pView->GetWrtShellPtr();
166 0 : aContentTree.SetActiveShell(pWrtShell);
167 : }
168 : else
169 0 : aContentTree.Display( sal_True );
170 0 : pActContView = pView;
171 : }
172 0 : }
173 :
174 0 : void SwNavigationPI::UsePage(SwWrtShell *pSh)
175 : {
176 0 : if (!pSh)
177 : {
178 0 : SwView *pView = GetCreateView();
179 0 : pSh = pView ? &pView->GetWrtShell() : 0;
180 0 : GetPageEdit().SetValue(1);
181 : }
182 0 : if (pSh)
183 : {
184 0 : const sal_uInt16 nPageCnt = pSh->GetPageCnt();
185 : sal_uInt16 nPhyPage, nVirPage;
186 0 : pSh->GetPageNum(nPhyPage, nVirPage);
187 :
188 0 : GetPageEdit().SetMax(nPageCnt);
189 0 : GetPageEdit().SetLast(nPageCnt);
190 0 : GetPageEdit().SetValue(nPhyPage);
191 : }
192 0 : }
193 :
194 : // Select handler of the toolboxes
195 :
196 0 : IMPL_LINK( SwNavigationPI, ToolBoxSelectHdl, ToolBox *, pBox )
197 : {
198 0 : const sal_uInt16 nCurrItemId = pBox->GetCurItemId();
199 0 : SwView *pView = GetCreateView();
200 0 : if (!pView)
201 0 : return 1;
202 0 : SwWrtShell &rSh = pView->GetWrtShell();
203 : // Get MouseModifier for Outline-Move
204 :
205 : // Standard: sublevels are taken
206 : // do not take sublevels with Ctrl
207 0 : sal_Bool bOutlineWithChildren = ( KEY_MOD1 != pBox->GetModifier());
208 0 : int nFuncId = 0;
209 0 : bool bFocusToDoc = false;
210 0 : switch (nCurrItemId)
211 : {
212 : case FN_UP:
213 : case FN_DOWN:
214 : {
215 : // #i75416# move the execution of the search to an asynchronously called static link
216 0 : bool* pbNext = new bool( FN_DOWN == nCurrItemId );
217 0 : Application::PostUserEvent( STATIC_LINK(pView, SwView, MoveNavigationHdl), pbNext );
218 : }
219 0 : break;
220 : case FN_SHOW_ROOT:
221 : {
222 0 : aContentTree.ToggleToRoot();
223 : }
224 0 : break;
225 : case FN_SHOW_CONTENT_BOX:
226 : case FN_SELECT_CONTENT:
227 0 : if(pContextWin!=NULL && pContextWin->GetFloatingWindow()!=NULL)
228 : {
229 0 : if(_IsZoomedIn() )
230 : {
231 0 : _ZoomOut();
232 : }
233 : else
234 : {
235 0 : _ZoomIn();
236 : }
237 : }
238 0 : return sal_True;
239 : // Functions that will trigger a direct action.
240 :
241 : case FN_SELECT_FOOTER:
242 : {
243 0 : rSh.MoveCrsr();
244 0 : const sal_uInt16 eType = rSh.GetFrmType(0,sal_False);
245 0 : if (eType & FRMTYPE_FOOTER)
246 : {
247 0 : if (rSh.EndPg())
248 0 : nFuncId = FN_END_OF_PAGE;
249 : }
250 0 : else if (rSh.GotoFooterTxt())
251 0 : nFuncId = FN_TO_FOOTER;
252 0 : bFocusToDoc = true;
253 : }
254 0 : break;
255 : case FN_SELECT_HEADER:
256 : {
257 0 : rSh.MoveCrsr();
258 0 : const sal_uInt16 eType = rSh.GetFrmType(0,sal_False);
259 0 : if (eType & FRMTYPE_HEADER)
260 : {
261 0 : if (rSh.SttPg())
262 0 : nFuncId = FN_START_OF_PAGE;
263 : }
264 0 : else if (rSh.GotoHeaderTxt())
265 0 : nFuncId = FN_TO_HEADER;
266 0 : bFocusToDoc = true;
267 : }
268 0 : break;
269 : case FN_SELECT_FOOTNOTE:
270 : {
271 0 : rSh.MoveCrsr();
272 0 : const sal_uInt16 eFrmType = rSh.GetFrmType(0,sal_False);
273 : // Jump from the footnote to the anchor.
274 0 : if (eFrmType & FRMTYPE_FOOTNOTE)
275 : {
276 0 : if (rSh.GotoFtnAnchor())
277 0 : nFuncId = FN_FOOTNOTE_TO_ANCHOR;
278 : }
279 : // Otherwise, jump to the first footnote text;
280 : // go to the next footnote if this is not possible;
281 : // if this is also not possible got to the footnote before.
282 : else
283 : {
284 0 : if (rSh.GotoFtnTxt())
285 0 : nFuncId = FN_FOOTNOTE_TO_ANCHOR;
286 0 : else if (rSh.GotoNextFtnAnchor())
287 0 : nFuncId = FN_NEXT_FOOTNOTE;
288 0 : else if (rSh.GotoPrevFtnAnchor())
289 0 : nFuncId = FN_PREV_FOOTNOTE;
290 : }
291 0 : bFocusToDoc = true;
292 : }
293 0 : break;
294 :
295 : case FN_SELECT_SET_AUTO_BOOKMARK:
296 0 : MakeMark();
297 0 : break;
298 : case FN_ITEM_DOWN:
299 : case FN_ITEM_UP:
300 : case FN_ITEM_LEFT:
301 : case FN_ITEM_RIGHT:
302 : case FN_GLOBAL_EDIT:
303 : {
304 0 : if(IsGlobalMode())
305 0 : aGlobalTree.ExecCommand(nCurrItemId);
306 : else
307 0 : aContentTree.ExecCommand(nCurrItemId, bOutlineWithChildren);
308 : }
309 0 : break;
310 : case FN_GLOBAL_SWITCH:
311 : {
312 0 : ToggleTree();
313 0 : pConfig->SetGlobalActive(IsGlobalMode());
314 : }
315 0 : break;
316 : case FN_GLOBAL_SAVE_CONTENT:
317 : {
318 0 : sal_Bool bSave = rSh.IsGlblDocSaveLinks();
319 0 : rSh.SetGlblDocSaveLinks( !bSave );
320 0 : pBox->CheckItem(FN_GLOBAL_SAVE_CONTENT, !bSave );
321 : }
322 0 : break;
323 : }
324 0 : if (nFuncId)
325 : {
326 0 : lcl_UnSelectFrm(&rSh);
327 : }
328 0 : if(bFocusToDoc)
329 0 : pView->GetEditWin().GrabFocus();
330 0 : return sal_True;
331 : }
332 :
333 : // Click handler of the toolboxes
334 :
335 0 : IMPL_LINK( SwNavigationPI, ToolBoxClickHdl, ToolBox *, pBox )
336 : {
337 0 : const sal_uInt16 nCurrItemId = pBox->GetCurItemId();
338 0 : switch (nCurrItemId)
339 : {
340 : case FN_GLOBAL_UPDATE:
341 : case FN_GLOBAL_OPEN:
342 : {
343 0 : aGlobalTree.TbxMenuHdl(nCurrItemId, pBox);
344 : }
345 0 : break;
346 : }
347 :
348 0 : return sal_True;
349 : }
350 :
351 0 : IMPL_LINK( SwNavigationPI, ToolBoxDropdownClickHdl, ToolBox*, pBox )
352 : {
353 0 : const sal_uInt16 nCurrItemId = pBox->GetCurItemId();
354 0 : switch (nCurrItemId)
355 : {
356 : case FN_CREATE_NAVIGATION:
357 : {
358 0 : CreateNavigationTool(pBox->GetItemRect(FN_CREATE_NAVIGATION), true);
359 : }
360 0 : break;
361 :
362 : case FN_DROP_REGION:
363 : {
364 : static const char* aHIDs[] =
365 : {
366 : HID_NAVI_DRAG_HYP,
367 : HID_NAVI_DRAG_LINK,
368 : HID_NAVI_DRAG_COPY,
369 : };
370 0 : PopupMenu *pMenu = new PopupMenu;
371 0 : for (sal_uInt16 i = 0; i <= REGION_MODE_EMBEDDED; i++)
372 : {
373 0 : pMenu->InsertItem( i + 1, aContextArr[i] );
374 0 : pMenu->SetHelpId(i + 1, aHIDs[i]);
375 : }
376 0 : pMenu->CheckItem( nRegionMode + 1 );
377 0 : pMenu->SetSelectHdl(LINK(this, SwNavigationPI, MenuSelectHdl));
378 0 : pBox->SetItemDown( nCurrItemId, sal_True );
379 : pMenu->Execute( pBox,
380 : pBox->GetItemRect(FN_DROP_REGION),
381 0 : POPUPMENU_EXECUTE_DOWN );
382 0 : pBox->SetItemDown( nCurrItemId, sal_False );
383 0 : pBox->EndSelection();
384 0 : delete pMenu;
385 0 : pBox->Invalidate();
386 : }
387 0 : break;
388 : case FN_OUTLINE_LEVEL:
389 : {
390 0 : PopupMenu *pMenu = new PopupMenu;
391 0 : for (sal_uInt16 i = 101; i <= 100 + MAXLEVEL; i++)
392 : {
393 0 : pMenu->InsertItem( i, OUString::number(i - 100) );
394 0 : pMenu->SetHelpId( i, HID_NAVI_OUTLINES );
395 : }
396 0 : pMenu->CheckItem( aContentTree.GetOutlineLevel() + 100 );
397 0 : pMenu->SetSelectHdl(LINK(this, SwNavigationPI, MenuSelectHdl));
398 0 : pBox->SetItemDown( nCurrItemId, sal_True );
399 : pMenu->Execute( pBox,
400 : pBox->GetItemRect(FN_OUTLINE_LEVEL),
401 0 : POPUPMENU_EXECUTE_DOWN );
402 0 : pBox->SetItemDown( nCurrItemId, sal_False );
403 0 : delete pMenu;
404 0 : pBox->EndSelection();
405 0 : pBox->Invalidate();
406 : }
407 0 : break;
408 : }
409 0 : return sal_True;
410 : }
411 :
412 0 : SwNavHelpToolBox::SwNavHelpToolBox(SwNavigationPI* pParent, const ResId &rResId) :
413 0 : SwHelpToolBox(pParent, rResId)
414 0 : {}
415 :
416 0 : void SwNavHelpToolBox::MouseButtonDown(const MouseEvent &rEvt)
417 : {
418 0 : if(rEvt.GetButtons() == MOUSE_LEFT &&
419 0 : FN_CREATE_NAVIGATION == GetItemId(rEvt.GetPosPixel()))
420 : {
421 0 : ((SwNavigationPI*)GetParent())->CreateNavigationTool(GetItemRect(FN_CREATE_NAVIGATION), false);
422 : }
423 : else
424 0 : SwHelpToolBox::MouseButtonDown(rEvt);
425 0 : }
426 :
427 0 : void SwNavigationPI::CreateNavigationTool(const Rectangle& rRect, bool bSetFocus)
428 : {
429 0 : Reference< XFrame > xFrame = GetCreateView()->GetViewFrame()->GetFrame().GetFrameInterface();
430 : SwScrollNaviPopup* pPopup = new
431 : SwScrollNaviPopup(FN_SCROLL_NAVIGATION,
432 0 : xFrame );
433 :
434 0 : Rectangle aRect(rRect);
435 0 : Point aT1 = aRect.TopLeft();
436 0 : aT1 = pPopup->GetParent()->OutputToScreenPixel(pPopup->GetParent()->AbsoluteScreenToOutputPixel(aContentToolBox.OutputToAbsoluteScreenPixel(aT1)));
437 0 : aRect.SetPos(aT1);
438 0 : pPopup->StartPopupMode(aRect, FLOATWIN_POPUPMODE_RIGHT|FLOATWIN_POPUPMODE_ALLOWTEAROFF);
439 0 : SetPopupWindow( pPopup );
440 0 : if(bSetFocus)
441 : {
442 0 : pPopup->EndPopupMode(FLOATWIN_POPUPMODEEND_TEAROFF);
443 0 : pPopup->GrabFocus();
444 0 : }
445 0 : }
446 :
447 0 : void SwNavHelpToolBox::RequestHelp( const HelpEvent& rHEvt )
448 : {
449 0 : sal_uInt16 nItemId = GetItemId(ScreenToOutputPixel(rHEvt.GetMousePosPixel()));
450 0 : if( FN_UP == nItemId || FN_DOWN == nItemId )
451 : {
452 0 : SetItemText(nItemId, SwScrollNaviPopup::GetQuickHelpText((FN_DOWN == nItemId)));
453 : }
454 0 : SwHelpToolBox::RequestHelp(rHEvt);
455 0 : }
456 :
457 : // Action-Handler Edit:
458 : // Switches to the page if the structure view is not turned on.
459 :
460 0 : IMPL_LINK( SwNavigationPI, EditAction, NumEditAction *, pEdit )
461 : {
462 0 : SwView *pView = GetCreateView();
463 0 : if (pView)
464 : {
465 0 : if(aPageChgTimer.IsActive())
466 0 : aPageChgTimer.Stop();
467 0 : pCreateView->GetWrtShell().GotoPage((sal_uInt16)pEdit->GetValue(), sal_True);
468 0 : pCreateView->GetEditWin().GrabFocus();
469 0 : pCreateView->GetViewFrame()->GetBindings().Invalidate(FN_STAT_PAGE);
470 : }
471 0 : return 0;
472 : }
473 :
474 : // If the page can be set here, the maximum is set.
475 :
476 0 : IMPL_LINK( SwNavigationPI, EditGetFocus, NumEditAction *, pEdit )
477 : {
478 0 : SwView *pView = GetCreateView();
479 0 : if (!pView)
480 0 : return 0;
481 0 : SwWrtShell &rSh = pView->GetWrtShell();
482 :
483 0 : const sal_uInt16 nPageCnt = rSh.GetPageCnt();
484 0 : pEdit->SetMax(nPageCnt);
485 0 : pEdit->SetLast(nPageCnt);
486 0 : return 0;
487 : }
488 :
489 0 : sal_Bool SwNavigationPI::Close()
490 : {
491 0 : SfxViewFrame* pVFrame = pCreateView->GetViewFrame();
492 0 : pVFrame->GetBindings().Invalidate(SID_NAVIGATOR);
493 0 : pVFrame->GetDispatcher()->Execute(SID_NAVIGATOR);
494 0 : return sal_True;
495 : }
496 :
497 : // Setting of an automatic mark
498 :
499 0 : void SwNavigationPI::MakeMark()
500 : {
501 0 : SwView *pView = GetCreateView();
502 0 : if (!pView) return;
503 0 : SwWrtShell &rSh = pView->GetWrtShell();
504 0 : IDocumentMarkAccess* const pMarkAccess = rSh.getIDocumentMarkAccess();
505 :
506 : // collect and sort navigator reminder names
507 0 : ::std::vector< OUString > vNavMarkNames;
508 0 : for(IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->getMarksBegin();
509 0 : ppMark != pMarkAccess->getMarksEnd();
510 : ++ppMark)
511 0 : if( IDocumentMarkAccess::GetType(**ppMark) == IDocumentMarkAccess::NAVIGATOR_REMINDER )
512 0 : vNavMarkNames.push_back(ppMark->get()->GetName());
513 0 : ::std::sort(vNavMarkNames.begin(), vNavMarkNames.end());
514 :
515 : // we are maxed out and delete one
516 : // nAutoMarkIdx rotates through the available MarkNames
517 : // this assumes that IDocumentMarkAccess generates Names in ascending order
518 0 : if(vNavMarkNames.size() == MAX_MARKS)
519 0 : pMarkAccess->deleteMark(pMarkAccess->findMark(vNavMarkNames[nAutoMarkIdx]));
520 :
521 0 : rSh.SetBookmark(KeyCode(), OUString(), OUString(), IDocumentMarkAccess::NAVIGATOR_REMINDER);
522 0 : SwView::SetActMark( nAutoMarkIdx );
523 :
524 0 : if(++nAutoMarkIdx == MAX_MARKS)
525 0 : nAutoMarkIdx = 0;
526 : }
527 :
528 0 : void SwNavigationPI::GotoPage()
529 : {
530 0 : if (pContextWin && pContextWin->GetFloatingWindow() && pContextWin->GetFloatingWindow()->IsRollUp())
531 0 : _ZoomIn();
532 0 : if(IsGlobalMode())
533 0 : ToggleTree();
534 0 : UsePage(0);
535 0 : GetPageEdit().GrabFocus();
536 0 : }
537 :
538 0 : void SwNavigationPI::_ZoomOut()
539 : {
540 0 : if (_IsZoomedIn())
541 : {
542 0 : FloatingWindow* pFloat = pContextWin!=NULL ? pContextWin->GetFloatingWindow() : NULL;
543 0 : bIsZoomedIn = sal_False;
544 0 : Size aSz(GetOutputSizePixel());
545 0 : aSz.Height() = nZoomOut;
546 0 : Size aMinOutSizePixel = ((SfxDockingWindow*)GetParent())->GetMinOutputSizePixel();
547 0 : ((SfxDockingWindow*)GetParent())->SetMinOutputSizePixel(Size(
548 0 : aMinOutSizePixel.Width(),nZoomOutInit));
549 0 : if (pFloat != NULL)
550 0 : pFloat->SetOutputSizePixel(aSz);
551 0 : FillBox();
552 0 : if(IsGlobalMode())
553 : {
554 0 : aGlobalTree.ShowTree();
555 : }
556 : else
557 : {
558 0 : aContentTree.ShowTree();
559 0 : aDocListBox.Show();
560 : }
561 0 : SvTreeListEntry* pFirst = aContentTree.FirstSelected();
562 0 : if(pFirst)
563 0 : aContentTree.Select(pFirst, sal_True); // Enable toolbox
564 0 : pConfig->SetSmall( sal_False );
565 0 : aContentToolBox.CheckItem(FN_SHOW_CONTENT_BOX);
566 : }
567 0 : }
568 :
569 0 : void SwNavigationPI::_ZoomIn()
570 : {
571 0 : if (pContextWin != NULL)
572 : {
573 0 : FloatingWindow* pFloat = pContextWin->GetFloatingWindow();
574 0 : if (pFloat &&
575 0 : (!_IsZoomedIn() || ( pContextWin->GetFloatingWindow()->IsRollUp())))
576 : {
577 0 : aContentTree.HideTree();
578 0 : aDocListBox.Hide();
579 0 : aGlobalTree.HideTree();
580 0 : bIsZoomedIn = sal_True;
581 0 : Size aSz(GetOutputSizePixel());
582 0 : if( aSz.Height() > nZoomIn )
583 0 : nZoomOut = ( short ) aSz.Height();
584 :
585 0 : aSz.Height() = nZoomIn;
586 0 : Size aMinOutSizePixel = ((SfxDockingWindow*)GetParent())->GetMinOutputSizePixel();
587 0 : ((SfxDockingWindow*)GetParent())->SetMinOutputSizePixel(Size(
588 0 : aMinOutSizePixel.Width(), aSz.Height()));
589 0 : pFloat->SetOutputSizePixel(aSz);
590 0 : SvTreeListEntry* pFirst = aContentTree.FirstSelected();
591 0 : if(pFirst)
592 0 : aContentTree.Select(pFirst, sal_True); // Enable toolbox
593 0 : pConfig->SetSmall( sal_True );
594 0 : aContentToolBox.CheckItem(FN_SHOW_CONTENT_BOX, sal_False);
595 : }
596 : }
597 0 : }
598 :
599 0 : void SwNavigationPI::Resize()
600 : {
601 0 : Window* pParent = GetParent();
602 0 : if( !_IsZoomedIn() )
603 : {
604 0 : Size aNewSize (pParent->GetOutputSizePixel());
605 :
606 0 : SfxDockingWindow* pDockingParent = dynamic_cast<SfxDockingWindow*>(pParent);
607 0 : if (pDockingParent != NULL)
608 : {
609 0 : FloatingWindow* pFloat = pDockingParent->GetFloatingWindow();
610 : //change the minimum width depending on the dock status
611 0 : Size aMinOutSizePixel = pDockingParent->GetMinOutputSizePixel();
612 0 : if( pFloat)
613 : {
614 0 : aNewSize = pFloat->GetOutputSizePixel();
615 0 : aMinOutSizePixel.Width() = nWishWidth;
616 0 : aMinOutSizePixel.Height() = _IsZoomedIn() ? nZoomIn : nZoomOutInit;
617 : }
618 : else
619 : {
620 0 : aMinOutSizePixel.Width() = 0;
621 0 : aMinOutSizePixel.Height() = 0;
622 : }
623 0 : pDockingParent->SetMinOutputSizePixel(aMinOutSizePixel);
624 : }
625 :
626 0 : const Point aPos = aContentTree.GetPosPixel();
627 0 : Point aLBPos = aDocListBox.GetPosPixel();
628 0 : long nDist = aPos.X();
629 0 : aNewSize.Height() -= (aPos.Y() + aPos.X() + nDocLBIniHeight + nDist);
630 0 : aNewSize.Width() -= 2 * nDist;
631 0 : aLBPos.Y() = aPos.Y() + aNewSize.Height() + nDist;
632 0 : aDocListBox.Show(!aGlobalTree.IsVisible() && aLBPos.Y() > aPos.Y() );
633 :
634 0 : Size aDocLBSz = aDocListBox.GetSizePixel();
635 0 : aDocLBSz.Width() = aNewSize.Width();
636 0 : if(aNewSize.Height() < 0)
637 0 : aDocLBSz.Height() = 0;
638 : else
639 0 : aDocLBSz.Height() = nDocLBIniHeight;
640 0 : aContentTree.SetSizePixel(aNewSize);
641 : // GlobalTree starts on to the top and goes all the way down.
642 0 : aNewSize.Height() += (nDist + nDocLBIniHeight + aPos.Y() - aGlobalTree.GetPosPixel().Y());
643 0 : aGlobalTree.SetSizePixel(aNewSize);
644 0 : aDocListBox.setPosSizePixel( aLBPos.X(), aLBPos.Y(),
645 0 : aDocLBSz.Width(), aDocLBSz.Height(),
646 0 : WINDOW_POSSIZE_X|WINDOW_POSSIZE_Y|WINDOW_POSSIZE_WIDTH);
647 : }
648 0 : }
649 :
650 0 : SwNavigationPI::SwNavigationPI( SfxBindings* _pBindings,
651 : SfxChildWindowContext* pCw,
652 : Window* pParent) :
653 :
654 : Window( pParent, SW_RES(DLG_NAVIGATION_PI)),
655 : SfxControllerItem( SID_DOCFULLNAME, *_pBindings ),
656 :
657 : aContentToolBox(this, SW_RES(TB_CONTENT)),
658 : aGlobalToolBox(this, SW_RES(TB_GLOBAL)),
659 : aContentImageList(SW_RES(IL_CONTENT)),
660 : aContentTree(this, SW_RES(TL_CONTENT)),
661 : aGlobalTree(this, SW_RES(TL_GLOBAL)),
662 : aDocListBox(this, SW_RES(LB_DOCS)),
663 :
664 : pxObjectShell(0),
665 : pContentView(0),
666 : pContentWrtShell(0),
667 : pActContView(0),
668 : pCreateView(0),
669 : pPopupWindow(0),
670 : pFloatingWindow(0),
671 :
672 : pContextWin(pCw),
673 :
674 0 : pConfig(SW_MOD()->GetNavigationConfig()),
675 : rBindings(*_pBindings),
676 :
677 : nWishWidth(0),
678 : nAutoMarkIdx(1),
679 : nRegionMode(REGION_MODE_NONE),
680 :
681 : bSmallMode(sal_False),
682 : bIsZoomedIn(sal_False),
683 : bPageCtrlsVisible(sal_False),
684 0 : bGlobalMode(sal_False)
685 : {
686 0 : GetCreateView();
687 0 : InitImageList();
688 :
689 0 : aContentToolBox.SetHelpId(HID_NAVIGATOR_TOOLBOX );
690 0 : aGlobalToolBox.SetHelpId(HID_NAVIGATOR_GLOBAL_TOOLBOX);
691 0 : aDocListBox.SetHelpId(HID_NAVIGATOR_LISTBOX );
692 :
693 0 : nDocLBIniHeight = aDocListBox.GetSizePixel().Height();
694 0 : nZoomOutInit = nZoomOut = Resource::ReadShortRes();
695 :
696 : // Insert the numeric field in the toolbox.
697 : NumEditAction* pEdit = new NumEditAction(
698 0 : &aContentToolBox, SW_RES(NF_PAGE ));
699 0 : pEdit->SetActionHdl(LINK(this, SwNavigationPI, EditAction));
700 0 : pEdit->SetGetFocusHdl(LINK(this, SwNavigationPI, EditGetFocus));
701 0 : pEdit->SetAccessibleName(pEdit->GetQuickHelpText());
702 0 : pEdit->SetUpHdl(LINK(this, SwNavigationPI, PageEditModifyHdl));
703 0 : pEdit->SetDownHdl(LINK(this, SwNavigationPI, PageEditModifyHdl));
704 :
705 0 : bPageCtrlsVisible = sal_True;
706 :
707 : // Double separators are not allowed, so you have to
708 : // determine the suitable size differently.
709 0 : Rectangle aFirstRect = aContentToolBox.GetItemRect(FN_SELECT_FOOTNOTE);
710 0 : Rectangle aSecondRect = aContentToolBox.GetItemRect(FN_SELECT_HEADER);
711 0 : sal_uInt16 nWidth = sal_uInt16(aFirstRect.Left() - aSecondRect.Left());
712 :
713 0 : Size aItemWinSize( nWidth , aFirstRect.Bottom() - aFirstRect.Top() );
714 0 : pEdit->SetSizePixel(aItemWinSize);
715 0 : aContentToolBox.InsertSeparator(4);
716 0 : aContentToolBox.InsertWindow( FN_PAGENUMBER, pEdit, 0, 4);
717 0 : aContentToolBox.InsertSeparator(4);
718 0 : aContentToolBox.SetHelpId(FN_PAGENUMBER, HID_NAVI_TBX16);
719 0 : aContentToolBox.ShowItem( FN_PAGENUMBER );
720 :
721 0 : for( sal_uInt16 i = 0; i <= REGION_MODE_EMBEDDED; i++ )
722 : {
723 0 : aContextArr[i] = SW_RESSTR(ST_HYPERLINK + i);
724 0 : aStatusArr[i] = SW_RESSTR(ST_STATUS_FIRST + i);
725 : }
726 0 : aStatusArr[3] = SW_RESSTR(ST_ACTIVE_VIEW);
727 0 : FreeResource();
728 :
729 :
730 0 : const Size& rOutSize = GetOutputSizePixel();
731 :
732 0 : nZoomIn = (short)rOutSize.Height();
733 :
734 : // Make sure the toolbox has a size that fits all its contents
735 0 : Size aContentToolboxSize( aContentToolBox.CalcWindowSizePixel() );
736 0 : aContentToolBox.SetOutputSizePixel( aContentToolboxSize );
737 :
738 : // position listbox below toolbar and add some space
739 0 : long nListboxYPos = aContentToolBox.GetPosPixel().Y() + aContentToolboxSize.Height() + 4;
740 :
741 : // The left and right margins around the toolboxes should be equal.
742 0 : nWishWidth = aContentToolboxSize.Width();
743 0 : nWishWidth += 2 * aContentToolBox.GetPosPixel().X();
744 :
745 0 : DockingWindow* pDockingParent = dynamic_cast<DockingWindow*>(pParent);
746 0 : if (pDockingParent != NULL)
747 : {
748 0 : FloatingWindow* pFloat = pDockingParent->GetFloatingWindow();
749 0 : Size aMinSize(pFloat ? nWishWidth : 0, pFloat ? nZoomOutInit : 0);
750 0 : pDockingParent->SetMinOutputSizePixel(aMinSize);
751 0 : SetOutputSizePixel( Size( nWishWidth, nZoomOutInit));
752 :
753 0 : SfxDockingWindow* pSfxDockingParent = dynamic_cast<SfxDockingWindow*>(pParent);
754 0 : if (pSfxDockingParent != NULL)
755 : {
756 0 : Size aTmpParentSize(pSfxDockingParent->GetSizePixel());
757 0 : if (aTmpParentSize.Width() < aMinSize.Width()
758 0 : || aTmpParentSize.Height() < aMinSize.Height())
759 : {
760 0 : if (pSfxDockingParent->GetFloatingWindow()
761 0 : && ! pSfxDockingParent->GetFloatingWindow()->IsRollUp())
762 : {
763 0 : pSfxDockingParent->SetOutputSizePixel(aMinSize);
764 : }
765 : }
766 : }
767 : }
768 :
769 0 : aContentTree.setPosSizePixel( 0, nListboxYPos, 0, 0, WINDOW_POSSIZE_Y );
770 0 : aContentTree.SetStyle( aContentTree.GetStyle()|WB_HASBUTTONS|WB_HASBUTTONSATROOT|
771 0 : WB_CLIPCHILDREN|WB_HSCROLL|WB_FORCE_MAKEVISIBLE );
772 0 : aContentTree.SetSpaceBetweenEntries(3);
773 0 : aContentTree.SetSelectionMode( SINGLE_SELECTION );
774 : aContentTree.SetDragDropMode( SV_DRAGDROP_CTRL_MOVE |
775 : SV_DRAGDROP_CTRL_COPY |
776 0 : SV_DRAGDROP_ENABLE_TOP );
777 0 : aContentTree.EnableAsyncDrag(sal_True);
778 0 : aContentTree.ShowTree();
779 0 : aContentToolBox.CheckItem(FN_SHOW_CONTENT_BOX, sal_True);
780 :
781 : // TreeListBox for global document
782 0 : aGlobalTree.setPosSizePixel( 0, nListboxYPos, 0, 0, WINDOW_POSSIZE_Y );
783 0 : aGlobalTree.SetSelectionMode( MULTIPLE_SELECTION );
784 0 : aGlobalTree.SetStyle( aGlobalTree.GetStyle()|WB_HASBUTTONS|WB_HASBUTTONSATROOT|
785 0 : WB_CLIPCHILDREN|WB_HSCROLL );
786 0 : Size aGlblSize(aGlobalToolBox.CalcWindowSizePixel());
787 0 : aGlobalToolBox.SetSizePixel(aGlblSize);
788 :
789 : // Handler
790 :
791 0 : Link aLk = LINK(this, SwNavigationPI, ToolBoxSelectHdl);
792 0 : aContentToolBox.SetSelectHdl( aLk );
793 0 : aGlobalToolBox.SetSelectHdl( aLk );
794 : aDocListBox.SetSelectHdl(LINK(this, SwNavigationPI,
795 0 : DocListBoxSelectHdl));
796 0 : aContentToolBox.SetClickHdl( LINK(this, SwNavigationPI, ToolBoxClickHdl) );
797 0 : aContentToolBox.SetDropdownClickHdl( LINK(this, SwNavigationPI, ToolBoxDropdownClickHdl) );
798 0 : aGlobalToolBox.SetClickHdl( LINK(this, SwNavigationPI, ToolBoxClickHdl) );
799 0 : aGlobalToolBox.SetDropdownClickHdl( LINK(this, SwNavigationPI, ToolBoxDropdownClickHdl) );
800 0 : aGlobalToolBox.CheckItem(FN_GLOBAL_SWITCH, sal_True);
801 :
802 0 : Font aFont(GetFont());
803 0 : aFont.SetWeight(WEIGHT_NORMAL);
804 0 : GetPageEdit().SetFont(aFont);
805 0 : aFont = aContentTree.GetFont();
806 0 : aFont.SetWeight(WEIGHT_NORMAL);
807 0 : aContentTree.SetFont(aFont);
808 0 : aGlobalTree.SetFont(aFont);
809 :
810 0 : StartListening(*SFX_APP());
811 0 : if ( pCreateView )
812 0 : StartListening(*pCreateView);
813 0 : SfxImageManager* pImgMan = SfxImageManager::GetImageManager( SW_MOD() );
814 0 : pImgMan->RegisterToolBox(&aContentToolBox, SFX_TOOLBOX_CHANGEOUTSTYLE);
815 0 : pImgMan->RegisterToolBox(&aGlobalToolBox, SFX_TOOLBOX_CHANGEOUTSTYLE);
816 :
817 0 : aContentToolBox.SetItemBits( FN_CREATE_NAVIGATION, aContentToolBox.GetItemBits( FN_CREATE_NAVIGATION ) | TIB_DROPDOWNONLY );
818 0 : aContentToolBox.SetItemBits( FN_DROP_REGION, aContentToolBox.GetItemBits( FN_DROP_REGION ) | TIB_DROPDOWNONLY );
819 0 : aContentToolBox.SetItemBits( FN_OUTLINE_LEVEL, aContentToolBox.GetItemBits( FN_OUTLINE_LEVEL ) | TIB_DROPDOWNONLY );
820 :
821 0 : if(IsGlobalDoc())
822 : {
823 0 : SwView *pActView = GetCreateView();
824 : aGlobalToolBox.CheckItem(FN_GLOBAL_SAVE_CONTENT,
825 0 : pActView->GetWrtShellPtr()->IsGlblDocSaveLinks());
826 0 : if(pConfig->IsGlobalActive())
827 0 : ToggleTree();
828 0 : aGlobalTree.GrabFocus();
829 : }
830 : else
831 0 : aContentTree.GrabFocus();
832 0 : UsePage(0);
833 0 : aPageChgTimer.SetTimeoutHdl(LINK(this, SwNavigationPI, ChangePageHdl));
834 0 : aPageChgTimer.SetTimeout(PAGE_CHANGE_TIMEOUT);
835 :
836 0 : aContentTree.SetAccessibleName(SW_RESSTR(STR_ACCESS_TL_CONTENT));
837 0 : aGlobalTree.SetAccessibleName(SW_RESSTR(STR_ACCESS_TL_GLOBAL));
838 0 : aDocListBox.SetAccessibleName(aStatusArr[3]);
839 :
840 0 : if (pContextWin == NULL)
841 : {
842 : // When the context window is missing then the navigator is
843 : // displayed in the sidebar. While the navigator could change
844 : // its size, the sidebar can not, and the navigator would just
845 : // waste space. Therefore hide this button.
846 0 : aContentToolBox.RemoveItem(aContentToolBox.GetItemPos(FN_SHOW_CONTENT_BOX));
847 0 : }
848 0 : }
849 :
850 0 : SwNavigationPI::~SwNavigationPI()
851 : {
852 0 : if(IsGlobalDoc() && !IsGlobalMode())
853 : {
854 0 : SwView *pView = GetCreateView();
855 0 : SwWrtShell &rSh = pView->GetWrtShell();
856 0 : if( !rSh.IsAllProtect() )
857 0 : pView->GetDocShell()->SetReadOnlyUI(sal_False);
858 : }
859 :
860 0 : EndListening(*SFX_APP());
861 :
862 0 : SfxImageManager* pImgMan = SfxImageManager::GetImageManager( SW_MOD() );
863 0 : pImgMan->ReleaseToolBox(&aContentToolBox);
864 0 : pImgMan->ReleaseToolBox(&aGlobalToolBox);
865 0 : delete aContentToolBox.GetItemWindow(FN_PAGENUMBER);
866 0 : aContentToolBox.Clear();
867 0 : if(pxObjectShell)
868 : {
869 0 : if(pxObjectShell->Is())
870 0 : (*pxObjectShell)->DoClose();
871 0 : delete pxObjectShell;
872 : }
873 0 : delete pPopupWindow;
874 0 : delete pFloatingWindow;
875 :
876 0 : if ( IsBound() )
877 0 : rBindings.Release(*this);
878 0 : }
879 :
880 0 : void SwNavigationPI::SetPopupWindow( SfxPopupWindow* pWindow )
881 : {
882 0 : pPopupWindow = pWindow;
883 0 : pPopupWindow->SetPopupModeEndHdl( LINK( this, SwNavigationPI, PopupModeEndHdl ));
884 0 : pPopupWindow->SetDeleteLink_Impl( LINK( this, SwNavigationPI, ClosePopupWindow ));
885 0 : }
886 :
887 0 : IMPL_LINK_NOARG(SwNavigationPI, PopupModeEndHdl)
888 : {
889 0 : if ( pPopupWindow->IsVisible() )
890 : {
891 : // Replace floating window with popup window and destroy
892 : // floating window instance.
893 0 : delete pFloatingWindow;
894 0 : pFloatingWindow = pPopupWindow;
895 0 : pPopupWindow = 0;
896 : }
897 : else
898 : {
899 : // Popup window has been closed by the user. No replacement, instance
900 : // will destroy itself.
901 0 : pPopupWindow = 0;
902 : }
903 :
904 0 : return 1;
905 : }
906 :
907 0 : IMPL_LINK( SwNavigationPI, ClosePopupWindow, SfxPopupWindow *, pWindow )
908 : {
909 0 : if ( pWindow == pFloatingWindow )
910 0 : pFloatingWindow = 0;
911 : else
912 0 : pPopupWindow = 0;
913 :
914 0 : return 1;
915 : }
916 :
917 0 : void SwNavigationPI::StateChanged( sal_uInt16 nSID, SfxItemState /*eState*/,
918 : const SfxPoolItem* /*pState*/ )
919 : {
920 0 : if(nSID == SID_DOCFULLNAME)
921 : {
922 0 : SwView *pActView = GetCreateView();
923 0 : if(pActView)
924 : {
925 0 : SwWrtShell* pWrtShell = pActView->GetWrtShellPtr();
926 0 : aContentTree.SetActiveShell(pWrtShell);
927 0 : sal_Bool bGlobal = IsGlobalDoc();
928 0 : aContentToolBox.EnableItem(FN_GLOBAL_SWITCH, bGlobal);
929 0 : if( (!bGlobal && IsGlobalMode()) ||
930 0 : (!IsGlobalMode() && pConfig->IsGlobalActive()) )
931 : {
932 0 : ToggleTree();
933 : }
934 0 : if(bGlobal)
935 : {
936 0 : aGlobalToolBox.CheckItem(FN_GLOBAL_SAVE_CONTENT, pWrtShell->IsGlblDocSaveLinks());
937 : }
938 : }
939 : else
940 : {
941 0 : aContentTree.SetActiveShell(0);
942 : }
943 0 : UpdateListBox();
944 : }
945 0 : }
946 :
947 : // Get the numeric field from the toolbox.
948 :
949 0 : NumEditAction& SwNavigationPI::GetPageEdit()
950 : {
951 0 : return *(NumEditAction*)aContentToolBox.GetItemWindow(FN_PAGENUMBER);
952 : }
953 :
954 0 : SfxChildAlignment SwNavigationPI::CheckAlignment
955 : (
956 : SfxChildAlignment eActAlign,
957 : SfxChildAlignment eAlign
958 : )
959 : {
960 : SfxChildAlignment eRetAlign;
961 :
962 0 : if(_IsZoomedIn())
963 0 : eRetAlign = SFX_ALIGN_NOALIGNMENT;
964 : else
965 0 : switch (eAlign)
966 : {
967 : case SFX_ALIGN_BOTTOM:
968 : case SFX_ALIGN_LOWESTBOTTOM:
969 : case SFX_ALIGN_HIGHESTBOTTOM:
970 0 : eRetAlign = eActAlign;
971 0 : break;
972 :
973 : case SFX_ALIGN_TOP:
974 : case SFX_ALIGN_HIGHESTTOP:
975 : case SFX_ALIGN_LOWESTTOP:
976 : case SFX_ALIGN_LEFT:
977 : case SFX_ALIGN_RIGHT:
978 : case SFX_ALIGN_FIRSTLEFT:
979 : case SFX_ALIGN_LASTLEFT:
980 : case SFX_ALIGN_FIRSTRIGHT:
981 : case SFX_ALIGN_LASTRIGHT:
982 0 : eRetAlign = eAlign;
983 0 : break;
984 :
985 : default:
986 0 : eRetAlign = eAlign;
987 0 : break;
988 : }
989 0 : return eRetAlign;
990 :
991 : }
992 :
993 : // Notification on modified DocInfo
994 :
995 0 : void SwNavigationPI::Notify( SfxBroadcaster& rBrdc, const SfxHint& rHint )
996 : {
997 0 : if(&rBrdc == pCreateView)
998 : {
999 0 : if(rHint.ISA(SfxSimpleHint) && ((SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING)
1000 : {
1001 0 : pCreateView = 0;
1002 : }
1003 : }
1004 : else
1005 : {
1006 0 : if(rHint.ISA(SfxEventHint))
1007 : {
1008 0 : if( pxObjectShell &&
1009 0 : ((SfxEventHint&) rHint).GetEventId() == SFX_EVENT_CLOSEAPP)
1010 : {
1011 0 : DELETEZ(pxObjectShell);
1012 : }
1013 0 : else if(((SfxEventHint&) rHint).GetEventId() == SFX_EVENT_OPENDOC)
1014 : {
1015 :
1016 0 : SwView *pActView = GetCreateView();
1017 0 : if(pActView)
1018 : {
1019 0 : SwWrtShell* pWrtShell = pActView->GetWrtShellPtr();
1020 0 : aContentTree.SetActiveShell(pWrtShell);
1021 0 : if(aGlobalTree.IsVisible())
1022 : {
1023 0 : if(aGlobalTree.Update( sal_False ))
1024 0 : aGlobalTree.Display();
1025 : else
1026 : // If no update is needed, then paint at least,
1027 : // because of the red entries for the broken links.
1028 0 : aGlobalTree.Invalidate();
1029 : }
1030 : }
1031 : }
1032 : }
1033 : }
1034 0 : }
1035 :
1036 0 : IMPL_LINK( SwNavigationPI, MenuSelectHdl, Menu *, pMenu )
1037 : {
1038 0 : sal_uInt16 nMenuId = pMenu->GetCurItemId();
1039 0 : if(nMenuId != USHRT_MAX)
1040 : {
1041 0 : if(nMenuId < 100)
1042 0 : SetRegionDropMode( --nMenuId);
1043 : else
1044 0 : aContentTree.SetOutlineLevel( static_cast< sal_uInt8 >(nMenuId - 100) );
1045 : }
1046 0 : return 0;
1047 : }
1048 :
1049 0 : void SwNavigationPI::UpdateListBox()
1050 : {
1051 0 : aDocListBox.SetUpdateMode(sal_False);
1052 0 : aDocListBox.Clear();
1053 0 : SwView *pActView = GetCreateView();
1054 0 : bool bDisable = pActView == 0;
1055 0 : SwView *pView = SwModule::GetFirstView();
1056 0 : sal_uInt16 nCount = 0;
1057 0 : sal_uInt16 nAct = 0;
1058 0 : sal_uInt16 nConstPos = 0;
1059 0 : const SwView* pConstView = aContentTree.IsConstantView() &&
1060 0 : aContentTree.GetActiveWrtShell() ?
1061 0 : &aContentTree.GetActiveWrtShell()->GetView():
1062 0 : 0;
1063 0 : while (pView)
1064 : {
1065 0 : SfxObjectShell* pDoc = pView->GetDocShell();
1066 : // #i53333# don't show help pages here
1067 0 : if ( !pDoc->IsHelpDocument() )
1068 : {
1069 0 : String sEntry = pDoc->GetTitle();
1070 0 : sEntry += OUString(" (");
1071 0 : if (pView == pActView)
1072 : {
1073 0 : nAct = nCount;
1074 0 : sEntry += aStatusArr[ST_ACTIVE - ST_STATUS_FIRST];
1075 : }
1076 : else
1077 0 : sEntry += aStatusArr[ST_INACTIVE - ST_STATUS_FIRST];
1078 0 : sEntry += ')';
1079 0 : aDocListBox.InsertEntry(sEntry);
1080 :
1081 :
1082 0 : if (pConstView && pView == pConstView)
1083 0 : nConstPos = nCount;
1084 :
1085 0 : nCount++;
1086 : }
1087 0 : pView = SwModule::GetNextView(pView);
1088 : }
1089 0 : aDocListBox.InsertEntry(aStatusArr[3]); // "Active Window"
1090 0 : nCount++;
1091 :
1092 0 : if(aContentTree.GetHiddenWrtShell())
1093 : {
1094 0 : String sEntry = aContentTree.GetHiddenWrtShell()->GetView().
1095 0 : GetDocShell()->GetTitle();
1096 0 : sEntry += OUString(" (");
1097 0 : sEntry += aStatusArr[ST_HIDDEN - ST_STATUS_FIRST];
1098 0 : sEntry += ')';
1099 0 : aDocListBox.InsertEntry(sEntry);
1100 0 : bDisable = false;
1101 : }
1102 0 : if(aContentTree.IsActiveView())
1103 : {
1104 : //Either the name of the current Document or "Active Document".
1105 0 : sal_uInt16 nTmp = pActView ? nAct : --nCount;
1106 0 : aDocListBox.SelectEntryPos( nTmp );
1107 : }
1108 0 : else if(aContentTree.IsHiddenView())
1109 : {
1110 0 : aDocListBox.SelectEntryPos(nCount);
1111 : }
1112 : else
1113 0 : aDocListBox.SelectEntryPos(nConstPos);
1114 :
1115 0 : aDocListBox.Enable( !bDisable );
1116 0 : aDocListBox.SetUpdateMode(sal_True);
1117 0 : }
1118 :
1119 0 : IMPL_LINK(SwNavigationPI, DoneLink, SfxPoolItem *, pItem)
1120 : {
1121 0 : const SfxViewFrameItem* pFrameItem = PTR_CAST(SfxViewFrameItem, pItem );
1122 0 : if( pFrameItem )
1123 : {
1124 0 : SfxViewFrame* pFrame = pFrameItem->GetFrame();
1125 0 : if(pFrame)
1126 : {
1127 0 : aContentTree.Clear();
1128 0 : pContentView = PTR_CAST(SwView, pFrame->GetViewShell());
1129 : OSL_ENSURE(pContentView, "no SwView");
1130 0 : if(pContentView)
1131 0 : pContentWrtShell = pContentView->GetWrtShellPtr();
1132 : else
1133 0 : pContentWrtShell = 0;
1134 0 : pxObjectShell = new SfxObjectShellLock(pFrame->GetObjectShell());
1135 0 : FillBox();
1136 0 : aContentTree.Update();
1137 : }
1138 : }
1139 0 : return 0;
1140 : }
1141 :
1142 0 : String SwNavigationPI::CreateDropFileName( TransferableDataHelper& rData )
1143 : {
1144 0 : String sFileName;
1145 : sal_uLong nFmt;
1146 0 : if( rData.HasFormat( nFmt = FORMAT_FILE_LIST ))
1147 : {
1148 0 : FileList aFileList;
1149 0 : rData.GetFileList( nFmt, aFileList );
1150 0 : sFileName = aFileList.GetFile( 0 );
1151 : }
1152 0 : else if( rData.HasFormat( nFmt = FORMAT_STRING ) ||
1153 0 : rData.HasFormat( nFmt = FORMAT_FILE ) ||
1154 0 : rData.HasFormat( nFmt = SOT_FORMATSTR_ID_FILENAME ))
1155 0 : rData.GetString( nFmt, sFileName );
1156 0 : else if( rData.HasFormat( nFmt = SOT_FORMATSTR_ID_SOLK ) ||
1157 0 : rData.HasFormat( nFmt = SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK )||
1158 0 : rData.HasFormat( nFmt = SOT_FORMATSTR_ID_FILECONTENT ) ||
1159 0 : rData.HasFormat( nFmt = SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR ) ||
1160 0 : rData.HasFormat( nFmt = SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR ))
1161 : {
1162 0 : INetBookmark aBkmk( aEmptyStr, aEmptyStr );
1163 0 : rData.GetINetBookmark( nFmt, aBkmk );
1164 0 : sFileName = aBkmk.GetURL();
1165 : }
1166 0 : if( sFileName.Len() )
1167 : {
1168 0 : sFileName = INetURLObject( sFileName ).GetMainURL( INetURLObject::NO_DECODE );
1169 : }
1170 0 : return sFileName;
1171 : }
1172 :
1173 0 : sal_Int8 SwNavigationPI::AcceptDrop( const AcceptDropEvent& /*rEvt*/ )
1174 : {
1175 0 : return ( !aContentTree.IsInDrag() &&
1176 0 : ( aContentTree.IsDropFormatSupported( FORMAT_FILE ) ||
1177 0 : aContentTree.IsDropFormatSupported( FORMAT_STRING ) ||
1178 0 : aContentTree.IsDropFormatSupported( SOT_FORMATSTR_ID_SOLK ) ||
1179 0 : aContentTree.IsDropFormatSupported( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK )||
1180 0 : aContentTree.IsDropFormatSupported( SOT_FORMATSTR_ID_FILECONTENT ) ||
1181 0 : aContentTree.IsDropFormatSupported( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR ) ||
1182 0 : aContentTree.IsDropFormatSupported( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR ) ||
1183 0 : aContentTree.IsDropFormatSupported( SOT_FORMATSTR_ID_FILENAME )))
1184 : ? DND_ACTION_COPY
1185 0 : : DND_ACTION_NONE;
1186 : }
1187 :
1188 0 : sal_Int8 SwNavigationPI::ExecuteDrop( const ExecuteDropEvent& rEvt )
1189 : {
1190 0 : TransferableDataHelper aData( rEvt.maDropEvent.Transferable );
1191 0 : sal_Int8 nRet = DND_ACTION_NONE;
1192 0 : String sFileName;
1193 0 : if( !aContentTree.IsInDrag() &&
1194 0 : 0 != (sFileName = SwNavigationPI::CreateDropFileName( aData )).Len() )
1195 : {
1196 0 : INetURLObject aTemp( sFileName );
1197 0 : GraphicDescriptor aDesc( aTemp );
1198 0 : if( !aDesc.Detect() ) // accept no graphics
1199 : {
1200 0 : if( STRING_NOTFOUND == sFileName.Search('#')
1201 0 : && (!sContentFileName.Len() || sContentFileName != sFileName ))
1202 : {
1203 0 : nRet = rEvt.mnAction;
1204 0 : sFileName = comphelper::string::stripEnd(sFileName, 0);
1205 0 : sContentFileName = sFileName;
1206 0 : if(pxObjectShell)
1207 : {
1208 0 : aContentTree.SetHiddenShell( 0 );
1209 0 : (*pxObjectShell)->DoClose();
1210 0 : DELETEZ( pxObjectShell);
1211 : }
1212 0 : SfxStringItem aFileItem(SID_FILE_NAME, sFileName );
1213 0 : SfxStringItem aOptionsItem( SID_OPTIONS, OUString("HRC") );
1214 : SfxLinkItem aLink( SID_DONELINK,
1215 0 : LINK( this, SwNavigationPI, DoneLink ) );
1216 0 : GetActiveView()->GetViewFrame()->GetDispatcher()->Execute(
1217 : SID_OPENDOC, SFX_CALLMODE_ASYNCHRON,
1218 0 : &aFileItem, &aOptionsItem, &aLink, 0L );
1219 : }
1220 0 : }
1221 : }
1222 0 : return nRet;
1223 : }
1224 :
1225 0 : void SwNavigationPI::SetRegionDropMode(sal_uInt16 nNewMode)
1226 : {
1227 0 : nRegionMode = nNewMode;
1228 0 : pConfig->SetRegionMode( nRegionMode );
1229 :
1230 0 : sal_uInt16 nDropId = FN_DROP_REGION;
1231 0 : if(nRegionMode == REGION_MODE_LINK)
1232 0 : nDropId = FN_DROP_REGION_LINK;
1233 0 : else if(nRegionMode == REGION_MODE_EMBEDDED)
1234 0 : nDropId = FN_DROP_REGION_COPY;
1235 :
1236 0 : ImageList& rImgLst = aContentImageList;
1237 :
1238 0 : aContentToolBox.SetItemImage( FN_DROP_REGION, rImgLst.GetImage(nDropId));
1239 0 : }
1240 :
1241 0 : sal_Bool SwNavigationPI::ToggleTree()
1242 : {
1243 0 : sal_Bool bRet = sal_True;
1244 0 : sal_Bool bGlobalDoc = IsGlobalDoc();
1245 0 : if(!IsGlobalMode() && bGlobalDoc)
1246 : {
1247 0 : SetUpdateMode(sal_False);
1248 0 : if(_IsZoomedIn())
1249 0 : _ZoomOut();
1250 0 : aGlobalTree.ShowTree();
1251 0 : aGlobalToolBox.Show();
1252 0 : aContentTree.HideTree();
1253 0 : aContentToolBox.Hide();
1254 0 : aDocListBox.Hide();
1255 0 : SetGlobalMode(sal_True);
1256 0 : SetUpdateMode(sal_True);
1257 : }
1258 : else
1259 : {
1260 0 : aGlobalTree.HideTree();
1261 0 : aGlobalToolBox.Hide();
1262 0 : if(!_IsZoomedIn())
1263 : {
1264 0 : aContentTree.ShowTree();
1265 0 : aContentToolBox.Show();
1266 0 : aDocListBox.Show();
1267 : }
1268 0 : bRet = sal_False;
1269 0 : SetGlobalMode(sal_False);
1270 : }
1271 0 : return bRet;
1272 : }
1273 :
1274 0 : sal_Bool SwNavigationPI::IsGlobalDoc() const
1275 : {
1276 0 : sal_Bool bRet = sal_False;
1277 0 : SwView *pView = GetCreateView();
1278 0 : if(pView)
1279 : {
1280 0 : SwWrtShell &rSh = pView->GetWrtShell();
1281 0 : bRet = rSh.IsGlobalDoc();
1282 : }
1283 0 : return bRet;
1284 : }
1285 :
1286 0 : IMPL_LINK_NOARG(SwNavigationPI, ChangePageHdl)
1287 : {
1288 0 : EditAction(&GetPageEdit());
1289 0 : GetPageEdit().GrabFocus();
1290 0 : return 0;
1291 : }
1292 :
1293 0 : IMPL_LINK_NOARG(SwNavigationPI, PageEditModifyHdl)
1294 : {
1295 0 : if(aPageChgTimer.IsActive())
1296 0 : aPageChgTimer.Stop();
1297 0 : aPageChgTimer.Start();
1298 0 : return 0;
1299 : }
1300 :
1301 0 : SwView* SwNavigationPI::GetCreateView() const
1302 : {
1303 0 : if(!pCreateView)
1304 : {
1305 0 : SwView* pView = SwModule::GetFirstView();
1306 0 : while(pView)
1307 : {
1308 0 : if(&pView->GetViewFrame()->GetBindings() == &rBindings)
1309 : {
1310 0 : ((SwNavigationPI*)this)->pCreateView = pView;
1311 0 : ((SwNavigationPI*)this)->StartListening(*pCreateView);
1312 0 : break;
1313 : }
1314 0 : pView = SwModule::GetNextView(pView);
1315 : }
1316 : }
1317 0 : return pCreateView;
1318 : }
1319 :
1320 0 : SwNavigationChild::SwNavigationChild( Window* pParent,
1321 : sal_uInt16 nId,
1322 : SfxBindings* _pBindings,
1323 : SfxChildWinInfo* )
1324 0 : : SfxChildWindowContext( nId )
1325 : {
1326 0 : SwNavigationPI* pNavi = new SwNavigationPI( _pBindings, this, pParent );
1327 0 : SetWindow( pNavi );
1328 0 : _pBindings->Invalidate(SID_NAVIGATOR);
1329 :
1330 0 : SwNavigationConfig* pNaviConfig = SW_MOD()->GetNavigationConfig();
1331 :
1332 0 : sal_uInt16 nRootType = static_cast< sal_uInt16 >( pNaviConfig->GetRootType() );
1333 0 : if( nRootType < CONTENT_TYPE_MAX )
1334 : {
1335 0 : pNavi->aContentTree.SetRootType(nRootType);
1336 0 : pNavi->aContentToolBox.CheckItem(FN_SHOW_ROOT, sal_True);
1337 : }
1338 0 : pNavi->aContentTree.SetOutlineLevel( static_cast< sal_uInt8 >( pNaviConfig->GetOutlineLevel() ) );
1339 0 : pNavi->SetRegionDropMode( static_cast< sal_uInt16 >( pNaviConfig->GetRegionMode() ) );
1340 :
1341 0 : if(GetFloatingWindow() && pNaviConfig->IsSmall())
1342 : {
1343 0 : pNavi->_ZoomIn();
1344 : }
1345 0 : }
1346 :
1347 0 : void SwNavigationPI::DataChanged( const DataChangedEvent& rDCEvt )
1348 : {
1349 0 : Window::DataChanged( rDCEvt );
1350 0 : if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
1351 0 : (rDCEvt.GetFlags() & SETTINGS_STYLE) )
1352 : {
1353 0 : InitImageList();
1354 0 : const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
1355 0 : Color aBgColor = rStyleSettings.GetFaceColor();
1356 0 : Wallpaper aBack( aBgColor );
1357 0 : SetBackground( aBack );
1358 : }
1359 0 : }
1360 :
1361 0 : void SwNavigationPI::InitImageList()
1362 : {
1363 : sal_uInt16 k;
1364 :
1365 0 : ImageList& rImgLst = aContentImageList;
1366 0 : for( k = 0; k < aContentToolBox.GetItemCount(); k++)
1367 0 : aContentToolBox.SetItemImage(aContentToolBox.GetItemId(k),
1368 0 : rImgLst.GetImage(aContentToolBox.GetItemId(k)));
1369 :
1370 0 : for( k = 0; k < aGlobalToolBox.GetItemCount(); k++)
1371 0 : aGlobalToolBox.SetItemImage(aGlobalToolBox.GetItemId(k),
1372 0 : rImgLst.GetImage(aGlobalToolBox.GetItemId(k)));
1373 :
1374 0 : sal_uInt16 nDropId = FN_DROP_REGION;
1375 0 : if(nRegionMode == REGION_MODE_LINK)
1376 0 : nDropId = FN_DROP_REGION_LINK;
1377 0 : else if(nRegionMode == REGION_MODE_EMBEDDED)
1378 0 : nDropId = FN_DROP_REGION_COPY;
1379 : aContentToolBox.SetItemImage( FN_DROP_REGION,
1380 0 : rImgLst.GetImage(nDropId));
1381 99 : }
1382 :
1383 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|