LibreOffice Module sc (master)  1
docsh5.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 <memory>
21 #include <sal/config.h>
22 
23 #include <cassert>
24 
25 #include <osl/diagnose.h>
26 #include <vcl/svapp.hxx>
27 #include <vcl/weld.hxx>
28 #include <sfx2/app.hxx>
29 #include <sfx2/bindings.hxx>
30 #include <unotools/charclass.hxx>
31 
32 #include <com/sun/star/script/vba/XVBACompatibility.hpp>
33 
34 #include <docsh.hxx>
35 #include <global.hxx>
36 #include <globstr.hrc>
37 #include <scresid.hxx>
38 #include <globalnames.hxx>
39 #include <undodat.hxx>
40 #include <undotab.hxx>
41 #include <undoblk.hxx>
42 #include <dpobject.hxx>
43 #include <dpshttab.hxx>
44 #include <dbdocfun.hxx>
45 #include <consoli.hxx>
46 #include <dbdata.hxx>
47 #include <progress.hxx>
48 #include <olinetab.hxx>
49 #include <patattr.hxx>
50 #include <attrib.hxx>
51 #include <docpool.hxx>
52 #include <uiitems.hxx>
53 #include <sc.hrc>
54 #include <sizedev.hxx>
55 #include <clipparam.hxx>
56 #include <rowheightcontext.hxx>
57 #include <refupdatecontext.hxx>
58 
59 using com::sun::star::script::XLibraryContainer;
60 using com::sun::star::script::vba::XVBACompatibility;
61 using com::sun::star::container::XNameContainer;
63 using com::sun::star::uno::UNO_QUERY;
64 
65 using ::std::unique_ptr;
66 using ::std::vector;
67 
68 // former viewfunc/dbfunc methods
69 
70 void ScDocShell::ErrorMessage(const char* pGlobStrId)
71 {
73 
75  weld::WaitObject aWaitOff( pParent );
76  bool bFocus = pParent && pParent->has_focus();
77 
78  if (pGlobStrId && strcmp(pGlobStrId, STR_PROTECTIONERR) == 0)
79  {
80  if (IsReadOnly())
81  {
82  pGlobStrId = STR_READONLYERR;
83  }
84  }
85 
86  std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pParent,
87  VclMessageType::Info, VclButtonsType::Ok,
88  ScResId(pGlobStrId)));
89  xInfoBox->run();
90 
91  if (bFocus)
92  pParent->grab_focus();
93 }
94 
96 {
97  // import into read-only document is possible - must be extended if other filters use api
98  // #i108547# MSOOXML filter uses "IsChangeReadOnlyEnabled" property
99 
101 }
102 
103 void ScDocShell::DBAreaDeleted( SCTAB nTab, SCCOL nX1, SCROW nY1, SCCOL nX2 )
104 {
105  ScDocShellModificator aModificator( *this );
106  // the auto-filter is in the first row of the area
107  m_aDocument.RemoveFlagsTab( nX1, nY1, nX2, nY1, nTab, ScMF::Auto );
108  PostPaint( nX1, nY1, nTab, nX2, nY1, nTab, PaintPartFlags::Grid );
109  // No SetDocumentModified, as the unnamed database range might have to be restored later.
110  // The UNO hint is broadcast directly instead, to keep UNO objects in valid state.
111  m_aDocument.BroadcastUno( SfxHint( SfxHintId::DataChanged ) );
112 }
113 
115 {
116  SCCOL nCol = rMarked.aStart.Col();
117  SCROW nRow = rMarked.aStart.Row();
118  SCTAB nTab = rMarked.aStart.Tab();
119 
120  SCCOL nStartCol = nCol;
121  SCROW nStartRow = nRow;
122  SCTAB nStartTab = nTab;
123  SCCOL nEndCol = rMarked.aEnd.Col();
124  SCROW nEndRow = rMarked.aEnd.Row();
125  // Not simply GetDBAtCursor: The continuous data range for "unnamed" (GetDataArea) may be
126  // located next to the cursor; so a named DB range needs to be searched for there as well.
128  ScDBData* pData = m_aDocument.GetDBAtArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow );
129  if (!pData)
130  pData = pColl->GetDBNearCursor(nCol, nRow, nTab );
131 
132  bool bSelected = ( eSel == ScGetDBSelection::ForceMark ||
133  (rMarked.aStart != rMarked.aEnd && eSel != ScGetDBSelection::RowDown) );
134  bool bOnlyDown = (!bSelected && eSel == ScGetDBSelection::RowDown && rMarked.aStart.Row() == rMarked.aEnd.Row());
135 
136  bool bUseThis = false;
137  if (pData)
138  {
139  // take range, if nothing else is marked
140 
141  SCTAB nDummy;
142  SCCOL nOldCol1;
143  SCROW nOldRow1;
144  SCCOL nOldCol2;
145  SCROW nOldRow2;
146  pData->GetArea( nDummy, nOldCol1,nOldRow1, nOldCol2,nOldRow2 );
147  bool bIsNoName = ( pData->GetName() == STR_DB_LOCAL_NONAME );
148 
149  if (!bSelected)
150  {
151  bUseThis = true;
152  if ( bIsNoName && (eMode == SC_DB_MAKE || eMode == SC_DB_AUTOFILTER) )
153  {
154  // If nothing marked or only one row marked, adapt
155  // "unnamed" to contiguous area.
156  nStartCol = nCol;
157  nStartRow = nRow;
158  if (bOnlyDown)
159  {
160  nEndCol = rMarked.aEnd.Col();
161  nEndRow = rMarked.aEnd.Row();
162  }
163  else
164  {
165  nEndCol = nStartCol;
166  nEndRow = nStartRow;
167  }
168  m_aDocument.GetDataArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow, false, bOnlyDown );
169  if ( nOldCol1 != nStartCol || nOldCol2 != nEndCol || nOldRow1 != nStartRow )
170  bUseThis = false; // doesn't fit at all
171  else if ( nOldRow2 != nEndRow )
172  {
173  // extend range to new end row
174  pData->SetArea( nTab, nOldCol1,nOldRow1, nOldCol2,nEndRow );
175  }
176  }
177  }
178  else
179  {
180  if ( nOldCol1 == nStartCol && nOldRow1 == nStartRow &&
181  nOldCol2 == nEndCol && nOldRow2 == nEndRow ) // marked precisely?
182  bUseThis = true;
183  else
184  bUseThis = false; // always take marking (Bug 11964)
185  }
186 
187  // never take "unnamed" for import
188 
189  if ( bUseThis && eMode == SC_DB_IMPORT && bIsNoName )
190  bUseThis = false;
191  }
192 
193  if ( bUseThis )
194  {
195  pData->GetArea( nStartTab, nStartCol,nStartRow, nEndCol,nEndRow );
196  }
197  else if ( eMode == SC_DB_OLD )
198  {
199  pData = nullptr; // nothing found
200  }
201  else
202  {
203  if ( !bSelected )
204  { // continuous range
205  nStartCol = nCol;
206  nStartRow = nRow;
207  if (bOnlyDown)
208  {
209  nEndCol = rMarked.aEnd.Col();
210  nEndRow = rMarked.aEnd.Row();
211  }
212  else
213  {
214  nEndCol = nStartCol;
215  nEndRow = nStartRow;
216  }
217  m_aDocument.GetDataArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow, false, bOnlyDown );
218  }
219 
220  bool bHasHeader = m_aDocument.HasColHeader( nStartCol,nStartRow, nEndCol,nEndRow, nTab );
221 
222  ScDBData* pNoNameData = m_aDocument.GetAnonymousDBData(nTab);
223  if ( eMode != SC_DB_IMPORT && pNoNameData)
224  {
225  // Do not reset AutoFilter range during temporary operations on
226  // other ranges, use the document global temporary anonymous range
227  // instead. But, if AutoFilter is to be toggled then do use the
228  // sheet-local DB range.
229  bool bSheetLocal = true;
230  if (eMode != SC_DB_AUTOFILTER && pNoNameData->HasAutoFilter())
231  {
232  bSheetLocal = false;
233  pNoNameData = m_aDocument.GetAnonymousDBData();
234  if (!pNoNameData)
235  {
236  m_aDocument.SetAnonymousDBData( std::unique_ptr<ScDBData>(new ScDBData( STR_DB_LOCAL_NONAME,
237  nTab, nStartCol, nStartRow, nEndCol, nEndRow, true, bHasHeader) ) );
238  pNoNameData = m_aDocument.GetAnonymousDBData();
239  }
240  // ScDocShell::CancelAutoDBRange() would restore the
241  // sheet-local anonymous DBData from pOldAutoDBRange, unset so
242  // that won't happen with data of a previous sheet-local
243  // DBData.
244  m_pOldAutoDBRange.reset();
245  }
246  else if (!m_pOldAutoDBRange)
247  {
248  // store the old unnamed database range with its settings for undo
249  // (store at the first change, get the state before all changes)
250  m_pOldAutoDBRange.reset( new ScDBData( *pNoNameData ) );
251  }
252  else if (m_pOldAutoDBRange->GetTab() != pNoNameData->GetTab())
253  {
254  // Different sheet-local unnamed DB range than the previous one.
255  *m_pOldAutoDBRange = *pNoNameData;
256  }
257 
258  SCCOL nOldX1; // take old range away cleanly
259  SCROW nOldY1;
260  SCCOL nOldX2;
261  SCROW nOldY2;
262  SCTAB nOldTab;
263  pNoNameData->GetArea( nOldTab, nOldX1, nOldY1, nOldX2, nOldY2 );
264 
265  // If previously bHasHeader was set and the new range starts on the
266  // same row and intersects the old column range, then don't reset
267  // bHasHeader but assume that the new range still has headers, just
268  // some are empty or numeric.
269  if (!bHasHeader && pNoNameData->HasHeader() && nTab == nOldTab && nStartRow == nOldY1 &&
270  nStartCol <= nOldY2 && nOldY1 <= nEndCol)
271  bHasHeader = true;
272 
273  // Remove AutoFilter button flags only for sheet-local DB range,
274  // not if a temporary is used.
275  if (bSheetLocal)
276  DBAreaDeleted( nOldTab, nOldX1, nOldY1, nOldX2 );
277 
278  pNoNameData->SetSortParam( ScSortParam() ); // reset parameter
279  pNoNameData->SetQueryParam( ScQueryParam() );
280  pNoNameData->SetSubTotalParam( ScSubTotalParam() );
281 
282  pNoNameData->SetArea( nTab, nStartCol,nStartRow, nEndCol,nEndRow ); // set anew
283  pNoNameData->SetByRow( true );
284  pNoNameData->SetHeader( bHasHeader );
285  pNoNameData->SetAutoFilter( false );
286  }
287  else
288  {
289  std::unique_ptr<ScDBCollection> pUndoColl;
290 
291  if (eMode==SC_DB_IMPORT)
292  {
294  pUndoColl.reset( new ScDBCollection( *pColl ) ); // Undo for import range
295 
296  OUString aImport = ScResId( STR_DBNAME_IMPORT );
297  tools::Long nCount = 0;
298  const ScDBData* pDummy = nullptr;
299  ScDBCollection::NamedDBs& rDBs = pColl->getNamedDBs();
300  OUString aNewName;
301  do
302  {
303  ++nCount;
304  aNewName = aImport + OUString::number( nCount );
305  pDummy = rDBs.findByUpperName(ScGlobal::getCharClassPtr()->uppercase(aNewName));
306  }
307  while (pDummy);
308  pNoNameData = new ScDBData( aNewName, nTab,
309  nStartCol,nStartRow, nEndCol,nEndRow,
310  true, bHasHeader );
311  bool ins = rDBs.insert(std::unique_ptr<ScDBData>(pNoNameData));
312  assert(ins); (void)ins;
313  }
314  else
315  {
316  pNoNameData = new ScDBData(STR_DB_LOCAL_NONAME, nTab,
317  nStartCol,nStartRow, nEndCol,nEndRow,
318  true, bHasHeader );
319  m_aDocument.SetAnonymousDBData(nTab, std::unique_ptr<ScDBData>(pNoNameData));
320  }
321 
322  if ( pUndoColl )
323  {
325 
326  GetUndoManager()->AddUndoAction( std::make_unique<ScUndoDBData>( this,
327  std::move(pUndoColl),
328  std::make_unique<ScDBCollection>( *pColl ) ) );
329  }
330 
331  // no longer needed to register new range at the Sba
332 
333  // announce "Import1", etc., at the Navigator
334  if (eMode==SC_DB_IMPORT)
335  SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScDbAreasChanged ) );
336  }
337  pData = pNoNameData;
338  }
339 
340  return pData;
341 }
342 
344 {
346  if (!pColl)
347  return nullptr;
348 
349  ScDBData* pData = pColl->getAnonDBs().getByRange(rRange);
350  if (!pData)
351  return nullptr;
352 
353  if (!pData->HasHeader())
354  {
355  bool bHasHeader = m_aDocument.HasColHeader(
356  rRange.aStart.Col(), rRange.aStart.Row(), rRange.aEnd.Col(), rRange.aEnd.Row(), rRange.aStart.Tab());
357  pData->SetHeader(bHasHeader);
358  }
359 
360  return pData;
361 }
362 
363 std::unique_ptr<ScDBData> ScDocShell::GetOldAutoDBRange()
364 {
365  return std::move(m_pOldAutoDBRange);
366 }
367 
369 {
370  // called when dialog is cancelled
371 //moggi:TODO
372  if ( !m_pOldAutoDBRange )
373  return;
374 
375  SCTAB nTab = GetCurTab();
376  ScDBData* pDBData = m_aDocument.GetAnonymousDBData(nTab);
377  if ( pDBData )
378  {
379  SCCOL nRangeX1;
380  SCROW nRangeY1;
381  SCCOL nRangeX2;
382  SCROW nRangeY2;
383  SCTAB nRangeTab;
384  pDBData->GetArea( nRangeTab, nRangeX1, nRangeY1, nRangeX2, nRangeY2 );
385  DBAreaDeleted( nRangeTab, nRangeX1, nRangeY1, nRangeX2 );
386 
387  *pDBData = *m_pOldAutoDBRange; // restore old settings
388 
389  if ( m_pOldAutoDBRange->HasAutoFilter() )
390  {
391  // restore AutoFilter buttons
392  m_pOldAutoDBRange->GetArea( nRangeTab, nRangeX1, nRangeY1, nRangeX2, nRangeY2 );
393  m_aDocument.ApplyFlagsTab( nRangeX1, nRangeY1, nRangeX2, nRangeY1, nRangeTab, ScMF::Auto );
394  PostPaint( nRangeX1, nRangeY1, nRangeTab, nRangeX2, nRangeY1, nRangeTab, PaintPartFlags::Grid );
395  }
396  }
397 
398  m_pOldAutoDBRange.reset();
399 }
400 
401  // adjust height
403 
404 bool ScDocShell::AdjustRowHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab )
405 {
406  ScSizeDeviceProvider aProv(this);
407  Fraction aZoom(1,1);
408  sc::RowHeightContext aCxt(m_aDocument.MaxRow(), aProv.GetPPTX(), aProv.GetPPTY(), aZoom, aZoom, aProv.GetDevice());
409  bool bChange = m_aDocument.SetOptimalHeight(aCxt, nStartRow,nEndRow, nTab);
410 
411  if (bChange)
412  {
413  // tdf#76183: recalculate objects' positions
415 
417  }
418 
419  return bChange;
420 }
421 
423 {
424  // update automatic row heights
425 
426  ScSizeDeviceProvider aProv(this);
427  Fraction aZoom(1,1);
428  sc::RowHeightContext aCxt(m_aDocument.MaxRow(), aProv.GetPPTX(), aProv.GetPPTY(), aZoom, aZoom, aProv.GetDevice());
429  m_aDocument.UpdateAllRowHeights(aCxt, pTabMark);
430 }
431 
432 void ScDocShell::UpdatePendingRowHeights( SCTAB nUpdateTab, bool bBefore )
433 {
434  bool bIsUndoEnabled = m_aDocument.IsUndoEnabled();
435  m_aDocument.EnableUndo( false );
436  m_aDocument.LockStreamValid( true ); // ignore draw page size (but not formula results)
437  if ( bBefore ) // check all sheets up to nUpdateTab
438  {
439  SCTAB nTabCount = m_aDocument.GetTableCount();
440  if ( nUpdateTab >= nTabCount )
441  nUpdateTab = nTabCount-1; // nUpdateTab is inclusive
442 
443  ScMarkData aUpdateSheets(m_aDocument.GetSheetLimits());
444  SCTAB nTab;
445  for (nTab=0; nTab<=nUpdateTab; ++nTab)
446  if ( m_aDocument.IsPendingRowHeights( nTab ) )
447  aUpdateSheets.SelectTable( nTab, true );
448 
449  if (aUpdateSheets.GetSelectCount())
450  UpdateAllRowHeights(&aUpdateSheets); // update with a single progress bar
451 
452  for (nTab=0; nTab<=nUpdateTab; ++nTab)
453  if ( aUpdateSheets.GetTableSelect( nTab ) )
454  {
456  m_aDocument.SetPendingRowHeights( nTab, false );
457  }
458  }
459  else // only nUpdateTab
460  {
461  if ( m_aDocument.IsPendingRowHeights( nUpdateTab ) )
462  {
463  AdjustRowHeight( 0, m_aDocument.MaxRow(), nUpdateTab );
464  m_aDocument.UpdatePageBreaks( nUpdateTab );
465  m_aDocument.SetPendingRowHeights( nUpdateTab, false );
466  }
467  }
468  m_aDocument.LockStreamValid( false );
469  m_aDocument.EnableUndo( bIsUndoEnabled );
470 }
471 
473 {
475  if (!pColl)
476  return;
477 
478  ScDBDocFunc aFunc(*this);
479  for (size_t i = 0, n = pColl->GetCount(); i < n; ++i)
480  {
481  ScDPObject& rOld = (*pColl)[i];
482 
483  const ScSheetSourceDesc* pSheetDesc = rOld.GetSheetDesc();
484  if (pSheetDesc && pSheetDesc->GetSourceRange().Intersects(rSource))
485  aFunc.UpdatePivotTable(rOld, true, false);
486  }
487 }
488 
489 static OUString lcl_GetAreaName( ScDocument* pDoc, const ScArea* pArea )
490 {
491  ScDBData* pData = pDoc->GetDBAtArea( pArea->nTab, pArea->nColStart, pArea->nRowStart,
492  pArea->nColEnd, pArea->nRowEnd );
493  if (pData)
494  return pData->GetName();
495 
496  OUString aName;
497  pDoc->GetName( pArea->nTab, aName );
498  return aName;
499 }
500 
501 void ScDocShell::DoConsolidate( const ScConsolidateParam& rParam, bool bRecord )
502 {
504 
505  sal_uInt16 nPos;
506  SCCOL nColSize = 0;
507  SCROW nRowSize = 0;
508  bool bErr = false;
509  for (nPos=0; nPos<rParam.nDataAreaCount; nPos++)
510  {
511  ScArea const & rArea = rParam.pDataAreas[nPos];
512  nColSize = std::max( nColSize, SCCOL( rArea.nColEnd - rArea.nColStart + 1 ) );
513  nRowSize = std::max( nRowSize, SCROW( rArea.nRowEnd - rArea.nRowStart + 1 ) );
514 
515  // test if source data were moved
516  if (rParam.bReferenceData)
517  if (rArea.nTab == rParam.nTab && rArea.nRowEnd >= rParam.nRow)
518  bErr = true;
519  }
520 
521  if (bErr)
522  {
523  std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetActiveDialogParent(),
524  VclMessageType::Info, VclButtonsType::Ok,
525  ScResId(STR_CONSOLIDATE_ERR1)));
526  xInfoBox->run();
527  return;
528  }
529 
530  // execute
531 
533  ScDocShellModificator aModificator( *this );
534 
535  ScRange aOldDest;
536  ScDBData* pDestData = m_aDocument.GetDBAtCursor( rParam.nCol, rParam.nRow, rParam.nTab, ScDBDataPortion::TOP_LEFT );
537  if (pDestData)
538  pDestData->GetArea(aOldDest);
539 
540  aData.SetSize( nColSize, nRowSize );
541  aData.SetFlags( rParam.eFunction, rParam.bByCol, rParam.bByRow, rParam.bReferenceData );
542  if ( rParam.bByCol || rParam.bByRow )
543  for (nPos=0; nPos<rParam.nDataAreaCount; nPos++)
544  {
545  ScArea const & rArea = rParam.pDataAreas[nPos];
546  aData.AddFields( &m_aDocument, rArea.nTab, rArea.nColStart, rArea.nRowStart,
547  rArea.nColEnd, rArea.nRowEnd );
548  }
549  aData.DoneFields();
550  for (nPos=0; nPos<rParam.nDataAreaCount; nPos++)
551  {
552  ScArea const & rArea = rParam.pDataAreas[nPos];
553  aData.AddData( &m_aDocument, rArea.nTab, rArea.nColStart, rArea.nRowStart,
554  rArea.nColEnd, rArea.nRowEnd );
555  aData.AddName( lcl_GetAreaName(&m_aDocument, &rArea) );
556  }
557 
558  aData.GetSize( nColSize, nRowSize );
559  if (bRecord && nColSize > 0 && nRowSize > 0)
560  {
561  std::unique_ptr<ScDBData> pUndoData(pDestData ? new ScDBData(*pDestData) : nullptr);
562 
563  SCTAB nDestTab = rParam.nTab;
564  ScArea aDestArea( rParam.nTab, rParam.nCol, rParam.nRow,
565  rParam.nCol+nColSize-1, rParam.nRow+nRowSize-1 );
566  if (rParam.bByCol) ++aDestArea.nColEnd;
567  if (rParam.bByRow) ++aDestArea.nRowEnd;
568 
569  if (rParam.bReferenceData)
570  {
571  SCTAB nTabCount = m_aDocument.GetTableCount();
572  SCROW nInsertCount = aData.GetInsertCount();
573 
574  // old outlines
575  ScOutlineTable* pTable = m_aDocument.GetOutlineTable( nDestTab );
576  std::unique_ptr<ScOutlineTable> pUndoTab(pTable ? new ScOutlineTable( *pTable ) : nullptr);
577 
579  pUndoDoc->InitUndo( m_aDocument, 0, nTabCount-1, false, true );
580 
581  // row state
582  m_aDocument.CopyToDocument(0, 0, nDestTab, m_aDocument.MaxCol(), m_aDocument.MaxRow(), nDestTab,
583  InsertDeleteFlags::NONE, false, *pUndoDoc);
584 
585  // all formulas
586  m_aDocument.CopyToDocument(0, 0, 0, m_aDocument.MaxCol(), m_aDocument.MaxRow(), nTabCount-1,
587  InsertDeleteFlags::FORMULA, false, *pUndoDoc);
588 
589  // complete output rows
590  m_aDocument.CopyToDocument(0, aDestArea.nRowStart, nDestTab,
591  m_aDocument.MaxCol(),aDestArea.nRowEnd, nDestTab,
592  InsertDeleteFlags::ALL, false, *pUndoDoc);
593 
594  // old output range
595  if (pDestData)
596  m_aDocument.CopyToDocument(aOldDest, InsertDeleteFlags::ALL, false, *pUndoDoc);
597 
599  std::make_unique<ScUndoConsolidate>( this, aDestArea, rParam, std::move(pUndoDoc),
600  true, nInsertCount, std::move(pUndoTab), std::move(pUndoData) ) );
601  }
602  else
603  {
605  pUndoDoc->InitUndo( m_aDocument, aDestArea.nTab, aDestArea.nTab );
606 
607  m_aDocument.CopyToDocument(aDestArea.nColStart, aDestArea.nRowStart, aDestArea.nTab,
608  aDestArea.nColEnd, aDestArea.nRowEnd, aDestArea.nTab,
609  InsertDeleteFlags::ALL, false, *pUndoDoc);
610 
611  // old output range
612  if (pDestData)
613  m_aDocument.CopyToDocument(aOldDest, InsertDeleteFlags::ALL, false, *pUndoDoc);
614 
616  std::make_unique<ScUndoConsolidate>( this, aDestArea, rParam, std::move(pUndoDoc),
617  false, 0, nullptr, std::move(pUndoData) ) );
618  }
619  }
620 
621  if (pDestData) // delete / adjust destination range
622  {
624  pDestData->SetArea( rParam.nTab, rParam.nCol, rParam.nRow,
625  rParam.nCol + nColSize - 1, rParam.nRow + nRowSize - 1 );
626  pDestData->SetHeader( rParam.bByRow );
627  }
628 
629  aData.OutputToDocument( m_aDocument, rParam.nCol, rParam.nRow, rParam.nTab );
630 
631  SCCOL nPaintStartCol = rParam.nCol;
632  SCROW nPaintStartRow = rParam.nRow;
633  SCCOL nPaintEndCol = nPaintStartCol + nColSize - 1;
634  SCROW nPaintEndRow = nPaintStartRow + nRowSize - 1;
635  PaintPartFlags nPaintFlags = PaintPartFlags::Grid;
636  if (rParam.bByCol)
637  ++nPaintEndRow;
638  if (rParam.bByRow)
639  ++nPaintEndCol;
640  if (rParam.bReferenceData)
641  {
642  nPaintStartCol = 0;
643  nPaintEndCol = m_aDocument.MaxCol();
644  nPaintEndRow = m_aDocument.MaxRow();
646  }
647  if (pDestData)
648  {
649  if ( aOldDest.aEnd.Col() > nPaintEndCol )
650  nPaintEndCol = aOldDest.aEnd.Col();
651  if ( aOldDest.aEnd.Row() > nPaintEndRow )
652  nPaintEndRow = aOldDest.aEnd.Row();
653  }
654  PostPaint( nPaintStartCol, nPaintStartRow, rParam.nTab,
655  nPaintEndCol, nPaintEndRow, rParam.nTab, nPaintFlags );
656  aModificator.SetDocumentModified();
657 }
658 
659 void ScDocShell::UseScenario( SCTAB nTab, const OUString& rName, bool bRecord )
660 {
661  if (!m_aDocument.IsScenario(nTab))
662  {
663  SCTAB nTabCount = m_aDocument.GetTableCount();
664  SCTAB nSrcTab = SCTAB_MAX;
665  SCTAB nEndTab = nTab;
666  OUString aCompare;
667  while ( nEndTab+1 < nTabCount && m_aDocument.IsScenario(nEndTab+1) )
668  {
669  ++nEndTab;
670  if (nSrcTab > MAXTAB) // still searching for the scenario?
671  {
672  m_aDocument.GetName( nEndTab, aCompare );
673  if (aCompare == rName)
674  nSrcTab = nEndTab; // found
675  }
676  }
677  if (ValidTab(nSrcTab))
678  {
679  if ( m_aDocument.TestCopyScenario( nSrcTab, nTab ) ) // test cell protection
680  {
681  ScDocShellModificator aModificator( *this );
683  m_aDocument.MarkScenario( nSrcTab, nTab, aScenMark );
684  ScRange aMultiRange;
685  aScenMark.GetMultiMarkArea( aMultiRange );
686  SCCOL nStartCol = aMultiRange.aStart.Col();
687  SCROW nStartRow = aMultiRange.aStart.Row();
688  SCCOL nEndCol = aMultiRange.aEnd.Col();
689  SCROW nEndRow = aMultiRange.aEnd.Row();
690 
691  if (bRecord)
692  {
694  pUndoDoc->InitUndo( m_aDocument, nTab,nEndTab ); // also all scenarios
695  // shown table:
696  m_aDocument.CopyToDocument(nStartCol, nStartRow, nTab,
697  nEndCol, nEndRow, nTab, InsertDeleteFlags::ALL,
698  true, *pUndoDoc, &aScenMark);
699  // scenarios
700  for (SCTAB i=nTab+1; i<=nEndTab; i++)
701  {
702  pUndoDoc->SetScenario( i, true );
703  OUString aComment;
704  Color aColor;
705  ScScenarioFlags nScenFlags;
706  m_aDocument.GetScenarioData( i, aComment, aColor, nScenFlags );
707  pUndoDoc->SetScenarioData( i, aComment, aColor, nScenFlags );
708  bool bActive = m_aDocument.IsActiveScenario( i );
709  pUndoDoc->SetActiveScenario( i, bActive );
710  // At copy-back scenarios also contents
711  if ( nScenFlags & ScScenarioFlags::TwoWay )
713  InsertDeleteFlags::ALL, false, *pUndoDoc );
714  }
715 
717  std::make_unique<ScUndoUseScenario>( this, aScenMark,
718  ScArea( nTab,nStartCol,nStartRow,nEndCol,nEndRow ),
719  std::move(pUndoDoc), rName ) );
720  }
721 
722  m_aDocument.CopyScenario( nSrcTab, nTab );
723 
726 
727  // paint all, because the active scenario may be modified in other ranges;
730  aModificator.SetDocumentModified();
731  }
732  else
733  {
734  std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetActiveDialogParent(),
735  VclMessageType::Info, VclButtonsType::Ok,
736  ScResId(STR_PROTECTIONERR)));
737  xInfoBox->run();
738  }
739  }
740  else
741  {
742  std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetActiveDialogParent(),
743  VclMessageType::Info, VclButtonsType::Ok,
744  ScResId(STR_SCENARIO_NOTFOUND)));
745  xInfoBox->run();
746  }
747  }
748  else
749  {
750  OSL_FAIL( "UseScenario on Scenario-Sheet" );
751  }
752 }
753 
754 void ScDocShell::ModifyScenario( SCTAB nTab, const OUString& rName, const OUString& rComment,
755  const Color& rColor, ScScenarioFlags nFlags )
756 {
757  // Undo
758  OUString aOldName;
759  m_aDocument.GetName( nTab, aOldName );
760  OUString aOldComment;
761  Color aOldColor;
762  ScScenarioFlags nOldFlags;
763  m_aDocument.GetScenarioData( nTab, aOldComment, aOldColor, nOldFlags );
765  std::make_unique<ScUndoScenarioFlags>(this, nTab,
766  aOldName, rName, aOldComment, rComment,
767  aOldColor, rColor, nOldFlags, nFlags) );
768 
769  // execute
770  ScDocShellModificator aModificator( *this );
771  m_aDocument.RenameTab( nTab, rName );
772  m_aDocument.SetScenarioData( nTab, rComment, rColor, nFlags );
774  aModificator.SetDocumentModified();
775 
776  if (aOldName != rName)
777  SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScTablesChanged ) );
778 
779  SfxBindings* pBindings = GetViewBindings();
780  if (pBindings)
781  pBindings->Invalidate( SID_SELECT_SCENARIO );
782 }
783 
784 SCTAB ScDocShell::MakeScenario( SCTAB nTab, const OUString& rName, const OUString& rComment,
785  const Color& rColor, ScScenarioFlags nFlags,
786  ScMarkData& rMark, bool bRecord )
787 {
788  rMark.MarkToMulti();
789  if (rMark.IsMultiMarked())
790  {
791  SCTAB nNewTab = nTab + 1;
792  while (m_aDocument.IsScenario(nNewTab))
793  ++nNewTab;
794 
795  bool bCopyAll = ( (nFlags & ScScenarioFlags::CopyAll) != ScScenarioFlags::NONE );
796  const ScMarkData* pCopyMark = nullptr;
797  if (!bCopyAll)
798  pCopyMark = &rMark;
799 
800  ScDocShellModificator aModificator( *this );
801 
802  if (bRecord)
803  m_aDocument.BeginDrawUndo(); // drawing layer must do its own undo actions
804 
805  if (m_aDocument.CopyTab( nTab, nNewTab, pCopyMark ))
806  {
807  if (bRecord)
808  {
810  std::make_unique<ScUndoMakeScenario>( this, nTab, nNewTab,
811  rName, rComment, rColor, nFlags, rMark ));
812  }
813 
814  m_aDocument.RenameTab( nNewTab, rName);
815  m_aDocument.SetScenario( nNewTab, true );
816  m_aDocument.SetScenarioData( nNewTab, rComment, rColor, nFlags );
817 
818  ScMarkData aDestMark = rMark;
819  aDestMark.SelectOneTable( nNewTab );
820 
822 
823  ScPatternAttr aProtPattern( m_aDocument.GetPool() );
824  aProtPattern.GetItemSet().Put( ScProtectionAttr( true ) );
825  m_aDocument.ApplyPatternAreaTab( 0,0, m_aDocument.MaxCol(),m_aDocument.MaxRow(), nNewTab, aProtPattern );
826 
827  ScPatternAttr aPattern( m_aDocument.GetPool() );
828  aPattern.GetItemSet().Put( ScMergeFlagAttr( ScMF::Scenario ) );
829  aPattern.GetItemSet().Put( ScProtectionAttr( true ) );
830  m_aDocument.ApplySelectionPattern( aPattern, aDestMark );
831 
832  if (!bCopyAll)
833  m_aDocument.SetVisible( nNewTab, false );
834 
835  // this is the active scenario, then
836  m_aDocument.CopyScenario( nNewTab, nTab, true ); // sal_True - don't copy anything from scenario
837 
838  if (nFlags & ScScenarioFlags::ShowFrame)
839  PostPaint( 0,0,nTab, m_aDocument.MaxCol(),m_aDocument.MaxRow(),nTab, PaintPartFlags::Grid ); // paint frames
840  PostPaintExtras(); // table tab
841  aModificator.SetDocumentModified();
842 
843  // A scenario tab is like a hidden sheet, broadcasting also
844  // notifies ScTabViewShell to add an ScViewData::maTabData entry.
845  Broadcast( ScTablesHint( SC_TAB_INSERTED, nNewTab ));
846  SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScTablesChanged ) );
847 
848  return nNewTab;
849  }
850  }
851  return nTab;
852 }
853 
855  SCTAB nDestPos, bool bInsertNew,
856  bool bNotifyAndPaint )
857 {
858  ScDocument& rSrcDoc = rSrcDocShell.GetDocument();
859 
860  // set the transferred area to the copyparam to make adjusting formulas possible
861  ScClipParam aParam;
862  ScRange aRange(0, 0, nSrcPos, m_aDocument.MaxCol(), m_aDocument.MaxRow(), nSrcPos);
863  aParam.maRanges.push_back(aRange);
864  rSrcDoc.SetClipParam(aParam);
865 
866  sal_uLong nErrVal = m_aDocument.TransferTab( rSrcDoc, nSrcPos, nDestPos,
867  bInsertNew ); // no insert
868 
869  // TransferTab doesn't copy drawing objects with bInsertNew=FALSE
870  if ( nErrVal > 0 && !bInsertNew)
871  m_aDocument.TransferDrawPage( rSrcDoc, nSrcPos, nDestPos );
872 
873  if(nErrVal>0 && rSrcDoc.IsScenario( nSrcPos ))
874  {
875  OUString aComment;
876  Color aColor;
877  ScScenarioFlags nFlags;
878 
879  rSrcDoc.GetScenarioData( nSrcPos, aComment,aColor, nFlags);
880  m_aDocument.SetScenario(nDestPos,true);
881  m_aDocument.SetScenarioData(nDestPos,aComment,aColor,nFlags);
882  bool bActive = rSrcDoc.IsActiveScenario(nSrcPos);
883  m_aDocument.SetActiveScenario(nDestPos, bActive );
884 
885  bool bVisible = rSrcDoc.IsVisible(nSrcPos);
886  m_aDocument.SetVisible(nDestPos,bVisible );
887 
888  }
889 
890  if ( nErrVal > 0 && rSrcDoc.IsTabProtected( nSrcPos ) )
891  m_aDocument.SetTabProtection(nDestPos, rSrcDoc.GetTabProtection(nSrcPos));
892  if ( bNotifyAndPaint )
893  {
894  Broadcast( ScTablesHint( SC_TAB_INSERTED, nDestPos ) );
895  PostPaintExtras();
897  }
898  return nErrVal;
899 }
900 
901 bool ScDocShell::MoveTable( SCTAB nSrcTab, SCTAB nDestTab, bool bCopy, bool bRecord )
902 {
903  ScDocShellModificator aModificator( *this );
904 
905  // #i92477# be consistent with ScDocFunc::InsertTable: any index past the last sheet means "append"
906  // #i101139# nDestTab must be the target position, not APPEND (for CopyTabProtection etc.)
907  if ( nDestTab >= m_aDocument.GetTableCount() )
908  nDestTab = m_aDocument.GetTableCount();
909 
910  if (bCopy)
911  {
912  if (bRecord)
913  m_aDocument.BeginDrawUndo(); // drawing layer must do its own undo actions
914 
915  OUString sSrcCodeName;
916  m_aDocument.GetCodeName( nSrcTab, sSrcCodeName );
917  if (!m_aDocument.CopyTab( nSrcTab, nDestTab ))
918  {
920  return false;
921  }
922  else
923  {
924  SCTAB nAdjSource = nSrcTab;
925  if ( nDestTab <= nSrcTab )
926  ++nAdjSource; // new position of source table after CopyTab
927 
928  if ( m_aDocument.IsTabProtected( nAdjSource ) )
929  m_aDocument.CopyTabProtection(nAdjSource, nDestTab);
930 
931  if (bRecord)
932  {
933  unique_ptr< vector<SCTAB> > pSrcList(new vector<SCTAB>(1, nSrcTab));
934  unique_ptr< vector<SCTAB> > pDestList(new vector<SCTAB>(1, nDestTab));
936  std::make_unique<ScUndoCopyTab>(this, std::move(pSrcList), std::move(pDestList)));
937  }
938 
939  bool bVbaEnabled = m_aDocument.IsInVBAMode();
940  if ( bVbaEnabled )
941  {
942  OUString aLibName( "Standard" );
944  Reference< XVBACompatibility > xVBACompat( xLibContainer, UNO_QUERY );
945 
946  if ( xVBACompat.is() )
947  {
948  aLibName = xVBACompat->getProjectName();
949  }
950 
951  SCTAB nTabToUse = nDestTab;
952  if ( nDestTab == SC_TAB_APPEND )
953  nTabToUse = m_aDocument.GetMaxTableNumber() - 1;
954  OUString sSource;
955  try
956  {
958  if( xLibContainer.is() )
959  {
960  css::uno::Any aLibAny = xLibContainer->getByName( aLibName );
961  aLibAny >>= xLib;
962  }
963  if( xLib.is() )
964  {
965  xLib->getByName( sSrcCodeName ) >>= sSource;
966  }
967  }
968  catch ( const css::uno::Exception& )
969  {
970  }
971  VBA_InsertModule( m_aDocument, nTabToUse, sSource );
972  }
973  }
974  Broadcast( ScTablesHint( SC_TAB_COPIED, nSrcTab, nDestTab ) );
975  }
976  else
977  {
978  if ( m_aDocument.GetChangeTrack() )
979  return false;
980 
981  if ( nSrcTab<nDestTab && nDestTab!=SC_TAB_APPEND )
982  nDestTab--;
983 
984  if ( nSrcTab == nDestTab )
985  {
987  return true; // nothing to do, but valid
988  }
989 
990  std::unique_ptr<ScProgress> pProgress(new ScProgress(this, ScResId(STR_UNDO_MOVE_TAB),
991  m_aDocument.GetCodeCount(), true));
992  bool bDone = m_aDocument.MoveTab( nSrcTab, nDestTab, pProgress.get() );
993  pProgress.reset();
994  if (!bDone)
995  {
996  return false;
997  }
998  else if (bRecord)
999  {
1000  unique_ptr< vector<SCTAB> > pSrcList(new vector<SCTAB>(1, nSrcTab));
1001  unique_ptr< vector<SCTAB> > pDestList(new vector<SCTAB>(1, nDestTab));
1003  std::make_unique<ScUndoMoveTab>(this, std::move(pSrcList), std::move(pDestList)));
1004  }
1005 
1006  Broadcast( ScTablesHint( SC_TAB_MOVED, nSrcTab, nDestTab ) );
1007  }
1008 
1009  PostPaintGridAll();
1010  PostPaintExtras();
1011  aModificator.SetDocumentModified();
1012  SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScTablesChanged ) );
1013 
1014  return true;
1015 }
1016 
1017 IMPL_LINK( ScDocShell, RefreshDBDataHdl, Timer*, pRefreshTimer, void )
1018 {
1019  ScDBDocFunc aFunc(*this);
1020 
1021  ScDBData* pDBData = static_cast<ScDBData*>(pRefreshTimer);
1022  ScImportParam aImportParam;
1023  pDBData->GetImportParam( aImportParam );
1024  if (aImportParam.bImport && !pDBData->HasImportSelection())
1025  {
1026  ScRange aRange;
1027  pDBData->GetArea( aRange );
1028  bool bContinue = aFunc.DoImport( aRange.aStart.Tab(), aImportParam, nullptr );
1029  // internal operations (sort, query, subtotal) only if no error
1030  if (bContinue)
1031  {
1032  aFunc.RepeatDB( pDBData->GetName(), true, true );
1033  RefreshPivotTables(aRange);
1034  }
1035  }
1036 }
1037 
1038 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void BeginDrawUndo()
Definition: documen9.cxx:58
void AddName(const OUString &rName)
Definition: consoli.cxx:206
SCTAB GetTab() const
Definition: dbdata.hxx:124
void UpdatePageBreaks(SCTAB nTab, const ScRange *pUserArea=nullptr)
Definition: document.cxx:6214
bool insert(std::unique_ptr< ScDBData > p)
Takes ownership of p and attempts to insert it into the collection.
Definition: dbdata.cxx:1157
bool HasAutoFilter() const
Definition: dbdata.hxx:204
SCCOL nColEnd
Definition: rangeutl.hxx:243
SCCOL nColStart
Definition: rangeutl.hxx:241
SC_DLLPUBLIC bool HasColHeader(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab)
Definition: documen3.cxx:1507
SC_DLLPUBLIC ScDBCollection * GetDBCollection() const
Definition: document.hxx:813
double GetPPTY() const
Definition: sizedev.hxx:43
ScAddress aStart
Definition: address.hxx:500
bool bVisible
SC_DLLPUBLIC void SetScenario(SCTAB nTab, bool bFlag)
Definition: documen3.cxx:420
SC_DLLPUBLIC bool IsTabProtected(SCTAB nTab) const
Definition: documen3.cxx:1889
void UpdatePendingRowHeights(SCTAB nUpdateTab, bool bBefore=false)
Definition: docsh5.cxx:432
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
Definition: markdata.hxx:43
std::unique_ptr< ScDBData > GetOldAutoDBRange()
Definition: docsh5.cxx:363
SC_DLLPUBLIC size_t GetCount() const
Definition: dpobject.cxx:3677
SCROW nRowStart
Definition: rangeutl.hxx:242
SC_DLLPUBLIC ScDBData * GetAnonymousDBData(SCTAB nTab)
Definition: document.cxx:305
SC_DLLPUBLIC void SetSortParam(const ScSortParam &rSortParam)
Definition: dbdata.cxx:398
SCROW Row() const
Definition: address.hxx:262
std::unique_ptr< ScDBData > m_pOldAutoDBRange
Definition: docsh.hxx:101
void PostPaintGridAll()
Definition: docsh3.cxx:180
bool AdjustRowHeight(SCROW nStartRow, SCROW nEndRow, SCTAB nTab)
merge with docfunc
Definition: docsh5.cxx:404
void MarkToMulti()
Definition: markdata.cxx:224
#define SC_TAB_MOVED
Definition: uiitems.hxx:78
ScDBData * GetAnonymousDBData(const ScRange &rRange)
Definition: docsh5.cxx:343
SC_DLLPUBLIC void SetTabProtection(SCTAB nTab, const ScTableProtection *pProtect)
Definition: documen3.cxx:1906
std::unique_ptr< ContentProperties > pData
static weld::Window * GetActiveDialogParent()
Definition: docsh.cxx:2950
SfxBindings * GetViewBindings()
Definition: docsh4.cxx:2579
bool HasHeader() const
Definition: dbdata.hxx:130
SC_DLLPUBLIC bool IsActiveScenario(SCTAB nTab) const
Definition: documen3.cxx:871
SC_DLLPUBLIC void SetAnonymousDBData(SCTAB nTab, std::unique_ptr< ScDBData > pDBData)
Definition: document.cxx:317
SC_DLLPUBLIC void SetDrawPageSize(SCTAB nTab)
Definition: documen9.cxx:193
void DoneFields()
Definition: consoli.cxx:130
ScScenarioFlags
Definition: global.hxx:238
void CopyScenario(SCTAB nSrcTab, SCTAB nDestTab, bool bNewScenario=false)
Definition: documen3.cxx:802
SC_DLLPUBLIC bool Intersects(const ScRange &rRange) const
Definition: address.cxx:1558
sal_uIntPtr sal_uLong
long Long
SC_DLLPUBLIC void CompileHybridFormula()
Call this immediately after updating named ranges.
Definition: document10.cxx:315
#define STR_DB_LOCAL_NONAME
Definition: globalnames.hxx:13
SC_DLLPUBLIC bool ApplyFlagsTab(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, ScMF nFlags)
Definition: document.cxx:5005
sal_Int64 n
don't create
Definition: global.hxx:397
SC_DLLPUBLIC ScDPCollection * GetDPCollection()
Definition: documen3.cxx:359
bool DoImport(SCTAB nTab, const ScImportParam &rParam, const svx::ODataAccessDescriptor *pDescriptor)
Definition: dbdocimp.cxx:121
void RefreshPivotTables(const ScRange &rSource)
Definition: docsh5.cxx:472
void SetPendingRowHeights(SCTAB nTab, bool bSet)
Definition: document.cxx:942
sal_uLong GetCodeCount() const
Definition: document.cxx:6154
const SfxItemSet & GetItemSet() const
void PostPaintExtras()
Definition: docsh3.cxx:195
sal_uInt16 nDataAreaCount
Definition: global.hxx:895
SC_DLLPUBLIC const ScDBData * GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const
Definition: documen3.cxx:332
ScAddress aEnd
Definition: address.hxx:501
create "Importx" (if necessary)
Definition: global.hxx:396
std::unique_ptr< ScArea[]> pDataAreas
Definition: global.hxx:896
#define SC_TAB_INSERTED
Definition: uiitems.hxx:76
void Invalidate(sal_uInt16 nId)
ScDBData * GetDBData(const ScRange &rMarked, ScGetDBMode eMode, ScGetDBSelection eSel)
Definition: docsh5.cxx:114
SC_DLLPUBLIC void SetVisible(SCTAB nTab, bool bVisible)
Definition: document.cxx:899
sal_uLong TransferTab(ScDocShell &rSrcDocShell, SCTAB nSrcPos, SCTAB nDestPos, bool bInsertNew, bool bNotifyAndPaint)
Definition: docsh5.cxx:854
Use structure ScDocument if a certain size is exceeded?
Definition: consoli.hxx:41
ScDBData * GetDBNearCursor(SCCOL nCol, SCROW nRow, SCTAB nTab)
Definition: dbdata.cxx:1468
void SetClipParam(const ScClipParam &rParam)
Definition: document.cxx:2555
void UpdateAllRowHeights(const ScMarkData *pTabMark=nullptr)
Definition: docsh5.cxx:422
ScGetDBMode
Definition: global.hxx:392
SfxApplication * SfxGetpApp()
bool UpdatePivotTable(ScDPObject &rDPObj, bool bRecord, bool bApi)
Definition: dbdocfun.cxx:1533
SC_DLLPUBLIC ScDocumentPool * GetPool()
Definition: document.cxx:6054
virtual SfxUndoManager * GetUndoManager() override
Definition: docsh.cxx:2806
void SetAllFormulasDirty(const sc::SetFormulaDirtyContext &rCxt)
Definition: document.cxx:3833
bool IsPendingRowHeights(SCTAB nTab) const
Definition: document.cxx:934
ScDBData * getByRange(const ScRange &rRange)
Definition: dbdata.cxx:1241
bool RepeatDB(const OUString &rDBName, bool bApi, bool bIsUnnamed, SCTAB aTab=0)
Definition: dbdocfun.cxx:281
SC_DLLPUBLIC bool RenameTab(SCTAB nTab, const OUString &rName, bool bExternalDocument=false)
Definition: document.cxx:851
SC_DLLPUBLIC SCROW MaxRow() const
Definition: document.hxx:870
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
SC_DLLPUBLIC SCTAB GetTableCount() const
Definition: document.cxx:312
AnonDBs & getAnonDBs()
Definition: dbdata.hxx:318
bool IsMultiMarked() const
Definition: markdata.hxx:83
int nCount
void GetSize(SCCOL &rCols, SCROW &rRows) const
Definition: consoli.cxx:142
void CopyToDocument(SCCOL nCol1, SCROW nRow1, SCTAB nTab1, SCCOL nCol2, SCROW nRow2, SCTAB nTab2, InsertDeleteFlags nFlags, bool bMarked, ScDocument &rDestDoc, const ScMarkData *pMarks=nullptr, bool bColRowFlags=true)
Definition: document.cxx:2074
SCROW nRowEnd
Definition: rangeutl.hxx:244
SC_DLLPUBLIC void TransferDrawPage(const ScDocument &rSrcDoc, SCTAB nSrcPos, SCTAB nDestPos)
Definition: documen9.cxx:64
void push_back(const ScRange &rRange)
Definition: rangelst.cxx:1142
SCTAB Tab() const
Definition: address.hxx:271
SC_DLLPUBLIC void SetQueryParam(const ScQueryParam &rQueryParam)
Definition: dbdata.cxx:422
SC_DLLPUBLIC const ScRange & GetSourceRange() const
Get the range that contains the source data.
Definition: dpshttab.cxx:229
void CopyTabProtection(SCTAB nTabSrc, SCTAB nTabDest)
Definition: documen3.cxx:1914
SCTAB GetMaxTableNumber() const
Definition: document.hxx:803
void SetFlags(ScSubTotalFunc eFunc, bool bColName, bool bRowName, bool bRef)
Definition: consoli.cxx:148
IMPL_LINK(ScDocShell, RefreshDBDataHdl, Timer *, pRefreshTimer, void)
Definition: docsh5.cxx:1017
If only one row or portion thereof is selected, shrink row to used data columns and select further ro...
ScChangeTrack * GetChangeTrack() const
Definition: document.hxx:2389
OutputDevice * GetDevice() const
Definition: sizedev.hxx:41
create "untitled" (if necessary)
Definition: global.hxx:394
constexpr OUStringLiteral aData
void SetArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
Definition: dbdata.cxx:322
void AddFields(const ScDocument *pSrcDoc, SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
Definition: consoli.cxx:159
SC_DLLPUBLIC void GetDataArea(SCTAB nTab, SCCOL &rStartCol, SCROW &rStartRow, SCCOL &rEndCol, SCROW &rEndRow, bool bIncludeOld, bool bOnlyDown) const
Return the smallest area containing at least all contiguous cells having data.
Definition: document.cxx:1094
SC_DLLPUBLIC void SetScenarioData(SCTAB nTab, const OUString &rComment, const Color &rColor, ScScenarioFlags nFlags)
Definition: documen3.cxx:431
SC_DLLPUBLIC SCCOL MaxCol() const
Definition: document.hxx:869
virtual void AddUndoAction(std::unique_ptr< SfxUndoAction > pAction, bool bTryMerg=false)
bool CopyTab(SCTAB nOldPos, SCTAB nNewPos, const ScMarkData *pOnlyMarked=nullptr)
Definition: documen2.cxx:764
bool IsImportingXML() const
Definition: document.hxx:2134
void DBAreaDeleted(SCTAB nTab, SCCOL nX1, SCROW nY1, SCCOL nX2)
Definition: docsh5.cxx:103
const SCTAB SC_TAB_APPEND
Definition: address.hxx:84
int i
void UpdateAllRowHeights(sc::RowHeightContext &rCxt, const ScMarkData *pTabMark)
Definition: document.cxx:4273
SC_DLLPUBLIC void SetActiveScenario(SCTAB nTab, bool bActive)
Definition: documen3.cxx:876
void SelectTable(SCTAB nTab, bool bNew)
Definition: markdata.cxx:172
std::unique_ptr< ScDocument, o3tl::default_delete< ScDocument > > ScDocumentUniquePtr
Definition: document.hxx:2610
sal_Int16 SCCOL
Definition: types.hxx:22
virtual bool has_focus() const =0
void OutputToDocument(ScDocument &rDestDoc, SCCOL nCol, SCROW nRow, SCTAB nTab)
Definition: consoli.cxx:392
SC_DLLPUBLIC bool SetOptimalHeight(sc::RowHeightContext &rCxt, SCROW nStartRow, SCROW nEndRow, SCTAB nTab)
Definition: document.cxx:4264
ScSheetLimits & GetSheetLimits() const
Definition: document.hxx:871
SC_DLLPUBLIC sal_uLong TransferTab(ScDocument &rSrcDoc, SCTAB nSrcPos, SCTAB nDestPos, bool bInsertNew=true, bool bResultsOnly=false)
Definition: documen2.cxx:905
void ModifyScenario(SCTAB nTab, const OUString &rName, const OUString &rComment, const Color &rColor, ScScenarioFlags nFlags)
Definition: docsh5.cxx:754
void SelectOneTable(SCTAB nTab)
Definition: markdata.cxx:189
void MarkScenario(SCTAB nSrcTab, SCTAB nDestTab, ScMarkData &rDestMark, bool bResetMark=true, ScScenarioFlags nNeededBits=ScScenarioFlags::NONE) const
Definition: documen3.cxx:846
OUString ScResId(const char *pId)
Definition: scdll.cxx:89
const OUString & GetName() const
Definition: dbdata.hxx:122
void AddData(ScDocument *pSrcDoc, SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
Definition: consoli.cxx:239
void GetImportParam(ScImportParam &rImportParam) const
Definition: dbdata.cxx:465
SC_DLLPUBLIC void ApplyPatternAreaTab(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, const ScPatternAttr &rAttr)
Definition: document.cxx:4784
void BroadcastUno(const SfxHint &rHint)
Definition: documen3.cxx:943
void UseScenario(SCTAB nTab, const OUString &rName, bool bRecord=true)
Definition: docsh5.cxx:659
bool IsEditable() const
Definition: docsh5.cxx:95
const SCTAB MAXTAB
Definition: address.hxx:71
ScRangeList maRanges
Definition: clipparam.hxx:34
void PostPaint(SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab, SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab, PaintPartFlags nPart, sal_uInt16 nExtFlags=0)
Definition: docsh3.cxx:98
void GetArea(SCTAB &rTab, SCCOL &rCol1, SCROW &rRow1, SCCOL &rCol2, SCROW &rRow2) const
Definition: dbdata.cxx:300
void SetHeader(bool bHasH)
Definition: dbdata.hxx:131
void LockStreamValid(bool bLock)
Definition: document.cxx:929
SCCOL Col() const
Definition: address.hxx:267
bool IsReadOnly() const
void SetByRow(bool bByR)
Definition: dbdata.hxx:129
ScDBData * findByUpperName(const OUString &rName)
Definition: dbdata.cxx:1144
top left cell of area
SC_DLLPUBLIC void GetScenarioData(SCTAB nTab, OUString &rComment, Color &rColor, ScScenarioFlags &rFlags) const
Definition: documen3.cxx:462
void VBA_InsertModule(ScDocument &rDoc, SCTAB nTab, const OUString &sSource)
Definition: docfunc.cxx:3188
static OUString lcl_GetAreaName(ScDocument *pDoc, const ScArea *pArea)
Definition: docsh5.cxx:489
Stores global named database ranges.
Definition: dbdata.hxx:235
SCROW GetInsertCount() const
Definition: consoli.cxx:370
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
Behave as if the range corresponding to a ScDBData area was selected, for API use.
sal_Int32 SCROW
Definition: types.hxx:18
void SetSize(SCCOL nCols, SCROW nRows)
Definition: consoli.cxx:135
ScGetDBSelection
For ScDBFunc::GetDBData()
Definition: global.hxx:401
bool MoveTab(SCTAB nOldPos, SCTAB nNewPos, ScProgress *pProgress=nullptr)
Definition: documen2.cxx:694
SC_DLLPUBLIC bool IsScenario(SCTAB nTab) const
Definition: documen3.cxx:426
virtual void grab_focus()=0
void ErrorMessage(const char *pGlobStrId)
Definition: docsh5.cxx:70
SCTAB MakeScenario(SCTAB nTab, const OUString &rName, const OUString &rComment, const Color &rColor, ScScenarioFlags nFlags, ScMarkData &rMark, bool bRecord=true)
Definition: docsh5.cxx:784
OUString aName
field button for datapilot
SC_DLLPUBLIC bool RemoveFlagsTab(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, ScMF nFlags)
Definition: document.cxx:5016
ScSubTotalFunc eFunction
Definition: global.hxx:894
SC_DLLPUBLIC void ApplySelectionPattern(const ScPatternAttr &rAttr, const ScMarkData &rMark, ScEditDataArray *pDataArray=nullptr, bool *pIsChanged=nullptr)
Definition: document.cxx:5867
const ScSheetSourceDesc * GetSheetDesc() const
Definition: dpobject.hxx:156
SC_DLLPUBLIC ScOutlineTable * GetOutlineTable(SCTAB nTab, bool bCreate=false)
Definition: documen3.cxx:730
bool IsInVBAMode() const
Definition: document.cxx:6484
static SC_DLLPUBLIC const CharClass * getCharClassPtr()
Definition: global.cxx:1009
force use of sheet-local instead of document global anonymous range
Definition: global.hxx:395
const ScDocument & GetDocument() const
Definition: docsh.hxx:217
SC_DLLPUBLIC void PreprocessDBDataUpdate()
Definition: document10.cxx:303
bool HasImportSelection() const
Definition: dbdata.hxx:201
bool bImport
Definition: global.hxx:456
void CancelAutoDBRange()
Definition: docsh5.cxx:368
NamedDBs & getNamedDBs()
Definition: dbdata.hxx:315
void SetDocumentModified()
Definition: docsh.cxx:3159
ScDocument m_aDocument
Definition: docsh.hxx:81
void DoConsolidate(const ScConsolidateParam &rParam, bool bRecord=true)
Definition: docsh5.cxx:501
bool MoveTable(SCTAB nSrcTab, SCTAB nDestTab, bool bCopy, bool bRecord)
Definition: docsh5.cxx:901
void SetSubTotalParam(const ScSubTotalParam &rSubTotalParam)
Definition: dbdata.cxx:460
SCTAB nTab
Definition: rangeutl.hxx:240
SC_DLLPUBLIC bool IsVisible(SCTAB nTab) const
Definition: document.cxx:906
bool IsUndoEnabled() const
Definition: document.hxx:1528
const OUString & GetCodeName() const
Definition: document.hxx:595
#define SC_TAB_COPIED
Definition: uiitems.hxx:79
bool TestCopyScenario(SCTAB nSrcTab, SCTAB nDestTab) const
Definition: documen3.cxx:882
const ScDBData * GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, ScDBDataPortion ePortion) const
Definition: documen3.cxx:316
PaintPartFlags
Definition: global.hxx:121
This struct stores general clipboard parameters associated with a ScDocument instance created in clip...
Definition: clipparam.hxx:30
SC_DLLPUBLIC void DeleteAreaTab(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, SCTAB nTab, InsertDeleteFlags nDelFlag)
Definition: document.cxx:1953
SC_DLLPUBLIC void EnableUndo(bool bVal)
Definition: document.cxx:6463
const SCTAB SCTAB_MAX
Definition: address.hxx:58
static SCTAB GetCurTab()
Definition: docsh4.cxx:2551
This class contains authoritative information on the internal reference used as the data source for d...
Definition: dpshttab.hxx:39
SC_DLLPUBLIC bool GetName(SCTAB nTab, OUString &rName) const
Definition: document.cxx:211
double GetPPTX() const
Definition: sizedev.hxx:42
bool ValidTab(SCTAB nTab)
Definition: address.hxx:105
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, bool bMobile=false)
Create before modifications of the document and destroy thereafter.
Definition: docsh.hxx:452
sal_uInt16 nPos
sal_Int16 SCTAB
Definition: types.hxx:23
void SetAutoFilter(bool bSet)
Definition: dbdata.hxx:205
bool IsChangeReadOnlyEnabled() const
Definition: document.hxx:1537
css::uno::Reference< css::script::XLibraryContainer > GetBasicContainer()
SC_DLLPUBLIC const ScTableProtection * GetTabProtection(SCTAB nTab) const
Definition: documen3.cxx:1898
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo