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* pDoc = GetViewData()->GetDocument();
283  bool bTheFlag=(pDoc->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* pDoc = GetViewData()->GetDocument();
351  bool bTheFlag=GetViewData()->IsMultiMarked() ||
353  (pDoc->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* pDoc = GetViewData()->GetDocument();
420  SCTAB nTab = GetViewData()->GetTabNo();
421  if ( pDoc->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* pDoc = GetViewData()->GetDocument();
558  SvNumberFormatter* pFormatter = pDoc->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  pDoc->GetNumberFormat( nStartCol, nStartRow, nStartTab, nPrivFormat );
629  pDoc->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  pDoc->GetInputString( nStartCol, nStartRow, nStartTab, aStartStr);
660  pDoc->GetValue( nStartCol, nStartRow, nStartTab, fStartVal );
661 
662  if(eFillDir==FILL_TO_BOTTOM && nStartRow < nEndRow )
663  {
664  pDoc->GetInputString( nStartCol, nStartRow+1, nStartTab, aEndStr);
665  if(!aEndStr.isEmpty())
666  {
667  pDoc->GetValue( nStartCol, nStartRow+1, nStartTab, fInputEndVal);
668  fIncVal=fInputEndVal-fStartVal;
669  }
670  }
671  else
672  {
673  if(nStartCol < nEndCol)
674  {
675  pDoc->GetInputString( nStartCol+1, nStartRow, nStartTab, aEndStr);
676  if(!aEndStr.isEmpty())
677  {
678  pDoc->GetValue( nStartCol+1, nStartRow, nStartTab, fInputEndVal);
679  fIncVal=fInputEndVal-fStartVal;
680  }
681  }
682  }
683  if(eFillCmd==FILL_DATE)
684  {
685  const Date& rNullDate = pDoc->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  *pDoc,
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  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  SCTAB nStartTab, nEndTab;
806 
807  GetViewData()->GetFillData( nStartCol, nStartRow, nEndCol, nEndRow );
808  SCCOL nFillCol = GetViewData()->GetRefEndX();
809  SCROW nFillRow = GetViewData()->GetRefEndY();
810  ScDocument* pDoc = GetViewData()->GetDocument();
811 
812  if( pReqArgs != nullptr )
813  {
814  const SfxPoolItem* pItem;
815 
816  if( pReqArgs->HasItem( FID_FILL_AUTO, &pItem ) )
817  {
818  ScAddress aScAddress;
819  OUString aArg = static_cast<const SfxStringItem*>(pItem)->GetValue();
820 
821  if( aScAddress.Parse( aArg, pDoc, pDoc->GetAddressConvention() ) & ScRefFlags::VALID )
822  {
823  nFillRow = aScAddress.Row();
824  nFillCol = aScAddress.Col();
825  }
826  }
827 
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, pDoc, pDoc->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 
1169  if ( pDlg->Execute() == RET_OK )
1170  bColumns = pDlg->GetColsChecked();
1171  else
1172  bOk = false;
1173  }
1174  }
1175  if (bOk)
1176  {
1177  pTabViewShell->MakeOutline( bColumns );
1178 
1179  if( ! rReq.IsAPI() )
1180  {
1181  OUString aCol = bColumns ? OUString('C') : OUString('R');
1182  rReq.AppendItem( SfxStringItem( SID_OUTLINE_MAKE, aCol ) );
1183  rReq.Done();
1184  }
1185  }
1186  }
1187  break;
1188 
1189  case SID_OUTLINE_REMOVE:
1190  {
1191  bool bColumns = false;
1192  bool bOk = true;
1193 
1194  if ( GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(),
1195  GetViewData()->GetCurY(), GetViewData()->GetTabNo() ) )
1196  {
1197  pTabViewShell->UngroupDataPilot();
1198  bOk = false;
1199  }
1200  else if( pReqArgs != nullptr )
1201  {
1202  const SfxPoolItem* pItem;
1203  bOk = false;
1204 
1205  if( pReqArgs->HasItem( SID_OUTLINE_REMOVE, &pItem ) )
1206  {
1207  OUString aCol = static_cast<const SfxStringItem*>(pItem)->GetValue();
1208  aCol = aCol.toAsciiUpperCase();
1209 
1210  switch (aCol[0])
1211  {
1212  case 'R': bColumns=false; bOk = true;break;
1213  case 'C': bColumns=true; bOk = true;break;
1214  }
1215  }
1216  }
1217  else // Dialog only when removal for rows and columns is possible
1218  {
1219  bool bColPoss, bRowPoss;
1220  pTabViewShell->TestRemoveOutline( bColPoss, bRowPoss );
1221  // TODO: handle this case in LOK too
1222  if ( bColPoss && bRowPoss && !comphelper::LibreOfficeKit::isActive() )
1223  {
1225 
1226  ScopedVclPtr<AbstractScGroupDlg> pDlg(pFact->CreateAbstractScGroupDlg(pTabViewShell->GetFrameWeld(), true));
1227  if ( pDlg->Execute() == RET_OK )
1228  bColumns = pDlg->GetColsChecked();
1229  else
1230  bOk = false;
1231  }
1232  else if ( bColPoss )
1233  bColumns = true;
1234  else if ( bRowPoss )
1235  bColumns = false;
1236  else
1237  bOk = false;
1238  }
1239  if (bOk)
1240  {
1241  pTabViewShell->RemoveOutline( bColumns );
1242 
1243  if( ! rReq.IsAPI() )
1244  {
1245  OUString aCol = bColumns ? OUString('C') : OUString('R');
1246  rReq.AppendItem( SfxStringItem( SID_OUTLINE_REMOVE, aCol ) );
1247  rReq.Done();
1248  }
1249  }
1250  }
1251  break;
1252 
1253  // Clipboard
1254 
1255  case SID_COPY: // for graphs in DrawShell
1256  {
1257  weld::WaitObject aWait( GetViewData()->GetDialogParent() );
1258  pTabViewShell->CopyToClip( nullptr, false, false, true );
1259  rReq.Done();
1261  pTabViewShell->ShowCursor();
1262  pTabViewShell->UpdateCopySourceOverlay();
1263  }
1264  break;
1265 
1266  case SID_CUT: // for graphs in DrawShell
1267  {
1268  weld::WaitObject aWait( GetViewData()->GetDialogParent() );
1269  pTabViewShell->CutToClip();
1270  rReq.Done();
1272  pTabViewShell->ShowCursor();
1273  pTabViewShell->UpdateCopySourceOverlay();
1274  }
1275  break;
1276 
1277  case SID_PASTE:
1278  {
1279  ScClipUtil::PasteFromClipboard ( GetViewData(), pTabViewShell, true );
1280  rReq.Done();
1281  }
1282  break;
1283 
1284  case SID_CLIPBOARD_FORMAT_ITEMS:
1285  {
1286  weld::WaitObject aWait( GetViewData()->GetDialogParent() );
1287 
1288  SotClipboardFormatId nFormat = SotClipboardFormatId::NONE;
1289  const SfxPoolItem* pItem;
1290  if ( pReqArgs &&
1291  pReqArgs->GetItemState(nSlot, true, &pItem) == SfxItemState::SET &&
1292  dynamic_cast<const SfxUInt32Item*>( pItem) != nullptr )
1293  {
1294  nFormat = static_cast<SotClipboardFormatId>(static_cast<const SfxUInt32Item*>(pItem)->GetValue());
1295  }
1296 
1297  if ( nFormat != SotClipboardFormatId::NONE )
1298  {
1299  css::uno::Reference<css::datatransfer::XTransferable2> xTransferable(ScTabViewShell::GetClipData(GetViewData()->GetActiveWin()));
1300  bool bCells = ( ScTransferObj::GetOwnClipboard(xTransferable) != nullptr );
1301  bool bDraw = ( ScDrawTransferObj::GetOwnClipboard(xTransferable) != nullptr );
1302  bool bOle = ( nFormat == SotClipboardFormatId::EMBED_SOURCE );
1303 
1304  if ( bCells && bOle )
1305  pTabViewShell->PasteFromSystem();
1306  else if ( bDraw && bOle )
1307  pTabViewShell->PasteDraw();
1308  else
1309  pTabViewShell->PasteFromSystem(nFormat);
1310  }
1311  //?else
1312  //? pTabViewShell->PasteFromSystem();
1313 
1314  rReq.Done();
1315  }
1316  pTabViewShell->CellContentChanged();
1317  break;
1318 
1319  case FID_INS_CELL_CONTENTS:
1320  {
1322  ScPasteFunc nFunction = ScPasteFunc::NONE;
1323  InsCellCmd eMoveMode = INS_NONE;
1324 
1325  ScDocument* pDoc = GetViewData()->GetDocument();
1326  bool bOtherDoc = !pDoc->IsClipboardSource();
1327  // keep a reference in case the clipboard is changed during dialog or PasteFromClip
1329  if ( pOwnClip )
1330  {
1331  bool bSkipEmpty = false;
1332  bool bTranspose = false;
1333  bool bAsLink = false;
1334 
1335  if ( pReqArgs!=nullptr && pTabViewShell->SelectionEditable() )
1336  {
1337  const SfxPoolItem* pItem;
1338  OUString aFlags('A');
1339 
1340  if( pReqArgs->HasItem( FID_INS_CELL_CONTENTS, &pItem ) )
1341  aFlags = static_cast<const SfxStringItem*>(pItem)->GetValue();
1342 
1343  nFlags |= FlagsFromString(aFlags);
1344 
1345  const SfxUInt16Item* pFuncItem = rReq.GetArg<SfxUInt16Item>(FN_PARAM_1);
1346  const SfxBoolItem* pSkipItem = rReq.GetArg<SfxBoolItem>(FN_PARAM_2);
1347  const SfxBoolItem* pTransposeItem = rReq.GetArg<SfxBoolItem>(FN_PARAM_3);
1348  const SfxBoolItem* pLinkItem = rReq.GetArg<SfxBoolItem>(FN_PARAM_4);
1349  const SfxInt16Item* pMoveItem = rReq.GetArg<SfxInt16Item>(FN_PARAM_5);
1350  if ( pFuncItem )
1351  nFunction = static_cast<ScPasteFunc>(pFuncItem->GetValue());
1352  if ( pSkipItem )
1353  bSkipEmpty = pSkipItem->GetValue();
1354  if ( pTransposeItem )
1355  bTranspose = pTransposeItem->GetValue();
1356  if ( pLinkItem )
1357  bAsLink = pLinkItem->GetValue();
1358  if ( pMoveItem )
1359  eMoveMode = static_cast<InsCellCmd>(pMoveItem->GetValue());
1360  }
1361  else
1362  {
1363  ScEditableTester aTester( pTabViewShell );
1364  if (aTester.IsEditable())
1365  {
1367 
1369  pDlg->SetOtherDoc( bOtherDoc );
1370  // if ChangeTrack MoveMode disable
1371  pDlg->SetChangeTrack( pDoc->GetChangeTrack() != nullptr );
1372  // fdo#56098 disable shift if necessary
1373  if (!bOtherDoc)
1374  {
1376  if ( pData->GetMarkData().GetTableSelect( pData->GetTabNo() ) )
1377  {
1378  SCCOL nStartX, nEndX, nClipStartX, nClipSizeX, nRangeSizeX;
1379  SCROW nStartY, nEndY, nClipStartY, nClipSizeY, nRangeSizeY;
1380  SCTAB nStartTab, nEndTab;
1381  pOwnClip->GetDocument()->GetClipStart( nClipStartX, nClipStartY );
1382  pOwnClip->GetDocument()->GetClipArea( nClipSizeX, nClipSizeY, true );
1383 
1384  if ( pData->GetSimpleArea( nStartX, nStartY, nStartTab,
1385  nEndX, nEndY, nEndTab ) != SC_MARK_SIMPLE ||
1386  nStartTab != nEndTab )
1387  {
1388  // the destination is not a simple range,
1389  // assume the destination as the current cell
1390  nStartX = nEndX = pData->GetCurX();
1391  nStartY = nEndY = pData->GetCurY();
1392  nStartTab = pData->GetTabNo();
1393  }
1394  // we now have clip- and range dimensions
1395  // the size of the destination area is the larger of the two
1396  nRangeSizeX = nClipSizeX >= nEndX - nStartX ? nClipSizeX : nEndX - nStartX;
1397  nRangeSizeY = nClipSizeY >= nEndY - nStartY ? nClipSizeY : nEndY - nStartY;
1398  // When the source and destination areas intersect things may go wrong,
1399  // especially if the area contains references. This may produce data loss
1400  // (e.g. formulas that get wrong references), this scenario _must_ be avoided.
1401  ScRange aSource( nClipStartX, nClipStartY, nStartTab,
1402  nClipStartX + nClipSizeX, nClipStartY + nClipSizeY, nStartTab );
1403  ScRange aDest( nStartX, nStartY, nStartTab,
1404  nStartX + nRangeSizeX, nStartY + nRangeSizeY, nStartTab );
1405  if ( pOwnClip->GetDocument()->IsCutMode() && aSource.Intersects( aDest ) )
1407  else
1408  {
1409  //no conflict with intersecting ranges,
1410  //check if paste plus shift will fit on sheet
1411  //and disable shift-option if no fit
1414 
1415  //check if horizontal shift will fit
1416  if ( !pData->GetDocument()->IsBlockEmpty( nStartTab,
1417  pDoc->MaxCol() - nRangeSizeX, nStartY,
1418  pDoc->MaxCol(), nStartY + nRangeSizeY ) )
1419  nDisableShiftX = CellShiftDisabledFlags::Right;
1420 
1421  //check if vertical shift will fit
1422  if ( !pData->GetDocument()->IsBlockEmpty( nStartTab,
1423  nStartX, pDoc->MaxRow() - nRangeSizeY,
1424  nStartX + nRangeSizeX, pDoc->MaxRow() ) )
1425  nDisableShiftY = CellShiftDisabledFlags::Down;
1426 
1427  if ( nDisableShiftX != CellShiftDisabledFlags::NONE || nDisableShiftY != CellShiftDisabledFlags::NONE)
1428  pDlg->SetCellShiftDisabled( nDisableShiftX | nDisableShiftY );
1429  }
1430  }
1431  }
1432  if (pDlg->Execute() == RET_OK)
1433  {
1434  nFlags = pDlg->GetInsContentsCmdBits();
1435  nFunction = pDlg->GetFormulaCmdBits();
1436  bSkipEmpty = pDlg->IsSkipEmptyCells();
1437  bTranspose = pDlg->IsTranspose();
1438  bAsLink = pDlg->IsLink();
1439  eMoveMode = pDlg->GetMoveMode();
1440  }
1441  }
1442  else
1443  pTabViewShell->ErrorMessage(aTester.GetMessageId());
1444  }
1445 
1446  if( nFlags != InsertDeleteFlags::NONE )
1447  {
1448  {
1449  weld::WaitObject aWait( GetViewData()->GetDialogParent() );
1450  if ( bAsLink && bOtherDoc )
1451  pTabViewShell->PasteFromSystem(SotClipboardFormatId::LINK); // DDE insert
1452  else
1453  {
1454  pTabViewShell->PasteFromClip( nFlags, pOwnClip->GetDocument(),
1455  nFunction, bSkipEmpty, bTranspose, bAsLink,
1456  eMoveMode, InsertDeleteFlags::NONE, true ); // allow warning dialog
1457  }
1458  }
1459 
1460  if( !pReqArgs )
1461  {
1462  OUString aFlags = FlagsToString( nFlags );
1463 
1464  rReq.AppendItem( SfxStringItem( FID_INS_CELL_CONTENTS, aFlags ) );
1465  rReq.AppendItem( SfxBoolItem( FN_PARAM_2, bSkipEmpty ) );
1466  rReq.AppendItem( SfxBoolItem( FN_PARAM_3, bTranspose ) );
1467  rReq.AppendItem( SfxBoolItem( FN_PARAM_4, bAsLink ) );
1468  rReq.AppendItem( SfxUInt16Item( FN_PARAM_1, static_cast<sal_uInt16>(nFunction) ) );
1469  rReq.AppendItem( SfxInt16Item( FN_PARAM_5, static_cast<sal_Int16>(eMoveMode) ) );
1470  rReq.Done();
1471  }
1472  }
1473  }
1474  }
1475  pTabViewShell->CellContentChanged(); // => PasteFromXXX ???
1476  break;
1477  case SID_PASTE_ONLY_VALUE:
1478  case SID_PASTE_ONLY_TEXT:
1479  case SID_PASTE_ONLY_FORMULA:
1480  {
1481  if ( ScTransferObj::GetOwnClipboard(ScTabViewShell::GetClipData(GetViewData()->GetActiveWin())) ) // own cell data
1482  {
1483  rReq.SetSlot( FID_INS_CELL_CONTENTS );
1484  OUString aFlags;
1485  if ( nSlot == SID_PASTE_ONLY_VALUE )
1486  aFlags = "V";
1487  else if ( nSlot == SID_PASTE_ONLY_TEXT )
1488  aFlags = "S";
1489  else
1490  aFlags = "F";
1491  rReq.AppendItem( SfxStringItem( FID_INS_CELL_CONTENTS, aFlags ) );
1492  ExecuteSlot( rReq, GetInterface() );
1493  rReq.SetReturnValue(SfxInt16Item(nSlot, 1)); // 1 = success
1494  pTabViewShell->CellContentChanged();
1495  }
1496  else
1497  rReq.SetReturnValue(SfxInt16Item(nSlot, 0)); // 0 = fail
1498  break;
1499  }
1500  case SID_PASTE_TEXTIMPORT_DIALOG:
1501  {
1502  vcl::Window* pWin = GetViewData()->GetActiveWin();
1503  TransferableDataHelper aDataHelper(
1505  const uno::Reference<datatransfer::XTransferable>& xTransferable
1506  = aDataHelper.GetTransferable();
1507  SotClipboardFormatId format = SotClipboardFormatId::STRING;
1508  bool bSuccess = false;
1509  if (xTransferable.is() && HasClipboardFormat(format))
1510  {
1511  OUString sStrBuffer;
1512  bSuccess = aDataHelper.GetString(format, sStrBuffer);
1513  if (bSuccess)
1514  {
1515  auto pStrm = std::make_shared<ScImportStringStream>(sStrBuffer);
1517  VclPtr<AbstractScImportAsciiDlg> pDlg(pFact->CreateScImportAsciiDlg(
1518  pWin ? pWin->GetFrameWeld() : nullptr, OUString(), pStrm.get(), SC_PASTETEXT));
1519  ScRange aRange;
1520  SCCOL nPosX = 0;
1521  SCROW nPosY = 0;
1522  if (GetViewData()->GetSimpleArea(aRange) == SC_MARK_SIMPLE)
1523  {
1524  nPosX = aRange.aStart.Col();
1525  nPosY = aRange.aStart.Row();
1526  }
1527  else
1528  {
1529  nPosX = GetViewData()->GetCurX();
1530  nPosY = GetViewData()->GetCurY();
1531  }
1532  ScAddress aCellPos(nPosX, nPosY, GetViewData()->GetTabNo());
1533  auto pObj = std::make_shared<ScImportExport>(GetViewData()->GetDocument(), aCellPos);
1534  pObj->SetOverwriting(true);
1535  if (pDlg->Execute()) {
1536  ScAsciiOptions aOptions;
1537  pDlg->GetOptions(aOptions);
1538  pDlg->SaveParameters();
1539  pObj->SetExtOptions(aOptions);
1540  pObj->ImportString(sStrBuffer, format);
1541  }
1542  pDlg->disposeOnce();
1543  rReq.SetReturnValue(SfxInt16Item(nSlot, 1)); // 1 = success, 0 = fail
1544  rReq.Done();
1545  }
1546  }
1547  if (!bSuccess)
1548  {
1549  rReq.SetReturnValue(SfxInt16Item(nSlot, 0)); // 0 = fail
1550  rReq.Ignore();
1551  }
1552  }
1553  break;
1554  case SID_PASTE_SPECIAL:
1555  // differentiate between own cell data and draw objects/external data
1556  // this makes FID_INS_CELL_CONTENTS superfluous
1557  {
1558  vcl::Window* pWin = GetViewData()->GetActiveWin();
1559  css::uno::Reference<css::datatransfer::XTransferable2> xTransferable(ScTabViewShell::GetClipData(pWin));
1560 
1561  // Clipboard-ID given as parameter? Basic "PasteSpecial(Format)"
1562  const SfxPoolItem* pItem=nullptr;
1563  if ( pReqArgs &&
1564  pReqArgs->GetItemState(nSlot, true, &pItem) == SfxItemState::SET &&
1565  dynamic_cast<const SfxUInt32Item*>( pItem) != nullptr )
1566  {
1567  SotClipboardFormatId nFormat = static_cast<SotClipboardFormatId>(static_cast<const SfxUInt32Item*>(pItem)->GetValue());
1568  bool bRet=true;
1569  {
1570  weld::WaitObject aWait( GetViewData()->GetDialogParent() );
1571  bool bDraw = ( ScDrawTransferObj::GetOwnClipboard(xTransferable) != nullptr );
1572  if ( bDraw && nFormat == SotClipboardFormatId::EMBED_SOURCE )
1573  pTabViewShell->PasteDraw();
1574  else
1575  bRet = pTabViewShell->PasteFromSystem(nFormat, true); // TRUE: no error messages
1576  }
1577 
1578  if ( bRet )
1579  {
1580  rReq.SetReturnValue(SfxInt16Item(nSlot, 1)); // 1 = success, 0 = fail
1581  rReq.Done();
1582  }
1583  else
1584  // if format is not available -> fallback to request without parameters
1585  pItem = nullptr;
1586  }
1587 
1588  if ( !pItem )
1589  {
1590  if ( ScTransferObj::GetOwnClipboard(xTransferable) ) // own cell data
1591  {
1592  rReq.SetSlot( FID_INS_CELL_CONTENTS );
1593  ExecuteSlot( rReq, GetInterface() );
1594  rReq.SetReturnValue(SfxInt16Item(nSlot, 1)); // 1 = success
1595  }
1596  else // draw objects or external data
1597  {
1598  bool bDraw = ( ScDrawTransferObj::GetOwnClipboard(xTransferable) != nullptr );
1599 
1600  SvxClipboardFormatItem aFormats( SID_CLIPBOARD_FORMAT_ITEMS );
1601  GetPossibleClipboardFormats( aFormats );
1602 
1603  sal_uInt16 nFormatCount = aFormats.Count();
1604  if ( nFormatCount )
1605  {
1607  ScopedVclPtr<SfxAbstractPasteDialog> pDlg(pFact->CreatePasteDialog(pTabViewShell->GetFrameWeld()));
1608  for (sal_uInt16 i=0; i<nFormatCount; i++)
1609  {
1610  SotClipboardFormatId nFormatId = aFormats.GetClipbrdFormatId( i );
1611  OUString aName = aFormats.GetClipbrdFormatName( i );
1612  // special case for paste dialog: '*' is replaced by object type
1613  if ( nFormatId == SotClipboardFormatId::EMBED_SOURCE )
1614  aName = "*";
1615  pDlg->Insert( nFormatId, aName );
1616  }
1617 
1618  SfxViewFrame* pViewFrame = pTabViewShell->GetViewFrame();
1619  auto xFrame = pViewFrame->GetFrame().GetFrameInterface();
1620  const OUString aModuleName(vcl::CommandInfoProvider::GetModuleIdentifier(xFrame));
1621  auto aProperties = vcl::CommandInfoProvider::GetCommandProperties(".uno:PasteTextImportDialog", aModuleName);
1623  pDlg->InsertUno(".uno:PasteTextImportDialog", sLabel);
1624 
1625  TransferableDataHelper aDataHelper(
1627  SotClipboardFormatId nFormat = pDlg->GetFormat( aDataHelper.GetTransferable() );
1628  if (nFormat != SotClipboardFormatId::NONE)
1629  {
1630  {
1631  weld::WaitObject aWait( GetViewData()->GetDialogParent() );
1632  if ( bDraw && nFormat == SotClipboardFormatId::EMBED_SOURCE )
1633  pTabViewShell->PasteDraw();
1634  else
1635  pTabViewShell->PasteFromSystem(nFormat);
1636  }
1637  rReq.SetReturnValue(SfxInt16Item(nSlot, 1)); // 1 = success
1638  rReq.AppendItem( SfxUInt32Item( nSlot, static_cast<sal_uInt32>(nFormat) ) );
1639  rReq.Done();
1640  }
1641  else
1642  {
1643  rReq.SetReturnValue(SfxInt16Item(nSlot, 0)); // 0 = fail
1644  rReq.Ignore();
1645  }
1646  }
1647  else
1648  rReq.SetReturnValue(SfxInt16Item(nSlot, 0)); // 0 = fail
1649  }
1650  }
1651  }
1652  pTabViewShell->CellContentChanged(); // => PasteFromSystem() ???
1653  break;
1654 
1655  case SID_PASTE_UNFORMATTED:
1656  // differentiate between own cell data and draw objects/external data
1657  // this makes FID_INS_CELL_CONTENTS superfluous
1658  {
1659  weld::WaitObject aWait( GetViewData()->GetDialogParent() );
1660 
1661  // we should differentiate between SotClipboardFormatId::STRING and SotClipboardFormatId::STRING_TSVC,
1662  // and paste the SotClipboardFormatId::STRING_TSVC if it is available.
1663  // Which makes a difference if the clipboard contains cells with embedded line breaks.
1664 
1665  SotClipboardFormatId nFormat = HasClipboardFormat( SotClipboardFormatId::STRING_TSVC) ?
1666  SotClipboardFormatId::STRING_TSVC : SotClipboardFormatId::STRING;
1667 
1668  const bool bRet = pTabViewShell->PasteFromSystem(nFormat, true); // TRUE: no error messages
1669  if ( bRet )
1670  {
1671  rReq.SetReturnValue(SfxInt16Item(nSlot, 1)); // 1 = success
1672  rReq.Done();
1673  }
1674  else
1675  {
1676  rReq.SetReturnValue(SfxInt16Item(nSlot, 0)); // 0 = fail
1677  }
1678 
1679  pTabViewShell->CellContentChanged(); // => PasteFromSystem() ???
1680  }
1681  break;
1682 
1683  // other
1684 
1685  case FID_INS_ROWBRK:
1686  pTabViewShell->InsertPageBreak( false );
1687  rReq.Done();
1688  break;
1689 
1690  case FID_INS_COLBRK:
1691  pTabViewShell->InsertPageBreak( true );
1692  rReq.Done();
1693  break;
1694 
1695  case FID_DEL_ROWBRK:
1696  pTabViewShell->DeletePageBreak( false );
1697  rReq.Done();
1698  break;
1699 
1700  case FID_DEL_COLBRK:
1701  pTabViewShell->DeletePageBreak( true );
1702  rReq.Done();
1703  break;
1704 
1705  case SID_DETECTIVE_ADD_PRED:
1706  pTabViewShell->DetectiveAddPred();
1707  rReq.Done();
1708  break;
1709 
1710  case SID_DETECTIVE_DEL_PRED:
1711  pTabViewShell->DetectiveDelPred();
1712  rReq.Done();
1713  break;
1714 
1715  case SID_DETECTIVE_ADD_SUCC:
1716  pTabViewShell->DetectiveAddSucc();
1717  rReq.Done();
1718  break;
1719 
1720  case SID_DETECTIVE_DEL_SUCC:
1721  pTabViewShell->DetectiveDelSucc();
1722  rReq.Done();
1723  break;
1724 
1725  case SID_DETECTIVE_ADD_ERR:
1726  pTabViewShell->DetectiveAddError();
1727  rReq.Done();
1728  break;
1729 
1730  case SID_DETECTIVE_INVALID:
1731  pTabViewShell->DetectiveMarkInvalid();
1732  rReq.Done();
1733  break;
1734 
1735  case SID_DETECTIVE_REFRESH:
1736  pTabViewShell->DetectiveRefresh();
1737  rReq.Done();
1738  break;
1739 
1740  case SID_DETECTIVE_MARK_PRED:
1741  pTabViewShell->DetectiveMarkPred();
1742  break;
1743  case SID_DETECTIVE_MARK_SUCC:
1744  pTabViewShell->DetectiveMarkSucc();
1745  break;
1746  case SID_INSERT_CURRENT_DATE:
1747  pTabViewShell->InsertCurrentTime(
1748  SvNumFormatType::DATE, ScResId(STR_UNDO_INSERT_CURRENT_DATE));
1749  break;
1750  case SID_INSERT_CURRENT_TIME:
1751  pTabViewShell->InsertCurrentTime(
1752  SvNumFormatType::TIME, ScResId(STR_UNDO_INSERT_CURRENT_TIME));
1753  break;
1754 
1755  case SID_SPELL_DIALOG:
1756  {
1757  SfxViewFrame* pViewFrame = pTabViewShell->GetViewFrame();
1758  if( rReq.GetArgs() )
1759  pViewFrame->SetChildWindow( SID_SPELL_DIALOG,
1760  static_cast< const SfxBoolItem& >( rReq.GetArgs()->
1761  Get( SID_SPELL_DIALOG ) ).GetValue() );
1762  else
1763  pViewFrame->ToggleChildWindow( SID_SPELL_DIALOG );
1764 
1765  pViewFrame->GetBindings().Invalidate( SID_SPELL_DIALOG );
1766  rReq.Ignore();
1767  }
1768  break;
1769 
1770  case SID_HANGUL_HANJA_CONVERSION:
1771  pTabViewShell->DoHangulHanjaConversion();
1772  break;
1773 
1774  case SID_CHINESE_CONVERSION:
1775  {
1776  //open ChineseTranslationDialog
1778  ::cppu::defaultBootstrap_InitialComponentContext() ); //@todo get context from calc if that has one
1779  if(xContext.is())
1780  {
1781  Reference< lang::XMultiComponentFactory > xMCF( xContext->getServiceManager() );
1782  if(xMCF.is())
1783  {
1784  Reference< ui::dialogs::XExecutableDialog > xDialog(
1785  xMCF->createInstanceWithContext(
1786  "com.sun.star.linguistic2.ChineseTranslationDialog"
1787  , xContext),
1788  UNO_QUERY);
1789  Reference< lang::XInitialization > xInit( xDialog, UNO_QUERY );
1790  if( xInit.is() )
1791  {
1792  // initialize dialog
1793  uno::Sequence<uno::Any> aSeq(comphelper::InitAnyPropertySequence(
1794  {
1795  {"ParentWindow", uno::Any(Reference< awt::XWindow >())}
1796  }));
1797  xInit->initialize( aSeq );
1798 
1799  //execute dialog
1800  sal_Int16 nDialogRet = xDialog->execute();
1801  if( RET_OK == nDialogRet )
1802  {
1803  //get some parameters from the dialog
1804  bool bToSimplified = true;
1805  bool bUseVariants = true;
1806  bool bCommonTerms = true;
1807  Reference< beans::XPropertySet > xProp( xDialog, UNO_QUERY );
1808  if( xProp.is() )
1809  {
1810  try
1811  {
1812  xProp->getPropertyValue("IsDirectionToSimplified") >>= bToSimplified;
1813  xProp->getPropertyValue("IsUseCharacterVariants") >>= bUseVariants;
1814  xProp->getPropertyValue("IsTranslateCommonTerms") >>= bCommonTerms;
1815  }
1816  catch( Exception& )
1817  {
1818  }
1819  }
1820 
1821  //execute translation
1824  sal_Int32 nOptions = bUseVariants ? i18n::TextConversionOption::USE_CHARACTER_VARIANTS : 0;
1825  if( !bCommonTerms )
1826  nOptions |= i18n::TextConversionOption::CHARACTER_BY_CHARACTER;
1827 
1829  DefaultFontType::CJK_SPREADSHEET,
1830  eTargetLang, GetDefaultFontFlags::OnlyOne );
1832  eSourceLang, eTargetLang, aTargetFont, nOptions, false );
1833  pTabViewShell->DoSheetConversion( aConvParam );
1834  }
1835  }
1836  Reference< lang::XComponent > xComponent( xDialog, UNO_QUERY );
1837  if( xComponent.is() )
1838  xComponent->dispose();
1839  }
1840  }
1841  }
1842  break;
1843 
1844  case SID_CONVERT_FORMULA_TO_VALUE:
1845  {
1846  pTabViewShell->ConvertFormulaToValue();
1847  }
1848  break;
1849  case SID_THESAURUS:
1850  pTabViewShell->DoThesaurus();
1851  break;
1852 
1853  case SID_TOGGLE_REL:
1854  pTabViewShell->DoRefConversion();
1855  break;
1856 
1857  case SID_DEC_INDENT:
1858  pTabViewShell->ChangeIndent( false );
1859  break;
1860  case SID_INC_INDENT:
1861  pTabViewShell->ChangeIndent( true );
1862  break;
1863 
1864  case FID_USE_NAME:
1865  {
1866  CreateNameFlags nFlags = pTabViewShell->GetCreateNameFlags();
1867 
1869 
1870  ScopedVclPtr<AbstractScNameCreateDlg> pDlg(pFact->CreateScNameCreateDlg(pTabViewShell->GetFrameWeld(), nFlags));
1871 
1872  if( pDlg->Execute() )
1873  {
1874  pTabViewShell->CreateNames(pDlg->GetFlags());
1875  rReq.Done();
1876  }
1877  }
1878  break;
1879 
1880  case SID_CONSOLIDATE:
1881  {
1882  const SfxPoolItem* pItem;
1883  if ( pReqArgs && SfxItemState::SET ==
1884  pReqArgs->GetItemState( SCITEM_CONSOLIDATEDATA, true, &pItem ) )
1885  {
1886  const ScConsolidateParam& rParam =
1887  static_cast<const ScConsolidateItem*>(pItem)->GetData();
1888 
1889  pTabViewShell->Consolidate( rParam );
1890  GetViewData()->GetDocument()->SetConsolidateDlgData( std::unique_ptr<ScConsolidateParam>(new ScConsolidateParam(rParam)) );
1891 
1892  rReq.Done();
1893  }
1894 #if HAVE_FEATURE_SCRIPTING
1895  else if (rReq.IsAPI())
1897 #endif
1898  }
1899  break;
1900 
1901  case SID_INS_FUNCTION:
1902  {
1903  const SfxBoolItem* pOkItem = static_cast<const SfxBoolItem*>(&pReqArgs->Get( SID_DLG_RETOK ));
1904 
1905  if ( pOkItem->GetValue() ) // OK
1906  {
1907  OUString aFormula;
1908  const SfxStringItem* pSItem = static_cast<const SfxStringItem*>(&pReqArgs->Get( SCITEM_STRING ));
1909  const SfxBoolItem* pMatrixItem = static_cast<const SfxBoolItem*>(&pReqArgs->Get( SID_DLG_MATRIX ));
1910 
1911  aFormula += pSItem->GetValue();
1912  pScMod->ActivateInputWindow( &aFormula, pMatrixItem->GetValue() );
1913  }
1914  else // CANCEL
1915  {
1916  pScMod->ActivateInputWindow();
1917  }
1918  rReq.Ignore(); // only SID_ENTER_STRING is recorded
1919  }
1920  break;
1921 
1922  case FID_DEFINE_NAME:
1923  case FID_DEFINE_CURRENT_NAME:
1924  if ( pReqArgs )
1925  {
1926  const SfxPoolItem* pItem;
1927  OUString aName, aSymbol, aAttrib;
1928 
1929  if( pReqArgs->HasItem( FID_DEFINE_NAME, &pItem ) )
1930  aName = static_cast<const SfxStringItem*>(pItem)->GetValue();
1931 
1932  if( pReqArgs->HasItem( FN_PARAM_1, &pItem ) )
1933  aSymbol = static_cast<const SfxStringItem*>(pItem)->GetValue();
1934 
1935  if( pReqArgs->HasItem( FN_PARAM_2, &pItem ) )
1936  aAttrib = static_cast<const SfxStringItem*>(pItem)->GetValue();
1937 
1938  if ( !aName.isEmpty() && !aSymbol.isEmpty() )
1939  {
1940  if (pTabViewShell->InsertName( aName, aSymbol, aAttrib ))
1941  rReq.Done();
1942 #if HAVE_FEATURE_SCRIPTING
1943  else
1945 #endif
1946  }
1947  }
1948  else
1949  {
1950  sal_uInt16 nId = ScNameDlgWrapper::GetChildWindowId();
1951  SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
1952  SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
1953 
1954  pScMod->SetRefDialog( nId, pWnd == nullptr );
1955  }
1956  break;
1957  case FID_ADD_NAME:
1958  {
1959  sal_uInt16 nId = ScNameDefDlgWrapper::GetChildWindowId();
1960  SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
1961  SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
1962 
1963  pScMod->SetRefDialog( nId, pWnd == nullptr );
1964  }
1965  break;
1966 
1967  case SID_OPENDLG_CONDFRMT:
1968  case SID_OPENDLG_CURRENTCONDFRMT:
1969  case SID_OPENDLG_COLORSCALE:
1970  case SID_OPENDLG_DATABAR:
1971  case SID_OPENDLG_ICONSET:
1972  case SID_OPENDLG_CONDDATE:
1973  {
1974  sal_uInt32 nIndex = sal_uInt32(-1);
1975  bool bManaged = false;
1976 
1977  // Get the pool item stored by Conditional Format Manager Dialog.
1978  auto itemsRange = pTabViewShell->GetPool().GetItemSurrogates(SCITEM_CONDFORMATDLGDATA);
1979  if (itemsRange.begin() != itemsRange.end())
1980  {
1981  const ScCondFormatDlgItem* pDlgItem = static_cast<const ScCondFormatDlgItem*>(*itemsRange.begin());
1982  nIndex = pDlgItem->GetIndex();
1983  bManaged = true;
1984  }
1985 
1986  // Check if the Conditional Manager Dialog is editing or adding
1987  // conditional format item.
1988  if ( bManaged )
1989  {
1990  sal_uInt16 nId = ScCondFormatDlgWrapper::GetChildWindowId();
1991  SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
1992  SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
1993 
1994  pScMod->SetRefDialog( nId, pWnd == nullptr );
1995  break;
1996  }
1997 
1998  ScRangeList aRangeList;
2000  pData->GetMarkData().FillRangeListWithMarks(&aRangeList, false);
2001 
2002  ScDocument* pDoc = GetViewData()->GetDocument();
2003  if(pDoc->IsTabProtected(pData->GetTabNo()))
2004  {
2005  pTabViewShell->ErrorMessage( STR_ERR_CONDFORMAT_PROTECTED );
2006  break;
2007  }
2008 
2009  ScAddress aPos(pData->GetCurX(), pData->GetCurY(), pData->GetTabNo());
2010  if(aRangeList.empty())
2011  {
2012  aRangeList.push_back(ScRange(aPos));
2013  }
2014 
2015  // try to find an existing conditional format
2016  const ScConditionalFormat* pCondFormat = nullptr;
2017  const ScPatternAttr* pPattern = pDoc->GetPattern(aPos.Col(), aPos.Row(), aPos.Tab());
2018  ScConditionalFormatList* pList = pDoc->GetCondFormList(aPos.Tab());
2019  const ScCondFormatIndexes& rCondFormats = pPattern->GetItem(ATTR_CONDITIONAL).GetCondFormatData();
2020  bool bContainsCondFormat = !rCondFormats.empty();
2021  bool bCondFormatDlg = false;
2022  bool bContainsExistingCondFormat = false;
2023  if(bContainsCondFormat)
2024  {
2025  for (const auto& rCondFormat : rCondFormats)
2026  {
2027  // check if at least one existing conditional format has the same range
2028  pCondFormat = pList->GetFormat(rCondFormat);
2029  if(!pCondFormat)
2030  continue;
2031 
2032  bContainsExistingCondFormat = true;
2033  const ScRangeList& rCondFormatRange = pCondFormat->GetRange();
2034  if(rCondFormatRange == aRangeList)
2035  {
2036  // found a matching range, edit this conditional format
2037  bCondFormatDlg = true;
2038  nIndex = pCondFormat->GetKey();
2039  break;
2040  }
2041  }
2042  }
2043 
2044  // do we have a parameter with the conditional formatting type?
2045  const SfxInt16Item* pParam = rReq.GetArg<SfxInt16Item>(FN_PARAM_1);
2046  if (pParam && nSlot == SID_OPENDLG_ICONSET)
2047  {
2048  auto pFormat = std::make_unique<ScConditionalFormat>(0, pDoc);
2049  pFormat->SetRange(aRangeList);
2050 
2052  const int nSteps = ScIconSetFormat::getIconSetElements(eIconSetType);
2053 
2054  ScIconSetFormat* pEntry = new ScIconSetFormat(pDoc);
2055  ScIconSetFormatData* pIconSetFormatData = new ScIconSetFormatData(eIconSetType);
2056 
2057  pIconSetFormatData->m_Entries.emplace_back(new ScColorScaleEntry(0, COL_RED, COLORSCALE_PERCENT));
2058  pIconSetFormatData->m_Entries.emplace_back(new ScColorScaleEntry(round(100. / nSteps), COL_BROWN, COLORSCALE_PERCENT));
2059  pIconSetFormatData->m_Entries.emplace_back(new ScColorScaleEntry(round(200. / nSteps), COL_YELLOW, COLORSCALE_PERCENT));
2060  if (nSteps > 3)
2061  pIconSetFormatData->m_Entries.emplace_back(new ScColorScaleEntry(round(300. / nSteps), COL_WHITE, COLORSCALE_PERCENT));
2062  if (nSteps > 4)
2063  pIconSetFormatData->m_Entries.emplace_back(new ScColorScaleEntry(round(400. / nSteps), COL_GREEN, COLORSCALE_PERCENT));
2064 
2065  pEntry->SetIconSetData(pIconSetFormatData);
2066  pFormat->AddEntry(pEntry);
2067 
2068  // use the new conditional formatting
2069  GetViewData()->GetDocShell()->GetDocFunc().ReplaceConditionalFormat(nIndex, std::move(pFormat), aPos.Tab(), aRangeList);
2070 
2071  break;
2072  }
2073 
2074  // if not found a conditional format ask whether we should edit one of the existing
2075  // or should create a new overlapping conditional format
2076  if(bContainsCondFormat && !bCondFormatDlg && bContainsExistingCondFormat)
2077  {
2078  std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(pTabViewShell->GetFrameWeld(),
2079  VclMessageType::Question, VclButtonsType::YesNo,
2080  ScResId(STR_EDIT_EXISTING_COND_FORMATS)));
2081  xQueryBox->set_default_response(RET_YES);
2082  bool bEditExisting = xQueryBox->run() == RET_YES;
2083  if (bEditExisting)
2084  {
2085  // differentiate between ranges where one conditional format is defined
2086  // and several formats are defined
2087  // if we have only one => open the cond format dlg to edit it
2088  // otherwise open the manage cond format dlg
2089  if (rCondFormats.size() == 1)
2090  {
2091  pCondFormat = pList->GetFormat(rCondFormats[0]);
2092  assert(pCondFormat);
2093  bCondFormatDlg = true;
2094  }
2095  else
2096  {
2097  // Queue message to open Conditional Format Manager Dialog.
2098  GetViewData()->GetDispatcher().Execute( SID_OPENDLG_CONDFRMT_MANAGER, SfxCallMode::ASYNCHRON );
2099  break;
2100  }
2101  }
2102  else
2103  {
2104  // define an overlapping conditional format
2105  // does not need to be handled here
2106  }
2107  }
2108 
2110  switch(nSlot)
2111  {
2112  case SID_OPENDLG_CONDFRMT:
2113  case SID_OPENDLG_CURRENTCONDFRMT:
2115  break;
2116  case SID_OPENDLG_COLORSCALE:
2118  break;
2119  case SID_OPENDLG_DATABAR:
2121  break;
2122  case SID_OPENDLG_ICONSET:
2124  break;
2125  case SID_OPENDLG_CONDDATE:
2126  eType = condformat::dialog::DATE;
2127  break;
2128  default:
2129  assert(false);
2130  break;
2131  }
2132 
2133 
2134  if(bCondFormatDlg || !bContainsCondFormat)
2135  {
2136  // Put the xml string parameter to initialize the
2137  // Conditional Format Dialog.
2138  ScCondFormatDlgItem aDlgItem(nullptr, nIndex, false);
2139  aDlgItem.SetDialogType(eType);
2140  pTabViewShell->GetPool().Put(aDlgItem);
2141 
2142  sal_uInt16 nId = ScCondFormatDlgWrapper::GetChildWindowId();
2143  SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
2144  SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
2145 
2146  pScMod->SetRefDialog( nId, pWnd == nullptr );
2147  }
2148  }
2149  break;
2150 
2151  case SID_DEFINE_COLROWNAMERANGES:
2152  {
2153 
2154  sal_uInt16 nId = ScColRowNameRangesDlgWrapper::GetChildWindowId();
2155  SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
2156  SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
2157 
2158  pScMod->SetRefDialog( nId, pWnd == nullptr );
2159 
2160  }
2161  break;
2162 
2163  case SID_UPDATECHART:
2164  {
2165  bool bAll = false;
2166 
2167  if( pReqArgs )
2168  {
2169  const SfxPoolItem* pItem;
2170 
2171  if( pReqArgs->HasItem( SID_UPDATECHART, &pItem ) )
2172  bAll = static_cast<const SfxBoolItem*>(pItem)->GetValue();
2173  }
2174 
2175  pTabViewShell->UpdateCharts( bAll );
2176 
2177  if( ! rReq.IsAPI() )
2178  {
2179  rReq.AppendItem( SfxBoolItem( SID_UPDATECHART, bAll ) );
2180  rReq.Done();
2181  }
2182  }
2183  break;
2184 
2185  case SID_TABOP:
2186  if (pReqArgs)
2187  {
2188  const ScTabOpItem& rItem =
2189  static_cast<const ScTabOpItem&>(
2190  pReqArgs->Get( SID_TABOP ));
2191 
2192  pTabViewShell->TabOp( rItem.GetData() );
2193 
2194  rReq.Done( *pReqArgs );
2195  }
2196  break;
2197 
2198  case SID_SOLVE:
2199  if (pReqArgs)
2200  {
2201  const ScSolveItem& rItem =
2202  static_cast<const ScSolveItem&>(
2203  pReqArgs->Get( SCITEM_SOLVEDATA ));
2204 
2205  pTabViewShell->Solve( rItem.GetData() );
2206 
2207  rReq.Done( *pReqArgs );
2208  }
2209  break;
2210 
2211  case FID_INSERT_NAME:
2212  {
2214 
2216  switch( pDlg->Execute() )
2217  {
2218  case BTN_PASTE_LIST:
2219  pTabViewShell->InsertNameList();
2220  break;
2221  case BTN_PASTE_NAME:
2222  {
2223  ScInputHandler* pHdl = pScMod->GetInputHdl( pTabViewShell );
2224  if (pHdl)
2225  {
2226  // "=" in KeyEvent, switches to input-mode
2227  (void)pScMod->InputKeyEvent( KeyEvent('=', vcl::KeyCode()) );
2228 
2229  std::vector<OUString> aNames = pDlg->GetSelectedNames();
2230  if (!aNames.empty())
2231  {
2232  OUStringBuffer aBuffer;
2233  for (const auto& rName : aNames)
2234  {
2235  aBuffer.append(rName).append(' ');
2236  }
2237  pHdl->InsertFunction( aBuffer.makeStringAndClear(), false ); // without "()"
2238  }
2239  }
2240  }
2241  break;
2242  }
2243  }
2244  break;
2245 
2246  case SID_RANGE_NOTETEXT:
2247  if (pReqArgs)
2248  {
2249  const SfxStringItem& rTextItem = static_cast<const SfxStringItem&>(pReqArgs->Get( SID_RANGE_NOTETEXT ));
2250 
2251  // always cursor position
2252  ScAddress aPos( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
2253  pTabViewShell->SetNoteText( aPos, rTextItem.GetValue() );
2254  rReq.Done();
2255  }
2256  break;
2257 
2258  case SID_INSERT_POSTIT:
2259  case SID_EDIT_POSTIT:
2260  {
2261  const SfxPoolItem* pText;
2262  if ( pReqArgs && pReqArgs->HasItem( SID_ATTR_POSTIT_TEXT, &pText) )
2263  {
2264  const SfxPoolItem* pCellId;
2265  OUString aCellId;
2266  // SID_ATTR_POSTIT_ID only argument for SID_EDIT_POSTIT
2267  if (pReqArgs->HasItem( SID_ATTR_POSTIT_ID, &pCellId ))
2268  aCellId = static_cast<const SvxPostItIdItem*>(pCellId)->GetValue();
2269 
2270  const SvxPostItTextItem* pTextItem = static_cast<const SvxPostItTextItem*>( pText );
2271  const SvxPostItAuthorItem* pAuthorItem = pReqArgs->GetItem( SID_ATTR_POSTIT_AUTHOR );
2272  const SvxPostItDateItem* pDateItem = pReqArgs->GetItem( SID_ATTR_POSTIT_DATE );
2273 
2274  if (!aCellId.isEmpty())
2275  {
2276  SetTabNoAndCursor( GetViewData(), aCellId );
2277  }
2278 
2279  ScAddress aPos( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
2280  pTabViewShell->ReplaceNote( aPos, pTextItem->GetValue(),
2281  pAuthorItem ? &pAuthorItem->GetValue() : nullptr,
2282  pDateItem ? &pDateItem->GetValue() : nullptr );
2283  }
2285  {
2286  pTabViewShell->EditNote(); // note object to edit
2287  }
2288  rReq.Done();
2289  }
2290  break;
2291 
2292  case FID_NOTE_VISIBLE:
2293  {
2294  ScDocument* pDoc = GetViewData()->GetDocument();
2295  ScAddress aPos( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
2296  if( ScPostIt* pNote = pDoc->GetNote(aPos) )
2297  {
2298  bool bShow;
2299  const SfxPoolItem* pItem;
2300  if ( pReqArgs && (pReqArgs->GetItemState( FID_NOTE_VISIBLE, true, &pItem ) == SfxItemState::SET) )
2301  bShow = static_cast<const SfxBoolItem*>(pItem)->GetValue();
2302  else
2303  bShow = !pNote->IsCaptionShown();
2304 
2305  pTabViewShell->ShowNote( bShow );
2306 
2307  if (!pReqArgs)
2308  rReq.AppendItem( SfxBoolItem( FID_NOTE_VISIBLE, bShow ) );
2309 
2310  rReq.Done();
2311  rBindings.Invalidate( FID_NOTE_VISIBLE );
2312  }
2313  else
2314  rReq.Ignore();
2315  }
2316  break;
2317 
2318  case FID_HIDE_NOTE:
2319  case FID_SHOW_NOTE:
2320  {
2321  bool bShowNote = nSlot == FID_SHOW_NOTE;
2323  ScDocument* pDoc = pData->GetDocument();
2324  ScMarkData& rMark = pData->GetMarkData();
2325 
2326  if (!rMark.IsMarked() && !rMark.IsMultiMarked())
2327  {
2328  // Check current cell
2329  ScAddress aPos( pData->GetCurX(), pData->GetCurY(), pData->GetTabNo() );
2330  if( pDoc->GetNote(aPos) )
2331  {
2332  pData->GetDocShell()->GetDocFunc().ShowNote( aPos, bShowNote );
2333  }
2334  }
2335  else
2336  {
2337  // Check selection range
2338  bool bDone = false;
2339  ScRangeListRef aRangesRef;
2340  pData->GetMultiArea(aRangesRef);
2341  const ScRangeList aRanges = *aRangesRef;
2342 
2343  OUString aUndo = ScResId( bShowNote ? STR_UNDO_SHOWNOTE : STR_UNDO_HIDENOTE );
2344  pData->GetDocShell()->GetUndoManager()->EnterListAction( aUndo, aUndo, 0, pData->GetViewShell()->GetViewShellId() );
2345 
2346  for (auto const& rTab : rMark.GetSelectedTabs())
2347  {
2348  // get notes
2349  std::vector<sc::NoteEntry> aNotes;
2350  pDoc->GetAllNoteEntries(rTab, aNotes);
2351 
2352  for (const sc::NoteEntry& rNote : aNotes)
2353  {
2354  // check if note is in our selection range
2355  const ScAddress& rAdr = rNote.maPos;
2356  const ScRange* rRange = aRanges.Find(rAdr);
2357  if (! rRange)
2358  continue;
2359 
2360  // check if cell is editable
2361  const SCTAB nRangeTab = rRange->aStart.Tab();
2362  if (pDoc->IsBlockEditable( nRangeTab, rAdr.Col(), rAdr.Row(), rAdr.Col(), rAdr.Row() ))
2363  {
2364  pData->GetDocShell()->GetDocFunc().ShowNote( rAdr, bShowNote );
2365  bDone = true;
2366  }
2367  }
2368  }
2369 
2371 
2372  if ( bDone )
2373  {
2374  rReq.Done();
2375  rBindings.Invalidate( nSlot );
2376  }
2377  else
2378  rReq.Ignore();
2379  }
2380 
2381  }
2382  break;
2383 
2384  case FID_SHOW_ALL_NOTES:
2385  case FID_HIDE_ALL_NOTES:
2386  {
2387  bool bShowNote = nSlot == FID_SHOW_ALL_NOTES;
2389  ScMarkData& rMark = pData->GetMarkData();
2390  ScDocument* pDoc = pData->GetDocument();
2391  std::vector<sc::NoteEntry> aNotes;
2392 
2393  OUString aUndo = ScResId( bShowNote ? STR_UNDO_SHOWALLNOTES : STR_UNDO_HIDEALLNOTES );
2394  pData->GetDocShell()->GetUndoManager()->EnterListAction( aUndo, aUndo, 0, pData->GetViewShell()->GetViewShellId() );
2395 
2396  for (auto const& rTab : rMark.GetSelectedTabs())
2397  {
2398  pDoc->GetAllNoteEntries(rTab, aNotes);
2399  }
2400 
2401  for (const sc::NoteEntry& rNote : aNotes)
2402  {
2403  const ScAddress& rAdr = rNote.maPos;
2404  pData->GetDocShell()->GetDocFunc().ShowNote( rAdr, bShowNote );
2405  }
2406 
2408  }
2409  break;
2410 
2411  case SID_TOGGLE_NOTES:
2412  {
2414  ScMarkData& rMark = pData->GetMarkData();
2415  ScDocument* pDoc = pData->GetDocument();
2416  ScRangeList aRanges;
2417  std::vector<sc::NoteEntry> aNotes;
2418 
2419  for (auto const& rTab : rMark.GetSelectedTabs())
2420  aRanges.push_back(ScRange(0,0,rTab,pDoc->MaxCol(),pDoc->MaxRow(),rTab));
2421 
2422  CommentCaptionState eState = pDoc->GetAllNoteCaptionsState( aRanges );
2423  pDoc->GetNotesInRange(aRanges, aNotes);
2424  bool bShowNote = (eState == ALLHIDDEN || eState == MIXED);
2425 
2426  OUString aUndo = ScResId( bShowNote ? STR_UNDO_SHOWALLNOTES : STR_UNDO_HIDEALLNOTES );
2427  pData->GetDocShell()->GetUndoManager()->EnterListAction( aUndo, aUndo, 0, pData->GetViewShell()->GetViewShellId() );
2428 
2429  for(const auto& rNote : aNotes)
2430  {
2431  const ScAddress& rAdr = rNote.maPos;
2432  pData->GetDocShell()->GetDocFunc().ShowNote( rAdr, bShowNote );
2433  }
2434 
2436 
2437  if (!pReqArgs)
2438  rReq.AppendItem( SfxBoolItem( SID_TOGGLE_NOTES, bShowNote ) );
2439 
2440  rReq.Done();
2441  rBindings.Invalidate( SID_TOGGLE_NOTES );
2442  }
2443  break;
2444 
2445  case SID_DELETE_NOTE:
2446  {
2447  const SfxPoolItem* pId;
2448  // If Id is mentioned, select the appropriate cell first
2449  if ( pReqArgs && pReqArgs->HasItem( SID_ATTR_POSTIT_ID, &pId) )
2450  {
2451  const SvxPostItIdItem* pIdItem = static_cast<const SvxPostItIdItem*>(pId);
2452  const OUString& aCellId = pIdItem->GetValue();
2453  if (!aCellId.isEmpty())
2454  {
2455  SetTabNoAndCursor( GetViewData(), aCellId );
2456  }
2457  }
2458 
2459  pTabViewShell->DeleteContents( InsertDeleteFlags::NOTE ); // delete all notes in selection
2460  rReq.Done();
2461  }
2462  break;
2463 
2464  case FID_DELETE_ALL_NOTES:
2465  {
2467  ScMarkData& rMark = pData->GetMarkData();
2468  ScDocument* pDoc = pData->GetDocument();
2469  ScMarkData aNewMark(pDoc->GetSheetLimits());
2470  ScRangeList aRangeList;
2471 
2472  for (auto const& rTab : rMark.GetSelectedTabs())
2473  {
2474  aRangeList.push_back(ScRange(0,0,rTab,pDoc->MaxCol(),pDoc->MaxRow(),rTab));
2475  }
2476 
2477  aNewMark.MarkFromRangeList( aRangeList, true );
2478  pData->GetDocShell()->GetDocFunc().DeleteContents(aNewMark, InsertDeleteFlags::NOTE, true, false );
2479  }
2480  break;
2481 
2482  case SID_CHARMAP:
2483  if( pReqArgs != nullptr )
2484  {
2485  OUString aChars, aFontName;
2486  const SfxItemSet *pArgs = rReq.GetArgs();
2487  const SfxPoolItem* pItem = nullptr;
2488  if ( pArgs )
2489  pArgs->GetItemState(GetPool().GetWhich(SID_CHARMAP), false, &pItem);
2490  if ( pItem )
2491  {
2492  const SfxStringItem* pStringItem = dynamic_cast<const SfxStringItem*>( pItem );
2493  if ( pStringItem )
2494  aChars = pStringItem->GetValue();
2495  const SfxPoolItem* pFtItem = nullptr;
2496  pArgs->GetItemState( GetPool().GetWhich(SID_ATTR_SPECIALCHAR), false, &pFtItem);
2497  const SfxStringItem* pFontItem = dynamic_cast<const SfxStringItem*>( pFtItem );
2498  if ( pFontItem )
2499  aFontName = pFontItem->GetValue();
2500  }
2501 
2502  if ( !aChars.isEmpty() )
2503  {
2504  vcl::Font aFont;
2505  pTabViewShell->GetSelectionPattern()->GetFont( aFont, SC_AUTOCOL_BLACK, nullptr, nullptr, nullptr,
2506  pTabViewShell->GetSelectionScriptType() );
2507  if ( !aFontName.isEmpty() )
2508  aFont = vcl::Font( aFontName, Size(1,1) );
2509  pTabViewShell->InsertSpecialChar( aChars, aFont );
2510  if( ! rReq.IsAPI() )
2511  rReq.Done();
2512  }
2513  }
2514  else
2515  {
2517 
2518  // font color doesn't matter here
2519  vcl::Font aCurFont;
2520  pTabViewShell->GetSelectionPattern()->GetFont( aCurFont, SC_AUTOCOL_BLACK, nullptr, nullptr, nullptr,
2521  pTabViewShell->GetSelectionScriptType() );
2522 
2523  SfxAllItemSet aSet( GetPool() );
2524  aSet.Put( SfxBoolItem( FN_PARAM_1, false ) );
2525  aSet.Put( SvxFontItem( aCurFont.GetFamilyType(), aCurFont.GetFamilyName(), aCurFont.GetStyleName(), aCurFont.GetPitch(), aCurFont.GetCharSet(), GetPool().GetWhich(SID_ATTR_CHAR_FONT) ) );
2526  SfxViewFrame* pViewFrame = pTabViewShell->GetViewFrame();
2527  auto xFrame = pViewFrame->GetFrame().GetFrameInterface();
2528  ScopedVclPtr<SfxAbstractDialog> pDlg(pFact->CreateCharMapDialog(pTabViewShell->GetFrameWeld(), aSet, xFrame));
2529  pDlg->Execute();
2530  }
2531  break;
2532 
2533  case SID_SELECT_SCENARIO:
2534  {
2535  // Testing
2536 
2537  if ( pReqArgs )
2538  {
2539  const SfxStringItem& rItem
2540  = static_cast<const SfxStringItem&>(pReqArgs->Get(SID_SELECT_SCENARIO));
2541  pTabViewShell->UseScenario(rItem.GetValue());
2543  rReq.SetReturnValue(SfxStringItem(SID_SELECT_SCENARIO, rItem.GetValue()));
2544  rReq.Done();
2545  }
2546  }
2547  break;
2548 
2549  case SID_HYPERLINK_SETLINK:
2550  if( pReqArgs )
2551  {
2552  const SfxPoolItem* pItem;
2553  if( pReqArgs->HasItem( SID_HYPERLINK_SETLINK, &pItem ) )
2554  {
2555  const SvxHyperlinkItem* pHyper = static_cast<const SvxHyperlinkItem*>(pItem);
2556  const OUString& rName = pHyper->GetName();
2557  const OUString& rURL = pHyper->GetURL();
2558  const OUString& rTarget = pHyper->GetTargetFrame();
2559  sal_uInt16 nType = static_cast<sal_uInt16>(pHyper->GetInsertMode());
2560 
2561  pTabViewShell->InsertURL( rName, rURL, rTarget, nType );
2562  rReq.Done();
2563  }
2564  else
2565  rReq.Ignore();
2566  }
2567  break;
2568 
2569  case SID_OPENDLG_CONDFRMT_MANAGER:
2570  case SID_OPENDLG_CURRENTCONDFRMT_MANAGER:
2571  {
2573 
2575  ScDocument* pDoc = pData->GetDocument();
2576 
2577  if(pDoc->IsTabProtected(pData->GetTabNo()))
2578  {
2579  pTabViewShell->ErrorMessage( STR_ERR_CONDFORMAT_PROTECTED );
2580  break;
2581  }
2582 
2583  ScAddress aPos(pData->GetCurX(), pData->GetCurY(), pData->GetTabNo());
2584 
2585  ScConditionalFormatList* pList = nullptr;
2586 
2587  const ScCondFormatDlgItem* pDlgItem = nullptr;
2588  auto itemsRange = pTabViewShell->GetPool().GetItemSurrogates(SCITEM_CONDFORMATDLGDATA);
2589  if (itemsRange.begin() != itemsRange.end())
2590  {
2591  pDlgItem= static_cast<const ScCondFormatDlgItem*>(*itemsRange.begin());
2592  pList = const_cast<ScCondFormatDlgItem*>(pDlgItem)->GetConditionalFormatList();
2593  }
2594 
2595  if (!pList)
2596  pList = pDoc->GetCondFormList( aPos.Tab() );
2597 
2599  pTabViewShell->GetFrameWeld(), pDoc, pList));
2600 
2601  if (pDlgItem)
2602  pDlg->SetModified();
2603 
2604  pDlg->StartExecuteAsync([this, pDlg, pData, pTabViewShell, pDlgItem, aPos](sal_Int32 nRet){
2605  std::unique_ptr<ScConditionalFormatList> pCondFormatList = pDlg->GetConditionalFormatList();
2606  if(nRet == RET_OK && pDlg->CondFormatsChanged())
2607  {
2608  pData->GetDocShell()->GetDocFunc().SetConditionalFormatList(pCondFormatList.release(), aPos.Tab());
2609  }
2610  else if(nRet == DLG_RET_ADD)
2611  {
2612  // Put the xml string parameter to initialize the
2613  // Conditional Format Dialog. ( add new )
2614  pTabViewShell->GetPool().Put(ScCondFormatDlgItem(
2615  std::shared_ptr<ScConditionalFormatList>(pCondFormatList.release()), -1, true));
2616  // Queue message to open Conditional Format Dialog
2617  GetViewData()->GetDispatcher().Execute( SID_OPENDLG_CONDFRMT, SfxCallMode::ASYNCHRON );
2618  }
2619  else if (nRet == DLG_RET_EDIT)
2620  {
2621  ScConditionalFormat* pFormat = pDlg->GetCondFormatSelected();
2622  sal_Int32 nIndex = pFormat ? pFormat->GetKey() : -1;
2623  // Put the xml string parameter to initialize the
2624  // Conditional Format Dialog. ( edit selected conditional format )
2625  pTabViewShell->GetPool().Put(ScCondFormatDlgItem(
2626  std::shared_ptr<ScConditionalFormatList>(pCondFormatList.release()), nIndex, true));
2627 
2628  // Queue message to open Conditional Format Dialog
2629  GetViewData()->GetDispatcher().Execute( SID_OPENDLG_CONDFRMT, SfxCallMode::ASYNCHRON );
2630  }
2631  else
2632  pCondFormatList.reset();
2633 
2634  if (pDlgItem)
2635  pTabViewShell->GetPool().Remove(*pDlgItem);
2636 
2637  pDlg->disposeOnce();
2638  });
2639  }
2640  break;
2641 
2642  case SID_EXTERNAL_SOURCE:
2643  {
2644  const SfxStringItem* pFile = rReq.GetArg<SfxStringItem>(SID_FILE_NAME);
2645  const SfxStringItem* pSource = rReq.GetArg<SfxStringItem>(FN_PARAM_1);
2646  if ( pFile && pSource )
2647  {
2648  OUString aFile;
2649  OUString aFilter;
2650  OUString aOptions;
2651  OUString aSource;
2652  sal_uLong nRefresh=0;
2653 
2654  aFile = pFile->GetValue();
2655  aSource = pSource->GetValue();
2656  const SfxStringItem* pFilter = rReq.GetArg<SfxStringItem>(SID_FILTER_NAME);
2657  if ( pFilter )
2658  aFilter = pFilter->GetValue();
2659  const SfxStringItem* pOptions = rReq.GetArg<SfxStringItem>(SID_FILE_FILTEROPTIONS);
2660  if ( pOptions )
2661  aOptions = pOptions->GetValue();
2662  const SfxUInt32Item* pRefresh = rReq.GetArg<SfxUInt32Item>(FN_PARAM_2);
2663  if ( pRefresh )
2664  nRefresh = pRefresh->GetValue();
2665 
2666  ExecuteExternalSource( aFile, aFilter, aOptions, aSource, nRefresh, rReq );
2667  }
2668  else
2669  {
2671 
2672  pImpl->m_pLinkedDlg.disposeAndClear();
2673  pImpl->m_pLinkedDlg =
2674  pFact->CreateScLinkedAreaDlg(pTabViewShell->GetFrameWeld());
2675  delete pImpl->m_pRequest;
2676  pImpl->m_pRequest = new SfxRequest( rReq );
2677  OUString sFile, sFilter, sOptions, sSource;
2678  sal_uLong nRefresh = 0;
2679  if (pImpl->m_pLinkedDlg->Execute() == RET_OK)
2680  {
2681  sFile = pImpl->m_pLinkedDlg->GetURL();
2682  sFilter = pImpl->m_pLinkedDlg->GetFilter();
2683  sOptions = pImpl->m_pLinkedDlg->GetOptions();
2684  sSource = pImpl->m_pLinkedDlg->GetSource();
2685  nRefresh = pImpl->m_pLinkedDlg->GetRefresh();
2686  if ( !sFile.isEmpty() )
2687  pImpl->m_pRequest->AppendItem( SfxStringItem( SID_FILE_NAME, sFile ) );
2688  if ( !sFilter.isEmpty() )
2689  pImpl->m_pRequest->AppendItem( SfxStringItem( SID_FILTER_NAME, sFilter ) );
2690  if ( !sOptions.isEmpty() )
2691  pImpl->m_pRequest->AppendItem( SfxStringItem( SID_FILE_FILTEROPTIONS, sOptions ) );
2692  if ( !sSource.isEmpty() )
2693  pImpl->m_pRequest->AppendItem( SfxStringItem( FN_PARAM_1, sSource ) );
2694  if ( nRefresh )
2695  pImpl->m_pRequest->AppendItem( SfxUInt32Item( FN_PARAM_2, nRefresh ) );
2696  }
2697 
2698  ExecuteExternalSource( sFile, sFilter, sOptions, sSource, nRefresh, *(pImpl->m_pRequest) );
2699  }
2700  }
2701  break;
2702 
2703  case SID_AUTO_SUM:
2704  {
2705  bool bSubTotal = false;
2706  bool bRangeFinder = false;
2707  const OUString aFormula = pTabViewShell->DoAutoSum( bRangeFinder, bSubTotal , ocSum );
2708  if ( !aFormula.isEmpty() )
2709  {
2710  const sal_Int32 nPar = aFormula.indexOf( '(' );
2711  const sal_Int32 nLen = aFormula.getLength();
2712  ScInputHandler* pHdl = pScMod->GetInputHdl( pTabViewShell );
2713 
2714  if ( pHdl && nPar != -1 )
2715  {
2716  if ( !pScMod->IsEditMode() )
2717  {
2718  pScMod->SetInputMode( SC_INPUT_TABLE );
2719  }
2720 
2721  EditView *pEditView=pHdl->GetActiveView();
2722  if ( pEditView )
2723  {
2724  ESelection aTextSel = pEditView->GetSelection();
2725  aTextSel.nStartPos = 0;
2726  aTextSel.nEndPos = EE_TEXTPOS_ALL;
2727  pHdl->DataChanging();
2728  pEditView->SetSelection(aTextSel);
2729  pEditView->InsertText(aFormula);
2730  pEditView->SetSelection( bRangeFinder ? ESelection( 0, nPar + ( bSubTotal ? 3 : 1 ), 0, nLen - 1 ) : ESelection( 0, nLen - 1, 0, nLen - 1 ) );
2731  pHdl->DataChanged();
2732 
2733  if ( bRangeFinder )
2734  {
2735  pHdl->InitRangeFinder( aFormula );
2736  }
2737  }
2738  }
2739  }
2740  }
2741  break;
2742 
2743  case SID_SELECT_UNPROTECTED_CELLS:
2744  {
2746  SCTAB aTab = pData->GetTabNo();
2747  ScMarkData& rMark = pData->GetMarkData();
2748  ScDocument* pDoc = pData->GetDocument();
2749  ScRangeList rRangeList;
2750 
2751  pDoc->GetUnprotectedCells(rRangeList, aTab);
2752  rMark.MarkFromRangeList(rRangeList, true);
2753  pTabViewShell->SetMarkData(rMark);
2754  }
2755  break;
2756 
2757  default:
2758  OSL_FAIL("incorrect slot in ExecuteEdit");
2759  break;
2760  }
2761 }
2762 
2764 {
2766  if ( nType != TransliterationFlags::NONE )
2767  {
2768  GetViewData()->GetView()->TransliterateText( nType );
2769  rReq.Done();
2770  }
2771 }
2772 
2774 {
2775  if( rReq.GetSlot() == SID_TRANSLITERATE_ROTATE_CASE )
2777 }
2778 
2780  const OUString& _rFile, const OUString& _rFilter, const OUString& _rOptions,
2781  const OUString& _rSource, sal_uLong _nRefresh, SfxRequest& _rRequest )
2782 {
2783  if ( !_rFile.isEmpty() && !_rSource.isEmpty() ) // filter may be empty
2784  {
2785  ScRange aLinkRange;
2786  bool bMove = false;
2787 
2789  ScMarkData& rMark = pData->GetMarkData();
2790  rMark.MarkToSimple();
2791  if ( rMark.IsMarked() )
2792  {
2793  rMark.GetMarkArea( aLinkRange );
2794  bMove = true; // insert/delete cells to fit range
2795  }
2796  else
2797  aLinkRange = ScRange( pData->GetCurX(), pData->GetCurY(), pData->GetTabNo() );
2798 
2799  pData->GetDocFunc().InsertAreaLink( _rFile, _rFilter, _rOptions, _rSource,
2800  aLinkRange, _nRefresh, bMove, false );
2801  _rRequest.Done();
2802  }
2803  else
2804  _rRequest.Ignore();
2805 }
2806 
2807 namespace {
2808 
2809 bool isDPSourceValid(const ScDPObject& rDPObj)
2810 {
2811  if (rDPObj.IsImportData())
2812  {
2813  // If the data type is database, check if the database is still valid.
2814  const ScImportSourceDesc* pDesc = rDPObj.GetImportSourceDesc();
2815  if (!pDesc)
2816  return false;
2817 
2818  const ScDPSaveData* pSaveData = rDPObj.GetSaveData();
2819  const ScDPDimensionSaveData* pDimData = nullptr;
2820  if (pSaveData)
2821  pDimData = pSaveData->GetExistingDimensionData();
2822 
2823  const ScDPCache* pCache = pDesc->CreateCache(pDimData);
2824  if (!pCache)
2825  // cache creation failed, probably due to invalid connection.
2826  return false;
2827  }
2828  return true;
2829 }
2830 
2831 }
2832 
2834 {
2835  ScModule* pScMod = SC_MOD();
2836  ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
2838  ScDocument* pDoc = pData->GetDocument();
2839 
2840  std::unique_ptr<ScDPObject> pNewDPObject;
2841 
2842  // ScPivot is no longer used...
2843  ScDPObject* pDPObj = pDoc->GetDPAtCursor(
2844  pData->GetCurX(), pData->GetCurY(),
2845  pData->GetTabNo() );
2846  if ( pDPObj ) // on an existing table?
2847  {
2848  if (isDPSourceValid(*pDPObj))
2849  pNewDPObject.reset(new ScDPObject(*pDPObj));
2850  }
2851  else // create new table
2852  {
2853  const char* pSrcErrorId = nullptr;
2854 
2855  // select database range or data
2856  pTabViewShell->GetDBData( true, SC_DB_OLD );
2857  ScMarkData& rMark = GetViewData()->GetMarkData();
2858  if ( !rMark.IsMarked() && !rMark.IsMultiMarked() )
2859  pTabViewShell->MarkDataArea( false );
2860 
2861  // output to cursor position for non-sheet data
2862  ScAddress aDestPos( pData->GetCurX(), pData->GetCurY(),
2863  pData->GetTabNo() );
2864 
2865  // first select type of source data
2866 
2867  bool bEnableExt = ScDPObject::HasRegisteredSources();
2868 
2870 
2873  pTabViewShell->GetFrameWeld(), bEnableExt));
2874 
2875  // Populate named ranges (if any).
2876  ScRangeName* pRangeName = pDoc->GetRangeName();
2877  if (pRangeName)
2878  {
2879  ScRangeName::const_iterator itr = pRangeName->begin(), itrEnd = pRangeName->end();
2880  for (; itr != itrEnd; ++itr)
2881  pTypeDlg->AppendNamedRange(itr->second->GetName());
2882  }
2883 
2884  if ( pTypeDlg->Execute() == RET_OK )
2885  {
2886  if ( pTypeDlg->IsExternal() )
2887  {
2888  std::vector<OUString> aSources = ScDPObject::GetRegisteredSources();
2891  pTabViewShell->GetFrameWeld(), aSources));
2892 
2893  if ( pServDlg->Execute() == RET_OK )
2894  {
2895  ScDPServiceDesc aServDesc(
2896  pServDlg->GetServiceName(),
2897  pServDlg->GetParSource(),
2898  pServDlg->GetParName(),
2899  pServDlg->GetParUser(),
2900  pServDlg->GetParPass() );
2901  pNewDPObject.reset(new ScDPObject(pDoc));
2902  pNewDPObject->SetServiceData( aServDesc );
2903  }
2904  }
2905  else if ( pTypeDlg->IsDatabase() )
2906  {
2907  assert(pFact && "ScAbstractFactory create fail!");
2909  pFact->CreateScDataPilotDatabaseDlg(pTabViewShell->GetFrameWeld()));
2910  assert(pDataDlg && "Dialog create fail!");
2911  if ( pDataDlg->Execute() == RET_OK )
2912  {
2913  ScImportSourceDesc aImpDesc(pDoc);
2914  pDataDlg->GetValues( aImpDesc );
2915  pNewDPObject.reset(new ScDPObject(pDoc));
2916  pNewDPObject->SetImportDesc( aImpDesc );
2917  }
2918  }
2919  else if (pTypeDlg->IsNamedRange())
2920  {
2921  OUString aName = pTypeDlg->GetSelectedNamedRange();
2922  ScSheetSourceDesc aShtDesc(pDoc);
2923  aShtDesc.SetRangeName(aName);
2924  pSrcErrorId = aShtDesc.CheckSourceRange();
2925  if (!pSrcErrorId)
2926  {
2927  pNewDPObject.reset(new ScDPObject(pDoc));
2928  pNewDPObject->SetSheetDesc(aShtDesc);
2929  }
2930  }
2931  else // selection
2932  {
2934  ScRange aRange;
2936  if ( (eType & SC_MARK_SIMPLE) == SC_MARK_SIMPLE )
2937  {
2938  // Shrink the range to the data area.
2939  SCCOL nStartCol = aRange.aStart.Col(), nEndCol = aRange.aEnd.Col();
2940  SCROW nStartRow = aRange.aStart.Row(), nEndRow = aRange.aEnd.Row();
2941  if (pDoc->ShrinkToDataArea(aRange.aStart.Tab(), nStartCol, nStartRow, nEndCol, nEndRow))
2942  {
2943  aRange.aStart.SetCol(nStartCol);
2944  aRange.aStart.SetRow(nStartRow);
2945  aRange.aEnd.SetCol(nEndCol);
2946  aRange.aEnd.SetRow(nEndRow);
2947  rMark.SetMarkArea(aRange);
2948  pTabViewShell->MarkRange(aRange);
2949  }
2950 
2951  bool bOK = true;
2952  if ( pDoc->HasSubTotalCells( aRange ) )
2953  {
2954  // confirm selection if it contains SubTotal cells
2955  std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(pTabViewShell->GetFrameWeld(),
2956  VclMessageType::Question, VclButtonsType::YesNo,
2957  ScResId(STR_DATAPILOT_SUBTOTAL)));
2958  xQueryBox->set_default_response(RET_YES);
2959  if (xQueryBox->run() == RET_NO)
2960  bOK = false;
2961  }
2962  if (bOK)
2963  {
2964  ScSheetSourceDesc aShtDesc(pDoc);
2965  aShtDesc.SetSourceRange(aRange);
2966  pSrcErrorId = aShtDesc.CheckSourceRange();
2967  if (!pSrcErrorId)
2968  {
2969  pNewDPObject.reset(new ScDPObject(pDoc));
2970  pNewDPObject->SetSheetDesc( aShtDesc );
2971  }
2972 
2973  // output below source data
2974  if ( aRange.aEnd.Row()+2 <= pDoc->MaxRow() - 4 )
2975  aDestPos = ScAddress( aRange.aStart.Col(),
2976  aRange.aEnd.Row()+2,
2977  aRange.aStart.Tab() );
2978  }
2979  }
2980  }
2981  }
2982 
2983  if (pSrcErrorId)
2984  {
2985  // Error occurred during data creation. Launch an error and bail out.
2986  std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pTabViewShell->GetFrameWeld(),
2987  VclMessageType::Info, VclButtonsType::Ok,
2988  ScResId(pSrcErrorId)));
2989  xInfoBox->run();
2990  return;
2991  }
2992 
2993  if ( pNewDPObject )
2994  pNewDPObject->SetOutRange( aDestPos );
2995  }
2996 
2997  bool bHadNewDPObject = pNewDPObject != nullptr;
2998  pTabViewShell->SetDialogDPObject( std::move(pNewDPObject) );
2999  if ( bHadNewDPObject )
3000  {
3001  // start layout dialog
3002 
3003  sal_uInt16 nId = ScPivotLayoutWrapper::GetChildWindowId();
3004  SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
3005  SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
3006  pScMod->SetRefDialog( nId, pWnd == nullptr );
3007  }
3008 }
3009 
3011 {
3012  ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
3013  if (!pTabViewShell)
3014  return;
3015 
3016  ScModule* pScMod = SC_MOD();
3017 
3018  sal_uInt16 nId = ScXMLSourceDlgWrapper::GetChildWindowId();
3019  SfxViewFrame* pViewFrame = pTabViewShell->GetViewFrame();
3020  SfxChildWindow* pWnd = pViewFrame->GetChildWindow(nId);
3021  pScMod->SetRefDialog(nId, pWnd == nullptr);
3022 }
3023 
3025 {
3026  ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
3027  const SfxItemSet* pArgs = rReq.GetArgs();
3028  if ( pArgs )
3029  {
3030  pTabViewShell->DoSubTotals( static_cast<const ScSubTotalItem&>( pArgs->Get( SCITEM_SUBTDATA )).
3031  GetSubTotalData() );
3032  rReq.Done();
3033  return;
3034  }
3035 
3037  ScSubTotalParam aSubTotalParam;
3039 
3040  bool bAnonymous;
3041 
3042  // Only get existing named database range.
3043  ScDBData* pDBData = pTabViewShell->GetDBData(true, SC_DB_OLD);
3044  if (pDBData)
3045  bAnonymous = false;
3046  else
3047  {
3048  // No existing DB data at this position. Create an
3049  // anonymous DB.
3050  bAnonymous = true;
3051  pDBData = pTabViewShell->GetAnonymousDBData();
3052  ScRange aDataRange;
3053  pDBData->GetArea(aDataRange);
3054  pTabViewShell->MarkRange(aDataRange, false);
3055  }
3056 
3057  pDBData->GetSubTotalParam( aSubTotalParam );
3058  aSubTotalParam.bRemoveOnly = false;
3059  if (bAnonymous)
3060  {
3061  // Preset sort formatting along with values and also create formula
3062  // cells with "needs formatting". Subtotals on data of different types
3063  // doesn't make much sense anyway.
3064  aSubTotalParam.bIncludePattern = true;
3065  }
3066 
3067  aArgSet.Put( ScSubTotalItem( SCITEM_SUBTDATA, GetViewData(), &aSubTotalParam ) );
3069  pDlg.disposeAndReset(pFact->CreateScSubTotalDlg(pTabViewShell->GetFrameWeld(), &aArgSet));
3070  pDlg->SetCurPageId("1stgroup");
3071 
3072  short bResult = pDlg->Execute();
3073 
3074  if ( (bResult == RET_OK) || (bResult == SCRET_REMOVE) )
3075  {
3076  const SfxItemSet* pOutSet = nullptr;
3077 
3078  if ( bResult == RET_OK )
3079  {
3080  pOutSet = pDlg->GetOutputItemSet();
3081  aSubTotalParam =
3082  static_cast<const ScSubTotalItem&>(
3083  pOutSet->Get( SCITEM_SUBTDATA )).
3084  GetSubTotalData();
3085  }
3086  else // if (bResult == SCRET_REMOVE)
3087  {
3088  pOutSet = &aArgSet;
3089  aSubTotalParam.bRemoveOnly = true;
3090  aSubTotalParam.bReplace = true;
3091  aArgSet.Put( ScSubTotalItem( SCITEM_SUBTDATA,
3092  GetViewData(),
3093  &aSubTotalParam ) );
3094  }
3095 
3096  pTabViewShell->DoSubTotals( aSubTotalParam );
3097  rReq.Done( *pOutSet );
3098  }
3099  else
3101 }
3102 
3104 {
3105  ScAddress aCurPos = GetViewData()->GetCurPos();
3106 
3107  OUString aInit;
3108 
3109  if (aCurPos.Row() > 0)
3110  {
3111  // Get the initial text value from the above cell.
3112 
3113  ScDocument* pDoc = GetViewData()->GetDocument();
3114  ScAddress aPrevPos = aCurPos;
3115  aPrevPos.IncRow(-1);
3116  ScRefCellValue aCell(*pDoc, aPrevPos);
3117 
3118  if (aCell.meType == CELLTYPE_FORMULA)
3119  {
3120  aInit = "=";
3121  const ScTokenArray* pCode = aCell.mpFormula->GetCode();
3122  sc::TokenStringContext aCxt(pDoc, pDoc->GetGrammar());
3123  aInit += pCode->CreateString(aCxt, aCurPos);
3124  }
3125  else
3126  aInit = aCell.getString(pDoc);
3127  }
3128 
3129  SC_MOD()->SetInputMode(SC_INPUT_TABLE, &aInit);
3130 }
3131 
3133  m_pLinkedDlg(),
3134  m_pRequest( nullptr ) {}
3135 
3137 {
3138 }
3139 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void AppendNamedRange(const OUString &rName)=0
ScMarkData & GetMarkData()
Definition: viewdata.cxx:3053
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:93
SC_DLLPUBLIC void InsertPageBreak(bool bColumn, bool bRecord=true, const ScAddress *pPos=nullptr, bool bSetModified=true)
Definition: viewfun2.cxx:941
SfxViewFrame * GetViewFrame() const
ScDBFunc * GetView() const
Definition: viewdata.hxx:356
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:5330
Numeric values (and numeric results if InsertDeleteFlags::FORMULA is not set).
const ScDPDimensionSaveData * GetExistingDimensionData() const
Definition: dpsave.hxx:348
SC_DLLPUBLIC ScDPObject * GetDPAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab) const
Definition: documen3.cxx:358
CreateNameFlags GetCreateNameFlags()
Definition: viewfunc.cxx:2918
void DeleteContents(InsertDeleteFlags nFlags)
Definition: viewfunc.cxx:1937
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:2111
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:2779
void MarkDataArea(bool bIncludeCursor=true)
Definition: tabview3.cxx:1644
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:3173
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
constexpr::Color COL_BROWN(0x80, 0x80, 0x00)
void ShowDataPilotSourceData(ScDPObject &rDPObj, const css::uno::Sequence< css::sheet::DataPilotFieldFilter > &rFilters)
Definition: dbfunc3.cxx:2030
void UngroupDataPilot()
Definition: dbfunc3.cxx:1260
void SetConsolidateDlgData(std::unique_ptr< ScConsolidateParam > pData)
Definition: documen2.cxx:1104
SC_DLLPUBLIC bool IsTabProtected(SCTAB nTab) const
Definition: documen3.cxx:1871
SC_DLLPUBLIC void GetInputString(SCCOL nCol, SCROW nRow, SCTAB nTab, OUString &rString)
Definition: document.cxx:3543
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
Definition: markdata.hxx:43
This class has to do with handling exclusively grouped dimensions? TODO: Find out what this class doe...
Definition: dpdimsave.hxx:160
SCROW GetRefEndY() const
Definition: viewdata.hxx:519
SfxChildWindow * GetChildWindow(sal_uInt16)
const OUString & GetFamilyName() const
bool IsEditMode()
Definition: scmod.cxx:1341
SC_DLLPUBLIC bool CopyToClip(ScDocument *pClipDoc, bool bCut, bool bApi=false, bool bIncludeObjects=false, bool bStopEdit=true)
Definition: viewfun3.cxx:165
virtual void SetOtherDoc(bool bSet)=0
SC_DLLPUBLIC bool DeleteContents(const ScMarkData &rMark, InsertDeleteFlags nFlags, bool bRecord, bool bApi)
Definition: docfunc.cxx:566
void CreateNames(CreateNameFlags nFlags)
Definition: viewfunc.cxx:2907
OUString GetTooltipLabelForCommand(const css::uno::Sequence< css::beans::PropertyValue > &rProperties)
SCROW Row() const
Definition: address.hxx:262
OUString getString(const ScDocument *pDoc) const
Retrieve string value.
Definition: cellvalue.cxx:660
virtual InsCellCmd GetInsCellCmd() const =0
void SetDialogDPObject(std::unique_ptr< ScDPObject > pObj)
Definition: tabvwsh4.cxx:1797
FillDir
Definition: global.hxx:318
void DoSheetConversion(const ScConversionParam &rParam)
Generic implementation of sheet conversion functions.
Definition: viewfun4.cxx:441
void FillTab(InsertDeleteFlags nFlags, ScPasteFunc nFunction, bool bSkipEmpty, bool bAsLink)
Definition: viewfun2.cxx:1609
std::unique_ptr< ContentProperties > pData
virtual const SfxItemSet * GetOutputItemSet() const =0
std::string GetValue
const OUString & GetStyleName() const
virtual bool GetColsChecked() const =0
virtual VclPtr< AbstractScDeleteCellDlg > CreateScDeleteCellDlg(weld::Window *pParent, bool bDisallowCellMove)=0
ScViewData * GetViewData()
Definition: formatsh.hxx:35
void DeleteCells(DelCellCmd eCmd)
Definition: viewfunc.cxx:1654
void MarkRange(const ScRange &rRange, bool bSetCursor=true, bool bContinue=false)
Definition: tabview3.cxx:1675
constexpr::Color COL_RED(0x80, 0x00, 0x00)
const OUString & GetTargetFrame() const
sal_uInt16 char char * pDesc
Definition: callform.cxx:58
bool DataChanging(sal_Unicode cTyped=0, bool bFromCommand=false)
Definition: inputhdl.cxx:2566
SC_DLLPUBLIC bool Intersects(const ScRange &rRange) const
Definition: address.cxx:1553
void GetOutputString(const double &fOutNumber, sal_uInt32 nFIndex, OUString &sOutString, Color **ppColor, bool bUseStarFormat=false)
void ExecuteEdit(SfxRequest &rReq)
Definition: cellsh1.cxx:171
virtual ScDPNumGroupInfo GetGroupInfo() const =0
#define FDS_OPT_VERT
Definition: scui_def.hxx:30
static SvxAbstractDialogFactory * Create()
ScTokenArray * GetCode()
void InsertNameList()
Definition: viewfunc.cxx:2980
sal_uIntPtr sal_uLong
virtual VclPtr< AbstractScDPShowDetailDlg > CreateScDPShowDetailDlg(weld::Window *pParent, ScDPObject &rDPObj, css::sheet::DataPilotFieldOrientation nOrient)=0
Reference< XFrame > xFrame
virtual FillDateCmd GetFillDateCmd() const =0
virtual VclPtr< AbstractScNamePasteDlg > CreateScNamePasteDlg(weld::Window *pParent, ScDocShell *pShell)=0
virtual void GetOptions(ScAsciiOptions &rOpt)=0
void SetPasteMode(ScPasteFlags nFlags)
Definition: viewdata.hxx:448
SCROW GetCurY() const
Definition: viewdata.hxx:402
SC_DLLPUBLIC ScRangeName * GetRangeName(SCTAB nTab) const
Definition: documen3.cxx:168
virtual OUString GetStartStr() const =0
ScDocFunc & GetDocFunc() const
Definition: viewdata.cxx:3036
virtual VclPtr< AbstractScInsertContentsDlg > CreateScInsertContentsDlg(weld::Window *pParent, const OUString *pStrTitle=nullptr)=0
FilterGroup & rTarget
don't create
Definition: global.hxx:395
sal_uInt16 GetValue() const
void FillRangeListWithMarks(ScRangeList *pList, bool bClear, SCTAB nForTab=-1) const
Create a range list of marks.
Definition: markdata.cxx:387
void MakeOutline(bool bColumns, bool bRecord=true)
Definition: dbfunc3.cxx:87
sal_Int16 nId
void Solve(const ScSolveParam &rParam)
Definition: viewfun2.cxx:2165
SCTAB GetTabNo() const
Definition: viewdata.hxx:395
SC_DLLPUBLIC void GetNumberFormat(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt32 &rFormat) const
Definition: document.cxx:3644
bool SimpleRowMarked()
Definition: viewdata.cxx:1236
void ExecuteDataPilotDialog()
Definition: cellsh1.cxx:2833
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:1268
void Done(bool bRemove=false)
static css::uno::Reference< css::datatransfer::XTransferable2 > GetClipData(vcl::Window *pWin)
Definition: tabvwshc.cxx:483
void GetFillData(SCCOL &rStartCol, SCROW &rStartRow, SCCOL &rEndCol, SCROW &rEndRow)
Definition: viewdata.cxx:1307
void ExecuteSubtotals(SfxRequest &rReq)
Definition: cellsh1.cxx:3024
ReturnType limit_cast(Type nValue, ReturnType nMin, ReturnType nMax)
Returns the value, if it is not less than nMin and not greater than nMax, otherwise one of the limits...
Definition: ftools.hxx:61
virtual bool IsSkipEmptyCells() const =0
This is very similar to ScCellValue, except that it references the original value instead of copying ...
Definition: cellvalue.hxx:104
SC_DLLPUBLIC formula::FormulaGrammar::Grammar GetGrammar() const
Definition: document.hxx:985
#define SCITEM_SUBTDATA
Definition: scitems.hxx:92
sal_uInt16 Count() const
const SfxItemSet * GetArgs() const
void Invalidate(sal_uInt16 nId)
void Remove(const SfxPoolItem &)
#define MAXDOUBLE
Definition: global.hxx:73
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:47
CreateNameFlags
Definition: scui_def.hxx:51
constexpr::Color COL_YELLOW(0xFF, 0xFF, 0x00)
ScConditionalFormat * GetFormat(sal_uInt32 nKey)
Definition: conditio.cxx:2069
virtual short Execute()=0
SC_DLLPUBLIC void SetCursor(SCCOL nPosX, SCROW nPosY, bool bNew=false)
Definition: tabview3.cxx:358
const MarkedTabsType & GetSelectedTabs() const
Definition: markdata.hxx:98
void GetClipArea(SCCOL &nClipX, SCROW &nClipY, bool bIncludeFiltered)
Definition: document.cxx:3121
SC_DLLPUBLIC formula::FormulaGrammar::AddressConvention GetAddressConvention() const
Definition: documen3.cxx:475
OUString DoAutoSum(bool &rRangeFinder, bool &rSubTotal, const OpCode eCode)
Definition: tabvwshc.cxx:654
virtual bool IsLink() const =0
void GetNotesInRange(const ScRangeList &rRange, std::vector< sc::NoteEntry > &rNotes) const
Definition: document.cxx:6769
bool IsImportData() const
Definition: dpobject.hxx:163
void HideMarkedOutlines(bool bRecord=true)
Definition: dbfunc3.cxx:406
void ConvertFormulaToValue()
Definition: viewfun2.cxx:1800
void MarkFromRangeList(const ScRangeList &rList, bool bReset)
Definition: markdata.cxx:334
FontFamily GetFamilyType()
SC_DLLPUBLIC void InputEnterHandler(ScEnterMode nBlockMode=ScEnterMode::NORMAL)
Definition: scmod.cxx:1359
virtual void ShowCursor(bool bOn) override
Definition: tabvwsh4.cxx:452
bool HasSelectionForDateGroup(ScDPNumGroupInfo &rOldInfo, sal_Int32 &rParts)
Definition: dbfunc3.cxx:804
const char * CheckSourceRange() const
Check the sanity of the data source range.
Definition: dpshttab.cxx:306
virtual VclPtr< AbstractScCondFormatManagerDlg > CreateScCondFormatMgrDlg(weld::Window *pParent, ScDocument *pDoc, const ScConditionalFormatList *pFormatList)=0
EditView * GetActiveView()
Definition: inputhdl.cxx:2212
static sal_Int32 getIconSetElements(ScIconSetType eType)
Internal use only (d&d undo): do not delete caption objects of cell notes.
DelCellCmd
Definition: global.hxx:290
void DetectiveMarkPred()
Definition: viewfun6.cxx:149
void GetMarkArea(ScRange &rRange) const
Definition: markdata.cxx:112
virtual SfxUndoManager * GetUndoManager() override
Definition: docsh.cxx:2805
void DateGroupDataPilot(const ScDPNumGroupInfo &rInfo, sal_Int32 nParts)
Definition: dbfunc3.cxx:985
void ToggleChildWindow(sal_uInt16)
RET_NO
const ScDPCache * CreateCache(const ScDPDimensionSaveData *pDimData) const
Definition: dpsdbtab.cxx:50
void ExecuteFillSingleEdit()
Definition: cellsh1.cxx:3103
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:6511
void SetSlot(sal_uInt16 nNewSlot)
bool InsertName(const OUString &rName, const OUString &rSymbol, const OUString &rType)
Definition: viewfunc.cxx:2853
SC_DLLPUBLIC ScConditionalFormatList * GetCondFormList(SCTAB nTab) const
Definition: documen4.cxx:857
CommentCaptionState GetAllNoteCaptionsState(const ScRangeList &rRanges)
Definition: document.cxx:6652
virtual VclPtr< AbstractScLinkedAreaDlg > CreateScLinkedAreaDlg(weld::Window *pParent)=0
RET_YES
static bool HasRegisteredSources()
Definition: dpobject.cxx:2730
SC_DLLPUBLIC void CutToClip()
Not used?
Definition: viewfun3.cxx:87
DataType::const_iterator const_iterator
Definition: rangenam.hxx:196
void FillSeries(FillDir eDir, FillCmd eCmd, FillDateCmd eDateCmd, double fStart, double fStep, double fMax)
Definition: viewfun2.cxx:1406
bool SelectionEditable(bool *pOnlyNotBecauseOfMatrix=nullptr)
Definition: viewfunc.cxx:260
PropertiesInfo aProperties
virtual bool IsExternal() const =0
SC_DLLPUBLIC SCROW MaxRow() const
Definition: document.hxx:873
size_t SCSIZE
size_t typedef to be able to find places where code was changed from USHORT to size_t and is used to ...
Definition: address.hxx:45
sal_Int32 SCCOLROW
a type capable of holding either SCCOL or SCROW
Definition: types.hxx:24
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
void ExecuteRotateTrans(const SfxRequest &rReq)
Definition: cellsh1.cxx:2773
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:343
void TransliterateText(TransliterationFlags nType)
Definition: viewfun2.cxx:1811
SC_DLLPUBLIC void SetRefDialog(sal_uInt16 nId, bool bVis, SfxViewFrame *pViewFrm=nullptr)
Reference dialogs.
Definition: scmod.cxx:1467
virtual bool CondFormatsChanged() const =0
void DoSubTotals(const ScSubTotalParam &rParam, bool bRecord=true, const ScSortParam *pForceNewSort=nullptr)
Definition: dbfunc3.cxx:429
static TransferableDataHelper CreateFromSystemClipboard(vcl::Window *pWindow)
void push_back(const ScRange &rRange)
Definition: rangelst.cxx:1144
void UpdateCharts(bool bAllCharts)
Definition: dbfunc2.cxx:24
void UpdateInputHandler(bool bForce=false, bool bStopEditing=true)
Definition: tabvwsha.cxx:632
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:3010
void SetRow(SCROW nRowP)
Definition: address.hxx:275
void DetectiveDelSucc()
Definition: viewfun6.cxx:72
ScDocument * GetDocument() const
Definition: viewdata.cxx:859
SotClipboardFormatId
#define SCRET_REMOVE
Definition: scui_def.hxx:68
SC_DLLPUBLIC const_iterator begin() const
Definition: rangenam.cxx:780
sal_Int32 nEndPos
virtual bool IsTranspose() const =0
const ScRange * Find(const ScAddress &) const
Definition: rangelst.cxx:1033
virtual void SetChangeTrack(bool bSet)=0
size_type size() const
ScDocument * GetDocument() const
Definition: transobj.hxx:81
bool HasSelectionForNumGroup(ScDPNumGroupInfo &rOldInfo)
Definition: dbfunc3.cxx:917
SC_DLLPUBLIC const ScPatternAttr * GetPattern(SCCOL nCol, SCROW nRow, SCTAB nTab) const
Definition: document.cxx:4738
SC_DLLPUBLIC void PasteFromSystem()
Definition: viewfun3.cxx:483
void SetCol(SCCOL nColP)
Definition: address.hxx:279
SvtScriptType GetSelectionScriptType()
Definition: viewfunc.cxx:803
ScChangeTrack * GetChangeTrack() const
Definition: document.hxx:2392
TransliterationFlags
SC_DLLPUBLIC void DeletePageBreak(bool bColumn, bool bRecord=true, const ScAddress *pPos=nullptr, bool bSetModified=true)
Definition: viewfun2.cxx:958
bool IsServiceData() const
Definition: dpobject.hxx:164
#define SCITEM_CONDFORMATDLGDATA
Definition: scitems.hxx:97
#define FDS_OPT_NONE
Definition: scui_def.hxx:28
static void SetError(ErrCode)
void PasteFromClipboard(ScViewData *pViewData, ScTabViewShell *pTabViewShell, bool bShowDialog)
Definition: cliputil.cxx:46
SfxItemPool & GetPool() const
const SfxPoolItem & GetItem(sal_uInt16 nWhichP) const
Definition: patattr.hxx:70
bool empty() const
Definition: rangelst.hxx:89
bool InputKeyEvent(const KeyEvent &rKEvt, bool bStartEdit=false)
Definition: scmod.cxx:1353
void GetPossibleClipboardFormats(SvxClipboardFormatItem &rFormats)
Definition: cellsh.cxx:443
DocumentType eType
SC_DLLPUBLIC double GetValue(const ScAddress &rPos) const
Definition: document.cxx:3631
ScTabViewShell * GetViewShell() const
Definition: viewdata.hxx:357
void SetNoteText(const ScAddress &rPos, const OUString &rNoteText)
Definition: viewfunc.cxx:2597
sal_Int16 GetYear() const
const char * GetMessageId() const
Definition: editable.cxx:152
sal_uInt32 GetKey() const
Definition: conditio.hxx:592
void SetMarkArea(const ScRange &rRange)
Definition: markdata.cxx:97
ScPasteFunc
Definition: global.hxx:189
OUString CreateString(sc::TokenStringContext &rCxt, const ScAddress &rPos) const
Create a string representation of formula token array without modifying the internal state of the tok...
Definition: token.cxx:5103
SC_DLLPUBLIC SCCOL MaxCol() const
Definition: document.hxx:872
void InsertURL(const OUString &rName, const OUString &rURL, const OUString &rTarget, sal_uInt16 nMode)
Definition: tabvwshe.cxx:120
void DetectiveAddPred()
Definition: viewfun6.cxx:51
SC_DLLPUBLIC SvNumberFormatter * GetFormatTable() const
Definition: documen2.cxx:438
SvNumFormatType GetType() const
void UseScenario(const OUString &rName)
Definition: viewfun2.cxx:2290
virtual sal_Int32 GetDatePart() const =0
FillCmd
Definition: global.hxx:326
SC_DLLPUBLIC const_iterator end() const
Definition: rangenam.cxx:785
static void GetFont(vcl::Font &rFont, const SfxItemSet &rItemSet, ScAutoFontColorMode eAutoMode, const OutputDevice *pOutDev=nullptr, const Fraction *pScale=nullptr, const SfxItemSet *pCondSet=nullptr, SvtScriptType nScript=SvtScriptType::NONE, const Color *pBackConfigColor=nullptr, const Color *pTextConfigColor=nullptr)
Static helper function to fill a font object from the passed item set.
Definition: patattr.cxx:216
const OUString & GetURL() const
virtual OUString GetParUser() const =0
sal_Int16 GetValue() const
OUString GetModuleIdentifier(const Reference< frame::XFrame > &rxFrame)
FontPitch GetPitch()
bool IsMarked() const
Definition: markdata.hxx:82
#define SCITEM_STRING
Definition: scitems.hxx:88
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
virtual ScConditionalFormat * GetCondFormatSelected()=0
int i
virtual VclPtr< AbstractScDPNumGroupDlg > CreateScDPNumGroupDlg(weld::Window *pParent, const ScDPNumGroupInfo &rInfo)=0
css::uno::Sequence< css::uno::Any > InitAnyPropertySequence(::std::initializer_list< ::std::pair< OUString, css::uno::Any > > vInit)
ScMarkType
States GetSimpleArea() returns for the underlying selection marks, so the caller can react if the res...
Definition: viewdata.hxx:61
sal_Int16 SCCOL
Definition: types.hxx:22
InsertDeleteFlags
Definition: global.hxx:158
bool GetString(SotClipboardFormatId nFormat, OUString &rStr)
#define SC_MOD()
Definition: scmod.hxx:253
void DetectiveAddSucc()
Definition: viewfun6.cxx:65
SfxBindings & GetBindings()
virtual OUString GetParName() const =0
virtual void SetEdStartValEnabled(bool bFlag)=0
Parameters for conversion.
Definition: spellparam.hxx:33
ScSheetLimits & GetSheetLimits() const
Definition: document.hxx:874
const OUString & GetValue() const
void GetUnprotectedCells(ScRangeList &rRange, SCTAB nTab) const
Definition: document.cxx:6781
SC_DLLPUBLIC void SetTabNo(SCTAB nTab, bool bNew=false, bool bExtendSelection=false, bool bSameTabButMoved=false)
Definition: tabview3.cxx:1786
const T * GetArg(sal_uInt16 nSlotId) const
void ExecuteTrans(SfxRequest &rReq)
Definition: cellsh1.cxx:2763
virtual ScPasteFunc GetFormulaCmdBits() const =0
virtual OUString GetDimensionName() const =0
void IncRow(SCROW nDelta=1)
Definition: address.hxx:300
OUString ScResId(const char *pId)
Definition: scdll.cxx:95
ScMarkType GetSimpleArea(SCCOL &rStartCol, SCROW &rStartRow, SCTAB &rStartTab, SCCOL &rEndCol, SCROW &rEndRow, SCTAB &rEndTab) const
Definition: viewdata.cxx:1173
virtual void SetCurPageId(const OString &rName)=0
bool IsNumberFormat(const OUString &sString, sal_uInt32 &F_Index, double &fOutNumber, SvNumInputOptions eInputOptions=SvNumInputOptions::NONE)
void ChangeIndent(bool bIncrement)
Definition: viewfunc.cxx:2823
Context for creating string from an array of formula tokens, used in ScTokenArray::CreateString().
bool IsCutMode()
Definition: document.cxx:2065
TransliterationFlags getNextMode()
virtual SotClipboardFormatId GetFormat(const TransferableDataHelper &aHelper)=0
ScGridWindow * GetActiveWin()
Definition: viewdata.cxx:3069
bool ShrinkToDataArea(SCTAB nTab, SCCOL &rStartCol, SCROW &rStartRow, SCCOL &rEndCol, SCROW &rEndRow) const
Shrink a range to only include data area.
Definition: document.cxx:1040
std::unique_ptr< CellShell_Impl > pImpl
Definition: cellsh.hxx:53
sal_uInt16 GetDay() const
virtual bool IsNamedRange() const =0
SvNumFormatType
#define LANGUAGE_CHINESE_SIMPLIFIED
void DetectiveAddError()
Definition: viewfun6.cxx:79
void InsertFunction(const OUString &rFuncName, bool bAddPar=true)
Definition: inputhdl.cxx:3479
ScDPSaveData * GetSaveData() const
Definition: dpobject.hxx:141
CPPUHELPER_DLLPUBLIC css::uno::Reference< css::uno::XComponentContext > SAL_CALL defaultBootstrap_InitialComponentContext()
void Consolidate(const ScConsolidateParam &rParam)
Definition: dbfunc3.cxx:604
void AddDays(sal_Int32 nAddDays)
void ReplaceNote(const ScAddress &rPos, const OUString &rNoteText, const OUString *pAuthor, const OUString *pDate)
Definition: viewfunc.cxx:2602
const ScImportSourceDesc * GetImportSourceDesc() const
Definition: dpobject.hxx:157
void InsertText(const OUString &rNew, bool bSelect=false)
virtual VclPtr< SfxAbstractDialog > CreateCharMapDialog(weld::Window *pParent, const SfxItemSet &rAttr, const css::uno::Reference< css::frame::XFrame > &rFrame)=0
#define DLG_RET_EDIT
bool IsEditable() const
Definition: editable.hxx:84
bool IsBlockEmpty(SCTAB nTab, SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, bool bIgnoreNotes=false) const
Definition: document.cxx:5299
virtual VclPtr< AbstractScFillSeriesDlg > CreateScFillSeriesDlg(weld::Window *pParent, ScDocument &rDocument, FillDir eFillDir, FillCmd eFillCmd, FillDateCmd eFillDateCmd, const OUString &aStartStr, double fStep, double fMax, SCSIZE nSelectHeight, SCSIZE nSelectWidth, sal_uInt16 nPossDir)=0
const ScTabOpParam & GetData() const
Definition: uiitems.hxx:274
bool empty() const
virtual double GetMax() const =0
void ShowMarkedOutlines(bool bRecord=true)
Definition: dbfunc3.cxx:383
static SC_DLLPUBLIC LanguageType eLnge
Definition: global.hxx:550
void ReplaceConditionalFormat(sal_uLong nOldIndex, std::unique_ptr< ScConditionalFormat > pFormat, SCTAB nTab, const ScRangeList &rRanges)
Definition: docfunc.cxx:5593
virtual CreateNameFlags GetFlags() const =0
CommentCaptionState
Definition: document.hxx:252
SCCOL GetRefEndX() const
Definition: viewdata.hxx:518
bool IsMultiMarked() const
Definition: viewdata.cxx:1251
bool StartExecuteAsync(const std::function< void(sal_Int32)> &rEndDialogFn)
virtual OUString GetSelectedNamedRange() const =0
void GetArea(SCTAB &rTab, SCCOL &rCol1, SCROW &rRow1, SCCOL &rCol2, SCROW &rRow2) const
Definition: dbdata.cxx:301
SC_DLLPUBLIC bool PasteFromClip(InsertDeleteFlags nFlags, ScDocument *pClipDoc, ScPasteFunc nFunction=ScPasteFunc::NONE, bool bSkipEmpty=false, bool bTranspose=false, bool bAsLink=false, InsCellCmd eMoveMode=INS_NONE, InsertDeleteFlags nUndoExtraFlags=InsertDeleteFlags::NONE, bool bAllowDialogs=false)
Definition: viewfun3.cxx:876
virtual FillCmd GetFillCmd() const =0
void DetectiveDelPred()
Definition: viewfun6.cxx:58
const css::uno::Reference< css::frame::XFrame > & GetFrameInterface() const
SCCOL Col() const
Definition: address.hxx:267
bool GetDataFieldPositionData(const ScAddress &rPos, css::uno::Sequence< css::sheet::DataPilotFieldFilter > &rFilters)
Definition: dpobject.cxx:1140
SC_DLLPUBLIC const ScPatternAttr * GetSelectionPattern()
Definition: viewfunc.cxx:829
void GetSubTotalParam(ScSubTotalParam &rSubTotalParam) const
Definition: dbdata.cxx:449
size_t LeaveListAction()
void SetInputMode(ScInputMode eMode, const OUString *pInitText=nullptr)
Definition: scmod.cxx:1334
virtual void Insert(SotClipboardFormatId nFormat, const OUString &rFormatName)=0
ScAddress GetCurPos() const
Definition: viewdata.cxx:4023
void InitRangeFinder(const OUString &rFormula)
Definition: inputhdl.cxx:306
void InsertAreaLink(const OUString &rFile, const OUString &rFilter, const OUString &rOptions, const OUString &rSource, const ScRange &rDestRange, sal_uLong nRefresh, bool bFitBlock, bool bApi)
Definition: docfunc.cxx:5504
void InsertCurrentTime(SvNumFormatType nCellFmt, const OUString &rUndoStr)
Insert date or time into current cell.
Definition: viewfun6.cxx:253
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)
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:462
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:100
static TransliterationFlags GetTransliterationType(sal_uInt16 nSlotID)
Definition: viewutil.cxx:98
void ErrorMessage(const char *pGlobStrId)
Definition: tabview2.cxx:1412
const SvNumberformat * GetEntry(sal_uInt32 nKey) const
constexpr::Color COL_GREEN(0x00, 0x80, 0x00)
void SetIconSetData(ScIconSetFormatData *pData)
#define GetWhich(nSlot)
void ActivateInputWindow(const OUString *pStr=nullptr, bool bMatrix=false)
Definition: scmod.cxx:1430
CellType
Definition: global.hxx:281
OUString aName
static SC_DLLPUBLIC ScAbstractDialogFactory * Create()
Definition: scabstdlg.cxx:38
sal_uInt32 GetStandardFormat(SvNumFormatType eType, LanguageType eLnge=LANGUAGE_DONTKNOW)
void GroupDataPilot()
Definition: dbfunc3.cxx:1125
SfxDispatcher & GetDispatcher()
Definition: viewdata.cxx:3047
RET_OK
Dates, times, datetime values.
InsCellCmd
Definition: global.hxx:299
void DetectiveMarkSucc()
Definition: viewfun6.cxx:213
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:196
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
void FillSimple(FillDir eDir)
Definition: viewfun2.cxx:1357
constexpr TypedWhichId< ScCondFormatItem > ATTR_CONDITIONAL(154)
virtual VclPtr< AbstractScInsertCellDlg > CreateScInsertCellDlg(weld::Window *pParent, bool bDisallowCellMove)=0
QPRO_FUNC_TYPE nType
Definition: qproform.cxx:401
Sequence< sal_Int8 > aSeq
const ScDocument & GetDocument() const
Definition: docsh.hxx:216
constexpr::Color COL_WHITE(0xFF, 0xFF, 0xFF)
void DataChanged(bool bFromTopNotify=false, bool bSetModified=true)
Definition: inputhdl.cxx:2578
const ScSolveParam & GetData() const
Definition: uiitems.hxx:259
Hangul-Hanja converter.
Definition: spellparam.hxx:29
void SetDataPilotDetails(bool bShow, const OUString *pNewDimensionName=nullptr)
Definition: dbfunc3.cxx:1944
virtual void SetCellShiftDisabled(CellShiftDisabledFlags nDisable)=0
void PasteDraw()
Definition: viewfun3.cxx:466
void DoRefConversion()
Definition: viewfun4.cxx:181
void CancelAutoDBRange()
Definition: docsh5.cxx:369
void HideListBox()
Definition: tabview3.cxx:2950
ScIconSetType
Definition: colorscale.hxx:189
void SetSelection(const ESelection &rNewSel)
bool HasSelectionForDrillDown(css::sheet::DataPilotFieldOrientation &rOrientation)
Definition: dbfunc3.cxx:1907
virtual SfxInterface * GetInterface() const
RotateTransliteration m_aRotateCase
Definition: cellsh.hxx:70
void GetMultiArea(ScRangeListRef &rRange) const
Definition: viewdata.cxx:1196
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:5669
const OUString & GetName() const
SvxLinkInsertMode GetInsertMode() const
void AppendItem(const SfxPoolItem &)
#define LANGUAGE_CHINESE_TRADITIONAL
void DoHangulHanjaConversion()
Definition: viewfun4.cxx:435
virtual FillDir GetFillDir() const =0
SVXCORE_DLLPUBLIC MSO_SPT Get(const OUString &)
ESelection GetSelection() const
ScInputHandler * GetInputHdl(ScTabViewShell *pViewSh=nullptr, bool bUseRef=true)
Input-Handler.
Definition: scmod.cxx:1303
bool IsAPI() const
ScDBData * GetAnonymousDBData()
Definition: dbfunc.cxx:155
ScDocFunc & GetDocFunc()
Definition: docsh.hxx:218
const SfxPoolItem * Execute(sal_uInt16 nSlot, SfxCallMode nCall=SfxCallMode::SLOT, const SfxPoolItem **pArgs=nullptr, sal_uInt16 nModi=0, const SfxPoolItem **pInternalArgs=nullptr)
virtual ScDPNumGroupInfo GetGroupInfo() const =0
void RemoveOutline(bool bColumns, bool bRecord=true)
Definition: dbfunc3.cxx:108
void InsertSpecialChar(const OUString &rStr, const vcl::Font &rFont)
Definition: viewfun2.cxx:3198
bool HasSubTotalCells(const ScRange &rRange)
Definition: documen3.cxx:763
SC_DLLPUBLIC void SetRangeName(const OUString &rName)
Definition: dpshttab.cxx:259
bool GetTableSelect(SCTAB nTab) const
Definition: markdata.cxx:184
#define DLG_RET_ADD
#define SCITEM_SOLVEDATA
Definition: scitems.hxx:95
virtual void SaveParameters()=0
void SetDialogType(condformat::dialog::ScCondFormatDialogType eType)
void EditNote()
Definition: viewfun6.cxx:472
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:312
static std::vector< OUString > GetRegisteredSources()
Definition: dpobject.cxx:2747
virtual OUString GetParSource() const =0
SC_DLLPUBLIC ScRefFlags Parse(const OUString &, const ScDocument *=nullptr, 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:1543
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:503
bool IsClipboardSource() const
Definition: document.cxx:2565
aStr
virtual VclPtr< SfxAbstractTabDialog > CreateScSubTotalDlg(weld::Window *pParent, const SfxItemSet *pArgSet)=0
virtual OUString GetParPass() const =0
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:3750
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:1601
CellShiftDisabledFlags
Definition: scui_def.hxx:42
void EnterData(SCCOL nCol, SCROW nRow, SCTAB nTab, const OUString &rString, const EditTextObject *pData=nullptr)
Definition: viewfunc.cxx:342
virtual InsertDeleteFlags GetInsContentsCmdBits() const =0
SCCOL GetCurX() const
Definition: viewdata.hxx:401
ViewShellId GetViewShellId() const override
void SetMarkData(const ScMarkData &rNew)
Definition: tabview3.cxx:1725
#define BTN_PASTE_NAME
Definition: scui_def.hxx:62
bool SimpleColMarked()
Definition: viewdata.cxx:1221
void TabOp(const ScTabOpParam &rParam, bool bRecord=true)
Definition: viewfun2.cxx:2238
ocSum
sal_Int32 nStartPos
SC_DLLPUBLIC void GetAllNoteEntries(std::vector< sc::NoteEntry > &rNotes) const
Definition: document.cxx:6749
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo