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