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
562namespace {
563
564bool checkDestRanges(ScViewData& rViewData)
565{
566 ScRange aDummy;
567 ScMarkType eMarkType = rViewData.GetSimpleArea( aDummy);
568 if (eMarkType != SC_MARK_MULTI)
569 {
570 // Single destination range.
571 if (eMarkType != SC_MARK_SIMPLE && eMarkType != SC_MARK_SIMPLE_FILTERED)
572 return false;
573 }
574
575 // Multiple destination ranges.
576
577 // Same as ScViewData::SelectionForbidsPaste() in
578 // sc/source/ui/view/viewdata.cxx but different return details.
579
580 vcl::Window* pWin = rViewData.GetActiveWin();
581 if (!pWin)
582 return false;
583
585 if (!pOwnClip)
586 // If it's not a Calc document, we won't be picky.
587 return true;
588
589 ScDocument* pClipDoc = pOwnClip->GetDocument();
590 if (!pClipDoc)
591 return false;
592
593 ScRange aSrcRange = pClipDoc->GetClipParam().getWholeRange();
594 SCROW nRowSize = aSrcRange.aEnd.Row() - aSrcRange.aStart.Row() + 1;
595 SCCOL nColSize = aSrcRange.aEnd.Col() - aSrcRange.aStart.Col() + 1;
596
597 if (rViewData.SelectionForbidsPaste( nColSize, nRowSize))
598 return false;
599
600 ScMarkData aMark = rViewData.GetMarkData();
601 ScRangeList aRanges;
602 aMark.MarkToSimple();
603 aMark.FillRangeListWithMarks(&aRanges, false);
604
605 return ScClipUtil::CheckDestRanges(rViewData.GetDocument(), nColSize, nRowSize, aMark, aRanges);
606}
607
608}
609
611{
612// SID_PASTE
613// SID_PASTE_SPECIAL
614// SID_PASTE_UNFORMATTED
615// SID_CLIPBOARD_FORMAT_ITEMS
616
617 if ( !pImpl->m_xClipEvtLstnr.is() )
618 {
619 // create listener
620 pImpl->m_xClipEvtLstnr = new TransferableClipboardListener( LINK( this, ScCellShell, ClipboardChanged ) );
622 pImpl->m_xClipEvtLstnr->AddListener( pWin );
623
624 // get initial state
627 }
628
629 bool bDisable = !bPastePossible;
630
631 // cell protection / multiple selection
632
633 if (!bDisable)
634 {
635 SCCOL nCol = GetViewData().GetCurX();
636 SCROW nRow = GetViewData().GetCurY();
637 SCTAB nTab = GetViewData().GetTabNo();
639 if (!rDoc.IsBlockEditable( nTab, nCol,nRow, nCol,nRow ))
640 bDisable = true;
641
642 if (!bDisable && !checkDestRanges(GetViewData()))
643 bDisable = true;
644 }
645
646 if (bDisable)
647 {
648 rSet.DisableItem( SID_PASTE );
649 rSet.DisableItem( SID_PASTE_SPECIAL );
650 rSet.DisableItem( SID_PASTE_UNFORMATTED );
651 rSet.DisableItem( SID_PASTE_ONLY_VALUE );
652 rSet.DisableItem( SID_PASTE_ONLY_TEXT );
653 rSet.DisableItem( SID_PASTE_ONLY_FORMULA );
654 rSet.DisableItem( SID_PASTE_TRANSPOSED );
655 rSet.DisableItem( SID_PASTE_AS_LINK );
656 rSet.DisableItem( SID_PASTE_TEXTIMPORT_DIALOG );
657 rSet.DisableItem( SID_CLIPBOARD_FORMAT_ITEMS );
658 }
659 else if ( rSet.GetItemState( SID_CLIPBOARD_FORMAT_ITEMS ) != SfxItemState::UNKNOWN )
660 {
661 SvxClipboardFormatItem aFormats( SID_CLIPBOARD_FORMAT_ITEMS );
662 GetPossibleClipboardFormats( aFormats );
663 rSet.Put( aFormats );
664 }
665}
666
667// only SID_HYPERLINK_GETLINK:
668
670{
671 // always return an item (or inserting will be disabled)
672 // if the cell at the cursor contains only a link, return that link
673
674 SvxHyperlinkItem aHLinkItem;
675 if ( !GetViewData().GetView()->HasBookmarkAtCursor( &aHLinkItem ) )
676 {
677 // tdf#80043 - put selected text into item
678 ScViewData& rData = GetViewData();
679 ScDocument& rDoc = rData.GetDocument();
680 SCCOL nPosX = rData.GetCurX();
681 SCROW nPosY = rData.GetCurY();
682 SCTAB nTab = rData.GetTabNo();
683 aHLinkItem.SetName(rDoc.GetString(nPosX, nPosY, nTab));
684 }
685
686 rSet.Put(aHLinkItem);
687}
688
690{
691 ScTabViewShell* pTabViewShell = GetViewData().GetViewShell();
692 ScDocShell* pDocSh = GetViewData().GetDocShell();
693 ScViewData& rData = GetViewData();
694 ScDocument& rDoc = rData.GetDocument();
695 ScMarkData& rMark = rData.GetMarkData();
696 SCCOL nPosX = rData.GetCurX();
697 SCROW nPosY = rData.GetCurY();
698 SCTAB nTab = rData.GetTabNo();
699
700 SCTAB nTabCount = rDoc.GetTableCount();
701 SCTAB nTabSelCount = rMark.GetSelectCount();
702
703 SfxWhichIter aIter(rSet);
704 sal_uInt16 nWhich = aIter.FirstWhich();
705 while ( nWhich )
706 {
707 switch ( nWhich )
708 {
709 case SID_DETECTIVE_REFRESH:
710 if (!rDoc.HasDetectiveOperations())
711 rSet.DisableItem( nWhich );
712 break;
713
714 case SID_RANGE_ADDRESS:
715 {
716 ScRange aRange;
717 if ( rData.GetSimpleArea( aRange ) == SC_MARK_SIMPLE )
718 {
719 OUString aStr(aRange.Format(rDoc, ScRefFlags::VALID | ScRefFlags::TAB_3D));
720 rSet.Put( SfxStringItem( nWhich, aStr ) );
721 }
722 }
723 break;
724
725 case SID_RANGE_NOTETEXT:
726 {
727 // always take cursor position, do not use top-left cell of selection
728 OUString aNoteText;
729 if ( const ScPostIt* pNote = rDoc.GetNote(nPosX, nPosY, nTab) )
730 aNoteText = pNote->GetText();
731 rSet.Put( SfxStringItem( nWhich, aNoteText ) );
732 }
733 break;
734
735 case SID_RANGE_ROW:
736 rSet.Put( SfxInt32Item( SID_RANGE_ROW, nPosY+1 ) );
737 break;
738
739 case SID_RANGE_COL:
740 rSet.Put( SfxInt16Item( SID_RANGE_COL, nPosX+1 ) );
741 break;
742
743 case SID_RANGE_TABLE:
744 rSet.Put( SfxInt16Item( SID_RANGE_TABLE, nTab+1 ) );
745 break;
746
747 case SID_RANGE_FORMULA:
748 {
749 OUString aString = rDoc.GetFormula( nPosX, nPosY, nTab );
750 if( aString.isEmpty() )
751 {
752 aString = rDoc.GetInputString( nPosX, nPosY, nTab );
753 }
754 rSet.Put( SfxStringItem( nWhich, aString ) );
755 }
756 break;
757
758 case SID_RANGE_TEXTVALUE:
759 {
760 OUString aString = rDoc.GetString(nPosX, nPosY, nTab);
761 rSet.Put( SfxStringItem( nWhich, aString ) );
762 }
763 break;
764
765 case SID_STATUS_SELMODE:
766 {
767 /* 0: STD Click cancels Sel
768 * 1: ER Click extends selection
769 * 2: ERG Click defines further selection
770 */
771 sal_uInt16 nMode = pTabViewShell->GetLockedModifiers();
772
773 switch ( nMode )
774 {
775 case KEY_SHIFT: nMode = 1; break;
776 case KEY_MOD1: nMode = 2; break; // Control-key
777 case 0:
778 default:
779 nMode = 0;
780 }
781
782 rSet.Put( SfxUInt16Item( nWhich, nMode ) );
783 }
784 break;
785
786 case SID_STATUS_DOCPOS:
787 {
788 OUString aStr = ScResId( STR_TABLE_COUNT );
789
790 aStr = aStr.replaceFirst("%1", OUString::number( nTab + 1 ) );
791 aStr = aStr.replaceFirst("%2", OUString::number( nTabCount ) );
792
793 rSet.Put( SfxStringItem( nWhich, aStr ) ); }
794 break;
795
796 case SID_ROWCOL_SELCOUNT:
797 {
798 ScRangeListRef aMarkRanges;
799 GetViewData().GetMultiArea(aMarkRanges);
800 const SCCOL nCol1 = aMarkRanges->front().aStart.Col();
801 const SCROW nRow1 = aMarkRanges->front().aStart.Row();
802 const SCCOL nCol2 = aMarkRanges->front().aEnd.Col();
803 const SCROW nRow2 = aMarkRanges->front().aEnd.Row();
804 const size_t nRanges = aMarkRanges->size();
805
806 if ((nRanges == 1 && (nCol2 != nCol1 || nRow1 != nRow2)) || nRanges > 1)
807 {
808 bool bSameRows = true;
809 bool bSameCols = true;
810 SCROW nRowsSum = 0;
811 SCCOL nColsSum = 0;
812 for (size_t i = 0; i < nRanges; ++i)
813 {
814 const ScRange& rRange = (*aMarkRanges)[i];
815 const SCCOL nRangeCol1 = rRange.aStart.Col();
816 const SCROW nRangeRow1 = rRange.aStart.Row();
817 const SCCOL nRangeCol2 = rRange.aEnd.Col();
818 const SCROW nRangeRow2 = rRange.aEnd.Row();
819 bSameRows &= (nRow1 == nRangeRow1 && nRow2 == nRangeRow2);
820 bSameCols &= (nCol1 == nRangeCol1 && nCol2 == nRangeCol2);
821 // Sum rows if the number of cols is the same or
822 // sum columns if the number of rows is the same,
823 // otherwise do not show any count of selected cells.
824 if (bSameRows || bSameCols)
825 {
826 const auto nCols = nRangeCol2 - nRangeCol1 + 1;
827 const auto nRows = (bSameCols || nRowsSum == 0) ?
828 rDoc.CountNonFilteredRows( nRangeRow1, nRangeRow2, rRange.aStart.Tab()) :
829 nRowsSum;
830 if (bSameRows)
831 {
832 nRowsSum = nRows;
833 nColsSum += nCols;
834 }
835 else if (bSameCols)
836 {
837 nRowsSum += nRows;
838 nColsSum = nCols;
839 }
840 }
841 else
842 break;
843 }
844 // Either the rows or columns are the same among selections
845 if (bSameRows || bSameCols)
846 {
847 const LocaleDataWrapper& rLocaleData
849 OUString aRowArg
850 = ScResId(STR_SELCOUNT_ROWARG, nRowsSum)
851 .replaceAll("$1", rLocaleData.getNum(nRowsSum, 0));
852 OUString aColArg
853 = ScResId(STR_SELCOUNT_COLARG, nColsSum)
854 .replaceAll("$1", rLocaleData.getNum(nColsSum, 0));
855 OUString aStr = ScResId(STR_SELCOUNT);
856 aStr = aStr.replaceAll("$1", aRowArg);
857 aStr = aStr.replaceAll("$2", aColArg);
858 rSet.Put(SfxStringItem(nWhich, aStr));
859 }
860 }
861 else
862 {
863 SCSIZE nSelected, nTotal;
864 rDoc.GetFilterSelCount( nPosX, nPosY, nTab, nSelected, nTotal );
865 if( nTotal && nSelected != SCSIZE_MAX )
866 {
867 OUString aStr = ScResId( STR_FILTER_SELCOUNT );
868 aStr = aStr.replaceAll( "$1", OUString::number( nSelected ) );
869 aStr = aStr.replaceAll( "$2", OUString::number( nTotal ) );
870 rSet.Put( SfxStringItem( nWhich, aStr ) );
871 }
872 }
873 }
874 break;
875
876 // calculations etc. with date/time/Fail/position&size together
877
878 // #i34458# The SvxStatusItem belongs only into SID_TABLE_CELL. It no longer has to be
879 // duplicated in SID_ATTR_POSITION or SID_ATTR_SIZE for SvxPosSizeStatusBarControl.
880 case SID_TABLE_CELL:
881 {
882 // Test, if error under cursor
883 // (not rDoc.GetErrCode, to avoid erasing circular references)
884
885 // In interpreter may happen via rescheduled Basic
886 if ( rDoc.IsInInterpreter() )
887 rSet.Put( SvxStatusItem( SID_TABLE_CELL, "...", StatusCategory::Formula ) );
888 else
889 {
890 FormulaError nErrCode = FormulaError::NONE;
891 ScFormulaCell* pCell = rDoc.GetFormulaCell(ScAddress(nPosX, nPosY, nTab));
892 if (pCell && !pCell->IsRunning())
893 nErrCode = pCell->GetErrCode();
894
895 OUString aFuncStr;
896 if ( pTabViewShell->GetFunction( aFuncStr, nErrCode ) )
897 {
898 rSet.Put( SvxStatusItem( SID_TABLE_CELL, aFuncStr, StatusCategory::Formula ) );
899 }
900 }
901 }
902 break;
903
904 case SID_DATA_SELECT:
905 // HasSelectionData includes column content and validity,
906 // page fields have to be checked separately.
907 if ( !rDoc.HasSelectionData( nPosX, nPosY, nTab ) &&
908 !pTabViewShell->HasPageFieldDataAtCursor() )
909 rSet.DisableItem( nWhich );
910 break;
911
912 case FID_CURRENTVALIDATION:
913 if ( !rDoc.HasValidationData( nPosX, nPosY, nTab ))
914 rSet.DisableItem( nWhich );
915 break;
916
917 case SID_STATUS_SUM:
918 {
919 OUString aFuncStr;
920 if ( pTabViewShell->GetFunction( aFuncStr, FormulaError::NONE ) )
921 rSet.Put( SfxStringItem( nWhich, aFuncStr ) );
922 }
923 break;
924
925 case FID_MERGE_ON:
926 if ( rDoc.GetChangeTrack() || !pTabViewShell->TestMergeCells() )
927 rSet.DisableItem( nWhich );
928 break;
929
930 case FID_MERGE_OFF:
931 if ( rDoc.GetChangeTrack() || !pTabViewShell->TestRemoveMerge() )
932 rSet.DisableItem( nWhich );
933 break;
934
935 case FID_MERGE_TOGGLE:
936 if ( rDoc.GetChangeTrack() )
937 rSet.DisableItem( nWhich );
938 else
939 {
940 bool bCanMerge = pTabViewShell->TestMergeCells();
941 bool bCanSplit = pTabViewShell->TestRemoveMerge();
942 if( !bCanMerge && !bCanSplit )
943 rSet.DisableItem( nWhich );
944 else
945 rSet.Put( SfxBoolItem( nWhich, bCanSplit ) );
946 }
947 break;
948
949 case FID_INS_ROWBRK:
950 if ( nPosY==0 || (rDoc.HasRowBreak(nPosY, nTab) & ScBreakType::Manual) || rDoc.IsTabProtected(nTab) )
951 rSet.DisableItem( nWhich );
952 break;
953
954 case FID_INS_COLBRK:
955 if ( nPosX==0 || (rDoc.HasColBreak(nPosX, nTab) & ScBreakType::Manual) || rDoc.IsTabProtected(nTab) )
956 rSet.DisableItem( nWhich );
957 break;
958
959 case FID_DEL_ROWBRK:
960 if ( nPosY==0 || !(rDoc.HasRowBreak(nPosY, nTab) & ScBreakType::Manual) || rDoc.IsTabProtected(nTab) )
961 rSet.DisableItem( nWhich );
962 break;
963
964 case FID_DEL_COLBRK:
965 if ( nPosX==0 || !(rDoc.HasColBreak(nPosX, nTab) & ScBreakType::Manual) || rDoc.IsTabProtected(nTab) )
966 rSet.DisableItem( nWhich );
967 break;
968
969 case FID_FILL_TAB:
970 if ( nTabSelCount < 2 )
971 rSet.DisableItem( nWhich );
972 break;
973
974 case SID_INSERT_CURRENT_DATE:
975 case SID_INSERT_CURRENT_TIME:
976 {
977 if ( rDoc.IsTabProtected(nTab) &&
978 rDoc.HasAttrib(nPosX, nPosY, nTab, nPosX, nPosY, nTab, HasAttrFlags::Protected))
979 rSet.DisableItem( nWhich );
980 }
981 break;
982
983 case SID_SELECT_SCENARIO:
984 {
985 std::vector<OUString> aList;
986 Color aDummyCol;
987
988 if ( !rDoc.IsScenario(nTab) )
989 {
990 OUString aStr;
991 ScScenarioFlags nFlags;
992 SCTAB nScTab = nTab + 1;
993 bool bSheetProtected = rDoc.IsTabProtected(nTab);
994
995 while ( rDoc.IsScenario(nScTab) )
996 {
997 rDoc.GetName( nScTab, aStr );
998 aList.push_back(aStr);
999 rDoc.GetScenarioData( nScTab, aStr, aDummyCol, nFlags );
1000 aList.push_back(aStr);
1001 // Protection is sal_True if both Sheet and Scenario are protected
1002 aList.push_back((bSheetProtected && (nFlags & ScScenarioFlags::Protected)) ? OUString("1") : OUString("0"));
1003 ++nScTab;
1004 }
1005 }
1006 else
1007 {
1008 OUString aComment;
1009 ScScenarioFlags nDummyFlags;
1010 rDoc.GetScenarioData( nTab, aComment, aDummyCol, nDummyFlags );
1011 OSL_ENSURE( aList.empty(), "List not empty!" );
1012 aList.push_back(aComment);
1013 }
1014
1015 rSet.Put( SfxStringListItem( nWhich, &aList ) );
1016 }
1017 break;
1018
1019 case FID_ROW_HIDE:
1020 case FID_ROW_SHOW:
1021 case FID_COL_HIDE:
1022 case FID_COL_SHOW:
1023 case FID_COL_OPT_WIDTH:
1024 case FID_ROW_OPT_HEIGHT:
1025 case FID_DELETE_CELL:
1026 if ( rDoc.IsTabProtected(nTab) || pDocSh->IsReadOnly())
1027 rSet.DisableItem( nWhich );
1028 break;
1029
1030 case SID_OUTLINE_MAKE:
1031 {
1032 if ( GetViewData().GetDocument().GetDPAtCursor( GetViewData().GetCurX(),
1033 GetViewData().GetCurY(), GetViewData().GetTabNo() ) )
1034 {
1036 }
1037 else if (rDoc.GetChangeTrack()!=nullptr || GetViewData().IsMultiMarked())
1038 {
1039 rSet.DisableItem( nWhich );
1040 }
1041 }
1042 break;
1043 case SID_OUTLINE_SHOW:
1044 if ( GetViewData().GetDocument().GetDPAtCursor( GetViewData().GetCurX(),
1045 GetViewData().GetCurY(), GetViewData().GetTabNo() ) )
1046 {
1048 }
1049 else if (!pTabViewShell->OutlinePossible(false))
1050 rSet.DisableItem( nWhich );
1051 break;
1052
1053 case SID_OUTLINE_HIDE:
1054 if ( GetViewData().GetDocument().GetDPAtCursor( GetViewData().GetCurX(),
1055 GetViewData().GetCurY(), GetViewData().GetTabNo() ) )
1056 {
1058 }
1059 else if (!pTabViewShell->OutlinePossible(true))
1060 rSet.DisableItem( nWhich );
1061 break;
1062
1063 case SID_OUTLINE_REMOVE:
1064 {
1065 if ( GetViewData().GetDocument().GetDPAtCursor( GetViewData().GetCurX(),
1066 GetViewData().GetCurY(), GetViewData().GetTabNo() ) )
1067 {
1069 }
1070 else
1071 {
1072 bool bCol, bRow;
1073 pTabViewShell->TestRemoveOutline( bCol, bRow );
1074 if ( !bCol && !bRow )
1075 rSet.DisableItem( nWhich );
1076 }
1077 }
1078 break;
1079
1080 case FID_COL_WIDTH:
1081 {
1082 SfxUInt16Item aWidthItem( FID_COL_WIDTH, rDoc.GetColWidth( nPosX , nTab) );
1083 rSet.Put( aWidthItem );
1084 if ( pDocSh->IsReadOnly())
1085 rSet.DisableItem( nWhich );
1086
1087 //XXX disable if not conclusive
1088 }
1089 break;
1090
1091 case FID_ROW_HEIGHT:
1092 {
1093 SfxUInt16Item aHeightItem( FID_ROW_HEIGHT, rDoc.GetRowHeight( nPosY , nTab) );
1094 rSet.Put( aHeightItem );
1095 //XXX disable if not conclusive
1096 if ( pDocSh->IsReadOnly())
1097 rSet.DisableItem( nWhich );
1098 }
1099 break;
1100
1101 case SID_DETECTIVE_FILLMODE:
1102 rSet.Put(SfxBoolItem( nWhich, pTabViewShell->IsAuditShell() ));
1103 break;
1104
1105 case FID_INPUTLINE_STATUS:
1106 OSL_FAIL( "Old update method. Use ScTabViewShell::UpdateInputHandler()." );
1107 break;
1108
1109 case SID_SCENARIOS: // scenarios:
1110 if (!(rMark.IsMarked() || rMark.IsMultiMarked())) // only, if something selected
1111 rSet.DisableItem( nWhich );
1112 break;
1113
1114 case FID_NOTE_VISIBLE:
1115 {
1116 const ScPostIt* pNote = rDoc.GetNote(nPosX, nPosY, nTab);
1117 if ( pNote && rDoc.IsBlockEditable( nTab, nPosX,nPosY, nPosX,nPosY ) )
1118 rSet.Put( SfxBoolItem( nWhich, pNote->IsCaptionShown() ) );
1119 else
1120 rSet.DisableItem( nWhich );
1121 }
1122 break;
1123
1124 case FID_HIDE_NOTE:
1125 case FID_SHOW_NOTE:
1126 {
1127 bool bEnable = false;
1128 bool bSearchForHidden = nWhich == FID_SHOW_NOTE;
1129 if (!rMark.IsMarked() && !rMark.IsMultiMarked())
1130 {
1131 // Check current cell
1132 const ScPostIt* pNote = rDoc.GetNote(nPosX, nPosY, nTab);
1133 if ( pNote && rDoc.IsBlockEditable( nTab, nPosX,nPosY, nPosX,nPosY ) )
1134 if ( pNote->IsCaptionShown() != bSearchForHidden)
1135 bEnable = true;
1136 }
1137 else
1138 {
1139 // Check selection range
1140 ScRangeListRef aRangesRef;
1141 rData.GetMultiArea(aRangesRef);
1142 ScRangeList aRanges = *aRangesRef;
1143 std::vector<sc::NoteEntry> aNotes;
1144 rDoc.GetNotesInRange(aRanges, aNotes);
1145 for(const auto& rNote : aNotes)
1146 {
1147 const ScAddress& rAdr = rNote.maPos;
1148 if( rDoc.IsBlockEditable( rAdr.Tab(), rAdr.Col(), rAdr.Row(), rAdr.Col(), rAdr.Row() ))
1149 {
1150 if (rNote.mpNote->IsCaptionShown() != bSearchForHidden)
1151 {
1152 bEnable = true;
1153 break;
1154 }
1155 }
1156 }
1157
1158 }
1159 if ( !bEnable )
1160 rSet.DisableItem( nWhich );
1161 }
1162 break;
1163
1164 case FID_SHOW_ALL_NOTES:
1165 case FID_HIDE_ALL_NOTES:
1166 case FID_DELETE_ALL_NOTES:
1167 {
1168 bool bHasNotes = false;
1169
1170 for (auto const& rTab : rMark.GetSelectedTabs())
1171 {
1172 if (rDoc.HasTabNotes( rTab ))
1173 {
1174 bHasNotes = true;
1175 break;
1176 }
1177 }
1178
1179 if ( !bHasNotes )
1180 rSet.DisableItem( nWhich );
1181 }
1182 break;
1183
1184 case SID_TOGGLE_NOTES:
1185 {
1186 bool bHasNotes = false;
1187 ScRangeList aRanges;
1188
1189 for (auto const& rTab : rMark.GetSelectedTabs())
1190 {
1191 if (rDoc.HasTabNotes( rTab ))
1192 {
1193 bHasNotes = true;
1194 aRanges.push_back(ScRange(0,0,rTab,rDoc.MaxCol(),rDoc.MaxRow(),rTab));
1195 }
1196 }
1197
1198 if ( !bHasNotes )
1199 rSet.DisableItem( nWhich );
1200 else
1201 {
1202 CommentCaptionState eState = rDoc.GetAllNoteCaptionsState( aRanges );
1203 bool bAllNotesInShown = (eState != ALLHIDDEN && eState != MIXED);
1204 rSet.Put( SfxBoolItem( SID_TOGGLE_NOTES, bAllNotesInShown) );
1205 }
1206 }
1207 break;
1208
1209 case SID_DELETE_NOTE:
1210 {
1211 bool bEnable = false;
1212 if ( rMark.IsMarked() || rMark.IsMultiMarked() )
1213 {
1214 if ( rDoc.IsSelectionEditable( rMark ) )
1215 {
1216 // look for at least one note in selection
1217 ScRangeList aRanges;
1218 rMark.FillRangeListWithMarks( &aRanges, false );
1219 bEnable = rDoc.ContainsNotesInRange( aRanges );
1220 }
1221 }
1222 else
1223 {
1224 bEnable = rDoc.IsBlockEditable( nTab, nPosX,nPosY, nPosX,nPosY ) &&
1225 rDoc.GetNote(nPosX, nPosY, nTab);
1226 }
1227 if ( !bEnable )
1228 rSet.DisableItem( nWhich );
1229 }
1230 break;
1231
1232 case SID_OPENDLG_CONSOLIDATE:
1234 {
1235 if (rDoc.GetChangeTrack()!=nullptr)
1236 rSet.DisableItem( nWhich);
1237 }
1238 break;
1239
1240 case SID_CHINESE_CONVERSION:
1241 case SID_HANGUL_HANJA_CONVERSION:
1242 ScViewUtil::HideDisabledSlot( rSet, rData.GetBindings(), nWhich );
1243 break;
1244
1245 case FID_USE_NAME:
1246 {
1247 if ( pDocSh && pDocSh->IsDocShared() )
1248 rSet.DisableItem( nWhich );
1249 else
1250 {
1251 ScRange aRange;
1252 if ( rData.GetSimpleArea( aRange ) != SC_MARK_SIMPLE )
1253 rSet.DisableItem( nWhich );
1254 }
1255 }
1256 break;
1257
1258 case FID_DEFINE_NAME:
1259 case FID_INSERT_NAME:
1260 case FID_ADD_NAME:
1261 case SID_DEFINE_COLROWNAMERANGES:
1262 {
1263 if ( pDocSh && pDocSh->IsDocShared() )
1264 {
1265 rSet.DisableItem( nWhich );
1266 }
1267 }
1268 break;
1269
1270 case FID_DEFINE_CURRENT_NAME:
1271 {
1272 ScAddress aCurrentAddress( nPosX, nPosY, nTab );
1273
1274 if ( !rDoc.IsAddressInRangeName( RangeNameScope::GLOBAL, aCurrentAddress ) &&
1275 !rDoc.IsAddressInRangeName( RangeNameScope::SHEET, aCurrentAddress ))
1276 {
1277 rSet.DisableItem( nWhich );
1278 }
1279 }
1280 break;
1281
1282 case SID_SPELL_DIALOG:
1283 {
1284 if (rDoc.IsTabProtected(rData.GetTabNo()))
1285 {
1286 bool bVisible = false;
1287 SfxViewFrame* pViewFrame = ( pTabViewShell ? &pTabViewShell->GetViewFrame() : nullptr );
1288 if ( pViewFrame && pViewFrame->HasChildWindow( nWhich ) )
1289 {
1290 SfxChildWindow* pChild = pViewFrame->GetChildWindow( nWhich );
1291 std::shared_ptr<SfxDialogController> xController = pChild ? pChild->GetController() : nullptr;
1292 if (xController && xController->getDialog()->get_visible())
1293 {
1294 bVisible = true;
1295 }
1296 }
1297 if ( !bVisible )
1298 {
1299 rSet.DisableItem( nWhich );
1300 }
1301 }
1302 }
1303 break;
1304
1305 case SID_OPENDLG_CURRENTCONDFRMT:
1306 case SID_OPENDLG_CURRENTCONDFRMT_MANAGER:
1307 {
1308 const SfxPoolItem* pItem = rDoc.GetAttr( nPosX, nPosY, nTab, ATTR_CONDITIONAL );
1309 const ScCondFormatItem* pCondFormatItem = static_cast<const ScCondFormatItem*>(pItem);
1310
1311 if ( pCondFormatItem->GetCondFormatData().empty() )
1312 rSet.DisableItem( nWhich );
1313 else if ( pCondFormatItem->GetCondFormatData().size() == 1 )
1314 rSet.DisableItem( SID_OPENDLG_CURRENTCONDFRMT_MANAGER );
1315 else if ( pCondFormatItem->GetCondFormatData().size() > 1 )
1316 rSet.DisableItem( SID_OPENDLG_CURRENTCONDFRMT );
1317 }
1318 break;
1319
1320 } // switch ( nWitch )
1321 nWhich = aIter.NextWhich();
1322 } // while ( nWitch )
1323}
1324
1325/* 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:669
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:689
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:610
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:438
SCROW CountNonFilteredRows(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const
Definition: document.cxx:4611
SC_DLLPUBLIC sal_uInt16 GetRowHeight(SCROW nRow, SCTAB nTab, bool bHiddenAsZero=true) const
Definition: document.cxx:4225
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:4184
CommentCaptionState GetAllNoteCaptionsState(const ScRangeList &rRanges)
Definition: document.cxx:6892
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:3839
ScClipParam & GetClipParam()
Definition: document.cxx:2591
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:966
bool IsSelectionEditable(const ScMarkData &rMark, bool *pOnlyNotBecauseOfMatrix=nullptr) const
Definition: document.cxx:5455
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:7026
SC_DLLPUBLIC ScPostIt * GetNote(const ScAddress &rPos)
Definition: document.cxx:6725
bool HasDetectiveOperations() const
Definition: documen4.cxx:894
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:4423
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:6631
SC_DLLPUBLIC ScBreakType HasColBreak(SCCOL nCol, SCTAB nTab) const
Definition: document.cxx:4438
SC_DLLPUBLIC bool HasAttrib(SCCOL nCol1, SCROW nRow1, SCTAB nTab1, SCCOL nCol2, SCROW nRow2, SCTAB nTab2, HasAttrFlags nMask) const
Definition: document.cxx:5273
bool IsBlockEditable(SCTAB nTab, SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, bool *pOnlyNotBecauseOfMatrix=nullptr, bool bNoMatrixAtAll=false) const
Definition: document.cxx:5431
SC_DLLPUBLIC OUString GetInputString(SCCOL nCol, SCROW nRow, SCTAB nTab, bool bForceSystemLocale=false) const
Definition: document.cxx:3592
SC_DLLPUBLIC bool HasTabNotes(SCTAB nTab) const
Definition: document.cxx:6808
SC_DLLPUBLIC bool HasOneSparklineGroup(ScRange const &rRange)
Definition: document.cxx:6669
bool IsInInterpreter() const
Definition: document.hxx:2411
bool HasValidationData(SCCOL nCol, SCROW nRow, SCTAB nTab) const
Definition: document.cxx:3851
SC_DLLPUBLIC OUString GetFormula(SCCOL nCol, SCROW nRow, SCTAB nTab) const
Definition: document.cxx:3758
SC_DLLPUBLIC OUString GetString(SCCOL nCol, SCROW nRow, SCTAB nTab, const ScInterpreterContext *pContext=nullptr) const
Definition: document.cxx:3545
SC_DLLPUBLIC const ScFormulaCell * GetFormulaCell(const ScAddress &rPos) const
Definition: document.cxx:3766
ScChangeTrack * GetChangeTrack() const
Definition: document.hxx:2493
SC_DLLPUBLIC CellType GetCellType(SCCOL nCol, SCROW nRow, SCTAB nTab) const
Definition: document.cxx:3790
void GetNotesInRange(const ScRangeList &rRange, std::vector< sc::NoteEntry > &rNotes) const
Definition: document.cxx:7009
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:5510
SC_DLLPUBLIC const SfxPoolItem * GetAttr(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt16 nWhich) const
Definition: document.cxx:4778
SC_DLLPUBLIC SCTAB GetTableCount() const
Definition: document.cxx:316
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: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: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:494
bool IsAuditShell() const
Definition: tabvwsh4.cxx:1049
bool GetFunction(OUString &rFuncStr, FormulaError nErrCode)
Definition: tabvwsha.cxx:84
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: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: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