Kaydet (Commit) 7488ad52 authored tarafından Zolnai Tamás's avatar Zolnai Tamás Kaydeden (comit) Lionel Elie Mamane

Add new dialog to Query Design View

In Query Properties Dialog can be set properties like
distinct values and limit.
To open choose Edit\Query Properties.

Steps of implementation:
- Add new slot to Edit menu (menubar.xml): delete the slot of distinct values,
  because it can set in this dialog too
- Separate LimitBox class from limitboxcontroller.cxx (LimitBox.hxx\cxx)
  With it only LimitBox header is included in the dialog source.
- Extend LimitBox class to work with new layout widget (make... and GetOptimalSize())
  and add it to the galde catalog
- Make a class for the new dialog (QueryPropertiesDialog.hxx\cxx) and
  write the .ui file. (querypropertiesdialog.ui)
- Syncronize the two LimitBox (querycontroller.cxx)

Change-Id: Ib84bef5a2ed55030333d6151342b99ff27766538
üst 30e14d7d
......@@ -166,6 +166,7 @@ $(eval $(call gb_Library_add_exception_objects,dbu,\
dbaccess/source/ui/dlg/paramdialog \
dbaccess/source/ui/dlg/queryfilter \
dbaccess/source/ui/dlg/queryorder \
dbaccess/source/ui/dlg/QueryPropertiesDialog \
dbaccess/source/ui/dlg/RelationDlg \
dbaccess/source/ui/dlg/sqlmessage \
dbaccess/source/ui/dlg/tablespage \
......@@ -214,6 +215,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/LimitBox \
dbaccess/source/ui/querydesign/limitboxcontroller \
dbaccess/source/ui/querydesign/QTableConnection \
dbaccess/source/ui/querydesign/QTableConnectionData \
......
......@@ -43,6 +43,7 @@ $(eval $(call gb_Module_add_targets,dbaccess,\
Library_sdbt \
Package_inc \
Package_uiconfig \
UI_dbaccess \
))
$(eval $(call gb_Module_add_check_targets,dbaccess,\
......
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#
# 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/.
#
$(eval $(call gb_UI_UI,dbaccess))
$(eval $(call gb_UI_add_uifiles,dbaccess, \
dbaccess/uiconfig/ui/querypropertiesdialog \
))
# vim: set noet sw=4 ts=4:
......@@ -102,6 +102,8 @@
#define SID_TABLEDESIGN_TABED_PRIMARYKEY ( SID_DBACCESS_START + 67 )
#define SID_TABLEDESIGN_INSERTROWS ( SID_DBACCESS_START + 68 )
#define SID_QUERY_PROP_DLG ( SID_DBACCESS_START + 69 )
#endif // _DBACCESS_SLOTID_HRC_
/* -*- 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 "QueryPropertiesDialog.hxx"
namespace dbaui
{
QueryPropertiesDialog::QueryPropertiesDialog(
Window* pParent, const sal_Bool bDistinct, const sal_Int64 nLimit )
: ModalDialog(pParent, "QueryPropertiesDialog", "dbaccess/ui/querypropertiesdialog.ui")
, m_pRB_Distinct( 0 )
, m_pRB_NonDistinct( 0 )
, m_pLB_Limit( 0 )
{
get( m_pRB_Distinct, "distinct" );
get( m_pRB_NonDistinct, "nondistinct" );
get( m_pLB_Limit, "limitbox" );
m_pRB_Distinct->Check( bDistinct );
m_pRB_NonDistinct->Check( !bDistinct );
m_pLB_Limit->SetValue( nLimit );
}
QueryPropertiesDialog::~QueryPropertiesDialog()
{
}
} ///dbaui namespace
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- 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 LIMIT_BOX_HXX
#define LIMIT_BOX_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( Window* pParent, WinBits nStyle );
virtual ~LimitBox();
virtual long Notify( NotifyEvent& rNEvt );
virtual OUString CreateFieldText( sal_Int64 nValue ) const;
virtual void Reformat();
virtual void ReformatAll();
virtual Size GetOptimalSize() const;
private:
void LoadDefaultLimits();
};
} ///dbaui namespace
#endif ///LIMIT_BOX_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- 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 QUERYPROPERTIESDIALOG_HXX
#define QUERYPROPERTIESDIALOG_HXX
#include <vcl/dialog.hxx>
#include <vcl/button.hxx>
#include <rtl/ustring.hxx>
#include "LimitBox.hxx"
namespace dbaui
{
/**
* Dialog to set such properties of a query as distinct values and limit
* It can be opened form Edit menu in Query Design View
*/
class QueryPropertiesDialog : public ModalDialog
{
public:
QueryPropertiesDialog(
Window* pParent, const sal_Bool bDistinct, const sal_Int64 nLimit );
~QueryPropertiesDialog();
sal_Bool getDistinct() const;
sal_Int64 getLimit() const;
private:
RadioButton* m_pRB_Distinct;
RadioButton* m_pRB_NonDistinct;
LimitBox* m_pLB_Limit;
};
inline sal_Bool QueryPropertiesDialog::getDistinct() const
{
return m_pRB_Distinct->IsChecked();
}
inline sal_Int64 QueryPropertiesDialog::getLimit() const
{
return m_pLB_Limit->GetValue();
}
} ///dbaui namespace
#endif ///QUERYPROPERTIESDIALOG_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -51,7 +51,6 @@ namespace dbaui
{
class OQueryContainerWindow;
class OQueryController;
typedef ::comphelper::OPropertyContainer OQueryController_PBase;
typedef ::comphelper::OPropertyArrayUsageHelper< OQueryController > OQueryController_PABase;
class OQueryController :public OJoinController
......@@ -117,6 +116,8 @@ namespace dbaui
::rtl::OUString getDefaultName() const;
void execute_QueryPropDlg();
protected:
// all the features which should be handled by this class
virtual void describeSupportedFeatures();
......
/* -*- 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 "dbu_qry.hrc"
#include "moduledbu.hxx"
#define ALL_STRING ModuleRes(STR_QUERY_LIMIT_ALL).toString()
#define ALL_INT -1
////////////////
///LimitBox
////////////////
namespace global{
/// Default values
sal_Int64 aDefLimitAry[] =
{
5,
10,
20,
50
};
}
namespace dbaui
{
LimitBox::LimitBox( Window* pParent, WinBits nStyle )
: NumericBox( pParent, nStyle )
{
SetShowTrailingZeros( sal_False );
SetDecimalDigits( 0 );
SetMin( -1 );
SetMax( 9999 );
LoadDefaultLimits();
Size aSize(
GetSizePixel().Width(),
CalcWindowSizePixel(GetEntryCount() + 1) );
SetSizePixel(aSize);
}
LimitBox::~LimitBox()
{
}
long LimitBox::Notify( NotifyEvent& rNEvt )
{
long nHandled = 0;
switch ( rNEvt.GetType() )
{
case EVENT_KEYINPUT:
{
const sal_uInt16 nCode = rNEvt.GetKeyEvent()->GetKeyCode().GetCode();
if( nCode == KEY_RETURN )
{
GrabFocusToDocument();
nHandled = 1;
}
break;
}
}
return nHandled ? nHandled : NumericBox::Notify( rNEvt );
}
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 )
{
RemoveEntry( 0 );
NumericBox::ReformatAll();
InsertEntry( ALL_STRING, 0);
}
else
{
NumericBox::ReformatAll();
}
}
Size LimitBox::GetOptimalSize() const
{
Size aSize = NumericBox::GetOptimalSize();
return Size( aSize.Width() + 20, aSize.Height());
}
///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] );
}
}
extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeLimitBox( Window *pParent )
{
LimitBox* pBox = new LimitBox( pParent, WB_DROPDOWN | WB_VSCROLL );
return pBox;
}
} ///dbaui namespace
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -16,105 +16,41 @@
#include <vcl/window.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include <osl/mutex.hxx>
#include <rtl/ustring.hxx>
#include "LimitBox.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[] =
class LimitBoxImpl: public LimitBox
{
5,
10,
20,
50
};
public:
LimitBoxImpl( Window* pParent, LimitBoxController* pCtrl );
virtual ~LimitBoxImpl();
}
virtual long Notify( NotifyEvent& rNEvt );
private:
LimitBoxController* m_pControl;
};
LimitBox::LimitBox( Window* pParent, LimitBoxController* pCtrl )
: NumericBox( pParent, WinBits( WB_DROPDOWN | WB_VSCROLL) )
LimitBoxImpl::LimitBoxImpl( Window* pParent, LimitBoxController* pCtrl )
: LimitBox( 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()
LimitBoxImpl::~LimitBoxImpl()
{
}
void LimitBox::Reformat()
long LimitBoxImpl::Notify( NotifyEvent& rNEvt )
{
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:
......@@ -125,36 +61,10 @@ long LimitBox::Notify( NotifyEvent& rNEvt )
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] );
}
return LimitBox::Notify( rNEvt );
}
/////////////////////////
///LimitBoxController
/////////////////////////
LimitBoxController::LimitBoxController(
const uno::Reference< lang::XMultiServiceFactory >& rServiceManager ) :
......@@ -263,7 +173,8 @@ uno::Reference< awt::XWindow > SAL_CALL LimitBoxController::createItemWindow(
if ( pParent )
{
SolarMutexGuard aSolarMutexGuard;
m_pLimitBox = new LimitBox(pParent, this);
m_pLimitBox = new LimitBoxImpl(pParent, this);
m_pLimitBox->SetSizePixel(m_pLimitBox->GetOptimalSize());
xItemWindow = VCLUnoHelper::GetInterface( m_pLimitBox );
}
......
......@@ -12,38 +12,14 @@
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <svtools/toolboxcontroller.hxx>
#include <vcl/field.hxx>
#include <rtl/ustring.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();
};
class LimitBoxImpl;
/**
* A ToolboxController to paste LimitBox onto the Query Design Toolbar
......@@ -83,7 +59,7 @@ class LimitBoxController: public svt::ToolboxController,
using svt::ToolboxController::dispatchCommand;
private:
LimitBox* m_pLimitBox;
LimitBoxImpl* m_pLimitBox;
};
} ///dbaui namespace
......
......@@ -39,6 +39,7 @@
#include "TableConnectionData.hxx"
#include "TableFieldDescription.hxx"
#include "UITools.hxx"
#include "QueryPropertiesDialog.hxx"
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/container/XChild.hpp>
......@@ -551,6 +552,9 @@ FeatureState OQueryController::GetState(sal_uInt16 _nId) const
if( aReturn.bEnabled )
aReturn.aValue = makeAny( m_nLimit );
break;
case SID_QUERY_PROP_DLG:
aReturn.bEnabled = m_bGraphicalDesign;
break;
case ID_BROWSER_QUERY_EXECUTE:
aReturn.bEnabled = sal_True;
break;
......@@ -727,6 +731,10 @@ void OQueryController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue >&
setModified(sal_True);
}
break;
case SID_QUERY_PROP_DLG:
grabFocusFromLimitBox(*this);
execute_QueryPropDlg();
break;
case ID_BROWSER_QUERY_EXECUTE:
grabFocusFromLimitBox(*this);
if ( getContainer()->checkStatement() )
......@@ -1160,6 +1168,7 @@ void OQueryController::describeSupportedFeatures()
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 );
implDescribeSupportedFeature( ".uno:DBQueryPropertiesDialog", SID_QUERY_PROP_DLG, CommandGroup::FORMAT );
#if OSL_DEBUG_LEVEL > 1
implDescribeSupportedFeature( ".uno:DBShowParseTree", ID_EDIT_QUERY_SQL );
......@@ -1254,6 +1263,20 @@ void OQueryController::loadViewSettings( const ::comphelper::NamedValueCollectio
m_aFieldInformation = o_rViewSettings.getOrDefault( "Fields", m_aFieldInformation );
}
// -----------------------------------------------------------------------------
void OQueryController::execute_QueryPropDlg()
{
QueryPropertiesDialog aQueryPropDlg(
getContainer(), m_bDistinct, m_nLimit );
if( aQueryPropDlg.Execute() == RET_OK )
{
m_bDistinct = aQueryPropDlg.getDistinct();
m_nLimit = aQueryPropDlg.getLimit();
InvalidateFeature( SID_QUERY_DISTINCT_VALUES );
InvalidateFeature( SID_QUERY_LIMIT, 0, sal_True );
}
}
// -----------------------------------------------------------------------------
sal_Int32 OQueryController::getColWidth(sal_uInt16 _nColPos) const
{
if ( _nColPos < m_aFieldInformation.getLength() )
......
......@@ -43,7 +43,7 @@
<menu:menuitem menu:id=".uno:Copy"/>
<menu:menuitem menu:id=".uno:Paste"/>
<menu:menuseparator/>
<menu:menuitem menu:id=".uno:DBDistinctValues"/>
<menu:menuitem menu:id=".uno:DBQueryPropertiesDialog"/>
<menu:menuitem menu:id=".uno:SbaNativeSql"/>
<menu:menuitem menu:id=".uno:DBClearQuery"/>
<menu:menuitem menu:id=".uno:SbaExecuteSql"/>
......
This diff is collapsed.
......@@ -48,6 +48,9 @@
<glade-widget-class title="Text Encoding ListBox" name="svxlo-SvxTextEncodingBox"
generic-name="TextEncodingBox" parent="GtkComboBox"
icon-name="widget-gtk-combobox"/>
<glade-widget-class title="Limit ListBox" name="dbulo-LimitBox"
generic-name="LimitBox" parent="GtkComboBox"
icon-name="widget-gtk-combobox"/>
<glade-widget-class title="Font Preview" name="svxlo-SvxFontPrevWindow"
generic-name="Font Preview Window" parent="GtkDrawingArea"
icon-name="widget-gtk-drawingarea"/>
......
......@@ -77,6 +77,11 @@
<value xml:lang="en-US">Limit</value>
</prop>
</node>
<node oor:name=".uno:DBQueryPropertiesDialog" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">Query Properties</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>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment