LibreOffice Module sc (master)  1
tabvwsh3.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/bindings.hxx>
21 #include <sfx2/dispatch.hxx>
22 #include <sfx2/passwd.hxx>
23 #include <sfx2/request.hxx>
24 #include <sfx2/sidebar/Sidebar.hxx>
25 #include <svl/ptitem.hxx>
26 #include <svl/stritem.hxx>
27 #include <tools/urlobj.hxx>
28 #include <sfx2/objface.hxx>
29 #include <vcl/vclenum.hxx>
30 #include <vcl/uitest/logger.hxx>
32 
33 #include <globstr.hrc>
34 #include <strings.hrc>
35 #include <scmod.hxx>
36 #include <appoptio.hxx>
37 #include <tabvwsh.hxx>
38 #include <document.hxx>
39 #include <sc.hrc>
40 #include <helpids.h>
41 #include <inputwin.hxx>
42 #include <scresid.hxx>
43 #include <docsh.hxx>
44 #include <rangeutl.hxx>
45 #include <reffact.hxx>
46 #include <tabprotection.hxx>
47 #include <protectiondlg.hxx>
48 #include <markdata.hxx>
49 
50 #include <svl/ilstitem.hxx>
51 #include <vector>
52 
53 #include <svx/zoomslideritem.hxx>
54 #include <svx/svxdlg.hxx>
55 #include <comphelper/lok.hxx>
56 #include <comphelper/string.hxx>
57 #include <sfx2/lokhelper.hxx>
58 #include <scabstdlg.hxx>
59 
61 
62 namespace
63 {
64  void collectUIInformation(const OUString& aZoom)
65  {
66  EventDescription aDescription;
67  aDescription.aID = "grid_window";
68  aDescription.aParameters = {{"ZOOM", aZoom}};
69  aDescription.aAction = "SET";
70  aDescription.aKeyWord = "ScGridWinUIObject";
71  aDescription.aParent = "MainWindow";
72  UITestLogger::getInstance().logEvent(aDescription);
73  }
74 
75  enum class DetectFlags
76  {
77  NONE,
78  RANGE,
79  ADDRESS
80  };
81 
82  struct ScRefFlagsAndType
83  {
84  ScRefFlags nResult;
85  DetectFlags eDetected;
86  };
87 
88  ScRefFlagsAndType lcl_ParseRangeOrAddress(ScRange& rScRange, ScAddress& rScAddress,
89  const OUString& aAddress, const ScDocument& rDoc,
90  SCCOL nCurCol, SCROW nCurRow)
91  {
92  ScRefFlagsAndType aRet;
93 
94  // Relative address parsing needs current position.
95  // row,col parameters, not col,row!
96  ScAddress::Details aDetails( rDoc.GetAddressConvention(), nCurRow, nCurCol);
97 
98  // start with the address convention set in the document
99  aRet.nResult = rScRange.Parse(aAddress, rDoc, aDetails);
100  if (aRet.nResult & ScRefFlags::VALID)
101  {
102  aRet.eDetected = DetectFlags::RANGE;
103  return aRet;
104  }
105 
106  aRet.nResult = rScAddress.Parse(aAddress, rDoc, aDetails);
107  if (aRet.nResult & ScRefFlags::VALID)
108  {
109  aRet.eDetected = DetectFlags::ADDRESS;
110  return aRet;
111  }
112 
113  // try the default Calc (A1) address convention
114  aRet.nResult = rScRange.Parse(aAddress, rDoc);
115  if (aRet.nResult & ScRefFlags::VALID)
116  {
117  aRet.eDetected = DetectFlags::RANGE;
118  return aRet;
119  }
120 
121  aRet.nResult = rScAddress.Parse(aAddress, rDoc);
122  if (aRet.nResult & ScRefFlags::VALID)
123  {
124  aRet.eDetected = DetectFlags::ADDRESS;
125  return aRet;
126  }
127 
128  // try the Excel A1 address convention
129  aRet.nResult = rScRange.Parse(aAddress, rDoc, formula::FormulaGrammar::CONV_XL_A1);
130  if (aRet.nResult & ScRefFlags::VALID)
131  {
132  aRet.eDetected = DetectFlags::RANGE;
133  return aRet;
134  }
135 
136  // try the Excel A1 address convention
137  aRet.nResult = rScAddress.Parse(aAddress, rDoc, formula::FormulaGrammar::CONV_XL_A1);
138  if (aRet.nResult & ScRefFlags::VALID)
139  {
140  aRet.eDetected = DetectFlags::ADDRESS;
141  return aRet;
142  }
143 
144  // try Excel R1C1 address convention
145  aDetails.eConv = formula::FormulaGrammar::CONV_XL_R1C1;
146  aRet.nResult = rScRange.Parse(aAddress, rDoc, aDetails);
147  if (aRet.nResult & ScRefFlags::VALID)
148  {
149  aRet.eDetected = DetectFlags::RANGE;
150  return aRet;
151  }
152 
153  aRet.nResult = rScAddress.Parse(aAddress, rDoc, aDetails);
154  if (aRet.nResult & ScRefFlags::VALID)
155  {
156  aRet.eDetected = DetectFlags::ADDRESS;
157  return aRet;
158  }
159 
160  aRet.nResult = ScRefFlags::ZERO;
161  aRet.eDetected = DetectFlags::NONE;
162 
163  return aRet;
164  }
165 }
166 
168 {
169  SfxViewFrame* pThisFrame = GetViewFrame();
170  SfxBindings& rBindings = pThisFrame->GetBindings();
171  ScModule* pScMod = SC_MOD();
172  const SfxItemSet* pReqArgs = rReq.GetArgs();
173  sal_uInt16 nSlot = rReq.GetSlot();
174 
175  if (nSlot != SID_CURRENTCELL) // comes with MouseButtonUp
176  HideListBox(); // Autofilter-DropDown-Listbox
177 
178  switch ( nSlot )
179  {
180  case FID_INSERT_FILE:
181  {
182  const SfxPoolItem* pItem;
183  if ( pReqArgs &&
184  pReqArgs->GetItemState(FID_INSERT_FILE,true,&pItem) == SfxItemState::SET )
185  {
186  OUString aFileName = static_cast<const SfxStringItem*>(pItem)->GetValue();
187 
188  // insert position
189 
190  Point aInsertPos;
191  if ( pReqArgs->GetItemState(FN_PARAM_1,true,&pItem) == SfxItemState::SET )
192  aInsertPos = static_cast<const SfxPointItem*>(pItem)->GetValue();
193  else
194  aInsertPos = GetInsertPos();
195 
196  // as Link?
197 
198  bool bAsLink = false;
199  if ( pReqArgs->GetItemState(FN_PARAM_2,true,&pItem) == SfxItemState::SET )
200  bAsLink = static_cast<const SfxBoolItem*>(pItem)->GetValue();
201 
202  // execute
203 
204  PasteFile( aInsertPos, aFileName, bAsLink );
205  }
206  }
207  break;
208 
209  case SID_OPENDLG_EDIT_PRINTAREA:
210  {
211  sal_uInt16 nId = ScPrintAreasDlgWrapper::GetChildWindowId();
212  SfxChildWindow* pWnd = pThisFrame->GetChildWindow( nId );
213 
214  pScMod->SetRefDialog( nId, pWnd == nullptr );
215  }
216  break;
217 
218  case SID_CHANGE_PRINTAREA:
219  {
220  if ( pReqArgs ) // OK from dialog
221  {
222  OUString aPrintStr;
223  OUString aRowStr;
224  OUString aColStr;
225  bool bEntire = false;
226  const SfxPoolItem* pItem;
227  if ( pReqArgs->GetItemState( SID_CHANGE_PRINTAREA, true, &pItem ) == SfxItemState::SET )
228  aPrintStr = static_cast<const SfxStringItem*>(pItem)->GetValue();
229  if ( pReqArgs->GetItemState( FN_PARAM_2, true, &pItem ) == SfxItemState::SET )
230  aRowStr = static_cast<const SfxStringItem*>(pItem)->GetValue();
231  if ( pReqArgs->GetItemState( FN_PARAM_3, true, &pItem ) == SfxItemState::SET )
232  aColStr = static_cast<const SfxStringItem*>(pItem)->GetValue();
233  if ( pReqArgs->GetItemState( FN_PARAM_4, true, &pItem ) == SfxItemState::SET )
234  bEntire = static_cast<const SfxBoolItem*>(pItem)->GetValue();
235 
236  SetPrintRanges( bEntire, &aPrintStr, &aColStr, &aRowStr, false );
237 
238  rReq.Done();
239  }
240  }
241  break;
242 
243  case SID_ADD_PRINTAREA:
244  case SID_DEFINE_PRINTAREA: // menu or basic
245  {
246  bool bAdd = ( nSlot == SID_ADD_PRINTAREA );
247  if ( pReqArgs )
248  {
249  OUString aPrintStr;
250  const SfxPoolItem* pItem;
251  if ( pReqArgs->GetItemState( SID_DEFINE_PRINTAREA, true, &pItem ) == SfxItemState::SET )
252  aPrintStr = static_cast<const SfxStringItem*>(pItem)->GetValue();
253  SetPrintRanges( false, &aPrintStr, nullptr, nullptr, bAdd );
254  }
255  else
256  {
257  SetPrintRanges( false, nullptr, nullptr, nullptr, bAdd ); // from selection
258  rReq.Done();
259  }
260  }
261  break;
262 
263  case SID_DELETE_PRINTAREA:
264  {
265  // Clear currently defined print range if any, and reset it to
266  // print entire sheet which is the default.
267  OUString aEmpty;
268  SetPrintRanges(true, &aEmpty, nullptr, nullptr, false);
269  rReq.Done();
270  }
271  break;
272 
273  case FID_DEL_MANUALBREAKS:
275  rReq.Done();
276  break;
277 
278  case FID_ADJUST_PRINTZOOM:
279  AdjustPrintZoom();
280  rReq.Done();
281  break;
282 
283  case FID_RESET_PRINTZOOM:
284  SetPrintZoom( 100 ); // 100%, not on pages
285  rReq.Done();
286  break;
287 
288  case SID_FORMATPAGE:
289  case SID_STATUS_PAGESTYLE:
290  case SID_HFEDIT:
292  ExecutePageStyle( *this, rReq, GetViewData().GetTabNo() );
293  break;
294 
295  case SID_JUMPTOMARK:
296  case SID_CURRENTCELL:
297  if ( pReqArgs )
298  {
299  OUString aAddress;
300  const SfxPoolItem* pItem;
301  if ( pReqArgs->GetItemState( nSlot, true, &pItem ) == SfxItemState::SET )
302  aAddress = static_cast<const SfxStringItem*>(pItem)->GetValue();
303  else if ( nSlot == SID_JUMPTOMARK && pReqArgs->GetItemState(
304  SID_JUMPTOMARK, true, &pItem ) == SfxItemState::SET )
305  aAddress = static_cast<const SfxStringItem*>(pItem)->GetValue();
306 
307  // #i14927# SID_CURRENTCELL with a single cell must unmark if FN_PARAM_1
308  // isn't set (for recorded macros, because IsAPI is no longer available).
309  // ScGridWindow::MouseButtonUp no longer executes the slot for a single
310  // cell if there is a multi selection.
311  bool bUnmark = ( nSlot == SID_CURRENTCELL );
312  if ( pReqArgs->GetItemState( FN_PARAM_1, true, &pItem ) == SfxItemState::SET )
313  bUnmark = static_cast<const SfxBoolItem*>(pItem)->GetValue();
314 
315  bool bAlignToCursor = true;
316  if (pReqArgs->GetItemState(FN_PARAM_2, true, &pItem) == SfxItemState::SET)
317  bAlignToCursor = static_cast<const SfxBoolItem*>(pItem)->GetValue();
318 
319  bool bForceGlobalName = false;
320  if (pReqArgs->GetItemState(FN_PARAM_3, true, &pItem) == SfxItemState::SET)
321  bForceGlobalName = static_cast<const SfxBoolItem*>(pItem)->GetValue();
322 
323  if ( nSlot == SID_JUMPTOMARK )
324  {
325  // URL has to be decoded for escaped characters (%20)
326  aAddress = INetURLObject::decode( aAddress,
328  }
329 
330  bool bFound = false;
331  ScViewData& rViewData = GetViewData();
332  ScDocument& rDoc = rViewData.GetDocument();
333  ScMarkData& rMark = rViewData.GetMarkData();
334  ScRange aScRange;
335  ScAddress aScAddress;
336  ScRefFlagsAndType aResult = lcl_ParseRangeOrAddress(aScRange, aScAddress, aAddress, rDoc,
337  rViewData.GetCurX(), rViewData.GetCurY());
338  ScRefFlags nResult = aResult.nResult;
339  SCTAB nTab = rViewData.GetTabNo();
340  bool bMark = true;
341 
342  // Is this a range ?
343  if (aResult.eDetected == DetectFlags::RANGE)
344  {
345  if ( nResult & ScRefFlags::TAB_3D )
346  {
347  if( aScRange.aStart.Tab() != nTab )
348  {
349  nTab = aScRange.aStart.Tab();
350  SetTabNo( nTab );
351  }
352  }
353  else
354  {
355  aScRange.aStart.SetTab( nTab );
356  aScRange.aEnd.SetTab( nTab );
357  }
358  }
359  // Is this a cell ?
360  else if (aResult.eDetected == DetectFlags::ADDRESS)
361  {
362  if ( nResult & ScRefFlags::TAB_3D )
363  {
364  if( aScAddress.Tab() != nTab )
365  {
366  nTab = aScAddress.Tab();
367  SetTabNo( nTab );
368  }
369  }
370  else
371  aScAddress.SetTab( nTab );
372 
373  aScRange = ScRange( aScAddress, aScAddress );
374  // cells should not be marked
375  bMark = false;
376  }
377  // Is it a named area (first named ranges then database ranges)?
378  else
379  {
380  const RutlNameScope eScope = (bForceGlobalName ? RUTL_NAMES_GLOBAL : RUTL_NAMES);
381  ScAddress::Details aDetails( rDoc.GetAddressConvention(), rViewData.GetCurY(), rViewData.GetCurX());
382  if (ScRangeUtil::MakeRangeFromName( aAddress, rDoc, nTab, aScRange, eScope, aDetails, true) ||
383  ScRangeUtil::MakeRangeFromName( aAddress, rDoc, nTab, aScRange, RUTL_DBASE, aDetails, true))
384  {
385  nResult |= ScRefFlags::VALID;
386  if( aScRange.aStart.Tab() != nTab )
387  {
388  nTab = aScRange.aStart.Tab();
389  SetTabNo( nTab );
390  }
391  }
392  }
393 
394  if ( !(nResult & ScRefFlags::VALID) && comphelper::string::isdigitAsciiString(aAddress) )
395  {
396  sal_Int32 nNumeric = aAddress.toInt32();
397  if ( nNumeric > 0 && nNumeric <= rDoc.MaxRow()+1 )
398  {
399  // one-based row numbers
400 
401  aScAddress.SetRow( static_cast<SCROW>(nNumeric - 1) );
402  aScAddress.SetCol( rViewData.GetCurX() );
403  aScAddress.SetTab( nTab );
404  aScRange = ScRange( aScAddress, aScAddress );
405  bMark = false;
406  nResult = ScRefFlags::VALID;
407  }
408  }
409 
410  if ( !rDoc.ValidRow(aScRange.aStart.Row()) || !rDoc.ValidRow(aScRange.aEnd.Row()) )
411  nResult = ScRefFlags::ZERO;
412 
413  // we have found something
414  if( nResult & ScRefFlags::VALID )
415  {
416  bFound = true;
417  SCCOL nCol = aScRange.aStart.Col();
418  SCROW nRow = aScRange.aStart.Row();
419  bool bNothing = ( rViewData.GetCurX()==nCol && rViewData.GetCurY()==nRow );
420 
421  // mark
422  if( bMark )
423  {
424  if (rMark.IsMarked()) // is the same range already marked?
425  {
426  ScRange aOldMark = rMark.GetMarkArea();
427  aOldMark.PutInOrder();
428  ScRange aCurrent = aScRange;
429  aCurrent.PutInOrder();
430  bNothing = ( aCurrent == aOldMark );
431  }
432  else
433  bNothing = false;
434 
435  if (!bNothing)
436  MarkRange( aScRange, false ); // cursor comes after...
437  }
438  else
439  {
440  // remove old selection, unless bUnmark argument is sal_False (from navigator)
441  if( bUnmark )
442  {
443  MoveCursorAbs( nCol, nRow,
444  SC_FOLLOW_NONE, false, false );
445  }
446  }
447 
448  // and set cursor
449 
450  // consider merged cells:
451  rDoc.SkipOverlapped(nCol, nRow, nTab);
452 
453  // navigator calls are not part of the API!!!
454 
455  if( bNothing )
456  {
457  if (rReq.IsAPI())
458  rReq.Ignore(); // if macro, then nothing
459  else
460  rReq.Done(); // then at least paint it
461  }
462  else
463  {
464  rViewData.ResetOldCursor();
465  SetCursor( nCol, nRow );
466  rBindings.Invalidate( SID_CURRENTCELL );
467  rBindings.Update( nSlot );
468 
469  if (!rReq.IsAPI())
470  rReq.Done();
471  }
472 
473  if (bAlignToCursor)
474  {
475  // align to cursor even if the cursor position hasn't changed,
476  // because the cursor may be set outside the visible area.
477  AlignToCursor( nCol, nRow, SC_FOLLOW_JUMP );
478  if ( nSlot == SID_JUMPTOMARK && comphelper::LibreOfficeKit::isActive() )
479  rViewData.GetActiveWin()->notifyKitCellFollowJump();
480  }
481 
482  rReq.SetReturnValue( SfxStringItem( SID_CURRENTCELL, aAddress ) );
483  }
484 
485  if (!bFound) // no valid range
486  {
487  // if it is a sheet name, then switch (for Navigator/URL)
488 
489  SCTAB nNameTab;
490  if ( rDoc.GetTable( aAddress, nNameTab ) )
491  {
492  bFound = true;
493  if ( nNameTab != nTab )
494  SetTabNo( nNameTab );
495  }
496  }
497 
498  if ( !bFound && nSlot == SID_JUMPTOMARK )
499  {
500  // test graphics objects (only for URL)
501 
502  bFound = SelectObject( aAddress );
503  }
504 
505  if (!bFound && !rReq.IsAPI())
506  ErrorMessage( STR_ERR_INVALID_AREA );
507  }
508  break;
509 
510  case SID_CURRENTOBJECT:
511  if ( pReqArgs )
512  {
513  OUString aName = static_cast<const SfxStringItem&>(pReqArgs->Get(nSlot)).GetValue();
514  SelectObject( aName );
515  }
516  break;
517 
518  case SID_CURRENTTAB:
519  if ( pReqArgs )
520  {
521  // sheet for basic is one-based
522  SCTAB nTab = static_cast<const SfxUInt16Item&>(pReqArgs->Get(nSlot)).GetValue() - 1;
523  ScDocument& rDoc = GetViewData().GetDocument();
524  if ( nTab < rDoc.GetTableCount() )
525  {
526  SetTabNo( nTab );
527  rBindings.Update( nSlot );
528 
529  if( ! rReq.IsAPI() )
530  rReq.Done();
531  }
533  }
534  break;
535 
536  case SID_CURRENTDOC:
537  if ( pReqArgs )
538  {
539  OUString aStrDocName( static_cast<const SfxStringItem&>(pReqArgs->
540  Get(nSlot)).GetValue() );
541 
542  SfxViewFrame* pViewFrame = nullptr;
543  ScDocShell* pDocSh = static_cast<ScDocShell*>(SfxObjectShell::GetFirst());
544  bool bFound = false;
545 
546  // search for ViewFrame to be activated
547 
548  while ( pDocSh && !bFound )
549  {
550  if ( pDocSh->GetTitle() == aStrDocName )
551  {
552  pViewFrame = SfxViewFrame::GetFirst( pDocSh );
553  bFound = ( nullptr != pViewFrame );
554  }
555 
556  pDocSh = static_cast<ScDocShell*>(SfxObjectShell::GetNext( *pDocSh ));
557  }
558 
559  if ( bFound )
560  pViewFrame->GetFrame().Appear();
561 
562  rReq.Ignore();//XXX is handled by SFX
563  }
564  break;
565 
566  case SID_PRINTPREVIEW:
567  {
568  if ( !pThisFrame->GetFrame().IsInPlace() ) // not for OLE
569  {
570  // print preview is now always in the same frame as the tab view
571  // -> always switch this frame back to normal view
572  // (ScPreviewShell ctor reads view data)
573 
574  // #102785#; finish input
575  pScMod->InputEnterHandler();
576 
577  pThisFrame->GetDispatcher()->Execute( SID_VIEWSHELL1, SfxCallMode::ASYNCHRON );
578  }
579  // else error (e.g. Ole)
580  }
581  break;
582 
583  case SID_DETECTIVE_DEL_ALL:
584  DetectiveDelAll();
585  rReq.Done();
586  break;
587 
588  // SID_TABLE_ACTIVATE and SID_MARKAREA are called by basic for the
589  // hidden View, to mark/switch on the visible View:
590 
591  case SID_TABLE_ACTIVATE:
592  OSL_FAIL("old slot SID_TABLE_ACTIVATE");
593  break;
594 
595  case SID_REPAINT:
596  PaintGrid();
597  PaintTop();
598  PaintLeft();
599  PaintExtras();
600  rReq.Done();
601  break;
602 
603  case FID_NORMALVIEWMODE:
604  case FID_PAGEBREAKMODE:
605  {
606  bool bWantPageBreak = nSlot == FID_PAGEBREAKMODE;
607 
608  // check whether there is an explicit argument, use it
609  const SfxPoolItem* pItem;
610  if ( pReqArgs && pReqArgs->GetItemState(nSlot, true, &pItem) == SfxItemState::SET )
611  {
612  bool bItemValue = static_cast<const SfxBoolItem*>(pItem)->GetValue();
613  bWantPageBreak = (nSlot == FID_PAGEBREAKMODE) == bItemValue;
614  }
615 
616  if( GetViewData().IsPagebreakMode() != bWantPageBreak )
617  {
618  SetPagebreakMode( bWantPageBreak );
621  PaintGrid();
622  PaintTop();
623  PaintLeft();
624  rBindings.Invalidate( nSlot );
625  rReq.AppendItem( SfxBoolItem( nSlot, true ) );
626  rReq.Done();
627  }
628  }
629  break;
630 
631  case FID_FUNCTION_BOX:
632  {
633  // First make sure that the sidebar is visible
634  pThisFrame->ShowChildWindow(SID_SIDEBAR);
635 
636  ::sfx2::sidebar::Sidebar::ShowPanel(u"ScFunctionsPanel",
637  pThisFrame->GetFrame().GetFrameInterface());
638  rReq.Done ();
639  }
640  break;
641 
642  case FID_TOGGLESYNTAX:
643  {
644  bool bSet = !GetViewData().IsSyntaxMode();
645  const SfxPoolItem* pItem;
646  if ( pReqArgs && pReqArgs->GetItemState(nSlot, true, &pItem) == SfxItemState::SET )
647  bSet = static_cast<const SfxBoolItem*>(pItem)->GetValue();
648  GetViewData().SetSyntaxMode( bSet );
649  PaintGrid();
650  rBindings.Invalidate( FID_TOGGLESYNTAX );
651  rReq.AppendItem( SfxBoolItem( nSlot, bSet ) );
652  rReq.Done();
653  }
654  break;
655  case FID_TOGGLEHEADERS:
656  {
657  bool bSet = !GetViewData().IsHeaderMode();
658  const SfxPoolItem* pItem;
659  if ( pReqArgs && pReqArgs->GetItemState(nSlot, true, &pItem) == SfxItemState::SET )
660  bSet = static_cast<const SfxBoolItem*>(pItem)->GetValue();
661  GetViewData().SetHeaderMode( bSet );
662  RepeatResize();
663  rBindings.Invalidate( FID_TOGGLEHEADERS );
664  rReq.AppendItem( SfxBoolItem( nSlot, bSet ) );
665  rReq.Done();
666  }
667  break;
668 
669  case FID_TOGGLEFORMULA:
670  {
671  ScViewData& rViewData = GetViewData();
672  const ScViewOptions& rOpts = rViewData.GetOptions();
673  bool bFormulaMode = !rOpts.GetOption( VOPT_FORMULAS );
674  const SfxPoolItem *pItem;
675  if( pReqArgs && pReqArgs->GetItemState(nSlot, true, &pItem) == SfxItemState::SET )
676  bFormulaMode = static_cast<const SfxBoolItem *>(pItem)->GetValue();
677 
678  ScViewOptions aSetOpts = rOpts;
679  aSetOpts.SetOption( VOPT_FORMULAS, bFormulaMode );
680  rViewData.SetOptions( aSetOpts );
681 
682  rViewData.GetDocShell()->PostPaintGridAll();
683 
684  rBindings.Invalidate( FID_TOGGLEFORMULA );
685  rReq.AppendItem( SfxBoolItem( nSlot, bFormulaMode ) );
686  rReq.Done();
687  }
688  break;
689 
690  case FID_TOGGLEINPUTLINE:
691  {
692  sal_uInt16 nId = ScInputWindowWrapper::GetChildWindowId();
693  SfxChildWindow* pWnd = pThisFrame->GetChildWindow( nId );
694  bool bSet = ( pWnd == nullptr );
695  const SfxPoolItem* pItem;
696  if ( pReqArgs && pReqArgs->GetItemState(nSlot, true, &pItem) == SfxItemState::SET )
697  bSet = static_cast<const SfxBoolItem*>(pItem)->GetValue();
698 
699  pThisFrame->SetChildWindow( nId, bSet );
700  rBindings.Invalidate( FID_TOGGLEINPUTLINE );
701  rReq.AppendItem( SfxBoolItem( nSlot, bSet ) );
702  rReq.Done();
703  }
704  break;
705 
706  // handling for SID_ZOOM_IN and SID_ZOOM_OUT is ScTabView::ScrollCommand
707  // CommandWheelMode::ZOOM inspired
708  case SID_ZOOM_IN:
709  case SID_ZOOM_OUT:
710  {
711  HideNoteMarker();
712 
713  if (!GetViewData().GetViewShell()->GetViewFrame()->GetFrame().IsInPlace())
714  {
715  // for ole inplace editing, the scale is defined by the visarea and client size
716  // and can't be changed directly
717 
718  const Fraction& rOldY = GetViewData().GetZoomY();
719  tools::Long nOld = tools::Long(rOldY * 100);
720  tools::Long nNew;
721  if (SID_ZOOM_OUT == nSlot)
722  nNew = std::max(tools::Long(MINZOOM), basegfx::zoomtools::zoomOut(nOld));
723  else
724  nNew = std::min(tools::Long(MAXZOOM), basegfx::zoomtools::zoomIn(nOld));
725  if ( nNew != nOld)
726  {
727  bool bSyncZoom = SC_MOD()->GetAppOptions().GetSynchronizeZoom();
728  SetZoomType(SvxZoomType::PERCENT, bSyncZoom);
729  Fraction aFract(nNew, 100);
730  SetZoom(aFract, aFract, bSyncZoom);
731  PaintGrid();
732  PaintTop();
733  PaintLeft();
734  rBindings.Invalidate(SID_ATTR_ZOOM);
735  rBindings.Invalidate(SID_ATTR_ZOOMSLIDER);
736  rBindings.Invalidate(SID_ZOOM_IN);
737  rBindings.Invalidate(SID_ZOOM_OUT);
738  rReq.Done();
739  }
740  }
741  }
742  break;
743 
744  case SID_ATTR_ZOOM: // status row
745  case FID_SCALE:
746  {
747  bool bSyncZoom = SC_MOD()->GetAppOptions().GetSynchronizeZoom();
748  SvxZoomType eOldZoomType = GetZoomType();
749  SvxZoomType eNewZoomType = eOldZoomType;
750  const Fraction& rOldY = GetViewData().GetZoomY(); // Y is shown
751  sal_uInt16 nOldZoom = static_cast<sal_uInt16>(tools::Long( rOldY * 100 ));
752  sal_uInt16 nZoom = nOldZoom;
753  bool bCancel = false;
754 
755  if ( pReqArgs )
756  {
757  const SvxZoomItem& rZoomItem = pReqArgs->Get(SID_ATTR_ZOOM);
758 
759  eNewZoomType = rZoomItem.GetType();
760  nZoom = rZoomItem.GetValue();
761  }
762  else
763  {
765  SvxZoomItem aZoomItem( eOldZoomType, nOldZoom, SID_ATTR_ZOOM );
767  ScMarkData& rMark = GetViewData().GetMarkData();
768  SvxZoomEnableFlags nBtnFlags = SvxZoomEnableFlags::N50
769  | SvxZoomEnableFlags::N75
770  | SvxZoomEnableFlags::N100
771  | SvxZoomEnableFlags::N150
772  | SvxZoomEnableFlags::N200
773  | SvxZoomEnableFlags::WHOLEPAGE
774  | SvxZoomEnableFlags::PAGEWIDTH;
775 
776  if ( rMark.IsMarked() || rMark.IsMultiMarked() )
777  nBtnFlags = nBtnFlags | SvxZoomEnableFlags::OPTIMAL;
778 
779  aZoomItem.SetValueSet( nBtnFlags );
780  aSet.Put( aZoomItem );
782  pDlg.disposeAndReset(pFact->CreateSvxZoomDialog(GetFrameWeld(), aSet));
783  pDlg->SetLimits( MINZOOM, MAXZOOM );
784 
785  bCancel = ( RET_CANCEL == pDlg->Execute() );
786 
787  // bCancel is True only if we were in the previous if block,
788  // so no need to check again pDlg
789  if ( !bCancel )
790  {
791  const SvxZoomItem& rZoomItem = pDlg->GetOutputItemSet()->
792  Get( SID_ATTR_ZOOM );
793 
794  eNewZoomType = rZoomItem.GetType();
795  nZoom = rZoomItem.GetValue();
796  }
797  }
798 
799  if ( !bCancel )
800  {
801  if ( eNewZoomType == SvxZoomType::PERCENT )
802  {
803  if ( nZoom < MINZOOM ) nZoom = MINZOOM;
804  if ( nZoom > MAXZOOM ) nZoom = MAXZOOM;
805  }
806  else
807  {
808  nZoom = CalcZoom( eNewZoomType, nOldZoom );
809  bCancel = nZoom == 0;
810  }
811 
812  switch ( eNewZoomType )
813  {
814  case SvxZoomType::WHOLEPAGE:
815  case SvxZoomType::PAGEWIDTH:
816  SetZoomType( eNewZoomType, bSyncZoom );
817  break;
818 
819  default:
820  SetZoomType( SvxZoomType::PERCENT, bSyncZoom );
821  }
822  }
823 
824  if ( nZoom != nOldZoom && !bCancel )
825  {
826  if (!GetViewData().IsPagebreakMode())
827  {
828  ScAppOptions aNewOpt = pScMod->GetAppOptions();
829  aNewOpt.SetZoom( nZoom );
830  aNewOpt.SetZoomType( GetZoomType() );
831  pScMod->SetAppOptions( aNewOpt );
832  }
833  Fraction aFract( nZoom, 100 );
834  SetZoom( aFract, aFract, bSyncZoom );
835  PaintGrid();
836  PaintTop();
837  PaintLeft();
838  rBindings.Invalidate( SID_ATTR_ZOOM );
839  rReq.AppendItem( SvxZoomItem( GetZoomType(), nZoom, nSlot ) );
840  rReq.Done();
841  }
842  }
843  break;
844 
845  case SID_ATTR_ZOOMSLIDER:
846  {
847  const SfxPoolItem* pItem = nullptr;
848  bool bSyncZoom = SC_MOD()->GetAppOptions().GetSynchronizeZoom();
849  if ( pReqArgs && pReqArgs->GetItemState(SID_ATTR_ZOOMSLIDER, true, &pItem) == SfxItemState::SET )
850  {
851  const sal_uInt16 nCurrentZoom = static_cast<const SvxZoomSliderItem *>(pItem)->GetValue();
852  if( nCurrentZoom )
853  {
854  SetZoomType( SvxZoomType::PERCENT, bSyncZoom );
855  if (!GetViewData().IsPagebreakMode())
856  {
857  ScAppOptions aNewOpt = pScMod->GetAppOptions();
858  aNewOpt.SetZoom( nCurrentZoom );
859  collectUIInformation(OUString::number(nCurrentZoom));
860  aNewOpt.SetZoomType( GetZoomType() );
861  pScMod->SetAppOptions( aNewOpt );
862  }
863  Fraction aFract( nCurrentZoom,100 );
864  SetZoom( aFract, aFract, bSyncZoom );
865  PaintGrid();
866  PaintTop();
867  PaintLeft();
868  rBindings.Invalidate( SID_ATTR_ZOOMSLIDER );
869  rBindings.Invalidate( SID_ZOOM_IN );
870  rBindings.Invalidate( SID_ZOOM_OUT );
871  rReq.Done();
872  }
873  }
874  }
875  break;
876 
877  case FID_TAB_SELECTALL:
878  SelectAllTables();
879  rReq.Done();
880  break;
881 
882  case FID_TAB_DESELECTALL:
884  rReq.Done();
885  break;
886 
887  case SID_SELECT_TABLES:
888  {
889  ScViewData& rViewData = GetViewData();
890  ScDocument& rDoc = rViewData.GetDocument();
891  ScMarkData& rMark = rViewData.GetMarkData();
892  SCTAB nTabCount = rDoc.GetTableCount();
893  SCTAB nTab;
894 
895  ::std::vector < sal_Int32 > aIndexList;
896  const SfxIntegerListItem* pItem = rReq.GetArg<SfxIntegerListItem>(SID_SELECT_TABLES);
897  if ( pItem )
898  aIndexList = pItem->GetList();
899  else
900  {
902 
904  pDlg->SetDescription(
905  ScResId( STR_DLG_SELECTTABLES_TITLE ),
906  ScResId( STR_DLG_SELECTTABLES_LBNAME ),
907  GetStaticInterface()->GetSlot(SID_SELECT_TABLES)->GetCommand(), HID_SELECTTABLES );
908 
909  // fill all table names with selection state
910  OUString aTabName;
911  for( nTab = 0; nTab < nTabCount; ++nTab )
912  {
913  rDoc.GetName( nTab, aTabName );
914  pDlg->Insert( aTabName, rMark.GetTableSelect( nTab ) );
915  }
916 
917  if( pDlg->Execute() == RET_OK )
918  {
919  aIndexList = pDlg->GetSelectedRows();
920  pDlg.disposeAndClear();
921  rReq.AppendItem( SfxIntegerListItem( SID_SELECT_TABLES, std::vector(aIndexList) ) );
922  }
923  else
924  rReq.Ignore();
925  }
926 
927  if ( !aIndexList.empty() )
928  {
929  sal_uInt16 nSelCount = aIndexList.size();
930  sal_uInt16 nSelIx;
931  SCTAB nFirstVisTab = 0;
932 
933  // special case: only hidden tables selected -> do nothing
934  bool bVisSelected = false;
935  for( nSelIx = 0; !bVisSelected && (nSelIx < nSelCount); ++nSelIx )
936  {
937  nFirstVisTab = static_cast<SCTAB>(aIndexList[nSelIx]);
938  bVisSelected = rDoc.IsVisible( nFirstVisTab );
939  }
940  if( !bVisSelected )
941  nSelCount = 0;
942 
943  // select the tables
944  if( nSelCount )
945  {
946  for( nTab = 0; nTab < nTabCount; ++nTab )
947  rMark.SelectTable( nTab, false );
948 
949  for( nSelIx = 0; nSelIx < nSelCount; ++nSelIx )
950  rMark.SelectTable( static_cast<SCTAB>(aIndexList[nSelIx]), true );
951 
952  // activate another table, if current is deselected
953  if( !rMark.GetTableSelect( rViewData.GetTabNo() ) )
954  {
955  rMark.SelectTable( nFirstVisTab, true );
956  SetTabNo( nFirstVisTab );
957  }
958 
959  rViewData.GetDocShell()->PostPaintExtras();
960  SfxBindings& rBind = rViewData.GetBindings();
961  rBind.Invalidate( FID_FILL_TAB );
962  rBind.Invalidate( FID_TAB_DESELECTALL );
963  }
964 
965  rReq.Done();
966  }
967  }
968  break;
969 
970  case SID_OUTLINE_DELETEALL:
972  rReq.Done();
973  break;
974 
975  case SID_AUTO_OUTLINE:
976  AutoOutline();
977  rReq.Done();
978  break;
979 
980  case SID_WINDOW_SPLIT:
981  {
982  ScSplitMode eHSplit = GetViewData().GetHSplitMode();
983  ScSplitMode eVSplit = GetViewData().GetVSplitMode();
984  if ( eHSplit == SC_SPLIT_NORMAL || eVSplit == SC_SPLIT_NORMAL ) // remove
985  RemoveSplit();
986  else if ( eHSplit == SC_SPLIT_FIX || eVSplit == SC_SPLIT_FIX ) // normal
987  FreezeSplitters( false );
988  else // create
989  SplitAtCursor();
990  rReq.Done();
991 
992  InvalidateSplit();
993  }
994  break;
995 
996  case SID_WINDOW_FIX:
997  {
999  {
1000  ScSplitMode eHSplit = GetViewData().GetHSplitMode();
1001  ScSplitMode eVSplit = GetViewData().GetVSplitMode();
1002  if ( eHSplit == SC_SPLIT_FIX || eVSplit == SC_SPLIT_FIX ) // remove
1003  RemoveSplit();
1004  else
1005  FreezeSplitters( true, SC_SPLIT_METHOD_CURSOR); // create or fixate
1006  rReq.Done();
1007  InvalidateSplit();
1008  }
1009  else
1010  {
1011  ScViewData& rViewData = GetViewData();
1012  SCTAB nThisTab = rViewData.GetTabNo();
1013  bool bChangedX = false, bChangedY = false;
1014  if (rViewData.GetLOKSheetFreezeIndex(true) > 0 ||
1015  rViewData.GetLOKSheetFreezeIndex(false) > 0 ) // remove freeze
1016  {
1017  bChangedX = rViewData.RemoveLOKFreeze();
1018  } // create or fixate
1019  else
1020  {
1021  bChangedX = rViewData.SetLOKSheetFreezeIndex(rViewData.GetCurX(), true); // Freeze column
1022  bChangedY = rViewData.SetLOKSheetFreezeIndex(rViewData.GetCurY(), false); // Freeze row
1023  }
1024 
1025  rReq.Done();
1026  if (bChangedX || bChangedY)
1027  {
1028  rBindings.Invalidate( SID_WINDOW_FIX );
1029  rBindings.Invalidate( SID_WINDOW_FIX_COL );
1030  rBindings.Invalidate( SID_WINDOW_FIX_ROW );
1031  // Invalidate the slot for all views on the same tab of the document.
1032  SfxLokHelper::forEachOtherView(this, [nThisTab](ScTabViewShell* pOther) {
1033  ScViewData& rOtherViewData = pOther->GetViewData();
1034  if (rOtherViewData.GetTabNo() != nThisTab)
1035  return;
1036 
1037  SfxBindings& rOtherBind = rOtherViewData.GetBindings();
1038  rOtherBind.Invalidate( SID_WINDOW_FIX );
1039  rOtherBind.Invalidate( SID_WINDOW_FIX_COL );
1040  rOtherBind.Invalidate( SID_WINDOW_FIX_ROW );
1041  });
1042  if (!GetViewData().GetDocShell()->IsReadOnly())
1044  }
1045  }
1046  }
1047  break;
1048 
1049  case SID_WINDOW_FIX_COL:
1050  case SID_WINDOW_FIX_ROW:
1051  {
1052  bool bIsCol = (nSlot == SID_WINDOW_FIX_COL);
1053  sal_Int32 nFreezeIndex = 1;
1054  if (const SfxInt32Item* pItem = rReq.GetArg<SfxInt32Item>(nSlot))
1055  {
1056  nFreezeIndex = pItem->GetValue();
1057  if (nFreezeIndex < 0)
1058  nFreezeIndex = 0;
1059  }
1060 
1062  {
1063  ScViewData& rViewData = GetViewData();
1064  SCTAB nThisTab = rViewData.GetTabNo();
1065  bool bChanged = rViewData.SetLOKSheetFreezeIndex(nFreezeIndex, bIsCol);
1066  rReq.Done();
1067  if (bChanged)
1068  {
1069  rBindings.Invalidate( SID_WINDOW_FIX );
1070  rBindings.Invalidate(nSlot);
1071  // Invalidate the slot for all views on the same tab of the document.
1072  SfxLokHelper::forEachOtherView(this, [nSlot, nThisTab](ScTabViewShell* pOther) {
1073  ScViewData& rOtherViewData = pOther->GetViewData();
1074  if (rOtherViewData.GetTabNo() != nThisTab)
1075  return;
1076 
1077  SfxBindings& rOtherBind = rOtherViewData.GetBindings();
1078  rOtherBind.Invalidate( SID_WINDOW_FIX );
1079  rOtherBind.Invalidate(nSlot);
1080  });
1081  if (!GetViewData().GetDocShell()->IsReadOnly())
1083  }
1084  }
1085  else
1086  {
1087  FreezeSplitters( true, bIsCol ? SC_SPLIT_METHOD_COL : SC_SPLIT_METHOD_ROW, nFreezeIndex);
1088  rReq.Done();
1089  InvalidateSplit();
1090  }
1091  }
1092  break;
1093 
1094  case FID_CHG_SHOW:
1095  {
1096  sal_uInt16 nId = ScHighlightChgDlgWrapper::GetChildWindowId();
1097  SfxChildWindow* pWnd = pThisFrame->GetChildWindow( nId );
1098 
1099  pScMod->SetRefDialog( nId, pWnd == nullptr );
1100  }
1101  break;
1102 
1103  case FID_CHG_ACCEPT:
1104  {
1105  pThisFrame->ToggleChildWindow(ScAcceptChgDlgWrapper::GetChildWindowId());
1106  GetViewFrame()->GetBindings().Invalidate(FID_CHG_ACCEPT);
1107  rReq.Done ();
1108 
1109  /*
1110  sal_uInt16 nId = ScAcceptChgDlgWrapper::GetChildWindowId();
1111  SfxChildWindow* pWnd = pThisFrame->GetChildWindow( nId );
1112 
1113  pScMod->SetRefDialog( nId, pWnd ? sal_False : sal_True );
1114  */
1115  }
1116  break;
1117 
1118  case FID_CHG_COMMENT:
1119  {
1121  ScAddress aCursorPos( rData.GetCurX(), rData.GetCurY(), rData.GetTabNo() );
1122  ScDocShell* pDocSh = rData.GetDocShell();
1123 
1124  ScChangeAction* pAction = pDocSh->GetChangeAction( aCursorPos );
1125  if ( pAction )
1126  {
1127  const SfxPoolItem* pItem;
1128  if ( pReqArgs &&
1129  pReqArgs->GetItemState( nSlot, true, &pItem ) == SfxItemState::SET &&
1130  dynamic_cast<const SfxStringItem*>( pItem) != nullptr )
1131  {
1132  OUString aComment = static_cast<const SfxStringItem*>(pItem)->GetValue();
1133  pDocSh->SetChangeComment( pAction, aComment );
1134  rReq.Done();
1135  }
1136  else
1137  {
1138  pDocSh->ExecuteChangeCommentDialog(pAction, GetFrameWeld());
1139  rReq.Done();
1140  }
1141  }
1142  }
1143  break;
1144 
1145  case SID_CREATE_SW_DRAWVIEW:
1146  // is called by Forms, when the DrawView has to be created with all
1147  // the extras
1148  if (!GetScDrawView())
1149  {
1151  rBindings.InvalidateAll(false);
1152  }
1153  break;
1154 
1155  case FID_PROTECT_DOC:
1156  {
1157  ScDocument& rDoc = GetViewData().GetDocument();
1158 
1159  if( pReqArgs )
1160  {
1161  const SfxPoolItem* pItem;
1162  if( pReqArgs->HasItem( FID_PROTECT_DOC, &pItem ) &&
1163  static_cast<const SfxBoolItem*>(pItem)->GetValue() == rDoc.IsDocProtected() )
1164  {
1165  rReq.Ignore();
1166  break;
1167  }
1168  }
1169 
1170  ScDocProtection* pProtect = rDoc.GetDocProtection();
1171  if (pProtect && pProtect->isProtected())
1172  {
1173  bool bCancel = false;
1174  OUString aPassword;
1175 
1176  if (pProtect->isProtectedWithPass())
1177  {
1178  OUString aText(ScResId(SCSTR_PASSWORD));
1179 
1180  SfxPasswordDialog aDlg(GetFrameWeld(), &aText);
1181  aDlg.set_title(ScResId(SCSTR_UNPROTECTDOC));
1182  aDlg.SetMinLen(0);
1183  aDlg.set_help_id(GetStaticInterface()->GetSlot(FID_PROTECT_DOC)->GetCommand());
1185 
1186  if (aDlg.run() == RET_OK)
1187  aPassword = aDlg.GetPassword();
1188  else
1189  bCancel = true;
1190  }
1191  if (!bCancel)
1192  {
1193  Unprotect( TABLEID_DOC, aPassword );
1194  rReq.AppendItem( SfxBoolItem( FID_PROTECT_DOC, false ) );
1195  rReq.Done();
1196  }
1197  }
1198  else
1199  {
1200  OUString aText(ScResId(SCSTR_PASSWORDOPT));
1201 
1202  SfxPasswordDialog aDlg(GetFrameWeld(), &aText);
1203  aDlg.set_title(ScResId(SCSTR_PROTECTDOC));
1204  aDlg.SetMinLen( 0 );
1205  aDlg.set_help_id(GetStaticInterface()->GetSlot(FID_PROTECT_DOC)->GetCommand());
1207  aDlg.ShowExtras(SfxShowExtras::CONFIRM);
1209 
1210  if (aDlg.run() == RET_OK)
1211  {
1212  OUString aPassword = aDlg.GetPassword();
1213  ProtectDoc( aPassword );
1214  rReq.AppendItem( SfxBoolItem( FID_PROTECT_DOC, true ) );
1215  rReq.Done();
1216  }
1217  }
1218  rBindings.Invalidate( FID_PROTECT_DOC );
1219  }
1220  break;
1221 
1222  case FID_PROTECT_TABLE:
1223  {
1224  ScDocument& rDoc = GetViewData().GetDocument();
1225  SCTAB nTab = GetViewData().GetTabNo();
1226  bool bOldProtection = rDoc.IsTabProtected(nTab);
1227 
1228  if( pReqArgs )
1229  {
1230  const SfxPoolItem* pItem;
1231  bool bNewProtection = !bOldProtection;
1232  if( pReqArgs->HasItem( FID_PROTECT_TABLE, &pItem ) )
1233  bNewProtection = static_cast<const SfxBoolItem*>(pItem)->GetValue();
1234  if( bNewProtection == bOldProtection )
1235  {
1236  rReq.Ignore();
1237  break;
1238  }
1239  }
1240 
1241  if (bOldProtection)
1242  {
1243  // Unprotect a protected sheet.
1244 
1245  const ScTableProtection* pProtect = rDoc.GetTabProtection(nTab);
1246  if (pProtect && pProtect->isProtectedWithPass())
1247  {
1248  OUString aText( ScResId(SCSTR_PASSWORDOPT) );
1249  SfxPasswordDialog aDlg(GetFrameWeld(), &aText);
1250  aDlg.set_title(ScResId(SCSTR_UNPROTECTTAB));
1251  aDlg.SetMinLen(0);
1252  aDlg.set_help_id(GetStaticInterface()->GetSlot(FID_PROTECT_TABLE)->GetCommand());
1254 
1255  if (aDlg.run() == RET_OK)
1256  {
1257  OUString aPassword = aDlg.GetPassword();
1258  Unprotect(nTab, aPassword);
1259  }
1260  }
1261  else
1262  // this sheet is not password-protected.
1263  Unprotect(nTab, OUString());
1264 
1265  if (!pReqArgs)
1266  {
1267  rReq.AppendItem( SfxBoolItem(FID_PROTECT_TABLE, false) );
1268  rReq.Done();
1269  }
1270  }
1271  else
1272  {
1273  // Protect a current sheet.
1274 
1276 
1277  const ScTableProtection* pProtect = rDoc.GetTabProtection(nTab);
1278  if (pProtect)
1279  aDlg.SetDialogData(*pProtect);
1280 
1281  if (aDlg.run() == RET_OK)
1282  {
1283  pScMod->InputEnterHandler();
1284 
1285  ScTableProtection aNewProtect;
1286  aDlg.WriteData(aNewProtect);
1287  ProtectSheet(nTab, aNewProtect);
1288  if (!pReqArgs)
1289  {
1290  rReq.AppendItem( SfxBoolItem(FID_PROTECT_TABLE, true) );
1291  rReq.Done();
1292  }
1293  }
1294  }
1295  TabChanged();
1296  UpdateInputHandler(true); // to immediately enable input again
1297  SelectionChanged();
1298  }
1299  break;
1300 
1301  case SID_OPT_LOCALE_CHANGED :
1302  { // locale changed, SYSTEM number formats changed => repaint cell contents
1303  PaintGrid();
1304  rReq.Done();
1305  }
1306  break;
1307 
1308  default:
1309  OSL_FAIL("Unknown Slot at ScTabViewShell::Execute");
1310  break;
1311  }
1312 }
1313 
1314 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SC_DLLPUBLIC bool IsDocProtected() const
Definition: documen3.cxx:1902
#define MAXZOOM
Definition: global.hxx:79
ScMarkData & GetMarkData()
Definition: viewdata.cxx:3135
static void ShowPanel(std::u16string_view rsPanelId, const css::uno::Reference< css::frame::XFrame > &rxFrame, bool bFocus=false)
void SetEditHelpId(const OString &rId)
SfxViewFrame * GetViewFrame() const
SvxZoomType GetZoomType() const
Definition: tabview5.cxx:417
void SetOption(ScViewOption eOpt, bool bNew)
Definition: viewopti.hxx:87
void Appear()
ScAddress aStart
Definition: address.hxx:497
ScDocShell * GetDocShell() const
Definition: viewdata.hxx:354
void FreezeSplitters(bool bFreeze, SplitMethod eSplitMethod=SC_SPLIT_METHOD_CURSOR, SCCOLROW nFreezeIndex=-1)
Definition: tabview.cxx:1922
void notifyKitCellFollowJump() const
Definition: gridwin.cxx:5122
void RemoveManualBreaks()
Definition: viewfun2.cxx:1006
constexpr OStringLiteral HID_PASSWD_DOC
Definition: helpids.h:60
SC_DLLPUBLIC bool IsTabProtected(SCTAB nTab) const
Definition: documen3.cxx:1913
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
Definition: markdata.hxx:42
SfxChildWindow * GetChildWindow(sal_uInt16)
OUString ScResId(TranslateId aId)
Definition: scdll.cxx:90
void ErrorMessage(TranslateId pGlobStrId)
Definition: tabview2.cxx:1446
static SfxInterface * GetStaticInterface()
RutlNameScope
Definition: rangeutl.hxx:35
SfxViewFrame * GetFrame() const
static bool MakeRangeFromName(const OUString &rName, const ScDocument &rDoc, SCTAB nCurTab, ScRange &rRange, RutlNameScope eScope=RUTL_NAMES, ScAddress::Details const &rDetails=ScAddress::detailsOOOa1, bool bUseDetailsPos=false)
Definition: rangeutl.cxx:233
SCROW Row() const
Definition: address.hxx:274
OUString GetTitle(sal_uInt16 nMaxLen=0) const
void PostPaintGridAll()
Definition: docsh3.cxx:183
void SetPrintRanges(bool bEntireSheet, const OUString *pPrint, const OUString *pRepCol, const OUString *pRepRow, bool bAddPrint)
Definition: viewfun2.cxx:1045
std::string GetValue
bool PaintExtras()
Definition: tabview3.cxx:2764
bool SelectObject(std::u16string_view rName)
Definition: tabvwsh2.cxx:460
void MarkRange(const ScRange &rRange, bool bSetCursor=true, bool bContinue=false)
Definition: tabview3.cxx:1689
sheet protection state container
bool isdigitAsciiString(std::string_view rString)
void SetHeaderMode(bool bNewMode)
Definition: viewdata.hxx:561
void SelectAllTables()
Definition: tabview2.cxx:1118
SfxDispatcher * GetDispatcher()
void SetPagebreakMode(bool bSet)
Definition: tabview5.cxx:443
static SvxAbstractDialogFactory * Create()
void RepeatResize(bool bUpdateFix=true)
Definition: tabview.cxx:772
long Long
void HideNoteMarker()
Definition: tabview2.cxx:1420
SCROW GetCurY() const
Definition: viewdata.hxx:402
SCCOLROW GetLOKSheetFreezeIndex(bool bIsCol) const
Definition: viewdata.cxx:4218
virtual bool isProtected() const override
void SetDocumentModified()
Definition: docsh.cxx:2959
sal_Int16 nId
const ContentProperties & rData
void PostPaintExtras()
Definition: docsh3.cxx:198
SCTAB GetTabNo() const
Definition: viewdata.hxx:395
void PaintGrid()
Definition: tabview3.cxx:2633
bool IsSyntaxMode() const
Definition: viewdata.hxx:558
ScAddress aEnd
Definition: address.hxx:498
void Done(bool bRemove=false)
ScDocument & GetDocument() const
Definition: viewdata.hxx:380
virtual bool isProtectedWithPass() const override
virtual short run() override
static OUString decode(std::u16string_view rText, DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
const SfxItemSet * GetArgs() const
void Invalidate(sal_uInt16 nId)
void TabChanged(bool bSameTabButMoved=false)
Called after moving, copying, inserting or deleting a sheet.
Definition: tabview5.cxx:281
static void forEachOtherView(ViewShellType *pThisViewShell, FunctionType f)
SC_DLLPUBLIC void SetCursor(SCCOL nPosX, SCROW nPosY, bool bNew=false)
Definition: tabview3.cxx:363
RET_CANCEL
SC_DLLPUBLIC formula::FormulaGrammar::AddressConvention GetAddressConvention() const
Definition: documen3.cxx:494
virtual const SfxItemSet * GetOutputItemSet() const =0
const ScRange & GetMarkArea() const
Definition: markdata.hxx:83
SC_DLLPUBLIC void MoveCursorAbs(SCCOL nCurX, SCROW nCurY, ScFollowMode eMode, bool bShift, bool bControl, bool bKeepOld=false, bool bKeepSel=false)
Definition: tabview3.cxx:1194
NONE
void DeselectAllTables()
Definition: tabview2.cxx:1136
void ToggleChildWindow(sal_uInt16)
static UITestLogger & getInstance()
void logEvent(const EventDescription &rDescription)
void disposeAndReset(reference_type *pBody)
void PaintLeft()
Definition: tabview3.cxx:2711
SC_DLLPUBLIC SCROW MaxRow() const
Definition: document.hxx:891
SC_DLLPUBLIC SCTAB GetTableCount() const
Definition: document.cxx:315
void SetConfirmHelpId(const OString &rId)
bool Unprotect(SCTAB nTab, const OUString &rPassword)
Definition: viewfunc.cxx:2576
bool IsMultiMarked() const
Definition: markdata.hxx:81
SC_DLLPUBLIC void InputEnterHandler(ScEnterMode nBlockMode=ScEnterMode::NORMAL, bool bBeforeSavingInLOK=false)
Definition: scmod.cxx:1408
SfxFrame & GetFrame() const
SC_DLLPUBLIC void SetRefDialog(sal_uInt16 nId, bool bVis, SfxViewFrame *pViewFrm=nullptr)
Reference dialogs.
Definition: scmod.cxx:1516
void SetOptions(const ScViewOptions &rOpt)
Definition: viewdata.cxx:3984
SC_DLLPUBLIC bool GetTable(const OUString &rName, SCTAB &rTab) const
Definition: document.cxx:262
void UpdateInputHandler(bool bForce=false, bool bStopEditing=true)
Definition: tabvwsha.cxx:668
SCTAB Tab() const
Definition: address.hxx:283
void SetRow(SCROW nRowP)
Definition: address.hxx:287
ScSplitMode GetHSplitMode() const
Definition: viewdata.hxx:416
const Fraction & GetZoomY() const
Definition: viewdata.hxx:460
void SetCol(SCCOL nColP)
Definition: address.hxx:291
ScDrawLayer * MakeDrawLayer()
Definition: docsh2.cxx:172
ScViewData & GetViewData()
Definition: tabview.hxx:333
void PaintTop()
Definition: tabview3.cxx:2644
void SelectionChanged(bool bFromPaste=false)
Definition: tabview3.cxx:532
SfxItemPool & GetPool() const
bool PasteFile(const Point &, const OUString &, bool bLink)
Definition: viewfun4.cxx:579
tools::Long zoomOut(tools::Long nCurrent)
SC_DLLPUBLIC void SetAppOptions(const ScAppOptions &rOpt)
Definition: scmod.cxx:761
void AutoOutline()
Definition: dbfunc3.cxx:214
SC_DLLPUBLIC ScDocProtection * GetDocProtection() const
Definition: documen3.cxx:1889
void SetTab(SCTAB nTabP)
Definition: address.hxx:295
void SetZoom(const Fraction &rNewX, const Fraction &rNewY, bool bAll)
Definition: tabview5.cxx:427
bool IsMarked() const
Definition: markdata.hxx:80
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
void SelectTable(SCTAB nTab, bool bNew)
Definition: markdata.cxx:157
SfxBindings & GetBindings()
Definition: viewdata.cxx:3123
virtual VclPtr< AbstractScShowTabDlg > CreateScShowTabDlg(weld::Window *pParent)=0
sal_Int16 SCCOL
Definition: types.hxx:21
tools::Long zoomIn(tools::Long nCurrent)
#define SC_MOD()
Definition: scmod.hxx:249
SfxBindings & GetBindings()
SC_DLLPUBLIC void SetTabNo(SCTAB nTab, bool bNew=false, bool bExtendSelection=false, bool bSameTabButMoved=false)
Definition: tabview3.cxx:1800
SC_DLLPUBLIC const ScAppOptions & GetAppOptions()
Definition: scmod.cxx:774
const T * GetArg(sal_uInt16 nSlotId) const
void ShowExtras(SfxShowExtras nExtras)
float u
bool GetOption(ScViewOption eOpt) const
Definition: viewopti.hxx:88
ScGridWindow * GetActiveWin()
Definition: viewdata.cxx:3151
void RemoveAllOutlines(bool bRecord=true)
Definition: dbfunc3.cxx:194
void InvalidateSplit()
Definition: tabview.cxx:2121
sal_uInt16 CalcZoom(SvxZoomType eType, sal_uInt16 nOldZoom)
Definition: tabview2.cxx:1214
void RemoveSplit()
Definition: tabview.cxx:2077
void SplitAtCursor()
Definition: tabview.cxx:2084
void SetDialogData(const ScTableProtection &rData)
void SetZoom(sal_uInt16 nNew)
Definition: appoptio.hxx:41
bool SetLOKSheetFreezeIndex(const SCCOLROW nFreezeIndex, bool bIsCol, SCTAB nForTab=-1)
Definition: viewdata.cxx:4224
SfxViewShell * GetViewShell() const
const SCTAB TABLEID_DOC
Definition: address.hxx:91
const css::uno::Reference< css::frame::XFrame > & GetFrameInterface() const
SCCOL Col() const
Definition: address.hxx:279
bool IsReadOnly() const
void SetMinLen(sal_uInt16 Len)
virtual void SetLimits(sal_uInt16 nMin, sal_uInt16 nMax)=0
constexpr OStringLiteral HID_PASSWD_TABLE
Definition: helpids.h:59
void DetectiveDelAll()
Definition: viewfun6.cxx:106
void SetReturnValue(const SfxPoolItem &)
void SetPrintZoom(sal_uInt16 nScale)
Definition: viewfun2.cxx:1030
void Update(sal_uInt16 nId)
void SkipOverlapped(SCCOL &rCol, SCROW &rRow, SCTAB nTab) const
Definition: document.cxx:5815
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
sal_Int32 SCROW
Definition: types.hxx:17
sal_uInt16 GetSlot() const
void PutInOrder()
Definition: address.hxx:622
bool ValidRow(SCROW nRow) const
Definition: document.hxx:898
weld::Window * GetFrameWeld() const
void SetCurSubShell(ObjectSelectionType eOST, bool bForce=false)
Definition: tabvwsh4.cxx:788
void ProtectSheet(SCTAB nTab, const ScTableProtection &rProtect)
Definition: viewfunc.cxx:2536
ScDrawView * GetScDrawView()
Definition: tabview.hxx:341
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
SvxZoomEnableFlags
bool IsInPlace() const
void SetValueSet(SvxZoomEnableFlags nValues)
static SfxObjectShell * GetFirst(const std::function< bool(const SfxObjectShell *)> &isObjectShell=nullptr, bool bOnlyVisible=true)
SvxZoomType GetType() const
bool IsHeaderMode() const
Definition: viewdata.hxx:560
static SfxViewShell * Get(const css::uno::Reference< css::frame::XController > &i_rController)
OUString aName
static SC_DLLPUBLIC ScAbstractDialogFactory * Create()
Definition: scabstdlg.cxx:37
RET_OK
ScRefFlags Parse(const OUString &, const ScDocument &, const ScAddress::Details &rDetails=ScAddress::detailsOOOa1, ScAddress::ExternalInfo *pExtInfo=nullptr, const css::uno::Sequence< css::sheet::ExternalLinkInfo > *pExternalLinks=nullptr, const OUString *pErrRef=nullptr)
Definition: address.cxx:1700
void SetChildWindow(sal_uInt16 nId, bool bVisible, bool bSetFocus=true)
bool HasItem(sal_uInt16 nWhich, const SfxPoolItem **ppItem=nullptr) const
OUString GetPassword() const
const ScViewOptions & GetOptions() const
Definition: viewdata.hxx:554
virtual short run()
void SetZoomType(SvxZoomType eNew)
Definition: appoptio.hxx:43
void AlignToCursor(SCCOL nCurX, SCROW nCurY, ScFollowMode eMode, const ScSplitPos *pWhich=nullptr)
Definition: tabview3.cxx:920
void ShowChildWindow(sal_uInt16, bool bVisible=true)
ScSplitMode
Definition: viewdata.hxx:42
void HideListBox()
Definition: tabview3.cxx:2973
void SetZoomType(SvxZoomType eNew, bool bAll)
Definition: tabview5.cxx:422
ObjectSelectionType GetCurObjectSelectionType() const
Definition: tabvwsh.hxx:305
void Execute(SfxRequest &rReq)
Definition: tabvwsh3.cxx:167
static SfxViewFrame * GetFirst(const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
void InvalidateAll(bool bWithMsg)
SC_DLLPUBLIC bool IsVisible(SCTAB nTab) const
Definition: document.cxx:911
void AppendItem(const SfxPoolItem &)
Point GetInsertPos() const
Definition: tabview.cxx:1669
void SetSyntaxMode(bool bNewMode)
Definition: viewdata.hxx:559
constexpr OStringLiteral HID_SELECTTABLES
Definition: helpids.h:65
DetectFlags
Definition: tabvwsh3.cxx:75
#define MINZOOM
Definition: global.hxx:78
static SfxObjectShell * GetNext(const SfxObjectShell &rPrev, const std::function< bool(const SfxObjectShell *)> &isObjectShell=nullptr, bool bOnlyVisible=true)
bool IsAPI() const
SC_DLLPUBLIC ScRefFlags Parse(const OUString &, const ScDocument &, const Details &rDetails=detailsOOOa1, ExternalInfo *pExtInfo=nullptr, const css::uno::Sequence< css::sheet::ExternalLinkInfo > *pExternalLinks=nullptr, sal_Int32 *pSheetEndPos=nullptr, const OUString *pErrRef=nullptr)
Definition: address.cxx:1537
const SfxPoolItem * Execute(sal_uInt16 nSlot, SfxCallMode nCall=SfxCallMode::SLOT, const SfxPoolItem **pArgs=nullptr, sal_uInt16 nModi=0, const SfxPoolItem **pInternalArgs=nullptr)
SvxZoomType
ScRefFlags
Definition: address.hxx:157
bool GetTableSelect(SCTAB nTab) const
Definition: markdata.cxx:169
void ProtectDoc(const OUString &rPassword)
Definition: viewfunc.cxx:2566
std::map< OUString, OUString > aParameters
bool IsPagebreakMode() const
Definition: viewdata.hxx:425
constexpr OStringLiteral HID_PASSWD_DOC_CONFIRM
Definition: helpids.h:61
const std::vector< sal_Int32 > & GetList() const
void WriteData(ScTableProtection &rData) const
void Ignore()
SC_DLLPUBLIC bool GetName(SCTAB nTab, OUString &rName) const
Definition: document.cxx:215
void UpdatePageBreakData(bool bForcePaint=false)
Definition: tabview2.cxx:1479
ScSplitMode GetVSplitMode() const
Definition: viewdata.hxx:417
virtual VclPtr< AbstractSvxZoomDialog > CreateSvxZoomDialog(weld::Window *pParent, const SfxItemSet &rCoreSet)=0
virtual bool isProtectedWithPass() const override
sal_Int16 SCTAB
Definition: types.hxx:22
void AdjustPrintZoom()
Definition: viewfun2.cxx:1037
void ResetOldCursor()
Definition: viewdata.cxx:1397
bool RemoveLOKFreeze()
Definition: viewdata.cxx:4240
SCCOL GetCurX() const
Definition: viewdata.hxx:401
SC_DLLPUBLIC const ScTableProtection * GetTabProtection(SCTAB nTab) const
Definition: documen3.cxx:1922