1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 #ifndef DBAUI_JOINCONTROLLER_HXX 28 #define DBAUI_JOINCONTROLLER_HXX 29 30 #include "singledoccontroller.hxx" 31 #include <com/sun/star/beans/XPropertySet.hpp> 32 #include "moduledbu.hxx" 33 #include "JoinTableView.hxx" 34 #include "JoinDesignView.hxx" 35 #include "TableConnectionData.hxx" 36 #include "TableWindowData.hxx" 37 #include <memory> 38 #include <boost/shared_ptr.hpp> 39 40 namespace comphelper 41 { 42 class NamedValueCollection; 43 } 44 45 class VCLXWindow; 46 namespace dbaui 47 { 48 class OAddTableDlg; 49 class AddTableDialogContext; 50 class OTableConnectionData; 51 class OTableWindowData; 52 class OTableWindow; 53 typedef OSingleDocumentController OJoinController_BASE; 54 55 class OJoinController : public OJoinController_BASE 56 { 57 OModuleClient m_aModuleClient; 58 protected: 59 TTableConnectionData m_vTableConnectionData; 60 TTableWindowData m_vTableData; 61 62 Fraction m_aZoom; 63 ::dbtools::SQLExceptionInfo m_aExceptionInfo; 64 65 OAddTableDlg* m_pAddTableDialog; 66 ::std::auto_ptr< AddTableDialogContext > m_pDialogContext; 67 Point m_aMinimumTableViewSize; 68 69 // state of a feature. 'feature' may be the handle of a ::com::sun::star::util::URL somebody requested a dispatch interface for OR a toolbar slot. 70 virtual FeatureState GetState(sal_uInt16 nId) const; 71 // execute a feature 72 virtual void Execute(sal_uInt16 nId, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& aArgs); 73 74 /** loads the information for the windows. 75 @param i_rViewSettings 76 The properties which comes from the layout information. 77 */ 78 void loadTableWindows( const ::comphelper::NamedValueCollection& i_rViewSettings ); 79 80 /** loads the information for one window. 81 @param _rTable 82 The properties which comes from the layout information. 83 */ 84 void loadTableWindow( const ::comphelper::NamedValueCollection& i_rTableWindowSettings ); 85 86 /** saves the TableWindows structure in a sequence of property values 87 @param _rViewProps 88 Contains the new sequence. 89 */ 90 void saveTableWindows( ::comphelper::NamedValueCollection& o_rViewSettings ) const; 91 92 virtual ~OJoinController(); 93 public: 94 OJoinController(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM); 95 96 // --------------------------------------------------------------- 97 // attribute access 98 inline TTableWindowData* getTableWindowData() { return &m_vTableData; } 99 inline TTableConnectionData* getTableConnectionData() { return &m_vTableConnectionData;} 100 inline OAddTableDlg* getAddTableDialog()const { return m_pAddTableDialog; } 101 102 // --------------------------------------------------------------- 103 // OSingleDocumentController overridables 104 virtual void reconnect( sal_Bool _bUI ); 105 virtual void impl_onModifyChanged(); 106 107 // --------------------------------------------------------------- 108 // own overridables 109 /** determines whether or not it's allowed for database views to participate in the game 110 */ 111 virtual bool allowViews() const = 0; 112 113 /** determines whether or not it's allowed for queries to participate in the game 114 */ 115 virtual bool allowQueries() const = 0; 116 117 /** provides access to the OJoinDesignView belonging to the controller, which might 118 or might not be the direct view (getView) 119 */ 120 virtual OJoinDesignView* getJoinView(); 121 122 123 // --------------------------------------------------------------- 124 /** erase the data in the data vector 125 @param _pData 126 the data whioch should be erased 127 */ 128 void removeConnectionData(const TTableConnectionData::value_type& _pData); 129 130 void SaveTabWinsPosSize( OJoinTableView::OTableWindowMap* pTabWinList, long nOffsetX, long nOffsetY ); 131 132 void SaveTabWinPosSize(OTableWindow* pTabWin, long nOffsetX, long nOffsetY); 133 134 // --------------------------------------------------------------- 135 // UNO interface overridables 136 // XEventListener 137 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException); 138 139 // ::com::sun::star::lang::XComponent 140 virtual void SAL_CALL disposing(); 141 // ::com::sun::star::frame::XController 142 virtual sal_Bool SAL_CALL suspend(sal_Bool bSuspend) throw( ::com::sun::star::uno::RuntimeException ); 143 144 145 // --------------------------------------------------------------- 146 // misc 147 /** only defines a method to save a SQLException in d&d methods to show the error at a later state 148 set the internal member m_aExceptionInfo to _rInfo 149 */ 150 void setErrorOccured(const ::dbtools::SQLExceptionInfo& _rInfo) 151 { 152 m_aExceptionInfo = _rInfo; 153 } 154 /** 155 just returns the internal member and clears it 156 */ 157 ::dbtools::SQLExceptionInfo clearOccuredError() 158 { 159 ::dbtools::SQLExceptionInfo aInfo = m_aExceptionInfo; 160 m_aExceptionInfo = ::dbtools::SQLExceptionInfo(); 161 return aInfo; 162 } 163 164 protected: 165 TTableWindowData::value_type createTableWindowData(const ::rtl::OUString& _sComposedName,const ::rtl::OUString& _sTableName,const ::rtl::OUString& _sWindowName); 166 // ask the user if the design should be saved when it is modified 167 virtual short saveModified() = 0; 168 // called when the orignal state should be reseted (first time load) 169 virtual void reset() = 0; 170 virtual void describeSupportedFeatures(); 171 172 AddTableDialogContext& impl_getDialogContext() const; 173 }; 174 } 175 #endif // DBAUI_JOINCONTROLLER_HXX 176 177