diff options
Diffstat (limited to 'dbaccess')
-rw-r--r-- | dbaccess/Library_dbu.mk | 1 | ||||
-rw-r--r-- | dbaccess/UIConfig_dbaccess.mk | 1 | ||||
-rw-r--r-- | dbaccess/inc/pch/precompiled_dba.hxx | 5 | ||||
-rw-r--r-- | dbaccess/inc/pch/precompiled_dbu.hxx | 13 | ||||
-rw-r--r-- | dbaccess/source/ui/inc/LimitBox.hxx | 43 | ||||
-rw-r--r-- | dbaccess/source/ui/inc/QueryPropertiesDialog.hxx | 1 | ||||
-rw-r--r-- | dbaccess/source/ui/querydesign/LimitBox.cxx | 110 | ||||
-rw-r--r-- | dbaccess/source/ui/querydesign/limitboxcontroller.cxx | 200 | ||||
-rw-r--r-- | dbaccess/source/ui/querydesign/limitboxcontroller.hxx | 4 | ||||
-rw-r--r-- | dbaccess/uiconfig/ui/limitbox.ui | 30 |
10 files changed, 185 insertions, 223 deletions
diff --git a/dbaccess/Library_dbu.mk b/dbaccess/Library_dbu.mk index 74223abd7038..f56531b485f6 100644 --- a/dbaccess/Library_dbu.mk +++ b/dbaccess/Library_dbu.mk @@ -188,7 +188,6 @@ $(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/LimitBox \ dbaccess/source/ui/querydesign/limitboxcontroller \ dbaccess/source/ui/querydesign/QTableConnection \ dbaccess/source/ui/querydesign/QTableConnectionData \ diff --git a/dbaccess/UIConfig_dbaccess.mk b/dbaccess/UIConfig_dbaccess.mk index aa94a1fb37ea..eed1ba41a531 100644 --- a/dbaccess/UIConfig_dbaccess.mk +++ b/dbaccess/UIConfig_dbaccess.mk @@ -46,6 +46,7 @@ $(eval $(call gb_UIConfig_add_uifiles,dbaccess, \ dbaccess/uiconfig/ui/keymenu \ dbaccess/uiconfig/ui/ldapconnectionpage \ dbaccess/uiconfig/ui/ldappage \ + dbaccess/uiconfig/ui/limitbox \ dbaccess/uiconfig/ui/mysqlnativepage \ dbaccess/uiconfig/ui/mysqlnativesettings \ dbaccess/uiconfig/ui/namematchingpage \ diff --git a/dbaccess/inc/pch/precompiled_dba.hxx b/dbaccess/inc/pch/precompiled_dba.hxx index 8c7b177d56ee..b49d1d43d4ae 100644 --- a/dbaccess/inc/pch/precompiled_dba.hxx +++ b/dbaccess/inc/pch/precompiled_dba.hxx @@ -13,7 +13,7 @@ manual changes will be rewritten by the next run of update_pch.sh (which presumably also fixes all possible problems, so it's usually better to use it). - Generated on 2020-01-22 15:57:40 using: + Generated on 2020-02-17 16:58:06 using: ./bin/update_pch dbaccess dba --cutoff=6 --exclude:system --include:module --include:local If after updating build fails, use the following command to locate conflicting headers: @@ -47,6 +47,7 @@ #include <type_traits> #include <utility> #include <vector> +#include <boost/property_tree/ptree_fwd.hpp> #endif // PCH_LEVEL >= 1 #if PCH_LEVEL >= 2 #include <osl/diagnose.h> @@ -162,6 +163,7 @@ #include <com/sun/star/sdbc/XColumnLocate.hpp> #include <com/sun/star/sdbc/XConnection.hpp> #include <com/sun/star/sdbc/XDatabaseMetaData.hpp> +#include <com/sun/star/sdbc/XResultSetMetaData.hpp> #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp> #include <com/sun/star/sdbc/XRow.hpp> #include <com/sun/star/sdbcx/KeyType.hpp> @@ -271,7 +273,6 @@ #if PCH_LEVEL >= 4 #include <ContainerMediator.hxx> #include <apitools.hxx> -#include <columnsettings.hxx> #include <core_resource.hxx> #include <definitioncolumn.hxx> #include <sdbcoretools.hxx> diff --git a/dbaccess/inc/pch/precompiled_dbu.hxx b/dbaccess/inc/pch/precompiled_dbu.hxx index d155948cdbcb..1c845be8632e 100644 --- a/dbaccess/inc/pch/precompiled_dbu.hxx +++ b/dbaccess/inc/pch/precompiled_dbu.hxx @@ -13,7 +13,7 @@ manual changes will be rewritten by the next run of update_pch.sh (which presumably also fixes all possible problems, so it's usually better to use it). - Generated on 2020-01-29 23:12:45 using: + Generated on 2020-02-17 16:58:13 using: ./bin/update_pch dbaccess dbu --cutoff=12 --exclude:system --exclude:module --exclude:local If after updating build fails, use the following command to locate conflicting headers: @@ -68,7 +68,6 @@ #include <sal/log.hxx> #include <sal/types.h> #include <vcl/IDialogRenderable.hxx> -#include <vcl/accel.hxx> #include <vcl/bitmap.hxx> #include <vcl/bitmapex.hxx> #include <vcl/cairo.hxx> @@ -81,14 +80,13 @@ #include <vcl/image.hxx> #include <vcl/keycod.hxx> #include <vcl/keycodes.hxx> +#include <vcl/layout.hxx> #include <vcl/mapmod.hxx> #include <vcl/menu.hxx> #include <vcl/metaactiontypes.hxx> -#include <vcl/mnemonicengine.hxx> #include <vcl/outdev.hxx> #include <vcl/outdevmap.hxx> #include <vcl/outdevstate.hxx> -#include <vcl/quickselectionengine.hxx> #include <vcl/region.hxx> #include <vcl/salnativewidgets.hxx> #include <vcl/settings.hxx> @@ -97,8 +95,6 @@ #include <vcl/tabpage.hxx> #include <vcl/timer.hxx> #include <vcl/transfer.hxx> -#include <vcl/treelist.hxx> -#include <vcl/treelistbox.hxx> #include <vcl/uitest/factory.hxx> #include <vcl/vclenum.hxx> #include <vcl/vclevent.hxx> @@ -118,7 +114,6 @@ #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/container/XChild.hpp> #include <com/sun/star/container/XContainer.hpp> -#include <com/sun/star/container/XIndexAccess.hpp> #include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/datatransfer/DataFlavor.hpp> @@ -224,16 +219,14 @@ #include <unotools/unotoolsdllapi.h> #endif // PCH_LEVEL >= 3 #if PCH_LEVEL >= 4 -#include <ConnectionLineData.hxx> #include <FieldDescriptions.hxx> #include <QEnumTypes.hxx> #include <QueryDesignView.hxx> #include <QueryTableView.hxx> -#include <TableWindowData.hxx> +#include <TableFieldDescription.hxx> #include <TypeInfo.hxx> #include <UITools.hxx> #include <browserids.hxx> -#include <callbacks.hxx> #include <dbaccess/dataview.hxx> #include <dbaccess/dbaccessdllapi.h> #include <dbadmin.hxx> diff --git a/dbaccess/source/ui/inc/LimitBox.hxx b/dbaccess/source/ui/inc/LimitBox.hxx deleted file mode 100644 index 430546f31aa7..000000000000 --- a/dbaccess/source/ui/inc/LimitBox.hxx +++ /dev/null @@ -1,43 +0,0 @@ -/* -*- 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 INCLUDED_DBACCESS_SOURCE_UI_INC_LIMITBOX_HXX -#define INCLUDED_DBACCESS_SOURCE_UI_INC_LIMITBOX_HXX - -#include <vcl/field.hxx> -#include <rtl/ustring.hxx> - -namespace dbaui -{ - -/** - * 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( vcl::Window* pParent ); - - virtual OUString CreateFieldText( sal_Int64 nValue ) const override; - - virtual void Reformat() override; - virtual void ReformatAll() override; - - virtual Size GetOptimalSize() const override; - - private: - void LoadDefaultLimits(); -}; - -} ///dbaui namespace - -#endif /// INCLUDED_DBACCESS_SOURCE_UI_INC_LIMITBOX_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/ui/inc/QueryPropertiesDialog.hxx b/dbaccess/source/ui/inc/QueryPropertiesDialog.hxx index b5b1dc16626d..d8a5c5a7167f 100644 --- a/dbaccess/source/ui/inc/QueryPropertiesDialog.hxx +++ b/dbaccess/source/ui/inc/QueryPropertiesDialog.hxx @@ -12,7 +12,6 @@ #include <vcl/weld.hxx> #include <rtl/ustring.hxx> -#include "LimitBox.hxx" namespace dbaui { diff --git a/dbaccess/source/ui/querydesign/LimitBox.cxx b/dbaccess/source/ui/querydesign/LimitBox.cxx deleted file mode 100644 index 89aa4f02a7c7..000000000000 --- a/dbaccess/source/ui/querydesign/LimitBox.cxx +++ /dev/null @@ -1,110 +0,0 @@ -/* -*- 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 <LimitBox.hxx> -#include <strings.hrc> -#include <core_resource.hxx> - -#define ALL_STRING DBA_RES(STR_QUERY_LIMIT_ALL) -#define ALL_INT -1 - -namespace global{ - -/// Default values -sal_Int64 const aDefLimitAry[] = -{ - 5, - 10, - 20, - 50 -}; - -} - -namespace dbaui -{ - - -LimitBox::LimitBox( vcl::Window* pParent ) - : NumericBox( pParent, WB_DROPDOWN | WB_VSCROLL ) -{ - SetShowTrailingZeros( false ); - SetDecimalDigits( 0 ); - SetMin( -1 ); - SetMax( SAL_MAX_INT64 ); - LoadDefaultLimits(); - - Size aSize( - GetSizePixel().Width(), - CalcWindowSizePixel(GetEntryCount() + 1) ); - SetSizePixel(aSize); -} - -OUString LimitBox::CreateFieldText( sal_Int64 nValue ) const -{ - if( nValue == ALL_INT ) - return ALL_STRING; - else - return NumericBox::CreateFieldText( nValue ); -} - -void LimitBox::Reformat() -{ - - if( GetText() == ALL_STRING ) - { - SetValue( ALL_INT ); - } - ///Reformat only when text is not All - else - { - ///Not allow user to type in -1 - if( GetText() == "-1" ) - { - Undo(); - } - else - NumericBox::Reformat(); - } -} - -void LimitBox::ReformatAll() -{ - ///First entry is All, which do not need numeric reformat - if ( GetEntryCount() > 0 ) - { - RemoveEntryAt( 0 ); - NumericBox::ReformatAll(); - InsertValue( ALL_INT, 0); - } - else - { - NumericBox::ReformatAll(); - } -} - -Size LimitBox::GetOptimalSize() const -{ - return CalcBlockSize(10,1); -} - -///Initialize entries -void LimitBox::LoadDefaultLimits() -{ - InsertValue( ALL_INT ); - - for(long nIndex : global::aDefLimitAry) - { - InsertValue( nIndex ); - } -} - -} ///dbaui namespace - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/ui/querydesign/limitboxcontroller.cxx b/dbaccess/source/ui/querydesign/limitboxcontroller.cxx index c07e093869d3..ffcee79520d7 100644 --- a/dbaccess/source/ui/querydesign/limitboxcontroller.cxx +++ b/dbaccess/source/ui/querydesign/limitboxcontroller.cxx @@ -14,6 +14,7 @@ #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/util/XURLTransformer.hpp> +#include <sfx2/InterimItemWindow.hxx> #include <vcl/event.hxx> #include <vcl/svapp.hxx> #include <vcl/window.hxx> @@ -21,77 +22,171 @@ #include <cppuhelper/queryinterface.hxx> #include <comphelper/processfactory.hxx> -#include <LimitBox.hxx> +#include <core_resource.hxx> #include <dbu_reghelper.hxx> - +#include <strings.hrc> using namespace ::com::sun::star; -namespace dbaui +namespace { -class LimitBoxImpl: public LimitBox +/// Default values +sal_Int64 const aDefLimitAry[] = { - public: - LimitBoxImpl( vcl::Window* pParent, LimitBoxController* pCtrl ); + 5, + 10, + 20, + 50 +}; - virtual bool EventNotify( NotifyEvent& rNEvt ) override; +} - private: - LimitBoxController* m_pControl; -}; +namespace dbaui +{ -LimitBoxImpl::LimitBoxImpl( vcl::Window* pParent, LimitBoxController* pCtrl ) - : LimitBox( pParent ) - , m_pControl( pCtrl ) +/** + * 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 final : public InterimItemWindow { -} +public: + LimitBox(vcl::Window* pParent, LimitBoxController* pCtrl) + : InterimItemWindow(pParent, "dbaccess/ui/limitbox.ui", "LimitBox") + , m_pControl( pCtrl ) + , m_xWidget(m_xBuilder->weld_combo_box("limit")) + { + LoadDefaultLimits(); + + m_xWidget->connect_key_press(LINK(this, LimitBox, KeyInputHdl)); + m_xWidget->connect_entry_activate(LINK(this, LimitBox, ActivateHdl)); + m_xWidget->connect_changed(LINK(this, LimitBox, ChangeHdl)); + m_xWidget->connect_focus_out(LINK(this, LimitBox, FocusOutHdl)); + m_xWidget->set_entry_width_chars(6); + SetSizePixel(m_xContainer->get_preferred_size()); + } + + virtual void dispose() override + { + m_xWidget.reset(); + InterimItemWindow::dispose(); + } + + virtual ~LimitBox() override + { + disposeOnce(); + } + + void set_sensitive(bool bSensitive) + { + m_xWidget->set_sensitive(bSensitive); + } + + virtual void GetFocus() override + { + if (m_xWidget) + m_xWidget->grab_focus(); + InterimItemWindow::GetFocus(); + } + + void set_value(int nLimit) + { + if (nLimit < 0) + m_xWidget->set_active(0); + else + m_xWidget->set_entry_text(OUString::number(nLimit)); + m_xWidget->save_value(); + } -bool LimitBoxImpl::EventNotify( NotifyEvent& rNEvt ) +private: + LimitBoxController* m_pControl; + std::unique_ptr<weld::ComboBox> m_xWidget; + + DECL_LINK(KeyInputHdl, const KeyEvent&, bool); + DECL_LINK(ActivateHdl, weld::ComboBox&, bool); + DECL_LINK(ChangeHdl, weld::ComboBox&, void); + DECL_LINK(FocusOutHdl, weld::Widget&, void); + + void Apply() + { + if (!m_xWidget->get_value_changed_from_saved()) + return; + uno::Sequence< beans::PropertyValue > aArgs( 1 ); + aArgs[0].Name = "DBLimit.Value"; + sal_Int64 nLimit; + OUString sActiveText = m_xWidget->get_active_text(); + if (sActiveText == DBA_RES(STR_QUERY_LIMIT_ALL)) + nLimit = -1; + else + { + nLimit = m_xWidget->get_active_text().toInt64(); + if (nLimit < 0) + nLimit = -1; + } + set_value(nLimit); + aArgs[0].Value <<= nLimit; + m_pControl->dispatchCommand( aArgs ); + } + + ///Initialize entries + void LoadDefaultLimits() + { + m_xWidget->freeze(); + m_xWidget->append_text(DBA_RES(STR_QUERY_LIMIT_ALL)); + for (auto nIndex : aDefLimitAry) + { + m_xWidget->append_text(OUString::number(nIndex)); + } + m_xWidget->thaw(); + } +}; + +IMPL_LINK(LimitBox, KeyInputHdl, const KeyEvent&, rKEvt, bool) { bool bHandled = false; - switch ( rNEvt.GetType() ) + const sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode(); + switch (nCode) { - case MouseNotifyEvent::LOSEFOCUS: - { - bHandled = LimitBox::EventNotify(rNEvt); - uno::Sequence< beans::PropertyValue > aArgs( 1 ); - aArgs[0].Name = "DBLimit.Value"; - aArgs[0].Value <<= GetValue(); - m_pControl->dispatchCommand( aArgs ); + case KEY_ESCAPE: + m_xWidget->set_entry_text(m_xWidget->get_saved_value()); + bHandled = true; break; - } - case MouseNotifyEvent::KEYINPUT: + case KEY_RETURN: { - const sal_uInt16 nCode = rNEvt.GetKeyEvent()->GetKeyCode().GetCode(); - switch ( nCode ) - { - case KEY_ESCAPE: - Undo(); - [[fallthrough]]; - case KEY_RETURN: - GrabFocusToDocument(); - bHandled = true; - break; - case KEY_TAB: - Select(); - break; - } + bHandled = ActivateHdl(*m_xWidget); break; } - default: - break; } - return bHandled || LimitBox::EventNotify(rNEvt); + return bHandled || ChildKeyInput(rKEvt); } +IMPL_LINK_NOARG(LimitBox, FocusOutHdl, weld::Widget&, void) +{ + if (!m_xWidget || m_xWidget->has_focus()) // comboboxes can be comprised of multiple widgets, ensure all have lost focus + return; + Apply(); +} + +IMPL_LINK(LimitBox, ChangeHdl, weld::ComboBox&, rComboBox, void) +{ + if (rComboBox.changed_by_direct_pick()) + ActivateHdl(rComboBox); +} + +IMPL_LINK_NOARG(LimitBox, ActivateHdl, weld::ComboBox&, bool) +{ + GrabFocusToDocument(); + Apply(); + return true; +} LimitBoxController::LimitBoxController( const uno::Reference< uno::XComponentContext >& rxContext ) : svt::ToolboxController( rxContext, uno::Reference< frame::XFrame >(), ".uno:DBLimit" ), - m_pLimitBox( nullptr ) + m_xLimitBox( nullptr ) { } @@ -137,29 +232,27 @@ void SAL_CALL LimitBoxController::dispose() svt::ToolboxController::dispose(); SolarMutexGuard aSolarMutexGuard; - m_pLimitBox.disposeAndClear(); + m_xLimitBox.disposeAndClear(); } /// XStatusListener void SAL_CALL LimitBoxController::statusChanged( const frame::FeatureStateEvent& rEvent ) { - if ( m_pLimitBox ) + if ( m_xLimitBox ) { SolarMutexGuard aSolarMutexGuard; if ( rEvent.FeatureURL.Path == "DBLimit" ) { if ( rEvent.IsEnabled ) { - m_pLimitBox->Enable(); + m_xLimitBox->set_sensitive(true); sal_Int64 nLimit = 0; - if ( rEvent.State >>= nLimit ) - { - m_pLimitBox->SetValue( nLimit ); - } + if (rEvent.State >>= nLimit) + m_xLimitBox->set_value(nLimit); } else - m_pLimitBox->Disable(); + m_xLimitBox->set_sensitive(false); } } } @@ -191,9 +284,8 @@ uno::Reference< awt::XWindow > SAL_CALL LimitBoxController::createItemWindow( if ( pParent ) { SolarMutexGuard aSolarMutexGuard; - m_pLimitBox = VclPtr<LimitBoxImpl>::Create(pParent, this); - m_pLimitBox->SetSizePixel(m_pLimitBox->CalcBlockSize(6,1)); - xItemWindow = VCLUnoHelper::GetInterface( m_pLimitBox ); + m_xLimitBox = VclPtr<LimitBox>::Create(pParent, this); + xItemWindow = VCLUnoHelper::GetInterface(m_xLimitBox); } return xItemWindow; diff --git a/dbaccess/source/ui/querydesign/limitboxcontroller.hxx b/dbaccess/source/ui/querydesign/limitboxcontroller.hxx index 721b9cc56ef7..49ee2afae411 100644 --- a/dbaccess/source/ui/querydesign/limitboxcontroller.hxx +++ b/dbaccess/source/ui/querydesign/limitboxcontroller.hxx @@ -20,7 +20,7 @@ namespace dbaui { -class LimitBoxImpl; +class LimitBox; /** * A ToolboxController to paste LimitBox onto the Query Design Toolbar @@ -66,7 +66,7 @@ class LimitBoxController: public svt::ToolboxController, using svt::ToolboxController::dispatchCommand; private: - VclPtr<LimitBoxImpl> m_pLimitBox; + VclPtr<LimitBox> m_xLimitBox; }; } ///dbaui namespace diff --git a/dbaccess/uiconfig/ui/limitbox.ui b/dbaccess/uiconfig/ui/limitbox.ui new file mode 100644 index 000000000000..efc0117e0fc6 --- /dev/null +++ b/dbaccess/uiconfig/ui/limitbox.ui @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.22.1 --> +<interface domain="dba"> + <requires lib="gtk+" version="3.18"/> + <object class="GtkBox" id="LimitBox"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="spacing">6</property> + <child> + <object class="GtkComboBoxText" id="limit"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="has_entry">True</property> + <child internal-child="entry"> + <object class="GtkEntry"> + <property name="can_focus">True</property> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + </object> +</interface> |