Kaydet (Commit) 27702e0c authored tarafından Caolán McNamara's avatar Caolán McNamara

weld SwLineNumberingDlg

and use the same SetFieldUnit as the reset of writer uses

Change-Id: I7fbc4743cdcf057a40b4b84375c62293b8edd074
Reviewed-on: https://gerrit.libreoffice.org/52607Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 1a4e0b30
......@@ -67,6 +67,7 @@ public:
virtual void set_margin_bottom(int nMargin) = 0;
virtual void set_accessible_name(const OUString& rName) = 0;
virtual OUString get_accessible_name() const = 0;
virtual void connect_focus_in(const Link<Widget&, void>& rLink) = 0;
virtual void connect_focus_out(const Link<Widget&, void>& rLink) = 0;
......
......@@ -87,7 +87,7 @@ class WriterLineNumbering(UITestCase):
self.assertEqual(get_state_as_dict(xstyledropdown)["SelectEntryText"], "Bullets")
self.assertEqual(get_state_as_dict(xformatdropdown)["SelectEntryText"], "A, B, C, ...")
self.assertEqual(get_state_as_dict(xpositiondropdown)["SelectEntryText"], "Right")
self.assertEqual(get_state_as_dict(xspacingspin)["Text"], "1.00 cm")
self.assertEqual(get_state_as_dict(xspacingspin)["Text"], "0.60 cm")
self.assertEqual(get_state_as_dict(xintervalspin)["Text"], "6")
self.assertEqual(get_state_as_dict(xtextentry)["Text"], ";")
self.assertEqual(get_state_as_dict(xlinesspin)["Text"], "4")
......@@ -118,4 +118,4 @@ class WriterLineNumbering(UITestCase):
xCancelBtn = xDialog.getChild("cancel")
self.ui_test.close_dialog_through_button(xCancelBtn)
self.ui_test.close_doc()
# vim: set shiftwidth=4 softtabstop=4 expandtab:
\ No newline at end of file
# vim: set shiftwidth=4 softtabstop=4 expandtab:
......@@ -115,6 +115,10 @@ short AbstractSwMergeTableDlg_Impl::Execute()
{
return m_xDlg->execute();
}
short AbstractGenericDialog_Impl::Execute()
{
return m_xDlg->run();
}
short AbstractSwSortDlg_Impl::Execute()
{
return m_xDlg->execute();
......@@ -950,8 +954,7 @@ VclPtr<VclAbstractDialog> SwAbstractDialogFactory_Impl::CreateTitlePageDlg ( vcl
VclPtr<VclAbstractDialog> SwAbstractDialogFactory_Impl::CreateVclSwViewDialog(SwView& rView)
{
VclPtr<Dialog> pDlg = VclPtr<SwLineNumberingDlg>::Create( &rView );
return VclPtr<VclAbstractDialog_Impl>::Create( pDlg );
return VclPtr<AbstractGenericDialog_Impl>::Create(new SwLineNumberingDlg(rView));
}
VclPtr<AbstractInsTableDlg> SwAbstractDialogFactory_Impl::CreateInsTableDlg(SwView& rView)
......
......@@ -106,6 +106,18 @@ class VclAbstractDialog_Impl : public VclAbstractDialog
DECL_ABSTDLG_BASE(VclAbstractDialog_Impl,Dialog)
};
class AbstractGenericDialog_Impl : public VclAbstractDialog
{
protected:
std::unique_ptr<weld::GenericDialogController> m_xDlg;
public:
explicit AbstractGenericDialog_Impl(weld::GenericDialogController* p)
: m_xDlg(p)
{
}
virtual short Execute() override;
};
class AbstractSwSortDlg_Impl : public VclAbstractDialog
{
protected:
......
This diff is collapsed.
......@@ -19,43 +19,41 @@
#ifndef INCLUDED_SW_SOURCE_UIBASE_INC_LINENUM_HXX
#define INCLUDED_SW_SOURCE_UIBASE_INC_LINENUM_HXX
#include <sfx2/basedlgs.hxx>
#include <vcl/button.hxx>
#include <vcl/layout.hxx>
#include <vcl/lstbox.hxx>
#include <vcl/weld.hxx>
#include "numberingtypelistbox.hxx"
namespace vcl { class Window; }
class SwView;
class SwWrtShell;
class SwLineNumberingDlg : public SfxModalDialog
class SwLineNumberingDlg : public weld::GenericDialogController
{
private:
SwWrtShell* pSh;
VclPtr<VclContainer> m_pBodyContent;
VclPtr<vcl::Window> m_pDivIntervalFT;
VclPtr<NumericField> m_pDivIntervalNF;
VclPtr<vcl::Window> m_pDivRowsFT;
VclPtr<NumericField> m_pNumIntervalNF;
VclPtr<ListBox> m_pCharStyleLB;
VclPtr<SwNumberingTypeListBox> m_pFormatLB;
VclPtr<ListBox> m_pPosLB;
VclPtr<MetricField> m_pOffsetMF;
VclPtr<Edit> m_pDivisorED;
VclPtr<CheckBox> m_pCountEmptyLinesCB;
VclPtr<CheckBox> m_pCountFrameLinesCB;
VclPtr<CheckBox> m_pRestartEachPageCB;
VclPtr<CheckBox> m_pNumberingOnCB;
VclPtr<CheckBox> m_pNumberingOnFooterHeader;
DECL_LINK(OKHdl, Button*, void);
DECL_LINK(LineOnOffHdl, Button*, void);
DECL_LINK(ModifyHdl, Edit&, void);
SwWrtShell* m_pSh;
std::unique_ptr<weld::Widget> m_xBodyContent;
std::unique_ptr<weld::Widget> m_xDivIntervalFT;
std::unique_ptr<weld::SpinButton> m_xDivIntervalNF;
std::unique_ptr<weld::Widget> m_xDivRowsFT;
std::unique_ptr<weld::SpinButton> m_xNumIntervalNF;
std::unique_ptr<weld::ComboBoxText> m_xCharStyleLB;
std::unique_ptr<NumberingTypeListBox> m_xFormatLB;
std::unique_ptr<weld::ComboBoxText> m_xPosLB;
std::unique_ptr<weld::MetricSpinButton> m_xOffsetMF;
std::unique_ptr<weld::Entry> m_xDivisorED;
std::unique_ptr<weld::CheckButton> m_xCountEmptyLinesCB;
std::unique_ptr<weld::CheckButton> m_xCountFrameLinesCB;
std::unique_ptr<weld::CheckButton> m_xRestartEachPageCB;
std::unique_ptr<weld::CheckButton> m_xNumberingOnCB;
std::unique_ptr<weld::CheckButton> m_xNumberingOnFooterHeader;
std::unique_ptr<weld::Button> m_xOKButton;
std::unique_ptr<weld::Widget> m_xNumIntervalFT;
std::unique_ptr<weld::Widget> m_xNumRowsFT;
DECL_LINK(OKHdl, weld::Button&, void);
DECL_LINK(LineOnOffHdl, weld::Button&, void);
DECL_LINK(ModifyHdl, weld::Entry&, void);
public:
SwLineNumberingDlg(SwView const *pVw);
SwLineNumberingDlg(const SwView& rVw);
virtual ~SwLineNumberingDlg() override;
virtual void dispose() override;
};
#endif
......
......@@ -21,6 +21,7 @@
#include <memory>
#include <vcl/lstbox.hxx>
#include <vcl/weld.hxx>
#include <swdllapi.h>
#include <o3tl/typed_flags_set.hxx>
#include <editeng/svxenum.hxx>
......@@ -57,6 +58,20 @@ public:
bool SelectNumberingType(SvxNumType nType);
};
class SW_DLLPUBLIC NumberingTypeListBox
{
std::unique_ptr<weld::ComboBoxText> m_xWidget;
std::unique_ptr<SwNumberingTypeListBox_Impl> m_xImpl;
public:
NumberingTypeListBox(weld::ComboBoxText* pWidget);
~NumberingTypeListBox();
void Reload(SwInsertNumTypes nTypeFlags);
SvxNumType GetSelectedNumberingType();
bool SelectNumberingType(SvxNumType nType);
};
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -184,4 +184,122 @@ bool SwNumberingTypeListBox::SelectNumberingType(SvxNumType nType)
return LISTBOX_ENTRY_NOTFOUND != nPos;
}
NumberingTypeListBox::NumberingTypeListBox(weld::ComboBoxText* pWidget)
: m_xWidget(pWidget)
, m_xImpl(new SwNumberingTypeListBox_Impl)
{
uno::Reference<uno::XComponentContext> xContext( ::comphelper::getProcessComponentContext() );
uno::Reference<text::XDefaultNumberingProvider> xDefNum = text::DefaultNumberingProvider::create(xContext);
m_xImpl->xInfo.set(xDefNum, uno::UNO_QUERY);
}
NumberingTypeListBox::~NumberingTypeListBox()
{
}
void NumberingTypeListBox::Reload(SwInsertNumTypes nTypeFlags)
{
m_xWidget->clear();
uno::Sequence<sal_Int16> aTypes;
const sal_Int16* pTypes = nullptr;
if (nTypeFlags & SwInsertNumTypes::Extended)
{
if (m_xImpl->xInfo.is())
{
aTypes = m_xImpl->xInfo->getSupportedNumberingTypes();
pTypes = aTypes.getConstArray();
}
}
for(size_t i = 0; i < SvxNumberingTypeTable::Count(); i++)
{
sal_IntPtr nValue = SvxNumberingTypeTable::GetValue(i);
bool bInsert = true;
int nPos = -1;
switch(nValue)
{
case style::NumberingType::NUMBER_NONE:
bInsert = bool(nTypeFlags & SwInsertNumTypes::NoNumbering);
nPos = 0;
break;
case style::NumberingType::CHAR_SPECIAL:
bInsert = bool(nTypeFlags & SwInsertNumTypes::Bullet);
break;
case style::NumberingType::PAGE_DESCRIPTOR:
bInsert = bool(nTypeFlags & SwInsertNumTypes::PageStyleNumbering);
break;
case style::NumberingType::BITMAP:
bInsert = bool(nTypeFlags & SwInsertNumTypes::Bitmap );
break;
case style::NumberingType::BITMAP | LINK_TOKEN:
bInsert = false;
break;
default:
if (nValue > style::NumberingType::CHARS_LOWER_LETTER_N)
{
// Insert only if offered by i18n framework per configuration.
bInsert = false;
if (pTypes)
{
for(sal_Int32 nType = 0; nType < aTypes.getLength(); nType++)
{
if (pTypes[nType] == nValue)
{
bInsert = true;
break; // for
}
}
}
}
}
if (bInsert)
{
m_xWidget->insert(nPos, OUString::number(nValue), SvxNumberingTypeTable::GetString(i));
}
}
if (nTypeFlags & SwInsertNumTypes::Extended)
{
if (pTypes)
{
for (sal_Int32 nType = 0; nType < aTypes.getLength(); nType++)
{
sal_Int16 nCurrent = pTypes[nType];
if (nCurrent > style::NumberingType::CHARS_LOWER_LETTER_N)
{
if (m_xWidget->find_id(OUString::number(nCurrent)) == -1)
{
m_xWidget->insert(-1, OUString::number(nCurrent), m_xImpl->xInfo->getNumberingIdentifier(nCurrent));
}
}
}
}
m_xWidget->set_active(0);
}
}
SvxNumType NumberingTypeListBox::GetSelectedNumberingType()
{
SvxNumType nRet = SVX_NUM_CHARS_UPPER_LETTER;
int nSelPos = m_xWidget->get_active();
if (nSelPos != -1)
nRet = static_cast<SvxNumType>(m_xWidget->get_id(nSelPos).toInt32());
#if OSL_DEBUG_LEVEL > 0
else
OSL_FAIL("NumberingTypeListBox not selected");
#endif
return nRet;
}
bool NumberingTypeListBox::SelectNumberingType(SvxNumType nType)
{
int nPos = m_xWidget->find_id(OUString::number(nType));
m_xWidget->set_active(nPos);
return nPos != -1;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -310,6 +310,11 @@ public:
m_xWidget->SetAccessibleName(rName);
}
virtual OUString get_accessible_name() const override
{
return m_xWidget->GetAccessibleName();
}
virtual void connect_focus_in(const Link<Widget&, void>& rLink) override
{
assert(!m_aFocusInHdl.IsSet());
......
......@@ -1332,7 +1332,14 @@ public:
AtkObject* pAtkObject = gtk_widget_get_accessible(m_pWidget);
if (!pAtkObject)
return;
atk_object_set_description(pAtkObject, OUStringToOString(rName, RTL_TEXTENCODING_UTF8).getStr());
atk_object_set_name(pAtkObject, OUStringToOString(rName, RTL_TEXTENCODING_UTF8).getStr());
}
virtual OUString get_accessible_name() const override
{
AtkObject* pAtkObject = gtk_widget_get_accessible(m_pWidget);
const char* pStr = pAtkObject ? atk_object_get_name(pAtkObject) : nullptr;
return OUString(pStr, pStr ? strlen(pStr) : 0, RTL_TEXTENCODING_UTF8);
}
virtual weld::Container* weld_parent() const override;
......
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