1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 INCLUDED_REPORTDESIGN_SOURCE_UI_INC_CONDFORMAT_HXX
21 #define INCLUDED_REPORTDESIGN_SOURCE_UI_INC_CONDFORMAT_HXX
23 #include <com/sun/star/report/XReportControlModel.hpp>
24 #include <vcl/weld.hxx>
31 constexpr size_t MAX_CONDITIONS
= 3;
33 class OReportController
;
37 //= IConditionalFormatAction
39 class SAL_NO_VTABLE IConditionalFormatAction
42 virtual void addCondition( size_t _nAddAfterIndex
) = 0;
43 virtual void deleteCondition( size_t _nCondIndex
) = 0;
44 virtual void applyCommand( size_t _nCondIndex
, sal_uInt16 _nCommandId
, const ::Color
& rColor
) = 0;
45 virtual void moveConditionUp( size_t _nCondIndex
) = 0;
46 virtual void moveConditionDown( size_t _nCondIndex
) = 0;
47 virtual OUString
getDataField() const = 0;
50 ~IConditionalFormatAction() {}
53 /*************************************************************************
55 |* Conditional formatting dialog
57 \************************************************************************/
58 class ConditionalFormattingDialog
: public weld::GenericDialogController
59 , public IConditionalFormatAction
61 typedef ::std::vector
< std::unique_ptr
<Condition
> > Conditions
;
63 ::rptui::OReportController
& m_rController
;
64 css::uno::Reference
< css::report::XReportControlModel
>
66 css::uno::Reference
< css::report::XReportControlModel
>
71 std::unique_ptr
<weld::ScrolledWindow
> m_xScrollWindow
;
72 std::unique_ptr
<weld::Box
> m_xConditionPlayground
;
73 Conditions m_aConditions
;
76 ConditionalFormattingDialog(
77 weld::Window
* pParent
,
78 const css::uno::Reference
< css::report::XReportControlModel
>& _xHoldAlive
,
79 ::rptui::OReportController
& _rController
81 virtual ~ConditionalFormattingDialog() override
;
82 // Dialog overridables
83 virtual short run() override
;
85 // IConditionalFormatAction overridables
86 virtual void addCondition( size_t _nAddAfterIndex
) override
;
87 virtual void deleteCondition( size_t _nCondIndex
) override
;
88 virtual void applyCommand( size_t _nCondIndex
, sal_uInt16 _nCommandId
, const ::Color
& rColor
) override
;
89 virtual void moveConditionUp( size_t _nCondIndex
) override
;
90 virtual void moveConditionDown( size_t _nCondIndex
) override
;
91 virtual OUString
getDataField() const override
;
94 DECL_LINK(OnScroll
, weld::ScrolledWindow
&, void);
97 /// returns the current number of conditions
98 size_t impl_getConditionCount() const { return m_aConditions
.size(); }
101 @param _nNewCondIndex
102 the index of the to-be-inserted condition
104 void impl_addCondition_nothrow( size_t _nNewCondIndex
);
106 /// deletes the condition with the given index
107 void impl_deleteCondition_nothrow( size_t _nCondIndex
);
109 /// moves the condition with the given index one position
110 void impl_moveCondition_nothrow( size_t _nCondIndex
, bool _bMoveUp
);
112 /// does the dialog layouting
113 void impl_layoutAll();
115 /// called when the number of conditions has changed in any way
116 void impl_conditionCountChanged();
118 /// initializes the conditions from m_xCopy
119 void impl_initializeConditions();
121 /// tells all our Condition instances their new index
122 void impl_updateConditionIndicies();
124 /// returns the number of the condition which has the (child path) focus
125 size_t impl_getFocusedConditionIndex( sal_Int32 _nFallBackIfNone
) const;
127 /// returns the index of the first visible condition
128 size_t impl_getFirstVisibleConditionIndex() const;
130 /// returns the index of the last visible condition
131 size_t impl_getLastVisibleConditionIndex() const;
133 /// focuses the condition with the given index, making it visible if necessary
134 void impl_focusCondition( size_t _nCondIndex
);
136 /// scrolls the condition with the given index to the top position
137 void impl_scrollTo( size_t _nTopCondIndex
);
139 /// ensures the condition with the given index is visible
140 void impl_ensureConditionVisible( size_t _nCondIndex
);
142 /// set the preferred height of the action_area
143 void impl_setPrefHeight(bool bFirst
);
150 #endif // INCLUDED_REPORTDESIGN_SOURCE_UI_INC_CONDFORMAT_HXX
152 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */