xref: /trunk/main/dbaccess/source/ui/inc/SqlNameEdit.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef DBAUI_SQLNAMEEDIT_HXX
28 #define DBAUI_SQLNAMEEDIT_HXX
29 
30 #ifndef _SV_EDIT_HXX
31 #include <vcl/edit.hxx>
32 #endif
33 #ifndef _SV_COMBOBOX_HXX
34 #include <vcl/combobox.hxx>
35 #endif
36 
37 namespace dbaui
38 {
39     class OSQLNameChecker
40     {
41         ::rtl::OUString m_sAllowedChars;
42         sal_Bool        m_bOnlyUpperCase;
43         sal_Bool        m_bCheck;           // true when we should check for invalid chars
44     public:
45         OSQLNameChecker(const ::rtl::OUString& _rAllowedChars)
46             :m_sAllowedChars(_rAllowedChars)
47             ,m_bOnlyUpperCase(sal_False)
48             ,m_bCheck(sal_True)
49         {
50         }
51 
52         void setUpperCase(sal_Bool _bUpper=sal_True)
53         {
54             m_bOnlyUpperCase = _bUpper;
55         }
56         void setAllowedChars(const ::rtl::OUString& _rAllowedChars)
57         {
58             m_sAllowedChars = _rAllowedChars;
59         }
60         // default is false because it is initialized with true
61         void setCheck(sal_Bool _bCheck = sal_False)
62         {
63             m_bCheck = _bCheck;
64         }
65         sal_Bool checkString(const ::rtl::OUString& _sOldValue,const ::rtl::OUString& _sToCheck,::rtl::OUString& _rsCorrected);
66     };
67     //==================================================================
68     class OSQLNameEdit : public Edit
69                         ,public OSQLNameChecker
70     {
71     public:
72         OSQLNameEdit(Window* _pParent,const ::rtl::OUString& _rAllowedChars, WinBits nStyle = WB_BORDER)
73             : Edit(_pParent,nStyle)
74             ,OSQLNameChecker(_rAllowedChars)
75         {
76         }
77         OSQLNameEdit(Window* _pParent,const ResId& _rRes,const ::rtl::OUString& _rAllowedChars = ::rtl::OUString())
78             : Edit(_pParent,_rRes)
79             ,OSQLNameChecker(_rAllowedChars)
80         {
81         }
82 
83         // Window overload
84         //  virtual long PreNotify( NotifyEvent& rNEvt );
85         // Edit
86         virtual void Modify();
87     };
88 
89     class OSQLNameComboBox : public ComboBox
90                             ,public OSQLNameChecker
91     {
92     public:
93         OSQLNameComboBox(Window* _pParent,const ::rtl::OUString& _rAllowedChars, WinBits nStyle = WB_BORDER)
94             : ComboBox(_pParent,nStyle)
95             ,OSQLNameChecker(_rAllowedChars)
96         {
97         }
98         OSQLNameComboBox(Window* _pParent,const ResId& _rRes,const ::rtl::OUString& _rAllowedChars = ::rtl::OUString())
99             : ComboBox(_pParent,_rRes)
100             ,OSQLNameChecker(_rAllowedChars)
101         {
102         }
103 
104         // Window overload
105         // Edit
106         virtual void Modify();
107     };
108 
109 }
110 #endif // DBAUI_SQLNAMEEDIT_HXX
111 
112 
113