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>
31
32#include <com/sun/star/script/vba/XVBACompatibility.hpp>
33
34#include <dociter.hxx>
35#include <docsh.hxx>
36#include <global.hxx>
37#include <globstr.hrc>
38#include <scresid.hxx>
39#include <globalnames.hxx>
40#include <undodat.hxx>
41#include <undotab.hxx>
42#include <undoblk.hxx>
43#include <dpobject.hxx>
44#include <dpshttab.hxx>
45#include <dbdocfun.hxx>
46#include <consoli.hxx>
47#include <dbdata.hxx>
48#include <progress.hxx>
49#include <olinetab.hxx>
50#include <patattr.hxx>
51#include <attrib.hxx>
52#include <docpool.hxx>
53#include <uiitems.hxx>
54#include <sc.hrc>
55#include <sizedev.hxx>
56#include <clipparam.hxx>
57#include <rowheightcontext.hxx>
58#include <refupdatecontext.hxx>
59
60using com::sun::star::script::XLibraryContainer;
61using com::sun::star::script::vba::XVBACompatibility;
62using com::sun::star::container::XNameContainer;
64using com::sun::star::uno::UNO_QUERY;
65
66using ::std::unique_ptr;
67using ::std::vector;
68
69// former viewfunc/dbfunc methods
70
72{
74
76 weld::WaitObject aWaitOff( pParent );
77 bool bFocus = pParent && pParent->has_focus();
78
79 if (pGlobStrId && pGlobStrId == STR_PROTECTIONERR)
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
101 return !IsReadOnly() || m_pDocument->IsImportingXML() || m_pDocument->IsChangeReadOnlyEnabled();
102}
103
105{
106 ScDocShellModificator aModificator( *this );
107 // the auto-filter is in the first row of the area
108 m_pDocument->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_pDocument->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.
128 ScDBCollection* pColl = m_pDocument->GetDBCollection();
129 ScDBData* pData = m_pDocument->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_pDocument->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_pDocument->GetDataArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow, false, bOnlyDown );
219 }
220
221 bool bHasHeader = m_pDocument->HasColHeader( nStartCol,nStartRow, nEndCol,nEndRow, nTab );
222
223 ScDBData* pNoNameData = m_pDocument->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_pDocument->GetAnonymousDBData();
235 if (!pNoNameData)
236 {
237 m_pDocument->SetAnonymousDBData( std::unique_ptr<ScDBData>(new ScDBData( STR_DB_LOCAL_NONAME,
238 nTab, nStartCol, nStartRow, nEndCol, nEndRow, true, bHasHeader) ) );
239 pNoNameData = m_pDocument->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 {
294 m_pDocument->PreprocessDBDataUpdate();
295 pUndoColl.reset( new ScDBCollection( *pColl ) ); // Undo for import range
296
297 OUString aImport = ScResId( STR_DBNAME_IMPORT );
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::getCharClass().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_pDocument->SetAnonymousDBData(nTab, std::unique_ptr<ScDBData>(pNoNameData));
321 }
322
323 if ( pUndoColl )
324 {
325 m_pDocument->CompileHybridFormula();
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{
346 ScDBCollection* pColl = m_pDocument->GetDBCollection();
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_pDocument->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
364std::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_pDocument->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_pDocument->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
405bool ScDocShell::AdjustRowHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab )
406{
407 ScSizeDeviceProvider aProv(this);
408 Fraction aZoom(1,1);
409 sc::RowHeightContext aCxt(m_pDocument->MaxRow(), aProv.GetPPTX(), aProv.GetPPTY(), aZoom, aZoom, aProv.GetDevice());
410 bool bChange = m_pDocument->SetOptimalHeight(aCxt, nStartRow,nEndRow, nTab, true);
411
412 if (bChange)
413 {
414 // tdf#76183: recalculate objects' positions
415 m_pDocument->SetDrawPageSize(nTab);
416
417 PostPaint( 0,nStartRow,nTab, m_pDocument->MaxCol(),m_pDocument->MaxRow(),nTab, PaintPartFlags::Grid|PaintPartFlags::Left );
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_pDocument->MaxRow(), aProv.GetPPTX(), aProv.GetPPTY(), aZoom, aZoom, aProv.GetDevice());
430 m_pDocument->UpdateAllRowHeights(aCxt, pTabMark);
431}
432
433void ScDocShell::UpdateAllRowHeights(const bool bOnlyUsedRows)
434{
435 // update automatic row heights on all sheets using the newer ScDocRowHeightUpdater
436 ScSizeDeviceProvider aProv(this);
437 ScDocRowHeightUpdater aUpdater(*m_pDocument, aProv.GetDevice(), aProv.GetPPTX(),
438 aProv.GetPPTY(), nullptr);
439 aUpdater.update(bOnlyUsedRows);
440}
441
442void ScDocShell::UpdatePendingRowHeights( SCTAB nUpdateTab, bool bBefore )
443{
444 bool bIsUndoEnabled = m_pDocument->IsUndoEnabled();
445 m_pDocument->EnableUndo( false );
446 m_pDocument->LockStreamValid( true ); // ignore draw page size (but not formula results)
447 if ( bBefore ) // check all sheets up to nUpdateTab
448 {
449 SCTAB nTabCount = m_pDocument->GetTableCount();
450 if ( nUpdateTab >= nTabCount )
451 nUpdateTab = nTabCount-1; // nUpdateTab is inclusive
452
453 ScMarkData aUpdateSheets(m_pDocument->GetSheetLimits());
454 SCTAB nTab;
455 for (nTab=0; nTab<=nUpdateTab; ++nTab)
456 if ( m_pDocument->IsPendingRowHeights( nTab ) )
457 aUpdateSheets.SelectTable( nTab, true );
458
459 if (aUpdateSheets.GetSelectCount())
460 UpdateAllRowHeights(&aUpdateSheets); // update with a single progress bar
461
462 for (nTab=0; nTab<=nUpdateTab; ++nTab)
463 if ( aUpdateSheets.GetTableSelect( nTab ) )
464 {
465 m_pDocument->UpdatePageBreaks( nTab );
466 m_pDocument->SetPendingRowHeights( nTab, false );
467 }
468 }
469 else // only nUpdateTab
470 {
471 if ( m_pDocument->IsPendingRowHeights( nUpdateTab ) )
472 {
473 AdjustRowHeight( 0, m_pDocument->MaxRow(), nUpdateTab );
474 m_pDocument->UpdatePageBreaks( nUpdateTab );
475 m_pDocument->SetPendingRowHeights( nUpdateTab, false );
476 }
477 }
478 m_pDocument->LockStreamValid( false );
479 m_pDocument->EnableUndo( bIsUndoEnabled );
480}
481
483{
484 ScDPCollection* pColl = m_pDocument->GetDPCollection();
485 if (!pColl)
486 return;
487
488 ScDBDocFunc aFunc(*this);
489 for (size_t i = 0, n = pColl->GetCount(); i < n; ++i)
490 {
491 ScDPObject& rOld = (*pColl)[i];
492
493 const ScSheetSourceDesc* pSheetDesc = rOld.GetSheetDesc();
494 if (pSheetDesc && pSheetDesc->GetSourceRange().Intersects(rSource))
495 aFunc.UpdatePivotTable(rOld, true, false);
496 }
497}
498
499static OUString lcl_GetAreaName( ScDocument* pDoc, const ScArea* pArea )
500{
501 ScDBData* pData = pDoc->GetDBAtArea( pArea->nTab, pArea->nColStart, pArea->nRowStart,
502 pArea->nColEnd, pArea->nRowEnd );
503 if (pData)
504 return pData->GetName();
505
506 OUString aName;
507 pDoc->GetName( pArea->nTab, aName );
508 return aName;
509}
510
511void ScDocShell::DoConsolidate( const ScConsolidateParam& rParam, bool bRecord )
512{
514
515 sal_uInt16 nPos;
516 SCCOL nColSize = 0;
517 SCROW nRowSize = 0;
518 bool bErr = false;
519 for (nPos=0; nPos<rParam.nDataAreaCount; nPos++)
520 {
521 ScArea const & rArea = rParam.pDataAreas[nPos];
522 nColSize = std::max( nColSize, SCCOL( rArea.nColEnd - rArea.nColStart + 1 ) );
523 nRowSize = std::max( nRowSize, SCROW( rArea.nRowEnd - rArea.nRowStart + 1 ) );
524
525 // test if source data were moved
526 if (rParam.bReferenceData)
527 if (rArea.nTab == rParam.nTab && rArea.nRowEnd >= rParam.nRow)
528 bErr = true;
529 }
530
531 if (bErr)
532 {
533 std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetActiveDialogParent(),
534 VclMessageType::Info, VclButtonsType::Ok,
535 ScResId(STR_CONSOLIDATE_ERR1)));
536 xInfoBox->run();
537 return;
538 }
539
540 // execute
541
543 ScDocShellModificator aModificator( *this );
544
545 ScRange aOldDest;
546 ScDBData* pDestData = m_pDocument->GetDBAtCursor( rParam.nCol, rParam.nRow, rParam.nTab, ScDBDataPortion::TOP_LEFT );
547 if (pDestData)
548 pDestData->GetArea(aOldDest);
549
550 aData.SetSize( nColSize, nRowSize );
551 aData.SetFlags( rParam.eFunction, rParam.bByCol, rParam.bByRow, rParam.bReferenceData );
552 if ( rParam.bByCol || rParam.bByRow )
553 for (nPos=0; nPos<rParam.nDataAreaCount; nPos++)
554 {
555 ScArea const & rArea = rParam.pDataAreas[nPos];
556 aData.AddFields( m_pDocument.get(), rArea.nTab, rArea.nColStart, rArea.nRowStart,
557 rArea.nColEnd, rArea.nRowEnd );
558 }
559 aData.DoneFields();
560 for (nPos=0; nPos<rParam.nDataAreaCount; nPos++)
561 {
562 ScArea const & rArea = rParam.pDataAreas[nPos];
563 aData.AddData( m_pDocument.get(), rArea.nTab, rArea.nColStart, rArea.nRowStart,
564 rArea.nColEnd, rArea.nRowEnd );
565 aData.AddName( lcl_GetAreaName(m_pDocument.get(), &rArea) );
566 }
567
568 aData.GetSize( nColSize, nRowSize );
569 if (bRecord && nColSize > 0 && nRowSize > 0)
570 {
571 std::unique_ptr<ScDBData> pUndoData(pDestData ? new ScDBData(*pDestData) : nullptr);
572
573 SCTAB nDestTab = rParam.nTab;
574 ScArea aDestArea( rParam.nTab, rParam.nCol, rParam.nRow,
575 rParam.nCol+nColSize-1, rParam.nRow+nRowSize-1 );
576 if (rParam.bByCol) ++aDestArea.nColEnd;
577 if (rParam.bByRow) ++aDestArea.nRowEnd;
578
579 if (rParam.bReferenceData)
580 {
581 SCTAB nTabCount = m_pDocument->GetTableCount();
582 SCROW nInsertCount = aData.GetInsertCount();
583
584 // old outlines
585 ScOutlineTable* pTable = m_pDocument->GetOutlineTable( nDestTab );
586 std::unique_ptr<ScOutlineTable> pUndoTab(pTable ? new ScOutlineTable( *pTable ) : nullptr);
587
589 pUndoDoc->InitUndo( *m_pDocument, 0, nTabCount-1, false, true );
590
591 // row state
592 m_pDocument->CopyToDocument(0, 0, nDestTab, m_pDocument->MaxCol(), m_pDocument->MaxRow(), nDestTab,
593 InsertDeleteFlags::NONE, false, *pUndoDoc);
594
595 // all formulas
596 m_pDocument->CopyToDocument(0, 0, 0, m_pDocument->MaxCol(), m_pDocument->MaxRow(), nTabCount-1,
597 InsertDeleteFlags::FORMULA, false, *pUndoDoc);
598
599 // complete output rows
600 m_pDocument->CopyToDocument(0, aDestArea.nRowStart, nDestTab,
601 m_pDocument->MaxCol(),aDestArea.nRowEnd, nDestTab,
602 InsertDeleteFlags::ALL, false, *pUndoDoc);
603
604 // old output range
605 if (pDestData)
606 m_pDocument->CopyToDocument(aOldDest, InsertDeleteFlags::ALL, false, *pUndoDoc);
607
609 std::make_unique<ScUndoConsolidate>( this, aDestArea, rParam, std::move(pUndoDoc),
610 true, nInsertCount, std::move(pUndoTab), std::move(pUndoData) ) );
611 }
612 else
613 {
615 pUndoDoc->InitUndo( *m_pDocument, aDestArea.nTab, aDestArea.nTab );
616
617 m_pDocument->CopyToDocument(aDestArea.nColStart, aDestArea.nRowStart, aDestArea.nTab,
618 aDestArea.nColEnd, aDestArea.nRowEnd, aDestArea.nTab,
619 InsertDeleteFlags::ALL, false, *pUndoDoc);
620
621 // old output range
622 if (pDestData)
623 m_pDocument->CopyToDocument(aOldDest, InsertDeleteFlags::ALL, false, *pUndoDoc);
624
626 std::make_unique<ScUndoConsolidate>( this, aDestArea, rParam, std::move(pUndoDoc),
627 false, 0, nullptr, std::move(pUndoData) ) );
628 }
629 }
630
631 if (pDestData) // delete / adjust destination range
632 {
633 m_pDocument->DeleteAreaTab(aOldDest, InsertDeleteFlags::CONTENTS);
634 pDestData->SetArea( rParam.nTab, rParam.nCol, rParam.nRow,
635 rParam.nCol + nColSize - 1, rParam.nRow + nRowSize - 1 );
636 pDestData->SetHeader( rParam.bByRow );
637 }
638
639 aData.OutputToDocument( *m_pDocument, rParam.nCol, rParam.nRow, rParam.nTab );
640
641 SCCOL nPaintStartCol = rParam.nCol;
642 SCROW nPaintStartRow = rParam.nRow;
643 SCCOL nPaintEndCol = nPaintStartCol + nColSize - 1;
644 SCROW nPaintEndRow = nPaintStartRow + nRowSize - 1;
646 if (rParam.bByCol)
647 ++nPaintEndRow;
648 if (rParam.bByRow)
649 ++nPaintEndCol;
650 if (rParam.bReferenceData)
651 {
652 nPaintStartCol = 0;
653 nPaintEndCol = m_pDocument->MaxCol();
654 nPaintEndRow = m_pDocument->MaxRow();
656 }
657 if (pDestData)
658 {
659 if ( aOldDest.aEnd.Col() > nPaintEndCol )
660 nPaintEndCol = aOldDest.aEnd.Col();
661 if ( aOldDest.aEnd.Row() > nPaintEndRow )
662 nPaintEndRow = aOldDest.aEnd.Row();
663 }
664 PostPaint( nPaintStartCol, nPaintStartRow, rParam.nTab,
665 nPaintEndCol, nPaintEndRow, rParam.nTab, nPaintFlags );
666 aModificator.SetDocumentModified();
667}
668
669void ScDocShell::UseScenario( SCTAB nTab, const OUString& rName, bool bRecord )
670{
671 if (!m_pDocument->IsScenario(nTab))
672 {
673 SCTAB nTabCount = m_pDocument->GetTableCount();
674 SCTAB nSrcTab = SCTAB_MAX;
675 SCTAB nEndTab = nTab;
676 OUString aCompare;
677 while ( nEndTab+1 < nTabCount && m_pDocument->IsScenario(nEndTab+1) )
678 {
679 ++nEndTab;
680 if (nSrcTab > MAXTAB) // still searching for the scenario?
681 {
682 m_pDocument->GetName( nEndTab, aCompare );
683 if (aCompare == rName)
684 nSrcTab = nEndTab; // found
685 }
686 }
687 if (ValidTab(nSrcTab))
688 {
689 if ( m_pDocument->TestCopyScenario( nSrcTab, nTab ) ) // test cell protection
690 {
691 ScDocShellModificator aModificator( *this );
692 ScMarkData aScenMark(m_pDocument->GetSheetLimits());
693 m_pDocument->MarkScenario( nSrcTab, nTab, aScenMark );
694 const ScRange& aMultiRange = aScenMark.GetMultiMarkArea();
695 SCCOL nStartCol = aMultiRange.aStart.Col();
696 SCROW nStartRow = aMultiRange.aStart.Row();
697 SCCOL nEndCol = aMultiRange.aEnd.Col();
698 SCROW nEndRow = aMultiRange.aEnd.Row();
699
700 if (bRecord)
701 {
703 pUndoDoc->InitUndo( *m_pDocument, nTab,nEndTab ); // also all scenarios
704 // shown table:
705 m_pDocument->CopyToDocument(nStartCol, nStartRow, nTab,
706 nEndCol, nEndRow, nTab, InsertDeleteFlags::ALL,
707 true, *pUndoDoc, &aScenMark);
708 // scenarios
709 for (SCTAB i=nTab+1; i<=nEndTab; i++)
710 {
711 pUndoDoc->SetScenario( i, true );
712 OUString aComment;
713 Color aColor;
714 ScScenarioFlags nScenFlags;
715 m_pDocument->GetScenarioData( i, aComment, aColor, nScenFlags );
716 pUndoDoc->SetScenarioData( i, aComment, aColor, nScenFlags );
717 bool bActive = m_pDocument->IsActiveScenario( i );
718 pUndoDoc->SetActiveScenario( i, bActive );
719 // At copy-back scenarios also contents
720 if ( nScenFlags & ScScenarioFlags::TwoWay )
721 m_pDocument->CopyToDocument(0, 0, i, m_pDocument->MaxCol(), m_pDocument->MaxRow(), i,
722 InsertDeleteFlags::ALL, false, *pUndoDoc );
723 }
724
726 std::make_unique<ScUndoUseScenario>( this, aScenMark,
727 ScArea( nTab,nStartCol,nStartRow,nEndCol,nEndRow ),
728 std::move(pUndoDoc), rName ) );
729 }
730
731 m_pDocument->CopyScenario( nSrcTab, nTab );
732
734 m_pDocument->SetAllFormulasDirty(aCxt);
735
736 // paint all, because the active scenario may be modified in other ranges;
738 PostPaint( 0,0,nTab, m_pDocument->MaxCol(),m_pDocument->MaxRow(),nTab, PaintPartFlags::Grid );
739 aModificator.SetDocumentModified();
740 }
741 else
742 {
743 std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetActiveDialogParent(),
744 VclMessageType::Info, VclButtonsType::Ok,
745 ScResId(STR_PROTECTIONERR)));
746 xInfoBox->run();
747 }
748 }
749 else
750 {
751 std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetActiveDialogParent(),
752 VclMessageType::Info, VclButtonsType::Ok,
753 ScResId(STR_SCENARIO_NOTFOUND)));
754 xInfoBox->run();
755 }
756 }
757 else
758 {
759 OSL_FAIL( "UseScenario on Scenario-Sheet" );
760 }
761}
762
763void ScDocShell::ModifyScenario( SCTAB nTab, const OUString& rName, const OUString& rComment,
764 const Color& rColor, ScScenarioFlags nFlags )
765{
766 // Undo
767 OUString aOldName;
768 m_pDocument->GetName( nTab, aOldName );
769 OUString aOldComment;
770 Color aOldColor;
771 ScScenarioFlags nOldFlags;
772 m_pDocument->GetScenarioData( nTab, aOldComment, aOldColor, nOldFlags );
774 std::make_unique<ScUndoScenarioFlags>(this, nTab,
775 aOldName, rName, aOldComment, rComment,
776 aOldColor, rColor, nOldFlags, nFlags) );
777
778 // execute
779 ScDocShellModificator aModificator( *this );
780 m_pDocument->RenameTab( nTab, rName );
781 m_pDocument->SetScenarioData( nTab, rComment, rColor, nFlags );
783 aModificator.SetDocumentModified();
784
785 if (aOldName != rName)
786 SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScTablesChanged ) );
787
788 SfxBindings* pBindings = GetViewBindings();
789 if (pBindings)
790 pBindings->Invalidate( SID_SELECT_SCENARIO );
791}
792
793SCTAB ScDocShell::MakeScenario( SCTAB nTab, const OUString& rName, const OUString& rComment,
794 const Color& rColor, ScScenarioFlags nFlags,
795 ScMarkData& rMark, bool bRecord )
796{
797 rMark.MarkToMulti();
798 if (rMark.IsMultiMarked())
799 {
800 SCTAB nNewTab = nTab + 1;
801 while (m_pDocument->IsScenario(nNewTab))
802 ++nNewTab;
803
804 bool bCopyAll = ( (nFlags & ScScenarioFlags::CopyAll) != ScScenarioFlags::NONE );
805 const ScMarkData* pCopyMark = nullptr;
806 if (!bCopyAll)
807 pCopyMark = &rMark;
808
809 ScDocShellModificator aModificator( *this );
810
811 if (bRecord)
812 m_pDocument->BeginDrawUndo(); // drawing layer must do its own undo actions
813
814 if (m_pDocument->CopyTab( nTab, nNewTab, pCopyMark ))
815 {
816 if (bRecord)
817 {
819 std::make_unique<ScUndoMakeScenario>( this, nTab, nNewTab,
820 rName, rComment, rColor, nFlags, rMark ));
821 }
822
823 m_pDocument->RenameTab( nNewTab, rName);
824 m_pDocument->SetScenario( nNewTab, true );
825 m_pDocument->SetScenarioData( nNewTab, rComment, rColor, nFlags );
826
827 ScMarkData aDestMark = rMark;
828 aDestMark.SelectOneTable( nNewTab );
829
831
832 ScPatternAttr aProtPattern( m_pDocument->GetPool() );
833 aProtPattern.GetItemSet().Put( ScProtectionAttr( true ) );
834 m_pDocument->ApplyPatternAreaTab( 0,0, m_pDocument->MaxCol(),m_pDocument->MaxRow(), nNewTab, aProtPattern );
835
836 ScPatternAttr aPattern( m_pDocument->GetPool() );
838 aPattern.GetItemSet().Put( ScProtectionAttr( true ) );
839 m_pDocument->ApplySelectionPattern( aPattern, aDestMark );
840
841 if (!bCopyAll)
842 m_pDocument->SetVisible( nNewTab, false );
843
844 // this is the active scenario, then
845 m_pDocument->CopyScenario( nNewTab, nTab, true ); // sal_True - don't copy anything from scenario
846
847 if (nFlags & ScScenarioFlags::ShowFrame)
848 PostPaint( 0,0,nTab, m_pDocument->MaxCol(),m_pDocument->MaxRow(),nTab, PaintPartFlags::Grid ); // paint frames
849 PostPaintExtras(); // table tab
850 aModificator.SetDocumentModified();
851
852 // A scenario tab is like a hidden sheet, broadcasting also
853 // notifies ScTabViewShell to add an ScViewData::maTabData entry.
854 Broadcast( ScTablesHint( SC_TAB_INSERTED, nNewTab ));
855 SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScTablesChanged ) );
856
857 return nNewTab;
858 }
859 }
860 return nTab;
861}
862
864 SCTAB nDestPos, bool bInsertNew,
865 bool bNotifyAndPaint )
866{
867 ScDocument& rSrcDoc = rSrcDocShell.GetDocument();
868
869 // set the transferred area to the copyparam to make adjusting formulas possible
870 ScClipParam aParam;
871 ScRange aRange(0, 0, nSrcPos, m_pDocument->MaxCol(), m_pDocument->MaxRow(), nSrcPos);
872 aParam.maRanges.push_back(aRange);
873 rSrcDoc.SetClipParam(aParam);
874
875 sal_uLong nErrVal = m_pDocument->TransferTab( rSrcDoc, nSrcPos, nDestPos,
876 bInsertNew ); // no insert
877
878 // TransferTab doesn't copy drawing objects with bInsertNew=FALSE
879 if ( nErrVal > 0 && !bInsertNew)
880 m_pDocument->TransferDrawPage( rSrcDoc, nSrcPos, nDestPos );
881
882 if(nErrVal>0 && rSrcDoc.IsScenario( nSrcPos ))
883 {
884 OUString aComment;
885 Color aColor;
886 ScScenarioFlags nFlags;
887
888 rSrcDoc.GetScenarioData( nSrcPos, aComment,aColor, nFlags);
889 m_pDocument->SetScenario(nDestPos,true);
890 m_pDocument->SetScenarioData(nDestPos,aComment,aColor,nFlags);
891 bool bActive = rSrcDoc.IsActiveScenario(nSrcPos);
892 m_pDocument->SetActiveScenario(nDestPos, bActive );
893
894 bool bVisible = rSrcDoc.IsVisible(nSrcPos);
895 m_pDocument->SetVisible(nDestPos,bVisible );
896
897 }
898
899 if ( nErrVal > 0 && rSrcDoc.IsTabProtected( nSrcPos ) )
900 m_pDocument->SetTabProtection(nDestPos, rSrcDoc.GetTabProtection(nSrcPos));
901 if ( bNotifyAndPaint )
902 {
903 Broadcast( ScTablesHint( SC_TAB_INSERTED, nDestPos ) );
906 }
907 return nErrVal;
908}
909
910bool ScDocShell::MoveTable( SCTAB nSrcTab, SCTAB nDestTab, bool bCopy, bool bRecord )
911{
912 ScDocShellModificator aModificator( *this );
913
914 // #i92477# be consistent with ScDocFunc::InsertTable: any index past the last sheet means "append"
915 // #i101139# nDestTab must be the target position, not APPEND (for CopyTabProtection etc.)
916 if ( nDestTab >= m_pDocument->GetTableCount() )
917 nDestTab = m_pDocument->GetTableCount();
918
919 if (bCopy)
920 {
921 if (bRecord)
922 m_pDocument->BeginDrawUndo(); // drawing layer must do its own undo actions
923
924 OUString sSrcCodeName;
925 m_pDocument->GetCodeName( nSrcTab, sSrcCodeName );
926 if (!m_pDocument->CopyTab( nSrcTab, nDestTab ))
927 {
929 return false;
930 }
931 else
932 {
933 SCTAB nAdjSource = nSrcTab;
934 if ( nDestTab <= nSrcTab )
935 ++nAdjSource; // new position of source table after CopyTab
936
937 if ( m_pDocument->IsTabProtected( nAdjSource ) )
938 m_pDocument->CopyTabProtection(nAdjSource, nDestTab);
939
940 if (bRecord)
941 {
942 unique_ptr< vector<SCTAB> > pSrcList(new vector<SCTAB>(1, nSrcTab));
943 unique_ptr< vector<SCTAB> > pDestList(new vector<SCTAB>(1, nDestTab));
945 std::make_unique<ScUndoCopyTab>(this, std::move(pSrcList), std::move(pDestList)));
946 }
947
948 bool bVbaEnabled = m_pDocument->IsInVBAMode();
949 if ( bVbaEnabled )
950 {
951 OUString aLibName( "Standard" );
953 Reference< XVBACompatibility > xVBACompat( xLibContainer, UNO_QUERY );
954
955 if ( xVBACompat.is() )
956 {
957 aLibName = xVBACompat->getProjectName();
958 }
959
960 SCTAB nTabToUse = nDestTab;
961 if ( nDestTab == SC_TAB_APPEND )
962 nTabToUse = m_pDocument->GetMaxTableNumber() - 1;
963 OUString sSource;
964 try
965 {
967 if( xLibContainer.is() )
968 {
969 css::uno::Any aLibAny = xLibContainer->getByName( aLibName );
970 aLibAny >>= xLib;
971 }
972 if( xLib.is() )
973 {
974 xLib->getByName( sSrcCodeName ) >>= sSource;
975 }
976 }
977 catch ( const css::uno::Exception& )
978 {
979 }
980 VBA_InsertModule( *m_pDocument, nTabToUse, sSource );
981 }
982 }
983 Broadcast( ScTablesHint( SC_TAB_COPIED, nSrcTab, nDestTab ) );
984 }
985 else
986 {
987 if ( m_pDocument->GetChangeTrack() )
988 return false;
989
990 if ( nSrcTab<nDestTab && nDestTab!=SC_TAB_APPEND )
991 nDestTab--;
992
993 if ( nSrcTab == nDestTab )
994 {
996 return true; // nothing to do, but valid
997 }
998
999 std::optional<ScProgress> pProgress(std::in_place, this, ScResId(STR_UNDO_MOVE_TAB),
1000 m_pDocument->GetCodeCount(), true);
1001 bool bDone = m_pDocument->MoveTab( nSrcTab, nDestTab, &*pProgress );
1002 pProgress.reset();
1003 if (!bDone)
1004 {
1005 return false;
1006 }
1007 else if (bRecord)
1008 {
1009 unique_ptr< vector<SCTAB> > pSrcList(new vector<SCTAB>(1, nSrcTab));
1010 unique_ptr< vector<SCTAB> > pDestList(new vector<SCTAB>(1, nDestTab));
1012 std::make_unique<ScUndoMoveTab>(this, std::move(pSrcList), std::move(pDestList)));
1013 }
1014
1015 Broadcast( ScTablesHint( SC_TAB_MOVED, nSrcTab, nDestTab ) );
1016 }
1017
1020 aModificator.SetDocumentModified();
1021 SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScTablesChanged ) );
1022
1023 return true;
1024}
1025
1026IMPL_LINK( ScDocShell, RefreshDBDataHdl, Timer*, pRefreshTimer, void )
1027{
1028 ScDBDocFunc aFunc(*this);
1029
1030 ScDBData* pDBData = static_cast<ScDBData*>(pRefreshTimer);
1031 ScImportParam aImportParam;
1032 pDBData->GetImportParam( aImportParam );
1033 if (aImportParam.bImport && !pDBData->HasImportSelection())
1034 {
1035 ScRange aRange;
1036 pDBData->GetArea( aRange );
1037 bool bContinue = aFunc.DoImport( aRange.aStart.Tab(), aImportParam, nullptr );
1038 // internal operations (sort, query, subtotal) only if no error
1039 if (bContinue)
1040 {
1041 aFunc.RepeatDB( pDBData->GetName(), true, true );
1042 RefreshPivotTables(aRange);
1043 }
1044 }
1045}
1046
1047/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool ValidTab(SCTAB nTab)
Definition: address.hxx:111
const SCTAB MAXTAB
Definition: address.hxx:70
const SCTAB SC_TAB_APPEND
Definition: address.hxx:90
const SCTAB SCTAB_MAX
Definition: address.hxx:57
SfxApplication * SfxGetpApp()
@ Scenario
field button for datapilot
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
SCTAB Tab() const
Definition: address.hxx:283
SCROW Row() const
Definition: address.hxx:274
SCCOL Col() const
Definition: address.hxx:279
SCCOL nColEnd
Definition: rangeutl.hxx:250
SCTAB nTab
Definition: rangeutl.hxx:247
SCCOL nColStart
Definition: rangeutl.hxx:248
SCROW nRowEnd
Definition: rangeutl.hxx:251
SCROW nRowStart
Definition: rangeutl.hxx:249
Use structure ScDocument if a certain size is exceeded?
Definition: consoli.hxx:41
ScDBData * getByRange(const ScRange &rRange)
Definition: dbdata.cxx:1324
Stores global named database ranges.
Definition: dbdata.hxx:243
bool insert(std::unique_ptr< ScDBData > p)
Takes ownership of p and attempts to insert it into the collection.
Definition: dbdata.cxx:1240
ScDBData * findByUpperName(const OUString &rName)
Definition: dbdata.cxx:1221
ScDBData * GetDBNearCursor(SCCOL nCol, SCROW nRow, SCTAB nTab)
Definition: dbdata.cxx:1594
NamedDBs & getNamedDBs()
Definition: dbdata.hxx:324
AnonDBs & getAnonDBs()
Definition: dbdata.hxx:327
void SetByRow(bool bByR)
Definition: dbdata.hxx:135
void GetImportParam(ScImportParam &rImportParam) const
Definition: dbdata.cxx:478
bool HasAutoFilter() const
Definition: dbdata.hxx:212
bool HasHeader() const
Definition: dbdata.hxx:136
const OUString & GetName() const
Definition: dbdata.hxx:127
void GetArea(SCTAB &rTab, SCCOL &rCol1, SCROW &rRow1, SCCOL &rCol2, SCROW &rRow2) const
Definition: dbdata.cxx:298
void SetAutoFilter(bool bSet)
Definition: dbdata.hxx:213
void SetSubTotalParam(const ScSubTotalParam &rSubTotalParam)
Definition: dbdata.cxx:473
void SetHeader(bool bHasH)
Definition: dbdata.hxx:137
SC_DLLPUBLIC void SetSortParam(const ScSortParam &rSortParam)
Definition: dbdata.cxx:411
SCTAB GetTab() const
Definition: dbdata.hxx:129
bool HasImportSelection() const
Definition: dbdata.hxx:209
SC_DLLPUBLIC void SetQueryParam(const ScQueryParam &rQueryParam)
Definition: dbdata.cxx:435
void SetArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
Definition: dbdata.cxx:320
bool UpdatePivotTable(ScDPObject &rDPObj, bool bRecord, bool bApi)
Definition: dbdocfun.cxx:1592
bool RepeatDB(const OUString &rDBName, bool bApi, bool bIsUnnamed, SCTAB aTab=0)
Definition: dbdocfun.cxx:283
bool DoImport(SCTAB nTab, const ScImportParam &rParam, const svx::ODataAccessDescriptor *pDescriptor)
Definition: dbdocimp.cxx:121
SC_DLLPUBLIC size_t GetCount() const
Definition: dpobject.cxx:3717
const ScSheetSourceDesc * GetSheetDesc() const
Definition: dpobject.hxx:156
void update(const bool bOnlyUsedRows=false)
Definition: dociter.cxx:1618
Create before modifications of the document and destroy thereafter.
Definition: docsh.hxx:455
void SetDocumentModified()
Definition: docsh.cxx:3315
SCTAB MakeScenario(SCTAB nTab, const OUString &rName, const OUString &rComment, const Color &rColor, ScScenarioFlags nFlags, ScMarkData &rMark, bool bRecord=true)
Definition: docsh5.cxx:793
static weld::Window * GetActiveDialogParent()
Definition: docsh.cxx:3112
void PostPaintGridAll()
Definition: docsh3.cxx:183
SfxBindings * GetViewBindings()
Definition: docsh4.cxx:2642
void ErrorMessage(TranslateId pGlobStrId)
Definition: docsh5.cxx:71
void UseScenario(SCTAB nTab, const OUString &rName, bool bRecord=true)
Definition: docsh5.cxx:669
const ScDocument & GetDocument() const
Definition: docsh.hxx:219
std::shared_ptr< ScDocument > m_pDocument
Definition: docsh.hxx:82
void UpdateAllRowHeights(const ScMarkData *pTabMark=nullptr)
Definition: docsh5.cxx:423
std::unique_ptr< ScDBData > GetOldAutoDBRange()
Definition: docsh5.cxx:364
void UpdatePendingRowHeights(SCTAB nUpdateTab, bool bBefore=false)
Definition: docsh5.cxx:442
void ModifyScenario(SCTAB nTab, const OUString &rName, const OUString &rComment, const Color &rColor, ScScenarioFlags nFlags)
Definition: docsh5.cxx:763
ScDBData * GetDBData(const ScRange &rMarked, ScGetDBMode eMode, ScGetDBSelection eSel)
Definition: docsh5.cxx:115
void PostPaintExtras()
Definition: docsh3.cxx:198
ScDBData * GetAnonymousDBData(const ScRange &rRange)
Definition: docsh5.cxx:344
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 DoConsolidate(const ScConsolidateParam &rParam, bool bRecord=true)
Definition: docsh5.cxx:511
bool MoveTable(SCTAB nSrcTab, SCTAB nDestTab, bool bCopy, bool bRecord)
Definition: docsh5.cxx:910
void CancelAutoDBRange()
Definition: docsh5.cxx:369
std::unique_ptr< ScDBData > m_pOldAutoDBRange
Definition: docsh.hxx:101
sal_uLong TransferTab(ScDocShell &rSrcDocShell, SCTAB nSrcPos, SCTAB nDestPos, bool bInsertNew, bool bNotifyAndPaint)
Definition: docsh5.cxx:863
void DBAreaDeleted(SCTAB nTab, SCCOL nX1, SCROW nY1, SCCOL nX2)
Definition: docsh5.cxx:104
bool AdjustRowHeight(SCROW nStartRow, SCROW nEndRow, SCTAB nTab)
merge with docfunc
Definition: docsh5.cxx:405
virtual SfxUndoManager * GetUndoManager() override
Definition: docsh.cxx:2968
bool IsEditable() const
Definition: docsh5.cxx:96
static SCTAB GetCurTab()
Definition: docsh4.cxx:2614
void RefreshPivotTables(const ScRange &rSource)
Definition: docsh5.cxx:482
SC_DLLPUBLIC bool IsScenario(SCTAB nTab) const
Definition: documen3.cxx:432
SC_DLLPUBLIC const ScTableProtection * GetTabProtection(SCTAB nTab) const
Definition: documen3.cxx:1914
SC_DLLPUBLIC bool IsTabProtected(SCTAB nTab) const
Definition: documen3.cxx:1905
SC_DLLPUBLIC const ScDBData * GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const
Definition: documen3.cxx:338
SC_DLLPUBLIC void GetScenarioData(SCTAB nTab, OUString &rComment, Color &rColor, ScScenarioFlags &rFlags) const
Definition: documen3.cxx:469
SC_DLLPUBLIC bool IsVisible(SCTAB nTab) const
Definition: document.cxx:890
SC_DLLPUBLIC bool GetName(SCTAB nTab, OUString &rName) const
Definition: document.cxx:204
void SetClipParam(const ScClipParam &rParam)
Definition: document.cxx:2572
SC_DLLPUBLIC bool IsActiveScenario(SCTAB nTab) const
Definition: documen3.cxx:880
static SC_DLLPUBLIC const CharClass & getCharClass()
Definition: global.cxx:1064
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
Definition: markdata.hxx:43
const ScRange & GetMultiMarkArea() const
Definition: markdata.hxx:84
void SelectTable(SCTAB nTab, bool bNew)
Definition: markdata.cxx:157
void SelectOneTable(SCTAB nTab)
Definition: markdata.cxx:174
bool IsMultiMarked() const
Definition: markdata.hxx:81
bool GetTableSelect(SCTAB nTab) const
Definition: markdata.cxx:169
SCTAB GetSelectCount() const
Definition: markdata.cxx:180
void MarkToMulti()
Definition: markdata.cxx:209
SfxItemSet & GetItemSet()
Definition: patattr.hxx:192
void push_back(const ScRange &rRange)
Definition: rangelst.cxx:1137
ScAddress aEnd
Definition: address.hxx:498
bool Intersects(const ScRange &rRange) const
Definition: address.hxx:734
ScAddress aStart
Definition: address.hxx:497
This class contains authoritative information on the internal reference used as the data source for d...
Definition: dpshttab.hxx:40
SC_DLLPUBLIC const ScRange & GetSourceRange() const
Get the range that contains the source data.
Definition: dpshttab.cxx:230
OutputDevice * GetDevice() const
Definition: sizedev.hxx:40
double GetPPTY() const
Definition: sizedev.hxx:42
double GetPPTX() const
Definition: sizedev.hxx:41
void Invalidate(sal_uInt16 nId)
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
css::uno::Reference< css::script::XLibraryContainer > GetBasicContainer()
bool IsReadOnly() const
virtual void AddUndoAction(std::unique_ptr< SfxUndoAction > pAction, bool bTryMerg=false)
virtual void grab_focus()=0
virtual bool has_focus() const=0
int nCount
@ TOP_LEFT
top left cell of area
void VBA_InsertModule(ScDocument &rDoc, SCTAB nTab, const OUString &sSource)
Definition: docfunc.cxx:3197
IMPL_LINK(ScDocShell, RefreshDBDataHdl, Timer *, pRefreshTimer, void)
Definition: docsh5.cxx:1026
static OUString lcl_GetAreaName(ScDocument *pDoc, const ScArea *pArea)
Definition: docsh5.cxx:499
std::unique_ptr< ScDocument, o3tl::default_delete< ScDocument > > ScDocumentUniquePtr
Definition: document.hxx:2720
@ SCDOCMODE_UNDO
Definition: document.hxx:258
@ FORMULA
Cell notes.
ScGetDBSelection
For ScDBFunc::GetDBData()
Definition: global.hxx:391
@ RowDown
If only one row or portion thereof is selected, shrink row to used data columns and select further ro...
@ ForceMark
Behave as if the range corresponding to a ScDBData area was selected, for API use.
PaintPartFlags
Definition: global.hxx:109
ScScenarioFlags
Definition: global.hxx:226
ScGetDBMode
Definition: global.hxx:382
@ SC_DB_AUTOFILTER
force use of sheet-local instead of document global anonymous range
Definition: global.hxx:384
@ SC_DB_IMPORT
create "Importx" (if necessary)
Definition: global.hxx:385
@ SC_DB_MAKE
create "untitled" (if necessary)
Definition: global.hxx:383
@ SC_DB_OLD
don't create
Definition: global.hxx:386
constexpr OUStringLiteral STR_DB_LOCAL_NONAME
Definition: globalnames.hxx:14
OUString aName
Mode eMode
sal_Int64 n
sal_uInt16 nPos
std::unique_ptr< sal_Int32[]> pData
constexpr OUStringLiteral aData
int i
long Long
OUString ScResId(TranslateId aId)
Definition: scdll.cxx:90
sal_uIntPtr sal_uLong
This struct stores general clipboard parameters associated with a ScDocument instance created in clip...
Definition: clipparam.hxx:31
ScRangeList maRanges
Definition: clipparam.hxx:34
sal_uInt16 nDataAreaCount
Definition: global.hxx:908
std::unique_ptr< ScArea[]> pDataAreas
Definition: global.hxx:909
ScSubTotalFunc eFunction
Definition: global.hxx:907
bool bImport
Definition: global.hxx:445
bool bVisible
sal_Int16 SCTAB
Definition: types.hxx:22
sal_Int16 SCCOL
Definition: types.hxx:21
sal_Int32 SCROW
Definition: types.hxx:17
#define SC_TAB_MOVED
Definition: uiitems.hxx:77
#define SC_TAB_COPIED
Definition: uiitems.hxx:78
#define SC_TAB_INSERTED
Definition: uiitems.hxx:75