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 28 #ifndef OPTIMIZERDIALOG_HXX 29 #define OPTIMIZERDIALOG_HXX 30 #ifndef _OPTIMIZERDIALOG_HRC 31 #include "optimizerdialog.hrc" 32 #endif 33 #include <vector> 34 #include "unodialog.hxx" 35 #include "pppoptimizertoken.hxx" 36 #include "optimizationstats.hxx" 37 #include "configurationaccess.hxx" 38 #include <com/sun/star/lang/XServiceInfo.hpp> 39 #include <com/sun/star/awt/XItemListener.hpp> 40 #include <com/sun/star/awt/XSpinField.hpp> 41 #include <com/sun/star/awt/XSpinListener.hpp> 42 #include <com/sun/star/beans/XPropertySet.hpp> 43 #include <com/sun/star/uno/Sequence.h> 44 #include <com/sun/star/text/XTextRange.hpp> 45 #include <com/sun/star/drawing/XShapes.hpp> 46 #include <com/sun/star/container/XIndexAccess.hpp> 47 #include <com/sun/star/frame/XController.hpp> 48 #include <com/sun/star/view/XSelectionSupplier.hpp> 49 #include <com/sun/star/uno/XComponentContext.hpp> 50 #include <com/sun/star/awt/XItemEventBroadcaster.hpp> 51 #ifndef _COM_SUN_STAR_UTIL_XCloseListener_HPP_ 52 #include <com/sun/star/util/XCloseListener.hpp> 53 #endif 54 #include <com/sun/star/frame/XStorable.hpp> 55 #include <com/sun/star/frame/XDispatch.hpp> 56 #include <com/sun/star/frame/XDesktop.hpp> 57 #include <com/sun/star/awt/PushButtonType.hpp> 58 59 #define MAX_STEP 4 60 #define OD_DIALOG_WIDTH 330 61 #define DIALOG_HEIGHT 210 62 #define BUTTON_WIDTH 50 63 #define BUTTON_HEIGHT 14 64 #define BUTTON_POS_Y DIALOG_HEIGHT - BUTTON_HEIGHT - 6 65 66 #define PAGE_POS_X 91 67 #define PAGE_POS_Y 8 68 #define PAGE_WIDTH OD_DIALOG_WIDTH - PAGE_POS_X 69 70 // ------------------- 71 // - OPTIMIZERDIALOG - 72 // ------------------- 73 class OptimizerDialog : public UnoDialog, public ConfigurationAccess 74 { 75 public : 76 77 OptimizerDialog( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& rxMSF, com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& rxFrame, 78 com::sun::star::uno::Reference< com::sun::star::frame::XDispatch > rxStatusDispatcher ); 79 ~OptimizerDialog(); 80 81 sal_Bool execute(); 82 83 sal_Int16 mnCurrentStep; 84 sal_Int16 mnTabIndex; 85 sal_Bool mbIsReadonly; 86 87 private : 88 com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >mxMSF; 89 com::sun::star::uno::Reference< com::sun::star::frame::XFrame > mxFrame; 90 91 com::sun::star::uno::Reference< com::sun::star::uno::XInterface > mxRoadmapControl; 92 com::sun::star::uno::Reference< com::sun::star::uno::XInterface > mxRoadmapControlModel; 93 94 com::sun::star::uno::Reference< com::sun::star::awt::XItemListener > mxItemListener; 95 com::sun::star::uno::Reference< com::sun::star::awt::XActionListener > mxActionListener; 96 com::sun::star::uno::Reference< com::sun::star::awt::XActionListener > mxActionListenerListBox0Pg0; 97 com::sun::star::uno::Reference< com::sun::star::awt::XTextListener > mxTextListenerFormattedField0Pg1; 98 com::sun::star::uno::Reference< com::sun::star::awt::XTextListener > mxTextListenerComboBox0Pg1; 99 com::sun::star::uno::Reference< com::sun::star::awt::XSpinListener > mxSpinListenerFormattedField0Pg1; 100 com::sun::star::uno::Reference< com::sun::star::frame::XDispatch > mxStatusDispatcher; 101 102 std::vector< std::vector< rtl::OUString > > maControlPages; 103 104 void InitDialog(); 105 void InitRoadmap(); 106 void InitNavigationBar(); 107 void InitPage0(); 108 void InitPage1(); 109 void InitPage2(); 110 void InitPage3(); 111 void InitPage4(); 112 void UpdateControlStatesPage0(); 113 void UpdateControlStatesPage1(); 114 void UpdateControlStatesPage2(); 115 void UpdateControlStatesPage3(); 116 void UpdateControlStatesPage4(); 117 118 void ActivatePage( sal_Int16 nStep ); 119 void DeactivatePage( sal_Int16 nStep ); 120 void InsertRoadmapItem( const sal_Int32 nIndex, const sal_Bool bEnabled, const rtl::OUString& rLabel, const sal_Int32 nItemID ); 121 122 public : 123 124 OptimizationStats maStats; 125 126 void UpdateStatus( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& rStatus ); 127 128 // the ConfigurationAccess is updated to actual control settings 129 void UpdateConfiguration(); 130 131 void EnablePage( sal_Int16 nStep ); 132 void DisablePage( sal_Int16 nStep ); 133 134 void SwitchPage( sal_Int16 nNewStep ); 135 void UpdateControlStates( sal_Int16 nStep = -1 ); 136 137 rtl::OUString GetSelectedString( PPPOptimizerTokenEnum eListBox ); 138 com::sun::star::uno::Reference< com::sun::star::frame::XDispatch >& GetStatusDispatcher() { return mxStatusDispatcher; }; 139 com::sun::star::uno::Reference< com::sun::star::frame::XFrame>& GetFrame() { return mxFrame; }; 140 const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& GetComponentContext() { return mxMSF; }; 141 }; 142 143 // ----------------------------------------------------------------------------- 144 145 class ItemListener : public ::cppu::WeakImplHelper1< com::sun::star::awt::XItemListener > 146 { 147 public: 148 ItemListener( OptimizerDialog& rOptimizerDialog ) : mrOptimizerDialog( rOptimizerDialog ){}; 149 150 virtual void SAL_CALL itemStateChanged( const ::com::sun::star::awt::ItemEvent& Event ) throw ( com::sun::star::uno::RuntimeException ); 151 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw ( com::sun::star::uno::RuntimeException); 152 private: 153 154 OptimizerDialog& mrOptimizerDialog; 155 }; 156 157 // ----------------------------------------------------------------------------- 158 159 class ActionListener : public ::cppu::WeakImplHelper1< com::sun::star::awt::XActionListener > 160 { 161 public: 162 ActionListener( OptimizerDialog& rOptimizerDialog ) : mrOptimizerDialog( rOptimizerDialog ){}; 163 164 virtual void SAL_CALL actionPerformed( const ::com::sun::star::awt::ActionEvent& Event ) throw ( com::sun::star::uno::RuntimeException ); 165 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw ( com::sun::star::uno::RuntimeException); 166 private: 167 168 OptimizerDialog& mrOptimizerDialog; 169 }; 170 171 // ----------------------------------------------------------------------------- 172 173 class ActionListenerListBox0Pg0 : public ::cppu::WeakImplHelper1< com::sun::star::awt::XActionListener > 174 { 175 public: 176 ActionListenerListBox0Pg0( OptimizerDialog& rOptimizerDialog ) : mrOptimizerDialog( rOptimizerDialog ){}; 177 178 virtual void SAL_CALL actionPerformed( const ::com::sun::star::awt::ActionEvent& Event ) throw ( com::sun::star::uno::RuntimeException ); 179 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw ( com::sun::star::uno::RuntimeException); 180 private: 181 182 OptimizerDialog& mrOptimizerDialog; 183 }; 184 185 // ----------------------------------------------------------------------------- 186 187 class TextListenerFormattedField0Pg1 : public ::cppu::WeakImplHelper1< com::sun::star::awt::XTextListener > 188 { 189 public: 190 TextListenerFormattedField0Pg1( OptimizerDialog& rOptimizerDialog ) : mrOptimizerDialog( rOptimizerDialog ){}; 191 192 virtual void SAL_CALL textChanged( const ::com::sun::star::awt::TextEvent& Event ) throw ( com::sun::star::uno::RuntimeException ); 193 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw ( com::sun::star::uno::RuntimeException); 194 private: 195 196 OptimizerDialog& mrOptimizerDialog; 197 }; 198 199 // ----------------------------------------------------------------------------- 200 201 class TextListenerComboBox0Pg1 : public ::cppu::WeakImplHelper1< com::sun::star::awt::XTextListener > 202 { 203 public: 204 TextListenerComboBox0Pg1( OptimizerDialog& rOptimizerDialog ) : mrOptimizerDialog( rOptimizerDialog ){}; 205 206 virtual void SAL_CALL textChanged( const ::com::sun::star::awt::TextEvent& Event ) throw ( com::sun::star::uno::RuntimeException ); 207 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw ( com::sun::star::uno::RuntimeException); 208 private: 209 210 OptimizerDialog& mrOptimizerDialog; 211 }; 212 213 // ----------------------------------------------------------------------------- 214 215 class SpinListenerFormattedField0Pg1 : public ::cppu::WeakImplHelper1< com::sun::star::awt::XSpinListener > 216 { 217 public: 218 SpinListenerFormattedField0Pg1( OptimizerDialog& rOptimizerDialog ) : mrOptimizerDialog( rOptimizerDialog ){}; 219 220 virtual void SAL_CALL up( const ::com::sun::star::awt::SpinEvent& Event ) throw ( com::sun::star::uno::RuntimeException ); 221 virtual void SAL_CALL down( const ::com::sun::star::awt::SpinEvent& Event ) throw ( com::sun::star::uno::RuntimeException ); 222 virtual void SAL_CALL first( const ::com::sun::star::awt::SpinEvent& Event ) throw ( com::sun::star::uno::RuntimeException ); 223 virtual void SAL_CALL last( const ::com::sun::star::awt::SpinEvent& Event ) throw ( com::sun::star::uno::RuntimeException ); 224 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw ( com::sun::star::uno::RuntimeException); 225 private: 226 227 OptimizerDialog& mrOptimizerDialog; 228 }; 229 230 // ----------------------------------------------------------------------------- 231 232 class HelpCloseListener : public ::cppu::WeakImplHelper1< com::sun::star::util::XCloseListener > 233 { 234 public: 235 HelpCloseListener( com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& rXFrame ) : mrXFrame( rXFrame ){}; 236 237 virtual void SAL_CALL addCloseListener(const com::sun::star::uno::Reference < com::sun::star::util::XCloseListener >& ) throw( com::sun::star::uno::RuntimeException ); 238 virtual void SAL_CALL removeCloseListener( const com::sun::star::uno::Reference < com::sun::star::util::XCloseListener >& xListener ) throw( com::sun::star::uno::RuntimeException ); 239 virtual void SAL_CALL notifyClosing( const com::sun::star::lang::EventObject& aEvent ) throw (com::sun::star::uno::RuntimeException) ; 240 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) ; 241 virtual void SAL_CALL disposing( const com::sun::star::lang::EventObject& aEvent ) throw (com::sun::star::uno::RuntimeException) ; 242 243 private: 244 245 com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& mrXFrame; 246 }; 247 248 249 #endif // OPTIMIZERDIALOG_HXX 250