LibreOffice Module sc (master)  1
cellsh1.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 <config_features.h>
21 
22 #include <com/sun/star/i18n/TextConversionOption.hpp>
23 #include <com/sun/star/sheet/DataPilotFieldFilter.hpp>
24 
25 #include <scitems.hxx>
26 #include <sfx2/viewfrm.hxx>
27 
28 #include <basic/sberrors.hxx>
29 #include <comphelper/lok.hxx>
31 #include <svl/stritem.hxx>
32 #include <svl/zforlist.hxx>
33 #include <svl/zformat.hxx>
34 #include <sfx2/dispatch.hxx>
35 #include <sfx2/request.hxx>
37 #include <vcl/svapp.hxx>
38 #include <vcl/weld.hxx>
39 #include <svx/svxdlg.hxx>
40 #include <sot/formats.hxx>
41 #include <svx/postattr.hxx>
42 #include <editeng/fontitem.hxx>
43 #include <svx/clipfmtitem.hxx>
44 #include <svx/hlnkitem.hxx>
45 #include <basic/sbxcore.hxx>
46 #include <editeng/editview.hxx>
47 #include <svtools/cliplistener.hxx>
48 
49 #include <cellsh.hxx>
50 #include <ftools.hxx>
51 #include <sc.hrc>
52 #include <document.hxx>
53 #include <patattr.hxx>
54 #include <scmod.hxx>
55 #include <tabvwsh.hxx>
56 #include <uiitems.hxx>
57 #include <reffact.hxx>
58 #include <inputhdl.hxx>
59 #include <transobj.hxx>
60 #include <drwtrans.hxx>
61 #include <docfunc.hxx>
62 #include <editable.hxx>
63 #include <dpobject.hxx>
64 #include <dpsave.hxx>
65 #include <spellparam.hxx>
66 #include <postit.hxx>
67 #include <dpsdbtab.hxx>
68 #include <dpshttab.hxx>
69 #include <dbdata.hxx>
70 #include <docsh.hxx>
71 #include <cliputil.hxx>
72 #include <markdata.hxx>
73 #include <colorscale.hxx>
74 #include <condformatdlg.hxx>
75 #include <attrib.hxx>
76 #include <condformatdlgitem.hxx>
77 #include <impex.hxx>
78 
79 #include <globstr.hrc>
80 #include <scresid.hxx>
81 #include <scui_def.hxx>
82 #include <scabstdlg.hxx>
83 #include <tokenstringcontext.hxx>
84 #include <cellvalue.hxx>
85 #include <tokenarray.hxx>
86 #include <formulacell.hxx>
87 #include <gridwin.hxx>
88 #include <searchresults.hxx>
89 
90 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
91 #include <com/sun/star/lang/XInitialization.hpp>
92 #include <com/sun/star/beans/XPropertySet.hpp>
93 #include <com/sun/star/uno/XComponentContext.hpp>
94 #include <cppuhelper/bootstrap.hxx>
95 
96 #include <memory>
97 
98 using namespace ::com::sun::star;
99 using namespace ::com::sun::star::beans;
100 using namespace ::com::sun::star::uno;
101 
102 namespace{
103 InsertDeleteFlags FlagsFromString(const OUString& rFlagsStr,
105 {
106  OUString aFlagsStr = rFlagsStr.toAsciiUpperCase();
108 
109  for (sal_Int32 i=0 ; i < aFlagsStr.getLength(); ++i)
110  {
111  switch (aFlagsStr[i])
112  {
113  case 'A': return InsertDeleteFlags::ALL;
114  case 'S': nFlags |= InsertDeleteFlags::STRING & nFlagsMask; break;
115  case 'V': nFlags |= InsertDeleteFlags::VALUE & nFlagsMask; break;
116  case 'D': nFlags |= InsertDeleteFlags::DATETIME & nFlagsMask; break;
117  case 'F': nFlags |= InsertDeleteFlags::FORMULA & nFlagsMask; break;
118  case 'N': nFlags |= InsertDeleteFlags::NOTE & nFlagsMask; break;
119  case 'T': nFlags |= InsertDeleteFlags::ATTRIB & nFlagsMask; break;
120  case 'O': nFlags |= InsertDeleteFlags::OBJECTS & nFlagsMask; break;
121  }
122  }
123  return nFlags;
124 }
125 
126 OUString FlagsToString( InsertDeleteFlags nFlags,
128 {
129  OUString aFlagsStr;
130 
131  if( nFlags == InsertDeleteFlags::ALL )
132  {
133  aFlagsStr = "A";
134  }
135  else
136  {
137  nFlags &= nFlagsMask;
138 
139  if( nFlags & InsertDeleteFlags::STRING ) aFlagsStr += "S";
140  if( nFlags & InsertDeleteFlags::VALUE ) aFlagsStr += "V";
141  if( nFlags & InsertDeleteFlags::DATETIME ) aFlagsStr += "D";
142  if( nFlags & InsertDeleteFlags::FORMULA ) aFlagsStr += "F";
143  if( nFlags & InsertDeleteFlags::NOTE ) aFlagsStr += "N";
144  if( nFlags & InsertDeleteFlags::ATTRIB ) aFlagsStr += "T";
145  if( nFlags & InsertDeleteFlags::OBJECTS ) aFlagsStr += "O";
146  }
147  return aFlagsStr;
148 }
149 
150 void SetTabNoAndCursor( const ScViewData* rViewData, const OUString& rCellId )
151 {
152  ScTabViewShell* pTabViewShell = rViewData->GetViewShell();
153  assert(pTabViewShell);
154  const ScDocument& rDoc = rViewData->GetDocShell()->GetDocument();
155  std::vector<sc::NoteEntry> aNotes;
156  rDoc.GetAllNoteEntries(aNotes);
157 
158  sal_uInt32 nId = rCellId.toUInt32();
159  auto lComp = [nId](const sc::NoteEntry& rNote) { return rNote.mpNote->GetId() == nId; };
160 
161  const auto& aFoundNoteIt = std::find_if(aNotes.begin(), aNotes.end(), lComp);
162  if (aFoundNoteIt != aNotes.end())
163  {
164  ScAddress aFoundPos = aFoundNoteIt->maPos;
165  pTabViewShell->SetTabNo(aFoundPos.Tab());
166  pTabViewShell->SetCursor(aFoundPos.Col(), aFoundPos.Row());
167  }
168 }
169 }
170 
172 {
173  ScModule* pScMod = SC_MOD();
174  ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
175  SfxBindings& rBindings = pTabViewShell->GetViewFrame()->GetBindings();
176  const SfxItemSet* pReqArgs = rReq.GetArgs();
177  sal_uInt16 nSlot = rReq.GetSlot();
178 
179  pTabViewShell->HideListBox(); // Autofilter-DropDown-Listbox
180 
181  // finish input
182  if ( GetViewData()->HasEditView( GetViewData()->GetActivePart() ) )
183  {
184  switch ( nSlot )
185  {
186  case FID_DEFINE_NAME:
187  case FID_ADD_NAME:
188  case FID_USE_NAME:
189  case FID_INSERT_NAME:
190  case SID_SPELL_DIALOG:
191  case SID_HANGUL_HANJA_CONVERSION:
192  case SID_OPENDLG_CONDFRMT:
193  case SID_OPENDLG_CURRENTCONDFRMT:
194  case SID_OPENDLG_COLORSCALE:
195  case SID_OPENDLG_DATABAR:
196  pScMod->InputEnterHandler();
197  pTabViewShell->UpdateInputHandler();
198  break;
199 
200  default:
201  break;
202  }
203  }
204 
205  switch ( nSlot )
206  {
207 
208  // insert / delete cells / rows / columns
209 
210  case FID_INS_ROW:
211  case FID_INS_ROWS_BEFORE:
212  pTabViewShell->InsertCells(INS_INSROWS_BEFORE);
213  rReq.Done();
214  break;
215 
216  case FID_INS_COLUMN:
217  case FID_INS_COLUMNS_BEFORE:
218  pTabViewShell->InsertCells(INS_INSCOLS_BEFORE);
219  rReq.Done();
220  break;
221 
222  case FID_INS_ROWS_AFTER:
223  pTabViewShell->InsertCells(INS_INSROWS_AFTER);
224  rReq.Done();
225  break;
226 
227  case FID_INS_COLUMNS_AFTER:
228  pTabViewShell->InsertCells(INS_INSCOLS_AFTER);
229  rReq.Done();
230  break;
231 
232  case FID_INS_CELLSDOWN:
233  pTabViewShell->InsertCells(INS_CELLSDOWN);
234  rReq.Done();
235  break;
236 
237  case FID_INS_CELLSRIGHT:
238  pTabViewShell->InsertCells(INS_CELLSRIGHT);
239  rReq.Done();
240  break;
241 
242  case SID_DEL_ROWS:
243  pTabViewShell->DeleteCells( DelCellCmd::Rows );
244  rReq.Done();
245  break;
246 
247  case SID_DEL_COLS:
248  pTabViewShell->DeleteCells( DelCellCmd::Cols );
249  rReq.Done();
250  break;
251 
252  case FID_INS_CELL:
253  {
254  InsCellCmd eCmd=INS_NONE;
255 
256  if ( pReqArgs )
257  {
258  const SfxPoolItem* pItem;
259  OUString aFlags;
260 
261  if( pReqArgs->HasItem( FID_INS_CELL, &pItem ) )
262  aFlags = static_cast<const SfxStringItem*>(pItem)->GetValue();
263  if( !aFlags.isEmpty() )
264  {
265  switch( aFlags[0] )
266  {
267  case 'V': eCmd = INS_CELLSDOWN ;break;
268  case '>': eCmd = INS_CELLSRIGHT ;break;
269  case 'R': eCmd = INS_INSROWS_BEFORE ;break;
270  case 'C': eCmd = INS_INSCOLS_BEFORE ;break;
271  }
272  }
273  }
274  else
275  {
276  if ( GetViewData()->SimpleColMarked() )
277  eCmd = INS_INSCOLS_BEFORE;
278  else if ( GetViewData()->SimpleRowMarked() )
279  eCmd = INS_INSROWS_BEFORE;
280  else
281  {
282  ScDocument& rDoc = GetViewData()->GetDocument();
283  bool bTheFlag=(rDoc.GetChangeTrack()!=nullptr);
284 
286 
287  ScopedVclPtr<AbstractScInsertCellDlg> pDlg(pFact->CreateScInsertCellDlg(pTabViewShell->GetFrameWeld(), bTheFlag));
288  if (pDlg->Execute() == RET_OK)
289  eCmd = pDlg->GetInsCellCmd();
290  }
291  }
292 
293  if (eCmd!=INS_NONE)
294  {
295  pTabViewShell->InsertCells( eCmd );
296 
297  if( ! rReq.IsAPI() )
298  {
299  OUString aParam;
300 
301  switch( eCmd )
302  {
303  case INS_CELLSDOWN: aParam = "V"; break;
304  case INS_CELLSRIGHT: aParam = ">"; break;
305  case INS_INSROWS_BEFORE: aParam = "R"; break;
306  case INS_INSCOLS_BEFORE: aParam = "C"; break;
307  default:
308  {
309  // added to avoid warnings
310  }
311  }
312  rReq.AppendItem( SfxStringItem( FID_INS_CELL, aParam ) );
313  rReq.Done();
314  }
315  }
316  }
317  break;
318 
319  case FID_DELETE_CELL:
320  {
322 
323  if ( pReqArgs )
324  {
325  const SfxPoolItem* pItem;
326  OUString aFlags;
327 
328  if( pReqArgs->HasItem( FID_DELETE_CELL, &pItem ) )
329  aFlags = static_cast<const SfxStringItem*>(pItem)->GetValue();
330  if( !aFlags.isEmpty() )
331  {
332  switch( aFlags[0] )
333  {
334  case 'U': eCmd = DelCellCmd::CellsUp ;break;
335  case 'L': eCmd = DelCellCmd::CellsLeft ;break;
336  case 'R': eCmd = DelCellCmd::Rows ;break;
337  case 'C': eCmd = DelCellCmd::Cols ;break;
338  }
339  }
340  }
341  else
342  {
343  if ( GetViewData()->SimpleColMarked() )
344  eCmd = DelCellCmd::Cols;
345  else if ( GetViewData()->SimpleRowMarked() )
346  eCmd = DelCellCmd::Rows;
347  else
348  {
349  ScRange aRange;
350  ScDocument& rDoc = GetViewData()->GetDocument();
351  bool bTheFlag=GetViewData()->IsMultiMarked() ||
353  (rDoc.GetChangeTrack() != nullptr);
354 
356 
357  ScopedVclPtr<AbstractScDeleteCellDlg> pDlg(pFact->CreateScDeleteCellDlg( pTabViewShell->GetFrameWeld(), bTheFlag ));
358 
359  if (pDlg->Execute() == RET_OK)
360  eCmd = pDlg->GetDelCellCmd();
361  }
362  }
363 
364  if (eCmd != DelCellCmd::NONE )
365  {
366  pTabViewShell->DeleteCells( eCmd );
367 
368  if( ! rReq.IsAPI() )
369  {
370  OUString aParam;
371 
372  switch( eCmd )
373  {
374  case DelCellCmd::CellsUp: aParam = "U"; break;
375  case DelCellCmd::CellsLeft: aParam = "L"; break;
376  case DelCellCmd::Rows: aParam = "R"; break;
377  case DelCellCmd::Cols: aParam = "C"; break;
378  default:
379  {
380  // added to avoid warnings
381  }
382  }
383  rReq.AppendItem( SfxStringItem( FID_DELETE_CELL, aParam ) );
384  rReq.Done();
385  }
386  }
387  }
388  break;
389 
390  // delete contents from cells
391 
392  case SID_DELETE_CONTENTS:
394  rReq.Done();
395  break;
396 
397  case SID_DELETE:
398  {
400 
401  if ( pReqArgs!=nullptr && pTabViewShell->SelectionEditable() )
402  {
403  const SfxPoolItem* pItem;
404  OUString aFlags('A');
405 
406  if( pReqArgs->HasItem( SID_DELETE, &pItem ) )
407  aFlags = static_cast<const SfxStringItem*>(pItem)->GetValue();
408 
409  nFlags |= FlagsFromString(aFlags, InsertDeleteFlags::ALL);
410  }
411  else
412  {
413  ScEditableTester aTester( pTabViewShell );
414  if (aTester.IsEditable())
415  {
417 
419  ScDocument& rDoc = GetViewData()->GetDocument();
420  SCTAB nTab = GetViewData()->GetTabNo();
421  if ( rDoc.IsTabProtected(nTab) )
422  pDlg->DisableObjects();
423  if (pDlg->Execute() == RET_OK)
424  {
425  nFlags = pDlg->GetDelContentsCmdBits();
426  }
427  }
428  else
429  pTabViewShell->ErrorMessage(aTester.GetMessageId());
430  }
431 
432  if( nFlags != InsertDeleteFlags::NONE )
433  {
434  pTabViewShell->DeleteContents( nFlags );
435 
436  if( ! rReq.IsAPI() )
437  {
438  OUString aFlags = FlagsToString( nFlags, InsertDeleteFlags::ALL );
439 
440  rReq.AppendItem( SfxStringItem( SID_DELETE, aFlags ) );
441  rReq.Done();
442  }
443  }
444  }
445  break;
446 
447  // fill...
448 
449  case FID_FILL_TO_BOTTOM:
450  pTabViewShell->FillSimple( FILL_TO_BOTTOM );
451  rReq.Done();
452  break;
453 
454  case FID_FILL_TO_RIGHT:
455  pTabViewShell->FillSimple( FILL_TO_RIGHT );
456  rReq.Done();
457  break;
458 
459  case FID_FILL_TO_TOP:
460  pTabViewShell->FillSimple( FILL_TO_TOP );
461  rReq.Done();
462  break;
463 
464  case FID_FILL_TO_LEFT:
465  pTabViewShell->FillSimple( FILL_TO_LEFT );
466  rReq.Done();
467  break;
468 
469  case FID_FILL_TAB:
470  {
472  ScPasteFunc nFunction = ScPasteFunc::NONE;
473  bool bSkipEmpty = false;
474  bool bAsLink = false;
475 
476  if ( pReqArgs!=nullptr && pTabViewShell->SelectionEditable() )
477  {
478  const SfxPoolItem* pItem;
479  OUString aFlags('A');
480 
481  if( pReqArgs->HasItem( FID_FILL_TAB, &pItem ) )
482  aFlags = static_cast<const SfxStringItem*>(pItem)->GetValue();
483 
484  nFlags |= FlagsFromString(aFlags);
485  }
486  else
487  {
489 
491  new OUString(ScResId(STR_FILL_TAB))));
492  pDlg->SetFillMode(true);
493 
494  if (pDlg->Execute() == RET_OK)
495  {
496  nFlags = pDlg->GetInsContentsCmdBits();
497  nFunction = pDlg->GetFormulaCmdBits();
498  bSkipEmpty = pDlg->IsSkipEmptyCells();
499  bAsLink = pDlg->IsLink();
500  // there is no MoveMode with fill tabs
501  }
502  }
503 
504  if( nFlags != InsertDeleteFlags::NONE )
505  {
506  pTabViewShell->FillTab( nFlags, nFunction, bSkipEmpty, bAsLink );
507 
508  if( ! rReq.IsAPI() )
509  {
510  OUString aFlags = FlagsToString( nFlags );
511 
512  rReq.AppendItem( SfxStringItem( FID_FILL_TAB, aFlags ) );
513  rReq.Done();
514  }
515  }
516  }
517  break;
518 
519  case FID_FILL_SERIES:
520  {
521  if (GetViewData()->SelectionForbidsCellFill())
522  // Slot should be already disabled, but in case it wasn't
523  // don't even attempt to do the evaluation and popup a
524  // dialog.
525  break;
526 
527  SCCOL nStartCol;
528  SCROW nStartRow;
529  SCTAB nStartTab;
530  SCCOL nEndCol;
531  SCROW nEndRow;
532  SCTAB nEndTab;
533  sal_uInt16 nPossDir = FDS_OPT_NONE;
534  FillDir eFillDir = FILL_TO_BOTTOM;
535  FillCmd eFillCmd = FILL_LINEAR;
536  FillDateCmd eFillDateCmd = FILL_DAY;
537  double fStartVal = MAXDOUBLE;
538  double fIncVal = 1;
539  double fMaxVal = MAXDOUBLE;
540  bool bDoIt = false;
541 
542  GetViewData()->GetSimpleArea( nStartCol, nStartRow, nStartTab,
543  nEndCol, nEndRow, nEndTab );
544 
545  if( nStartCol!=nEndCol )
546  {
547  nPossDir |= FDS_OPT_HORZ;
548  eFillDir=FILL_TO_RIGHT;
549  }
550 
551  if( nStartRow!=nEndRow )
552  {
553  nPossDir |= FDS_OPT_VERT;
554  eFillDir=FILL_TO_BOTTOM;
555  }
556 
557  ScDocument& rDoc = GetViewData()->GetDocument();
558  SvNumberFormatter* pFormatter = rDoc.GetFormatTable();
559 
560  if( pReqArgs )
561  {
562  const SfxPoolItem* pItem;
563  OUString aFillDir, aFillCmd, aFillDateCmd;
564  OUString aFillStep, aFillStart, aFillMax;
565  sal_uInt32 nKey;
566  double fTmpVal;
567 
568  if( pReqArgs->HasItem( FID_FILL_SERIES, &pItem ) )
569  aFillDir = static_cast<const SfxStringItem*>(pItem)->GetValue();
570  if( pReqArgs->HasItem( FN_PARAM_1, &pItem ) )
571  aFillCmd = static_cast<const SfxStringItem*>(pItem)->GetValue();
572  if( pReqArgs->HasItem( FN_PARAM_2, &pItem ) )
573  aFillDateCmd = static_cast<const SfxStringItem*>(pItem)->GetValue();
574  if( pReqArgs->HasItem( FN_PARAM_3, &pItem ) )
575  aFillStep = static_cast<const SfxStringItem*>(pItem)->GetValue();
576  if( pReqArgs->HasItem( FN_PARAM_4, &pItem ) )
577  aFillStart = static_cast<const SfxStringItem*>(pItem)->GetValue();
578  if( pReqArgs->HasItem( FN_PARAM_5, &pItem ) )
579  aFillMax = static_cast<const SfxStringItem*>(pItem)->GetValue();
580 
581  if( !aFillDir.isEmpty() )
582  switch( aFillDir[0] )
583  {
584  case 'B': case 'b': eFillDir=FILL_TO_BOTTOM; break;
585  case 'R': case 'r': eFillDir=FILL_TO_RIGHT; break;
586  case 'T': case 't': eFillDir=FILL_TO_TOP; break;
587  case 'L': case 'l': eFillDir=FILL_TO_LEFT; break;
588  }
589 
590  if( !aFillCmd.isEmpty() )
591  switch( aFillCmd[0] )
592  {
593  case 'S': case 's': eFillCmd=FILL_SIMPLE; break;
594  case 'L': case 'l': eFillCmd=FILL_LINEAR; break;
595  case 'G': case 'g': eFillCmd=FILL_GROWTH; break;
596  case 'D': case 'd': eFillCmd=FILL_DATE; break;
597  case 'A': case 'a': eFillCmd=FILL_AUTO; break;
598  }
599 
600  if( !aFillDateCmd.isEmpty() )
601  switch( aFillDateCmd[0] )
602  {
603  case 'D': case 'd': eFillDateCmd=FILL_DAY; break;
604  case 'W': case 'w': eFillDateCmd=FILL_WEEKDAY; break;
605  case 'M': case 'm': eFillDateCmd=FILL_MONTH; break;
606  case 'Y': case 'y': eFillDateCmd=FILL_YEAR; break;
607  }
608 
609  nKey = 0;
610  if( pFormatter->IsNumberFormat( aFillStart, nKey, fTmpVal ))
611  fStartVal = fTmpVal;
612 
613  nKey = 0;
614  if( pFormatter->IsNumberFormat( aFillStep, nKey, fTmpVal ))
615  fIncVal = fTmpVal;
616 
617  nKey = 0;
618  if( pFormatter->IsNumberFormat( aFillMax, nKey, fTmpVal ))
619  fMaxVal = fTmpVal;
620 
621  bDoIt = true;
622 
623  }
624  else // (pReqArgs == nullptr) => raise Dialog
625  {
626  sal_uInt32 nPrivFormat;
627  CellType eCellType;
628  rDoc.GetNumberFormat( nStartCol, nStartRow, nStartTab, nPrivFormat );
629  rDoc.GetCellType( nStartCol, nStartRow, nStartTab,eCellType );
630  const SvNumberformat* pPrivEntry = pFormatter->GetEntry( nPrivFormat );
631  const SCSIZE nSelectHeight = nEndRow - nStartRow + 1;
632  const SCSIZE nSelectWidth = nEndCol - nStartCol + 1;
633 
634  if (!pPrivEntry)
635  {
636  OSL_FAIL("Numberformat not found !!!");
637  }
638  else
639  {
640  SvNumFormatType nPrivType = pPrivEntry->GetType();
641  if (nPrivType & SvNumFormatType::DATE)
642  {
643  eFillCmd=FILL_DATE;
644  }
645  else if(eCellType==CELLTYPE_STRING)
646  {
647  eFillCmd=FILL_AUTO;
648  }
649  }
650 
651  OUString aStartStr;
652 
653  // suggest default Startvalue only, when just 1 row or column
654  if ( nStartCol == nEndCol || nStartRow == nEndRow )
655  {
656  double fInputEndVal = 0.0;
657  OUString aEndStr;
658 
659  rDoc.GetInputString( nStartCol, nStartRow, nStartTab, aStartStr);
660  rDoc.GetValue( nStartCol, nStartRow, nStartTab, fStartVal );
661 
662  if(eFillDir==FILL_TO_BOTTOM && nStartRow < nEndRow )
663  {
664  rDoc.GetInputString( nStartCol, nStartRow+1, nStartTab, aEndStr);
665  if(!aEndStr.isEmpty())
666  {
667  rDoc.GetValue( nStartCol, nStartRow+1, nStartTab, fInputEndVal);
668  fIncVal=fInputEndVal-fStartVal;
669  }
670  }
671  else
672  {
673  if(nStartCol < nEndCol)
674  {
675  rDoc.GetInputString( nStartCol+1, nStartRow, nStartTab, aEndStr);
676  if(!aEndStr.isEmpty())
677  {
678  rDoc.GetValue( nStartCol+1, nStartRow, nStartTab, fInputEndVal);
679  fIncVal=fInputEndVal-fStartVal;
680  }
681  }
682  }
683  if(eFillCmd==FILL_DATE)
684  {
685  const Date& rNullDate = rDoc.GetFormatTable()->GetNullDate();
686  Date aStartDate = rNullDate;
687  aStartDate.AddDays(fStartVal);
688  Date aEndDate = rNullDate;
689  aEndDate.AddDays(fInputEndVal);
690  double fTempDate=0;
691 
692  if(aStartDate.GetYear()!=aEndDate.GetYear())
693  {
694  eFillDateCmd = FILL_YEAR;
695  fTempDate=aEndDate.GetYear()-aStartDate.GetYear();
696  }
697  if(aStartDate.GetMonth()!=aEndDate.GetMonth())
698  {
699  eFillDateCmd = FILL_MONTH;
700  fTempDate=fTempDate*12+aEndDate.GetMonth()-aStartDate.GetMonth();
701  }
702  if(aStartDate.GetDay()==aEndDate.GetDay())
703  {
704  fIncVal=fTempDate;
705  }
706  }
707  }
709 
711  rDoc,
712  eFillDir, eFillCmd, eFillDateCmd,
713  aStartStr, fIncVal, fMaxVal,
714  nSelectHeight, nSelectWidth, nPossDir));
715 
716  if ( nStartCol != nEndCol && nStartRow != nEndRow )
717  {
718  pDlg->SetEdStartValEnabled(false);
719  }
720 
721  if ( pDlg->Execute() == RET_OK )
722  {
723  eFillDir = pDlg->GetFillDir();
724  eFillCmd = pDlg->GetFillCmd();
725  eFillDateCmd = pDlg->GetFillDateCmd();
726 
727  if(eFillCmd==FILL_AUTO)
728  {
729  OUString aStr = pDlg->GetStartStr();
730  if(!aStr.isEmpty())
731  pTabViewShell->EnterData( nStartCol, nStartRow, nStartTab, aStr );
732  }
733  fStartVal = pDlg->GetStart();
734  fIncVal = pDlg->GetStep();
735  fMaxVal = pDlg->GetMax();
736  bDoIt = true;
737  }
738  }
739 
740  if( bDoIt )
741  {
742  //nScFillModeMouseModifier = 0; // no Ctrl/Copy
743  pTabViewShell->FillSeries( eFillDir, eFillCmd, eFillDateCmd, fStartVal, fIncVal, fMaxVal );
744 
745  if( ! rReq.IsAPI() )
746  {
747  OUString aPara;
748  const Color* pColor = nullptr;
749 
750  switch( eFillDir )
751  {
752  case FILL_TO_BOTTOM: aPara = "B"; break;
753  case FILL_TO_RIGHT: aPara = "R"; break;
754  case FILL_TO_TOP: aPara = "T"; break;
755  case FILL_TO_LEFT: aPara = "L"; break;
756  default: break;
757  }
758  rReq.AppendItem( SfxStringItem( FID_FILL_SERIES, aPara ) );
759 
760  switch( eFillCmd )
761  {
762  case FILL_SIMPLE: aPara = "S"; break;
763  case FILL_LINEAR: aPara = "L"; break;
764  case FILL_GROWTH: aPara = "G"; break;
765  case FILL_DATE: aPara = "D"; break;
766  case FILL_AUTO: aPara = "A"; break;
767  default: break;
768  }
769  rReq.AppendItem( SfxStringItem( FN_PARAM_1, aPara ) );
770 
771  switch( eFillDateCmd )
772  {
773  case FILL_DAY: aPara = "D"; break;
774  case FILL_WEEKDAY: aPara = "W"; break;
775  case FILL_MONTH: aPara = "M"; break;
776  case FILL_YEAR: aPara = "Y"; break;
777  default: break;
778  }
779  rReq.AppendItem( SfxStringItem( FN_PARAM_2, aPara ) );
780 
781  sal_uInt32 nFormatKey = pFormatter->GetStandardFormat(SvNumFormatType::NUMBER,
782  ScGlobal::eLnge );
783 
784  pFormatter->GetOutputString( fIncVal, nFormatKey, aPara, &pColor );
785  rReq.AppendItem( SfxStringItem( FN_PARAM_3, aPara ) );
786 
787  pFormatter->GetOutputString( fStartVal, nFormatKey, aPara, &pColor );
788  rReq.AppendItem( SfxStringItem( FN_PARAM_4, aPara ) );
789 
790  pFormatter->GetOutputString( fMaxVal, nFormatKey, aPara, &pColor );
791  rReq.AppendItem( SfxStringItem( FN_PARAM_5, aPara ) );
792 
793  rReq.Done();
794  }
795  }
796  }
797  break;
798 
799  case FID_FILL_AUTO:
800  {
801  SCCOL nStartCol;
802  SCROW nStartRow;
803  SCCOL nEndCol;
804  SCROW nEndRow;
805 
806  GetViewData()->GetFillData( nStartCol, nStartRow, nEndCol, nEndRow );
807  SCCOL nFillCol = GetViewData()->GetRefEndX();
808  SCROW nFillRow = GetViewData()->GetRefEndY();
809  ScDocument& rDoc = GetViewData()->GetDocument();
810 
811  if( pReqArgs != nullptr )
812  {
813  const SfxPoolItem* pItem;
814 
815  if( pReqArgs->HasItem( FID_FILL_AUTO, &pItem ) )
816  {
817  ScAddress aScAddress;
818  OUString aArg = static_cast<const SfxStringItem*>(pItem)->GetValue();
819 
820  if( aScAddress.Parse( aArg, rDoc, rDoc.GetAddressConvention() ) & ScRefFlags::VALID )
821  {
822  nFillRow = aScAddress.Row();
823  nFillCol = aScAddress.Col();
824  }
825  }
826 
827  SCTAB nStartTab, nEndTab;
828  GetViewData()->GetSimpleArea( nStartCol,nStartRow,nStartTab,
829  nEndCol,nEndRow,nEndTab );
830  }
831  else // call via mouse
832  {
833  // not in a merged cell
834 
835  if ( nStartCol == nEndCol && nStartRow == nEndRow )
836  {
837  SCCOL nMergeCol = nStartCol;
838  SCROW nMergeRow = nStartRow;
839  if ( GetViewData()->GetDocument().ExtendMerge(
840  nStartCol, nStartRow, nMergeCol, nMergeRow,
841  GetViewData()->GetTabNo() ) )
842  {
843  if ( nFillCol >= nStartCol && nFillCol <= nMergeCol && nFillRow == nStartRow )
844  nFillCol = nStartCol;
845  if ( nFillRow >= nStartRow && nFillRow <= nMergeRow && nFillCol == nStartCol )
846  nFillRow = nStartRow;
847  }
848  }
849  }
850 
851  if ( nFillCol != nEndCol || nFillRow != nEndRow )
852  {
853  if ( nFillCol==nEndCol || nFillRow==nEndRow )
854  {
855  FillDir eDir = FILL_TO_BOTTOM;
856  SCCOLROW nCount = 0;
857 
858  if ( nFillCol==nEndCol )
859  {
860  if ( nFillRow > nEndRow )
861  {
862  eDir = FILL_TO_BOTTOM;
863  nCount = nFillRow - nEndRow;
864  }
865  else if ( nFillRow < nStartRow )
866  {
867  eDir = FILL_TO_TOP;
868  nCount = nStartRow - nFillRow;
869  }
870  }
871  else
872  {
873  if ( nFillCol > nEndCol )
874  {
875  eDir = FILL_TO_RIGHT;
876  nCount = nFillCol - nEndCol;
877  }
878  else if ( nFillCol < nStartCol )
879  {
880  eDir = FILL_TO_LEFT;
881  nCount = nStartCol - nFillCol;
882  }
883  }
884 
885  if ( nCount != 0)
886  {
887  pTabViewShell->FillAuto( eDir, nStartCol, nStartRow, nEndCol, nEndRow, nCount );
888 
889  if( ! rReq.IsAPI() )
890  {
891  ScAddress aAdr( nFillCol, nFillRow, 0 );
892  OUString aAdrStr(aAdr.Format(ScRefFlags::RANGE_ABS, &rDoc, rDoc.GetAddressConvention()));
893 
894  rReq.AppendItem( SfxStringItem( FID_FILL_AUTO, aAdrStr ) );
895  rReq.Done();
896  }
897  }
898 
899  }
900  else
901  {
902  OSL_FAIL( "Direction not unique for autofill" );
903  }
904  }
905  }
906  break;
907  case FID_FILL_SINGLE_EDIT:
909  break;
910  case SID_RANDOM_NUMBER_GENERATOR_DIALOG:
911  {
913  SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
914  SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
915 
916  pScMod->SetRefDialog( nId, pWnd == nullptr );
917 
918  }
919  break;
920  case SID_SAMPLING_DIALOG:
921  {
923  SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
924  SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
925 
926  pScMod->SetRefDialog( nId, pWnd == nullptr );
927  }
928  break;
929  case SID_DESCRIPTIVE_STATISTICS_DIALOG:
930  {
932  SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
933  SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
934 
935  pScMod->SetRefDialog( nId, pWnd == nullptr );
936  }
937  break;
938  case SID_ANALYSIS_OF_VARIANCE_DIALOG:
939  {
941  SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
942  SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
943 
944  pScMod->SetRefDialog( nId, pWnd == nullptr );
945  }
946  break;
947  case SID_CORRELATION_DIALOG:
948  {
950  SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
951  SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
952 
953  pScMod->SetRefDialog( nId, pWnd == nullptr );
954  }
955  break;
956  case SID_COVARIANCE_DIALOG:
957  {
959  SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
960  SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
961 
962  pScMod->SetRefDialog( nId, pWnd == nullptr );
963  }
964  break;
965  case SID_EXPONENTIAL_SMOOTHING_DIALOG:
966  {
968  SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
969  SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
970 
971  pScMod->SetRefDialog( nId, pWnd == nullptr );
972  }
973  break;
974  case SID_MOVING_AVERAGE_DIALOG:
975  {
977  SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
978  SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
979 
980  pScMod->SetRefDialog( nId, pWnd == nullptr );
981  }
982  break;
983  case SID_REGRESSION_DIALOG:
984  {
986  SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
987  SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
988 
989  pScMod->SetRefDialog( nId, pWnd == nullptr );
990  }
991  break;
992  case SID_TTEST_DIALOG:
993  {
994  sal_uInt16 nId = ScTTestDialogWrapper::GetChildWindowId();
995  SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
996  SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
997 
998  pScMod->SetRefDialog( nId, pWnd == nullptr );
999 
1000  }
1001  break;
1002  case SID_FTEST_DIALOG:
1003  {
1004  sal_uInt16 nId = ScFTestDialogWrapper::GetChildWindowId();
1005  SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
1006  SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
1007 
1008  pScMod->SetRefDialog( nId, pWnd == nullptr );
1009 
1010  }
1011  break;
1012  case SID_ZTEST_DIALOG:
1013  {
1014  sal_uInt16 nId = ScZTestDialogWrapper::GetChildWindowId();
1015  SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
1016  SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
1017 
1018  pScMod->SetRefDialog( nId, pWnd == nullptr );
1019 
1020  }
1021  break;
1022  case SID_CHI_SQUARE_TEST_DIALOG:
1023  {
1025  SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
1026  SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
1027 
1028  pScMod->SetRefDialog( nId, pWnd == nullptr );
1029 
1030  }
1031  break;
1032  case SID_FOURIER_ANALYSIS_DIALOG:
1033  {
1035  SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
1036  SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
1037 
1038  pScMod->SetRefDialog( nId, pWnd == nullptr );
1039 
1040  }
1041  break;
1042  case SID_SEARCH_RESULTS_DIALOG:
1043  {
1044  const SfxPoolItem* pItem = nullptr;
1045  if (pReqArgs && pReqArgs->HasItem(SID_SEARCH_RESULTS_DIALOG, &pItem))
1046  {
1047  bool bVisible = static_cast<const SfxBoolItem*>(pItem)->GetValue();
1048  SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
1049  // The window ID should equal the slot ID, but not a biggie if it wasn't.
1050  sal_uInt16 nId = sc::SearchResultsDlgWrapper::GetChildWindowId();
1051  pViewFrm->SetChildWindow(nId, bVisible, false);
1052  }
1053  rReq.Done();
1054  }
1055  break;
1056 
1057  // disposal (Outlines)
1058  // SID_AUTO_OUTLINE, SID_OUTLINE_DELETEALL in Execute (in docsh.idl)
1059 
1060  case SID_OUTLINE_HIDE:
1061  if ( GetViewData()->GetDocument().GetDPAtCursor( GetViewData()->GetCurX(),
1062  GetViewData()->GetCurY(), GetViewData()->GetTabNo() ) )
1063  pTabViewShell->SetDataPilotDetails( false );
1064  else
1065  pTabViewShell->HideMarkedOutlines();
1066  rReq.Done();
1067  break;
1068 
1069  case SID_OUTLINE_SHOW:
1070  {
1071  ScDPObject* pDPObj = GetViewData()->GetDocument().GetDPAtCursor( GetViewData()->GetCurX(),
1072  GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
1073  if ( pDPObj )
1074  {
1075  Sequence<sheet::DataPilotFieldFilter> aFilters;
1076  css::sheet::DataPilotFieldOrientation nOrientation;
1077  if ( pTabViewShell->HasSelectionForDrillDown( nOrientation ) )
1078  {
1081  pTabViewShell->GetFrameWeld(), *pDPObj, nOrientation ) );
1082  if ( pDlg->Execute() == RET_OK )
1083  {
1084  OUString aNewDimName( pDlg->GetDimensionName() );
1085  pTabViewShell->SetDataPilotDetails( true, &aNewDimName );
1086  }
1087  }
1088  else if ( !pDPObj->IsServiceData() &&
1089  pDPObj->GetDataFieldPositionData(
1090  ScAddress( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() ),
1091  aFilters ) )
1092  pTabViewShell->ShowDataPilotSourceData( *pDPObj, aFilters );
1093  else
1094  pTabViewShell->SetDataPilotDetails(true);
1095  }
1096  else
1097  pTabViewShell->ShowMarkedOutlines();
1098  rReq.Done();
1099  }
1100  break;
1101 
1102  case SID_OUTLINE_MAKE:
1103  {
1104  bool bColumns = false;
1105  bool bOk = true;
1106 
1107  if ( GetViewData()->GetDocument().GetDPAtCursor( GetViewData()->GetCurX(),
1108  GetViewData()->GetCurY(), GetViewData()->GetTabNo() ) )
1109  {
1110  ScDPNumGroupInfo aNumInfo;
1111  aNumInfo.mbEnable = true;
1112  aNumInfo.mbAutoStart = true;
1113  aNumInfo.mbAutoEnd = true;
1114  sal_Int32 nParts = 0;
1115  if ( pTabViewShell->HasSelectionForDateGroup( aNumInfo, nParts ) )
1116  {
1118  const Date& rNullDate( GetViewData()->GetDocument().GetFormatTable()->GetNullDate() );
1120  pTabViewShell->GetFrameWeld(),
1121  aNumInfo, nParts, rNullDate ) );
1122  if( pDlg->Execute() == RET_OK )
1123  {
1124  aNumInfo = pDlg->GetGroupInfo();
1125  pTabViewShell->DateGroupDataPilot( aNumInfo, pDlg->GetDatePart() );
1126  }
1127  }
1128  else if ( pTabViewShell->HasSelectionForNumGroup( aNumInfo ) )
1129  {
1132  pTabViewShell->GetFrameWeld(), aNumInfo ) );
1133  if( pDlg->Execute() == RET_OK )
1134  pTabViewShell->NumGroupDataPilot( pDlg->GetGroupInfo() );
1135  }
1136  else
1137  pTabViewShell->GroupDataPilot();
1138 
1139  bOk = false;
1140  }
1141  else if( pReqArgs != nullptr )
1142  {
1143  const SfxPoolItem* pItem;
1144  bOk = false;
1145 
1146  if( pReqArgs->HasItem( SID_OUTLINE_MAKE, &pItem ) )
1147  {
1148  OUString aCol = static_cast<const SfxStringItem*>(pItem)->GetValue();
1149  aCol = aCol.toAsciiUpperCase();
1150 
1151  switch( aCol[0] )
1152  {
1153  case 'R': bColumns=false; bOk = true;break;
1154  case 'C': bColumns=true; bOk = true;break;
1155  }
1156  }
1157  }
1158  else // Dialog, when not whole rows/columns are marked
1159  {
1160  if ( GetViewData()->SimpleColMarked() && !GetViewData()->SimpleRowMarked() )
1161  bColumns = true;
1162  else if ( !GetViewData()->SimpleColMarked() && GetViewData()->SimpleRowMarked() )
1163  bColumns = false;
1164  else
1165  {
1167 
1168  VclPtr<AbstractScGroupDlg> pDlg(pFact->CreateAbstractScGroupDlg(pTabViewShell->GetFrameWeld()));
1169 
1170  pDlg->StartExecuteAsync(
1171  [pDlg, pTabViewShell] (sal_Int32 nResult) {
1172  if( RET_OK == nResult )
1173  {
1174  bool bColumn = pDlg->GetColsChecked();
1175  pTabViewShell->MakeOutline( bColumn );
1176  }
1177  pDlg->disposeOnce();
1178  }
1179  );
1180 
1181  bOk = false;
1182  }
1183  }
1184  if (bOk)
1185  {
1186  pTabViewShell->MakeOutline( bColumns );
1187 
1188  if( ! rReq.IsAPI() )
1189  {
1190  OUString aCol = bColumns ? OUString('C') : OUString('R');
1191  rReq.AppendItem( SfxStringItem( SID_OUTLINE_MAKE, aCol ) );
1192  rReq.Done();
1193  }
1194  }
1195  }
1196  break;
1197 
1198  case SID_OUTLINE_REMOVE:
1199  {
1200  bool bColumns = false;
1201  bool bOk = true;
1202 
1203  if ( GetViewData()->GetDocument().GetDPAtCursor( GetViewData()->GetCurX(),
1204  GetViewData()->GetCurY(), GetViewData()->GetTabNo() ) )
1205  {
1206  pTabViewShell->UngroupDataPilot();
1207  bOk = false;
1208  }
1209  else if( pReqArgs != nullptr )
1210  {
1211  const SfxPoolItem* pItem;
1212  bOk = false;
1213 
1214  if( pReqArgs->HasItem( SID_OUTLINE_REMOVE, &pItem ) )
1215  {
1216  OUString aCol = static_cast<const SfxStringItem*>(pItem)->GetValue();
1217  aCol = aCol.toAsciiUpperCase();
1218 
1219  switch (aCol[0])
1220  {
1221  case 'R': bColumns=false; bOk = true;break;
1222  case 'C': bColumns=true; bOk = true;break;
1223  }
1224  }
1225  }
1226  else // Dialog only when removal for rows and columns is possible
1227  {
1228  bool bColPoss, bRowPoss;
1229  pTabViewShell->TestRemoveOutline( bColPoss, bRowPoss );
1230  // TODO: handle this case in LOK too
1231  if ( bColPoss && bRowPoss && !comphelper::LibreOfficeKit::isActive() )
1232  {
1234 
1235  VclPtr<AbstractScGroupDlg> pDlg(pFact->CreateAbstractScGroupDlg(pTabViewShell->GetFrameWeld(), true));
1236 
1237  pDlg->StartExecuteAsync(
1238  [pDlg, pTabViewShell] (sal_Int32 nResult) {
1239  if( RET_OK == nResult )
1240  {
1241  bool bColumn = pDlg->GetColsChecked();
1242  pTabViewShell->RemoveOutline( bColumn );
1243  }
1244  pDlg->disposeOnce();
1245  }
1246  );
1247 
1248  bOk = false;
1249  }
1250  else if ( bColPoss )
1251  bColumns = true;
1252  else if ( bRowPoss )
1253  bColumns = false;
1254  else
1255  bOk = false;
1256  }
1257  if (bOk)
1258  {
1259  pTabViewShell->RemoveOutline( bColumns );
1260 
1261  if( ! rReq.IsAPI() )
1262  {
1263  OUString aCol = bColumns ? OUString('C') : OUString('R');
1264  rReq.AppendItem( SfxStringItem( SID_OUTLINE_REMOVE, aCol ) );
1265  rReq.Done();
1266  }
1267  }
1268  }
1269  break;
1270 
1271  // Clipboard
1272 
1273  case SID_COPY: // for graphs in DrawShell
1274  {
1275  weld::WaitObject aWait( GetViewData()->GetDialogParent() );
1276  pTabViewShell->CopyToClip( nullptr, false, false, true );
1277  rReq.Done();
1279  pTabViewShell->ShowCursor();
1280  pTabViewShell->UpdateCopySourceOverlay();
1281  }
1282  break;
1283 
1284  case SID_CUT: // for graphs in DrawShell
1285  {
1286  weld::WaitObject aWait( GetViewData()->GetDialogParent() );
1287  pTabViewShell->CutToClip();
1288  rReq.Done();
1290  pTabViewShell->ShowCursor();
1291  pTabViewShell->UpdateCopySourceOverlay();
1292  }
1293  break;
1294 
1295  case SID_PASTE:
1296  {
1297  ScClipUtil::PasteFromClipboard ( GetViewData(), pTabViewShell, true );
1298  rReq.Done();
1299  }
1300  break;
1301 
1302  case SID_CLIPBOARD_FORMAT_ITEMS:
1303  {
1304  weld::WaitObject aWait( GetViewData()->GetDialogParent() );
1305 
1306  SotClipboardFormatId nFormat = SotClipboardFormatId::NONE;
1307  const SfxPoolItem* pItem;
1308  if ( pReqArgs &&
1309  pReqArgs->GetItemState(nSlot, true, &pItem) == SfxItemState::SET &&
1310  dynamic_cast<const SfxUInt32Item*>( pItem) != nullptr )
1311  {
1312  nFormat = static_cast<SotClipboardFormatId>(static_cast<const SfxUInt32Item*>(pItem)->GetValue());
1313  }
1314 
1315  if ( nFormat != SotClipboardFormatId::NONE )
1316  {
1317  css::uno::Reference<css::datatransfer::XTransferable2> xTransferable(ScTabViewShell::GetClipData(GetViewData()->GetActiveWin()));
1318  bool bCells = ( ScTransferObj::GetOwnClipboard(xTransferable) != nullptr );
1319  bool bDraw = ( ScDrawTransferObj::GetOwnClipboard(xTransferable) != nullptr );
1320  bool bOle = ( nFormat == SotClipboardFormatId::EMBED_SOURCE );
1321 
1322  if ( bCells && bOle )
1323  pTabViewShell->PasteFromSystem();
1324  else if ( bDraw && bOle )
1325  pTabViewShell->PasteDraw();
1326  else
1327  pTabViewShell->PasteFromSystem(nFormat);
1328  }
1329  //?else
1330  //? pTabViewShell->PasteFromSystem();
1331 
1332  rReq.Done();
1333  }
1334  pTabViewShell->CellContentChanged();
1335  break;
1336 
1337  case FID_INS_CELL_CONTENTS:
1338  {
1339  ScDocument& rDoc = GetViewData()->GetDocument();
1340  bool bOtherDoc = !rDoc.IsClipboardSource();
1341  // keep a reference in case the clipboard is changed during dialog or PasteFromClip
1343  if ( pOwnClip )
1344  {
1346  ScPasteFunc nFunction = ScPasteFunc::NONE;
1347  InsCellCmd eMoveMode = INS_NONE;
1348  bool bSkipEmpty = false;
1349  bool bTranspose = false;
1350  bool bAsLink = false;
1351 
1352  if ( pReqArgs!=nullptr && pTabViewShell->SelectionEditable() )
1353  {
1354  const SfxPoolItem* pItem;
1355  OUString aFlags('A');
1356 
1357  if( pReqArgs->HasItem( FID_INS_CELL_CONTENTS, &pItem ) )
1358  aFlags = static_cast<const SfxStringItem*>(pItem)->GetValue();
1359 
1360  nFlags |= FlagsFromString(aFlags);
1361 
1362  const SfxUInt16Item* pFuncItem = rReq.GetArg<SfxUInt16Item>(FN_PARAM_1);
1363  const SfxBoolItem* pSkipItem = rReq.GetArg<SfxBoolItem>(FN_PARAM_2);
1364  const SfxBoolItem* pTransposeItem = rReq.GetArg<SfxBoolItem>(FN_PARAM_3);
1365  const SfxBoolItem* pLinkItem = rReq.GetArg<SfxBoolItem>(FN_PARAM_4);
1366  const SfxInt16Item* pMoveItem = rReq.GetArg<SfxInt16Item>(FN_PARAM_5);
1367  if ( pFuncItem )
1368  nFunction = static_cast<ScPasteFunc>(pFuncItem->GetValue());
1369  if ( pSkipItem )
1370  bSkipEmpty = pSkipItem->GetValue();
1371  if ( pTransposeItem )
1372  bTranspose = pTransposeItem->GetValue();
1373  if ( pLinkItem )
1374  bAsLink = pLinkItem->GetValue();
1375  if ( pMoveItem )
1376  eMoveMode = static_cast<InsCellCmd>(pMoveItem->GetValue());
1377  }
1378  else
1379  {
1380  ScEditableTester aTester( pTabViewShell );
1381  if (aTester.IsEditable())
1382  {
1384 
1386  pDlg->SetOtherDoc( bOtherDoc );
1387  // if ChangeTrack MoveMode disable
1388  pDlg->SetChangeTrack( rDoc.GetChangeTrack() != nullptr );
1389  // fdo#56098 disable shift if necessary
1390  if (!bOtherDoc)
1391  {
1393  if ( pData->GetMarkData().GetTableSelect( pData->GetTabNo() ) )
1394  {
1395  SCCOL nStartX, nEndX, nClipStartX, nClipSizeX, nRangeSizeX;
1396  SCROW nStartY, nEndY, nClipStartY, nClipSizeY, nRangeSizeY;
1397  SCTAB nStartTab, nEndTab;
1398  pOwnClip->GetDocument()->GetClipStart( nClipStartX, nClipStartY );
1399  pOwnClip->GetDocument()->GetClipArea( nClipSizeX, nClipSizeY, true );
1400 
1401  if ( pData->GetSimpleArea( nStartX, nStartY, nStartTab,
1402  nEndX, nEndY, nEndTab ) != SC_MARK_SIMPLE ||
1403  nStartTab != nEndTab )
1404  {
1405  // the destination is not a simple range,
1406  // assume the destination as the current cell
1407  nStartX = nEndX = pData->GetCurX();
1408  nStartY = nEndY = pData->GetCurY();
1409  nStartTab = pData->GetTabNo();
1410  }
1411  // we now have clip- and range dimensions
1412  // the size of the destination area is the larger of the two
1413  nRangeSizeX = nClipSizeX >= nEndX - nStartX ? nClipSizeX : nEndX - nStartX;
1414  nRangeSizeY = nClipSizeY >= nEndY - nStartY ? nClipSizeY : nEndY - nStartY;
1415  // When the source and destination areas intersect things may go wrong,
1416  // especially if the area contains references. This may produce data loss
1417  // (e.g. formulas that get wrong references), this scenario _must_ be avoided.
1418  ScRange aSource( nClipStartX, nClipStartY, nStartTab,
1419  nClipStartX + nClipSizeX, nClipStartY + nClipSizeY, nStartTab );
1420  ScRange aDest( nStartX, nStartY, nStartTab,
1421  nStartX + nRangeSizeX, nStartY + nRangeSizeY, nStartTab );
1422  if ( pOwnClip->GetDocument()->IsCutMode() && aSource.Intersects( aDest ) )
1424  else
1425  {
1426  //no conflict with intersecting ranges,
1427  //check if paste plus shift will fit on sheet
1428  //and disable shift-option if no fit
1431 
1432  //check if horizontal shift will fit
1433  if ( !pData->GetDocument().IsBlockEmpty( nStartTab,
1434  rDoc.MaxCol() - nRangeSizeX, nStartY,
1435  rDoc.MaxCol(), nStartY + nRangeSizeY ) )
1436  nDisableShiftX = CellShiftDisabledFlags::Right;
1437 
1438  //check if vertical shift will fit
1439  if ( !pData->GetDocument().IsBlockEmpty( nStartTab,
1440  nStartX, rDoc.MaxRow() - nRangeSizeY,
1441  nStartX + nRangeSizeX, rDoc.MaxRow() ) )
1442  nDisableShiftY = CellShiftDisabledFlags::Down;
1443 
1444  if ( nDisableShiftX != CellShiftDisabledFlags::NONE || nDisableShiftY != CellShiftDisabledFlags::NONE)
1445  pDlg->SetCellShiftDisabled( nDisableShiftX | nDisableShiftY );
1446  }
1447  }
1448  }
1449  if (pDlg->Execute() == RET_OK)
1450  {
1451  nFlags = pDlg->GetInsContentsCmdBits();
1452  nFunction = pDlg->GetFormulaCmdBits();
1453  bSkipEmpty = pDlg->IsSkipEmptyCells();
1454  bTranspose = pDlg->IsTranspose();
1455  bAsLink = pDlg->IsLink();
1456  eMoveMode = pDlg->GetMoveMode();
1457  }
1458  }
1459  else
1460  pTabViewShell->ErrorMessage(aTester.GetMessageId());
1461  }
1462 
1463  if( nFlags != InsertDeleteFlags::NONE )
1464  {
1465  {
1466  weld::WaitObject aWait( GetViewData()->GetDialogParent() );
1467  if ( bAsLink && bOtherDoc )
1468  pTabViewShell->PasteFromSystem(SotClipboardFormatId::LINK); // DDE insert
1469  else
1470  {
1471  pTabViewShell->PasteFromClip( nFlags, pOwnClip->GetDocument(),
1472  nFunction, bSkipEmpty, bTranspose, bAsLink,
1473  eMoveMode, InsertDeleteFlags::NONE, true ); // allow warning dialog
1474  }
1475  }
1476 
1477  if( !pReqArgs )
1478  {
1479  OUString aFlags = FlagsToString( nFlags );
1480 
1481  rReq.AppendItem( SfxStringItem( FID_INS_CELL_CONTENTS, aFlags ) );
1482  rReq.AppendItem( SfxBoolItem( FN_PARAM_2, bSkipEmpty ) );
1483  rReq.AppendItem( SfxBoolItem( FN_PARAM_3, bTranspose ) );
1484  rReq.AppendItem( SfxBoolItem( FN_PARAM_4, bAsLink ) );
1485  rReq.AppendItem( SfxUInt16Item( FN_PARAM_1, static_cast<sal_uInt16>(nFunction) ) );
1486  rReq.AppendItem( SfxInt16Item( FN_PARAM_5, static_cast<sal_Int16>(eMoveMode) ) );
1487  rReq.Done();
1488  }
1489  }
1490  }
1491  }
1492  pTabViewShell->CellContentChanged(); // => PasteFromXXX ???
1493  break;
1494  case SID_PASTE_ONLY_VALUE:
1495  case SID_PASTE_ONLY_TEXT:
1496  case SID_PASTE_ONLY_FORMULA:
1497  {
1498  if ( ScTransferObj::GetOwnClipboard(ScTabViewShell::GetClipData(GetViewData()->GetActiveWin())) ) // own cell data
1499  {
1500  rReq.SetSlot( FID_INS_CELL_CONTENTS );
1501  OUString aFlags;
1502  if ( nSlot == SID_PASTE_ONLY_VALUE )
1503  aFlags = "V";
1504  else if ( nSlot == SID_PASTE_ONLY_TEXT )
1505  aFlags = "S";
1506  else
1507  aFlags = "F";
1508  rReq.AppendItem( SfxStringItem( FID_INS_CELL_CONTENTS, aFlags ) );
1509  ExecuteSlot( rReq, GetInterface() );
1510  rReq.SetReturnValue(SfxInt16Item(nSlot, 1)); // 1 = success
1511  pTabViewShell->CellContentChanged();
1512  }
1513  else
1514  rReq.SetReturnValue(SfxInt16Item(nSlot, 0)); // 0 = fail
1515  break;
1516  }
1517  case SID_PASTE_TEXTIMPORT_DIALOG:
1518  {
1519  vcl::Window* pWin = GetViewData()->GetActiveWin();
1520  TransferableDataHelper aDataHelper(
1522  const uno::Reference<datatransfer::XTransferable>& xTransferable
1523  = aDataHelper.GetTransferable();
1524  SotClipboardFormatId format = SotClipboardFormatId::STRING;
1525  bool bSuccess = false;
1526  if (xTransferable.is() && HasClipboardFormat(format))
1527  {
1528  OUString sStrBuffer;
1529  bSuccess = aDataHelper.GetString(format, sStrBuffer);
1530  if (bSuccess)
1531  {
1532  auto pStrm = std::make_shared<ScImportStringStream>(sStrBuffer);
1534  VclPtr<AbstractScImportAsciiDlg> pDlg(pFact->CreateScImportAsciiDlg(
1535  pWin ? pWin->GetFrameWeld() : nullptr, OUString(), pStrm.get(), SC_PASTETEXT));
1536  ScRange aRange;
1537  SCCOL nPosX = 0;
1538  SCROW nPosY = 0;
1539  if (GetViewData()->GetSimpleArea(aRange) == SC_MARK_SIMPLE)
1540  {
1541  nPosX = aRange.aStart.Col();
1542  nPosY = aRange.aStart.Row();
1543  }
1544  else
1545  {
1546  nPosX = GetViewData()->GetCurX();
1547  nPosY = GetViewData()->GetCurY();
1548  }
1549  ScAddress aCellPos(nPosX, nPosY, GetViewData()->GetTabNo());
1550  auto pObj = std::make_shared<ScImportExport>(GetViewData()->GetDocument(), aCellPos);
1551  pObj->SetOverwriting(true);
1552  if (pDlg->Execute()) {
1553  ScAsciiOptions aOptions;
1554  pDlg->GetOptions(aOptions);
1555  pDlg->SaveParameters();
1556  pObj->SetExtOptions(aOptions);
1557  pObj->ImportString(sStrBuffer, format);
1558  }
1559  pDlg->disposeOnce();
1560  rReq.SetReturnValue(SfxInt16Item(nSlot, 1)); // 1 = success, 0 = fail
1561  rReq.Done();
1562  }
1563  }
1564  if (!bSuccess)
1565  {
1566  rReq.SetReturnValue(SfxInt16Item(nSlot, 0)); // 0 = fail
1567  rReq.Ignore();
1568  }
1569  }
1570  break;
1571  case SID_PASTE_SPECIAL:
1572  // differentiate between own cell data and draw objects/external data
1573  // this makes FID_INS_CELL_CONTENTS superfluous
1574  {
1575  vcl::Window* pWin = GetViewData()->GetActiveWin();
1576  css::uno::Reference<css::datatransfer::XTransferable2> xTransferable(ScTabViewShell::GetClipData(pWin));
1577 
1578  // Clipboard-ID given as parameter? Basic "PasteSpecial(Format)"
1579  const SfxPoolItem* pItem=nullptr;
1580  if ( pReqArgs &&
1581  pReqArgs->GetItemState(nSlot, true, &pItem) == SfxItemState::SET &&
1582  dynamic_cast<const SfxUInt32Item*>( pItem) != nullptr )
1583  {
1584  SotClipboardFormatId nFormat = static_cast<SotClipboardFormatId>(static_cast<const SfxUInt32Item*>(pItem)->GetValue());
1585  bool bRet=true;
1586  {
1587  weld::WaitObject aWait( GetViewData()->GetDialogParent() );
1588  bool bDraw = ( ScDrawTransferObj::GetOwnClipboard(xTransferable) != nullptr );
1589  if ( bDraw && nFormat == SotClipboardFormatId::EMBED_SOURCE )
1590  pTabViewShell->PasteDraw();
1591  else
1592  bRet = pTabViewShell->PasteFromSystem(nFormat, true); // TRUE: no error messages
1593  }
1594 
1595  if ( bRet )
1596  {
1597  rReq.SetReturnValue(SfxInt16Item(nSlot, 1)); // 1 = success, 0 = fail
1598  rReq.Done();
1599  }
1600  else
1601  // if format is not available -> fallback to request without parameters
1602  pItem = nullptr;
1603  }
1604 
1605  if ( !pItem )
1606  {
1607  if ( ScTransferObj::GetOwnClipboard(xTransferable) ) // own cell data
1608  {
1609  rReq.SetSlot( FID_INS_CELL_CONTENTS );
1610  ExecuteSlot( rReq, GetInterface() );
1611  rReq.SetReturnValue(SfxInt16Item(nSlot, 1)); // 1 = success
1612  }
1613  else // draw objects or external data
1614  {
1615  bool bDraw = ( ScDrawTransferObj::GetOwnClipboard(xTransferable) != nullptr );
1616 
1617  SvxClipboardFormatItem aFormats( SID_CLIPBOARD_FORMAT_ITEMS );
1618  GetPossibleClipboardFormats( aFormats );
1619 
1620  sal_uInt16 nFormatCount = aFormats.Count();
1621  if ( nFormatCount )
1622  {
1624  ScopedVclPtr<SfxAbstractPasteDialog> pDlg(pFact->CreatePasteDialog(pTabViewShell->GetFrameWeld()));
1625  for (sal_uInt16 i=0; i<nFormatCount; i++)
1626  {
1627  SotClipboardFormatId nFormatId = aFormats.GetClipbrdFormatId( i );
1628  OUString aName = aFormats.GetClipbrdFormatName( i );
1629  // special case for paste dialog: '*' is replaced by object type
1630  if ( nFormatId == SotClipboardFormatId::EMBED_SOURCE )
1631  aName = "*";
1632  pDlg->Insert( nFormatId, aName );
1633  }
1634 
1635  SfxViewFrame* pViewFrame = pTabViewShell->GetViewFrame();
1636  auto xFrame = pViewFrame->GetFrame().GetFrameInterface();
1637  const OUString aModuleName(vcl::CommandInfoProvider::GetModuleIdentifier(xFrame));
1638  auto aProperties = vcl::CommandInfoProvider::GetCommandProperties(".uno:PasteTextImportDialog", aModuleName);
1640  pDlg->InsertUno(".uno:PasteTextImportDialog", sLabel);
1641 
1642  TransferableDataHelper aDataHelper(
1644  SotClipboardFormatId nFormat = pDlg->GetFormat( aDataHelper.GetTransferable() );
1645  if (nFormat != SotClipboardFormatId::NONE)
1646  {
1647  {
1648  weld::WaitObject aWait( GetViewData()->GetDialogParent() );
1649  if ( bDraw && nFormat == SotClipboardFormatId::EMBED_SOURCE )
1650  pTabViewShell->PasteDraw();
1651  else
1652  pTabViewShell->PasteFromSystem(nFormat);
1653  }
1654  rReq.SetReturnValue(SfxInt16Item(nSlot, 1)); // 1 = success
1655  rReq.AppendItem( SfxUInt32Item( nSlot, static_cast<sal_uInt32>(nFormat) ) );
1656  rReq.Done();
1657  }
1658  else
1659  {
1660  rReq.SetReturnValue(SfxInt16Item(nSlot, 0)); // 0 = fail
1661  rReq.Ignore();
1662  }
1663  }
1664  else
1665  rReq.SetReturnValue(SfxInt16Item(nSlot, 0)); // 0 = fail
1666  }
1667  }
1668  }
1669  pTabViewShell->CellContentChanged(); // => PasteFromSystem() ???
1670  break;
1671 
1672  case SID_PASTE_UNFORMATTED:
1673  // differentiate between own cell data and draw objects/external data
1674  // this makes FID_INS_CELL_CONTENTS superfluous
1675  {
1676  weld::WaitObject aWait( GetViewData()->GetDialogParent() );
1677 
1678  // we should differentiate between SotClipboardFormatId::STRING and SotClipboardFormatId::STRING_TSVC,
1679  // and paste the SotClipboardFormatId::STRING_TSVC if it is available.
1680  // Which makes a difference if the clipboard contains cells with embedded line breaks.
1681 
1682  SotClipboardFormatId nFormat = HasClipboardFormat( SotClipboardFormatId::STRING_TSVC) ?
1683  SotClipboardFormatId::STRING_TSVC : SotClipboardFormatId::STRING;
1684 
1685  const bool bRet = pTabViewShell->PasteFromSystem(nFormat, true); // TRUE: no error messages
1686  if ( bRet )
1687  {
1688  rReq.SetReturnValue(SfxInt16Item(nSlot, 1)); // 1 = success
1689  rReq.Done();
1690  }
1691  else
1692  {
1693  rReq.SetReturnValue(SfxInt16Item(nSlot, 0)); // 0 = fail
1694  }
1695 
1696  pTabViewShell->CellContentChanged(); // => PasteFromSystem() ???
1697  }
1698  break;
1699 
1700  // other
1701 
1702  case FID_INS_ROWBRK:
1703  pTabViewShell->InsertPageBreak( false );
1704  rReq.Done();
1705  break;
1706 
1707  case FID_INS_COLBRK:
1708  pTabViewShell->InsertPageBreak( true );
1709  rReq.Done();
1710  break;
1711 
1712  case FID_DEL_ROWBRK:
1713  pTabViewShell->DeletePageBreak( false );
1714  rReq.Done();
1715  break;
1716 
1717  case FID_DEL_COLBRK:
1718  pTabViewShell->DeletePageBreak( true );
1719  rReq.Done();
1720  break;
1721 
1722  case SID_DETECTIVE_ADD_PRED:
1723  pTabViewShell->DetectiveAddPred();
1724  rReq.Done();
1725  break;
1726 
1727  case SID_DETECTIVE_DEL_PRED:
1728  pTabViewShell->DetectiveDelPred();
1729  rReq.Done();
1730  break;
1731 
1732  case SID_DETECTIVE_ADD_SUCC:
1733  pTabViewShell->DetectiveAddSucc();
1734  rReq.Done();
1735  break;
1736 
1737  case SID_DETECTIVE_DEL_SUCC:
1738  pTabViewShell->DetectiveDelSucc();
1739  rReq.Done();
1740  break;
1741 
1742  case SID_DETECTIVE_ADD_ERR:
1743  pTabViewShell->DetectiveAddError();
1744  rReq.Done();
1745  break;
1746 
1747  case SID_DETECTIVE_INVALID:
1748  pTabViewShell->DetectiveMarkInvalid();
1749  rReq.Done();
1750  break;
1751 
1752  case SID_DETECTIVE_REFRESH:
1753  pTabViewShell->DetectiveRefresh();
1754  rReq.Done();
1755  break;
1756 
1757  case SID_DETECTIVE_MARK_PRED:
1758  pTabViewShell->DetectiveMarkPred();
1759  break;
1760  case SID_DETECTIVE_MARK_SUCC:
1761  pTabViewShell->DetectiveMarkSucc();
1762  break;
1763  case SID_INSERT_CURRENT_DATE:
1764  pTabViewShell->InsertCurrentTime(
1765  SvNumFormatType::DATE, ScResId(STR_UNDO_INSERT_CURRENT_DATE));
1766  break;
1767  case SID_INSERT_CURRENT_TIME:
1768  pTabViewShell->InsertCurrentTime(
1769  SvNumFormatType::TIME, ScResId(STR_UNDO_INSERT_CURRENT_TIME));
1770  break;
1771 
1772  case SID_SPELL_DIALOG:
1773  {
1774  SfxViewFrame* pViewFrame = pTabViewShell->GetViewFrame();
1775  if( rReq.GetArgs() )
1776  pViewFrame->SetChildWindow( SID_SPELL_DIALOG,
1777  static_cast< const SfxBoolItem& >( rReq.GetArgs()->
1778  Get( SID_SPELL_DIALOG ) ).GetValue() );
1779  else
1780  pViewFrame->ToggleChildWindow( SID_SPELL_DIALOG );
1781 
1782  pViewFrame->GetBindings().Invalidate( SID_SPELL_DIALOG );
1783  rReq.Ignore();
1784  }
1785  break;
1786 
1787  case SID_HANGUL_HANJA_CONVERSION:
1788  pTabViewShell->DoHangulHanjaConversion();
1789  break;
1790 
1791  case SID_CHINESE_CONVERSION:
1792  {
1793  //open ChineseTranslationDialog
1795  ::cppu::defaultBootstrap_InitialComponentContext() ); //@todo get context from calc if that has one
1796  if(xContext.is())
1797  {
1798  Reference< lang::XMultiComponentFactory > xMCF( xContext->getServiceManager() );
1799  if(xMCF.is())
1800  {
1801  Reference< ui::dialogs::XExecutableDialog > xDialog(
1802  xMCF->createInstanceWithContext(
1803  "com.sun.star.linguistic2.ChineseTranslationDialog"
1804  , xContext),
1805  UNO_QUERY);
1806  Reference< lang::XInitialization > xInit( xDialog, UNO_QUERY );
1807  if( xInit.is() )
1808  {
1809  // initialize dialog
1810  uno::Sequence<uno::Any> aSeq(comphelper::InitAnyPropertySequence(
1811  {
1812  {"ParentWindow", uno::Any(Reference< awt::XWindow >())}
1813  }));
1814  xInit->initialize( aSeq );
1815 
1816  //execute dialog
1817  sal_Int16 nDialogRet = xDialog->execute();
1818  if( RET_OK == nDialogRet )
1819  {
1820  //get some parameters from the dialog
1821  bool bToSimplified = true;
1822  bool bUseVariants = true;
1823  bool bCommonTerms = true;
1824  Reference< beans::XPropertySet > xProp( xDialog, UNO_QUERY );
1825  if( xProp.is() )
1826  {
1827  try
1828  {
1829  xProp->getPropertyValue("IsDirectionToSimplified") >>= bToSimplified;
1830  xProp->getPropertyValue("IsUseCharacterVariants") >>= bUseVariants;
1831  xProp->getPropertyValue("IsTranslateCommonTerms") >>= bCommonTerms;
1832  }
1833  catch( Exception& )
1834  {
1835  }
1836  }
1837 
1838  //execute translation
1841  sal_Int32 nOptions = bUseVariants ? i18n::TextConversionOption::USE_CHARACTER_VARIANTS : 0;
1842  if( !bCommonTerms )
1843  nOptions |= i18n::TextConversionOption::CHARACTER_BY_CHARACTER;
1844 
1846  DefaultFontType::CJK_SPREADSHEET,
1847  eTargetLang, GetDefaultFontFlags::OnlyOne );
1849  eSourceLang, eTargetLang, aTargetFont, nOptions, false );
1850  pTabViewShell->DoSheetConversion( aConvParam );
1851  }
1852  }
1853  Reference< lang::XComponent > xComponent( xDialog, UNO_QUERY );
1854  if( xComponent.is() )
1855  xComponent->dispose();
1856  }
1857  }
1858  }
1859  break;
1860 
1861  case SID_CONVERT_FORMULA_TO_VALUE:
1862  {
1863  pTabViewShell->ConvertFormulaToValue();
1864  }
1865  break;
1866  case SID_THESAURUS:
1867  pTabViewShell->DoThesaurus();
1868  break;
1869 
1870  case SID_TOGGLE_REL:
1871  pTabViewShell->DoRefConversion();
1872  break;
1873 
1874  case SID_DEC_INDENT:
1875  pTabViewShell->ChangeIndent( false );
1876  break;
1877  case SID_INC_INDENT:
1878  pTabViewShell->ChangeIndent( true );
1879  break;
1880 
1881  case FID_USE_NAME:
1882  {
1883  CreateNameFlags nFlags = pTabViewShell->GetCreateNameFlags();
1884 
1886 
1887  ScopedVclPtr<AbstractScNameCreateDlg> pDlg(pFact->CreateScNameCreateDlg(pTabViewShell->GetFrameWeld(), nFlags));
1888 
1889  if( pDlg->Execute() )
1890  {
1891  pTabViewShell->CreateNames(pDlg->GetFlags());
1892  rReq.Done();
1893  }
1894  }
1895  break;
1896 
1897  case SID_CONSOLIDATE:
1898  {
1899  const SfxPoolItem* pItem;
1900  if ( pReqArgs && SfxItemState::SET ==
1901  pReqArgs->GetItemState( SCITEM_CONSOLIDATEDATA, true, &pItem ) )
1902  {
1903  const ScConsolidateParam& rParam =
1904  static_cast<const ScConsolidateItem*>(pItem)->GetData();
1905 
1906  pTabViewShell->Consolidate( rParam );
1907  GetViewData()->GetDocument().SetConsolidateDlgData( std::unique_ptr<ScConsolidateParam>(new ScConsolidateParam(rParam)) );
1908 
1909  rReq.Done();
1910  }
1911 #if HAVE_FEATURE_SCRIPTING
1912  else if (rReq.IsAPI())
1914 #endif
1915  }
1916  break;
1917 
1918  case SID_INS_FUNCTION:
1919  {
1920  const SfxBoolItem* pOkItem = static_cast<const SfxBoolItem*>(&pReqArgs->Get( SID_DLG_RETOK ));
1921 
1922  if ( pOkItem->GetValue() ) // OK
1923  {
1924  OUString aFormula;
1925  const SfxStringItem* pSItem = static_cast<const SfxStringItem*>(&pReqArgs->Get( SCITEM_STRING ));
1926  const SfxBoolItem* pMatrixItem = static_cast<const SfxBoolItem*>(&pReqArgs->Get( SID_DLG_MATRIX ));
1927 
1928  aFormula += pSItem->GetValue();
1929  pScMod->ActivateInputWindow( &aFormula, pMatrixItem->GetValue() );
1930  }
1931  else // CANCEL
1932  {
1933  pScMod->ActivateInputWindow();
1934  }
1935  rReq.Ignore(); // only SID_ENTER_STRING is recorded
1936  }
1937  break;
1938 
1939  case FID_DEFINE_NAME:
1940  case FID_DEFINE_CURRENT_NAME:
1941  if ( pReqArgs )
1942  {
1943  const SfxPoolItem* pItem;
1944  OUString aName, aSymbol, aAttrib;
1945 
1946  if( pReqArgs->HasItem( FID_DEFINE_NAME, &pItem ) )
1947  aName = static_cast<const SfxStringItem*>(pItem)->GetValue();
1948 
1949  if( pReqArgs->HasItem( FN_PARAM_1, &pItem ) )
1950  aSymbol = static_cast<const SfxStringItem*>(pItem)->GetValue();
1951 
1952  if( pReqArgs->HasItem( FN_PARAM_2, &pItem ) )
1953  aAttrib = static_cast<const SfxStringItem*>(pItem)->GetValue();
1954 
1955  if ( !aName.isEmpty() && !aSymbol.isEmpty() )
1956  {
1957  if (pTabViewShell->InsertName( aName, aSymbol, aAttrib ))
1958  rReq.Done();
1959 #if HAVE_FEATURE_SCRIPTING
1960  else
1962 #endif
1963  }
1964  }
1965  else
1966  {
1967  sal_uInt16 nId = ScNameDlgWrapper::GetChildWindowId();
1968  SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
1969  SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
1970 
1971  pScMod->SetRefDialog( nId, pWnd == nullptr );
1972  }
1973  break;
1974  case FID_ADD_NAME:
1975  {
1976  sal_uInt16 nId = ScNameDefDlgWrapper::GetChildWindowId();
1977  SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
1978  SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
1979 
1980  pScMod->SetRefDialog( nId, pWnd == nullptr );
1981  }
1982  break;
1983 
1984  case SID_OPENDLG_CONDFRMT:
1985  case SID_OPENDLG_CURRENTCONDFRMT:
1986  case SID_OPENDLG_COLORSCALE:
1987  case SID_OPENDLG_DATABAR:
1988  case SID_OPENDLG_ICONSET:
1989  case SID_OPENDLG_CONDDATE:
1990  {
1991  sal_uInt32 nIndex = sal_uInt32(-1);
1992  bool bManaged = false;
1993 
1994  // Get the pool item stored by Conditional Format Manager Dialog.
1995  auto itemsRange = pTabViewShell->GetPool().GetItemSurrogates(SCITEM_CONDFORMATDLGDATA);
1996  if (itemsRange.begin() != itemsRange.end())
1997  {
1998  const ScCondFormatDlgItem* pDlgItem = static_cast<const ScCondFormatDlgItem*>(*itemsRange.begin());
1999  nIndex = pDlgItem->GetIndex();
2000  bManaged = true;
2001  }
2002 
2003  // Check if the Conditional Manager Dialog is editing or adding
2004  // conditional format item.
2005  if ( bManaged )
2006  {
2007  sal_uInt16 nId = ScCondFormatDlgWrapper::GetChildWindowId();
2008  SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
2009  SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
2010 
2011  pScMod->SetRefDialog( nId, pWnd == nullptr );
2012  break;
2013  }
2014 
2015  ScRangeList aRangeList;
2017  pData->GetMarkData().FillRangeListWithMarks(&aRangeList, false);
2018 
2019  ScDocument& rDoc = GetViewData()->GetDocument();
2020  if(rDoc.IsTabProtected(pData->GetTabNo()))
2021  {
2022  pTabViewShell->ErrorMessage( STR_ERR_CONDFORMAT_PROTECTED );
2023  break;
2024  }
2025 
2026  ScAddress aPos(pData->GetCurX(), pData->GetCurY(), pData->GetTabNo());
2027  if(aRangeList.empty())
2028  {
2029  aRangeList.push_back(ScRange(aPos));
2030  }
2031 
2032  // try to find an existing conditional format
2033  const ScConditionalFormat* pCondFormat = nullptr;
2034  const ScPatternAttr* pPattern = rDoc.GetPattern(aPos.Col(), aPos.Row(), aPos.Tab());
2035  ScConditionalFormatList* pList = rDoc.GetCondFormList(aPos.Tab());
2036  const ScCondFormatIndexes& rCondFormats = pPattern->GetItem(ATTR_CONDITIONAL).GetCondFormatData();
2037  bool bContainsCondFormat = !rCondFormats.empty();
2038  bool bCondFormatDlg = false;
2039  bool bContainsExistingCondFormat = false;
2040  if(bContainsCondFormat)
2041  {
2042  for (const auto& rCondFormat : rCondFormats)
2043  {
2044  // check if at least one existing conditional format has the same range
2045  pCondFormat = pList->GetFormat(rCondFormat);
2046  if(!pCondFormat)
2047  continue;
2048 
2049  bContainsExistingCondFormat = true;
2050  const ScRangeList& rCondFormatRange = pCondFormat->GetRange();
2051  if(rCondFormatRange == aRangeList)
2052  {
2053  // found a matching range, edit this conditional format
2054  bCondFormatDlg = true;
2055  nIndex = pCondFormat->GetKey();
2056  break;
2057  }
2058  }
2059  }
2060 
2061  // do we have a parameter with the conditional formatting type?
2062  const SfxInt16Item* pParam = rReq.GetArg<SfxInt16Item>(FN_PARAM_1);
2063  if (pParam && nSlot == SID_OPENDLG_ICONSET)
2064  {
2065  auto pFormat = std::make_unique<ScConditionalFormat>(0, &rDoc);
2066  pFormat->SetRange(aRangeList);
2067 
2069  const int nSteps = ScIconSetFormat::getIconSetElements(eIconSetType);
2070 
2071  ScIconSetFormat* pEntry = new ScIconSetFormat(&rDoc);
2072  ScIconSetFormatData* pIconSetFormatData = new ScIconSetFormatData(eIconSetType);
2073 
2074  pIconSetFormatData->m_Entries.emplace_back(new ScColorScaleEntry(0, COL_RED, COLORSCALE_PERCENT));
2075  pIconSetFormatData->m_Entries.emplace_back(new ScColorScaleEntry(round(100. / nSteps), COL_BROWN, COLORSCALE_PERCENT));
2076  pIconSetFormatData->m_Entries.emplace_back(new ScColorScaleEntry(round(200. / nSteps), COL_YELLOW, COLORSCALE_PERCENT));
2077  if (nSteps > 3)
2078  pIconSetFormatData->m_Entries.emplace_back(new ScColorScaleEntry(round(300. / nSteps), COL_WHITE, COLORSCALE_PERCENT));
2079  if (nSteps > 4)
2080  pIconSetFormatData->m_Entries.emplace_back(new ScColorScaleEntry(round(400. / nSteps), COL_GREEN, COLORSCALE_PERCENT));
2081 
2082  pEntry->SetIconSetData(pIconSetFormatData);
2083  pFormat->AddEntry(pEntry);
2084 
2085  // use the new conditional formatting
2086  GetViewData()->GetDocShell()->GetDocFunc().ReplaceConditionalFormat(nIndex, std::move(pFormat), aPos.Tab(), aRangeList);
2087 
2088  break;
2089  }
2090 
2091  // if not found a conditional format ask whether we should edit one of the existing
2092  // or should create a new overlapping conditional format
2093  if(bContainsCondFormat && !bCondFormatDlg && bContainsExistingCondFormat)
2094  {
2095  std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(pTabViewShell->GetFrameWeld(),
2096  VclMessageType::Question, VclButtonsType::YesNo,
2097  ScResId(STR_EDIT_EXISTING_COND_FORMATS)));
2098  xQueryBox->set_default_response(RET_YES);
2099  bool bEditExisting = xQueryBox->run() == RET_YES;
2100  if (bEditExisting)
2101  {
2102  // differentiate between ranges where one conditional format is defined
2103  // and several formats are defined
2104  // if we have only one => open the cond format dlg to edit it
2105  // otherwise open the manage cond format dlg
2106  if (rCondFormats.size() == 1)
2107  {
2108  pCondFormat = pList->GetFormat(rCondFormats[0]);
2109  assert(pCondFormat);
2110  bCondFormatDlg = true;
2111  }
2112  else
2113  {
2114  // Queue message to open Conditional Format Manager Dialog.
2115  GetViewData()->GetDispatcher().Execute( SID_OPENDLG_CONDFRMT_MANAGER, SfxCallMode::ASYNCHRON );
2116  break;
2117  }
2118  }
2119  else
2120  {
2121  // define an overlapping conditional format
2122  // does not need to be handled here
2123  }
2124  }
2125 
2127  switch(nSlot)
2128  {
2129  case SID_OPENDLG_CONDFRMT:
2130  case SID_OPENDLG_CURRENTCONDFRMT:
2132  break;
2133  case SID_OPENDLG_COLORSCALE:
2135  break;
2136  case SID_OPENDLG_DATABAR:
2138  break;
2139  case SID_OPENDLG_ICONSET:
2141  break;
2142  case SID_OPENDLG_CONDDATE:
2143  eType = condformat::dialog::DATE;
2144  break;
2145  default:
2146  assert(false);
2147  break;
2148  }
2149 
2150 
2151  if(bCondFormatDlg || !bContainsCondFormat)
2152  {
2153  // Put the xml string parameter to initialize the
2154  // Conditional Format Dialog.
2155  ScCondFormatDlgItem aDlgItem(nullptr, nIndex, false);
2156  aDlgItem.SetDialogType(eType);
2157  pTabViewShell->GetPool().Put(aDlgItem);
2158 
2159  sal_uInt16 nId = ScCondFormatDlgWrapper::GetChildWindowId();
2160  SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
2161  SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
2162 
2163  pScMod->SetRefDialog( nId, pWnd == nullptr );
2164  }
2165  }
2166  break;
2167 
2168  case SID_DEFINE_COLROWNAMERANGES:
2169  {
2170 
2171  sal_uInt16 nId = ScColRowNameRangesDlgWrapper::GetChildWindowId();
2172  SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
2173  SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
2174 
2175  pScMod->SetRefDialog( nId, pWnd == nullptr );
2176 
2177  }
2178  break;
2179 
2180  case SID_UPDATECHART:
2181  {
2182  bool bAll = false;
2183 
2184  if( pReqArgs )
2185  {
2186  const SfxPoolItem* pItem;
2187 
2188  if( pReqArgs->HasItem( SID_UPDATECHART, &pItem ) )
2189  bAll = static_cast<const SfxBoolItem*>(pItem)->GetValue();
2190  }
2191 
2192  pTabViewShell->UpdateCharts( bAll );
2193 
2194  if( ! rReq.IsAPI() )
2195  {
2196  rReq.AppendItem( SfxBoolItem( SID_UPDATECHART, bAll ) );
2197  rReq.Done();
2198  }
2199  }
2200  break;
2201 
2202  case SID_TABOP:
2203  if (pReqArgs)
2204  {
2205  const ScTabOpItem& rItem =
2206  static_cast<const ScTabOpItem&>(
2207  pReqArgs->Get( SID_TABOP ));
2208 
2209  pTabViewShell->TabOp( rItem.GetData() );
2210 
2211  rReq.Done( *pReqArgs );
2212  }
2213  break;
2214 
2215  case SID_SOLVE:
2216  if (pReqArgs)
2217  {
2218  const ScSolveItem& rItem =
2219  static_cast<const ScSolveItem&>(
2220  pReqArgs->Get( SCITEM_SOLVEDATA ));
2221 
2222  pTabViewShell->Solve( rItem.GetData() );
2223 
2224  rReq.Done( *pReqArgs );
2225  }
2226  break;
2227 
2228  case FID_INSERT_NAME:
2229  {
2231 
2233  switch( pDlg->Execute() )
2234  {
2235  case BTN_PASTE_LIST:
2236  pTabViewShell->InsertNameList();
2237  break;
2238  case BTN_PASTE_NAME:
2239  {
2240  ScInputHandler* pHdl = pScMod->GetInputHdl( pTabViewShell );
2241  if (pHdl)
2242  {
2243  // "=" in KeyEvent, switches to input-mode
2244  (void)pScMod->InputKeyEvent( KeyEvent('=', vcl::KeyCode()) );
2245 
2246  std::vector<OUString> aNames = pDlg->GetSelectedNames();
2247  if (!aNames.empty())
2248  {
2249  OUStringBuffer aBuffer;
2250  for (const auto& rName : aNames)
2251  {
2252  aBuffer.append(rName).append(' ');
2253  }
2254  pHdl->InsertFunction( aBuffer.makeStringAndClear(), false ); // without "()"
2255  }
2256  }
2257  }
2258  break;
2259  }
2260  }
2261  break;
2262 
2263  case SID_RANGE_NOTETEXT:
2264  if (pReqArgs)
2265  {
2266  const SfxStringItem& rTextItem = static_cast<const SfxStringItem&>(pReqArgs->Get( SID_RANGE_NOTETEXT ));
2267 
2268  // always cursor position
2269  ScAddress aPos( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
2270  pTabViewShell->SetNoteText( aPos, rTextItem.GetValue() );
2271  rReq.Done();
2272  }
2273  break;
2274 
2275  case SID_INSERT_POSTIT:
2276  case SID_EDIT_POSTIT:
2277  {
2278  const SfxPoolItem* pText;
2279  if ( pReqArgs && pReqArgs->HasItem( SID_ATTR_POSTIT_TEXT, &pText) )
2280  {
2281  const SfxPoolItem* pCellId;
2282  OUString aCellId;
2283  // SID_ATTR_POSTIT_ID only argument for SID_EDIT_POSTIT
2284  if (pReqArgs->HasItem( SID_ATTR_POSTIT_ID, &pCellId ))
2285  aCellId = static_cast<const SvxPostItIdItem*>(pCellId)->GetValue();
2286 
2287  const SvxPostItTextItem* pTextItem = static_cast<const SvxPostItTextItem*>( pText );
2288  const SvxPostItAuthorItem* pAuthorItem = pReqArgs->GetItem( SID_ATTR_POSTIT_AUTHOR );
2289  const SvxPostItDateItem* pDateItem = pReqArgs->GetItem( SID_ATTR_POSTIT_DATE );
2290 
2291  if (!aCellId.isEmpty())
2292  {
2293  SetTabNoAndCursor( GetViewData(), aCellId );
2294  }
2295 
2296  ScAddress aPos( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
2297  pTabViewShell->ReplaceNote( aPos, pTextItem->GetValue(),
2298  pAuthorItem ? &pAuthorItem->GetValue() : nullptr,
2299  pDateItem ? &pDateItem->GetValue() : nullptr );
2300  }
2302  {
2303  pTabViewShell->EditNote(); // note object to edit
2304  }
2305  rReq.Done();
2306  }
2307  break;
2308 
2309  case FID_NOTE_VISIBLE:
2310  {
2311  ScDocument& rDoc = GetViewData()->GetDocument();
2312  ScAddress aPos( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
2313  if( ScPostIt* pNote = rDoc.GetNote(aPos) )
2314  {
2315  bool bShow;
2316  const SfxPoolItem* pItem;
2317  if ( pReqArgs && (pReqArgs->GetItemState( FID_NOTE_VISIBLE, true, &pItem ) == SfxItemState::SET) )
2318  bShow = static_cast<const SfxBoolItem*>(pItem)->GetValue();
2319  else
2320  bShow = !pNote->IsCaptionShown();
2321 
2322  pTabViewShell->ShowNote( bShow );
2323 
2324  if (!pReqArgs)
2325  rReq.AppendItem( SfxBoolItem( FID_NOTE_VISIBLE, bShow ) );
2326 
2327  rReq.Done();
2328  rBindings.Invalidate( FID_NOTE_VISIBLE );
2329  }
2330  else
2331  rReq.Ignore();
2332  }
2333  break;
2334 
2335  case FID_HIDE_NOTE:
2336  case FID_SHOW_NOTE:
2337  {
2338  bool bShowNote = nSlot == FID_SHOW_NOTE;
2340  ScDocument& rDoc = pData->GetDocument();
2341  ScMarkData& rMark = pData->GetMarkData();
2342 
2343  if (!rMark.IsMarked() && !rMark.IsMultiMarked())
2344  {
2345  // Check current cell
2346  ScAddress aPos( pData->GetCurX(), pData->GetCurY(), pData->GetTabNo() );
2347  if( rDoc.GetNote(aPos) )
2348  {
2349  pData->GetDocShell()->GetDocFunc().ShowNote( aPos, bShowNote );
2350  }
2351  }
2352  else
2353  {
2354  // Check selection range
2355  bool bDone = false;
2356  ScRangeListRef aRangesRef;
2357  pData->GetMultiArea(aRangesRef);
2358  const ScRangeList aRanges = *aRangesRef;
2359 
2360  OUString aUndo = ScResId( bShowNote ? STR_UNDO_SHOWNOTE : STR_UNDO_HIDENOTE );
2361  pData->GetDocShell()->GetUndoManager()->EnterListAction( aUndo, aUndo, 0, pData->GetViewShell()->GetViewShellId() );
2362 
2363  for (auto const& rTab : rMark.GetSelectedTabs())
2364  {
2365  // get notes
2366  std::vector<sc::NoteEntry> aNotes;
2367  rDoc.GetAllNoteEntries(rTab, aNotes);
2368 
2369  for (const sc::NoteEntry& rNote : aNotes)
2370  {
2371  // check if note is in our selection range
2372  const ScAddress& rAdr = rNote.maPos;
2373  const ScRange* rRange = aRanges.Find(rAdr);
2374  if (! rRange)
2375  continue;
2376 
2377  // check if cell is editable
2378  const SCTAB nRangeTab = rRange->aStart.Tab();
2379  if (rDoc.IsBlockEditable( nRangeTab, rAdr.Col(), rAdr.Row(), rAdr.Col(), rAdr.Row() ))
2380  {
2381  pData->GetDocShell()->GetDocFunc().ShowNote( rAdr, bShowNote );
2382  bDone = true;
2383  }
2384  }
2385  }
2386 
2388 
2389  if ( bDone )
2390  {
2391  rReq.Done();
2392  rBindings.Invalidate( nSlot );
2393  }
2394  else
2395  rReq.Ignore();
2396  }
2397 
2398  }
2399  break;
2400 
2401  case FID_SHOW_ALL_NOTES:
2402  case FID_HIDE_ALL_NOTES:
2403  {
2404  bool bShowNote = nSlot == FID_SHOW_ALL_NOTES;
2406  ScMarkData& rMark = pData->GetMarkData();
2407  ScDocument& rDoc = pData->GetDocument();
2408  std::vector<sc::NoteEntry> aNotes;
2409 
2410  OUString aUndo = ScResId( bShowNote ? STR_UNDO_SHOWALLNOTES : STR_UNDO_HIDEALLNOTES );
2411  pData->GetDocShell()->GetUndoManager()->EnterListAction( aUndo, aUndo, 0, pData->GetViewShell()->GetViewShellId() );
2412 
2413  for (auto const& rTab : rMark.GetSelectedTabs())
2414  {
2415  rDoc.GetAllNoteEntries(rTab, aNotes);
2416  }
2417 
2418  for (const sc::NoteEntry& rNote : aNotes)
2419  {
2420  const ScAddress& rAdr = rNote.maPos;
2421  pData->GetDocShell()->GetDocFunc().ShowNote( rAdr, bShowNote );
2422  }
2423 
2425  }
2426  break;
2427 
2428  case SID_TOGGLE_NOTES:
2429  {
2431  ScMarkData& rMark = pData->GetMarkData();
2432  ScDocument& rDoc = pData->GetDocument();
2433  ScRangeList aRanges;
2434  std::vector<sc::NoteEntry> aNotes;
2435 
2436  for (auto const& rTab : rMark.GetSelectedTabs())
2437  aRanges.push_back(ScRange(0,0,rTab,rDoc.MaxCol(),rDoc.MaxRow(),rTab));
2438 
2439  CommentCaptionState eState = rDoc.GetAllNoteCaptionsState( aRanges );
2440  rDoc.GetNotesInRange(aRanges, aNotes);
2441  bool bShowNote = (eState == ALLHIDDEN || eState == MIXED);
2442 
2443  OUString aUndo = ScResId( bShowNote ? STR_UNDO_SHOWALLNOTES : STR_UNDO_HIDEALLNOTES );
2444  pData->GetDocShell()->GetUndoManager()->EnterListAction( aUndo, aUndo, 0, pData->GetViewShell()->GetViewShellId() );
2445 
2446  for(const auto& rNote : aNotes)
2447  {
2448  const ScAddress& rAdr = rNote.maPos;
2449  pData->GetDocShell()->GetDocFunc().ShowNote( rAdr, bShowNote );
2450  }
2451 
2453 
2454  if (!pReqArgs)
2455  rReq.AppendItem( SfxBoolItem( SID_TOGGLE_NOTES, bShowNote ) );
2456 
2457  rReq.Done();
2458  rBindings.Invalidate( SID_TOGGLE_NOTES );
2459  }
2460  break;
2461 
2462  case SID_DELETE_NOTE:
2463  {
2464  const SfxPoolItem* pId;
2465  // If Id is mentioned, select the appropriate cell first
2466  if ( pReqArgs && pReqArgs->HasItem( SID_ATTR_POSTIT_ID, &pId) )
2467  {
2468  const SvxPostItIdItem* pIdItem = static_cast<const SvxPostItIdItem*>(pId);
2469  const OUString& aCellId = pIdItem->GetValue();
2470  if (!aCellId.isEmpty())
2471  {
2472  SetTabNoAndCursor( GetViewData(), aCellId );
2473  }
2474  }
2475 
2476  pTabViewShell->DeleteContents( InsertDeleteFlags::NOTE ); // delete all notes in selection
2477  rReq.Done();
2478  }
2479  break;
2480 
2481  case FID_DELETE_ALL_NOTES:
2482  {
2484  ScMarkData& rMark = pData->GetMarkData();
2485  ScDocument& rDoc = pData->GetDocument();
2486  ScMarkData aNewMark(rDoc.GetSheetLimits());
2487  ScRangeList aRangeList;
2488 
2489  for (auto const& rTab : rMark.GetSelectedTabs())
2490  {
2491  aRangeList.push_back(ScRange(0,0,rTab,rDoc.MaxCol(),rDoc.MaxRow(),rTab));
2492  }
2493 
2494  aNewMark.MarkFromRangeList( aRangeList, true );
2495  pData->GetDocShell()->GetDocFunc().DeleteContents(aNewMark, InsertDeleteFlags::NOTE, true, false );
2496  }
2497  break;
2498 
2499  case SID_CHARMAP:
2500  if( pReqArgs != nullptr )
2501  {
2502  OUString aChars, aFontName;
2503  const SfxItemSet *pArgs = rReq.GetArgs();
2504  const SfxPoolItem* pItem = nullptr;
2505  if ( pArgs )
2506  pArgs->GetItemState(GetPool().GetWhich(SID_CHARMAP), false, &pItem);
2507  if ( pItem )
2508  {
2509  const SfxStringItem* pStringItem = dynamic_cast<const SfxStringItem*>( pItem );
2510  if ( pStringItem )
2511  aChars = pStringItem->GetValue();
2512  const SfxPoolItem* pFtItem = nullptr;
2513  pArgs->GetItemState( GetPool().GetWhich(SID_ATTR_SPECIALCHAR), false, &pFtItem);
2514  const SfxStringItem* pFontItem = dynamic_cast<const SfxStringItem*>( pFtItem );
2515  if ( pFontItem )
2516  aFontName = pFontItem->GetValue();
2517  }
2518 
2519  if ( !aChars.isEmpty() )
2520  {
2521  vcl::Font aFont;
2522  pTabViewShell->GetSelectionPattern()->GetFont( aFont, SC_AUTOCOL_BLACK, nullptr, nullptr, nullptr,
2523  pTabViewShell->GetSelectionScriptType() );
2524  if ( !aFontName.isEmpty() )
2525  aFont = vcl::Font( aFontName, Size(1,1) );
2526  pTabViewShell->InsertSpecialChar( aChars, aFont );
2527  if( ! rReq.IsAPI() )
2528  rReq.Done();
2529  }
2530  }
2531  else
2532  {
2534 
2535  // font color doesn't matter here
2536  vcl::Font aCurFont;
2537  pTabViewShell->GetSelectionPattern()->GetFont( aCurFont, SC_AUTOCOL_BLACK, nullptr, nullptr, nullptr,
2538  pTabViewShell->GetSelectionScriptType() );
2539 
2540  SfxAllItemSet aSet( GetPool() );
2541  aSet.Put( SfxBoolItem( FN_PARAM_1, false ) );
2542  aSet.Put( SvxFontItem( aCurFont.GetFamilyType(), aCurFont.GetFamilyName(), aCurFont.GetStyleName(), aCurFont.GetPitch(), aCurFont.GetCharSet(), GetPool().GetWhich(SID_ATTR_CHAR_FONT) ) );
2543  SfxViewFrame* pViewFrame = pTabViewShell->GetViewFrame();
2544  auto xFrame = pViewFrame->GetFrame().GetFrameInterface();
2545  ScopedVclPtr<SfxAbstractDialog> pDlg(pFact->CreateCharMapDialog(pTabViewShell->GetFrameWeld(), aSet, xFrame));
2546  pDlg->Execute();
2547  }
2548  break;
2549 
2550  case SID_SELECT_SCENARIO:
2551  {
2552  // Testing
2553 
2554  if ( pReqArgs )
2555  {
2556  const SfxStringItem& rItem
2557  = static_cast<const SfxStringItem&>(pReqArgs->Get(SID_SELECT_SCENARIO));
2558  pTabViewShell->UseScenario(rItem.GetValue());
2560  rReq.SetReturnValue(SfxStringItem(SID_SELECT_SCENARIO, rItem.GetValue()));
2561  rReq.Done();
2562  }
2563  }
2564  break;
2565 
2566  case SID_HYPERLINK_SETLINK:
2567  if( pReqArgs )
2568  {
2569  const SfxPoolItem* pItem;
2570  if( pReqArgs->HasItem( SID_HYPERLINK_SETLINK, &pItem ) )
2571  {
2572  const SvxHyperlinkItem* pHyper = static_cast<const SvxHyperlinkItem*>(pItem);
2573  const OUString& rName = pHyper->GetName();
2574  const OUString& rURL = pHyper->GetURL();
2575  const OUString& rTarget = pHyper->GetTargetFrame();
2576  sal_uInt16 nType = static_cast<sal_uInt16>(pHyper->GetInsertMode());
2577 
2578  pTabViewShell->InsertURL( rName, rURL, rTarget, nType );
2579  rReq.Done();
2580  }
2581  else
2582  rReq.Ignore();
2583  }
2584  break;
2585 
2586  case SID_OPENDLG_CONDFRMT_MANAGER:
2587  case SID_OPENDLG_CURRENTCONDFRMT_MANAGER:
2588  {
2590 
2592  ScDocument& rDoc = pData->GetDocument();
2593 
2594  if (rDoc.IsTabProtected(pData->GetTabNo()))
2595  {
2596  pTabViewShell->ErrorMessage( STR_ERR_CONDFORMAT_PROTECTED );
2597  break;
2598  }
2599 
2600  ScAddress aPos(pData->GetCurX(), pData->GetCurY(), pData->GetTabNo());
2601 
2602  ScConditionalFormatList* pList = nullptr;
2603 
2604  const ScCondFormatDlgItem* pDlgItem = nullptr;
2605  auto itemsRange = pTabViewShell->GetPool().GetItemSurrogates(SCITEM_CONDFORMATDLGDATA);
2606  if (itemsRange.begin() != itemsRange.end())
2607  {
2608  pDlgItem= static_cast<const ScCondFormatDlgItem*>(*itemsRange.begin());
2609  pList = const_cast<ScCondFormatDlgItem*>(pDlgItem)->GetConditionalFormatList();
2610  }
2611 
2612  if (!pList)
2613  pList = rDoc.GetCondFormList( aPos.Tab() );
2614 
2616  pTabViewShell->GetFrameWeld(), rDoc, pList));
2617 
2618  if (pDlgItem)
2619  pDlg->SetModified();
2620 
2621  pDlg->StartExecuteAsync([this, pDlg, pData, pTabViewShell, pDlgItem, aPos](sal_Int32 nRet){
2622  std::unique_ptr<ScConditionalFormatList> pCondFormatList = pDlg->GetConditionalFormatList();
2623  if(nRet == RET_OK && pDlg->CondFormatsChanged())
2624  {
2625  pData->GetDocShell()->GetDocFunc().SetConditionalFormatList(pCondFormatList.release(), aPos.Tab());
2626  }
2627  else if(nRet == DLG_RET_ADD)
2628  {
2629  // Put the xml string parameter to initialize the
2630  // Conditional Format Dialog. ( add new )
2631  pTabViewShell->GetPool().Put(ScCondFormatDlgItem(
2632  std::shared_ptr<ScConditionalFormatList>(pCondFormatList.release()), -1, true));
2633  // Queue message to open Conditional Format Dialog
2634  GetViewData()->GetDispatcher().Execute( SID_OPENDLG_CONDFRMT, SfxCallMode::ASYNCHRON );
2635  }
2636  else if (nRet == DLG_RET_EDIT)
2637  {
2638  ScConditionalFormat* pFormat = pDlg->GetCondFormatSelected();
2639  sal_Int32 nIndex = pFormat ? pFormat->GetKey() : -1;
2640  // Put the xml string parameter to initialize the
2641  // Conditional Format Dialog. ( edit selected conditional format )
2642  pTabViewShell->GetPool().Put(ScCondFormatDlgItem(
2643  std::shared_ptr<ScConditionalFormatList>(pCondFormatList.release()), nIndex, true));
2644 
2645  // Queue message to open Conditional Format Dialog
2646  GetViewData()->GetDispatcher().Execute( SID_OPENDLG_CONDFRMT, SfxCallMode::ASYNCHRON );
2647  }
2648  else
2649  pCondFormatList.reset();
2650 
2651  if (pDlgItem)
2652  pTabViewShell->GetPool().Remove(*pDlgItem);
2653 
2654  pDlg->disposeOnce();
2655  });
2656  }
2657  break;
2658 
2659  case SID_EXTERNAL_SOURCE:
2660  {
2661  const SfxStringItem* pFile = rReq.GetArg<SfxStringItem>(SID_FILE_NAME);
2662  const SfxStringItem* pSource = rReq.GetArg<SfxStringItem>(FN_PARAM_1);
2663  if ( pFile && pSource )
2664  {
2665  OUString aFile;
2666  OUString aFilter;
2667  OUString aOptions;
2668  OUString aSource;
2669  sal_uLong nRefresh=0;
2670 
2671  aFile = pFile->GetValue();
2672  aSource = pSource->GetValue();
2673  const SfxStringItem* pFilter = rReq.GetArg<SfxStringItem>(SID_FILTER_NAME);
2674  if ( pFilter )
2675  aFilter = pFilter->GetValue();
2676  const SfxStringItem* pOptions = rReq.GetArg<SfxStringItem>(SID_FILE_FILTEROPTIONS);
2677  if ( pOptions )
2678  aOptions = pOptions->GetValue();
2679  const SfxUInt32Item* pRefresh = rReq.GetArg<SfxUInt32Item>(FN_PARAM_2);
2680  if ( pRefresh )
2681  nRefresh = pRefresh->GetValue();
2682 
2683  ExecuteExternalSource( aFile, aFilter, aOptions, aSource, nRefresh, rReq );
2684  }
2685  else
2686  {
2688 
2689  pImpl->m_pLinkedDlg.disposeAndClear();
2690  pImpl->m_pLinkedDlg =
2691  pFact->CreateScLinkedAreaDlg(pTabViewShell->GetFrameWeld());
2692  delete pImpl->m_pRequest;
2693  pImpl->m_pRequest = new SfxRequest( rReq );
2694  OUString sFile, sFilter, sOptions, sSource;
2695  sal_uLong nRefresh = 0;
2696  if (pImpl->m_pLinkedDlg->Execute() == RET_OK)
2697  {
2698  sFile = pImpl->m_pLinkedDlg->GetURL();
2699  sFilter = pImpl->m_pLinkedDlg->GetFilter();
2700  sOptions = pImpl->m_pLinkedDlg->GetOptions();
2701  sSource = pImpl->m_pLinkedDlg->GetSource();
2702  nRefresh = pImpl->m_pLinkedDlg->GetRefresh();
2703  if ( !sFile.isEmpty() )
2704  pImpl->m_pRequest->AppendItem( SfxStringItem( SID_FILE_NAME, sFile ) );
2705  if ( !sFilter.isEmpty() )
2706  pImpl->m_pRequest->AppendItem( SfxStringItem( SID_FILTER_NAME, sFilter ) );
2707  if ( !sOptions.isEmpty() )
2708  pImpl->m_pRequest->AppendItem( SfxStringItem( SID_FILE_FILTEROPTIONS, sOptions ) );
2709  if ( !sSource.isEmpty() )
2710  pImpl->m_pRequest->AppendItem( SfxStringItem( FN_PARAM_1, sSource ) );
2711  if ( nRefresh )
2712  pImpl->m_pRequest->AppendItem( SfxUInt32Item( FN_PARAM_2, nRefresh ) );
2713  }
2714 
2715  ExecuteExternalSource( sFile, sFilter, sOptions, sSource, nRefresh, *(pImpl->m_pRequest) );
2716  }
2717  }
2718  break;
2719 
2720  case SID_AUTO_SUM:
2721  {
2722  bool bSubTotal = false;
2723  bool bRangeFinder = false;
2724  const OUString aFormula = pTabViewShell->DoAutoSum( bRangeFinder, bSubTotal , ocSum );
2725  if ( !aFormula.isEmpty() )
2726  {
2727  const sal_Int32 nPar = aFormula.indexOf( '(' );
2728  const sal_Int32 nLen = aFormula.getLength();
2729  ScInputHandler* pHdl = pScMod->GetInputHdl( pTabViewShell );
2730 
2731  if ( pHdl && nPar != -1 )
2732  {
2733  if ( !pScMod->IsEditMode() )
2734  {
2735  pScMod->SetInputMode( SC_INPUT_TABLE );
2736  }
2737 
2738  EditView *pEditView=pHdl->GetActiveView();
2739  if ( pEditView )
2740  {
2741  ESelection aTextSel = pEditView->GetSelection();
2742  aTextSel.nStartPos = 0;
2743  aTextSel.nEndPos = EE_TEXTPOS_ALL;
2744  pHdl->DataChanging();
2745  pEditView->SetSelection(aTextSel);
2746  pEditView->InsertText(aFormula);
2747  pEditView->SetSelection( bRangeFinder ? ESelection( 0, nPar + ( bSubTotal ? 3 : 1 ), 0, nLen - 1 ) : ESelection( 0, nLen - 1, 0, nLen - 1 ) );
2748  pHdl->DataChanged();
2749 
2750  if ( bRangeFinder )
2751  {
2752  pHdl->InitRangeFinder( aFormula );
2753  }
2754  }
2755  }
2756  }
2757  }
2758  break;
2759 
2760  case SID_SELECT_UNPROTECTED_CELLS:
2761  {
2763  SCTAB aTab = pData->GetTabNo();
2764  ScMarkData& rMark = pData->GetMarkData();
2765  ScDocument& rDoc = pData->GetDocument();
2766  ScRangeList rRangeList;
2767 
2768  rDoc.GetUnprotectedCells(rRangeList, aTab);
2769  rMark.MarkFromRangeList(rRangeList, true);
2770  pTabViewShell->SetMarkData(rMark);
2771  }
2772  break;
2773 
2774  default:
2775  OSL_FAIL("incorrect slot in ExecuteEdit");
2776  break;
2777  }
2778 }
2779 
2781 {
2783  if ( nType != TransliterationFlags::NONE )
2784  {
2785  GetViewData()->GetView()->TransliterateText( nType );
2786  rReq.Done();
2787  }
2788 }
2789 
2791 {
2792  if( rReq.GetSlot() == SID_TRANSLITERATE_ROTATE_CASE )
2794 }
2795 
2797  const OUString& _rFile, const OUString& _rFilter, const OUString& _rOptions,
2798  const OUString& _rSource, sal_uLong _nRefresh, SfxRequest& _rRequest )
2799 {
2800  if ( !_rFile.isEmpty() && !_rSource.isEmpty() ) // filter may be empty
2801  {
2802  ScRange aLinkRange;
2803  bool bMove = false;
2804 
2806  ScMarkData& rMark = pData->GetMarkData();
2807  rMark.MarkToSimple();
2808  if ( rMark.IsMarked() )
2809  {
2810  rMark.GetMarkArea( aLinkRange );
2811  bMove = true; // insert/delete cells to fit range
2812  }
2813  else
2814  aLinkRange = ScRange( pData->GetCurX(), pData->GetCurY(), pData->GetTabNo() );
2815 
2816  pData->GetDocFunc().InsertAreaLink( _rFile, _rFilter, _rOptions, _rSource,
2817  aLinkRange, _nRefresh, bMove, false );
2818  _rRequest.Done();
2819  }
2820  else
2821  _rRequest.Ignore();
2822 }
2823 
2824 namespace {
2825 
2826 bool isDPSourceValid(const ScDPObject& rDPObj)
2827 {
2828  if (rDPObj.IsImportData())
2829  {
2830  // If the data type is database, check if the database is still valid.
2831  const ScImportSourceDesc* pDesc = rDPObj.GetImportSourceDesc();
2832  if (!pDesc)
2833  return false;
2834 
2835  const ScDPSaveData* pSaveData = rDPObj.GetSaveData();
2836  const ScDPDimensionSaveData* pDimData = nullptr;
2837  if (pSaveData)
2838  pDimData = pSaveData->GetExistingDimensionData();
2839 
2840  const ScDPCache* pCache = pDesc->CreateCache(pDimData);
2841  if (!pCache)
2842  // cache creation failed, probably due to invalid connection.
2843  return false;
2844  }
2845  return true;
2846 }
2847 
2848 }
2849 
2851 {
2852  ScModule* pScMod = SC_MOD();
2853  ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
2855  ScDocument& rDoc = pData->GetDocument();
2856 
2857  std::unique_ptr<ScDPObject> pNewDPObject;
2858 
2859  // ScPivot is no longer used...
2860  ScDPObject* pDPObj = rDoc.GetDPAtCursor(
2861  pData->GetCurX(), pData->GetCurY(),
2862  pData->GetTabNo() );
2863  if ( pDPObj ) // on an existing table?
2864  {
2865  if (isDPSourceValid(*pDPObj))
2866  pNewDPObject.reset(new ScDPObject(*pDPObj));
2867  }
2868  else // create new table
2869  {
2870  const char* pSrcErrorId = nullptr;
2871 
2872  // select database range or data
2873  pTabViewShell->GetDBData( true, SC_DB_OLD );
2874  ScMarkData& rMark = GetViewData()->GetMarkData();
2875  if ( !rMark.IsMarked() && !rMark.IsMultiMarked() )
2876  pTabViewShell->MarkDataArea( false );
2877 
2878  // output to cursor position for non-sheet data
2879  ScAddress aDestPos( pData->GetCurX(), pData->GetCurY(),
2880  pData->GetTabNo() );
2881 
2882  // first select type of source data
2883 
2884  bool bEnableExt = ScDPObject::HasRegisteredSources();
2885 
2887 
2890  pTabViewShell->GetFrameWeld(), bEnableExt));
2891 
2892  // Populate named ranges (if any).
2893  ScRangeName* pRangeName = rDoc.GetRangeName();
2894  if (pRangeName)
2895  {
2896  ScRangeName::const_iterator itr = pRangeName->begin(), itrEnd = pRangeName->end();
2897  for (; itr != itrEnd; ++itr)
2898  pTypeDlg->AppendNamedRange(itr->second->GetName());
2899  }
2900 
2901  if ( pTypeDlg->Execute() == RET_OK )
2902  {
2903  if ( pTypeDlg->IsExternal() )
2904  {
2905  std::vector<OUString> aSources = ScDPObject::GetRegisteredSources();
2908  pTabViewShell->GetFrameWeld(), aSources));
2909 
2910  if ( pServDlg->Execute() == RET_OK )
2911  {
2912  ScDPServiceDesc aServDesc(
2913  pServDlg->GetServiceName(),
2914  pServDlg->GetParSource(),
2915  pServDlg->GetParName(),
2916  pServDlg->GetParUser(),
2917  pServDlg->GetParPass() );
2918  pNewDPObject.reset(new ScDPObject(&rDoc));
2919  pNewDPObject->SetServiceData( aServDesc );
2920  }
2921  }
2922  else if ( pTypeDlg->IsDatabase() )
2923  {
2924  assert(pFact && "ScAbstractFactory create fail!");
2926  pFact->CreateScDataPilotDatabaseDlg(pTabViewShell->GetFrameWeld()));
2927  assert(pDataDlg && "Dialog create fail!");
2928  if ( pDataDlg->Execute() == RET_OK )
2929  {
2930  ScImportSourceDesc aImpDesc(&rDoc);
2931  pDataDlg->GetValues( aImpDesc );
2932  pNewDPObject.reset(new ScDPObject(&rDoc));
2933  pNewDPObject->SetImportDesc( aImpDesc );
2934  }
2935  }
2936  else if (pTypeDlg->IsNamedRange())
2937  {
2938  OUString aName = pTypeDlg->GetSelectedNamedRange();
2939  ScSheetSourceDesc aShtDesc(&rDoc);
2940  aShtDesc.SetRangeName(aName);
2941  pSrcErrorId = aShtDesc.CheckSourceRange();
2942  if (!pSrcErrorId)
2943  {
2944  pNewDPObject.reset(new ScDPObject(&rDoc));
2945  pNewDPObject->SetSheetDesc(aShtDesc);
2946  }
2947  }
2948  else // selection
2949  {
2951  ScRange aRange;
2953  if ( (eType & SC_MARK_SIMPLE) == SC_MARK_SIMPLE )
2954  {
2955  // Shrink the range to the data area.
2956  SCCOL nStartCol = aRange.aStart.Col(), nEndCol = aRange.aEnd.Col();
2957  SCROW nStartRow = aRange.aStart.Row(), nEndRow = aRange.aEnd.Row();
2958  if (rDoc.ShrinkToDataArea(aRange.aStart.Tab(), nStartCol, nStartRow, nEndCol, nEndRow))
2959  {
2960  aRange.aStart.SetCol(nStartCol);
2961  aRange.aStart.SetRow(nStartRow);
2962  aRange.aEnd.SetCol(nEndCol);
2963  aRange.aEnd.SetRow(nEndRow);
2964  rMark.SetMarkArea(aRange);
2965  pTabViewShell->MarkRange(aRange);
2966  }
2967 
2968  bool bOK = true;
2969  if ( rDoc.HasSubTotalCells( aRange ) )
2970  {
2971  // confirm selection if it contains SubTotal cells
2972  std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(pTabViewShell->GetFrameWeld(),
2973  VclMessageType::Question, VclButtonsType::YesNo,
2974  ScResId(STR_DATAPILOT_SUBTOTAL)));
2975  xQueryBox->set_default_response(RET_YES);
2976  if (xQueryBox->run() == RET_NO)
2977  bOK = false;
2978  }
2979  if (bOK)
2980  {
2981  ScSheetSourceDesc aShtDesc(&rDoc);
2982  aShtDesc.SetSourceRange(aRange);
2983  pSrcErrorId = aShtDesc.CheckSourceRange();
2984  if (!pSrcErrorId)
2985  {
2986  pNewDPObject.reset(new ScDPObject(&rDoc));
2987  pNewDPObject->SetSheetDesc( aShtDesc );
2988  }
2989 
2990  // output below source data
2991  if ( aRange.aEnd.Row()+2 <= rDoc.MaxRow() - 4 )
2992  aDestPos = ScAddress( aRange.aStart.Col(),
2993  aRange.aEnd.Row()+2,
2994  aRange.aStart.Tab() );
2995  }
2996  }
2997  }
2998  }
2999 
3000  if (pSrcErrorId)
3001  {
3002  // Error occurred during data creation. Launch an error and bail out.
3003  std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pTabViewShell->GetFrameWeld(),
3004  VclMessageType::Info, VclButtonsType::Ok,
3005  ScResId(pSrcErrorId)));
3006  xInfoBox->run();
3007  return;
3008  }
3009 
3010  if ( pNewDPObject )
3011  pNewDPObject->SetOutRange( aDestPos );
3012  }
3013 
3014  bool bHadNewDPObject = pNewDPObject != nullptr;
3015  pTabViewShell->SetDialogDPObject( std::move(pNewDPObject) );
3016  if ( bHadNewDPObject )
3017  {
3018  // start layout dialog
3019 
3020  sal_uInt16 nId = ScPivotLayoutWrapper::GetChildWindowId();
3021  SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
3022  SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
3023  pScMod->SetRefDialog( nId, pWnd == nullptr );
3024  }
3025 }
3026 
3028 {
3029  ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
3030  if (!pTabViewShell)
3031  return;
3032 
3033  ScModule* pScMod = SC_MOD();
3034 
3035  sal_uInt16 nId = ScXMLSourceDlgWrapper::GetChildWindowId();
3036  SfxViewFrame* pViewFrame = pTabViewShell->GetViewFrame();
3037  SfxChildWindow* pWnd = pViewFrame->GetChildWindow(nId);
3038  pScMod->SetRefDialog(nId, pWnd == nullptr);
3039 }
3040 
3042 {
3043  ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
3044  const SfxItemSet* pArgs = rReq.GetArgs();
3045  if ( pArgs )
3046  {
3047  pTabViewShell->DoSubTotals( static_cast<const ScSubTotalItem&>( pArgs->Get( SCITEM_SUBTDATA )).
3048  GetSubTotalData() );
3049  rReq.Done();
3050  return;
3051  }
3052 
3054  ScSubTotalParam aSubTotalParam;
3056 
3057  bool bAnonymous;
3058 
3059  // Only get existing named database range.
3060  ScDBData* pDBData = pTabViewShell->GetDBData(true, SC_DB_OLD);
3061  if (pDBData)
3062  bAnonymous = false;
3063  else
3064  {
3065  // No existing DB data at this position. Create an
3066  // anonymous DB.
3067  bAnonymous = true;
3068  pDBData = pTabViewShell->GetAnonymousDBData();
3069  ScRange aDataRange;
3070  pDBData->GetArea(aDataRange);
3071  pTabViewShell->MarkRange(aDataRange, false);
3072  }
3073 
3074  pDBData->GetSubTotalParam( aSubTotalParam );
3075  aSubTotalParam.bRemoveOnly = false;
3076  if (bAnonymous)
3077  {
3078  // Preset sort formatting along with values and also create formula
3079  // cells with "needs formatting". Subtotals on data of different types
3080  // doesn't make much sense anyway.
3081  aSubTotalParam.bIncludePattern = true;
3082  }
3083 
3084  aArgSet.Put( ScSubTotalItem( SCITEM_SUBTDATA, GetViewData(), &aSubTotalParam ) );
3086  pDlg.disposeAndReset(pFact->CreateScSubTotalDlg(pTabViewShell->GetFrameWeld(), &aArgSet));
3087  pDlg->SetCurPageId("1stgroup");
3088 
3089  short bResult = pDlg->Execute();
3090 
3091  if ( (bResult == RET_OK) || (bResult == SCRET_REMOVE) )
3092  {
3093  const SfxItemSet* pOutSet = nullptr;
3094 
3095  if ( bResult == RET_OK )
3096  {
3097  pOutSet = pDlg->GetOutputItemSet();
3098  aSubTotalParam =
3099  static_cast<const ScSubTotalItem&>(
3100  pOutSet->Get( SCITEM_SUBTDATA )).
3101  GetSubTotalData();
3102  }
3103  else // if (bResult == SCRET_REMOVE)
3104  {
3105  pOutSet = &aArgSet;
3106  aSubTotalParam.bRemoveOnly = true;
3107  aSubTotalParam.bReplace = true;
3108  aArgSet.Put( ScSubTotalItem( SCITEM_SUBTDATA,
3109  GetViewData(),
3110  &aSubTotalParam ) );
3111  }
3112 
3113  pTabViewShell->DoSubTotals( aSubTotalParam );
3114  rReq.Done( *pOutSet );
3115  }
3116  else
3118 }
3119 
3121 {
3122  ScAddress aCurPos = GetViewData()->GetCurPos();
3123 
3124  OUString aInit;
3125 
3126  if (aCurPos.Row() > 0)
3127  {
3128  // Get the initial text value from the above cell.
3129 
3130  ScDocument& rDoc = GetViewData()->GetDocument();
3131  ScAddress aPrevPos = aCurPos;
3132  aPrevPos.IncRow(-1);
3133  ScRefCellValue aCell(rDoc, aPrevPos);
3134 
3135  if (aCell.meType == CELLTYPE_FORMULA)
3136  {
3137  aInit = "=";
3138  const ScTokenArray* pCode = aCell.mpFormula->GetCode();
3139  sc::TokenStringContext aCxt(rDoc, rDoc.GetGrammar());
3140  aInit += pCode->CreateString(aCxt, aCurPos);
3141  }
3142  else
3143  aInit = aCell.getString(&rDoc);
3144  }
3145 
3146  SC_MOD()->SetInputMode(SC_INPUT_TABLE, &aInit);
3147 }
3148 
3150  m_pLinkedDlg(),
3151  m_pRequest( nullptr ) {}
3152 
3154 {
3155 }
3156 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void AppendNamedRange(const OUString &rName)=0
ScMarkData & GetMarkData()
Definition: viewdata.cxx:3046
virtual void SetFillMode(bool bSet)=0
const SfxPoolItem * ExecuteSlot(SfxRequest &rReq, const SfxInterface *pIF=nullptr)
bool HasClipboardFormat(SotClipboardFormatId nFormatId)
Definition: cellsh.cxx:511
void DetectiveMarkInvalid()
Definition: viewfun6.cxx:111
SC_DLLPUBLIC void InsertPageBreak(bool bColumn, bool bRecord=true, const ScAddress *pPos=nullptr, bool bSetModified=true)
Definition: viewfun2.cxx:941
SfxViewFrame * GetViewFrame() const
SotClipboardFormatId GetClipbrdFormatId(sal_uInt16 nPos) const
bool GetValue() const
virtual VclPtr< AbstractScDPDateGroupDlg > CreateScDPDateGroupDlg(weld::Window *pParent, const ScDPNumGroupInfo &rInfo, sal_Int32 nDatePart, const Date &rNullDate)=0
bool IsBlockEditable(SCTAB nTab, SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, bool *pOnlyNotBecauseOfMatrix=nullptr, bool bNoMatrixAtAll=false) const
Definition: document.cxx:5327
Numeric values (and numeric results if InsertDeleteFlags::FORMULA is not set).
const ScDPDimensionSaveData * GetExistingDimensionData() const
Definition: dpsave.hxx:349
SC_DLLPUBLIC ScDPObject * GetDPAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab) const
Definition: documen3.cxx:372
CreateNameFlags GetCreateNameFlags()
Definition: viewfunc.cxx:2918
void DeleteContents(InsertDeleteFlags nFlags)
Definition: viewfunc.cxx:1936
OUString const & GetClipbrdFormatName(sal_uInt16 nPos) const
virtual VclPtr< AbstractScNameCreateDlg > CreateScNameCreateDlg(weld::Window *pParent, CreateNameFlags nFlags)=0
SC_DLLPUBLIC void Format(OStringBuffer &r, ScRefFlags nFlags, const ScDocument *pDocument=nullptr, const Details &rDetails=detailsOOOa1) const
Definition: address.cxx:2107
static ScDrawTransferObj * GetOwnClipboard(const css::uno::Reference< css::datatransfer::XTransferable2 > &)
Definition: drwtrans.cxx:230
void ExecuteExternalSource(const OUString &_rFile, const OUString &_rFilter, const OUString &_rOptions, const OUString &_rSource, sal_uLong _nRefresh, SfxRequest &_rRequest)
Definition: cellsh1.cxx:2796
void MarkDataArea(bool bIncludeCursor=true)
Definition: tabview3.cxx:1651
static vcl::Font GetDefaultFont(DefaultFontType nType, LanguageType eLang, GetDefaultFontFlags nFlags, const OutputDevice *pOutDev=nullptr)
virtual VclPtr< AbstractScDeleteContentsDlg > CreateScDeleteContentsDlg(weld::Window *pParent)=0
void MarkToSimple()
Definition: markdata.cxx:237
sal_Int32 nIndex
virtual DelCellCmd GetDelCellCmd() const =0
void GetClipStart(SCCOL &nClipX, SCROW &nClipY)
Definition: document.cxx:3170
ScDBData * GetDBData(bool bMarkArea=true, ScGetDBMode eMode=SC_DB_MAKE, ScGetDBSelection eSel=ScGetDBSelection::Keep)
Definition: dbfunc.cxx:80
ScAddress aStart
Definition: address.hxx:500
ScDocShell * GetDocShell() const
Definition: viewdata.hxx:354
virtual InsertDeleteFlags GetDelContentsCmdBits() const =0
bool bVisible
void ShowDataPilotSourceData(ScDPObject &rDPObj, const css::uno::Sequence< css::sheet::DataPilotFieldFilter > &rFilters)
Definition: dbfunc3.cxx:2030
void UngroupDataPilot()
Definition: dbfunc3.cxx:1260
void SetConsolidateDlgData(std::unique_ptr< ScConsolidateParam > pData)
Definition: documen2.cxx:1104
SC_DLLPUBLIC bool IsTabProtected(SCTAB nTab) const
Definition: documen3.cxx:1890
SC_DLLPUBLIC void GetInputString(SCCOL nCol, SCROW nRow, SCTAB nTab, OUString &rString)
Definition: document.cxx:3540
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
Definition: markdata.hxx:43
This class has to do with handling exclusively grouped dimensions? TODO: Find out what this class doe...
Definition: dpdimsave.hxx:160
SCROW GetRefEndY() const
Definition: viewdata.hxx:519
SfxChildWindow * GetChildWindow(sal_uInt16)
const OUString & GetFamilyName() const
bool IsEditMode()
Definition: scmod.cxx:1341
SC_DLLPUBLIC bool CopyToClip(ScDocument *pClipDoc, bool bCut, bool bApi=false, bool bIncludeObjects=false, bool bStopEdit=true)
Definition: viewfun3.cxx:165
virtual void SetOtherDoc(bool bSet)=0
SC_DLLPUBLIC bool DeleteContents(const ScMarkData &rMark, InsertDeleteFlags nFlags, bool bRecord, bool bApi)
Definition: docfunc.cxx:567
void CreateNames(CreateNameFlags nFlags)
Definition: viewfunc.cxx:2907
OUString GetTooltipLabelForCommand(const css::uno::Sequence< css::beans::PropertyValue > &rProperties)
SCROW Row() const
Definition: address.hxx:262
OUString getString(const ScDocument *pDoc) const
Retrieve string value.
Definition: cellvalue.cxx:660
virtual InsCellCmd GetInsCellCmd() const =0
void SetDialogDPObject(std::unique_ptr< ScDPObject > pObj)
Definition: tabvwsh4.cxx:1796
FillDir
Definition: global.hxx:319
void DoSheetConversion(const ScConversionParam &rParam)
Generic implementation of sheet conversion functions.
Definition: viewfun4.cxx:439
void FillTab(InsertDeleteFlags nFlags, ScPasteFunc nFunction, bool bSkipEmpty, bool bAsLink)
Definition: viewfun2.cxx:1610
std::unique_ptr< ContentProperties > pData
virtual const SfxItemSet * GetOutputItemSet() const =0
std::string GetValue
const OUString & GetStyleName() const
virtual bool GetColsChecked() const =0
virtual VclPtr< AbstractScDeleteCellDlg > CreateScDeleteCellDlg(weld::Window *pParent, bool bDisallowCellMove)=0
ScViewData * GetViewData()
Definition: formatsh.hxx:35
void DeleteCells(DelCellCmd eCmd)
Definition: viewfunc.cxx:1653
void MarkRange(const ScRange &rRange, bool bSetCursor=true, bool bContinue=false)
Definition: tabview3.cxx:1682
constexpr::Color COL_RED(0x80, 0x00, 0x00)
const OUString & GetTargetFrame() const
sal_uInt16 char char * pDesc
Definition: callform.cxx:58
bool DataChanging(sal_Unicode cTyped=0, bool bFromCommand=false)
Definition: inputhdl.cxx:2572
SC_DLLPUBLIC bool Intersects(const ScRange &rRange) const
Definition: address.cxx:1549
void ExecuteEdit(SfxRequest &rReq)
Definition: cellsh1.cxx:171
virtual ScDPNumGroupInfo GetGroupInfo() const =0
#define FDS_OPT_VERT
Definition: scui_def.hxx:30
static SvxAbstractDialogFactory * Create()
ScTokenArray * GetCode()
void InsertNameList()
Definition: viewfunc.cxx:2980
sal_uIntPtr sal_uLong
virtual VclPtr< AbstractScDPShowDetailDlg > CreateScDPShowDetailDlg(weld::Window *pParent, ScDPObject &rDPObj, css::sheet::DataPilotFieldOrientation nOrient)=0
Reference< XFrame > xFrame
virtual FillDateCmd GetFillDateCmd() const =0
virtual VclPtr< AbstractScNamePasteDlg > CreateScNamePasteDlg(weld::Window *pParent, ScDocShell *pShell)=0
virtual void GetOptions(ScAsciiOptions &rOpt)=0
void SetPasteMode(ScPasteFlags nFlags)
Definition: viewdata.hxx:448
SCROW GetCurY() const
Definition: viewdata.hxx:402
SC_DLLPUBLIC ScRangeName * GetRangeName(SCTAB nTab) const
Definition: documen3.cxx:168
virtual OUString GetStartStr() const =0
ScDocFunc & GetDocFunc() const
Definition: viewdata.cxx:3029
virtual VclPtr< AbstractScInsertContentsDlg > CreateScInsertContentsDlg(weld::Window *pParent, const OUString *pStrTitle=nullptr)=0
FilterGroup & rTarget
don't create
Definition: global.hxx:396
sal_uInt16 GetValue() const
void FillRangeListWithMarks(ScRangeList *pList, bool bClear, SCTAB nForTab=-1) const
Create a range list of marks.
Definition: markdata.cxx:387
void MakeOutline(bool bColumns, bool bRecord=true)
Definition: dbfunc3.cxx:87
sal_Int16 nId
void Solve(const ScSolveParam &rParam)
Definition: viewfun2.cxx:2166
SCTAB GetTabNo() const
Definition: viewdata.hxx:395
SC_DLLPUBLIC void GetNumberFormat(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt32 &rFormat) const
Definition: document.cxx:3641
bool SimpleRowMarked()
Definition: viewdata.cxx:1233
void ExecuteDataPilotDialog()
Definition: cellsh1.cxx:2850
virtual VclPtr< AbstractScDataPilotServiceDlg > CreateScDataPilotServiceDlg(weld::Window *pParent, const std::vector< OUString > &rServices)=0
ScAddress aEnd
Definition: address.hxx:501
virtual double GetStep() const =0
SC_DLLPUBLIC bool ShowNote(const ScAddress &rPos, bool bShow)
Definition: docfunc.cxx:1278
void Done(bool bRemove=false)
ScDocument & GetDocument() const
Definition: viewdata.hxx:380
static css::uno::Reference< css::datatransfer::XTransferable2 > GetClipData(vcl::Window *pWin)
Definition: tabvwshc.cxx:483
void GetFillData(SCCOL &rStartCol, SCROW &rStartRow, SCCOL &rEndCol, SCROW &rEndRow)
Definition: viewdata.cxx:1304
void ExecuteSubtotals(SfxRequest &rReq)
Definition: cellsh1.cxx:3041
ReturnType limit_cast(Type nValue, ReturnType nMin, ReturnType nMax)
Returns the value, if it is not less than nMin and not greater than nMax, otherwise one of the limits...
Definition: ftools.hxx:61
virtual bool IsSkipEmptyCells() const =0
This is very similar to ScCellValue, except that it references the original value instead of copying ...
Definition: cellvalue.hxx:104
SC_DLLPUBLIC formula::FormulaGrammar::Grammar GetGrammar() const
Definition: document.hxx:985
#define SCITEM_SUBTDATA
Definition: scitems.hxx:92
sal_uInt16 Count() const
const SfxItemSet * GetArgs() const
void Invalidate(sal_uInt16 nId)
void Remove(const SfxPoolItem &)
#define MAXDOUBLE
Definition: global.hxx:74
virtual VclPtr< AbstractScGroupDlg > CreateAbstractScGroupDlg(weld::Window *pParent, bool bUnGroup=false)=0
This class represents the cached data part of the datapilot cache table implementation.
Definition: dpcache.hxx:48
CreateNameFlags
Definition: scui_def.hxx:51
ScConditionalFormat * GetFormat(sal_uInt32 nKey)
Definition: conditio.cxx:2069
virtual short Execute()=0
SC_DLLPUBLIC void SetCursor(SCCOL nPosX, SCROW nPosY, bool bNew=false)
Definition: tabview3.cxx:358
const MarkedTabsType & GetSelectedTabs() const
Definition: markdata.hxx:98
void GetClipArea(SCCOL &nClipX, SCROW &nClipY, bool bIncludeFiltered)
Definition: document.cxx:3118
SC_DLLPUBLIC formula::FormulaGrammar::AddressConvention GetAddressConvention() const
Definition: documen3.cxx:489
OUString DoAutoSum(bool &rRangeFinder, bool &rSubTotal, const OpCode eCode)
Definition: tabvwshc.cxx:654
virtual bool IsLink() const =0
void GetNotesInRange(const ScRangeList &rRange, std::vector< sc::NoteEntry > &rNotes) const
Definition: document.cxx:6766
bool IsImportData() const
Definition: dpobject.hxx:163
void HideMarkedOutlines(bool bRecord=true)
Definition: dbfunc3.cxx:406
void ConvertFormulaToValue()
Definition: viewfun2.cxx:1801
void MarkFromRangeList(const ScRangeList &rList, bool bReset)
Definition: markdata.cxx:334
FontFamily GetFamilyType()
SC_DLLPUBLIC void InputEnterHandler(ScEnterMode nBlockMode=ScEnterMode::NORMAL)
Definition: scmod.cxx:1359
virtual void ShowCursor(bool bOn) override
Definition: tabvwsh4.cxx:452
bool HasSelectionForDateGroup(ScDPNumGroupInfo &rOldInfo, sal_Int32 &rParts)
Definition: dbfunc3.cxx:804
const char * CheckSourceRange() const
Check the sanity of the data source range.
Definition: dpshttab.cxx:306
EditView * GetActiveView()
Definition: inputhdl.cxx:2218
static sal_Int32 getIconSetElements(ScIconSetType eType)
Internal use only (d&d undo): do not delete caption objects of cell notes.
DelCellCmd
Definition: global.hxx:291
void DetectiveMarkPred()
Definition: viewfun6.cxx:167
void GetMarkArea(ScRange &rRange) const
Definition: markdata.cxx:112
virtual SfxUndoManager * GetUndoManager() override
Definition: docsh.cxx:2805
void DateGroupDataPilot(const ScDPNumGroupInfo &rInfo, sal_Int32 nParts)
Definition: dbfunc3.cxx:985
void ToggleChildWindow(sal_uInt16)
RET_NO
const ScDPCache * CreateCache(const ScDPDimensionSaveData *pDimData) const
Definition: dpsdbtab.cxx:50
void ExecuteFillSingleEdit()
Definition: cellsh1.cxx:3120
void UpdateCopySourceOverlay()
Definition: tabview2.cxx:978
weld::Window * GetFrameWeld() const
const ScRangeList & GetRange() const
Definition: conditio.hxx:560
void disposeAndReset(reference_type *pBody)
SC_DLLPUBLIC void SetSourceRange(const ScRange &rRange)
Definition: dpshttab.cxx:223
SC_DLLPUBLIC ScPostIt * GetNote(const ScAddress &rPos)
Notes.
Definition: document.cxx:6508
void SetSlot(sal_uInt16 nNewSlot)
bool InsertName(const OUString &rName, const OUString &rSymbol, const OUString &rType)
Definition: viewfunc.cxx:2853
SC_DLLPUBLIC ScConditionalFormatList * GetCondFormList(SCTAB nTab) const
Definition: documen4.cxx:857
CommentCaptionState GetAllNoteCaptionsState(const ScRangeList &rRanges)
Definition: document.cxx:6649
virtual VclPtr< AbstractScLinkedAreaDlg > CreateScLinkedAreaDlg(weld::Window *pParent)=0
RET_YES
static bool HasRegisteredSources()
Definition: dpobject.cxx:2730
SC_DLLPUBLIC void CutToClip()
Not used?
Definition: viewfun3.cxx:87
DataType::const_iterator const_iterator
Definition: rangenam.hxx:196
void FillSeries(FillDir eDir, FillCmd eCmd, FillDateCmd eDateCmd, double fStart, double fStep, double fMax)
Definition: viewfun2.cxx:1406
bool SelectionEditable(bool *pOnlyNotBecauseOfMatrix=nullptr)
Definition: viewfunc.cxx:260
PropertiesInfo aProperties
virtual bool IsExternal() const =0
SC_DLLPUBLIC SCROW MaxRow() const
Definition: document.hxx:873
size_t SCSIZE
size_t typedef to be able to find places where code was changed from USHORT to size_t and is used to ...
Definition: address.hxx:45
sal_Int32 SCCOLROW
a type capable of holding either SCCOL or SCROW
Definition: types.hxx:24
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
void ExecuteRotateTrans(const SfxRequest &rReq)
Definition: cellsh1.cxx:2790
Additional class containing cell annotation data.
Definition: postit.hxx:160
sal_uInt16 GetMonth() const
bool IsMultiMarked() const
Definition: markdata.hxx:83
virtual void InsertUno(const OUString &sCmd, const OUString &sLabel)=0
std::string GetNullDate
SfxFrame & GetFrame() const
int nCount
FillDateCmd
Definition: global.hxx:344
void TransliterateText(TransliterationFlags nType)
Definition: viewfun2.cxx:1812
SC_DLLPUBLIC void SetRefDialog(sal_uInt16 nId, bool bVis, SfxViewFrame *pViewFrm=nullptr)
Reference dialogs.
Definition: scmod.cxx:1467
virtual bool CondFormatsChanged() const =0
void DoSubTotals(const ScSubTotalParam &rParam, bool bRecord=true, const ScSortParam *pForceNewSort=nullptr)
Definition: dbfunc3.cxx:429
static TransferableDataHelper CreateFromSystemClipboard(vcl::Window *pWindow)
void push_back(const ScRange &rRange)
Definition: rangelst.cxx:1144
void UpdateCharts(bool bAllCharts)
Definition: dbfunc2.cxx:24
void UpdateInputHandler(bool bForce=false, bool bStopEditing=true)
Definition: tabvwsha.cxx:638
ScFormulaCell * mpFormula
Definition: cellvalue.hxx:111
SCTAB Tab() const
Definition: address.hxx:271
virtual VclPtr< AbstractScDataPilotDatabaseDlg > CreateScDataPilotDatabaseDlg(weld::Window *pParent)=0
void ExecuteXMLSourceDialog()
Definition: cellsh1.cxx:3027
void SetRow(SCROW nRowP)
Definition: address.hxx:275
void DetectiveDelSucc()
Definition: viewfun6.cxx:90
SotClipboardFormatId
#define SCRET_REMOVE
Definition: scui_def.hxx:68
SC_DLLPUBLIC const_iterator begin() const
Definition: rangenam.cxx:780
sal_Int32 nEndPos
virtual bool IsTranspose() const =0
const ScRange * Find(const ScAddress &) const
Definition: rangelst.cxx:1033
virtual void SetChangeTrack(bool bSet)=0
size_type size() const
ScDocument * GetDocument() const
Definition: transobj.hxx:81
bool HasSelectionForNumGroup(ScDPNumGroupInfo &rOldInfo)
Definition: dbfunc3.cxx:917
SC_DLLPUBLIC const ScPatternAttr * GetPattern(SCCOL nCol, SCROW nRow, SCTAB nTab) const
Definition: document.cxx:4735
SC_DLLPUBLIC void PasteFromSystem()
Definition: viewfun3.cxx:482
void SetCol(SCCOL nColP)
Definition: address.hxx:279
SvtScriptType GetSelectionScriptType()
Definition: viewfunc.cxx:803
ScChangeTrack * GetChangeTrack() const
Definition: document.hxx:2392
TransliterationFlags
SC_DLLPUBLIC void DeletePageBreak(bool bColumn, bool bRecord=true, const ScAddress *pPos=nullptr, bool bSetModified=true)
Definition: viewfun2.cxx:958
bool IsServiceData() const
Definition: dpobject.hxx:164
#define SCITEM_CONDFORMATDLGDATA
Definition: scitems.hxx:97
#define FDS_OPT_NONE
Definition: scui_def.hxx:28
static void SetError(ErrCode)
void PasteFromClipboard(ScViewData *pViewData, ScTabViewShell *pTabViewShell, bool bShowDialog)
Definition: cliputil.cxx:46
SfxItemPool & GetPool() const
const SfxPoolItem & GetItem(sal_uInt16 nWhichP) const
Definition: patattr.hxx:70
bool empty() const
Definition: rangelst.hxx:89
bool InputKeyEvent(const KeyEvent &rKEvt, bool bStartEdit=false)
Definition: scmod.cxx:1353
void GetPossibleClipboardFormats(SvxClipboardFormatItem &rFormats)
Definition: cellsh.cxx:443
DocumentType eType
SC_DLLPUBLIC double GetValue(const ScAddress &rPos) const
Definition: document.cxx:3628
ScTabViewShell * GetViewShell() const
Definition: viewdata.hxx:357
void SetNoteText(const ScAddress &rPos, const OUString &rNoteText)
Definition: viewfunc.cxx:2597
sal_Int16 GetYear() const
const char * GetMessageId() const
Definition: editable.cxx:152
sal_uInt32 GetKey() const
Definition: conditio.hxx:592
void SetMarkArea(const ScRange &rRange)
Definition: markdata.cxx:97
ScPasteFunc
Definition: global.hxx:190
OUString CreateString(sc::TokenStringContext &rCxt, const ScAddress &rPos) const
Create a string representation of formula token array without modifying the internal state of the tok...
Definition: token.cxx:5103
SC_DLLPUBLIC SCCOL MaxCol() const
Definition: document.hxx:872
void InsertURL(const OUString &rName, const OUString &rURL, const OUString &rTarget, sal_uInt16 nMode)
Definition: tabvwshe.cxx:120
void DetectiveAddPred()
Definition: viewfun6.cxx:69
SC_DLLPUBLIC SvNumberFormatter * GetFormatTable() const
Definition: documen2.cxx:438
SvNumFormatType GetType() const
void UseScenario(const OUString &rName)
Definition: viewfun2.cxx:2288
virtual sal_Int32 GetDatePart() const =0
FillCmd
Definition: global.hxx:327
SC_DLLPUBLIC const_iterator end() const
Definition: rangenam.cxx:785
static void GetFont(vcl::Font &rFont, const SfxItemSet &rItemSet, ScAutoFontColorMode eAutoMode, const OutputDevice *pOutDev=nullptr, const Fraction *pScale=nullptr, const SfxItemSet *pCondSet=nullptr, SvtScriptType nScript=SvtScriptType::NONE, const Color *pBackConfigColor=nullptr, const Color *pTextConfigColor=nullptr)
Static helper function to fill a font object from the passed item set.
Definition: patattr.cxx:216
const OUString & GetURL() const
virtual OUString GetParUser() const =0
sal_Int16 GetValue() const
OUString GetModuleIdentifier(const Reference< frame::XFrame > &rxFrame)
FontPitch GetPitch()
bool IsMarked() const
Definition: markdata.hxx:82
#define SCITEM_STRING
Definition: scitems.hxx:88
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
virtual ScConditionalFormat * GetCondFormatSelected()=0
int i
virtual VclPtr< AbstractScDPNumGroupDlg > CreateScDPNumGroupDlg(weld::Window *pParent, const ScDPNumGroupInfo &rInfo)=0
css::uno::Sequence< css::uno::Any > InitAnyPropertySequence(::std::initializer_list< ::std::pair< OUString, css::uno::Any > > vInit)
ScMarkType
States GetSimpleArea() returns for the underlying selection marks, so the caller can react if the res...
Definition: viewdata.hxx:61
sal_Int16 SCCOL
Definition: types.hxx:22
InsertDeleteFlags
Definition: global.hxx:159
bool GetString(SotClipboardFormatId nFormat, OUString &rStr)
#define SC_MOD()
Definition: scmod.hxx:253
void DetectiveAddSucc()
Definition: viewfun6.cxx:83
SfxBindings & GetBindings()
virtual OUString GetParName() const =0
virtual void SetEdStartValEnabled(bool bFlag)=0
Parameters for conversion.
Definition: spellparam.hxx:33
ScSheetLimits & GetSheetLimits() const
Definition: document.hxx:874
const OUString & GetValue() const
void GetUnprotectedCells(ScRangeList &rRange, SCTAB nTab) const
Definition: document.cxx:6778
SC_DLLPUBLIC void SetTabNo(SCTAB nTab, bool bNew=false, bool bExtendSelection=false, bool bSameTabButMoved=false)
Definition: tabview3.cxx:1793
const T * GetArg(sal_uInt16 nSlotId) const
void ExecuteTrans(SfxRequest &rReq)
Definition: cellsh1.cxx:2780
virtual ScPasteFunc GetFormulaCmdBits() const =0
virtual OUString GetDimensionName() const =0
void IncRow(SCROW nDelta=1)
Definition: address.hxx:300
OUString ScResId(const char *pId)
Definition: scdll.cxx:95
ScMarkType GetSimpleArea(SCCOL &rStartCol, SCROW &rStartRow, SCTAB &rStartTab, SCCOL &rEndCol, SCROW &rEndRow, SCTAB &rEndTab) const
Definition: viewdata.cxx:1170
virtual void SetCurPageId(const OString &rName)=0
bool IsNumberFormat(const OUString &sString, sal_uInt32 &F_Index, double &fOutNumber, SvNumInputOptions eInputOptions=SvNumInputOptions::NONE)
void ChangeIndent(bool bIncrement)
Definition: viewfunc.cxx:2823
Context for creating string from an array of formula tokens, used in ScTokenArray::CreateString().
bool IsCutMode()
Definition: document.cxx:2065
TransliterationFlags getNextMode()
virtual SotClipboardFormatId GetFormat(const TransferableDataHelper &aHelper)=0
ScGridWindow * GetActiveWin()
Definition: viewdata.cxx:3062
bool ShrinkToDataArea(SCTAB nTab, SCCOL &rStartCol, SCROW &rStartRow, SCCOL &rEndCol, SCROW &rEndRow) const
Shrink a range to only include data area.
Definition: document.cxx:1040
std::unique_ptr< CellShell_Impl > pImpl
Definition: cellsh.hxx:53
sal_uInt16 GetDay() const
virtual bool IsNamedRange() const =0
SvNumFormatType
#define LANGUAGE_CHINESE_SIMPLIFIED
void DetectiveAddError()
Definition: viewfun6.cxx:97
void InsertFunction(const OUString &rFuncName, bool bAddPar=true)
Definition: inputhdl.cxx:3485
ScDPSaveData * GetSaveData() const
Definition: dpobject.hxx:141
CPPUHELPER_DLLPUBLIC css::uno::Reference< css::uno::XComponentContext > SAL_CALL defaultBootstrap_InitialComponentContext()
void Consolidate(const ScConsolidateParam &rParam)
Definition: dbfunc3.cxx:604
void AddDays(sal_Int32 nAddDays)
void ReplaceNote(const ScAddress &rPos, const OUString &rNoteText, const OUString *pAuthor, const OUString *pDate)
Definition: viewfunc.cxx:2602
const ScImportSourceDesc * GetImportSourceDesc() const
Definition: dpobject.hxx:157
void InsertText(const OUString &rNew, bool bSelect=false)
virtual VclPtr< SfxAbstractDialog > CreateCharMapDialog(weld::Window *pParent, const SfxItemSet &rAttr, const css::uno::Reference< css::frame::XFrame > &rFrame)=0
#define DLG_RET_EDIT
bool IsEditable() const
Definition: editable.hxx:84
bool IsBlockEmpty(SCTAB nTab, SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, bool bIgnoreNotes=false) const
Definition: document.cxx:5296
virtual VclPtr< AbstractScFillSeriesDlg > CreateScFillSeriesDlg(weld::Window *pParent, ScDocument &rDocument, FillDir eFillDir, FillCmd eFillCmd, FillDateCmd eFillDateCmd, const OUString &aStartStr, double fStep, double fMax, SCSIZE nSelectHeight, SCSIZE nSelectWidth, sal_uInt16 nPossDir)=0
const ScTabOpParam & GetData() const
Definition: uiitems.hxx:274
bool empty() const
virtual double GetMax() const =0
void ShowMarkedOutlines(bool bRecord=true)
Definition: dbfunc3.cxx:383
static SC_DLLPUBLIC LanguageType eLnge
Definition: global.hxx:548
void ReplaceConditionalFormat(sal_uLong nOldIndex, std::unique_ptr< ScConditionalFormat > pFormat, SCTAB nTab, const ScRangeList &rRanges)
Definition: docfunc.cxx:5603
virtual CreateNameFlags GetFlags() const =0
CommentCaptionState
Definition: document.hxx:252
SCCOL GetRefEndX() const
Definition: viewdata.hxx:518
bool IsMultiMarked() const
Definition: viewdata.cxx:1248
bool StartExecuteAsync(const std::function< void(sal_Int32)> &rEndDialogFn)
virtual OUString GetSelectedNamedRange() const =0
void GetArea(SCTAB &rTab, SCCOL &rCol1, SCROW &rRow1, SCCOL &rCol2, SCROW &rRow2) const
Definition: dbdata.cxx:301
SC_DLLPUBLIC bool PasteFromClip(InsertDeleteFlags nFlags, ScDocument *pClipDoc, ScPasteFunc nFunction=ScPasteFunc::NONE, bool bSkipEmpty=false, bool bTranspose=false, bool bAsLink=false, InsCellCmd eMoveMode=INS_NONE, InsertDeleteFlags nUndoExtraFlags=InsertDeleteFlags::NONE, bool bAllowDialogs=false)
Definition: viewfun3.cxx:875
virtual FillCmd GetFillCmd() const =0
void DetectiveDelPred()
Definition: viewfun6.cxx:76
const css::uno::Reference< css::frame::XFrame > & GetFrameInterface() const
SCCOL Col() const
Definition: address.hxx:267
bool GetDataFieldPositionData(const ScAddress &rPos, css::uno::Sequence< css::sheet::DataPilotFieldFilter > &rFilters)
Definition: dpobject.cxx:1140
SC_DLLPUBLIC const ScPatternAttr * GetSelectionPattern()
Definition: viewfunc.cxx:829
void GetSubTotalParam(ScSubTotalParam &rSubTotalParam) const
Definition: dbdata.cxx:449
size_t LeaveListAction()
ScDBFunc * GetView() const
Definition: viewdata.cxx:852
void SetInputMode(ScInputMode eMode, const OUString *pInitText=nullptr)
Definition: scmod.cxx:1334
virtual void Insert(SotClipboardFormatId nFormat, const OUString &rFormatName)=0
ScAddress GetCurPos() const
Definition: viewdata.cxx:4007
void InitRangeFinder(const OUString &rFormula)
Definition: inputhdl.cxx:306
void InsertAreaLink(const OUString &rFile, const OUString &rFilter, const OUString &rOptions, const OUString &rSource, const ScRange &rDestRange, sal_uLong nRefresh, bool bFitBlock, bool bApi)
Definition: docfunc.cxx:5514
void InsertCurrentTime(SvNumFormatType nCellFmt, const OUString &rUndoStr)
Insert date or time into current cell.
Definition: viewfun6.cxx:271
virtual double GetStart() const =0
void SetReturnValue(const SfxPoolItem &)
#define ERRCODE_BASIC_BAD_PARAMETER
bool bReplace
replace existing results
sal_Int32 GetIndex() const
CellType meType
Definition: cellvalue.hxx:106
Sequence< beans::PropertyValue > GetCommandProperties(const OUString &rsCommandName, const OUString &rsModuleName)
SC_DLLPUBLIC void FillAuto(FillDir eDir, SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, sal_uLong nCount)
Definition: viewfun2.cxx:1429
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
sal_Int32 SCROW
Definition: types.hxx:18
sal_uInt16 GetSlot() const
std::unique_ptr< char[]> aBuffer
virtual VclPtr< AbstractScDataPilotSourceTypeDlg > CreateScDataPilotSourceTypeDlg(weld::Window *pParent, bool bEnableExternal)=0
virtual InsCellCmd GetMoveMode()=0
virtual bool IsDatabase() const =0
void ShowNote(bool bShow)
Definition: viewfun6.cxx:480
weld::Window * GetFrameWeld() const
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
sal_uInt16 GetWhich(sal_uInt16 nSlot, bool bDeep=true) const
void DetectiveRefresh()
Definition: viewfun6.cxx:118
static TransliterationFlags GetTransliterationType(sal_uInt16 nSlotID)
Definition: viewutil.cxx:98
void ErrorMessage(const char *pGlobStrId)
Definition: tabview2.cxx:1412
const SvNumberformat * GetEntry(sal_uInt32 nKey) const
constexpr::Color COL_GREEN(0x00, 0x80, 0x00)
void SetIconSetData(ScIconSetFormatData *pData)
#define GetWhich(nSlot)
void ActivateInputWindow(const OUString *pStr=nullptr, bool bMatrix=false)
Definition: scmod.cxx:1430
CellType
Definition: global.hxx:282
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_WHITE
OUString aName
static SC_DLLPUBLIC ScAbstractDialogFactory * Create()
Definition: scabstdlg.cxx:38
sal_uInt32 GetStandardFormat(SvNumFormatType eType, LanguageType eLnge=LANGUAGE_DONTKNOW)
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_BROWN
void GroupDataPilot()
Definition: dbfunc3.cxx:1125
SfxDispatcher & GetDispatcher()
Definition: viewdata.cxx:3040
RET_OK
Dates, times, datetime values.
InsCellCmd
Definition: global.hxx:300
void DetectiveMarkSucc()
Definition: viewfun6.cxx:231
Item2Range GetItemSurrogates(sal_uInt16 nWhich) const
bool bIncludePattern
sort formats
virtual std::unique_ptr< ScConditionalFormatList > GetConditionalFormatList()=0
void SetChildWindow(sal_uInt16 nId, bool bVisible, bool bSetFocus=true)
const T & Put(std::unique_ptr< T > xItem, sal_uInt16 nWhich=0)
virtual void GetValues(ScImportSourceDesc &rDesc)=0
static SC_DLLPUBLIC ScTransferObj * GetOwnClipboard(const css::uno::Reference< css::datatransfer::XTransferable2 > &)
Definition: transobj.cxx:192
bool HasItem(sal_uInt16 nWhich, const SfxPoolItem **ppItem=nullptr) const
virtual void EnterListAction(const OUString &rComment, const OUString &rRepeatComment, sal_uInt16 nId, ViewShellId nViewShellId)
void NumGroupDataPilot(const ScDPNumGroupInfo &rInfo)
Definition: dbfunc3.cxx:1083
SC_DLLPUBLIC void FillSimple(FillDir eDir)
Definition: viewfun2.cxx:1357
constexpr TypedWhichId< ScCondFormatItem > ATTR_CONDITIONAL(154)
virtual VclPtr< AbstractScInsertCellDlg > CreateScInsertCellDlg(weld::Window *pParent, bool bDisallowCellMove)=0
QPRO_FUNC_TYPE nType
Definition: qproform.cxx:401
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_YELLOW
Sequence< sal_Int8 > aSeq
const ScDocument & GetDocument() const
Definition: docsh.hxx:216
void DataChanged(bool bFromTopNotify=false, bool bSetModified=true)
Definition: inputhdl.cxx:2584
const ScSolveParam & GetData() const
Definition: uiitems.hxx:259
Hangul-Hanja converter.
Definition: spellparam.hxx:29
void SetDataPilotDetails(bool bShow, const OUString *pNewDimensionName=nullptr)
Definition: dbfunc3.cxx:1944
virtual void SetCellShiftDisabled(CellShiftDisabledFlags nDisable)=0
void PasteDraw()
Definition: viewfun3.cxx:465
void DoRefConversion()
Definition: viewfun4.cxx:179
virtual VclPtr< AbstractScCondFormatManagerDlg > CreateScCondFormatMgrDlg(weld::Window *pParent, ScDocument &rDoc, const ScConditionalFormatList *pFormatList)=0
void CancelAutoDBRange()
Definition: docsh5.cxx:369
void HideListBox()
Definition: tabview3.cxx:2957
ScIconSetType
Definition: colorscale.hxx:189
void SetSelection(const ESelection &rNewSel)
bool HasSelectionForDrillDown(css::sheet::DataPilotFieldOrientation &rOrientation)
Definition: dbfunc3.cxx:1907
virtual SfxInterface * GetInterface() const
RotateTransliteration m_aRotateCase
Definition: cellsh.hxx:70
void GetMultiArea(ScRangeListRef &rRange) const
Definition: viewdata.cxx:1193
sal_uInt32 GetValue() const
#define BTN_PASTE_LIST
Definition: scui_def.hxx:63
void SetConditionalFormatList(ScConditionalFormatList *pList, SCTAB nTab)
Sets or replaces the conditional format list of a table.
Definition: docfunc.cxx:5679
const OUString & GetName() const
SvxLinkInsertMode GetInsertMode() const
void AppendItem(const SfxPoolItem &)
#define LANGUAGE_CHINESE_TRADITIONAL
void DoHangulHanjaConversion()
Definition: viewfun4.cxx:433
virtual FillDir GetFillDir() const =0
SVXCORE_DLLPUBLIC MSO_SPT Get(const OUString &)
ESelection GetSelection() const
ScInputHandler * GetInputHdl(ScTabViewShell *pViewSh=nullptr, bool bUseRef=true)
Input-Handler.
Definition: scmod.cxx:1303
bool IsAPI() const
SC_DLLPUBLIC ScRefFlags Parse(const OUString &, const ScDocument &, const Details &rDetails=detailsOOOa1, ExternalInfo *pExtInfo=nullptr, const css::uno::Sequence< css::sheet::ExternalLinkInfo > *pExternalLinks=nullptr, sal_Int32 *pSheetEndPos=nullptr, const OUString *pErrRef=nullptr)
Definition: address.cxx:1539
ScDBData * GetAnonymousDBData()
Definition: dbfunc.cxx:155
ScDocFunc & GetDocFunc()
Definition: docsh.hxx:218
const SfxPoolItem * Execute(sal_uInt16 nSlot, SfxCallMode nCall=SfxCallMode::SLOT, const SfxPoolItem **pArgs=nullptr, sal_uInt16 nModi=0, const SfxPoolItem **pInternalArgs=nullptr)
virtual ScDPNumGroupInfo GetGroupInfo() const =0
void RemoveOutline(bool bColumns, bool bRecord=true)
Definition: dbfunc3.cxx:108
void InsertSpecialChar(const OUString &rStr, const vcl::Font &rFont)
Definition: viewfun2.cxx:3199
bool HasSubTotalCells(const ScRange &rRange)
Definition: documen3.cxx:777
SC_DLLPUBLIC void SetRangeName(const OUString &rName)
Definition: dpshttab.cxx:259
bool GetTableSelect(SCTAB nTab) const
Definition: markdata.cxx:184
#define DLG_RET_ADD
#define SCITEM_SOLVEDATA
Definition: scitems.hxx:95
virtual void SaveParameters()=0
void SetDialogType(condformat::dialog::ScCondFormatDialogType eType)
void EditNote()
Definition: viewfun6.cxx:490
void TestRemoveOutline(bool &rCol, bool &rRow)
Definition: dbfunc3.cxx:129
const Date & GetNullDate() const
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
const css::uno::Reference< css::datatransfer::XTransferable > & GetTransferable() const
#define FDS_OPT_HORZ
Definition: scui_def.hxx:29
void Ignore()
void DoThesaurus()
Definition: viewfun4.cxx:310
static std::vector< OUString > GetRegisteredSources()
Definition: dpobject.cxx:2747
virtual OUString GetParSource() const =0
This class contains authoritative information on the internal reference used as the data source for d...
Definition: dpshttab.hxx:39
#define EE_TEXTPOS_ALL
SC_DLLPUBLIC void CellContentChanged()
Definition: tabview3.cxx:509
bool IsClipboardSource() const
Definition: document.cxx:2562
aStr
virtual VclPtr< SfxAbstractTabDialog > CreateScSubTotalDlg(weld::Window *pParent, const SfxItemSet *pArgSet)=0
virtual OUString GetParPass() const =0
void GetOutputString(const double &fOutNumber, sal_uInt32 nFIndex, OUString &sOutString, const Color **ppColor, bool bUseStarFormat=false)
Strings (and string results if InsertDeleteFlags::FORMULA is not set).
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, bool bMobile=false)
SC_DLLPUBLIC void GetCellType(SCCOL nCol, SCROW nRow, SCTAB nTab, CellType &rCellType) const
Definition: document.cxx:3747
virtual std::vector< OUString > GetSelectedNames() const =0
#define SCITEM_CONSOLIDATEDATA
Definition: scitems.hxx:93
rtl_TextEncoding GetCharSet() const
virtual void DisableObjects()=0
virtual OUString GetServiceName() const =0
sal_Int16 SCTAB
Definition: types.hxx:23
bool InsertCells(InsCellCmd eCmd, bool bRecord=true, bool bPartOfPaste=false)
Definition: viewfunc.cxx:1600
CellShiftDisabledFlags
Definition: scui_def.hxx:42
void EnterData(SCCOL nCol, SCROW nRow, SCTAB nTab, const OUString &rString, const EditTextObject *pData=nullptr)
Definition: viewfunc.cxx:342
virtual InsertDeleteFlags GetInsContentsCmdBits() const =0
SCCOL GetCurX() const
Definition: viewdata.hxx:401
ViewShellId GetViewShellId() const override
void SetMarkData(const ScMarkData &rNew)
Definition: tabview3.cxx:1732
#define BTN_PASTE_NAME
Definition: scui_def.hxx:62
bool SimpleColMarked()
Definition: viewdata.cxx:1218
void TabOp(const ScTabOpParam &rParam, bool bRecord=true)
Definition: viewfun2.cxx:2236
ocSum
sal_Int32 nStartPos
SC_DLLPUBLIC void GetAllNoteEntries(std::vector< sc::NoteEntry > &rNotes) const
Definition: document.cxx:6746
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo