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>
101 const enum class Type { FILLTEXT, COL_FIELD, COL_TEXT, SPLITPARA }
eColType;
117 pText(new OUString(rText)),
144struct DB_ColumnConfigData
150 OUString sTAutoFormatNm;
156 DB_ColumnConfigData(DB_ColumnConfigData
const&) =
delete;
157 DB_ColumnConfigData& operator=(DB_ColumnConfigData
const&) =
delete;
159 DB_ColumnConfigData()
161 bIsTable = bIsHeadlineOn =
true;
162 bIsField = bIsEmptyHeadln =
false;
174 Reference<XDataSource>
const & xDataSource,
175 Reference<sdbcx::XColumnsSupplier>
const & xColSupp,
180 , m_sNoTmpl(
SwResId(SW_STR_NONE))
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"))
218 Reference< util::XNumberFormats > xDocNumberFormats = pNumFormat->getNumberFormats();
219 Reference< util::XNumberFormatTypes > xDocNumberFormatTypes(xDocNumberFormats, UNO_QUERY);
221 Reference<XPropertySet> xSourceProps(xDataSource, UNO_QUERY);
222 Reference< util::XNumberFormats > xNumberFormats;
223 if(xSourceProps.is())
225 Any aFormats = xSourceProps->getPropertyValue(
"NumberFormatsSupplier");
226 if(aFormats.hasValue())
228 Reference< util::XNumberFormatsSupplier> xSuppl;
232 xNumberFormats = xSuppl->getNumberFormats( );
236 Reference <XNameAccess> xCols = xColSupp->getColumns();
237 const Sequence<OUString>
aColNames = xCols->getElementNames();
238 for (
const OUString& rColName :
aColNames)
240 std::unique_ptr<SwInsDBColumn> pNew(
new SwInsDBColumn( rColName ));
241 Any aCol = xCols->getByName(rColName);
242 Reference <XPropertySet> xCol;
244 Any aType = xCol->getPropertyValue(
"Type");
245 sal_Int32 eDataType = 0;
250 case DataType::BOOLEAN:
251 case DataType::TINYINT:
252 case DataType::SMALLINT:
253 case DataType::INTEGER:
254 case DataType::BIGINT:
255 case DataType::FLOAT:
257 case DataType::DOUBLE:
258 case DataType::NUMERIC:
259 case DataType::DECIMAL:
262 case DataType::TIMESTAMP:
264 pNew->bHasFormat =
true;
265 Any aFormat = xCol->getPropertyValue(
"FormatKey");
266 if(aFormat.hasValue())
268 sal_Int32 nFormat = 0;
270 if(xNumberFormats.is())
274 Reference<XPropertySet> xNumProps = xNumberFormats->getByKey( nFormat );
275 Any aFormatVal = xNumProps->getPropertyValue(
"FormatString");
276 Any aLocale = xNumProps->getPropertyValue(
"Locale");
278 aFormatVal >>= sFormat;
281 sal_Int32 nKey = xDocNumberFormats->queryKey( sFormat, aLoc,
true);
284 nKey = xDocNumberFormats->addNew( sFormat, aLoc );
286 pNew->nDBNumFormat = nKey;
290 OSL_FAIL(
"illegal number format key");
305 OSL_ENSURE(
false,
"Spaltenname mehrfach vergeben?" );
319 pBase = pPool->
Next();
394 if (!rButton.get_active())
397 bool bShowTable = m_xRbAsTable->get_active();
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 );
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 );
422 m_xPbTableFormat->set_sensitive( 0 != m_xLbTableCol->n_children() );
424 TVSelectHdl( bShowTable ? *m_xLbTableDbColumn : *m_xLbTextDbColumn );
429 if (!rButton.get_active())
433 ? ( m_xLbTableCol->get_id(0).isEmpty()
434 ? *m_xLbTableDbColumn
436 : *m_xLbTextDbColumn;
441 bool bFromDB = m_xRbDbFormatFromDb->get_active();
442 (*it)->bIsDBFormat = bFromDB;
443 m_xLbDbFormatFromUsr->set_sensitive( !bFromDB );
448 bool bChgEnable =
true, bEnableTo =
true, bEnableFrom =
true;
450 if( &rButton == m_xIbDbcolAllTo.get() )
454 sal_Int32
n, nInsPos = m_xLbTableCol->get_selected_index(),
455 nCnt = m_xLbTableDbColumn->n_children();
457 m_xLbTableDbColumn->unselect_all();
459 m_xLbTableDbColumn->freeze();
460 m_xLbTableCol->freeze();
463 for(
n = 0;
n < nCnt; ++
n )
464 m_xLbTableCol->append_text(m_xLbTableDbColumn->get_text(
n));
466 for(
n = 0;
n < nCnt; ++
n, ++nInsPos )
467 m_xLbTableCol->insert_text(nInsPos, m_xLbTableDbColumn->get_text(
n));
468 m_xLbTableDbColumn->clear();
470 m_xLbTableDbColumn->thaw();
471 m_xLbTableCol->thaw();
473 m_xLbTableCol->select(nInsPos);
475 else if( &rButton == m_xIbDbcolOneTo.get() &&
476 m_xLbTableDbColumn->get_selected_index() != -1 )
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);
483 m_xLbTableCol->select(nInsPos);
484 if (nDelPos >= m_xLbTableDbColumn->n_children())
485 nDelPos = m_xLbTableDbColumn->n_children() - 1;
486 m_xLbTableDbColumn->select(nDelPos);
488 bEnableTo = 0 != m_xLbTableDbColumn->n_children();
490 else if( &rButton == m_xIbDbcolOneFrom.get() )
492 if (m_xLbTableCol->get_selected_index() != -1)
495 nDelPos = m_xLbTableCol->get_selected_index();
500 if( it == m_aDBColumns.begin() || (it+1) == m_aDBColumns.end() )
501 nInsPos = it - m_aDBColumns.begin();
505 while( ++it != m_aDBColumns.end() &&
506 -1 == (nInsPos = m_xLbTableDbColumn->
507 find_text( (*it)->sColumn )) )
511 m_xLbTableDbColumn->insert_text(nInsPos, aSrch.
sColumn);
512 m_xLbTableCol->remove( nDelPos );
514 if (nInsPos >= m_xLbTableDbColumn->n_children())
515 nInsPos = m_xLbTableDbColumn->n_children() - 1;
516 m_xLbTableDbColumn->select(nInsPos);
518 if (nDelPos >= m_xLbTableCol->n_children())
519 nDelPos = m_xLbTableCol->n_children() - 1;
520 m_xLbTableCol->select(nDelPos);
523 bEnableTo = 0 != m_xLbTableDbColumn->n_children();
525 bEnableFrom = 0 != m_xLbTableCol->n_children();
527 else if( &rButton == m_xIbDbcolAllFrom.get() )
531 m_xLbTableDbColumn->freeze();
532 m_xLbTableCol->freeze();
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);
539 m_xLbTableDbColumn->thaw();
540 m_xLbTableCol->thaw();
542 m_xLbTableDbColumn->select(0);
544 else if( &rButton == m_xIbDbcolToEdit.get() )
548 OUString aField(m_xLbTextDbColumn->get_selected_text());
549 if( !aField.isEmpty() )
551 OUString
aStr( m_xEdDbText->get_text() );
552 int nStartPos, nEndPos;
553 m_xEdDbText->get_selection_bounds(nStartPos, nEndPos);
555 sal_Int32 nMax = std::max(nStartPos, nEndPos);
556 const sal_Int32 nSel = nMax -
nPos;
562 if( !
aStr.isEmpty() )
567 if(
'\n' != c &&
'\r' != c )
568 aField =
" " + aField;
573 if(
'\n' != c &&
'\r' != c )
578 m_xEdDbText->set_text(
aStr.replaceAt(
nPos, 0, aField ) );
579 nPos += aField.getLength();
580 m_xEdDbText->select_region(
nPos,
nPos);
587 m_xIbDbcolOneTo->set_sensitive( bEnableTo );
588 m_xIbDbcolAllTo->set_sensitive( bEnableTo );
589 m_xIbDbcolOneFrom->set_sensitive( bEnableFrom );
590 m_xIbDbcolAllFrom->set_sensitive( bEnableFrom );
592 m_xRbDbFormatFromDb->set_sensitive(
false );
593 m_xRbDbFormatFromUsr->set_sensitive(
false );
594 m_xLbDbFormatFromUsr->set_sensitive(
false );
596 m_xPbTableFormat->set_sensitive( bEnableFrom );
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();
610 TableToFromHdl(*pButton);
618 bool bNewSet =
false;
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 );
648 aBoxInfo.
SetValid( SvxBoxInfoItemValidFlags::DISABLE );
649 m_pTableSet->Put( aBoxInfo );
665 for( sal_uInt16
i = 0;
i < nNum; ++
i )
668 nStart1 = pCol->
GetLeft() + nWidth1;
672 if(nStart1 || nEnd1 != nWidth)
673 nWidth = nEnd1 - nStart1;
686 m_pRep->SetSpace( nWidth );
687 m_pRep->SetWidth( nWidth );
688 m_pRep->SetWidthPercent( 100 );
695 sal_Int32 nCols = m_xLbTableCol->n_children();
696 if (nCols != m_pRep->GetAllColCount() && nCols > 0)
706 const sal_Int32 nStep = nWidth / (nCols+1);
707 for( sal_Int32
n = 0;
n < nCols; ++
n )
709 aTabCols.
Insert( nStep*(
n+1),
false,
n );
714 m_pRep->SetSpace( nWidth );
715 m_pRep->SetWidth( nWidth );
716 m_pRep->SetWidthPercent( 100 );
723 if(
RET_OK == pDlg->Execute() )
724 m_pTableSet->Put( *pDlg->GetOutputItemSet() );
737 if(
RET_OK == pDlg->Execute())
738 m_xTAutoFormat = pDlg->FillAutoFormatOfIndex();
750 OUString sText( m_xFormatFrame->get_label().copy( 0, m_nGBFormatLen ));
753 m_xRbDbFormatFromDb->set_sensitive(
false );
754 m_xRbDbFormatFromUsr->set_sensitive(
false );
755 m_xLbDbFormatFromUsr->set_sensitive(
false );
759 bool bEnableFormat = (*it)->bHasFormat;
760 m_xRbDbFormatFromDb->set_sensitive( bEnableFormat );
761 m_xRbDbFormatFromUsr->set_sensitive( bEnableFormat );
765 sText +=
" (" + aSrch.
sColumn +
")";
768 bool bIsDBFormat = (*it)->bIsDBFormat;
769 m_xRbDbFormatFromDb->set_active( bIsDBFormat );
770 m_xRbDbFormatFromUsr->set_active( !bIsDBFormat );
771 m_xLbDbFormatFromUsr->set_sensitive( !bIsDBFormat );
773 m_xLbDbFormatFromUsr->SetDefFormat( (*it)->nUsrNumFormat );
776 m_xFormatFrame->set_label(sText);
778 if (m_xLbTableCol->n_children())
782 if (&rBox == m_xLbTableCol.get())
783 m_xLbTableCol->set_id(0,
"tablecols");
785 m_xLbTableCol->set_id(0, OUString());
792 ? ( m_xLbTableCol->get_id(0).isEmpty()
793 ? m_xLbTableDbColumn.get()
794 : m_xLbTableCol.get() )
795 : m_xLbTextDbColumn.get();
802 m_xLbDbFormatFromUsr->CallSelectHdl();
803 (*it)->nUsrNumFormat = m_xLbDbFormatFromUsr->GetFormat();
809 bool bEnable = m_xCbTableHeadon->get_active();
810 m_xRbHeadlColnms->set_sensitive( bEnable );
811 m_xRbHeadlEmpty->set_sensitive( bEnable );
818 while( std::u16string_view::npos != ( nFndPos = aText.find(
'\x0A', nSttPos )) )
822 rColArr.push_back(std::make_unique<DB_Column>(OUString(aText.substr(nSttPos, nFndPos -1))));
824 rColArr.push_back(std::make_unique<DB_Column>());
825 nSttPos = nFndPos + 1;
827 if( nSttPos < aText.size() )
829 rColArr.push_back(std::make_unique<DB_Column>(OUString(aText.substr(nSttPos))));
840 OUString sText( rText );
841 sal_Int32 nFndPos, nEndPos, nSttPos = 0;
843 while( -1 != ( nFndPos = sText.indexOf(
cDBFieldStart, nSttPos )))
845 nSttPos = nFndPos + 1;
850 SwInsDBColumn aSrch( sText.copy( nSttPos, nEndPos - nSttPos ));
863 sText = sText.copy( nSttPos-1 );
866 sText = sText.copy( rFndCol.
sColumn.getLength() + 2 );
869 sal_uInt16 nSubType = 0;
874 nFormat =
static_cast<sal_uInt32
>(rFndCol.
nDBNumFormat);
896 pNew =
new DB_Column( rFndCol, nFormat );
898 rColArr.push_back( std::unique_ptr<DB_Column>(pNew) );
904 if( !sText.isEmpty() )
907 return !rColArr.empty();
911 Reference< XDataSource>
const & xSource,
912 Reference< XConnection>
const & xConnection,
913 Reference< sdbc::XResultSet >
const & xResultSet_in )
915 auto xResultSet = xResultSet_in;
917 const Any* pSelection = rSelection.hasElements() ? rSelection.getConstArray() :
nullptr;
921 bool bDisposeResultSet =
false;
923 if ( !xResultSet.is() )
926 bDisposeResultSet = xResultSet.is();
929 Reference< sdbc::XRow > xRow(xResultSet, UNO_QUERY);
944 std::optional<SwWait> oWait;
946 Reference< XColumnsSupplier > xColsSupp( xResultSet, UNO_QUERY );
947 Reference <XNameAccess> xCols = xColsSupp->getColumns();
949 uno::Reference<sdbcx::XRowLocate> xRowLocate(xResultSet, uno::UNO_QUERY_THROW);
962 nRows += rSelection.getLength();
967 std::vector<SwInsDBColumn*> aColFields;
968 for( sal_Int32
n = 0;
n < nCols; ++
n )
973 aColFields.push_back(it->get());
975 OSL_ENSURE(
false,
"database column not found" );
979 if(
static_cast<size_t>(nCols) != aColFields.size() )
981 OSL_ENSURE(
false,
"not all database columns found" );
982 nCols =
static_cast<sal_Int32
>(aColFields.size());
987 OSL_ENSURE(
false,
"wrong parameters" );
1008 for( sal_Int32
n = 0;
n < nCols; ++
n )
1012 rSh.SwEditShell::Insert2( aColFields[
n ]->sColumn );
1020 for( sal_Int32
i = 0 ; ; ++
i )
1022 bool bBreak =
false;
1027 bBreak = !xRowLocate->moveToBookmark(pSelection[
i]);
1030 bBreak = !xResultSet->first();
1039 for( sal_Int32
n = 0;
n < nCols; ++
n )
1051 Reference< XPropertySet > xColumnProps(
xColumn, UNO_QUERY );
1052 sal_Int32 eDataType = 0;
1053 if( xColumnProps.is() )
1055 Any aType = xColumnProps->getPropertyValue(
"Type");
1056 aType >>= eDataType;
1065 aTableSet.
Put(aNumFormat);
1068 double fVal =
xColumn->getDouble();
1073 if(rNumFormatr.
GetType(aNumFormat.
GetValue()) & SvNumFormatType::DATE)
1075 ::Date aStandard(1,1,1900);
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
1105 const OUString sVal =
xColumn->getString();
1108 rSh.SwEditShell::Insert2( sVal );
1120 if ( !xResultSet->next() )
1123 else if(
i+1 >= rSelection.getLength() )
1150 rSh.SwEditShell::SplitNode();
1153 rSh.SwEditShell::SplitNode();
1169 if( USHRT_MAX !=
nId )
1181 Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
1182 aDBFormatData.
xFormatter.set(util::NumberFormatter::create(xContext), UNO_QUERY_THROW) ;
1184 Reference<XPropertySet> xSourceProps(xSource, UNO_QUERY);
1185 if(xSourceProps.is())
1187 Any aFormats = xSourceProps->getPropertyValue(
"NumberFormatsSupplier");
1188 if(aFormats.hasValue())
1190 Reference< util::XNumberFormatsSupplier> xSuppl;
1191 aFormats >>= xSuppl;
1194 Reference< XPropertySet > xSettings = xSuppl->getNumberFormatSettings();
1195 Any aNull = xSettings->getPropertyValue(
"NullDate");
1198 aDBFormatData.
xFormatter->attachNumberFormatsSupplier(xSuppl);
1207 bool bSetCursor =
true;
1208 const size_t nCols = aColArr.size();
1210 for( sal_Int32
i = 0 ; ; ++
i )
1212 bool bBreak =
false;
1217 bBreak = !xRowLocate->moveToBookmark(pSelection[
i]);
1220 bBreak = !xResultSet->first();
1230 for(
size_t n = 0;
n < nCols; ++
n )
1237 sIns = *pDBCol->
pText;
1250 std::unique_ptr<SwDBField> pField(
static_cast<SwDBField *
>(
1254 Reference< XPropertySet > xColumnProps;
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)
1270 ::Date aStandard(1,1,1900);
1274 if(aStandard != aCompare)
1275 nValue += (aStandard - aCompare);
1277 pField->ChgValue(
nValue,
true );
1279 pField->SetInitialized();
1288 Reference< XPropertySet > xColumnProps;
1300 ::Date aStandard(1,1,1900);
1312 if( !sIns.isEmpty() )
1322 rSh.SwCursorShell::MovePara(
1328 rSh.SwCursorShell::MovePara(
1337 bool bNext = xResultSet->next();
1341 else if(
i+1 >= rSelection.getLength() )
1348 rSh.SwEditShell::SplitNode();
1354 if( !bSetCursor && pMark !=
nullptr)
1376 if ( bDisposeResultSet )
1377 ::comphelper::disposeComponent(xResultSet);
1404 static const sal_uInt16 aIds[3] =
1406 for(sal_uInt16
i : aIds)
1408 false, &pItem ) && *pItem == aBrush )
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;
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"
1459 sal_Int32 nIdx = aNames.getLength();
1462 const OUString sRet =
"_" + OUString::number(nIdx++);
1474 for(OUString
const & nodeName : std::as_const(aNames))
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;
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++)
1505 for( sal_Int32
n = 0;
n < nCnt; ++
n )
1508 if (!sTmp.isEmpty())
1524 sNewNode +=
"/ColumnSet";
1532 OUString sColumnInsertNode(sNewNode +
"/__");
1534 sColumnInsertNode +=
"00";
1535 else if( nCol < 100 )
1536 sColumnInsertNode +=
"0";
1537 sColumnInsertNode += OUString::number( nCol );
1540 Sequence<PropertyValue> aSubValues(aSubNodeNames.getLength());
1541 PropertyValue* pSubValues = aSubValues.getArray();
1544 for(
const OUString& rSubNodeName : aSubNodeNames)
1545 pSubValues[
i++].Name = rSubNodeName;
1546 pSubValues[0].Value <<= pColumn->
sColumn;
1547 pSubValues[1].Value <<=
i;
1561 pSubValues[4].Value <<= sTmp;
1566 if( eLang != ePrevLang )
1572 pSubValues[5].Value <<= sPrevLang;
1579 const Sequence<OUString> aNames =
GetNodeNames(OUString());
1581 for(OUString
const & nodeName : aNames)
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;
1595 DB_ColumnConfigData aNewData;
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]);
1610 const OUString sSubNodeName(nodeName +
"/ColumnSet/");
1611 const Sequence <OUString> aSubNames =
GetNodeNames(sSubNodeName);
1612 for(
const OUString& rSubName : aSubNames)
1614 Sequence <OUString> aSubNodeNames =
1617 const Any* pSubProps = aSubProps.getConstArray();
1620 pSubProps[0] >>= sColumn;
1622 bool bFound =
false;
1623 for(
size_t nRealColumn = 0; nRealColumn <
m_aDBColumns.
size(); ++nRealColumn)
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]);
1641 pSubProps[4] >>= pInsDBColumn->sUsrNumFormat;
1642 OUString sNumberFormatLocale;
1643 pSubProps[5] >>= sNumberFormatLocale;
1655 pInsDBColumn->nUsrNumFormat = rNFormatr.
GetEntryKey( pInsDBColumn->sUsrNumFormat,
1656 pInsDBColumn->eUsrNumFormatLng );
1658 aNewData.aDBColumns.insert(std::move(pInsDBColumn));
1660 OUString sTmp( aNewData.sTableList );
1661 if( !sTmp.isEmpty() )
1665 const OUString sEntry( sTmp.getToken( 0,
'\x0a',
n ) );
1684 sTmp = aNewData.sTmplNm;
1685 if( !sTmp.isEmpty() )
1691 sTmp = aNewData.sTAutoFormatNm;
1692 if( !sTmp.isEmpty() )
1696 aAutoFormatTable.
Load();
1697 for(
size_t nAutoFormat = aAutoFormatTable.
size(); nAutoFormat; )
1698 if( sTmp == aAutoFormatTable[ --nAutoFormat ].
GetName() )
1707 m_xRbAsText->set_active( !aNewData.bIsTable && !aNewData.bIsField );
1719 for(
size_t m = 0;
m < aNewData.aDBColumns.size() ; ++
m )
1726 rSet.bIsDBFormat =
false;
1731 sal_Int32 nCheckPos;
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
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
sal_uInt16 GetLeft() const
sal_uInt16 GetRight() const
void SetAutoUpdateCells(bool bFlag)
::sw::mark::IMark * SetBookmark(const vcl::KeyCode &, const OUString &rName, IDocumentMarkAccess::MarkType eMark=IDocumentMarkAccess::MarkType::BOOKMARK)
bool MoveTable(SwWhichTable, SwMoveFnCollection const &)
bool IsAutoUpdateCells() const
bool GoNextCell(bool bAppendLine=true)
set cursor into next/previous cell
static OUString GetDBField(css::uno::Reference< css::beans::XPropertySet > const &xColumnProp, const SwDBFormatData &rDBFormatData, double *pNumber=nullptr)
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.
virtual SfxStyleSheetBasePool * GetStyleSheetPool() override
For Style PI.
void StartAllAction()
For all views of this document.
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.
SwUndoId StartUndo(SwUndoId eUndoId=SwUndoId::EMPTY, const SwRewriter *pRewriter=nullptr)
Undo: set up Undo parenthesis, return nUndoId of this parenthesis.
SwFrameFormat * GetTableFormat()
SvNumberFormatter * GetNumberFormatter()
Query NumberFormatter from document.
void SetTextFormatColl(SwTextFormatColl *, const bool bResetListAttrs=false)
Add 2nd optional parameter <bResetListAttrs> - see also <SwDoc::SetTextFormatColl(....
void SetTableBoxFormulaAttrs(const SfxItemSet &rSet)
void AppendUndoForInsertFromDB(bool bIsTable)
Set up InsertDB as table Undo.
SwTextFormatColl * FindTextFormatCollByName(const OUString &rName) const
SwTextFormatColl * GetTextCollFromPool(sal_uInt16 nId)
SwFieldType * InsertFieldType(const SwFieldType &)
insert field type
SwUndoId EndUndo(SwUndoId eUndoId=SwUndoId::EMPTY, const SwRewriter *pRewriter=nullptr)
Closes parenthesis of nUndoId, not used by UI.
void DoUndo(bool bOn=true)
Undo.
OUString GetUniqueTableName() const
SwTextFormatColl * MakeTextFormatColl(const OUString &rFormatCollName, SwTextFormatColl *pDerivedFrom=nullptr)
LanguageType GetCurLang() const
sal_uInt16 GetCurColNum(SwGetCurColNumPara *pPara=nullptr) const
The ruler needs some information too.
FrameTypeFlags GetFrameType(const Point *pPt, bool bStopAtFly) const
For return values see above FrameType.
void SetTableStyle(const OUString &rStyleName)
Set table style of the current table.
void SetRowsToRepeat(sal_uInt16 nNumOfRows)
const SwRect & GetAnyCurRect(CurRectType eType, const Point *pPt=nullptr, const css::uno::Reference< css::embed::XEmbeddedObject > &=css::uno::Reference< css::embed::XEmbeddedObject >()) const
Base class of all fields.
std::unique_ptr< SwField > CopyField() const
virtual void SetSubType(sal_uInt16)
SwInsertDBColAutoPilot(SwView &rView, css::uno::Reference< css::sdbc::XDataSource > const &rxSource, css::uno::Reference< css::sdbcx::XColumnsSupplier > const &xColSupp, SwDBData aData)
virtual ~SwInsertDBColAutoPilot() override
std::unique_ptr< SfxItemSet > m_pTableSet
SwInsDBColumns m_aDBColumns
std::unique_ptr< weld::RadioButton > m_xRbHeadlColnms
std::unique_ptr< weld::CheckButton > m_xCbTableHeadon
bool SplitTextToColArr(const OUString &rText, DB_Columns &rColArr, bool bInsField)
std::unique_ptr< weld::Frame > m_xFormatFrame
std::unique_ptr< weld::Button > m_xIbDbcolToEdit
std::unique_ptr< weld::RadioButton > m_xRbAsTable
std::unique_ptr< weld::RadioButton > m_xRbAsField
std::unique_ptr< weld::Frame > m_xHeadFrame
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)
std::unique_ptr< weld::TextView > m_xEdDbText
std::unique_ptr< weld::RadioButton > m_xRbDbFormatFromDb
std::unique_ptr< weld::TreeView > m_xLbTextDbColumn
std::unique_ptr< weld::TreeView > m_xLbTableCol
std::unique_ptr< weld::Button > m_xIbDbcolAllFrom
std::unique_ptr< weld::Button > m_xIbDbcolAllTo
std::unique_ptr< weld::RadioButton > m_xRbHeadlEmpty
std::unique_ptr< weld::Button > m_xPbTableFormat
std::unique_ptr< weld::ComboBox > m_xLbDbParaColl
virtual void Notify(const css::uno::Sequence< OUString > &aPropertyNames) override
std::unique_ptr< NumFormatListBox > m_xLbDbFormatFromUsr
std::unique_ptr< SwTableAutoFormat > m_xTAutoFormat
std::unique_ptr< weld::Button > m_xIbDbcolOneTo
std::unique_ptr< weld::RadioButton > m_xRbAsText
std::unique_ptr< weld::TreeView > m_xLbTableDbColumn
std::unique_ptr< weld::Button > m_xPbTableAutofmt
virtual void ImplCommit() override
std::unique_ptr< weld::RadioButton > m_xRbDbFormatFromUsr
std::unique_ptr< weld::Button > m_xIbDbcolOneFrom
const SwInsertTableOptions & GetInsTableFlags(bool bHTML) const
void Width(tools::Long nNew)
static SW_DLLPUBLIC sal_uInt16 GetPoolIdFromUIName(const OUString &rName, SwGetPoolIdFromName)
static void FillUIName(const OUString &rName, OUString &rFillName, SwGetPoolIdFromName)
void SetRight(tools::Long nNew)
void SetRightMax(tools::Long nNew)
void Insert(tools::Long nValue, bool bValue, size_t nPos)
Represents the style of a paragraph.
SwTextFormatColl & GetNextTextFormatColl() const
sal_uInt8 GetTableDest() const
const SwViewOption * GetViewOptions() const
const IDocumentMarkAccess * getIDocumentMarkAccess() const
Provides access to the document bookmark interface.
const SfxItemPool & GetAttrPool() const
SwWrtShell & GetWrtShell() const
SwDocShell * GetDocShell()
Used by the UI to modify the document model.
void GotoMark(const ::sw::mark::IMark *const pMark)
void Insert(const OUString &)
void SplitNode(bool bAutoFormat=false)
bool DelRight(bool isReplaceHeuristic=false)
bool HasSelection() const
bool InsertField2(SwField const &, SwPaM *pAnnotationRange=nullptr)
std::vector< Value >::const_iterator const_iterator
const_iterator find(const Value &x) const
const_iterator end() 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_selected_text() const=0
#define FN_PARAM_TABLE_NAME
#define FN_PARAM_TABLE_HEADLINE
static OUString lcl_CreateUniqueName(const Sequence< OUString > &aNames)
static Sequence< OUString > lcl_CreateSubNames(std::u16string_view rSubNodeName)
static void lcl_InsTextInArr(std::u16string_view aText, DB_Columns &rColArr)
IMPL_LINK_NOARG(SwInsertDBColAutoPilot, TableFormatHdl, weld::Button &, void)
IMPL_LINK(SwInsertDBColAutoPilot, PageHdl, weld::Toggleable &, rButton, void)
static Sequence< OUString > lcl_createSourceNames(std::u16string_view rNodeName)
std::vector< std::unique_ptr< DB_Column > > DB_Columns
#define TOOLS_WARN_EXCEPTION(area, stream)
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
virtual OUString GetName() const override
@ FlyEmbeddedPrt
Rect of PrtArea of FlyFrame.
@ PagePrt
Rect of current PrtArea of page.
std::vector< SwColumn > SwColumns
constexpr TypedWhichId< SwTableBoxValue > RES_BOXATR_VALUE(158)
constexpr TypedWhichId< SvxBrushItem > RES_BACKGROUND(111)
constexpr TypedWhichId< SvxBoxItem > RES_BOX(112)
LanguageType GetAppLanguage()
CollatorWrapper & GetAppCollator()
#define LINK(Instance, Class, Member)
constexpr OUStringLiteral aData
sal_Int32 findValue(const css::uno::Sequence< T1 > &_rList, const T2 &_rValue)
const SwExtendedSubType SUB_OWN_FMT
SwDBField: Don't accept formatting from database.
SwAbstractDialogFactory & GetFactory()
SwNodeOffset min(const SwNodeOffset &a, const SwNodeOffset &b)
bool GoCurrPara(SwPaM &rPam, SwMoveFnCollection const &aPosPara)
SwMoveFnCollection const & fnParaStart
SwMoveFnCollection const & fnTableEnd
SwMoveFnCollection const & fnParaEnd
SwMoveFnCollection const & fnTableStart
@ RES_POOLCOLL_STANDARD
Standard.
const Color aColNames[SC_RANGECOLORS]
DB_Column(const SwInsDBColumn &rInfo, sal_uInt32 nFormat_)
DB_Column(const OUString &rText)
DB_Column(const SwInsDBColumn &rInfo, SwDBField &rField)
enum DB_Column::Type eColType
const SwInsDBColumn * pColInfo
const SwFrameFormat * pFrameFormat
bool operator<(const SwInsDBColumn &rCmp) const
LanguageType eUsrNumFormatLng
OUString SwResId(TranslateId aId)
constexpr SwTwips MIN_BORDER_DIST
SW_DLLPUBLIC const WhichRangesContainer & SwuiGetUITableAttrRange()
SW_DLLPUBLIC void ItemSetToTableParam(const SfxItemSet &rSet, SwWrtShell &rSh)
bool GotoCurrTable(SwPaM &rCurrentCursor, SwMoveFnCollection const &fnPosTable, bool bInReadOnly)
bool GotoPrevTable(SwPaM &rCurrentCursor, SwMoveFnCollection const &fnPosTable, bool bInReadOnly)
sal_uInt16 GetHtmlMode(const SwDocShell *pShell)
constexpr sal_uInt32 NUMBERFORMAT_ENTRY_NOT_FOUND