1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
20 #include "controlwizard.hxx"
21 #include <tools/debug.hxx>
22 #include <com/sun/star/container/XNameAccess.hpp>
23 #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
24 #include <com/sun/star/sdb/DatabaseContext.hpp>
25 #include <com/sun/star/sdb/XQueriesSupplier.hpp>
26 #include <com/sun/star/sdbc/XPreparedStatement.hpp>
27 #include <com/sun/star/container/XChild.hpp>
28 #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
29 #include <com/sun/star/frame/XModel.hpp>
30 #include <com/sun/star/sheet/XSpreadsheetView.hpp>
31 #include <com/sun/star/drawing/XDrawView.hpp>
32 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
33 #include <com/sun/star/sdb/CommandType.hpp>
34 #include <com/sun/star/sdbc/SQLWarning.hpp>
35 #include <com/sun/star/sdb/SQLContext.hpp>
36 #include <com/sun/star/task/InteractionHandler.hpp>
37 #include <comphelper/processfactory.hxx>
38 #include <comphelper/types.hxx>
39 #include <connectivity/dbtools.hxx>
40 #include <vcl/msgbox.hxx>
41 #include <comphelper/interaction.hxx>
42 #include <vcl/stdtext.hxx>
43 #include <svtools/localresaccess.hxx>
44 #include <connectivity/conncleanup.hxx>
45 #include <com/sun/star/sdbc/DataType.hpp>
46 #include <tools/urlobj.hxx>
47 #include <vcl/layout.hxx>
51 using namespace ::com::sun::star::uno
;
52 using namespace ::com::sun::star::awt
;
53 using namespace ::com::sun::star::lang
;
54 using namespace ::com::sun::star::sdb
;
55 using namespace ::com::sun::star::sdbc
;
56 using namespace ::com::sun::star::sdbcx
;
57 using namespace ::com::sun::star::beans
;
58 using namespace ::com::sun::star::container
;
59 using namespace ::com::sun::star::drawing
;
60 using namespace ::com::sun::star::frame
;
61 using namespace ::com::sun::star::sheet
;
62 using namespace ::com::sun::star::form
;
63 using namespace ::com::sun::star::task
;
64 using namespace ::svt
;
65 using namespace ::comphelper
;
66 using namespace ::dbtools
;
68 struct OAccessRegulator
70 friend class OControlWizardPage
;
73 OAccessRegulator() { }
76 OControlWizardPage::OControlWizardPage( OControlWizard
* _pParent
, const OString
& rID
, const OUString
& rUIXMLDescription
)
77 :OControlWizardPage_Base( _pParent
, rID
, rUIXMLDescription
)
78 ,m_pFormDatasourceLabel(NULL
)
79 ,m_pFormDatasource(NULL
)
80 ,m_pFormContentTypeLabel(NULL
)
81 ,m_pFormContentType(NULL
)
82 ,m_pFormTableLabel(NULL
)
87 OControlWizardPage::~OControlWizardPage()
92 void OControlWizardPage::dispose()
94 m_pFormDatasourceLabel
.clear();
95 m_pFormDatasource
.clear();
96 m_pFormContentTypeLabel
.clear();
97 m_pFormContentType
.clear();
98 m_pFormTableLabel
.clear();
100 OControlWizardPage_Base::dispose();
103 OControlWizard
* OControlWizardPage::getDialog()
105 return static_cast< OControlWizard
* >(GetParent());
108 const OControlWizard
* OControlWizardPage::getDialog() const
110 return static_cast< OControlWizard
* >(GetParent());
114 bool OControlWizardPage::updateContext()
116 return getDialog()->updateContext(OAccessRegulator());
120 Reference
< XConnection
> OControlWizardPage::getFormConnection() const
122 return getDialog()->getFormConnection(OAccessRegulator());
126 void OControlWizardPage::setFormConnection( const Reference
< XConnection
>& _rxConn
, bool _bAutoDispose
)
128 getDialog()->setFormConnection( OAccessRegulator(), _rxConn
, _bAutoDispose
);
132 const OControlWizardContext
& OControlWizardPage::getContext()
134 return getDialog()->getContext();
138 void OControlWizardPage::fillListBox(ListBox
& _rList
, const Sequence
< OUString
>& _rItems
, bool _bClear
)
142 const OUString
* pItems
= _rItems
.getConstArray();
143 const OUString
* pEnd
= pItems
+ _rItems
.getLength();
144 ::svt::WizardTypes::WizardState nPos
;
145 sal_Int32 nIndex
= 0;
146 for (;pItems
< pEnd
; ++pItems
, ++nIndex
)
148 nPos
= _rList
.InsertEntry(*pItems
);
149 _rList
.SetEntryData(nPos
, reinterpret_cast<void*>(nIndex
));
154 void OControlWizardPage::fillListBox(ComboBox
& _rList
, const Sequence
< OUString
>& _rItems
, bool _bClear
)
158 const OUString
* pItems
= _rItems
.getConstArray();
159 const OUString
* pEnd
= pItems
+ _rItems
.getLength();
160 ::svt::WizardTypes::WizardState nPos
;
161 sal_Int32 nIndex
= 0;
162 for (;pItems
< pEnd
; ++pItems
)
164 nPos
= _rList
.InsertEntry(*pItems
);
165 _rList
.SetEntryData(nPos
, reinterpret_cast<void*>(nIndex
));
170 void OControlWizardPage::enableFormDatasourceDisplay()
172 if (m_pFormContentType
)
176 VclFrame
*_pFrame
= get
<VclFrame
>("sourceframe");
178 get(m_pFormContentType
,"contenttype");
179 get(m_pFormContentTypeLabel
,"contenttypelabel");
180 get(m_pFormDatasource
, "datasource");
181 get(m_pFormDatasourceLabel
, "datasourcelabel");
182 get(m_pFormTable
,"formtable");
183 get(m_pFormTableLabel
,"formtablelabel");
185 const OControlWizardContext
& rContext
= getContext();
186 if ( rContext
.bEmbedded
)
188 m_pFormDatasourceLabel
->Hide();
189 m_pFormDatasource
->Hide();
190 m_pFormContentTypeLabel
->SetPosPixel(m_pFormDatasourceLabel
->GetPosPixel());
191 m_pFormContentType
->SetPosPixel(m_pFormDatasource
->GetPosPixel());
192 m_pFormTableLabel
->SetPosPixel(::Point(m_pFormDatasourceLabel
->GetPosPixel().X(),m_pFormTableLabel
->GetPosPixel().Y()));
193 m_pFormTable
->SetPosPixel(::Point(m_pFormDatasource
->GetPosPixel().X(),m_pFormTable
->GetPosPixel().Y()));
197 void OControlWizardPage::initializePage()
199 if (m_pFormDatasource
&& m_pFormContentTypeLabel
&& m_pFormTable
)
201 const OControlWizardContext
& rContext
= getContext();
202 OUString sDataSource
;
204 sal_Int32 nCommandType
= CommandType::COMMAND
;
207 rContext
.xForm
->getPropertyValue("DataSourceName") >>= sDataSource
;
208 rContext
.xForm
->getPropertyValue("Command") >>= sCommand
;
209 rContext
.xForm
->getPropertyValue("CommandType") >>= nCommandType
;
211 catch(const Exception
&)
213 OSL_FAIL("OControlWizardPage::initializePage: caught an exception!");
216 INetURLObject
aURL( sDataSource
);
217 if( aURL
.GetProtocol() != INetProtocol::NotValid
)
218 sDataSource
= aURL
.GetName(INetURLObject::DECODE_WITH_CHARSET
);
219 m_pFormDatasource
->SetText(sDataSource
);
220 m_pFormTable
->SetText(sCommand
);
222 ::svt::WizardTypes::WizardState nCommandTypeResourceId
= 0;
223 switch (nCommandType
)
225 case CommandType::TABLE
:
226 nCommandTypeResourceId
= RID_STR_TYPE_TABLE
;
229 case CommandType::QUERY
:
230 nCommandTypeResourceId
= RID_STR_TYPE_QUERY
;
234 nCommandTypeResourceId
= RID_STR_TYPE_COMMAND
;
237 m_pFormContentType
->SetText(ModuleRes(nCommandTypeResourceId
).toString());
240 OControlWizardPage_Base::initializePage();
243 OControlWizard::OControlWizard( vcl::Window
* _pParent
,
244 const Reference
< XPropertySet
>& _rxObjectModel
, const Reference
< XComponentContext
>& _rxContext
)
245 :OWizardMachine(_pParent
, WizardButtonFlags::CANCEL
| WizardButtonFlags::PREVIOUS
| WizardButtonFlags::NEXT
| WizardButtonFlags::FINISH
)
246 ,m_xContext(_rxContext
)
248 m_aContext
.xObjectModel
= _rxObjectModel
;
251 SetPageSizePixel(LogicToPixel(::Size(WINDOW_SIZE_X
, WINDOW_SIZE_Y
), MAP_APPFONT
));
252 defaultButton(WizardButtonFlags::NEXT
);
253 enableButtons(WizardButtonFlags::FINISH
, false);
256 OControlWizard::~OControlWizard()
260 short OControlWizard::Execute()
262 // get the class id of the control we're dealing with
263 sal_Int16 nClassId
= FormComponentType::CONTROL
;
266 getContext().xObjectModel
->getPropertyValue("ClassId") >>= nClassId
;
268 catch(const Exception
&)
270 OSL_FAIL("OControlWizard::activate: could not obtain the class id!");
272 if (!approveControl(nClassId
))
274 // TODO: MessageBox or exception
280 return OControlWizard_Base::Execute();
284 void OControlWizard::ActivatePage()
286 OControlWizard_Base::ActivatePage();
290 void OControlWizard::implDetermineShape()
292 Reference
< XIndexAccess
> xPageObjects(m_aContext
.xDrawPage
, UNO_QUERY
);
293 DBG_ASSERT(xPageObjects
.is(), "OControlWizard::implDetermineShape: invalid page!");
295 // for comparing the model
296 Reference
< XControlModel
> xModelCompare(m_aContext
.xObjectModel
, UNO_QUERY
);
298 if (xPageObjects
.is())
300 // loop through all objects of the page
301 sal_Int32 nObjects
= xPageObjects
->getCount();
302 Reference
< XControlShape
> xControlShape
;
303 Reference
< XControlModel
> xControlModel
;
304 for (sal_Int32 i
=0; i
<nObjects
; ++i
)
306 if (xPageObjects
->getByIndex(i
) >>= xControlShape
)
307 { // it _is_ a control shape
308 xControlModel
= xControlShape
->getControl();
309 DBG_ASSERT(xControlModel
.is(), "OControlWizard::implDetermineShape: control shape without model!");
310 if (xModelCompare
.get() == xControlModel
.get())
312 m_aContext
.xObjectShape
= xControlShape
;
321 void OControlWizard::implDetermineForm()
323 Reference
< XChild
> xModelAsChild(m_aContext
.xObjectModel
, UNO_QUERY
);
324 Reference
< XInterface
> xControlParent
;
325 if (xModelAsChild
.is())
326 xControlParent
= xModelAsChild
->getParent();
328 m_aContext
.xForm
= Reference
< XPropertySet
>(xControlParent
, UNO_QUERY
);
329 m_aContext
.xRowSet
= Reference
< XRowSet
>(xControlParent
, UNO_QUERY
);
330 DBG_ASSERT(m_aContext
.xForm
.is() && m_aContext
.xRowSet
.is(),
331 "OControlWizard::implDetermineForm: missing some interfaces of the control parent!");
336 void OControlWizard::implDeterminePage()
340 // get the document model
341 Reference
< XChild
> xControlAsChild(m_aContext
.xObjectModel
, UNO_QUERY
);
342 Reference
< XChild
> xModelSearch(xControlAsChild
->getParent(), UNO_QUERY
);
344 Reference
< XModel
> xModel(xModelSearch
, UNO_QUERY
);
345 while (xModelSearch
.is() && !xModel
.is())
347 xModelSearch
= Reference
< XChild
>(xModelSearch
->getParent(), UNO_QUERY
);
348 xModel
= Reference
< XModel
>(xModelSearch
, UNO_QUERY
);
351 Reference
< XDrawPage
> xPage
;
354 m_aContext
.xDocumentModel
= xModel
;
356 Reference
< XDrawPageSupplier
> xPageSupp(xModel
, UNO_QUERY
);
358 { // it's a document with only one page -> Writer
359 xPage
= xPageSupp
->getDrawPage();
363 // get the controller currently working on this model
364 Reference
< XController
> xController
= xModel
->getCurrentController();
365 DBG_ASSERT(xController
.is(), "OControlWizard::implDeterminePage: no current controller!");
367 // maybe it's a spreadsheet
368 Reference
< XSpreadsheetView
> xView(xController
, UNO_QUERY
);
371 Reference
< XSpreadsheet
> xSheet
= xView
->getActiveSheet();
372 xPageSupp
= Reference
< XDrawPageSupplier
>(xSheet
, UNO_QUERY
);
373 DBG_ASSERT(xPageSupp
.is(), "OControlWizard::implDeterminePage: a spreadsheet which is no page supplier!");
375 xPage
= xPageSupp
->getDrawPage();
378 { // can be a draw/impress doc only
379 Reference
< XDrawView
> xDrawView(xController
, UNO_QUERY
);
380 DBG_ASSERT(xDrawView
.is(), "OControlWizard::implDeterminePage: no alternatives left ... can't determine the page!");
382 xPage
= xDrawView
->getCurrentPage();
388 DBG_ASSERT(xPage
.is(), "OControlWizard::implDeterminePage: can't determine the page (no model)!");
390 m_aContext
.xDrawPage
= xPage
;
392 catch(const Exception
&)
394 OSL_FAIL("OControlWizard::implDeterminePage: caught an exception!");
399 void OControlWizard::implGetDSContext()
403 DBG_ASSERT(m_xContext
.is(), "OControlWizard::implGetDSContext: invalid service factory!");
405 m_aContext
.xDatasourceContext
= DatabaseContext::create(m_xContext
);
407 catch(const Exception
&)
409 OSL_FAIL("OControlWizard::implGetDSContext: invalid database context!");
414 Reference
< XConnection
> OControlWizard::getFormConnection(const OAccessRegulator
&) const
416 return getFormConnection();
419 Reference
< XConnection
> OControlWizard::getFormConnection() const
421 Reference
< XConnection
> xConn
;
424 if ( !::dbtools::isEmbeddedInDatabase(m_aContext
.xForm
,xConn
) )
425 m_aContext
.xForm
->getPropertyValue("ActiveConnection") >>= xConn
;
427 catch(const Exception
&)
429 OSL_FAIL("OControlWizard::getFormConnection: caught an exception!");
435 void OControlWizard::setFormConnection( const OAccessRegulator
& _rAccess
, const Reference
< XConnection
>& _rxConn
, bool _bAutoDispose
)
439 Reference
< XConnection
> xOldConn
= getFormConnection(_rAccess
);
440 if (xOldConn
.get() == _rxConn
.get())
443 disposeComponent(xOldConn
);
445 // set the new connection
448 // for this, use a AutoDisposer (so the conn is cleaned up when the form dies or get's another connection)
449 Reference
< XRowSet
> xFormRowSet( m_aContext
.xForm
, UNO_QUERY
);
450 OAutoConnectionDisposer
* pAutoDispose
= new OAutoConnectionDisposer( xFormRowSet
, _rxConn
);
451 Reference
< XPropertyChangeListener
> xEnsureDelete( pAutoDispose
);
455 m_aContext
.xForm
->setPropertyValue("ActiveConnection", makeAny( _rxConn
) );
458 catch(const Exception
&)
460 OSL_FAIL("OControlWizard::setFormConnection: caught an exception!");
465 bool OControlWizard::updateContext(const OAccessRegulator
&)
467 return initContext();
470 Reference
< XInteractionHandler
> OControlWizard::getInteractionHandler(vcl::Window
* _pWindow
) const
472 Reference
< XInteractionHandler
> xHandler
;
475 xHandler
= Reference
< XInteractionHandler
>( InteractionHandler::createWithParent(m_xContext
, 0), UNO_QUERY_THROW
);
477 catch(const Exception
&) { }
480 const OUString
sInteractionHandlerServiceName("com.sun.star.task.InteractionHandler");
481 ShowServiceNotAvailableError(_pWindow
, sInteractionHandlerServiceName
, true);
486 bool OControlWizard::initContext()
488 DBG_ASSERT(m_aContext
.xObjectModel
.is(), "OGroupBoxWizard::initContext: have no control model to work with!");
489 if (!m_aContext
.xObjectModel
.is())
493 m_aContext
.xForm
.clear();
494 m_aContext
.xRowSet
.clear();
495 m_aContext
.xDocumentModel
.clear();
496 m_aContext
.xDrawPage
.clear();
497 m_aContext
.xObjectShape
.clear();
498 m_aContext
.aFieldNames
.realloc(0);
500 m_aContext
.xObjectContainer
.clear();
501 m_aContext
.aTypes
.clear();
502 m_aContext
.bEmbedded
= false;
505 Reference
< XPreparedStatement
> xStatement
;
508 // get the datasource context
511 // first, determine the form the control belongs to
514 // need the page, too
517 // the shape of the control
518 implDetermineShape();
520 // get the columns of the object the settins refer to
521 Reference
< XNameAccess
> xColumns
;
523 if (m_aContext
.xForm
.is())
525 // collect some properties of the form
526 OUString sObjectName
= ::comphelper::getString(m_aContext
.xForm
->getPropertyValue("Command"));
527 sal_Int32 nObjectType
= ::comphelper::getINT32(m_aContext
.xForm
->getPropertyValue("CommandType"));
529 // calculate the connection the rowset is working with
530 Reference
< XConnection
> xConnection
;
531 m_aContext
.bEmbedded
= ::dbtools::isEmbeddedInDatabase( m_aContext
.xForm
, xConnection
);
532 if ( !m_aContext
.bEmbedded
)
533 xConnection
= ::dbtools::connectRowset( m_aContext
.xRowSet
, m_xContext
, true );
536 if (xConnection
.is())
542 Reference
< XTablesSupplier
> xSupplyTables(xConnection
, UNO_QUERY
);
543 if (xSupplyTables
.is() && xSupplyTables
->getTables().is() && xSupplyTables
->getTables()->hasByName(sObjectName
))
545 Reference
< XColumnsSupplier
> xSupplyColumns
;
546 m_aContext
.xObjectContainer
= xSupplyTables
->getTables();
547 m_aContext
.xObjectContainer
->getByName(sObjectName
) >>= xSupplyColumns
;
548 DBG_ASSERT(xSupplyColumns
.is(), "OControlWizard::initContext: invalid table columns!");
549 xColumns
= xSupplyColumns
->getColumns();
555 Reference
< XQueriesSupplier
> xSupplyQueries(xConnection
, UNO_QUERY
);
556 if (xSupplyQueries
.is() && xSupplyQueries
->getQueries().is() && xSupplyQueries
->getQueries()->hasByName(sObjectName
))
558 Reference
< XColumnsSupplier
> xSupplyColumns
;
559 m_aContext
.xObjectContainer
= xSupplyQueries
->getQueries();
560 m_aContext
.xObjectContainer
->getByName(sObjectName
) >>= xSupplyColumns
;
561 DBG_ASSERT(xSupplyColumns
.is(), "OControlWizard::initContext: invalid query columns!");
562 xColumns
= xSupplyColumns
->getColumns();
568 xStatement
= xConnection
->prepareStatement(sObjectName
);
570 // not interested in any results, only in the fields
571 Reference
< XPropertySet
> xStatementProps(xStatement
, UNO_QUERY
);
572 xStatementProps
->setPropertyValue("MaxRows", makeAny(sal_Int32(0)));
574 // TODO: think about handling local SQLExceptions here ...
575 Reference
< XColumnsSupplier
> xSupplyCols(xStatement
->executeQuery(), UNO_QUERY
);
576 if (xSupplyCols
.is())
577 xColumns
= xSupplyCols
->getColumns();
585 m_aContext
.aFieldNames
= xColumns
->getElementNames();
586 static const char s_sFieldTypeProperty
[] = "Type";
587 const OUString
* pBegin
= m_aContext
.aFieldNames
.getConstArray();
588 const OUString
* pEnd
= pBegin
+ m_aContext
.aFieldNames
.getLength();
589 for(;pBegin
!= pEnd
;++pBegin
)
591 sal_Int32 nFieldType
= DataType::OTHER
;
594 Reference
< XPropertySet
> xColumn
;
595 xColumns
->getByName(*pBegin
) >>= xColumn
;
596 xColumn
->getPropertyValue(s_sFieldTypeProperty
) >>= nFieldType
;
598 catch(const Exception
&)
600 OSL_FAIL("OControlWizard::initContext: unexpected exception while gathering column information!");
602 m_aContext
.aTypes
.insert(OControlWizardContext::TNameTypeMap::value_type(*pBegin
,nFieldType
));
606 catch(const SQLContext
& e
) { aSQLException
<<= e
; }
607 catch(const SQLWarning
& e
) { aSQLException
<<= e
; }
608 catch(const SQLException
& e
) { aSQLException
<<= e
; }
609 catch(const Exception
&)
611 OSL_FAIL("OControlWizard::initContext: could not retrieve the control context (caught an exception)!");
614 ::comphelper::disposeComponent(xStatement
);
616 if (aSQLException
.hasValue())
617 { // an SQLException (or derivee) was thrown ...
619 // prepend an extra SQLContext explaining what we were doing
621 aContext
.Message
= ModuleRes(RID_STR_COULDNOTOPENTABLE
).toString();
622 aContext
.NextException
= aSQLException
;
624 // create an interaction handler to display this exception
625 Reference
< XInteractionHandler
> xHandler
= getInteractionHandler(this);
626 if ( !xHandler
.is() )
629 Reference
< XInteractionRequest
> xRequest
= new OInteractionRequest(makeAny(aContext
));
632 xHandler
->handle(xRequest
);
634 catch(const Exception
&) { }
638 return 0 != m_aContext
.aFieldNames
.getLength();
642 void OControlWizard::commitControlSettings(OControlWizardSettings
* _pSettings
)
644 DBG_ASSERT(m_aContext
.xObjectModel
.is(), "OControlWizard::commitControlSettings: have no control model to work with!");
645 if (!m_aContext
.xObjectModel
.is())
648 // the only thing we have at the moment is the label
651 OUString
sLabelPropertyName("Label");
652 Reference
< XPropertySetInfo
> xInfo
= m_aContext
.xObjectModel
->getPropertySetInfo();
653 if (xInfo
.is() && xInfo
->hasPropertyByName(sLabelPropertyName
))
655 OUString
sControlLabel(_pSettings
->sControlLabel
);
656 m_aContext
.xObjectModel
->setPropertyValue(
658 makeAny(sControlLabel
)
662 catch(const Exception
&)
664 OSL_FAIL("OControlWizard::commitControlSettings: could not commit the basic control settings!");
669 void OControlWizard::initControlSettings(OControlWizardSettings
* _pSettings
)
671 DBG_ASSERT(m_aContext
.xObjectModel
.is(), "OControlWizard::initControlSettings: have no control model to work with!");
672 if (!m_aContext
.xObjectModel
.is())
675 // initialize some settings from the control model give
678 OUString
sLabelPropertyName("Label");
679 Reference
< XPropertySetInfo
> xInfo
= m_aContext
.xObjectModel
->getPropertySetInfo();
680 if (xInfo
.is() && xInfo
->hasPropertyByName(sLabelPropertyName
))
682 OUString sControlLabel
;
683 m_aContext
.xObjectModel
->getPropertyValue(sLabelPropertyName
) >>= sControlLabel
;
684 _pSettings
->sControlLabel
= sControlLabel
;
687 catch(const Exception
&)
689 OSL_FAIL("OControlWizard::initControlSettings: could not retrieve the basic control settings!");
694 bool OControlWizard::needDatasourceSelection()
697 return (0 == getContext().aFieldNames
.getLength());
698 // if we got fields, the data source is valid ...
705 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */