bump product version to 4.1.6.2
[LibreOffice.git] / reportdesign / source / ui / inc / CondFormat.hxx
blob4d8fa7c515cd5b0c0b2854391da29faede20d2bd
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef RPTUI_CONDFORMAT_HXX
21 #define RPTUI_CONDFORMAT_HXX
23 #include "ModuleHelper.hxx"
25 #include <com/sun/star/report/XReportControlModel.hpp>
27 #include <vcl/dialog.hxx>
28 #include <vcl/button.hxx>
29 #include <vcl/fixed.hxx>
30 #include <vcl/scrbar.hxx>
32 #include <boost/shared_ptr.hpp>
33 #include <boost/noncopyable.hpp>
35 #include <vector>
37 // .............................................................................
38 namespace rptui
40 // .............................................................................
42 #define MAX_CONDITIONS (size_t)3
44 class OReportController;
45 class Condition;
47 //=========================================================================
48 //= IConditionalFormatAction
49 //=========================================================================
50 class SAL_NO_VTABLE IConditionalFormatAction
52 public:
53 virtual void addCondition( size_t _nAddAfterIndex ) = 0;
54 virtual void deleteCondition( size_t _nCondIndex ) = 0;
55 virtual void applyCommand( size_t _nCondIndex, sal_uInt16 _nCommandId, const ::Color _aColor ) = 0;
56 virtual void moveConditionUp( size_t _nCondIndex ) = 0;
57 virtual void moveConditionDown( size_t _nCondIndex ) = 0;
58 virtual OUString getDataField() const = 0;
60 protected:
61 ~IConditionalFormatAction() {}
64 /*************************************************************************
66 |* Conditional formatting dialog
68 \************************************************************************/
69 class ConditionalFormattingDialog :public ModalDialog
70 ,public IConditionalFormatAction
71 ,private ::boost::noncopyable
73 typedef ::boost::shared_ptr< Condition > ConditionPtr;
74 typedef ::std::vector< ConditionPtr > Conditions;
76 OModuleClient m_aModuleClient;
77 Window m_aConditionPlayground;
78 Conditions m_aConditions;
79 FixedLine m_aSeparator;
80 OKButton m_aPB_OK;
81 CancelButton m_aPB_CANCEL;
82 HelpButton m_aPB_Help;
83 ScrollBar m_aCondScroll;
85 ::rptui::OReportController& m_rController;
86 ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportControlModel >
87 m_xFormatConditions;
88 ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportControlModel >
89 m_xCopy;
91 bool m_bDeletingCondition;
93 public:
94 ConditionalFormattingDialog(
95 Window* pParent,
96 const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportControlModel>& _xHoldAlive,
97 ::rptui::OReportController& _rController
99 virtual ~ConditionalFormattingDialog();
101 // Dialog overridables
102 virtual short Execute();
104 // IConditionalFormatAction overridables
105 virtual void addCondition( size_t _nAddAfterIndex );
106 virtual void deleteCondition( size_t _nCondIndex );
107 virtual void applyCommand( size_t _nCondIndex, sal_uInt16 _nCommandId, const ::Color _aColor );
108 virtual void moveConditionUp( size_t _nCondIndex );
109 virtual void moveConditionDown( size_t _nCondIndex );
110 virtual OUString getDataField() const;
112 protected:
113 virtual long PreNotify( NotifyEvent& rNEvt );
115 private:
116 DECL_LINK( OnScroll, ScrollBar* );
118 private:
119 /// returns the current number of conditions
120 size_t impl_getConditionCount() const { return m_aConditions.size(); }
122 /** adds a condition
123 @param _nNewCondIndex
124 the index of the to-be-inserted condition
126 void impl_addCondition_nothrow( size_t _nNewCondIndex );
128 /// deletes the condition with the given index
129 void impl_deleteCondition_nothrow( size_t _nCondIndex );
131 /// moves the condition with the given index one position
132 void impl_moveCondition_nothrow( size_t _nCondIndex, bool _bMoveUp );
134 /// does the dialog layouting
135 void impl_layoutAll();
137 /// does the layout for the condition windows
138 void impl_layoutConditions( Point& _out_rBelowLastVisible );
140 /// called when the number of conditions has changed in any way
141 void impl_conditionCountChanged();
143 /// initializes the conditions from m_xCopy
144 void impl_initializeConditions();
146 /// tells all our Condition instances their new index
147 void impl_updateConditionIndicies();
149 /// returns the number of the condition which has the (child path) focus
150 size_t impl_getFocusedConditionIndex( sal_Int32 _nFallBackIfNone ) const;
152 /// returns the index of the first visible condition
153 size_t impl_getFirstVisibleConditionIndex() const;
155 /// returns the index of the last visible condition
156 size_t impl_getLastVisibleConditionIndex() const;
158 /// determines the width of a Condition
159 long impl_getConditionWidth() const;
161 /// focuses the condition with the given index, making it visible if necessary
162 void impl_focusCondition( size_t _nCondIndex );
164 /// updates the scrollbar range. (does not update the scrollbar visibility)
165 void impl_updateScrollBarRange();
167 /// determines whether we need a scrollbar for the conditions
168 bool impl_needScrollBar() const { return m_aConditions.size() > MAX_CONDITIONS; }
170 /// scrolls the condition with the given index to the top position
171 void impl_scrollTo( size_t _nTopCondIndex );
173 /// ensures the condition with the given index is visible
174 void impl_ensureConditionVisible( size_t _nCondIndex );
177 // .............................................................................
178 } // namespace rptui
179 // .............................................................................
181 #endif // RPTUI_CONDFORMAT_HXX
183 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */