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/fntctrl.hxx>
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>
41 namespace svx
{ class ToolboxButtonColorUpdater
; }
46 class OReportController
;
47 class IConditionalFormatAction
;
52 VclPtr
<Condition
> m_pParent
;
53 VclPtr
<Edit
> m_pSubEdit
;
54 VclPtr
<PushButton
> m_pFormula
;
56 DECL_LINK( OnFormula
, Button
* );
58 ConditionField(Condition
* pParent
, Edit
* pSubEdit
, PushButton
*pFormula
);
59 void GrabFocus() { m_pSubEdit
->GrabFocus(); }
60 void Show(bool bShow
) { m_pSubEdit
->Show(bShow
); m_pFormula
->Show(bShow
); }
61 void SetText(const OUString
& rText
) { m_pSubEdit
->SetText(rText
); }
62 OUString
GetText() const { return m_pSubEdit
->GetText(); }
67 class Condition
:public VclHBox
68 ,public dbaui::OToolBoxHelper
69 ,public VclBuilderContainer
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
;
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
;
94 svx::ToolboxButtonColorUpdater
* m_pBtnUpdaterFontColor
; // updates the color below the toolbar icon
95 svx::ToolboxButtonColorUpdater
* m_pBtnUpdaterBackgroundColor
;
99 bool m_bInDestruction
;
101 ConditionalExpressions m_aConditionalExpressions
;
103 DECL_LINK_TYPED( OnFormatAction
, ToolBox
*, void );
104 DECL_LINK_TYPED( DropdownClick
, ToolBox
*, void );
105 DECL_LINK( OnConditionAction
, Button
* );
108 Condition( vcl::Window
* _pParent
, IConditionalFormatAction
& _rAction
, ::rptui::OReportController
& _rController
);
109 virtual ~Condition();
110 virtual void dispose() SAL_OVERRIDE
;
112 /** will be called when the id of the image list needs to change.
116 virtual void setImageList(sal_Int16 _eBitmapSet
) SAL_OVERRIDE
;
118 /** will be called when the controls need to be resized.
120 virtual void resizeControls(const Size
& _rDiff
) SAL_OVERRIDE
;
122 /** sets the props at the control
123 @param _xCondition the source
125 void setCondition(const com::sun::star::uno::Reference
< com::sun::star::report::XFormatCondition
>& _xCondition
);
127 /** fills from the control
128 _xCondition the destination
130 void fillFormatCondition(const com::sun::star::uno::Reference
< com::sun::star::report::XFormatCondition
>& _xCondition
);
132 /** updates the toolbar
133 _xCondition the destination
135 void updateToolbar(const ::com::sun::star::uno::Reference
< ::com::sun::star::report::XReportControlFormat
>& _xCondition
);
137 /// tells the condition its new index within the dialog's condition array
138 void setConditionIndex( size_t _nCondIndex
, size_t _nCondCount
);
140 /// returns the condition's index within the dialog's condition array
141 size_t getConditionIndex() const { return m_nCondIndex
; }
143 /** determines whether the condition is actually empty
145 bool isEmpty() const;
147 /** forward to the parent class
149 void ApplyCommand(sal_uInt16 _nCommandId
, const ::Color
& _aColor
);
151 inline ::rptui::OReportController
& getController() const { return m_rController
; }
153 sal_uInt16
mapToolbarItemToSlotId(sal_uInt16 nItemId
) const;
156 virtual void GetFocus() SAL_OVERRIDE
;
159 void impl_layoutOperands();
162 impl_getCurrentConditionType() const;
164 inline ComparisonOperation
165 impl_getCurrentComparisonOperation() const;
167 void impl_setCondition( const OUString
& _rConditionFormula
);
170 DECL_LINK( OnTypeSelected
, ListBox
* );
171 DECL_LINK( OnOperationSelected
, ListBox
* );
175 inline ConditionType
Condition::impl_getCurrentConditionType() const
177 return sal::static_int_cast
< ConditionType
>( m_pConditionType
->GetSelectEntryPos() );
181 inline ComparisonOperation
Condition::impl_getCurrentComparisonOperation() const
183 return sal::static_int_cast
< ComparisonOperation
>( m_pOperationList
->GetSelectEntryPos() );
189 #endif // INCLUDED_REPORTDESIGN_SOURCE_UI_DLG_CONDITION_HXX
191 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */