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