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 
71 {
73 
75  weld::WaitObject aWaitOff( pParent );
76  bool bFocus = pParent && pParent->has_focus();
77 
78  if (pGlobStrId && pGlobStrId == STR_PROTECTIONERR)
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 
100  return !IsReadOnly() || m_pDocument->IsImportingXML() || m_pDocument->IsChangeReadOnlyEnabled();
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_pDocument->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_pDocument->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.
127  ScDBCollection* pColl = m_pDocument->GetDBCollection();
128  ScDBData* pData = m_pDocument->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_pDocument->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_pDocument->GetDataArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow, false, bOnlyDown );
218  }
219 
220  bool bHasHeader = m_pDocument->HasColHeader( nStartCol,nStartRow, nEndCol,nEndRow, nTab );
221 
222  ScDBData* pNoNameData = m_pDocument->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_pDocument->GetAnonymousDBData();
234  if (!pNoNameData)
235  {
236  m_pDocument->SetAnonymousDBData( std::unique_ptr<ScDBData>(new ScDBData( STR_DB_LOCAL_NONAME,
237  nTab, nStartCol, nStartRow, nEndCol, nEndRow, true, bHasHeader) ) );
238  pNoNameData = m_pDocument->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  {
293  m_pDocument->PreprocessDBDataUpdate();
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::getCharClass().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_pDocument->SetAnonymousDBData(nTab, std::unique_ptr<ScDBData>(pNoNameData));
320  }
321 
322  if ( pUndoColl )
323  {
324  m_pDocument->CompileHybridFormula();
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 {
345  ScDBCollection* pColl = m_pDocument->GetDBCollection();
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_pDocument->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_pDocument->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_pDocument->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_pDocument->MaxRow(), aProv.GetPPTX(), aProv.GetPPTY(), aZoom, aZoom, aProv.GetDevice());
409  bool bChange = m_pDocument->SetOptimalHeight(aCxt, nStartRow,nEndRow, nTab, true);
410 
411  if (bChange)
412  {
413  // tdf#76183: recalculate objects' positions
414  m_pDocument->SetDrawPageSize(nTab);
415 
416  PostPaint( 0,nStartRow,nTab, m_pDocument->MaxCol(),m_pDocument->MaxRow(),nTab, PaintPartFlags::Grid|PaintPartFlags::Left );
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_pDocument->MaxRow(), aProv.GetPPTX(), aProv.GetPPTY(), aZoom, aZoom, aProv.GetDevice());
429  m_pDocument->UpdateAllRowHeights(aCxt, pTabMark);
430 }
431 
432 void ScDocShell::UpdatePendingRowHeights( SCTAB nUpdateTab, bool bBefore )
433 {
434  bool bIsUndoEnabled = m_pDocument->IsUndoEnabled();
435  m_pDocument->EnableUndo( false );
436  m_pDocument->LockStreamValid( true ); // ignore draw page size (but not formula results)
437  if ( bBefore ) // check all sheets up to nUpdateTab
438  {
439  SCTAB nTabCount = m_pDocument->GetTableCount();
440  if ( nUpdateTab >= nTabCount )
441  nUpdateTab = nTabCount-1; // nUpdateTab is inclusive
442 
443  ScMarkData aUpdateSheets(m_pDocument->GetSheetLimits());
444  SCTAB nTab;
445  for (nTab=0; nTab<=nUpdateTab; ++nTab)
446  if ( m_pDocument->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  {
455  m_pDocument->UpdatePageBreaks( nTab );
456  m_pDocument->SetPendingRowHeights( nTab, false );
457  }
458  }
459  else // only nUpdateTab
460  {
461  if ( m_pDocument->IsPendingRowHeights( nUpdateTab ) )
462  {
463  AdjustRowHeight( 0, m_pDocument->MaxRow(), nUpdateTab );
464  m_pDocument->UpdatePageBreaks( nUpdateTab );
465  m_pDocument->SetPendingRowHeights( nUpdateTab, false );
466  }
467  }
468  m_pDocument->LockStreamValid( false );
469  m_pDocument->EnableUndo( bIsUndoEnabled );
470 }
471 
473 {
474  ScDPCollection* pColl = m_pDocument->GetDPCollection();
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_pDocument->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_pDocument.get(), 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_pDocument.get(), rArea.nTab, rArea.nColStart, rArea.nRowStart,
554  rArea.nColEnd, rArea.nRowEnd );
555  aData.AddName( lcl_GetAreaName(m_pDocument.get(), &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_pDocument->GetTableCount();
572  SCROW nInsertCount = aData.GetInsertCount();
573 
574  // old outlines
575  ScOutlineTable* pTable = m_pDocument->GetOutlineTable( nDestTab );
576  std::unique_ptr<ScOutlineTable> pUndoTab(pTable ? new ScOutlineTable( *pTable ) : nullptr);
577 
579  pUndoDoc->InitUndo( *m_pDocument, 0, nTabCount-1, false, true );
580 
581  // row state
582  m_pDocument->CopyToDocument(0, 0, nDestTab, m_pDocument->MaxCol(), m_pDocument->MaxRow(), nDestTab,
583  InsertDeleteFlags::NONE, false, *pUndoDoc);
584 
585  // all formulas
586  m_pDocument->CopyToDocument(0, 0, 0, m_pDocument->MaxCol(), m_pDocument->MaxRow(), nTabCount-1,
587  InsertDeleteFlags::FORMULA, false, *pUndoDoc);
588 
589  // complete output rows
590  m_pDocument->CopyToDocument(0, aDestArea.nRowStart, nDestTab,
591  m_pDocument->MaxCol(),aDestArea.nRowEnd, nDestTab,
592  InsertDeleteFlags::ALL, false, *pUndoDoc);
593 
594  // old output range
595  if (pDestData)
596  m_pDocument->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_pDocument, aDestArea.nTab, aDestArea.nTab );
606 
607  m_pDocument->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_pDocument->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  {
623  m_pDocument->DeleteAreaTab(aOldDest, InsertDeleteFlags::CONTENTS);
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_pDocument, 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_pDocument->MaxCol();
644  nPaintEndRow = m_pDocument->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_pDocument->IsScenario(nTab))
662  {
663  SCTAB nTabCount = m_pDocument->GetTableCount();
664  SCTAB nSrcTab = SCTAB_MAX;
665  SCTAB nEndTab = nTab;
666  OUString aCompare;
667  while ( nEndTab+1 < nTabCount && m_pDocument->IsScenario(nEndTab+1) )
668  {
669  ++nEndTab;
670  if (nSrcTab > MAXTAB) // still searching for the scenario?
671  {
672  m_pDocument->GetName( nEndTab, aCompare );
673  if (aCompare == rName)
674  nSrcTab = nEndTab; // found
675  }
676  }
677  if (ValidTab(nSrcTab))
678  {
679  if ( m_pDocument->TestCopyScenario( nSrcTab, nTab ) ) // test cell protection
680  {
681  ScDocShellModificator aModificator( *this );
682  ScMarkData aScenMark(m_pDocument->GetSheetLimits());
683  m_pDocument->MarkScenario( nSrcTab, nTab, aScenMark );
684  const ScRange& aMultiRange = aScenMark.GetMultiMarkArea();
685  SCCOL nStartCol = aMultiRange.aStart.Col();
686  SCROW nStartRow = aMultiRange.aStart.Row();
687  SCCOL nEndCol = aMultiRange.aEnd.Col();
688  SCROW nEndRow = aMultiRange.aEnd.Row();
689 
690  if (bRecord)
691  {
693  pUndoDoc->InitUndo( *m_pDocument, nTab,nEndTab ); // also all scenarios
694  // shown table:
695  m_pDocument->CopyToDocument(nStartCol, nStartRow, nTab,
696  nEndCol, nEndRow, nTab, InsertDeleteFlags::ALL,
697  true, *pUndoDoc, &aScenMark);
698  // scenarios
699  for (SCTAB i=nTab+1; i<=nEndTab; i++)
700  {
701  pUndoDoc->SetScenario( i, true );
702  OUString aComment;
703  Color aColor;
704  ScScenarioFlags nScenFlags;
705  m_pDocument->GetScenarioData( i, aComment, aColor, nScenFlags );
706  pUndoDoc->SetScenarioData( i, aComment, aColor, nScenFlags );
707  bool bActive = m_pDocument->IsActiveScenario( i );
708  pUndoDoc->SetActiveScenario( i, bActive );
709  // At copy-back scenarios also contents
710  if ( nScenFlags & ScScenarioFlags::TwoWay )
711  m_pDocument->CopyToDocument(0, 0, i, m_pDocument->MaxCol(), m_pDocument->MaxRow(), i,
712  InsertDeleteFlags::ALL, false, *pUndoDoc );
713  }
714 
716  std::make_unique<ScUndoUseScenario>( this, aScenMark,
717  ScArea( nTab,nStartCol,nStartRow,nEndCol,nEndRow ),
718  std::move(pUndoDoc), rName ) );
719  }
720 
721  m_pDocument->CopyScenario( nSrcTab, nTab );
722 
724  m_pDocument->SetAllFormulasDirty(aCxt);
725 
726  // paint all, because the active scenario may be modified in other ranges;
728  PostPaint( 0,0,nTab, m_pDocument->MaxCol(),m_pDocument->MaxRow(),nTab, PaintPartFlags::Grid );
729  aModificator.SetDocumentModified();
730  }
731  else
732  {
733  std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetActiveDialogParent(),
734  VclMessageType::Info, VclButtonsType::Ok,
735  ScResId(STR_PROTECTIONERR)));
736  xInfoBox->run();
737  }
738  }
739  else
740  {
741  std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetActiveDialogParent(),
742  VclMessageType::Info, VclButtonsType::Ok,
743  ScResId(STR_SCENARIO_NOTFOUND)));
744  xInfoBox->run();
745  }
746  }
747  else
748  {
749  OSL_FAIL( "UseScenario on Scenario-Sheet" );
750  }
751 }
752 
753 void ScDocShell::ModifyScenario( SCTAB nTab, const OUString& rName, const OUString& rComment,
754  const Color& rColor, ScScenarioFlags nFlags )
755 {
756  // Undo
757  OUString aOldName;
758  m_pDocument->GetName( nTab, aOldName );
759  OUString aOldComment;
760  Color aOldColor;
761  ScScenarioFlags nOldFlags;
762  m_pDocument->GetScenarioData( nTab, aOldComment, aOldColor, nOldFlags );
764  std::make_unique<ScUndoScenarioFlags>(this, nTab,
765  aOldName, rName, aOldComment, rComment,
766  aOldColor, rColor, nOldFlags, nFlags) );
767 
768  // execute
769  ScDocShellModificator aModificator( *this );
770  m_pDocument->RenameTab( nTab, rName );
771  m_pDocument->SetScenarioData( nTab, rComment, rColor, nFlags );
773  aModificator.SetDocumentModified();
774 
775  if (aOldName != rName)
776  SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScTablesChanged ) );
777 
778  SfxBindings* pBindings = GetViewBindings();
779  if (pBindings)
780  pBindings->Invalidate( SID_SELECT_SCENARIO );
781 }
782 
783 SCTAB ScDocShell::MakeScenario( SCTAB nTab, const OUString& rName, const OUString& rComment,
784  const Color& rColor, ScScenarioFlags nFlags,
785  ScMarkData& rMark, bool bRecord )
786 {
787  rMark.MarkToMulti();
788  if (rMark.IsMultiMarked())
789  {
790  SCTAB nNewTab = nTab + 1;
791  while (m_pDocument->IsScenario(nNewTab))
792  ++nNewTab;
793 
794  bool bCopyAll = ( (nFlags & ScScenarioFlags::CopyAll) != ScScenarioFlags::NONE );
795  const ScMarkData* pCopyMark = nullptr;
796  if (!bCopyAll)
797  pCopyMark = &rMark;
798 
799  ScDocShellModificator aModificator( *this );
800 
801  if (bRecord)
802  m_pDocument->BeginDrawUndo(); // drawing layer must do its own undo actions
803 
804  if (m_pDocument->CopyTab( nTab, nNewTab, pCopyMark ))
805  {
806  if (bRecord)
807  {
809  std::make_unique<ScUndoMakeScenario>( this, nTab, nNewTab,
810  rName, rComment, rColor, nFlags, rMark ));
811  }
812 
813  m_pDocument->RenameTab( nNewTab, rName);
814  m_pDocument->SetScenario( nNewTab, true );
815  m_pDocument->SetScenarioData( nNewTab, rComment, rColor, nFlags );
816 
817  ScMarkData aDestMark = rMark;
818  aDestMark.SelectOneTable( nNewTab );
819 
821 
822  ScPatternAttr aProtPattern( m_pDocument->GetPool() );
823  aProtPattern.GetItemSet().Put( ScProtectionAttr( true ) );
824  m_pDocument->ApplyPatternAreaTab( 0,0, m_pDocument->MaxCol(),m_pDocument->MaxRow(), nNewTab, aProtPattern );
825 
826  ScPatternAttr aPattern( m_pDocument->GetPool() );
827  aPattern.GetItemSet().Put( ScMergeFlagAttr( ScMF::Scenario ) );
828  aPattern.GetItemSet().Put( ScProtectionAttr( true ) );
829  m_pDocument->ApplySelectionPattern( aPattern, aDestMark );
830 
831  if (!bCopyAll)
832  m_pDocument->SetVisible( nNewTab, false );
833 
834  // this is the active scenario, then
835  m_pDocument->CopyScenario( nNewTab, nTab, true ); // sal_True - don't copy anything from scenario
836 
837  if (nFlags & ScScenarioFlags::ShowFrame)
838  PostPaint( 0,0,nTab, m_pDocument->MaxCol(),m_pDocument->MaxRow(),nTab, PaintPartFlags::Grid ); // paint frames
839  PostPaintExtras(); // table tab
840  aModificator.SetDocumentModified();
841 
842  // A scenario tab is like a hidden sheet, broadcasting also
843  // notifies ScTabViewShell to add an ScViewData::maTabData entry.
844  Broadcast( ScTablesHint( SC_TAB_INSERTED, nNewTab ));
845  SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScTablesChanged ) );
846 
847  return nNewTab;
848  }
849  }
850  return nTab;
851 }
852 
854  SCTAB nDestPos, bool bInsertNew,
855  bool bNotifyAndPaint )
856 {
857  ScDocument& rSrcDoc = rSrcDocShell.GetDocument();
858 
859  // set the transferred area to the copyparam to make adjusting formulas possible
860  ScClipParam aParam;
861  ScRange aRange(0, 0, nSrcPos, m_pDocument->MaxCol(), m_pDocument->MaxRow(), nSrcPos);
862  aParam.maRanges.push_back(aRange);
863  rSrcDoc.SetClipParam(aParam);
864 
865  sal_uLong nErrVal = m_pDocument->TransferTab( rSrcDoc, nSrcPos, nDestPos,
866  bInsertNew ); // no insert
867 
868  // TransferTab doesn't copy drawing objects with bInsertNew=FALSE
869  if ( nErrVal > 0 && !bInsertNew)
870  m_pDocument->TransferDrawPage( rSrcDoc, nSrcPos, nDestPos );
871 
872  if(nErrVal>0 && rSrcDoc.IsScenario( nSrcPos ))
873  {
874  OUString aComment;
875  Color aColor;
876  ScScenarioFlags nFlags;
877 
878  rSrcDoc.GetScenarioData( nSrcPos, aComment,aColor, nFlags);
879  m_pDocument->SetScenario(nDestPos,true);
880  m_pDocument->SetScenarioData(nDestPos,aComment,aColor,nFlags);
881  bool bActive = rSrcDoc.IsActiveScenario(nSrcPos);
882  m_pDocument->SetActiveScenario(nDestPos, bActive );
883 
884  bool bVisible = rSrcDoc.IsVisible(nSrcPos);
885  m_pDocument->SetVisible(nDestPos,bVisible );
886 
887  }
888 
889  if ( nErrVal > 0 && rSrcDoc.IsTabProtected( nSrcPos ) )
890  m_pDocument->SetTabProtection(nDestPos, rSrcDoc.GetTabProtection(nSrcPos));
891  if ( bNotifyAndPaint )
892  {
893  Broadcast( ScTablesHint( SC_TAB_INSERTED, nDestPos ) );
894  PostPaintExtras();
896  }
897  return nErrVal;
898 }
899 
900 bool ScDocShell::MoveTable( SCTAB nSrcTab, SCTAB nDestTab, bool bCopy, bool bRecord )
901 {
902  ScDocShellModificator aModificator( *this );
903 
904  // #i92477# be consistent with ScDocFunc::InsertTable: any index past the last sheet means "append"
905  // #i101139# nDestTab must be the target position, not APPEND (for CopyTabProtection etc.)
906  if ( nDestTab >= m_pDocument->GetTableCount() )
907  nDestTab = m_pDocument->GetTableCount();
908 
909  if (bCopy)
910  {
911  if (bRecord)
912  m_pDocument->BeginDrawUndo(); // drawing layer must do its own undo actions
913 
914  OUString sSrcCodeName;
915  m_pDocument->GetCodeName( nSrcTab, sSrcCodeName );
916  if (!m_pDocument->CopyTab( nSrcTab, nDestTab ))
917  {
919  return false;
920  }
921  else
922  {
923  SCTAB nAdjSource = nSrcTab;
924  if ( nDestTab <= nSrcTab )
925  ++nAdjSource; // new position of source table after CopyTab
926 
927  if ( m_pDocument->IsTabProtected( nAdjSource ) )
928  m_pDocument->CopyTabProtection(nAdjSource, nDestTab);
929 
930  if (bRecord)
931  {
932  unique_ptr< vector<SCTAB> > pSrcList(new vector<SCTAB>(1, nSrcTab));
933  unique_ptr< vector<SCTAB> > pDestList(new vector<SCTAB>(1, nDestTab));
935  std::make_unique<ScUndoCopyTab>(this, std::move(pSrcList), std::move(pDestList)));
936  }
937 
938  bool bVbaEnabled = m_pDocument->IsInVBAMode();
939  if ( bVbaEnabled )
940  {
941  OUString aLibName( "Standard" );
943  Reference< XVBACompatibility > xVBACompat( xLibContainer, UNO_QUERY );
944 
945  if ( xVBACompat.is() )
946  {
947  aLibName = xVBACompat->getProjectName();
948  }
949 
950  SCTAB nTabToUse = nDestTab;
951  if ( nDestTab == SC_TAB_APPEND )
952  nTabToUse = m_pDocument->GetMaxTableNumber() - 1;
953  OUString sSource;
954  try
955  {
957  if( xLibContainer.is() )
958  {
959  css::uno::Any aLibAny = xLibContainer->getByName( aLibName );
960  aLibAny >>= xLib;
961  }
962  if( xLib.is() )
963  {
964  xLib->getByName( sSrcCodeName ) >>= sSource;
965  }
966  }
967  catch ( const css::uno::Exception& )
968  {
969  }
970  VBA_InsertModule( *m_pDocument, nTabToUse, sSource );
971  }
972  }
973  Broadcast( ScTablesHint( SC_TAB_COPIED, nSrcTab, nDestTab ) );
974  }
975  else
976  {
977  if ( m_pDocument->GetChangeTrack() )
978  return false;
979 
980  if ( nSrcTab<nDestTab && nDestTab!=SC_TAB_APPEND )
981  nDestTab--;
982 
983  if ( nSrcTab == nDestTab )
984  {
986  return true; // nothing to do, but valid
987  }
988 
989  std::optional<ScProgress> pProgress(std::in_place, this, ScResId(STR_UNDO_MOVE_TAB),
990  m_pDocument->GetCodeCount(), true);
991  bool bDone = m_pDocument->MoveTab( nSrcTab, nDestTab, &*pProgress );
992  pProgress.reset();
993  if (!bDone)
994  {
995  return false;
996  }
997  else if (bRecord)
998  {
999  unique_ptr< vector<SCTAB> > pSrcList(new vector<SCTAB>(1, nSrcTab));
1000  unique_ptr< vector<SCTAB> > pDestList(new vector<SCTAB>(1, nDestTab));
1002  std::make_unique<ScUndoMoveTab>(this, std::move(pSrcList), std::move(pDestList)));
1003  }
1004 
1005  Broadcast( ScTablesHint( SC_TAB_MOVED, nSrcTab, nDestTab ) );
1006  }
1007 
1008  PostPaintGridAll();
1009  PostPaintExtras();
1010  aModificator.SetDocumentModified();
1011  SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScTablesChanged ) );
1012 
1013  return true;
1014 }
1015 
1016 IMPL_LINK( ScDocShell, RefreshDBDataHdl, Timer*, pRefreshTimer, void )
1017 {
1018  ScDBDocFunc aFunc(*this);
1019 
1020  ScDBData* pDBData = static_cast<ScDBData*>(pRefreshTimer);
1021  ScImportParam aImportParam;
1022  pDBData->GetImportParam( aImportParam );
1023  if (aImportParam.bImport && !pDBData->HasImportSelection())
1024  {
1025  ScRange aRange;
1026  pDBData->GetArea( aRange );
1027  bool bContinue = aFunc.DoImport( aRange.aStart.Tab(), aImportParam, nullptr );
1028  // internal operations (sort, query, subtotal) only if no error
1029  if (bContinue)
1030  {
1031  aFunc.RepeatDB( pDBData->GetName(), true, true );
1032  RefreshPivotTables(aRange);
1033  }
1034  }
1035 }
1036 
1037 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void AddName(const OUString &rName)
Definition: consoli.cxx:206
SCTAB GetTab() const
Definition: dbdata.hxx:123
bool insert(std::unique_ptr< ScDBData > p)
Takes ownership of p and attempts to insert it into the collection.
Definition: dbdata.cxx:1215
bool HasAutoFilter() const
Definition: dbdata.hxx:204
SCCOL nColEnd
Definition: rangeutl.hxx:250
SCCOL nColStart
Definition: rangeutl.hxx:248
double GetPPTY() const
Definition: sizedev.hxx:42
ScAddress aStart
Definition: address.hxx:497
bool bVisible
SC_DLLPUBLIC bool IsTabProtected(SCTAB nTab) const
Definition: documen3.cxx:1913
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:42
std::unique_ptr< ScDBData > GetOldAutoDBRange()
Definition: docsh5.cxx:363
OUString ScResId(TranslateId aId)
Definition: scdll.cxx:90
SC_DLLPUBLIC size_t GetCount() const
Definition: dpobject.cxx:3679
SCROW nRowStart
Definition: rangeutl.hxx:249
SC_DLLPUBLIC void SetSortParam(const ScSortParam &rSortParam)
Definition: dbdata.cxx:413
SCROW Row() const
Definition: address.hxx:274
std::unique_ptr< ScDBData > m_pOldAutoDBRange
Definition: docsh.hxx:102
void PostPaintGridAll()
Definition: docsh3.cxx:183
bool AdjustRowHeight(SCROW nStartRow, SCROW nEndRow, SCTAB nTab)
merge with docfunc
Definition: docsh5.cxx:404
void MarkToMulti()
Definition: markdata.cxx:209
#define SC_TAB_MOVED
Definition: uiitems.hxx:77
ScDBData * GetAnonymousDBData(const ScRange &rRange)
Definition: docsh5.cxx:343
static weld::Window * GetActiveDialogParent()
Definition: docsh.cxx:3076
SfxBindings * GetViewBindings()
Definition: docsh4.cxx:2627
bool HasHeader() const
Definition: dbdata.hxx:130
SC_DLLPUBLIC bool IsActiveScenario(SCTAB nTab) const
Definition: documen3.cxx:880
void DoneFields()
Definition: consoli.cxx:130
std::unique_ptr< sal_Int32[]> pData
ScScenarioFlags
Definition: global.hxx:224
bool Intersects(const ScRange &rRange) const
Definition: address.hxx:734
sal_uIntPtr sal_uLong
long Long
sal_Int64 n
don't create
Definition: global.hxx:384
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 PostPaintExtras()
Definition: docsh3.cxx:198
sal_uInt16 nDataAreaCount
Definition: global.hxx:892
SC_DLLPUBLIC const ScDBData * GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const
Definition: documen3.cxx:338
ScAddress aEnd
Definition: address.hxx:498
create "Importx" (if necessary)
Definition: global.hxx:383
std::unique_ptr< ScArea[]> pDataAreas
Definition: global.hxx:893
#define SC_TAB_INSERTED
Definition: uiitems.hxx:75
void Invalidate(sal_uInt16 nId)
ScDBData * GetDBData(const ScRange &rMarked, ScGetDBMode eMode, ScGetDBSelection eSel)
Definition: docsh5.cxx:114
sal_uLong TransferTab(ScDocShell &rSrcDocShell, SCTAB nSrcPos, SCTAB nDestPos, bool bInsertNew, bool bNotifyAndPaint)
Definition: docsh5.cxx:853
Use structure ScDocument if a certain size is exceeded?
Definition: consoli.hxx:40
ScDBData * GetDBNearCursor(SCCOL nCol, SCROW nRow, SCTAB nTab)
Definition: dbdata.cxx:1563
void SetClipParam(const ScClipParam &rParam)
Definition: document.cxx:2600
void UpdateAllRowHeights(const ScMarkData *pTabMark=nullptr)
Definition: docsh5.cxx:422
ScGetDBMode
Definition: global.hxx:379
SfxApplication * SfxGetpApp()
bool UpdatePivotTable(ScDPObject &rDPObj, bool bRecord, bool bApi)
Definition: dbdocfun.cxx:1592
virtual SfxUndoManager * GetUndoManager() override
Definition: docsh.cxx:2932
ScDBData * getByRange(const ScRange &rRange)
Definition: dbdata.cxx:1299
bool RepeatDB(const OUString &rDBName, bool bApi, bool bIsUnnamed, SCTAB aTab=0)
Definition: dbdocfun.cxx:283
AnonDBs & getAnonDBs()
Definition: dbdata.hxx:319
bool IsMultiMarked() const
Definition: markdata.hxx:81
int nCount
void GetSize(SCCOL &rCols, SCROW &rRows) const
Definition: consoli.cxx:142
SCROW nRowEnd
Definition: rangeutl.hxx:251
void push_back(const ScRange &rRange)
Definition: rangelst.cxx:1137
SCTAB Tab() const
Definition: address.hxx:283
SC_DLLPUBLIC void SetQueryParam(const ScQueryParam &rQueryParam)
Definition: dbdata.cxx:437
SC_DLLPUBLIC const ScRange & GetSourceRange() const
Get the range that contains the source data.
Definition: dpshttab.cxx:230
void SetFlags(ScSubTotalFunc eFunc, bool bColName, bool bRowName, bool bRef)
Definition: consoli.cxx:148
IMPL_LINK(ScDocShell, RefreshDBDataHdl, Timer *, pRefreshTimer, void)
Definition: docsh5.cxx:1016
If only one row or portion thereof is selected, shrink row to used data columns and select further ro...
OutputDevice * GetDevice() const
Definition: sizedev.hxx:40
create "untitled" (if necessary)
Definition: global.hxx:381
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
virtual void AddUndoAction(std::unique_ptr< SfxUndoAction > pAction, bool bTryMerg=false)
void DBAreaDeleted(SCTAB nTab, SCCOL nX1, SCROW nY1, SCCOL nX2)
Definition: docsh5.cxx:103
const SCTAB SC_TAB_APPEND
Definition: address.hxx:90
int i
void SelectTable(SCTAB nTab, bool bNew)
Definition: markdata.cxx:157
std::unique_ptr< ScDocument, o3tl::default_delete< ScDocument > > ScDocumentUniquePtr
Definition: document.hxx:2715
sal_Int16 SCCOL
Definition: types.hxx:21
virtual bool has_focus() const =0
void OutputToDocument(ScDocument &rDestDoc, SCCOL nCol, SCROW nRow, SCTAB nTab)
Definition: consoli.cxx:391
static SC_DLLPUBLIC const CharClass & getCharClass()
Definition: global.cxx:1024
void ModifyScenario(SCTAB nTab, const OUString &rName, const OUString &rComment, const Color &rColor, ScScenarioFlags nFlags)
Definition: docsh5.cxx:753
void SelectOneTable(SCTAB nTab)
Definition: markdata.cxx:174
SfxItemSet & GetItemSet()
Definition: patattr.hxx:155
const OUString & GetName() const
Definition: dbdata.hxx:121
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:480
std::shared_ptr< ScDocument > m_pDocument
Definition: docsh.hxx:82
void UseScenario(SCTAB nTab, const OUString &rName, bool bRecord=true)
Definition: docsh5.cxx:659
bool IsEditable() const
Definition: docsh5.cxx:95
constexpr OUStringLiteral STR_DB_LOCAL_NONAME
Definition: globalnames.hxx:14
const SCTAB MAXTAB
Definition: address.hxx:70
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:101
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
SCCOL Col() const
Definition: address.hxx:279
bool IsReadOnly() const
void SetByRow(bool bByR)
Definition: dbdata.hxx:129
ScDBData * findByUpperName(const OUString &rName)
Definition: dbdata.cxx:1196
top left cell of area
SC_DLLPUBLIC void GetScenarioData(SCTAB nTab, OUString &rComment, Color &rColor, ScScenarioFlags &rFlags) const
Definition: documen3.cxx:468
void VBA_InsertModule(ScDocument &rDoc, SCTAB nTab, const OUString &sSource)
Definition: docfunc.cxx:3197
static OUString lcl_GetAreaName(ScDocument *pDoc, const ScArea *pArea)
Definition: docsh5.cxx:489
Stores global named database ranges.
Definition: dbdata.hxx:234
SCROW GetInsertCount() const
Definition: consoli.cxx:369
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:17
void SetSize(SCCOL nCols, SCROW nRows)
Definition: consoli.cxx:135
ScGetDBSelection
For ScDBFunc::GetDBData()
Definition: global.hxx:388
SC_DLLPUBLIC bool IsScenario(SCTAB nTab) const
Definition: documen3.cxx:432
virtual void grab_focus()=0
SCTAB MakeScenario(SCTAB nTab, const OUString &rName, const OUString &rComment, const Color &rColor, ScScenarioFlags nFlags, ScMarkData &rMark, bool bRecord=true)
Definition: docsh5.cxx:783
OUString aName
field button for datapilot
ScSubTotalFunc eFunction
Definition: global.hxx:891
const ScSheetSourceDesc * GetSheetDesc() const
Definition: dpobject.hxx:156
force use of sheet-local instead of document global anonymous range
Definition: global.hxx:382
const ScDocument & GetDocument() const
Definition: docsh.hxx:220
void ErrorMessage(TranslateId pGlobStrId)
Definition: docsh5.cxx:70
bool HasImportSelection() const
Definition: dbdata.hxx:201
bool bImport
Definition: global.hxx:443
void CancelAutoDBRange()
Definition: docsh5.cxx:368
NamedDBs & getNamedDBs()
Definition: dbdata.hxx:316
void SetDocumentModified()
Definition: docsh.cxx:3284
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:900
void SetSubTotalParam(const ScSubTotalParam &rSubTotalParam)
Definition: dbdata.cxx:475
SCTAB nTab
Definition: rangeutl.hxx:247
SC_DLLPUBLIC bool IsVisible(SCTAB nTab) const
Definition: document.cxx:911
#define SC_TAB_COPIED
Definition: uiitems.hxx:78
PaintPartFlags
Definition: global.hxx:108
This struct stores general clipboard parameters associated with a ScDocument instance created in clip...
Definition: clipparam.hxx:30
const SCTAB SCTAB_MAX
Definition: address.hxx:57
static SCTAB GetCurTab()
Definition: docsh4.cxx:2599
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:215
double GetPPTX() const
Definition: sizedev.hxx:41
bool ValidTab(SCTAB nTab)
Definition: address.hxx:111
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:456
sal_uInt16 nPos
sal_Int16 SCTAB
Definition: types.hxx:22
void SetAutoFilter(bool bSet)
Definition: dbdata.hxx:205
css::uno::Reference< css::script::XLibraryContainer > GetBasicContainer()
SC_DLLPUBLIC const ScTableProtection * GetTabProtection(SCTAB nTab) const
Definition: documen3.cxx:1922
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo