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