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
35namespace 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
71 {
72 std::shared_ptr<PaletteManager> m_xPaletteManager;
76
79
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 OUString&, void );
107 DECL_LINK( OnConditionAction, weld::Button&, void );
108
109 public:
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::u16string_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
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: */
ConditionColorWrapper(Condition *pControl, sal_uInt16 nSlotId)
Definition: Condition.cxx:70
void operator()(const OUString &rCommand, const NamedColor &rColor)
Definition: Condition.cxx:76
DECL_LINK(OnFormula, weld::Button &, void)
OUString get_text() const
Definition: Condition.hxx:54
std::unique_ptr< weld::Entry > m_xSubEdit
Definition: Condition.hxx:45
void set_visible(bool bShow)
Definition: Condition.hxx:52
std::unique_ptr< weld::Button > m_xFormula
Definition: Condition.hxx:46
void set_text(const OUString &rText)
Definition: Condition.hxx:53
ConditionField(Condition *pParent, std::unique_ptr< weld::Entry > xSubEdit, std::unique_ptr< weld::Button > xFormula)
Definition: Condition.cxx:42
Condition * m_pParent
Definition: Condition.hxx:44
std::unique_ptr< weld::ComboBox > m_xConditionType
Definition: Condition.hxx:89
ConditionType impl_getCurrentConditionType() const
Definition: Condition.hxx:169
weld::Window * m_pDialog
Definition: Condition.hxx:85
void updateToolbar(const css::uno::Reference< css::report::XReportControlFormat > &_xCondition)
updates the toolbar _xCondition the destination
Definition: Condition.cxx:305
std::unique_ptr< weld::Toolbar > m_xActions
Definition: Condition.hxx:94
void SetBackgroundDropdownClick()
Definition: Condition.cxx:152
void fillFormatCondition(const css::uno::Reference< css::report::XFormatCondition > &_xCondition)
fills from the control _xCondition the destination
Definition: Condition.cxx:336
ConditionalExpressions m_aConditionalExpressions
Definition: Condition.hxx:82
Condition(weld::Container *pParent, weld::Window *pDialog, IConditionalFormatAction &rAction, ::rptui::OReportController &rController)
Definition: Condition.cxx:83
std::unique_ptr< weld::Label > m_xOperandGlue
Definition: Condition.hxx:92
ConditionColorWrapper m_aBackColorWrapper
Definition: Condition.hxx:74
void setConditionIndex(size_t _nCondIndex, size_t _nCondCount)
tells the condition its new index within the dialog's condition array
Definition: Condition.cxx:359
DECL_LINK(OnTypeSelected, weld::ComboBox &, void)
bool has_focus() const
Definition: Condition.hxx:149
std::unique_ptr< weld::Label > m_xHeader
Definition: Condition.hxx:88
size_t getConditionIndex() const
returns the condition's index within the dialog's condition array
Definition: Condition.hxx:132
void setCondition(const css::uno::Reference< css::report::XFormatCondition > &_xCondition)
sets the props at the control
Definition: Condition.cxx:284
Size get_preferred_size() const
Definition: Condition.hxx:150
ComparisonOperation impl_getCurrentComparisonOperation() const
Definition: Condition.hxx:174
std::unique_ptr< weld::ComboBox > m_xOperationList
Definition: Condition.hxx:90
std::unique_ptr< weld::CustomWeld > m_xPreview
Definition: Condition.hxx:95
std::unique_ptr< ConditionField > m_xCondLHS
Definition: Condition.hxx:91
void impl_layoutOperands()
Definition: Condition.cxx:216
DECL_LINK(OnFormatAction, const OUString &, void)
std::unique_ptr< weld::Container > m_xContainer
Definition: Condition.hxx:87
::rptui::OReportController & m_rController
Definition: Condition.hxx:77
void SetForegroundDropdownClick()
Definition: Condition.cxx:167
std::unique_ptr< weld::Builder > m_xBuilder
Definition: Condition.hxx:86
void ApplyCommand(sal_uInt16 _nCommandId, const NamedColor &rNamedColor)
forward to the parent class
Definition: Condition.cxx:201
std::unique_ptr< weld::Button > m_xMoveDown
Definition: Condition.hxx:97
void impl_setCondition(const OUString &_rConditionFormula)
Definition: Condition.cxx:235
SvxFontPrevWindow m_aPreview
Definition: Condition.hxx:84
std::unique_ptr< ColorWindow > m_xForeColorFloat
Definition: Condition.hxx:101
::rptui::OReportController & getController() const
Definition: Condition.hxx:142
bool isEmpty() const
determines whether the condition is actually empty
Definition: Condition.cxx:371
css::uno::Reference< css::awt::XWindow > GetXWindow() const
Definition: Condition.hxx:146
std::unique_ptr< ConditionField > m_xCondRHS
Definition: Condition.hxx:93
ColorStatus m_aColorStatus
Definition: Condition.hxx:73
std::shared_ptr< PaletteManager > m_xPaletteManager
Definition: Condition.hxx:72
std::unique_ptr< ColorWindow > m_xBackColorFloat
Definition: Condition.hxx:100
std::unique_ptr< weld::Button > m_xAddCondition
Definition: Condition.hxx:98
std::unique_ptr< weld::Button > m_xRemoveCondition
Definition: Condition.hxx:99
size_t m_nCondIndex
Definition: Condition.hxx:80
std::unique_ptr< weld::Button > m_xMoveUp
Definition: Condition.hxx:96
static sal_uInt16 mapToolbarItemToSlotId(std::u16string_view rItemId)
Definition: Condition.cxx:131
weld::Widget * get_widget() const
Definition: Condition.hxx:151
DECL_LINK(OnConditionAction, weld::Button &, void)
DECL_LINK(OnOperationSelected, weld::ComboBox &, void)
ConditionColorWrapper m_aForeColorWrapper
Definition: Condition.hxx:75
IConditionalFormatAction & m_rAction
Definition: Condition.hxx:78
virtual css::uno::Reference< css::awt::XWindow > GetXWindow()=0
::std::map< ComparisonOperation, PConditionalExpression > ConditionalExpressions