Kaydet (Commit) 7f8004ef authored tarafından Tamás Zolnai's avatar Tamás Zolnai Kaydeden (comit) Andras Timar

MSForms: Introduce a properties dialog for Drop-down form field

- Dialog created similar to the edit dialog of Input field
- On the dialog, the user can edit the list of the drop down field
- This dialog is only for editing of the field, so the user can't select
an item from the list to display in the field.

Reviewed-on: https://gerrit.libreoffice.org/67909
Tested-by: Jenkins
Reviewed-by: 's avatarTamás Zolnai <tamas.zolnai@collabora.com>
(cherry picked from commit 117da8da)

Change-Id: I6222aba9b211afeb0e9d10d97a49347921ff7353
Reviewed-on: https://gerrit.libreoffice.org/67924Reviewed-by: 's avatarAndras Timar <andras.timar@collabora.com>
Tested-by: 's avatarAndras Timar <andras.timar@collabora.com>
üst 8c9aa1c4
...@@ -110,6 +110,7 @@ $(eval $(call gb_Library_add_exception_objects,swui,\ ...@@ -110,6 +110,7 @@ $(eval $(call gb_Library_add_exception_objects,swui,\
sw/source/ui/envelp/labprt \ sw/source/ui/envelp/labprt \
sw/source/ui/envelp/mailmrge \ sw/source/ui/envelp/mailmrge \
sw/source/ui/fldui/DropDownFieldDialog \ sw/source/ui/fldui/DropDownFieldDialog \
sw/source/ui/fldui/DropDownFormFieldDialog \
sw/source/ui/fldui/FldRefTreeListBox \ sw/source/ui/fldui/FldRefTreeListBox \
sw/source/ui/fldui/changedb \ sw/source/ui/fldui/changedb \
sw/source/ui/fldui/flddb \ sw/source/ui/fldui/flddb \
......
...@@ -122,6 +122,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/swriter,\ ...@@ -122,6 +122,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/swriter,\
sw/uiconfig/swriter/ui/datasourcesunavailabledialog \ sw/uiconfig/swriter/ui/datasourcesunavailabledialog \
sw/uiconfig/swriter/ui/dropcapspage \ sw/uiconfig/swriter/ui/dropcapspage \
sw/uiconfig/swriter/ui/dropdownfielddialog \ sw/uiconfig/swriter/ui/dropdownfielddialog \
sw/uiconfig/swriter/ui/dropdownformfielddialog \
sw/uiconfig/swriter/ui/editcategories \ sw/uiconfig/swriter/ui/editcategories \
sw/uiconfig/swriter/ui/editfielddialog \ sw/uiconfig/swriter/ui/editfielddialog \
sw/uiconfig/swriter/ui/editsectiondialog \ sw/uiconfig/swriter/ui/editsectiondialog \
......
...@@ -91,6 +91,9 @@ namespace com{namespace sun{namespace star{ ...@@ -91,6 +91,9 @@ namespace com{namespace sun{namespace star{
} }
}}} }}}
namespace sw { namespace mark { class IFieldmark; } }
typedef void (*SwLabDlgMethod) (css::uno::Reference< css::frame::XModel> const & xModel, const SwLabItem& rItem); typedef void (*SwLabDlgMethod) (css::uno::Reference< css::frame::XModel> const & xModel, const SwLabItem& rItem);
typedef OUString (*GlossaryGetCurrGroup)(); typedef OUString (*GlossaryGetCurrGroup)();
...@@ -409,8 +412,11 @@ public: ...@@ -409,8 +412,11 @@ public:
virtual VclPtr<AbstractDropDownFieldDialog> CreateDropDownFieldDialog(SwWrtShell &rSh, virtual VclPtr<AbstractDropDownFieldDialog> CreateDropDownFieldDialog(SwWrtShell &rSh,
SwField* pField, bool bPrevButton, bool bNextButton) = 0; SwField* pField, bool bPrevButton, bool bNextButton) = 0;
virtual VclPtr<VclAbstractDialog> CreateDropDownFormFieldDialog(sw::mark::IFieldmark* pDropDownField) = 0;
virtual VclPtr<SfxAbstractTabDialog> CreateSwEnvDlg ( vcl::Window* pParent, const SfxItemSet& rSet, SwWrtShell* pWrtSh, Printer* pPrt, bool bInsert ) = 0; virtual VclPtr<SfxAbstractTabDialog> CreateSwEnvDlg ( vcl::Window* pParent, const SfxItemSet& rSet, SwWrtShell* pWrtSh, Printer* pPrt, bool bInsert ) = 0;
virtual VclPtr<AbstractSwLabDlg> CreateSwLabDlg(const SfxItemSet& rSet, virtual VclPtr<AbstractSwLabDlg> CreateSwLabDlg(const SfxItemSet& rSet,
SwDBManager* pDBManager, bool bLabel) = 0; SwDBManager* pDBManager, bool bLabel) = 0;
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include <docfnote.hxx> #include <docfnote.hxx>
#include <docstdlg.hxx> #include <docstdlg.hxx>
#include <DropDownFieldDialog.hxx> #include <DropDownFieldDialog.hxx>
#include <DropDownFormFieldDialog.hxx>
#include <envlop.hxx> #include <envlop.hxx>
#include <label.hxx> #include <label.hxx>
#include <drpcps.hxx> #include <drpcps.hxx>
...@@ -86,6 +87,7 @@ ...@@ -86,6 +87,7 @@
#include <uiborder.hxx> #include <uiborder.hxx>
#include <mmresultdialogs.hxx> #include <mmresultdialogs.hxx>
using namespace ::com::sun::star; using namespace ::com::sun::star;
IMPL_ABSTDLG_BASE(AbstractSwWordCountFloatDlg_Impl); IMPL_ABSTDLG_BASE(AbstractSwWordCountFloatDlg_Impl);
...@@ -99,9 +101,11 @@ IMPL_ABSTDLG_BASE(AbstractTabDialog_Impl); ...@@ -99,9 +101,11 @@ IMPL_ABSTDLG_BASE(AbstractTabDialog_Impl);
IMPL_ABSTDLG_BASE(AbstractSwConvertTableDlg_Impl); IMPL_ABSTDLG_BASE(AbstractSwConvertTableDlg_Impl);
IMPL_ABSTDLG_BASE(AbstractSwInsertDBColAutoPilot_Impl); IMPL_ABSTDLG_BASE(AbstractSwInsertDBColAutoPilot_Impl);
IMPL_ABSTDLG_BASE(AbstractDropDownFieldDialog_Impl); IMPL_ABSTDLG_BASE(AbstractDropDownFieldDialog_Impl);
IMPL_ABSTDLG_BASE(AbstractDropDownFormFieldDialog_Impl);
IMPL_ABSTDLG_BASE(AbstractSwLabDlg_Impl); IMPL_ABSTDLG_BASE(AbstractSwLabDlg_Impl);
IMPL_ABSTDLG_BASE(AbstractSwSelGlossaryDlg_Impl); IMPL_ABSTDLG_BASE(AbstractSwSelGlossaryDlg_Impl);
IMPL_ABSTDLG_BASE(AbstractSwAutoFormatDlg_Impl); IMPL_ABSTDLG_BASE(AbstractSwAutoFormatDlg_Impl);
IMPL_ABSTDLG_BASE(AbstractSwFieldDlg_Impl); IMPL_ABSTDLG_BASE(AbstractSwFieldDlg_Impl);
IMPL_ABSTDLG_BASE(AbstractSwRenameXNamedDlg_Impl); IMPL_ABSTDLG_BASE(AbstractSwRenameXNamedDlg_Impl);
IMPL_ABSTDLG_BASE(AbstractSwModalRedlineAcceptDlg_Impl); IMPL_ABSTDLG_BASE(AbstractSwModalRedlineAcceptDlg_Impl);
...@@ -771,6 +775,12 @@ VclPtr<AbstractDropDownFieldDialog> SwAbstractDialogFactory_Impl::CreateDropDown ...@@ -771,6 +775,12 @@ VclPtr<AbstractDropDownFieldDialog> SwAbstractDialogFactory_Impl::CreateDropDown
return VclPtr<AbstractDropDownFieldDialog_Impl>::Create( pDlg ); return VclPtr<AbstractDropDownFieldDialog_Impl>::Create( pDlg );
} }
VclPtr<VclAbstractDialog> SwAbstractDialogFactory_Impl::CreateDropDownFormFieldDialog(sw::mark::IFieldmark* pDropDownField)
{
VclPtr<sw::DropDownFormFieldDialog> pDlg = VclPtr<sw::DropDownFormFieldDialog>::Create(nullptr, pDropDownField);
return VclPtr<VclAbstractDialog_Impl>::Create( pDlg );
}
VclPtr<SfxAbstractTabDialog> SwAbstractDialogFactory_Impl::CreateSwEnvDlg ( vcl::Window* pParent, const SfxItemSet& rSet, VclPtr<SfxAbstractTabDialog> SwAbstractDialogFactory_Impl::CreateSwEnvDlg ( vcl::Window* pParent, const SfxItemSet& rSet,
SwWrtShell* pWrtSh, Printer* pPrt, SwWrtShell* pWrtSh, Printer* pPrt,
bool bInsert ) bool bInsert )
......
...@@ -44,6 +44,7 @@ class SwSplitTableDlg; ...@@ -44,6 +44,7 @@ class SwSplitTableDlg;
namespace sw namespace sw
{ {
class DropDownFieldDialog; class DropDownFieldDialog;
class DropDownFormFieldDialog;
} }
#define DECL_ABSTDLG_BASE(Class,DialogClass) \ #define DECL_ABSTDLG_BASE(Class,DialogClass) \
...@@ -167,6 +168,11 @@ class AbstractDropDownFieldDialog_Impl : public AbstractDropDownFieldDialog ...@@ -167,6 +168,11 @@ class AbstractDropDownFieldDialog_Impl : public AbstractDropDownFieldDialog
virtual bool NextButtonPressed() const override; virtual bool NextButtonPressed() const override;
}; };
class AbstractDropDownFormFieldDialog_Impl : public VclAbstractDialog
{
DECL_ABSTDLG_BASE(AbstractDropDownFormFieldDialog_Impl, sw::DropDownFormFieldDialog)
};
class AbstractSwLabDlg_Impl : public AbstractSwLabDlg class AbstractSwLabDlg_Impl : public AbstractSwLabDlg
{ {
DECL_ABSTDLG_BASE(AbstractSwLabDlg_Impl,SwLabDlg) DECL_ABSTDLG_BASE(AbstractSwLabDlg_Impl,SwLabDlg)
...@@ -403,6 +409,7 @@ public: ...@@ -403,6 +409,7 @@ public:
virtual VclPtr<AbstractDropDownFieldDialog> CreateDropDownFieldDialog(SwWrtShell &rSh, virtual VclPtr<AbstractDropDownFieldDialog> CreateDropDownFieldDialog(SwWrtShell &rSh,
SwField* pField, bool bPrevButton, bool bNextButton) override; SwField* pField, bool bPrevButton, bool bNextButton) override;
virtual VclPtr<VclAbstractDialog> CreateDropDownFormFieldDialog(sw::mark::IFieldmark* pDropDownField) override;
virtual VclPtr<SfxAbstractTabDialog> CreateSwEnvDlg ( vcl::Window* pParent, const SfxItemSet& rSet, SwWrtShell* pWrtSh, Printer* pPrt, bool bInsert ) override; virtual VclPtr<SfxAbstractTabDialog> CreateSwEnvDlg ( vcl::Window* pParent, const SfxItemSet& rSet, SwWrtShell* pWrtSh, Printer* pPrt, bool bInsert ) override;
virtual VclPtr<AbstractSwLabDlg> CreateSwLabDlg(const SfxItemSet& rSet, virtual VclPtr<AbstractSwLabDlg> CreateSwLabDlg(const SfxItemSet& rSet,
SwDBManager* pDBManager, bool bLabel) override; SwDBManager* pDBManager, bool bLabel) override;
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <convert.hxx> #include <convert.hxx>
#include <dbinsdlg.hxx> #include <dbinsdlg.hxx>
#include <DropDownFieldDialog.hxx> #include <DropDownFieldDialog.hxx>
#include <DropDownFormFieldDialog.hxx>
#include <fldtdlg.hxx> #include <fldtdlg.hxx>
#include <glossary.hxx> #include <glossary.hxx>
#include <inpdlg.hxx> #include <inpdlg.hxx>
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
/*
* 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 <DropDownFormFieldDialog.hxx>
#include <vcl/event.hxx>
#include <IMark.hxx>
#include <xmloff/odffields.hxx>
namespace sw
{
DropDownFormFieldDialog::DropDownFormFieldDialog(vcl::Window* pParent,
mark::IFieldmark* pDropDownField)
: SvxStandardDialog(pParent, "DropDownFormFieldDialog",
"modules/swriter/ui/dropdownformfielddialog.ui")
, m_pDropDownField(pDropDownField)
, m_bListHasChanged(false)
{
get(m_xListItemEntry, "item_entry");
get(m_xListAddButton, "add_button");
get(m_xListItemsTreeView, "items_treeview");
get(m_xListRemoveButton, "remove_button");
get(m_xListUpButton, "up_button");
get(m_xListDownButton, "down_button");
m_xListItemsTreeView->set_width_request(m_xListItemEntry->get_preferred_size().Width());
m_xListItemsTreeView->set_height_request(m_xListItemEntry->get_preferred_size().Height() * 5);
m_xListItemsTreeView->SetSelectHdl(LINK(this, DropDownFormFieldDialog, SelectHdl));
m_xListItemEntry->SetModifyHdl(LINK(this, DropDownFormFieldDialog, ModifyEditHdl));
m_xListItemEntry->SetReturnActionLink(LINK(this, DropDownFormFieldDialog, ReturnActionHdl));
Link<Button*, void> aPushButtonLink(LINK(this, DropDownFormFieldDialog, ButtonPushedHdl));
m_xListAddButton->SetClickHdl(aPushButtonLink);
m_xListRemoveButton->SetClickHdl(aPushButtonLink);
m_xListUpButton->SetClickHdl(aPushButtonLink);
m_xListDownButton->SetClickHdl(aPushButtonLink);
InitControls();
}
DropDownFormFieldDialog::~DropDownFormFieldDialog() {}
IMPL_LINK_NOARG(DropDownFormFieldDialog, SelectHdl, ListBox&, void) { UpdateButtons(); }
IMPL_LINK_NOARG(DropDownFormFieldDialog, ModifyEditHdl, Edit&, void) { UpdateButtons(); }
IMPL_LINK_NOARG(DropDownFormFieldDialog, ReturnActionHdl, ReturnActionEdit&, void)
{
AppendItemToList();
}
IMPL_LINK(DropDownFormFieldDialog, ButtonPushedHdl, Button*, pButton, void)
{
if (pButton == m_xListAddButton)
{
AppendItemToList();
}
else if (m_xListItemsTreeView->GetSelectedEntryPos() != LISTBOX_ENTRY_NOTFOUND)
{
int nSelPos = m_xListItemsTreeView->GetSelectedEntryPos();
if (pButton == m_xListRemoveButton)
{
m_xListItemsTreeView->RemoveEntry(nSelPos);
m_xListItemsTreeView->SelectEntryPos(nSelPos > 0 ? nSelPos - 1 : 0);
}
else if (pButton == m_xListUpButton)
{
const OUString sEntry = m_xListItemsTreeView->GetSelectedEntry();
m_xListItemsTreeView->RemoveEntry(nSelPos);
nSelPos--;
m_xListItemsTreeView->InsertEntry(sEntry, nSelPos);
m_xListItemsTreeView->SelectEntryPos(nSelPos);
}
else if (pButton == m_xListDownButton)
{
const OUString sEntry = m_xListItemsTreeView->GetSelectedEntry();
m_xListItemsTreeView->RemoveEntry(nSelPos);
nSelPos++;
m_xListItemsTreeView->InsertEntry(sEntry, nSelPos);
m_xListItemsTreeView->SelectEntryPos(nSelPos);
}
m_bListHasChanged = true;
}
UpdateButtons();
}
void DropDownFormFieldDialog::InitControls()
{
if (m_pDropDownField != nullptr)
{
const mark::IFieldmark::parameter_map_t* const pParameters
= m_pDropDownField->GetParameters();
auto pListEntries = pParameters->find(ODF_FORMDROPDOWN_LISTENTRY);
if (pListEntries != pParameters->end())
{
css::uno::Sequence<OUString> vListEntries;
pListEntries->second >>= vListEntries;
for (const OUString& rItem : vListEntries)
m_xListItemsTreeView->InsertEntry(rItem);
// Select the current one
auto pResult = pParameters->find(ODF_FORMDROPDOWN_RESULT);
if (pResult != pParameters->end())
{
sal_Int32 nSelection = -1;
pResult->second >>= nSelection;
m_xListItemsTreeView->SelectEntry(vListEntries[nSelection]);
}
}
}
UpdateButtons();
}
void DropDownFormFieldDialog::AppendItemToList()
{
if (m_xListAddButton->IsEnabled())
{
const OUString sEntry(m_xListItemEntry->GetText());
if (!sEntry.isEmpty())
{
m_xListItemsTreeView->InsertEntry(sEntry);
m_xListItemsTreeView->SelectEntry(sEntry);
m_bListHasChanged = true;
// Clear entry
m_xListItemEntry->SetText(OUString());
m_xListItemEntry->GrabFocus();
}
UpdateButtons();
}
}
void DropDownFormFieldDialog::UpdateButtons()
{
m_xListAddButton->Enable(
!m_xListItemEntry->GetText().isEmpty()
&& (LISTBOX_ENTRY_NOTFOUND
== m_xListItemsTreeView->GetEntryPos(m_xListItemEntry->GetText())));
int nSelPos = m_xListItemsTreeView->GetSelectedEntryPos();
m_xListRemoveButton->Enable(nSelPos != LISTBOX_ENTRY_NOTFOUND);
m_xListUpButton->Enable(nSelPos != LISTBOX_ENTRY_NOTFOUND && nSelPos != 0);
m_xListDownButton->Enable(nSelPos != LISTBOX_ENTRY_NOTFOUND
&& nSelPos < m_xListItemsTreeView->GetEntryCount() - 1);
}
void DropDownFormFieldDialog::Apply()
{
if (m_pDropDownField != nullptr && m_bListHasChanged)
{
mark::IFieldmark::parameter_map_t* pParameters = m_pDropDownField->GetParameters();
css::uno::Sequence<OUString> vListEntries(m_xListItemsTreeView->GetEntryCount());
for (int nIndex = 0; nIndex < m_xListItemsTreeView->GetEntryCount(); ++nIndex)
{
vListEntries[nIndex] = m_xListItemsTreeView->GetEntry(nIndex);
}
if (vListEntries.getLength() != 0)
{
(*pParameters)[ODF_FORMDROPDOWN_LISTENTRY] <<= vListEntries;
}
else
{
pParameters->erase(ODF_FORMDROPDOWN_LISTENTRY);
}
// After editing the drop down field's list we don't specify the selected item
pParameters->erase(ODF_FORMDROPDOWN_RESULT);
}
}
} // namespace sw
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef INCLUDED_SW_SOURCE_UIBASE_INC_DROPDOWNFORMFIELDDIALOG_HXX
#define INCLUDED_SW_SOURCE_UIBASE_INC_DROPDOWNFORMFIELDDIALOG_HXX
#include <vcl/lstbox.hxx>
#include <vcl/button.hxx>
#include <vcl/edit.hxx>
#include <vcl/window.hxx>
#include <svx/stddlg.hxx>
#include "actctrl.hxx"
namespace sw
{
namespace mark
{
class IFieldmark;
}
} // namespace sw
/// Dialog to specify the properties of drop-down form field
namespace sw
{
class DropDownFormFieldDialog : public SvxStandardDialog
{
private:
mark::IFieldmark* m_pDropDownField;
bool m_bListHasChanged;
VclPtr<ReturnActionEdit> m_xListItemEntry;
VclPtr<PushButton> m_xListAddButton;
VclPtr<ListBox> m_xListItemsTreeView;
VclPtr<PushButton> m_xListRemoveButton;
VclPtr<PushButton> m_xListUpButton;
VclPtr<PushButton> m_xListDownButton;
DECL_LINK(SelectHdl, ListBox&, void);
DECL_LINK(ModifyEditHdl, Edit&, void);
DECL_LINK(ReturnActionHdl, ReturnActionEdit&, void);
DECL_LINK(ButtonPushedHdl, Button*, void);
void InitControls();
void AppendItemToList();
void UpdateButtons();
virtual void Apply() override;
public:
DropDownFormFieldDialog(vcl::Window* pParent, mark::IFieldmark* pDropDownField);
virtual ~DropDownFormFieldDialog() override;
};
} // namespace sw
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
This diff is collapsed.
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