1*96de5490SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*96de5490SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*96de5490SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*96de5490SAndrew Rist * distributed with this work for additional information 6*96de5490SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*96de5490SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*96de5490SAndrew Rist * "License"); you may not use this file except in compliance 9*96de5490SAndrew Rist * with the License. You may obtain a copy of the License at 10*96de5490SAndrew Rist * 11*96de5490SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*96de5490SAndrew Rist * 13*96de5490SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*96de5490SAndrew Rist * software distributed under the License is distributed on an 15*96de5490SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*96de5490SAndrew Rist * KIND, either express or implied. See the License for the 17*96de5490SAndrew Rist * specific language governing permissions and limitations 18*96de5490SAndrew Rist * under the License. 19*96de5490SAndrew Rist * 20*96de5490SAndrew Rist *************************************************************/ 21*96de5490SAndrew Rist 22*96de5490SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_dbaccess.hxx" 26cdf0e10cSrcweir #ifndef _SFXSIDS_HRC 27cdf0e10cSrcweir #include <sfx2/sfxsids.hrc> 28cdf0e10cSrcweir #endif 29cdf0e10cSrcweir #ifndef _DBU_QRY_HRC_ 30cdf0e10cSrcweir #include "dbu_qry.hrc" 31cdf0e10cSrcweir #endif 32cdf0e10cSrcweir #ifndef DBACCESS_UI_BROWSER_ID_HXX 33cdf0e10cSrcweir #include "browserids.hxx" 34cdf0e10cSrcweir #endif 35cdf0e10cSrcweir #ifndef _COMPHELPER_TYPES_HXX_ 36cdf0e10cSrcweir #include <comphelper/types.hxx> 37cdf0e10cSrcweir #endif 38cdf0e10cSrcweir #ifndef DBACCESS_SHARED_DBUSTRINGS_HRC 39cdf0e10cSrcweir #include "dbustrings.hrc" 40cdf0e10cSrcweir #endif 41cdf0e10cSrcweir #ifndef _CONNECTIVITY_DBTOOLS_HXX_ 42cdf0e10cSrcweir #include <connectivity/dbtools.hxx> 43cdf0e10cSrcweir #endif 44cdf0e10cSrcweir #ifndef _COM_SUN_STAR_FRAME_FRAMESEARCHFLAG_HPP_ 45cdf0e10cSrcweir #include <com/sun/star/frame/FrameSearchFlag.hpp> 46cdf0e10cSrcweir #endif 47cdf0e10cSrcweir #ifndef _COMPHELPER_EXTRACT_HXX_ 48cdf0e10cSrcweir #include <comphelper/extract.hxx> 49cdf0e10cSrcweir #endif 50cdf0e10cSrcweir #ifndef _COM_SUN_STAR_CONTAINER_XCHILD_HPP_ 51cdf0e10cSrcweir #include <com/sun/star/container/XChild.hpp> 52cdf0e10cSrcweir #endif 53cdf0e10cSrcweir #ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_ 54cdf0e10cSrcweir #include <com/sun/star/container/XNameContainer.hpp> 55cdf0e10cSrcweir #endif 56cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBCX_XDATADESCRIPTORFACTORY_HPP_ 57cdf0e10cSrcweir #include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp> 58cdf0e10cSrcweir #endif 59cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_ 60cdf0e10cSrcweir #include <com/sun/star/sdbcx/XTablesSupplier.hpp> 61cdf0e10cSrcweir #endif 62cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBCX_KEYTYPE_HPP_ 63cdf0e10cSrcweir #include <com/sun/star/sdbcx/KeyType.hpp> 64cdf0e10cSrcweir #endif 65cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBCX_XDROP_HPP_ 66cdf0e10cSrcweir #include <com/sun/star/sdbcx/XDrop.hpp> 67cdf0e10cSrcweir #endif 68cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBCX_XALTERTABLE_HPP_ 69cdf0e10cSrcweir #include <com/sun/star/sdbcx/XAlterTable.hpp> 70cdf0e10cSrcweir #endif 71cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBCX_XAPPEND_HPP_ 72cdf0e10cSrcweir #include <com/sun/star/sdbcx/XAppend.hpp> 73cdf0e10cSrcweir #endif 74cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDB_SQLCONTEXT_HPP_ 75cdf0e10cSrcweir #include <com/sun/star/sdb/SQLContext.hpp> 76cdf0e10cSrcweir #endif 77cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_SQLWARNING_HPP_ 78cdf0e10cSrcweir #include <com/sun/star/sdbc/SQLWarning.hpp> 79cdf0e10cSrcweir #endif 80cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_ 81cdf0e10cSrcweir #include <com/sun/star/sdbc/ColumnValue.hpp> 82cdf0e10cSrcweir #endif 83cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ 84cdf0e10cSrcweir #include <com/sun/star/sdbc/XRow.hpp> 85cdf0e10cSrcweir #endif 86cdf0e10cSrcweir #ifndef _DBHELPER_DBEXCEPTION_HXX_ 87cdf0e10cSrcweir #include <connectivity/dbexception.hxx> 88cdf0e10cSrcweir #endif 89cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UI_DIALOGS_XEXECUTABLEDIALOG_HPP_ 90cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> 91cdf0e10cSrcweir #endif 92cdf0e10cSrcweir #ifndef _COMPHELPER_STREAMSECTION_HXX_ 93cdf0e10cSrcweir #include <comphelper/streamsection.hxx> 94cdf0e10cSrcweir #endif 95cdf0e10cSrcweir #ifndef _COMPHELPER_BASIC_IO_HXX_ 96cdf0e10cSrcweir #include <comphelper/basicio.hxx> 97cdf0e10cSrcweir #endif 98cdf0e10cSrcweir #ifndef _COMPHELPER_SEQSTREAM_HXX 99cdf0e10cSrcweir #include <comphelper/seqstream.hxx> 100cdf0e10cSrcweir #endif 101cdf0e10cSrcweir #ifndef _COM_SUN_STAR_IO_XACTIVEDATASOURCE_HPP_ 102cdf0e10cSrcweir #include <com/sun/star/io/XActiveDataSource.hpp> 103cdf0e10cSrcweir #endif 104cdf0e10cSrcweir #ifndef _COM_SUN_STAR_IO_XACTIVEDATASINK_HPP_ 105cdf0e10cSrcweir #include <com/sun/star/io/XActiveDataSink.hpp> 106cdf0e10cSrcweir #endif 107cdf0e10cSrcweir #ifndef _DBAUI_SQLMESSAGE_HXX_ 108cdf0e10cSrcweir #include "sqlmessage.hxx" 109cdf0e10cSrcweir #endif 110cdf0e10cSrcweir #ifndef DBAUI_JOINCONTROLLER_HXX 111cdf0e10cSrcweir #include "JoinController.hxx" 112cdf0e10cSrcweir #endif 113cdf0e10cSrcweir #ifndef _SV_MSGBOX_HXX 114cdf0e10cSrcweir #include <vcl/msgbox.hxx> 115cdf0e10cSrcweir #endif 116cdf0e10cSrcweir #ifndef DBAUI_TABLEWINDOWDATA_HXX 117cdf0e10cSrcweir #include "TableWindowData.hxx" 118cdf0e10cSrcweir #endif 119cdf0e10cSrcweir #ifndef DBAUI_TABLEWINDOW_HXX 120cdf0e10cSrcweir #include "TableWindow.hxx" 121cdf0e10cSrcweir #endif 122cdf0e10cSrcweir #ifndef DBAUI_TABLECONNECTIONDATA_HXX 123cdf0e10cSrcweir #include "TableConnectionData.hxx" 124cdf0e10cSrcweir #endif 125cdf0e10cSrcweir #ifndef DBAUI_QYDLGTAB_HXX 126cdf0e10cSrcweir #include "adtabdlg.hxx" 127cdf0e10cSrcweir #endif 128cdf0e10cSrcweir #ifndef _SV_WAITOBJ_HXX 129cdf0e10cSrcweir #include <vcl/waitobj.hxx> 130cdf0e10cSrcweir #endif 131cdf0e10cSrcweir #ifndef _SV_SVAPP_HXX 132cdf0e10cSrcweir #include <vcl/svapp.hxx> 133cdf0e10cSrcweir #endif 134cdf0e10cSrcweir #ifndef _VOS_MUTEX_HXX_ 135cdf0e10cSrcweir #include <vos/mutex.hxx> 136cdf0e10cSrcweir #endif 137cdf0e10cSrcweir #ifndef DBAUI_TOOLS_HXX 138cdf0e10cSrcweir #include "UITools.hxx" 139cdf0e10cSrcweir #endif 140cdf0e10cSrcweir 141cdf0e10cSrcweir #include <boost/optional.hpp> 142cdf0e10cSrcweir 143cdf0e10cSrcweir using namespace ::com::sun::star::uno; 144cdf0e10cSrcweir using namespace ::com::sun::star::io; 145cdf0e10cSrcweir using namespace ::com::sun::star::beans; 146cdf0e10cSrcweir using namespace ::com::sun::star::frame; 147cdf0e10cSrcweir using namespace ::com::sun::star::util; 148cdf0e10cSrcweir using namespace ::com::sun::star::lang; 149cdf0e10cSrcweir using namespace ::com::sun::star::container; 150cdf0e10cSrcweir using namespace ::com::sun::star::sdbcx; 151cdf0e10cSrcweir using namespace ::com::sun::star::sdbc; 152cdf0e10cSrcweir using namespace ::com::sun::star::sdb; 153cdf0e10cSrcweir using namespace ::com::sun::star::ui::dialogs; 154cdf0e10cSrcweir using namespace ::dbtools; 155cdf0e10cSrcweir using namespace ::comphelper; 156cdf0e10cSrcweir 157cdf0e10cSrcweir // ............................................................................. 158cdf0e10cSrcweir namespace dbaui 159cdf0e10cSrcweir { 160cdf0e10cSrcweir // ............................................................................. 161cdf0e10cSrcweir 162cdf0e10cSrcweir // ============================================================================= 163cdf0e10cSrcweir // = AddTableDialogContext 164cdf0e10cSrcweir // ============================================================================= 165cdf0e10cSrcweir class AddTableDialogContext : public IAddTableDialogContext 166cdf0e10cSrcweir { 167cdf0e10cSrcweir OJoinController& m_rController; 168cdf0e10cSrcweir 169cdf0e10cSrcweir public: 170cdf0e10cSrcweir AddTableDialogContext( OJoinController& _rController ) 171cdf0e10cSrcweir :m_rController( _rController ) 172cdf0e10cSrcweir { 173cdf0e10cSrcweir } 174cdf0e10cSrcweir 175cdf0e10cSrcweir // IAddTableDialogContext 176cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > 177cdf0e10cSrcweir getConnection() const; 178cdf0e10cSrcweir virtual bool allowViews() const; 179cdf0e10cSrcweir virtual bool allowQueries() const; 180cdf0e10cSrcweir virtual bool allowAddition() const; 181cdf0e10cSrcweir virtual void addTableWindow( const String& _rQualifiedTableName, const String& _rAliasName ); 182cdf0e10cSrcweir virtual void onWindowClosing( const Window* _pWindow ); 183cdf0e10cSrcweir 184cdf0e10cSrcweir private: 185cdf0e10cSrcweir OJoinTableView* getTableView() const; 186cdf0e10cSrcweir }; 187cdf0e10cSrcweir 188cdf0e10cSrcweir // ----------------------------------------------------------------------------- 189cdf0e10cSrcweir Reference< XConnection > AddTableDialogContext::getConnection() const 190cdf0e10cSrcweir { 191cdf0e10cSrcweir return m_rController.getConnection(); 192cdf0e10cSrcweir } 193cdf0e10cSrcweir 194cdf0e10cSrcweir // ----------------------------------------------------------------------------- 195cdf0e10cSrcweir bool AddTableDialogContext::allowViews() const 196cdf0e10cSrcweir { 197cdf0e10cSrcweir return m_rController.allowViews(); 198cdf0e10cSrcweir } 199cdf0e10cSrcweir 200cdf0e10cSrcweir // ----------------------------------------------------------------------------- 201cdf0e10cSrcweir bool AddTableDialogContext::allowQueries() const 202cdf0e10cSrcweir { 203cdf0e10cSrcweir return m_rController.allowQueries(); 204cdf0e10cSrcweir } 205cdf0e10cSrcweir 206cdf0e10cSrcweir // ----------------------------------------------------------------------------- 207cdf0e10cSrcweir bool AddTableDialogContext::allowAddition() const 208cdf0e10cSrcweir { 209cdf0e10cSrcweir return const_cast< OJoinController& >( m_rController ).getJoinView()->getTableView()->IsAddAllowed(); 210cdf0e10cSrcweir } 211cdf0e10cSrcweir 212cdf0e10cSrcweir // ----------------------------------------------------------------------------- 213cdf0e10cSrcweir void AddTableDialogContext::addTableWindow( const String& _rQualifiedTableName, const String& _rAliasName ) 214cdf0e10cSrcweir { 215cdf0e10cSrcweir getTableView()->AddTabWin( _rQualifiedTableName, _rAliasName, sal_True ); 216cdf0e10cSrcweir } 217cdf0e10cSrcweir 218cdf0e10cSrcweir // ----------------------------------------------------------------------------- 219cdf0e10cSrcweir void AddTableDialogContext::onWindowClosing( const Window* _pWindow ) 220cdf0e10cSrcweir { 221cdf0e10cSrcweir if ( !m_rController.getView() ) 222cdf0e10cSrcweir return; 223cdf0e10cSrcweir 224cdf0e10cSrcweir ::dbaui::notifySystemWindow( 225cdf0e10cSrcweir m_rController.getView(), const_cast< Window* >( _pWindow ), ::comphelper::mem_fun( &TaskPaneList::RemoveWindow ) ); 226cdf0e10cSrcweir 227cdf0e10cSrcweir m_rController.InvalidateFeature( ID_BROWSER_ADDTABLE ); 228cdf0e10cSrcweir m_rController.getView()->GrabFocus(); 229cdf0e10cSrcweir } 230cdf0e10cSrcweir 231cdf0e10cSrcweir // ----------------------------------------------------------------------------- 232cdf0e10cSrcweir OJoinTableView* AddTableDialogContext::getTableView() const 233cdf0e10cSrcweir { 234cdf0e10cSrcweir if ( m_rController.getJoinView() ) 235cdf0e10cSrcweir return m_rController.getJoinView()->getTableView(); 236cdf0e10cSrcweir return NULL; 237cdf0e10cSrcweir } 238cdf0e10cSrcweir 239cdf0e10cSrcweir // ============================================================================= 240cdf0e10cSrcweir // = OJoinController 241cdf0e10cSrcweir // ============================================================================= 242cdf0e10cSrcweir 243cdf0e10cSrcweir DBG_NAME(OJoinController) 244cdf0e10cSrcweir // ----------------------------------------------------------------------------- 245cdf0e10cSrcweir OJoinController::OJoinController(const Reference< XMultiServiceFactory >& _rM) 246cdf0e10cSrcweir :OJoinController_BASE(_rM) 247cdf0e10cSrcweir ,m_pAddTableDialog(NULL) 248cdf0e10cSrcweir { 249cdf0e10cSrcweir DBG_CTOR(OJoinController,NULL); 250cdf0e10cSrcweir } 251cdf0e10cSrcweir // ----------------------------------------------------------------------------- 252cdf0e10cSrcweir OJoinController::~OJoinController() 253cdf0e10cSrcweir { 254cdf0e10cSrcweir DBG_DTOR(OJoinController,NULL); 255cdf0e10cSrcweir } 256cdf0e10cSrcweir 257cdf0e10cSrcweir // ----------------------------------------------------------------------------- 258cdf0e10cSrcweir void SAL_CALL OJoinController::disposing( const EventObject& _rSource ) throw(RuntimeException) 259cdf0e10cSrcweir { 260cdf0e10cSrcweir OJoinController_BASE::disposing( _rSource ); 261cdf0e10cSrcweir } 262cdf0e10cSrcweir 263cdf0e10cSrcweir // ----------------------------------------------------------------------------- 264cdf0e10cSrcweir OJoinDesignView* OJoinController::getJoinView() 265cdf0e10cSrcweir { 266cdf0e10cSrcweir return static_cast< OJoinDesignView* >( getView() ); 267cdf0e10cSrcweir } 268cdf0e10cSrcweir 269cdf0e10cSrcweir // ----------------------------------------------------------------------------- 270cdf0e10cSrcweir void OJoinController::disposing() 271cdf0e10cSrcweir { 272cdf0e10cSrcweir { 273cdf0e10cSrcweir ::std::auto_ptr< Window > pEnsureDelete( m_pAddTableDialog ); 274cdf0e10cSrcweir m_pAddTableDialog = NULL; 275cdf0e10cSrcweir } 276cdf0e10cSrcweir 277cdf0e10cSrcweir OJoinController_BASE::disposing(); 278cdf0e10cSrcweir 279cdf0e10cSrcweir clearView(); 280cdf0e10cSrcweir 281cdf0e10cSrcweir m_vTableConnectionData.clear(); 282cdf0e10cSrcweir m_vTableData.clear(); 283cdf0e10cSrcweir } 284cdf0e10cSrcweir // ----------------------------------------------------------------------------- 285cdf0e10cSrcweir void OJoinController::reconnect( sal_Bool _bUI ) 286cdf0e10cSrcweir { 287cdf0e10cSrcweir OJoinController_BASE::reconnect( _bUI ); 288cdf0e10cSrcweir if ( isConnected() && m_pAddTableDialog ) 289cdf0e10cSrcweir m_pAddTableDialog->Update(); 290cdf0e10cSrcweir } 291cdf0e10cSrcweir 292cdf0e10cSrcweir // ----------------------------------------------------------------------------- 293cdf0e10cSrcweir void OJoinController::impl_onModifyChanged() 294cdf0e10cSrcweir { 295cdf0e10cSrcweir OJoinController_BASE::impl_onModifyChanged(); 296cdf0e10cSrcweir InvalidateFeature( SID_RELATION_ADD_RELATION ); 297cdf0e10cSrcweir } 298cdf0e10cSrcweir // ----------------------------------------------------------------------------- 299cdf0e10cSrcweir void OJoinController::SaveTabWinPosSize(OTableWindow* pTabWin, long nOffsetX, long nOffsetY) 300cdf0e10cSrcweir { 301cdf0e10cSrcweir // die Daten zum Fenster 302cdf0e10cSrcweir TTableWindowData::value_type pData = pTabWin->GetData(); 303cdf0e10cSrcweir OSL_ENSURE(pData != NULL, "SaveTabWinPosSize : TabWin hat keine Daten !"); 304cdf0e10cSrcweir 305cdf0e10cSrcweir // Position & Size der Daten neu setzen (aus den aktuellen Fenster-Parametern) 306cdf0e10cSrcweir Point aPos = pTabWin->GetPosPixel(); 307cdf0e10cSrcweir aPos.X() += nOffsetX; 308cdf0e10cSrcweir aPos.Y() += nOffsetY; 309cdf0e10cSrcweir pData->SetPosition(aPos); 310cdf0e10cSrcweir pData->SetSize(pTabWin->GetSizePixel()); 311cdf0e10cSrcweir 312cdf0e10cSrcweir } 313cdf0e10cSrcweir // ----------------------------------------------------------------------------- 314cdf0e10cSrcweir FeatureState OJoinController::GetState(sal_uInt16 _nId) const 315cdf0e10cSrcweir { 316cdf0e10cSrcweir FeatureState aReturn; 317cdf0e10cSrcweir // (disabled automatically) 318cdf0e10cSrcweir aReturn.bEnabled = sal_True; 319cdf0e10cSrcweir 320cdf0e10cSrcweir switch (_nId) 321cdf0e10cSrcweir { 322cdf0e10cSrcweir case ID_BROWSER_EDITDOC: 323cdf0e10cSrcweir aReturn.bChecked = isEditable(); 324cdf0e10cSrcweir break; 325cdf0e10cSrcweir case ID_BROWSER_ADDTABLE: 326cdf0e10cSrcweir aReturn.bEnabled = ( getView() != NULL ) 327cdf0e10cSrcweir && const_cast< OJoinController* >( this )->getJoinView()->getTableView()->IsAddAllowed(); 328cdf0e10cSrcweir aReturn.bChecked = aReturn.bEnabled && m_pAddTableDialog != NULL && m_pAddTableDialog->IsVisible() ; 329cdf0e10cSrcweir if ( aReturn.bEnabled ) 330cdf0e10cSrcweir aReturn.sTitle = OAddTableDlg::getDialogTitleForContext( impl_getDialogContext() ); 331cdf0e10cSrcweir break; 332cdf0e10cSrcweir 333cdf0e10cSrcweir default: 334cdf0e10cSrcweir aReturn = OJoinController_BASE::GetState(_nId); 335cdf0e10cSrcweir } 336cdf0e10cSrcweir return aReturn; 337cdf0e10cSrcweir } 338cdf0e10cSrcweir 339cdf0e10cSrcweir // ----------------------------------------------------------------------------- 340cdf0e10cSrcweir AddTableDialogContext& OJoinController::impl_getDialogContext() const 341cdf0e10cSrcweir { 342cdf0e10cSrcweir if ( !m_pDialogContext.get() ) 343cdf0e10cSrcweir { 344cdf0e10cSrcweir OJoinController* pNonConstThis = const_cast< OJoinController* >( this ); 345cdf0e10cSrcweir pNonConstThis->m_pDialogContext.reset( new AddTableDialogContext( *pNonConstThis ) ); 346cdf0e10cSrcweir } 347cdf0e10cSrcweir return *m_pDialogContext; 348cdf0e10cSrcweir } 349cdf0e10cSrcweir 350cdf0e10cSrcweir // ----------------------------------------------------------------------------- 351cdf0e10cSrcweir void OJoinController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue >& aArgs) 352cdf0e10cSrcweir { 353cdf0e10cSrcweir switch(_nId) 354cdf0e10cSrcweir { 355cdf0e10cSrcweir case ID_BROWSER_EDITDOC: 356cdf0e10cSrcweir if(isEditable()) 357cdf0e10cSrcweir { // the state should be changed to not editable 358cdf0e10cSrcweir switch (saveModified()) 359cdf0e10cSrcweir { 360cdf0e10cSrcweir case RET_CANCEL: 361cdf0e10cSrcweir // don't change anything here so return 362cdf0e10cSrcweir return; 363cdf0e10cSrcweir case RET_NO: 364cdf0e10cSrcweir reset(); 365cdf0e10cSrcweir setModified(sal_False); // and we are not modified yet 366cdf0e10cSrcweir break; 367cdf0e10cSrcweir default: 368cdf0e10cSrcweir break; 369cdf0e10cSrcweir } 370cdf0e10cSrcweir } 371cdf0e10cSrcweir setEditable(!isEditable()); 372cdf0e10cSrcweir getJoinView()->setReadOnly(!isEditable()); 373cdf0e10cSrcweir InvalidateAll(); 374cdf0e10cSrcweir return; 375cdf0e10cSrcweir case ID_BROWSER_ADDTABLE: 376cdf0e10cSrcweir if ( !m_pAddTableDialog ) 377cdf0e10cSrcweir m_pAddTableDialog = new OAddTableDlg( getView(), impl_getDialogContext() ); 378cdf0e10cSrcweir 379cdf0e10cSrcweir if ( m_pAddTableDialog->IsVisible() ) 380cdf0e10cSrcweir { 381cdf0e10cSrcweir m_pAddTableDialog->Show( sal_False ); 382cdf0e10cSrcweir getView()->GrabFocus(); 383cdf0e10cSrcweir } 384cdf0e10cSrcweir else 385cdf0e10cSrcweir { 386cdf0e10cSrcweir { 387cdf0e10cSrcweir WaitObject aWaitCursor( getView() ); 388cdf0e10cSrcweir m_pAddTableDialog->Update(); 389cdf0e10cSrcweir } 390cdf0e10cSrcweir m_pAddTableDialog->Show( sal_True ); 391cdf0e10cSrcweir ::dbaui::notifySystemWindow(getView(),m_pAddTableDialog,::comphelper::mem_fun(&TaskPaneList::AddWindow)); 392cdf0e10cSrcweir } 393cdf0e10cSrcweir break; 394cdf0e10cSrcweir default: 395cdf0e10cSrcweir OJoinController_BASE::Execute(_nId,aArgs); 396cdf0e10cSrcweir } 397cdf0e10cSrcweir InvalidateFeature(_nId); 398cdf0e10cSrcweir } 399cdf0e10cSrcweir // ----------------------------------------------------------------------------- 400cdf0e10cSrcweir void OJoinController::SaveTabWinsPosSize( OJoinTableView::OTableWindowMap* pTabWinList, long nOffsetX, long nOffsetY ) 401cdf0e10cSrcweir { 402cdf0e10cSrcweir // Das Loeschen und Neuanlegen der alten Implementation ist unter dem aktuellen Modell nicht mehr richtig : Die TabWins 403cdf0e10cSrcweir // habe einen Zeiger auf ihre Daten, verwaltet werden sie aber von mir. Wenn ich die alten loesche, haben die TabWins 404cdf0e10cSrcweir // ploetzlich Zeiger auf nicht mehr existente Objekte. 405cdf0e10cSrcweir // Wenn die TabWins ein SetData haetten, koennte ich mir das sparen ... haben sie aber nicht, ausserdem muesste ich dann immer 406cdf0e10cSrcweir // noch Informationen, die sich eigentlich nicht geaendert haben, auch neu setzen. 407cdf0e10cSrcweir // Also loesche ich die TabWinDatas nicht, sondern aktualisiere sie nur. 408cdf0e10cSrcweir DBG_ASSERT(m_vTableData.size() == pTabWinList->size(), 409cdf0e10cSrcweir "OJoinController::SaveTabWinsPosSize : inkonsistenter Zustand : sollte genausviel TabWinDatas haben wie TabWins !"); 410cdf0e10cSrcweir 411cdf0e10cSrcweir OJoinTableView::OTableWindowMap::iterator aIter = pTabWinList->begin(); 412cdf0e10cSrcweir OJoinTableView::OTableWindowMap::iterator aEnd = pTabWinList->end(); 413cdf0e10cSrcweir for(;aIter != aEnd;++aIter) 414cdf0e10cSrcweir SaveTabWinPosSize(aIter->second, nOffsetX, nOffsetY); 415cdf0e10cSrcweir } 416cdf0e10cSrcweir // ----------------------------------------------------------------------------- 417cdf0e10cSrcweir void OJoinController::removeConnectionData(const TTableConnectionData::value_type& _pData) 418cdf0e10cSrcweir { 419cdf0e10cSrcweir m_vTableConnectionData.erase( ::std::remove(m_vTableConnectionData.begin(),m_vTableConnectionData.end(),_pData),m_vTableConnectionData.end()); 420cdf0e10cSrcweir } 421cdf0e10cSrcweir // ----------------------------------------------------------------------------- 422cdf0e10cSrcweir void OJoinController::describeSupportedFeatures() 423cdf0e10cSrcweir { 424cdf0e10cSrcweir OJoinController_BASE::describeSupportedFeatures(); 425cdf0e10cSrcweir implDescribeSupportedFeature( ".uno:Redo", ID_BROWSER_REDO, CommandGroup::EDIT ); 426cdf0e10cSrcweir implDescribeSupportedFeature( ".uno:Save", ID_BROWSER_SAVEDOC, CommandGroup::DOCUMENT ); 427cdf0e10cSrcweir implDescribeSupportedFeature( ".uno:Undo", ID_BROWSER_UNDO, CommandGroup::EDIT ); 428cdf0e10cSrcweir implDescribeSupportedFeature( ".uno:AddTable", ID_BROWSER_ADDTABLE,CommandGroup::EDIT ); 429cdf0e10cSrcweir implDescribeSupportedFeature( ".uno:EditDoc", ID_BROWSER_EDITDOC, CommandGroup::EDIT ); 430cdf0e10cSrcweir } 431cdf0e10cSrcweir // ----------------------------------------------------------------------------- 432cdf0e10cSrcweir sal_Bool SAL_CALL OJoinController::suspend(sal_Bool _bSuspend) throw( RuntimeException ) 433cdf0e10cSrcweir { 434cdf0e10cSrcweir if ( getBroadcastHelper().bInDispose || getBroadcastHelper().bDisposed ) 435cdf0e10cSrcweir return sal_True; 436cdf0e10cSrcweir 437cdf0e10cSrcweir vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 438cdf0e10cSrcweir ::osl::MutexGuard aGuard( getMutex() ); 439cdf0e10cSrcweir if ( getView() && getView()->IsInModalMode() ) 440cdf0e10cSrcweir return sal_False; 441cdf0e10cSrcweir sal_Bool bCheck = sal_True; 442cdf0e10cSrcweir if ( _bSuspend ) 443cdf0e10cSrcweir { 444cdf0e10cSrcweir bCheck = saveModified() != RET_CANCEL; 445cdf0e10cSrcweir if ( bCheck ) 446cdf0e10cSrcweir OSingleDocumentController::suspend(_bSuspend); 447cdf0e10cSrcweir } 448cdf0e10cSrcweir return bCheck; 449cdf0e10cSrcweir } 450cdf0e10cSrcweir // ----------------------------------------------------------------------------- 451cdf0e10cSrcweir void OJoinController::loadTableWindows( const ::comphelper::NamedValueCollection& i_rViewSettings ) 452cdf0e10cSrcweir { 453cdf0e10cSrcweir m_vTableData.clear(); 454cdf0e10cSrcweir 455cdf0e10cSrcweir m_aMinimumTableViewSize = Point(); 456cdf0e10cSrcweir 457cdf0e10cSrcweir Sequence< PropertyValue > aWindowData; 458cdf0e10cSrcweir aWindowData = i_rViewSettings.getOrDefault( "Tables", aWindowData ); 459cdf0e10cSrcweir 460cdf0e10cSrcweir const PropertyValue* pTablesIter = aWindowData.getConstArray(); 461cdf0e10cSrcweir const PropertyValue* pTablesEnd = pTablesIter + aWindowData.getLength(); 462cdf0e10cSrcweir for ( ; pTablesIter != pTablesEnd; ++pTablesIter ) 463cdf0e10cSrcweir { 464cdf0e10cSrcweir ::comphelper::NamedValueCollection aSingleTableData( pTablesIter->Value ); 465cdf0e10cSrcweir loadTableWindow( aSingleTableData ); 466cdf0e10cSrcweir } 467cdf0e10cSrcweir if ( m_aMinimumTableViewSize != Point() ) 468cdf0e10cSrcweir { 469cdf0e10cSrcweir getJoinView()->getScrollHelper()->resetRange( m_aMinimumTableViewSize ); 470cdf0e10cSrcweir } 471cdf0e10cSrcweir } 472cdf0e10cSrcweir 473cdf0e10cSrcweir // ----------------------------------------------------------------------------- 474cdf0e10cSrcweir void OJoinController::loadTableWindow( const ::comphelper::NamedValueCollection& i_rTableWindowSettings ) 475cdf0e10cSrcweir { 476cdf0e10cSrcweir sal_Int32 nX = -1, nY = -1, nHeight = -1, nWidth = -1; 477cdf0e10cSrcweir 478cdf0e10cSrcweir ::rtl::OUString sComposedName,sTableName,sWindowName; 479cdf0e10cSrcweir sal_Bool bShowAll = false; 480cdf0e10cSrcweir 481cdf0e10cSrcweir sComposedName = i_rTableWindowSettings.getOrDefault( "ComposedName", sComposedName ); 482cdf0e10cSrcweir sTableName = i_rTableWindowSettings.getOrDefault( "TableName", sTableName ); 483cdf0e10cSrcweir sWindowName = i_rTableWindowSettings.getOrDefault( "WindowName", sWindowName ); 484cdf0e10cSrcweir nY = i_rTableWindowSettings.getOrDefault( "WindowTop", nY ); 485cdf0e10cSrcweir nX = i_rTableWindowSettings.getOrDefault( "WindowLeft", nX ); 486cdf0e10cSrcweir nWidth = i_rTableWindowSettings.getOrDefault( "WindowWidth", nWidth ); 487cdf0e10cSrcweir nHeight = i_rTableWindowSettings.getOrDefault( "WindowHeight", nHeight ); 488cdf0e10cSrcweir bShowAll = i_rTableWindowSettings.getOrDefault( "ShowAll", bShowAll ); 489cdf0e10cSrcweir 490cdf0e10cSrcweir TTableWindowData::value_type pData = createTableWindowData(sComposedName,sTableName,sWindowName); 491cdf0e10cSrcweir if ( pData ) 492cdf0e10cSrcweir { 493cdf0e10cSrcweir pData->SetPosition(Point(nX,nY)); 494cdf0e10cSrcweir pData->SetSize( Size( nWidth, nHeight ) ); 495cdf0e10cSrcweir pData->ShowAll(bShowAll); 496cdf0e10cSrcweir m_vTableData.push_back(pData); 497cdf0e10cSrcweir if ( m_aMinimumTableViewSize.X() < (nX+nWidth) ) 498cdf0e10cSrcweir m_aMinimumTableViewSize.X() = (nX+nWidth); 499cdf0e10cSrcweir if ( m_aMinimumTableViewSize.Y() < (nY+nHeight) ) 500cdf0e10cSrcweir m_aMinimumTableViewSize.Y() = (nY+nHeight); 501cdf0e10cSrcweir } 502cdf0e10cSrcweir } 503cdf0e10cSrcweir // ----------------------------------------------------------------------------- 504cdf0e10cSrcweir void OJoinController::saveTableWindows( ::comphelper::NamedValueCollection& o_rViewSettings ) const 505cdf0e10cSrcweir { 506cdf0e10cSrcweir if ( !m_vTableData.empty() ) 507cdf0e10cSrcweir { 508cdf0e10cSrcweir ::comphelper::NamedValueCollection aAllTablesData; 509cdf0e10cSrcweir 510cdf0e10cSrcweir TTableWindowData::const_iterator aIter = m_vTableData.begin(); 511cdf0e10cSrcweir TTableWindowData::const_iterator aEnd = m_vTableData.end(); 512cdf0e10cSrcweir for ( sal_Int32 i = 1; aIter != aEnd; ++aIter, ++i ) 513cdf0e10cSrcweir { 514cdf0e10cSrcweir ::comphelper::NamedValueCollection aWindowData; 515cdf0e10cSrcweir aWindowData.put( "ComposedName", (*aIter)->GetComposedName() ); 516cdf0e10cSrcweir aWindowData.put( "TableName", (*aIter)->GetTableName() ); 517cdf0e10cSrcweir aWindowData.put( "WindowName", (*aIter)->GetWinName() ); 518cdf0e10cSrcweir aWindowData.put( "WindowTop", static_cast<sal_Int32>((*aIter)->GetPosition().Y()) ); 519cdf0e10cSrcweir aWindowData.put( "WindowLeft", static_cast<sal_Int32>((*aIter)->GetPosition().X()) ); 520cdf0e10cSrcweir aWindowData.put( "WindowWidth", static_cast<sal_Int32>((*aIter)->GetSize().Width()) ); 521cdf0e10cSrcweir aWindowData.put( "WindowHeight", static_cast<sal_Int32>((*aIter)->GetSize().Height()) ); 522cdf0e10cSrcweir aWindowData.put( "ShowAll", (*aIter)->IsShowAll() ); 523cdf0e10cSrcweir 524cdf0e10cSrcweir const ::rtl::OUString sTableName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Table" ) ) + ::rtl::OUString::valueOf( i ) ); 525cdf0e10cSrcweir aAllTablesData.put( sTableName, aWindowData.getPropertyValues() ); 526cdf0e10cSrcweir } 527cdf0e10cSrcweir 528cdf0e10cSrcweir o_rViewSettings.put( "Tables", aAllTablesData.getPropertyValues() ); 529cdf0e10cSrcweir } 530cdf0e10cSrcweir } 531cdf0e10cSrcweir // ----------------------------------------------------------------------------- 532cdf0e10cSrcweir TTableWindowData::value_type OJoinController::createTableWindowData(const ::rtl::OUString& _sComposedName,const ::rtl::OUString& _sTableName,const ::rtl::OUString& _sWindowName) 533cdf0e10cSrcweir { 534cdf0e10cSrcweir OJoinDesignView* pView = getJoinView(); 535cdf0e10cSrcweir if( pView ) 536cdf0e10cSrcweir return pView->getTableView()->createTableWindowData(_sComposedName,_sTableName,_sWindowName); 537cdf0e10cSrcweir OSL_ENSURE(0,"We should never ever reach this point!"); 538cdf0e10cSrcweir 539cdf0e10cSrcweir return TTableWindowData::value_type(); 540cdf0e10cSrcweir } 541cdf0e10cSrcweir // ............................................................................. 542cdf0e10cSrcweir } // namespace dbaui 543cdf0e10cSrcweir // ............................................................................. 544