LibreOffice Module dbaccess (master) 1
querycontroller.hxx
Go to the documentation of this file.
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
20#pragma once
21
22#include "JoinController.hxx"
24#include <svx/ParseContext.hxx>
26
27#include <com/sun/star/sdb/CommandType.hpp>
28#include <com/sun/star/sdb/XSQLQueryComposer.hpp>
29#include <com/sun/star/sdbcx/XAlterView.hpp>
30
33#include <comphelper/uno3.hxx>
36
37namespace comphelper
38{
39 class NamedValueCollection;
40}
41
42namespace dbaui
43{
44 class OQueryContainerWindow;
45
47 typedef ::comphelper::OPropertyArrayUsageHelper< OQueryController > OQueryController_PABase;
51 {
53 OTableFields m_vUnUsedFieldsDesc; // contains fields which aren't visible and don't have any criteria
54
55 css::uno::Sequence< css::beans::PropertyValue > m_aFieldInformation;
56
57 std::unique_ptr<::svxform::OSystemParseContext> m_pParseContext;
59 std::unique_ptr<::connectivity::OSQLParseTreeIterator> m_pSqlIterator;
60
61 css::uno::Reference< css::sdb::XSQLQueryComposer > m_xComposer;
63 css::uno::Reference< css::sdbcx::XAlterView > m_xAlterView;
64
65 OUString m_sStatement; // contains the current sql statement
66 OUString m_sUpdateCatalogName; // catalog for update data
67 OUString m_sUpdateSchemaName; // schema for update data
68 mutable OUString
69 m_sName; // name of the query
70
71 sal_Int64 m_nLimit; // the limit of the query result (All==-1)
72
73 sal_Int32 m_nVisibleRows; // which rows the selection browse should show
74 sal_Int32 m_nSplitPos; // the position of the splitter
75 sal_Int32 m_nCommandType; // the type of the object we're designing
76 bool m_bGraphicalDesign; // are we in the graphical design mode (sal_True) or in the text design (sal_False)?
77 bool m_bDistinct; // true when you want "select distinct" otherwise false
78 bool m_bEscapeProcessing;// is true when we shouldn't parse the statement
79
80
86 css::uno::Reference< css::container::XNameAccess >
87 getObjectContainer() const;
88
91 bool editingCommand() const { return m_nCommandType == css::sdb::CommandType::COMMAND; }
92
93 bool askForNewName( const css::uno::Reference< css::container::XNameAccess>& _xElements,
94 bool _bSaveAs);
95 // creates the querycomposer
96 void setQueryComposer();
97 void deleteIterator();
98 void executeQuery();
99 bool doSaveAsDoc(bool _bSaveAs);
100
101 void saveViewSettings( ::comphelper::NamedValueCollection& o_rViewSettings, const bool i_includingCriteria ) const;
102 void loadViewSettings( const ::comphelper::NamedValueCollection& o_rViewSettings );
103 OUString translateStatement( bool _bFireStatementChange = true );
104
106
107 protected:
108 // all the features which should be handled by this class
109 virtual void describeSupportedFeatures() override;
110 // state of a feature. 'feature' may be the handle of a css::util::URL somebody requested a dispatch interface for OR a toolbar slot.
111 virtual FeatureState GetState(sal_uInt16 nId) const override;
112 // execute a feature
113 virtual void Execute(sal_uInt16 nId, const css::uno::Sequence< css::beans::PropertyValue>& aArgs) override;
114
115 virtual void reconnect( bool _bUI ) override;
116 virtual OUString getPrivateTitle( ) const override;
117
118 OQueryContainerWindow* getContainer() const { return static_cast< OQueryContainerWindow* >( getView() ); }
119
120 public:
121 OQueryController(const css::uno::Reference< css::uno::XComponentContext >& _rM);
122
123 virtual ~OQueryController() override;
126
127 void clearFields();
128
129 virtual void impl_onModifyChanged() override;
130
131 // should the statement be parsed by our own sql parser
133 bool isGraphicalDesign() const { return m_bGraphicalDesign; }
134 bool isDistinct() const { return m_bDistinct; }
135 sal_Int64 getLimit() const { return m_nLimit; }
136
137 const OUString& getStatement() const { return m_sStatement; }
138 sal_Int32 getSplitPos() const { return m_nSplitPos;}
139 sal_Int32 getVisibleRows() const { return m_nVisibleRows; }
140
141 void setDistinct(bool _bDistinct) { m_bDistinct = _bDistinct;}
142 void setLimit(const sal_Int64 _nLimit) { m_nLimit = _nLimit;}
143 void setSplitPos(sal_Int32 _nSplitPos) { m_nSplitPos = _nSplitPos;}
144 void setVisibleRows(sal_Int32 _nVisibleRows) { m_nVisibleRows = _nVisibleRows;}
145
146 sal_Int32 getColWidth(sal_uInt16 _nColPos) const;
147
148 const css::uno::Sequence< css::beans::PropertyValue >&
150
153
154 virtual bool Construct(vcl::Window* pParent) override;
155
157 DECLARE_XTYPEPROVIDER( )
158 // XPropertySet
159 virtual css::uno::Reference<css::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() override;
160 virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override;
161
162 // XEventListener
163 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
164
165 // css::lang::XComponent
166 virtual void SAL_CALL disposing() override;
167
168 virtual OUString SAL_CALL getImplementationName() override;
169 virtual css::uno::Sequence< OUString> SAL_CALL getSupportedServiceNames() override;
170
171 // XController
172 virtual css::uno::Any SAL_CALL getViewData() override;
173 virtual void SAL_CALL restoreViewData(const css::uno::Any& Data) override;
174
175 private:
176 virtual void onLoadedMenu(const css::uno::Reference< css::frame::XLayoutManager >& _xLayoutManager) override;
177 // OPropertyArrayUsageHelper
178 virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const override;
179
180 // OPropertySetHelper
181 virtual void SAL_CALL getFastPropertyValue(
182 css::uno::Any& rValue,
183 sal_Int32 nHandle
184 ) const override;
185
186 virtual OJoinDesignView* getJoinView() override;
187 // ask the user if the design should be saved when it is modified
188 virtual short saveModified() override;
189 virtual void reset() override;
190 virtual void impl_initialize() override;
191
192 void impl_reset( const bool i_bIgnoreQuerySettings = false );
194 void impl_showAutoSQLViewError( const css::uno::Any& _rErrorDetails );
195
198 void impl_setViewMode( ::dbtools::SQLExceptionInfo* _pErrorInfo );
199
201 void setStatement_fireEvent( const OUString& _rNewStatement, bool _bFireStatementChange = true );
203 void setEscapeProcessing_fireEvent( const bool _bEscapeProcessing );
204
205 // OJoinController overridables
206 virtual bool allowViews() const override;
207 virtual bool allowQueries() const override;
208
209 private:
210 DECL_LINK( OnExecuteAddTable, void*, void );
211
212 private:
214 };
215}
216
217/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::container::XNameAccess > getObjectContainer() const
returns the container of queries, views, or command definitions, depending on what object type we des...
virtual OUString getPrivateTitle() const override
virtual FeatureState GetState(sal_uInt16 nId) const override
virtual bool allowQueries() const override
determines whether or not it's allowed for queries to participate in the game
virtual void SAL_CALL restoreViewData(const css::uno::Any &Data) override
OUString translateStatement(bool _bFireStatementChange=true)
virtual bool allowViews() const override
determines whether or not it's allowed for database views to participate in the game
virtual void onLoadedMenu(const css::uno::Reference< css::frame::XLayoutManager > &_xLayoutManager) override
void impl_setViewMode(::dbtools::SQLExceptionInfo *_pErrorInfo)
switches to the graphical or SQL view mode, as determined by m_bGraphicalDesign
void setVisibleRows(sal_Int32 _nVisibleRows)
::connectivity::OSQLParser m_aSqlParser
virtual short saveModified() override
virtual void impl_initialize() override
css::uno::Sequence< css::beans::PropertyValue > m_aFieldInformation
sal_Int32 getVisibleRows() const
OTableFields & getUnUsedFields()
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
virtual bool Construct(vcl::Window *pParent) override
virtual OUString SAL_CALL getImplementationName() override
std::unique_ptr<::svxform::OSystemParseContext > m_pParseContext
void setEscapeProcessing_fireEvent(const bool _bEscapeProcessing)
sets the m_bEscapeProcessing member, and notifies our respective property change listeners
void setLimit(const sal_Int64 _nLimit)
::connectivity::OSQLParser & getParser()
const css::uno::Sequence< css::beans::PropertyValue > & getFieldInformation() const
const OUString & getStatement() const
bool askForNewName(const css::uno::Reference< css::container::XNameAccess > &_xElements, bool _bSaveAs)
OQueryContainerWindow * getContainer() const
virtual ~OQueryController() override
void setDistinct(bool _bDistinct)
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
void saveViewSettings(::comphelper::NamedValueCollection &o_rViewSettings, const bool i_includingCriteria) const
void impl_reset(const bool i_bIgnoreQuerySettings=false)
std::unique_ptr<::connectivity::OSQLParseTreeIterator > m_pSqlIterator
virtual OJoinDesignView * getJoinView() override
provides access to the OJoinDesignView belonging to the controller, which might or might not be the d...
OTableFields & getTableFieldDesc()
void loadViewSettings(const ::comphelper::NamedValueCollection &o_rViewSettings)
css::uno::Reference< css::sdb::XSQLQueryComposer > m_xComposer
virtual void impl_onModifyChanged() override
bool doSaveAsDoc(bool _bSaveAs)
virtual void describeSupportedFeatures() override
void setSplitPos(sal_Int32 _nSplitPos)
virtual css::uno::Any SAL_CALL getViewData() override
virtual void SAL_CALL getFastPropertyValue(css::uno::Any &rValue, sal_Int32 nHandle) const override
sal_Int32 getColWidth(sal_uInt16 _nColPos) const
virtual void reset() override
OTableFields m_vUnUsedFieldsDesc
sal_Int64 getLimit() const
DECL_LINK(OnExecuteAddTable, void *, void)
void impl_showAutoSQLViewError(const css::uno::Any &_rErrorDetails)
tells the user that we needed to switch to SQL view automatically
sal_Int32 getSplitPos() const
virtual ::cppu::IPropertyArrayHelper * createArrayHelper() const override
virtual void reconnect(bool _bUI) override
virtual void Execute(sal_uInt16 nId, const css::uno::Sequence< css::beans::PropertyValue > &aArgs) override
OQueryController(const css::uno::Reference< css::uno::XComponentContext > &_rM)
css::uno::Reference< css::sdbcx::XAlterView > m_xAlterView
if we're editing an existing view, this is non-NULL
void setStatement_fireEvent(const OUString &_rNewStatement, bool _bFireStatementChange=true)
sets m_sStatement, and notifies our respective property change listeners
virtual void SAL_CALL disposing() override
virtual ::cppu::IPropertyArrayHelper &SAL_CALL getInfoHelper() override
::connectivity::OSQLParseTreeIterator & getParseIterator()
::comphelper::OPropertyArrayUsageHelper< OQueryController > OQueryController_PABase
::comphelper::OPropertyContainer OQueryController_PBase
std::vector< OTableFieldDescRef > OTableFields
SwView * getView(const uno::Reference< frame::XModel > &xModel)
describes the state of a feature
#define DECLARE_XINTERFACE()