Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / extensions / source / propctrlr / formlinkdialog.cxx
blob746b7e50a139ec4654a005e723b1ed3e2cdd22e6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include "formlinkdialog.hxx"
23 #include "modulepcr.hxx"
24 #include <strings.hrc>
25 #include "formstrings.hxx"
26 #include <sal/log.hxx>
27 #include <vcl/svapp.hxx>
28 #include <connectivity/dbtools.hxx>
29 #include <connectivity/dbexception.hxx>
30 #include <comphelper/sequence.hxx>
32 #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
33 #include <com/sun/star/sdbcx/XKeysSupplier.hpp>
34 #include <com/sun/star/sdbcx/KeyType.hpp>
35 #include <com/sun/star/container/XNameAccess.hpp>
36 #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
37 #include <com/sun/star/sdbc/XRowSet.hpp>
38 #include <com/sun/star/sdb/CommandType.hpp>
39 #include <com/sun/star/sdb/SQLContext.hpp>
42 namespace pcr
46 using namespace ::com::sun::star::uno;
47 using namespace ::com::sun::star::lang;
48 using namespace ::com::sun::star::form;
49 using namespace ::com::sun::star::sdb;
50 using namespace ::com::sun::star::sdbc;
51 using namespace ::com::sun::star::sdbcx;
52 using namespace ::com::sun::star::beans;
53 using namespace ::com::sun::star::container;
56 //= FieldLinkRow
58 class FieldLinkRow
60 private:
61 std::unique_ptr<weld::ComboBox> m_xDetailColumn;
62 std::unique_ptr<weld::ComboBox> m_xMasterColumn;
64 Link<FieldLinkRow&,void> m_aLinkChangeHandler;
66 public:
67 FieldLinkRow(std::unique_ptr<weld::ComboBox> xDetailColumn,
68 std::unique_ptr<weld::ComboBox> xMasterColumn);
71 void SetLinkChangeHandler( const Link<FieldLinkRow&,void>& _rHdl ) { m_aLinkChangeHandler = _rHdl; }
73 enum LinkParticipant
75 eDetailField,
76 eMasterField
78 /** retrieves the selected field name for either the master or the detail field
79 @return <TRUE/> if and only a valid field is selected
81 bool GetFieldName( LinkParticipant _eWhich, OUString& /* [out] */ _rName ) const;
82 void SetFieldName( LinkParticipant _eWhich, const OUString& _rName );
84 void fillList( LinkParticipant _eWhich, const Sequence< OUString >& _rFieldNames );
86 void Show()
88 m_xDetailColumn->show();
89 m_xMasterColumn->show();
92 private:
93 DECL_LINK( OnFieldNameChanged, weld::ComboBox&, void );
97 FieldLinkRow::FieldLinkRow(std::unique_ptr<weld::ComboBox> xDetailColumn,
98 std::unique_ptr<weld::ComboBox> xMasterColumn)
99 : m_xDetailColumn(std::move(xDetailColumn))
100 , m_xMasterColumn(std::move(xMasterColumn))
102 m_xDetailColumn->connect_changed( LINK( this, FieldLinkRow, OnFieldNameChanged ) );
103 m_xMasterColumn->connect_changed( LINK( this, FieldLinkRow, OnFieldNameChanged ) );
106 void FieldLinkRow::fillList( LinkParticipant _eWhich, const Sequence< OUString >& _rFieldNames )
108 weld::ComboBox* pBox = ( _eWhich == eDetailField ) ? m_xDetailColumn.get() : m_xMasterColumn.get();
110 const OUString* pFieldName = _rFieldNames.getConstArray();
111 const OUString* pFieldNameEnd = pFieldName + _rFieldNames.getLength();
112 for ( ; pFieldName != pFieldNameEnd; ++pFieldName )
113 pBox->append_text( *pFieldName );
116 bool FieldLinkRow::GetFieldName( LinkParticipant _eWhich, OUString& /* [out] */ _rName ) const
118 const weld::ComboBox* pBox = ( _eWhich == eDetailField ) ? m_xDetailColumn.get() : m_xMasterColumn.get();
119 _rName = pBox->get_active_text();
120 return !_rName.isEmpty();
123 void FieldLinkRow::SetFieldName( LinkParticipant _eWhich, const OUString& _rName )
125 weld::ComboBox* pBox = ( _eWhich == eDetailField ) ? m_xDetailColumn.get() : m_xMasterColumn.get();
126 pBox->set_entry_text( _rName );
129 IMPL_LINK_NOARG( FieldLinkRow, OnFieldNameChanged, weld::ComboBox&, void )
131 m_aLinkChangeHandler.Call( *this );
134 //= FormLinkDialog
136 FormLinkDialog::FormLinkDialog(weld::Window* _pParent, const Reference< XPropertySet >& _rxDetailForm,
137 const Reference< XPropertySet >& _rxMasterForm, const Reference< XComponentContext >& _rxContext,
138 const OUString& _sExplanation,
139 const OUString& _sDetailLabel,
140 const OUString& _sMasterLabel)
141 : GenericDialogController(_pParent, "modules/spropctrlr/ui/formlinksdialog.ui", "FormLinks")
142 , m_xContext ( _rxContext )
143 , m_xDetailForm( _rxDetailForm )
144 , m_xMasterForm( _rxMasterForm )
145 , m_sDetailLabel(_sDetailLabel)
146 , m_sMasterLabel(_sMasterLabel)
147 , m_xExplanation(m_xBuilder->weld_label("explanationLabel"))
148 , m_xDetailLabel(m_xBuilder->weld_label("detailLabel"))
149 , m_xMasterLabel(m_xBuilder->weld_label("masterLabel"))
150 , m_xRow1(std::make_unique<FieldLinkRow>(m_xBuilder->weld_combo_box("detailCombobox1"),
151 m_xBuilder->weld_combo_box("masterCombobox1")))
152 , m_xRow2(std::make_unique<FieldLinkRow>(m_xBuilder->weld_combo_box("detailCombobox2"),
153 m_xBuilder->weld_combo_box("masterCombobox2")))
154 , m_xRow3(std::make_unique<FieldLinkRow>(m_xBuilder->weld_combo_box("detailCombobox3"),
155 m_xBuilder->weld_combo_box("masterCombobox3")))
156 , m_xRow4(std::make_unique<FieldLinkRow>(m_xBuilder->weld_combo_box("detailCombobox4"),
157 m_xBuilder->weld_combo_box("masterCombobox4")))
158 , m_xOK(m_xBuilder->weld_button("ok"))
159 , m_xSuggest(m_xBuilder->weld_button("suggestButton"))
161 m_xRow1->Show();
162 m_xRow2->Show();
163 m_xRow3->Show();
164 m_xRow4->Show();
165 m_xDialog->set_size_request(600, -1);
167 if ( !_sExplanation.isEmpty() )
168 m_xExplanation->set_label(_sExplanation);
170 m_xSuggest->connect_clicked(LINK(this, FormLinkDialog, OnSuggest));
171 m_xRow1->SetLinkChangeHandler( LINK( this, FormLinkDialog, OnFieldChanged ) );
172 m_xRow2->SetLinkChangeHandler( LINK( this, FormLinkDialog, OnFieldChanged ) );
173 m_xRow3->SetLinkChangeHandler( LINK( this, FormLinkDialog, OnFieldChanged ) );
174 m_xRow4->SetLinkChangeHandler( LINK( this, FormLinkDialog, OnFieldChanged ) );
176 Application::PostUserEvent(LINK(this, FormLinkDialog, OnInitialize));
178 updateOkButton();
181 FormLinkDialog::~FormLinkDialog()
185 void FormLinkDialog::commitLinkPairs()
187 // collect the field lists from the rows
188 std::vector< OUString > aDetailFields; aDetailFields.reserve( 4 );
189 std::vector< OUString > aMasterFields; aMasterFields.reserve( 4 );
191 const FieldLinkRow* aRows[] = {
192 m_xRow1.get(), m_xRow2.get(), m_xRow3.get(), m_xRow4.get()
195 for (const FieldLinkRow* aRow : aRows)
197 OUString sDetailField, sMasterField;
198 aRow->GetFieldName( FieldLinkRow::eDetailField, sDetailField );
199 aRow->GetFieldName( FieldLinkRow::eMasterField, sMasterField );
200 if ( sDetailField.isEmpty() && sMasterField.isEmpty() )
201 continue;
203 aDetailFields.push_back( sDetailField );
204 aMasterFields.push_back( sMasterField );
207 // and set as property values
210 if ( m_xDetailForm.is() )
212 m_xDetailForm->setPropertyValue( PROPERTY_DETAILFIELDS, makeAny( Sequence< OUString >( aDetailFields.data(), aDetailFields.size() ) ) );
213 m_xDetailForm->setPropertyValue( PROPERTY_MASTERFIELDS, makeAny( Sequence< OUString >( aMasterFields.data(), aMasterFields.size() ) ) );
216 catch( const Exception& )
218 OSL_FAIL( "FormLinkDialog::commitLinkPairs: caught an exception while setting the properties!" );
222 short FormLinkDialog::run()
224 short nResult = GenericDialogController::run();
226 if ( RET_OK == nResult )
227 commitLinkPairs();
229 return nResult;
232 void FormLinkDialog::initializeFieldLists()
234 Sequence< OUString > sDetailFields;
235 getFormFields( m_xDetailForm, sDetailFields );
237 Sequence< OUString > sMasterFields;
238 getFormFields( m_xMasterForm, sMasterFields );
240 FieldLinkRow* aRows[] = {
241 m_xRow1.get(), m_xRow2.get(), m_xRow3.get(), m_xRow4.get()
243 for (FieldLinkRow* aRow : aRows)
245 aRow->fillList( FieldLinkRow::eDetailField, sDetailFields );
246 aRow->fillList( FieldLinkRow::eMasterField, sMasterFields );
252 void FormLinkDialog::initializeColumnLabels()
254 // label for the detail form
255 OUString sDetailType = getFormDataSourceType( m_xDetailForm );
256 if ( sDetailType.isEmpty() )
258 if ( m_sDetailLabel.isEmpty() )
260 m_sDetailLabel = PcrRes(STR_DETAIL_FORM);
262 sDetailType = m_sDetailLabel;
264 m_xDetailLabel->set_label( sDetailType );
266 // label for the master form
267 OUString sMasterType = getFormDataSourceType( m_xMasterForm );
268 if ( sMasterType.isEmpty() )
270 if ( m_sMasterLabel.isEmpty() )
272 m_sMasterLabel = PcrRes(STR_MASTER_FORM);
274 sMasterType = m_sMasterLabel;
276 m_xMasterLabel->set_label( sMasterType );
279 void FormLinkDialog::initializeFieldRowsFrom( std::vector< OUString >& _rDetailFields, std::vector< OUString >& _rMasterFields )
281 // our UI does allow 4 fields max
282 _rDetailFields.resize( 4 );
283 _rMasterFields.resize( 4 );
285 FieldLinkRow* aRows[] = {
286 m_xRow1.get(), m_xRow2.get(), m_xRow3.get(), m_xRow4.get()
288 for ( sal_Int32 i = 0; i < 4; ++i )
290 aRows[ i ]->SetFieldName( FieldLinkRow::eDetailField, _rDetailFields[i] );
291 aRows[ i ]->SetFieldName( FieldLinkRow::eMasterField, _rMasterFields[i] );
296 void FormLinkDialog::initializeLinks()
300 Sequence< OUString > aDetailFields;
301 Sequence< OUString > aMasterFields;
303 if ( m_xDetailForm.is() )
305 m_xDetailForm->getPropertyValue( PROPERTY_DETAILFIELDS ) >>= aDetailFields;
306 m_xDetailForm->getPropertyValue( PROPERTY_MASTERFIELDS ) >>= aMasterFields;
309 std::vector< OUString > aDetailFields1;
310 comphelper::sequenceToContainer(aDetailFields1, aDetailFields);
311 std::vector< OUString > aMasterFields1;
312 comphelper::sequenceToContainer(aMasterFields1, aMasterFields);
313 initializeFieldRowsFrom( aDetailFields1, aMasterFields1 );
315 catch( const Exception& )
317 OSL_FAIL( "FormLinkDialog::initializeLinks: caught an exception!" );
322 void FormLinkDialog::updateOkButton()
324 // in all rows, there must be either two valid selections, or none at all
325 // If there is at least one row with exactly one valid selection, then the
326 // OKButton needs to be disabled
327 bool bEnable = true;
329 const FieldLinkRow* aRows[] = {
330 m_xRow1.get(), m_xRow2.get(), m_xRow3.get(), m_xRow4.get()
333 for ( sal_Int32 i = 0; ( i < 4 ) && bEnable; ++i )
335 OUString sNotInterestedInRightNow;
336 if ( aRows[ i ]->GetFieldName( FieldLinkRow::eDetailField, sNotInterestedInRightNow )
337 != aRows[ i ]->GetFieldName( FieldLinkRow::eMasterField, sNotInterestedInRightNow )
339 bEnable = false;
342 m_xOK->set_sensitive(bEnable);
345 OUString FormLinkDialog::getFormDataSourceType( const Reference< XPropertySet >& _rxForm )
347 OUString sReturn;
348 if ( !_rxForm.is() )
349 return sReturn;
353 sal_Int32 nCommandType = CommandType::COMMAND;
354 OUString sCommand;
356 _rxForm->getPropertyValue( PROPERTY_COMMANDTYPE ) >>= nCommandType;
357 _rxForm->getPropertyValue( PROPERTY_COMMAND ) >>= sCommand;
359 if ( ( nCommandType == CommandType::TABLE )
360 || ( nCommandType == CommandType::QUERY )
362 sReturn = sCommand;
364 catch( const Exception& )
366 OSL_FAIL( "FormLinkDialog::getFormDataSourceType: caught an exception!" );
368 return sReturn;
371 void FormLinkDialog::getFormFields( const Reference< XPropertySet >& _rxForm, Sequence< OUString >& /* [out] */ _rNames ) const
373 _rNames.realloc( 0 );
375 ::dbtools::SQLExceptionInfo aErrorInfo;
376 OUString sCommand;
379 weld::WaitObject aWaitCursor(m_xDialog.get());
381 OSL_ENSURE( _rxForm.is(), "FormLinkDialog::getFormFields: invalid form!" );
383 sal_Int32 nCommandType = CommandType::COMMAND;
385 _rxForm->getPropertyValue( PROPERTY_COMMANDTYPE ) >>= nCommandType;
386 _rxForm->getPropertyValue( PROPERTY_COMMAND ) >>= sCommand;
388 Reference< XConnection > xConnection;
389 ensureFormConnection( _rxForm, xConnection );
391 _rNames = ::dbtools::getFieldNamesByCommandDescriptor(
392 xConnection,
393 nCommandType,
394 sCommand,
395 &aErrorInfo
398 catch (const SQLContext& e) { aErrorInfo = e; }
399 catch (const SQLWarning& e) { aErrorInfo = e; }
400 catch (const SQLException& e ) { aErrorInfo = e; }
401 catch( const Exception& )
403 OSL_FAIL( "FormLinkDialog::getFormFields: caught a non-SQL exception!" );
406 if ( aErrorInfo.isValid() )
408 OUString sErrorMessage;
410 sErrorMessage = PcrRes(STR_ERROR_RETRIEVING_COLUMNS);
411 sErrorMessage = sErrorMessage.replaceFirst("#", sCommand);
414 SQLContext aContext;
415 aContext.Message = sErrorMessage;
416 aContext.NextException = aErrorInfo.get();
417 ::dbtools::showError(aContext, m_xDialog->GetXWindow(), m_xContext);
421 void FormLinkDialog::ensureFormConnection( const Reference< XPropertySet >& _rxFormProps, Reference< XConnection >& /* [out] */ _rxConnection ) const
423 OSL_PRECOND( _rxFormProps.is(), "FormLinkDialog::ensureFormConnection: invalid form!" );
424 if ( !_rxFormProps.is() )
425 return;
426 if ( _rxFormProps->getPropertySetInfo()->hasPropertyByName(PROPERTY_ACTIVE_CONNECTION) )
427 _rxConnection.set(_rxFormProps->getPropertyValue(PROPERTY_ACTIVE_CONNECTION),UNO_QUERY);
429 if ( !_rxConnection.is() )
430 _rxConnection = ::dbtools::connectRowset( Reference< XRowSet >( _rxFormProps, UNO_QUERY ), m_xContext, nullptr );
434 void FormLinkDialog::getConnectionMetaData( const Reference< XPropertySet >& _rxFormProps, Reference< XDatabaseMetaData >& /* [out] */ _rxMeta )
436 if ( _rxFormProps.is() )
438 Reference< XConnection > xConnection;
439 if ( !::dbtools::isEmbeddedInDatabase( _rxFormProps, xConnection ) )
440 _rxFormProps->getPropertyValue( PROPERTY_ACTIVE_CONNECTION ) >>= xConnection;
441 if ( xConnection.is() )
442 _rxMeta = xConnection->getMetaData();
447 Reference< XPropertySet > FormLinkDialog::getCanonicUnderlyingTable( const Reference< XPropertySet >& _rxFormProps ) const
449 Reference< XPropertySet > xTable;
452 Reference< XTablesSupplier > xTablesInForm( ::dbtools::getCurrentSettingsComposer( _rxFormProps, m_xContext, nullptr ), UNO_QUERY );
453 Reference< XNameAccess > xTables;
454 if ( xTablesInForm.is() )
455 xTables = xTablesInForm->getTables();
456 Sequence< OUString > aTableNames;
457 if ( xTables.is() )
458 aTableNames = xTables->getElementNames();
460 if ( aTableNames.getLength() == 1 )
462 xTables->getByName( aTableNames[ 0 ] ) >>= xTable;
463 OSL_ENSURE( xTable.is(), "FormLinkDialog::getCanonicUnderlyingTable: invalid table!" );
466 catch( const Exception& )
468 OSL_FAIL( "FormLinkDialog::getCanonicUnderlyingTable: caught an exception!" );
470 return xTable;
474 bool FormLinkDialog::getExistingRelation( const Reference< XPropertySet >& _rxLHS, const Reference< XPropertySet >& /*_rxRHS*/,
475 // TODO: fix the usage of _rxRHS. This is issue #i81956#.
476 std::vector< OUString >& _rLeftFields, std::vector< OUString >& _rRightFields )
480 Reference< XKeysSupplier > xSuppKeys( _rxLHS, UNO_QUERY );
481 Reference< XIndexAccess > xKeys;
482 if ( xSuppKeys.is() )
483 xKeys = xSuppKeys->getKeys();
485 if ( xKeys.is() )
487 Reference< XPropertySet > xKey;
488 Reference< XColumnsSupplier > xKeyColSupp( xKey, UNO_QUERY );
489 Reference< XIndexAccess > xKeyColumns;
490 Reference< XPropertySet > xKeyColumn;
491 OUString sColumnName, sRelatedColumnName;
493 const sal_Int32 keyCount = xKeys->getCount();
494 for ( sal_Int32 key = 0; key < keyCount; ++key )
496 xKeys->getByIndex( key ) >>= xKey;
497 sal_Int32 nKeyType = 0;
498 xKey->getPropertyValue("Type") >>= nKeyType;
499 if ( nKeyType != KeyType::FOREIGN )
500 continue;
502 xKeyColumns.clear();
503 xKeyColSupp.set(xKey, css::uno::UNO_QUERY);
504 if ( xKeyColSupp.is() )
505 xKeyColumns.set(xKeyColSupp->getColumns(), css::uno::UNO_QUERY);
506 OSL_ENSURE( xKeyColumns.is(), "FormLinkDialog::getExistingRelation: could not obtain the columns for the key!" );
508 if ( !xKeyColumns.is() )
509 continue;
511 const sal_Int32 columnCount = xKeyColumns->getCount();
512 _rLeftFields.resize( columnCount );
513 _rRightFields.resize( columnCount );
514 for ( sal_Int32 column = 0; column < columnCount; ++column )
516 xKeyColumn.clear();
517 xKeyColumns->getByIndex( column ) >>= xKeyColumn;
518 OSL_ENSURE( xKeyColumn.is(), "FormLinkDialog::getExistingRelation: invalid key column!" );
519 if ( xKeyColumn.is() )
521 xKeyColumn->getPropertyValue( PROPERTY_NAME ) >>= sColumnName;
522 xKeyColumn->getPropertyValue("RelatedColumn") >>= sRelatedColumnName;
524 _rLeftFields[ column ] = sColumnName;
525 _rRightFields[ column ] = sRelatedColumnName;
531 catch( const Exception& )
533 OSL_FAIL( "FormLinkDialog::getExistingRelation: caught an exception!" );
536 return ( !_rLeftFields.empty() ) && ( !_rLeftFields[ 0 ].isEmpty() );
540 void FormLinkDialog::initializeSuggest()
542 if ( !m_xDetailForm.is() || !m_xMasterForm.is() )
543 return;
547 // only show the button when both forms are based on the same data source
548 OUString sMasterDS, sDetailDS;
549 m_xMasterForm->getPropertyValue( PROPERTY_DATASOURCE ) >>= sMasterDS;
550 m_xDetailForm->getPropertyValue( PROPERTY_DATASOURCE ) >>= sDetailDS;
551 bool bEnable = ( sMasterDS == sDetailDS );
553 // only show the button when the connection supports relations
554 if ( bEnable )
556 Reference< XDatabaseMetaData > xMeta;
557 getConnectionMetaData( m_xDetailForm, xMeta );
558 OSL_ENSURE( xMeta.is(), "FormLinkDialog::initializeSuggest: unable to retrieve the meta data for the connection!" );
561 bEnable = xMeta.is() && xMeta->supportsIntegrityEnhancementFacility();
563 catch(const Exception&)
565 bEnable = false;
569 // only enable the button if there is a "canonic" table underlying both forms
570 Reference< XPropertySet > xDetailTable, xMasterTable;
571 if ( bEnable )
573 xDetailTable = getCanonicUnderlyingTable( m_xDetailForm );
574 xMasterTable = getCanonicUnderlyingTable( m_xMasterForm );
575 bEnable = xDetailTable.is() && xMasterTable.is();
578 // only enable the button if there is a relation between both tables
579 m_aRelationDetailColumns.clear();
580 m_aRelationMasterColumns.clear();
581 if ( bEnable )
583 bEnable = getExistingRelation( xDetailTable, xMasterTable, m_aRelationDetailColumns, m_aRelationMasterColumns );
584 SAL_WARN_IF( m_aRelationMasterColumns.size() != m_aRelationDetailColumns.size(),
585 "extensions.propctrlr",
586 "FormLinkDialog::initializeSuggest: nonsense!" );
587 if ( m_aRelationMasterColumns.empty() )
588 { // okay, there is no relation "pointing" (via a foreign key) from the detail table to the master table
589 // but perhaps the other way round (would make less sense, but who knows ...)
590 bEnable = getExistingRelation( xMasterTable, xDetailTable, m_aRelationMasterColumns, m_aRelationDetailColumns );
594 // only enable the button if the relation contains at most 4 field pairs
595 if ( bEnable )
597 bEnable = ( m_aRelationMasterColumns.size() <= 4 );
600 m_xSuggest->set_sensitive(bEnable);
602 catch( const Exception& )
604 OSL_FAIL( "FormLinkDialog::initializeSuggest: caught an exception!" );
608 IMPL_LINK_NOARG( FormLinkDialog, OnSuggest, weld::Button&, void )
610 initializeFieldRowsFrom( m_aRelationDetailColumns, m_aRelationMasterColumns );
613 IMPL_LINK_NOARG( FormLinkDialog, OnFieldChanged, FieldLinkRow&, void )
615 updateOkButton();
618 IMPL_LINK_NOARG( FormLinkDialog, OnInitialize, void*, void )
620 initializeColumnLabels();
621 initializeFieldLists();
622 initializeLinks();
623 initializeSuggest();
626 } // namespace pcr
629 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */