Date: prev next · Thread: first prev next last
2013 Archives by date, by thread · List index


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/1994

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/94/1994/1

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)
 - 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)

Change-Id: I0eb09d1d40cfdb9b8a2a57ab8911faca91d5e690
---
M dbaccess/Library_dbu.mk
M dbaccess/inc/dbaccess_slotid.hrc
M dbaccess/source/ui/inc/dbu_qry.hrc
M dbaccess/source/ui/inc/querycontroller.hxx
M dbaccess/source/ui/misc/uiservices.cxx
M dbaccess/source/ui/querydesign/QueryDesignView.cxx
A dbaccess/source/ui/querydesign/limitboxcontroller.cxx
A dbaccess/source/ui/querydesign/limitboxcontroller.hxx
M dbaccess/source/ui/querydesign/query.src
M dbaccess/source/ui/querydesign/querycontroller.cxx
M dbaccess/uiconfig/dbquery/toolbar/designobjectbar.xml
M dbaccess/util/dbu.component
M officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu
M officecfg/registry/data/org/openoffice/Office/UI/DbuCommands.xcu
14 files changed, 458 insertions(+), 4 deletions(-)



diff --git a/dbaccess/Library_dbu.mk b/dbaccess/Library_dbu.mk
index 1ca0f82..ef84bfe 100644
--- a/dbaccess/Library_dbu.mk
+++ b/dbaccess/Library_dbu.mk
@@ -214,6 +214,7 @@
     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 c3db103..37a333e 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 659254f..1907b0c 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 789f9ea..2fddb24 100644
--- a/dbaccess/source/ui/inc/querycontroller.hxx
+++ b/dbaccess/source/ui/inc/querycontroller.hxx
@@ -78,6 +78,8 @@
         mutable ::rtl::OUString
                         m_sName;                // name of the query
 
+        OUString        m_sLimit;           // the limit of the query result (a number or All)
+
         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 @@
         sal_Bool        isEsacpeProcessing()    const { return m_bEscapeProcessing; }
         sal_Bool        isGraphicalDesign()     const { return m_bGraphicalDesign; }
         sal_Bool        isDistinct()            const { return m_bDistinct; }
+        OUString        getLimit()              const { return m_sLimit; }
 
         ::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 OUString& _sLimit)       { m_sLimit = _sLimit;}
         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 672f970..81fe7ba 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_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 @@
         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 fe780c9..6f4bc36264 100644
--- a/dbaccess/source/ui/querydesign/QueryDesignView.cxx
+++ b/dbaccess/source/ui/querydesign/QueryDesignView.cxx
@@ -2004,7 +2004,7 @@
             }
 
             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;
@@ -2102,6 +2102,19 @@
                     {
                         rController.setDistinct(sal_False);
                     }
+
+                    ///check if query has a limit
+                    if( pTableExp->getChild(6)->count() >= 2 && 
pTableExp->getChild(6)->getChild(1) )
+                    {
+                        const OUString sLimit =
+                            pTableExp->getChild(6)->getChild(1)->getTokenValue();
+                        rController.setLimit( sLimit );
+                    }
+                    else
+                    {
+                        rController.setLimit( ModuleRes(STR_QUERY_LIMIT_ALL) );
+                    }
+
                     if ( (eErrorCode = InstallFields(_pView,pParseTree, 
pTableView->GetTabWinMap())) == eOk )
                     {
                         // GetSelectionCriteria must be called before GetHavingCriteria
@@ -2933,7 +2946,7 @@
     }
     // ----------------- Statement aufbauen ----------------------
     ::rtl::OUStringBuffer aSqlCmd(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SELECT ")));
-    if(static_cast<OQueryController&>(getController()).isDistinct())
+    if(rController.isDistinct())
         aSqlCmd.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" DISTINCT ")));
     aSqlCmd.append(aFieldListStr);
     aSqlCmd.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" FROM ")));
@@ -2971,6 +2984,11 @@
 
         m_rController.displayError();
     }
