xref: /AOO41X/main/sdext/source/minimizer/optimizerdialog.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef OPTIMIZERDIALOG_HXX
29*cdf0e10cSrcweir #define OPTIMIZERDIALOG_HXX
30*cdf0e10cSrcweir #ifndef _OPTIMIZERDIALOG_HRC
31*cdf0e10cSrcweir #include "optimizerdialog.hrc"
32*cdf0e10cSrcweir #endif
33*cdf0e10cSrcweir #include <vector>
34*cdf0e10cSrcweir #include "unodialog.hxx"
35*cdf0e10cSrcweir #include "pppoptimizertoken.hxx"
36*cdf0e10cSrcweir #include "optimizationstats.hxx"
37*cdf0e10cSrcweir #include "configurationaccess.hxx"
38*cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
39*cdf0e10cSrcweir #include <com/sun/star/awt/XItemListener.hpp>
40*cdf0e10cSrcweir #include <com/sun/star/awt/XSpinField.hpp>
41*cdf0e10cSrcweir #include <com/sun/star/awt/XSpinListener.hpp>
42*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
43*cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.h>
44*cdf0e10cSrcweir #include <com/sun/star/text/XTextRange.hpp>
45*cdf0e10cSrcweir #include <com/sun/star/drawing/XShapes.hpp>
46*cdf0e10cSrcweir #include <com/sun/star/container/XIndexAccess.hpp>
47*cdf0e10cSrcweir #include <com/sun/star/frame/XController.hpp>
48*cdf0e10cSrcweir #include <com/sun/star/view/XSelectionSupplier.hpp>
49*cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp>
50*cdf0e10cSrcweir #include <com/sun/star/awt/XItemEventBroadcaster.hpp>
51*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UTIL_XCloseListener_HPP_
52*cdf0e10cSrcweir #include <com/sun/star/util/XCloseListener.hpp>
53*cdf0e10cSrcweir #endif
54*cdf0e10cSrcweir #include <com/sun/star/frame/XStorable.hpp>
55*cdf0e10cSrcweir #include <com/sun/star/frame/XDispatch.hpp>
56*cdf0e10cSrcweir #include <com/sun/star/frame/XDesktop.hpp>
57*cdf0e10cSrcweir #include <com/sun/star/awt/PushButtonType.hpp>
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir #define MAX_STEP		4
60*cdf0e10cSrcweir #define OD_DIALOG_WIDTH	330
61*cdf0e10cSrcweir #define DIALOG_HEIGHT	210
62*cdf0e10cSrcweir #define BUTTON_WIDTH	50
63*cdf0e10cSrcweir #define BUTTON_HEIGHT	14
64*cdf0e10cSrcweir #define BUTTON_POS_Y	DIALOG_HEIGHT - BUTTON_HEIGHT - 6
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir #define PAGE_POS_X		91
67*cdf0e10cSrcweir #define PAGE_POS_Y		8
68*cdf0e10cSrcweir #define PAGE_WIDTH		OD_DIALOG_WIDTH - PAGE_POS_X
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir // -------------------
71*cdf0e10cSrcweir // - OPTIMIZERDIALOG -
72*cdf0e10cSrcweir // -------------------
73*cdf0e10cSrcweir class OptimizerDialog : public UnoDialog, public ConfigurationAccess
74*cdf0e10cSrcweir {
75*cdf0e10cSrcweir public :
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir 	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*cdf0e10cSrcweir 		com::sun::star::uno::Reference< com::sun::star::frame::XDispatch > rxStatusDispatcher );
79*cdf0e10cSrcweir     ~OptimizerDialog();
80*cdf0e10cSrcweir 
81*cdf0e10cSrcweir 	sal_Bool				execute();
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir 	sal_Int16				mnCurrentStep;
84*cdf0e10cSrcweir 	sal_Int16				mnTabIndex;
85*cdf0e10cSrcweir 	sal_Bool				mbIsReadonly;
86*cdf0e10cSrcweir 
87*cdf0e10cSrcweir private :
88*cdf0e10cSrcweir 	com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >mxMSF;
89*cdf0e10cSrcweir 	com::sun::star::uno::Reference< com::sun::star::frame::XFrame >			mxFrame;
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir 	com::sun::star::uno::Reference< com::sun::star::uno::XInterface >		mxRoadmapControl;
92*cdf0e10cSrcweir 	com::sun::star::uno::Reference< com::sun::star::uno::XInterface >		mxRoadmapControlModel;
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir 	com::sun::star::uno::Reference< com::sun::star::awt::XItemListener >	mxItemListener;
95*cdf0e10cSrcweir 	com::sun::star::uno::Reference< com::sun::star::awt::XActionListener >	mxActionListener;
96*cdf0e10cSrcweir 	com::sun::star::uno::Reference< com::sun::star::awt::XActionListener >	mxActionListenerListBox0Pg0;
97*cdf0e10cSrcweir 	com::sun::star::uno::Reference< com::sun::star::awt::XTextListener >	mxTextListenerFormattedField0Pg1;
98*cdf0e10cSrcweir 	com::sun::star::uno::Reference< com::sun::star::awt::XTextListener >	mxTextListenerComboBox0Pg1;
99*cdf0e10cSrcweir 	com::sun::star::uno::Reference< com::sun::star::awt::XSpinListener >	mxSpinListenerFormattedField0Pg1;
100*cdf0e10cSrcweir 	com::sun::star::uno::Reference< com::sun::star::frame::XDispatch >		mxStatusDispatcher;
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir 	std::vector< std::vector< rtl::OUString > > maControlPages;
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir 	void InitDialog();
105*cdf0e10cSrcweir 	void InitRoadmap();
106*cdf0e10cSrcweir 	void InitNavigationBar();
107*cdf0e10cSrcweir 	void InitPage0();
108*cdf0e10cSrcweir 	void InitPage1();
109*cdf0e10cSrcweir 	void InitPage2();
110*cdf0e10cSrcweir 	void InitPage3();
111*cdf0e10cSrcweir 	void InitPage4();
112*cdf0e10cSrcweir 	void UpdateControlStatesPage0();
113*cdf0e10cSrcweir 	void UpdateControlStatesPage1();
114*cdf0e10cSrcweir 	void UpdateControlStatesPage2();
115*cdf0e10cSrcweir 	void UpdateControlStatesPage3();
116*cdf0e10cSrcweir 	void UpdateControlStatesPage4();
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir 	void ActivatePage( sal_Int16 nStep );
119*cdf0e10cSrcweir 	void DeactivatePage( sal_Int16 nStep );
120*cdf0e10cSrcweir 	void InsertRoadmapItem( const sal_Int32 nIndex, const sal_Bool bEnabled, const rtl::OUString& rLabel, const sal_Int32 nItemID );
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir public :
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir 	OptimizationStats maStats;
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir 	void UpdateStatus( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& rStatus );
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir 	// the ConfigurationAccess is updated to actual control settings
129*cdf0e10cSrcweir 	void UpdateConfiguration();
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir 	void EnablePage( sal_Int16 nStep );
132*cdf0e10cSrcweir 	void DisablePage( sal_Int16 nStep );
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir 	void SwitchPage( sal_Int16 nNewStep );
135*cdf0e10cSrcweir 	void UpdateControlStates( sal_Int16 nStep = -1 );
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir 	rtl::OUString GetSelectedString( PPPOptimizerTokenEnum eListBox );
138*cdf0e10cSrcweir 	com::sun::star::uno::Reference< com::sun::star::frame::XDispatch >& GetStatusDispatcher() { return mxStatusDispatcher; };
139*cdf0e10cSrcweir 	com::sun::star::uno::Reference< com::sun::star::frame::XFrame>& GetFrame() { return mxFrame; };
140*cdf0e10cSrcweir 	const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& GetComponentContext() { return mxMSF; };
141*cdf0e10cSrcweir };
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir // -----------------------------------------------------------------------------
144*cdf0e10cSrcweir 
145*cdf0e10cSrcweir class ItemListener : public ::cppu::WeakImplHelper1< com::sun::star::awt::XItemListener >
146*cdf0e10cSrcweir {
147*cdf0e10cSrcweir public:
148*cdf0e10cSrcweir 	ItemListener( OptimizerDialog& rOptimizerDialog ) : mrOptimizerDialog( rOptimizerDialog ){};
149*cdf0e10cSrcweir 
150*cdf0e10cSrcweir     virtual void SAL_CALL itemStateChanged( const ::com::sun::star::awt::ItemEvent& Event ) throw ( com::sun::star::uno::RuntimeException );
151*cdf0e10cSrcweir 	virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw ( com::sun::star::uno::RuntimeException);
152*cdf0e10cSrcweir private:
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir 	OptimizerDialog& mrOptimizerDialog;
155*cdf0e10cSrcweir };
156*cdf0e10cSrcweir 
157*cdf0e10cSrcweir // -----------------------------------------------------------------------------
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir class ActionListener : public ::cppu::WeakImplHelper1< com::sun::star::awt::XActionListener >
160*cdf0e10cSrcweir {
161*cdf0e10cSrcweir public:
162*cdf0e10cSrcweir 	ActionListener( OptimizerDialog& rOptimizerDialog ) : mrOptimizerDialog( rOptimizerDialog ){};
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir     virtual void SAL_CALL actionPerformed( const ::com::sun::star::awt::ActionEvent& Event ) throw ( com::sun::star::uno::RuntimeException );
165*cdf0e10cSrcweir 	virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw ( com::sun::star::uno::RuntimeException);
166*cdf0e10cSrcweir private:
167*cdf0e10cSrcweir 
168*cdf0e10cSrcweir 	OptimizerDialog& mrOptimizerDialog;
169*cdf0e10cSrcweir };
170*cdf0e10cSrcweir 
171*cdf0e10cSrcweir // -----------------------------------------------------------------------------
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir class ActionListenerListBox0Pg0 : public ::cppu::WeakImplHelper1< com::sun::star::awt::XActionListener >
174*cdf0e10cSrcweir {
175*cdf0e10cSrcweir public:
176*cdf0e10cSrcweir 	ActionListenerListBox0Pg0( OptimizerDialog& rOptimizerDialog ) : mrOptimizerDialog( rOptimizerDialog ){};
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir     virtual void SAL_CALL actionPerformed( const ::com::sun::star::awt::ActionEvent& Event ) throw ( com::sun::star::uno::RuntimeException );
179*cdf0e10cSrcweir 	virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw ( com::sun::star::uno::RuntimeException);
180*cdf0e10cSrcweir private:
181*cdf0e10cSrcweir 
182*cdf0e10cSrcweir 	OptimizerDialog& mrOptimizerDialog;
183*cdf0e10cSrcweir };
184*cdf0e10cSrcweir 
185*cdf0e10cSrcweir // -----------------------------------------------------------------------------
186*cdf0e10cSrcweir 
187*cdf0e10cSrcweir class TextListenerFormattedField0Pg1 : public ::cppu::WeakImplHelper1< com::sun::star::awt::XTextListener >
188*cdf0e10cSrcweir {
189*cdf0e10cSrcweir public:
190*cdf0e10cSrcweir 	TextListenerFormattedField0Pg1( OptimizerDialog& rOptimizerDialog ) : mrOptimizerDialog( rOptimizerDialog ){};
191*cdf0e10cSrcweir 
192*cdf0e10cSrcweir     virtual void SAL_CALL textChanged( const ::com::sun::star::awt::TextEvent& Event ) throw ( com::sun::star::uno::RuntimeException );
193*cdf0e10cSrcweir 	virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw ( com::sun::star::uno::RuntimeException);
194*cdf0e10cSrcweir private:
195*cdf0e10cSrcweir 
196*cdf0e10cSrcweir 	OptimizerDialog& mrOptimizerDialog;
197*cdf0e10cSrcweir };
198*cdf0e10cSrcweir 
199*cdf0e10cSrcweir // -----------------------------------------------------------------------------
200*cdf0e10cSrcweir 
201*cdf0e10cSrcweir class TextListenerComboBox0Pg1 : public ::cppu::WeakImplHelper1< com::sun::star::awt::XTextListener >
202*cdf0e10cSrcweir {
203*cdf0e10cSrcweir public:
204*cdf0e10cSrcweir 	TextListenerComboBox0Pg1( OptimizerDialog& rOptimizerDialog ) : mrOptimizerDialog( rOptimizerDialog ){};
205*cdf0e10cSrcweir 
206*cdf0e10cSrcweir     virtual void SAL_CALL textChanged( const ::com::sun::star::awt::TextEvent& Event ) throw ( com::sun::star::uno::RuntimeException );
207*cdf0e10cSrcweir 	virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw ( com::sun::star::uno::RuntimeException);
208*cdf0e10cSrcweir private:
209*cdf0e10cSrcweir 
210*cdf0e10cSrcweir 	OptimizerDialog& mrOptimizerDialog;
211*cdf0e10cSrcweir };
212*cdf0e10cSrcweir 
213*cdf0e10cSrcweir // -----------------------------------------------------------------------------
214*cdf0e10cSrcweir 
215*cdf0e10cSrcweir class SpinListenerFormattedField0Pg1 : public ::cppu::WeakImplHelper1< com::sun::star::awt::XSpinListener >
216*cdf0e10cSrcweir {
217*cdf0e10cSrcweir public:
218*cdf0e10cSrcweir 	SpinListenerFormattedField0Pg1( OptimizerDialog& rOptimizerDialog ) : mrOptimizerDialog( rOptimizerDialog ){};
219*cdf0e10cSrcweir 
220*cdf0e10cSrcweir     virtual void SAL_CALL up( const ::com::sun::star::awt::SpinEvent& Event ) throw ( com::sun::star::uno::RuntimeException );
221*cdf0e10cSrcweir     virtual void SAL_CALL down( const ::com::sun::star::awt::SpinEvent& Event ) throw ( com::sun::star::uno::RuntimeException );
222*cdf0e10cSrcweir     virtual void SAL_CALL first( const ::com::sun::star::awt::SpinEvent& Event ) throw ( com::sun::star::uno::RuntimeException );
223*cdf0e10cSrcweir     virtual void SAL_CALL last( const ::com::sun::star::awt::SpinEvent& Event ) throw ( com::sun::star::uno::RuntimeException );
224*cdf0e10cSrcweir 	virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw ( com::sun::star::uno::RuntimeException);
225*cdf0e10cSrcweir private:
226*cdf0e10cSrcweir 
227*cdf0e10cSrcweir 	OptimizerDialog& mrOptimizerDialog;
228*cdf0e10cSrcweir };
229*cdf0e10cSrcweir 
230*cdf0e10cSrcweir // -----------------------------------------------------------------------------
231*cdf0e10cSrcweir 
232*cdf0e10cSrcweir class HelpCloseListener : public ::cppu::WeakImplHelper1< com::sun::star::util::XCloseListener >
233*cdf0e10cSrcweir {
234*cdf0e10cSrcweir public:
235*cdf0e10cSrcweir 	HelpCloseListener( com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& rXFrame ) : mrXFrame( rXFrame ){};
236*cdf0e10cSrcweir 
237*cdf0e10cSrcweir 	virtual void SAL_CALL addCloseListener(const com::sun::star::uno::Reference < com::sun::star::util::XCloseListener >& ) throw( com::sun::star::uno::RuntimeException );
238*cdf0e10cSrcweir 	virtual void SAL_CALL removeCloseListener( const com::sun::star::uno::Reference < com::sun::star::util::XCloseListener >& xListener ) throw( com::sun::star::uno::RuntimeException );
239*cdf0e10cSrcweir     virtual void SAL_CALL notifyClosing( const com::sun::star::lang::EventObject& aEvent ) throw (com::sun::star::uno::RuntimeException) ;
240*cdf0e10cSrcweir 	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*cdf0e10cSrcweir     virtual void SAL_CALL disposing( const com::sun::star::lang::EventObject& aEvent ) throw (com::sun::star::uno::RuntimeException) ;
242*cdf0e10cSrcweir 
243*cdf0e10cSrcweir private:
244*cdf0e10cSrcweir 
245*cdf0e10cSrcweir 	com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& mrXFrame;
246*cdf0e10cSrcweir };
247*cdf0e10cSrcweir 
248*cdf0e10cSrcweir 
249*cdf0e10cSrcweir #endif // OPTIMIZERDIALOG_HXX
250