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: Condition.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 RPTUI_CONDITION_HXX
32 #define RPTUI_CONDITION_HXX
34 #include "conditionalexpression.hxx"
36 #include <com/sun/star/report/XFormatCondition.hpp>
38 #include <dbaccess/ToolBoxHelper.hxx>
40 #include <svx/fntctrl.hxx>
42 #include <svtools/valueset.hxx>
44 #include <vcl/fixed.hxx>
45 #include <vcl/lstbox.hxx>
46 #include <vcl/field.hxx>
47 #include <vcl/button.hxx>
48 #include <vcl/toolbox.hxx>
52 namespace svx
{ class ToolboxButtonColorUpdater
; }
56 class ConditionalFormattingDialog
;
58 class OReportController
;
59 class IConditionalFormatAction
;
62 class ConditionField
: public Edit
66 PushButton m_aFormula
;
68 DECL_LINK( OnFormula
, Button
* );
70 ConditionField( Condition
* pParent
, const ResId
& rResId
);
71 virtual ~ConditionField();
72 virtual void Resize();
75 //========================================================================
77 //========================================================================
78 class Condition
:public Control
79 ,public dbaui::OToolBoxHelper
81 ::rptui::OReportController
& m_rController
;
82 IConditionalFormatAction
& m_rAction
;
84 ListBox m_aConditionType
;
85 ListBox m_aOperationList
;
86 ConditionField m_aCondLHS
;
87 FixedText m_aOperandGlue
;
88 ConditionField m_aCondRHS
;
90 SvxFontPrevWindow m_aPreview
;
91 ImageButton m_aMoveUp
;
92 ImageButton m_aMoveDown
;
93 PushButton m_aAddCondition
;
94 PushButton m_aRemoveCondition
;
95 OColorPopup
* m_pColorFloat
;
97 ::svx::ToolboxButtonColorUpdater
* m_pBtnUpdaterFontColor
; // updates the color below the toolbar icon
98 ::svx::ToolboxButtonColorUpdater
* m_pBtnUpdaterBackgroundColor
;
102 long m_nLastKnownWindowWidth
;
103 bool m_bInDestruction
;
105 ConditionalExpressions m_aConditionalExpressions
;
107 DECL_LINK( OnFormatAction
, ToolBox
* );
108 DECL_LINK( DropdownClick
, ToolBox
* );
109 DECL_LINK( OnConditionAction
, Button
* );
112 Condition( Window
* _pParent
, IConditionalFormatAction
& _rAction
, ::rptui::OReportController
& _rController
);
113 virtual ~Condition();
115 /** will be called when the id of the image list is needed.
119 <TRUE/> when in high contrast mode.
121 virtual ImageList
getImageList(sal_Int16 _eBitmapSet
,sal_Bool _bHiContast
) const;
123 /** will be called when the controls need to be resized.
125 virtual void resizeControls(const Size
& _rDiff
);
127 /** sets the props at the control
128 @param _xCondition the source
130 void setCondition(const com::sun::star::uno::Reference
< com::sun::star::report::XFormatCondition
>& _xCondition
);
132 /** fills from the control
133 _xCondition the destination
135 void fillFormatCondition(const com::sun::star::uno::Reference
< com::sun::star::report::XFormatCondition
>& _xCondition
);
137 /** updates the toolbar
138 _xCondition the destination
140 void updateToolbar(const ::com::sun::star::uno::Reference
< ::com::sun::star::report::XReportControlFormat
>& _xCondition
);
142 /// tells the condition its new index within the dialog's condition array
143 void setConditionIndex( size_t _nCondIndex
, size_t _nCondCount
);
145 /// returns the condition's index within the dialog's condition array
146 size_t getConditionIndex() const { return m_nCondIndex
; }
148 /** determines whether the condition is actually empty
150 bool isEmpty() const;
152 /** forward to the parent class
154 void ApplyCommand(USHORT _nCommandId
, const ::Color
& _aColor
);
156 inline ::rptui::OReportController
& getController() const { return m_rController
; }
159 virtual void StateChanged( StateChangedType nStateChange
);
160 virtual void DataChanged( const DataChangedEvent
& rDCEvt
);
161 virtual void Paint( const Rectangle
& rRect
);
162 virtual void Resize();
163 virtual void GetFocus();
166 void impl_layoutAll();
167 void impl_layoutOperands();
169 /// determines the rectangle to be occupied by the toolbar, including the border drawn around it
170 Rectangle
impl_getToolBarBorderRect() const;
173 impl_getCurrentConditionType() const;
175 inline ComparisonOperation
176 impl_getCurrentComparisonOperation() const;
178 void impl_setCondition( const ::rtl::OUString
& _rConditionFormula
);
181 DECL_LINK( OnTypeSelected
, ListBox
* );
182 DECL_LINK( OnOperationSelected
, ListBox
* );
185 // -------------------------------------------------------------------------
186 inline ConditionType
Condition::impl_getCurrentConditionType() const
188 return sal::static_int_cast
< ConditionType
>( m_aConditionType
.GetSelectEntryPos() );
191 // -------------------------------------------------------------------------
192 inline ComparisonOperation
Condition::impl_getCurrentComparisonOperation() const
194 return sal::static_int_cast
< ComparisonOperation
>( m_aOperationList
.GetSelectEntryPos() );
197 // =============================================================================
199 // =============================================================================
200 #endif // RPTUI_CONDITION_HXX