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_CONDFORMAT_HXX 25cdf0e10cSrcweir #define RPTUI_CONDFORMAT_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "ModuleHelper.hxx" 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include <com/sun/star/report/XReportControlModel.hpp> 30cdf0e10cSrcweir 31cdf0e10cSrcweir #include <vcl/dialog.hxx> 32cdf0e10cSrcweir #include <vcl/button.hxx> 33cdf0e10cSrcweir #include <vcl/fixed.hxx> 34cdf0e10cSrcweir #include <vcl/scrbar.hxx> 35cdf0e10cSrcweir 36cdf0e10cSrcweir #include <boost/shared_ptr.hpp> 37cdf0e10cSrcweir #include <boost/noncopyable.hpp> 38cdf0e10cSrcweir 39cdf0e10cSrcweir #include <vector> 40cdf0e10cSrcweir 41cdf0e10cSrcweir // ............................................................................. 42cdf0e10cSrcweir namespace rptui 43cdf0e10cSrcweir { 44cdf0e10cSrcweir // ............................................................................. 45cdf0e10cSrcweir 46cdf0e10cSrcweir #define MAX_CONDITIONS (size_t)3 47cdf0e10cSrcweir 48cdf0e10cSrcweir class OReportController; 49cdf0e10cSrcweir class Condition; 50cdf0e10cSrcweir 51cdf0e10cSrcweir //========================================================================= 52cdf0e10cSrcweir //= IConditionalFormatAction 53cdf0e10cSrcweir //========================================================================= 54cdf0e10cSrcweir class SAL_NO_VTABLE IConditionalFormatAction 55cdf0e10cSrcweir { 56cdf0e10cSrcweir public: 57cdf0e10cSrcweir virtual void addCondition( size_t _nAddAfterIndex ) = 0; 58cdf0e10cSrcweir virtual void deleteCondition( size_t _nCondIndex ) = 0; 59cdf0e10cSrcweir virtual void applyCommand( size_t _nCondIndex, sal_uInt16 _nCommandId, const ::Color _aColor ) = 0; 60cdf0e10cSrcweir virtual void moveConditionUp( size_t _nCondIndex ) = 0; 61cdf0e10cSrcweir virtual void moveConditionDown( size_t _nCondIndex ) = 0; 62cdf0e10cSrcweir virtual ::rtl::OUString getDataField() const = 0; 63cdf0e10cSrcweir }; 64cdf0e10cSrcweir 65cdf0e10cSrcweir /************************************************************************* 66cdf0e10cSrcweir |* 67cdf0e10cSrcweir |* Conditional formatting dialog 68cdf0e10cSrcweir |* 69cdf0e10cSrcweir \************************************************************************/ 70cdf0e10cSrcweir class ConditionalFormattingDialog :public ModalDialog 71cdf0e10cSrcweir ,public IConditionalFormatAction 72cdf0e10cSrcweir ,private ::boost::noncopyable 73cdf0e10cSrcweir { 74cdf0e10cSrcweir typedef ::boost::shared_ptr< Condition > ConditionPtr; 75cdf0e10cSrcweir typedef ::std::vector< ConditionPtr > Conditions; 76cdf0e10cSrcweir 77cdf0e10cSrcweir OModuleClient m_aModuleClient; 78cdf0e10cSrcweir Window m_aConditionPlayground; 79cdf0e10cSrcweir Conditions m_aConditions; 80cdf0e10cSrcweir FixedLine m_aSeparator; 81cdf0e10cSrcweir OKButton m_aPB_OK; 82cdf0e10cSrcweir CancelButton m_aPB_CANCEL; 83cdf0e10cSrcweir HelpButton m_aPB_Help; 84cdf0e10cSrcweir ScrollBar m_aCondScroll; 85cdf0e10cSrcweir 86cdf0e10cSrcweir ::rptui::OReportController& m_rController; 87cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportControlModel > 88cdf0e10cSrcweir m_xFormatConditions; 89cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportControlModel > 90cdf0e10cSrcweir m_xCopy; 91cdf0e10cSrcweir 92cdf0e10cSrcweir bool m_bDeletingCondition; 93cdf0e10cSrcweir 94cdf0e10cSrcweir public: 95cdf0e10cSrcweir ConditionalFormattingDialog( 96cdf0e10cSrcweir Window* pParent, 97cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportControlModel>& _xHoldAlive, 98cdf0e10cSrcweir ::rptui::OReportController& _rController 99cdf0e10cSrcweir ); 100cdf0e10cSrcweir virtual ~ConditionalFormattingDialog(); 101cdf0e10cSrcweir 102cdf0e10cSrcweir // Dialog overridables 103cdf0e10cSrcweir virtual short Execute(); 104cdf0e10cSrcweir 105cdf0e10cSrcweir // IConditionalFormatAction overridables 106cdf0e10cSrcweir virtual void addCondition( size_t _nAddAfterIndex ); 107cdf0e10cSrcweir virtual void deleteCondition( size_t _nCondIndex ); 108cdf0e10cSrcweir virtual void applyCommand( size_t _nCondIndex, sal_uInt16 _nCommandId, const ::Color _aColor ); 109cdf0e10cSrcweir virtual void moveConditionUp( size_t _nCondIndex ); 110cdf0e10cSrcweir virtual void moveConditionDown( size_t _nCondIndex ); 111cdf0e10cSrcweir virtual ::rtl::OUString getDataField() const; 112cdf0e10cSrcweir 113cdf0e10cSrcweir protected: 114cdf0e10cSrcweir virtual long PreNotify( NotifyEvent& rNEvt ); 115cdf0e10cSrcweir 116cdf0e10cSrcweir private: 117cdf0e10cSrcweir DECL_LINK( OnScroll, ScrollBar* ); 118cdf0e10cSrcweir 119cdf0e10cSrcweir private: 120cdf0e10cSrcweir /// returns the current number of conditions impl_getConditionCount() const121cdf0e10cSrcweir size_t impl_getConditionCount() const { return m_aConditions.size(); } 122cdf0e10cSrcweir 123cdf0e10cSrcweir /** adds a condition 124cdf0e10cSrcweir @param _nNewCondIndex 125cdf0e10cSrcweir the index of the to-be-inserted condition 126cdf0e10cSrcweir */ 127cdf0e10cSrcweir void impl_addCondition_nothrow( size_t _nNewCondIndex ); 128cdf0e10cSrcweir 129cdf0e10cSrcweir /// deletes the condition with the given index 130cdf0e10cSrcweir void impl_deleteCondition_nothrow( size_t _nCondIndex ); 131cdf0e10cSrcweir 132cdf0e10cSrcweir /// moves the condition with the given index one position 133cdf0e10cSrcweir void impl_moveCondition_nothrow( size_t _nCondIndex, bool _bMoveUp ); 134cdf0e10cSrcweir 135cdf0e10cSrcweir /// does the dialog layouting 136cdf0e10cSrcweir void impl_layoutAll(); 137cdf0e10cSrcweir 138cdf0e10cSrcweir /// does the layout for the condition windows 139cdf0e10cSrcweir void impl_layoutConditions( Point& _out_rBelowLastVisible ); 140cdf0e10cSrcweir 141cdf0e10cSrcweir /// called when the number of conditions has changed in any way 142cdf0e10cSrcweir void impl_conditionCountChanged(); 143cdf0e10cSrcweir 144cdf0e10cSrcweir /// initializes the conditions from m_xCopy 145cdf0e10cSrcweir void impl_initializeConditions(); 146cdf0e10cSrcweir 147cdf0e10cSrcweir /// tells all our Condition instances their new index 148cdf0e10cSrcweir void impl_updateConditionIndicies(); 149cdf0e10cSrcweir 150cdf0e10cSrcweir /// returns the number of the condition which has the (child path) focus 151cdf0e10cSrcweir size_t impl_getFocusedConditionIndex( sal_Int32 _nFallBackIfNone ) const; 152cdf0e10cSrcweir 153cdf0e10cSrcweir /// returns the index of the first visible condition 154cdf0e10cSrcweir size_t impl_getFirstVisibleConditionIndex() const; 155cdf0e10cSrcweir 156cdf0e10cSrcweir /// returns the index of the last visible condition 157cdf0e10cSrcweir size_t impl_getLastVisibleConditionIndex() const; 158cdf0e10cSrcweir 159cdf0e10cSrcweir /// determines the width of a Condition 160cdf0e10cSrcweir long impl_getConditionWidth() const; 161cdf0e10cSrcweir 162cdf0e10cSrcweir /// focuses the condition with the given index, making it visible if necessary 163cdf0e10cSrcweir void impl_focusCondition( size_t _nCondIndex ); 164cdf0e10cSrcweir 165cdf0e10cSrcweir /// updates the scrollbar range. (does not update the scrollbar visibility) 166cdf0e10cSrcweir void impl_updateScrollBarRange(); 167cdf0e10cSrcweir 168cdf0e10cSrcweir /// determines whether we need a scrollbar for the conditions impl_needScrollBar() const169cdf0e10cSrcweir bool impl_needScrollBar() const { return m_aConditions.size() > MAX_CONDITIONS; } 170cdf0e10cSrcweir 171cdf0e10cSrcweir /// scrolls the condition with the given index to the top position 172cdf0e10cSrcweir void impl_scrollTo( size_t _nTopCondIndex ); 173cdf0e10cSrcweir 174cdf0e10cSrcweir /// ensures the condition with the given index is visible 175cdf0e10cSrcweir void impl_ensureConditionVisible( size_t _nCondIndex ); 176cdf0e10cSrcweir }; 177cdf0e10cSrcweir 178cdf0e10cSrcweir // ............................................................................. 179cdf0e10cSrcweir } // namespace rptui 180cdf0e10cSrcweir // ............................................................................. 181cdf0e10cSrcweir 182cdf0e10cSrcweir #endif // RPTUI_CONDFORMAT_HXX 183