23#include <com/sun/star/container/XNameAccess.hpp>
24#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
25#include <com/sun/star/sdb/DatabaseContext.hpp>
26#include <com/sun/star/sdb/XQueriesSupplier.hpp>
27#include <com/sun/star/sdbc/XPreparedStatement.hpp>
28#include <com/sun/star/container/XChild.hpp>
29#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
30#include <com/sun/star/frame/XModel.hpp>
31#include <com/sun/star/sheet/XSpreadsheetView.hpp>
32#include <com/sun/star/drawing/XDrawView.hpp>
33#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
34#include <com/sun/star/sdb/CommandType.hpp>
35#include <com/sun/star/sdbc/SQLWarning.hpp>
36#include <com/sun/star/sdb/SQLContext.hpp>
37#include <com/sun/star/task/InteractionHandler.hpp>
43#include <com/sun/star/sdbc/DataType.hpp>
46#define WIZARD_SIZE_X 60
47#define WIZARD_SIZE_Y 23
120 const OUString* pItems = _rItems.getConstArray();
121 const OUString* pEnd = pItems + _rItems.getLength();
123 for (;pItems < pEnd; ++pItems, ++
nIndex)
125 _rList.
append(OUString::number(nIndex), *pItems);
132 const OUString* pItems = _rItems.getConstArray();
133 const OUString* pEnd = pItems + _rItems.getLength();
134 for (;pItems < pEnd; ++pItems)
167 OUString sDataSource;
169 sal_Int32 nCommandType = CommandType::COMMAND;
172 rContext.
xForm->getPropertyValue(
"DataSourceName") >>= sDataSource;
173 rContext.
xForm->getPropertyValue(
"Command") >>= sCommand;
174 rContext.
xForm->getPropertyValue(
"CommandType") >>= nCommandType;
182 if(
aURL.GetProtocol() != INetProtocol::NotValid )
188 switch (nCommandType)
190 case CommandType::TABLE:
191 pCommandTypeResourceId = RID_STR_TYPE_TABLE;
194 case CommandType::QUERY:
195 pCommandTypeResourceId = RID_STR_TYPE_QUERY;
199 pCommandTypeResourceId = RID_STR_TYPE_COMMAND;
209 const Reference< XPropertySet >& _rxObjectModel,
const Reference< XComponentContext >& _rxContext )
227 sal_Int16 nClassId = FormComponentType::CONTROL;
234 OSL_FAIL(
"OControlWizard::activate: could not obtain the class id!");
252 DBG_ASSERT(xPageObjects.is(),
"OControlWizard::implDetermineShape: invalid page!");
257 if (!xPageObjects.is())
261 sal_Int32 nObjects = xPageObjects->getCount();
262 Reference< XControlShape > xControlShape;
263 Reference< XControlModel > xControlModel;
264 for (sal_Int32
i=0;
i<nObjects; ++
i)
266 if (xPageObjects->getByIndex(
i) >>= xControlShape)
268 xControlModel = xControlShape->getControl();
269 DBG_ASSERT(xControlModel.is(),
"OControlWizard::implDetermineShape: control shape without model!");
270 if (xModelCompare.get() == xControlModel.get())
284 if (xModelAsChild.is())
285 xControlParent = xModelAsChild->getParent();
290 "OControlWizard::implDetermineForm: missing some interfaces of the control parent!");
301 Reference< XChild > xModelSearch(xControlAsChild->getParent(), UNO_QUERY);
303 Reference< XModel >
xModel(xModelSearch, UNO_QUERY);
304 while (xModelSearch.is() && !
xModel.is())
306 xModelSearch.set(xModelSearch->getParent(), UNO_QUERY);
307 xModel.set(xModelSearch, UNO_QUERY);
310 Reference< XDrawPage > xPage;
315 Reference< XDrawPageSupplier > xPageSupp(
xModel, UNO_QUERY);
318 xPage = xPageSupp->getDrawPage();
327 Reference< XSpreadsheetView > xView(
xController, UNO_QUERY);
330 Reference< XSpreadsheet > xSheet = xView->getActiveSheet();
331 xPageSupp.set(xSheet, UNO_QUERY);
332 DBG_ASSERT(xPageSupp.is(),
"OControlWizard::implDeterminePage: a spreadsheet which is no page supplier!");
334 xPage = xPageSupp->getDrawPage();
338 Reference< XDrawView > xDrawView(
xController, UNO_QUERY);
339 DBG_ASSERT(xDrawView.is(),
"OControlWizard::implDeterminePage: no alternatives left ... can't determine the page!");
341 xPage = xDrawView->getCurrentPage();
347 DBG_ASSERT(xPage.is(),
"OControlWizard::implDeterminePage: can't determine the page (no model)!");
368 OSL_FAIL(
"OControlWizard::implGetDSContext: invalid database context!");
380 Reference< XConnection > xConn;
399 if (xOldConn.get() == _rxConn.get())
409 new OAutoConnectionDisposer( xFormRowSet, _rxConn );
430 Reference< XInteractionHandler > xHandler;
433 xHandler.set( InteractionHandler::createWithParent(
m_xContext,
nullptr), UNO_QUERY_THROW );
462 Reference< XPreparedStatement > xStatement;
478 Reference< XNameAccess > xColumns;
483 OUString sObjectName = ::comphelper::getString(
m_aContext.
xForm->getPropertyValue(
"Command"));
484 sal_Int32 nObjectType = ::comphelper::getINT32(
m_aContext.
xForm->getPropertyValue(
"CommandType"));
487 Reference< XConnection > xConnection;
493 if (xConnection.is())
499 Reference< XTablesSupplier > xSupplyTables(xConnection, UNO_QUERY);
500 if (xSupplyTables.is() && xSupplyTables->getTables().is() && xSupplyTables->getTables()->hasByName(sObjectName))
502 Reference< XColumnsSupplier > xSupplyColumns;
505 DBG_ASSERT(xSupplyColumns.is(),
"OControlWizard::initContext: invalid table columns!");
506 xColumns = xSupplyColumns->getColumns();
512 Reference< XQueriesSupplier > xSupplyQueries(xConnection, UNO_QUERY);
513 if (xSupplyQueries.is() && xSupplyQueries->getQueries().is() && xSupplyQueries->getQueries()->hasByName(sObjectName))
515 Reference< XColumnsSupplier > xSupplyColumns;
518 DBG_ASSERT(xSupplyColumns.is(),
"OControlWizard::initContext: invalid query columns!");
519 xColumns = xSupplyColumns->getColumns();
525 xStatement = xConnection->prepareStatement(sObjectName);
528 Reference< XPropertySet > xStatementProps(xStatement, UNO_QUERY);
529 xStatementProps->setPropertyValue(
"MaxRows",
Any(sal_Int32(0)));
532 Reference< XColumnsSupplier > xSupplyCols(xStatement->executeQuery(), UNO_QUERY);
533 if (xSupplyCols.is())
534 xColumns = xSupplyCols->getColumns();
545 for(;pBegin != pEnd;++pBegin)
547 sal_Int32 nFieldType = DataType::OTHER;
550 Reference< XPropertySet >
xColumn;
551 xColumns->getByName(*pBegin) >>=
xColumn;
552 xColumn->getPropertyValue(
"Type") >>= nFieldType;
557 "extensions.dbpilots",
558 "unexpected exception while gathering column information!");
564 catch(
const SQLContext& e) { aSQLException <<= e; }
565 catch(
const SQLWarning& e) { aSQLException <<= e; }
566 catch(
const SQLException& e) { aSQLException <<= e; }
569 TOOLS_WARN_EXCEPTION(
"extensions.dbpilots",
"OControlWizard::initContext: could not retrieve the control context");
572 ::comphelper::disposeComponent(xStatement);
574 if (aSQLException.hasValue())
580 aContext.NextException = aSQLException;
584 if ( !xHandler.is() )
587 Reference< XInteractionRequest > xRequest =
new OInteractionRequest(
Any(aContext));
590 xHandler->handle(xRequest);
610 if (xInfo.is() && xInfo->hasPropertyByName(
"Label"))
621 TOOLS_WARN_EXCEPTION(
"extensions.dbpilots",
"OControlWizard::commitControlSettings: could not commit the basic control settings!");
635 OUString sLabelPropertyName(
"Label");
637 if (xInfo.is() && xInfo->hasPropertyByName(sLabelPropertyName))
639 OUString sControlLabel;
646 TOOLS_WARN_EXCEPTION(
"extensions.dbpilots",
"OControlWizard::initControlSettings: could not retrieve the basic control settings!");
std::unique_ptr< weld::Builder > m_xBuilder
std::unique_ptr< weld::Container > m_xContainer
OControlWizardPage(weld::Container *pPage, OControlWizard *pWizard, const OUString &rUIXMLDescription, const OUString &rID)
std::unique_ptr< weld::Label > m_xFormDatasource
OControlWizard * getDialog()
css::uno::Reference< css::sdbc::XConnection > getFormConnection() const
virtual ~OControlWizardPage() override
virtual void initializePage() override
std::unique_ptr< weld::Label > m_xFormTable
std::unique_ptr< weld::Label > m_xFormContentTypeLabel
const OControlWizardContext & getContext() const
std::unique_ptr< weld::Frame > m_xFrame
void enableFormDatasourceDisplay()
void setFormConnection(const css::uno::Reference< css::sdbc::XConnection > &_rxConn, bool _bAutoDispose=true)
static void fillListBox(weld::TreeView &_rList, const css::uno::Sequence< OUString > &_rItems)
std::unique_ptr< weld::Label > m_xFormDatasourceLabel
OControlWizard * m_pDialog
std::unique_ptr< weld::Label > m_xFormContentType
css::uno::Reference< css::sdbc::XConnection > getFormConnection(const OAccessRegulator &) const
OControlWizardContext m_aContext
virtual short run() override
void initControlSettings(OControlWizardSettings *_pSettings)
virtual bool approveControl(sal_Int16 _nClassId)=0
css::uno::Reference< css::uno::XComponentContext > m_xContext
bool needDatasourceSelection()
OControlWizard(weld::Window *_pParent, const css::uno::Reference< css::beans::XPropertySet > &_rxObjectModel, const css::uno::Reference< css::uno::XComponentContext > &_rxContext)
void commitControlSettings(OControlWizardSettings const *_pSettings)
css::uno::Reference< css::sdbc::XConnection > getFormConnection() const
css::uno::Reference< css::task::XInteractionHandler > getInteractionHandler(weld::Window *_pWindow) const
returns the com.sun.star.task.InteractionHandler
bool updateContext(const OAccessRegulator &)
void implDetermineShape()
virtual ~OControlWizard() override
void setFormConnection(const OAccessRegulator &, const css::uno::Reference< css::sdbc::XConnection > &_rxConn, bool _bAutoDispose)
const OControlWizardContext & getContext() const
virtual void initializePage() override
void defaultButton(WizardButtonFlags _nWizardButtonFlags)
virtual void ActivatePage()
void enableButtons(WizardButtonFlags _nWizardButtonFlags, bool _bEnable)
std::unique_ptr< weld::Assistant > m_xAssistant
void append_text(const OUString &rStr)
void append(TreeIter *pRet=nullptr)
#define DBG_ASSERT(sCon, aError)
#define TOOLS_WARN_EXCEPTION(area, stream)
Reference< XComponentContext > m_xContext
void disposeComponent(css::uno::Reference< TYPE > &_rxComp)
OUString ModuleRes(TranslateId pId)
void VCL_DLLPUBLIC ShowServiceNotAvailableError(weld::Widget *pParent, std::u16string_view rServiceName, bool bError)
css::uno::Reference< css::beans::XPropertySet > xObjectModel
css::uno::Reference< css::drawing::XControlShape > xObjectShape
css::uno::Sequence< OUString > aFieldNames
css::uno::Reference< css::container::XNameAccess > xObjectContainer
css::uno::Reference< css::sdbc::XRowSet > xRowSet
css::uno::Reference< css::sdb::XDatabaseContext > xDatasourceContext
css::uno::Reference< css::frame::XModel > xDocumentModel
css::uno::Reference< css::drawing::XDrawPage > xDrawPage
css::uno::Reference< css::beans::XPropertySet > xForm
Reference< XController > xController
Reference< XModel > xModel