Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef RPTUI_CONDITION_HXX
30 : : #define RPTUI_CONDITION_HXX
31 : :
32 : : #include "conditionalexpression.hxx"
33 : :
34 : : #include <com/sun/star/report/XFormatCondition.hpp>
35 : :
36 : : #include <dbaccess/ToolBoxHelper.hxx>
37 : :
38 : : #include <svx/fntctrl.hxx>
39 : :
40 : : #include <vcl/fixed.hxx>
41 : : #include <vcl/lstbox.hxx>
42 : : #include <vcl/field.hxx>
43 : : #include <vcl/button.hxx>
44 : : #include <vcl/toolbox.hxx>
45 : :
46 : : #include <memory>
47 : :
48 : : namespace svx { class ToolboxButtonColorUpdater; }
49 : :
50 : : namespace rptui
51 : : {
52 : : class OColorPopup;
53 : : class OReportController;
54 : : class IConditionalFormatAction;
55 : : class Condition;
56 : :
57 : : class ConditionField : public Edit
58 : : {
59 : : Condition* m_pParent;
60 : : Edit* m_pSubEdit;
61 : : PushButton m_aFormula;
62 : :
63 : : DECL_LINK( OnFormula, Button* );
64 : : public:
65 : : ConditionField( Condition* pParent, const ResId& rResId );
66 : : virtual ~ConditionField();
67 : : virtual void Resize();
68 : : };
69 : :
70 : : //========================================================================
71 : : //= Condition
72 : : //========================================================================
73 : : class Condition :public Control
74 : : ,public dbaui::OToolBoxHelper
75 : : {
76 : : ::rptui::OReportController& m_rController;
77 : : IConditionalFormatAction& m_rAction;
78 : : FixedLine m_aHeader;
79 : : ListBox m_aConditionType;
80 : : ListBox m_aOperationList;
81 : : ConditionField m_aCondLHS;
82 : : FixedText m_aOperandGlue;
83 : : ConditionField m_aCondRHS;
84 : : ToolBox m_aActions;
85 : : SvxFontPrevWindow m_aPreview;
86 : : ImageButton m_aMoveUp;
87 : : ImageButton m_aMoveDown;
88 : : PushButton m_aAddCondition;
89 : : PushButton m_aRemoveCondition;
90 : : OColorPopup* m_pColorFloat;
91 : :
92 : : ::svx::ToolboxButtonColorUpdater* m_pBtnUpdaterFontColor; // updates the color below the toolbar icon
93 : : ::svx::ToolboxButtonColorUpdater* m_pBtnUpdaterBackgroundColor;
94 : :
95 : :
96 : : size_t m_nCondIndex;
97 : : long m_nLastKnownWindowWidth;
98 : : bool m_bInDestruction;
99 : :
100 : : ConditionalExpressions m_aConditionalExpressions;
101 : :
102 : : DECL_LINK( OnFormatAction, ToolBox* );
103 : : DECL_LINK( DropdownClick, ToolBox* );
104 : : DECL_LINK( OnConditionAction, Button* );
105 : :
106 : : public:
107 : : Condition( Window* _pParent, IConditionalFormatAction& _rAction, ::rptui::OReportController& _rController );
108 : : virtual ~Condition();
109 : :
110 : : /** will be called when the id of the image list is needed.
111 : : @param _eBitmapSet
112 : : <svtools/imgdef.hxx>
113 : : */
114 : : virtual ImageList getImageList(sal_Int16 _eBitmapSet) const;
115 : :
116 : : /** will be called when the controls need to be resized.
117 : : */
118 : : virtual void resizeControls(const Size& _rDiff);
119 : :
120 : : /** sets the props at the control
121 : : @param _xCondition the source
122 : : */
123 : : void setCondition(const com::sun::star::uno::Reference< com::sun::star::report::XFormatCondition >& _xCondition);
124 : :
125 : : /** fills from the control
126 : : _xCondition the destination
127 : : */
128 : : void fillFormatCondition(const com::sun::star::uno::Reference< com::sun::star::report::XFormatCondition >& _xCondition);
129 : :
130 : : /** updates the toolbar
131 : : _xCondition the destination
132 : : */
133 : : void updateToolbar(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportControlFormat >& _xCondition);
134 : :
135 : : /// tells the condition its new index within the dialog's condition array
136 : : void setConditionIndex( size_t _nCondIndex, size_t _nCondCount );
137 : :
138 : : /// returns the condition's index within the dialog's condition array
139 : 0 : size_t getConditionIndex() const { return m_nCondIndex; }
140 : :
141 : : /** determines whether the condition is actually empty
142 : : */
143 : : bool isEmpty() const;
144 : :
145 : : /** forward to the parent class
146 : : */
147 : : void ApplyCommand(sal_uInt16 _nCommandId, const ::Color& _aColor );
148 : :
149 : 0 : inline ::rptui::OReportController& getController() const { return m_rController; }
150 : :
151 : : protected:
152 : : virtual void StateChanged( StateChangedType nStateChange );
153 : : virtual void DataChanged( const DataChangedEvent& rDCEvt );
154 : : virtual void Paint( const Rectangle& rRect );
155 : : virtual void Resize();
156 : : virtual void GetFocus();
157 : :
158 : : private:
159 : : void impl_layoutAll();
160 : : void impl_layoutOperands();
161 : :
162 : : /// determines the rectangle to be occupied by the toolbar, including the border drawn around it
163 : : Rectangle impl_getToolBarBorderRect() const;
164 : :
165 : : inline ConditionType
166 : : impl_getCurrentConditionType() const;
167 : :
168 : : inline ComparisonOperation
169 : : impl_getCurrentComparisonOperation() const;
170 : :
171 : : void impl_setCondition( const ::rtl::OUString& _rConditionFormula );
172 : :
173 : : private:
174 : : DECL_LINK( OnTypeSelected, ListBox* );
175 : : DECL_LINK( OnOperationSelected, ListBox* );
176 : : };
177 : :
178 : : // -------------------------------------------------------------------------
179 : 0 : inline ConditionType Condition::impl_getCurrentConditionType() const
180 : : {
181 : 0 : return sal::static_int_cast< ConditionType >( m_aConditionType.GetSelectEntryPos() );
182 : : }
183 : :
184 : : // -------------------------------------------------------------------------
185 : 0 : inline ComparisonOperation Condition::impl_getCurrentComparisonOperation() const
186 : : {
187 : 0 : return sal::static_int_cast< ComparisonOperation >( m_aOperationList.GetSelectEntryPos() );
188 : : }
189 : :
190 : : // =============================================================================
191 : : } // namespace rptui
192 : : // =============================================================================
193 : : #endif // RPTUI_CONDITION_HXX
194 : :
195 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|