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_REPORTDESIGN_SOURCE_UI_DLG_CONDITION_HXX
21 : #define INCLUDED_REPORTDESIGN_SOURCE_UI_DLG_CONDITION_HXX
22 :
23 : #include "conditionalexpression.hxx"
24 :
25 : #include <com/sun/star/report/XFormatCondition.hpp>
26 :
27 : #include <dbaccess/ToolBoxHelper.hxx>
28 :
29 : #include <svx/fntctrl.hxx>
30 :
31 : #include <vcl/fixed.hxx>
32 : #include <vcl/lstbox.hxx>
33 : #include <vcl/field.hxx>
34 : #include <vcl/button.hxx>
35 : #include <vcl/toolbox.hxx>
36 : #include <vcl/builder.hxx>
37 : #include <vcl/layout.hxx>
38 :
39 : #include <memory>
40 :
41 : namespace svx { class ToolboxButtonColorUpdater; }
42 :
43 : namespace rptui
44 : {
45 : class OColorPopup;
46 : class OReportController;
47 : class IConditionalFormatAction;
48 : class Condition;
49 :
50 : class ConditionField
51 : {
52 : Condition* m_pParent;
53 : Edit* m_pSubEdit;
54 : PushButton* m_pFormula;
55 :
56 : DECL_LINK( OnFormula, Button* );
57 : public:
58 : ConditionField(Condition* pParent, Edit* pSubEdit, PushButton *pFormula);
59 0 : void GrabFocus() { m_pSubEdit->GrabFocus(); }
60 0 : void Show(bool bShow) { m_pSubEdit->Show(bShow); m_pFormula->Show(bShow); }
61 0 : void SetText(const OUString& rText) { m_pSubEdit->SetText(rText); }
62 0 : OUString GetText() const { return m_pSubEdit->GetText(); }
63 : };
64 :
65 : //= Condition
66 :
67 : class Condition :public VclHBox
68 : ,public dbaui::OToolBoxHelper
69 : ,public VclBuilderContainer
70 : {
71 : sal_uInt16 m_nBoldId;
72 : sal_uInt16 m_nItalicId;
73 : sal_uInt16 m_nUnderLineId;
74 : sal_uInt16 m_nBackgroundColorId;
75 : sal_uInt16 m_nFontColorId;
76 : sal_uInt16 m_nFontDialogId;
77 :
78 : ::rptui::OReportController& m_rController;
79 : IConditionalFormatAction& m_rAction;
80 : FixedText* m_pHeader;
81 : ListBox* m_pConditionType;
82 : ListBox* m_pOperationList;
83 : ConditionField* m_pCondLHS;
84 : FixedText* m_pOperandGlue;
85 : ConditionField* m_pCondRHS;
86 : ToolBox* m_pActions;
87 : SvxFontPrevWindow* m_pPreview;
88 : PushButton* m_pMoveUp;
89 : PushButton* m_pMoveDown;
90 : PushButton* m_pAddCondition;
91 : PushButton* m_pRemoveCondition;
92 : OColorPopup* m_pColorFloat;
93 :
94 : ::svx::ToolboxButtonColorUpdater* m_pBtnUpdaterFontColor; // updates the color below the toolbar icon
95 : ::svx::ToolboxButtonColorUpdater* m_pBtnUpdaterBackgroundColor;
96 :
97 :
98 : size_t m_nCondIndex;
99 : bool m_bInDestruction;
100 :
101 : ConditionalExpressions m_aConditionalExpressions;
102 :
103 : DECL_LINK( OnFormatAction, ToolBox* );
104 : DECL_LINK( DropdownClick, ToolBox* );
105 : DECL_LINK( OnConditionAction, Button* );
106 :
107 : public:
108 : Condition( vcl::Window* _pParent, IConditionalFormatAction& _rAction, ::rptui::OReportController& _rController );
109 : virtual ~Condition();
110 :
111 : /** will be called when the id of the image list needs to change.
112 : @param _eBitmapSet
113 : <svtools/imgdef.hxx>
114 : */
115 : virtual void setImageList(sal_Int16 _eBitmapSet) SAL_OVERRIDE;
116 :
117 : /** will be called when the controls need to be resized.
118 : */
119 : virtual void resizeControls(const Size& _rDiff) SAL_OVERRIDE;
120 :
121 : /** sets the props at the control
122 : @param _xCondition the source
123 : */
124 : void setCondition(const com::sun::star::uno::Reference< com::sun::star::report::XFormatCondition >& _xCondition);
125 :
126 : /** fills from the control
127 : _xCondition the destination
128 : */
129 : void fillFormatCondition(const com::sun::star::uno::Reference< com::sun::star::report::XFormatCondition >& _xCondition);
130 :
131 : /** updates the toolbar
132 : _xCondition the destination
133 : */
134 : void updateToolbar(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportControlFormat >& _xCondition);
135 :
136 : /// tells the condition its new index within the dialog's condition array
137 : void setConditionIndex( size_t _nCondIndex, size_t _nCondCount );
138 :
139 : /// returns the condition's index within the dialog's condition array
140 0 : size_t getConditionIndex() const { return m_nCondIndex; }
141 :
142 : /** determines whether the condition is actually empty
143 : */
144 : bool isEmpty() const;
145 :
146 : /** forward to the parent class
147 : */
148 : void ApplyCommand(sal_uInt16 _nCommandId, const ::Color& _aColor );
149 :
150 0 : inline ::rptui::OReportController& getController() const { return m_rController; }
151 :
152 : sal_uInt16 mapToolbarItemToSlotId(sal_uInt16 nItemId) const;
153 :
154 : protected:
155 : virtual void GetFocus() SAL_OVERRIDE;
156 :
157 : private:
158 : void impl_layoutOperands();
159 :
160 : inline ConditionType
161 : impl_getCurrentConditionType() const;
162 :
163 : inline ComparisonOperation
164 : impl_getCurrentComparisonOperation() const;
165 :
166 : void impl_setCondition( const OUString& _rConditionFormula );
167 :
168 : private:
169 : DECL_LINK( OnTypeSelected, ListBox* );
170 : DECL_LINK( OnOperationSelected, ListBox* );
171 : };
172 :
173 :
174 0 : inline ConditionType Condition::impl_getCurrentConditionType() const
175 : {
176 0 : return sal::static_int_cast< ConditionType >( m_pConditionType->GetSelectEntryPos() );
177 : }
178 :
179 :
180 0 : inline ComparisonOperation Condition::impl_getCurrentComparisonOperation() const
181 : {
182 0 : return sal::static_int_cast< ComparisonOperation >( m_pOperationList->GetSelectEntryPos() );
183 : }
184 :
185 :
186 : } // namespace rptui
187 :
188 : #endif // INCLUDED_REPORTDESIGN_SOURCE_UI_DLG_CONDITION_HXX
189 :
190 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|