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