diff options
author | Caolán McNamara <caolanm@redhat.com> | 2019-12-02 12:43:00 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-12-03 21:04:45 +0100 |
commit | eef7c4d30bdf4b8250b2de4186ba58fcaebe4993 (patch) | |
tree | 2ecb2d124aa50ebe8246d02b53e5896fab24d40e /reportdesign/source | |
parent | 1f0c54c250c2390962105128dcf871aad0689323 (diff) |
weld OAddFieldWindow
Change-Id: I1e0ca144943fd37769c7b6cfc7e77c4f001b31a0
Reviewed-on: https://gerrit.libreoffice.org/84233
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'reportdesign/source')
-rw-r--r-- | reportdesign/source/ui/dlg/AddField.cxx | 389 | ||||
-rw-r--r-- | reportdesign/source/ui/dlg/Formula.cxx | 28 | ||||
-rw-r--r-- | reportdesign/source/ui/inc/AddField.hxx | 59 | ||||
-rw-r--r-- | reportdesign/source/ui/inc/DesignView.hxx | 2 | ||||
-rw-r--r-- | reportdesign/source/ui/inc/Formula.hxx | 2 | ||||
-rw-r--r-- | reportdesign/source/ui/report/DesignView.cxx | 35 |
6 files changed, 197 insertions, 318 deletions
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 <AddField.hxx> #include <UITools.hxx> -#include <svx/dbaexchange.hxx> #include <svx/svdpagv.hxx> #include <com/sun/star/sdb/CommandType.hpp> #include <com/sun/star/util/URL.hpp> @@ -38,17 +37,15 @@ #include <helpids.h> #include <strings.hrc> #include <strings.hxx> -#include <ColumnInfo.hxx> #include <comphelper/processfactory.hxx> #include <comphelper/property.hxx> +#include <comphelper/sequence.hxx> #include <svtools/imgdef.hxx> #include <vcl/treelistentry.hxx> 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<OAddFieldWindow> 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<TransferDataContainer> 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<OMultiColumnTransferable> 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<OAddFieldWindowListBox>::Create(get<vcl::Window>("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<ColumnInfo*>(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<beans::PropertyValue> 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<sal_Int64>(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<sal_Int64>(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<container::XChild> xChild(getConnection(),uno::UNO_QUERY); if ( xChild.is( ) ) @@ -386,104 +272,91 @@ void OAddFieldWindow::fillDescriptor(SvTreeListEntry const * _pSelected,svx::ODa { uno::Reference<frame::XModel> 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<ColumnInfo*>(_pSelected->GetUserData()); - _rDescriptor[ svx::DataAccessDescriptorProperty::ColumnName ] <<= pInfo->sColumnName; + ColumnInfo* pInfo = reinterpret_cast<ColumnInfo*>(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<sal_Int64>(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<OAddFieldWindow>::Create(nullptr, m_xRowSet); - m_pAddField->SetCreateHdl(LINK( this, FormulaDialog, OnClickHdl ) ); + m_xAddField = std::make_shared<OAddFieldWindow>(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 <com/sun/star/lang/XComponent.hpp> #include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/sdbc/XConnection.hpp> -#include <vcl/transfer.hxx> -#include <vcl/treelistbox.hxx> -#include <vcl/floatwin.hxx> #include <comphelper/propmultiplex.hxx> #include <comphelper/containermultiplexer.hxx> -#include <vcl/button.hxx> #include <svx/dataaccessdescriptor.hxx> +#include <svx/dbaexchange.hxx> #include <cppuhelper/basemutex.hxx> -#include <vcl/toolbox.hxx> -#include <vcl/fixed.hxx> + +#include <vcl/transfer.hxx> +#include <vcl/weld.hxx> #include <rtl/ref.hxx> +#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<ToolBox> m_aActions; - - VclPtr<OAddFieldWindowListBox> m_pListBox; - VclPtr<FixedText> m_aHelpText; + std::unique_ptr<weld::Toolbar> m_xActions; + std::unique_ptr<weld::TreeView> m_xListBox; + std::unique_ptr<weld::Label> m_xHelpText; Link<OAddFieldWindow&,void> 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<std::unique_ptr<ColumnInfo>> 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<OUString>& rEntries); + void addToList(const css::uno::Reference<css::container::XNameAccess>& 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<OScrollWindowHelper> m_aScrollWindow; VclPtr<vcl::Window> m_pTaskPane; VclPtr<PropBrw> m_pPropWin; - VclPtr<OAddFieldWindow> m_pAddField; + std::shared_ptr<OAddFieldWindow> m_xAddField; OSectionView* m_pCurrentView; VclPtr<ONavigator> 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<formula::IFunctionManager> m_aFunctionManager; std::unique_ptr<formula::FormEditData> m_xFormulaData; - VclPtr<OAddFieldWindow> m_pAddField; + std::shared_ptr<OAddFieldWindow> 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<rptui::OScrollWindowHelper>::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<OAddFieldWindow>::Create(this,xSet); - m_pAddField->SetCreateHdl(LINK( &rReportController, OReportController, OnCreateHdl ) ); + m_xAddField = std::make_shared<OAddFieldWindow>(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; |