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