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