xref: /AOO41X/main/dbaccess/source/ui/inc/QueryDesignView.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir #ifndef DBAUI_QUERYDESIGNVIEW_HXX
28*cdf0e10cSrcweir #define DBAUI_QUERYDESIGNVIEW_HXX
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir #ifndef DBAUI_QUERYVIEW_HXX
31*cdf0e10cSrcweir #include "queryview.hxx"
32*cdf0e10cSrcweir #endif
33*cdf0e10cSrcweir #ifndef _SV_SPLIT_HXX
34*cdf0e10cSrcweir #include <vcl/split.hxx>
35*cdf0e10cSrcweir #endif
36*cdf0e10cSrcweir #ifndef _STRING_HXX
37*cdf0e10cSrcweir #include <tools/string.hxx>
38*cdf0e10cSrcweir #endif
39*cdf0e10cSrcweir #ifndef DBAUI_ENUMTYPES_HXX
40*cdf0e10cSrcweir #include "QEnumTypes.hxx"
41*cdf0e10cSrcweir #endif
42*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
43*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
44*cdf0e10cSrcweir #endif
45*cdf0e10cSrcweir #ifndef DBAUI_QUERYCONTROLLER_HXX
46*cdf0e10cSrcweir #include "querycontroller.hxx"
47*cdf0e10cSrcweir #endif
48*cdf0e10cSrcweir #ifndef DBAUI_CONNECTIONLINEDATA_HXX
49*cdf0e10cSrcweir #include "ConnectionLineData.hxx"
50*cdf0e10cSrcweir #endif
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir namespace connectivity
53*cdf0e10cSrcweir {
54*cdf0e10cSrcweir     class OSQLParseNode;
55*cdf0e10cSrcweir }
56*cdf0e10cSrcweir 
57*cdf0e10cSrcweir class ComboBox;
58*cdf0e10cSrcweir namespace dbaui
59*cdf0e10cSrcweir {
60*cdf0e10cSrcweir     enum SqlParseError
61*cdf0e10cSrcweir     {
62*cdf0e10cSrcweir         eIllegalJoin,
63*cdf0e10cSrcweir         eStatementTooLong,
64*cdf0e10cSrcweir         eNoConnection,
65*cdf0e10cSrcweir         eNoSelectStatement,
66*cdf0e10cSrcweir         eStatementTooComplex,
67*cdf0e10cSrcweir         eColumnInLikeNotFound,
68*cdf0e10cSrcweir         eNoColumnInLike,
69*cdf0e10cSrcweir         eColumnNotFound,
70*cdf0e10cSrcweir         eNativeMode,
71*cdf0e10cSrcweir         eTooManyTables,
72*cdf0e10cSrcweir         eTooManyConditions,
73*cdf0e10cSrcweir         eTooManyColumns,
74*cdf0e10cSrcweir         eIllegalJoinCondition,
75*cdf0e10cSrcweir         eOk
76*cdf0e10cSrcweir     };
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir     class OQueryViewSwitch;
79*cdf0e10cSrcweir     class OAddTableDlg;
80*cdf0e10cSrcweir     class OQueryTableWindow;
81*cdf0e10cSrcweir     class OSelectionBrowseBox;
82*cdf0e10cSrcweir     class OTableConnection;
83*cdf0e10cSrcweir     class OQueryTableConnectionData;
84*cdf0e10cSrcweir     class OQueryContainerWindow;
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir     class OQueryDesignView : public OQueryView
87*cdf0e10cSrcweir     {
88*cdf0e10cSrcweir         enum ChildFocusState
89*cdf0e10cSrcweir         {
90*cdf0e10cSrcweir             SELECTION,
91*cdf0e10cSrcweir             TABLEVIEW,
92*cdf0e10cSrcweir             NONE
93*cdf0e10cSrcweir         };
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir         Splitter                            m_aSplitter;
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir         ::com::sun::star::lang::Locale      m_aLocale;
98*cdf0e10cSrcweir         ::rtl::OUString                     m_sDecimalSep;
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir         OSelectionBrowseBox*                m_pSelectionBox;    // presents the lower window
101*cdf0e10cSrcweir         ChildFocusState                     m_eChildFocus;
102*cdf0e10cSrcweir         sal_Bool                            m_bInKeyEvent;
103*cdf0e10cSrcweir         sal_Bool                            m_bInSplitHandler;
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir     public:
106*cdf0e10cSrcweir         OQueryDesignView(OQueryContainerWindow* pParent, OQueryController& _rController,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& );
107*cdf0e10cSrcweir         virtual ~OQueryDesignView();
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir         virtual sal_Bool isCutAllowed();
110*cdf0e10cSrcweir         virtual sal_Bool isPasteAllowed();
111*cdf0e10cSrcweir         virtual sal_Bool isCopyAllowed();
112*cdf0e10cSrcweir         virtual void copy();
113*cdf0e10cSrcweir         virtual void cut();
114*cdf0e10cSrcweir         virtual void paste();
115*cdf0e10cSrcweir         // clears the whole query
116*cdf0e10cSrcweir         virtual void clear();
117*cdf0e10cSrcweir         // set the view readonly or not
118*cdf0e10cSrcweir         virtual void setReadOnly(sal_Bool _bReadOnly);
119*cdf0e10cSrcweir         // check if the statement is correct when not returning false
120*cdf0e10cSrcweir         virtual sal_Bool checkStatement();
121*cdf0e10cSrcweir         // set the statement for representation
122*cdf0e10cSrcweir         virtual void setStatement(const ::rtl::OUString& _rsStatement);
123*cdf0e10cSrcweir         // returns the current sql statement
124*cdf0e10cSrcweir         virtual ::rtl::OUString getStatement();
125*cdf0e10cSrcweir         /// late construction
126*cdf0e10cSrcweir         virtual void Construct();
127*cdf0e10cSrcweir         virtual void initialize();
128*cdf0e10cSrcweir         // window overloads
129*cdf0e10cSrcweir         virtual long PreNotify( NotifyEvent& rNEvt );
130*cdf0e10cSrcweir         virtual void GetFocus();
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir         sal_Bool isSlotEnabled(sal_Int32 _nSlotId);
133*cdf0e10cSrcweir         void setSlotEnabled(sal_Int32 _nSlotId,sal_Bool _bEnable);
134*cdf0e10cSrcweir         void setNoneVisbleRow(sal_Int32 _nRows);
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir         ::com::sun::star::lang::Locale      getLocale() const           { return m_aLocale;}
137*cdf0e10cSrcweir         ::rtl::OUString                     getDecimalSeparator() const { return m_sDecimalSep;}
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir         SqlParseError   InsertField( const OTableFieldDescRef& rInfo, sal_Bool bVis=sal_True, sal_Bool bActivate = sal_True);
140*cdf0e10cSrcweir         bool            HasFieldByAliasName(const ::rtl::OUString& rFieldName, OTableFieldDescRef& rInfo) const;
141*cdf0e10cSrcweir         // save the position of the table window and the pos of the splitters
142*cdf0e10cSrcweir         // called when fields are deleted
143*cdf0e10cSrcweir         void DeleteFields( const ::rtl::OUString& rAliasName );
144*cdf0e10cSrcweir         // called when a table from tabeview was deleted
145*cdf0e10cSrcweir         void TableDeleted(const ::rtl::OUString& rAliasName);
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir         sal_Int32 getColWidth( sal_uInt16 _nColPos) const;
148*cdf0e10cSrcweir         void fillValidFields(const ::rtl::OUString& strTableName, ComboBox* pFieldList);
149*cdf0e10cSrcweir 
150*cdf0e10cSrcweir         void SaveUIConfig();
151*cdf0e10cSrcweir         void stopTimer();
152*cdf0e10cSrcweir         void startTimer();
153*cdf0e10cSrcweir         void reset();
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir         /** initializes the view from the current parser / parse iterator of the controller
156*cdf0e10cSrcweir 
157*cdf0e10cSrcweir             @param _pErrorInfo
158*cdf0e10cSrcweir                 When not <NULL/>, the instance pointed to by this parameter takes the error
159*cdf0e10cSrcweir                 which happened during the initialization.
160*cdf0e10cSrcweir                 If it is not <NULL/>, then any such error will be displayed, using the controller's
161*cdf0e10cSrcweir                 showError method.
162*cdf0e10cSrcweir 
163*cdf0e10cSrcweir             @return <TRUE/> if and only if the initialization was successful
164*cdf0e10cSrcweir         */
165*cdf0e10cSrcweir         bool    initByParseIterator( ::dbtools::SQLExceptionInfo* _pErrorInfo );
166*cdf0e10cSrcweir 
167*cdf0e10cSrcweir         void    initByFieldDescriptions(
168*cdf0e10cSrcweir                     const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& i_rFieldDescriptions
169*cdf0e10cSrcweir                 );
170*cdf0e10cSrcweir 
171*cdf0e10cSrcweir         ::connectivity::OSQLParseNode* getPredicateTreeFromEntry(   OTableFieldDescRef pEntry,
172*cdf0e10cSrcweir                                                                     const String& _sCriteria,
173*cdf0e10cSrcweir                                                                     ::rtl::OUString& _rsErrorMessage,
174*cdf0e10cSrcweir                                                                     ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxColumn) const;
175*cdf0e10cSrcweir 
176*cdf0e10cSrcweir         void fillFunctionInfo(   const ::connectivity::OSQLParseNode* pNode
177*cdf0e10cSrcweir                                 ,const ::rtl::OUString& sFunctionTerm
178*cdf0e10cSrcweir                                 ,OTableFieldDescRef& aInfo);
179*cdf0e10cSrcweir     protected:
180*cdf0e10cSrcweir         // return the Rectangle where I can paint myself
181*cdf0e10cSrcweir         virtual void resizeDocumentView(Rectangle& rRect);
182*cdf0e10cSrcweir         DECL_LINK( SplitHdl, void* );
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir     private:
185*cdf0e10cSrcweir         using OQueryView::SaveTabWinUIConfig;
186*cdf0e10cSrcweir     };
187*cdf0e10cSrcweir }
188*cdf0e10cSrcweir #endif // DBAUI_QUERYDESIGNVIEW_HXX
189*cdf0e10cSrcweir 
190