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 0 : class ConditionField
51 : {
52 : VclPtr<Condition> m_pParent;
53 : VclPtr<Edit> m_pSubEdit;
54 : VclPtr<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 : VclPtr<FixedText> m_pHeader;
81 : VclPtr<ListBox> m_pConditionType;
82 : VclPtr<ListBox> m_pOperationList;
83 : ConditionField* m_pCondLHS;
84 : VclPtr<FixedText> m_pOperandGlue;
85 : ConditionField* m_pCondRHS;
86 : VclPtr<ToolBox> m_pActions;
87 : VclPtr<SvxFontPrevWindow> m_pPreview;
88 : VclPtr<PushButton> m_pMoveUp;
89 : VclPtr<PushButton> m_pMoveDown;
90 : VclPtr<PushButton> m_pAddCondition;
91 : VclPtr<PushButton> m_pRemoveCondition;
92 : VclPtr<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_TYPED( OnFormatAction, ToolBox*, void );
104 : DECL_LINK_TYPED( DropdownClick, ToolBox*, void );
105 : DECL_LINK( OnConditionAction, Button* );
106 :
107 : public:
108 : Condition( vcl::Window* _pParent, IConditionalFormatAction& _rAction, ::rptui::OReportController& _rController );
109 : virtual ~Condition();
110 : virtual void dispose() SAL_OVERRIDE;
111 :
112 : /** will be called when the id of the image list needs to change.
113 : @param _eBitmapSet
114 : <svtools/imgdef.hxx>
115 : */
116 : virtual void setImageList(sal_Int16 _eBitmapSet) SAL_OVERRIDE;
117 :
118 : /** will be called when the controls need to be resized.
119 : */
120 : virtual void resizeControls(const Size& _rDiff) SAL_OVERRIDE;
121 :
122 : /** sets the props at the control
123 : @param _xCondition the source
124 : */
125 : void setCondition(const com::sun::star::uno::Reference< com::sun::star::report::XFormatCondition >& _xCondition);
126 :
127 : /** fills from the control
128 : _xCondition the destination
129 : */
130 : void fillFormatCondition(const com::sun::star::uno::Reference< com::sun::star::report::XFormatCondition >& _xCondition);
131 :
132 : /** updates the toolbar
133 : _xCondition the destination
134 : */
135 : void updateToolbar(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportControlFormat >& _xCondition);
136 :
137 : /// tells the condition its new index within the dialog's condition array
138 : void setConditionIndex( size_t _nCondIndex, size_t _nCondCount );
139 :
140 : /// returns the condition's index within the dialog's condition array
141 0 : size_t getConditionIndex() const { return m_nCondIndex; }
142 :
143 : /** determines whether the condition is actually empty
144 : */
145 : bool isEmpty() const;
146 :
147 : /** forward to the parent class
148 : */
149 : void ApplyCommand(sal_uInt16 _nCommandId, const ::Color& _aColor );
150 :
151 0 : inline ::rptui::OReportController& getController() const { return m_rController; }
152 :
153 : sal_uInt16 mapToolbarItemToSlotId(sal_uInt16 nItemId) const;
154 :
155 : protected:
156 : virtual void GetFocus() SAL_OVERRIDE;
157 :
158 : private:
159 : void impl_layoutOperands();
160 :
161 : inline ConditionType
162 : impl_getCurrentConditionType() const;
163 :
164 : inline ComparisonOperation
165 : impl_getCurrentComparisonOperation() const;
166 :
167 : void impl_setCondition( const OUString& _rConditionFormula );
168 :
169 : private:
170 : DECL_LINK( OnTypeSelected, ListBox* );
171 : DECL_LINK( OnOperationSelected, ListBox* );
172 : };
173 :
174 :
175 0 : inline ConditionType Condition::impl_getCurrentConditionType() const
176 : {
177 0 : return sal::static_int_cast< ConditionType >( m_pConditionType->GetSelectEntryPos() );
178 : }
179 :
180 :
181 0 : inline ComparisonOperation Condition::impl_getCurrentComparisonOperation() const
182 : {
183 0 : return sal::static_int_cast< ComparisonOperation >( m_pOperationList->GetSelectEntryPos() );
184 : }
185 :
186 :
187 : } // namespace rptui
188 :
189 : #endif // INCLUDED_REPORTDESIGN_SOURCE_UI_DLG_CONDITION_HXX
190 :
191 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|