00001 /************************************************************************* 00002 * 00003 * The Contents of this file are made available subject to 00004 * the terms of GNU Lesser General Public License Version 2.1. 00005 * 00006 * 00007 * GNU Lesser General Public License Version 2.1 00008 * ============================================= 00009 * Copyright 2005 by Kohei Yoshida. 00010 * 1039 Kingsway Dr., Apex, NC 27502, USA 00011 * 00012 * This library is free software; you can redistribute it and/or 00013 * modify it under the terms of the GNU Lesser General Public 00014 * License version 2.1, as published by the Free Software Foundation. 00015 * 00016 * This library is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00019 * Lesser General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU Lesser General Public 00022 * License along with this library; if not, write to the Free Software 00023 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 00024 * MA 02111-1307 USA 00025 * 00026 ************************************************************************/ 00027 00028 00029 #ifndef _LISTENER_HXX_ 00030 #define _LISTENER_HXX_ 00031 00032 #include "unoglobal.hxx" 00033 #include "type.hxx" 00034 #include "baselistener.hxx" 00035 00036 #include <cppuhelper/implbase1.hxx> 00037 #include <com/sun/star/sheet/XRangeSelectionListener.hpp> 00038 #include <com/sun/star/awt/XWindow.hpp> 00039 00040 #include <memory> 00041 00042 using namespace ::com::sun::star; 00043 using namespace ::com::sun::star::uno; 00044 00045 namespace com { namespace sun { namespace star { 00046 00047 namespace sheet 00048 { 00049 class RangeSelectionEvent; 00050 class XRangeSelection; 00051 } 00052 00053 }}} 00054 00055 00056 00057 namespace scsolver { 00058 00059 class RngBtnListener; 00060 class BaseDialog; 00061 class Listener; 00062 class FocusListener; 00063 class ItemListener; 00064 class ActionListener; 00065 00066 class MessageDialog; 00067 00068 class SolverDialog; 00069 class SolveBtnListener; 00070 class CloseBtnListener; 00071 class MaxRadioBtnListener; 00072 class ConstEditBtnListener; 00073 class WindowFocusListener; 00074 class WindowMouseListener; 00075 class ConstListBoxListener; 00076 class OKCancelBtnListener; 00077 00078 //-------------------------------------------------------------------------- 00079 // Class RngSelListener 00080 00081 class RngSelListener : public ::cppu::WeakImplHelper1< sheet::XRangeSelectionListener > 00082 { 00083 00084 public: 00085 00086 RngSelListener( BaseDialog*, RngBtnListener*, const rtl::OUString& ); 00087 ~RngSelListener() throw(); 00088 00089 virtual void SAL_CALL disposing( const lang::EventObject& ) throw ( RuntimeException ); 00090 virtual void SAL_CALL done( const sheet::RangeSelectionEvent& ) throw ( RuntimeException ); 00091 virtual void SAL_CALL aborted( const sheet::RangeSelectionEvent& ) throw ( RuntimeException ); 00092 00093 private: 00094 BaseDialog* m_pDlg; 00095 RngBtnListener* m_pBtn; 00096 rtl::OUString m_sEditName; 00097 00098 }; 00099 00100 00101 //--------------------------------------------------------------------------- 00102 // Class RngBtnListener 00103 00104 class RngBtnListener : public ActionListener 00105 { 00106 public: 00107 00108 RngBtnListener( BaseDialog* pDlg, Reference< sheet::XRangeSelection >, const rtl::OUString& ); 00109 virtual ~RngBtnListener() throw(); 00110 00111 // XEventListener 00112 virtual void SAL_CALL disposing( const lang::EventObject& oEvt ) throw ( RuntimeException ); 00113 00114 // XActionListener 00115 virtual void SAL_CALL actionPerformed( const awt::ActionEvent& ) throw ( RuntimeException ); 00116 00117 void registerRngSelListener(); 00118 void setEventOwner( bool b ) { m_bEventOwner = b; } 00119 void setSingleCell( bool b ) { m_bSingleCell = b; } 00120 bool isEventOwner() { return m_bEventOwner; } 00121 00122 private: 00123 00124 Reference< sheet::XRangeSelection > m_xRngSel; 00125 RngSelListener* m_pRngSelListener; 00126 rtl::OUString m_sEditName; 00127 bool m_bEventOwner; 00128 bool m_bSingleCell; 00129 }; 00130 00131 00132 class SolveBtnListener : public ::scsolver::ActionListener 00133 { 00134 00135 public: 00136 00137 SolveBtnListener( SolverDialog* ); 00138 virtual ~SolveBtnListener() throw(); 00139 00140 // XEventListener 00141 virtual void SAL_CALL disposing( const lang::EventObject& ) throw ( RuntimeException ); 00142 00143 // XActionListener 00144 virtual void SAL_CALL actionPerformed( const awt::ActionEvent& ) throw ( RuntimeException ); 00145 00146 }; 00147 00155 class CloseBtnListener : public ActionListener 00156 { 00157 public: 00158 CloseBtnListener( BaseDialog* pDlg ); 00159 virtual ~CloseBtnListener() throw(); 00160 00161 // XEventListener 00162 virtual void SAL_CALL disposing( const lang::EventObject& oEvt ) 00163 throw ( RuntimeException ); 00164 00165 // XActionListener 00166 virtual void SAL_CALL actionPerformed( const awt::ActionEvent& ) 00167 throw ( RuntimeException ); 00168 }; 00169 00170 00171 class SaveBtnListener : public ::scsolver::ActionListener 00172 { 00173 00174 public: 00175 00176 SaveBtnListener( SolverDialog* pDlg ); 00177 virtual ~SaveBtnListener() throw(); 00178 00179 // XEventListener 00180 virtual void SAL_CALL disposing( const lang::EventObject& oEvt ) throw ( RuntimeException ); 00181 00182 // XActionListener 00183 virtual void SAL_CALL actionPerformed( const awt::ActionEvent& ) 00184 throw ( RuntimeException ); 00185 }; 00186 00187 00188 class LoadBtnListener : public ::scsolver::ActionListener 00189 { 00190 00191 public: 00192 00193 LoadBtnListener( SolverDialog* pDlg ); 00194 virtual ~LoadBtnListener() throw(); 00195 00196 // XEventListener 00197 virtual void SAL_CALL disposing( const lang::EventObject& oEvt ) throw ( RuntimeException ); 00198 00199 // XActionListener 00200 virtual void SAL_CALL actionPerformed( const awt::ActionEvent& ) 00201 throw ( RuntimeException ); 00202 }; 00203 00204 00205 class ResetBtnListener : public ::scsolver::ActionListener 00206 { 00207 00208 public: 00209 00210 ResetBtnListener( SolverDialog* pDlg ); 00211 virtual ~ResetBtnListener() throw(); 00212 00213 // XEventListener 00214 virtual void SAL_CALL disposing( const lang::EventObject& oEvt ) throw ( RuntimeException ); 00215 00216 // XActionListener 00217 virtual void SAL_CALL actionPerformed( const awt::ActionEvent& ) 00218 throw ( RuntimeException ); 00219 00220 private: 00221 std::auto_ptr<MessageDialog> m_pDlg; 00222 }; 00223 00224 00225 class OptionBtnListener : public ::scsolver::ActionListener 00226 { 00227 public: 00228 OptionBtnListener( SolverDialog* pDlg ); 00229 virtual ~OptionBtnListener() throw(); 00230 00231 // XEventListener 00232 virtual void SAL_CALL disposing( const lang::EventObject& oEvt ) throw ( RuntimeException ); 00233 00234 // XActionListener 00235 virtual void SAL_CALL actionPerformed( const awt::ActionEvent& oEvt ) 00236 throw ( RuntimeException ); 00237 00238 private: 00239 std::auto_ptr<MessageDialog> m_pDlg; 00240 }; 00241 00242 00243 class ConstEditBtnListener : public ::scsolver::ActionListener 00244 { 00245 00246 public: 00247 00248 ConstEditBtnListener( SolverDialog*, ConstButtonType ); 00249 virtual ~ConstEditBtnListener() throw(); 00250 00251 // XEventListener 00252 virtual void SAL_CALL disposing( const lang::EventObject& oEvt ) throw ( RuntimeException ); 00253 00254 // XActionListener 00255 virtual void SAL_CALL actionPerformed( const awt::ActionEvent& ) throw ( RuntimeException ); 00256 00257 private: 00258 00259 ConstButtonType m_eBtnType; 00260 ConstButtonType getButtonType() const { return m_eBtnType; } 00261 00262 }; 00263 00264 00265 class ConstListBoxListener : public ItemListener 00266 { 00267 public: 00268 ConstListBoxListener( SolverDialog* ); 00269 virtual ~ConstListBoxListener() throw() {} 00270 00271 virtual void SAL_CALL disposing( const lang::EventObject& ) throw ( RuntimeException ) {} 00272 00273 virtual void SAL_CALL itemStateChanged( const awt::ItemEvent& ) throw ( RuntimeException ); 00274 00275 private: 00276 00277 }; 00278 00279 00280 class MaxRadioBtnListener : public ItemListener 00281 { 00282 private: 00283 00284 public: 00285 00286 MaxRadioBtnListener( SolverDialog* pDlg ); 00287 virtual ~MaxRadioBtnListener() throw(); 00288 00289 virtual void SAL_CALL disposing( const lang::EventObject& ) throw ( RuntimeException ); 00290 virtual void SAL_CALL itemStateChanged( const awt::ItemEvent& ) throw ( RuntimeException ); 00291 }; 00292 00293 00294 class WindowFocusListener : public FocusListener 00295 { 00296 public: 00297 00298 WindowFocusListener( BaseDialog* ); 00299 virtual ~WindowFocusListener() throw() {} 00300 00301 virtual rtl::OUString getListenerType() const { return ascii( "FocusListener" ); } 00302 00303 virtual void SAL_CALL disposing( const lang::EventObject& ) throw ( RuntimeException ) {} 00304 virtual void SAL_CALL focusGained( const awt::FocusEvent& ) throw( RuntimeException ); 00305 virtual void SAL_CALL focusLost( const awt::FocusEvent& ) throw( RuntimeException ); 00306 00307 }; 00308 00309 00310 class WindowMouseListener : public MouseListener 00311 { 00312 public: 00313 00314 WindowMouseListener( BaseDialog* ); 00315 virtual ~WindowMouseListener() throw(); 00316 00317 virtual void SAL_CALL mousePressed( const awt::MouseEvent& ) throw( RuntimeException ); 00318 virtual void SAL_CALL mouseReleased( const awt::MouseEvent& ) throw( RuntimeException ) {} 00319 virtual void SAL_CALL mouseEntered( const awt::MouseEvent& ) throw( RuntimeException ) {} 00320 virtual void SAL_CALL mouseExited( const awt::MouseEvent& ) throw( RuntimeException ) {} 00321 00322 virtual void SAL_CALL disposing( const lang::EventObject& ) throw ( RuntimeException ) {} 00323 }; 00324 00325 //-------------------------------------------------------------------------- 00326 00327 class OKCancelBtnListener : public ::scsolver::ActionListener 00328 { 00329 public: 00330 00331 OKCancelBtnListener( BaseDialog*, const rtl::OUString& ); 00332 virtual ~OKCancelBtnListener() throw(); 00333 00334 // XEventListener 00335 virtual void SAL_CALL disposing( const lang::EventObject& ) throw ( RuntimeException ); 00336 00337 // XActionListener 00338 virtual void SAL_CALL actionPerformed( const awt::ActionEvent& ) throw ( RuntimeException ); 00339 00340 private: 00341 00342 rtl::OUString m_sMode; 00343 }; 00344 00345 } 00346 00347 00348 #endif // _LISTENER_HXX
1.5.3