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