1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: optimizerdialog.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef OPTIMIZERDIALOG_HXX
32 #define OPTIMIZERDIALOG_HXX
33 #ifndef _OPTIMIZERDIALOG_HRC
34 #include "optimizerdialog.hrc"
37 #include "unodialog.hxx"
38 #include "pppoptimizertoken.hxx"
39 #include "optimizationstats.hxx"
40 #include "configurationaccess.hxx"
41 #include <com/sun/star/lang/XServiceInfo.hpp>
42 #include <com/sun/star/awt/XItemListener.hpp>
43 #include <com/sun/star/awt/XSpinField.hpp>
44 #include <com/sun/star/awt/XSpinListener.hpp>
45 #include <com/sun/star/beans/XPropertySet.hpp>
46 #include <com/sun/star/uno/Sequence.h>
47 #include <com/sun/star/text/XTextRange.hpp>
48 #include <com/sun/star/drawing/XShapes.hpp>
49 #include <com/sun/star/container/XIndexAccess.hpp>
50 #include <com/sun/star/frame/XController.hpp>
51 #include <com/sun/star/view/XSelectionSupplier.hpp>
52 #include <com/sun/star/uno/XComponentContext.hpp>
53 #include <com/sun/star/awt/XItemEventBroadcaster.hpp>
54 #ifndef _COM_SUN_STAR_UTIL_XCloseListener_HPP_
55 #include <com/sun/star/util/XCloseListener.hpp>
57 #include <com/sun/star/frame/XStorable.hpp>
58 #include <com/sun/star/frame/XDispatch.hpp>
59 #include <com/sun/star/frame/XDesktop.hpp>
60 #include <com/sun/star/awt/PushButtonType.hpp>
63 #define OD_DIALOG_WIDTH 330
64 #define DIALOG_HEIGHT 210
65 #define BUTTON_WIDTH 50
66 #define BUTTON_HEIGHT 14
67 #define BUTTON_POS_Y DIALOG_HEIGHT - BUTTON_HEIGHT - 6
71 #define PAGE_WIDTH OD_DIALOG_WIDTH - PAGE_POS_X
73 // -------------------
74 // - OPTIMIZERDIALOG -
75 // -------------------
76 class OptimizerDialog
: public UnoDialog
, public ConfigurationAccess
80 OptimizerDialog( const com::sun::star::uno::Reference
< com::sun::star::uno::XComponentContext
>& rxMSF
, com::sun::star::uno::Reference
< com::sun::star::frame::XFrame
>& rxFrame
,
81 com::sun::star::uno::Reference
< com::sun::star::frame::XDispatch
> rxStatusDispatcher
);
86 sal_Int16 mnCurrentStep
;
88 sal_Bool mbIsReadonly
;
91 com::sun::star::uno::Reference
< com::sun::star::uno::XComponentContext
>mxMSF
;
92 com::sun::star::uno::Reference
< com::sun::star::frame::XFrame
> mxFrame
;
94 com::sun::star::uno::Reference
< com::sun::star::uno::XInterface
> mxRoadmapControl
;
95 com::sun::star::uno::Reference
< com::sun::star::uno::XInterface
> mxRoadmapControlModel
;
97 com::sun::star::uno::Reference
< com::sun::star::awt::XItemListener
> mxItemListener
;
98 com::sun::star::uno::Reference
< com::sun::star::awt::XActionListener
> mxActionListener
;
99 com::sun::star::uno::Reference
< com::sun::star::awt::XActionListener
> mxActionListenerListBox0Pg0
;
100 com::sun::star::uno::Reference
< com::sun::star::awt::XTextListener
> mxTextListenerFormattedField0Pg1
;
101 com::sun::star::uno::Reference
< com::sun::star::awt::XTextListener
> mxTextListenerComboBox0Pg1
;
102 com::sun::star::uno::Reference
< com::sun::star::awt::XSpinListener
> mxSpinListenerFormattedField0Pg1
;
103 com::sun::star::uno::Reference
< com::sun::star::frame::XDispatch
> mxStatusDispatcher
;
105 std::vector
< std::vector
< rtl::OUString
> > maControlPages
;
109 void InitNavigationBar();
115 void UpdateControlStatesPage0();
116 void UpdateControlStatesPage1();
117 void UpdateControlStatesPage2();
118 void UpdateControlStatesPage3();
119 void UpdateControlStatesPage4();
121 void ActivatePage( sal_Int16 nStep
);
122 void DeactivatePage( sal_Int16 nStep
);
123 void InsertRoadmapItem( const sal_Int32 nIndex
, const sal_Bool bEnabled
, const rtl::OUString
& rLabel
, const sal_Int32 nItemID
);
127 OptimizationStats maStats
;
129 void UpdateStatus( const com::sun::star::uno::Sequence
< com::sun::star::beans::PropertyValue
>& rStatus
);
131 // the ConfigurationAccess is updated to actual control settings
132 void UpdateConfiguration();
134 void EnablePage( sal_Int16 nStep
);
135 void DisablePage( sal_Int16 nStep
);
137 void SwitchPage( sal_Int16 nNewStep
);
138 void UpdateControlStates( sal_Int16 nStep
= -1 );
140 rtl::OUString
GetSelectedString( PPPOptimizerTokenEnum eListBox
);
141 com::sun::star::uno::Reference
< com::sun::star::frame::XDispatch
>& GetStatusDispatcher() { return mxStatusDispatcher
; };
142 com::sun::star::uno::Reference
< com::sun::star::frame::XFrame
>& GetFrame() { return mxFrame
; };
143 const com::sun::star::uno::Reference
< com::sun::star::uno::XComponentContext
>& GetComponentContext() { return mxMSF
; };
146 // -----------------------------------------------------------------------------
148 class ItemListener
: public ::cppu::WeakImplHelper1
< com::sun::star::awt::XItemListener
>
151 ItemListener( OptimizerDialog
& rOptimizerDialog
) : mrOptimizerDialog( rOptimizerDialog
){};
153 virtual void SAL_CALL
itemStateChanged( const ::com::sun::star::awt::ItemEvent
& Event
) throw ( com::sun::star::uno::RuntimeException
);
154 virtual void SAL_CALL
disposing( const ::com::sun::star::lang::EventObject
& Source
) throw ( com::sun::star::uno::RuntimeException
);
157 OptimizerDialog
& mrOptimizerDialog
;
160 // -----------------------------------------------------------------------------
162 class ActionListener
: public ::cppu::WeakImplHelper1
< com::sun::star::awt::XActionListener
>
165 ActionListener( OptimizerDialog
& rOptimizerDialog
) : mrOptimizerDialog( rOptimizerDialog
){};
167 virtual void SAL_CALL
actionPerformed( const ::com::sun::star::awt::ActionEvent
& Event
) throw ( com::sun::star::uno::RuntimeException
);
168 virtual void SAL_CALL
disposing( const ::com::sun::star::lang::EventObject
& Source
) throw ( com::sun::star::uno::RuntimeException
);
171 OptimizerDialog
& mrOptimizerDialog
;
174 // -----------------------------------------------------------------------------
176 class ActionListenerListBox0Pg0
: public ::cppu::WeakImplHelper1
< com::sun::star::awt::XActionListener
>
179 ActionListenerListBox0Pg0( OptimizerDialog
& rOptimizerDialog
) : mrOptimizerDialog( rOptimizerDialog
){};
181 virtual void SAL_CALL
actionPerformed( const ::com::sun::star::awt::ActionEvent
& Event
) throw ( com::sun::star::uno::RuntimeException
);
182 virtual void SAL_CALL
disposing( const ::com::sun::star::lang::EventObject
& Source
) throw ( com::sun::star::uno::RuntimeException
);
185 OptimizerDialog
& mrOptimizerDialog
;
188 // -----------------------------------------------------------------------------
190 class TextListenerFormattedField0Pg1
: public ::cppu::WeakImplHelper1
< com::sun::star::awt::XTextListener
>
193 TextListenerFormattedField0Pg1( OptimizerDialog
& rOptimizerDialog
) : mrOptimizerDialog( rOptimizerDialog
){};
195 virtual void SAL_CALL
textChanged( const ::com::sun::star::awt::TextEvent
& Event
) throw ( com::sun::star::uno::RuntimeException
);
196 virtual void SAL_CALL
disposing( const ::com::sun::star::lang::EventObject
& Source
) throw ( com::sun::star::uno::RuntimeException
);
199 OptimizerDialog
& mrOptimizerDialog
;
202 // -----------------------------------------------------------------------------
204 class TextListenerComboBox0Pg1
: public ::cppu::WeakImplHelper1
< com::sun::star::awt::XTextListener
>
207 TextListenerComboBox0Pg1( OptimizerDialog
& rOptimizerDialog
) : mrOptimizerDialog( rOptimizerDialog
){};
209 virtual void SAL_CALL
textChanged( const ::com::sun::star::awt::TextEvent
& Event
) throw ( com::sun::star::uno::RuntimeException
);
210 virtual void SAL_CALL
disposing( const ::com::sun::star::lang::EventObject
& Source
) throw ( com::sun::star::uno::RuntimeException
);
213 OptimizerDialog
& mrOptimizerDialog
;
216 // -----------------------------------------------------------------------------
218 class SpinListenerFormattedField0Pg1
: public ::cppu::WeakImplHelper1
< com::sun::star::awt::XSpinListener
>
221 SpinListenerFormattedField0Pg1( OptimizerDialog
& rOptimizerDialog
) : mrOptimizerDialog( rOptimizerDialog
){};
223 virtual void SAL_CALL
up( const ::com::sun::star::awt::SpinEvent
& Event
) throw ( com::sun::star::uno::RuntimeException
);
224 virtual void SAL_CALL
down( const ::com::sun::star::awt::SpinEvent
& Event
) throw ( com::sun::star::uno::RuntimeException
);
225 virtual void SAL_CALL
first( const ::com::sun::star::awt::SpinEvent
& Event
) throw ( com::sun::star::uno::RuntimeException
);
226 virtual void SAL_CALL
last( const ::com::sun::star::awt::SpinEvent
& Event
) throw ( com::sun::star::uno::RuntimeException
);
227 virtual void SAL_CALL
disposing( const ::com::sun::star::lang::EventObject
& Source
) throw ( com::sun::star::uno::RuntimeException
);
230 OptimizerDialog
& mrOptimizerDialog
;
233 // -----------------------------------------------------------------------------
235 class HelpCloseListener
: public ::cppu::WeakImplHelper1
< com::sun::star::util::XCloseListener
>
238 HelpCloseListener( com::sun::star::uno::Reference
< com::sun::star::frame::XFrame
>& rXFrame
) : mrXFrame( rXFrame
){};
240 virtual void SAL_CALL
addCloseListener(const com::sun::star::uno::Reference
< com::sun::star::util::XCloseListener
>& ) throw( com::sun::star::uno::RuntimeException
);
241 virtual void SAL_CALL
removeCloseListener( const com::sun::star::uno::Reference
< com::sun::star::util::XCloseListener
>& xListener
) throw( com::sun::star::uno::RuntimeException
);
242 virtual void SAL_CALL
notifyClosing( const com::sun::star::lang::EventObject
& aEvent
) throw (com::sun::star::uno::RuntimeException
) ;
243 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
) ;
244 virtual void SAL_CALL
disposing( const com::sun::star::lang::EventObject
& aEvent
) throw (com::sun::star::uno::RuntimeException
) ;
248 com::sun::star::uno::Reference
< com::sun::star::frame::XFrame
>& mrXFrame
;
252 #endif // OPTIMIZERDIALOG_HXX