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 OUString&, 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 OUString&, 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 OUString&, rIdent, void)
259{
260 if (rIdent == u"hyperlink")
261 SetDropMode(0);
262 else if (rIdent == u"link")
263 SetDropMode(1);
264 else if (rIdent == u"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
428 {
429 m_xBuilder->weld_container("gridbuttons")->hide();
430 m_xLbDocuments->hide();
431 }
432}
433
435{
436 if (m_xNavigatorDlg)
437 return m_xNavigatorDlg->GetFrameWeld();
439}
440
442{
444 {
445 ScDocument& rDoc = pData->GetDocument();
446 m_xEdRow->set_range(1, SCNAV_MAXROW(rDoc.GetSheetLimits()));
447 m_xEdCol->set_range(1, SCNAV_MAXCOL(rDoc.GetSheetLimits()));
448 m_xEdCol->set_width_chars(SCNAV_COLDIGITS(rDoc.GetSheetLimits())); // 1...256...18278 or A...IV...ZZZ
449 }
450}
451
453{
454 // When the navigator is displayed in the sidebar, or is otherwise
455 // docked, it has the whole deck to fill. Therefore hide the button that
456 // hides all controls below the top two rows of buttons.
457 m_xTbxCmd1->set_item_visible("contents", ParentIsFloatingWindow(m_xNavigatorDlg));
458}
459
461{
462 SfxNavigator::StateChanged(nStateChange);
463 if (nStateChange == StateChangedType::InitShow)
464 m_xNavigator->UpdateInitShow();
465}
466
468{
470
471 for (auto & p : mvBoundItems)
472 p.reset();
473 moMarkArea.reset();
474
475 EndListening( *(SfxGetpApp()) );
477
478 m_xEdCol.reset();
479 m_xEdRow.reset();
480 m_xTbxCmd1.reset();
481 m_xTbxCmd2.reset();
482 m_xDragModeMenu.reset();
483 m_xLbEntries.reset();
484 m_xWndScenarios.reset();
485 m_xScenarioBox.reset();
486 m_xLbDocuments.reset();
487}
488
490{
491 if (const SfxEventHint* pHint = dynamic_cast<const SfxEventHint*>(&rHint))
492 {
493 if (pHint->GetEventId() == SfxEventHintId::ActivateDoc)
494 {
496 bool bRefreshed = m_xLbEntries->ActiveDocChanged();
497 // UpdateAll just possibly calls Refresh (and always
498 // ContentUpdated) so if ActiveDocChanged already called Refresh
499 // skip re-calling it
500 if (bRefreshed)
502 else
503 UpdateAll();
504 }
505 }
506 else
507 {
508 const SfxHintId nHintId = rHint.GetId();
509
510 if (nHintId == SfxHintId::ScDocNameChanged)
511 {
512 m_xLbEntries->ActiveDocChanged();
513 }
514 else if (NAV_LMODE_NONE == eListMode)
515 {
516 // Table not any more
517 }
518 else
519 {
520 switch ( nHintId )
521 {
522 case SfxHintId::ScTablesChanged:
524 break;
525
526 case SfxHintId::ScDbAreasChanged:
528 break;
529
530 case SfxHintId::ScAreasChanged:
532 break;
533
534 case SfxHintId::ScDrawChanged:
538 break;
539
540 case SfxHintId::ScAreaLinksChanged:
542 break;
543
544 // SfxHintId::DocChanged not only at document change
545
546 case SfxHintId::ScNavigatorUpdateAll:
547 UpdateAll();
548 break;
549
550 case SfxHintId::ScDataChanged:
551 case SfxHintId::ScAnyDataChanged:
552 aContentIdle.Start(); // Do not search notes immediately
553 break;
554 case SfxHintId::ScSelectionChanged:
556 break;
557 default:
558 break;
559 }
560 }
561 }
562}
563
564IMPL_LINK( ScNavigatorDlg, TimeHdl, Timer*, pIdle, void )
565{
566 if ( pIdle != &aContentIdle )
567 return;
568
569 m_xLbEntries->Refresh( ScContentId::NOTE );
570}
571
572void ScNavigatorDlg::SetDropMode(sal_uInt16 nNew)
573{
574 nDropMode = nNew;
576 ScNavipiCfg& rCfg = SC_MOD()->GetNavipiCfg();
578}
579
581{
582 if ((nColNo+1 == nCurCol) && (nRowNo+1 == nCurRow))
583 return;
584
585 // SID_CURRENTCELL == Item #0 clear cache, so it's possible
586 // setting the current cell even in combined areas
587 mvBoundItems[0]->ClearCache();
588
589 ScAddress aScAddress( nColNo, nRowNo, 0 );
590 OUString aAddr(aScAddress.Format(ScRefFlags::ADDR_ABS));
591
592 bool bUnmark = false;
593 if ( GetViewData() )
594 bUnmark = !pViewData->GetMarkData().IsCellMarked( nColNo, nRowNo );
595
596 SfxStringItem aPosItem( SID_CURRENTCELL, aAddr );
597 SfxBoolItem aUnmarkItem( FN_PARAM_1, bUnmark ); // cancel selection
598
599 rBindings.GetDispatcher()->ExecuteList(SID_CURRENTCELL,
600 SfxCallMode::SYNCHRON | SfxCallMode::RECORD,
601 { &aPosItem, &aUnmarkItem });
602}
603
604void ScNavigatorDlg::SetCurrentCellStr( const OUString& rName )
605{
606 mvBoundItems[0]->ClearCache();
607 SfxStringItem aNameItem( SID_CURRENTCELL, rName );
608
609 rBindings.GetDispatcher()->ExecuteList(SID_CURRENTCELL,
610 SfxCallMode::SYNCHRON | SfxCallMode::RECORD,
611 { &aNameItem });
612}
613
615{
616 if ( nTabNo != nCurTab )
617 {
618 // Table for basic is base-1
619 SfxUInt16Item aTabItem( SID_CURRENTTAB, static_cast<sal_uInt16>(nTabNo) + 1 );
620 rBindings.GetDispatcher()->ExecuteList(SID_CURRENTTAB,
621 SfxCallMode::SYNCHRON | SfxCallMode::RECORD,
622 { &aTabItem });
623 }
624}
625
626void ScNavigatorDlg::SetCurrentTableStr( std::u16string_view rName )
627{
628 if (!GetViewData()) return;
629
631 SCTAB nCount = rDoc.GetTableCount();
632 OUString aTabName;
633 SCTAB nLastSheet = 0;
634
635 for (SCTAB i = 0; i<nCount; i++)
636 {
637 rDoc.GetName(i, aTabName);
638 if (aTabName == rName)
639 {
640 // Check if this is a Scenario sheet and if so select the sheet
641 // where it belongs to, which is the previous non-Scenario sheet.
642 if (rDoc.IsScenario(i))
643 {
644 SetCurrentTable(nLastSheet);
645 return;
646 }
647 else
648 {
650 return;
651 }
652 }
653 else
654 {
655 if (!rDoc.IsScenario(i))
656 nLastSheet = i;
657 }
658 }
659}
660
661void ScNavigatorDlg::SetCurrentObject( const OUString& rName )
662{
663 SfxStringItem aNameItem( SID_CURRENTOBJECT, rName );
664 rBindings.GetDispatcher()->ExecuteList( SID_CURRENTOBJECT,
665 SfxCallMode::SYNCHRON | SfxCallMode::RECORD,
666 { &aNameItem });
667}
668
669void ScNavigatorDlg::SetCurrentDoc( const OUString& rDocName ) // activate
670{
671 SfxStringItem aDocItem( SID_CURRENTDOC, rDocName );
672 rBindings.GetDispatcher()->ExecuteList( SID_CURRENTDOC,
673 SfxCallMode::SYNCHRON | SfxCallMode::RECORD,
674 { &aDocItem });
675}
676
678{
679 ScTabViewShell* pViewSh = GetTabViewShell();
680 if( !pViewSh )
681 return;
682
683 uno::Reference< drawing::XShapes > xShapes = pViewSh->getSelectedXShapes();
684 if( !xShapes )
685 return;
686
687 uno::Reference< container::XIndexAccess > xIndexAccess(
688 xShapes, uno::UNO_QUERY_THROW );
689 if( xIndexAccess->getCount() > 1 )
690 return;
691 uno::Reference< drawing::XShape > xShape;
692 if( xIndexAccess->getByIndex(0) >>= xShape )
693 {
694 uno::Reference< container::XNamed > xNamed( xShape, uno::UNO_QUERY_THROW );
695 OUString sName = xNamed->getName();
696 if (!sName.isEmpty())
697 {
698 m_xLbEntries->SelectEntryByName( ScContentId::DRAWING, sName );
699 }
700 }
701}
702
704{
705 return dynamic_cast<ScTabViewShell*>( SfxViewShell::Current() );
706}
707
709{
710 // Don't store the settings pointer here, because the settings belong to
711 // the view, and the view may be closed while the navigator is open (reload).
712 // If the pointer is cached here again later for performance reasons, it has to
713 // be forgotten when the view is closed.
714
715 ScTabViewShell* pViewSh = GetTabViewShell();
716 return pViewSh ? pViewSh->GetNavigatorSettings() : nullptr;
717}
718
720{
721 ScTabViewShell* pViewSh = GetTabViewShell();
722 pViewData = pViewSh ? &pViewSh->GetViewData() : nullptr;
723 return pViewData;
724}
725
727{
728 if ( pCol )
729 nCurCol = *pCol;
730 else if ( GetViewData() )
731 nCurCol = pViewData->GetCurX() + 1;
732
733 m_xEdCol->set_value(nCurCol);
734}
735
737{
738 if ( pRow )
739 nCurRow = *pRow;
740 else if ( GetViewData() )
741 nCurRow = pViewData->GetCurY() + 1;
742
743 m_xEdRow->set_value(nCurRow);
744}
745
747{
748 if ( pTab )
749 nCurTab = *pTab;
750 else if ( GetViewData() )
752}
753
755{
756 switch (eListMode)
757 {
758 case NAV_LMODE_AREAS:
759 m_xLbEntries->Refresh();
760 break;
761 case NAV_LMODE_NONE:
763 break;
764 default:
765 break;
766 }
767 ContentUpdated(); // not again
768}
769
771{
773}
774
776{
777 if (eMode != eListMode)
778 {
779 bool bForceParentResize = ParentIsFloatingWindow(m_xNavigatorDlg) &&
781 SfxNavigator* pNav = bForceParentResize ? m_xNavigatorDlg.get() : nullptr;
782 if (pNav && eMode == NAV_LMODE_NONE) //save last normal size on minimizing
783 aExpandedSize = pNav->GetSizePixel();
784
786
787 switch (eMode)
788 {
789 case NAV_LMODE_NONE:
790 ShowList(false);
791 break;
792 case NAV_LMODE_AREAS:
793 m_xLbEntries->Refresh();
794 ShowList(true);
795 break;
798 break;
799 }
800
802
803 if (eMode != NAV_LMODE_NONE)
804 {
805 ScNavipiCfg& rCfg = SC_MOD()->GetNavipiCfg();
806 rCfg.SetListMode( static_cast<sal_uInt16>(eMode) );
807 }
808
809 if (pNav)
810 {
811 pNav->InvalidateChildSizeCache();
812 Size aOptimalSize(pNav->GetOptimalSize());
813 Size aNewSize(pNav->GetOutputSizePixel());
814 aNewSize.setHeight( eMode == NAV_LMODE_NONE ? aOptimalSize.Height() : aExpandedSize.Height() );
815 pNav->SetMinOutputSizePixel(aOptimalSize);
816 pNav->SetOutputSizePixel(aNewSize);
817 }
818 }
819
820 if (moMarkArea)
822}
823
825{
826 if (bShow)
827 {
828 m_xLbEntries->show();
829 m_xLbDocuments->show();
830 }
831 else
832 {
833 m_xLbEntries->hide();
834 m_xLbDocuments->hide();
835 }
836 m_xScenarioBox->hide();
837}
838
840{
841 rBindings.Invalidate( SID_SELECT_SCENARIO );
842 rBindings.Update( SID_SELECT_SCENARIO );
843
844 m_xScenarioBox->show();
845 m_xLbDocuments->show();
846 m_xLbEntries->hide();
847}
848
849// documents for Dropdown-Listbox
850void ScNavigatorDlg::GetDocNames( const OUString* pManualSel )
851{
852 m_xLbDocuments->clear();
853 m_xLbDocuments->freeze();
854
855 ScDocShell* pCurrentSh = dynamic_cast<ScDocShell*>( SfxObjectShell::Current() );
856
857 OUString aSelEntry;
859 while ( pSh )
860 {
861 if ( dynamic_cast<const ScDocShell*>( pSh) != nullptr )
862 {
863 OUString aName = pSh->GetTitle();
864 OUString aEntry = aName;
865 if (pSh == pCurrentSh)
866 aEntry += aStrActive;
867 else
868 aEntry += aStrNotActive;
869 m_xLbDocuments->append_text(aEntry);
870
871 if ( pManualSel ? ( aName == *pManualSel )
872 : ( pSh == pCurrentSh ) )
873 aSelEntry = aEntry; // complete entry for selection
874 }
875
876 pSh = SfxObjectShell::GetNext( *pSh );
877 }
878
879 m_xLbDocuments->append_text(aStrActiveWin);
880
881 OUString aHidden = m_xLbEntries->GetHiddenTitle();
882 if (!aHidden.isEmpty())
883 {
884 OUString aEntry = aHidden + aStrHidden;
885 m_xLbDocuments->append_text(aEntry);
886
887 if ( pManualSel && aHidden == *pManualSel )
888 aSelEntry = aEntry;
889 }
890
891 m_xLbDocuments->thaw();
892
893 m_xLbDocuments->set_active_text(aSelEntry);
894}
895
897{
898 ScTabViewShell* pViewSh = GetTabViewShell();
899
900 if ( !pViewSh )
901 return;
902
903 if ( !moMarkArea )
904 moMarkArea.emplace();
905
906 pViewSh->MarkDataArea();
907 const ScRange& aMarkRange = pViewSh->GetViewData().GetMarkData().GetMarkArea();
908 moMarkArea->nColStart = aMarkRange.aStart.Col();
909 moMarkArea->nRowStart = aMarkRange.aStart.Row();
910 moMarkArea->nColEnd = aMarkRange.aEnd.Col();
911 moMarkArea->nRowEnd = aMarkRange.aEnd.Row();
912 moMarkArea->nTab = aMarkRange.aStart.Tab();
913}
914
916{
917 ScTabViewShell* pViewSh = GetTabViewShell();
918
919 if ( pViewSh )
920 {
921 pViewSh->Unmark();
922 moMarkArea.reset();
923 }
924}
925
927{
928 // pMarkArea evaluate ???
929
930 if ( GetViewData() )
931 {
932 ScMarkData& rMark = pViewData->GetMarkData();
933 const ScRange& aMarkRange = rMark.GetMarkArea();
934
935 SCCOL nCol = aMarkRange.aStart.Col();
936 SCROW nRow = aMarkRange.aStart.Row();
937
938 if ( (nCol+1 != m_xEdCol->get_value()) || (nRow+1 != m_xEdRow->get_value()) )
939 SetCurrentCell( nCol, nRow );
940 }
941}
942
944{
945 // pMarkArea evaluate ???
946
947 if ( GetViewData() )
948 {
949 ScMarkData& rMark = pViewData->GetMarkData();
950 const ScRange& aMarkRange = rMark.GetMarkArea();
951
952 SCCOL nCol = aMarkRange.aEnd.Col();
953 SCROW nRow = aMarkRange.aEnd.Row();
954
955 if ( (nCol+1 != m_xEdCol->get_value()) || (nRow+1 != m_xEdRow->get_value()) )
956 SetCurrentCell( nCol, nRow );
957 }
958}
959
961
963 SfxBindings* pBindings, SfxChildWinInfo* pInfo)
964 : SfxNavigatorWrapper(_pParent, nId)
965{
966 SetWindow(VclPtr<ScNavigatorWin>::Create(pBindings, this, _pParent, pInfo));
967 Initialize();
968}
969
970/* 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:2509
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
std::unique_ptr< weld::Builder > m_xBuilder
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:432
ScSheetLimits & GetSheetLimits() const
Definition: document.hxx:898
SC_DLLPUBLIC bool GetName(SCTAB nTab, OUString &rName) const
Definition: document.cxx:204
SC_DLLPUBLIC SCTAB GetTableCount() const
Definition: document.cxx:297
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:580
std::unique_ptr< weld::Widget > m_xScenarioBox
Definition: navipi.hxx:102
void StartOfDataArea()
Definition: navipi.cxx:926
void EndOfDataArea()
Definition: navipi.cxx:943
void SetListMode(NavListMode eMode)
Definition: navipi.cxx:775
void UpdateColumn(const SCCOL *pCol=nullptr)
Definition: navipi.cxx:726
void UpdateSheetLimits()
Definition: navipi.cxx:441
ScViewData * GetViewData()
Definition: navipi.cxx:719
VclPtr< SfxNavigator > m_xNavigatorDlg
Definition: navipi.hxx:107
virtual weld::Window * GetFrameWeld() const override
Definition: navipi.cxx:434
void ContentUpdated()
Definition: navipi.cxx:770
std::unique_ptr< ScContentTree > m_xLbEntries
Definition: navipi.hxx:101
void SetDropMode(sal_uInt16 nNew)
Definition: navipi.cxx:572
static ScNavigatorSettings * GetNavigatorSettings()
Definition: navipi.cxx:708
OUString aStrActiveWin
Definition: navipi.hxx:115
void UnmarkDataArea()
Definition: navipi.cxx:915
OUString aStrNotActive
Definition: navipi.hxx:113
void UpdateAll()
Definition: navipi.cxx:754
void MarkDataArea()
Definition: navipi.cxx:896
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:703
std::unique_ptr< weld::SpinButton > m_xEdCol
Definition: navipi.hxx:97
friend class ScNavigatorControllerItem
Definition: navipi.hxx:89
std::optional< ScArea > moMarkArea
Definition: navipi.hxx:117
std::unique_ptr< weld::Toolbar > m_xTbxCmd1
Definition: navipi.hxx:99
void SetCurrentTable(SCTAB nTab)
Definition: navipi.cxx:614
void SetCurrentTableStr(std::u16string_view rName)
Definition: navipi.cxx:626
void SetCurrentCellStr(const OUString &rName)
Definition: navipi.cxx:604
void GetDocNames(const OUString *pSelEntry)
Definition: navipi.cxx:850
void SetCurrentObject(const OUString &rName)
Definition: navipi.cxx:661
Size aExpandedSize
Definition: navipi.hxx:109
void UpdateTable(const SCTAB *pTab)
Definition: navipi.cxx:746
void UpdateSelection()
Definition: navipi.cxx:677
void ShowList(bool bShow)
Definition: navipi.cxx:824
void ShowScenarios()
Definition: navipi.cxx:839
SCROW nCurRow
Definition: navipi.hxx:123
virtual ~ScNavigatorDlg() override
Definition: navipi.cxx:467
Idle aContentIdle
Definition: navipi.hxx:110
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:669
std::unique_ptr< weld::Menu > m_xDragModeMenu
Definition: navipi.hxx:105
void UpdateInitShow()
Definition: navipi.cxx:452
void UpdateRow(const SCROW *pRow=nullptr)
Definition: navipi.cxx:736
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:489
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:460
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:962
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:1893
css::uno::Reference< css::drawing::XShapes > getSelectedXShapes()
Definition: viewuno.cxx:824
void MarkDataArea(bool bIncludeCursor=true)
Definition: tabview3.cxx:1677
ScViewData & GetViewData()
Definition: tabview.hxx:344
void Unmark()
Definition: tabview3.cxx:1744
ScMarkData & GetMarkData()
Definition: viewdata.cxx:3146
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
float u
OUString sName
SfxHintId
OUString aName
Mode eMode
void * p
aStr
std::unique_ptr< sal_Int32[]> pData
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:247
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