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