LibreOffice Module sw (master) 1
dbinsdlg.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 <dbinsdlg.hxx>
21
22#include <float.h>
23
24#include <hintids.hxx>
25#include <com/sun/star/container/XNameAccess.hpp>
26#include <com/sun/star/sdbc/XDataSource.hpp>
27#include <com/sun/star/sdbc/XRow.hpp>
28#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
29#include <com/sun/star/sdbcx/XRowLocate.hpp>
30#include <com/sun/star/sdb/XQueriesSupplier.hpp>
31#include <com/sun/star/sdb/XColumn.hpp>
32#include <com/sun/star/sdbc/DataType.hpp>
33#include <com/sun/star/beans/XPropertySet.hpp>
34#include <com/sun/star/util/NumberFormatter.hpp>
35#include <com/sun/star/util/XNumberFormatTypes.hpp>
38#include <comphelper/types.hxx>
39#include <svl/numuno.hxx>
40#include <svl/numformat.hxx>
41#include <svl/stritem.hxx>
43#include <utility>
44#include <vcl/mnemonic.hxx>
45#include <svl/style.hxx>
46#include <svl/zformat.hxx>
47#include <sfx2/htmlmode.hxx>
48#include <svl/itemset.hxx>
49#include <editeng/brushitem.hxx>
50#include <editeng/boxitem.hxx>
52#include <fmtclds.hxx>
53#include <tabcol.hxx>
54#include <uiitems.hxx>
55#include <viewopt.hxx>
56#include <wrtsh.hxx>
57#include <view.hxx>
58#include <docsh.hxx>
59#include <dbmgr.hxx>
60#include <tblafmt.hxx>
61#include <cellatr.hxx>
62#include <swtablerep.hxx>
63#include <dbfld.hxx>
64#include <fmtcol.hxx>
65#include <swwait.hxx>
66#include <modcfg.hxx>
67#include <swmodule.hxx>
68#include <poolfmt.hxx>
70
71#include <cmdid.h>
72#include <SwStyleNameMapper.hxx>
73#include <tabsh.hxx>
74#include <swabstdlg.hxx>
75#include <strings.hrc>
77
78#include <o3tl/any.hxx>
79
80#include <memory>
81#include <string_view>
82
83#include <swuiexp.hxx>
84
85using namespace ::dbtools;
86using namespace ::com::sun::star;
87using namespace ::com::sun::star::beans;
88using namespace ::com::sun::star::container;
89using namespace ::com::sun::star::lang;
90using namespace ::com::sun::star::sdb;
91using namespace ::com::sun::star::sdbc;
92using namespace ::com::sun::star::sdbcx;
93using namespace ::com::sun::star::uno;
94
95const char cDBFieldStart = '<';
96const char cDBFieldEnd = '>';
97
98// Helper structure for adding database rows as fields or text
100{
101 const enum class Type { FILLTEXT, COL_FIELD, COL_TEXT, SPLITPARA } eColType;
102
103 union {
104 OUString* pText;
106 sal_uInt32 nFormat;
107 };
109
110 DB_Column() : eColType(Type::SPLITPARA),
111 pText(nullptr),
112 pColInfo(nullptr)
113 {}
114
115 explicit DB_Column( const OUString& rText )
116 : eColType(Type::FILLTEXT),
117 pText(new OUString(rText)),
118 pColInfo(nullptr)
119 {}
120
121 DB_Column( const SwInsDBColumn& rInfo, sal_uInt32 nFormat_ )
122 : eColType(Type::COL_TEXT),
123 nFormat(nFormat_),
124 pColInfo(&rInfo)
125 {}
126
127 DB_Column( const SwInsDBColumn& rInfo, SwDBField& rField )
128 : eColType(Type::COL_FIELD),
129 pField(&rField),
130 pColInfo(&rInfo)
131 {}
132
134 {
136 delete pField;
137 else if( Type::FILLTEXT == eColType )
138 delete pText;
139 }
140};
141
142namespace {
143
144struct DB_ColumnConfigData
145{
146 SwInsDBColumns aDBColumns;
147 OUString sEdit;
148 OUString sTableList;
149 OUString sTmplNm;
150 OUString sTAutoFormatNm;
151 bool bIsTable : 1,
152 bIsField : 1,
153 bIsHeadlineOn : 1,
154 bIsEmptyHeadln : 1;
155
156 DB_ColumnConfigData(DB_ColumnConfigData const&) = delete;
157 DB_ColumnConfigData& operator=(DB_ColumnConfigData const&) = delete;
158
159 DB_ColumnConfigData()
160 {
161 bIsTable = bIsHeadlineOn = true;
162 bIsField = bIsEmptyHeadln = false;
163 }
164};
165
166}
167
169{
170 return 0 > GetAppCollator().compareString( sColumn, rCmp.sColumn );
171}
172
174 Reference<XDataSource> const & xDataSource,
175 Reference<sdbcx::XColumnsSupplier> const & xColSupp,
177 : SfxDialogController(rView.GetWindow()->GetFrameWeld(), "modules/swriter/ui/insertdbcolumnsdialog.ui", "InsertDbColumnsDialog")
178 , ConfigItem("Office.Writer/InsertData/DataSet", ConfigItemMode::NONE)
179 , m_aDBData(std::move(aData))
180 , m_sNoTmpl(SwResId(SW_STR_NONE))
181 , m_pView(&rView)
182 , m_xRbAsTable(m_xBuilder->weld_radio_button("astable"))
183 , m_xRbAsField(m_xBuilder->weld_radio_button("asfields"))
184 , m_xRbAsText(m_xBuilder->weld_radio_button("astext"))
185 , m_xHeadFrame(m_xBuilder->weld_frame("dbframe"))
186 , m_xLbTableDbColumn(m_xBuilder->weld_tree_view("tabledbcols"))
187 , m_xLbTextDbColumn(m_xBuilder->weld_tree_view("tabletxtcols"))
188 , m_xFormatFrame(m_xBuilder->weld_frame("formatframe"))
189 , m_xRbDbFormatFromDb(m_xBuilder->weld_radio_button("fromdatabase"))
190 , m_xRbDbFormatFromUsr(m_xBuilder->weld_radio_button("userdefined"))
191 , m_xLbDbFormatFromUsr(new NumFormatListBox(m_xBuilder->weld_combo_box("numformat")))
192 , m_xIbDbcolToEdit(m_xBuilder->weld_button("toedit"))
193 , m_xEdDbText(m_xBuilder->weld_text_view("textview"))
194 , m_xFtDbParaColl(m_xBuilder->weld_label("parastylelabel"))
195 , m_xLbDbParaColl(m_xBuilder->weld_combo_box("parastyle"))
196 , m_xIbDbcolAllTo(m_xBuilder->weld_button("oneright"))
197 , m_xIbDbcolOneTo(m_xBuilder->weld_button("allright"))
198 , m_xIbDbcolOneFrom(m_xBuilder->weld_button("oneleft"))
199 , m_xIbDbcolAllFrom(m_xBuilder->weld_button("allleft"))
200 , m_xFtTableCol(m_xBuilder->weld_label("tablecolft"))
201 , m_xLbTableCol(m_xBuilder->weld_tree_view("tablecols"))
202 , m_xCbTableHeadon(m_xBuilder->weld_check_button("tableheading"))
203 , m_xRbHeadlColnms(m_xBuilder->weld_radio_button("columnname"))
204 , m_xRbHeadlEmpty(m_xBuilder->weld_radio_button("rowonly"))
205 , m_xPbTableFormat(m_xBuilder->weld_button("tableformat"))
206 , m_xPbTableAutofmt(m_xBuilder->weld_button("autoformat"))
207{
208 m_xEdDbText->set_size_request(m_xEdDbText->get_approximate_digit_width() * 40, -1);
209 m_xLbDbParaColl->make_sorted();
210
211 m_nGBFormatLen = m_xFormatFrame->get_label().getLength();
212
213 if (xColSupp.is())
214 {
216 SvNumberFormatter* pNumFormatr = rSh.GetNumberFormatter();
218 Reference< util::XNumberFormats > xDocNumberFormats = pNumFormat->getNumberFormats();
219 Reference< util::XNumberFormatTypes > xDocNumberFormatTypes(xDocNumberFormats, UNO_QUERY);
220
221 Reference<XPropertySet> xSourceProps(xDataSource, UNO_QUERY);
222 Reference< util::XNumberFormats > xNumberFormats;
223 if(xSourceProps.is())
224 {
225 Any aFormats = xSourceProps->getPropertyValue("NumberFormatsSupplier");
226 if(aFormats.hasValue())
227 {
228 Reference< util::XNumberFormatsSupplier> xSuppl;
229 aFormats >>= xSuppl;
230 if(xSuppl.is())
231 {
232 xNumberFormats = xSuppl->getNumberFormats( );
233 }
234 }
235 }
236 Reference <XNameAccess> xCols = xColSupp->getColumns();
237 const Sequence<OUString> aColNames = xCols->getElementNames();
238 for (const OUString& rColName : aColNames)
239 {
240 std::unique_ptr<SwInsDBColumn> pNew(new SwInsDBColumn( rColName ));
241 Any aCol = xCols->getByName(rColName);
242 Reference <XPropertySet> xCol;
243 aCol >>= xCol;
244 Any aType = xCol->getPropertyValue("Type");
245 sal_Int32 eDataType = 0;
246 aType >>= eDataType;
247 switch(eDataType)
248 {
249 case DataType::BIT:
250 case DataType::BOOLEAN:
251 case DataType::TINYINT:
252 case DataType::SMALLINT:
253 case DataType::INTEGER:
254 case DataType::BIGINT:
255 case DataType::FLOAT:
256 case DataType::REAL:
257 case DataType::DOUBLE:
258 case DataType::NUMERIC:
259 case DataType::DECIMAL:
260 case DataType::DATE:
261 case DataType::TIME:
262 case DataType::TIMESTAMP:
263 {
264 pNew->bHasFormat = true;
265 Any aFormat = xCol->getPropertyValue("FormatKey");
266 if(aFormat.hasValue())
267 {
268 sal_Int32 nFormat = 0;
269 aFormat >>= nFormat;
270 if(xNumberFormats.is())
271 {
272 try
273 {
274 Reference<XPropertySet> xNumProps = xNumberFormats->getByKey( nFormat );
275 Any aFormatVal = xNumProps->getPropertyValue("FormatString");
276 Any aLocale = xNumProps->getPropertyValue("Locale");
277 OUString sFormat;
278 aFormatVal >>= sFormat;
279 lang::Locale aLoc;
280 aLocale >>= aLoc;
281 sal_Int32 nKey = xDocNumberFormats->queryKey( sFormat, aLoc, true);
282 if(nKey < 0)
283 {
284 nKey = xDocNumberFormats->addNew( sFormat, aLoc );
285 }
286 pNew->nDBNumFormat = nKey;
287 }
288 catch (const Exception&)
289 {
290 OSL_FAIL("illegal number format key");
291 }
292 }
293 }
294 else
295 {
296 pNew->nDBNumFormat = getDefaultNumberFormat(xCol,
297 xDocNumberFormatTypes, LanguageTag( rSh.GetCurLang() ).getLocale());
298 }
299
300 }
301 break;
302 }
303 if( !m_aDBColumns.insert( std::move(pNew) ).second )
304 {
305 OSL_ENSURE( false, "Spaltenname mehrfach vergeben?" );
306 }
307 }
308 }
309
310 // fill paragraph templates-ListBox
311 {
313 m_xLbDbParaColl->append_text( m_sNoTmpl );
314
315 const SfxStyleSheetBase* pBase = pPool->First(SfxStyleFamily::Para);
316 while( pBase )
317 {
318 m_xLbDbParaColl->append_text( pBase->GetName() );
319 pBase = pPool->Next();
320 }
321 m_xLbDbParaColl->set_active( 0 );
322 }
323
324 // when the cursor is inside of a table, table must NEVER be selectable
326 {
327 m_xRbAsField->set_active(true);
328 m_xRbAsTable->set_sensitive(false);
329 m_xRbDbFormatFromDb->set_active(true);
330 }
331 else
332 {
333 m_xRbAsTable->set_active(true);
334 m_xRbDbFormatFromDb->set_active(true);
335 m_xIbDbcolOneFrom->set_sensitive( false );
336 m_xIbDbcolAllFrom->set_sensitive( false );
337 }
338
339 // by default, select header button
340 m_xRbHeadlColnms->set_active(true);
341 m_xRbHeadlEmpty->set_active(false);
342
343 m_xRbAsTable->connect_toggled( LINK(this, SwInsertDBColAutoPilot, PageHdl ));
344 m_xRbAsField->connect_toggled( LINK(this, SwInsertDBColAutoPilot, PageHdl ));
345 m_xRbAsText->connect_toggled( LINK(this, SwInsertDBColAutoPilot, PageHdl ));
346
347 m_xRbDbFormatFromDb->connect_toggled( LINK(this, SwInsertDBColAutoPilot, DBFormatHdl ));
348 m_xRbDbFormatFromUsr->connect_toggled( LINK(this, SwInsertDBColAutoPilot, DBFormatHdl ));
349
350 m_xPbTableFormat->connect_clicked(LINK(this, SwInsertDBColAutoPilot, TableFormatHdl ));
351 m_xPbTableAutofmt->connect_clicked(LINK(this, SwInsertDBColAutoPilot, AutoFormatHdl ));
352
353 m_xIbDbcolAllTo->connect_clicked( LINK(this, SwInsertDBColAutoPilot, TableToFromHdl ));
354 m_xIbDbcolOneTo->connect_clicked( LINK(this, SwInsertDBColAutoPilot, TableToFromHdl ));
355 m_xIbDbcolOneFrom->connect_clicked( LINK(this, SwInsertDBColAutoPilot, TableToFromHdl ));
356 m_xIbDbcolAllFrom->connect_clicked( LINK(this, SwInsertDBColAutoPilot, TableToFromHdl ));
357 m_xIbDbcolToEdit->connect_clicked( LINK(this, SwInsertDBColAutoPilot, TableToFromHdl ));
358
359 m_xCbTableHeadon->connect_toggled( LINK(this, SwInsertDBColAutoPilot, HeaderHdl ));
360
361 m_xLbTextDbColumn->connect_changed( LINK( this, SwInsertDBColAutoPilot, TVSelectHdl ));
362 m_xLbTableDbColumn->connect_changed( LINK( this, SwInsertDBColAutoPilot, TVSelectHdl ));
363 m_xLbDbFormatFromUsr->connect_changed( LINK( this, SwInsertDBColAutoPilot, CBSelectHdl ));
364 m_xLbTableCol->connect_changed( LINK( this, SwInsertDBColAutoPilot, TVSelectHdl ));
365
366 m_xLbTextDbColumn->connect_row_activated( LINK( this, SwInsertDBColAutoPilot, DblClickHdl ));
367 m_xLbTableDbColumn->connect_row_activated( LINK( this, SwInsertDBColAutoPilot, DblClickHdl ));
368 m_xLbTableCol->connect_row_activated( LINK( this, SwInsertDBColAutoPilot, DblClickHdl ));
369
370 for( size_t n = 0; n < m_aDBColumns.size(); ++n )
371 {
372 const OUString& rS = m_aDBColumns[ n ]->sColumn;
373 m_xLbTableDbColumn->append_text(rS);
374 m_xLbTextDbColumn->append_text(rS);
375 }
376 m_xLbTextDbColumn->select(0);
377 m_xLbTableDbColumn->select(0);
378
379 // read configuration
380 Load();
381
382 // lock size to widest config
383 m_xHeadFrame->set_size_request(m_xHeadFrame->get_preferred_size().Width(), -1);
384 // initialise Controls:
385 PageHdl(m_xRbAsTable->get_active() ? *m_xRbAsTable : *m_xRbAsField);
386}
387
389{
390}
391
393{
394 if (!rButton.get_active())
395 return;
396
397 bool bShowTable = m_xRbAsTable->get_active();
398
399 weld::RadioButton& rRadio = dynamic_cast<weld::RadioButton&>(rButton);
400 m_xHeadFrame->set_label(MnemonicGenerator::EraseAllMnemonicChars(rRadio.get_label().replace('_', '~')));
401
402 m_xLbTextDbColumn->set_visible( !bShowTable );
403 m_xIbDbcolToEdit->set_visible( !bShowTable );
404 m_xEdDbText->set_visible( !bShowTable );
405 m_xFtDbParaColl->set_visible( !bShowTable );
406 m_xLbDbParaColl->set_visible( !bShowTable );
407
408 m_xLbTableDbColumn->set_visible( bShowTable );
409 m_xIbDbcolAllTo->set_visible( bShowTable );
410 m_xIbDbcolOneTo->set_visible( bShowTable );
411 m_xIbDbcolOneFrom->set_visible( bShowTable );
412 m_xIbDbcolAllFrom->set_visible( bShowTable );
413 m_xFtTableCol->set_visible( bShowTable );
414 m_xLbTableCol->set_visible( bShowTable );
415 m_xCbTableHeadon->set_visible( bShowTable );
416 m_xRbHeadlColnms->set_visible( bShowTable );
417 m_xRbHeadlEmpty->set_visible( bShowTable );
418 m_xPbTableFormat->set_visible( bShowTable );
419 m_xPbTableAutofmt->set_visible( bShowTable );
420
421 if( bShowTable )
422 m_xPbTableFormat->set_sensitive( 0 != m_xLbTableCol->n_children() );
423
424 TVSelectHdl( bShowTable ? *m_xLbTableDbColumn : *m_xLbTextDbColumn );
425}
426
427IMPL_LINK( SwInsertDBColAutoPilot, DBFormatHdl, weld::Toggleable&, rButton, void )
428{
429 if (!rButton.get_active())
430 return;
431
432 weld::TreeView& rBox = m_xRbAsTable->get_active()
433 ? ( m_xLbTableCol->get_id(0).isEmpty()
434 ? *m_xLbTableDbColumn
435 : *m_xLbTableCol )
436 : *m_xLbTextDbColumn;
437
438 SwInsDBColumn aSrch(rBox.get_selected_text());
439 SwInsDBColumns::const_iterator it = m_aDBColumns.find( &aSrch );
440
441 bool bFromDB = m_xRbDbFormatFromDb->get_active();
442 (*it)->bIsDBFormat = bFromDB;
443 m_xLbDbFormatFromUsr->set_sensitive( !bFromDB );
444}
445
446IMPL_LINK( SwInsertDBColAutoPilot, TableToFromHdl, weld::Button&, rButton, void )
447{
448 bool bChgEnable = true, bEnableTo = true, bEnableFrom = true;
449
450 if( &rButton == m_xIbDbcolAllTo.get() )
451 {
452 bEnableTo = false;
453
454 sal_Int32 n, nInsPos = m_xLbTableCol->get_selected_index(),
455 nCnt = m_xLbTableDbColumn->n_children();
456
457 m_xLbTableDbColumn->unselect_all();
458
459 m_xLbTableDbColumn->freeze();
460 m_xLbTableCol->freeze();
461
462 if (nInsPos == -1)
463 for( n = 0; n < nCnt; ++n )
464 m_xLbTableCol->append_text(m_xLbTableDbColumn->get_text(n));
465 else
466 for( n = 0; n < nCnt; ++n, ++nInsPos )
467 m_xLbTableCol->insert_text(nInsPos, m_xLbTableDbColumn->get_text(n));
468 m_xLbTableDbColumn->clear();
469
470 m_xLbTableDbColumn->thaw();
471 m_xLbTableCol->thaw();
472
473 m_xLbTableCol->select(nInsPos);
474 }
475 else if( &rButton == m_xIbDbcolOneTo.get() &&
476 m_xLbTableDbColumn->get_selected_index() != -1 )
477 {
478 sal_Int32 nInsPos = m_xLbTableCol->get_selected_index(),
479 nDelPos = m_xLbTableDbColumn->get_selected_index();
480 m_xLbTableCol->insert_text(nInsPos, m_xLbTableDbColumn->get_text(nDelPos));
481 m_xLbTableDbColumn->remove(nDelPos);
482
483 m_xLbTableCol->select(nInsPos);
484 if (nDelPos >= m_xLbTableDbColumn->n_children())
485 nDelPos = m_xLbTableDbColumn->n_children() - 1;
486 m_xLbTableDbColumn->select(nDelPos);
487
488 bEnableTo = 0 != m_xLbTableDbColumn->n_children();
489 }
490 else if( &rButton == m_xIbDbcolOneFrom.get() )
491 {
492 if (m_xLbTableCol->get_selected_index() != -1)
493 {
494 sal_Int32 nInsPos,
495 nDelPos = m_xLbTableCol->get_selected_index();
496
497 // look for the right InsertPos!!
498 SwInsDBColumn aSrch(m_xLbTableCol->get_text(nDelPos));
499 SwInsDBColumns::const_iterator it = m_aDBColumns.find( &aSrch );
500 if( it == m_aDBColumns.begin() || (it+1) == m_aDBColumns.end() )
501 nInsPos = it - m_aDBColumns.begin();
502 else
503 {
504 nInsPos = -1;
505 while( ++it != m_aDBColumns.end() &&
506 -1 == (nInsPos = m_xLbTableDbColumn->
507 find_text( (*it)->sColumn )) )
508 ;
509 }
510
511 m_xLbTableDbColumn->insert_text(nInsPos, aSrch.sColumn);
512 m_xLbTableCol->remove( nDelPos );
513
514 if (nInsPos >= m_xLbTableDbColumn->n_children())
515 nInsPos = m_xLbTableDbColumn->n_children() - 1;
516 m_xLbTableDbColumn->select(nInsPos);
517
518 if (nDelPos >= m_xLbTableCol->n_children())
519 nDelPos = m_xLbTableCol->n_children() - 1;
520 m_xLbTableCol->select(nDelPos);
521 }
522 else
523 bEnableTo = 0 != m_xLbTableDbColumn->n_children();
524
525 bEnableFrom = 0 != m_xLbTableCol->n_children();
526 }
527 else if( &rButton == m_xIbDbcolAllFrom.get() )
528 {
529 bEnableFrom = false;
530
531 m_xLbTableDbColumn->freeze();
532 m_xLbTableCol->freeze();
533
534 m_xLbTableDbColumn->clear();
535 m_xLbTableCol->clear();
536 for (size_t n = 0; n < m_aDBColumns.size(); ++n)
537 m_xLbTableDbColumn->append_text(m_aDBColumns[n]->sColumn);
538
539 m_xLbTableDbColumn->thaw();
540 m_xLbTableCol->thaw();
541
542 m_xLbTableDbColumn->select(0);
543 }
544 else if( &rButton == m_xIbDbcolToEdit.get() )
545 {
546 bChgEnable = false;
547 // move data to Edit:
548 OUString aField(m_xLbTextDbColumn->get_selected_text());
549 if( !aField.isEmpty() )
550 {
551 OUString aStr( m_xEdDbText->get_text() );
552 int nStartPos, nEndPos;
553 m_xEdDbText->get_selection_bounds(nStartPos, nEndPos);
554 sal_Int32 nPos = std::min(nStartPos, nEndPos);
555 sal_Int32 nMax = std::max(nStartPos, nEndPos);
556 const sal_Int32 nSel = nMax - nPos;
557 if( nSel )
558 // first delete the existing selection
559 aStr = aStr.replaceAt( nPos, nSel, u"" );
560
561 aField = OUStringChar(cDBFieldStart) + aField + OUStringChar(cDBFieldEnd);
562 if( !aStr.isEmpty() )
563 {
564 if( nPos ) // one blank in front
565 {
566 sal_Unicode c = aStr[ nPos-1 ];
567 if( '\n' != c && '\r' != c )
568 aField = " " + aField;
569 }
570 if( nPos < aStr.getLength() ) // one blank behind
571 {
572 sal_Unicode c = aStr[ nPos ];
573 if( '\n' != c && '\r' != c )
574 aField += " ";
575 }
576 }
577
578 m_xEdDbText->set_text( aStr.replaceAt( nPos, 0, aField ) );
579 nPos += aField.getLength();
580 m_xEdDbText->select_region(nPos, nPos);
581 }
582 }
583
584 if( !bChgEnable )
585 return;
586
587 m_xIbDbcolOneTo->set_sensitive( bEnableTo );
588 m_xIbDbcolAllTo->set_sensitive( bEnableTo );
589 m_xIbDbcolOneFrom->set_sensitive( bEnableFrom );
590 m_xIbDbcolAllFrom->set_sensitive( bEnableFrom );
591
592 m_xRbDbFormatFromDb->set_sensitive( false );
593 m_xRbDbFormatFromUsr->set_sensitive( false );
594 m_xLbDbFormatFromUsr->set_sensitive( false );
595
596 m_xPbTableFormat->set_sensitive( bEnableFrom );
597}
598
600{
601 weld::Button* pButton = nullptr;
602 if( &rBox == m_xLbTextDbColumn.get() )
603 pButton = m_xIbDbcolToEdit.get();
604 else if( &rBox == m_xLbTableDbColumn.get() && m_xIbDbcolOneTo->get_sensitive() )
605 pButton = m_xIbDbcolOneTo.get();
606 else if( &rBox == m_xLbTableCol.get() && m_xIbDbcolOneFrom->get_sensitive() )
607 pButton = m_xIbDbcolOneFrom.get();
608
609 if (pButton)
610 TableToFromHdl(*pButton);
611
612 return true;
613}
614
616{
617 SwWrtShell& rSh = m_pView->GetWrtShell();
618 bool bNewSet = false;
619 if( !m_pTableSet )
620 {
621 bNewSet = true;
622 m_pTableSet.reset(new SfxItemSet( rSh.GetAttrPool(), SwuiGetUITableAttrRange() ));
623
624 // At first acquire the simple attributes
625 m_pTableSet->Put( SfxStringItem( FN_PARAM_TABLE_NAME, rSh.GetUniqueTableName() ));
626 m_pTableSet->Put( SfxUInt16Item( FN_PARAM_TABLE_HEADLINE, 1 ) );
627
628 m_pTableSet->Put( SfxUInt16Item( SID_BACKGRND_DESTINATION,
629 rSh.GetViewOptions()->GetTableDest() ));
630
632 m_pTableSet->Put( aBrush );
633 aBrush.SetWhich(SID_ATTR_BRUSH_ROW);
634 m_pTableSet->Put( aBrush );
635 aBrush.SetWhich(SID_ATTR_BRUSH_TABLE);
636 m_pTableSet->Put( aBrush );
637
638 SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
639 // table variant, when multiple table cells are selected
640 aBoxInfo.SetTable( true );
641 // always show gap field
642 aBoxInfo.SetDist( true);
643 // set minimum size in tables and paragraphs
644 aBoxInfo.SetMinDist( false );
645 // always set default-gap
646 aBoxInfo.SetDefDist( MIN_BORDER_DIST );
647 // Single lines can have DontCare-status only in tables
648 aBoxInfo.SetValid( SvxBoxInfoItemValidFlags::DISABLE );
649 m_pTableSet->Put( aBoxInfo );
650
651 SwGetCurColNumPara aPara;
652 const sal_uInt16 nNum = rSh.GetCurColNum( &aPara );
653 tools::Long nWidth;
654
655 if( nNum )
656 {
657 nWidth = aPara.pPrtRect->Width();
658 const SwFormatCol& rCol = aPara.pFrameFormat->GetCol();
659 const SwColumns& rCols = rCol.GetColumns();
660
661 // initialise nStart and nEnd for nNum == 0
662 tools::Long nWidth1 = 0,
663 nStart1 = 0,
664 nEnd1 = nWidth;
665 for( sal_uInt16 i = 0; i < nNum; ++i )
666 {
667 const SwColumn* pCol = &rCols[i];
668 nStart1 = pCol->GetLeft() + nWidth1;
669 nWidth1 += static_cast<tools::Long>(rCol.CalcColWidth( i, o3tl::narrowing<sal_uInt16>(nWidth) ));
670 nEnd1 = nWidth1 - pCol->GetRight();
671 }
672 if(nStart1 || nEnd1 != nWidth)
673 nWidth = nEnd1 - nStart1;
674 }
675 else
676 nWidth = rSh.GetAnyCurRect(
677 (FrameTypeFlags::FLY_ANY & rSh.GetFrameType( nullptr, true ))
680
681 SwTabCols aTabCols;
682 aTabCols.SetRight( nWidth );
683 aTabCols.SetRightMax( nWidth );
684 m_pRep.reset(new SwTableRep( aTabCols ));
685 m_pRep->SetAlign( text::HoriOrientation::NONE );
686 m_pRep->SetSpace( nWidth );
687 m_pRep->SetWidth( nWidth );
688 m_pRep->SetWidthPercent( 100 );
689 m_pTableSet->Put( SwPtrItem( FN_TABLE_REP, m_pRep.get() ));
690
691 m_pTableSet->Put( SfxUInt16Item( SID_HTML_MODE,
692 ::GetHtmlMode( m_pView->GetDocShell() )));
693 }
694
695 sal_Int32 nCols = m_xLbTableCol->n_children();
696 if (nCols != m_pRep->GetAllColCount() && nCols > 0)
697 {
698 // Number of columns has changed: then the TabCols have to be adjusted
699 tools::Long nWidth = m_pRep->GetWidth();
700 --nCols;
701 SwTabCols aTabCols( nCols );
702 aTabCols.SetRight( nWidth );
703 aTabCols.SetRightMax( nWidth );
704 if( nCols )
705 {
706 const sal_Int32 nStep = nWidth / (nCols+1);
707 for( sal_Int32 n = 0; n < nCols; ++n )
708 {
709 aTabCols.Insert( nStep*(n+1), false, n );
710 }
711 }
712 m_pRep.reset(new SwTableRep( aTabCols ));
713 m_pRep->SetAlign( text::HoriOrientation::NONE );
714 m_pRep->SetSpace( nWidth );
715 m_pRep->SetWidth( nWidth );
716 m_pRep->SetWidthPercent( 100 );
717 m_pTableSet->Put( SwPtrItem( FN_TABLE_REP, m_pRep.get() ));
718 }
719
721
722 ScopedVclPtr<SfxAbstractTabDialog> pDlg(rFact.CreateSwTableTabDlg(m_xDialog.get(), m_pTableSet.get(), &rSh));
723 if( RET_OK == pDlg->Execute() )
724 m_pTableSet->Put( *pDlg->GetOutputItemSet() );
725 else if( bNewSet )
726 {
727 m_pTableSet.reset();
728 m_pRep.reset();
729 }
730}
731
733{
735
736 ScopedVclPtr<AbstractSwAutoFormatDlg> pDlg(rFact.CreateSwAutoFormatDlg(m_xDialog.get(), m_pView->GetWrtShellPtr(), false, m_xTAutoFormat.get()));
737 if( RET_OK == pDlg->Execute())
738 m_xTAutoFormat = pDlg->FillAutoFormatOfIndex();
739}
740
742{
743 weld::TreeView* pGetBox = &rBox;
744
745 SwInsDBColumn aSrch(pGetBox->get_selected_text());
746 SwInsDBColumns::const_iterator it = m_aDBColumns.find( &aSrch );
747
748 // set the selected FieldName at the FormatGroupBox, so that
749 // it's clear what field is configured by the format!
750 OUString sText( m_xFormatFrame->get_label().copy( 0, m_nGBFormatLen ));
751 if( aSrch.sColumn.isEmpty() )
752 {
753 m_xRbDbFormatFromDb->set_sensitive( false );
754 m_xRbDbFormatFromUsr->set_sensitive( false );
755 m_xLbDbFormatFromUsr->set_sensitive( false );
756 }
757 else
758 {
759 bool bEnableFormat = (*it)->bHasFormat;
760 m_xRbDbFormatFromDb->set_sensitive( bEnableFormat );
761 m_xRbDbFormatFromUsr->set_sensitive( bEnableFormat );
762
763 if( bEnableFormat )
764 {
765 sText += " (" + aSrch.sColumn + ")";
766 }
767
768 bool bIsDBFormat = (*it)->bIsDBFormat;
769 m_xRbDbFormatFromDb->set_active( bIsDBFormat );
770 m_xRbDbFormatFromUsr->set_active( !bIsDBFormat );
771 m_xLbDbFormatFromUsr->set_sensitive( !bIsDBFormat );
772 if( !bIsDBFormat )
773 m_xLbDbFormatFromUsr->SetDefFormat( (*it)->nUsrNumFormat );
774 }
775
776 m_xFormatFrame->set_label(sText);
777
778 if (m_xLbTableCol->n_children())
779 {
780 // to know later on, what ListBox was the "active", a Flag
781 // is remembered in the 1st entry
782 if (&rBox == m_xLbTableCol.get())
783 m_xLbTableCol->set_id(0, "tablecols");
784 else
785 m_xLbTableCol->set_id(0, OUString());
786 }
787}
788
790{
791 weld::TreeView* pGetBox = m_xRbAsTable->get_active()
792 ? ( m_xLbTableCol->get_id(0).isEmpty()
793 ? m_xLbTableDbColumn.get()
794 : m_xLbTableCol.get() )
795 : m_xLbTextDbColumn.get();
796
797 SwInsDBColumn aSrch(pGetBox->get_selected_text());
798 SwInsDBColumns::const_iterator it = m_aDBColumns.find( &aSrch );
799
800 if( !aSrch.sColumn.isEmpty() )
801 {
802 m_xLbDbFormatFromUsr->CallSelectHdl();
803 (*it)->nUsrNumFormat = m_xLbDbFormatFromUsr->GetFormat();
804 }
805}
806
808{
809 bool bEnable = m_xCbTableHeadon->get_active();
810 m_xRbHeadlColnms->set_sensitive( bEnable );
811 m_xRbHeadlEmpty->set_sensitive( bEnable );
812}
813
814static void lcl_InsTextInArr( std::u16string_view aText, DB_Columns& rColArr )
815{
816 size_t nSttPos = 0;
817 size_t nFndPos;
818 while( std::u16string_view::npos != ( nFndPos = aText.find( '\x0A', nSttPos )) )
819 {
820 if( 1 < nFndPos )
821 {
822 rColArr.push_back(std::make_unique<DB_Column>(OUString(aText.substr(nSttPos, nFndPos -1))));
823 }
824 rColArr.push_back(std::make_unique<DB_Column>());
825 nSttPos = nFndPos + 1;
826 }
827 if( nSttPos < aText.size() )
828 {
829 rColArr.push_back(std::make_unique<DB_Column>(OUString(aText.substr(nSttPos))));
830 }
831}
832
834 DB_Columns& rColArr,
835 bool bInsField )
836{
837 // create each of the database columns from the text again
838 // and then save in an array
839 // database columns are in <> and must be present in the columns' array:
840 OUString sText( rText );
841 sal_Int32 nFndPos, nEndPos, nSttPos = 0;
842
843 while( -1 != ( nFndPos = sText.indexOf( cDBFieldStart, nSttPos )))
844 {
845 nSttPos = nFndPos + 1;
846 nEndPos = sText.indexOf( cDBFieldEnd, nSttPos+1 );
847 if( -1 != nEndPos )
848 {
849 // Text in <> brackets found: what is it:
850 SwInsDBColumn aSrch( sText.copy( nSttPos, nEndPos - nSttPos ));
852 if( it != m_aDBColumns.end() )
853 {
854 // that is a valid field
855 // so surely the text "before":
856 const SwInsDBColumn& rFndCol = **it;
857
858 DB_Column* pNew;
859
860 if( 1 < nSttPos )
861 {
862 ::lcl_InsTextInArr( sText.subView( 0, nSttPos-1 ), rColArr );
863 sText = sText.copy( nSttPos-1 );
864 }
865
866 sText = sText.copy( rFndCol.sColumn.getLength() + 2 );
867 nSttPos = 0;
868
869 sal_uInt16 nSubType = 0;
870 sal_uInt32 nFormat;
871 if( rFndCol.bHasFormat )
872 {
873 if( rFndCol.bIsDBFormat )
874 nFormat = static_cast<sal_uInt32>(rFndCol.nDBNumFormat);
875 else
876 {
877 nFormat = rFndCol.nUsrNumFormat;
879 }
880 }
881 else
882 nFormat = 0;
883
884 if( bInsField )
885 {
887 SwDBFieldType aFieldType( rSh.GetDoc(), aSrch.sColumn,
888 m_aDBData );
889 pNew = new DB_Column( rFndCol, *new SwDBField(
890 static_cast<SwDBFieldType*>(rSh.InsertFieldType( aFieldType )),
891 nFormat ) );
892 if( nSubType )
893 pNew->pField->SetSubType( nSubType );
894 }
895 else
896 pNew = new DB_Column( rFndCol, nFormat );
897
898 rColArr.push_back( std::unique_ptr<DB_Column>(pNew) );
899 }
900 }
901 }
902
903 // don't forget the last text
904 if( !sText.isEmpty() )
905 ::lcl_InsTextInArr( sText, rColArr );
906
907 return !rColArr.empty();
908}
909
910void SwInsertDBColAutoPilot::DataToDoc( const Sequence<Any>& rSelection,
911 Reference< XDataSource> const & xSource,
912 Reference< XConnection> const & xConnection,
913 Reference< sdbc::XResultSet > const & xResultSet_in )
914{
915 auto xResultSet = xResultSet_in;
916
917 const Any* pSelection = rSelection.hasElements() ? rSelection.getConstArray() : nullptr;
919
920 //with the drag and drop interface no result set is initially available
921 bool bDisposeResultSet = false;
922 // we don't have a cursor, so we have to create our own RowSet
923 if ( !xResultSet.is() )
924 {
926 bDisposeResultSet = xResultSet.is();
927 }
928
929 Reference< sdbc::XRow > xRow(xResultSet, UNO_QUERY);
930 if ( !xRow.is() )
931 return;
932
933 rSh.StartAllAction();
934 bool bUndo = rSh.DoesUndo();
935 if( bUndo )
936 rSh.StartUndo();
937
938 bool bAsTable = m_xRbAsTable->get_active();
939 SvNumberFormatter& rNumFormatr = *rSh.GetNumberFormatter();
940
941 if( rSh.HasSelection() )
942 rSh.DelRight();
943
944 std::optional<SwWait> oWait;
945
946 Reference< XColumnsSupplier > xColsSupp( xResultSet, UNO_QUERY );
947 Reference <XNameAccess> xCols = xColsSupp->getColumns();
948
949 uno::Reference<sdbcx::XRowLocate> xRowLocate(xResultSet, uno::UNO_QUERY_THROW);
950
951 do{ // middle checked loop!!
952 if( bAsTable ) // fill in data as table
953 {
954 rSh.DoUndo( false );
955
956 sal_Int32 nCols = m_xLbTableCol->n_children();
957 sal_Int32 nRows = 0;
958 if( m_xCbTableHeadon->get_active() )
959 nRows++;
960
961 if( pSelection )
962 nRows += rSelection.getLength();
963 else
964 ++nRows;
965
966 // prepare the array for the selected columns
967 std::vector<SwInsDBColumn*> aColFields;
968 for( sal_Int32 n = 0; n < nCols; ++n )
969 {
970 SwInsDBColumn aSrch(m_xLbTableCol->get_text(n));
972 if (it != m_aDBColumns.end())
973 aColFields.push_back(it->get());
974 else {
975 OSL_ENSURE( false, "database column not found" );
976 }
977 }
978
979 if( static_cast<size_t>(nCols) != aColFields.size() )
980 {
981 OSL_ENSURE( false, "not all database columns found" );
982 nCols = static_cast<sal_Int32>(aColFields.size());
983 }
984
985 if(!nRows || !nCols)
986 {
987 OSL_ENSURE( false, "wrong parameters" );
988 break;
989 }
990
991 const SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig();
992
993 bool bHTML = 0 != (::GetHtmlMode( m_pView->GetDocShell() ) & HTMLMODE_ON);
994 rSh.InsertTable(
995 pModOpt->GetInsTableFlags(bHTML),
996 nRows, nCols, (pSelection ? m_xTAutoFormat.get(): nullptr) );
998
999 if( pSelection && m_pTableSet )
1000 SetTabSet();
1001
1003 bool bIsAutoUpdateCells = rSh.IsAutoUpdateCells();
1004 rSh.SetAutoUpdateCells( false );
1005
1006 if( m_xCbTableHeadon->get_active() )
1007 {
1008 for( sal_Int32 n = 0; n < nCols; ++n )
1009 {
1010 if( m_xRbHeadlColnms->get_active() )
1011 {
1012 rSh.SwEditShell::Insert2( aColFields[ n ]->sColumn );
1013 }
1014 rSh.GoNextCell();
1015 }
1016 }
1017 else
1018 rSh.SetRowsToRepeat( 0 );
1019
1020 for( sal_Int32 i = 0 ; ; ++i )
1021 {
1022 bool bBreak = false;
1023 try
1024 {
1025 if(pSelection)
1026 {
1027 bBreak = !xRowLocate->moveToBookmark(pSelection[i]);
1028 }
1029 else if(!i)
1030 bBreak = !xResultSet->first();
1031 }
1032 catch (const Exception&)
1033 {
1034 bBreak = true;
1035 }
1036 if(bBreak)
1037 break;
1038
1039 for( sal_Int32 n = 0; n < nCols; ++n )
1040 {
1041 // at the very first time, NO GoNextCell, because we're
1042 // already in it. Also no GoNextCell after the Insert,
1043 // because an empty line is added at the end.
1044 if( i || n )
1045 rSh.GoNextCell();
1046
1047 const SwInsDBColumn* pEntry = aColFields[ n ];
1048
1049 Reference< XColumn > xColumn;
1050 xCols->getByName(pEntry->sColumn) >>= xColumn;
1051 Reference< XPropertySet > xColumnProps( xColumn, UNO_QUERY );
1052 sal_Int32 eDataType = 0;
1053 if( xColumnProps.is() )
1054 {
1055 Any aType = xColumnProps->getPropertyValue("Type");
1056 aType >>= eDataType;
1057 }
1058 try
1059 {
1060 if( pEntry->bHasFormat )
1061 {
1062 SwTableBoxNumFormat aNumFormat(
1063 pEntry->bIsDBFormat ? static_cast<sal_uInt32>(pEntry->nDBNumFormat)
1064 : pEntry->nUsrNumFormat );
1065 aTableSet.Put(aNumFormat);
1066 if( xColumn.is() )
1067 {
1068 double fVal = xColumn->getDouble();
1069 if( xColumn->wasNull() )
1070 aTableSet.ClearItem( RES_BOXATR_VALUE );
1071 else
1072 {
1073 if(rNumFormatr.GetType(aNumFormat.GetValue()) & SvNumFormatType::DATE)
1074 {
1075 ::Date aStandard(1,1,1900);
1076 if (rNumFormatr.GetNullDate() != aStandard)
1077 fVal += (aStandard - rNumFormatr.GetNullDate());
1078 }
1079 aTableSet.Put( SwTableBoxValue( fVal ));
1080 }
1081 }
1082 else
1083 aTableSet.ClearItem( RES_BOXATR_VALUE );
1084 rSh.SetTableBoxFormulaAttrs( aTableSet );
1085 }
1086 //#i60207# don't insert binary data as string - creates a loop
1087 else if( DataType::BINARY == eDataType ||
1088 DataType::VARBINARY == eDataType ||
1089 DataType::LONGVARBINARY== eDataType ||
1090 DataType::SQLNULL == eDataType ||
1091 DataType::OTHER == eDataType ||
1092 DataType::OBJECT == eDataType ||
1093 DataType::DISTINCT == eDataType ||
1094 DataType::STRUCT == eDataType ||
1095 DataType::ARRAY == eDataType ||
1096 DataType::BLOB == eDataType ||
1097 DataType::CLOB == eDataType ||
1098 DataType::REF == eDataType
1099 )
1100 {
1101 // do nothing
1102 }
1103 else
1104 {
1105 const OUString sVal = xColumn->getString();
1106 if(!xColumn->wasNull())
1107 {
1108 rSh.SwEditShell::Insert2( sVal );
1109 }
1110 }
1111 }
1112 catch (const Exception&)
1113 {
1114 TOOLS_WARN_EXCEPTION("sw", "");
1115 }
1116 }
1117
1118 if( !pSelection )
1119 {
1120 if ( !xResultSet->next() )
1121 break;
1122 }
1123 else if( i+1 >= rSelection.getLength() )
1124 break;
1125
1126 if( 10 == i )
1127 oWait.emplace( *m_pView->GetDocShell(), true );
1128 }
1129
1131 if( !pSelection && ( m_pTableSet || m_xTAutoFormat ))
1132 {
1133 if( m_pTableSet )
1134 SetTabSet();
1135
1136 if (m_xTAutoFormat)
1138 }
1139 rSh.SetAutoUpdateCells( bIsAutoUpdateCells );
1140 }
1141 else // add data as fields/text
1142 {
1143 DB_Columns aColArr;
1144 if( SplitTextToColArr( m_xEdDbText->get_text(), aColArr, m_xRbAsField->get_active() ) )
1145 {
1146 // now for each data set, we can iterate over the array
1147 // and add the data
1148
1149 if( !rSh.IsSttPara() )
1150 rSh.SwEditShell::SplitNode();
1151 if( !rSh.IsEndPara() )
1152 {
1153 rSh.SwEditShell::SplitNode();
1154 rSh.SwCursorShell::Left(1,SwCursorSkipMode::Chars);
1155 }
1156
1157 rSh.DoUndo( false );
1158
1159 SwTextFormatColl* pColl = nullptr;
1160 {
1161 const OUString sTmplNm(m_xLbDbParaColl->get_active_text());
1162 if( m_sNoTmpl != sTmplNm )
1163 {
1164 pColl = rSh.FindTextFormatCollByName( sTmplNm );
1165 if( !pColl )
1166 {
1169 if( USHRT_MAX != nId )
1170 pColl = rSh.GetTextCollFromPool( nId );
1171 else
1172 pColl = rSh.MakeTextFormatColl( sTmplNm );
1173 }
1174 rSh.SetTextFormatColl( pColl );
1175 }
1176 }
1177
1178 // for adding as fields -> insert a "NextField" after
1179 // every data set
1180 SwDBFormatData aDBFormatData;
1181 Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
1182 aDBFormatData.xFormatter.set(util::NumberFormatter::create(xContext), UNO_QUERY_THROW) ;
1183
1184 Reference<XPropertySet> xSourceProps(xSource, UNO_QUERY);
1185 if(xSourceProps.is())
1186 {
1187 Any aFormats = xSourceProps->getPropertyValue("NumberFormatsSupplier");
1188 if(aFormats.hasValue())
1189 {
1190 Reference< util::XNumberFormatsSupplier> xSuppl;
1191 aFormats >>= xSuppl;
1192 if(xSuppl.is())
1193 {
1194 Reference< XPropertySet > xSettings = xSuppl->getNumberFormatSettings();
1195 Any aNull = xSettings->getPropertyValue("NullDate");
1196 aNull >>= aDBFormatData.aNullDate;
1197 if(aDBFormatData.xFormatter.is())
1198 aDBFormatData.xFormatter->attachNumberFormatsSupplier(xSuppl);
1199 }
1200 }
1201 }
1202 aDBFormatData.aLocale = LanguageTag( rSh.GetCurLang() ).getLocale();
1203 SwDBNextSetField aNxtDBField( static_cast<SwDBNextSetFieldType*>(rSh.
1204 GetFieldType( 0, SwFieldIds::DbNextSet )),
1205 "1", m_aDBData );
1206
1207 bool bSetCursor = true;
1208 const size_t nCols = aColArr.size();
1209 ::sw::mark::IMark* pMark = nullptr;
1210 for( sal_Int32 i = 0 ; ; ++i )
1211 {
1212 bool bBreak = false;
1213 try
1214 {
1215 if(pSelection)
1216 {
1217 bBreak = !xRowLocate->moveToBookmark(pSelection[i]);
1218 }
1219 else if(!i)
1220 bBreak = !xResultSet->first();
1221 }
1222 catch (const Exception&)
1223 {
1224 bBreak = true;
1225 }
1226
1227 if(bBreak)
1228 break;
1229
1230 for( size_t n = 0; n < nCols; ++n )
1231 {
1232 DB_Column* pDBCol = aColArr[ n ].get();
1233 OUString sIns;
1234 switch( pDBCol->eColType )
1235 {
1237 sIns = *pDBCol->pText;
1238 break;
1239
1241 rSh.SplitNode();
1242 // when the template is not the same as the follow template,
1243 // the selected has to be set newly
1244 if( pColl && &pColl->GetNextTextFormatColl() != pColl )
1245 rSh.SetTextFormatColl( pColl );
1246 break;
1247
1249 {
1250 std::unique_ptr<SwDBField> pField(static_cast<SwDBField *>(
1251 pDBCol->pField->CopyField().release()));
1252 double nValue = DBL_MAX;
1253
1254 Reference< XPropertySet > xColumnProps;
1255 xCols->getByName(pDBCol->pColInfo->sColumn) >>= xColumnProps;
1256
1257 pField->SetExpansion( SwDBManager::GetDBField(
1258 xColumnProps,
1259 aDBFormatData,
1260 &nValue ) );
1261 if( DBL_MAX != nValue )
1262 {
1263 Any aType = xColumnProps->getPropertyValue("Type");
1264 sal_Int32 eDataType = 0;
1265 aType >>= eDataType;
1266 if( DataType::DATE == eDataType || DataType::TIME == eDataType ||
1267 DataType::TIMESTAMP == eDataType)
1268
1269 {
1270 ::Date aStandard(1,1,1900);
1271 ::Date aCompare(aDBFormatData.aNullDate.Day ,
1272 aDBFormatData.aNullDate.Month,
1273 aDBFormatData.aNullDate.Year);
1274 if(aStandard != aCompare)
1275 nValue += (aStandard - aCompare);
1276 }
1277 pField->ChgValue( nValue, true );
1278 }
1279 pField->SetInitialized();
1280
1281 rSh.InsertField2( *pField );
1282 }
1283 break;
1284
1286 {
1287 double nValue = DBL_MAX;
1288 Reference< XPropertySet > xColumnProps;
1289 xCols->getByName(pDBCol->pColInfo->sColumn) >>= xColumnProps;
1291 xColumnProps,
1292 aDBFormatData,
1293 &nValue );
1294 if( pDBCol->nFormat &&
1295 DBL_MAX != nValue )
1296 {
1297 const Color* pCol;
1298 if(rNumFormatr.GetType(pDBCol->nFormat) & SvNumFormatType::DATE)
1299 {
1300 ::Date aStandard(1,1,1900);
1301 if (rNumFormatr.GetNullDate() != aStandard)
1302 nValue += (aStandard - rNumFormatr.GetNullDate());
1303 }
1304 rNumFormatr.GetOutputString( nValue,
1305 pDBCol->nFormat,
1306 sIns, &pCol );
1307 }
1308 }
1309 break;
1310 }
1311
1312 if( !sIns.isEmpty() )
1313 {
1314 rSh.Insert( sIns );
1315
1316 if( bSetCursor)
1317 {
1318 // to the beginning and set a mark, so that
1319 // the cursor can be set to the initial position
1320 // at the end.
1321
1322 rSh.SwCursorShell::MovePara(
1324 pMark = rSh.SetBookmark(
1325 vcl::KeyCode(),
1326 OUString(),
1328 rSh.SwCursorShell::MovePara(
1330 bSetCursor = false;
1331 }
1332 }
1333 }
1334
1335 if( !pSelection )
1336 {
1337 bool bNext = xResultSet->next();
1338 if(!bNext)
1339 break;
1340 }
1341 else if( i+1 >= rSelection.getLength() )
1342 break;
1343
1344 if( m_xRbAsField->get_active() )
1345 rSh.InsertField2( aNxtDBField );
1346
1347 if( !rSh.IsSttPara() )
1348 rSh.SwEditShell::SplitNode();
1349
1350 if( 10 == i )
1351 oWait.emplace( *m_pView->GetDocShell(), true );
1352 }
1353
1354 if( !bSetCursor && pMark != nullptr)
1355 {
1356 rSh.SetMark();
1357 rSh.GotoMark( pMark );
1358 rSh.getIDocumentMarkAccess()->deleteMark( pMark );
1359 break;
1360 }
1361 }
1362 }
1363 // write configuration
1364 Commit();
1365 }while( false ); // middle checked loop
1366
1367 if( bUndo )
1368 {
1369 rSh.DoUndo();
1370 rSh.AppendUndoForInsertFromDB( bAsTable );
1371 rSh.EndUndo();
1372 }
1373 rSh.ClearMark();
1374 rSh.EndAllAction();
1375
1376 if ( bDisposeResultSet )
1377 ::comphelper::disposeComponent(xResultSet);
1378}
1379
1381{
1382 SwWrtShell& rSh = m_pView->GetWrtShell();
1383 const SfxPoolItem* pItem;
1384
1385 if (m_xTAutoFormat)
1386 {
1387 if (m_xTAutoFormat->IsFrame())
1388 {
1389 // border is from AutoFormat
1390 m_pTableSet->ClearItem( RES_BOX );
1391 m_pTableSet->ClearItem( SID_ATTR_BORDER_INNER );
1392 }
1393 if (m_xTAutoFormat->IsBackground())
1394 {
1395 m_pTableSet->ClearItem( RES_BACKGROUND );
1396 m_pTableSet->ClearItem( SID_ATTR_BRUSH_ROW );
1397 m_pTableSet->ClearItem( SID_ATTR_BRUSH_TABLE );
1398 }
1399 }
1400 else
1401 {
1402 // remove the defaults again, it makes no sense to set them
1403 SvxBrushItem aBrush( RES_BACKGROUND );
1404 static const sal_uInt16 aIds[3] =
1405 { RES_BACKGROUND, SID_ATTR_BRUSH_ROW, SID_ATTR_BRUSH_TABLE };
1406 for(sal_uInt16 i : aIds)
1407 if( SfxItemState::SET == m_pTableSet->GetItemState( i,
1408 false, &pItem ) && *pItem == aBrush )
1409 m_pTableSet->ClearItem( i );
1410 }
1411
1412 const SfxStringItem* pTableNameItem = m_pTableSet->GetItemIfSet( FN_PARAM_TABLE_NAME, false);
1413 if( pTableNameItem && pTableNameItem->GetValue() == rSh.GetTableFormat()->GetName() )
1414 m_pTableSet->ClearItem( FN_PARAM_TABLE_NAME );
1415
1417 rSh.SetMark();
1419
1421
1422 rSh.ClearMark();
1424}
1425
1426static Sequence<OUString> lcl_createSourceNames(std::u16string_view rNodeName)
1427{
1428 Sequence<OUString> aSourceNames(11);
1429 OUString* pNames = aSourceNames.getArray();
1430 pNames[0] = OUString::Concat(rNodeName) + "/DataSource";
1431 pNames[1] = OUString::Concat(rNodeName) + "/Command";
1432 pNames[2] = OUString::Concat(rNodeName) + "/CommandType";
1433 pNames[3] = OUString::Concat(rNodeName) + "/ColumnsToText";
1434 pNames[4] = OUString::Concat(rNodeName) + "/ColumnsToTable";
1435 pNames[5] = OUString::Concat(rNodeName) + "/ParaStyle";
1436 pNames[6] = OUString::Concat(rNodeName) + "/TableAutoFormat";
1437 pNames[7] = OUString::Concat(rNodeName) + "/IsTable";
1438 pNames[8] = OUString::Concat(rNodeName) + "/IsField";
1439 pNames[9] = OUString::Concat(rNodeName) + "/IsHeadlineOn";
1440 pNames[10] = OUString::Concat(rNodeName) + "/IsEmptyHeadline";
1441 return aSourceNames;
1442}
1443
1444static Sequence<OUString> lcl_CreateSubNames(std::u16string_view rSubNodeName)
1445{
1446 return
1447 {
1448 OUString::Concat(rSubNodeName) + "/ColumnName",
1449 OUString::Concat(rSubNodeName) + "/ColumnIndex",
1450 OUString::Concat(rSubNodeName) + "/IsNumberFormat",
1451 OUString::Concat(rSubNodeName) + "/IsNumberFormatFromDataBase",
1452 OUString::Concat(rSubNodeName) + "/NumberFormat",
1453 OUString::Concat(rSubNodeName) + "/NumberFormatLocale"
1454 };
1455}
1456
1457static OUString lcl_CreateUniqueName(const Sequence<OUString>& aNames)
1458{
1459 sal_Int32 nIdx = aNames.getLength();
1460 while(true)
1461 {
1462 const OUString sRet = "_" + OUString::number(nIdx++);
1463 if ( comphelper::findValue(aNames, sRet) == -1 )
1464 return sRet; // No match found, return unique name
1465 }
1466}
1467
1468void SwInsertDBColAutoPilot::Notify( const css::uno::Sequence< OUString >& ) {}
1469
1471{
1472 Sequence <OUString> aNames = GetNodeNames(OUString());
1473 //remove entries that contain this data source + table at first
1474 for(OUString const & nodeName : std::as_const(aNames))
1475 {
1476 Sequence<Any> aSourceProperties = GetProperties({ nodeName + "/DataSource", nodeName + "/Command" });
1477 const Any* pSourceProps = aSourceProperties.getArray();
1478 OUString sSource, sCommand;
1479 pSourceProps[0] >>= sSource;
1480 pSourceProps[1] >>= sCommand;
1481 if(sSource==m_aDBData.sDataSource && sCommand==m_aDBData.sCommand)
1482 {
1483 ClearNodeElements(OUString(), { nodeName });
1484 }
1485 }
1486
1487 aNames = GetNodeNames(OUString());
1488 OUString sNewNode = lcl_CreateUniqueName(aNames);
1489 Sequence<OUString> aNodeNames = lcl_createSourceNames(sNewNode);
1490 Sequence<PropertyValue> aValues(aNodeNames.getLength());
1491 PropertyValue* pValues = aValues.getArray();
1492 const OUString* pNodeNames = aNodeNames.getConstArray();
1493 for(sal_Int32 i = 0; i < aNodeNames.getLength(); i++)
1494 {
1495 pValues[i].Name = "/" + pNodeNames[i];
1496 }
1497
1498 pValues[0].Value <<= m_aDBData.sDataSource;
1499 pValues[1].Value <<= m_aDBData.sCommand;
1500 pValues[2].Value <<= m_aDBData.nCommandType;
1501 pValues[3].Value <<= m_xEdDbText->get_text();
1502
1503 OUString sTmp;
1504 const sal_Int32 nCnt = m_xLbTableCol->n_children();
1505 for( sal_Int32 n = 0; n < nCnt; ++n )
1506 sTmp += m_xLbTableCol->get_text(n) + "\x0a";
1507
1508 if (!sTmp.isEmpty())
1509 pValues[4].Value <<= sTmp;
1510
1511 if( m_sNoTmpl != (sTmp = m_xLbDbParaColl->get_active_text()) )
1512 pValues[5].Value <<= sTmp;
1513
1514 if (m_xTAutoFormat)
1515 pValues[6].Value <<= m_xTAutoFormat->GetName();
1516
1517 pValues[7].Value <<= m_xRbAsTable->get_active();
1518 pValues[8].Value <<= m_xRbAsField->get_active();
1519 pValues[9].Value <<= m_xCbTableHeadon->get_active();
1520 pValues[10].Value <<= m_xRbHeadlEmpty->get_active();
1521
1522 SetSetProperties(OUString(), aValues);
1523
1524 sNewNode += "/ColumnSet";
1525
1526 LanguageType ePrevLang(0xffff);
1527
1529 for(size_t nCol = 0; nCol < m_aDBColumns.size(); nCol++)
1530 {
1531 SwInsDBColumn* pColumn = m_aDBColumns[nCol].get();
1532 OUString sColumnInsertNode(sNewNode + "/__");
1533 if( nCol < 10 )
1534 sColumnInsertNode += "00";
1535 else if( nCol < 100 )
1536 sColumnInsertNode += "0";
1537 sColumnInsertNode += OUString::number( nCol );
1538
1539 const Sequence <OUString> aSubNodeNames = lcl_CreateSubNames(sColumnInsertNode);
1540 Sequence<PropertyValue> aSubValues(aSubNodeNames.getLength());
1541 PropertyValue* pSubValues = aSubValues.getArray();
1542 sal_Int32 i = 0;
1543
1544 for( const OUString& rSubNodeName : aSubNodeNames)
1545 pSubValues[i++].Name = rSubNodeName;
1546 pSubValues[0].Value <<= pColumn->sColumn;
1547 pSubValues[1].Value <<= i;
1548 pSubValues[2].Value <<= pColumn->bHasFormat;
1549 pSubValues[3].Value <<= pColumn->bIsDBFormat;
1550
1552 const SvNumberformat* pNF = rNFormatr.GetEntry( pColumn->nUsrNumFormat );
1553 LanguageType eLang;
1554 if( pNF )
1555 {
1556 pSubValues[4].Value <<= pNF->GetFormatstring();
1557 eLang = pNF->GetLanguage();
1558 }
1559 else
1560 {
1561 pSubValues[4].Value <<= sTmp;
1562 eLang = GetAppLanguage();
1563 }
1564
1565 OUString sPrevLang;
1566 if( eLang != ePrevLang )
1567 {
1568 sPrevLang = LanguageTag::convertToBcp47( eLang );
1569 ePrevLang = eLang;
1570 }
1571
1572 pSubValues[5].Value <<= sPrevLang;
1573 SetSetProperties(sNewNode, aSubValues);
1574 }
1575}
1576
1578{
1579 const Sequence<OUString> aNames = GetNodeNames(OUString());
1581 for(OUString const & nodeName : aNames)
1582 {
1583 //search for entries with the appropriate data source and table
1584 Sequence<OUString> aSourceNames = lcl_createSourceNames(nodeName);
1585
1586 Sequence< Any> aDataSourceProps = GetProperties(aSourceNames);
1587 const Any* pDataSourceProps = aDataSourceProps.getConstArray();
1588 OUString sSource, sCommand;
1589 sal_Int16 nCommandType;
1590 pDataSourceProps[0] >>= sSource;
1591 pDataSourceProps[1] >>= sCommand;
1592 pDataSourceProps[2] >>= nCommandType;
1593 if(sSource == m_aDBData.sDataSource && sCommand == m_aDBData.sCommand)
1594 {
1595 DB_ColumnConfigData aNewData;
1596
1597 pDataSourceProps[3] >>= aNewData.sEdit;
1598 pDataSourceProps[4] >>= aNewData.sTableList;
1599 pDataSourceProps[5] >>= aNewData.sTmplNm;
1600 pDataSourceProps[6] >>= aNewData.sTAutoFormatNm;
1601 if(pDataSourceProps[7].hasValue())
1602 aNewData.bIsTable = *o3tl::doAccess<bool>(pDataSourceProps[7]);
1603 if(pDataSourceProps[8].hasValue())
1604 aNewData.bIsField = *o3tl::doAccess<bool>(pDataSourceProps[8]);
1605 if(pDataSourceProps[9].hasValue())
1606 aNewData.bIsHeadlineOn = *o3tl::doAccess<bool>(pDataSourceProps[9]);
1607 if(pDataSourceProps[10].hasValue())
1608 aNewData.bIsEmptyHeadln = *o3tl::doAccess<bool>(pDataSourceProps[10]);
1609
1610 const OUString sSubNodeName(nodeName + "/ColumnSet/");
1611 const Sequence <OUString> aSubNames = GetNodeNames(sSubNodeName);
1612 for(const OUString& rSubName : aSubNames)
1613 {
1614 Sequence <OUString> aSubNodeNames =
1615 lcl_CreateSubNames(Concat2View(sSubNodeName + rSubName));
1616 Sequence< Any> aSubProps = GetProperties(aSubNodeNames);
1617 const Any* pSubProps = aSubProps.getConstArray();
1618
1619 OUString sColumn;
1620 pSubProps[0] >>= sColumn;
1621 // check for existence of the loaded column name
1622 bool bFound = false;
1623 for(size_t nRealColumn = 0; nRealColumn < m_aDBColumns.size(); ++nRealColumn)
1624 {
1625 if(m_aDBColumns[nRealColumn]->sColumn == sColumn)
1626 {
1627 bFound = true;
1628 break;
1629 }
1630 }
1631 if(!bFound)
1632 continue;
1633 sal_Int16 nIndex = 0;
1634 pSubProps[1] >>= nIndex;
1635 std::unique_ptr<SwInsDBColumn> pInsDBColumn(new SwInsDBColumn(sColumn));
1636 if(pSubProps[2].hasValue())
1637 pInsDBColumn->bHasFormat = *o3tl::doAccess<bool>(pSubProps[2]);
1638 if(pSubProps[3].hasValue())
1639 pInsDBColumn->bIsDBFormat = *o3tl::doAccess<bool>(pSubProps[3]);
1640
1641 pSubProps[4] >>= pInsDBColumn->sUsrNumFormat;
1642 OUString sNumberFormatLocale;
1643 pSubProps[5] >>= sNumberFormatLocale;
1644
1645 /* XXX Earlier versions wrote a Country-Language string in
1646 * SwInsertDBColAutoPilot::Commit() that here was read as
1647 * Language-Country with 2 characters copied to language,
1648 * 1 character separator and unconditionally 2 characters read
1649 * as country. So for 'DE-de' and locales that have similar
1650 * case-insensitive equal language/country combos that may have
1651 * worked, for all others not. FIXME if you need to read old
1652 * data that you were never able to read before. */
1653 pInsDBColumn->eUsrNumFormatLng = LanguageTag::convertToLanguageType( sNumberFormatLocale );
1654
1655 pInsDBColumn->nUsrNumFormat = rNFormatr.GetEntryKey( pInsDBColumn->sUsrNumFormat,
1656 pInsDBColumn->eUsrNumFormatLng );
1657
1658 aNewData.aDBColumns.insert(std::move(pInsDBColumn));
1659 }
1660 OUString sTmp( aNewData.sTableList );
1661 if( !sTmp.isEmpty() )
1662 {
1663 sal_Int32 n = 0;
1664 do {
1665 const OUString sEntry( sTmp.getToken( 0, '\x0a', n ) );
1666 //preselect column - if they still exist!
1667 if (m_xLbTableDbColumn->find_text(sEntry) != -1)
1668 {
1669 m_xLbTableCol->append_text(sEntry);
1670 m_xLbTableDbColumn->remove_text(sEntry);
1671 }
1672 } while( n>=0 );
1673
1674 if (!m_xLbTableDbColumn->n_children())
1675 {
1676 m_xIbDbcolAllTo->set_sensitive( false );
1677 m_xIbDbcolOneTo->set_sensitive( false );
1678 }
1679 m_xIbDbcolOneFrom->set_sensitive(true);
1680 m_xIbDbcolAllFrom->set_sensitive(true);
1681 }
1682 m_xEdDbText->set_text( aNewData.sEdit );
1683
1684 sTmp = aNewData.sTmplNm;
1685 if( !sTmp.isEmpty() )
1686 m_xLbDbParaColl->set_active_text(sTmp);
1687 else
1688 m_xLbDbParaColl->set_active(0);
1689
1690 m_xTAutoFormat.reset();
1691 sTmp = aNewData.sTAutoFormatNm;
1692 if( !sTmp.isEmpty() )
1693 {
1694 // then load the AutoFormat file and look for Autoformat first
1695 SwTableAutoFormatTable aAutoFormatTable;
1696 aAutoFormatTable.Load();
1697 for( size_t nAutoFormat = aAutoFormatTable.size(); nAutoFormat; )
1698 if( sTmp == aAutoFormatTable[ --nAutoFormat ].GetName() )
1699 {
1700 m_xTAutoFormat.reset(new SwTableAutoFormat(aAutoFormatTable[nAutoFormat]));
1701 break;
1702 }
1703 }
1704
1705 m_xRbAsTable->set_active( aNewData.bIsTable );
1706 m_xRbAsField->set_active( aNewData.bIsField );
1707 m_xRbAsText->set_active( !aNewData.bIsTable && !aNewData.bIsField );
1708
1709 m_xCbTableHeadon->set_active( aNewData.bIsHeadlineOn );
1710 m_xRbHeadlColnms->set_active( !aNewData.bIsEmptyHeadln );
1711 m_xRbHeadlEmpty->set_active( aNewData.bIsEmptyHeadln );
1712 HeaderHdl(*m_xCbTableHeadon);
1713
1714 // now copy the user defined Numberformat strings to the
1715 // Shell. Then only these are available as ID
1716 for( size_t n = 0; n < m_aDBColumns.size() ; ++n )
1717 {
1719 for( size_t m = 0; m < aNewData.aDBColumns.size() ; ++m )
1720 {
1721 SwInsDBColumn& rGet = *aNewData.aDBColumns[ m ];
1722 if(rGet.sColumn == rSet.sColumn)
1723 {
1724 if( rGet.bHasFormat && !rGet.bIsDBFormat )
1725 {
1726 rSet.bIsDBFormat = false;
1727 rSet.nUsrNumFormat = rNFormatr.GetEntryKey( rGet.sUsrNumFormat,
1728 rGet.eUsrNumFormatLng );
1729 if( NUMBERFORMAT_ENTRY_NOT_FOUND == rSet.nUsrNumFormat )
1730 {
1731 sal_Int32 nCheckPos;
1733 rNFormatr.PutEntry( rGet.sUsrNumFormat, nCheckPos, nType,
1734 rSet.nUsrNumFormat, rGet.eUsrNumFormatLng );
1735 }
1736 }
1737 break;
1738 }
1739 }
1740 }
1741
1742 // when the cursor is inside of a table, table must NEVER be selectable
1743 if( !m_xRbAsTable->get_sensitive() && m_xRbAsTable->get_active() )
1744 m_xRbAsField->set_active(true);
1745 break;
1746 }
1747 }
1748}
1749
1750/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const PropertyValue * pValues
Reference< XExecutableDialog > m_xDialog
sal_uInt32 GetValue() const
const OUString & GetValue() const
sal_Int32 compareString(const OUString &s1, const OUString &s2) const
virtual std::unique_ptr< ILazyDeleter > deleteMark(const IDocumentMarkAccess::const_iterator_t &ppMark, bool isMoveNodes)=0
Deletes a mark.
const css::lang::Locale & getLocale(bool bResolveSystem=true) const
static OUString convertToBcp47(LanguageType nLangID)
static LanguageType convertToLanguageType(const css::lang::Locale &rLocale, bool bResolveSystem=true)
static OUString EraseAllMnemonicChars(const OUString &rStr)
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
SfxStyleSheetBase * First(SfxStyleFamily eFamily, SfxStyleSearchBits eMask=SfxStyleSearchBits::All)
SfxStyleSheetBase * Next()
const OUString & GetName() const
bool PutEntry(OUString &rString, sal_Int32 &nCheckPos, SvNumFormatType &nType, sal_uInt32 &nKey, LanguageType eLnge=LANGUAGE_DONTKNOW, bool bReplaceBooleanEquivalent=true)
void GetOutputString(const double &fOutNumber, sal_uInt32 nFIndex, OUString &sOutString, const Color **ppColor, bool bUseStarFormat=false)
sal_uInt32 GetEntryKey(std::u16string_view sStr, LanguageType eLnge=LANGUAGE_DONTKNOW)
const Date & GetNullDate() const
SvNumFormatType GetType(sal_uInt32 nFIndex) const
const SvNumberformat * GetEntry(sal_uInt32 nKey) const
LanguageType GetLanguage() const
const OUString & GetFormatstring() const
void SetTable(bool bNew)
void SetDist(bool bNew)
void SetMinDist(bool bNew)
void SetDefDist(sal_uInt16 nNew)
void SetValid(SvxBoxInfoItemValidFlags nValid, bool bValid=true)
virtual VclPtr< SfxAbstractTabDialog > CreateSwTableTabDlg(weld::Window *pParent, const SfxItemSet *pItemSet, SwWrtShell *pSh)=0
virtual VclPtr< AbstractSwAutoFormatDlg > CreateSwAutoFormatDlg(weld::Window *pParent, SwWrtShell *pShell, bool bSetAutoFormat=true, const SwTableAutoFormat *pSelFormat=nullptr)=0
ColumnDescriptor.
Definition: fmtclds.hxx:34
sal_uInt16 GetLeft() const
Definition: fmtclds.hxx:51
sal_uInt16 GetRight() const
Definition: fmtclds.hxx:52
void SetAutoUpdateCells(bool bFlag)
Definition: crsrsh.hxx:829
::sw::mark::IMark * SetBookmark(const vcl::KeyCode &, const OUString &rName, IDocumentMarkAccess::MarkType eMark=IDocumentMarkAccess::MarkType::BOOKMARK)
Definition: crbm.cxx:78
bool IsEndPara() const
Definition: crsrsh.cxx:1114
bool MoveTable(SwWhichTable, SwMoveFnCollection const &)
Definition: trvltbl.cxx:679
bool IsSttPara() const
Definition: crsrsh.cxx:1095
void ClearMark()
Definition: crsrsh.cxx:939
void SetMark()
Definition: crsrsh.hxx:895
bool IsAutoUpdateCells() const
Definition: crsrsh.hxx:828
bool GoNextCell(bool bAppendLine=true)
set cursor into next/previous cell
Definition: trvltbl.cxx:39
static OUString GetDBField(css::uno::Reference< css::beans::XPropertySet > const &xColumnProp, const SwDBFormatData &rDBFormatData, double *pNumber=nullptr)
Definition: dbmgr.cxx:1949
static css::uno::Reference< css::sdbc::XResultSet > createCursor(const OUString &_sDataSourceName, const OUString &_sCommand, sal_Int32 _nCommandType, const css::uno::Reference< css::sdbc::XConnection > &_xConnection, const SwView *pView)
creates a RowSet, which must be disposed after use.
Definition: dbmgr.cxx:3108
virtual SfxStyleSheetBasePool * GetStyleSheetPool() override
For Style PI.
Definition: docsh.cxx:1154
void StartAllAction()
For all views of this document.
Definition: edws.cxx:86
const SwTable & InsertTable(const SwInsertTableOptions &rInsTableOpts, sal_uInt16 nRows, sal_uInt16 nCols, const SwTableAutoFormat *pTAFormat=nullptr)
Inserts an nRows x nCols table to the document at the current position.
Definition: edtab.cxx:101
SwUndoId StartUndo(SwUndoId eUndoId=SwUndoId::EMPTY, const SwRewriter *pRewriter=nullptr)
Undo: set up Undo parenthesis, return nUndoId of this parenthesis.
Definition: edws.cxx:223
SwFrameFormat * GetTableFormat()
Definition: edws.cxx:183
SvNumberFormatter * GetNumberFormatter()
Query NumberFormatter from document.
Definition: editsh.cxx:756
void SetTextFormatColl(SwTextFormatColl *, const bool bResetListAttrs=false)
Add 2nd optional parameter <bResetListAttrs> - see also <SwDoc::SetTextFormatColl(....
Definition: edfcol.cxx:2189
void SetTableBoxFormulaAttrs(const SfxItemSet &rSet)
Definition: edtab.cxx:342
void AppendUndoForInsertFromDB(bool bIsTable)
Set up InsertDB as table Undo.
Definition: edtab.cxx:524
SwTextFormatColl * FindTextFormatCollByName(const OUString &rName) const
Definition: edfmt.cxx:152
SwTextFormatColl * GetTextCollFromPool(sal_uInt16 nId)
Definition: edfmt.cxx:121
SwFieldType * InsertFieldType(const SwFieldType &)
insert field type
Definition: edfld.cxx:338
bool DoesUndo() const
Definition: edws.cxx:203
SwUndoId EndUndo(SwUndoId eUndoId=SwUndoId::EMPTY, const SwRewriter *pRewriter=nullptr)
Closes parenthesis of nUndoId, not used by UI.
Definition: edws.cxx:234
void DoUndo(bool bOn=true)
Undo.
Definition: edws.cxx:200
OUString GetUniqueTableName() const
Definition: edfmt.cxx:109
SwTextFormatColl * MakeTextFormatColl(const OUString &rFormatCollName, SwTextFormatColl *pDerivedFrom=nullptr)
Definition: edfcol.cxx:2258
void EndAllAction()
Definition: edws.cxx:97
LanguageType GetCurLang() const
Definition: edattr.cxx:801
sal_uInt16 GetCurColNum(SwGetCurColNumPara *pPara=nullptr) const
The ruler needs some information too.
Definition: fews.cxx:640
FrameTypeFlags GetFrameType(const Point *pPt, bool bStopAtFly) const
For return values see above FrameType.
Definition: fews.cxx:237
void SetTableStyle(const OUString &rStyleName)
Set table style of the current table.
Definition: fetab.cxx:1289
void SetRowsToRepeat(sal_uInt16 nNumOfRows)
Definition: fetab.cxx:1115
const SwRect & GetAnyCurRect(CurRectType eType, const Point *pPt=nullptr, const css::uno::Reference< css::embed::XEmbeddedObject > &=css::uno::Reference< css::embed::XEmbeddedObject >()) const
Definition: fews.cxx:90
Base class of all fields.
Definition: fldbas.hxx:292
std::unique_ptr< SwField > CopyField() const
Definition: fldbas.cxx:504
virtual void SetSubType(sal_uInt16)
Definition: fldbas.cxx:347
sal_uInt16 CalcColWidth(sal_uInt16 nCol, sal_uInt16 nAct) const
Calculates current width of column nCol.
Definition: atrfrm.cxx:991
const SwColumns & GetColumns() const
Definition: fmtclds.hxx:112
const OUString & GetName() const
Definition: format.hxx:131
const SwFormatCol & GetCol(bool=true) const
Definition: fmtclds.hxx:168
SwInsertDBColAutoPilot(SwView &rView, css::uno::Reference< css::sdbc::XDataSource > const &rxSource, css::uno::Reference< css::sdbcx::XColumnsSupplier > const &xColSupp, SwDBData aData)
Definition: dbinsdlg.cxx:173
virtual ~SwInsertDBColAutoPilot() override
Definition: dbinsdlg.cxx:388
std::unique_ptr< SfxItemSet > m_pTableSet
Definition: dbinsdlg.hxx:90
SwInsDBColumns m_aDBColumns
Definition: dbinsdlg.hxx:82
std::unique_ptr< weld::RadioButton > m_xRbHeadlColnms
Definition: dbinsdlg.hxx:122
std::unique_ptr< weld::CheckButton > m_xCbTableHeadon
Definition: dbinsdlg.hxx:121
const SwDBData m_aDBData
Definition: dbinsdlg.hxx:83
bool SplitTextToColArr(const OUString &rText, DB_Columns &rColArr, bool bInsField)
Definition: dbinsdlg.cxx:833
std::unique_ptr< weld::Frame > m_xFormatFrame
Definition: dbinsdlg.hxx:103
std::unique_ptr< weld::Button > m_xIbDbcolToEdit
Definition: dbinsdlg.hxx:109
std::unique_ptr< weld::RadioButton > m_xRbAsTable
Definition: dbinsdlg.hxx:94
std::unique_ptr< weld::RadioButton > m_xRbAsField
Definition: dbinsdlg.hxx:95
std::unique_ptr< weld::Frame > m_xHeadFrame
Definition: dbinsdlg.hxx:98
sal_Int32 m_nGBFormatLen
Definition: dbinsdlg.hxx:92
void DataToDoc(const css::uno::Sequence< css::uno::Any > &rSelection, css::uno::Reference< css::sdbc::XDataSource > const &rxSource, css::uno::Reference< css::sdbc::XConnection > const &xConnection, css::uno::Reference< css::sdbc::XResultSet > const &xResultSet)
Definition: dbinsdlg.cxx:910
std::unique_ptr< weld::TextView > m_xEdDbText
Definition: dbinsdlg.hxx:110
std::unique_ptr< weld::RadioButton > m_xRbDbFormatFromDb
Definition: dbinsdlg.hxx:104
std::unique_ptr< weld::TreeView > m_xLbTextDbColumn
Definition: dbinsdlg.hxx:101
std::unique_ptr< weld::TreeView > m_xLbTableCol
Definition: dbinsdlg.hxx:120
std::unique_ptr< weld::Button > m_xIbDbcolAllFrom
Definition: dbinsdlg.hxx:118
std::unique_ptr< weld::Button > m_xIbDbcolAllTo
Definition: dbinsdlg.hxx:115
std::unique_ptr< weld::RadioButton > m_xRbHeadlEmpty
Definition: dbinsdlg.hxx:123
std::unique_ptr< weld::Button > m_xPbTableFormat
Definition: dbinsdlg.hxx:124
std::unique_ptr< weld::ComboBox > m_xLbDbParaColl
Definition: dbinsdlg.hxx:112
virtual void Notify(const css::uno::Sequence< OUString > &aPropertyNames) override
Definition: dbinsdlg.cxx:1468
std::unique_ptr< NumFormatListBox > m_xLbDbFormatFromUsr
Definition: dbinsdlg.hxx:106
std::unique_ptr< SwTableAutoFormat > m_xTAutoFormat
Definition: dbinsdlg.hxx:88
std::unique_ptr< weld::Button > m_xIbDbcolOneTo
Definition: dbinsdlg.hxx:116
std::unique_ptr< weld::RadioButton > m_xRbAsText
Definition: dbinsdlg.hxx:96
std::unique_ptr< weld::TreeView > m_xLbTableDbColumn
Definition: dbinsdlg.hxx:100
std::unique_ptr< weld::Button > m_xPbTableAutofmt
Definition: dbinsdlg.hxx:125
virtual void ImplCommit() override
Definition: dbinsdlg.cxx:1470
std::unique_ptr< weld::RadioButton > m_xRbDbFormatFromUsr
Definition: dbinsdlg.hxx:105
std::unique_ptr< weld::Button > m_xIbDbcolOneFrom
Definition: dbinsdlg.hxx:117
const SwInsertTableOptions & GetInsTableFlags(bool bHTML) const
Definition: modcfg.hxx:303
void Width(tools::Long nNew)
Definition: swrect.hxx:189
static SW_DLLPUBLIC sal_uInt16 GetPoolIdFromUIName(const OUString &rName, SwGetPoolIdFromName)
static void FillUIName(const OUString &rName, OUString &rFillName, SwGetPoolIdFromName)
void SetRight(tools::Long nNew)
Definition: tabcol.hxx:84
void SetRightMax(tools::Long nNew)
Definition: tabcol.hxx:85
void Insert(tools::Long nValue, bool bValue, size_t nPos)
Definition: tabcol.cxx:69
size_t size() const
Definition: tblafmt.cxx:917
SAL_DLLPRIVATE bool Load(SvStream &rStream)
Definition: tblafmt.cxx:1048
Represents the style of a paragraph.
Definition: fmtcol.hxx:59
SwTextFormatColl & GetNextTextFormatColl() const
Definition: fmtcol.hxx:104
sal_uInt8 GetTableDest() const
Definition: viewopt.hxx:656
const SwViewOption * GetViewOptions() const
Definition: viewsh.hxx:433
const IDocumentMarkAccess * getIDocumentMarkAccess() const
Provides access to the document bookmark interface.
Definition: viewsh.cxx:2807
SwDoc * GetDoc() const
Definition: viewsh.hxx:290
const SfxItemPool & GetAttrPool() const
Definition: viewsh.hxx:624
Definition: view.hxx:146
SwWrtShell & GetWrtShell() const
Definition: view.hxx:416
SwDocShell * GetDocShell()
Definition: view.cxx:1160
Used by the UI to modify the document model.
Definition: wrtsh.hxx:97
void GotoMark(const ::sw::mark::IMark *const pMark)
Definition: wrtsh3.cxx:276
void Insert(const OUString &)
Definition: wrtsh1.cxx:224
void SplitNode(bool bAutoFormat=false)
Definition: wrtsh1.cxx:1297
bool DelRight(bool isReplaceHeuristic=false)
Definition: delete.cxx:291
bool HasSelection() const
Definition: wrtsh.hxx:147
bool InsertField2(SwField const &, SwPaM *pAnnotationRange=nullptr)
Definition: wrtsh2.cxx:63
const_iterator find(const Value &x) const
const_iterator end() const
size_type size() const
std::pair< const_iterator, bool > insert(Value &&x)
static bool SetSetProperties(css::uno::Reference< css::container::XHierarchicalNameAccess > const &xHierarchyAccess, const OUString &rNode, const css::uno::Sequence< css::beans::PropertyValue > &rValues)
static css::uno::Sequence< css::uno::Any > GetProperties(css::uno::Reference< css::container::XHierarchicalNameAccess > const &xHierarchyAccess, const css::uno::Sequence< OUString > &rNames, bool bAllLocales)
bool ClearNodeElements(const OUString &rNode, css::uno::Sequence< OUString > const &rElements)
static css::uno::Sequence< OUString > GetNodeNames(css::uno::Reference< css::container::XHierarchicalNameAccess > const &xHierarchyAccess, const OUString &rNode, ConfigNameFormat eFormat)
virtual OUString get_label() const=0
virtual void set_label(const OUString &rText)=0
virtual OUString get_selected_text() const=0
#define FN_PARAM_TABLE_NAME
Definition: cmdid.h:801
#define FN_PARAM_TABLE_HEADLINE
Definition: cmdid.h:802
#define FN_TABLE_REP
Definition: cmdid.h:362
ConfigItemMode
static OUString lcl_CreateUniqueName(const Sequence< OUString > &aNames)
Definition: dbinsdlg.cxx:1457
static Sequence< OUString > lcl_CreateSubNames(std::u16string_view rSubNodeName)
Definition: dbinsdlg.cxx:1444
static void lcl_InsTextInArr(std::u16string_view aText, DB_Columns &rColArr)
Definition: dbinsdlg.cxx:814
IMPL_LINK_NOARG(SwInsertDBColAutoPilot, TableFormatHdl, weld::Button &, void)
Definition: dbinsdlg.cxx:615
const char cDBFieldEnd
Definition: dbinsdlg.cxx:96
IMPL_LINK(SwInsertDBColAutoPilot, PageHdl, weld::Toggleable &, rButton, void)
Definition: dbinsdlg.cxx:392
static Sequence< OUString > lcl_createSourceNames(std::u16string_view rNodeName)
Definition: dbinsdlg.cxx:1426
const char cDBFieldStart
Definition: dbinsdlg.cxx:95
std::vector< std::unique_ptr< DB_Column > > DB_Columns
Definition: dbinsdlg.hxx:51
#define TOOLS_WARN_EXCEPTION(area, stream)
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
Definition: dialoghelp.cxx:19
virtual OUString GetName() const override
float u
@ FlyEmbeddedPrt
Rect of PrtArea of FlyFrame.
@ PagePrt
Rect of current PrtArea of page.
sal_Int16 nValue
std::vector< SwColumn > SwColumns
Definition: fmtclds.hxx:57
Reference< XColumn > xColumn
constexpr TypedWhichId< SwTableBoxValue > RES_BOXATR_VALUE(152)
constexpr TypedWhichId< SvxBoxItem > RES_BOX(106)
constexpr TypedWhichId< SvxBrushItem > RES_BACKGROUND(105)
HTMLMODE_ON
LanguageType GetAppLanguage()
Definition: init.cxx:725
CollatorWrapper & GetAppCollator()
Definition: init.cxx:737
sal_Int32 nIndex
sal_Int64 n
sal_uInt16 nPos
aStr
constexpr OUStringLiteral aData
Definition: ww8scan.hxx:48
@ Exception
sal_Int32 findValue(const css::uno::Sequence< T1 > &_rList, const T2 &_rValue)
sal_Int32 getDefaultNumberFormat(const Reference< XPropertySet > &_xColumn, const Reference< XNumberFormatTypes > &_xTypes, const Locale &_rLocale)
int i
m
const SwExtendedSubType SUB_OWN_FMT
SwDBField: Don't accept formatting from database.
Definition: fldbas.hxx:214
SwAbstractDialogFactory & GetFactory()
Definition: swuiexp.cxx:26
long Long
SwNodeOffset min(const SwNodeOffset &a, const SwNodeOffset &b)
Definition: nodeoffset.hxx:35
sal_Int16 nId
bool GoCurrPara(SwPaM &rPam, SwMoveFnCollection const &aPosPara)
Definition: pam.cxx:1224
SwMoveFnCollection const & fnParaStart
Definition: paminit.cxx:48
SwMoveFnCollection const & fnTableEnd
Definition: paminit.cxx:55
SwMoveFnCollection const & fnParaEnd
Definition: paminit.cxx:49
SwMoveFnCollection const & fnTableStart
Definition: paminit.cxx:54
@ RES_POOLCOLL_STANDARD
Standard.
Definition: poolfmt.hxx:250
QPRO_FUNC_TYPE nType
const Color aColNames[SC_RANGECOLORS]
static SfxItemSet & rSet
DB_Column(const SwInsDBColumn &rInfo, sal_uInt32 nFormat_)
Definition: dbinsdlg.cxx:121
sal_uInt32 nFormat
Definition: dbinsdlg.cxx:106
DB_Column(const OUString &rText)
Definition: dbinsdlg.cxx:115
OUString * pText
Definition: dbinsdlg.cxx:104
DB_Column(const SwInsDBColumn &rInfo, SwDBField &rField)
Definition: dbinsdlg.cxx:127
enum DB_Column::Type eColType
SwField * pField
Definition: dbinsdlg.cxx:105
const SwInsDBColumn * pColInfo
Definition: dbinsdlg.cxx:108
sal_Int32 nCommandType
Definition: swdbdata.hxx:32
OUString sDataSource
Definition: swdbdata.hxx:30
OUString sCommand
Definition: swdbdata.hxx:31
css::util::Date aNullDate
Definition: dbmgr.hxx:67
css::uno::Reference< css::util::XNumberFormatter > xFormatter
Definition: dbmgr.hxx:68
css::lang::Locale aLocale
Definition: dbmgr.hxx:69
const SwRect * pPrtRect
Definition: fesh.hxx:154
const SwFrameFormat * pFrameFormat
Definition: fesh.hxx:153
bool bHasFormat
Definition: dbinsdlg.hxx:61
sal_uInt32 nUsrNumFormat
Definition: dbinsdlg.hxx:59
sal_Int32 nDBNumFormat
Definition: dbinsdlg.hxx:58
bool operator<(const SwInsDBColumn &rCmp) const
Definition: dbinsdlg.cxx:168
OUString sUsrNumFormat
Definition: dbinsdlg.hxx:57
OUString sColumn
Definition: dbinsdlg.hxx:57
bool bIsDBFormat
Definition: dbinsdlg.hxx:62
LanguageType eUsrNumFormatLng
Definition: dbinsdlg.hxx:60
OUString SwResId(TranslateId aId)
Definition: swmodule.cxx:165
#define SW_MOD()
Definition: swmodule.hxx:256
constexpr SwTwips MIN_BORDER_DIST
Definition: swtypes.hxx:70
SW_DLLPUBLIC const WhichRangesContainer & SwuiGetUITableAttrRange()
Definition: tabsh.cxx:126
SW_DLLPUBLIC void ItemSetToTableParam(const SfxItemSet &rSet, SwWrtShell &rSh)
Definition: tabsh.cxx:272
bool GotoCurrTable(SwPaM &rCurrentCursor, SwMoveFnCollection const &fnPosTable, bool bInReadOnly)
Definition: trvltbl.cxx:631
bool GotoPrevTable(SwPaM &rCurrentCursor, SwMoveFnCollection const &fnPosTable, bool bInReadOnly)
Definition: trvltbl.cxx:481
sal_uInt16 sal_Unicode
RET_OK
sal_uInt16 GetHtmlMode(const SwDocShell *pShell)
Definition: viewopt.cxx:332
SvNumFormatType
constexpr sal_uInt32 NUMBERFORMAT_ENTRY_NOT_FOUND