Line data Source code
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 : #ifndef DBAUI_SQLNAMEEDIT_HXX
20 : #define DBAUI_SQLNAMEEDIT_HXX
21 :
22 : #include <vcl/edit.hxx>
23 : #include <vcl/combobox.hxx>
24 :
25 : namespace dbaui
26 : {
27 0 : class OSQLNameChecker
28 : {
29 : ::rtl::OUString m_sAllowedChars;
30 : sal_Bool m_bOnlyUpperCase;
31 : sal_Bool m_bCheck; // true when we should check for invalid chars
32 : public:
33 0 : OSQLNameChecker(const ::rtl::OUString& _rAllowedChars)
34 : :m_sAllowedChars(_rAllowedChars)
35 : ,m_bOnlyUpperCase(sal_False)
36 0 : ,m_bCheck(sal_True)
37 : {
38 0 : }
39 :
40 : void setUpperCase(sal_Bool _bUpper=sal_True)
41 : {
42 : m_bOnlyUpperCase = _bUpper;
43 : }
44 0 : void setAllowedChars(const ::rtl::OUString& _rAllowedChars)
45 : {
46 0 : m_sAllowedChars = _rAllowedChars;
47 0 : }
48 : // default is false because it is initialized with true
49 0 : void setCheck(sal_Bool _bCheck = sal_False)
50 : {
51 0 : m_bCheck = _bCheck;
52 0 : }
53 : sal_Bool checkString(const ::rtl::OUString& _sOldValue,const ::rtl::OUString& _sToCheck,::rtl::OUString& _rsCorrected);
54 : };
55 : //==================================================================
56 0 : class OSQLNameEdit : public Edit
57 : ,public OSQLNameChecker
58 : {
59 : public:
60 0 : OSQLNameEdit(Window* _pParent,const ::rtl::OUString& _rAllowedChars, WinBits nStyle = WB_BORDER)
61 : : Edit(_pParent,nStyle)
62 0 : ,OSQLNameChecker(_rAllowedChars)
63 : {
64 0 : }
65 0 : OSQLNameEdit(Window* _pParent,const ResId& _rRes,const ::rtl::OUString& _rAllowedChars = ::rtl::OUString())
66 : : Edit(_pParent,_rRes)
67 0 : ,OSQLNameChecker(_rAllowedChars)
68 : {
69 0 : }
70 :
71 : // Window overload
72 : // virtual long PreNotify( NotifyEvent& rNEvt );
73 : // Edit
74 : virtual void Modify();
75 : };
76 :
77 0 : class OSQLNameComboBox : public ComboBox
78 : ,public OSQLNameChecker
79 : {
80 : public:
81 : OSQLNameComboBox(Window* _pParent,const ::rtl::OUString& _rAllowedChars, WinBits nStyle = WB_BORDER)
82 : : ComboBox(_pParent,nStyle)
83 : ,OSQLNameChecker(_rAllowedChars)
84 : {
85 : }
86 0 : OSQLNameComboBox(Window* _pParent,const ResId& _rRes,const ::rtl::OUString& _rAllowedChars = ::rtl::OUString())
87 : : ComboBox(_pParent,_rRes)
88 0 : ,OSQLNameChecker(_rAllowedChars)
89 : {
90 0 : }
91 :
92 : // Window overload
93 : // Edit
94 : virtual void Modify();
95 : };
96 :
97 : }
98 : #endif // DBAUI_SQLNAMEEDIT_HXX
99 :
100 :
101 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|