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