LibreOffice Module sc (master) 1
dbdocimp.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 <vcl/errinf.hxx>
22#include <comphelper/types.hxx>
23#include <vcl/svapp.hxx>
24#include <vcl/weld.hxx>
26#include <sfx2/viewfrm.hxx>
27#include <sal/log.hxx>
28#include <osl/diagnose.h>
30
31#include <com/sun/star/sdb/CommandType.hpp>
32#include <com/sun/star/sdb/XCompletedExecution.hpp>
33#include <com/sun/star/sdbc/SQLException.hpp>
34#include <com/sun/star/sdbc/XRow.hpp>
35#include <com/sun/star/sdbc/XRowSet.hpp>
36#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
37#include <com/sun/star/sdbcx/XRowLocate.hpp>
38#include <com/sun/star/task/InteractionHandler.hpp>
39#include <com/sun/star/lang/XMultiServiceFactory.hpp>
40#include <com/sun/star/beans/XPropertySet.hpp>
41#include <com/sun/star/frame/FrameSearchFlag.hpp>
42#include <com/sun/star/view/XSelectionSupplier.hpp>
43
44#include <dbdocfun.hxx>
45#include <docsh.hxx>
46#include <globstr.hrc>
47#include <scresid.hxx>
48#include <scerrors.hxx>
49#include <dbdata.hxx>
50#include <markdata.hxx>
51#include <undodat.hxx>
52#include <progress.hxx>
53#include <patattr.hxx>
54#include <docpool.hxx>
55#include <attrib.hxx>
56#include <dbdocutl.hxx>
57#include <editable.hxx>
58#include <hints.hxx>
59#include <miscuno.hxx>
60#include <chgtrack.hxx>
61#include <refupdatecontext.hxx>
62
63using namespace com::sun::star;
64
65constexpr OUStringLiteral SC_SERVICE_ROWSET = u"com.sun.star.sdb.RowSet";
66
68constexpr OUStringLiteral SC_DBPROP_DATASOURCENAME = u"DataSourceName";
69constexpr OUStringLiteral SC_DBPROP_COMMAND = u"Command";
70constexpr OUStringLiteral SC_DBPROP_COMMANDTYPE = u"CommandType";
71
72void ScDBDocFunc::ShowInBeamer( const ScImportParam& rParam, const SfxViewFrame* pFrame )
73{
74 // called after opening the database beamer
75
76 if ( !pFrame || !rParam.bImport )
77 return;
78
79 uno::Reference<frame::XFrame> xFrame = pFrame->GetFrame().GetFrameInterface();
80
81 uno::Reference<frame::XFrame> xBeamerFrame = xFrame->findFrame(
82 "_beamer",
83 frame::FrameSearchFlag::CHILDREN);
84 if (!xBeamerFrame.is())
85 return;
86
87 uno::Reference<frame::XController> xController = xBeamerFrame->getController();
88 uno::Reference<view::XSelectionSupplier> xControllerSelection(xController, uno::UNO_QUERY);
89 if (xControllerSelection.is())
90 {
91 sal_Int32 nType = rParam.bSql ? sdb::CommandType::COMMAND :
94
96 aSelection.setDataSource(rParam.aDBName);
99
100 xControllerSelection->select(uno::Any(aSelection.createPropertyValueSequence()));
101 }
102 else
103 {
104 OSL_FAIL("no selection supplier in the beamer!");
105 }
106}
107
109 const uno::Sequence<beans::PropertyValue>& aArgs )
110{
111 svx::ODataAccessDescriptor aDesc( aArgs ); // includes selection and result set
112
113 // create database range
115 DBG_ASSERT(pDBData, "can't create DB data");
116 OUString sTarget = pDBData->GetName();
117
118 UpdateImport( sTarget, aDesc );
119}
120
121bool ScDBDocFunc::DoImport( SCTAB nTab, const ScImportParam& rParam,
122 const svx::ODataAccessDescriptor* pDescriptor )
123{
125 ScChangeTrack *pChangeTrack = nullptr;
126 ScRange aChangedRange;
127
128 bool bRecord = true;
129 if (!rDoc.IsUndoEnabled())
130 bRecord = false;
131
132 ScDBData* pDBData = rDoc.GetDBAtArea( nTab, rParam.nCol1, rParam.nRow1,
133 rParam.nCol2, rParam.nRow2 );
134 if (!pDBData)
135 {
136 OSL_FAIL( "DoImport: no DBData" );
137 return false;
138 }
139
140 std::unique_ptr<weld::WaitObject> xWaitWin(new weld::WaitObject(ScDocShell::GetActiveDialogParent()));
141 ScDocShellModificator aModificator( rDocShell );
142
143 bool bSuccess = false;
144 bool bTruncated = false; // for warning
145 TranslateId pErrStringId;
146 OUString aErrorMessage;
147
148 SCCOL nCol = rParam.nCol1;
149 SCROW nRow = rParam.nRow1;
150 SCCOL nEndCol = nCol; // end of resulting database area
151 SCROW nEndRow = nRow;
152
153 bool bDoSelection = false;
154 bool bRealSelection = false; // sal_True if not everything is selected
155 bool bBookmarkSelection = false;
156 sal_Int32 nListPos = 0;
157 sal_Int32 nRowsRead = 0;
158 sal_Int32 nListCount = 0;
159
160 uno::Sequence<uno::Any> aSelection;
161 if ( pDescriptor && pDescriptor->has(svx::DataAccessDescriptorProperty::Selection) )
162 {
163 (*pDescriptor)[svx::DataAccessDescriptorProperty::Selection] >>= aSelection;
164 nListCount = aSelection.getLength();
165 if ( nListCount > 0 )
166 {
167 bDoSelection = true;
170 if ( bBookmarkSelection )
171 {
172 // From bookmarks, there's no way to detect if all records are selected.
173 // Rely on base to pass no selection in that case.
174 bRealSelection = true;
175 }
176 }
177 }
178
179 uno::Reference<sdbc::XResultSet> xResultSet;
180 if ( pDescriptor && pDescriptor->has(svx::DataAccessDescriptorProperty::Cursor) )
181 xResultSet.set((*pDescriptor)[svx::DataAccessDescriptorProperty::Cursor], uno::UNO_QUERY);
182
183 // ImportDoc - also used for Redo
185 pImportDoc->InitUndo( rDoc, nTab, nTab );
186
187 // get data from database into import document
188
189 try
190 {
191 // progress bar
192 // only text (title is still needed, for the cancel button)
193 ScProgress aProgress( &rDocShell, ScResId(STR_UNDO_IMPORTDATA), 0, true );
194
195 uno::Reference<sdbc::XRowSet> xRowSet( xResultSet, uno::UNO_QUERY );
196 bool bDispose = false;
197 if ( !xRowSet.is() )
198 {
199 bDispose = true;
202 uno::UNO_QUERY);
203 uno::Reference<beans::XPropertySet> xRowProp( xRowSet, uno::UNO_QUERY );
204 OSL_ENSURE( xRowProp.is(), "can't get RowSet" );
205 if ( xRowProp.is() )
206 {
207
208 // set source parameters
209
210 sal_Int32 nType = rParam.bSql ? sdb::CommandType::COMMAND :
211 ( (rParam.nType == ScDbQuery) ? sdb::CommandType::QUERY :
213
214 xRowProp->setPropertyValue( SC_DBPROP_DATASOURCENAME, uno::Any(rParam.aDBName) );
215
216 xRowProp->setPropertyValue( SC_DBPROP_COMMAND, uno::Any(rParam.aStatement) );
217
218 xRowProp->setPropertyValue( SC_DBPROP_COMMANDTYPE, uno::Any(nType) );
219
220 uno::Reference<sdb::XCompletedExecution> xExecute( xRowSet, uno::UNO_QUERY );
221 if ( xExecute.is() )
222 {
223 uno::Reference<task::XInteractionHandler> xHandler(
224 task::InteractionHandler::createWithParent(comphelper::getProcessComponentContext(), nullptr),
225 uno::UNO_QUERY_THROW);
226 xExecute->executeWithCompletion( xHandler );
227 }
228 else
229 xRowSet->execute();
230 }
231 }
232 if ( xRowSet.is() )
233 {
234
235 // get column descriptions
236
237 sal_Int32 nColCount = 0;
238 uno::Reference<sdbc::XResultSetMetaData> xMeta;
239 uno::Reference<sdbc::XResultSetMetaDataSupplier> xMetaSupp( xRowSet, uno::UNO_QUERY );
240 if ( xMetaSupp.is() )
241 xMeta = xMetaSupp->getMetaData();
242 if ( xMeta.is() )
243 nColCount = xMeta->getColumnCount(); // this is the number of real columns
244
245 if ( rParam.nCol1 + nColCount - 1 > rDoc.MaxCol() )
246 {
247 nColCount = 0;
249 }
250
251 uno::Reference<sdbcx::XRowLocate> xLocate;
252 if ( bBookmarkSelection )
253 {
254 xLocate.set( xRowSet, uno::UNO_QUERY );
255 if ( !xLocate.is() )
256 {
257 SAL_WARN( "sc.ui","can't get XRowLocate");
258 bDoSelection = bRealSelection = bBookmarkSelection = false;
259 }
260 }
261
262 uno::Reference<sdbc::XRow> xRow( xRowSet, uno::UNO_QUERY );
263 if ( nColCount > 0 && xRow.is() )
264 {
265 nEndCol = static_cast<SCCOL>( rParam.nCol1 + nColCount - 1 );
266
267 uno::Sequence<sal_Int32> aColTypes( nColCount ); // column types
268 uno::Sequence<sal_Bool> aColCurr( nColCount ); // currency flag is not in types
269 sal_Int32* pTypeArr = aColTypes.getArray();
270 sal_Bool* pCurrArr = aColCurr.getArray();
271 for (tools::Long i=0; i<nColCount; i++)
272 {
273 pTypeArr[i] = xMeta->getColumnType( i+1 );
274 pCurrArr[i] = xMeta->isCurrency( i+1 );
275 }
276
277 // read column names
278 nCol = rParam.nCol1;
279 for (tools::Long i=0; i<nColCount; i++)
280 {
281 pImportDoc->SetString( nCol, nRow, nTab,
282 xMeta->getColumnLabel( i+1 ) );
283 ++nCol;
284 }
285 ++nRow;
286
287 bool bEnd = false;
288 if ( !bDoSelection )
289 xRowSet->beforeFirst();
290 sal_uInt16 nInserted = 0;
291 while ( !bEnd )
292 {
293 // skip rows that are not selected
294 if ( !bDoSelection )
295 {
296 bEnd = !xRowSet->next();
297 if ( !bEnd )
298 ++nRowsRead;
299 }
300 else
301 {
302 if (nListPos < nListCount)
303 {
304 if ( bBookmarkSelection )
305 {
306 bEnd = !xLocate->moveToBookmark(aSelection[nListPos]);
307 }
308 else // use record numbers
309 {
310 sal_Int32 nNextRow = 0;
311 aSelection[nListPos] >>= nNextRow;
312 if ( nRowsRead+1 < nNextRow )
313 bRealSelection = true;
314 nRowsRead = nNextRow;
315 bEnd = !xRowSet->absolute(nRowsRead);
316 }
317 ++nListPos;
318 }
319 else
320 {
321 if ( !bBookmarkSelection && xRowSet->next() )
322 bRealSelection = true; // more data available but not used
323 bEnd = true;
324 }
325 }
326
327 if ( !bEnd )
328 {
329 if ( rDoc.ValidRow(nRow) )
330 {
331 nCol = rParam.nCol1;
332 for (tools::Long i=0; i<nColCount; i++)
333 {
334 ScDatabaseDocUtil::PutData( *pImportDoc, nCol, nRow, nTab,
335 xRow, i+1, pTypeArr[i], pCurrArr[i] );
336 ++nCol;
337 }
338 nEndRow = nRow;
339 ++nRow;
340
341 // progress bar
342
343 ++nInserted;
344 if (!(nInserted & 15))
345 {
346 aProgress.SetState( 0 );
347 }
348 }
349 else // past the end of the spreadsheet
350 {
351 bEnd = true; // don't continue
352 bTruncated = true; // warning flag
353 }
354 }
355 }
356
357 bSuccess = true;
358 }
359
360 if ( bDispose )
361 ::comphelper::disposeComponent( xRowSet );
362 }
363 }
364 catch ( const sdbc::SQLException& rError )
365 {
366 aErrorMessage = rError.Message;
367 }
368 catch ( uno::Exception& )
369 {
370 TOOLS_WARN_EXCEPTION( "sc", "Unexpected exception in database");
371 }
372
373 // test for cell protection
374
375 bool bKeepFormat = pDBData->IsKeepFmt();
376 bool bMoveCells = pDBData->IsDoSize();
377 SCCOL nFormulaCols = 0; // columns to be filled with formulas
378 if (bMoveCells && nEndCol == rParam.nCol2)
379 {
380 // if column count changes, formulas would become invalid anyway
381 // -> only set nFormulaCols for unchanged column count
382
383 SCCOL nTestCol = rParam.nCol2 + 1; // right of the data
384 SCROW nTestRow = rParam.nRow1 + 1; // below the title row
385 while ( nTestCol <= rDoc.MaxCol() &&
386 rDoc.GetCellType(ScAddress( nTestCol, nTestRow, nTab )) == CELLTYPE_FORMULA )
387 {
388 ++nTestCol;
389 ++nFormulaCols;
390 }
391 }
392
393 if (bSuccess)
394 {
395 // old and new range editable?
396 ScEditableTester aTester;
397 aTester.TestBlock( rDoc, nTab, rParam.nCol1,rParam.nRow1,rParam.nCol2,rParam.nRow2 );
398 aTester.TestBlock( rDoc, nTab, rParam.nCol1,rParam.nRow1,nEndCol,nEndRow );
399 if ( !aTester.IsEditable() )
400 {
401 pErrStringId = aTester.GetMessageId();
402 bSuccess = false;
403 }
404 else if ( (pChangeTrack = rDoc.GetChangeTrack()) != nullptr )
405 aChangedRange = ScRange(rParam.nCol1, rParam.nRow1, nTab,
406 nEndCol+nFormulaCols, nEndRow, nTab );
407 }
408
409 if ( bSuccess && bMoveCells )
410 {
411 ScRange aOld( rParam.nCol1, rParam.nRow1, nTab,
412 rParam.nCol2+nFormulaCols, rParam.nRow2, nTab );
413 ScRange aNew( rParam.nCol1, rParam.nRow1, nTab,
414 nEndCol+nFormulaCols, nEndRow, nTab );
415 if (!rDoc.CanFitBlock( aOld, aNew ))
416 {
417 pErrStringId = STR_MSSG_DOSUBTOTALS_2; // can't insert cells
418 bSuccess = false;
419 }
420 }
421
422 // copy data from import doc into real document
423
424 if ( bSuccess )
425 {
426 if (bKeepFormat)
427 {
428 // keep formatting of title and first data row from the document
429 // CopyToDocument also copies styles, Apply... needs separate calls
430
431 SCCOL nMinEndCol = std::min( rParam.nCol2, nEndCol ); // not too much
432 nMinEndCol = sal::static_int_cast<SCCOL>( nMinEndCol + nFormulaCols ); // only if column count unchanged
433 pImportDoc->DeleteAreaTab( 0,0, rDoc.MaxCol(),rDoc.MaxRow(), nTab, InsertDeleteFlags::ATTRIB );
434 rDoc.CopyToDocument(rParam.nCol1, rParam.nRow1, nTab,
435 nMinEndCol, rParam.nRow1, nTab,
436 InsertDeleteFlags::ATTRIB, false, *pImportDoc);
437
438 SCROW nDataStartRow = rParam.nRow1+1;
439 for (SCCOL nCopyCol=rParam.nCol1; nCopyCol<=nMinEndCol; nCopyCol++)
440 {
441 const ScPatternAttr* pSrcPattern = rDoc.GetPattern(
442 nCopyCol, nDataStartRow, nTab );
443 pImportDoc->ApplyPatternAreaTab( nCopyCol, nDataStartRow, nCopyCol, nEndRow,
444 nTab, *pSrcPattern );
445 const ScStyleSheet* pStyle = pSrcPattern->GetStyleSheet();
446 if (pStyle)
447 pImportDoc->ApplyStyleAreaTab( nCopyCol, nDataStartRow, nCopyCol, nEndRow,
448 nTab, *pStyle );
449 }
450 }
451
452 // don't set cell protection attribute if table is protected
453 if (rDoc.IsTabProtected(nTab))
454 {
455 ScPatternAttr aPattern(pImportDoc->GetPool());
456 aPattern.GetItemSet().Put( ScProtectionAttr( false,false,false,false ) );
457 pImportDoc->ApplyPatternAreaTab( 0,0,rDoc.MaxCol(),rDoc.MaxRow(), nTab, aPattern );
458 }
459
460 // copy old data for undo
461
462 SCCOL nUndoEndCol = std::max( nEndCol, rParam.nCol2 ); // rParam = old end
463 SCROW nUndoEndRow = std::max( nEndRow, rParam.nRow2 );
464
465 ScDocumentUniquePtr pUndoDoc;
466 std::unique_ptr<ScDBData> pUndoDBData;
467 if ( bRecord )
468 {
469 pUndoDoc.reset(new ScDocument( SCDOCMODE_UNDO ));
470 pUndoDoc->InitUndo( rDoc, nTab, nTab );
471
472 pUndoDBData.reset(new ScDBData( *pDBData ));
473 }
474
475 ScMarkData aNewMark(rDoc.GetSheetLimits());
476 aNewMark.SelectOneTable( nTab );
477
478 if (bRecord)
479 {
480 // do not touch notes (ScUndoImportData does not support drawing undo)
482
483 // nFormulaCols is set only if column count is unchanged
484 rDoc.CopyToDocument(rParam.nCol1, rParam.nRow1, nTab,
485 nEndCol+nFormulaCols, nEndRow, nTab,
486 nCopyFlags, false, *pUndoDoc);
487 if ( rParam.nCol2 > nEndCol )
488 rDoc.CopyToDocument(nEndCol+1, rParam.nRow1, nTab,
489 nUndoEndCol, nUndoEndRow, nTab,
490 nCopyFlags, false, *pUndoDoc);
491 if ( rParam.nRow2 > nEndRow )
492 rDoc.CopyToDocument(rParam.nCol1, nEndRow+1, nTab,
493 nUndoEndCol+nFormulaCols, nUndoEndRow, nTab,
494 nCopyFlags, false, *pUndoDoc);
495 }
496
497 // move new data
498
499 if (bMoveCells)
500 {
501 // clear only the range without the formulas,
502 // so the formula title and first row are preserved
503
504 ScRange aDelRange( rParam.nCol1, rParam.nRow1, nTab,
505 rParam.nCol2, rParam.nRow2, nTab );
506 rDoc.DeleteAreaTab( aDelRange, InsertDeleteFlags::ALL & ~InsertDeleteFlags::NOTE ); // without the formulas
507
508 ScRange aOld( rParam.nCol1, rParam.nRow1, nTab,
509 rParam.nCol2+nFormulaCols, rParam.nRow2, nTab );
510 ScRange aNew( rParam.nCol1, rParam.nRow1, nTab,
511 nEndCol+nFormulaCols, nEndRow, nTab );
512 rDoc.FitBlock( aOld, aNew, false ); // Do not delete formulas
513 }
514 else if ( nEndCol < rParam.nCol2 ) // DeleteArea calls PutInOrder
515 rDoc.DeleteArea( nEndCol+1, rParam.nRow1, rParam.nCol2, rParam.nRow2,
517
518 // CopyToDocument doesn't remove contents
519 rDoc.DeleteAreaTab( rParam.nCol1, rParam.nRow1, nEndCol, nEndRow, nTab, InsertDeleteFlags::CONTENTS & ~InsertDeleteFlags::NOTE );
520
521 // remove each column from ImportDoc after copying to reduce memory usage
522 bool bOldAutoCalc = rDoc.GetAutoCalc();
523 rDoc.SetAutoCalc( false ); // outside of the loop
524 for (SCCOL nCopyCol = rParam.nCol1; nCopyCol <= nEndCol; nCopyCol++)
525 {
526 pImportDoc->CopyToDocument(nCopyCol, rParam.nRow1, nTab, nCopyCol, nEndRow, nTab,
527 InsertDeleteFlags::ALL, false, rDoc);
528 pImportDoc->DeleteAreaTab( nCopyCol, rParam.nRow1, nCopyCol, nEndRow, nTab, InsertDeleteFlags::CONTENTS );
529 }
530 rDoc.SetAutoCalc( bOldAutoCalc );
531
532 if (nFormulaCols > 0) // copy formulas
533 {
534 if (bKeepFormat) // formats for formulas
535 pImportDoc->CopyToDocument(nEndCol+1, rParam.nRow1, nTab,
536 nEndCol+nFormulaCols, nEndRow, nTab,
537 InsertDeleteFlags::ATTRIB, false, rDoc);
538 // fill formulas
539 ScMarkData aMark(rDoc.GetSheetLimits());
540 aMark.SelectOneTable(nTab);
541
542 sal_uLong nProgCount = nFormulaCols;
543 nProgCount *= nEndRow-rParam.nRow1-1;
544 ScProgress aProgress( rDoc.GetDocumentShell(),
545 ScResId(STR_FILL_SERIES_PROGRESS), nProgCount, true );
546
547 rDoc.Fill( nEndCol+1, rParam.nRow1+1, nEndCol+nFormulaCols, rParam.nRow1+1,
548 &aProgress, aMark, nEndRow-rParam.nRow1-1, FILL_TO_BOTTOM, FILL_SIMPLE );
549 }
550
551 // if new range is smaller, clear old contents
552
553 if (!bMoveCells) // move has happened above
554 {
555 if ( rParam.nCol2 > nEndCol )
556 rDoc.DeleteArea( nEndCol+1, rParam.nRow1, rParam.nCol2, rParam.nRow2,
557 aNewMark, InsertDeleteFlags::CONTENTS );
558 if ( rParam.nRow2 > nEndRow )
559 rDoc.DeleteArea( rParam.nCol1, nEndRow+1, rParam.nCol2, rParam.nRow2,
560 aNewMark, InsertDeleteFlags::CONTENTS );
561 }
562
563 // update database range
564 pDBData->SetImportParam( rParam );
565 pDBData->SetHeader( true );
566 pDBData->SetByRow( true );
567 pDBData->SetArea( nTab, rParam.nCol1,rParam.nRow1, nEndCol,nEndRow );
568 pDBData->SetImportSelection( bRealSelection );
569 rDoc.CompileDBFormula();
570
571 if (bRecord)
572 {
573 ScDocumentUniquePtr pRedoDoc = std::move(pImportDoc);
574
575 if (nFormulaCols > 0) // include filled formulas for redo
576 rDoc.CopyToDocument(rParam.nCol1, rParam.nRow1, nTab,
577 nEndCol+nFormulaCols, nEndRow, nTab,
579
580 std::unique_ptr<ScDBData> pRedoDBData(new ScDBData(*pDBData));
581
583 std::make_unique<ScUndoImportData>( &rDocShell, nTab,
584 rParam, nUndoEndCol, nUndoEndRow,
585 nFormulaCols,
586 std::move(pUndoDoc), std::move(pRedoDoc),
587 std::move(pUndoDBData), std::move(pRedoDBData) ) );
588 }
589
591 rDoc.SetAllFormulasDirty(aCxt);
592 rDocShell.PostPaint(ScRange(0, 0, nTab, rDoc.MaxCol(), rDoc.MaxRow(), nTab), PaintPartFlags::Grid);
593 aModificator.SetDocumentModified();
594
595 ScDBRangeRefreshedHint aHint( rParam );
596 rDoc.BroadcastUno( aHint );
597
598 xWaitWin.reset();
599
600 if ( bTruncated ) // show warning
602 }
603 else
604 {
605 xWaitWin.reset();
606
607 if (aErrorMessage.isEmpty())
608 {
609 if (!pErrStringId)
610 pErrStringId = STR_MSSG_IMPORTDATA_0;
611 aErrorMessage = ScResId(pErrStringId);
612 }
613
614 std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(ScDocShell::GetActiveDialogParent(),
615 VclMessageType::Info, VclButtonsType::Ok,
616 aErrorMessage));
617 xInfoBox->run();
618 }
619
620 pImportDoc.reset();
621
622 if (bSuccess && pChangeTrack)
623 pChangeTrack->AppendInsert ( aChangedRange );
624
625 return bSuccess;
626}
627
628/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
HRESULT createInstance(REFIID iid, Ifc **ppIfc)
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
static DialogMask HandleError(ErrCode nId, weld::Window *pParent=nullptr, DialogMask nMask=DialogMask::MAX)
SC_DLLPUBLIC void AppendInsert(const ScRange &rRange, bool bEndOfList=false)
Definition: chgtrack.cxx:2763
void SetByRow(bool bByR)
Definition: dbdata.hxx:135
bool IsDoSize() const
Definition: dbdata.hxx:142
const OUString & GetName() const
Definition: dbdata.hxx:127
void SetImportParam(const ScImportParam &rImportParam)
Definition: dbdata.cxx:488
void SetHeader(bool bHasH)
Definition: dbdata.hxx:137
void SetImportSelection(bool bSet)
Definition: dbdata.hxx:210
bool IsKeepFmt() const
Definition: dbdata.hxx:144
void SetArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
Definition: dbdata.cxx:320
static void ShowInBeamer(const ScImportParam &rParam, const SfxViewFrame *pFrame)
Definition: dbdocimp.cxx:72
ScDocShell & rDocShell
Definition: dbdocfun.hxx:48
void UpdateImport(const OUString &rTarget, const svx::ODataAccessDescriptor &rDescriptor)
Definition: dbdocfun.cxx:1727
void DoImportUno(const ScAddress &rPos, const css::uno::Sequence< css::beans::PropertyValue > &aArgs)
Definition: dbdocimp.cxx:108
bool DoImport(SCTAB nTab, const ScImportParam &rParam, const svx::ODataAccessDescriptor *pDescriptor)
Definition: dbdocimp.cxx:121
static void PutData(ScDocument &rDoc, SCCOL nCol, SCROW nRow, SCTAB nTab, const css::uno::Reference< css::sdbc::XRow > &xRow, sal_Int32 nRowPos, tools::Long nType, bool bCurrency, StrData *pStrData=nullptr)
Definition: dbdocutl.cxx:38
Create before modifications of the document and destroy thereafter.
Definition: docsh.hxx:455
void SetDocumentModified()
Definition: docsh.cxx:3315
static weld::Window * GetActiveDialogParent()
Definition: docsh.cxx:3112
const ScDocument & GetDocument() const
Definition: docsh.hxx:219
ScDBData * GetDBData(const ScRange &rMarked, ScGetDBMode eMode, ScGetDBSelection eSel)
Definition: docsh5.cxx:115
void PostPaint(SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab, SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab, PaintPartFlags nPart, sal_uInt16 nExtFlags=0)
Definition: docsh3.cxx:101
virtual SfxUndoManager * GetUndoManager() override
Definition: docsh.cxx:2968
ScSheetLimits & GetSheetLimits() const
Definition: document.hxx:898
bool ValidRow(SCROW nRow) const
Definition: document.hxx:900
SC_DLLPUBLIC void Fill(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScProgress *pProgress, const ScMarkData &rMark, sal_uInt64 nFillCount, FillDir eFillDir=FILL_TO_BOTTOM, FillCmd eFillCmd=FILL_LINEAR, FillDateCmd eFillDateCmd=FILL_DAY, double nStepValue=1.0, double nMaxValue=1E307)
Definition: documen3.cxx:1156
SC_DLLPUBLIC bool IsTabProtected(SCTAB nTab) const
Definition: documen3.cxx:1905
SC_DLLPUBLIC SCCOL MaxCol() const
Definition: document.hxx:892
SC_DLLPUBLIC SCROW MaxRow() const
Definition: document.hxx:893
SC_DLLPUBLIC const ScDBData * GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const
Definition: documen3.cxx:338
SC_DLLPUBLIC bool GetAutoCalc() const
Definition: document.hxx:1413
SC_DLLPUBLIC void DeleteArea(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, const ScMarkData &rMark, InsertDeleteFlags nDelFlag, bool bBroadcast=true, sc::ColumnSpanSet *pBroadcastSpans=nullptr)
Definition: document.cxx:1859
void SetAllFormulasDirty(const sc::SetFormulaDirtyContext &rCxt)
Definition: document.cxx:3819
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:2041
void FitBlock(const ScRange &rOld, const ScRange &rNew, bool bClear=true)
Definition: document.cxx:1827
SfxObjectShell * GetDocumentShell() const
Definition: document.hxx:1083
SC_DLLPUBLIC void SetAutoCalc(bool bNewAutoCalc)
Definition: documen7.cxx:602
SC_DLLPUBLIC void DeleteAreaTab(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, SCTAB nTab, InsertDeleteFlags nDelFlag)
Definition: document.cxx:1920
ScChangeTrack * GetChangeTrack() const
Definition: document.hxx:2494
SC_DLLPUBLIC CellType GetCellType(SCCOL nCol, SCROW nRow, SCTAB nTab) const
Definition: document.cxx:3736
void CompileDBFormula()
Definition: documen4.cxx:554
bool IsUndoEnabled() const
Definition: document.hxx:1595
bool CanFitBlock(const ScRange &rOld, const ScRange &rNew)
Definition: document.cxx:1796
SC_DLLPUBLIC const ScPatternAttr * GetPattern(SCCOL nCol, SCROW nRow, SCTAB nTab) const
Definition: document.cxx:4719
void BroadcastUno(const SfxHint &rHint)
Definition: documen3.cxx:952
bool IsEditable() const
Definition: editable.hxx:84
TranslateId GetMessageId() const
Definition: editable.cxx:152
void TestBlock(const ScDocument &rDoc, SCTAB nTab, SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, bool bNoMatrixAtAll=false)
Definition: editable.cxx:82
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
Definition: markdata.hxx:43
void SelectOneTable(SCTAB nTab)
Definition: markdata.cxx:174
const ScStyleSheet * GetStyleSheet() const
Definition: patattr.hxx:165
SfxItemSet & GetItemSet()
Definition: patattr.hxx:192
void SetState(sal_uInt64 nVal, sal_uInt64 nNewRange=0)
Definition: progress.hxx:78
static bool GetBoolFromAny(const css::uno::Any &aAny)
Definition: miscuno.cxx:139
const css::uno::Reference< css::frame::XFrame > & GetFrameInterface() const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
virtual void AddUndoAction(std::unique_ptr< SfxUndoAction > pAction, bool bTryMerg=false)
SfxFrame & GetFrame() const
css::uno::Sequence< css::beans::PropertyValue > const & createPropertyValueSequence()
bool has(DataAccessDescriptorProperty _eWhich) const
void setDataSource(const OUString &_sDataSourceNameOrLocation)
constexpr OUStringLiteral SC_DBPROP_DATASOURCENAME
move to a header file?
Definition: dbdocimp.cxx:68
constexpr OUStringLiteral SC_DBPROP_COMMAND
Definition: dbdocimp.cxx:69
constexpr OUStringLiteral SC_SERVICE_ROWSET
Definition: dbdocimp.cxx:65
constexpr OUStringLiteral SC_DBPROP_COMMANDTYPE
Definition: dbdocimp.cxx:70
#define DBG_ASSERT(sCon, aError)
#define TOOLS_WARN_EXCEPTION(area, stream)
std::unique_ptr< ScDocument, o3tl::default_delete< ScDocument > > ScDocumentUniquePtr
Definition: document.hxx:2720
@ SCDOCMODE_UNDO
Definition: document.hxx:258
float u
@ CELLTYPE_FORMULA
Definition: global.hxx:276
InsertDeleteFlags
Definition: global.hxx:149
@ NOTE
Strings (and string results if InsertDeleteFlags::FORMULA is not set).
@ ATTRIB
Internal use only (d&d undo): do not delete caption objects of cell notes.
@ Keep
Keep selection as is, expand to used data area if no selection.
@ ScDbQuery
Definition: global.hxx:421
@ SC_DB_IMPORT
create "Importx" (if necessary)
Definition: global.hxx:385
@ FILL_SIMPLE
Definition: global.hxx:318
@ FILL_TO_BOTTOM
Definition: global.hxx:310
#define SAL_WARN(area, stream)
Reference< XMultiServiceFactory > getProcessServiceFactory()
Reference< XComponentContext > getProcessComponentContext()
int i
long Long
QPRO_FUNC_TYPE nType
Definition: qproform.cxx:398
OUString ScResId(TranslateId aId)
Definition: scdll.cxx:90
#define SCWARN_IMPORT_RANGE_OVERFLOW
Definition: scerrors.hxx:61
sal_uIntPtr sal_uLong
SCROW nRow1
Definition: global.hxx:442
OUString aStatement
Definition: global.hxx:447
SCCOL nCol1
Definition: global.hxx:441
SCCOL nCol2
Definition: global.hxx:443
SCROW nRow2
Definition: global.hxx:444
sal_uInt8 nType
Definition: global.hxx:450
OUString aDBName
Definition: global.hxx:446
bool bImport
Definition: global.hxx:445
Reference< XController > xController
Reference< XFrame > xFrame
unsigned char sal_Bool
sal_Int16 SCTAB
Definition: types.hxx:22
sal_Int16 SCCOL
Definition: types.hxx:21
sal_Int32 SCROW
Definition: types.hxx:17
@ QUERY
Definition: xmldpimp.hxx:44
@ TABLE
Definition: xmldpimp.hxx:43