LibreOffice Module reportdesign (master)  1
Condition.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_DLG_CONDITION_HXX
21 #define INCLUDED_REPORTDESIGN_SOURCE_UI_DLG_CONDITION_HXX
22 
24 
25 #include <com/sun/star/report/XFormatCondition.hpp>
26 
27 #include <svx/colorwindow.hxx>
28 #include <svx/fntctrl.hxx>
29 
30 #include <vcl/customweld.hxx>
31 #include <vcl/weld.hxx>
32 
33 #include <memory>
34 
35 namespace rptui
36 {
37  class OColorPopup;
38  class OReportController;
39  class IConditionalFormatAction;
40  class Condition;
41 
43  {
45  std::unique_ptr<weld::Entry> m_xSubEdit;
46  std::unique_ptr<weld::Button> m_xFormula;
47 
48  DECL_LINK(OnFormula, weld::Button&, void);
49  public:
50  ConditionField(Condition* pParent, std::unique_ptr<weld::Entry> xSubEdit, std::unique_ptr<weld::Button> xFormula);
51  void grab_focus() { m_xSubEdit->grab_focus(); }
52  void set_visible(bool bShow) { m_xSubEdit->set_visible(bShow); m_xFormula->set_visible(bShow); }
53  void set_text(const OUString& rText) { m_xSubEdit->set_text(rText); }
54  OUString get_text() const { return m_xSubEdit->get_text(); }
55  };
56 
58  {
59  public:
60  ConditionColorWrapper(Condition* pControl, sal_uInt16 nSlotId);
61  void operator()(const OUString& rCommand, const NamedColor& rColor);
62  // ColorSelectFunction signature
63  private:
65  sal_uInt16 mnSlotId;
66  };
67 
68  //= Condition
69 
70  class Condition
71  {
72  std::shared_ptr<PaletteManager> m_xPaletteManager;
76 
79 
80  size_t m_nCondIndex;
81 
83 
86  std::unique_ptr<weld::Builder> m_xBuilder;
87  std::unique_ptr<weld::Container> m_xContainer;
88  std::unique_ptr<weld::Label> m_xHeader;
89  std::unique_ptr<weld::ComboBox> m_xConditionType;
90  std::unique_ptr<weld::ComboBox> m_xOperationList;
91  std::unique_ptr<ConditionField> m_xCondLHS;
92  std::unique_ptr<weld::Label> m_xOperandGlue;
93  std::unique_ptr<ConditionField> m_xCondRHS;
94  std::unique_ptr<weld::Toolbar> m_xActions;
95  std::unique_ptr<weld::CustomWeld> m_xPreview;
96  std::unique_ptr<weld::Button> m_xMoveUp;
97  std::unique_ptr<weld::Button> m_xMoveDown;
98  std::unique_ptr<weld::Button> m_xAddCondition;
99  std::unique_ptr<weld::Button> m_xRemoveCondition;
100  std::unique_ptr<ColorWindow> m_xBackColorFloat;
101  std::unique_ptr<ColorWindow> m_xForeColorFloat;
102 
105 
106  DECL_LINK( OnFormatAction, const OString&, void );
107  DECL_LINK( OnConditionAction, weld::Button&, void );
108 
109  public:
110  Condition(weld::Container* pParent, weld::Window* pDialog, IConditionalFormatAction& rAction, ::rptui::OReportController& rController);
111  ~Condition();
112 
116  void setCondition(const css::uno::Reference< css::report::XFormatCondition >& _xCondition);
117 
121  void fillFormatCondition(const css::uno::Reference< css::report::XFormatCondition >& _xCondition);
122 
126  void updateToolbar(const css::uno::Reference< css::report::XReportControlFormat >& _xCondition);
127 
129  void setConditionIndex( size_t _nCondIndex, size_t _nCondCount );
130 
132  size_t getConditionIndex() const { return m_nCondIndex; }
133 
136  bool isEmpty() const;
137 
140  void ApplyCommand( sal_uInt16 _nCommandId, const NamedColor& rNamedColor );
141 
143 
144  static sal_uInt16 mapToolbarItemToSlotId(std::string_view rItemId);
145 
146  css::uno::Reference<css::awt::XWindow> GetXWindow() const { return m_pDialog->GetXWindow(); }
147 
148  void grab_focus() { m_xContainer->grab_focus(); }
149  bool has_focus() const { return m_xContainer->has_focus(); }
150  Size get_preferred_size() const { return m_xContainer->get_preferred_size(); }
151  weld::Widget* get_widget() const { return m_xContainer.get(); }
152 
153  private:
154  void impl_layoutOperands();
155 
156  inline ConditionType
158 
159  inline ComparisonOperation
161 
162  void impl_setCondition( const OUString& _rConditionFormula );
163 
164  private:
165  DECL_LINK( OnTypeSelected, weld::ComboBox&, void );
166  DECL_LINK( OnOperationSelected, weld::ComboBox&, void );
167  };
168 
170  {
171  return sal::static_int_cast<ConditionType>(m_xConditionType->get_active());
172  }
173 
175  {
176  return sal::static_int_cast<ComparisonOperation>(m_xOperationList->get_active());
177  }
178 
179 } // namespace rptui
180 
181 #endif // INCLUDED_REPORTDESIGN_SOURCE_UI_DLG_CONDITION_HXX
182 
183 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::unique_ptr< weld::Builder > m_xBuilder
Definition: Condition.hxx:86
std::pair< Color, OUString > NamedColor
bool has_focus() const
Definition: Condition.hxx:149
::rptui::OReportController & getController() const
Definition: Condition.hxx:142
virtual css::uno::Reference< css::awt::XWindow > GetXWindow()=0
bool isEmpty() const
determines whether the condition is actually empty
Definition: Condition.cxx:371
size_t getConditionIndex() const
returns the condition's index within the dialog's condition array
Definition: Condition.hxx:132
OUString get_text() const
Definition: Condition.hxx:54
ComparisonOperation impl_getCurrentComparisonOperation() const
Definition: Condition.hxx:174
size_t m_nCondIndex
Definition: Condition.hxx:80
std::unique_ptr< ConditionField > m_xCondLHS
Definition: Condition.hxx:91
Size get_preferred_size() const
Definition: Condition.hxx:150
void impl_setCondition(const OUString &_rConditionFormula)
Definition: Condition.cxx:235
std::unique_ptr< weld::Button > m_xFormula
Definition: Condition.hxx:46
IConditionalFormatAction & m_rAction
Definition: Condition.hxx:78
std::unique_ptr< weld::ComboBox > m_xOperationList
Definition: Condition.hxx:90
void operator()(const OUString &rCommand, const NamedColor &rColor)
Definition: Condition.cxx:76
void set_visible(bool bShow)
Definition: Condition.hxx:52
ConditionalExpressions m_aConditionalExpressions
Definition: Condition.hxx:82
void SetBackgroundDropdownClick()
Definition: Condition.cxx:152
std::unique_ptr< weld::Button > m_xMoveUp
Definition: Condition.hxx:96
weld::Window * m_pDialog
Definition: Condition.hxx:85
std::unique_ptr< ColorWindow > m_xBackColorFloat
Definition: Condition.hxx:100
std::unique_ptr< weld::Entry > m_xSubEdit
Definition: Condition.hxx:45
SvxFontPrevWindow m_aPreview
Definition: Condition.hxx:84
std::unique_ptr< weld::Container > m_xContainer
Definition: Condition.hxx:87
ConditionColorWrapper(Condition *pControl, sal_uInt16 nSlotId)
Definition: Condition.cxx:70
::std::map< ComparisonOperation, PConditionalExpression > ConditionalExpressions
std::unique_ptr< weld::Toolbar > m_xActions
Definition: Condition.hxx:94
void fillFormatCondition(const css::uno::Reference< css::report::XFormatCondition > &_xCondition)
fills from the control _xCondition the destination
Definition: Condition.cxx:336
void set_text(const OUString &rText)
Definition: Condition.hxx:53
void setCondition(const css::uno::Reference< css::report::XFormatCondition > &_xCondition)
sets the props at the control
Definition: Condition.cxx:284
::rptui::OReportController & m_rController
Definition: Condition.hxx:77
std::unique_ptr< weld::Button > m_xRemoveCondition
Definition: Condition.hxx:99
Condition * m_pParent
Definition: Condition.hxx:44
std::unique_ptr< weld::Label > m_xHeader
Definition: Condition.hxx:88
void updateToolbar(const css::uno::Reference< css::report::XReportControlFormat > &_xCondition)
updates the toolbar _xCondition the destination
Definition: Condition.cxx:305
ColorStatus m_aColorStatus
Definition: Condition.hxx:73
DECL_LINK(OnFormatAction, const OString &, void)
void setConditionIndex(size_t _nCondIndex, size_t _nCondCount)
tells the condition its new index within the dialog's condition array
Definition: Condition.cxx:359
ConditionField(Condition *pParent, std::unique_ptr< weld::Entry > xSubEdit, std::unique_ptr< weld::Button > xFormula)
Definition: Condition.cxx:42
void ApplyCommand(sal_uInt16 _nCommandId, const NamedColor &rNamedColor)
forward to the parent class
Definition: Condition.cxx:201
ConditionColorWrapper m_aBackColorWrapper
Definition: Condition.hxx:74
DECL_LINK(OnFormula, weld::Button &, void)
void SetForegroundDropdownClick()
Definition: Condition.cxx:167
std::unique_ptr< weld::CustomWeld > m_xPreview
Definition: Condition.hxx:95
std::unique_ptr< ConditionField > m_xCondRHS
Definition: Condition.hxx:93
Condition(weld::Container *pParent, weld::Window *pDialog, IConditionalFormatAction &rAction,::rptui::OReportController &rController)
Definition: Condition.cxx:83
std::unique_ptr< weld::Button > m_xMoveDown
Definition: Condition.hxx:97
css::uno::Reference< css::awt::XWindow > GetXWindow() const
Definition: Condition.hxx:146
weld::Widget * get_widget() const
Definition: Condition.hxx:151
std::unique_ptr< weld::ComboBox > m_xConditionType
Definition: Condition.hxx:89
std::unique_ptr< weld::Label > m_xOperandGlue
Definition: Condition.hxx:92
std::shared_ptr< PaletteManager > m_xPaletteManager
Definition: Condition.hxx:72
void impl_layoutOperands()
Definition: Condition.cxx:216
std::unique_ptr< weld::Button > m_xAddCondition
Definition: Condition.hxx:98
ConditionType impl_getCurrentConditionType() const
Definition: Condition.hxx:169
static sal_uInt16 mapToolbarItemToSlotId(std::string_view rItemId)
Definition: Condition.cxx:131
ConditionColorWrapper m_aForeColorWrapper
Definition: Condition.hxx:75
std::unique_ptr< ColorWindow > m_xForeColorFloat
Definition: Condition.hxx:101