LibreOffice Module sc (master)  1
cellsh.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 <scitems.hxx>
21 
22 #include <svl/slstitm.hxx>
23 #include <svl/stritem.hxx>
24 #include <svl/whiter.hxx>
25 #include <svtools/cliplistener.hxx>
26 #include <svtools/insdlg.hxx>
27 #include <sot/formats.hxx>
28 #include <svx/hlnkitem.hxx>
29 #include <sfx2/bindings.hxx>
30 #include <sfx2/childwin.hxx>
31 #include <sfx2/objface.hxx>
32 #include <sfx2/request.hxx>
33 #include <sfx2/viewfrm.hxx>
34 #include <vcl/EnumContext.hxx>
35 #include <vcl/svapp.hxx>
36 #include <svx/clipfmtitem.hxx>
37 
38 #include <cellsh.hxx>
39 #include <sc.hrc>
40 #include <docsh.hxx>
41 #include <attrib.hxx>
42 #include <tabvwsh.hxx>
43 #include <formulacell.hxx>
44 #include <scmod.hxx>
45 #include <globstr.hrc>
46 #include <scresid.hxx>
47 #include <transobj.hxx>
48 #include <drwtrans.hxx>
49 #include <scabstdlg.hxx>
50 #include <postit.hxx>
51 #include <cliputil.hxx>
52 #include <clipparam.hxx>
53 #include <markdata.hxx>
54 #include <gridwin.hxx>
55 
56 #define ShellClass_ScCellShell
57 #define ShellClass_CellMovement
58 #include <scslots.hxx>
59 
60 
62 
63 void ScCellShell::InitInterface_Impl()
64 {
65  GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT,
66  SfxVisibilityFlags::Standard | SfxVisibilityFlags::Server,
67  ToolbarId::Objectbar_Format);
68 
69  GetStaticInterface()->RegisterPopupMenu("cell");
70 }
71 
73  ScFormatShell(&rData),
74  pImpl( new CellShell_Impl() ),
75  bPastePossible(false),
76  pFrameWin(frameWin)
77 {
78  SetName("Cell");
80 }
81 
83 {
84  if ( pImpl->m_xClipEvtLstnr.is() )
85  {
86  pImpl->m_xClipEvtLstnr->RemoveListener( GetViewData()->GetActiveWin() );
87 
88  // The listener may just now be waiting for the SolarMutex and call the link
89  // afterwards, in spite of RemoveListener. So the link has to be reset, too.
90  pImpl->m_xClipEvtLstnr->ClearCallbackLink();
91 
92  pImpl->m_xClipEvtLstnr.clear();
93  }
94 
95  pImpl->m_pLinkedDlg.disposeAndClear();
96  delete pImpl->m_pRequest;
97 }
98 
100 {
101  ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
102  ScRange aMarkRange;
103  ScMarkType eMarkType = GetViewData()->GetSimpleArea( aMarkRange );
104  bool bSimpleArea = (eMarkType == SC_MARK_SIMPLE);
105  bool bOnlyNotBecauseOfMatrix;
106  bool bEditable = pTabViewShell->SelectionEditable( &bOnlyNotBecauseOfMatrix );
107  ScDocument& rDoc = GetViewData()->GetDocument();
108  ScDocShell* pDocShell = GetViewData()->GetDocShell();
109  ScMarkData& rMark = GetViewData()->GetMarkData();
110  SCCOL nCol1, nCol2;
111  SCROW nRow1, nRow2;
112  nCol1 = aMarkRange.aStart.Col();
113  nRow1 = aMarkRange.aStart.Row();
114  nCol2 = aMarkRange.aEnd.Col();
115  nRow2 = aMarkRange.aEnd.Row();
116 
117  SfxWhichIter aIter(rSet);
118  sal_uInt16 nWhich = aIter.FirstWhich();
119  while ( nWhich )
120  {
121  bool bDisable = false;
122  bool bNeedEdit = true; // need selection be editable?
123  switch ( nWhich )
124  {
125  case FID_FILL_TO_BOTTOM: // fill to top / bottom
126  {
127  bDisable = !bSimpleArea || (nRow1 == 0 && nRow2 == 0);
128  if (!bDisable && GetViewData()->SelectionForbidsCellFill())
129  bDisable = true;
130  if ( !bDisable && bEditable )
131  { // do not damage matrix
132  bDisable = rDoc.HasSelectedBlockMatrixFragment(
133  nCol1, nRow1, nCol2, nRow1, rMark ); // first row
134  }
135  }
136  break;
137  case FID_FILL_TO_TOP:
138  {
139  bDisable = (!bSimpleArea) || (nRow1 == rDoc.MaxRow() && nRow2 == rDoc.MaxRow());
140  if (!bDisable && GetViewData()->SelectionForbidsCellFill())
141  bDisable = true;
142  if ( !bDisable && bEditable )
143  { // do not damage matrix
144  bDisable = rDoc.HasSelectedBlockMatrixFragment(
145  nCol1, nRow2, nCol2, nRow2, rMark ); // last row
146  }
147  }
148  break;
149  case FID_FILL_TO_RIGHT: // fill to left / right
150  {
151  bDisable = !bSimpleArea || (nCol1 == 0 && nCol2 == 0);
152  if (!bDisable && GetViewData()->SelectionForbidsCellFill())
153  bDisable = true;
154  if ( !bDisable && bEditable )
155  { // do not damage matrix
156  bDisable = rDoc.HasSelectedBlockMatrixFragment(
157  nCol1, nRow1, nCol1, nRow2, rMark ); // first column
158  }
159  }
160  break;
161  case FID_FILL_TO_LEFT:
162  {
163  bDisable = (!bSimpleArea) || (nCol1 == rDoc.MaxCol() && nCol2 == rDoc.MaxCol());
164  if (!bDisable && GetViewData()->SelectionForbidsCellFill())
165  bDisable = true;
166  if ( !bDisable && bEditable )
167  { // do not damage matrix
168  bDisable = rDoc.HasSelectedBlockMatrixFragment(
169  nCol2, nRow1, nCol2, nRow2, rMark ); // last column
170  }
171  }
172  break;
173 
174  case SID_RANDOM_NUMBER_GENERATOR_DIALOG:
175  bDisable = !bSimpleArea || GetViewData()->SelectionForbidsCellFill();
176  break;
177  case SID_SAMPLING_DIALOG:
178  case SID_DESCRIPTIVE_STATISTICS_DIALOG:
179  case SID_ANALYSIS_OF_VARIANCE_DIALOG:
180  case SID_CORRELATION_DIALOG:
181  case SID_COVARIANCE_DIALOG:
182  {
183  bDisable = !bSimpleArea;
184  }
185  break;
186 
187  case FID_FILL_SERIES: // fill block
188  case SID_OPENDLG_TABOP: // multiple-cell operations, are at least 2 cells marked?
189  if (rDoc.GetChangeTrack()!=nullptr &&nWhich ==SID_OPENDLG_TABOP)
190  bDisable = true;
191  else
192  bDisable = (!bSimpleArea) || (nCol1 == nCol2 && nRow1 == nRow2);
193 
194  if (!bDisable && GetViewData()->SelectionForbidsCellFill())
195  bDisable = true;
196 
197  if ( !bDisable && bEditable && nWhich == FID_FILL_SERIES )
198  { // do not damage matrix
199  bDisable = rDoc.HasSelectedBlockMatrixFragment(
200  nCol1, nRow1, nCol2, nRow1, rMark ) // first row
202  nCol1, nRow2, nCol2, nRow2, rMark ) // last row
204  nCol1, nRow1, nCol1, nRow2, rMark ) // first column
206  nCol2, nRow1, nCol2, nRow2, rMark ); // last column
207  }
208  break;
209  case FID_FILL_SINGLE_EDIT:
210  bDisable = false;
211  break;
212  case SID_CUT: // cut
213  bDisable = !bSimpleArea || GetObjectShell()->isContentExtractionLocked();
214  break;
215  case FID_INS_CELL: // insert cells, just simple selection
216  bDisable = (!bSimpleArea);
217  break;
218 
219  case SID_PASTE:
220  case SID_PASTE_SPECIAL:
221  case SID_PASTE_UNFORMATTED:
222  case SID_PASTE_ONLY_VALUE:
223  case SID_PASTE_ONLY_TEXT:
224  case SID_PASTE_ONLY_FORMULA:
225  case SID_PASTE_TEXTIMPORT_DIALOG:
226  bDisable = GetViewData()->SelectionForbidsCellFill();
227  break;
228 
229  case FID_INS_ROW:
230  case FID_INS_ROWS_BEFORE: // insert rows
231  case FID_INS_ROWS_AFTER:
232  {
234  if (nWhich == FID_INS_ROWS_AFTER)
236 
237  bDisable = (!bSimpleArea) || GetViewData()->SimpleColMarked();
238  if (!bEditable && nCol1 == 0 && nCol2 == rDoc.MaxCol())
239  {
240  // See if row insertions are allowed.
241  bEditable = rDoc.IsEditActionAllowed(eAction, rMark, nRow1, nRow2);
242  }
243  break;
244  }
245  case FID_INS_CELLSDOWN:
246  bDisable = (!bSimpleArea) || GetViewData()->SimpleColMarked();
247  break;
248 
249  case FID_INS_COLUMN:
250  case FID_INS_COLUMNS_BEFORE: // insert columns
251  case FID_INS_COLUMNS_AFTER:
252  {
254  if (nWhich == FID_INS_COLUMNS_AFTER)
256 
257  bDisable = (!bSimpleArea) || GetViewData()->SimpleRowMarked();
258  if (!bEditable && nRow1 == 0 && nRow2 == rDoc.MaxRow())
259  {
260  // See if row insertions are allowed.
261  bEditable = rDoc.IsEditActionAllowed(eAction, rMark, nCol1, nCol2);
262  }
263  break;
264  }
265  case FID_INS_CELLSRIGHT:
266  bDisable = (!bSimpleArea) || GetViewData()->SimpleRowMarked();
267  break;
268 
269  case SID_COPY: // copy
270  // not editable because of matrix only? Do not damage matrix
274  if ( bEditable || !bOnlyNotBecauseOfMatrix )
275  bNeedEdit = false; // allowed when protected/ReadOnly
277  break;
278 
279  case SID_AUTOFORMAT: // Autoformat, at least 3x3 selected
280  bDisable = (!bSimpleArea)
281  || ((nCol2 - nCol1) < 2) || ((nRow2 - nRow1) < 2);
282  break;
283 
284  case SID_CELL_FORMAT_RESET :
285  case FID_CELL_FORMAT :
286  case SID_ENABLE_HYPHENATION :
287  // not editable because of matrix only? Attribute ok nonetheless
288  if ( !bEditable && bOnlyNotBecauseOfMatrix )
289  bNeedEdit = false;
290  break;
291 
292  case FID_VALIDATION:
293  {
294  if ( pDocShell && pDocShell->IsDocShared() )
295  {
296  bDisable = true;
297  }
298  }
299  break;
300  case SID_TRANSLITERATE_HALFWIDTH:
301  case SID_TRANSLITERATE_FULLWIDTH:
302  case SID_TRANSLITERATE_HIRAGANA:
303  case SID_TRANSLITERATE_KATAKANA:
304  ScViewUtil::HideDisabledSlot( rSet, GetViewData()->GetBindings(), nWhich );
305  break;
306  case SID_CONVERT_FORMULA_TO_VALUE:
307  {
308  // Check and see if the marked range has at least one formula cell.
309  bDisable = !rDoc.HasFormulaCell(aMarkRange);
310  }
311  break;
312  }
313  if (!bDisable && bNeedEdit && !bEditable)
314  bDisable = true;
315 
316  if (bDisable)
317  rSet.DisableItem(nWhich);
318  else if (nWhich == SID_ENABLE_HYPHENATION)
319  {
320  // toggle slots need a bool item
321  rSet.Put( SfxBoolItem( nWhich, false ) );
322  }
323  nWhich = aIter.NextWhich();
324  }
325 }
326 
327 // functions, disabled depending on cursor position
328 // Default:
329 // SID_INSERT_POSTIT, SID_CHARMAP, SID_OPENDLG_FUNCTION
330 
332 {
333  ScDocShell* pDocShell = GetViewData()->GetDocShell();
335  ScAddress aCursor( GetViewData()->GetCurX(), GetViewData()->GetCurY(),
336  GetViewData()->GetTabNo() );
337  SfxWhichIter aIter(rSet);
338  sal_uInt16 nWhich = aIter.FirstWhich();
339  while ( nWhich )
340  {
341  bool bDisable = false;
342  bool bNeedEdit = true; // need cursor position be editable?
343  switch ( nWhich )
344  {
345  case SID_THESAURUS:
346  {
347  CellType eType = rDoc.GetCellType( aCursor );
348  bDisable = ( eType != CELLTYPE_STRING && eType != CELLTYPE_EDIT);
349  if (!bDisable)
350  {
351  // test for available languages
352  LanguageType nLang = ScViewUtil::GetEffLanguage( rDoc, aCursor );
353  bDisable = !ScModule::HasThesaurusLanguage( nLang );
354  }
355  }
356  break;
357  case SID_OPENDLG_FUNCTION:
358  {
359  ScMarkData aMarkData = GetViewData()->GetMarkData();
360  aMarkData.MarkToSimple();
361  ScRange aRange;
362  aMarkData.GetMarkArea(aRange);
363  if(aMarkData.IsMarked())
364  {
365  if (!rDoc.IsBlockEditable( aCursor.Tab(), aRange.aStart.Col(),aRange.aStart.Row(),
366  aRange.aEnd.Col(),aRange.aEnd.Row() ))
367  {
368  bDisable = true;
369  }
370  bNeedEdit=false;
371  }
372 
373  }
374  break;
375  case SID_INSERT_POSTIT:
376  {
377  ScAddress aPos( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
378  if( rDoc.GetNote(aPos) )
379  {
380  bDisable = true;
381  }
382  else
383  {
384  bDisable = false;
385  if ( pDocShell && pDocShell->IsDocShared() )
386  {
387  bDisable = true;
388  }
389  }
390  }
391  break;
392  case SID_EDIT_POSTIT:
393  {
394  ScAddress aPos( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
395  bDisable = rDoc.GetNote(aPos) == nullptr;
396  }
397  break;
398  }
399  if (!bDisable && bNeedEdit)
400  if (!rDoc.IsBlockEditable( aCursor.Tab(), aCursor.Col(),aCursor.Row(),
401  aCursor.Col(),aCursor.Row() ))
402  bDisable = true;
403  if (bDisable)
404  rSet.DisableItem(nWhich);
405  nWhich = aIter.NextWhich();
406  }
407 }
408 
409 static bool lcl_TestFormat( SvxClipboardFormatItem& rFormats, const TransferableDataHelper& rDataHelper,
410  SotClipboardFormatId nFormatId )
411 {
412  if ( rDataHelper.HasFormat( nFormatId ) )
413  {
414  // translated format name strings are no longer inserted here,
415  // handled by "paste special" dialog / toolbox controller instead.
416  // Only the object type name has to be set here:
417  OUString aStrVal;
418  if ( nFormatId == SotClipboardFormatId::EMBED_SOURCE )
419  {
421  if ( const_cast<TransferableDataHelper&>(rDataHelper).GetTransferableObjectDescriptor(
422  SotClipboardFormatId::OBJECTDESCRIPTOR, aDesc ) )
423  aStrVal = aDesc.maTypeName;
424  }
425  else if ( nFormatId == SotClipboardFormatId::EMBED_SOURCE_OLE
426  || nFormatId == SotClipboardFormatId::EMBEDDED_OBJ_OLE )
427  {
428  OUString aSource;
429  SvPasteObjectHelper::GetEmbeddedName( rDataHelper, aStrVal, aSource, nFormatId );
430  }
431 
432  if ( !aStrVal.isEmpty() )
433  rFormats.AddClipbrdFormat( nFormatId, aStrVal );
434  else
435  rFormats.AddClipbrdFormat( nFormatId );
436 
437  return true;
438  }
439 
440  return false;
441 }
442 
444 {
445  vcl::Window* pWin = GetViewData()->GetActiveWin();
447 
449 
450  lcl_TestFormat( rFormats, aDataHelper, SotClipboardFormatId::DRAWING );
451  lcl_TestFormat( rFormats, aDataHelper, SotClipboardFormatId::SVXB );
452  lcl_TestFormat( rFormats, aDataHelper, SotClipboardFormatId::GDIMETAFILE );
453  lcl_TestFormat( rFormats, aDataHelper, SotClipboardFormatId::PNG );
454  lcl_TestFormat( rFormats, aDataHelper, SotClipboardFormatId::BITMAP );
455  lcl_TestFormat( rFormats, aDataHelper, SotClipboardFormatId::EMBED_SOURCE );
456 
457  if ( !bDraw )
458  {
459  lcl_TestFormat( rFormats, aDataHelper, SotClipboardFormatId::LINK );
460  lcl_TestFormat( rFormats, aDataHelper, SotClipboardFormatId::STRING );
461  lcl_TestFormat( rFormats, aDataHelper, SotClipboardFormatId::STRING_TSVC );
462  lcl_TestFormat( rFormats, aDataHelper, SotClipboardFormatId::DIF );
463  lcl_TestFormat( rFormats, aDataHelper, SotClipboardFormatId::RTF );
464  lcl_TestFormat( rFormats, aDataHelper, SotClipboardFormatId::RICHTEXT );
465  lcl_TestFormat( rFormats, aDataHelper, SotClipboardFormatId::HTML );
466  lcl_TestFormat( rFormats, aDataHelper, SotClipboardFormatId::HTML_SIMPLE );
467  lcl_TestFormat( rFormats, aDataHelper, SotClipboardFormatId::BIFF_8 );
468  lcl_TestFormat( rFormats, aDataHelper, SotClipboardFormatId::BIFF_5 );
469  }
470 
471  if ( !lcl_TestFormat( rFormats, aDataHelper, SotClipboardFormatId::EMBED_SOURCE_OLE ) )
472  lcl_TestFormat( rFormats, aDataHelper, SotClipboardFormatId::EMBEDDED_OBJ_OLE );
473 }
474 
475 // insert, insert contents
476 
478 {
479  bool bPossible = false;
480  css::uno::Reference< css::datatransfer::XTransferable2 > xTransferable(rData.GetXTransferable(), css::uno::UNO_QUERY);
481  if ( ScTransferObj::GetOwnClipboard(xTransferable) || ScDrawTransferObj::GetOwnClipboard(xTransferable) )
482  bPossible = true;
483  else
484  {
485  if ( rData.HasFormat( SotClipboardFormatId::PNG ) ||
486  rData.HasFormat( SotClipboardFormatId::BITMAP ) ||
487  rData.HasFormat( SotClipboardFormatId::GDIMETAFILE ) ||
488  rData.HasFormat( SotClipboardFormatId::SVXB ) ||
489  rData.HasFormat( SotClipboardFormatId::PRIVATE ) ||
490  rData.HasFormat( SotClipboardFormatId::RTF ) ||
491  rData.HasFormat( SotClipboardFormatId::RICHTEXT ) ||
492  rData.HasFormat( SotClipboardFormatId::EMBED_SOURCE ) ||
493  rData.HasFormat( SotClipboardFormatId::LINK_SOURCE ) ||
494  rData.HasFormat( SotClipboardFormatId::EMBED_SOURCE_OLE ) ||
495  rData.HasFormat( SotClipboardFormatId::LINK_SOURCE_OLE ) ||
496  rData.HasFormat( SotClipboardFormatId::EMBEDDED_OBJ_OLE ) ||
497  rData.HasFormat( SotClipboardFormatId::STRING ) ||
498  rData.HasFormat( SotClipboardFormatId::STRING_TSVC ) ||
499  rData.HasFormat( SotClipboardFormatId::SYLK ) ||
500  rData.HasFormat( SotClipboardFormatId::LINK ) ||
501  rData.HasFormat( SotClipboardFormatId::HTML ) ||
502  rData.HasFormat( SotClipboardFormatId::HTML_SIMPLE ) ||
503  rData.HasFormat( SotClipboardFormatId::DIF ) )
504  {
505  bPossible = true;
506  }
507  }
508  return bPossible;
509 }
510 
512 {
513  vcl::Window* pWin = GetViewData()->GetActiveWin();
515  return aDataHelper.HasFormat( nFormatId );
516 }
517 
518 IMPL_LINK( ScCellShell, ClipboardChanged, TransferableDataHelper*, pDataHelper, void )
519 {
520  bPastePossible = lcl_IsCellPastePossible( *pDataHelper );
521 
522  SfxBindings& rBindings = GetViewData()->GetBindings();
523  rBindings.Invalidate( SID_PASTE );
524  rBindings.Invalidate( SID_PASTE_SPECIAL );
525  rBindings.Invalidate( SID_PASTE_UNFORMATTED );
526  rBindings.Invalidate( SID_PASTE_ONLY_VALUE );
527  rBindings.Invalidate( SID_PASTE_ONLY_TEXT );
528  rBindings.Invalidate( SID_PASTE_ONLY_FORMULA );
529  rBindings.Invalidate( SID_PASTE_TEXTIMPORT_DIALOG );
530  rBindings.Invalidate( SID_CLIPBOARD_FORMAT_ITEMS );
531 }
532 
533 namespace {
534 
535 bool checkDestRanges(ScViewData& rViewData)
536 {
537  ScRange aDummy;
538  ScMarkType eMarkType = rViewData.GetSimpleArea( aDummy);
539  if (eMarkType != SC_MARK_MULTI)
540  {
541  // Single destination range.
542  if (eMarkType != SC_MARK_SIMPLE && eMarkType != SC_MARK_SIMPLE_FILTERED)
543  return false;
544  }
545 
546  if (rViewData.SelectionForbidsCellFill())
547  return false;
548 
549  // Multiple destination ranges.
550 
551  ScDocument& rDoc = rViewData.GetDocument();
552  vcl::Window* pWin = rViewData.GetActiveWin();
553  if (!pWin)
554  return false;
555 
557  if (!pOwnClip)
558  // If it's not a Calc document, we won't be picky.
559  return true;
560 
561  ScDocument* pClipDoc = pOwnClip->GetDocument();
562  if (!pClipDoc)
563  return false;
564 
565  ScRange aSrcRange = pClipDoc->GetClipParam().getWholeRange();
566  SCROW nRowSize = aSrcRange.aEnd.Row() - aSrcRange.aStart.Row() + 1;
567  SCCOL nColSize = aSrcRange.aEnd.Col() - aSrcRange.aStart.Col() + 1;
568 
569  ScMarkData aMark = rViewData.GetMarkData();
570  ScRangeList aRanges;
571  aMark.MarkToSimple();
572  aMark.FillRangeListWithMarks(&aRanges, false);
573 
574  return ScClipUtil::CheckDestRanges(rDoc, nColSize, nRowSize, aMark, aRanges);
575 }
576 
577 }
578 
580 {
581 // SID_PASTE
582 // SID_PASTE_SPECIAL
583 // SID_PASTE_UNFORMATTED
584 // SID_CLIPBOARD_FORMAT_ITEMS
585 
586  if ( !pImpl->m_xClipEvtLstnr.is() )
587  {
588  // create listener
589  pImpl->m_xClipEvtLstnr = new TransferableClipboardListener( LINK( this, ScCellShell, ClipboardChanged ) );
590  vcl::Window* pWin = GetViewData()->GetActiveWin();
591  pImpl->m_xClipEvtLstnr->AddListener( pWin );
592 
593  // get initial state
595  bPastePossible = lcl_IsCellPastePossible( aDataHelper );
596  }
597 
598  bool bDisable = !bPastePossible;
599 
600  // cell protection / multiple selection
601 
602  if (!bDisable)
603  {
604  SCCOL nCol = GetViewData()->GetCurX();
605  SCROW nRow = GetViewData()->GetCurY();
606  SCTAB nTab = GetViewData()->GetTabNo();
608  if (!rDoc.IsBlockEditable( nTab, nCol,nRow, nCol,nRow ))
609  bDisable = true;
610 
611  if (!bDisable && !checkDestRanges(*GetViewData()))
612  bDisable = true;
613  }
614 
615  if (bDisable)
616  {
617  rSet.DisableItem( SID_PASTE );
618  rSet.DisableItem( SID_PASTE_SPECIAL );
619  rSet.DisableItem( SID_PASTE_UNFORMATTED );
620  rSet.DisableItem( SID_PASTE_ONLY_VALUE );
621  rSet.DisableItem( SID_PASTE_ONLY_TEXT );
622  rSet.DisableItem( SID_PASTE_ONLY_FORMULA );
623  rSet.DisableItem( SID_PASTE_TEXTIMPORT_DIALOG );
624  rSet.DisableItem( SID_CLIPBOARD_FORMAT_ITEMS );
625  }
626  else if ( rSet.GetItemState( SID_CLIPBOARD_FORMAT_ITEMS ) != SfxItemState::UNKNOWN )
627  {
628  SvxClipboardFormatItem aFormats( SID_CLIPBOARD_FORMAT_ITEMS );
629  GetPossibleClipboardFormats( aFormats );
630  rSet.Put( aFormats );
631  }
632 }
633 
634 // only SID_HYPERLINK_GETLINK:
635 
637 {
638  // always return an item (or inserting will be disabled)
639  // if the cell at the cursor contains only a link, return that link
640 
641  SvxHyperlinkItem aHLinkItem;
642  if ( !GetViewData()->GetView()->HasBookmarkAtCursor( &aHLinkItem ) )
643  {
645  }
646 
647  rSet.Put(aHLinkItem);
648 }
649 
651 {
652  ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
653  ScDocShell* pDocSh = GetViewData()->GetDocShell();
655  ScDocument& rDoc = pData->GetDocument();
656  ScMarkData& rMark = pData->GetMarkData();
657  SCCOL nPosX = pData->GetCurX();
658  SCROW nPosY = pData->GetCurY();
659  SCTAB nTab = pData->GetTabNo();
660 
661  SCTAB nTabCount = rDoc.GetTableCount();
662  SCTAB nTabSelCount = rMark.GetSelectCount();
663 
664  SfxWhichIter aIter(rSet);
665  sal_uInt16 nWhich = aIter.FirstWhich();
666  while ( nWhich )
667  {
668  switch ( nWhich )
669  {
670  case SID_DETECTIVE_REFRESH:
671  if (!rDoc.HasDetectiveOperations())
672  rSet.DisableItem( nWhich );
673  break;
674 
675  case SID_RANGE_ADDRESS:
676  {
677  ScRange aRange;
678  if ( pData->GetSimpleArea( aRange ) == SC_MARK_SIMPLE )
679  {
680  OUString aStr(aRange.Format(rDoc, ScRefFlags::VALID | ScRefFlags::TAB_3D));
681  rSet.Put( SfxStringItem( nWhich, aStr ) );
682  }
683  }
684  break;
685 
686  case SID_RANGE_NOTETEXT:
687  {
688  // always take cursor position, do not use top-left cell of selection
689  OUString aNoteText;
690  if ( const ScPostIt* pNote = rDoc.GetNote(nPosX, nPosY, nTab) )
691  aNoteText = pNote->GetText();
692  rSet.Put( SfxStringItem( nWhich, aNoteText ) );
693  }
694  break;
695 
696  case SID_RANGE_ROW:
697  rSet.Put( SfxInt32Item( nWhich, nPosY+1 ) );
698  break;
699 
700  case SID_RANGE_COL:
701  rSet.Put( SfxInt16Item( nWhich, nPosX+1 ) );
702  break;
703 
704  case SID_RANGE_TABLE:
705  rSet.Put( SfxInt16Item( nWhich, nTab+1 ) );
706  break;
707 
708  case SID_RANGE_FORMULA:
709  {
710  OUString aString;
711  rDoc.GetFormula( nPosX, nPosY, nTab, aString );
712  if( aString.isEmpty() )
713  {
714  rDoc.GetInputString( nPosX, nPosY, nTab, aString );
715  }
716  rSet.Put( SfxStringItem( nWhich, aString ) );
717  }
718  break;
719 
720  case SID_RANGE_TEXTVALUE:
721  {
722  OUString aString = rDoc.GetString(nPosX, nPosY, nTab);
723  rSet.Put( SfxStringItem( nWhich, aString ) );
724  }
725  break;
726 
727  case SID_STATUS_SELMODE:
728  {
729  /* 0: STD Click cancels Sel
730  * 1: ER Click extends selection
731  * 2: ERG Click defines further selection
732  */
733  sal_uInt16 nMode = pTabViewShell->GetLockedModifiers();
734 
735  switch ( nMode )
736  {
737  case KEY_SHIFT: nMode = 1; break;
738  case KEY_MOD1: nMode = 2; break; // Control-key
739  case 0:
740  default:
741  nMode = 0;
742  }
743 
744  rSet.Put( SfxUInt16Item( nWhich, nMode ) );
745  }
746  break;
747 
748  case SID_STATUS_DOCPOS:
749  {
750  OUString aStr = ScResId( STR_TABLE_COUNT );
751 
752  aStr = aStr.replaceFirst("%1", OUString::number( nTab + 1 ) );
753  aStr = aStr.replaceFirst("%2", OUString::number( nTabCount ) );
754 
755  rSet.Put( SfxStringItem( nWhich, aStr ) ); }
756  break;
757 
758  case SID_ROWCOL_SELCOUNT:
759  {
760  ScRange aMarkRange;
761  GetViewData()->GetSimpleArea( aMarkRange );
762  SCCOL nCol1, nCol2;
763  SCROW nRow1, nRow2;
764  nCol1 = aMarkRange.aStart.Col();
765  nRow1 = aMarkRange.aStart.Row();
766  nCol2 = aMarkRange.aEnd.Col();
767  nRow2 = aMarkRange.aEnd.Row();
768  if( nCol2 != nCol1 || nRow1 != nRow2 )
769  {
770  const auto nRows = nRow2 - nRow1 + 1;
771  const auto nCols = nCol2 - nCol1 + 1;
773  OUString aRowArg = ScResId(STR_SELCOUNT_ROWARG, nRows).replaceAll("$1", rLocaleData.getNum(nRows, 0));
774  OUString aColArg = ScResId(STR_SELCOUNT_COLARG, nCols).replaceAll("$1", rLocaleData.getNum(nCols, 0));
775  OUString aStr = ScResId(STR_SELCOUNT);
776  aStr = aStr.replaceAll("$1", aRowArg);
777  aStr = aStr.replaceAll("$2", aColArg);
778  rSet.Put( SfxStringItem( nWhich, aStr ) );
779  }
780  else
781  {
782  SCSIZE nSelected, nTotal;
783  rDoc.GetFilterSelCount( nPosX, nPosY, nTab, nSelected, nTotal );
784  if( nTotal )
785  {
786  OUString aStr = ScResId( STR_FILTER_SELCOUNT );
787  aStr = aStr.replaceAll( "$1", OUString::number( nSelected ) );
788  aStr = aStr.replaceAll( "$2", OUString::number( nTotal ) );
789  rSet.Put( SfxStringItem( nWhich, aStr ) );
790  }
791  }
792  }
793  break;
794 
795  // calculations etc. with date/time/Fail/position&size together
796 
797  // #i34458# The SfxStringItem belongs only into SID_TABLE_CELL. It no longer has to be
798  // duplicated in SID_ATTR_POSITION or SID_ATTR_SIZE for SvxPosSizeStatusBarControl.
799  case SID_TABLE_CELL:
800  {
801  // Test, if error under cursor
802  // (not rDoc.GetErrCode, to avoid erasing circular references)
803 
804  // In interpreter may happen via rescheduled Basic
805  if ( rDoc.IsInInterpreter() )
806  rSet.Put( SfxStringItem( nWhich, "..." ) );
807  else
808  {
809  FormulaError nErrCode = FormulaError::NONE;
810  ScFormulaCell* pCell = rDoc.GetFormulaCell(ScAddress(nPosX, nPosY, nTab));
811  if (pCell && !pCell->IsRunning())
812  nErrCode = pCell->GetErrCode();
813 
814  OUString aFuncStr;
815  if ( pTabViewShell->GetFunction( aFuncStr, nErrCode ) )
816  rSet.Put( SfxStringItem( nWhich, aFuncStr ) );
817  }
818  }
819  break;
820 
821  case SID_DATA_SELECT:
822  // HasSelectionData includes column content and validity,
823  // page fields have to be checked separately.
824  if ( !rDoc.HasSelectionData( nPosX, nPosY, nTab ) &&
825  !pTabViewShell->HasPageFieldDataAtCursor() )
826  rSet.DisableItem( nWhich );
827  break;
828 
829  case FID_CURRENTVALIDATION:
830  if ( !rDoc.HasValidationData( nPosX, nPosY, nTab ))
831  rSet.DisableItem( nWhich );
832  break;
833 
834  case SID_STATUS_SUM:
835  {
836  OUString aFuncStr;
837  if ( pTabViewShell->GetFunction( aFuncStr, FormulaError::NONE ) )
838  rSet.Put( SfxStringItem( nWhich, aFuncStr ) );
839  }
840  break;
841 
842  case FID_MERGE_ON:
843  if ( rDoc.GetChangeTrack() || !pTabViewShell->TestMergeCells() )
844  rSet.DisableItem( nWhich );
845  break;
846 
847  case FID_MERGE_OFF:
848  if ( rDoc.GetChangeTrack() || !pTabViewShell->TestRemoveMerge() )
849  rSet.DisableItem( nWhich );
850  break;
851 
852  case FID_MERGE_TOGGLE:
853  if ( rDoc.GetChangeTrack() )
854  rSet.DisableItem( nWhich );
855  else
856  {
857  bool bCanMerge = pTabViewShell->TestMergeCells();
858  bool bCanSplit = pTabViewShell->TestRemoveMerge();
859  if( !bCanMerge && !bCanSplit )
860  rSet.DisableItem( nWhich );
861  else
862  rSet.Put( SfxBoolItem( nWhich, bCanSplit ) );
863  }
864  break;
865 
866  case FID_INS_ROWBRK:
867  if ( nPosY==0 || (rDoc.HasRowBreak(nPosY, nTab) & ScBreakType::Manual) || rDoc.IsTabProtected(nTab) )
868  rSet.DisableItem( nWhich );
869  break;
870 
871  case FID_INS_COLBRK:
872  if ( nPosX==0 || (rDoc.HasColBreak(nPosX, nTab) & ScBreakType::Manual) || rDoc.IsTabProtected(nTab) )
873  rSet.DisableItem( nWhich );
874  break;
875 
876  case FID_DEL_ROWBRK:
877  if ( nPosY==0 || !(rDoc.HasRowBreak(nPosY, nTab) & ScBreakType::Manual) || rDoc.IsTabProtected(nTab) )
878  rSet.DisableItem( nWhich );
879  break;
880 
881  case FID_DEL_COLBRK:
882  if ( nPosX==0 || !(rDoc.HasColBreak(nPosX, nTab) & ScBreakType::Manual) || rDoc.IsTabProtected(nTab) )
883  rSet.DisableItem( nWhich );
884  break;
885 
886  case FID_FILL_TAB:
887  if ( nTabSelCount < 2 )
888  rSet.DisableItem( nWhich );
889  break;
890 
891  case SID_INSERT_CURRENT_DATE:
892  case SID_INSERT_CURRENT_TIME:
893  {
894  if ( rDoc.IsTabProtected(nTab) &&
895  rDoc.HasAttrib(nPosX, nPosY, nTab, nPosX, nPosY, nTab, HasAttrFlags::Protected))
896  rSet.DisableItem( nWhich );
897  }
898  break;
899 
900  case SID_SELECT_SCENARIO:
901  {
902  std::vector<OUString> aList;
903  Color aDummyCol;
904 
905  if ( !rDoc.IsScenario(nTab) )
906  {
907  OUString aStr;
908  ScScenarioFlags nFlags;
909  SCTAB nScTab = nTab + 1;
910  bool bSheetProtected = rDoc.IsTabProtected(nTab);
911 
912  while ( rDoc.IsScenario(nScTab) )
913  {
914  rDoc.GetName( nScTab, aStr );
915  aList.push_back(aStr);
916  rDoc.GetScenarioData( nScTab, aStr, aDummyCol, nFlags );
917  aList.push_back(aStr);
918  // Protection is sal_True if both Sheet and Scenario are protected
919  aList.push_back((bSheetProtected && (nFlags & ScScenarioFlags::Protected)) ? OUString("1") : OUString("0"));
920  ++nScTab;
921  }
922  }
923  else
924  {
925  OUString aComment;
926  ScScenarioFlags nDummyFlags;
927  rDoc.GetScenarioData( nTab, aComment, aDummyCol, nDummyFlags );
928  OSL_ENSURE( aList.empty(), "List not empty!" );
929  aList.push_back(aComment);
930  }
931 
932  rSet.Put( SfxStringListItem( nWhich, &aList ) );
933  }
934  break;
935 
936  case FID_ROW_HIDE:
937  case FID_ROW_SHOW:
938  case FID_COL_HIDE:
939  case FID_COL_SHOW:
940  case FID_COL_OPT_WIDTH:
941  case FID_ROW_OPT_HEIGHT:
942  case FID_DELETE_CELL:
943  if ( rDoc.IsTabProtected(nTab) || pDocSh->IsReadOnly())
944  rSet.DisableItem( nWhich );
945  break;
946 
947  case SID_OUTLINE_MAKE:
948  {
949  if ( GetViewData()->GetDocument().GetDPAtCursor( GetViewData()->GetCurX(),
950  GetViewData()->GetCurY(), GetViewData()->GetTabNo() ) )
951  {
953  }
954  else if (rDoc.GetChangeTrack()!=nullptr || GetViewData()->IsMultiMarked())
955  {
956  rSet.DisableItem( nWhich );
957  }
958  }
959  break;
960  case SID_OUTLINE_SHOW:
961  if ( GetViewData()->GetDocument().GetDPAtCursor( GetViewData()->GetCurX(),
962  GetViewData()->GetCurY(), GetViewData()->GetTabNo() ) )
963  {
965  }
966  else if (!pTabViewShell->OutlinePossible(false))
967  rSet.DisableItem( nWhich );
968  break;
969 
970  case SID_OUTLINE_HIDE:
971  if ( GetViewData()->GetDocument().GetDPAtCursor( GetViewData()->GetCurX(),
972  GetViewData()->GetCurY(), GetViewData()->GetTabNo() ) )
973  {
975  }
976  else if (!pTabViewShell->OutlinePossible(true))
977  rSet.DisableItem( nWhich );
978  break;
979 
980  case SID_OUTLINE_REMOVE:
981  {
982  if ( GetViewData()->GetDocument().GetDPAtCursor( GetViewData()->GetCurX(),
983  GetViewData()->GetCurY(), GetViewData()->GetTabNo() ) )
984  {
986  }
987  else
988  {
989  bool bCol, bRow;
990  pTabViewShell->TestRemoveOutline( bCol, bRow );
991  if ( !bCol && !bRow )
992  rSet.DisableItem( nWhich );
993  }
994  }
995  break;
996 
997  case FID_COL_WIDTH:
998  {
999  SfxUInt16Item aWidthItem( FID_COL_WIDTH, rDoc.GetColWidth( nPosX , nTab) );
1000  rSet.Put( aWidthItem );
1001  if ( pDocSh->IsReadOnly())
1002  rSet.DisableItem( nWhich );
1003 
1004  //XXX disable if not conclusive
1005  }
1006  break;
1007 
1008  case FID_ROW_HEIGHT:
1009  {
1010  SfxUInt16Item aHeightItem( FID_ROW_HEIGHT, rDoc.GetRowHeight( nPosY , nTab) );
1011  rSet.Put( aHeightItem );
1012  //XXX disable if not conclusive
1013  if ( pDocSh->IsReadOnly())
1014  rSet.DisableItem( nWhich );
1015  }
1016  break;
1017 
1018  case SID_DETECTIVE_FILLMODE:
1019  rSet.Put(SfxBoolItem( nWhich, pTabViewShell->IsAuditShell() ));
1020  break;
1021 
1022  case FID_INPUTLINE_STATUS:
1023  OSL_FAIL( "Old update method. Use ScTabViewShell::UpdateInputHandler()." );
1024  break;
1025 
1026  case SID_SCENARIOS: // scenarios:
1027  if (!(rMark.IsMarked() || rMark.IsMultiMarked())) // only, if something selected
1028  rSet.DisableItem( nWhich );
1029  break;
1030 
1031  case FID_NOTE_VISIBLE:
1032  {
1033  const ScPostIt* pNote = rDoc.GetNote(nPosX, nPosY, nTab);
1034  if ( pNote && rDoc.IsBlockEditable( nTab, nPosX,nPosY, nPosX,nPosY ) )
1035  rSet.Put( SfxBoolItem( nWhich, pNote->IsCaptionShown() ) );
1036  else
1037  rSet.DisableItem( nWhich );
1038  }
1039  break;
1040 
1041  case FID_HIDE_NOTE:
1042  case FID_SHOW_NOTE:
1043  {
1044  bool bEnable = false;
1045  bool bSearchForHidden = nWhich == FID_SHOW_NOTE;
1046  if (!rMark.IsMarked() && !rMark.IsMultiMarked())
1047  {
1048  // Check current cell
1049  const ScPostIt* pNote = rDoc.GetNote(nPosX, nPosY, nTab);
1050  if ( pNote && rDoc.IsBlockEditable( nTab, nPosX,nPosY, nPosX,nPosY ) )
1051  if ( pNote->IsCaptionShown() != bSearchForHidden)
1052  bEnable = true;
1053  }
1054  else
1055  {
1056  // Check selection range
1057  ScRangeListRef aRangesRef;
1058  pData->GetMultiArea(aRangesRef);
1059  ScRangeList aRanges = *aRangesRef;
1060  std::vector<sc::NoteEntry> aNotes;
1061  rDoc.GetNotesInRange(aRanges, aNotes);
1062  for(const auto& rNote : aNotes)
1063  {
1064  const ScAddress& rAdr = rNote.maPos;
1065  if( rDoc.IsBlockEditable( rAdr.Tab(), rAdr.Col(), rAdr.Row(), rAdr.Col(), rAdr.Row() ))
1066  {
1067  if (rNote.mpNote->IsCaptionShown() != bSearchForHidden)
1068  {
1069  bEnable = true;
1070  break;
1071  }
1072  }
1073  }
1074 
1075  }
1076  if ( !bEnable )
1077  rSet.DisableItem( nWhich );
1078  }
1079  break;
1080 
1081  case FID_SHOW_ALL_NOTES:
1082  case FID_HIDE_ALL_NOTES:
1083  case FID_DELETE_ALL_NOTES:
1084  {
1085  bool bHasNotes = false;
1086 
1087  for (auto const& rTab : rMark.GetSelectedTabs())
1088  {
1089  if (rDoc.HasTabNotes( rTab ))
1090  {
1091  bHasNotes = true;
1092  break;
1093  }
1094  }
1095 
1096  if ( !bHasNotes )
1097  rSet.DisableItem( nWhich );
1098  }
1099  break;
1100 
1101  case SID_TOGGLE_NOTES:
1102  {
1103  bool bHasNotes = false;
1104  ScRangeList aRanges;
1105 
1106  for (auto const& rTab : rMark.GetSelectedTabs())
1107  {
1108  if (rDoc.HasTabNotes( rTab ))
1109  {
1110  bHasNotes = true;
1111  aRanges.push_back(ScRange(0,0,rTab,rDoc.MaxCol(),rDoc.MaxRow(),rTab));
1112  }
1113  }
1114 
1115  if ( !bHasNotes )
1116  rSet.DisableItem( nWhich );
1117  else
1118  {
1119  CommentCaptionState eState = rDoc.GetAllNoteCaptionsState( aRanges );
1120  bool bAllNotesInShown = (eState != ALLHIDDEN && eState != MIXED);
1121  rSet.Put( SfxBoolItem( SID_TOGGLE_NOTES, bAllNotesInShown) );
1122  }
1123  }
1124  break;
1125 
1126  case SID_DELETE_NOTE:
1127  {
1128  bool bEnable = false;
1129  if ( rMark.IsMarked() || rMark.IsMultiMarked() )
1130  {
1131  if ( rDoc.IsSelectionEditable( rMark ) )
1132  {
1133  // look for at least one note in selection
1134  ScRangeList aRanges;
1135  rMark.FillRangeListWithMarks( &aRanges, false );
1136  bEnable = rDoc.ContainsNotesInRange( aRanges );
1137  }
1138  }
1139  else
1140  {
1141  bEnable = rDoc.IsBlockEditable( nTab, nPosX,nPosY, nPosX,nPosY ) &&
1142  rDoc.GetNote(nPosX, nPosY, nTab);
1143  }
1144  if ( !bEnable )
1145  rSet.DisableItem( nWhich );
1146  }
1147  break;
1148 
1149  case SID_OPENDLG_CONSOLIDATE:
1151  {
1152  if (rDoc.GetChangeTrack()!=nullptr)
1153  rSet.DisableItem( nWhich);
1154  }
1155  break;
1156 
1157  case SID_CHINESE_CONVERSION:
1158  case SID_HANGUL_HANJA_CONVERSION:
1159  ScViewUtil::HideDisabledSlot( rSet, pData->GetBindings(), nWhich );
1160  break;
1161 
1162  case FID_USE_NAME:
1163  {
1164  if ( pDocSh && pDocSh->IsDocShared() )
1165  rSet.DisableItem( nWhich );
1166  else
1167  {
1168  ScRange aRange;
1169  if ( pData->GetSimpleArea( aRange ) != SC_MARK_SIMPLE )
1170  rSet.DisableItem( nWhich );
1171  }
1172  }
1173  break;
1174 
1175  case FID_DEFINE_NAME:
1176  case FID_INSERT_NAME:
1177  case FID_ADD_NAME:
1178  case SID_DEFINE_COLROWNAMERANGES:
1179  {
1180  if ( pDocSh && pDocSh->IsDocShared() )
1181  {
1182  rSet.DisableItem( nWhich );
1183  }
1184  }
1185  break;
1186 
1187  case FID_DEFINE_CURRENT_NAME:
1188  {
1189  ScAddress aCurrentAddress( nPosX, nPosY, nTab );
1190 
1191  if ( !rDoc.IsAddressInRangeName( RangeNameScope::GLOBAL, aCurrentAddress ) &&
1192  !rDoc.IsAddressInRangeName( RangeNameScope::SHEET, aCurrentAddress ))
1193  {
1194  rSet.DisableItem( nWhich );
1195  }
1196  }
1197  break;
1198 
1199  case SID_SPELL_DIALOG:
1200  {
1201  if ( pData && rDoc.IsTabProtected( pData->GetTabNo() ) )
1202  {
1203  bool bVisible = false;
1204  SfxViewFrame* pViewFrame = ( pTabViewShell ? pTabViewShell->GetViewFrame() : nullptr );
1205  if ( pViewFrame && pViewFrame->HasChildWindow( nWhich ) )
1206  {
1207  SfxChildWindow* pChild = pViewFrame->GetChildWindow( nWhich );
1208  std::shared_ptr<SfxDialogController> xController = pChild ? pChild->GetController() : nullptr;
1209  if (xController && xController->getDialog()->get_visible())
1210  {
1211  bVisible = true;
1212  }
1213  }
1214  if ( !bVisible )
1215  {
1216  rSet.DisableItem( nWhich );
1217  }
1218  }
1219  }
1220  break;
1221 
1222  case SID_OPENDLG_CURRENTCONDFRMT:
1223  case SID_OPENDLG_CURRENTCONDFRMT_MANAGER:
1224  {
1225  const SfxPoolItem* pItem = rDoc.GetAttr( nPosX, nPosY, nTab, ATTR_CONDITIONAL );
1226  const ScCondFormatItem* pCondFormatItem = static_cast<const ScCondFormatItem*>(pItem);
1227 
1228  if ( pCondFormatItem->GetCondFormatData().empty() )
1229  rSet.DisableItem( nWhich );
1230  else if ( pCondFormatItem->GetCondFormatData().size() == 1 )
1231  rSet.DisableItem( SID_OPENDLG_CURRENTCONDFRMT_MANAGER );
1232  else if ( pCondFormatItem->GetCondFormatData().size() > 1 )
1233  rSet.DisableItem( SID_OPENDLG_CURRENTCONDFRMT );
1234  }
1235  break;
1236 
1237  } // switch ( nWitch )
1238  nWhich = aIter.NextWhich();
1239  } // while ( nWitch )
1240 }
1241 
1242 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ScMarkData & GetMarkData()
Definition: viewdata.cxx:3046
bool HasClipboardFormat(SotClipboardFormatId nFormatId)
Definition: cellsh.cxx:511
std::shared_ptr< SfxDialogController > & GetController()
SfxViewFrame * GetViewFrame() const
bool IsBlockEditable(SCTAB nTab, SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, bool *pOnlyNotBecauseOfMatrix=nullptr, bool bNoMatrixAtAll=false) const
Definition: document.cxx:5327
static ScDrawTransferObj * GetOwnClipboard(const css::uno::Reference< css::datatransfer::XTransferable2 > &)
Definition: drwtrans.cxx:230
static void HideDisabledSlot(SfxItemSet &rSet, SfxBindings &rBindings, sal_uInt16 nSlotId)
Definition: viewutil.cxx:285
void MarkToSimple()
Definition: markdata.cxx:237
ScAddress aStart
Definition: address.hxx:500
ScDocShell * GetDocShell() const
Definition: viewdata.hxx:354
bool bVisible
SC_DLLPUBLIC bool IsTabProtected(SCTAB nTab) const
Definition: documen3.cxx:1890
SC_DLLPUBLIC void GetInputString(SCCOL nCol, SCROW nRow, SCTAB nTab, OUString &rString)
Definition: document.cxx:3540
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
Definition: markdata.hxx:43
SfxChildWindow * GetChildWindow(sal_uInt16)
bool isContentExtractionLocked() const
constexpr sal_uInt16 KEY_MOD1
#define SFX_IMPL_INTERFACE(Class, SuperClass)
bool IsInInterpreter() const
Definition: document.hxx:2310
SCROW Row() const
Definition: address.hxx:262
std::unique_ptr< ContentProperties > pData
ScViewData * GetViewData()
Definition: formatsh.hxx:35
SC_DLLPUBLIC const ScFormulaCell * GetFormulaCell(const ScAddress &rPos) const
Definition: document.cxx:3723
ScScenarioFlags
Definition: global.hxx:237
bool IsAddressInRangeName(RangeNameScope eScope, const ScAddress &rAddress)
Definition: documen3.cxx:196
SC_DLLPUBLIC bool HasTabNotes(SCTAB nTab) const
Definition: document.cxx:6566
static const AllSettings & GetSettings()
SCROW GetCurY() const
Definition: viewdata.hxx:402
void FillRangeListWithMarks(ScRangeList *pList, bool bClear, SCTAB nForTab=-1) const
Create a range list of marks.
Definition: markdata.cxx:387
sal_uInt16 FirstWhich()
sal_uInt16 GetLockedModifiers() const
Definition: tabview.cxx:1890
SCTAB GetTabNo() const
Definition: viewdata.hxx:395
bool SimpleRowMarked()
Definition: viewdata.cxx:1233
ScAddress aEnd
Definition: address.hxx:501
ScDocument & GetDocument() const
Definition: viewdata.hxx:380
static css::uno::Reference< css::datatransfer::XTransferable2 > GetClipData(vcl::Window *pWin)
Definition: tabvwshc.cxx:483
static bool HasThesaurusLanguage(LanguageType nLang)
Definition: scmod.cxx:2230
void Invalidate(sal_uInt16 nId)
virtual ~ScCellShell() override
Definition: cellsh.cxx:82
bool HasFormat(SotClipboardFormatId nFormat) const
const MarkedTabsType & GetSelectedTabs() const
Definition: markdata.hxx:98
SC_DLLPUBLIC bool HasAttrib(SCCOL nCol1, SCROW nRow1, SCTAB nTab1, SCCOL nCol2, SCROW nRow2, SCTAB nTab2, HasAttrFlags nMask) const
Definition: document.cxx:5179
void GetNotesInRange(const ScRangeList &rRange, std::vector< sc::NoteEntry > &rNotes) const
Definition: document.cxx:6766
SC_DLLPUBLIC void GetFormula(SCCOL nCol, SCROW nRow, SCTAB nTab, OUString &rFormula) const
Definition: document.cxx:3715
SC_DLLPUBLIC ScBreakType HasRowBreak(SCROW nRow, SCTAB nTab) const
Definition: document.cxx:4359
SC_DLLPUBLIC sal_uInt16 GetRowHeight(SCROW nRow, SCTAB nTab, bool bHiddenAsZero=true) const
Definition: document.cxx:4161
sal_uInt16 NextWhich()
void GetMarkArea(ScRange &rRange) const
Definition: markdata.cxx:112
SC_DLLPUBLIC ScPostIt * GetNote(const ScAddress &rPos)
Notes.
Definition: document.cxx:6508
CommentCaptionState GetAllNoteCaptionsState(const ScRangeList &rRanges)
Definition: document.cxx:6649
Reference< XController > xController
bool SelectionEditable(bool *pOnlyNotBecauseOfMatrix=nullptr)
Definition: viewfunc.cxx:260
ScClipParam & GetClipParam()
Definition: document.cxx:2549
SC_DLLPUBLIC SCROW MaxRow() const
Definition: document.hxx:873
size_t SCSIZE
size_t typedef to be able to find places where code was changed from USHORT to size_t and is used to ...
Definition: address.hxx:45
SC_DLLPUBLIC SCTAB GetTableCount() const
Definition: document.cxx:314
Additional class containing cell annotation data.
Definition: postit.hxx:160
bool IsMultiMarked() const
Definition: markdata.hxx:83
SCTAB GetSelectCount() const
Definition: markdata.cxx:195
FormulaError GetErrCode()
SC_DLLPUBLIC OUString GetString(SCCOL nCol, SCROW nRow, SCTAB nTab, const ScInterpreterContext *pContext=nullptr) const
Definition: document.cxx:3486
bool bPastePossible
Definition: cellsh.hxx:54
static TransferableDataHelper CreateFromSystemClipboard(vcl::Window *pWindow)
void push_back(const ScRange &rRange)
Definition: rangelst.cxx:1144
const LocaleDataWrapper & GetUILocaleDataWrapper() const
bool IsDocShared() const
SCTAB Tab() const
Definition: address.hxx:271
SotClipboardFormatId
bool GetFunction(OUString &rFuncStr, FormulaError nErrCode)
Definition: tabvwsha.cxx:69
size_type size() const
ScDocument * GetDocument() const
Definition: transobj.hxx:81
ScChangeTrack * GetChangeTrack() const
Definition: document.hxx:2392
SC_DLLPUBLIC const SfxPoolItem * GetAttr(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt16 nWhich) const
Definition: document.cxx:4714
bool HasValidationData(SCCOL nCol, SCROW nRow, SCTAB nTab) const
Definition: document.cxx:3809
ScCellShell(ScViewData &rData, const VclPtr< vcl::Window > &pFrameWin)
Definition: cellsh.cxx:72
void GetPossibleClipboardFormats(SvxClipboardFormatItem &rFormats)
Definition: cellsh.cxx:443
DocumentType eType
ScTabViewShell * GetViewShell() const
Definition: viewdata.hxx:357
SC_DLLPUBLIC SCCOL MaxCol() const
Definition: document.hxx:872
void GetState(SfxItemSet &)
Definition: cellsh.cxx:650
IMPL_LINK(ScCellShell, ClipboardChanged, TransferableDataHelper *, pDataHelper, void)
Definition: cellsh.cxx:518
bool IsMarked() const
Definition: markdata.hxx:82
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
static bool lcl_TestFormat(SvxClipboardFormatItem &rFormats, const TransferableDataHelper &rDataHelper, SotClipboardFormatId nFormatId)
Definition: cellsh.cxx:409
static bool lcl_IsCellPastePossible(const TransferableDataHelper &rData)
Definition: cellsh.cxx:477
SfxBindings & GetBindings()
Definition: viewdata.cxx:3034
ScMarkType
States GetSimpleArea() returns for the underlying selection marks, so the caller can react if the res...
Definition: viewdata.hxx:61
css::uno::Reference< css::datatransfer::XTransferable > GetXTransferable() const
sal_Int16 SCCOL
Definition: types.hxx:22
bool TestMergeCells()
Definition: viewfun2.cxx:1123
SC_DLLPUBLIC OUString Format(const ScDocument &rDocument, ScRefFlags nFlags=ScRefFlags::ZERO, const ScAddress::Details &rDetails=ScAddress::detailsOOOa1, bool bFullAddressNotation=false) const
Returns string with formatted cell range from aStart to aEnd, according to provided address conventio...
Definition: address.cxx:2203
bool OutlinePossible(bool bHide)
Definition: dbfunc3.cxx:305
OUString ScResId(const char *pId)
Definition: scdll.cxx:95
ScMarkType GetSimpleArea(SCCOL &rStartCol, SCROW &rStartRow, SCTAB &rStartTab, SCCOL &rEndCol, SCROW &rEndRow, SCTAB &rEndTab) const
Definition: viewdata.cxx:1170
ScGridWindow * GetActiveWin()
Definition: viewdata.cxx:3062
std::unique_ptr< CellShell_Impl > pImpl
Definition: cellsh.hxx:53
bool IsRunning() const
void SetName(const OUString &rName)
bool empty() const
bool HasPageFieldDataAtCursor() const
Definition: tabview.cxx:2164
CommentCaptionState
Definition: document.hxx:252
bool IsMultiMarked() const
Definition: viewdata.cxx:1248
bool HasSelectedBlockMatrixFragment(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, const ScMarkData &rMark) const
Definition: document.cxx:5407
FormulaError
SCCOL Col() const
Definition: address.hxx:267
bool IsReadOnly() const
#define SFX_OBJECTBAR_OBJECT
bool IsEditActionAllowed(sc::ColRowEditAction eAction, SCTAB nTab, SCCOLROW nStart, SCCOLROW nEnd) const
Definition: document10.cxx:950
bool IsAuditShell() const
Definition: tabvwsh4.cxx:996
SC_DLLPUBLIC void GetScenarioData(SCTAB nTab, OUString &rComment, Color &rColor, ScScenarioFlags &rFlags) const
Definition: documen3.cxx:463
bool CheckDestRanges(const ScDocument &rDoc, SCCOL nSrcCols, SCROW nSrcRows, const ScMarkData &rMark, const ScRangeList &rDest)
Definition: cliputil.cxx:96
void GetClipState(SfxItemSet &rSet)
Definition: cellsh.cxx:579
void GetFilterSelCount(SCCOL nCol, SCROW nRow, SCTAB nTab, SCSIZE &nSelected, SCSIZE &nTotal)
Definition: documen3.cxx:1520
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
sal_Int32 SCROW
Definition: types.hxx:18
static const OUString & GetContextName(const Context eContext)
ScRange getWholeRange() const
Return a single range that encompasses all individual ranges.
Definition: clipparam.cxx:103
bool HasChildWindow(sal_uInt16)
ColRowEditAction
Definition: global.hxx:436
bool HasFormulaCell(const ScRange &rRange) const
Check if there is at least one formula cell in specified range.
Definition: document10.cxx:446
void DisableItem(sal_uInt16 nWhich)
SC_DLLPUBLIC bool IsScenario(SCTAB nTab) const
Definition: documen3.cxx:427
CellType
Definition: global.hxx:282
bool HasSelectionData(SCCOL nCol, SCROW nRow, SCTAB nTab) const
Returns true, if there is any data to create a selection list for rPos.
Definition: document.cxx:3797
SC_DLLPUBLIC ScBreakType HasColBreak(SCCOL nCol, SCTAB nTab) const
Definition: document.cxx:4374
bool ContainsNotesInRange(const ScRangeList &rRange) const
Definition: document.cxx:6783
void GetBlockState(SfxItemSet &rSet)
Definition: cellsh.cxx:99
static SC_DLLPUBLIC ScTransferObj * GetOwnClipboard(const css::uno::Reference< css::datatransfer::XTransferable2 > &)
Definition: transobj.cxx:192
constexpr TypedWhichId< ScCondFormatItem > ATTR_CONDITIONAL(154)
const ScDocument & GetDocument() const
Definition: docsh.hxx:216
void GetCellState(SfxItemSet &rSet)
Definition: cellsh.cxx:331
const ScCondFormatIndexes & GetCondFormatData() const
Definition: attrib.hxx:280
void GetHLinkState(SfxItemSet &rSet)
Definition: cellsh.cxx:636
void AddClipbrdFormat(SotClipboardFormatId nId)
void GetMultiArea(ScRangeListRef &rRange) const
Definition: viewdata.cxx:1193
OUString getNum(sal_Int64 nNumber, sal_uInt16 nDecimals, bool bUseThousandSep=true, bool bTrailingZeros=true) const
bool SelectionForbidsCellFill()
Disallow cell fill (Paste,Fill,...) on Ctrl+A all selected or another high amount of selected cells...
Definition: viewdata.cxx:1258
static LanguageType GetEffLanguage(ScDocument &rDoc, const ScAddress &rPos)
Definition: viewutil.cxx:69
bool TestRemoveMerge()
Definition: viewfun2.cxx:1268
constexpr sal_uInt16 KEY_SHIFT
void TestRemoveOutline(bool &rCol, bool &rRow)
Definition: dbfunc3.cxx:129
SC_DLLPUBLIC sal_uInt16 GetColWidth(SCCOL nCol, SCTAB nTab, bool bHiddenAsZero=true) const
Definition: document.cxx:4120
bool HasDetectiveOperations() const
Definition: documen4.cxx:885
void SetContextName(const OUString &rsContextName)
aStr
SC_DLLPUBLIC bool GetName(SCTAB nTab, OUString &rName) const
Definition: document.cxx:213
virtual SfxObjectShell * GetObjectShell()
bool IsSelectionEditable(const ScMarkData &rMark, bool *pOnlyNotBecauseOfMatrix=nullptr) const
Definition: document.cxx:5351
SC_DLLPUBLIC void GetCellType(SCCOL nCol, SCROW nRow, SCTAB nTab, CellType &rCellType) const
Definition: document.cxx:3747
#define SCITEM_CONSOLIDATEDATA
Definition: scitems.hxx:93
sal_Int16 SCTAB
Definition: types.hxx:23
static bool GetEmbeddedName(const TransferableDataHelper &rData, OUString &_rName, OUString &_rSource, SotClipboardFormatId const &_nFormat)
SCCOL GetCurX() const
Definition: viewdata.hxx:401
bool IsCaptionShown() const
Returns true, if the caption object is visible.
Definition: postit.hxx:255
bool SimpleColMarked()
Definition: viewdata.cxx:1218
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo