summaryrefslogtreecommitdiff
path: root/dbaccess
diff options
context:
space:
mode:
authorZolnai Tamás <zolnaitamas2000@gmail.com>2013-02-04 15:21:33 +0100
committerAndras Timar <atimar@suse.com>2013-02-25 20:04:03 +0000
commit9a471b8cd85d1c08d53ed2675e580ca9466ca433 (patch)
tree2796af7c686d69a186e326446586c74a2ab42723 /dbaccess
parentb57cb5326713da9e926bb2ad5a56dce90ac00a87 (diff)
Database: Add Limit in Query Desing View
Levels of implementation - Add a new toolbar item to ui (designobjectbar.xml) - Make a control for this element( LimitBox: derived from NumericBox) - Make an own controller for this control (LimitBoxController) and register it - Add new feature to the general\central controller (OQueryController) and construct a communication channel between the two controller - Modify the view switching (SQL<->Design) methods to use\set limit value (QueryDesignView.cxx) Conflicts: dbaccess/source/ui/querydesign/QueryDesignView.cxx Change-Id: I0eb09d1d40cfdb9b8a2a57ab8911faca91d5e690 Reviewed-on: https://gerrit.libreoffice.org/1994 Reviewed-by: Andras Timar <atimar@suse.com> Tested-by: Andras Timar <atimar@suse.com>
Diffstat (limited to 'dbaccess')
-rw-r--r--dbaccess/Library_dbu.mk1
-rw-r--r--dbaccess/inc/dbaccess_slotid.hrc1
-rw-r--r--dbaccess/source/ui/inc/dbu_qry.hrc2
-rw-r--r--dbaccess/source/ui/inc/querycontroller.hxx4
-rw-r--r--dbaccess/source/ui/misc/uiservices.cxx2
-rw-r--r--dbaccess/source/ui/querydesign/QueryDesignView.cxx24
-rw-r--r--dbaccess/source/ui/querydesign/limitboxcontroller.cxx298
-rw-r--r--dbaccess/source/ui/querydesign/limitboxcontroller.hxx93
-rw-r--r--dbaccess/source/ui/querydesign/query.src5
-rw-r--r--dbaccess/source/ui/querydesign/querycontroller.cxx40
-rw-r--r--dbaccess/uiconfig/dbquery/toolbar/designobjectbar.xml3
-rw-r--r--dbaccess/util/dbu.component3
12 files changed, 472 insertions, 4 deletions
diff --git a/dbaccess/Library_dbu.mk b/dbaccess/Library_dbu.mk
index 1ca0f82589d9..ef84bfe2bdac 100644
--- a/dbaccess/Library_dbu.mk
+++ b/dbaccess/Library_dbu.mk
@@ -214,6 +214,7 @@ $(eval $(call gb_Library_add_exception_objects,dbu,\
dbaccess/source/ui/querydesign/JoinDesignView \
dbaccess/source/ui/querydesign/JoinExchange \
dbaccess/source/ui/querydesign/JoinTableView \
+ dbaccess/source/ui/querydesign/limitboxcontroller \
dbaccess/source/ui/querydesign/QTableConnection \
dbaccess/source/ui/querydesign/QTableConnectionData \
dbaccess/source/ui/querydesign/QTableWindow \
diff --git a/dbaccess/inc/dbaccess_slotid.hrc b/dbaccess/inc/dbaccess_slotid.hrc
index c3db103a03dc..37a333ebec61 100644
--- a/dbaccess/inc/dbaccess_slotid.hrc
+++ b/dbaccess/inc/dbaccess_slotid.hrc
@@ -83,6 +83,7 @@
#define SID_APP_NEW_FOLDER ( SID_DBACCESS_START + 53 )
#define SID_APP_NEW_FORM ( SID_DBACCESS_START + 54 )
#define SID_DB_APP_PASTE_SPECIAL ( SID_DBACCESS_START + 55 )
+#define SID_QUERY_LIMIT ( SID_DBACCESS_START + 56 )
// status information
#define SID_DB_APP_STATUS_TYPE ( SID_DBACCESS_START + 57 )
diff --git a/dbaccess/source/ui/inc/dbu_qry.hrc b/dbaccess/source/ui/inc/dbu_qry.hrc
index 659254f41d98..1907b0c4576c 100644
--- a/dbaccess/source/ui/inc/dbu_qry.hrc
+++ b/dbaccess/source/ui/inc/dbu_qry.hrc
@@ -42,7 +42,7 @@
#define STR_QUERY_NOTABLE RID_STR_QRY_START + 21
#define STR_QRY_ORDERBY_UNRELATED RID_STR_QRY_START + 22
#define STR_QUERY_HANDLETEXT RID_STR_QRY_START + 23
-// free
+#define STR_QUERY_LIMIT_ALL RID_STR_QRY_START + 24
// free
#define STR_QRY_TOO_MANY_COLUMNS RID_STR_QRY_START + 26
#define STR_SVT_SQL_SYNTAX_ERROR RID_STR_QRY_START + 27
diff --git a/dbaccess/source/ui/inc/querycontroller.hxx b/dbaccess/source/ui/inc/querycontroller.hxx
index 789f9ea57713..0b28bae4af06 100644
--- a/dbaccess/source/ui/inc/querycontroller.hxx
+++ b/dbaccess/source/ui/inc/querycontroller.hxx
@@ -78,6 +78,8 @@ namespace dbaui
mutable ::rtl::OUString
m_sName; // name of the query
+ sal_Int64 m_nLimit; // the limit of the query result (All==-1)
+
sal_Int32 m_nVisibleRows; // which rows the selection browse should show
sal_Int32 m_nSplitPos; // the position of the splitter
sal_Int32 m_nCommandType; // the type of the object we're designing
@@ -143,12 +145,14 @@ namespace dbaui
sal_Bool isEsacpeProcessing() const { return m_bEscapeProcessing; }
sal_Bool isGraphicalDesign() const { return m_bGraphicalDesign; }
sal_Bool isDistinct() const { return m_bDistinct; }
+ sal_Int64 getLimit() const { return m_nLimit; }
::rtl::OUString getStatement() const { return m_sStatement; }
sal_Int32 getSplitPos() const { return m_nSplitPos;}
sal_Int32 getVisibleRows() const { return m_nVisibleRows; }
void setDistinct(sal_Bool _bDistinct) { m_bDistinct = _bDistinct;}
+ void setLimit(const sal_Int64 _nLimit) { m_nLimit = _nLimit;}
void setSplitPos(sal_Int32 _nSplitPos) { m_nSplitPos = _nSplitPos;}
void setVisibleRows(sal_Int32 _nVisibleRows) { m_nVisibleRows = _nVisibleRows;}
diff --git a/dbaccess/source/ui/misc/uiservices.cxx b/dbaccess/source/ui/misc/uiservices.cxx
index 672f97010337..81fe7ba766b4 100644
--- a/dbaccess/source/ui/misc/uiservices.cxx
+++ b/dbaccess/source/ui/misc/uiservices.cxx
@@ -58,6 +58,7 @@ extern "C" void SAL_CALL createRegistryInfo_OToolboxController();
extern "C" void SAL_CALL createRegistryInfo_OStatusbarController();
extern "C" void SAL_CALL createRegistryInfo_CopyTableWizard();
extern "C" void SAL_CALL createRegistryInfo_OTextConnectionSettingsDialog();
+extern "C" void SAL_CALL createRegistryInfo_LimitBoxController();
//***************************************************************************************
extern "C" void SAL_CALL createRegistryInfo_DBU()
@@ -90,6 +91,7 @@ extern "C" void SAL_CALL createRegistryInfo_DBU()
createRegistryInfo_OStatusbarController();
createRegistryInfo_CopyTableWizard();
createRegistryInfo_OTextConnectionSettingsDialog();
+ createRegistryInfo_LimitBoxController();
bInit = sal_True;
}
}
diff --git a/dbaccess/source/ui/querydesign/QueryDesignView.cxx b/dbaccess/source/ui/querydesign/QueryDesignView.cxx
index ab74b23d1901..279dfcce0f0c 100644
--- a/dbaccess/source/ui/querydesign/QueryDesignView.cxx
+++ b/dbaccess/source/ui/querydesign/QueryDesignView.cxx
@@ -2003,7 +2003,7 @@ namespace
}
const OSQLParseNode* pTableExp = pParseTree->getChild(3);
- if ( pTableExp->getChild(6)->count() > 0 || pTableExp->getChild(7)->count() > 0 || pTableExp->getChild(8)->count() > 0)
+ if ( pTableExp->getChild(7)->count() > 0 || pTableExp->getChild(8)->count() > 0)
{
eErrorCode = eStatementTooComplex;
break;
@@ -2101,6 +2101,18 @@ namespace
{
rController.setDistinct(sal_False);
}
+
+ ///check if query has a limit
+ if( pTableExp->getChild(6)->count() >= 2 && pTableExp->getChild(6)->getChild(1) )
+ {
+ rController.setLimit(
+ pTableExp->getChild(6)->getChild(1)->getTokenValue().toInt64() );
+ }
+ else
+ {
+ rController.setLimit(-1);
+ }
+
if ( (eErrorCode = InstallFields(_pView,pParseTree, pTableView->GetTabWinMap())) == eOk )
{
// GetSelectionCriteria must be called before GetHavingCriteria
@@ -2932,7 +2944,7 @@ OUString OQueryDesignView::getStatement()
}
// ----------------- Statement aufbauen ----------------------
OUStringBuffer aSqlCmd(OUString(RTL_CONSTASCII_USTRINGPARAM("SELECT ")));
- if(static_cast<OQueryController&>(getController()).isDistinct())
+ if(rController.isDistinct())
aSqlCmd.append(OUString(RTL_CONSTASCII_USTRINGPARAM(" DISTINCT ")));
aSqlCmd.append(aFieldListStr);
aSqlCmd.append(OUString(RTL_CONSTASCII_USTRINGPARAM(" FROM ")));
@@ -2970,6 +2982,14 @@ OUString OQueryDesignView::getStatement()
m_rController.displayError();
}
+ // --------------------- Limit Clause -------------------
+ {
+ const sal_Int64 nLimit = rController.getLimit();
+ if( nLimit != -1 )
+ {
+ aSqlCmd.append( " LIMIT " + OUString::number(nLimit) );
+ }
+ }
OUString sSQL = aSqlCmd.makeStringAndClear();
if ( xConnection.is() )
diff --git a/dbaccess/source/ui/querydesign/limitboxcontroller.cxx b/dbaccess/source/ui/querydesign/limitboxcontroller.cxx
new file mode 100644
index 000000000000..ba5449e089d9
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/limitboxcontroller.cxx
@@ -0,0 +1,298 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "limitboxcontroller.hxx"
+
+#include <com/sun/star/frame/XDispatchProvider.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+
+#include <vcl/svapp.hxx>
+#include <vcl/window.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <osl/mutex.hxx>
+#include <rtl/ustring.hxx>
+
+#include "dbu_reghelper.hxx"
+#include "dbu_qry.hrc"
+#include "moduledbu.hxx"
+
+#define ALL_STRING ModuleRes(STR_QUERY_LIMIT_ALL).toString()
+#define ALL_INT -1
+
+using namespace ::com::sun::star;
+
+////////////////
+///LimitBox
+////////////////
+
+namespace dbaui
+{
+
+namespace global{
+
+/// Default values
+sal_Int64 aDefLimitAry[] =
+{
+ 5,
+ 10,
+ 20,
+ 50
+};
+
+}
+
+
+LimitBox::LimitBox( Window* pParent, LimitBoxController* pCtrl )
+ : NumericBox( pParent, WinBits( WB_DROPDOWN | WB_VSCROLL) )
+ , m_pControl( pCtrl )
+{
+ SetShowTrailingZeros( sal_False );
+ SetDecimalDigits( 0 );
+ SetMin( -1 );
+ SetMax( 9999 );
+ LoadDefaultLimits();
+
+ Size aSize(
+ CalcMinimumSize().Width() + 20 ,
+ CalcWindowSizePixel(GetEntryCount() + 1) );
+ SetSizePixel(aSize);
+}
+
+LimitBox::~LimitBox()
+{
+}
+
+void LimitBox::Reformat()
+{
+
+ if( GetText() == ALL_STRING )
+ {
+ SetValue( -1 );
+ }
+ ///Reformat only when text is not All
+ else
+ {
+ ///Not allow user to type -1
+ if( GetText() == "-1" )
+ {
+ Undo();
+ }
+ else
+ NumericBox::Reformat();
+ }
+}
+
+void LimitBox::ReformatAll()
+{
+ ///First entry is All, which do not need numeric reformat
+ if ( GetEntryCount() > 0 )
+ {
+ RemoveEntry( 0 );
+ NumericBox::ReformatAll();
+ InsertEntry( ALL_STRING, 0);
+ }
+ else
+ {
+ NumericBox::ReformatAll();
+ }
+}
+
+OUString LimitBox::CreateFieldText( sal_Int64 nValue ) const
+{
+ if( nValue == ALL_INT )
+ return ALL_STRING;
+ else
+ return NumericBox::CreateFieldText( nValue );
+}
+
+long LimitBox::Notify( NotifyEvent& rNEvt )
+{
+ long nReturn = NumericBox::Notify( rNEvt );
+
+ switch ( rNEvt.GetType() )
+ {
+ case EVENT_LOSEFOCUS:
+ {
+ uno::Sequence< beans::PropertyValue > aArgs( 1 );
+ aArgs[0].Name = OUString( "DBLimit.Value" );
+ aArgs[0].Value = uno::makeAny( GetValue() );
+ m_pControl->dispatchCommand( aArgs );
+ break;
+ }
+ case EVENT_KEYINPUT:
+ {
+ const sal_uInt16 nCode = rNEvt.GetKeyEvent()->GetKeyCode().GetCode();
+ if( nCode == KEY_RETURN )
+ {
+ GrabFocusToDocument();
+ }
+ break;
+ }
+ }
+ return nReturn;
+}
+
+///Initialize entries
+void LimitBox::LoadDefaultLimits()
+{
+ SetValue( ALL_INT );
+ InsertEntry( ALL_STRING );
+
+ const unsigned nSize =
+ sizeof(global::aDefLimitAry)/sizeof(global::aDefLimitAry[0]);
+ for( unsigned nIndex = 0; nIndex< nSize; ++nIndex)
+ {
+ InsertValue( global::aDefLimitAry[nIndex] );
+ }
+}
+
+/////////////////////////
+///LimitBoxController
+/////////////////////////
+
+LimitBoxController::LimitBoxController(
+ const uno::Reference< lang::XMultiServiceFactory >& rServiceManager ) :
+ svt::ToolboxController( rServiceManager,
+ uno::Reference< frame::XFrame >(),
+ OUString( ".uno:DBLimit" ) ),
+ m_pLimitBox( NULL )
+{
+}
+
+LimitBoxController::~LimitBoxController()
+{
+}
+
+/// XInterface
+uno::Any SAL_CALL LimitBoxController::queryInterface( const uno::Type& aType )
+throw (uno::RuntimeException)
+{
+ uno::Any a = ToolboxController::queryInterface( aType );
+ if ( a.hasValue() )
+ return a;
+
+ return ::cppu::queryInterface( aType, static_cast< lang::XServiceInfo* >( this ));
+}
+
+void SAL_CALL LimitBoxController::acquire() throw ()
+{
+ ToolboxController::acquire();
+}
+
+void SAL_CALL LimitBoxController::release() throw ()
+{
+ ToolboxController::release();
+}
+
+
+/// XServiceInfo
+IMPLEMENT_SERVICE_INFO1_STATIC(LimitBoxController,"org.libreoffice.comp.dbu.LimitBoxController","com.sun.star.frame.ToolboxController")
+
+/// XComponent
+void SAL_CALL LimitBoxController::dispose()
+throw (uno::RuntimeException)
+{
+ svt::ToolboxController::dispose();
+
+ SolarMutexGuard aSolarMutexGuard;
+ delete m_pLimitBox;
+ m_pLimitBox = 0;
+}
+
+/// XStatusListener
+void SAL_CALL LimitBoxController::statusChanged(
+ const frame::FeatureStateEvent& rEvent )
+throw ( uno::RuntimeException )
+{
+ if ( m_pLimitBox )
+ {
+ SolarMutexGuard aSolarMutexGuard;
+ if ( rEvent.FeatureURL.Path == "DBLimit" )
+ {
+ if ( rEvent.IsEnabled )
+ {
+ m_pLimitBox->Enable();
+ sal_Int64 nLimit;
+ if ( (rEvent.State >>= nLimit) )
+ {
+ m_pLimitBox->SetValue( nLimit );
+ }
+ }
+ else
+ m_pLimitBox->Disable();
+ }
+ }
+}
+
+/// XToolbarController
+void SAL_CALL LimitBoxController::execute( sal_Int16 /*KeyModifier*/ )
+throw (uno::RuntimeException)
+{
+}
+
+void SAL_CALL LimitBoxController::click()
+throw (uno::RuntimeException)
+{
+}
+
+void SAL_CALL LimitBoxController::doubleClick()
+throw (uno::RuntimeException)
+{
+}
+
+uno::Reference< awt::XWindow > SAL_CALL LimitBoxController::createPopupWindow()
+throw (uno::RuntimeException)
+{
+ return uno::Reference< awt::XWindow >();
+}
+
+uno::Reference< awt::XWindow > SAL_CALL LimitBoxController::createItemWindow(
+ const uno::Reference< awt::XWindow >& Parent )
+ throw (uno::RuntimeException)
+{
+ uno::Reference< awt::XWindow > xItemWindow;
+ uno::Reference< awt::XWindow > xParent( Parent );
+
+ Window* pParent = VCLUnoHelper::GetWindow( xParent );
+ if ( pParent )
+ {
+ SolarMutexGuard aSolarMutexGuard;
+ m_pLimitBox = new LimitBox(pParent, this);
+ xItemWindow = VCLUnoHelper::GetInterface( m_pLimitBox );
+ }
+
+ return xItemWindow;
+}
+
+void LimitBoxController::dispatchCommand(
+ const uno::Sequence< beans::PropertyValue >& rArgs )
+{
+ uno::Reference< frame::XDispatchProvider > xDispatchProvider( m_xFrame, uno::UNO_QUERY );
+ if ( xDispatchProvider.is() )
+ {
+ util::URL aURL;
+ uno::Reference< frame::XDispatch > xDispatch;
+ uno::Reference< util::XURLTransformer > xURLTransformer = getURLTransformer();
+
+ aURL.Complete = OUString( ".uno:DBLimit" );
+ xURLTransformer->parseStrict( aURL );
+ xDispatch = xDispatchProvider->queryDispatch( aURL, OUString(), 0 );
+ if ( xDispatch.is() )
+ xDispatch->dispatch( aURL, rArgs );
+ }
+}
+
+} ///dbaui namespace
+
+extern "C" void SAL_CALL createRegistryInfo_LimitBoxController()
+{
+ static ::dbaui::OMultiInstanceAutoRegistration< ::dbaui::LimitBoxController > aAutoRegistration;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/querydesign/limitboxcontroller.hxx b/dbaccess/source/ui/querydesign/limitboxcontroller.hxx
new file mode 100644
index 000000000000..a0e746ea8b22
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/limitboxcontroller.hxx
@@ -0,0 +1,93 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef _LIMITBOXCONTROLLER_HXX_
+#define _LIMITBOXCONTROLLER_HXX_
+
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <svtools/toolboxcontroller.hxx>
+#include <vcl/field.hxx>
+
+#include "apitools.hxx"
+
+namespace dbaui
+{
+
+class LimitBoxController;
+
+/**
+ * Input box to add limit to an SQL query (maximum number of result's rows)
+ * This box is reachable on the Query Design Toolbar
+ */
+class LimitBox: public NumericBox
+{
+ public:
+ LimitBox( Window* pParent, LimitBoxController* pCtrl );
+ virtual ~LimitBox();
+
+ virtual long Notify( NotifyEvent& rNEvt );
+
+ virtual OUString CreateFieldText( sal_Int64 nValue ) const;
+
+ virtual void Reformat();
+ virtual void ReformatAll();
+
+ private:
+ LimitBoxController* m_pControl;
+
+ void LoadDefaultLimits();
+};
+
+
+/**
+ * A ToolboxController to paste LimitBox onto the Query Design Toolbar
+ * It is communicating with querycontroller and this channel make enable
+ * to set\get the value of limitbox when switching between views
+ */
+class LimitBoxController: public svt::ToolboxController,
+ public ::com::sun::star::lang::XServiceInfo
+{
+ public:
+ LimitBoxController(
+ const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rServiceManager );
+ ~LimitBoxController();
+
+ /// XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire() throw ();
+ virtual void SAL_CALL release() throw ();
+
+ /// XServiceInfo
+ DECLARE_SERVICE_INFO_STATIC();
+
+ /// XComponent
+ virtual void SAL_CALL dispose() throw (::com::sun::star::uno::RuntimeException);
+
+ /// XStatusListener
+ virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException );
+
+ /// XToolbarController
+ virtual void SAL_CALL execute( sal_Int16 KeyModifier ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL click() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL doubleClick() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > SAL_CALL createPopupWindow() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > SAL_CALL createItemWindow( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& Parent ) throw (::com::sun::star::uno::RuntimeException);
+
+ void dispatchCommand( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rArgs );
+ using svt::ToolboxController::dispatchCommand;
+
+ private:
+ LimitBox* m_pLimitBox;
+};
+
+} ///dbaui namespace
+
+#endif /// _LIMITBOXCONTROLLER_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/querydesign/query.src b/dbaccess/source/ui/querydesign/query.src
index 575ee1e905b7..89af2adec2b7 100644
--- a/dbaccess/source/ui/querydesign/query.src
+++ b/dbaccess/source/ui/querydesign/query.src
@@ -217,6 +217,11 @@ String STR_QUERY_HANDLETEXT
Text [ en-US ] = "Field;Alias;Table;Sort;Visible;Function;Criterion;Or;Or";
};
+String STR_QUERY_LIMIT_ALL
+{
+ Text [ en-US ] = "All";
+};
+
String STR_QRY_TOO_MANY_COLUMNS
{
Text [ en-US ] = "There are too many columns.";
diff --git a/dbaccess/source/ui/querydesign/querycontroller.cxx b/dbaccess/source/ui/querydesign/querycontroller.cxx
index 31e6d18002bf..a1c3c90c8eb7 100644
--- a/dbaccess/source/ui/querydesign/querycontroller.cxx
+++ b/dbaccess/source/ui/querydesign/querycontroller.cxx
@@ -63,6 +63,7 @@
#include <com/sun/star/util/XCloseable.hpp>
#include <com/sun/star/util/VetoException.hpp>
#include <com/sun/star/frame/XUntitledNumbers.hpp>
+#include <com/sun/star/ui/XUIElement.hpp>
#include <comphelper/basicio.hxx>
#include <comphelper/extract.hxx>
@@ -246,6 +247,7 @@ using namespace ::com::sun::star::container;
using namespace ::com::sun::star::sdbcx;
using namespace ::com::sun::star::sdbc;
using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::ui;
using namespace ::com::sun::star::ui::dialogs;
using namespace ::com::sun::star::awt;
using namespace ::dbtools;
@@ -276,6 +278,27 @@ namespace
xLayoutManager->doLayout();
}
}
+
+ /**
+ * The value of m_nLimit is updated when LimitBox loose its focus
+ * So in those case when execution needs recent data, grab the focus
+ * (e.g. execute SQL statment, change views)
+ */
+ void grabFocusFromLimitBox( OQueryController& _rController )
+ {
+ static const OUString sResourceURL( "private:resource/toolbar/designobjectbar" );
+ Reference< XLayoutManager > xLayoutManager = _rController.getLayoutManager( _rController.getFrame() );
+ Reference< XUIElement > xUIElement = xLayoutManager->getElement(sResourceURL);
+ if (xUIElement.is())
+ {
+ Reference< XWindow > xWindow(xUIElement->getRealInterface(), css::uno::UNO_QUERY);
+ Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
+ if( pWindow || pWindow->HasChildPathFocus() )
+ {
+ pWindow->GrabFocusToDocument();
+ }
+ }
+ }
}
//------------------------------------------------------------------------------
@@ -314,6 +337,7 @@ OQueryController::OQueryController(const Reference< XComponentContext >& _rM)
,m_pParseContext( new svxform::OSystemParseContext )
,m_aSqlParser( _rM, m_pParseContext )
,m_pSqlIterator(NULL)
+ ,m_nLimit(-1)
,m_nVisibleRows(0x400)
,m_nSplitPos(-1)
,m_nCommandType( CommandType::QUERY )
@@ -522,6 +546,11 @@ FeatureState OQueryController::GetState(sal_uInt16 _nId) const
aReturn.bEnabled = m_bGraphicalDesign && isEditable();
aReturn.bChecked = m_bDistinct;
break;
+ case SID_QUERY_LIMIT:
+ aReturn.bEnabled = m_bGraphicalDesign;
+ if( aReturn.bEnabled )
+ aReturn.aValue = makeAny( m_nLimit );
+ break;
case ID_BROWSER_QUERY_EXECUTE:
aReturn.bEnabled = sal_True;
break;
@@ -561,6 +590,7 @@ void OQueryController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue >&
break;
case ID_BROWSER_SAVEASDOC:
case ID_BROWSER_SAVEDOC:
+ grabFocusFromLimitBox(*this);
doSaveAsDoc(ID_BROWSER_SAVEASDOC == _nId);
break;
case SID_RELATION_ADD_RELATION:
@@ -583,6 +613,7 @@ void OQueryController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue >&
break;
case ID_BROWSER_SQL:
{
+ grabFocusFromLimitBox(*this);
if ( !getContainer()->checkStatement() )
break;
SQLExceptionInfo aError;
@@ -689,7 +720,15 @@ void OQueryController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue >&
m_bDistinct = !m_bDistinct;
setModified(sal_True);
break;
+ case SID_QUERY_LIMIT:
+ if ( aArgs.getLength() >= 1 && aArgs[0].Name == "DBLimit.Value" )
+ {
+ aArgs[0].Value >>= m_nLimit;
+ setModified(sal_True);
+ }
+ break;
case ID_BROWSER_QUERY_EXECUTE:
+ grabFocusFromLimitBox(*this);
if ( getContainer()->checkStatement() )
executeQuery();
break;
@@ -1120,6 +1159,7 @@ void OQueryController::describeSupportedFeatures()
implDescribeSupportedFeature( ".uno:SbaExecuteSql", ID_BROWSER_QUERY_EXECUTE, CommandGroup::VIEW );
implDescribeSupportedFeature( ".uno:DBAddRelation", SID_RELATION_ADD_RELATION, CommandGroup::EDIT );
implDescribeSupportedFeature( ".uno:DBQueryPreview", SID_DB_QUERY_PREVIEW, CommandGroup::VIEW );
+ implDescribeSupportedFeature( ".uno:DBLimit", SID_QUERY_LIMIT, CommandGroup::FORMAT );
#if OSL_DEBUG_LEVEL > 1
implDescribeSupportedFeature( ".uno:DBShowParseTree", ID_EDIT_QUERY_SQL );
diff --git a/dbaccess/uiconfig/dbquery/toolbar/designobjectbar.xml b/dbaccess/uiconfig/dbquery/toolbar/designobjectbar.xml
index 64cc4bf6fdad..a25548ff6898 100644
--- a/dbaccess/uiconfig/dbquery/toolbar/designobjectbar.xml
+++ b/dbaccess/uiconfig/dbquery/toolbar/designobjectbar.xml
@@ -24,4 +24,5 @@
<toolbar:toolbaritem xlink:href=".uno:DBViewTableNames" toolbar:helpid="helpid:12298" toolbar:text="" toolbar:style="" />
<toolbar:toolbaritem xlink:href=".uno:DBViewAliases" toolbar:helpid="helpid:12299" toolbar:text="" toolbar:style="" />
<toolbar:toolbaritem xlink:href=".uno:DBDistinctValues" toolbar:helpid="helpid:12300" toolbar:text="" toolbar:style="" />
-</toolbar:toolbar> \ No newline at end of file
+ <toolbar:toolbaritem xlink:href=".uno:DBLimit" />
+</toolbar:toolbar>
diff --git a/dbaccess/util/dbu.component b/dbaccess/util/dbu.component
index 17d3ab937d83..afd9002407bd 100644
--- a/dbaccess/util/dbu.component
+++ b/dbaccess/util/dbu.component
@@ -104,4 +104,7 @@
<implementation name="org.openoffice.comp.dbu.OViewDesign">
<service name="com.sun.star.sdb.ViewDesign"/>
</implementation>
+ <implementation name="org.libreoffice.comp.dbu.LimitBoxController">
+ <service name="com.sun.star.frame.ToolbarController"/>
+ </implementation>
</component>