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_QUERYVIEWSWITCH_HXX
24 #define DBAUI_QUERYVIEWSWITCH_HXX
25 
26 #include "queryview.hxx"
27 
28 namespace dbtools
29 {
30     class SQLExceptionInfo;
31 }
32 
33 namespace dbaui
34 {
35 	class OQueryDesignView;
36 	class OQueryTextView;
37 	class OAddTableDlg;
38 	class OQueryContainerWindow;
39 	class OQueryViewSwitch
40 	{
41 		OQueryDesignView*	m_pDesignView;
42 		OQueryTextView*		m_pTextView;
43 		sal_Bool			m_bAddTableDialogWasVisible; // true if so
44 	public:
45 		OQueryViewSwitch(OQueryContainerWindow* pParent, OQueryController& _rController,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& );
46 		virtual ~OQueryViewSwitch();
47 
48 		virtual sal_Bool isCutAllowed();
49 		virtual sal_Bool isPasteAllowed();
50 		virtual sal_Bool isCopyAllowed();
51 		virtual void copy();
52 		virtual void cut();
53 		virtual void paste();
54 		// clears the whole query
55 		virtual void clear();
56 		// set the view readonly or not
57 		virtual void setReadOnly(sal_Bool _bReadOnly);
58 		// check if the statement is correct when not returning false
59 		virtual sal_Bool checkStatement();
60 		// set the statement for representation
61 		virtual void setStatement(const ::rtl::OUString& _rsStatement);
62 		// returns the current sql statement
63 		virtual ::rtl::OUString getStatement();
64 		/// late construction
65 		virtual void Construct();
66 		virtual void initialize();
67 		/** show the text or the design view
68 			@return
69 				<TRUE/> if and only if the view could be successfully, switched, <FALSE/> otherwise
70                 (In the latter case, the controller will issue another switchView call to restore the
71                 old state)
72 		*/
73 		bool     switchView( ::dbtools::SQLExceptionInfo* _pErrorInfo );
74         void     forceInitialView();
75 		sal_Bool isSlotEnabled(sal_Int32 _nSlotId);
76 		void	 setSlotEnabled(sal_Int32 _nSlotId,sal_Bool _bEnable);
77 		void	 setNoneVisbleRow(sal_Int32 _nRows);
78 		void     SaveUIConfig();
79 		bool     reset( ::dbtools::SQLExceptionInfo* _pErrorInfo );
80 		void     GrabFocus();
81 
82         // returs the add table dialog from the design view
83 		OAddTableDlg* getAddTableDialog();
84 
getDesignView() const85 		OQueryDesignView*		getDesignView() const { return m_pDesignView; }
86 		OQueryContainerWindow*	getContainer() const;
87 
88 		void SetPosSizePixel( Point _rPt,Size _rSize);
89 		::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > getORB() const;
90 	protected:
91 		// return the Rectangle where I can paint myself
92 		virtual void resizeDocumentView(Rectangle& rRect);
93 
94     private:
95         void    impl_forceSQLView();
96         bool    impl_postViewSwitch( const bool i_bGraphicalDesign, const bool i_bSuccess );
97 	};
98 }
99 #endif // DBAUI_QUERYVIEWSWITCH_HXX
100 
101