+    // --------------------- Limit Clause -------------------
+    if( rController.getLimit() != ModuleRes(STR_QUERY_LIMIT_ALL).toString() )
+    {
+        aSqlCmd.append(" LIMIT " + rController.getLimit());
+    }
 
     ::rtl::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 0000000..6f8c4be
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/limitboxcontroller.cxx
@@ -0,0 +1,278 @@
+/* -*- 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"
+
+using namespace ::com::sun::star;
+
+
+////////////////
+///LimitBox
+////////////////
+
+namespace dbaui
+{
+
+namespace{
+
+/// Default values
+OUString aDefLimitAry[] =
+{
+    "5",
+    "10",
+    "20",
+    "50"
+};
+
+
+///Initialize entries
+static void lcl_LoadDefaultLimits( LimitBox& io_rLimitBox )
+{
+    const OUString sAll = ModuleRes(STR_QUERY_LIMIT_ALL);
+    io_rLimitBox.SetText( sAll );
+    io_rLimitBox.InsertEntry( sAll );
+
+    const unsigned nSize = sizeof(aDefLimitAry)/sizeof(aDefLimitAry[0]);
+    for( unsigned nIndex = 0; nIndex< nSize; ++nIndex)
+    {
+        io_rLimitBox.InsertEntry( aDefLimitAry[nIndex] );
+    }
+}
+
+///Check input string whether it can be a limit value
+static bool lcl_CheckData( const OUString& rData )
+{
+    if( rData.isEmpty() )
+    {
+        return false;
+    }
+    if( rData == String(ModuleRes(STR_QUERY_LIMIT_ALL)) )
+    {
+        return true;
+    }
+    sal_Int32 nIndex = 0;
+    sal_uInt32 nChar;
+    while( nIndex < rData.getLength() )
+    {
+        nChar = rData.iterateCodePoints( &nIndex );
+        if( nChar < '0' || nChar > '9' )
+        {
+            return false;
+        }
+    }
+    return true;
+}
+
+} /// anonymous namespace
+
+LimitBox::LimitBox( Window* pParent, LimitBoxController* pCtrl )
+    : ComboBox( pParent, WinBits( WB_DROPDOWN | WB_VSCROLL) )
+    , m_pControl( pCtrl )
+{
+    lcl_LoadDefaultLimits( *this );
+    EnableAutocomplete(sal_False);
+    Size aSize(
+        CalcMinimumSize().Width() + 30 ,
+        CalcWindowSizePixel(GetEntryCount() + 1) );
+    SetSizePixel(aSize);
+}
+
+LimitBox::~LimitBox()
+{
+}
+
+long LimitBox::Notify( NotifyEvent& rNEvt )
+{
+    long nHandled = 0;
+
+    switch ( rNEvt.GetType() )
+    {
+        /**
+         * Check the current data
+         * If it can a limit value than dispatch it
+         * Else set the previous data (checked value)
+         */
+        case EVENT_LOSEFOCUS:
+        {
+            const OUString sText = GetText();
+            if ( lcl_CheckData( sText ) )
+            {
+                uno::Sequence< beans::PropertyValue > aArgs( 1 );
+                aArgs[0].Name  = OUString( "DBLimit.Value" );
+                aArgs[0].Value = uno::makeAny( sText );
+                m_pControl->dispatchCommand( aArgs );
+            }
+            else
+            {
+                Undo();
+            }
+            nHandled = 1;
+            break;
+        }
+    }
+    return nHandled ? nHandled : ComboBox::Notify( rNEvt );
+}
+
+/////////////////////////
+///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();
+                OUString sLimit;
+                if ( (rEvent.State >>= sLimit) && !sLimit.isEmpty()  )
+                {
+                    m_pLimitBox->SetText(sLimit);
+                }
+            }
+            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 0000000..0ab559a
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/limitboxcontroller.hxx
@@ -0,0 +1,85 @@
+/* -*- 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/combobox.hxx>
+
+#include "apitools.hxx"
+
+namespace dbaui
+{
+
+class LimitBoxController;
+
+/** Input box to add limit to an SQL query (max rownumber of result)
+ * This box is reachable on the Query Design Toolbar
+ */
+class LimitBox: public ComboBox
+{
+    public:
+        LimitBox( Window* pParent, LimitBoxController* pCtrl );
+        virtual ~LimitBox();
+
+        virtual long Notify( NotifyEvent& rNEvt );
+
+    private:
+        LimitBoxController* m_pControl;
+};
+
+
+/**
+ * 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 575ee1e..89af2ad 100644
--- a/dbaccess/source/ui/querydesign/query.src
+++ b/dbaccess/source/ui/querydesign/query.src
@@ -217,6 +217,11 @@
     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 31e6d18..1ed5d82d 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::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;
@@ -274,6 +276,27 @@
             }
             xLayoutManager->unlock();
             xLayoutManager->doLayout();
+        }
+    }
+
+    /**
+     * The value of m_sLimit 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 @@
     ,m_pParseContext( new svxform::OSystemParseContext )
     ,m_aSqlParser( _rM, m_pParseContext )
     ,m_pSqlIterator(NULL)
+    ,m_sLimit( OUString() )
     ,m_nVisibleRows(0x400)
     ,m_nSplitPos(-1)
     ,m_nCommandType( CommandType::QUERY )
@@ -522,6 +546,11 @@
             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_sLimit );
+            break;
         case ID_BROWSER_QUERY_EXECUTE:
             aReturn.bEnabled = sal_True;
             break;
@@ -561,6 +590,7 @@
             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 @@
             break;
         case ID_BROWSER_SQL:
         {
+            grabFocusFromLimitBox(*this);
             if ( !getContainer()->checkStatement() )
                 break;
             SQLExceptionInfo aError;
@@ -689,7 +720,15 @@
             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_sLimit;
+                setModified(sal_True);
+            }
+            break;
         case ID_BROWSER_QUERY_EXECUTE:
+            grabFocusFromLimitBox(*this);
             if ( getContainer()->checkStatement() )
                 executeQuery();
             break;
@@ -1120,6 +1159,7 @@
     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 64cc4bf..a25548f 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 17d3ab9..afd9002 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>
diff --git a/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu 
b/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu
index fe27c05..2f40b2a 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu
@@ -187,6 +187,17 @@
           <value>com.sun.star.sdb.ApplicationToolboxController</value>
         </prop>
       </node>
+      <node oor:name="org.libreoffice.comp.dbu.LimitBoxController" oor:op="replace">
+        <prop oor:name="Command">
+          <value>.uno:DBLimit</value>
+        </prop>
+        <prop oor:name="Module">
+          <value/>
+        </prop>
+        <prop oor:name="Controller">
+          <value>org.libreoffice.comp.dbu.LimitBoxController</value>
+        </prop>
+      </node>
       <node oor:name="c2" oor:op="replace">
         <prop oor:name="Command">
           <value>.uno:Refresh</value>
diff --git a/officecfg/registry/data/org/openoffice/Office/UI/DbuCommands.xcu 
b/officecfg/registry/data/org/openoffice/Office/UI/DbuCommands.xcu
index f3c3c56..44f2d42 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/DbuCommands.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/DbuCommands.xcu
@@ -72,6 +72,11 @@
                     <value>1</value>
                 </prop>
             </node>
+            <node oor:name=".uno:DBLimit" oor:op="replace">
+                <prop oor:name="Label" oor:type="xs:string">
+                    <value xml:lang="en-US">Limit</value>
+                </prop>
+            </node>
             <node oor:name=".uno:PasteSpecial" oor:op="replace">
                 <prop oor:name="Label" oor:type="xs:string">
                     <value xml:lang="en-US">Paste ~Special...</value>

-- 
To view, visit https://gerrit.libreoffice.org/1994
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0eb09d1d40cfdb9b8a2a57ab8911faca91d5e690
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Zolnai Tamás <zolnaitamas2000@gmail.com>

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.