LibreOffice Module sc (master)  1
navipi.cxx
Go to the documentation of this file.
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 <sfx2/app.hxx>
21 #include <sfx2/bindings.hxx>
22 #include <sfx2/dispatch.hxx>
23 #include <sfx2/event.hxx>
24 #include <sfx2/navigat.hxx>
25 #include <svl/stritem.hxx>
26 #include <unotools/charclass.hxx>
27 #include <uiobject.hxx>
28 
29 #include <viewdata.hxx>
30 #include <tabvwsh.hxx>
31 #include <docsh.hxx>
32 #include <document.hxx>
33 #include <rangeutl.hxx>
34 #include <sc.hrc>
35 #include <strings.hrc>
36 #include <bitmaps.hlst>
37 #include <scresid.hxx>
38 #include <scmod.hxx>
39 #include <navicfg.hxx>
40 #include <navcitem.hxx>
41 #include <navipi.hxx>
42 #include <navsett.hxx>
43 #include <markdata.hxx>
44 
45 #include <com/sun/star/uno/Reference.hxx>
46 
47 using namespace com::sun::star;
48 
49 // maximum values for UI
50 static SCCOL SCNAV_MAXCOL(const ScSheetLimits& rLimits) { return rLimits.GetMaxColCount(); }
51 static sal_Int32 SCNAV_COLDIGITS(const ScSheetLimits& rLimits)
52 {
53  return static_cast<sal_Int32>( floor( log10( static_cast<double>(SCNAV_MAXCOL(rLimits)))) ) + 1; // 1...256...18278
54 }
55 static sal_Int32 SCNAV_COLLETTERS(const ScSheetLimits& rLimits)
56 {
57  return ::ScColToAlpha(SCNAV_MAXCOL(rLimits)).getLength(); // A...IV...ZZZ
58 }
59 
60 static SCROW SCNAV_MAXROW(const ScSheetLimits& rSheetLimits)
61 {
62  return rSheetLimits.GetMaxRowCount();
63 }
64 
66 {
68 
69  if ( pCurSh )
70  {
71  vcl::Window* pShellWnd = pCurSh->GetWindow();
72  if ( pShellWnd )
73  pShellWnd->GrabFocus();
74  }
75 }
76 
77 namespace
78 {
79  SCCOL NumToAlpha(const ScSheetLimits& rSheetLimits, SCCOL nColNo, OUString& rStr)
80  {
81  if ( nColNo > SCNAV_MAXCOL(rSheetLimits) )
82  nColNo = SCNAV_MAXCOL(rSheetLimits);
83  else if ( nColNo < 1 )
84  nColNo = 1;
85 
86  ::ScColToAlpha( rStr, nColNo - 1);
87 
88  return nColNo;
89  }
90 
91  SCCOL AlphaToNum(const ScDocument& rDoc, OUString& rStr)
92  {
93  SCCOL nColumn = 0;
94 
95  if ( CharClass::isAsciiAlpha( rStr) )
96  {
97  rStr = rStr.toAsciiUpperCase();
98 
99  if (::AlphaToCol( rDoc, nColumn, rStr))
100  ++nColumn;
101 
102  if ( (rStr.getLength() > SCNAV_COLLETTERS(rDoc.GetSheetLimits())) ||
103  (nColumn > SCNAV_MAXCOL(rDoc.GetSheetLimits())) )
104  {
105  nColumn = SCNAV_MAXCOL(rDoc.GetSheetLimits());
106  NumToAlpha( rDoc.GetSheetLimits(), nColumn, rStr );
107  }
108  }
109  else
110  rStr.clear();
111 
112  return nColumn;
113  }
114 
115  SCCOL NumStrToAlpha(const ScSheetLimits& rSheetLimits, OUString& rStr)
116  {
117  SCCOL nColumn = 0;
118 
119  if ( CharClass::isAsciiNumeric(rStr) )
120  nColumn = NumToAlpha( rSheetLimits, static_cast<SCCOL>(rStr.toInt32()), rStr );
121  else
122  rStr.clear();
123 
124  return nColumn;
125  }
126 }
127 
128 IMPL_LINK(ScNavigatorDlg, ParseRowInputHdl, int*, result, bool)
129 {
130  SCCOL nCol;
131 
132  OUString aStrCol = m_xEdCol->get_text();
133 
134  if (!aStrCol.isEmpty())
135  {
136  // nKeyGroup is no longer set at VCL, in cause of lack of keyinput
137 
138  ScTabViewShell* pViewSh = dynamic_cast<ScTabViewShell*>( SfxViewShell::Current() );
139  auto& rDoc = pViewSh->GetViewData().GetDocument();
140  if ( CharClass::isAsciiNumeric(aStrCol) )
141  nCol = NumStrToAlpha( rDoc.GetSheetLimits(), aStrCol );
142  else
143  nCol = AlphaToNum( rDoc, aStrCol );
144  }
145  else
146  nCol = 0;
147 
148  *result = nCol;
149  return true;
150 }
151 
153 {
154  ReleaseFocus();
155 
156  SCROW nRow = m_xEdRow->get_value();
157  SCCOL nCol = m_xEdCol->get_value();
158 
159  if ( (nCol > 0) && (nRow > 0) )
160  SetCurrentCell(nCol - 1, nRow - 1);
161 
162  return true;
163 }
164 
165 IMPL_LINK_NOARG(ScNavigatorDlg, FormatRowOutputHdl, weld::SpinButton&, void)
166 {
167  OUString aStr;
168  ::ScColToAlpha(aStr, m_xEdCol->get_value() - 1);
169  m_xEdCol->set_text(aStr);
170 }
171 
173 {
174  ReleaseFocus();
175 
176  SCCOL nCol = m_xEdCol->get_value();
177  SCROW nRow = m_xEdRow->get_value();
178 
179  if ( (nCol > 0) && (nRow > 0) )
180  SetCurrentCell(nCol - 1, nRow - 1);
181 
182  return true;
183 }
184 
185 IMPL_LINK(ScNavigatorDlg, DocumentSelectHdl, weld::ComboBox&, rListBox, void)
186 {
188 
189  OUString aDocName = rListBox.get_active_text();
190  m_xLbEntries->SelectDoc(aDocName);
191 }
192 
193 IMPL_LINK(ScNavigatorDlg, ToolBoxSelectHdl, const OString&, rSelId, void)
194 {
195  // Switch the mode?
196  if (rSelId == "contents" || rSelId == "scenarios")
197  {
198  NavListMode eOldMode = eListMode;
199  NavListMode eNewMode;
200 
201  if (rSelId == "scenarios")
202  {
203  if (eOldMode == NAV_LMODE_SCENARIOS)
204  eNewMode = NAV_LMODE_AREAS;
205  else
206  eNewMode = NAV_LMODE_SCENARIOS;
207  }
208  else // on/off
209  {
210  if (eOldMode == NAV_LMODE_NONE)
211  eNewMode = NAV_LMODE_AREAS;
212  else
213  eNewMode = NAV_LMODE_NONE;
214  }
215  SetListMode(eNewMode);
216  UpdateButtons();
217  }
218  else if (rSelId == "dragmode")
219  m_xTbxCmd2->set_menu_item_active("dragmode", !m_xTbxCmd2->get_menu_item_active("dragmode"));
220  else
221  {
222  if (rSelId == "datarange")
223  MarkDataArea();
224  else if (rSelId == "start")
225  StartOfDataArea();
226  else if (rSelId == "end")
227  EndOfDataArea();
228  else if (rSelId == "toggle")
229  {
230  m_xLbEntries->ToggleRoot();
231  UpdateButtons();
232  }
233  }
234 }
235 
236 IMPL_LINK(ScNavigatorDlg, ToolBoxDropdownClickHdl, const OString&, rCommand, void)
237 {
238  if (!m_xTbxCmd2->get_menu_item_active(rCommand))
239  return;
240 
241  // the popup menu of the drop mode has to be called in the
242  // click (button down) and not in the select (button up)
243  if (rCommand != "dragmode")
244  return;
245 
246  switch (GetDropMode())
247  {
248  case 0:
249  m_xDragModeMenu->set_active("hyperlink", true);
250  break;
251  case 1:
252  m_xDragModeMenu->set_active("link", true);
253  break;
254  case 2:
255  m_xDragModeMenu->set_active("copy", true);
256  break;
257  }
258 }
259 
260 IMPL_LINK(ScNavigatorDlg, MenuSelectHdl, const OString&, rIdent, void)
261 {
262  if (rIdent == "hyperlink")
263  SetDropMode(0);
264  else if (rIdent == "link")
265  SetDropMode(1);
266  else if (rIdent == "copy")
267  SetDropMode(2);
268 }
269 
271 {
272  NavListMode eMode = eListMode;
273  m_xTbxCmd2->set_item_active("scenarios", eMode == NAV_LMODE_SCENARIOS);
274  m_xTbxCmd1->set_item_active("contents", eMode != NAV_LMODE_NONE);
275 
276  // the toggle button:
277  if (eMode == NAV_LMODE_SCENARIOS || eMode == NAV_LMODE_NONE)
278  {
279  m_xTbxCmd2->set_item_sensitive("toggle", false);
280  m_xTbxCmd2->set_item_active("toggle", false);
281  }
282  else
283  {
284  m_xTbxCmd2->set_item_sensitive("toggle", true);
285  bool bRootSet = m_xLbEntries->GetRootType() != ScContentId::ROOT;
286  m_xTbxCmd2->set_item_active("toggle", bRootSet);
287  }
288 
289  OUString sImageId;
290  switch (nDropMode)
291  {
292  case SC_DROPMODE_URL:
293  sImageId = RID_BMP_DROP_URL;
294  break;
295  case SC_DROPMODE_LINK:
296  sImageId = RID_BMP_DROP_LINK;
297  break;
298  case SC_DROPMODE_COPY:
299  sImageId = RID_BMP_DROP_COPY;
300  break;
301  }
302  m_xTbxCmd2->set_item_icon_name("dragmode", sImageId);
303 }
304 
306  : mnRootSelected(ScContentId::ROOT)
307  , mnChildSelected(SC_CONTENT_NOCHILD)
308 {
309  maExpandedVec.fill(false);
310 }
311 
313 
315  sal_uInt16 nId,
316  SfxBindings* pBind,
317  SAL_UNUSED_PARAMETER SfxChildWinInfo* /* pInfo */)
318  : SfxChildWindowContext(nId)
319 {
320  pNavigator = VclPtr<ScNavigatorDlg>::Create(pBind, pParent);
321  if (SfxNavigator* pNav = dynamic_cast<SfxNavigator*>(pParent))
322  pNav->SetMinOutputSizePixel(pNavigator->GetOptimalSize());
323  SetWindow(pNavigator);
324 }
325 
327  : PanelLayout(pParent, "NavigatorPanel", "modules/scalc/ui/navigatorpanel.ui", nullptr)
328  , rBindings(*pB)
329  , m_xEdCol(m_xBuilder->weld_spin_button("column"))
330  , m_xEdRow(m_xBuilder->weld_spin_button("row"))
331  , m_xTbxCmd1(m_xBuilder->weld_toolbar("toolbox1"))
332  , m_xTbxCmd2(m_xBuilder->weld_toolbar("toolbox2"))
333  , m_xLbEntries(new ScContentTree(m_xBuilder->weld_tree_view("contentbox"), this))
334  , m_xScenarioBox(m_xBuilder->weld_widget("scenariobox"))
335  , m_xWndScenarios(new ScScenarioWindow(*m_xBuilder,
336  ScResId(SCSTR_QHLP_SCEN_LISTBOX), ScResId(SCSTR_QHLP_SCEN_COMMENT)))
337  , m_xLbDocuments(m_xBuilder->weld_combo_box("documents"))
338  , m_xDragModeMenu(m_xBuilder->weld_menu("dragmodemenu"))
339  , aStrActiveWin(ScResId(SCSTR_ACTIVEWIN))
340  , pViewData(nullptr )
341  , eListMode(NAV_LMODE_NONE)
342  , nDropMode(SC_DROPMODE_URL)
343  , nCurCol(0)
344  , nCurRow(0)
345  , nCurTab(0)
346 {
347  set_id("NavigatorPanelParent"); // for uitests
348 
350  m_xEdRow->set_width_chars(5);
351  //max rows is 1,000,000, which is too long for typical use
352  m_xEdRow->connect_activate(LINK(this, ScNavigatorDlg, ExecuteRowHdl));
353 
354  m_xEdCol->connect_activate(LINK(this, ScNavigatorDlg, ExecuteColHdl));
355  m_xEdCol->connect_output(LINK(this, ScNavigatorDlg, FormatRowOutputHdl));
356  m_xEdCol->connect_input(LINK(this, ScNavigatorDlg, ParseRowInputHdl));
357 
358  m_xTbxCmd1->connect_clicked(LINK(this, ScNavigatorDlg, ToolBoxSelectHdl));
359  m_xTbxCmd2->connect_clicked(LINK(this, ScNavigatorDlg, ToolBoxSelectHdl));
360 
361  m_xTbxCmd2->set_item_menu("dragmode", m_xDragModeMenu.get());
362  m_xDragModeMenu->connect_activate(LINK(this, ScNavigatorDlg, MenuSelectHdl));
363  m_xTbxCmd2->connect_menu_toggled(LINK(this, ScNavigatorDlg, ToolBoxDropdownClickHdl));
364 
365  ScNavipiCfg& rCfg = SC_MOD()->GetNavipiCfg();
366  nDropMode = rCfg.GetDragMode();
367 
368  m_xLbDocuments->set_size_request(42, -1); // set a nominal width so it takes width of surroundings
369  m_xLbDocuments->connect_changed(LINK(this, ScNavigatorDlg, DocumentSelectHdl));
370  aStrActive = " (" + ScResId(SCSTR_ACTIVE) + ")"; // " (active)"
371  aStrNotActive = " (" + ScResId(SCSTR_NOTACTIVE) + ")"; // " (not active)"
372  aStrHidden = " (" + ScResId(SCSTR_HIDDEN) + ")"; // " (hidden)"
373 
374  rBindings.ENTERREGISTRATIONS();
375 
376  mvBoundItems[0].reset(new ScNavigatorControllerItem(SID_CURRENTCELL,*this,rBindings));
377  mvBoundItems[1].reset(new ScNavigatorControllerItem(SID_CURRENTTAB,*this,rBindings));
378  mvBoundItems[2].reset(new ScNavigatorControllerItem(SID_CURRENTDOC,*this,rBindings));
379  mvBoundItems[3].reset(new ScNavigatorControllerItem(SID_SELECT_SCENARIO,*this,rBindings));
380 
381  rBindings.LEAVEREGISTRATIONS();
382 
383  StartListening( *(SfxGetpApp()) );
385 
386  m_xLbEntries->set_selection_mode( SelectionMode::Single );
387  Size aSize(LogicToPixel(Size(110, 100), MapMode(MapUnit::MapAppFont)));
388  m_xLbEntries->set_size_request(aSize.Width(), aSize.Height());
389 
390  // was a category chosen as root?
391  ScContentId nLastRoot = rCfg.GetRootType();
392  if ( nLastRoot != ScContentId::ROOT )
393  m_xLbEntries->SetRootType( nLastRoot );
394 
395  m_xLbEntries->Refresh();
396  GetDocNames(nullptr);
397 
398  UpdateButtons();
399 
400  UpdateColumn();
401  UpdateRow();
402  UpdateTable(nullptr);
403  m_xLbEntries->hide();
404  m_xScenarioBox->hide();
405 
406  aContentIdle.SetInvokeHandler( LINK( this, ScNavigatorDlg, TimeHdl ) );
407  aContentIdle.SetPriority( TaskPriority::LOWEST );
408 
409  m_xLbEntries->SetNavigatorDlgFlag(true);
410 
411  // if scenario was active, switch on
412  NavListMode eNavMode = static_cast<NavListMode>(rCfg.GetListMode());
413  if (eNavMode == NAV_LMODE_SCENARIOS)
414  m_xTbxCmd2->set_item_active("scenarios", true);
415  else
416  eNavMode = NAV_LMODE_AREAS;
417  SetListMode(eNavMode);
418 
420 }
421 
423 {
424  if (ScViewData* pData = GetViewData())
425  {
426  ScDocument& rDoc = pData->GetDocument();
427  m_xEdRow->set_range(1, SCNAV_MAXROW(rDoc.GetSheetLimits()));
428  m_xEdCol->set_range(1, SCNAV_MAXCOL(rDoc.GetSheetLimits()));
429  m_xEdCol->set_width_chars(SCNAV_COLDIGITS(rDoc.GetSheetLimits())); // 1...256...18278 or A...IV...ZZZ
430  }
431 }
432 
434 {
435  PanelLayout::StateChanged(nStateChange);
436  if (nStateChange == StateChangedType::InitShow)
437  {
438  // When the navigator is displayed in the sidebar, or is otherwise
439  // docked, it has the whole deck to fill. Therefore hide the button that
440  // hides all controls below the top two rows of buttons.
441  m_xTbxCmd1->set_item_visible("contents", SfxChildWindowContext::GetFloatingWindow(GetParent()) != nullptr);
442  }
443 }
444 
446 {
448 }
449 
451 {
452  disposeOnce();
453 }
454 
456 {
457  aContentIdle.Stop();
458 
459  for (auto & p : mvBoundItems)
460  p.reset();
461  pMarkArea.reset();
462 
463  EndListening( *(SfxGetpApp()) );
465 
466  m_xEdCol.reset();
467  m_xEdRow.reset();
468  m_xTbxCmd1.reset();
469  m_xTbxCmd2.reset();
470  m_xDragModeMenu.reset();
471  m_xLbEntries.reset();
472  m_xWndScenarios.reset();
473  m_xScenarioBox.reset();
474  m_xLbDocuments.reset();
476 }
477 
479 {
480  if (const SfxEventHint* pHint = dynamic_cast<const SfxEventHint*>(&rHint))
481  {
482  if (pHint->GetEventId() == SfxEventHintId::ActivateDoc)
483  {
485  m_xLbEntries->ActiveDocChanged();
486  UpdateAll();
487  }
488  }
489  else
490  {
491  const SfxHintId nHintId = rHint.GetId();
492 
493  if (nHintId == SfxHintId::ScDocNameChanged)
494  {
495  m_xLbEntries->ActiveDocChanged();
496  }
497  else if (NAV_LMODE_NONE == eListMode)
498  {
499  // Table not any more
500  }
501  else
502  {
503  switch ( nHintId )
504  {
505  case SfxHintId::ScTablesChanged:
506  m_xLbEntries->Refresh( ScContentId::TABLE );
507  break;
508 
509  case SfxHintId::ScDbAreasChanged:
510  m_xLbEntries->Refresh( ScContentId::DBAREA );
511  break;
512 
513  case SfxHintId::ScAreasChanged:
515  break;
516 
517  case SfxHintId::ScDrawChanged:
521  break;
522 
523  case SfxHintId::ScAreaLinksChanged:
525  break;
526 
527  // SfxHintId::DocChanged not only at document change
528 
529  case SfxHintId::ScNavigatorUpdateAll:
530  UpdateAll();
531  break;
532 
533  case SfxHintId::ScDataChanged:
534  case SfxHintId::ScAnyDataChanged:
535  aContentIdle.Start(); // Do not search notes immediately
536  break;
537  case SfxHintId::ScKillEditView:
538  m_xLbEntries->ObjectFresh( ScContentId::OLEOBJECT );
539  m_xLbEntries->ObjectFresh( ScContentId::DRAWING );
540  m_xLbEntries->ObjectFresh( ScContentId::GRAPHIC );
541  break;
542  case SfxHintId::ScSelectionChanged:
543  UpdateSelection();
544  break;
545  default:
546  break;
547  }
548  }
549  }
550 }
551 
552 IMPL_LINK( ScNavigatorDlg, TimeHdl, Timer*, pIdle, void )
553 {
554  if ( pIdle != &aContentIdle )
555  return;
556 
557  m_xLbEntries->Refresh( ScContentId::NOTE );
558 }
559 
560 void ScNavigatorDlg::SetDropMode(sal_uInt16 nNew)
561 {
562  nDropMode = nNew;
563  UpdateButtons();
564  ScNavipiCfg& rCfg = SC_MOD()->GetNavipiCfg();
565  rCfg.SetDragMode(nDropMode);
566 }
567 
569 {
570  if ((nColNo+1 == nCurCol) && (nRowNo+1 == nCurRow))
571  return;
572 
573  // SID_CURRENTCELL == Item #0 clear cache, so it's possible
574  // setting the current cell even in combined areas
575  mvBoundItems[0]->ClearCache();
576 
577  ScAddress aScAddress( nColNo, nRowNo, 0 );
578  OUString aAddr(aScAddress.Format(ScRefFlags::ADDR_ABS));
579 
580  bool bUnmark = false;
581  if ( GetViewData() )
582  bUnmark = !pViewData->GetMarkData().IsCellMarked( nColNo, nRowNo );
583 
584  SfxStringItem aPosItem( SID_CURRENTCELL, aAddr );
585  SfxBoolItem aUnmarkItem( FN_PARAM_1, bUnmark ); // cancel selection
586 
587  rBindings.GetDispatcher()->ExecuteList(SID_CURRENTCELL,
588  SfxCallMode::SYNCHRON | SfxCallMode::RECORD,
589  { &aPosItem, &aUnmarkItem });
590 }
591 
592 void ScNavigatorDlg::SetCurrentCellStr( const OUString& rName )
593 {
594  mvBoundItems[0]->ClearCache();
595  SfxStringItem aNameItem( SID_CURRENTCELL, rName );
596 
597  rBindings.GetDispatcher()->ExecuteList(SID_CURRENTCELL,
598  SfxCallMode::SYNCHRON | SfxCallMode::RECORD,
599  { &aNameItem });
600 }
601 
603 {
604  if ( nTabNo != nCurTab )
605  {
606  // Table for basic is base-1
607  SfxUInt16Item aTabItem( SID_CURRENTTAB, static_cast<sal_uInt16>(nTabNo) + 1 );
608  rBindings.GetDispatcher()->ExecuteList(SID_CURRENTTAB,
609  SfxCallMode::SYNCHRON | SfxCallMode::RECORD,
610  { &aTabItem });
611  }
612 }
613 
614 void ScNavigatorDlg::SetCurrentTableStr( const OUString& rName )
615 {
616  if (!GetViewData()) return;
617 
618  ScDocument& rDoc = pViewData->GetDocument();
619  SCTAB nCount = rDoc.GetTableCount();
620  OUString aTabName;
621  SCTAB nLastSheet = 0;
622 
623  for (SCTAB i = 0; i<nCount; i++)
624  {
625  rDoc.GetName(i, aTabName);
626  if (aTabName == rName)
627  {
628  // Check if this is a Scenario sheet and if so select the sheet
629  // where it belongs to, which is the previous non-Scenario sheet.
630  if (rDoc.IsScenario(i))
631  {
632  SetCurrentTable(nLastSheet);
633  return;
634  }
635  else
636  {
638  return;
639  }
640  }
641  else
642  {
643  if (!rDoc.IsScenario(i))
644  nLastSheet = i;
645  }
646  }
647 }
648 
649 void ScNavigatorDlg::SetCurrentObject( const OUString& rName )
650 {
651  SfxStringItem aNameItem( SID_CURRENTOBJECT, rName );
652  rBindings.GetDispatcher()->ExecuteList( SID_CURRENTOBJECT,
653  SfxCallMode::SYNCHRON | SfxCallMode::RECORD,
654  { &aNameItem });
655 }
656 
657 void ScNavigatorDlg::SetCurrentDoc( const OUString& rDocName ) // activate
658 {
659  SfxStringItem aDocItem( SID_CURRENTDOC, rDocName );
660  rBindings.GetDispatcher()->ExecuteList( SID_CURRENTDOC,
661  SfxCallMode::SYNCHRON | SfxCallMode::RECORD,
662  { &aDocItem });
663 }
664 
666 {
667  ScTabViewShell* pViewSh = GetTabViewShell();
668  if( !pViewSh )
669  return;
670 
671  uno::Reference< drawing::XShapes > xShapes = pViewSh->getSelectedXShapes();
672  if( !xShapes )
673  return;
674 
675  uno::Reference< container::XIndexAccess > xIndexAccess(
676  xShapes, uno::UNO_QUERY_THROW );
677  if( xIndexAccess->getCount() > 1 )
678  return;
679  uno::Reference< drawing::XShape > xShape;
680  if( xIndexAccess->getByIndex(0) >>= xShape )
681  {
682  uno::Reference< container::XNamed > xNamed( xShape, uno::UNO_QUERY_THROW );
683  OUString sName = xNamed->getName();
684  if (!sName.isEmpty())
685  {
686  m_xLbEntries->SelectEntryByName( ScContentId::DRAWING, sName );
687  }
688  }
689 }
690 
692 {
693  return dynamic_cast<ScTabViewShell*>( SfxViewShell::Current() );
694 }
695 
697 {
698  // Don't store the settings pointer here, because the settings belong to
699  // the view, and the view may be closed while the navigator is open (reload).
700  // If the pointer is cached here again later for performance reasons, it has to
701  // be forgotten when the view is closed.
702 
703  ScTabViewShell* pViewSh = GetTabViewShell();
704  return pViewSh ? pViewSh->GetNavigatorSettings() : nullptr;
705 }
706 
708 {
709  ScTabViewShell* pViewSh = GetTabViewShell();
710  pViewData = pViewSh ? &pViewSh->GetViewData() : nullptr;
711  return pViewData;
712 }
713 
715 {
716  if ( pCol )
717  nCurCol = *pCol;
718  else if ( GetViewData() )
719  nCurCol = pViewData->GetCurX() + 1;
720 
721  m_xEdCol->set_value(nCurCol);
722 }
723 
724 void ScNavigatorDlg::UpdateRow( const SCROW* pRow )
725 {
726  if ( pRow )
727  nCurRow = *pRow;
728  else if ( GetViewData() )
729  nCurRow = pViewData->GetCurY() + 1;
730 
731  m_xEdRow->set_value(nCurRow);
732 }
733 
735 {
736  if ( pTab )
737  nCurTab = *pTab;
738  else if ( GetViewData() )
740 }
741 
743 {
744  switch (eListMode)
745  {
746  case NAV_LMODE_AREAS:
747  m_xLbEntries->Refresh();
748  break;
749  case NAV_LMODE_NONE:
751  break;
752  default:
753  break;
754  }
755 
756  aContentIdle.Stop(); // not again
757 }
758 
760 {
761  if (eMode != eListMode)
762  {
763  bool bForceParentResize = SfxChildWindowContext::GetFloatingWindow(GetParent()) &&
764  (eMode == NAV_LMODE_NONE || eListMode == NAV_LMODE_NONE);
765  SfxNavigator* pNav = bForceParentResize ? dynamic_cast<SfxNavigator*>(GetParent()) : nullptr;
766  if (pNav && eMode == NAV_LMODE_NONE) //save last normal size on minimizing
767  aExpandedSize = GetSizePixel();
768 
769  eListMode = eMode;
770 
771  switch (eMode)
772  {
773  case NAV_LMODE_NONE:
774  ShowList(false);
775  break;
776  case NAV_LMODE_AREAS:
777  m_xLbEntries->Refresh();
778  ShowList(true);
779  break;
780  case NAV_LMODE_SCENARIOS:
781  ShowScenarios();
782  break;
783  }
784 
785  UpdateButtons();
786 
787  if (eMode != NAV_LMODE_NONE)
788  {
789  ScNavipiCfg& rCfg = SC_MOD()->GetNavipiCfg();
790  rCfg.SetListMode( static_cast<sal_uInt16>(eMode) );
791  }
792 
793  if (pNav)
794  {
795  Size aOptimalSize(GetOptimalSize());
796  Size aNewSize(pNav->GetOutputSizePixel());
797  aNewSize.setHeight( eMode == NAV_LMODE_NONE ? aOptimalSize.Height() : aExpandedSize.Height() );
798  pNav->SetMinOutputSizePixel(aOptimalSize);
799  pNav->SetOutputSizePixel(aNewSize);
800  }
801  }
802 
803  if (pMarkArea)
804  UnmarkDataArea();
805 }
806 
807 void ScNavigatorDlg::ShowList(bool bShow)
808 {
809  if (bShow)
810  {
811  m_xLbEntries->show();
812  m_xLbDocuments->show();
813  }
814  else
815  {
816  m_xLbEntries->hide();
817  m_xLbDocuments->hide();
818  }
819  m_xScenarioBox->hide();
820 }
821 
823 {
824  rBindings.Invalidate( SID_SELECT_SCENARIO );
825  rBindings.Update( SID_SELECT_SCENARIO );
826 
827  m_xScenarioBox->show();
828  m_xLbDocuments->show();
829  m_xLbEntries->hide();
830 }
831 
832 // documents for Dropdown-Listbox
833 void ScNavigatorDlg::GetDocNames( const OUString* pManualSel )
834 {
835  m_xLbDocuments->clear();
836  m_xLbDocuments->freeze();
837 
838  ScDocShell* pCurrentSh = dynamic_cast<ScDocShell*>( SfxObjectShell::Current() );
839 
840  OUString aSelEntry;
842  while ( pSh )
843  {
844  if ( dynamic_cast<const ScDocShell*>( pSh) != nullptr )
845  {
846  OUString aName = pSh->GetTitle();
847  OUString aEntry = aName;
848  if (pSh == pCurrentSh)
849  aEntry += aStrActive;
850  else
851  aEntry += aStrNotActive;
852  m_xLbDocuments->append_text(aEntry);
853 
854  if ( pManualSel ? ( aName == *pManualSel )
855  : ( pSh == pCurrentSh ) )
856  aSelEntry = aEntry; // complete entry for selection
857  }
858 
859  pSh = SfxObjectShell::GetNext( *pSh );
860  }
861 
862  m_xLbDocuments->append_text(aStrActiveWin);
863 
864  OUString aHidden = m_xLbEntries->GetHiddenTitle();
865  if (!aHidden.isEmpty())
866  {
867  OUString aEntry = aHidden + aStrHidden;
868  m_xLbDocuments->append_text(aEntry);
869 
870  if ( pManualSel && aHidden == *pManualSel )
871  aSelEntry = aEntry;
872  }
873 
874  m_xLbDocuments->thaw();
875 
876  m_xLbDocuments->set_active_text(aSelEntry);
877 }
878 
880 {
881  ScTabViewShell* pViewSh = GetTabViewShell();
882 
883  if ( !pViewSh )
884  return;
885 
886  if ( !pMarkArea )
887  pMarkArea.reset( new ScArea );
888 
889  pViewSh->MarkDataArea();
890  ScRange aMarkRange;
891  pViewSh->GetViewData().GetMarkData().GetMarkArea(aMarkRange);
892  pMarkArea->nColStart = aMarkRange.aStart.Col();
893  pMarkArea->nRowStart = aMarkRange.aStart.Row();
894  pMarkArea->nColEnd = aMarkRange.aEnd.Col();
895  pMarkArea->nRowEnd = aMarkRange.aEnd.Row();
896  pMarkArea->nTab = aMarkRange.aStart.Tab();
897 }
898 
900 {
901  ScTabViewShell* pViewSh = GetTabViewShell();
902 
903  if ( pViewSh )
904  {
905  pViewSh->Unmark();
906  pMarkArea.reset();
907  }
908 }
909 
911 {
912  // pMarkArea evaluate ???
913 
914  if ( GetViewData() )
915  {
916  ScMarkData& rMark = pViewData->GetMarkData();
917  ScRange aMarkRange;
918  rMark.GetMarkArea( aMarkRange );
919 
920  SCCOL nCol = aMarkRange.aStart.Col();
921  SCROW nRow = aMarkRange.aStart.Row();
922 
923  if ( (nCol+1 != m_xEdCol->get_value()) || (nRow+1 != m_xEdRow->get_value()) )
924  SetCurrentCell( nCol, nRow );
925  }
926 }
927 
929 {
930  // pMarkArea evaluate ???
931 
932  if ( GetViewData() )
933  {
934  ScMarkData& rMark = pViewData->GetMarkData();
935  ScRange aMarkRange;
936  rMark.GetMarkArea( aMarkRange );
937 
938  SCCOL nCol = aMarkRange.aEnd.Col();
939  SCROW nRow = aMarkRange.aEnd.Row();
940 
941  if ( (nCol+1 != m_xEdCol->get_value()) || (nRow+1 != m_xEdRow->get_value()) )
942  SetCurrentCell( nCol, nRow );
943  }
944 }
945 
946 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ScMarkData & GetMarkData()
Definition: viewdata.cxx:3046
std::unique_ptr< weld::ComboBox > m_xLbDocuments
Definition: navipi.hxx:105
sal_uInt16 GetDragMode() const
Definition: navicfg.hxx:42
SC_DLLPUBLIC void Format(OStringBuffer &r, ScRefFlags nFlags, const ScDocument *pDocument=nullptr, const Details &rDetails=detailsOOOa1) const
Definition: address.cxx:2107
void MarkDataArea(bool bIncludeCursor=true)
Definition: tabview3.cxx:1651
const SfxPoolItem * ExecuteList(sal_uInt16 nSlot, SfxCallMode nCall, std::initializer_list< SfxPoolItem const * > args, std::initializer_list< SfxPoolItem const * > internalargs=std::initializer_list< SfxPoolItem const * >())
SfxHintId
ScAddress aStart
Definition: address.hxx:500
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
Definition: markdata.hxx:43
void SetMinOutputSizePixel(const Size &rSize)
FactoryFunction GetUITestFactory() const override
Definition: navipi.cxx:445
SCROW Row() const
Definition: address.hxx:262
void SetCurrentTable(SCTAB nTab)
Definition: navipi.cxx:602
OUString GetTitle(sal_uInt16 nMaxLen=0) const
ScViewData * pViewData
Definition: navipi.hxx:117
std::unique_ptr< ContentProperties > pData
void UpdateSheetLimits()
Definition: navipi.cxx:422
SCROW nCurRow
Definition: navipi.hxx:122
SCCOL GetMaxColCount() const
Definition: sheetlimits.hxx:63
SCROW GetCurY() const
Definition: viewdata.hxx:402
void EndOfDataArea()
Definition: navipi.cxx:928
void UpdateTable(const SCTAB *pTab)
Definition: navipi.cxx:734
void ScColToAlpha(OUStringBuffer &rBuf, SCCOL nCol)
append alpha representation of column to buffer
Definition: address.cxx:1917
std::function< std::unique_ptr< UIObject >vcl::Window *)> FactoryFunction
SCTAB GetTabNo() const
Definition: viewdata.hxx:395
OUString aStrNotActive
Definition: navipi.hxx:112
Contains settings of the navigator listbox.
Definition: navsett.hxx:30
void Unmark()
Definition: tabview3.cxx:1718
ScAddress aEnd
Definition: address.hxx:501
ScDocument & GetDocument() const
Definition: viewdata.hxx:380
static SfxObjectShell * Current()
std::unique_ptr< weld::SpinButton > m_xEdCol
Definition: navipi.hxx:98
void Invalidate(sal_uInt16 nId)
SCROW GetMaxRowCount() const
Definition: sheetlimits.hxx:61
SfxHintId GetId() const
void GetDocNames(const OUString *pSelEntry)
Definition: navipi.cxx:833
void fill(V val)
virtual Size GetOptimalSize() const override
bool IsCellMarked(SCCOL nCol, SCROW nRow, bool bNoSimple=false) const
Definition: markdata.cxx:285
SfxApplication * SfxGetpApp()
css::uno::Reference< css::drawing::XShapes > getSelectedXShapes()
Definition: viewuno.cxx:825
void GetMarkArea(ScRange &rRange) const
Definition: markdata.cxx:112
void UpdateAll()
Definition: navipi.cxx:742
StateChangedType
void StartOfDataArea()
Definition: navipi.cxx:910
o3tl::enumarray< ScContentId, bool > maExpandedVec
Definition: navsett.hxx:33
SCCOL nCurCol
Definition: navipi.hxx:121
SC_DLLPUBLIC SCTAB GetTableCount() const
Definition: document.cxx:314
int nCount
static SfxViewShell * Current()
virtual void Start() override
Mode eMode
SCTAB Tab() const
Definition: address.hxx:271
void SetCurrentObject(const OUString &rName)
Definition: navipi.cxx:649
const char * sName
ScViewData & GetViewData()
Definition: tabview.hxx:332
void ShowScenarios()
Definition: navipi.cxx:822
std::unique_ptr< ScScenarioWindow > m_xWndScenarios
Definition: navipi.hxx:104
virtual void StateChanged(StateChangedType nStateChange) override
Definition: navipi.cxx:433
std::unique_ptr< ScArea > pMarkArea
Definition: navipi.hxx:116
OUString aStrActiveWin
Definition: navipi.hxx:114
std::unique_ptr< weld::Toolbar > m_xTbxCmd2
Definition: navipi.hxx:101
ScContentId GetRootType() const
Definition: navicfg.hxx:44
int i
NavListMode eListMode
Definition: navipi.hxx:119
sal_Int16 SCCOL
Definition: types.hxx:22
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Definition: navipi.cxx:478
#define SC_MOD()
Definition: scmod.hxx:253
Idle aContentIdle
Definition: navipi.hxx:109
void UpdateButtons()
Definition: navipi.cxx:270
ScSheetLimits & GetSheetLimits() const
Definition: document.hxx:874
ScNavigatorSettings * GetNavigatorSettings()
Definition: tabvwsh4.cxx:1827
static ScTabViewShell * GetTabViewShell()
Definition: navipi.cxx:691
tools::Long Width() const
void ShowList(bool bShow)
Definition: navipi.cxx:807
OUString ScResId(const char *pId)
Definition: scdll.cxx:95
void SetDragMode(sal_uInt16 nNew)
Definition: navicfg.cxx:42
void SetCurrentDoc(const OUString &rDocName)
Definition: navipi.cxx:657
void UpdateRow(const SCROW *pRow=nullptr)
Definition: navipi.cxx:724
void StartListening(SfxBroadcaster &rBroadcaster, DuplicateHandling eDuplicateHanding=DuplicateHandling::Unexpected)
ScContentId
Definition: content.hxx:35
void GrabFocus()
std::array< std::unique_ptr< ScNavigatorControllerItem >, CTRL_ITEMS > mvBoundItems
Definition: navipi.hxx:125
ScNavigatorDlg(SfxBindings *pB, vcl::Window *pParent)
Definition: navipi.cxx:326
SCCOL Col() const
Definition: address.hxx:267
void SetCurrentCellStr(const OUString &rName)
Definition: navipi.cxx:592
void UnmarkDataArea()
Definition: navipi.cxx:899
virtual void dispose() override
Definition: navipi.cxx:455
friend class ScNavigatorControllerItem
Definition: navipi.hxx:88
void Update(sal_uInt16 nId)
virtual void dispose() override
bool AlphaToCol(const ScDocument &rDoc, SCCOL &rCol, const OUString &rStr)
get column number of A..IV... string
Definition: address.cxx:2532
sal_Int32 SCROW
Definition: types.hxx:18
std::unique_ptr< weld::Widget > m_xScenarioBox
Definition: navipi.hxx:103
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
Definition: uiobject.cxx:399
static ScNavigatorSettings * GetNavigatorSettings()
Definition: navipi.cxx:696
void Stop()
SC_DLLPUBLIC bool IsScenario(SCTAB nTab) const
Definition: documen3.cxx:427
void UpdateSelection()
Definition: navipi.cxx:665
OUString aStrHidden
Definition: navipi.hxx:113
static SfxObjectShell * GetFirst(const std::function< bool(const SfxObjectShell *)> &isObjectShell=nullptr, bool bOnlyVisible=true)
std::unique_ptr< weld::Menu > m_xDragModeMenu
Definition: navipi.hxx:106
ScNavigatorSettings()
Index of selected child entry.
Definition: navipi.cxx:305
OUString aName
std::unique_ptr< ScContentTree > m_xLbEntries
Definition: navipi.hxx:102
static VclPtr< reference_type > Create(Arg &&...arg)
SfxBindings & rBindings
Definition: navipi.hxx:96
#define SFX_IMPL_CHILDWINDOWCONTEXT(Class, MyID)
void EndListening(SfxBroadcaster &rBroadcaster, bool bRemoveAllDuplicates=false)
void SetCurrentCell(SCCOL nCol, SCROW Row)
Definition: navipi.cxx:568
sal_uInt16 GetListMode() const
Definition: navicfg.hxx:40
tools::Long Height() const
void * p
void SetInvokeHandler(const Link< Timer *, void > &rLink)
vcl::Window * GetWindow() const
static FloatingWindow * GetFloatingWindow(vcl::Window *pParent)
static bool isAsciiNumeric(const OUString &rStr)
ROOT
void setHeight(tools::Long nHeight)
void SetDropMode(sal_uInt16 nNew)
Definition: navipi.cxx:560
SfxDispatcher * GetDispatcher() const
Any result
static SfxObjectShell * GetNext(const SfxObjectShell &rPrev, const std::function< bool(const SfxObjectShell *)> &isObjectShell=nullptr, bool bOnlyVisible=true)
void SetPriority(TaskPriority ePriority)
static void ReleaseFocus()
Definition: navipi.cxx:65
std::unique_ptr< weld::SpinButton > m_xEdRow
Definition: navipi.hxx:99
void SetListMode(NavListMode eMode)
Definition: navipi.cxx:759
ScViewData * GetViewData()
Definition: navipi.cxx:707
void UpdateColumn(const SCCOL *pCol=nullptr)
Definition: navipi.cxx:714
virtual ~ScNavigatorDlg() override
Definition: navipi.cxx:450
static bool isAsciiAlpha(const OUString &rStr)
OUString aStrActive
Definition: navipi.hxx:111
aStr
SC_DLLPUBLIC bool GetName(SCTAB nTab, OUString &rName) const
Definition: document.cxx:213
Size aExpandedSize
Definition: navipi.hxx:108
void MarkDataArea()
Definition: navipi.cxx:879
sal_uInt16 nDropMode
Definition: navipi.hxx:120
SCTAB nCurTab
Definition: navipi.hxx:123
sal_Int16 SCTAB
Definition: types.hxx:23
void SetListMode(sal_uInt16 nNew)
Definition: navicfg.cxx:33
SCCOL GetCurX() const
Definition: viewdata.hxx:401
const sal_uLong SC_CONTENT_NOCHILD
Definition: content.hxx:41
std::unique_ptr< weld::Toolbar > m_xTbxCmd1
Definition: navipi.hxx:100
void SetCurrentTableStr(const OUString &rName)
Definition: navipi.cxx:614