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