From eef7c4d30bdf4b8250b2de4186ba58fcaebe4993 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 2 Dec 2019 12:43:00 +0000 Subject: weld OAddFieldWindow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I1e0ca144943fd37769c7b6cfc7e77c4f001b31a0 Reviewed-on: https://gerrit.libreoffice.org/84233 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- include/svx/dbaexchange.hxx | 6 +- include/vcl/weld.hxx | 1 + reportdesign/source/ui/dlg/AddField.cxx | 389 +++++++-------------- reportdesign/source/ui/dlg/Formula.cxx | 28 +- reportdesign/source/ui/inc/AddField.hxx | 59 ++-- reportdesign/source/ui/inc/DesignView.hxx | 2 +- reportdesign/source/ui/inc/Formula.hxx | 2 +- reportdesign/source/ui/report/DesignView.cxx | 35 +- reportdesign/uiconfig/dbreport/ui/floatingfield.ui | 236 ++++++++----- svx/source/fmcomp/dbaexchange.cxx | 15 +- svx/uiconfig/ui/formfielddialog.ui | 2 +- 11 files changed, 361 insertions(+), 414 deletions(-) diff --git a/include/svx/dbaexchange.hxx b/include/svx/dbaexchange.hxx index bccdf5bacf00..0881d3760dbd 100644 --- a/include/svx/dbaexchange.hxx +++ b/include/svx/dbaexchange.hxx @@ -238,10 +238,12 @@ namespace svx /** class for transferring multiple columns */ - class SAL_WARN_UNUSED SVX_DLLPUBLIC OMultiColumnTransferable final : public TransferableHelper + class SAL_WARN_UNUSED SVX_DLLPUBLIC OMultiColumnTransferable final : public TransferDataContainer { public: - OMultiColumnTransferable(const css::uno::Sequence< css::beans::PropertyValue >& _aDescriptors); + OMultiColumnTransferable(); + + void setDescriptors(const css::uno::Sequence< css::beans::PropertyValue >& rDescriptors); /** checks whether or not an object descriptor can be extracted from the data flavor vector given @param _rFlavors diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx index 60f705e1e624..32720b074dec 100644 --- a/include/vcl/weld.hxx +++ b/include/vcl/weld.hxx @@ -956,6 +956,7 @@ public: // return the number of toplevel nodes virtual int n_children() const = 0; + // afterwards, entries will be in default ascending sort order virtual void make_sorted() = 0; virtual void make_unsorted() = 0; virtual bool get_sort_order() const = 0; diff --git a/reportdesign/source/ui/dlg/AddField.cxx b/reportdesign/source/ui/dlg/AddField.cxx index 2247ad2fa8be..40a709432f2e 100644 --- a/reportdesign/source/ui/dlg/AddField.cxx +++ b/reportdesign/source/ui/dlg/AddField.cxx @@ -18,7 +18,6 @@ */ #include #include -#include #include #include #include @@ -38,17 +37,15 @@ #include #include #include -#include #include #include +#include #include #include namespace rptui { -const long STD_WIN_SIZE_X = 180; -const long STD_WIN_SIZE_Y = 320; using namespace ::com::sun::star; using namespace sdbc; @@ -60,133 +57,50 @@ using namespace lang; using namespace container; using namespace ::svx; -class OAddFieldWindowListBox: public SvTreeListBox +IMPL_LINK_NOARG(OAddFieldWindow, DragBeginHdl, weld::TreeView&, bool) { - VclPtr m_pTabWin; - -public: - explicit OAddFieldWindowListBox(Window* pParent, OAddFieldWindow* pFieldWindow); - virtual ~OAddFieldWindowListBox() override; - virtual void dispose() override; - - sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) override; - sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) override; - - uno::Sequence< beans::PropertyValue > getSelectedFieldDescriptors(); - -protected: - // DragSourceHelper - virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel ) override; - -private: - using SvTreeListBox::ExecuteDrop; -}; - -uno::Sequence< beans::PropertyValue > OAddFieldWindowListBox::getSelectedFieldDescriptors() -{ - uno::Sequence< beans::PropertyValue > aArgs(GetSelectionCount()); - sal_Int32 i = 0; - SvTreeListEntry* pSelected = FirstSelected(); - while( pSelected ) + if (m_xListBox->get_selected_index() == -1) { - // build a descriptor for the currently selected field - svx::ODataAccessDescriptor aDescriptor; - m_pTabWin->fillDescriptor(pSelected,aDescriptor); - aArgs[i++].Value <<= aDescriptor.createPropertyValueSequence(); - pSelected = NextSelected(pSelected); + // no drag without a field + return true; } - return aArgs; -} - - - -OAddFieldWindowListBox::OAddFieldWindowListBox(Window *pParent, OAddFieldWindow* pFieldWindow) - : SvTreeListBox(pParent, WB_TABSTOP|WB_BORDER|WB_SORT) - , m_pTabWin(pFieldWindow) -{ - SetHelpId( HID_RPT_FIELD_SEL ); - SetSelectionMode(SelectionMode::Multiple); - SetDragDropMode( DragDropMode::ALL ); - SetHighlightRange( ); -} - - -OAddFieldWindowListBox::~OAddFieldWindowListBox() -{ - disposeOnce(); -} - -void OAddFieldWindowListBox::dispose() -{ - m_pTabWin.clear(); - SvTreeListBox::dispose(); -} -sal_Int8 OAddFieldWindowListBox::AcceptDrop( const AcceptDropEvent& /*rEvt*/ ) -{ - return DND_ACTION_NONE; + m_xHelper->setDescriptors(getSelectedFieldDescriptors()); + return false; } - -sal_Int8 OAddFieldWindowListBox::ExecuteDrop( const ExecuteDropEvent& /*rEvt*/ ) +OAddFieldWindow::OAddFieldWindow(weld::Window* pParent, const uno::Reference< beans::XPropertySet >& xRowSet) + : GenericDialogController(pParent, "modules/dbreport/ui/floatingfield.ui", "FloatingField") + , ::comphelper::OPropertyChangeListener(m_aMutex) + , ::comphelper::OContainerListener(m_aMutex) + , m_xRowSet(xRowSet) + , m_xActions(m_xBuilder->weld_toolbar("toolbox")) + , m_xListBox(m_xBuilder->weld_tree_view("treeview")) + , m_xHelpText(m_xBuilder->weld_label("helptext")) + , m_nCommandType(0) + , m_bEscapeProcessing(false) { - return DND_ACTION_NONE; -} + m_xListBox->set_help_id(HID_RPT_FIELD_SEL); + m_xListBox->set_selection_mode(SelectionMode::Multiple); + m_xHelper.set(new svx::OMultiColumnTransferable); + rtl::Reference xHelper(m_xHelper.get()); + m_xListBox->enable_drag_source(xHelper, DND_ACTION_COPYMOVE | DND_ACTION_LINK); + m_xListBox->connect_drag_begin(LINK(this, OAddFieldWindow, DragBeginHdl)); + m_xDialog->connect_toplevel_focus_changed(LINK(this, OAddFieldWindow, FocusChangeHdl)); -void OAddFieldWindowListBox::StartDrag( sal_Int8 /*_nAction*/, const Point& /*_rPosPixel*/ ) -{ - if ( GetSelectionCount() < 1 ) - // no drag without a field - return; + m_xDialog->set_help_id(HID_RPT_FIELD_SEL_WIN); - rtl::Reference pDataContainer = new OMultiColumnTransferable(getSelectedFieldDescriptors()); + m_xActions->connect_clicked(LINK(this, OAddFieldWindow, OnSortAction)); + m_xActions->set_item_active("up", true); + m_xListBox->make_sorted(); + m_xActions->set_item_sensitive("insert", false); - EndSelection(); - pDataContainer->StartDrag( this, DND_ACTION_COPYMOVE | DND_ACTION_LINK ); -} + m_xListBox->connect_row_activated(LINK( this, OAddFieldWindow, OnDoubleClickHdl ) ); + m_xListBox->connect_changed(LINK( this, OAddFieldWindow, OnSelectHdl ) ); + m_xListBox->set_size_request(m_xListBox->get_approximate_digit_width() * 45, m_xListBox->get_height_rows(8)); -OAddFieldWindow::OAddFieldWindow(vcl::Window* pParent ,const uno::Reference< beans::XPropertySet >& _xRowSet) - : FloatingWindow(pParent, "FloatingField", "modules/dbreport/ui/floatingfield.ui") - , ::comphelper::OPropertyChangeListener(m_aMutex) - , ::comphelper::OContainerListener(m_aMutex) - , m_xRowSet(_xRowSet) - , m_pListBox(VclPtr::Create(get("box"), this)) - , m_nCommandType(0) - , m_bEscapeProcessing(false) -{ - get(m_aActions, "toolbox"); - m_nSortUpId = m_aActions->GetItemId(0); - m_nSortDownId = m_aActions->GetItemId(1); - m_nRemoveSortId = m_aActions->GetItemId(2); - m_nInsertId = m_aActions->GetItemId(4); - get(m_aHelpText, "helptext"); - - SetHelpId( HID_RPT_FIELD_SEL_WIN ); - SetBackground( Wallpaper( Application::GetSettings().GetStyleSettings().GetFaceColor()) ); - SetMinOutputSizePixel(Size(STD_WIN_SIZE_X,STD_WIN_SIZE_Y)); - - m_aActions->SetLineSpacing(true); - m_aActions->SetBackground( Wallpaper( Application::GetSettings().GetStyleSettings().GetFaceColor()) ); - - m_aActions->SetSelectHdl(LINK(this, OAddFieldWindow, OnSortAction)); - m_aActions->CheckItem(m_nSortUpId); - m_aActions->EnableItem(m_nInsertId, false); - - m_pListBox->SetDoubleClickHdl(LINK( this, OAddFieldWindow, OnDoubleClickHdl ) ); - m_pListBox->SetSelectHdl(LINK( this, OAddFieldWindow, OnSelectHdl ) ); - m_pListBox->SetDeselectHdl(LINK( this, OAddFieldWindow, OnSelectHdl ) ); - m_pListBox->SetDoubleClickHdl(LINK( this, OAddFieldWindow, OnDoubleClickHdl ) ); - m_pListBox->set_expand(true); - m_pListBox->set_height_request(m_pListBox->GetTextHeight() * 8); - m_pListBox->set_width_request(m_pListBox->approximate_char_width() * 40); - m_pListBox->Show(); - - m_aHelpText->SetControlBackground( GetSettings().GetStyleSettings().GetFaceColor() ); - - SetSizePixel(Size(STD_WIN_SIZE_X,STD_WIN_SIZE_Y)); - - if ( m_xRowSet.is() ) + if (m_xRowSet.is()) { try { @@ -206,61 +120,34 @@ OAddFieldWindow::OAddFieldWindow(vcl::Window* pParent ,const uno::Reference< bea OAddFieldWindow::~OAddFieldWindow() { - disposeOnce(); -} - -void OAddFieldWindow::dispose() -{ - if ( m_pListBox.get() ) - { - SvTreeList* pModel = m_pListBox->GetModel(); - sal_uLong nCount = pModel->GetEntryCount(); - for(sal_uLong i = 0; i< nCount;++i) - { - delete static_cast(pModel->GetEntry(i)->GetUserData()); - } - } + m_aListBoxData.clear(); if (m_pChangeListener.is()) m_pChangeListener->dispose(); if ( m_pContainerListener.is() ) m_pContainerListener->dispose(); - - m_aActions.clear(); - m_aHelpText.clear(); - m_pListBox.disposeAndClear(); - FloatingWindow::dispose(); } -void OAddFieldWindow::GetFocus() +IMPL_LINK_NOARG(OAddFieldWindow, FocusChangeHdl, weld::Widget&, void) { - if ( m_pListBox.get() ) - m_pListBox->GrabFocus(); - else - FloatingWindow::GetFocus(); + if (m_xDialog->has_toplevel_focus()) + m_xListBox->grab_focus(); } uno::Sequence< beans::PropertyValue > OAddFieldWindow::getSelectedFieldDescriptors() { - return m_pListBox->getSelectedFieldDescriptors(); -} + std::vector aArgs; + m_xListBox->selected_foreach([this, &aArgs](weld::TreeIter& rEntry){ + // build a descriptor for the currently selected field + svx::ODataAccessDescriptor aDescriptor; + fillDescriptor(rEntry, aDescriptor); + aArgs.push_back(beans::PropertyValue()); + aArgs.back().Value <<= aDescriptor.createPropertyValueSequence(); -bool OAddFieldWindow::PreNotify( NotifyEvent& _rNEvt ) -{ - if ( MouseNotifyEvent::KEYINPUT == _rNEvt.GetType() ) - { - const vcl::KeyCode& rKeyCode = _rNEvt.GetKeyEvent()->GetKeyCode(); - if ( ( 0 == rKeyCode.GetModifier() ) && ( KEY_RETURN == rKeyCode.GetCode() ) ) - { - if ( m_aCreateLink.IsSet() ) - { - m_aCreateLink.Call(*this); - return true; - } - } - } + return false; + }); - return FloatingWindow::PreNotify( _rNEvt ); + return comphelper::containerToSequence(aArgs); } void OAddFieldWindow::_propertyChanged( const beans::PropertyChangeEvent& _evt ) @@ -269,32 +156,34 @@ void OAddFieldWindow::_propertyChanged( const beans::PropertyChangeEvent& _evt ) Update(); } - -namespace +void OAddFieldWindow::addToList(const uno::Sequence< OUString >& rEntries) { - void lcl_addToList( OAddFieldWindowListBox& _rListBox, const uno::Sequence< OUString >& _rEntries ) + for (const OUString& rEntry : rEntries) { - for ( const OUString& rEntry : _rEntries ) - _rListBox.InsertEntry( rEntry,nullptr,false,TREELIST_APPEND,new ColumnInfo(rEntry) ); + m_aListBoxData.emplace_back(new ColumnInfo(rEntry)); + OUString sId(OUString::number(reinterpret_cast(m_aListBoxData.back().get()))); + m_xListBox->append(sId, rEntry); } - void lcl_addToList( OAddFieldWindowListBox& _rListBox, const uno::Reference< container::XNameAccess>& i_xColumns ) +} + +void OAddFieldWindow::addToList(const uno::Reference< container::XNameAccess>& i_xColumns) +{ + const uno::Sequence< OUString > aEntries = i_xColumns->getElementNames(); + for ( const OUString& rEntry : aEntries ) { - const uno::Sequence< OUString > aEntries = i_xColumns->getElementNames(); - for ( const OUString& rEntry : aEntries ) - { - uno::Reference< beans::XPropertySet> xColumn(i_xColumns->getByName(rEntry),UNO_QUERY_THROW); - OUString sLabel; - if ( xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_LABEL) ) - xColumn->getPropertyValue(PROPERTY_LABEL) >>= sLabel; - if ( !sLabel.isEmpty() ) - _rListBox.InsertEntry( sLabel,nullptr,false,TREELIST_APPEND,new ColumnInfo(rEntry,sLabel) ); - else - _rListBox.InsertEntry( rEntry,nullptr,false,TREELIST_APPEND,new ColumnInfo(rEntry,sLabel) ); - } + uno::Reference< beans::XPropertySet> xColumn(i_xColumns->getByName(rEntry),UNO_QUERY_THROW); + OUString sLabel; + if ( xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_LABEL) ) + xColumn->getPropertyValue(PROPERTY_LABEL) >>= sLabel; + m_aListBoxData.emplace_back(new ColumnInfo(rEntry, sLabel)); + OUString sId(OUString::number(reinterpret_cast(m_aListBoxData.back().get()))); + if ( !sLabel.isEmpty() ) + m_xListBox->append(sId, sLabel); + else + m_xListBox->append(sId, rEntry); } } - void OAddFieldWindow::Update() { SolarMutexGuard aSolarGuard; @@ -307,15 +196,14 @@ void OAddFieldWindow::Update() try { // ListBox loeschen - m_pListBox->Clear(); - const ToolBox::ImplToolItems::size_type nItemCount = m_aActions->GetItemCount(); - for (ToolBox::ImplToolItems::size_type j = 0; j< nItemCount; ++j) - { - m_aActions->EnableItem(m_aActions->GetItemId(j),false); - } + m_xListBox->clear(); + m_aListBoxData.clear(); + const OString aIds[] = { "up", "down" }; + for (size_t j = 0; j< SAL_N_ELEMENTS(aIds); ++j) + m_xActions->set_item_sensitive(aIds[j], false); OUString aTitle(RptResId(RID_STR_FIELDSELECTION)); - SetText(aTitle); + m_xDialog->set_title(aTitle); if ( m_xRowSet.is() ) { OUString sCommand( m_aCommandName ); @@ -339,7 +227,7 @@ void OAddFieldWindow::Update() m_xColumns = dbtools::getFieldsByCommandDescriptor( xCon, GetCommandType(), GetCommand(), m_xHoldAlive ); if ( m_xColumns.is() ) { - lcl_addToList( *m_pListBox, m_xColumns ); + addToList(m_xColumns); uno::Reference< container::XContainer> xContainer(m_xColumns,uno::UNO_QUERY); if ( xContainer.is() ) m_pContainerListener = new ::comphelper::OContainerListenerAdapter(this,xContainer); @@ -348,19 +236,17 @@ void OAddFieldWindow::Update() // add the parameter columns to the list uno::Reference< css::sdbc::XRowSet > xRowSet(m_xRowSet,uno::UNO_QUERY); Sequence< OUString > aParamNames( getParameterNames( xRowSet ) ); - lcl_addToList( *m_pListBox, aParamNames ); + addToList(aParamNames); // set title aTitle += " " + m_aCommandName; - SetText( aTitle ); + m_xDialog->set_title(aTitle); if ( !m_aCommandName.isEmpty() ) { - for (ToolBox::ImplToolItems::size_type i = 0; i < nItemCount; ++i) - { - m_aActions->EnableItem(m_aActions->GetItemId(i)); - } + for (size_t i = 0; i < SAL_N_ELEMENTS(aIds); ++i) + m_xActions->set_item_sensitive(aIds[i], true); } - OnSelectHdl(nullptr); + OnSelectHdl(*m_xListBox); } } catch( const Exception& ) @@ -374,9 +260,9 @@ uno::Reference< sdbc::XConnection> OAddFieldWindow::getConnection() const return uno::Reference< sdbc::XConnection>(m_xRowSet->getPropertyValue( PROPERTY_ACTIVECONNECTION ),uno::UNO_QUERY); } -void OAddFieldWindow::fillDescriptor(SvTreeListEntry const * _pSelected,svx::ODataAccessDescriptor& _rDescriptor) +void OAddFieldWindow::fillDescriptor(const weld::TreeIter& rSelected, svx::ODataAccessDescriptor& rDescriptor) { - if ( _pSelected && m_xColumns.is() ) + if (m_xColumns.is()) { uno::Reference xChild(getConnection(),uno::UNO_QUERY); if ( xChild.is( ) ) @@ -386,104 +272,91 @@ void OAddFieldWindow::fillDescriptor(SvTreeListEntry const * _pSelected,svx::ODa { uno::Reference xModel(xDocument->getDatabaseDocument(),uno::UNO_QUERY); if ( xModel.is() ) - _rDescriptor[ DataAccessDescriptorProperty::DatabaseLocation ] <<= xModel->getURL(); + rDescriptor[ DataAccessDescriptorProperty::DatabaseLocation ] <<= xModel->getURL(); } } - _rDescriptor[ svx::DataAccessDescriptorProperty::Command ] <<= GetCommand(); - _rDescriptor[ svx::DataAccessDescriptorProperty::CommandType ] <<= GetCommandType(); - _rDescriptor[ svx::DataAccessDescriptorProperty::EscapeProcessing ] <<= GetEscapeProcessing(); - _rDescriptor[ svx::DataAccessDescriptorProperty::Connection ] <<= getConnection(); + rDescriptor[ svx::DataAccessDescriptorProperty::Command ] <<= GetCommand(); + rDescriptor[ svx::DataAccessDescriptorProperty::CommandType ] <<= GetCommandType(); + rDescriptor[ svx::DataAccessDescriptorProperty::EscapeProcessing ] <<= GetEscapeProcessing(); + rDescriptor[ svx::DataAccessDescriptorProperty::Connection ] <<= getConnection(); - ColumnInfo* pInfo = static_cast(_pSelected->GetUserData()); - _rDescriptor[ svx::DataAccessDescriptorProperty::ColumnName ] <<= pInfo->sColumnName; + ColumnInfo* pInfo = reinterpret_cast(m_xListBox->get_id(rSelected).toInt64()); + rDescriptor[ svx::DataAccessDescriptorProperty::ColumnName ] <<= pInfo->sColumnName; if ( m_xColumns->hasByName( pInfo->sColumnName ) ) - _rDescriptor[ svx::DataAccessDescriptorProperty::ColumnObject ] = m_xColumns->getByName(pInfo->sColumnName); + rDescriptor[ svx::DataAccessDescriptorProperty::ColumnObject ] = m_xColumns->getByName(pInfo->sColumnName); } } void OAddFieldWindow::_elementInserted( const container::ContainerEvent& _rEvent ) { - if ( m_pListBox.get() ) + OUString sName; + if ( (_rEvent.Accessor >>= sName) && m_xColumns->hasByName(sName) ) { - OUString sName; - if ( (_rEvent.Accessor >>= sName) && m_xColumns->hasByName(sName) ) - { - uno::Reference< beans::XPropertySet> xColumn(m_xColumns->getByName(sName),UNO_QUERY_THROW); - OUString sLabel; - if ( xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_LABEL) ) - xColumn->getPropertyValue(PROPERTY_LABEL) >>= sLabel; - if ( !sLabel.isEmpty() ) - m_pListBox->InsertEntry( sLabel,nullptr,false,TREELIST_APPEND,new ColumnInfo(sName,sLabel) ); - else - m_pListBox->InsertEntry( sName,nullptr,false,TREELIST_APPEND,new ColumnInfo(sName,sLabel) ); - } + uno::Reference< beans::XPropertySet> xColumn(m_xColumns->getByName(sName),UNO_QUERY_THROW); + OUString sLabel; + if ( xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_LABEL) ) + xColumn->getPropertyValue(PROPERTY_LABEL) >>= sLabel; + m_aListBoxData.emplace_back(new ColumnInfo(sName, sLabel)); + OUString sId(OUString::number(reinterpret_cast(m_aListBoxData.back().get()))); + if (!sLabel.isEmpty()) + m_xListBox->append(sId, sLabel); + else + m_xListBox->append(sId, sName); } } void OAddFieldWindow::_elementRemoved( const container::ContainerEvent& /*_rEvent*/ ) { - if ( m_pListBox.get() ) - { - m_pListBox->Clear(); - if ( m_xColumns.is() ) - lcl_addToList( *m_pListBox, m_xColumns ); - } + m_xListBox->clear(); + m_aListBoxData.clear(); + if ( m_xColumns.is() ) + addToList(m_xColumns); } void OAddFieldWindow::_elementReplaced( const container::ContainerEvent& /*_rEvent*/ ) { } -IMPL_LINK_NOARG( OAddFieldWindow, OnSelectHdl, SvTreeListBox*, void ) +IMPL_LINK_NOARG( OAddFieldWindow, OnSelectHdl, weld::TreeView&, void ) { - m_aActions->EnableItem(m_nInsertId, ( m_pListBox.get() && m_pListBox->GetSelectionCount() > 0 )); + m_xActions->set_item_sensitive("insert", m_xListBox->get_selected_index() != -1); } -IMPL_LINK_NOARG( OAddFieldWindow, OnDoubleClickHdl, SvTreeListBox*, bool ) +IMPL_LINK_NOARG( OAddFieldWindow, OnDoubleClickHdl, weld::TreeView&, bool ) { m_aCreateLink.Call(*this); - - return false; + return true; } -IMPL_LINK_NOARG( OAddFieldWindow, OnSortAction, ToolBox*, void ) +IMPL_LINK(OAddFieldWindow, OnSortAction, const OString&, rCurItem, void) { - const sal_uInt16 nCurItem = m_aActions->GetCurItemId(); - if (nCurItem == m_nInsertId) - OnDoubleClickHdl(nullptr); - else + if (rCurItem == "insert") { - if (nCurItem == m_nRemoveSortId || !m_aActions->IsItemChecked(nCurItem)) - { - const ToolBox::ImplToolItems::size_type nItemCount = m_aActions->GetItemCount(); - for (ToolBox::ImplToolItems::size_type j = 0; j< nItemCount; ++j) - { - const sal_uInt16 nItemId = m_aActions->GetItemId(j); - if ( nCurItem != nItemId ) - m_aActions->CheckItem(nItemId,false); - } - SvSortMode eSortMode = SortNone; - if (nCurItem != m_nRemoveSortId) - { - m_aActions->CheckItem(nCurItem,!m_aActions->IsItemChecked(nCurItem)); - if (m_aActions->IsItemChecked(m_nSortUpId)) - eSortMode = SortAscending; - else if (m_aActions->IsItemChecked(m_nSortDownId)) - eSortMode = SortDescending; - } + OnDoubleClickHdl(*m_xListBox); + return; + } - m_pListBox->GetModel()->SetSortMode(eSortMode); - if (nCurItem == m_nRemoveSortId) - Update(); + const OString aIds[] = { "up", "down" }; - m_pListBox->GetModel()->Resort(); - } + if (rCurItem == "delete") + { + for (size_t j = 0; j< SAL_N_ELEMENTS(aIds); ++j) + m_xActions->set_item_active(aIds[j], false); + + m_xListBox->make_unsorted(); + Update(); + return; } -} + for (size_t j = 0; j< SAL_N_ELEMENTS(aIds); ++j) + m_xActions->set_item_active(aIds[j], rCurItem == aIds[j]); -} // namespace rptui + m_xListBox->make_sorted(); + if (m_xActions->get_item_active("down")) + m_xListBox->set_sort_order(false); +} +} // namespace rptui /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/reportdesign/source/ui/dlg/Formula.cxx b/reportdesign/source/ui/dlg/Formula.cxx index f4c46be3ce6c..8d391e92072e 100644 --- a/reportdesign/source/ui/dlg/Formula.cxx +++ b/reportdesign/source/ui/dlg/Formula.cxx @@ -53,7 +53,6 @@ FormulaDialog::FormulaDialog(weld::Window* pParent : FormulaModalDialog( pParent, _pFunctionMgr.get(),this) ,m_aFunctionManager(_pFunctionMgr) ,m_xFormulaData(new FormEditData()) - ,m_pAddField(nullptr) ,m_xRowSet(_xRowSet) ,m_pEdit(nullptr) ,m_sFormula("=") @@ -88,15 +87,19 @@ void FormulaDialog::fill() FormulaDialog::~FormulaDialog() { - if ( m_pAddField ) + if ( m_xAddField ) { SvtViewOptions aDlgOpt( EViewType::Window, HID_RPT_FIELD_SEL_WIN ); - aDlgOpt.SetWindowState(OStringToOUString(m_pAddField->GetWindowState(WindowStateMask::X | WindowStateMask::Y | WindowStateMask::State | WindowStateMask::Minimized), RTL_TEXTENCODING_ASCII_US)); + aDlgOpt.SetWindowState(OStringToOUString(m_xAddField->getDialog()->get_window_state(WindowStateMask::X | WindowStateMask::Y | WindowStateMask::State | WindowStateMask::Minimized), RTL_TEXTENCODING_ASCII_US)); + + if (m_xAddField->getDialog()->get_visible()) + m_xAddField->response(RET_CANCEL); + + m_xAddField.reset(); } StoreFormEditData(m_xFormulaData.get()); m_pEdit = nullptr; - m_pAddField.clear(); } // functions for right side @@ -205,21 +208,23 @@ void FormulaDialog::ToggleCollapsed( RefEdit* _pEdit, RefButton* _pButton) if ( aPair.first ) aPair.first->GetWidget()->hide(); - if ( !m_pAddField ) + if (!m_xAddField) { - m_pAddField = VclPtr::Create(nullptr, m_xRowSet); - m_pAddField->SetCreateHdl(LINK( this, FormulaDialog, OnClickHdl ) ); + m_xAddField = std::make_shared(m_xDialog.get(), m_xRowSet); + m_xAddField->SetCreateHdl(LINK( this, FormulaDialog, OnClickHdl ) ); SvtViewOptions aDlgOpt( EViewType::Window, HID_RPT_FIELD_SEL_WIN ); if ( aDlgOpt.Exists() ) { - m_pAddField->SetWindowState(OUStringToOString(aDlgOpt.GetWindowState(), RTL_TEXTENCODING_ASCII_US)); + m_xAddField->getDialog()->set_window_state(OUStringToOString(aDlgOpt.GetWindowState(), RTL_TEXTENCODING_ASCII_US)); } - m_pAddField->Update(); + m_xAddField->Update(); } RefInputStartAfter(); - m_pAddField->Show(); + + if (!m_xAddField->getDialog()->get_visible()) + weld::DialogController::runAsync(m_xAddField, [this](sal_Int32 /*nResult*/) { m_xAddField.reset(); }); } IMPL_LINK( FormulaDialog, OnClickHdl, OAddFieldWindow& ,_rAddFieldDlg, void) @@ -240,7 +245,8 @@ IMPL_LINK( FormulaDialog, OnClickHdl, OAddFieldWindow& ,_rAddFieldDlg, void) } } m_pEdit = nullptr; - _rAddFieldDlg.Hide(); + if (_rAddFieldDlg.getDialog()->get_visible()) + _rAddFieldDlg.response(RET_CANCEL); RefInputDoneAfter(); } diff --git a/reportdesign/source/ui/inc/AddField.hxx b/reportdesign/source/ui/inc/AddField.hxx index 2c16546e1004..b5397b284fc3 100644 --- a/reportdesign/source/ui/inc/AddField.hxx +++ b/reportdesign/source/ui/inc/AddField.hxx @@ -23,66 +23,65 @@ #include #include #include -#include -#include -#include #include #include -#include #include +#include #include -#include -#include + +#include +#include #include +#include "ColumnInfo.hxx" + namespace rptui { class OAddFieldWindow; -class OAddFieldWindowListBox; -class OAddFieldWindow :public FloatingWindow - , public ::cppu::BaseMutex - , public ::comphelper::OPropertyChangeListener - , public ::comphelper::OContainerListener +class OAddFieldWindow : public weld::GenericDialogController + , public ::cppu::BaseMutex + , public ::comphelper::OPropertyChangeListener + , public ::comphelper::OContainerListener { css::uno::Reference< css::lang::XComponent> m_xHoldAlive; css::uno::Reference< css::container::XNameAccess> m_xColumns; css::uno::Reference< css::beans::XPropertySet > m_xRowSet; - VclPtr m_aActions; - - VclPtr m_pListBox; - VclPtr m_aHelpText; + std::unique_ptr m_xActions; + std::unique_ptr m_xListBox; + std::unique_ptr m_xHelpText; Link m_aCreateLink; OUString m_aCommandName; OUString m_sFilter; - sal_uInt16 m_nSortUpId; - sal_uInt16 m_nSortDownId; - sal_uInt16 m_nRemoveSortId; - sal_uInt16 m_nInsertId; sal_Int32 m_nCommandType; bool m_bEscapeProcessing; ::rtl::Reference< comphelper::OPropertyChangeMultiplexer> m_pChangeListener; ::rtl::Reference< comphelper::OContainerListenerAdapter> m_pContainerListener; + ::rtl::Reference< svx::OMultiColumnTransferable > m_xHelper; + + std::vector> m_aListBoxData; + + DECL_LINK( OnDoubleClickHdl, weld::TreeView&, bool ); + DECL_LINK( OnSelectHdl, weld::TreeView&, void ); + DECL_LINK( DragBeginHdl, weld::TreeView&, bool ); + DECL_LINK( OnSortAction, const OString&, void ); + DECL_LINK( FocusChangeHdl, weld::Widget&, void ); - DECL_LINK( OnDoubleClickHdl, SvTreeListBox*, bool ); - DECL_LINK( OnSelectHdl, SvTreeListBox*, void ); - DECL_LINK( OnSortAction, ToolBox*, void ); + void addToList(const css::uno::Sequence& rEntries); + void addToList(const css::uno::Reference& i_xColumns); OAddFieldWindow(const OAddFieldWindow&) = delete; void operator =(const OAddFieldWindow&) = delete; public: - OAddFieldWindow(vcl::Window* pParent - , const css::uno::Reference< css::beans::XPropertySet >& _xRowSet); + OAddFieldWindow(weld::Window* pParent, + const css::uno::Reference< css::beans::XPropertySet >& xRowSet); virtual ~OAddFieldWindow() override; - virtual void dispose() override; - virtual void GetFocus() override; - virtual bool PreNotify( NotifyEvent& _rNEvt ) override; const OUString& GetCommand() const { return m_aCommandName; } sal_Int32 GetCommandType() const { return m_nCommandType; } @@ -98,10 +97,10 @@ public: /** fills the descriptor with the column name, column object, command and command type * - * \param _pSelected the currently selected - * \param _rDescriptor the descriptor will be filled + * \param rSelected the currently selected + * \param rDescriptor the descriptor will be filled */ - void fillDescriptor(SvTreeListEntry const * _pSelected,svx::ODataAccessDescriptor& _rDescriptor); + void fillDescriptor(const weld::TreeIter& rSelected, svx::ODataAccessDescriptor& rDescriptor); private: // FmXChangeListener diff --git a/reportdesign/source/ui/inc/DesignView.hxx b/reportdesign/source/ui/inc/DesignView.hxx index 5a5adf9ab8ef..05136a7544c3 100644 --- a/reportdesign/source/ui/inc/DesignView.hxx +++ b/reportdesign/source/ui/inc/DesignView.hxx @@ -63,7 +63,7 @@ namespace rptui VclPtr m_aScrollWindow; VclPtr m_pTaskPane; VclPtr m_pPropWin; - VclPtr m_pAddField; + std::shared_ptr m_xAddField; OSectionView* m_pCurrentView; VclPtr m_pReportExplorer; Idle m_aMarkIdle; diff --git a/reportdesign/source/ui/inc/Formula.hxx b/reportdesign/source/ui/inc/Formula.hxx index 1335c6012dd8..504c445ddaac 100644 --- a/reportdesign/source/ui/inc/Formula.hxx +++ b/reportdesign/source/ui/inc/Formula.hxx @@ -47,7 +47,7 @@ class FormulaDialog : public formula::FormulaModalDialog, { std::shared_ptr m_aFunctionManager; std::unique_ptr m_xFormulaData; - VclPtr m_pAddField; + std::shared_ptr m_xAddField; css::uno::Reference < css::beans::XPropertySet > m_xRowSet; css::uno::Reference< css::report::meta::XFormulaParser> m_xParser; css::uno::Reference< css::sheet::XFormulaOpCodeMapper> m_xOpCodeMapper; diff --git a/reportdesign/source/ui/report/DesignView.cxx b/reportdesign/source/ui/report/DesignView.cxx index f65c2ead1830..7f5df21d53a3 100644 --- a/reportdesign/source/ui/report/DesignView.cxx +++ b/reportdesign/source/ui/report/DesignView.cxx @@ -90,7 +90,6 @@ ODesignView::ODesignView( vcl::Window* pParent, ,m_rReportController( _rController ) ,m_aScrollWindow(VclPtr::Create(this)) ,m_pPropWin(nullptr) - ,m_pAddField(nullptr) ,m_pCurrentView(nullptr) ,m_pReportExplorer(nullptr) ,m_eMode( DlgEdMode::Select ) @@ -135,12 +134,15 @@ void ODesignView::dispose() notifySystemWindow(this,m_pPropWin,::comphelper::mem_fun(&TaskPaneList::RemoveWindow)); m_pPropWin.disposeAndClear(); } - if ( m_pAddField ) + if ( m_xAddField ) { SvtViewOptions aDlgOpt( EViewType::Window, UID_RPT_RPT_APP_VIEW ); - aDlgOpt.SetWindowState(OStringToOUString(m_pAddField->GetWindowState(), RTL_TEXTENCODING_ASCII_US)); - notifySystemWindow(this,m_pAddField,::comphelper::mem_fun(&TaskPaneList::RemoveWindow)); - m_pAddField.disposeAndClear(); + aDlgOpt.SetWindowState(OStringToOUString(m_xAddField->getDialog()->get_window_state(WindowStateMask::All), RTL_TEXTENCODING_ASCII_US)); + + if (m_xAddField->getDialog()->get_visible()) + m_xAddField->response(RET_CANCEL); + + m_xAddField.reset(); } if ( m_pReportExplorer ) { @@ -184,7 +186,7 @@ bool ODesignView::PreNotify( NotifyEvent& rNEvt ) { if ( m_pPropWin && m_pPropWin->HasChildPathFocus() ) return false; - if ( m_pAddField && m_pAddField->HasChildPathFocus() ) + if (m_xAddField && m_xAddField->getDialog()->has_toplevel_focus()) return false; if ( m_pReportExplorer && m_pReportExplorer->HasChildPathFocus() ) return false; @@ -483,12 +485,12 @@ void ODesignView::toggleReportExplorer() bool ODesignView::isAddFieldVisible() const { - return m_pAddField && m_pAddField->IsVisible(); + return m_xAddField && m_xAddField->getDialog()->get_visible(); } void ODesignView::toggleAddField() { - if ( !m_pAddField ) + if (!m_xAddField) { uno::Reference< report::XReportDefinition > xReport(m_xReportComponent,uno::UNO_QUERY); uno::Reference< report::XReportComponent > xReportComponent(m_xReportComponent,uno::UNO_QUERY); @@ -506,18 +508,17 @@ void ODesignView::toggleAddField() xReport = xSection->getReportDefinition(); } uno::Reference < beans::XPropertySet > xSet(rReportController.getRowSet(),uno::UNO_QUERY); - m_pAddField = VclPtr::Create(this,xSet); - m_pAddField->SetCreateHdl(LINK( &rReportController, OReportController, OnCreateHdl ) ); + m_xAddField = std::make_shared(GetFrameWeld(), xSet); + m_xAddField->SetCreateHdl(LINK( &rReportController, OReportController, OnCreateHdl ) ); SvtViewOptions aDlgOpt( EViewType::Window, UID_RPT_RPT_APP_VIEW ); if ( aDlgOpt.Exists() ) - m_pAddField->SetWindowState(OUStringToOString(aDlgOpt.GetWindowState(), RTL_TEXTENCODING_ASCII_US)); - m_pAddField->Update(); - m_pAddField->AddEventListener(LINK(&rReportController,OReportController,EventLstHdl)); - notifySystemWindow(this,m_pAddField,::comphelper::mem_fun(&TaskPaneList::AddWindow)); - m_pAddField->Show(); + m_xAddField->getDialog()->set_window_state(OUStringToOString(aDlgOpt.GetWindowState(), RTL_TEXTENCODING_ASCII_US)); + m_xAddField->Update(); } + if (!m_xAddField->getDialog()->get_visible()) + weld::DialogController::runAsync(m_xAddField, [this](sal_Int32 /*nResult*/) { m_xAddField.reset(); }); else - m_pAddField->Show(!m_pAddField->IsVisible()); + m_xAddField->response(RET_CANCEL); } uno::Reference< report::XSection > ODesignView::getCurrentSection() const @@ -584,7 +585,7 @@ bool ODesignView::handleKeyEvent(const KeyEvent& _rEvent) { if ( m_pPropWin && m_pPropWin->HasChildPathFocus() ) return false; - if ( m_pAddField && m_pAddField->HasChildPathFocus() ) + if (m_xAddField && m_xAddField->getDialog()->has_toplevel_focus()) return false; if ( m_pReportExplorer && m_pReportExplorer->HasChildPathFocus() ) return false; diff --git a/reportdesign/uiconfig/dbreport/ui/floatingfield.ui b/reportdesign/uiconfig/dbreport/ui/floatingfield.ui index e18e3279925d..65ac5bdc19c2 100644 --- a/reportdesign/uiconfig/dbreport/ui/floatingfield.ui +++ b/reportdesign/uiconfig/dbreport/ui/floatingfield.ui @@ -1,124 +1,188 @@ - + - - True + + + + + + + + + False - True - True 6 Sorting and Grouping - utility + 0 + 0 + dialog - + + + + True False - 6 - 12 + vertical + + + False + True + end + + + + + + False + True + end + 0 + + - + True False - start True - icons - - - True - False - Sort Ascending - True - cmd/sc_sortup.png - - - False - True - - - - - True - False - Sort Descending - True - cmd/sc_sortdown.png - - - False - True - - + True + 6 - + True False - Remove sorting - True - cmd/sc_removefiltersort.png + start + True + icons + + + True + False + Sort Ascending + True + cmd/sc_sortup.png + + + False + False + + + + + True + False + Sort Descending + True + cmd/sc_sortdown.png + + + False + False + + + + + True + False + Remove sorting + True + cmd/sc_removefiltersort.png + + + False + False + + + + + True + False + + + False + False + + + + + True + False + Insert + True + + + False + False + + - False - True + 0 + 0 - + True - False + True + True + True + in + + + True + True + True + True + True + liststore1 + False + True + 0 + False + + + + + + True + + + + 0 + + + + + + - False - True + 0 + 1 - + True False - Insert - True + Highlight the fields to insert into the selected section of the template, then click Insert or press Enter. + True + 45 + 45 + 0 - False - True + 0 + 2 - 0 - 0 - - - - - True - False - start - Highlight the fields to insert into the selected section of the template, then click Insert or press Enter. - True - 60 - 0 - - - 0 - 2 - - - - - True - False - True - True - vertical - - - - - - 0 - 1 + True + True + 0 diff --git a/svx/source/fmcomp/dbaexchange.cxx b/svx/source/fmcomp/dbaexchange.cxx index 698a7e6e6055..8316e7eea6f3 100644 --- a/svx/source/fmcomp/dbaexchange.cxx +++ b/svx/source/fmcomp/dbaexchange.cxx @@ -49,6 +49,8 @@ namespace svx void OColumnTransferable::setDescriptor(const ODataAccessDescriptor& rDescriptor) { + ClearFormats(); + OUString sDataSource, sDatabaseLocation, sConnectionResource, sCommand, sFieldName; if ( rDescriptor.has( DataAccessDescriptorProperty::DataSource ) ) rDescriptor[ DataAccessDescriptorProperty::DataSource ] >>= sDataSource; if ( rDescriptor.has( DataAccessDescriptorProperty::DatabaseLocation ) ) rDescriptor[ DataAccessDescriptorProperty::DatabaseLocation ] >>= sDatabaseLocation; @@ -59,7 +61,6 @@ namespace svx sal_Int32 nCommandType = CommandType::TABLE; OSL_VERIFY( rDescriptor[ DataAccessDescriptorProperty::CommandType ] >>= nCommandType ); - implConstruct( sDataSource.isEmpty() ? sDatabaseLocation : sDataSource, sConnectionResource, nCommandType, sCommand, sFieldName ); @@ -558,9 +559,14 @@ namespace svx m_sCompatibleObjectDescription += sSeparator; } + OMultiColumnTransferable::OMultiColumnTransferable() + { + } - OMultiColumnTransferable::OMultiColumnTransferable(const Sequence< PropertyValue >& _aDescriptors) : m_aDescriptors(_aDescriptors) + void OMultiColumnTransferable::setDescriptors(const Sequence< PropertyValue >& rDescriptors) { + ClearFormats(); + m_aDescriptors = rDescriptors; } SotClipboardFormatId OMultiColumnTransferable::getDescriptorFormatId() @@ -590,7 +596,6 @@ namespace svx return false; } - bool OMultiColumnTransferable::canExtractDescriptor(const DataFlavorExVector& _rFlavors) { const SotClipboardFormatId nFormatId = getDescriptorFormatId(); @@ -598,7 +603,6 @@ namespace svx [&nFormatId](const DataFlavorEx& rCheck) { return nFormatId == rCheck.mnSotId; }); } - Sequence< PropertyValue > OMultiColumnTransferable::extractDescriptor(const TransferableDataHelper& _rData) { Sequence< PropertyValue > aList; @@ -619,9 +623,6 @@ namespace svx { m_aDescriptors.realloc(0); } - - } - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/uiconfig/ui/formfielddialog.ui b/svx/uiconfig/ui/formfielddialog.ui index 3a3d56441852..d77c2ce7856c 100644 --- a/svx/uiconfig/ui/formfielddialog.ui +++ b/svx/uiconfig/ui/formfielddialog.ui @@ -15,7 +15,7 @@ 6 0 0 - dialog + utility -- cgit