LibreOffice Module dbaccess (master) 1
SqlNameEdit.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#pragma once
20
22#include <utility>
23#include <vcl/weld.hxx>
24
25namespace dbaui
26{
28 {
30 bool m_bCheck; // true when we should check for invalid chars
31 public:
32 OSQLNameChecker(OUString _sAllowedChars)
33 :m_sAllowedChars(std::move(_sAllowedChars))
34 ,m_bCheck(true)
35 {
36 }
37
38 void setAllowedChars(const OUString& _rAllowedChars)
39 {
40 m_sAllowedChars = _rAllowedChars;
41 }
42 void setCheck(bool _bCheck)
43 {
44 m_bCheck = _bCheck;
45 }
46 bool checkString(std::u16string_view _sToCheck,OUString& _rsCorrected);
47 };
48
50 , public OSQLNameChecker
51 {
52 public:
53 OSQLNameEditControl(BrowserDataWin* pParent, const OUString& rAllowedChars)
54 : svt::EditControl(pParent)
55 , OSQLNameChecker(rAllowedChars)
56 {
57 m_xWidget->connect_changed(LINK(this, OSQLNameEditControl, ModifyHdl));
58 }
59
60 virtual void connect_changed(const Link<weld::Entry&, void>& rLink) override
61 {
62 m_ChainChangedHdl = rLink;
63 }
64
65 private:
66 DECL_LINK(ModifyHdl, weld::Entry&, void);
67
69 };
70
72 {
73 private:
75 public:
77 : m_pWidget(pWidget)
78 {
79 }
80
81 void hide() { m_pWidget->hide(); }
82 void show() { m_pWidget->show(); }
83 void set_sensitive(bool bSensitive) { m_pWidget->set_sensitive(bSensitive); }
84
86
87 virtual bool get_value_changed_from_saved() const = 0;
88 virtual void save_value() = 0;
89
90 virtual ~OWidgetBase() {}
91 };
92
94 , public OSQLNameChecker
95 {
96 private:
97 std::unique_ptr<weld::Entry> m_xEntry;
98
99 DECL_LINK(ModifyHdl, weld::Entry&, void);
100
101 public:
102 OSQLNameEntry(std::unique_ptr<weld::Entry> xEntry, const OUString& _rAllowedChars = OUString())
103 : OWidgetBase(xEntry.get())
104 , OSQLNameChecker(_rAllowedChars)
105 , m_xEntry(std::move(xEntry))
106 {
107 m_xEntry->connect_changed(LINK(this, OSQLNameEntry, ModifyHdl));
108 }
109
110 OUString get_text() const { return m_xEntry->get_text(); }
111 void set_text(const OUString& rText) { m_xEntry->set_text(rText); }
112 void set_max_length(int nLen) { m_xEntry->set_max_length(nLen); }
113 virtual void save_value() override { m_xEntry->save_value(); }
114 virtual bool get_value_changed_from_saved() const override
115 {
116 return m_xEntry->get_value_changed_from_saved();
117 }
118 };
119
120}
121
122/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void setAllowedChars(const OUString &_rAllowedChars)
Definition: SqlNameEdit.hxx:38
bool checkString(std::u16string_view _sToCheck, OUString &_rsCorrected)
Definition: SqlNameEdit.cxx:34
OSQLNameChecker(OUString _sAllowedChars)
Definition: SqlNameEdit.hxx:32
void setCheck(bool _bCheck)
Definition: SqlNameEdit.hxx:42
DECL_LINK(ModifyHdl, weld::Entry &, void)
OSQLNameEditControl(BrowserDataWin *pParent, const OUString &rAllowedChars)
Definition: SqlNameEdit.hxx:53
Link< weld::Entry &, void > m_ChainChangedHdl
Definition: SqlNameEdit.hxx:68
virtual void connect_changed(const Link< weld::Entry &, void > &rLink) override
Definition: SqlNameEdit.hxx:60
virtual void save_value() override
OUString get_text() const
void set_text(const OUString &rText)
std::unique_ptr< weld::Entry > m_xEntry
Definition: SqlNameEdit.hxx:97
void set_max_length(int nLen)
DECL_LINK(ModifyHdl, weld::Entry &, void)
OSQLNameEntry(std::unique_ptr< weld::Entry > xEntry, const OUString &_rAllowedChars=OUString())
virtual bool get_value_changed_from_saved() const override
weld::Widget * m_pWidget
Definition: SqlNameEdit.hxx:74
void set_sensitive(bool bSensitive)
Definition: SqlNameEdit.hxx:83
virtual void save_value()=0
weld::Widget * GetWidget()
Definition: SqlNameEdit.hxx:85
OWidgetBase(weld::Widget *pWidget)
Definition: SqlNameEdit.hxx:76
virtual ~OWidgetBase()
Definition: SqlNameEdit.hxx:90
virtual bool get_value_changed_from_saved() const =0
std::unique_ptr< weld::Entry > m_xWidget
virtual void show()=0
virtual void hide()=0
virtual void set_sensitive(bool sensitive)=0
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)