1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef DBAUI_SQLNAMEEDIT_HXX
24 #define DBAUI_SQLNAMEEDIT_HXX
25 
26 #ifndef _SV_EDIT_HXX
27 #include <vcl/edit.hxx>
28 #endif
29 #ifndef _SV_COMBOBOX_HXX
30 #include <vcl/combobox.hxx>
31 #endif
32 
33 namespace dbaui
34 {
35 	class OSQLNameChecker
36 	{
37 		::rtl::OUString m_sAllowedChars;
38 		sal_Bool		m_bOnlyUpperCase;
39 		sal_Bool		m_bCheck;			// true when we should check for invalid chars
40 	public:
OSQLNameChecker(const::rtl::OUString & _rAllowedChars)41 		OSQLNameChecker(const ::rtl::OUString& _rAllowedChars)
42 			:m_sAllowedChars(_rAllowedChars)
43 			,m_bOnlyUpperCase(sal_False)
44 			,m_bCheck(sal_True)
45 		{
46 		}
47 
setUpperCase(sal_Bool _bUpper=sal_True)48 		void setUpperCase(sal_Bool _bUpper=sal_True)
49 		{
50 			m_bOnlyUpperCase = _bUpper;
51 		}
setAllowedChars(const::rtl::OUString & _rAllowedChars)52 		void setAllowedChars(const ::rtl::OUString& _rAllowedChars)
53 		{
54 			m_sAllowedChars = _rAllowedChars;
55 		}
56 		// default is false because it is initialized with true
setCheck(sal_Bool _bCheck=sal_False)57 		void setCheck(sal_Bool _bCheck = sal_False)
58 		{
59 			m_bCheck = _bCheck;
60 		}
61 		sal_Bool checkString(const ::rtl::OUString& _sOldValue,const ::rtl::OUString& _sToCheck,::rtl::OUString& _rsCorrected);
62 	};
63 	//==================================================================
64 	class OSQLNameEdit : public Edit
65 						,public OSQLNameChecker
66 	{
67 	public:
OSQLNameEdit(Window * _pParent,const::rtl::OUString & _rAllowedChars,WinBits nStyle=WB_BORDER)68 		OSQLNameEdit(Window* _pParent,const ::rtl::OUString& _rAllowedChars, WinBits nStyle = WB_BORDER)
69 			: Edit(_pParent,nStyle)
70 			,OSQLNameChecker(_rAllowedChars)
71 		{
72 		}
OSQLNameEdit(Window * _pParent,const ResId & _rRes,const::rtl::OUString & _rAllowedChars=::rtl::OUString ())73 		OSQLNameEdit(Window* _pParent,const ResId& _rRes,const ::rtl::OUString& _rAllowedChars = ::rtl::OUString())
74 			: Edit(_pParent,_rRes)
75 			,OSQLNameChecker(_rAllowedChars)
76 		{
77 		}
78 
79 		// Window overload
80 		//	virtual long PreNotify( NotifyEvent& rNEvt );
81 		// Edit
82 		virtual void Modify();
83 	};
84 
85 	class OSQLNameComboBox : public ComboBox
86 							,public OSQLNameChecker
87 	{
88 	public:
OSQLNameComboBox(Window * _pParent,const::rtl::OUString & _rAllowedChars,WinBits nStyle=WB_BORDER)89 		OSQLNameComboBox(Window* _pParent,const ::rtl::OUString& _rAllowedChars, WinBits nStyle = WB_BORDER)
90 			: ComboBox(_pParent,nStyle)
91 			,OSQLNameChecker(_rAllowedChars)
92 		{
93 		}
OSQLNameComboBox(Window * _pParent,const ResId & _rRes,const::rtl::OUString & _rAllowedChars=::rtl::OUString ())94 		OSQLNameComboBox(Window* _pParent,const ResId& _rRes,const ::rtl::OUString& _rAllowedChars = ::rtl::OUString())
95 			: ComboBox(_pParent,_rRes)
96 			,OSQLNameChecker(_rAllowedChars)
97 		{
98 		}
99 
100 		// Window overload
101 		// Edit
102 		virtual void Modify();
103 	};
104 
105 }
106 #endif // DBAUI_SQLNAMEEDIT_HXX
107 
108 
109