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 css::uno::Reference< css::uno::XComponentContext >& rxContext, css::uno::Reference< css::frame::XFrame >& rxFrame,
64 : css::uno::Reference< css::frame::XDispatch > rxStatusDispatcher );
65 : ~OptimizerDialog();
66 :
67 : bool execute();
68 :
69 : sal_Int16 mnCurrentStep;
70 : sal_Int16 mnTabIndex;
71 : bool mbIsReadonly;
72 :
73 : private :
74 : css::uno::Reference< css::frame::XFrame > mxFrame;
75 :
76 : css::uno::Reference< css::uno::XInterface > mxRoadmapControl;
77 : css::uno::Reference< css::uno::XInterface > mxRoadmapControlModel;
78 :
79 : css::uno::Reference< css::awt::XItemListener > mxItemListener;
80 : css::uno::Reference< css::awt::XActionListener > mxActionListener;
81 : css::uno::Reference< css::awt::XActionListener > mxActionListenerListBox0Pg0;
82 : css::uno::Reference< css::awt::XTextListener > mxTextListenerFormattedField0Pg1;
83 : css::uno::Reference< css::awt::XTextListener > mxTextListenerComboBox0Pg1;
84 : css::uno::Reference< css::awt::XSpinListener > mxSpinListenerFormattedField0Pg1;
85 : css::uno::Reference< css::frame::XDispatch > mxStatusDispatcher;
86 :
87 : std::vector< std::vector< OUString > > maControlPages;
88 :
89 : void InitDialog();
90 : void InitRoadmap();
91 : void InitNavigationBar();
92 : void InitPage0();
93 : void InitPage1();
94 : void InitPage2();
95 : void InitPage3();
96 : void InitPage4();
97 : void UpdateControlStatesPage0();
98 : void UpdateControlStatesPage1();
99 : void UpdateControlStatesPage2();
100 : void UpdateControlStatesPage3();
101 : void UpdateControlStatesPage4();
102 :
103 : void ActivatePage( sal_Int16 nStep );
104 : void DeactivatePage( sal_Int16 nStep );
105 : void InsertRoadmapItem( const sal_Int32 nIndex, const bool bEnabled, const OUString& rLabel, const sal_Int32 nItemID );
106 :
107 : public :
108 :
109 : OptimizationStats maStats;
110 :
111 : void UpdateStatus( const css::uno::Sequence< css::beans::PropertyValue >& rStatus );
112 :
113 : // the ConfigurationAccess is updated to actual control settings
114 : void UpdateConfiguration();
115 :
116 : void EnablePage( sal_Int16 nStep );
117 : void DisablePage( sal_Int16 nStep );
118 :
119 : void SwitchPage( sal_Int16 nNewStep );
120 : void UpdateControlStates( sal_Int16 nStep = -1 );
121 :
122 : OUString GetSelectedString( OUString const & token );
123 0 : css::uno::Reference< css::frame::XDispatch >& GetStatusDispatcher() { return mxStatusDispatcher; };
124 0 : css::uno::Reference< css::frame::XFrame>& GetFrame() { return mxFrame; };
125 0 : const css::uno::Reference< css::uno::XComponentContext >& GetComponentContext() { return UnoDialog::mxContext; };
126 : };
127 :
128 :
129 :
130 0 : class ItemListener : public ::cppu::WeakImplHelper1< css::awt::XItemListener >
131 : {
132 : public:
133 0 : ItemListener( OptimizerDialog& rOptimizerDialog ) : mrOptimizerDialog( rOptimizerDialog ){};
134 :
135 : virtual void SAL_CALL itemStateChanged( const css::awt::ItemEvent& Event ) throw ( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
136 : virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) throw ( css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
137 : private:
138 :
139 : OptimizerDialog& mrOptimizerDialog;
140 : };
141 :
142 :
143 :
144 0 : class ActionListener : public ::cppu::WeakImplHelper1< css::awt::XActionListener >
145 : {
146 : public:
147 0 : ActionListener( OptimizerDialog& rOptimizerDialog ) : mrOptimizerDialog( rOptimizerDialog ){};
148 :
149 : virtual void SAL_CALL actionPerformed( const css::awt::ActionEvent& Event ) throw ( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
150 : virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) throw ( css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
151 : private:
152 :
153 : OptimizerDialog& mrOptimizerDialog;
154 : };
155 :
156 :
157 :
158 0 : class ActionListenerListBox0Pg0 : public ::cppu::WeakImplHelper1< css::awt::XActionListener >
159 : {
160 : public:
161 0 : ActionListenerListBox0Pg0( OptimizerDialog& rOptimizerDialog ) : mrOptimizerDialog( rOptimizerDialog ){};
162 :
163 : virtual void SAL_CALL actionPerformed( const css::awt::ActionEvent& Event ) throw ( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
164 : virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) throw ( css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
165 : private:
166 :
167 : OptimizerDialog& mrOptimizerDialog;
168 : };
169 :
170 :
171 :
172 0 : class TextListenerFormattedField0Pg1 : public ::cppu::WeakImplHelper1< css::awt::XTextListener >
173 : {
174 : public:
175 0 : TextListenerFormattedField0Pg1( OptimizerDialog& rOptimizerDialog ) : mrOptimizerDialog( rOptimizerDialog ){};
176 :
177 : virtual void SAL_CALL textChanged( const css::awt::TextEvent& Event ) throw ( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
178 : virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) throw ( css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
179 : private:
180 :
181 : OptimizerDialog& mrOptimizerDialog;
182 : };
183 :
184 :
185 :
186 0 : class TextListenerComboBox0Pg1 : public ::cppu::WeakImplHelper1< css::awt::XTextListener >
187 : {
188 : public:
189 0 : TextListenerComboBox0Pg1( OptimizerDialog& rOptimizerDialog ) : mrOptimizerDialog( rOptimizerDialog ){};
190 :
191 : virtual void SAL_CALL textChanged( const css::awt::TextEvent& Event ) throw ( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
192 : virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) throw ( css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
193 : private:
194 :
195 : OptimizerDialog& mrOptimizerDialog;
196 : };
197 :
198 :
199 :
200 0 : class SpinListenerFormattedField0Pg1 : public ::cppu::WeakImplHelper1< css::awt::XSpinListener >
201 : {
202 : public:
203 0 : SpinListenerFormattedField0Pg1( OptimizerDialog& rOptimizerDialog ) : mrOptimizerDialog( rOptimizerDialog ){};
204 :
205 : virtual void SAL_CALL up( const css::awt::SpinEvent& Event ) throw ( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
206 : virtual void SAL_CALL down( const css::awt::SpinEvent& Event ) throw ( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
207 : virtual void SAL_CALL first( const css::awt::SpinEvent& Event ) throw ( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
208 : virtual void SAL_CALL last( const css::awt::SpinEvent& Event ) throw ( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
209 : virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) throw ( css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
210 : private:
211 :
212 : OptimizerDialog& mrOptimizerDialog;
213 : };
214 :
215 : #endif // INCLUDED_SDEXT_SOURCE_MINIMIZER_OPTIMIZERDIALOG_HXX
216 :
217 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|