Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 : #ifndef DBAUI_QUERYDESIGNVIEW_HXX
20 : #define DBAUI_QUERYDESIGNVIEW_HXX
21 :
22 : #include "queryview.hxx"
23 : #include <vcl/split.hxx>
24 : #include <tools/string.hxx>
25 : #include "QEnumTypes.hxx"
26 : #include <com/sun/star/beans/XPropertySet.hpp>
27 : #include "querycontroller.hxx"
28 : #include "ConnectionLineData.hxx"
29 :
30 : namespace connectivity
31 : {
32 : class OSQLParseNode;
33 : }
34 :
35 : class ComboBox;
36 : namespace dbaui
37 : {
38 : enum SqlParseError
39 : {
40 : eIllegalJoin,
41 : eStatementTooLong,
42 : eNoConnection,
43 : eNoSelectStatement,
44 : eStatementTooComplex,
45 : eColumnInLikeNotFound,
46 : eNoColumnInLike,
47 : eColumnNotFound,
48 : eNativeMode,
49 : eTooManyTables,
50 : eTooManyConditions,
51 : eTooManyColumns,
52 : eIllegalJoinCondition,
53 : eOk
54 : };
55 :
56 : class OSelectionBrowseBox;
57 : class OQueryContainerWindow;
58 :
59 : class OQueryDesignView : public OQueryView
60 : {
61 : enum ChildFocusState
62 : {
63 : SELECTION,
64 : TABLEVIEW,
65 : NONE
66 : };
67 :
68 : Splitter m_aSplitter;
69 :
70 : ::com::sun::star::lang::Locale m_aLocale;
71 : ::rtl::OUString m_sDecimalSep;
72 :
73 : OSelectionBrowseBox* m_pSelectionBox; // presents the lower window
74 : ChildFocusState m_eChildFocus;
75 : sal_Bool m_bInSplitHandler;
76 :
77 : public:
78 : OQueryDesignView(OQueryContainerWindow* pParent, OQueryController& _rController,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& );
79 : virtual ~OQueryDesignView();
80 :
81 : virtual sal_Bool isCutAllowed();
82 : virtual sal_Bool isPasteAllowed();
83 : virtual sal_Bool isCopyAllowed();
84 : virtual void copy();
85 : virtual void cut();
86 : virtual void paste();
87 : // clears the whole query
88 : virtual void clear();
89 : // set the view readonly or not
90 : virtual void setReadOnly(sal_Bool _bReadOnly);
91 : // check if the statement is correct when not returning false
92 : virtual sal_Bool checkStatement();
93 : // set the statement for representation
94 : virtual void setStatement(const ::rtl::OUString& _rsStatement);
95 : // returns the current sql statement
96 : virtual ::rtl::OUString getStatement();
97 : /// late construction
98 : virtual void Construct();
99 : virtual void initialize();
100 : // window overloads
101 : virtual long PreNotify( NotifyEvent& rNEvt );
102 : virtual void GetFocus();
103 :
104 : sal_Bool isSlotEnabled(sal_Int32 _nSlotId);
105 : void setSlotEnabled(sal_Int32 _nSlotId,sal_Bool _bEnable);
106 : void setNoneVisbleRow(sal_Int32 _nRows);
107 :
108 0 : ::com::sun::star::lang::Locale getLocale() const { return m_aLocale;}
109 0 : ::rtl::OUString getDecimalSeparator() const { return m_sDecimalSep;}
110 :
111 : SqlParseError InsertField( const OTableFieldDescRef& rInfo, sal_Bool bVis=sal_True, sal_Bool bActivate = sal_True);
112 : bool HasFieldByAliasName(const ::rtl::OUString& rFieldName, OTableFieldDescRef& rInfo) const;
113 : // save the position of the table window and the pos of the splitters
114 : // called when fields are deleted
115 : void DeleteFields( const ::rtl::OUString& rAliasName );
116 : // called when a table from tabeview was deleted
117 : void TableDeleted(const ::rtl::OUString& rAliasName);
118 :
119 : sal_Int32 getColWidth( sal_uInt16 _nColPos) const;
120 : void fillValidFields(const ::rtl::OUString& strTableName, ComboBox* pFieldList);
121 :
122 : void SaveUIConfig();
123 : void stopTimer();
124 : void startTimer();
125 : void reset();
126 :
127 : /** initializes the view from the current parser / parse iterator of the controller
128 :
129 : @param _pErrorInfo
130 : When not <NULL/>, the instance pointed to by this parameter takes the error
131 : which happened during the initialization.
132 : If it is not <NULL/>, then any such error will be displayed, using the controller's
133 : showError method.
134 :
135 : @return <TRUE/> if and only if the initialization was successful
136 : */
137 : bool initByParseIterator( ::dbtools::SQLExceptionInfo* _pErrorInfo );
138 :
139 : void initByFieldDescriptions(
140 : const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& i_rFieldDescriptions
141 : );
142 :
143 : ::connectivity::OSQLParseNode* getPredicateTreeFromEntry( OTableFieldDescRef pEntry,
144 : const String& _sCriteria,
145 : ::rtl::OUString& _rsErrorMessage,
146 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxColumn) const;
147 :
148 : void fillFunctionInfo( const ::connectivity::OSQLParseNode* pNode
149 : ,const ::rtl::OUString& sFunctionTerm
150 : ,OTableFieldDescRef& aInfo);
151 : protected:
152 : // return the Rectangle where I can paint myself
153 : virtual void resizeDocumentView(Rectangle& rRect);
154 : DECL_LINK( SplitHdl, void* );
155 :
156 : private:
157 : using OQueryView::SaveTabWinUIConfig;
158 : };
159 : }
160 : #endif // DBAUI_QUERYDESIGNVIEW_HXX
161 :
162 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|