LibreOffice Module reportdesign (master)  1
CondFormat.hxx
Go to the documentation of this file.
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 <com/sun/star/report/XReportControlModel.hpp>
24 #include <vcl/weld.hxx>
25 #include <vector>
26 
27 namespace rptui
28 {
29 
30 
31  constexpr size_t MAX_CONDITIONS = 3;
32 
33  class OReportController;
34  class Condition;
35 
36 
37  //= IConditionalFormatAction
38 
40  {
41  public:
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;
48 
49  protected:
51  };
52 
53  /*************************************************************************
54  |*
55  |* Conditional formatting dialog
56  |*
57  \************************************************************************/
60  {
61  typedef ::std::vector< std::unique_ptr<Condition> > Conditions;
62 
64  css::uno::Reference< css::report::XReportControlModel >
66  css::uno::Reference< css::report::XReportControlModel >
68 
70 
71  std::unique_ptr<weld::ScrolledWindow> m_xScrollWindow;
72  std::unique_ptr<weld::Box> m_xConditionPlayground;
73  Conditions m_aConditions;
74 
75  public:
77  weld::Window* pParent,
78  const css::uno::Reference< css::report::XReportControlModel>& _xHoldAlive,
79  ::rptui::OReportController& _rController
80  );
81  virtual ~ConditionalFormattingDialog() override;
82  // Dialog overridables
83  virtual short run() override;
84 
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;
92 
93  private:
94  DECL_LINK(OnScroll, weld::ScrolledWindow&, void);
95 
96  private:
98  size_t impl_getConditionCount() const { return m_aConditions.size(); }
99 
104  void impl_addCondition_nothrow( size_t _nNewCondIndex );
105 
107  void impl_deleteCondition_nothrow( size_t _nCondIndex );
108 
110  void impl_moveCondition_nothrow( size_t _nCondIndex, bool _bMoveUp );
111 
113  void impl_layoutAll();
114 
117 
120 
123 
125  size_t impl_getFocusedConditionIndex( sal_Int32 _nFallBackIfNone ) const;
126 
128  size_t impl_getFirstVisibleConditionIndex() const;
129 
131  size_t impl_getLastVisibleConditionIndex() const;
132 
134  void impl_focusCondition( size_t _nCondIndex );
135 
137  void impl_scrollTo( size_t _nTopCondIndex );
138 
140  void impl_ensureConditionVisible( size_t _nCondIndex );
141 
143  void impl_setPrefHeight(bool bFirst);
144  };
145 
146 
147 } // namespace rptui
148 
149 
150 #endif // INCLUDED_REPORTDESIGN_SOURCE_UI_INC_CONDFORMAT_HXX
151 
152 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void moveConditionUp(size_t _nCondIndex) override
Definition: CondFormat.cxx:330
void impl_addCondition_nothrow(size_t _nNewCondIndex)
adds a condition
Definition: CondFormat.cxx:138
void impl_deleteCondition_nothrow(size_t _nCondIndex)
deletes the condition with the given index
Definition: CondFormat.cxx:172
size_t impl_getConditionCount() const
returns the current number of conditions
Definition: CondFormat.hxx:98
::rptui::OReportController & m_rController
Definition: CondFormat.hxx:63
size_t impl_getFirstVisibleConditionIndex() const
returns the index of the first visible condition
Definition: CondFormat.cxx:408
virtual short run() override
Definition: CondFormat.cxx:359
void impl_ensureConditionVisible(size_t _nCondIndex)
ensures the condition with the given index is visible
Definition: CondFormat.cxx:438
void impl_scrollTo(size_t _nTopCondIndex)
scrolls the condition with the given index to the top position
Definition: CondFormat.cxx:428
void impl_layoutAll()
does the dialog layouting
Definition: CondFormat.cxx:270
::std::vector< std::unique_ptr< Condition > > Conditions
Definition: CondFormat.hxx:61
std::unique_ptr< weld::Box > m_xConditionPlayground
Definition: CondFormat.hxx:72
css::uno::Reference< css::report::XReportControlModel > m_xCopy
Definition: CondFormat.hxx:67
size_t impl_getFocusedConditionIndex(sal_Int32 _nFallBackIfNone) const
returns the number of the condition which has the (child path) focus
Definition: CondFormat.cxx:419
std::unique_ptr< weld::ScrolledWindow > m_xScrollWindow
Definition: CondFormat.hxx:71
virtual void applyCommand(size_t _nCondIndex, sal_uInt16 _nCommandId, const ::Color &rColor) override
Definition: CondFormat.cxx:301
ConditionalFormattingDialog(weld::Window *pParent, const css::uno::Reference< css::report::XReportControlModel > &_xHoldAlive,::rptui::OReportController &_rController)
Definition: CondFormat.cxx:77
css::uno::Reference< css::report::XReportControlModel > m_xFormatConditions
Definition: CondFormat.hxx:65
void impl_initializeConditions()
initializes the conditions from m_xCopy
Definition: CondFormat.cxx:278
virtual void addCondition(size_t _nAddAfterIndex) override
Definition: CondFormat.cxx:125
void impl_moveCondition_nothrow(size_t _nCondIndex, bool _bMoveUp)
moves the condition with the given index one position
Definition: CondFormat.cxx:219
DECL_LINK(OnScroll, weld::ScrolledWindow &, void)
void impl_updateConditionIndicies()
tells all our Condition instances their new index
Definition: CondFormat.cxx:103
virtual void moveConditionDown(size_t _nCondIndex) override
Definition: CondFormat.cxx:338
virtual ~ConditionalFormattingDialog() override
Definition: CondFormat.cxx:99
virtual OUString getDataField() const override
Definition: CondFormat.cxx:345
void impl_setPrefHeight(bool bFirst)
set the preferred height of the action_area
Definition: CondFormat.cxx:55
size_t impl_getLastVisibleConditionIndex() const
returns the index of the last visible condition
Definition: CondFormat.cxx:414
void impl_conditionCountChanged()
called when the number of conditions has changed in any way
Definition: CondFormat.cxx:114
virtual void deleteCondition(size_t _nCondIndex) override
Definition: CondFormat.cxx:132
#define SAL_NO_VTABLE
void impl_focusCondition(size_t _nCondIndex)
focuses the condition with the given index, making it visible if necessary
Definition: CondFormat.cxx:163
constexpr size_t MAX_CONDITIONS
Definition: CondFormat.hxx:31