diff options
author | Tamás Zolnai <tamas.zolnai@collabora.com> | 2019-03-04 20:52:38 +0100 |
---|---|---|
committer | Tamás Zolnai <tamas.zolnai@collabora.com> | 2019-03-09 21:58:40 +0100 |
commit | 10be5b6ce972dff517f3ceed41cab04d3e051f57 (patch) | |
tree | 2cd382716b678e7d493ff679417a4f5761e5766d /sw/source/uibase | |
parent | 31f96c3e0d13180447c45212158ee69e791c645a (diff) |
MSForms: Add a drop-down button for drop-down form field
* Introduce a editing frame with a button for drop-down form field.
** The frame is mouse transparent.
** Pushing the button opens the popup window with the items of the field.
* The button is visible when the cursor is inside the field.
Change-Id: I5c7db138d14380899fee046c95a5afe14cfea213
Reviewed-on: https://gerrit.libreoffice.org/68961
Tested-by: Jenkins
Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>
Diffstat (limited to 'sw/source/uibase')
-rw-r--r-- | sw/source/uibase/docvw/edtwin.cxx | 6 | ||||
-rw-r--r-- | sw/source/uibase/shells/textsh1.cxx | 14 | ||||
-rw-r--r-- | sw/source/uibase/uiview/view.cxx | 3 | ||||
-rw-r--r-- | sw/source/uibase/uiview/viewling.cxx | 110 |
4 files changed, 13 insertions, 120 deletions
diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx index 22458d77b710..85d24b1d61c5 100644 --- a/sw/source/uibase/docvw/edtwin.cxx +++ b/sw/source/uibase/docvw/edtwin.cxx @@ -4627,12 +4627,6 @@ void SwEditWin::MouseButtonUp(const MouseEvent& rMEvt) rCheckboxFm.SetChecked(!rCheckboxFm.IsChecked()); rCheckboxFm.Invalidate(); rSh.InvalidateWindows( m_rView.GetVisArea() ); - } else if ( fieldBM->GetFieldname() == ODF_FORMDROPDOWN ) { - m_rView.ExecFieldPopup( aDocPt, fieldBM ); - fieldBM->Invalidate(); - rSh.InvalidateWindows( m_rView.GetVisArea() ); - } else { - // unknown type.. } } } diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx index 65484c32e748..c70e84156b97 100644 --- a/sw/source/uibase/shells/textsh1.cxx +++ b/sw/source/uibase/shells/textsh1.cxx @@ -120,6 +120,8 @@ #include <numrule.hxx> #include <memory> #include <xmloff/odffields.hxx> +#include <swabstdlg.hxx> +#include <bookmrk.hxx> using namespace ::com::sun::star; using namespace com::sun::star::beans; @@ -1382,10 +1384,14 @@ void SwTextShell::Execute(SfxRequest &rReq) { SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateDropDownFormFieldDialog(rWrtSh.GetView().GetFrameWeld(), pFieldBM)); - pDlg->Execute(); - pFieldBM->Invalidate(); - rWrtSh.InvalidateWindows( rWrtSh.GetView().GetVisArea() ); - rWrtSh.UpdateCursor(); // cursor position might be invalid + if (pDlg->Execute() == RET_OK) + { + pFieldBM->Invalidate(); + rWrtSh.InvalidateWindows( rWrtSh.GetView().GetVisArea() ); + rWrtSh.UpdateCursor(); // cursor position might be invalid + // Hide the button here and make it visible later, to make transparent background work with SAL_USE_VCLPLUGIN=gen + dynamic_cast<::sw::mark::DropDownFieldmark*>(pFieldBM)->HideButton(); + } } else { diff --git a/sw/source/uibase/uiview/view.cxx b/sw/source/uibase/uiview/view.cxx index 63febf29b44a..59fc540e0d35 100644 --- a/sw/source/uibase/uiview/view.cxx +++ b/sw/source/uibase/uiview/view.cxx @@ -1067,6 +1067,9 @@ SwView::~SwView() SfxLokHelper::notifyOtherViews(this, LOK_CALLBACK_TEXT_VIEW_SELECTION, "selection", ""); SfxLokHelper::notifyOtherViews(this, LOK_CALLBACK_GRAPHIC_VIEW_SELECTION, "selection", "EMPTY"); + // Need to remove activated field's button before disposing EditWin. + GetWrtShell().getIDocumentMarkAccess()->ClearFieldActivation(); + GetViewFrame()->GetWindow().RemoveChildEventListener( LINK( this, SwView, WindowChildEventListener ) ); m_pPostItMgr.reset(); diff --git a/sw/source/uibase/uiview/viewling.cxx b/sw/source/uibase/uiview/viewling.cxx index 7d6aac2913d9..3ac2ebcadd3e 100644 --- a/sw/source/uibase/uiview/viewling.cxx +++ b/sw/source/uibase/uiview/viewling.cxx @@ -825,114 +825,4 @@ void SwView::ExecSmartTagPopup( const Point& rPt ) m_pWrtShell->LockView( bOldViewLock ); } -class SwFieldDialog : public FloatingWindow -{ -private: - VclPtr<ListBox> aListBox; - IFieldmark *pFieldmark; - - DECL_LINK( MyListBoxHandler, ListBox&, void ); - -public: - SwFieldDialog( SwEditWin* parent, IFieldmark *fieldBM ); - virtual ~SwFieldDialog() override; - virtual void dispose() override; -}; - -SwFieldDialog::SwFieldDialog( SwEditWin* parent, IFieldmark *fieldBM ) : - FloatingWindow( parent, WB_BORDER | WB_SYSTEMWINDOW ), - aListBox(VclPtr<ListBox>::Create(this)), - pFieldmark( fieldBM ) -{ - if ( fieldBM != nullptr ) - { - const IFieldmark::parameter_map_t* const pParameters = fieldBM->GetParameters(); - - OUString sListKey = ODF_FORMDROPDOWN_LISTENTRY; - IFieldmark::parameter_map_t::const_iterator pListEntries = pParameters->find( sListKey ); - if(pListEntries != pParameters->end()) - { - Sequence< OUString > vListEntries; - pListEntries->second >>= vListEntries; - for( OUString const & i : vListEntries) - aListBox->InsertEntry(i); - } - - // Select the current one - OUString sResultKey = ODF_FORMDROPDOWN_RESULT; - IFieldmark::parameter_map_t::const_iterator pResult = pParameters->find( sResultKey ); - if ( pResult != pParameters->end() ) - { - sal_Int32 nSelection = -1; - pResult->second >>= nSelection; - aListBox->SelectEntryPos( nSelection ); - } - } - - Size lbSize(aListBox->GetOptimalSize()); - lbSize.AdjustWidth(50 ); - lbSize.AdjustHeight(20 ); - aListBox->SetSizePixel(lbSize); - aListBox->SetSelectHdl( LINK( this, SwFieldDialog, MyListBoxHandler ) ); - aListBox->Show(); - - SetSizePixel( lbSize ); -} - -SwFieldDialog::~SwFieldDialog() -{ - disposeOnce(); -} - -void SwFieldDialog::dispose() -{ - aListBox.disposeAndClear(); - FloatingWindow::dispose(); -} - -IMPL_LINK( SwFieldDialog, MyListBoxHandler, ListBox&, rBox, void ) -{ - if ( !rBox.IsTravelSelect() ) - { - sal_Int32 selection = rBox.GetSelectedEntryPos(); - if ( selection >= 0 ) - { - OUString sKey = ODF_FORMDROPDOWN_RESULT; - (*pFieldmark->GetParameters())[ sKey ] <<= selection; - pFieldmark->Invalidate(); - SwView& rView = static_cast<SwEditWin*>( GetParent() )->GetView(); - rView.GetDocShell()->SetModified(); - } - - EndPopupMode(); - } -} - -IMPL_LINK_NOARG(SwView, FieldPopupModeEndHdl, FloatingWindow*, void) -{ - m_pFieldPopup.disposeAndClear(); -} - -void SwView::ExecFieldPopup( const Point& rPt, IFieldmark *fieldBM ) -{ - // Don't show popup if there is no list item - auto pListEntries = fieldBM->GetParameters()->find( ODF_FORMDROPDOWN_LISTENTRY ); - Sequence< OUString > vListEntries; - if(pListEntries != fieldBM->GetParameters()->end()) - { - pListEntries->second >>= vListEntries; - } - - if(vListEntries.getLength() == 0) - return; - - const Point aPixPos = GetEditWin().LogicToPixel( rPt ); - - m_pFieldPopup = VclPtr<SwFieldDialog>::Create( m_pEditWin, fieldBM ); - m_pFieldPopup->SetPopupModeEndHdl( LINK( this, SwView, FieldPopupModeEndHdl ) ); - - tools::Rectangle aRect( m_pEditWin->OutputToScreenPixel( aPixPos ), Size( 0, 0 ) ); - m_pFieldPopup->StartPopupMode( aRect, FloatWinPopupFlags::Down|FloatWinPopupFlags::GrabFocus ); -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |