Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef INCLUDED_REPORTDESIGN_SOURCE_UI_INC_CONDFORMAT_HXX
21 : #define INCLUDED_REPORTDESIGN_SOURCE_UI_INC_CONDFORMAT_HXX
22 :
23 : #include "ModuleHelper.hxx"
24 :
25 : #include <com/sun/star/report/XReportControlModel.hpp>
26 :
27 : #include <vcl/dialog.hxx>
28 : #include <vcl/button.hxx>
29 : #include <vcl/fixed.hxx>
30 : #include <vcl/layout.hxx>
31 : #include <vcl/scrbar.hxx>
32 :
33 : #include <boost/shared_ptr.hpp>
34 : #include <boost/noncopyable.hpp>
35 :
36 : #include <vector>
37 :
38 :
39 : namespace rptui
40 : {
41 :
42 :
43 : #define MAX_CONDITIONS (size_t)3
44 :
45 : class OReportController;
46 : class Condition;
47 :
48 :
49 : //= IConditionalFormatAction
50 :
51 0 : class SAL_NO_VTABLE IConditionalFormatAction
52 : {
53 : public:
54 : virtual void addCondition( size_t _nAddAfterIndex ) = 0;
55 : virtual void deleteCondition( size_t _nCondIndex ) = 0;
56 : virtual void applyCommand( size_t _nCondIndex, sal_uInt16 _nCommandId, const ::Color _aColor ) = 0;
57 : virtual void moveConditionUp( size_t _nCondIndex ) = 0;
58 : virtual void moveConditionDown( size_t _nCondIndex ) = 0;
59 : virtual OUString getDataField() const = 0;
60 :
61 : protected:
62 0 : ~IConditionalFormatAction() {}
63 : };
64 :
65 : /*************************************************************************
66 : |*
67 : |* Conditional formatting dialog
68 : |*
69 : \************************************************************************/
70 : class ConditionalFormattingDialog :public ModalDialog
71 : ,public IConditionalFormatAction
72 : {
73 : typedef ::boost::shared_ptr< Condition > ConditionPtr;
74 : typedef ::std::vector< ConditionPtr > Conditions;
75 :
76 : OModuleClient m_aModuleClient;
77 : vcl::Window* m_pConditionPlayground;
78 : Conditions m_aConditions;
79 : VclScrolledWindow* m_pScrollWindow;
80 : ScrollBar* m_pCondScroll;
81 :
82 : ::rptui::OReportController& m_rController;
83 : ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportControlModel >
84 : m_xFormatConditions;
85 : ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportControlModel >
86 : m_xCopy;
87 :
88 : bool m_bDeletingCondition;
89 : bool m_bConstructed;
90 :
91 : public:
92 : ConditionalFormattingDialog(
93 : vcl::Window* pParent,
94 : const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportControlModel>& _xHoldAlive,
95 : ::rptui::OReportController& _rController
96 : );
97 : virtual ~ConditionalFormattingDialog();
98 :
99 : // Dialog overridables
100 : virtual short Execute() SAL_OVERRIDE;
101 :
102 : // IConditionalFormatAction overridables
103 : virtual void addCondition( size_t _nAddAfterIndex ) SAL_OVERRIDE;
104 : virtual void deleteCondition( size_t _nCondIndex ) SAL_OVERRIDE;
105 : virtual void applyCommand( size_t _nCondIndex, sal_uInt16 _nCommandId, const ::Color _aColor ) SAL_OVERRIDE;
106 : virtual void moveConditionUp( size_t _nCondIndex ) SAL_OVERRIDE;
107 : virtual void moveConditionDown( size_t _nCondIndex ) SAL_OVERRIDE;
108 : virtual OUString getDataField() const SAL_OVERRIDE;
109 :
110 : protected:
111 : virtual bool PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
112 :
113 : private:
114 : DECL_LINK( OnScroll, ScrollBar* );
115 :
116 : private:
117 : /// returns the current number of conditions
118 0 : size_t impl_getConditionCount() const { return m_aConditions.size(); }
119 :
120 : /** adds a condition
121 : @param _nNewCondIndex
122 : the index of the to-be-inserted condition
123 : */
124 : void impl_addCondition_nothrow( size_t _nNewCondIndex );
125 :
126 : /// deletes the condition with the given index
127 : void impl_deleteCondition_nothrow( size_t _nCondIndex );
128 :
129 : /// moves the condition with the given index one position
130 : void impl_moveCondition_nothrow( size_t _nCondIndex, bool _bMoveUp );
131 :
132 : /// does the dialog layouting
133 : void impl_layoutAll();
134 :
135 : /// does the layout for the condition windows
136 : void impl_layoutConditions();
137 :
138 : /// called when the number of conditions has changed in any way
139 : void impl_conditionCountChanged();
140 :
141 : /// initializes the conditions from m_xCopy
142 : void impl_initializeConditions();
143 :
144 : /// tells all our Condition instances their new index
145 : void impl_updateConditionIndicies();
146 :
147 : /// returns the number of the condition which has the (child path) focus
148 : size_t impl_getFocusedConditionIndex( sal_Int32 _nFallBackIfNone ) const;
149 :
150 : /// returns the index of the first visible condition
151 : size_t impl_getFirstVisibleConditionIndex() const;
152 :
153 : /// returns the index of the last visible condition
154 : size_t impl_getLastVisibleConditionIndex() const;
155 :
156 : /// focuses the condition with the given index, making it visible if necessary
157 : void impl_focusCondition( size_t _nCondIndex );
158 :
159 : /// updates the scrollbar range. (does not update the scrollbar visibility)
160 : void impl_updateScrollBarRange();
161 :
162 : /// determines whether we need a scrollbar for the conditions
163 0 : bool impl_needScrollBar() const { return m_aConditions.size() > MAX_CONDITIONS; }
164 :
165 : /// scrolls the condition with the given index to the top position
166 : void impl_scrollTo( size_t _nTopCondIndex );
167 :
168 : /// ensures the condition with the given index is visible
169 : void impl_ensureConditionVisible( size_t _nCondIndex );
170 :
171 : /// set the preferred height of the action_area
172 : void impl_setPrefHeight(bool bFirst);
173 : };
174 :
175 :
176 : } // namespace rptui
177 :
178 :
179 : #endif // INCLUDED_REPORTDESIGN_SOURCE_UI_INC_CONDFORMAT_HXX
180 :
181 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|