LibreOffice Module extensions (master) 1
formlinkdialog.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
21#include "formlinkdialog.hxx"
22
23#include "modulepcr.hxx"
24#include <strings.hrc>
25#include "formstrings.hxx"
26#include <sal/log.hxx>
28#include <utility>
29#include <vcl/svapp.hxx>
33
34#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
35#include <com/sun/star/sdbcx/XKeysSupplier.hpp>
36#include <com/sun/star/sdbcx/KeyType.hpp>
37#include <com/sun/star/container/XNameAccess.hpp>
38#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
39#include <com/sun/star/sdbc/XRowSet.hpp>
40#include <com/sun/star/sdb/CommandType.hpp>
41#include <com/sun/star/sdb/SQLContext.hpp>
42#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
43
44namespace pcr
45{
46
47
48 using namespace ::com::sun::star::uno;
49 using namespace ::com::sun::star::lang;
50 using namespace ::com::sun::star::sdb;
51 using namespace ::com::sun::star::sdbc;
52 using namespace ::com::sun::star::sdbcx;
53 using namespace ::com::sun::star::beans;
54 using namespace ::com::sun::star::container;
55
56
57 //= FieldLinkRow
58
60 {
61 private:
62 std::unique_ptr<weld::ComboBox> m_xDetailColumn;
63 std::unique_ptr<weld::ComboBox> m_xMasterColumn;
64
66
67 public:
68 FieldLinkRow(std::unique_ptr<weld::ComboBox> xDetailColumn,
69 std::unique_ptr<weld::ComboBox> xMasterColumn);
70
71
73
75 {
78 };
82 bool GetFieldName( LinkParticipant _eWhich, OUString& /* [out] */ _rName ) const;
83 void SetFieldName( LinkParticipant _eWhich, const OUString& _rName );
84
85 void fillList( LinkParticipant _eWhich, const Sequence< OUString >& _rFieldNames );
86
87 void Show()
88 {
89 m_xDetailColumn->show();
90 m_xMasterColumn->show();
91 }
92
93 private:
94 DECL_LINK( OnFieldNameChanged, weld::ComboBox&, void );
95 };
96
97
98 FieldLinkRow::FieldLinkRow(std::unique_ptr<weld::ComboBox> xDetailColumn,
99 std::unique_ptr<weld::ComboBox> xMasterColumn)
100 : m_xDetailColumn(std::move(xDetailColumn))
101 , m_xMasterColumn(std::move(xMasterColumn))
102 {
103 m_xDetailColumn->connect_changed( LINK( this, FieldLinkRow, OnFieldNameChanged ) );
104 m_xMasterColumn->connect_changed( LINK( this, FieldLinkRow, OnFieldNameChanged ) );
105 }
106
107 void FieldLinkRow::fillList( LinkParticipant _eWhich, const Sequence< OUString >& _rFieldNames )
108 {
109 weld::ComboBox* pBox = ( _eWhich == eDetailField ) ? m_xDetailColumn.get() : m_xMasterColumn.get();
110
111 const OUString* pFieldName = _rFieldNames.getConstArray();
112 const OUString* pFieldNameEnd = pFieldName + _rFieldNames.getLength();
113 for ( ; pFieldName != pFieldNameEnd; ++pFieldName )
114 pBox->append_text( *pFieldName );
115 }
116
117 bool FieldLinkRow::GetFieldName( LinkParticipant _eWhich, OUString& /* [out] */ _rName ) const
118 {
119 const weld::ComboBox* pBox = ( _eWhich == eDetailField ) ? m_xDetailColumn.get() : m_xMasterColumn.get();
120 _rName = pBox->get_active_text();
121 return !_rName.isEmpty();
122 }
123
124 void FieldLinkRow::SetFieldName( LinkParticipant _eWhich, const OUString& _rName )
125 {
126 weld::ComboBox* pBox = ( _eWhich == eDetailField ) ? m_xDetailColumn.get() : m_xMasterColumn.get();
127 pBox->set_entry_text( _rName );
128 }
129
130 IMPL_LINK_NOARG( FieldLinkRow, OnFieldNameChanged, weld::ComboBox&, void )
131 {
132 m_aLinkChangeHandler.Call( *this );
133 }
134
135 //= FormLinkDialog
136
137 FormLinkDialog::FormLinkDialog(weld::Window* _pParent, const Reference< XPropertySet >& _rxDetailForm,
138 const Reference< XPropertySet >& _rxMasterForm, const Reference< XComponentContext >& _rxContext,
139 const OUString& _sExplanation,
140 OUString _sDetailLabel,
141 OUString _sMasterLabel)
142 : GenericDialogController(_pParent, "modules/spropctrlr/ui/formlinksdialog.ui", "FormLinks")
143 , m_xContext ( _rxContext )
144 , m_xDetailForm( _rxDetailForm )
145 , m_xMasterForm( _rxMasterForm )
146 , m_sDetailLabel(std::move(_sDetailLabel))
147 , m_sMasterLabel(std::move(_sMasterLabel))
148 , m_xExplanation(m_xBuilder->weld_label("explanationLabel"))
149 , m_xDetailLabel(m_xBuilder->weld_label("detailLabel"))
150 , m_xMasterLabel(m_xBuilder->weld_label("masterLabel"))
151 , m_xRow1(std::make_unique<FieldLinkRow>(m_xBuilder->weld_combo_box("detailCombobox1"),
152 m_xBuilder->weld_combo_box("masterCombobox1")))
153 , m_xRow2(std::make_unique<FieldLinkRow>(m_xBuilder->weld_combo_box("detailCombobox2"),
154 m_xBuilder->weld_combo_box("masterCombobox2")))
155 , m_xRow3(std::make_unique<FieldLinkRow>(m_xBuilder->weld_combo_box("detailCombobox3"),
156 m_xBuilder->weld_combo_box("masterCombobox3")))
157 , m_xRow4(std::make_unique<FieldLinkRow>(m_xBuilder->weld_combo_box("detailCombobox4"),
158 m_xBuilder->weld_combo_box("masterCombobox4")))
159 , m_xOK(m_xBuilder->weld_button("ok"))
160 , m_xSuggest(m_xBuilder->weld_button("suggestButton"))
161 {
162 m_xRow1->Show();
163 m_xRow2->Show();
164 m_xRow3->Show();
165 m_xRow4->Show();
166 m_xDialog->set_size_request(600, -1);
167
168 if ( !_sExplanation.isEmpty() )
169 m_xExplanation->set_label(_sExplanation);
170
171 m_xSuggest->connect_clicked(LINK(this, FormLinkDialog, OnSuggest));
172 m_xRow1->SetLinkChangeHandler( LINK( this, FormLinkDialog, OnFieldChanged ) );
173 m_xRow2->SetLinkChangeHandler( LINK( this, FormLinkDialog, OnFieldChanged ) );
174 m_xRow3->SetLinkChangeHandler( LINK( this, FormLinkDialog, OnFieldChanged ) );
175 m_xRow4->SetLinkChangeHandler( LINK( this, FormLinkDialog, OnFieldChanged ) );
176
177 Application::PostUserEvent(LINK(this, FormLinkDialog, OnInitialize));
178
180 }
181
183 {
184 }
185
187 {
188 // collect the field lists from the rows
189 std::vector< OUString > aDetailFields; aDetailFields.reserve( 4 );
190 std::vector< OUString > aMasterFields; aMasterFields.reserve( 4 );
191
192 const FieldLinkRow* aRows[] = {
193 m_xRow1.get(), m_xRow2.get(), m_xRow3.get(), m_xRow4.get()
194 };
195
196 for (const FieldLinkRow* aRow : aRows)
197 {
198 OUString sDetailField, sMasterField;
199 aRow->GetFieldName( FieldLinkRow::eDetailField, sDetailField );
200 aRow->GetFieldName( FieldLinkRow::eMasterField, sMasterField );
201 if ( sDetailField.isEmpty() && sMasterField.isEmpty() )
202 continue;
203
204 aDetailFields.push_back( sDetailField );
205 aMasterFields.push_back( sMasterField );
206 }
207
208 // and set as property values
209 try
210 {
211 if ( m_xDetailForm.is() )
212 {
213 m_xDetailForm->setPropertyValue( PROPERTY_DETAILFIELDS, Any( Sequence< OUString >( aDetailFields.data(), aDetailFields.size() ) ) );
214 m_xDetailForm->setPropertyValue( PROPERTY_MASTERFIELDS, Any( Sequence< OUString >( aMasterFields.data(), aMasterFields.size() ) ) );
215 }
216 }
217 catch( const Exception& )
218 {
219 TOOLS_WARN_EXCEPTION("extensions.propctrlr",
220 "caught an exception while setting the properties!");
221 }
222 }
223
225 {
226 short nResult = GenericDialogController::run();
227
228 if ( RET_OK == nResult )
230
231 return nResult;
232 }
233
235 {
236 Sequence< OUString > sDetailFields;
237 getFormFields( m_xDetailForm, sDetailFields );
238
239 Sequence< OUString > sMasterFields;
240 getFormFields( m_xMasterForm, sMasterFields );
241
242 FieldLinkRow* aRows[] = {
243 m_xRow1.get(), m_xRow2.get(), m_xRow3.get(), m_xRow4.get()
244 };
245 for (FieldLinkRow* aRow : aRows)
246 {
247 aRow->fillList( FieldLinkRow::eDetailField, sDetailFields );
248 aRow->fillList( FieldLinkRow::eMasterField, sMasterFields );
249 }
250
251 }
252
253
255 {
256 // label for the detail form
257 OUString sDetailType = getFormDataSourceType( m_xDetailForm );
258 if ( sDetailType.isEmpty() )
259 {
260 if ( m_sDetailLabel.isEmpty() )
261 {
262 m_sDetailLabel = PcrRes(STR_DETAIL_FORM);
263 }
264 sDetailType = m_sDetailLabel;
265 }
266 m_xDetailLabel->set_label( sDetailType );
267
268 // label for the master form
269 OUString sMasterType = getFormDataSourceType( m_xMasterForm );
270 if ( sMasterType.isEmpty() )
271 {
272 if ( m_sMasterLabel.isEmpty() )
273 {
274 m_sMasterLabel = PcrRes(STR_MASTER_FORM);
275 }
276 sMasterType = m_sMasterLabel;
277 }
278 m_xMasterLabel->set_label( sMasterType );
279 }
280
281 void FormLinkDialog::initializeFieldRowsFrom( std::vector< OUString >& _rDetailFields, std::vector< OUString >& _rMasterFields )
282 {
283 // our UI does allow 4 fields max
284 _rDetailFields.resize( 4 );
285 _rMasterFields.resize( 4 );
286
287 FieldLinkRow* aRows[] = {
288 m_xRow1.get(), m_xRow2.get(), m_xRow3.get(), m_xRow4.get()
289 };
290 for ( sal_Int32 i = 0; i < 4; ++i )
291 {
292 aRows[ i ]->SetFieldName( FieldLinkRow::eDetailField, _rDetailFields[i] );
293 aRows[ i ]->SetFieldName( FieldLinkRow::eMasterField, _rMasterFields[i] );
294 }
295 }
296
297
299 {
300 try
301 {
302 Sequence< OUString > aDetailFields;
303 Sequence< OUString > aMasterFields;
304
305 if ( m_xDetailForm.is() )
306 {
307 m_xDetailForm->getPropertyValue( PROPERTY_DETAILFIELDS ) >>= aDetailFields;
308 m_xDetailForm->getPropertyValue( PROPERTY_MASTERFIELDS ) >>= aMasterFields;
309 }
310
311 std::vector< OUString > aDetailFields1;
312 comphelper::sequenceToContainer(aDetailFields1, aDetailFields);
313 std::vector< OUString > aMasterFields1;
314 comphelper::sequenceToContainer(aMasterFields1, aMasterFields);
315 initializeFieldRowsFrom( aDetailFields1, aMasterFields1 );
316 }
317 catch( const Exception& )
318 {
319 TOOLS_WARN_EXCEPTION( "extensions.propctrlr", "FormLinkDialog::initializeLinks" );
320 }
321 }
322
323
325 {
326 // in all rows, there must be either two valid selections, or none at all
327 // If there is at least one row with exactly one valid selection, then the
328 // OKButton needs to be disabled
329 bool bEnable = true;
330
331 const FieldLinkRow* aRows[] = {
332 m_xRow1.get(), m_xRow2.get(), m_xRow3.get(), m_xRow4.get()
333 };
334
335 for ( sal_Int32 i = 0; ( i < 4 ) && bEnable; ++i )
336 {
337 OUString sNotInterestedInRightNow;
338 if ( aRows[ i ]->GetFieldName( FieldLinkRow::eDetailField, sNotInterestedInRightNow )
339 != aRows[ i ]->GetFieldName( FieldLinkRow::eMasterField, sNotInterestedInRightNow )
340 )
341 bEnable = false;
342 }
343
344 m_xOK->set_sensitive(bEnable);
345 }
346
347 OUString FormLinkDialog::getFormDataSourceType( const Reference< XPropertySet >& _rxForm )
348 {
349 OUString sReturn;
350 if ( !_rxForm.is() )
351 return sReturn;
352
353 try
354 {
355 sal_Int32 nCommandType = CommandType::COMMAND;
356 OUString sCommand;
357
358 _rxForm->getPropertyValue( PROPERTY_COMMANDTYPE ) >>= nCommandType;
359 _rxForm->getPropertyValue( PROPERTY_COMMAND ) >>= sCommand;
360
361 if ( ( nCommandType == CommandType::TABLE )
362 || ( nCommandType == CommandType::QUERY )
363 )
364 sReturn = sCommand;
365 }
366 catch( const Exception& )
367 {
368 TOOLS_WARN_EXCEPTION( "extensions.propctrlr", "FormLinkDialog::getFormDataSourceType" );
369 }
370 return sReturn;
371 }
372
373 void FormLinkDialog::getFormFields( const Reference< XPropertySet >& _rxForm, Sequence< OUString >& /* [out] */ _rNames ) const
374 {
375 _rNames.realloc( 0 );
376
378 OUString sCommand;
379 try
380 {
381 weld::WaitObject aWaitCursor(m_xDialog.get());
382
383 OSL_ENSURE( _rxForm.is(), "FormLinkDialog::getFormFields: invalid form!" );
384
385 sal_Int32 nCommandType = CommandType::COMMAND;
386
387 _rxForm->getPropertyValue( PROPERTY_COMMANDTYPE ) >>= nCommandType;
388 _rxForm->getPropertyValue( PROPERTY_COMMAND ) >>= sCommand;
389
390 Reference< XConnection > xConnection;
391 ensureFormConnection( _rxForm, xConnection );
392
393 _rNames = ::dbtools::getFieldNamesByCommandDescriptor(
394 xConnection,
395 nCommandType,
396 sCommand,
397 &aErrorInfo
398 );
399 }
400 catch (const SQLContext& e) { aErrorInfo = e; }
401 catch (const SQLWarning& e) { aErrorInfo = e; }
402 catch (const SQLException& e ) { aErrorInfo = e; }
403 catch( const Exception& )
404 {
405 TOOLS_WARN_EXCEPTION( "extensions.propctrlr", "FormLinkDialog::getFormFields: caught a non-SQL exception!" );
406 }
407
408 if ( !aErrorInfo.isValid() )
409 return;
410
411 OUString sErrorMessage;
412 {
413 sErrorMessage = PcrRes(STR_ERROR_RETRIEVING_COLUMNS);
414 sErrorMessage = sErrorMessage.replaceFirst("#", sCommand);
415 }
416
417 SQLContext aContext;
418 aContext.Message = sErrorMessage;
419 aContext.NextException = aErrorInfo.get();
420 ::dbtools::showError(aContext, m_xDialog->GetXWindow(), m_xContext);
421 }
422
423 void FormLinkDialog::ensureFormConnection( const Reference< XPropertySet >& _rxFormProps, Reference< XConnection >& /* [out] */ _rxConnection ) const
424 {
425 OSL_PRECOND( _rxFormProps.is(), "FormLinkDialog::ensureFormConnection: invalid form!" );
426 if ( !_rxFormProps.is() )
427 return;
428 if ( _rxFormProps->getPropertySetInfo()->hasPropertyByName(PROPERTY_ACTIVE_CONNECTION) )
429 _rxConnection.set(_rxFormProps->getPropertyValue(PROPERTY_ACTIVE_CONNECTION),UNO_QUERY);
430
431 if ( !_rxConnection.is() )
432 _rxConnection = ::dbtools::connectRowset( Reference< XRowSet >( _rxFormProps, UNO_QUERY ), m_xContext, nullptr );
433 }
434
435
436 void FormLinkDialog::getConnectionMetaData( const Reference< XPropertySet >& _rxFormProps, Reference< XDatabaseMetaData >& /* [out] */ _rxMeta )
437 {
438 if ( _rxFormProps.is() )
439 {
440 Reference< XConnection > xConnection;
441 if ( !::dbtools::isEmbeddedInDatabase( _rxFormProps, xConnection ) )
442 _rxFormProps->getPropertyValue( PROPERTY_ACTIVE_CONNECTION ) >>= xConnection;
443 if ( xConnection.is() )
444 _rxMeta = xConnection->getMetaData();
445 }
446 }
447
448
449 Reference< XPropertySet > FormLinkDialog::getCanonicUnderlyingTable( const Reference< XPropertySet >& _rxFormProps ) const
450 {
451 Reference< XPropertySet > xTable;
452 try
453 {
454 Reference< XTablesSupplier > xTablesInForm( ::dbtools::getCurrentSettingsComposer( _rxFormProps, m_xContext, nullptr ), UNO_QUERY );
455 Reference< XNameAccess > xTables;
456 if ( xTablesInForm.is() )
457 xTables = xTablesInForm->getTables();
458 Sequence< OUString > aTableNames;
459 if ( xTables.is() )
460 aTableNames = xTables->getElementNames();
461
462 if ( aTableNames.getLength() == 1 )
463 {
464 xTables->getByName( aTableNames[ 0 ] ) >>= xTable;
465 OSL_ENSURE( xTable.is(), "FormLinkDialog::getCanonicUnderlyingTable: invalid table!" );
466 }
467 }
468 catch( const Exception& )
469 {
470 TOOLS_WARN_EXCEPTION( "extensions.propctrlr", "FormLinkDialog::getCanonicUnderlyingTable" );
471 }
472 return xTable;
473 }
474
475
476 bool FormLinkDialog::getExistingRelation( const Reference< XPropertySet >& _rxLHS, const Reference< XPropertySet >& /*_rxRHS*/,
477 // TODO: fix the usage of _rxRHS. This is issue #i81956#.
478 std::vector< OUString >& _rLeftFields, std::vector< OUString >& _rRightFields )
479 {
480 try
481 {
482 Reference< XKeysSupplier > xSuppKeys( _rxLHS, UNO_QUERY );
483 Reference< XIndexAccess > xKeys;
484 if ( xSuppKeys.is() )
485 xKeys = xSuppKeys->getKeys();
486
487 if ( xKeys.is() )
488 {
489 Reference< XPropertySet > xKey;
490 Reference< XColumnsSupplier > xKeyColSupp( xKey, UNO_QUERY );
491 Reference< XIndexAccess > xKeyColumns;
492 Reference< XPropertySet > xKeyColumn;
493 OUString sColumnName, sRelatedColumnName;
494
495 const sal_Int32 keyCount = xKeys->getCount();
496 for ( sal_Int32 key = 0; key < keyCount; ++key )
497 {
498 xKeys->getByIndex( key ) >>= xKey;
499 sal_Int32 nKeyType = 0;
500 xKey->getPropertyValue("Type") >>= nKeyType;
501 if ( nKeyType != KeyType::FOREIGN )
502 continue;
503
504 xKeyColumns.clear();
505 xKeyColSupp.set(xKey, css::uno::UNO_QUERY);
506 if ( xKeyColSupp.is() )
507 xKeyColumns.set(xKeyColSupp->getColumns(), css::uno::UNO_QUERY);
508 OSL_ENSURE( xKeyColumns.is(), "FormLinkDialog::getExistingRelation: could not obtain the columns for the key!" );
509
510 if ( !xKeyColumns.is() )
511 continue;
512
513 const sal_Int32 columnCount = xKeyColumns->getCount();
514 _rLeftFields.resize( columnCount );
515 _rRightFields.resize( columnCount );
516 for ( sal_Int32 column = 0; column < columnCount; ++column )
517 {
518 xKeyColumn.clear();
519 xKeyColumns->getByIndex( column ) >>= xKeyColumn;
520 OSL_ENSURE( xKeyColumn.is(), "FormLinkDialog::getExistingRelation: invalid key column!" );
521 if ( xKeyColumn.is() )
522 {
523 xKeyColumn->getPropertyValue( PROPERTY_NAME ) >>= sColumnName;
524 xKeyColumn->getPropertyValue("RelatedColumn") >>= sRelatedColumnName;
525
526 _rLeftFields[ column ] = sColumnName;
527 _rRightFields[ column ] = sRelatedColumnName;
528 }
529 }
530 }
531 }
532 }
533 catch( const Exception& )
534 {
535 TOOLS_WARN_EXCEPTION( "extensions.propctrlr", "FormLinkDialog::getExistingRelation" );
536 }
537
538 return ( !_rLeftFields.empty() ) && ( !_rLeftFields[ 0 ].isEmpty() );
539 }
540
541
543 {
544 if ( !m_xDetailForm.is() || !m_xMasterForm.is() )
545 return;
546
547 try
548 {
549 // only show the button when both forms are based on the same data source
550 OUString sMasterDS, sDetailDS;
551 m_xMasterForm->getPropertyValue( PROPERTY_DATASOURCE ) >>= sMasterDS;
552 m_xDetailForm->getPropertyValue( PROPERTY_DATASOURCE ) >>= sDetailDS;
553 bool bEnable = ( sMasterDS == sDetailDS );
554
555 // only show the button when the connection supports relations
556 if ( bEnable )
557 {
558 Reference< XDatabaseMetaData > xMeta;
560 OSL_ENSURE( xMeta.is(), "FormLinkDialog::initializeSuggest: unable to retrieve the meta data for the connection!" );
561 try
562 {
563 bEnable = xMeta.is() && xMeta->supportsIntegrityEnhancementFacility();
564 }
565 catch(const Exception&)
566 {
567 bEnable = false;
568 }
569 }
570
571 // only enable the button if there is a "canonic" table underlying both forms
572 Reference< XPropertySet > xDetailTable, xMasterTable;
573 if ( bEnable )
574 {
577 bEnable = xDetailTable.is() && xMasterTable.is();
578 }
579
580 // only enable the button if there is a relation between both tables
583 if ( bEnable )
584 {
585 bEnable = getExistingRelation( xDetailTable, xMasterTable, m_aRelationDetailColumns, m_aRelationMasterColumns );
587 "extensions.propctrlr",
588 "FormLinkDialog::initializeSuggest: nonsense!" );
589 if ( m_aRelationMasterColumns.empty() )
590 { // okay, there is no relation "pointing" (via a foreign key) from the detail table to the master table
591 // but perhaps the other way round (would make less sense, but who knows ...)
592 bEnable = getExistingRelation( xMasterTable, xDetailTable, m_aRelationMasterColumns, m_aRelationDetailColumns );
593 }
594 }
595
596 // only enable the button if the relation contains at most 4 field pairs
597 if ( bEnable )
598 {
599 bEnable = ( m_aRelationMasterColumns.size() <= 4 );
600 }
601
602 m_xSuggest->set_sensitive(bEnable);
603 }
604 catch( const Exception& )
605 {
606 TOOLS_WARN_EXCEPTION( "extensions.propctrlr", "FormLinkDialog::initializeSuggest" );
607 }
608 }
609
611 {
612 initializeFieldRowsFrom( m_aRelationDetailColumns, m_aRelationMasterColumns );
613 }
614
615 IMPL_LINK_NOARG( FormLinkDialog, OnFieldChanged, FieldLinkRow&, void )
616 {
617 updateOkButton();
618 }
619
620 IMPL_LINK_NOARG( FormLinkDialog, OnInitialize, void*, void )
621 {
622 initializeColumnLabels();
623 initializeFieldLists();
624 initializeLinks();
625 initializeSuggest();
626 }
627
628} // namespace pcr
629
630
631/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static ImplSVEvent * PostUserEvent(const Link< void *, void > &rLink, void *pCaller=nullptr, bool bReferenceLink=false)
const css::uno::Any & get() const
void fillList(LinkParticipant _eWhich, const Sequence< OUString > &_rFieldNames)
std::unique_ptr< weld::ComboBox > m_xDetailColumn
void SetLinkChangeHandler(const Link< FieldLinkRow &, void > &_rHdl)
Link< FieldLinkRow &, void > m_aLinkChangeHandler
FieldLinkRow(std::unique_ptr< weld::ComboBox > xDetailColumn, std::unique_ptr< weld::ComboBox > xMasterColumn)
bool GetFieldName(LinkParticipant _eWhich, OUString &_rName) const
retrieves the selected field name for either the master or the detail field
std::unique_ptr< weld::ComboBox > m_xMasterColumn
DECL_LINK(OnFieldNameChanged, weld::ComboBox &, void)
void SetFieldName(LinkParticipant _eWhich, const OUString &_rName)
std::unique_ptr< FieldLinkRow > m_xRow4
static OUString getFormDataSourceType(const css::uno::Reference< css::beans::XPropertySet > &_rxForm)
css::uno::Reference< css::uno::XComponentContext > m_xContext
std::unique_ptr< weld::Label > m_xExplanation
std::vector< OUString > m_aRelationMasterColumns
std::unique_ptr< FieldLinkRow > m_xRow1
std::vector< OUString > m_aRelationDetailColumns
css::uno::Reference< css::beans::XPropertySet > m_xDetailForm
css::uno::Reference< css::beans::XPropertySet > getCanonicUnderlyingTable(const css::uno::Reference< css::beans::XPropertySet > &_rxFormProps) const
static bool getExistingRelation(const css::uno::Reference< css::beans::XPropertySet > &_rxLHS, const css::uno::Reference< css::beans::XPropertySet > &_rxRHS, std::vector< OUString > &_rLeftFields, std::vector< OUString > &_rRightFields)
std::unique_ptr< weld::Label > m_xDetailLabel
std::unique_ptr< FieldLinkRow > m_xRow3
std::unique_ptr< weld::Button > m_xSuggest
static void getConnectionMetaData(const css::uno::Reference< css::beans::XPropertySet > &_rxFormProps, css::uno::Reference< css::sdbc::XDatabaseMetaData > &_rxMeta)
std::unique_ptr< FieldLinkRow > m_xRow2
void initializeFieldRowsFrom(std::vector< OUString > &_rDetailFields, std::vector< OUString > &_rMasterFields)
virtual short run() override
void getFormFields(const css::uno::Reference< css::beans::XPropertySet > &_rxForm, css::uno::Sequence< OUString > &_rNames) const
FormLinkDialog(weld::Window *_pParent, const css::uno::Reference< css::beans::XPropertySet > &_rxDetailForm, const css::uno::Reference< css::beans::XPropertySet > &_rxMasterForm, const css::uno::Reference< css::uno::XComponentContext > &_rxContext, const OUString &_sExplanation=OUString(), OUString _sDetailLabel=OUString(), OUString _sMasterLabel=OUString())
std::unique_ptr< weld::Button > m_xOK
css::uno::Reference< css::beans::XPropertySet > m_xMasterForm
virtual ~FormLinkDialog() override
std::unique_ptr< weld::Label > m_xMasterLabel
void ensureFormConnection(const css::uno::Reference< css::beans::XPropertySet > &_rxFormProps, css::uno::Reference< css::sdbc::XConnection > &_rxConnection) const
virtual OUString get_active_text() const=0
virtual void set_entry_text(const OUString &rStr)=0
void append_text(const OUString &rStr)
std::shared_ptr< weld::Dialog > m_xDialog
#define TOOLS_WARN_EXCEPTION(area, stream)
Reference< XComponentContext > m_xContext
Definition: filehandler.cxx:78
constexpr OUStringLiteral PROPERTY_NAME
Definition: formstrings.hxx:36
constexpr OUStringLiteral PROPERTY_COMMAND
constexpr OUStringLiteral PROPERTY_DETAILFIELDS
constexpr OUStringLiteral PROPERTY_MASTERFIELDS
Definition: formstrings.hxx:91
constexpr OUStringLiteral PROPERTY_COMMANDTYPE
constexpr OUStringLiteral PROPERTY_DATASOURCE
constexpr OUStringLiteral PROPERTY_ACTIVE_CONNECTION
#define SAL_WARN_IF(condition, area, stream)
@ Exception
DstType sequenceToContainer(const css::uno::Sequence< SrcType > &i_Sequence)
int i
a property handler for any virtual string properties
Definition: browserline.cxx:39
OUString PcrRes(TranslateId aId)
Definition: modulepcr.cxx:26
IMPL_LINK_NOARG(OBrowserLine, OnButtonFocus, weld::Widget &, void)
RET_OK