xref: /trunk/main/dbaccess/source/ui/inc/QueryDesignView.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_QUERYDESIGNVIEW_HXX
28 #define DBAUI_QUERYDESIGNVIEW_HXX
29 
30 #ifndef DBAUI_QUERYVIEW_HXX
31 #include "queryview.hxx"
32 #endif
33 #ifndef _SV_SPLIT_HXX
34 #include <vcl/split.hxx>
35 #endif
36 #ifndef _STRING_HXX
37 #include <tools/string.hxx>
38 #endif
39 #ifndef DBAUI_ENUMTYPES_HXX
40 #include "QEnumTypes.hxx"
41 #endif
42 #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
43 #include <com/sun/star/beans/XPropertySet.hpp>
44 #endif
45 #ifndef DBAUI_QUERYCONTROLLER_HXX
46 #include "querycontroller.hxx"
47 #endif
48 #ifndef DBAUI_CONNECTIONLINEDATA_HXX
49 #include "ConnectionLineData.hxx"
50 #endif
51 
52 namespace connectivity
53 {
54     class OSQLParseNode;
55 }
56 
57 class ComboBox;
58 namespace dbaui
59 {
60     enum SqlParseError
61     {
62         eIllegalJoin,
63         eStatementTooLong,
64         eNoConnection,
65         eNoSelectStatement,
66         eStatementTooComplex,
67         eColumnInLikeNotFound,
68         eNoColumnInLike,
69         eColumnNotFound,
70         eNativeMode,
71         eTooManyTables,
72         eTooManyConditions,
73         eTooManyColumns,
74         eIllegalJoinCondition,
75         eOk
76     };
77 
78     class OQueryViewSwitch;
79     class OAddTableDlg;
80     class OQueryTableWindow;
81     class OSelectionBrowseBox;
82     class OTableConnection;
83     class OQueryTableConnectionData;
84     class OQueryContainerWindow;
85 
86     class OQueryDesignView : public OQueryView
87     {
88         enum ChildFocusState
89         {
90             SELECTION,
91             TABLEVIEW,
92             NONE
93         };
94 
95         Splitter                            m_aSplitter;
96 
97         ::com::sun::star::lang::Locale      m_aLocale;
98         ::rtl::OUString                     m_sDecimalSep;
99 
100         OSelectionBrowseBox*                m_pSelectionBox;    // presents the lower window
101         ChildFocusState                     m_eChildFocus;
102         sal_Bool                            m_bInKeyEvent;
103         sal_Bool                            m_bInSplitHandler;
104 
105     public:
106         OQueryDesignView(OQueryContainerWindow* pParent, OQueryController& _rController,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& );
107         virtual ~OQueryDesignView();
108 
109         virtual sal_Bool isCutAllowed();
110         virtual sal_Bool isPasteAllowed();
111         virtual sal_Bool isCopyAllowed();
112         virtual void copy();
113         virtual void cut();
114         virtual void paste();
115         // clears the whole query
116         virtual void clear();
117         // set the view readonly or not
118         virtual void setReadOnly(sal_Bool _bReadOnly);
119         // check if the statement is correct when not returning false
120         virtual sal_Bool checkStatement();
121         // set the statement for representation
122         virtual void setStatement(const ::rtl::OUString& _rsStatement);
123         // returns the current sql statement
124         virtual ::rtl::OUString getStatement();
125         /// late construction
126         virtual void Construct();
127         virtual void initialize();
128         // window overloads
129         virtual long PreNotify( NotifyEvent& rNEvt );
130         virtual void GetFocus();
131 
132         sal_Bool isSlotEnabled(sal_Int32 _nSlotId);
133         void setSlotEnabled(sal_Int32 _nSlotId,sal_Bool _bEnable);
134         void setNoneVisbleRow(sal_Int32 _nRows);
135 
136         ::com::sun::star::lang::Locale      getLocale() const           { return m_aLocale;}
137         ::rtl::OUString                     getDecimalSeparator() const { return m_sDecimalSep;}
138 
139         SqlParseError   InsertField( const OTableFieldDescRef& rInfo, sal_Bool bVis=sal_True, sal_Bool bActivate = sal_True);
140         bool            HasFieldByAliasName(const ::rtl::OUString& rFieldName, OTableFieldDescRef& rInfo) const;
141         // save the position of the table window and the pos of the splitters
142         // called when fields are deleted
143         void DeleteFields( const ::rtl::OUString& rAliasName );
144         // called when a table from tabeview was deleted
145         void TableDeleted(const ::rtl::OUString& rAliasName);
146 
147         sal_Int32 getColWidth( sal_uInt16 _nColPos) const;
148         void fillValidFields(const ::rtl::OUString& strTableName, ComboBox* pFieldList);
149 
150         void SaveUIConfig();
151         void stopTimer();
152         void startTimer();
153         void reset();
154 
155         /** initializes the view from the current parser / parse iterator of the controller
156 
157             @param _pErrorInfo
158                 When not <NULL/>, the instance pointed to by this parameter takes the error
159                 which happened during the initialization.
160                 If it is not <NULL/>, then any such error will be displayed, using the controller's
161                 showError method.
162 
163             @return <TRUE/> if and only if the initialization was successful
164         */
165         bool    initByParseIterator( ::dbtools::SQLExceptionInfo* _pErrorInfo );
166 
167         void    initByFieldDescriptions(
168                     const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& i_rFieldDescriptions
169                 );
170 
171         ::connectivity::OSQLParseNode* getPredicateTreeFromEntry(   OTableFieldDescRef pEntry,
172                                                                     const String& _sCriteria,
173                                                                     ::rtl::OUString& _rsErrorMessage,
174                                                                     ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxColumn) const;
175 
176         void fillFunctionInfo(   const ::connectivity::OSQLParseNode* pNode
177                                 ,const ::rtl::OUString& sFunctionTerm
178                                 ,OTableFieldDescRef& aInfo);
179     protected:
180         // return the Rectangle where I can paint myself
181         virtual void resizeDocumentView(Rectangle& rRect);
182         DECL_LINK( SplitHdl, void* );
183 
184     private:
185         using OQueryView::SaveTabWinUIConfig;
186     };
187 }
188 #endif // DBAUI_QUERYDESIGNVIEW_HXX
189 
190