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 && pReqArgs->GetItemState(nSlot, true, &pItem) == SfxItemState::SET )
1309  if (auto pIntItem = dynamic_cast<const SfxUInt32Item*>(pItem) )
1310  nFormat = static_cast<SotClipboardFormatId>(pIntItem->GetValue());
1311 
1312  if ( nFormat != SotClipboardFormatId::NONE )
1313  {
1314  css::uno::Reference<css::datatransfer::XTransferable2> xTransferable(ScTabViewShell::GetClipData(GetViewData().GetActiveWin()));
1315  bool bCells = ( ScTransferObj::GetOwnClipboard(xTransferable) != nullptr );
1316  bool bDraw = ( ScDrawTransferObj::GetOwnClipboard(xTransferable) != nullptr );
1317  bool bOle = ( nFormat == SotClipboardFormatId::EMBED_SOURCE );
1318 
1319  if ( bCells && bOle )
1320  pTabViewShell->PasteFromSystem();
1321  else if ( bDraw && bOle )
1322  pTabViewShell->PasteDraw();
1323  else
1324  pTabViewShell->PasteFromSystem(nFormat);
1325  }
1326  //?else
1327  //? pTabViewShell->PasteFromSystem();
1328 
1329  rReq.Done();
1330  }
1331  pTabViewShell->CellContentChanged();
1332  break;
1333 
1334  case FID_INS_CELL_CONTENTS:
1335  {
1336  ScDocument& rDoc = GetViewData().GetDocument();
1337  bool bOtherDoc = !rDoc.IsClipboardSource();
1338  // keep a reference in case the clipboard is changed during dialog or PasteFromClip
1340  if ( pOwnClip )
1341  {
1343  ScPasteFunc nFunction = ScPasteFunc::NONE;
1344  InsCellCmd eMoveMode = INS_NONE;
1345  bool bSkipEmpty = false;
1346  bool bTranspose = false;
1347  bool bAsLink = false;
1348 
1349  if ( pReqArgs!=nullptr && pTabViewShell->SelectionEditable() )
1350  {
1351  const SfxPoolItem* pItem;
1352  OUString aFlags('A');
1353 
1354  if( pReqArgs->HasItem( FID_INS_CELL_CONTENTS, &pItem ) )
1355  aFlags = static_cast<const SfxStringItem*>(pItem)->GetValue();
1356 
1357  nFlags |= FlagsFromString(aFlags);
1358 
1359  const SfxUInt16Item* pFuncItem = rReq.GetArg<SfxUInt16Item>(FN_PARAM_1);
1360  const SfxBoolItem* pSkipItem = rReq.GetArg<SfxBoolItem>(FN_PARAM_2);
1361  const SfxBoolItem* pTransposeItem = rReq.GetArg<SfxBoolItem>(FN_PARAM_3);
1362  const SfxBoolItem* pLinkItem = rReq.GetArg<SfxBoolItem>(FN_PARAM_4);
1363  const SfxInt16Item* pMoveItem = rReq.GetArg<SfxInt16Item>(FN_PARAM_5);
1364  if ( pFuncItem )
1365  nFunction = static_cast<ScPasteFunc>(pFuncItem->GetValue());
1366  if ( pSkipItem )
1367  bSkipEmpty = pSkipItem->GetValue();
1368  if ( pTransposeItem )
1369  bTranspose = pTransposeItem->GetValue();
1370  if ( pLinkItem )
1371  bAsLink = pLinkItem->GetValue();
1372  if ( pMoveItem )
1373  eMoveMode = static_cast<InsCellCmd>(pMoveItem->GetValue());
1374  }
1375  else
1376  {
1377  ScEditableTester aTester( pTabViewShell );
1378  if (aTester.IsEditable())
1379  {
1381 
1383  pDlg->SetOtherDoc( bOtherDoc );
1384  // if ChangeTrack MoveMode disable
1385  pDlg->SetChangeTrack( rDoc.GetChangeTrack() != nullptr );
1386  // fdo#56098 disable shift if necessary
1387  if (!bOtherDoc)
1388  {
1390  if ( rData.GetMarkData().GetTableSelect( rData.GetTabNo() ) )
1391  {
1392  SCCOL nStartX, nEndX, nClipStartX, nClipSizeX, nRangeSizeX;
1393  SCROW nStartY, nEndY, nClipStartY, nClipSizeY, nRangeSizeY;
1394  SCTAB nStartTab, nEndTab;
1395  pOwnClip->GetDocument()->GetClipStart( nClipStartX, nClipStartY );
1396  pOwnClip->GetDocument()->GetClipArea( nClipSizeX, nClipSizeY, true );
1397 
1398  if ( rData.GetSimpleArea( nStartX, nStartY, nStartTab,
1399  nEndX, nEndY, nEndTab ) != SC_MARK_SIMPLE ||
1400  nStartTab != nEndTab )
1401  {
1402  // the destination is not a simple range,
1403  // assume the destination as the current cell
1404  nStartX = nEndX = rData.GetCurX();
1405  nStartY = nEndY = rData.GetCurY();
1406  nStartTab = rData.GetTabNo();
1407  }
1408  // we now have clip- and range dimensions
1409  // the size of the destination area is the larger of the two
1410  nRangeSizeX = nClipSizeX >= nEndX - nStartX ? nClipSizeX : nEndX - nStartX;
1411  nRangeSizeY = nClipSizeY >= nEndY - nStartY ? nClipSizeY : nEndY - nStartY;
1412  // When the source and destination areas intersect things may go wrong,
1413  // especially if the area contains references. This may produce data loss
1414  // (e.g. formulas that get wrong references), this scenario _must_ be avoided.
1415  ScRange aSource( nClipStartX, nClipStartY, nStartTab,
1416  nClipStartX + nClipSizeX, nClipStartY + nClipSizeY, nStartTab );
1417  ScRange aDest( nStartX, nStartY, nStartTab,
1418  nStartX + nRangeSizeX, nStartY + nRangeSizeY, nStartTab );
1419  if ( pOwnClip->GetDocument()->IsCutMode() && aSource.Intersects( aDest ) )
1421  else
1422  {
1423  //no conflict with intersecting ranges,
1424  //check if paste plus shift will fit on sheet
1425  //and disable shift-option if no fit
1428 
1429  //check if horizontal shift will fit
1430  if ( !rData.GetDocument().IsBlockEmpty( nStartTab,
1431  rDoc.MaxCol() - nRangeSizeX, nStartY,
1432  rDoc.MaxCol(), nStartY + nRangeSizeY ) )
1433  nDisableShiftX = CellShiftDisabledFlags::Right;
1434 
1435  //check if vertical shift will fit
1436  if ( !rData.GetDocument().IsBlockEmpty( nStartTab,
1437  nStartX, rDoc.MaxRow() - nRangeSizeY,
1438  nStartX + nRangeSizeX, rDoc.MaxRow() ) )
1439  nDisableShiftY = CellShiftDisabledFlags::Down;
1440 
1441  if ( nDisableShiftX != CellShiftDisabledFlags::NONE || nDisableShiftY != CellShiftDisabledFlags::NONE)
1442  pDlg->SetCellShiftDisabled( nDisableShiftX | nDisableShiftY );
1443  }
1444  }
1445  }
1446  if (pDlg->Execute() == RET_OK)
1447  {
1448  nFlags = pDlg->GetInsContentsCmdBits();
1449  nFunction = pDlg->GetFormulaCmdBits();
1450  bSkipEmpty = pDlg->IsSkipEmptyCells();
1451  bTranspose = pDlg->IsTranspose();
1452  bAsLink = pDlg->IsLink();
1453  eMoveMode = pDlg->GetMoveMode();
1454  }
1455  }
1456  else
1457  pTabViewShell->ErrorMessage(aTester.GetMessageId());
1458  }
1459 
1460  if( nFlags != InsertDeleteFlags::NONE )
1461  {
1462  {
1463  weld::WaitObject aWait( GetViewData().GetDialogParent() );
1464  if ( bAsLink && bOtherDoc )
1465  pTabViewShell->PasteFromSystem(SotClipboardFormatId::LINK); // DDE insert
1466  else
1467  {
1468  pTabViewShell->PasteFromClip( nFlags, pOwnClip->GetDocument(),
1469  nFunction, bSkipEmpty, bTranspose, bAsLink,
1470  eMoveMode, InsertDeleteFlags::NONE, true ); // allow warning dialog
1471  }
1472  }
1473 
1474  if( !pReqArgs )
1475  {
1476  OUString aFlags = FlagsToString( nFlags );
1477 
1478  rReq.AppendItem( SfxStringItem( FID_INS_CELL_CONTENTS, aFlags ) );
1479  rReq.AppendItem( SfxBoolItem( FN_PARAM_2, bSkipEmpty ) );
1480  rReq.AppendItem( SfxBoolItem( FN_PARAM_3, bTranspose ) );
1481  rReq.AppendItem( SfxBoolItem( FN_PARAM_4, bAsLink ) );
1482  rReq.AppendItem( SfxUInt16Item( FN_PARAM_1, static_cast<sal_uInt16>(nFunction) ) );
1483  rReq.AppendItem( SfxInt16Item( FN_PARAM_5, static_cast<sal_Int16>(eMoveMode) ) );
1484  rReq.Done();
1485  }
1486  }
1487  }
1488  }
1489  pTabViewShell->CellContentChanged(); // => PasteFromXXX ???
1490  break;
1491  case SID_PASTE_ONLY_VALUE:
1492  case SID_PASTE_ONLY_TEXT:
1493  case SID_PASTE_ONLY_FORMULA:
1494  {
1495  if ( ScTransferObj::GetOwnClipboard(ScTabViewShell::GetClipData(GetViewData().GetActiveWin())) ) // own cell data
1496  {
1497  rReq.SetSlot( FID_INS_CELL_CONTENTS );
1498  OUString aFlags;
1499  if ( nSlot == SID_PASTE_ONLY_VALUE )
1500  aFlags = "V";
1501  else if ( nSlot == SID_PASTE_ONLY_TEXT )
1502  aFlags = "S";
1503  else
1504  aFlags = "F";
1505  rReq.AppendItem( SfxStringItem( FID_INS_CELL_CONTENTS, aFlags ) );
1506  ExecuteSlot( rReq, GetInterface() );
1507  rReq.SetReturnValue(SfxInt16Item(nSlot, 1)); // 1 = success
1508  pTabViewShell->CellContentChanged();
1509  }
1510  else
1511  rReq.SetReturnValue(SfxInt16Item(nSlot, 0)); // 0 = fail
1512  break;
1513  }
1514  case SID_PASTE_TEXTIMPORT_DIALOG:
1515  {
1516  vcl::Window* pWin = GetViewData().GetActiveWin();
1517  TransferableDataHelper aDataHelper(
1519  const uno::Reference<datatransfer::XTransferable>& xTransferable
1520  = aDataHelper.GetTransferable();
1521  SotClipboardFormatId format = SotClipboardFormatId::STRING;
1522  bool bSuccess = false;
1523  if (xTransferable.is() && HasClipboardFormat(format))
1524  {
1525  OUString sStrBuffer;
1526  bSuccess = aDataHelper.GetString(format, sStrBuffer);
1527  if (bSuccess)
1528  {
1529  auto pStrm = std::make_shared<ScImportStringStream>(sStrBuffer);
1531  VclPtr<AbstractScImportAsciiDlg> pDlg(pFact->CreateScImportAsciiDlg(
1532  pWin ? pWin->GetFrameWeld() : nullptr, OUString(), pStrm.get(), SC_PASTETEXT));
1533  ScRange aRange;
1534  SCCOL nPosX = 0;
1535  SCROW nPosY = 0;
1536  if (GetViewData().GetSimpleArea(aRange) == SC_MARK_SIMPLE)
1537  {
1538  nPosX = aRange.aStart.Col();
1539  nPosY = aRange.aStart.Row();
1540  }
1541  else
1542  {
1543  nPosX = GetViewData().GetCurX();
1544  nPosY = GetViewData().GetCurY();
1545  }
1546  ScAddress aCellPos(nPosX, nPosY, GetViewData().GetTabNo());
1547  auto pObj = std::make_shared<ScImportExport>(GetViewData().GetDocument(), aCellPos);
1548  pObj->SetOverwriting(true);
1549  if (pDlg->Execute()) {
1550  ScAsciiOptions aOptions;
1551  pDlg->GetOptions(aOptions);
1552  pDlg->SaveParameters();
1553  pObj->SetExtOptions(aOptions);
1554  pObj->ImportString(sStrBuffer, format);
1555  }
1556  pDlg->disposeOnce();
1557  rReq.SetReturnValue(SfxInt16Item(nSlot, 1)); // 1 = success, 0 = fail
1558  rReq.Done();
1559  }
1560  }
1561  if (!bSuccess)
1562  {
1563  rReq.SetReturnValue(SfxInt16Item(nSlot, 0)); // 0 = fail
1564  rReq.Ignore();
1565  }
1566  }
1567  break;
1568  case SID_PASTE_SPECIAL:
1569  // differentiate between own cell data and draw objects/external data
1570  // this makes FID_INS_CELL_CONTENTS superfluous
1571  {
1572  vcl::Window* pWin = GetViewData().GetActiveWin();
1573  css::uno::Reference<css::datatransfer::XTransferable2> xTransferable(ScTabViewShell::GetClipData(pWin));
1574 
1575  // Clipboard-ID given as parameter? Basic "PasteSpecial(Format)"
1576  const SfxPoolItem* pItem=nullptr;
1577  if ( pReqArgs &&
1578  pReqArgs->GetItemState(nSlot, true, &pItem) == SfxItemState::SET &&
1579  dynamic_cast<const SfxUInt32Item*>( pItem) != nullptr )
1580  {
1581  SotClipboardFormatId nFormat = static_cast<SotClipboardFormatId>(static_cast<const SfxUInt32Item*>(pItem)->GetValue());
1582  bool bRet=true;
1583  {
1584  weld::WaitObject aWait( GetViewData().GetDialogParent() );
1585  bool bDraw = ( ScDrawTransferObj::GetOwnClipboard(xTransferable) != nullptr );
1586  if ( bDraw && nFormat == SotClipboardFormatId::EMBED_SOURCE )
1587  pTabViewShell->PasteDraw();
1588  else
1589  bRet = pTabViewShell->PasteFromSystem(nFormat, true); // TRUE: no error messages
1590  }
1591 
1592  if ( bRet )
1593  {
1594  rReq.SetReturnValue(SfxInt16Item(nSlot, 1)); // 1 = success, 0 = fail
1595  rReq.Done();
1596  }
1597  else
1598  // if format is not available -> fallback to request without parameters
1599  pItem = nullptr;
1600  }
1601 
1602  if ( !pItem )
1603  {
1604  if ( ScTransferObj::GetOwnClipboard(xTransferable) ) // own cell data
1605  {
1606  rReq.SetSlot( FID_INS_CELL_CONTENTS );
1607  ExecuteSlot( rReq, GetInterface() );
1608  rReq.SetReturnValue(SfxInt16Item(nSlot, 1)); // 1 = success
1609  }
1610  else // draw objects or external data
1611  {
1612  bool bDraw = ( ScDrawTransferObj::GetOwnClipboard(xTransferable) != nullptr );
1613 
1614  SvxClipboardFormatItem aFormats( SID_CLIPBOARD_FORMAT_ITEMS );
1615  GetPossibleClipboardFormats( aFormats );
1616 
1617  sal_uInt16 nFormatCount = aFormats.Count();
1618  if ( nFormatCount )
1619  {
1621  ScopedVclPtr<SfxAbstractPasteDialog> pDlg(pFact->CreatePasteDialog(pTabViewShell->GetFrameWeld()));
1622  for (sal_uInt16 i=0; i<nFormatCount; i++)
1623  {
1624  SotClipboardFormatId nFormatId = aFormats.GetClipbrdFormatId( i );
1625  OUString aName = aFormats.GetClipbrdFormatName( i );
1626  // special case for paste dialog: '*' is replaced by object type
1627  if ( nFormatId == SotClipboardFormatId::EMBED_SOURCE )
1628  aName = "*";
1629  pDlg->Insert( nFormatId, aName );
1630  }
1631 
1632  SfxViewFrame* pViewFrame = pTabViewShell->GetViewFrame();
1633  auto xFrame = pViewFrame->GetFrame().GetFrameInterface();
1634  const OUString aModuleName(vcl::CommandInfoProvider::GetModuleIdentifier(xFrame));
1635  auto aProperties = vcl::CommandInfoProvider::GetCommandProperties(".uno:PasteTextImportDialog", aModuleName);
1637  pDlg->InsertUno(".uno:PasteTextImportDialog", sLabel);
1638 
1639  TransferableDataHelper aDataHelper(
1641  SotClipboardFormatId nFormat = pDlg->GetFormat( aDataHelper.GetTransferable() );
1642  if (nFormat != SotClipboardFormatId::NONE)
1643  {
1644  {
1645  weld::WaitObject aWait( GetViewData().GetDialogParent() );
1646  if ( bDraw && nFormat == SotClipboardFormatId::EMBED_SOURCE )
1647  pTabViewShell->PasteDraw();
1648  else
1649  pTabViewShell->PasteFromSystem(nFormat);
1650  }
1651  rReq.SetReturnValue(SfxInt16Item(nSlot, 1)); // 1 = success
1652  rReq.AppendItem( SfxUInt32Item( nSlot, static_cast<sal_uInt32>(nFormat) ) );
1653  rReq.Done();
1654  }
1655  else
1656  {
1657  rReq.SetReturnValue(SfxInt16Item(nSlot, 0)); // 0 = fail
1658  rReq.Ignore();
1659  }
1660  }
1661  else
1662  rReq.SetReturnValue(SfxInt16Item(nSlot, 0)); // 0 = fail
1663  }
1664  }
1665  }
1666  pTabViewShell->CellContentChanged(); // => PasteFromSystem() ???
1667  break;
1668 
1669  case SID_PASTE_UNFORMATTED:
1670  // differentiate between own cell data and draw objects/external data
1671  // this makes FID_INS_CELL_CONTENTS superfluous
1672  {
1673  weld::WaitObject aWait( GetViewData().GetDialogParent() );
1674 
1675  // we should differentiate between SotClipboardFormatId::STRING and SotClipboardFormatId::STRING_TSVC,
1676  // and paste the SotClipboardFormatId::STRING_TSVC if it is available.
1677  // Which makes a difference if the clipboard contains cells with embedded line breaks.
1678 
1679  SotClipboardFormatId nFormat = HasClipboardFormat( SotClipboardFormatId::STRING_TSVC) ?
1680  SotClipboardFormatId::STRING_TSVC : SotClipboardFormatId::STRING;
1681 
1682  const bool bRet = pTabViewShell->PasteFromSystem(nFormat, true); // TRUE: no error messages
1683  if ( bRet )
1684  {
1685  rReq.SetReturnValue(SfxInt16Item(nSlot, 1)); // 1 = success
1686  rReq.Done();
1687  }
1688  else
1689  {
1690  rReq.SetReturnValue(SfxInt16Item(nSlot, 0)); // 0 = fail
1691  }
1692 
1693  pTabViewShell->CellContentChanged(); // => PasteFromSystem() ???
1694  }
1695  break;
1696 
1697  // other
1698 
1699  case FID_INS_ROWBRK:
1700  pTabViewShell->InsertPageBreak( false );
1701  rReq.Done();
1702  break;
1703 
1704  case FID_INS_COLBRK:
1705  pTabViewShell->InsertPageBreak( true );
1706  rReq.Done();
1707  break;
1708 
1709  case FID_DEL_ROWBRK:
1710  pTabViewShell->DeletePageBreak( false );
1711  rReq.Done();
1712  break;
1713 
1714  case FID_DEL_COLBRK:
1715  pTabViewShell->DeletePageBreak( true );
1716  rReq.Done();
1717  break;
1718 
1719  case SID_DETECTIVE_ADD_PRED:
1720  pTabViewShell->DetectiveAddPred();
1721  rReq.Done();
1722  break;
1723 
1724  case SID_DETECTIVE_DEL_PRED:
1725  pTabViewShell->DetectiveDelPred();
1726  rReq.Done();
1727  break;
1728 
1729  case SID_DETECTIVE_ADD_SUCC:
1730  pTabViewShell->DetectiveAddSucc();
1731  rReq.Done();
1732  break;
1733 
1734  case SID_DETECTIVE_DEL_SUCC:
1735  pTabViewShell->DetectiveDelSucc();
1736  rReq.Done();
1737  break;
1738 
1739  case SID_DETECTIVE_ADD_ERR:
1740  pTabViewShell->DetectiveAddError();
1741  rReq.Done();
1742  break;
1743 
1744  case SID_DETECTIVE_INVALID:
1745  pTabViewShell->DetectiveMarkInvalid();
1746  rReq.Done();
1747  break;
1748 
1749  case SID_DETECTIVE_REFRESH:
1750  pTabViewShell->DetectiveRefresh();
1751  rReq.Done();
1752  break;
1753 
1754  case SID_DETECTIVE_MARK_PRED:
1755  pTabViewShell->DetectiveMarkPred();
1756  break;
1757  case SID_DETECTIVE_MARK_SUCC:
1758  pTabViewShell->DetectiveMarkSucc();
1759  break;
1760  case SID_INSERT_CURRENT_DATE:
1761  pTabViewShell->InsertCurrentTime(
1762  SvNumFormatType::DATE, ScResId(STR_UNDO_INSERT_CURRENT_DATE));
1763  break;
1764  case SID_INSERT_CURRENT_TIME:
1765  pTabViewShell->InsertCurrentTime(
1766  SvNumFormatType::TIME, ScResId(STR_UNDO_INSERT_CURRENT_TIME));
1767  break;
1768 
1769  case SID_SPELL_DIALOG:
1770  {
1771  SfxViewFrame* pViewFrame = pTabViewShell->GetViewFrame();
1772  if( rReq.GetArgs() )
1773  pViewFrame->SetChildWindow( SID_SPELL_DIALOG,
1774  static_cast< const SfxBoolItem& >( rReq.GetArgs()->
1775  Get( SID_SPELL_DIALOG ) ).GetValue() );
1776  else
1777  pViewFrame->ToggleChildWindow( SID_SPELL_DIALOG );
1778 
1779  pViewFrame->GetBindings().Invalidate( SID_SPELL_DIALOG );
1780  rReq.Ignore();
1781  }
1782  break;
1783 
1784  case SID_HANGUL_HANJA_CONVERSION:
1785  pTabViewShell->DoHangulHanjaConversion();
1786  break;
1787 
1788  case SID_CHINESE_CONVERSION:
1789  {
1790  //open ChineseTranslationDialog
1792  ::cppu::defaultBootstrap_InitialComponentContext() ); //@todo get context from calc if that has one
1793  if(xContext.is())
1794  {
1795  Reference< lang::XMultiComponentFactory > xMCF( xContext->getServiceManager() );
1796  if(xMCF.is())
1797  {
1798  Reference< ui::dialogs::XExecutableDialog > xDialog(
1799  xMCF->createInstanceWithContext(
1800  "com.sun.star.linguistic2.ChineseTranslationDialog"
1801  , xContext),
1802  UNO_QUERY);
1803  Reference< lang::XInitialization > xInit( xDialog, UNO_QUERY );
1804  if( xInit.is() )
1805  {
1806  // initialize dialog
1807  uno::Sequence<uno::Any> aSeq(comphelper::InitAnyPropertySequence(
1808  {
1809  {"ParentWindow", uno::Any(Reference< awt::XWindow >())}
1810  }));
1811  xInit->initialize( aSeq );
1812 
1813  //execute dialog
1814  sal_Int16 nDialogRet = xDialog->execute();
1815  if( RET_OK == nDialogRet )
1816  {
1817  //get some parameters from the dialog
1818  bool bToSimplified = true;
1819  bool bUseVariants = true;
1820  bool bCommonTerms = true;
1821  Reference< beans::XPropertySet > xProp( xDialog, UNO_QUERY );
1822  if( xProp.is() )
1823  {
1824  try
1825  {
1826  xProp->getPropertyValue("IsDirectionToSimplified") >>= bToSimplified;
1827  xProp->getPropertyValue("IsUseCharacterVariants") >>= bUseVariants;
1828  xProp->getPropertyValue("IsTranslateCommonTerms") >>= bCommonTerms;
1829  }
1830  catch( Exception& )
1831  {
1832  }
1833  }
1834 
1835  //execute translation
1838  sal_Int32 nOptions = bUseVariants ? i18n::TextConversionOption::USE_CHARACTER_VARIANTS : 0;
1839  if( !bCommonTerms )
1840  nOptions |= i18n::TextConversionOption::CHARACTER_BY_CHARACTER;
1841 
1843  DefaultFontType::CJK_SPREADSHEET,
1844  eTargetLang, GetDefaultFontFlags::OnlyOne );
1846  eSourceLang, eTargetLang, aTargetFont, nOptions, false );
1847  pTabViewShell->DoSheetConversion( aConvParam );
1848  }
1849  }
1850  Reference< lang::XComponent > xComponent( xDialog, UNO_QUERY );
1851  if( xComponent.is() )
1852  xComponent->dispose();
1853  }
1854  }
1855  }
1856  break;
1857 
1858  case SID_CONVERT_FORMULA_TO_VALUE:
1859  {
1860  pTabViewShell->ConvertFormulaToValue();
1861  }
1862  break;
1863  case SID_THESAURUS:
1864  pTabViewShell->DoThesaurus();
1865  break;
1866 
1867  case SID_TOGGLE_REL:
1868  pTabViewShell->DoRefConversion();
1869  break;
1870 
1871  case SID_DEC_INDENT:
1872  pTabViewShell->ChangeIndent( false );
1873  break;
1874  case SID_INC_INDENT:
1875  pTabViewShell->ChangeIndent( true );
1876  break;
1877 
1878  case FID_USE_NAME:
1879  {
1880  CreateNameFlags nFlags = pTabViewShell->GetCreateNameFlags();
1881 
1883 
1884  ScopedVclPtr<AbstractScNameCreateDlg> pDlg(pFact->CreateScNameCreateDlg(pTabViewShell->GetFrameWeld(), nFlags));
1885 
1886  if( pDlg->Execute() )
1887  {
1888  pTabViewShell->CreateNames(pDlg->GetFlags());
1889  rReq.Done();
1890  }
1891  }
1892  break;
1893 
1894  case SID_CONSOLIDATE:
1895  {
1896  const SfxPoolItem* pItem;
1897  if ( pReqArgs && SfxItemState::SET ==
1898  pReqArgs->GetItemState( SCITEM_CONSOLIDATEDATA, true, &pItem ) )
1899  {
1900  const ScConsolidateParam& rParam =
1901  static_cast<const ScConsolidateItem*>(pItem)->GetData();
1902 
1903  pTabViewShell->Consolidate( rParam );
1904  GetViewData().GetDocument().SetConsolidateDlgData( std::unique_ptr<ScConsolidateParam>(new ScConsolidateParam(rParam)) );
1905 
1906  rReq.Done();
1907  }
1908 #if HAVE_FEATURE_SCRIPTING
1909  else if (rReq.IsAPI())
1911 #endif
1912  }
1913  break;
1914 
1915  case SID_INS_FUNCTION:
1916  {
1917  const SfxBoolItem* pOkItem = static_cast<const SfxBoolItem*>(&pReqArgs->Get( SID_DLG_RETOK ));
1918 
1919  if ( pOkItem->GetValue() ) // OK
1920  {
1921  OUString aFormula;
1922  const SfxStringItem* pSItem = static_cast<const SfxStringItem*>(&pReqArgs->Get( SCITEM_STRING ));
1923  const SfxBoolItem* pMatrixItem = static_cast<const SfxBoolItem*>(&pReqArgs->Get( SID_DLG_MATRIX ));
1924 
1925  aFormula += pSItem->GetValue();
1926  pScMod->ActivateInputWindow( &aFormula, pMatrixItem->GetValue() );
1927  }
1928  else // CANCEL
1929  {
1930  pScMod->ActivateInputWindow();
1931  }
1932  rReq.Ignore(); // only SID_ENTER_STRING is recorded
1933  }
1934  break;
1935 
1936  case FID_DEFINE_NAME:
1937  case FID_DEFINE_CURRENT_NAME:
1938  if ( pReqArgs )
1939  {
1940  const SfxPoolItem* pItem;
1941  OUString aName, aSymbol, aAttrib;
1942 
1943  if( pReqArgs->HasItem( FID_DEFINE_NAME, &pItem ) )
1944  aName = static_cast<const SfxStringItem*>(pItem)->GetValue();
1945 
1946  if( pReqArgs->HasItem( FN_PARAM_1, &pItem ) )
1947  aSymbol = static_cast<const SfxStringItem*>(pItem)->GetValue();
1948 
1949  if( pReqArgs->HasItem( FN_PARAM_2, &pItem ) )
1950  aAttrib = static_cast<const SfxStringItem*>(pItem)->GetValue();
1951 
1952  if ( !aName.isEmpty() && !aSymbol.isEmpty() )
1953  {
1954  if (pTabViewShell->InsertName( aName, aSymbol, aAttrib ))
1955  rReq.Done();
1956 #if HAVE_FEATURE_SCRIPTING
1957  else
1959 #endif
1960  }
1961  }
1962  else
1963  {
1964  sal_uInt16 nId = ScNameDlgWrapper::GetChildWindowId();
1965  SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
1966  SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
1967 
1968  pScMod->SetRefDialog( nId, pWnd == nullptr );
1969  }
1970  break;
1971  case FID_ADD_NAME:
1972  {
1973  sal_uInt16 nId = ScNameDefDlgWrapper::GetChildWindowId();
1974  SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
1975  SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
1976 
1977  pScMod->SetRefDialog( nId, pWnd == nullptr );
1978  }
1979  break;
1980 
1981  case SID_OPENDLG_CONDFRMT:
1982  case SID_OPENDLG_CURRENTCONDFRMT:
1983  case SID_OPENDLG_COLORSCALE:
1984  case SID_OPENDLG_DATABAR:
1985  case SID_OPENDLG_ICONSET:
1986  case SID_OPENDLG_CONDDATE:
1987  {
1988  sal_uInt32 nIndex = sal_uInt32(-1);
1989  bool bManaged = false;
1990 
1991  // Get the pool item stored by Conditional Format Manager Dialog.
1992  auto itemsRange = pTabViewShell->GetPool().GetItemSurrogates(SCITEM_CONDFORMATDLGDATA);
1993  if (itemsRange.begin() != itemsRange.end())
1994  {
1995  const ScCondFormatDlgItem* pDlgItem = static_cast<const ScCondFormatDlgItem*>(*itemsRange.begin());
1996  nIndex = pDlgItem->GetIndex();
1997  bManaged = true;
1998  }
1999 
2000  // Check if the Conditional Manager Dialog is editing or adding
2001  // conditional format item.
2002  if ( bManaged )
2003  {
2004  sal_uInt16 nId = ScCondFormatDlgWrapper::GetChildWindowId();
2005  SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
2006  SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
2007 
2008  pScMod->SetRefDialog( nId, pWnd == nullptr );
2009  break;
2010  }
2011 
2012  ScRangeList aRangeList;
2014  rData.GetMarkData().FillRangeListWithMarks(&aRangeList, false);
2015 
2016  ScDocument& rDoc = GetViewData().GetDocument();
2017  if(rDoc.IsTabProtected(rData.GetTabNo()))
2018  {
2019  pTabViewShell->ErrorMessage( STR_ERR_CONDFORMAT_PROTECTED );
2020  break;
2021  }
2022 
2023  ScAddress aPos(rData.GetCurX(), rData.GetCurY(), rData.GetTabNo());
2024  if(aRangeList.empty())
2025  {
2026  aRangeList.push_back(ScRange(aPos));
2027  }
2028 
2029  // try to find an existing conditional format
2030  const ScConditionalFormat* pCondFormat = nullptr;
2031  const ScPatternAttr* pPattern = rDoc.GetPattern(aPos.Col(), aPos.Row(), aPos.Tab());
2032  ScConditionalFormatList* pList = rDoc.GetCondFormList(aPos.Tab());
2033  const ScCondFormatIndexes& rCondFormats = pPattern->GetItem(ATTR_CONDITIONAL).GetCondFormatData();
2034  bool bContainsCondFormat = !rCondFormats.empty();
2035  bool bCondFormatDlg = false;
2036  bool bContainsExistingCondFormat = false;
2037  if(bContainsCondFormat)
2038  {
2039  for (const auto& rCondFormat : rCondFormats)
2040  {
2041  // check if at least one existing conditional format has the same range
2042  pCondFormat = pList->GetFormat(rCondFormat);
2043  if(!pCondFormat)
2044  continue;
2045 
2046  bContainsExistingCondFormat = true;
2047  const ScRangeList& rCondFormatRange = pCondFormat->GetRange();
2048  if(rCondFormatRange == aRangeList)
2049  {
2050  // found a matching range, edit this conditional format
2051  bCondFormatDlg = true;
2052  nIndex = pCondFormat->GetKey();
2053  break;
2054  }
2055  }
2056  }
2057 
2058  // do we have a parameter with the conditional formatting type?
2059  const SfxInt16Item* pParam = rReq.GetArg<SfxInt16Item>(FN_PARAM_1);
2060  if (pParam && nSlot == SID_OPENDLG_ICONSET)
2061  {
2062  auto pFormat = std::make_unique<ScConditionalFormat>(0, &rDoc);
2063  pFormat->SetRange(aRangeList);
2064 
2066  const int nSteps = ScIconSetFormat::getIconSetElements(eIconSetType);
2067 
2068  ScIconSetFormat* pEntry = new ScIconSetFormat(&rDoc);
2069  ScIconSetFormatData* pIconSetFormatData = new ScIconSetFormatData(eIconSetType);
2070 
2071  pIconSetFormatData->m_Entries.emplace_back(new ScColorScaleEntry(0, COL_RED, COLORSCALE_PERCENT));
2072  pIconSetFormatData->m_Entries.emplace_back(new ScColorScaleEntry(round(100. / nSteps), COL_BROWN, COLORSCALE_PERCENT));
2073  pIconSetFormatData->m_Entries.emplace_back(new ScColorScaleEntry(round(200. / nSteps), COL_YELLOW, COLORSCALE_PERCENT));
2074  if (nSteps > 3)
2075  pIconSetFormatData->m_Entries.emplace_back(new ScColorScaleEntry(round(300. / nSteps), COL_WHITE, COLORSCALE_PERCENT));
2076  if (nSteps > 4)
2077  pIconSetFormatData->m_Entries.emplace_back(new ScColorScaleEntry(round(400. / nSteps), COL_GREEN, COLORSCALE_PERCENT));
2078 
2079  pEntry->SetIconSetData(pIconSetFormatData);
2080  pFormat->AddEntry(pEntry);
2081 
2082  // use the new conditional formatting
2083  GetViewData().GetDocShell()->GetDocFunc().ReplaceConditionalFormat(nIndex, std::move(pFormat), aPos.Tab(), aRangeList);
2084 
2085  break;
2086  }
2087 
2088  // if not found a conditional format ask whether we should edit one of the existing
2089  // or should create a new overlapping conditional format
2090  if(bContainsCondFormat && !bCondFormatDlg && bContainsExistingCondFormat)
2091  {
2092  std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(pTabViewShell->GetFrameWeld(),
2093  VclMessageType::Question, VclButtonsType::YesNo,
2094  ScResId(STR_EDIT_EXISTING_COND_FORMATS)));
2095  xQueryBox->set_default_response(RET_YES);
2096  bool bEditExisting = xQueryBox->run() == RET_YES;
2097  if (bEditExisting)
2098  {
2099  // differentiate between ranges where one conditional format is defined
2100  // and several formats are defined
2101  // if we have only one => open the cond format dlg to edit it
2102  // otherwise open the manage cond format dlg
2103  if (rCondFormats.size() == 1)
2104  {
2105  pCondFormat = pList->GetFormat(rCondFormats[0]);
2106  assert(pCondFormat);
2107  bCondFormatDlg = true;
2108  }
2109  else
2110  {
2111  // Queue message to open Conditional Format Manager Dialog.
2112  GetViewData().GetDispatcher().Execute( SID_OPENDLG_CONDFRMT_MANAGER, SfxCallMode::ASYNCHRON );
2113  break;
2114  }
2115  }
2116  else
2117  {
2118  // define an overlapping conditional format
2119  // does not need to be handled here
2120  }
2121  }
2122 
2124  switch(nSlot)
2125  {
2126  case SID_OPENDLG_CONDFRMT:
2127  case SID_OPENDLG_CURRENTCONDFRMT:
2129  break;
2130  case SID_OPENDLG_COLORSCALE:
2132  break;
2133  case SID_OPENDLG_DATABAR:
2135  break;
2136  case SID_OPENDLG_ICONSET:
2138  break;
2139  case SID_OPENDLG_CONDDATE:
2140  eType = condformat::dialog::DATE;
2141  break;
2142  default:
2143  assert(false);
2144  break;
2145  }
2146 
2147 
2148  if(bCondFormatDlg || !bContainsCondFormat)
2149  {
2150  // Put the xml string parameter to initialize the
2151  // Conditional Format Dialog.
2152  ScCondFormatDlgItem aDlgItem(nullptr, nIndex, false);
2153  aDlgItem.SetDialogType(eType);
2154  pTabViewShell->GetPool().Put(aDlgItem);
2155 
2156  sal_uInt16 nId = ScCondFormatDlgWrapper::GetChildWindowId();
2157  SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
2158  SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
2159 
2160  pScMod->SetRefDialog( nId, pWnd == nullptr );
2161  }
2162  }
2163  break;
2164 
2165  case SID_DEFINE_COLROWNAMERANGES:
2166  {
2167 
2168  sal_uInt16 nId = ScColRowNameRangesDlgWrapper::GetChildWindowId();
2169  SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
2170  SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
2171 
2172  pScMod->SetRefDialog( nId, pWnd == nullptr );
2173 
2174  }
2175  break;
2176 
2177  case SID_UPDATECHART:
2178  {
2179  bool bAll = false;
2180 
2181  if( pReqArgs )
2182  {
2183  const SfxPoolItem* pItem;
2184 
2185  if( pReqArgs->HasItem( SID_UPDATECHART, &pItem ) )
2186  bAll = static_cast<const SfxBoolItem*>(pItem)->GetValue();
2187  }
2188 
2189  pTabViewShell->UpdateCharts( bAll );
2190 
2191  if( ! rReq.IsAPI() )
2192  {
2193  rReq.AppendItem( SfxBoolItem( SID_UPDATECHART, bAll ) );
2194  rReq.Done();
2195  }
2196  }
2197  break;
2198 
2199  case SID_TABOP:
2200  if (pReqArgs)
2201  {
2202  const ScTabOpItem& rItem =
2203  static_cast<const ScTabOpItem&>(
2204  pReqArgs->Get( SID_TABOP ));
2205 
2206  pTabViewShell->TabOp( rItem.GetData() );
2207 
2208  rReq.Done( *pReqArgs );
2209  }
2210  break;
2211 
2212  case SID_SOLVE:
2213  if (pReqArgs)
2214  {
2215  const ScSolveItem& rItem =
2216  static_cast<const ScSolveItem&>(
2217  pReqArgs->Get( SCITEM_SOLVEDATA ));
2218 
2219  pTabViewShell->Solve( rItem.GetData() );
2220 
2221  rReq.Done( *pReqArgs );
2222  }
2223  break;
2224 
2225  case FID_INSERT_NAME:
2226  {
2228 
2230  switch( pDlg->Execute() )
2231  {
2232  case BTN_PASTE_LIST:
2233  pTabViewShell->InsertNameList();
2234  break;
2235  case BTN_PASTE_NAME:
2236  {
2237  ScInputHandler* pHdl = pScMod->GetInputHdl( pTabViewShell );
2238  if (pHdl)
2239  {
2240  // "=" in KeyEvent, switches to input-mode
2241  (void)pScMod->InputKeyEvent( KeyEvent('=', vcl::KeyCode()) );
2242 
2243  std::vector<OUString> aNames = pDlg->GetSelectedNames();
2244  if (!aNames.empty())
2245  {
2246  OUStringBuffer aBuffer;
2247  for (const auto& rName : aNames)
2248  {
2249  aBuffer.append(rName).append(' ');
2250  }
2251  pHdl->InsertFunction( aBuffer.makeStringAndClear(), false ); // without "()"
2252  }
2253  }
2254  }
2255  break;
2256  }
2257  }
2258  break;
2259 
2260  case SID_RANGE_NOTETEXT:
2261  if (pReqArgs)
2262  {
2263  const SfxStringItem& rTextItem = static_cast<const SfxStringItem&>(pReqArgs->Get( SID_RANGE_NOTETEXT ));
2264 
2265  // always cursor position
2266  ScAddress aPos( GetViewData().GetCurX(), GetViewData().GetCurY(), GetViewData().GetTabNo() );
2267  pTabViewShell->SetNoteText( aPos, rTextItem.GetValue() );
2268  rReq.Done();
2269  }
2270  break;
2271 
2272  case SID_INSERT_POSTIT:
2273  case SID_EDIT_POSTIT:
2274  {
2275  const SfxPoolItem* pText;
2276  if ( pReqArgs && pReqArgs->HasItem( SID_ATTR_POSTIT_TEXT, &pText) )
2277  {
2278  const SfxPoolItem* pCellId;
2279  OUString aCellId;
2280  // SID_ATTR_POSTIT_ID only argument for SID_EDIT_POSTIT
2281  if (pReqArgs->HasItem( SID_ATTR_POSTIT_ID, &pCellId ))
2282  aCellId = static_cast<const SvxPostItIdItem*>(pCellId)->GetValue();
2283 
2284  const SvxPostItTextItem* pTextItem = static_cast<const SvxPostItTextItem*>( pText );
2285  const SvxPostItAuthorItem* pAuthorItem = pReqArgs->GetItem( SID_ATTR_POSTIT_AUTHOR );
2286  const SvxPostItDateItem* pDateItem = pReqArgs->GetItem( SID_ATTR_POSTIT_DATE );
2287 
2288  if (!aCellId.isEmpty())
2289  {
2290  SetTabNoAndCursor( GetViewData(), aCellId );
2291  }
2292 
2293  ScAddress aPos( GetViewData().GetCurX(), GetViewData().GetCurY(), GetViewData().GetTabNo() );
2294  pTabViewShell->ReplaceNote( aPos, pTextItem->GetValue(),
2295  pAuthorItem ? &pAuthorItem->GetValue() : nullptr,
2296  pDateItem ? &pDateItem->GetValue() : nullptr );
2297  }
2299  {
2300  pTabViewShell->EditNote(); // note object to edit
2301  }
2302  rReq.Done();
2303  }
2304  break;
2305 
2306  case FID_NOTE_VISIBLE:
2307  {
2308  ScDocument& rDoc = GetViewData().GetDocument();
2309  ScAddress aPos( GetViewData().GetCurX(), GetViewData().GetCurY(), GetViewData().GetTabNo() );
2310  if( ScPostIt* pNote = rDoc.GetNote(aPos) )
2311  {
2312  bool bShow;
2313  const SfxPoolItem* pItem;
2314  if ( pReqArgs && (pReqArgs->GetItemState( FID_NOTE_VISIBLE, true, &pItem ) == SfxItemState::SET) )
2315  bShow = static_cast<const SfxBoolItem*>(pItem)->GetValue();
2316  else
2317  bShow = !pNote->IsCaptionShown();
2318 
2319  pTabViewShell->ShowNote( bShow );
2320 
2321  if (!pReqArgs)
2322  rReq.AppendItem( SfxBoolItem( FID_NOTE_VISIBLE, bShow ) );
2323 
2324  rReq.Done();
2325  rBindings.Invalidate( FID_NOTE_VISIBLE );
2326  }
2327  else
2328  rReq.Ignore();
2329  }
2330  break;
2331 
2332  case FID_HIDE_NOTE:
2333  case FID_SHOW_NOTE:
2334  {
2335  bool bShowNote = nSlot == FID_SHOW_NOTE;
2337  ScDocument& rDoc = rData.GetDocument();
2338  ScMarkData& rMark = rData.GetMarkData();
2339 
2340  if (!rMark.IsMarked() && !rMark.IsMultiMarked())
2341  {
2342  // Check current cell
2343  ScAddress aPos( rData.GetCurX(), rData.GetCurY(), rData.GetTabNo() );
2344  if( rDoc.GetNote(aPos) )
2345  {
2346  rData.GetDocShell()->GetDocFunc().ShowNote( aPos, bShowNote );
2347  }
2348  }
2349  else
2350  {
2351  // Check selection range
2352  bool bDone = false;
2353  ScRangeListRef aRangesRef;
2354  rData.GetMultiArea(aRangesRef);
2355  const ScRangeList aRanges = *aRangesRef;
2356 
2357  OUString aUndo = ScResId( bShowNote ? STR_UNDO_SHOWNOTE : STR_UNDO_HIDENOTE );
2358  rData.GetDocShell()->GetUndoManager()->EnterListAction( aUndo, aUndo, 0, rData.GetViewShell()->GetViewShellId() );
2359 
2360  for (auto const& rTab : rMark.GetSelectedTabs())
2361  {
2362  // get notes
2363  std::vector<sc::NoteEntry> aNotes;
2364  rDoc.GetAllNoteEntries(rTab, aNotes);
2365 
2366  for (const sc::NoteEntry& rNote : aNotes)
2367  {
2368  // check if note is in our selection range
2369  const ScAddress& rAdr = rNote.maPos;
2370  const ScRange* rRange = aRanges.Find(rAdr);
2371  if (! rRange)
2372  continue;
2373 
2374  // check if cell is editable
2375  const SCTAB nRangeTab = rRange->aStart.Tab();
2376  if (rDoc.IsBlockEditable( nRangeTab, rAdr.Col(), rAdr.Row(), rAdr.Col(), rAdr.Row() ))
2377  {
2378  rData.GetDocShell()->GetDocFunc().ShowNote( rAdr, bShowNote );
2379  bDone = true;
2380  }
2381  }
2382  }
2383 
2385 
2386  if ( bDone )
2387  {
2388  rReq.Done();
2389  rBindings.Invalidate( nSlot );
2390  }
2391  else
2392  rReq.Ignore();
2393  }
2394 
2395  }
2396  break;
2397 
2398  case FID_SHOW_ALL_NOTES:
2399  case FID_HIDE_ALL_NOTES:
2400  {
2401  bool bShowNote = nSlot == FID_SHOW_ALL_NOTES;
2403  ScMarkData& rMark = rData.GetMarkData();
2404  ScDocument& rDoc = rData.GetDocument();
2405  std::vector<sc::NoteEntry> aNotes;
2406 
2407  OUString aUndo = ScResId( bShowNote ? STR_UNDO_SHOWALLNOTES : STR_UNDO_HIDEALLNOTES );
2408  rData.GetDocShell()->GetUndoManager()->EnterListAction( aUndo, aUndo, 0, rData.GetViewShell()->GetViewShellId() );
2409 
2410  for (auto const& rTab : rMark.GetSelectedTabs())
2411  {
2412  rDoc.GetAllNoteEntries(rTab, aNotes);
2413  }
2414 
2415  for (const sc::NoteEntry& rNote : aNotes)
2416  {
2417  const ScAddress& rAdr = rNote.maPos;
2418  rData.GetDocShell()->GetDocFunc().ShowNote( rAdr, bShowNote );
2419  }
2420 
2422  }
2423  break;
2424 
2425  case SID_TOGGLE_NOTES:
2426  {
2428  ScMarkData& rMark = rData.GetMarkData();
2429  ScDocument& rDoc = rData.GetDocument();
2430  ScRangeList aRanges;
2431  std::vector<sc::NoteEntry> aNotes;
2432 
2433  for (auto const& rTab : rMark.GetSelectedTabs())
2434  aRanges.push_back(ScRange(0,0,rTab,rDoc.MaxCol(),rDoc.MaxRow(),rTab));
2435 
2436  CommentCaptionState eState = rDoc.GetAllNoteCaptionsState( aRanges );
2437  rDoc.GetNotesInRange(aRanges, aNotes);
2438  bool bShowNote = (eState == ALLHIDDEN || eState == MIXED);
2439 
2440  OUString aUndo = ScResId( bShowNote ? STR_UNDO_SHOWALLNOTES : STR_UNDO_HIDEALLNOTES );
2441  rData.GetDocShell()->GetUndoManager()->EnterListAction( aUndo, aUndo, 0, rData.GetViewShell()->GetViewShellId() );
2442 
2443  for(const auto& rNote : aNotes)
2444  {
2445  const ScAddress& rAdr = rNote.maPos;
2446  rData.GetDocShell()->GetDocFunc().ShowNote( rAdr, bShowNote );
2447  }
2448 
2450 
2451  if (!pReqArgs)
2452  rReq.AppendItem( SfxBoolItem( SID_TOGGLE_NOTES, bShowNote ) );
2453 
2454  rReq.Done();
2455  rBindings.Invalidate( SID_TOGGLE_NOTES );
2456  }
2457  break;
2458 
2459  case SID_DELETE_NOTE:
2460  {
2461  const SfxPoolItem* pId;
2462  // If Id is mentioned, select the appropriate cell first
2463  if ( pReqArgs && pReqArgs->HasItem( SID_ATTR_POSTIT_ID, &pId) )
2464  {
2465  const SvxPostItIdItem* pIdItem = static_cast<const SvxPostItIdItem*>(pId);
2466  const OUString& aCellId = pIdItem->GetValue();
2467  if (!aCellId.isEmpty())
2468  {
2469  SetTabNoAndCursor( GetViewData(), aCellId );
2470  }
2471  }
2472 
2473  pTabViewShell->DeleteContents( InsertDeleteFlags::NOTE ); // delete all notes in selection
2474  rReq.Done();
2475  }
2476  break;
2477 
2478  case FID_DELETE_ALL_NOTES:
2479  {
2481  ScMarkData& rMark = rData.GetMarkData();
2482  ScDocument& rDoc = rData.GetDocument();
2483  ScMarkData aNewMark(rDoc.GetSheetLimits());
2484  ScRangeList aRangeList;
2485 
2486  for (auto const& rTab : rMark.GetSelectedTabs())
2487  {
2488  aRangeList.push_back(ScRange(0,0,rTab,rDoc.MaxCol(),rDoc.MaxRow(),rTab));
2489  }
2490 
2491  aNewMark.MarkFromRangeList( aRangeList, true );
2492  rData.GetDocShell()->GetDocFunc().DeleteContents(aNewMark, InsertDeleteFlags::NOTE, true, false );
2493  }
2494  break;
2495 
2496  case SID_CHARMAP:
2497  if( pReqArgs != nullptr )
2498  {
2499  OUString aChars, aFontName;
2500  const SfxItemSet *pArgs = rReq.GetArgs();
2501  const SfxPoolItem* pItem = nullptr;
2502  if ( pArgs )
2503  pArgs->GetItemState(GetPool().GetWhich(SID_CHARMAP), false, &pItem);
2504  if ( pItem )
2505  {
2506  const SfxStringItem* pStringItem = dynamic_cast<const SfxStringItem*>( pItem );
2507  if ( pStringItem )
2508  aChars = pStringItem->GetValue();
2509  const SfxPoolItem* pFtItem = nullptr;
2510  pArgs->GetItemState( GetPool().GetWhich(SID_ATTR_SPECIALCHAR), false, &pFtItem);
2511  const SfxStringItem* pFontItem = dynamic_cast<const SfxStringItem*>( pFtItem );
2512  if ( pFontItem )
2513  aFontName = pFontItem->GetValue();
2514  }
2515 
2516  if ( !aChars.isEmpty() )
2517  {
2518  vcl::Font aFont;
2519  pTabViewShell->GetSelectionPattern()->GetFont( aFont, SC_AUTOCOL_BLACK, nullptr, nullptr, nullptr,
2520  pTabViewShell->GetSelectionScriptType() );
2521  if ( !aFontName.isEmpty() )
2522  aFont = vcl::Font( aFontName, Size(1,1) );
2523  pTabViewShell->InsertSpecialChar( aChars, aFont );
2524  if( ! rReq.IsAPI() )
2525  rReq.Done();
2526  }
2527  }
2528  else
2529  {
2531 
2532  // font color doesn't matter here
2533  vcl::Font aCurFont;
2534  pTabViewShell->GetSelectionPattern()->GetFont( aCurFont, SC_AUTOCOL_BLACK, nullptr, nullptr, nullptr,
2535  pTabViewShell->GetSelectionScriptType() );
2536 
2537  SfxAllItemSet aSet( GetPool() );
2538  aSet.Put( SfxBoolItem( FN_PARAM_1, false ) );
2539  aSet.Put( SvxFontItem( aCurFont.GetFamilyType(), aCurFont.GetFamilyName(), aCurFont.GetStyleName(), aCurFont.GetPitch(), aCurFont.GetCharSet(), GetPool().GetWhich(SID_ATTR_CHAR_FONT) ) );
2540  SfxViewFrame* pViewFrame = pTabViewShell->GetViewFrame();
2541  auto xFrame = pViewFrame->GetFrame().GetFrameInterface();
2542  ScopedVclPtr<SfxAbstractDialog> pDlg(pFact->CreateCharMapDialog(pTabViewShell->GetFrameWeld(), aSet, xFrame));
2543  pDlg->Execute();
2544  }
2545  break;
2546 
2547  case SID_SELECT_SCENARIO:
2548  {
2549  // Testing
2550 
2551  if ( pReqArgs )
2552  {
2553  const SfxStringItem& rItem
2554  = static_cast<const SfxStringItem&>(pReqArgs->Get(SID_SELECT_SCENARIO));
2555  pTabViewShell->UseScenario(rItem.GetValue());
2557  rReq.SetReturnValue(SfxStringItem(SID_SELECT_SCENARIO, rItem.GetValue()));
2558  rReq.Done();
2559  }
2560  }
2561  break;
2562 
2563  case SID_HYPERLINK_SETLINK:
2564  if( pReqArgs )
2565  {
2566  const SfxPoolItem* pItem;
2567  if( pReqArgs->HasItem( SID_HYPERLINK_SETLINK, &pItem ) )
2568  {
2569  const SvxHyperlinkItem* pHyper = static_cast<const SvxHyperlinkItem*>(pItem);
2570  const OUString& rName = pHyper->GetName();
2571  const OUString& rURL = pHyper->GetURL();
2572  const OUString& rTarget = pHyper->GetTargetFrame();
2573  sal_uInt16 nType = static_cast<sal_uInt16>(pHyper->GetInsertMode());
2574 
2575  pTabViewShell->InsertURL( rName, rURL, rTarget, nType );
2576  rReq.Done();
2577  }
2578  else
2579  rReq.Ignore();
2580  }
2581  break;
2582 
2583  case SID_OPENDLG_CONDFRMT_MANAGER:
2584  case SID_OPENDLG_CURRENTCONDFRMT_MANAGER:
2585  {
2587 
2589  ScDocument& rDoc = rData.GetDocument();
2590 
2591  if (rDoc.IsTabProtected(rData.GetTabNo()))
2592  {
2593  pTabViewShell->ErrorMessage( STR_ERR_CONDFORMAT_PROTECTED );
2594  break;
2595  }
2596 
2597  ScAddress aPos(rData.GetCurX(), rData.GetCurY(), rData.GetTabNo());
2598 
2599  ScConditionalFormatList* pList = nullptr;
2600 
2601  const ScCondFormatDlgItem* pDlgItem = nullptr;
2602  auto itemsRange = pTabViewShell->GetPool().GetItemSurrogates(SCITEM_CONDFORMATDLGDATA);
2603  if (itemsRange.begin() != itemsRange.end())
2604  {
2605  pDlgItem= static_cast<const ScCondFormatDlgItem*>(*itemsRange.begin());
2606  pList = const_cast<ScCondFormatDlgItem*>(pDlgItem)->GetConditionalFormatList();
2607  }
2608 
2609  if (!pList)
2610  pList = rDoc.GetCondFormList( aPos.Tab() );
2611 
2613  pTabViewShell->GetFrameWeld(), rDoc, pList));
2614 
2615  if (pDlgItem)
2616  pDlg->SetModified();
2617 
2618  pDlg->StartExecuteAsync([this, pDlg, &rData, pTabViewShell, pDlgItem, aPos](sal_Int32 nRet){
2619  std::unique_ptr<ScConditionalFormatList> pCondFormatList = pDlg->GetConditionalFormatList();
2620  if(nRet == RET_OK && pDlg->CondFormatsChanged())
2621  {
2622  rData.GetDocShell()->GetDocFunc().SetConditionalFormatList(pCondFormatList.release(), aPos.Tab());
2623  }
2624  else if(nRet == DLG_RET_ADD)
2625  {
2626  // Put the xml string parameter to initialize the
2627  // Conditional Format Dialog. ( add new )
2628  pTabViewShell->GetPool().Put(ScCondFormatDlgItem(
2629  std::shared_ptr<ScConditionalFormatList>(pCondFormatList.release()), -1, true));
2630  // Queue message to open Conditional Format Dialog
2631  GetViewData().GetDispatcher().Execute( SID_OPENDLG_CONDFRMT, SfxCallMode::ASYNCHRON );
2632  }
2633  else if (nRet == DLG_RET_EDIT)
2634  {
2635  ScConditionalFormat* pFormat = pDlg->GetCondFormatSelected();
2636  sal_Int32 nIndex = pFormat ? pFormat->GetKey() : -1;
2637  // Put the xml string parameter to initialize the
2638  // Conditional Format Dialog. ( edit selected conditional format )
2639  pTabViewShell->GetPool().Put(ScCondFormatDlgItem(
2640  std::shared_ptr<ScConditionalFormatList>(pCondFormatList.release()), nIndex, true));
2641 
2642  // Queue message to open Conditional Format Dialog
2643  GetViewData().GetDispatcher().Execute( SID_OPENDLG_CONDFRMT, SfxCallMode::ASYNCHRON );
2644  }
2645  else
2646  pCondFormatList.reset();
2647 
2648  if (pDlgItem)
2649  pTabViewShell->GetPool().Remove(*pDlgItem);
2650 
2651  pDlg->disposeOnce();
2652  });
2653  }
2654  break;
2655 
2656  case SID_EXTERNAL_SOURCE:
2657  {
2658  const SfxStringItem* pFile = rReq.GetArg<SfxStringItem>(SID_FILE_NAME);
2659  const SfxStringItem* pSource = rReq.GetArg<SfxStringItem>(FN_PARAM_1);
2660  if ( pFile && pSource )
2661  {
2662  OUString aFile;
2663  OUString aFilter;
2664  OUString aOptions;
2665  OUString aSource;
2666  sal_uLong nRefresh=0;
2667 
2668  aFile = pFile->GetValue();
2669  aSource = pSource->GetValue();
2670  const SfxStringItem* pFilter = rReq.GetArg<SfxStringItem>(SID_FILTER_NAME);
2671  if ( pFilter )
2672  aFilter = pFilter->GetValue();
2673  const SfxStringItem* pOptions = rReq.GetArg<SfxStringItem>(SID_FILE_FILTEROPTIONS);
2674  if ( pOptions )
2675  aOptions = pOptions->GetValue();
2676  const SfxUInt32Item* pRefresh = rReq.GetArg<SfxUInt32Item>(FN_PARAM_2);
2677  if ( pRefresh )
2678  nRefresh = pRefresh->GetValue();
2679 
2680  ExecuteExternalSource( aFile, aFilter, aOptions, aSource, nRefresh, rReq );
2681  }
2682  else
2683  {
2685 
2686  pImpl->m_pLinkedDlg.disposeAndClear();
2687  pImpl->m_pLinkedDlg =
2688  pFact->CreateScLinkedAreaDlg(pTabViewShell->GetFrameWeld());
2689  delete pImpl->m_pRequest;
2690  pImpl->m_pRequest = new SfxRequest( rReq );
2691  OUString sFile, sFilter, sOptions, sSource;
2692  sal_uLong nRefresh = 0;
2693  if (pImpl->m_pLinkedDlg->Execute() == RET_OK)
2694  {
2695  sFile = pImpl->m_pLinkedDlg->GetURL();
2696  sFilter = pImpl->m_pLinkedDlg->GetFilter();
2697  sOptions = pImpl->m_pLinkedDlg->GetOptions();
2698  sSource = pImpl->m_pLinkedDlg->GetSource();
2699  nRefresh = pImpl->m_pLinkedDlg->GetRefresh();
2700  if ( !sFile.isEmpty() )
2701  pImpl->m_pRequest->AppendItem( SfxStringItem( SID_FILE_NAME, sFile ) );
2702  if ( !sFilter.isEmpty() )
2703  pImpl->m_pRequest->AppendItem( SfxStringItem( SID_FILTER_NAME, sFilter ) );
2704  if ( !sOptions.isEmpty() )
2705  pImpl->m_pRequest->AppendItem( SfxStringItem( SID_FILE_FILTEROPTIONS, sOptions ) );
2706  if ( !sSource.isEmpty() )
2707  pImpl->m_pRequest->AppendItem( SfxStringItem( FN_PARAM_1, sSource ) );
2708  if ( nRefresh )
2709  pImpl->m_pRequest->AppendItem( SfxUInt32Item( FN_PARAM_2, nRefresh ) );
2710  }
2711 
2712  ExecuteExternalSource( sFile, sFilter, sOptions, sSource, nRefresh, *(pImpl->m_pRequest) );
2713  }
2714  }
2715  break;
2716 
2717  case SID_AUTO_SUM:
2718  {
2719  bool bSubTotal = false;
2720  bool bRangeFinder = false;
2721  const OUString aFormula = pTabViewShell->DoAutoSum( bRangeFinder, bSubTotal , ocSum );
2722  if ( !aFormula.isEmpty() )
2723  {
2724  const sal_Int32 nPar = aFormula.indexOf( '(' );
2725  const sal_Int32 nLen = aFormula.getLength();
2726  ScInputHandler* pHdl = pScMod->GetInputHdl( pTabViewShell );
2727 
2728  if ( pHdl && nPar != -1 )
2729  {
2730  if ( !pScMod->IsEditMode() )
2731  {
2732  pScMod->SetInputMode( SC_INPUT_TABLE );
2733  }
2734 
2735  EditView *pEditView=pHdl->GetActiveView();
2736  if ( pEditView )
2737  {
2738  ESelection aTextSel = pEditView->GetSelection();
2739  aTextSel.nStartPos = 0;
2740  aTextSel.nEndPos = EE_TEXTPOS_ALL;
2741  pHdl->DataChanging();
2742  pEditView->SetSelection(aTextSel);
2743  pEditView->InsertText(aFormula);
2744  pEditView->SetSelection( bRangeFinder ? ESelection( 0, nPar + ( bSubTotal ? 3 : 1 ), 0, nLen - 1 ) : ESelection( 0, nLen - 1, 0, nLen - 1 ) );
2745  pHdl->DataChanged();
2746 
2747  if ( bRangeFinder )
2748  {
2749  pHdl->InitRangeFinder( aFormula );
2750  }
2751  }
2752  }
2753  }
2754  }
2755  break;
2756 
2757  case SID_SELECT_UNPROTECTED_CELLS:
2758  {
2760  SCTAB aTab = rData.GetTabNo();
2761  ScMarkData& rMark = rData.GetMarkData();
2762  ScDocument& rDoc = rData.GetDocument();
2763  ScRangeList rRangeList;
2764 
2765  rDoc.GetUnprotectedCells(rRangeList, aTab);
2766  rMark.MarkFromRangeList(rRangeList, true);
2767  pTabViewShell->SetMarkData(rMark);
2768  }
2769  break;
2770 
2771  default:
2772  OSL_FAIL("incorrect slot in ExecuteEdit");
2773  break;
2774  }
2775 }
2776 
2778 {
2780  if ( nType != TransliterationFlags::NONE )
2781  {
2782  GetViewData().GetView()->TransliterateText( nType );
2783  rReq.Done();
2784  }
2785 }
2786 
2788 {
2789  if( rReq.GetSlot() == SID_TRANSLITERATE_ROTATE_CASE )
2791 }
2792 
2794  const OUString& _rFile, const OUString& _rFilter, const OUString& _rOptions,
2795  const OUString& _rSource, sal_uLong _nRefresh, SfxRequest& _rRequest )
2796 {
2797  if ( !_rFile.isEmpty() && !_rSource.isEmpty() ) // filter may be empty
2798  {
2799  ScRange aLinkRange;
2800  bool bMove = false;
2801 
2803  ScMarkData& rMark = rData.GetMarkData();
2804  rMark.MarkToSimple();
2805  if ( rMark.IsMarked() )
2806  {
2807  rMark.GetMarkArea( aLinkRange );
2808  bMove = true; // insert/delete cells to fit range
2809  }
2810  else
2811  aLinkRange = ScRange( rData.GetCurX(), rData.GetCurY(), rData.GetTabNo() );
2812 
2813  rData.GetDocFunc().InsertAreaLink( _rFile, _rFilter, _rOptions, _rSource,
2814  aLinkRange, _nRefresh, bMove, false );
2815  _rRequest.Done();
2816  }
2817  else
2818  _rRequest.Ignore();
2819 }
2820 
2821 namespace {
2822 
2823 bool isDPSourceValid(const ScDPObject& rDPObj)
2824 {
2825  if (rDPObj.IsImportData())
2826  {
2827  // If the data type is database, check if the database is still valid.
2828  const ScImportSourceDesc* pDesc = rDPObj.GetImportSourceDesc();
2829  if (!pDesc)
2830  return false;
2831 
2832  const ScDPSaveData* pSaveData = rDPObj.GetSaveData();
2833  const ScDPDimensionSaveData* pDimData = nullptr;
2834  if (pSaveData)
2835  pDimData = pSaveData->GetExistingDimensionData();
2836 
2837  const ScDPCache* pCache = pDesc->CreateCache(pDimData);
2838  if (!pCache)
2839  // cache creation failed, probably due to invalid connection.
2840  return false;
2841  }
2842  return true;
2843 }
2844 
2845 void RunPivotLayoutDialog(ScModule* pScMod,
2846  ScTabViewShell* pTabViewShell,
2847  std::unique_ptr<ScDPObject>& pNewDPObject)
2848 {
2849  bool bHadNewDPObject = pNewDPObject != nullptr;
2850  pTabViewShell->SetDialogDPObject( std::move(pNewDPObject) );
2851  if ( bHadNewDPObject )
2852  {
2853  // start layout dialog
2854 
2855  sal_uInt16 nId = ScPivotLayoutWrapper::GetChildWindowId();
2856  SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
2857  SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
2858  pScMod->SetRefDialog( nId, pWnd == nullptr );
2859  }
2860 }
2861 
2862 }
2863 
2865 {
2866  ScModule* pScMod = SC_MOD();
2867  ScTabViewShell* pTabViewShell = GetViewData().GetViewShell();
2869  ScDocument& rDoc = rData.GetDocument();
2870 
2871  // ScPivot is no longer used...
2872  ScDPObject* pDPObj = rDoc.GetDPAtCursor(
2873  rData.GetCurX(), rData.GetCurY(),
2874  rData.GetTabNo() );
2875  if ( pDPObj ) // on an existing table?
2876  {
2877  std::unique_ptr<ScDPObject> pNewDPObject;
2878 
2879  if (isDPSourceValid(*pDPObj))
2880  pNewDPObject.reset(new ScDPObject(*pDPObj));
2881 
2882  RunPivotLayoutDialog(pScMod, pTabViewShell, pNewDPObject);
2883  }
2884  else // create new table
2885  {
2886  // select database range or data
2887  pTabViewShell->GetDBData( true, SC_DB_OLD );
2888  ScMarkData& rMark = GetViewData().GetMarkData();
2889  if ( !rMark.IsMarked() && !rMark.IsMultiMarked() )
2890  pTabViewShell->MarkDataArea( false );
2891 
2892  // output to cursor position for non-sheet data
2893  ScAddress aDestPos( rData.GetCurX(), rData.GetCurY(),
2894  rData.GetTabNo() );
2895 
2896  // first select type of source data
2897 
2898  bool bEnableExt = ScDPObject::HasRegisteredSources();
2899 
2901 
2904  pTabViewShell->GetFrameWeld(), bEnableExt));
2905 
2906  // Populate named ranges (if any).
2907  ScRangeName* pRangeName = rDoc.GetRangeName();
2908  if (pRangeName)
2909  {
2910  ScRangeName::const_iterator itr = pRangeName->begin(), itrEnd = pRangeName->end();
2911  for (; itr != itrEnd; ++itr)
2912  pTypeDlg->AppendNamedRange(itr->second->GetName());
2913  }
2914 
2915  pTypeDlg->StartExecuteAsync([this, pTypeDlg, pTabViewShell,
2916  pScMod, pFact, &rDoc, &rMark, aDestPos](int nResult) mutable {
2917 
2918  if (nResult == RET_OK )
2919  {
2920  if ( pTypeDlg->IsExternal() )
2921  {
2922  std::vector<OUString> aSources = ScDPObject::GetRegisteredSources();
2925  pTabViewShell->GetFrameWeld(), aSources));
2926 
2927  pServDlg->StartExecuteAsync([pServDlg, pScMod, pTabViewShell,
2928  aDestPos, &rDoc](int nResult2) mutable {
2929  if ( nResult2 == RET_OK )
2930  {
2931  ScDPServiceDesc aServDesc(
2932  pServDlg->GetServiceName(),
2933  pServDlg->GetParSource(),
2934  pServDlg->GetParName(),
2935  pServDlg->GetParUser(),
2936  pServDlg->GetParPass() );
2937  std::unique_ptr<ScDPObject> pNewDPObject(new ScDPObject(&rDoc));
2938  pNewDPObject->SetServiceData( aServDesc );
2939 
2940  if ( pNewDPObject )
2941  pNewDPObject->SetOutRange( aDestPos );
2942 
2943  RunPivotLayoutDialog(pScMod, pTabViewShell, pNewDPObject);
2944  }
2945 
2946  pServDlg->disposeOnce();
2947  });
2948  }
2949  else if ( pTypeDlg->IsDatabase() )
2950  {
2951  assert(pFact && "ScAbstractFactory create fail!");
2953  pFact->CreateScDataPilotDatabaseDlg(pTabViewShell->GetFrameWeld()));
2954  assert(pDataDlg && "Dialog create fail!");
2955 
2956  pDataDlg->StartExecuteAsync([pDataDlg, pScMod, pTabViewShell,
2957  aDestPos, &rDoc](int nResult2) mutable {
2958  if ( nResult2 == RET_OK )
2959  {
2960  ScImportSourceDesc aImpDesc(&rDoc);
2961  pDataDlg->GetValues( aImpDesc );
2962  std::unique_ptr<ScDPObject> pNewDPObject(new ScDPObject(&rDoc));
2963  pNewDPObject->SetImportDesc( aImpDesc );
2964 
2965  if ( pNewDPObject )
2966  pNewDPObject->SetOutRange( aDestPos );
2967 
2968  RunPivotLayoutDialog(pScMod, pTabViewShell, pNewDPObject);
2969  }
2970 
2971  pDataDlg->disposeOnce();
2972  });
2973  }
2974  else
2975  {
2976  std::unique_ptr<ScDPObject> pNewDPObject;
2977  const char* pSrcErrorId = nullptr;
2978 
2979  if (pTypeDlg->IsNamedRange())
2980  {
2981  OUString aName = pTypeDlg->GetSelectedNamedRange();
2982  ScSheetSourceDesc aShtDesc(&rDoc);
2983  aShtDesc.SetRangeName(aName);
2984  pSrcErrorId = aShtDesc.CheckSourceRange();
2985  if (!pSrcErrorId)
2986  {
2987  pNewDPObject.reset(new ScDPObject(&rDoc));
2988  pNewDPObject->SetSheetDesc(aShtDesc);
2989  }
2990  }
2991  else // selection
2992  {
2994  ScRange aRange;
2996  if ( (eType & SC_MARK_SIMPLE) == SC_MARK_SIMPLE )
2997  {
2998  // Shrink the range to the data area.
2999  SCCOL nStartCol = aRange.aStart.Col(), nEndCol = aRange.aEnd.Col();
3000  SCROW nStartRow = aRange.aStart.Row(), nEndRow = aRange.aEnd.Row();
3001  if (rDoc.ShrinkToDataArea(aRange.aStart.Tab(), nStartCol, nStartRow, nEndCol, nEndRow))
3002  {
3003  aRange.aStart.SetCol(nStartCol);
3004  aRange.aStart.SetRow(nStartRow);
3005  aRange.aEnd.SetCol(nEndCol);
3006  aRange.aEnd.SetRow(nEndRow);
3007  rMark.SetMarkArea(aRange);
3008  pTabViewShell->MarkRange(aRange);
3009  }
3010 
3011  bool bOK = true;
3012  if ( rDoc.HasSubTotalCells( aRange ) )
3013  {
3014  // confirm selection if it contains SubTotal cells
3015  std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(pTabViewShell->GetFrameWeld(),
3016  VclMessageType::Question, VclButtonsType::YesNo,
3017  ScResId(STR_DATAPILOT_SUBTOTAL)));
3018  xQueryBox->set_default_response(RET_YES);
3019  if (xQueryBox->run() == RET_NO)
3020  bOK = false;
3021  }
3022  if (bOK)
3023  {
3024  ScSheetSourceDesc aShtDesc(&rDoc);
3025  aShtDesc.SetSourceRange(aRange);
3026  pSrcErrorId = aShtDesc.CheckSourceRange();
3027  if (!pSrcErrorId)
3028  {
3029  pNewDPObject.reset(new ScDPObject(&rDoc));
3030  pNewDPObject->SetSheetDesc( aShtDesc );
3031  }
3032 
3033  // output below source data
3034  if ( aRange.aEnd.Row()+2 <= rDoc.MaxRow() - 4 )
3035  aDestPos = ScAddress( aRange.aStart.Col(),
3036  aRange.aEnd.Row()+2,
3037  aRange.aStart.Tab() );
3038  }
3039  }
3040  }
3041 
3042  if (pSrcErrorId)
3043  {
3044  // Error occurred during data creation. Launch an error and bail out.
3045  std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pTabViewShell->GetFrameWeld(),
3046  VclMessageType::Info, VclButtonsType::Ok,
3047  ScResId(pSrcErrorId)));
3048  xInfoBox->run();
3049  return;
3050  }
3051 
3052  if ( pNewDPObject )
3053  pNewDPObject->SetOutRange( aDestPos );
3054 
3055  RunPivotLayoutDialog(pScMod, pTabViewShell, pNewDPObject);
3056  }
3057  }
3058 
3059  pTypeDlg->disposeOnce();
3060  });
3061  }
3062 }
3063 
3065 {
3066  ScTabViewShell* pTabViewShell = GetViewData().GetViewShell();
3067  if (!pTabViewShell)
3068  return;
3069 
3070  ScModule* pScMod = SC_MOD();
3071 
3072  sal_uInt16 nId = ScXMLSourceDlgWrapper::GetChildWindowId();
3073  SfxViewFrame* pViewFrame = pTabViewShell->GetViewFrame();
3074  SfxChildWindow* pWnd = pViewFrame->GetChildWindow(nId);
3075  pScMod->SetRefDialog(nId, pWnd == nullptr);
3076 }
3077 
3079 {
3080  ScTabViewShell* pTabViewShell = GetViewData().GetViewShell();
3081  const SfxItemSet* pArgs = rReq.GetArgs();
3082  if ( pArgs )
3083  {
3084  pTabViewShell->DoSubTotals( static_cast<const ScSubTotalItem&>( pArgs->Get( SCITEM_SUBTDATA )).
3085  GetSubTotalData() );
3086  rReq.Done();
3087  return;
3088  }
3089 
3091  ScSubTotalParam aSubTotalParam;
3093 
3094  bool bAnonymous;
3095 
3096  // Only get existing named database range.
3097  ScDBData* pDBData = pTabViewShell->GetDBData(true, SC_DB_OLD);
3098  if (pDBData)
3099  bAnonymous = false;
3100  else
3101  {
3102  // No existing DB data at this position. Create an
3103  // anonymous DB.
3104  bAnonymous = true;
3105  pDBData = pTabViewShell->GetAnonymousDBData();
3106  ScRange aDataRange;
3107  pDBData->GetArea(aDataRange);
3108  pTabViewShell->MarkRange(aDataRange, false);
3109  }
3110 
3111  pDBData->GetSubTotalParam( aSubTotalParam );
3112  aSubTotalParam.bRemoveOnly = false;
3113  if (bAnonymous)
3114  {
3115  // Preset sort formatting along with values and also create formula
3116  // cells with "needs formatting". Subtotals on data of different types
3117  // doesn't make much sense anyway.
3118  aSubTotalParam.bIncludePattern = true;
3119  }
3120 
3121  aArgSet.Put( ScSubTotalItem( SCITEM_SUBTDATA, &GetViewData(), &aSubTotalParam ) );
3123  pDlg.disposeAndReset(pFact->CreateScSubTotalDlg(pTabViewShell->GetFrameWeld(), aArgSet));
3124  pDlg->SetCurPageId("1stgroup");
3125 
3126  short bResult = pDlg->Execute();
3127 
3128  if ( (bResult == RET_OK) || (bResult == SCRET_REMOVE) )
3129  {
3130  const SfxItemSet* pOutSet = nullptr;
3131 
3132  if ( bResult == RET_OK )
3133  {
3134  pOutSet = pDlg->GetOutputItemSet();
3135  aSubTotalParam =
3136  static_cast<const ScSubTotalItem&>(
3137  pOutSet->Get( SCITEM_SUBTDATA )).
3138  GetSubTotalData();
3139  }
3140  else // if (bResult == SCRET_REMOVE)
3141  {
3142  pOutSet = &aArgSet;
3143  aSubTotalParam.bRemoveOnly = true;
3144  aSubTotalParam.bReplace = true;
3145  aArgSet.Put( ScSubTotalItem( SCITEM_SUBTDATA,
3146  &GetViewData(),
3147  &aSubTotalParam ) );
3148  }
3149 
3150  pTabViewShell->DoSubTotals( aSubTotalParam );
3151  rReq.Done( *pOutSet );
3152  }
3153  else
3155 }
3156 
3158 {
3159  ScAddress aCurPos = GetViewData().GetCurPos();
3160 
3161  OUString aInit;
3162 
3163  if (aCurPos.Row() > 0)
3164  {
3165  // Get the initial text value from the above cell.
3166 
3167  ScDocument& rDoc = GetViewData().GetDocument();
3168  ScAddress aPrevPos = aCurPos;
3169  aPrevPos.IncRow(-1);
3170  ScRefCellValue aCell(rDoc, aPrevPos);
3171 
3172  if (aCell.meType == CELLTYPE_FORMULA)
3173  {
3174  aInit = "=";
3175  const ScTokenArray* pCode = aCell.mpFormula->GetCode();
3176  sc::TokenStringContext aCxt(rDoc, rDoc.GetGrammar());
3177  aInit += pCode->CreateString(aCxt, aCurPos);
3178  }
3179  else
3180  aInit = aCell.getString(&rDoc);
3181  }
3182 
3183  SC_MOD()->SetInputMode(SC_INPUT_TABLE, &aInit);
3184 }
3185 
3187  m_pLinkedDlg(),
3188  m_pRequest( nullptr ) {}
3189 
3191 {
3192 }
3193 /* 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:5320
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:371
CreateNameFlags GetCreateNameFlags()
Definition: viewfunc.cxx:2917
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:2116
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:2793
void MarkDataArea(bool bIncludeCursor=true)
Definition: tabview3.cxx:1652
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:3168
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:1103
SC_DLLPUBLIC bool IsTabProtected(SCTAB nTab) const
Definition: documen3.cxx:1889
SC_DLLPUBLIC void GetInputString(SCCOL nCol, SCROW nRow, SCTAB nTab, OUString &rString)
Definition: document.cxx:3538
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:164
SCROW GetRefEndY() const
Definition: viewdata.hxx:519
SfxChildWindow * GetChildWindow(sal_uInt16)
const OUString & GetFamilyName() const
bool IsEditMode()
Definition: scmod.cxx:1342
SC_DLLPUBLIC bool CopyToClip(ScDocument *pClipDoc, bool bCut, bool bApi=false, bool bIncludeObjects=false, bool bStopEdit=true)
Definition: viewfun3.cxx:166
virtual void SetOtherDoc(bool bSet)=0
SC_DLLPUBLIC bool DeleteContents(const ScMarkData &rMark, InsertDeleteFlags nFlags, bool bRecord, bool bApi)
Definition: docfunc.cxx:568
void CreateNames(CreateNameFlags nFlags)
Definition: viewfunc.cxx:2906
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:1802
FillDir
Definition: global.hxx:320
void DoSheetConversion(const ScConversionParam &rParam)
Generic implementation of sheet conversion functions.
Definition: viewfun4.cxx:438
void FillTab(InsertDeleteFlags nFlags, ScPasteFunc nFunction, bool bSkipEmpty, bool bAsLink)
Definition: viewfun2.cxx:1638
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
void DeleteCells(DelCellCmd eCmd)
Definition: viewfunc.cxx:1652
void MarkRange(const ScRange &rRange, bool bSetCursor=true, bool bContinue=false)
Definition: tabview3.cxx:1683
constexpr::Color COL_RED(0x80, 0x00, 0x00)
const OUString & GetTargetFrame() const
sal_uInt16 char char * pDesc
Definition: callform.cxx:57
bool DataChanging(sal_Unicode cTyped=0, bool bFromCommand=false)
Definition: inputhdl.cxx:2574
SC_DLLPUBLIC bool Intersects(const ScRange &rRange) const
Definition: address.cxx:1558
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:2979
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:167
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:397
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
ScViewData & GetViewData()
Definition: formatsh.hxx:35
sal_Int16 nId
const ContentProperties & rData
void Solve(const ScSolveParam &rParam)
Definition: viewfun2.cxx:2194
SCTAB GetTabNo() const
Definition: viewdata.hxx:395
SC_DLLPUBLIC void GetNumberFormat(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt32 &rFormat) const
Definition: document.cxx:3639
bool SimpleRowMarked()
Definition: viewdata.cxx:1233
void ExecuteDataPilotDialog()
Definition: cellsh1.cxx:2864
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:1279
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:485
void GetFillData(SCCOL &rStartCol, SCROW &rStartRow, SCCOL &rEndCol, SCROW &rEndRow)
Definition: viewdata.cxx:1304
void ExecuteSubtotals(SfxRequest &rReq)
Definition: cellsh1.cxx:3078
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:64
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:982
#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:75
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:359
const MarkedTabsType & GetSelectedTabs() const
Definition: markdata.hxx:98
void GetClipArea(SCCOL &nClipX, SCROW &nClipY, bool bIncludeFiltered)
Definition: document.cxx:3116
SC_DLLPUBLIC formula::FormulaGrammar::AddressConvention GetAddressConvention() const
Definition: documen3.cxx:488
OUString DoAutoSum(bool &rRangeFinder, bool &rSubTotal, const OpCode eCode)
Definition: tabvwshc.cxx:657
virtual bool IsLink() const =0
void GetNotesInRange(const ScRangeList &rRange, std::vector< sc::NoteEntry > &rNotes) const
Definition: document.cxx:6759
bool IsImportData() const
Definition: dpobject.hxx:163
void HideMarkedOutlines(bool bRecord=true)
Definition: dbfunc3.cxx:406
void ConvertFormulaToValue()
Definition: viewfun2.cxx:1829
void MarkFromRangeList(const ScRangeList &rList, bool bReset)
Definition: markdata.cxx:334
FontFamily GetFamilyType()
SC_DLLPUBLIC void InputEnterHandler(ScEnterMode nBlockMode=ScEnterMode::NORMAL)
Definition: scmod.cxx:1360
virtual void ShowCursor(bool bOn) override
Definition: tabvwsh4.cxx:449
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:2220
static sal_Int32 getIconSetElements(ScIconSetType eType)
Internal use only (d&d undo): do not delete caption objects of cell notes.
DelCellCmd
Definition: global.hxx:292
void DetectiveMarkPred()
Definition: viewfun6.cxx:167
void GetMarkArea(ScRange &rRange) const
Definition: markdata.cxx:112
virtual SfxUndoManager * GetUndoManager() override
Definition: docsh.cxx:2806
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:3157
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:6501
void SetSlot(sal_uInt16 nNewSlot)
bool InsertName(const OUString &rName, const OUString &rSymbol, const OUString &rType)
Definition: viewfunc.cxx:2852
SC_DLLPUBLIC ScConditionalFormatList * GetCondFormList(SCTAB nTab) const
Definition: documen4.cxx:857
CommentCaptionState GetAllNoteCaptionsState(const ScRangeList &rRanges)
Definition: document.cxx:6642
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:88
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:259
PropertiesInfo aProperties
virtual bool IsExternal() const =0
SC_DLLPUBLIC SCROW MaxRow() const
Definition: document.hxx:870
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:2787
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:345
void TransliterateText(TransliterationFlags nType)
Definition: viewfun2.cxx:1840
SC_DLLPUBLIC void SetRefDialog(sal_uInt16 nId, bool bVis, SfxViewFrame *pViewFrm=nullptr)
Reference dialogs.
Definition: scmod.cxx:1468
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:1142
void UpdateCharts(bool bAllCharts)
Definition: dbfunc2.cxx:24
void UpdateInputHandler(bool bForce=false, bool bStopEditing=true)
Definition: tabvwsha.cxx:653
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:3064
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:777
sal_Int32 nEndPos
virtual bool IsTranspose() const =0
const ScRange * Find(const ScAddress &) const
Definition: rangelst.cxx:1031
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:4733
SC_DLLPUBLIC void PasteFromSystem()
Definition: viewfun3.cxx:483
void SetCol(SCCOL nColP)
Definition: address.hxx:279
SvtScriptType GetSelectionScriptType()
Definition: viewfunc.cxx:802
ScChangeTrack * GetChangeTrack() const
Definition: document.hxx:2389
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)
SfxItemPool & GetPool() const
const SfxPoolItem & GetItem(sal_uInt16 nWhichP) const
Definition: patattr.hxx:71
bool empty() const
Definition: rangelst.hxx:89
bool InputKeyEvent(const KeyEvent &rKEvt, bool bStartEdit=false)
Definition: scmod.cxx:1354
void GetPossibleClipboardFormats(SvxClipboardFormatItem &rFormats)
Definition: cellsh.cxx:443
DocumentType eType
SC_DLLPUBLIC double GetValue(const ScAddress &rPos) const
Definition: document.cxx:3626
ScTabViewShell * GetViewShell() const
Definition: viewdata.hxx:357
void SetNoteText(const ScAddress &rPos, const OUString &rNoteText)
Definition: viewfunc.cxx:2596
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:191
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:5096
SC_DLLPUBLIC SCCOL MaxCol() const
Definition: document.hxx:869
void InsertURL(const OUString &rName, const OUString &rURL, const OUString &rTarget, sal_uInt16 nMode)
Definition: tabvwshe.cxx:117
void DetectiveAddPred()
Definition: viewfun6.cxx:69
SC_DLLPUBLIC SvNumberFormatter * GetFormatTable() const
Definition: documen2.cxx:437
SvNumFormatType GetType() const
void UseScenario(const OUString &rName)
Definition: viewfun2.cxx:2316
virtual sal_Int32 GetDatePart() const =0
FillCmd
Definition: global.hxx:328
SC_DLLPUBLIC const_iterator end() const
Definition: rangenam.cxx:782
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:160
bool GetString(SotClipboardFormatId nFormat, OUString &rStr)
#define SC_MOD()
Definition: scmod.hxx:250
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:871
const OUString & GetValue() const
void GetUnprotectedCells(ScRangeList &rRange, SCTAB nTab) const
Definition: document.cxx:6771
SC_DLLPUBLIC void SetTabNo(SCTAB nTab, bool bNew=false, bool bExtendSelection=false, bool bSameTabButMoved=false)
Definition: tabview3.cxx:1794
const T * GetArg(sal_uInt16 nSlotId) const
void ExecuteTrans(SfxRequest &rReq)
Definition: cellsh1.cxx:2777
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:89
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:2822
Context for creating string from an array of formula tokens, used in ScTokenArray::CreateString().
bool IsCutMode()
Definition: document.cxx:2063
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:1038
std::unique_ptr< CellShell_Impl > pImpl
Definition: cellsh.hxx:54
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:3487
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:2601
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:5289
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:272
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:549
void ReplaceConditionalFormat(sal_uLong nOldIndex, std::unique_ptr< ScConditionalFormat > pFormat, SCTAB nTab, const ScRangeList &rRanges)
Definition: docfunc.cxx:5597
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:300
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:876
virtual FillCmd GetFillCmd() const =0
virtual VclPtr< SfxAbstractTabDialog > CreateScSubTotalDlg(weld::Window *pParent, const SfxItemSet &rArgSet)=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:828
void GetSubTotalParam(ScSubTotalParam &rSubTotalParam) const
Definition: dbdata.cxx:448
size_t LeaveListAction()
ScDBFunc * GetView() const
Definition: viewdata.cxx:852
void SetInputMode(ScInputMode eMode, const OUString *pInitText=nullptr)
Definition: scmod.cxx:1335
virtual void Insert(SotClipboardFormatId nFormat, const OUString &rFormatName)=0
ScAddress GetCurPos() const
Definition: viewdata.cxx:4007
void InitRangeFinder(const OUString &rFormula)
Definition: inputhdl.cxx:299
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:5508
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:1431
CellType
Definition: global.hxx:283
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_WHITE
OUString aName
static SC_DLLPUBLIC ScAbstractDialogFactory * Create()
Definition: scabstdlg.cxx:37
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:301
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:400
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_YELLOW
Sequence< sal_Int8 > aSeq
const ScDocument & GetDocument() const
Definition: docsh.hxx:217
void DataChanged(bool bFromTopNotify=false, bool bSetModified=true)
Definition: inputhdl.cxx:2586
const ScSolveParam & GetData() const
Definition: uiitems.hxx:257
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:466
void DoRefConversion()
Definition: viewfun4.cxx:178
virtual VclPtr< AbstractScCondFormatManagerDlg > CreateScCondFormatMgrDlg(weld::Window *pParent, ScDocument &rDoc, const ScConditionalFormatList *pFormatList)=0
void CancelAutoDBRange()
Definition: docsh5.cxx:368
void HideListBox()
Definition: tabview3.cxx:2960
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:71
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:5673
const OUString & GetName() const
SvxLinkInsertMode GetInsertMode() const
void AppendItem(const SfxPoolItem &)
#define LANGUAGE_CHINESE_TRADITIONAL
void DoHangulHanjaConversion()
Definition: viewfun4.cxx:432
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:1304
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:1548
ScDBData * GetAnonymousDBData()
Definition: dbfunc.cxx:155
ScDocFunc & GetDocFunc()
Definition: docsh.hxx:219
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:3227
bool HasSubTotalCells(const ScRange &rRange)
Definition: documen3.cxx:776
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 PasteFromClipboard(ScViewData &rViewData, ScTabViewShell *pTabViewShell, bool bShowDialog)
Definition: cliputil.cxx:46
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:309
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:510
bool IsClipboardSource() const
Definition: document.cxx:2560
aStr
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:3745
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:1599
CellShiftDisabledFlags
Definition: scui_def.hxx:42
void EnterData(SCCOL nCol, SCROW nRow, SCTAB nTab, const OUString &rString, const EditTextObject *pData=nullptr)
Definition: viewfunc.cxx:341
virtual InsertDeleteFlags GetInsContentsCmdBits() const =0
SCCOL GetCurX() const
Definition: viewdata.hxx:401
ViewShellId GetViewShellId() const override
void SetMarkData(const ScMarkData &rNew)
Definition: tabview3.cxx:1733
#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:2264
ocSum
sal_Int32 nStartPos
SC_DLLPUBLIC void GetAllNoteEntries(std::vector< sc::NoteEntry > &rNotes) const
Definition: document.cxx:6739
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo