1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir #ifndef RPTUI_CONDFORMAT_HXX 29*cdf0e10cSrcweir #define RPTUI_CONDFORMAT_HXX 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include "ModuleHelper.hxx" 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir #include <com/sun/star/report/XReportControlModel.hpp> 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir #include <vcl/dialog.hxx> 36*cdf0e10cSrcweir #include <vcl/button.hxx> 37*cdf0e10cSrcweir #include <vcl/fixed.hxx> 38*cdf0e10cSrcweir #include <vcl/scrbar.hxx> 39*cdf0e10cSrcweir 40*cdf0e10cSrcweir #include <boost/shared_ptr.hpp> 41*cdf0e10cSrcweir #include <boost/noncopyable.hpp> 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir #include <vector> 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir // ............................................................................. 46*cdf0e10cSrcweir namespace rptui 47*cdf0e10cSrcweir { 48*cdf0e10cSrcweir // ............................................................................. 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir #define MAX_CONDITIONS (size_t)3 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir class OReportController; 53*cdf0e10cSrcweir class Condition; 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir //========================================================================= 56*cdf0e10cSrcweir //= IConditionalFormatAction 57*cdf0e10cSrcweir //========================================================================= 58*cdf0e10cSrcweir class SAL_NO_VTABLE IConditionalFormatAction 59*cdf0e10cSrcweir { 60*cdf0e10cSrcweir public: 61*cdf0e10cSrcweir virtual void addCondition( size_t _nAddAfterIndex ) = 0; 62*cdf0e10cSrcweir virtual void deleteCondition( size_t _nCondIndex ) = 0; 63*cdf0e10cSrcweir virtual void applyCommand( size_t _nCondIndex, sal_uInt16 _nCommandId, const ::Color _aColor ) = 0; 64*cdf0e10cSrcweir virtual void moveConditionUp( size_t _nCondIndex ) = 0; 65*cdf0e10cSrcweir virtual void moveConditionDown( size_t _nCondIndex ) = 0; 66*cdf0e10cSrcweir virtual ::rtl::OUString getDataField() const = 0; 67*cdf0e10cSrcweir }; 68*cdf0e10cSrcweir 69*cdf0e10cSrcweir /************************************************************************* 70*cdf0e10cSrcweir |* 71*cdf0e10cSrcweir |* Conditional formatting dialog 72*cdf0e10cSrcweir |* 73*cdf0e10cSrcweir \************************************************************************/ 74*cdf0e10cSrcweir class ConditionalFormattingDialog :public ModalDialog 75*cdf0e10cSrcweir ,public IConditionalFormatAction 76*cdf0e10cSrcweir ,private ::boost::noncopyable 77*cdf0e10cSrcweir { 78*cdf0e10cSrcweir typedef ::boost::shared_ptr< Condition > ConditionPtr; 79*cdf0e10cSrcweir typedef ::std::vector< ConditionPtr > Conditions; 80*cdf0e10cSrcweir 81*cdf0e10cSrcweir OModuleClient m_aModuleClient; 82*cdf0e10cSrcweir Window m_aConditionPlayground; 83*cdf0e10cSrcweir Conditions m_aConditions; 84*cdf0e10cSrcweir FixedLine m_aSeparator; 85*cdf0e10cSrcweir OKButton m_aPB_OK; 86*cdf0e10cSrcweir CancelButton m_aPB_CANCEL; 87*cdf0e10cSrcweir HelpButton m_aPB_Help; 88*cdf0e10cSrcweir ScrollBar m_aCondScroll; 89*cdf0e10cSrcweir 90*cdf0e10cSrcweir ::rptui::OReportController& m_rController; 91*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportControlModel > 92*cdf0e10cSrcweir m_xFormatConditions; 93*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportControlModel > 94*cdf0e10cSrcweir m_xCopy; 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir bool m_bDeletingCondition; 97*cdf0e10cSrcweir 98*cdf0e10cSrcweir public: 99*cdf0e10cSrcweir ConditionalFormattingDialog( 100*cdf0e10cSrcweir Window* pParent, 101*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportControlModel>& _xHoldAlive, 102*cdf0e10cSrcweir ::rptui::OReportController& _rController 103*cdf0e10cSrcweir ); 104*cdf0e10cSrcweir virtual ~ConditionalFormattingDialog(); 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir // Dialog overridables 107*cdf0e10cSrcweir virtual short Execute(); 108*cdf0e10cSrcweir 109*cdf0e10cSrcweir // IConditionalFormatAction overridables 110*cdf0e10cSrcweir virtual void addCondition( size_t _nAddAfterIndex ); 111*cdf0e10cSrcweir virtual void deleteCondition( size_t _nCondIndex ); 112*cdf0e10cSrcweir virtual void applyCommand( size_t _nCondIndex, sal_uInt16 _nCommandId, const ::Color _aColor ); 113*cdf0e10cSrcweir virtual void moveConditionUp( size_t _nCondIndex ); 114*cdf0e10cSrcweir virtual void moveConditionDown( size_t _nCondIndex ); 115*cdf0e10cSrcweir virtual ::rtl::OUString getDataField() const; 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir protected: 118*cdf0e10cSrcweir virtual long PreNotify( NotifyEvent& rNEvt ); 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir private: 121*cdf0e10cSrcweir DECL_LINK( OnScroll, ScrollBar* ); 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir private: 124*cdf0e10cSrcweir /// returns the current number of conditions 125*cdf0e10cSrcweir size_t impl_getConditionCount() const { return m_aConditions.size(); } 126*cdf0e10cSrcweir 127*cdf0e10cSrcweir /** adds a condition 128*cdf0e10cSrcweir @param _nNewCondIndex 129*cdf0e10cSrcweir the index of the to-be-inserted condition 130*cdf0e10cSrcweir */ 131*cdf0e10cSrcweir void impl_addCondition_nothrow( size_t _nNewCondIndex ); 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir /// deletes the condition with the given index 134*cdf0e10cSrcweir void impl_deleteCondition_nothrow( size_t _nCondIndex ); 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir /// moves the condition with the given index one position 137*cdf0e10cSrcweir void impl_moveCondition_nothrow( size_t _nCondIndex, bool _bMoveUp ); 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir /// does the dialog layouting 140*cdf0e10cSrcweir void impl_layoutAll(); 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir /// does the layout for the condition windows 143*cdf0e10cSrcweir void impl_layoutConditions( Point& _out_rBelowLastVisible ); 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir /// called when the number of conditions has changed in any way 146*cdf0e10cSrcweir void impl_conditionCountChanged(); 147*cdf0e10cSrcweir 148*cdf0e10cSrcweir /// initializes the conditions from m_xCopy 149*cdf0e10cSrcweir void impl_initializeConditions(); 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir /// tells all our Condition instances their new index 152*cdf0e10cSrcweir void impl_updateConditionIndicies(); 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir /// returns the number of the condition which has the (child path) focus 155*cdf0e10cSrcweir size_t impl_getFocusedConditionIndex( sal_Int32 _nFallBackIfNone ) const; 156*cdf0e10cSrcweir 157*cdf0e10cSrcweir /// returns the index of the first visible condition 158*cdf0e10cSrcweir size_t impl_getFirstVisibleConditionIndex() const; 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir /// returns the index of the last visible condition 161*cdf0e10cSrcweir size_t impl_getLastVisibleConditionIndex() const; 162*cdf0e10cSrcweir 163*cdf0e10cSrcweir /// determines the width of a Condition 164*cdf0e10cSrcweir long impl_getConditionWidth() const; 165*cdf0e10cSrcweir 166*cdf0e10cSrcweir /// focuses the condition with the given index, making it visible if necessary 167*cdf0e10cSrcweir void impl_focusCondition( size_t _nCondIndex ); 168*cdf0e10cSrcweir 169*cdf0e10cSrcweir /// updates the scrollbar range. (does not update the scrollbar visibility) 170*cdf0e10cSrcweir void impl_updateScrollBarRange(); 171*cdf0e10cSrcweir 172*cdf0e10cSrcweir /// determines whether we need a scrollbar for the conditions 173*cdf0e10cSrcweir bool impl_needScrollBar() const { return m_aConditions.size() > MAX_CONDITIONS; } 174*cdf0e10cSrcweir 175*cdf0e10cSrcweir /// scrolls the condition with the given index to the top position 176*cdf0e10cSrcweir void impl_scrollTo( size_t _nTopCondIndex ); 177*cdf0e10cSrcweir 178*cdf0e10cSrcweir /// ensures the condition with the given index is visible 179*cdf0e10cSrcweir void impl_ensureConditionVisible( size_t _nCondIndex ); 180*cdf0e10cSrcweir }; 181*cdf0e10cSrcweir 182*cdf0e10cSrcweir // ............................................................................. 183*cdf0e10cSrcweir } // namespace rptui 184*cdf0e10cSrcweir // ............................................................................. 185*cdf0e10cSrcweir 186*cdf0e10cSrcweir #endif // RPTUI_CONDFORMAT_HXX 187