1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_REPORTDESIGN_SOURCE_UI_DLG_CONDITION_HXX
21 #define INCLUDED_REPORTDESIGN_SOURCE_UI_DLG_CONDITION_HXX
23 #include <conditionalexpression.hxx>
25 #include <com/sun/star/report/XFormatCondition.hpp>
27 #include <dbaccess/ToolBoxHelper.hxx>
29 #include <svx/colorwindow.hxx>
30 #include <svx/fntctrl.hxx>
32 #include <vcl/fixed.hxx>
33 #include <vcl/lstbox.hxx>
34 #include <vcl/field.hxx>
35 #include <vcl/button.hxx>
36 #include <vcl/toolbox.hxx>
37 #include <vcl/builder.hxx>
38 #include <vcl/layout.hxx>
42 namespace svx
{ class ToolboxButtonColorUpdater
; }
47 class OReportController
;
48 class IConditionalFormatAction
;
53 VclPtr
<Condition
> m_pParent
;
54 VclPtr
<Edit
> m_pSubEdit
;
55 VclPtr
<PushButton
> m_pFormula
;
57 DECL_LINK( OnFormula
, Button
*, void );
59 ConditionField(Condition
* pParent
, Edit
* pSubEdit
, PushButton
*pFormula
);
60 void GrabFocus() { m_pSubEdit
->GrabFocus(); }
61 void Show(bool bShow
) { m_pSubEdit
->Show(bShow
); m_pFormula
->Show(bShow
); }
62 void SetText(const OUString
& rText
) { m_pSubEdit
->SetText(rText
); }
63 OUString
GetText() const { return m_pSubEdit
->GetText(); }
66 class ConditionColorWrapper
69 ConditionColorWrapper(Condition
* pControl
);
70 void SetSlotId(sal_uInt16 nSlotId
) { mnSlotId
= nSlotId
; }
71 void operator()(const OUString
& rCommand
, const NamedColor
& rColor
);
74 VclPtr
<Condition
> mxControl
;
80 class Condition
:public VclHBox
81 ,public dbaui::OToolBoxHelper
82 ,public VclBuilderContainer
85 sal_uInt16 m_nItalicId
;
86 sal_uInt16 m_nUnderLineId
;
87 sal_uInt16 m_nBackgroundColorId
;
88 sal_uInt16 m_nFontColorId
;
89 sal_uInt16 m_nFontDialogId
;
90 std::shared_ptr
<PaletteManager
> m_xPaletteManager
;
91 ColorStatus m_aColorStatus
;
92 ConditionColorWrapper m_aColorWrapper
;
94 ::rptui::OReportController
& m_rController
;
95 IConditionalFormatAction
& m_rAction
;
96 VclPtr
<FixedText
> m_pHeader
;
97 VclPtr
<ListBox
> m_pConditionType
;
98 VclPtr
<ListBox
> m_pOperationList
;
99 std::unique_ptr
<ConditionField
> m_pCondLHS
;
100 VclPtr
<FixedText
> m_pOperandGlue
;
101 std::unique_ptr
<ConditionField
> m_pCondRHS
;
102 VclPtr
<ToolBox
> m_pActions
;
103 VclPtr
<SvxFontPrevWindow
> m_pPreview
;
104 VclPtr
<PushButton
> m_pMoveUp
;
105 VclPtr
<PushButton
> m_pMoveDown
;
106 VclPtr
<PushButton
> m_pAddCondition
;
107 VclPtr
<PushButton
> m_pRemoveCondition
;
108 VclPtr
<SvxColorWindow
> m_pColorFloat
;
110 std::unique_ptr
<svx::ToolboxButtonColorUpdater
> m_pBtnUpdaterFontColor
; // updates the color below the toolbar icon
111 std::unique_ptr
<svx::ToolboxButtonColorUpdater
> m_pBtnUpdaterBackgroundColor
;
115 bool m_bInDestruction
;
117 ConditionalExpressions m_aConditionalExpressions
;
119 DECL_LINK( OnFormatAction
, ToolBox
*, void );
120 DECL_LINK( DropdownClick
, ToolBox
*, void );
121 DECL_LINK( OnConditionAction
, Button
*, void );
124 Condition( vcl::Window
* _pParent
, IConditionalFormatAction
& _rAction
, ::rptui::OReportController
& _rController
);
125 virtual ~Condition() override
;
126 virtual void dispose() override
;
128 /** will be called when the id of the image list needs to change.
132 virtual void setImageList(sal_Int16 _eBitmapSet
) override
;
134 /** will be called when the controls need to be resized.
136 virtual void resizeControls(const Size
& _rDiff
) override
;
138 /** sets the props at the control
139 @param _xCondition the source
141 void setCondition(const css::uno::Reference
< css::report::XFormatCondition
>& _xCondition
);
143 /** fills from the control
144 _xCondition the destination
146 void fillFormatCondition(const css::uno::Reference
< css::report::XFormatCondition
>& _xCondition
);
148 /** updates the toolbar
149 _xCondition the destination
151 void updateToolbar(const css::uno::Reference
< css::report::XReportControlFormat
>& _xCondition
);
153 /// tells the condition its new index within the dialog's condition array
154 void setConditionIndex( size_t _nCondIndex
, size_t _nCondCount
);
156 /// returns the condition's index within the dialog's condition array
157 size_t getConditionIndex() const { return m_nCondIndex
; }
159 /** determines whether the condition is actually empty
161 bool isEmpty() const;
163 /** forward to the parent class
165 void ApplyCommand( sal_uInt16 _nCommandId
, const NamedColor
& rNamedColor
);
167 ::rptui::OReportController
& getController() const { return m_rController
; }
169 sal_uInt16
mapToolbarItemToSlotId(sal_uInt16 nItemId
) const;
172 virtual void GetFocus() override
;
175 void impl_layoutOperands();
178 impl_getCurrentConditionType() const;
180 inline ComparisonOperation
181 impl_getCurrentComparisonOperation() const;
183 void impl_setCondition( const OUString
& _rConditionFormula
);
186 DECL_LINK( OnTypeSelected
, ListBox
&, void );
187 DECL_LINK( OnOperationSelected
, ListBox
&, void );
191 inline ConditionType
Condition::impl_getCurrentConditionType() const
193 return sal::static_int_cast
< ConditionType
>( m_pConditionType
->GetSelectedEntryPos() );
197 inline ComparisonOperation
Condition::impl_getCurrentComparisonOperation() const
199 return sal::static_int_cast
< ComparisonOperation
>( m_pOperationList
->GetSelectedEntryPos() );
205 #endif // INCLUDED_REPORTDESIGN_SOURCE_UI_DLG_CONDITION_HXX
207 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */