Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef INCLUDED_SDEXT_SOURCE_MINIMIZER_OPTIMIZERDIALOG_HXX
21 : #define INCLUDED_SDEXT_SOURCE_MINIMIZER_OPTIMIZERDIALOG_HXX
22 : #include "optimizerdialog.hrc"
23 : #include <vector>
24 : #include "unodialog.hxx"
25 : #include "optimizationstats.hxx"
26 : #include "configurationaccess.hxx"
27 : #include <com/sun/star/lang/XServiceInfo.hpp>
28 : #include <com/sun/star/awt/XItemListener.hpp>
29 : #include <com/sun/star/awt/XSpinField.hpp>
30 : #include <com/sun/star/awt/XSpinListener.hpp>
31 : #include <com/sun/star/beans/XPropertySet.hpp>
32 : #include <com/sun/star/uno/Sequence.h>
33 : #include <com/sun/star/text/XTextRange.hpp>
34 : #include <com/sun/star/drawing/XShapes.hpp>
35 : #include <com/sun/star/container/XIndexAccess.hpp>
36 : #include <com/sun/star/frame/XController.hpp>
37 : #include <com/sun/star/view/XSelectionSupplier.hpp>
38 : #include <com/sun/star/uno/XComponentContext.hpp>
39 : #include <com/sun/star/awt/XItemEventBroadcaster.hpp>
40 : #include <com/sun/star/frame/XStorable.hpp>
41 : #include <com/sun/star/frame/XDispatch.hpp>
42 : #include <com/sun/star/frame/XDesktop.hpp>
43 : #include <com/sun/star/awt/PushButtonType.hpp>
44 :
45 : #define MAX_STEP 4
46 : #define OD_DIALOG_WIDTH 330
47 : #define DIALOG_HEIGHT 210
48 : #define BUTTON_WIDTH 50
49 : #define BUTTON_HEIGHT 14
50 : #define BUTTON_POS_Y DIALOG_HEIGHT - BUTTON_HEIGHT - 6
51 :
52 : #define PAGE_POS_X 91
53 : #define PAGE_POS_Y 8
54 : #define PAGE_WIDTH OD_DIALOG_WIDTH - PAGE_POS_X
55 :
56 :
57 : // - OPTIMIZERDIALOG -
58 :
59 : class OptimizerDialog : public UnoDialog, public ConfigurationAccess
60 : {
61 : public :
62 :
63 : OptimizerDialog( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& rxContext, com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& rxFrame,
64 : com::sun::star::uno::Reference< com::sun::star::frame::XDispatch > rxStatusDispatcher );
65 : ~OptimizerDialog();
66 :
67 : sal_Bool execute();
68 :
69 : sal_Int16 mnCurrentStep;
70 : sal_Int16 mnTabIndex;
71 : sal_Bool mbIsReadonly;
72 :
73 : private :
74 : com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > mxContext;
75 : com::sun::star::uno::Reference< com::sun::star::frame::XFrame > mxFrame;
76 :
77 : com::sun::star::uno::Reference< com::sun::star::uno::XInterface > mxRoadmapControl;
78 : com::sun::star::uno::Reference< com::sun::star::uno::XInterface > mxRoadmapControlModel;
79 :
80 : com::sun::star::uno::Reference< com::sun::star::awt::XItemListener > mxItemListener;
81 : com::sun::star::uno::Reference< com::sun::star::awt::XActionListener > mxActionListener;
82 : com::sun::star::uno::Reference< com::sun::star::awt::XActionListener > mxActionListenerListBox0Pg0;
83 : com::sun::star::uno::Reference< com::sun::star::awt::XTextListener > mxTextListenerFormattedField0Pg1;
84 : com::sun::star::uno::Reference< com::sun::star::awt::XTextListener > mxTextListenerComboBox0Pg1;
85 : com::sun::star::uno::Reference< com::sun::star::awt::XSpinListener > mxSpinListenerFormattedField0Pg1;
86 : com::sun::star::uno::Reference< com::sun::star::frame::XDispatch > mxStatusDispatcher;
87 :
88 : std::vector< std::vector< OUString > > maControlPages;
89 :
90 : void InitDialog();
91 : void InitRoadmap();
92 : void InitNavigationBar();
93 : void InitPage0();
94 : void InitPage1();
95 : void InitPage2();
96 : void InitPage3();
97 : void InitPage4();
98 : void UpdateControlStatesPage0();
99 : void UpdateControlStatesPage1();
100 : void UpdateControlStatesPage2();
101 : void UpdateControlStatesPage3();
102 : void UpdateControlStatesPage4();
103 :
104 : void ActivatePage( sal_Int16 nStep );
105 : void DeactivatePage( sal_Int16 nStep );
106 : void InsertRoadmapItem( const sal_Int32 nIndex, const sal_Bool bEnabled, const OUString& rLabel, const sal_Int32 nItemID );
107 :
108 : public :
109 :
110 : OptimizationStats maStats;
111 :
112 : void UpdateStatus( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& rStatus );
113 :
114 : // the ConfigurationAccess is updated to actual control settings
115 : void UpdateConfiguration();
116 :
117 : void EnablePage( sal_Int16 nStep );
118 : void DisablePage( sal_Int16 nStep );
119 :
120 : void SwitchPage( sal_Int16 nNewStep );
121 : void UpdateControlStates( sal_Int16 nStep = -1 );
122 :
123 : OUString GetSelectedString( OUString const & token );
124 0 : com::sun::star::uno::Reference< com::sun::star::frame::XDispatch >& GetStatusDispatcher() { return mxStatusDispatcher; };
125 0 : com::sun::star::uno::Reference< com::sun::star::frame::XFrame>& GetFrame() { return mxFrame; };
126 0 : const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& GetComponentContext() { return mxContext; };
127 : };
128 :
129 :
130 :
131 0 : class ItemListener : public ::cppu::WeakImplHelper1< com::sun::star::awt::XItemListener >
132 : {
133 : public:
134 0 : ItemListener( OptimizerDialog& rOptimizerDialog ) : mrOptimizerDialog( rOptimizerDialog ){};
135 :
136 : virtual void SAL_CALL itemStateChanged( const ::com::sun::star::awt::ItemEvent& Event ) throw ( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
137 : virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw ( com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
138 : private:
139 :
140 : OptimizerDialog& mrOptimizerDialog;
141 : };
142 :
143 :
144 :
145 0 : class ActionListener : public ::cppu::WeakImplHelper1< com::sun::star::awt::XActionListener >
146 : {
147 : public:
148 0 : ActionListener( OptimizerDialog& rOptimizerDialog ) : mrOptimizerDialog( rOptimizerDialog ){};
149 :
150 : virtual void SAL_CALL actionPerformed( const ::com::sun::star::awt::ActionEvent& Event ) throw ( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
151 : virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw ( com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
152 : private:
153 :
154 : OptimizerDialog& mrOptimizerDialog;
155 : };
156 :
157 :
158 :
159 0 : class ActionListenerListBox0Pg0 : public ::cppu::WeakImplHelper1< com::sun::star::awt::XActionListener >
160 : {
161 : public:
162 0 : ActionListenerListBox0Pg0( OptimizerDialog& rOptimizerDialog ) : mrOptimizerDialog( rOptimizerDialog ){};
163 :
164 : virtual void SAL_CALL actionPerformed( const ::com::sun::star::awt::ActionEvent& Event ) throw ( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
165 : virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw ( com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
166 : private:
167 :
168 : OptimizerDialog& mrOptimizerDialog;
169 : };
170 :
171 :
172 :
173 0 : class TextListenerFormattedField0Pg1 : public ::cppu::WeakImplHelper1< com::sun::star::awt::XTextListener >
174 : {
175 : public:
176 0 : TextListenerFormattedField0Pg1( OptimizerDialog& rOptimizerDialog ) : mrOptimizerDialog( rOptimizerDialog ){};
177 :
178 : virtual void SAL_CALL textChanged( const ::com::sun::star::awt::TextEvent& Event ) throw ( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
179 : virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw ( com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
180 : private:
181 :
182 : OptimizerDialog& mrOptimizerDialog;
183 : };
184 :
185 :
186 :
187 0 : class TextListenerComboBox0Pg1 : public ::cppu::WeakImplHelper1< com::sun::star::awt::XTextListener >
188 : {
189 : public:
190 0 : TextListenerComboBox0Pg1( OptimizerDialog& rOptimizerDialog ) : mrOptimizerDialog( rOptimizerDialog ){};
191 :
192 : virtual void SAL_CALL textChanged( const ::com::sun::star::awt::TextEvent& Event ) throw ( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
193 : virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw ( com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
194 : private:
195 :
196 : OptimizerDialog& mrOptimizerDialog;
197 : };
198 :
199 :
200 :
201 0 : class SpinListenerFormattedField0Pg1 : public ::cppu::WeakImplHelper1< com::sun::star::awt::XSpinListener >
202 : {
203 : public:
204 0 : SpinListenerFormattedField0Pg1( OptimizerDialog& rOptimizerDialog ) : mrOptimizerDialog( rOptimizerDialog ){};
205 :
206 : virtual void SAL_CALL up( const ::com::sun::star::awt::SpinEvent& Event ) throw ( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
207 : virtual void SAL_CALL down( const ::com::sun::star::awt::SpinEvent& Event ) throw ( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
208 : virtual void SAL_CALL first( const ::com::sun::star::awt::SpinEvent& Event ) throw ( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
209 : virtual void SAL_CALL last( const ::com::sun::star::awt::SpinEvent& Event ) throw ( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
210 : virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw ( com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
211 : private:
212 :
213 : OptimizerDialog& mrOptimizerDialog;
214 : };
215 :
216 : #endif // INCLUDED_SDEXT_SOURCE_MINIMIZER_OPTIMIZERDIALOG_HXX
217 :
218 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|