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