1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef OPTIMIZERDIALOG_HXX 25 #define OPTIMIZERDIALOG_HXX 26 #ifndef _OPTIMIZERDIALOG_HRC 27 #include "optimizerdialog.hrc" 28 #endif 29 #include <vector> 30 #include "unodialog.hxx" 31 #include "pppoptimizertoken.hxx" 32 #include "optimizationstats.hxx" 33 #include "configurationaccess.hxx" 34 #include <com/sun/star/lang/XServiceInfo.hpp> 35 #include <com/sun/star/awt/XItemListener.hpp> 36 #include <com/sun/star/awt/XSpinField.hpp> 37 #include <com/sun/star/awt/XSpinListener.hpp> 38 #include <com/sun/star/beans/XPropertySet.hpp> 39 #include <com/sun/star/uno/Sequence.h> 40 #include <com/sun/star/text/XTextRange.hpp> 41 #include <com/sun/star/drawing/XShapes.hpp> 42 #include <com/sun/star/container/XIndexAccess.hpp> 43 #include <com/sun/star/frame/XController.hpp> 44 #include <com/sun/star/view/XSelectionSupplier.hpp> 45 #include <com/sun/star/uno/XComponentContext.hpp> 46 #include <com/sun/star/awt/XItemEventBroadcaster.hpp> 47 #ifndef _COM_SUN_STAR_UTIL_XCloseListener_HPP_ 48 #include <com/sun/star/util/XCloseListener.hpp> 49 #endif 50 #include <com/sun/star/frame/XStorable.hpp> 51 #include <com/sun/star/frame/XDispatch.hpp> 52 #include <com/sun/star/frame/XDesktop.hpp> 53 #include <com/sun/star/awt/PushButtonType.hpp> 54 55 #define MAX_STEP 4 56 #define OD_DIALOG_WIDTH 330 57 #define DIALOG_HEIGHT 210 58 #define BUTTON_WIDTH 50 59 #define BUTTON_HEIGHT 14 60 #define BUTTON_POS_Y DIALOG_HEIGHT - BUTTON_HEIGHT - 6 61 62 #define PAGE_POS_X 91 63 #define PAGE_POS_Y 8 64 #define PAGE_WIDTH OD_DIALOG_WIDTH - PAGE_POS_X 65 66 // ------------------- 67 // - OPTIMIZERDIALOG - 68 // ------------------- 69 class OptimizerDialog : public UnoDialog, public ConfigurationAccess 70 { 71 public : 72 73 OptimizerDialog( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& rxMSF, com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& rxFrame, 74 com::sun::star::uno::Reference< com::sun::star::frame::XDispatch > rxStatusDispatcher ); 75 ~OptimizerDialog(); 76 77 sal_Bool execute(); 78 79 sal_Int16 mnCurrentStep; 80 sal_Int16 mnTabIndex; 81 sal_Bool mbIsReadonly; 82 83 private : 84 com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >mxMSF; 85 com::sun::star::uno::Reference< com::sun::star::frame::XFrame > mxFrame; 86 87 com::sun::star::uno::Reference< com::sun::star::uno::XInterface > mxRoadmapControl; 88 com::sun::star::uno::Reference< com::sun::star::uno::XInterface > mxRoadmapControlModel; 89 90 com::sun::star::uno::Reference< com::sun::star::awt::XItemListener > mxItemListener; 91 com::sun::star::uno::Reference< com::sun::star::awt::XActionListener > mxActionListener; 92 com::sun::star::uno::Reference< com::sun::star::awt::XActionListener > mxActionListenerListBox0Pg0; 93 com::sun::star::uno::Reference< com::sun::star::awt::XTextListener > mxTextListenerFormattedField0Pg1; 94 com::sun::star::uno::Reference< com::sun::star::awt::XTextListener > mxTextListenerComboBox0Pg1; 95 com::sun::star::uno::Reference< com::sun::star::awt::XSpinListener > mxSpinListenerFormattedField0Pg1; 96 com::sun::star::uno::Reference< com::sun::star::frame::XDispatch > mxStatusDispatcher; 97 98 std::vector< std::vector< rtl::OUString > > maControlPages; 99 100 void InitDialog(); 101 void InitRoadmap(); 102 void InitNavigationBar(); 103 void InitPage0(); 104 void InitPage1(); 105 void InitPage2(); 106 void InitPage3(); 107 void InitPage4(); 108 void UpdateControlStatesPage0(); 109 void UpdateControlStatesPage1(); 110 void UpdateControlStatesPage2(); 111 void UpdateControlStatesPage3(); 112 void UpdateControlStatesPage4(); 113 114 void ActivatePage( sal_Int16 nStep ); 115 void DeactivatePage( sal_Int16 nStep ); 116 void InsertRoadmapItem( const sal_Int32 nIndex, const sal_Bool bEnabled, const rtl::OUString& rLabel, const sal_Int32 nItemID ); 117 118 public : 119 120 OptimizationStats maStats; 121 122 void UpdateStatus( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& rStatus ); 123 124 // the ConfigurationAccess is updated to actual control settings 125 void UpdateConfiguration(); 126 127 void EnablePage( sal_Int16 nStep ); 128 void DisablePage( sal_Int16 nStep ); 129 130 void SwitchPage( sal_Int16 nNewStep ); 131 void UpdateControlStates( sal_Int16 nStep = -1 ); 132 133 rtl::OUString GetSelectedString( PPPOptimizerTokenEnum eListBox ); 134 com::sun::star::uno::Reference< com::sun::star::frame::XDispatch >& GetStatusDispatcher() { return mxStatusDispatcher; }; 135 com::sun::star::uno::Reference< com::sun::star::frame::XFrame>& GetFrame() { return mxFrame; }; 136 const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& GetComponentContext() { return mxMSF; }; 137 }; 138 139 // ----------------------------------------------------------------------------- 140 141 class ItemListener : public ::cppu::WeakImplHelper1< com::sun::star::awt::XItemListener > 142 { 143 public: 144 ItemListener( OptimizerDialog& rOptimizerDialog ) : mrOptimizerDialog( rOptimizerDialog ){}; 145 146 virtual void SAL_CALL itemStateChanged( const ::com::sun::star::awt::ItemEvent& Event ) throw ( com::sun::star::uno::RuntimeException ); 147 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw ( com::sun::star::uno::RuntimeException); 148 private: 149 150 OptimizerDialog& mrOptimizerDialog; 151 }; 152 153 // ----------------------------------------------------------------------------- 154 155 class ActionListener : public ::cppu::WeakImplHelper1< com::sun::star::awt::XActionListener > 156 { 157 public: 158 ActionListener( OptimizerDialog& rOptimizerDialog ) : mrOptimizerDialog( rOptimizerDialog ){}; 159 160 virtual void SAL_CALL actionPerformed( const ::com::sun::star::awt::ActionEvent& Event ) throw ( com::sun::star::uno::RuntimeException ); 161 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw ( com::sun::star::uno::RuntimeException); 162 private: 163 164 OptimizerDialog& mrOptimizerDialog; 165 }; 166 167 // ----------------------------------------------------------------------------- 168 169 class ActionListenerListBox0Pg0 : public ::cppu::WeakImplHelper1< com::sun::star::awt::XActionListener > 170 { 171 public: 172 ActionListenerListBox0Pg0( OptimizerDialog& rOptimizerDialog ) : mrOptimizerDialog( rOptimizerDialog ){}; 173 174 virtual void SAL_CALL actionPerformed( const ::com::sun::star::awt::ActionEvent& Event ) throw ( com::sun::star::uno::RuntimeException ); 175 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw ( com::sun::star::uno::RuntimeException); 176 private: 177 178 OptimizerDialog& mrOptimizerDialog; 179 }; 180 181 // ----------------------------------------------------------------------------- 182 183 class TextListenerFormattedField0Pg1 : public ::cppu::WeakImplHelper1< com::sun::star::awt::XTextListener > 184 { 185 public: 186 TextListenerFormattedField0Pg1( OptimizerDialog& rOptimizerDialog ) : mrOptimizerDialog( rOptimizerDialog ){}; 187 188 virtual void SAL_CALL textChanged( const ::com::sun::star::awt::TextEvent& Event ) throw ( com::sun::star::uno::RuntimeException ); 189 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw ( com::sun::star::uno::RuntimeException); 190 private: 191 192 OptimizerDialog& mrOptimizerDialog; 193 }; 194 195 // ----------------------------------------------------------------------------- 196 197 class TextListenerComboBox0Pg1 : public ::cppu::WeakImplHelper1< com::sun::star::awt::XTextListener > 198 { 199 public: 200 TextListenerComboBox0Pg1( OptimizerDialog& rOptimizerDialog ) : mrOptimizerDialog( rOptimizerDialog ){}; 201 202 virtual void SAL_CALL textChanged( const ::com::sun::star::awt::TextEvent& Event ) throw ( com::sun::star::uno::RuntimeException ); 203 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw ( com::sun::star::uno::RuntimeException); 204 private: 205 206 OptimizerDialog& mrOptimizerDialog; 207 }; 208 209 // ----------------------------------------------------------------------------- 210 211 class SpinListenerFormattedField0Pg1 : public ::cppu::WeakImplHelper1< com::sun::star::awt::XSpinListener > 212 { 213 public: 214 SpinListenerFormattedField0Pg1( OptimizerDialog& rOptimizerDialog ) : mrOptimizerDialog( rOptimizerDialog ){}; 215 216 virtual void SAL_CALL up( const ::com::sun::star::awt::SpinEvent& Event ) throw ( com::sun::star::uno::RuntimeException ); 217 virtual void SAL_CALL down( const ::com::sun::star::awt::SpinEvent& Event ) throw ( com::sun::star::uno::RuntimeException ); 218 virtual void SAL_CALL first( const ::com::sun::star::awt::SpinEvent& Event ) throw ( com::sun::star::uno::RuntimeException ); 219 virtual void SAL_CALL last( const ::com::sun::star::awt::SpinEvent& Event ) throw ( com::sun::star::uno::RuntimeException ); 220 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw ( com::sun::star::uno::RuntimeException); 221 private: 222 223 OptimizerDialog& mrOptimizerDialog; 224 }; 225 226 // ----------------------------------------------------------------------------- 227 228 class HelpCloseListener : public ::cppu::WeakImplHelper1< com::sun::star::util::XCloseListener > 229 { 230 public: 231 HelpCloseListener( com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& rXFrame ) : mrXFrame( rXFrame ){}; 232 233 virtual void SAL_CALL addCloseListener(const com::sun::star::uno::Reference < com::sun::star::util::XCloseListener >& ) throw( com::sun::star::uno::RuntimeException ); 234 virtual void SAL_CALL removeCloseListener( const com::sun::star::uno::Reference < com::sun::star::util::XCloseListener >& xListener ) throw( com::sun::star::uno::RuntimeException ); 235 virtual void SAL_CALL notifyClosing( const com::sun::star::lang::EventObject& aEvent ) throw (com::sun::star::uno::RuntimeException) ; 236 virtual void SAL_CALL queryClosing( const com::sun::star::lang::EventObject& aEvent, sal_Bool bDeliverOwnership ) throw (com::sun::star::uno::RuntimeException, com::sun::star::util::CloseVetoException) ; 237 virtual void SAL_CALL disposing( const com::sun::star::lang::EventObject& aEvent ) throw (com::sun::star::uno::RuntimeException) ; 238 239 private: 240 241 com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& mrXFrame; 242 }; 243 244 245 #endif // OPTIMIZERDIALOG_HXX 246