1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_dbaccess.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #ifndef DBACCESS_SOURCE_UI_UNO_COMPOSERDIALOGS_HXX 32*cdf0e10cSrcweir #include "composerdialogs.hxx" 33*cdf0e10cSrcweir #endif 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir /** === begin UNO includes === **/ 36*cdf0e10cSrcweir #ifndef _DBU_REGHELPER_HXX_ 37*cdf0e10cSrcweir #include "dbu_reghelper.hxx" 38*cdf0e10cSrcweir #endif 39*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_ 40*cdf0e10cSrcweir #include <com/sun/star/sdbcx/XColumnsSupplier.hpp> 41*cdf0e10cSrcweir #endif 42*cdf0e10cSrcweir /** === end UNO includes === **/ 43*cdf0e10cSrcweir #ifndef DBACCESS_SHARED_DBUSTRINGS_HRC 44*cdf0e10cSrcweir #include "dbustrings.hrc" 45*cdf0e10cSrcweir #endif 46*cdf0e10cSrcweir #ifndef DBAUI_QUERYFILTER_HXX 47*cdf0e10cSrcweir #include "queryfilter.hxx" 48*cdf0e10cSrcweir #endif 49*cdf0e10cSrcweir #ifndef DBAUI_QUERYORDER_HXX 50*cdf0e10cSrcweir #include "queryorder.hxx" 51*cdf0e10cSrcweir #endif 52*cdf0e10cSrcweir #ifndef _CONNECTIVITY_DBTOOLS_HXX_ 53*cdf0e10cSrcweir #include <connectivity/dbtools.hxx> 54*cdf0e10cSrcweir #endif 55*cdf0e10cSrcweir #ifndef _TOOLS_DEBUG_HXX 56*cdf0e10cSrcweir #include <tools/debug.hxx> 57*cdf0e10cSrcweir #endif 58*cdf0e10cSrcweir #ifndef TOOLS_DIAGNOSE_EX_H 59*cdf0e10cSrcweir #include <tools/diagnose_ex.h> 60*cdf0e10cSrcweir #endif 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir extern "C" void SAL_CALL createRegistryInfo_ComposerDialogs() 63*cdf0e10cSrcweir { 64*cdf0e10cSrcweir static ::dbaui::OMultiInstanceAutoRegistration< ::dbaui::RowsetOrderDialog > aOrderDialogRegistration; 65*cdf0e10cSrcweir static ::dbaui::OMultiInstanceAutoRegistration< ::dbaui::RowsetFilterDialog > aFilterDialogRegistration; 66*cdf0e10cSrcweir } 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir //......................................................................... 69*cdf0e10cSrcweir namespace dbaui 70*cdf0e10cSrcweir { 71*cdf0e10cSrcweir //......................................................................... 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir #define PROPERTY_ID_QUERYCOMPOSER 100 74*cdf0e10cSrcweir #define PROPERTY_ID_ROWSET 101 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir IMPLEMENT_CONSTASCII_USTRING( PROPERTY_QUERYCOMPOSER, "QueryComposer" ); 77*cdf0e10cSrcweir IMPLEMENT_CONSTASCII_USTRING( PROPERTY_ROWSET, "RowSet" ); 78*cdf0e10cSrcweir 79*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 80*cdf0e10cSrcweir using namespace ::com::sun::star::lang; 81*cdf0e10cSrcweir using namespace ::com::sun::star::beans; 82*cdf0e10cSrcweir using namespace ::com::sun::star::container; 83*cdf0e10cSrcweir using namespace ::com::sun::star::sdbcx; 84*cdf0e10cSrcweir using namespace ::com::sun::star::sdbc; 85*cdf0e10cSrcweir using namespace ::com::sun::star::sdb; 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir //===================================================================== 88*cdf0e10cSrcweir //= ComposerDialog 89*cdf0e10cSrcweir //===================================================================== 90*cdf0e10cSrcweir DBG_NAME(ComposerDialog) 91*cdf0e10cSrcweir //--------------------------------------------------------------------- 92*cdf0e10cSrcweir ComposerDialog::ComposerDialog(const Reference< XMultiServiceFactory >& _rxORB) 93*cdf0e10cSrcweir :ComposerDialog_BASE( _rxORB ) 94*cdf0e10cSrcweir { 95*cdf0e10cSrcweir DBG_CTOR(ComposerDialog,NULL); 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir registerProperty( PROPERTY_QUERYCOMPOSER, PROPERTY_ID_QUERYCOMPOSER, PropertyAttribute::TRANSIENT, 98*cdf0e10cSrcweir &m_xComposer, ::getCppuType( &m_xComposer ) ); 99*cdf0e10cSrcweir registerProperty( PROPERTY_ROWSET, PROPERTY_ID_ROWSET, PropertyAttribute::TRANSIENT, 100*cdf0e10cSrcweir &m_xRowSet, ::getCppuType( &m_xRowSet ) ); 101*cdf0e10cSrcweir } 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir //--------------------------------------------------------------------- 104*cdf0e10cSrcweir ComposerDialog::~ComposerDialog() 105*cdf0e10cSrcweir { 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir DBG_DTOR(ComposerDialog,NULL); 108*cdf0e10cSrcweir } 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir //--------------------------------------------------------------------- 111*cdf0e10cSrcweir IMPLEMENT_IMPLEMENTATION_ID( ComposerDialog ) 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir //--------------------------------------------------------------------- 114*cdf0e10cSrcweir IMPLEMENT_PROPERTYCONTAINER_DEFAULTS( ComposerDialog ) 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir //--------------------------------------------------------------------- 117*cdf0e10cSrcweir Dialog* ComposerDialog::createDialog(Window* _pParent) 118*cdf0e10cSrcweir { 119*cdf0e10cSrcweir // obtain all the objects needed for the dialog 120*cdf0e10cSrcweir Reference< XConnection > xConnection; 121*cdf0e10cSrcweir Reference< XNameAccess > xColumns; 122*cdf0e10cSrcweir try 123*cdf0e10cSrcweir { 124*cdf0e10cSrcweir // the connection the row set is working with 125*cdf0e10cSrcweir if ( !::dbtools::isEmbeddedInDatabase( m_xRowSet, xConnection ) ) 126*cdf0e10cSrcweir { 127*cdf0e10cSrcweir Reference< XPropertySet > xRowsetProps( m_xRowSet, UNO_QUERY ); 128*cdf0e10cSrcweir if ( xRowsetProps.is() ) 129*cdf0e10cSrcweir xRowsetProps->getPropertyValue( PROPERTY_ACTIVE_CONNECTION ) >>= xConnection; 130*cdf0e10cSrcweir } 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir // fallback: if there is a connection and thus a row set, but no composer, create one 133*cdf0e10cSrcweir if ( xConnection.is() && !m_xComposer.is() ) 134*cdf0e10cSrcweir m_xComposer = ::dbtools::getCurrentSettingsComposer( Reference< XPropertySet >( m_xRowSet, UNO_QUERY ), m_aContext.getLegacyServiceFactory() ); 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir // the columns of the row set 137*cdf0e10cSrcweir Reference< XColumnsSupplier > xSuppColumns( m_xRowSet, UNO_QUERY ); 138*cdf0e10cSrcweir if ( xSuppColumns.is() ) 139*cdf0e10cSrcweir xColumns = xSuppColumns->getColumns(); 140*cdf0e10cSrcweir 141*cdf0e10cSrcweir if ( !xColumns.is() || !xColumns->hasElements() ) 142*cdf0e10cSrcweir { // perhaps the composer can supply us with columns? This is necessary for cases 143*cdf0e10cSrcweir // where the dialog is invoked for a rowset which is not yet loaded 144*cdf0e10cSrcweir // #i22878# - 2003-12-16 - fs@openoffice.org 145*cdf0e10cSrcweir xSuppColumns = xSuppColumns.query( m_xComposer ); 146*cdf0e10cSrcweir if ( xSuppColumns.is() ) 147*cdf0e10cSrcweir xColumns = xSuppColumns->getColumns(); 148*cdf0e10cSrcweir } 149*cdf0e10cSrcweir 150*cdf0e10cSrcweir DBG_ASSERT( xColumns.is() && xColumns->hasElements(), "ComposerDialog::createDialog: not much fun without any columns!" ); 151*cdf0e10cSrcweir } 152*cdf0e10cSrcweir catch( const Exception& ) 153*cdf0e10cSrcweir { 154*cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 155*cdf0e10cSrcweir } 156*cdf0e10cSrcweir 157*cdf0e10cSrcweir if ( !xConnection.is() || !xColumns.is() || !m_xComposer.is() ) 158*cdf0e10cSrcweir // can't create the dialog if I have improper settings 159*cdf0e10cSrcweir return NULL; 160*cdf0e10cSrcweir 161*cdf0e10cSrcweir return createComposerDialog( _pParent, xConnection, xColumns ); 162*cdf0e10cSrcweir } 163*cdf0e10cSrcweir 164*cdf0e10cSrcweir //===================================================================== 165*cdf0e10cSrcweir //= RowsetFilterDialog 166*cdf0e10cSrcweir //===================================================================== 167*cdf0e10cSrcweir //--------------------------------------------------------------------- 168*cdf0e10cSrcweir RowsetFilterDialog::RowsetFilterDialog( const Reference< XMultiServiceFactory >& _rxORB ) 169*cdf0e10cSrcweir :ComposerDialog( _rxORB ) 170*cdf0e10cSrcweir { 171*cdf0e10cSrcweir } 172*cdf0e10cSrcweir 173*cdf0e10cSrcweir //--------------------------------------------------------------------- 174*cdf0e10cSrcweir IMPLEMENT_SERVICE_INFO1_STATIC( RowsetFilterDialog, "com.sun.star.uno.comp.sdb.RowsetFilterDialog", "com.sun.star.sdb.FilterDialog" ) 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir //--------------------------------------------------------------------- 177*cdf0e10cSrcweir Dialog* RowsetFilterDialog::createComposerDialog( Window* _pParent, const Reference< XConnection >& _rxConnection, const Reference< XNameAccess >& _rxColumns ) 178*cdf0e10cSrcweir { 179*cdf0e10cSrcweir return new DlgFilterCrit( _pParent, m_aContext.getLegacyServiceFactory(), _rxConnection, m_xComposer, _rxColumns ); 180*cdf0e10cSrcweir } 181*cdf0e10cSrcweir 182*cdf0e10cSrcweir //--------------------------------------------------------------------- 183*cdf0e10cSrcweir void RowsetFilterDialog::executedDialog( sal_Int16 _nExecutionResult ) 184*cdf0e10cSrcweir { 185*cdf0e10cSrcweir ComposerDialog::executedDialog( _nExecutionResult ); 186*cdf0e10cSrcweir 187*cdf0e10cSrcweir if ( _nExecutionResult && m_pDialog ) 188*cdf0e10cSrcweir static_cast< DlgFilterCrit* >( m_pDialog )->BuildWherePart(); 189*cdf0e10cSrcweir } 190*cdf0e10cSrcweir 191*cdf0e10cSrcweir //===================================================================== 192*cdf0e10cSrcweir //= RowsetOrderDialog 193*cdf0e10cSrcweir //===================================================================== 194*cdf0e10cSrcweir //--------------------------------------------------------------------- 195*cdf0e10cSrcweir RowsetOrderDialog::RowsetOrderDialog( const Reference< XMultiServiceFactory >& _rxORB ) 196*cdf0e10cSrcweir :ComposerDialog( _rxORB ) 197*cdf0e10cSrcweir { 198*cdf0e10cSrcweir } 199*cdf0e10cSrcweir 200*cdf0e10cSrcweir //--------------------------------------------------------------------- 201*cdf0e10cSrcweir IMPLEMENT_SERVICE_INFO1_STATIC( RowsetOrderDialog, "com.sun.star.uno.comp.sdb.RowsetOrderDialog", "com.sun.star.sdb.OrderDialog" ) 202*cdf0e10cSrcweir 203*cdf0e10cSrcweir //--------------------------------------------------------------------- 204*cdf0e10cSrcweir Dialog* RowsetOrderDialog::createComposerDialog( Window* _pParent, const Reference< XConnection >& _rxConnection, const Reference< XNameAccess >& _rxColumns ) 205*cdf0e10cSrcweir { 206*cdf0e10cSrcweir return new DlgOrderCrit( _pParent, _rxConnection, m_xComposer, _rxColumns ); 207*cdf0e10cSrcweir } 208*cdf0e10cSrcweir 209*cdf0e10cSrcweir //--------------------------------------------------------------------- 210*cdf0e10cSrcweir void RowsetOrderDialog::executedDialog( sal_Int16 _nExecutionResult ) 211*cdf0e10cSrcweir { 212*cdf0e10cSrcweir ComposerDialog::executedDialog( _nExecutionResult ); 213*cdf0e10cSrcweir 214*cdf0e10cSrcweir if ( !m_pDialog ) 215*cdf0e10cSrcweir return; 216*cdf0e10cSrcweir 217*cdf0e10cSrcweir if ( _nExecutionResult ) 218*cdf0e10cSrcweir static_cast< DlgOrderCrit* >( m_pDialog )->BuildOrderPart(); 219*cdf0e10cSrcweir else if ( m_xComposer.is() ) 220*cdf0e10cSrcweir m_xComposer->setOrder( static_cast< DlgOrderCrit* >( m_pDialog )->GetOrignalOrder() ); 221*cdf0e10cSrcweir } 222*cdf0e10cSrcweir 223*cdf0e10cSrcweir //......................................................................... 224*cdf0e10cSrcweir } // namespace dbaui 225*cdf0e10cSrcweir //......................................................................... 226*cdf0e10cSrcweir 227*cdf0e10cSrcweir 228