1*9ee13d13SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*9ee13d13SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*9ee13d13SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*9ee13d13SAndrew Rist * distributed with this work for additional information 6*9ee13d13SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*9ee13d13SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*9ee13d13SAndrew Rist * "License"); you may not use this file except in compliance 9*9ee13d13SAndrew Rist * with the License. You may obtain a copy of the License at 10*9ee13d13SAndrew Rist * 11*9ee13d13SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*9ee13d13SAndrew Rist * 13*9ee13d13SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*9ee13d13SAndrew Rist * software distributed under the License is distributed on an 15*9ee13d13SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*9ee13d13SAndrew Rist * KIND, either express or implied. See the License for the 17*9ee13d13SAndrew Rist * specific language governing permissions and limitations 18*9ee13d13SAndrew Rist * under the License. 19*9ee13d13SAndrew Rist * 20*9ee13d13SAndrew Rist *************************************************************/ 21*9ee13d13SAndrew Rist 22*9ee13d13SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef RPTUI_CONDITION_HXX 25cdf0e10cSrcweir #define RPTUI_CONDITION_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "conditionalexpression.hxx" 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include <com/sun/star/report/XFormatCondition.hpp> 30cdf0e10cSrcweir 31cdf0e10cSrcweir #include <dbaccess/ToolBoxHelper.hxx> 32cdf0e10cSrcweir 33cdf0e10cSrcweir #include <svx/fntctrl.hxx> 34cdf0e10cSrcweir 35cdf0e10cSrcweir #include <svtools/valueset.hxx> 36cdf0e10cSrcweir 37cdf0e10cSrcweir #include <vcl/fixed.hxx> 38cdf0e10cSrcweir #include <vcl/lstbox.hxx> 39cdf0e10cSrcweir #include <vcl/field.hxx> 40cdf0e10cSrcweir #include <vcl/button.hxx> 41cdf0e10cSrcweir #include <vcl/toolbox.hxx> 42cdf0e10cSrcweir 43cdf0e10cSrcweir #include <memory> 44cdf0e10cSrcweir 45cdf0e10cSrcweir namespace svx { class ToolboxButtonColorUpdater; } 46cdf0e10cSrcweir 47cdf0e10cSrcweir namespace rptui 48cdf0e10cSrcweir { 49cdf0e10cSrcweir class ConditionalFormattingDialog; 50cdf0e10cSrcweir class OColorPopup; 51cdf0e10cSrcweir class OReportController; 52cdf0e10cSrcweir class IConditionalFormatAction; 53cdf0e10cSrcweir class Condition; 54cdf0e10cSrcweir 55cdf0e10cSrcweir class ConditionField : public Edit 56cdf0e10cSrcweir { 57cdf0e10cSrcweir Condition* m_pParent; 58cdf0e10cSrcweir Edit* m_pSubEdit; 59cdf0e10cSrcweir PushButton m_aFormula; 60cdf0e10cSrcweir 61cdf0e10cSrcweir DECL_LINK( OnFormula, Button* ); 62cdf0e10cSrcweir public: 63cdf0e10cSrcweir ConditionField( Condition* pParent, const ResId& rResId ); 64cdf0e10cSrcweir virtual ~ConditionField(); 65cdf0e10cSrcweir virtual void Resize(); 66cdf0e10cSrcweir }; 67cdf0e10cSrcweir 68cdf0e10cSrcweir //======================================================================== 69cdf0e10cSrcweir //= Condition 70cdf0e10cSrcweir //======================================================================== 71cdf0e10cSrcweir class Condition :public Control 72cdf0e10cSrcweir ,public dbaui::OToolBoxHelper 73cdf0e10cSrcweir { 74cdf0e10cSrcweir ::rptui::OReportController& m_rController; 75cdf0e10cSrcweir IConditionalFormatAction& m_rAction; 76cdf0e10cSrcweir FixedLine m_aHeader; 77cdf0e10cSrcweir ListBox m_aConditionType; 78cdf0e10cSrcweir ListBox m_aOperationList; 79cdf0e10cSrcweir ConditionField m_aCondLHS; 80cdf0e10cSrcweir FixedText m_aOperandGlue; 81cdf0e10cSrcweir ConditionField m_aCondRHS; 82cdf0e10cSrcweir ToolBox m_aActions; 83cdf0e10cSrcweir SvxFontPrevWindow m_aPreview; 84cdf0e10cSrcweir ImageButton m_aMoveUp; 85cdf0e10cSrcweir ImageButton m_aMoveDown; 86cdf0e10cSrcweir PushButton m_aAddCondition; 87cdf0e10cSrcweir PushButton m_aRemoveCondition; 88cdf0e10cSrcweir OColorPopup* m_pColorFloat; 89cdf0e10cSrcweir 90cdf0e10cSrcweir ::svx::ToolboxButtonColorUpdater* m_pBtnUpdaterFontColor; // updates the color below the toolbar icon 91cdf0e10cSrcweir ::svx::ToolboxButtonColorUpdater* m_pBtnUpdaterBackgroundColor; 92cdf0e10cSrcweir 93cdf0e10cSrcweir 94cdf0e10cSrcweir size_t m_nCondIndex; 95cdf0e10cSrcweir long m_nLastKnownWindowWidth; 96cdf0e10cSrcweir bool m_bInDestruction; 97cdf0e10cSrcweir 98cdf0e10cSrcweir ConditionalExpressions m_aConditionalExpressions; 99cdf0e10cSrcweir 100cdf0e10cSrcweir DECL_LINK( OnFormatAction, ToolBox* ); 101cdf0e10cSrcweir DECL_LINK( DropdownClick, ToolBox* ); 102cdf0e10cSrcweir DECL_LINK( OnConditionAction, Button* ); 103cdf0e10cSrcweir 104cdf0e10cSrcweir public: 105cdf0e10cSrcweir Condition( Window* _pParent, IConditionalFormatAction& _rAction, ::rptui::OReportController& _rController ); 106cdf0e10cSrcweir virtual ~Condition(); 107cdf0e10cSrcweir 108cdf0e10cSrcweir /** will be called when the id of the image list is needed. 109cdf0e10cSrcweir @param _eBitmapSet 110cdf0e10cSrcweir <svtools/imgdef.hxx> 111cdf0e10cSrcweir @param _bHiContast 112cdf0e10cSrcweir <TRUE/> when in high contrast mode. 113cdf0e10cSrcweir */ 114cdf0e10cSrcweir virtual ImageList getImageList(sal_Int16 _eBitmapSet,sal_Bool _bHiContast) const; 115cdf0e10cSrcweir 116cdf0e10cSrcweir /** will be called when the controls need to be resized. 117cdf0e10cSrcweir */ 118cdf0e10cSrcweir virtual void resizeControls(const Size& _rDiff); 119cdf0e10cSrcweir 120cdf0e10cSrcweir /** sets the props at the control 121cdf0e10cSrcweir @param _xCondition the source 122cdf0e10cSrcweir */ 123cdf0e10cSrcweir void setCondition(const com::sun::star::uno::Reference< com::sun::star::report::XFormatCondition >& _xCondition); 124cdf0e10cSrcweir 125cdf0e10cSrcweir /** fills from the control 126cdf0e10cSrcweir _xCondition the destination 127cdf0e10cSrcweir */ 128cdf0e10cSrcweir void fillFormatCondition(const com::sun::star::uno::Reference< com::sun::star::report::XFormatCondition >& _xCondition); 129cdf0e10cSrcweir 130cdf0e10cSrcweir /** updates the toolbar 131cdf0e10cSrcweir _xCondition the destination 132cdf0e10cSrcweir */ 133cdf0e10cSrcweir void updateToolbar(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportControlFormat >& _xCondition); 134cdf0e10cSrcweir 135cdf0e10cSrcweir /// tells the condition its new index within the dialog's condition array 136cdf0e10cSrcweir void setConditionIndex( size_t _nCondIndex, size_t _nCondCount ); 137cdf0e10cSrcweir 138cdf0e10cSrcweir /// returns the condition's index within the dialog's condition array getConditionIndex() const139cdf0e10cSrcweir size_t getConditionIndex() const { return m_nCondIndex; } 140cdf0e10cSrcweir 141cdf0e10cSrcweir /** determines whether the condition is actually empty 142cdf0e10cSrcweir */ 143cdf0e10cSrcweir bool isEmpty() const; 144cdf0e10cSrcweir 145cdf0e10cSrcweir /** forward to the parent class 146cdf0e10cSrcweir */ 147cdf0e10cSrcweir void ApplyCommand(sal_uInt16 _nCommandId, const ::Color& _aColor ); 148cdf0e10cSrcweir getController() const149cdf0e10cSrcweir inline ::rptui::OReportController& getController() const { return m_rController; } 150cdf0e10cSrcweir 151cdf0e10cSrcweir protected: 152cdf0e10cSrcweir virtual void StateChanged( StateChangedType nStateChange ); 153cdf0e10cSrcweir virtual void DataChanged( const DataChangedEvent& rDCEvt ); 154cdf0e10cSrcweir virtual void Paint( const Rectangle& rRect ); 155cdf0e10cSrcweir virtual void Resize(); 156cdf0e10cSrcweir virtual void GetFocus(); 157cdf0e10cSrcweir 158cdf0e10cSrcweir private: 159cdf0e10cSrcweir void impl_layoutAll(); 160cdf0e10cSrcweir void impl_layoutOperands(); 161cdf0e10cSrcweir 162cdf0e10cSrcweir /// determines the rectangle to be occupied by the toolbar, including the border drawn around it 163cdf0e10cSrcweir Rectangle impl_getToolBarBorderRect() const; 164cdf0e10cSrcweir 165cdf0e10cSrcweir inline ConditionType 166cdf0e10cSrcweir impl_getCurrentConditionType() const; 167cdf0e10cSrcweir 168cdf0e10cSrcweir inline ComparisonOperation 169cdf0e10cSrcweir impl_getCurrentComparisonOperation() const; 170cdf0e10cSrcweir 171cdf0e10cSrcweir void impl_setCondition( const ::rtl::OUString& _rConditionFormula ); 172cdf0e10cSrcweir 173cdf0e10cSrcweir private: 174cdf0e10cSrcweir DECL_LINK( OnTypeSelected, ListBox* ); 175cdf0e10cSrcweir DECL_LINK( OnOperationSelected, ListBox* ); 176cdf0e10cSrcweir }; 177cdf0e10cSrcweir 178cdf0e10cSrcweir // ------------------------------------------------------------------------- impl_getCurrentConditionType() const179cdf0e10cSrcweir inline ConditionType Condition::impl_getCurrentConditionType() const 180cdf0e10cSrcweir { 181cdf0e10cSrcweir return sal::static_int_cast< ConditionType >( m_aConditionType.GetSelectEntryPos() ); 182cdf0e10cSrcweir } 183cdf0e10cSrcweir 184cdf0e10cSrcweir // ------------------------------------------------------------------------- impl_getCurrentComparisonOperation() const185cdf0e10cSrcweir inline ComparisonOperation Condition::impl_getCurrentComparisonOperation() const 186cdf0e10cSrcweir { 187cdf0e10cSrcweir return sal::static_int_cast< ComparisonOperation >( m_aOperationList.GetSelectEntryPos() ); 188cdf0e10cSrcweir } 189cdf0e10cSrcweir 190cdf0e10cSrcweir // ============================================================================= 191cdf0e10cSrcweir } // namespace rptui 192cdf0e10cSrcweir // ============================================================================= 193cdf0e10cSrcweir #endif // RPTUI_CONDITION_HXX 194cdf0e10cSrcweir 195