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