1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SDEXT_SOURCE_MINIMIZER_OPTIMIZERDIALOG_HXX
21 #define INCLUDED_SDEXT_SOURCE_MINIMIZER_OPTIMIZERDIALOG_HXX
22 #include "optimizerdialog.hrc"
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>
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
54 #define PAGE_WIDTH OD_DIALOG_WIDTH - PAGE_POS_X
57 // - OPTIMIZERDIALOG -
59 class OptimizerDialog
: public UnoDialog
, public ConfigurationAccess
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
);
69 sal_Int16 mnCurrentStep
;
74 css::uno::Reference
< css::frame::XFrame
> mxFrame
;
76 css::uno::Reference
< css::uno::XInterface
> mxRoadmapControl
;
77 css::uno::Reference
< css::uno::XInterface
> mxRoadmapControlModel
;
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
;
87 std::vector
< std::vector
< OUString
> > maControlPages
;
91 void InitNavigationBar();
97 void UpdateControlStatesPage0();
98 void UpdateControlStatesPage1();
99 void UpdateControlStatesPage2();
100 void UpdateControlStatesPage3();
101 void UpdateControlStatesPage4();
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
);
109 OptimizationStats maStats
;
111 void UpdateStatus( const css::uno::Sequence
< css::beans::PropertyValue
>& rStatus
);
113 // the ConfigurationAccess is updated to actual control settings
114 void UpdateConfiguration();
116 void EnablePage( sal_Int16 nStep
);
117 void DisablePage( sal_Int16 nStep
);
119 void SwitchPage( sal_Int16 nNewStep
);
120 void UpdateControlStates( sal_Int16 nStep
= -1 );
122 OUString
GetSelectedString( OUString
const & token
);
123 css::uno::Reference
< css::frame::XDispatch
>& GetStatusDispatcher() { return mxStatusDispatcher
; };
124 css::uno::Reference
< css::frame::XFrame
>& GetFrame() { return mxFrame
; };
125 const css::uno::Reference
< css::uno::XComponentContext
>& GetComponentContext() { return UnoDialog::mxContext
; };
130 class ItemListener
: public ::cppu::WeakImplHelper1
< css::awt::XItemListener
>
133 ItemListener( OptimizerDialog
& rOptimizerDialog
) : mrOptimizerDialog( rOptimizerDialog
){};
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
;
139 OptimizerDialog
& mrOptimizerDialog
;
144 class ActionListener
: public ::cppu::WeakImplHelper1
< css::awt::XActionListener
>
147 ActionListener( OptimizerDialog
& rOptimizerDialog
) : mrOptimizerDialog( rOptimizerDialog
){};
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
;
153 OptimizerDialog
& mrOptimizerDialog
;
158 class ActionListenerListBox0Pg0
: public ::cppu::WeakImplHelper1
< css::awt::XActionListener
>
161 ActionListenerListBox0Pg0( OptimizerDialog
& rOptimizerDialog
) : mrOptimizerDialog( rOptimizerDialog
){};
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
;
167 OptimizerDialog
& mrOptimizerDialog
;
172 class TextListenerFormattedField0Pg1
: public ::cppu::WeakImplHelper1
< css::awt::XTextListener
>
175 TextListenerFormattedField0Pg1( OptimizerDialog
& rOptimizerDialog
) : mrOptimizerDialog( rOptimizerDialog
){};
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
;
181 OptimizerDialog
& mrOptimizerDialog
;
186 class TextListenerComboBox0Pg1
: public ::cppu::WeakImplHelper1
< css::awt::XTextListener
>
189 TextListenerComboBox0Pg1( OptimizerDialog
& rOptimizerDialog
) : mrOptimizerDialog( rOptimizerDialog
){};
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
;
195 OptimizerDialog
& mrOptimizerDialog
;
200 class SpinListenerFormattedField0Pg1
: public ::cppu::WeakImplHelper1
< css::awt::XSpinListener
>
203 SpinListenerFormattedField0Pg1( OptimizerDialog
& rOptimizerDialog
) : mrOptimizerDialog( rOptimizerDialog
){};
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
;
212 OptimizerDialog
& mrOptimizerDialog
;
215 #endif // INCLUDED_SDEXT_SOURCE_MINIMIZER_OPTIMIZERDIALOG_HXX
217 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */