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