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

weld split cells dialog

Change-Id: I726c6d84807ab3efba509058eed554fe4c0ffced
Reviewed-on: https://gerrit.libreoffice.org/50636Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst dab9a2b6
...@@ -20,90 +20,71 @@ ...@@ -20,90 +20,71 @@
#include <sfx2/dispatch.hxx> #include <sfx2/dispatch.hxx>
#include <svl/intitem.hxx> #include <svl/intitem.hxx>
#include <svl/eitem.hxx> #include <svl/eitem.hxx>
#include <vcl/svapp.hxx>
#include <dialmgr.hxx> #include <dialmgr.hxx>
#include <splitcelldlg.hxx> #include <splitcelldlg.hxx>
namespace { SvxSplitTableDlg::SvxSplitTableDlg(weld::Window *pParent, bool bIsTableVertical, long nMaxVertical, long nMaxHorizontal)
class NoApplyDialog : public SvxStandardDialog : m_xBuilder(Application::CreateBuilder(pParent, "cui/ui/splitcellsdialog.ui"))
{ , m_xDialog(m_xBuilder->weld_dialog("SplitCellsDialog"))
public: , m_xCountEdit(m_xBuilder->weld_spin_button("countnf"))
NoApplyDialog(vcl::Window *pParent, const OUString &rId, const OUString &rXML) : , m_xHorzBox(!bIsTableVertical ? m_xBuilder->weld_radio_button("hori") : m_xBuilder->weld_radio_button("vert"))
SvxStandardDialog(pParent, rId, rXML) { } , m_xVertBox(!bIsTableVertical ? m_xBuilder->weld_radio_button("vert") : m_xBuilder->weld_radio_button("hori"))
protected: , m_xPropCB(m_xBuilder->weld_check_button("prop"))
virtual void Apply() override {}
};
}
SvxSplitTableDlg::SvxSplitTableDlg( vcl::Window *pParent, bool bIsTableVertical,
long nMaxVertical, long nMaxHorizontal )
: m_pDialog(VclPtr<NoApplyDialog>::Create(pParent, "SplitCellsDialog", "cui/ui/splitcellsdialog.ui"))
, mnMaxVertical(nMaxVertical) , mnMaxVertical(nMaxVertical)
, mnMaxHorizontal(nMaxHorizontal) , mnMaxHorizontal(nMaxHorizontal)
{ {
m_pDialog->get(m_pCountEdit, "countnf"); m_xHorzBox->connect_clicked(LINK(this, SvxSplitTableDlg, ClickHdl));
m_pDialog->get(m_pHorzBox, "hori"); m_xPropCB->connect_clicked(LINK(this, SvxSplitTableDlg, ClickHdl));
m_pDialog->get(m_pVertBox, "vert"); m_xVertBox->connect_clicked(LINK(this, SvxSplitTableDlg, ClickHdl));
m_pDialog->get(m_pPropCB, "prop");
m_pHorzBox->SetClickHdl( LINK( this, SvxSplitTableDlg, ClickHdl ));
m_pPropCB->SetClickHdl( LINK( this, SvxSplitTableDlg, ClickHdl ));
m_pVertBox->SetClickHdl( LINK( this, SvxSplitTableDlg, ClickHdl ));
if( mnMaxVertical < 2 ) if (mnMaxVertical < 2)
m_pVertBox->Enable(false); {
if (!bIsTableVertical)
m_xVertBox->set_sensitive(false);
else
m_xHorzBox->set_sensitive(false);
}
//exchange the meaning of horizontal and vertical for vertical text //exchange the meaning of horizontal and vertical for vertical text
if(bIsTableVertical) if (bIsTableVertical)
{ {
Image aTmpImg(m_pHorzBox->GetModeRadioImage()); int nHorzTopAttach = m_xHorzBox->get_grid_top_attach();
OUString sTmp(m_pHorzBox->GetText()); int nVertTopAttach = m_xVertBox->get_grid_top_attach();
m_pHorzBox->SetText(m_pVertBox->GetText()); m_xHorzBox->set_grid_top_attach(nVertTopAttach);
m_pHorzBox->SetModeRadioImage(m_pVertBox->GetModeRadioImage()); m_xVertBox->set_grid_top_attach(nHorzTopAttach);
m_pVertBox->SetText(sTmp); m_xHorzBox->set_active(m_xVertBox->get_active());
m_pVertBox->SetModeRadioImage(aTmpImg);
} }
} }
SvxSplitTableDlg::~SvxSplitTableDlg() IMPL_LINK(SvxSplitTableDlg, ClickHdl, weld::Button&, rButton, void)
{
disposeOnce();
}
void SvxSplitTableDlg::dispose()
{
m_pCountEdit.clear();
m_pHorzBox.clear();
m_pVertBox.clear();
m_pPropCB.clear();
m_pDialog.disposeAndClear();
SvxAbstractSplittTableDialog::dispose();
}
IMPL_LINK( SvxSplitTableDlg, ClickHdl, Button *, pButton, void )
{ {
const bool bIsVert = pButton == m_pVertBox ; const bool bIsVert = &rButton == m_xVertBox.get();
long nMax = bIsVert ? mnMaxVertical : mnMaxHorizontal; long nMax = bIsVert ? mnMaxVertical : mnMaxHorizontal;
m_pPropCB->Enable(!bIsVert); m_xPropCB->set_sensitive(!bIsVert);
m_pCountEdit->SetMax( nMax ); int nMin, dummy;
m_xCountEdit->get_range(nMin, dummy);
m_xCountEdit->set_range(nMin, nMax);
} }
bool SvxSplitTableDlg::IsHorizontal() const bool SvxSplitTableDlg::IsHorizontal() const
{ {
return m_pHorzBox->IsChecked(); return m_xHorzBox->get_active();
} }
bool SvxSplitTableDlg::IsProportional() const bool SvxSplitTableDlg::IsProportional() const
{ {
return m_pPropCB->IsChecked() && m_pHorzBox->IsChecked(); return m_xPropCB->get_active() && m_xHorzBox->get_active();
} }
long SvxSplitTableDlg::GetCount() const long SvxSplitTableDlg::GetCount() const
{ {
return sal::static_int_cast<long>( m_pCountEdit->GetValue() ); return m_xCountEdit->get_value();
} }
short SvxSplitTableDlg::Execute() short SvxSplitTableDlg::Execute()
{ {
return m_pDialog->Execute(); return m_xDialog->run();
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -1488,7 +1488,7 @@ VclPtr<SfxAbstractTabDialog> AbstractDialogFactory_Impl::CreateSvxFormatCellsDia ...@@ -1488,7 +1488,7 @@ VclPtr<SfxAbstractTabDialog> AbstractDialogFactory_Impl::CreateSvxFormatCellsDia
return VclPtr<CuiAbstractTabDialog_Impl>::Create( VclPtr<SvxFormatCellsDialog>::Create( nullptr, pAttr, pModel ) ); return VclPtr<CuiAbstractTabDialog_Impl>::Create( VclPtr<SvxFormatCellsDialog>::Create( nullptr, pAttr, pModel ) );
} }
VclPtr<SvxAbstractSplittTableDialog> AbstractDialogFactory_Impl::CreateSvxSplittTableDialog( vcl::Window* pParent, bool bIsTableVertical, long nMaxVertical ) VclPtr<SvxAbstractSplittTableDialog> AbstractDialogFactory_Impl::CreateSvxSplittTableDialog(weld::Window* pParent, bool bIsTableVertical, long nMaxVertical)
{ {
return VclPtr<SvxSplitTableDlg>::Create( pParent, bIsTableVertical, nMaxVertical, 99 ); return VclPtr<SvxSplitTableDlg>::Create( pParent, bIsTableVertical, nMaxVertical, 99 );
} }
......
...@@ -617,7 +617,7 @@ public: ...@@ -617,7 +617,7 @@ public:
virtual VclPtr<SfxAbstractTabDialog> CreateSvxFormatCellsDialog( const SfxItemSet* pAttr, SdrModel* pModel, const SdrObject* pObj ) override; virtual VclPtr<SfxAbstractTabDialog> CreateSvxFormatCellsDialog( const SfxItemSet* pAttr, SdrModel* pModel, const SdrObject* pObj ) override;
virtual VclPtr<SvxAbstractSplittTableDialog> CreateSvxSplittTableDialog( vcl::Window* pParent, bool bIsTableVertical, long nMaxVertical ) override; virtual VclPtr<SvxAbstractSplittTableDialog> CreateSvxSplittTableDialog(weld::Window* pParent, bool bIsTableVertical, long nMaxVertical) override;
virtual VclPtr<SvxAbstractNewTableDialog> CreateSvxNewTableDialog() override ; virtual VclPtr<SvxAbstractNewTableDialog> CreateSvxNewTableDialog() override ;
......
...@@ -19,30 +19,26 @@ ...@@ -19,30 +19,26 @@
#ifndef INCLUDED_CUI_SOURCE_INC_SPLITCELLDLG_HXX #ifndef INCLUDED_CUI_SOURCE_INC_SPLITCELLDLG_HXX
#define INCLUDED_CUI_SOURCE_INC_SPLITCELLDLG_HXX #define INCLUDED_CUI_SOURCE_INC_SPLITCELLDLG_HXX
#include <vcl/fixed.hxx>
#include <vcl/field.hxx>
#include <vcl/button.hxx>
#include <svx/stddlg.hxx>
#include <svx/svxdlg.hxx> #include <svx/svxdlg.hxx>
#include <vcl/weld.hxx>
class SvxSplitTableDlg : public SvxAbstractSplittTableDialog class SvxSplitTableDlg : public SvxAbstractSplittTableDialog
{ {
VclPtr<SvxStandardDialog> m_pDialog; private:
VclPtr<NumericField> m_pCountEdit; std::unique_ptr<weld::Builder> m_xBuilder;
VclPtr<RadioButton> m_pHorzBox; std::unique_ptr<weld::Dialog> m_xDialog;
VclPtr<RadioButton> m_pVertBox; std::unique_ptr<weld::SpinButton> m_xCountEdit;
VclPtr<CheckBox> m_pPropCB; std::unique_ptr<weld::RadioButton> m_xHorzBox;
std::unique_ptr<weld::RadioButton> m_xVertBox;
std::unique_ptr<weld::CheckButton> m_xPropCB;
long mnMaxVertical; long mnMaxVertical;
long mnMaxHorizontal; long mnMaxHorizontal;
public: public:
SvxSplitTableDlg(vcl::Window *pParent, bool bIsTableVertical, long nMaxVertical, long nMaxHorizontal ); SvxSplitTableDlg(weld::Window *pParent, bool bIsTableVertical, long nMaxVertical, long nMaxHorizontal);
virtual ~SvxSplitTableDlg() override;
virtual void dispose() override;
DECL_LINK( ClickHdl, Button *, void ); DECL_LINK(ClickHdl, weld::Button&, void);
virtual bool IsHorizontal() const override; virtual bool IsHorizontal() const override;
virtual bool IsProportional() const override; virtual bool IsProportional() const override;
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 --> <!-- Generated with glade 3.20.2 -->
<interface domain="cui"> <interface domain="cui">
<requires lib="gtk+" version="3.0"/> <requires lib="gtk+" version="3.20"/>
<object class="GtkAdjustment" id="adjustment1"> <object class="GtkAdjustment" id="adjustment1">
<property name="lower">2</property> <property name="lower">2</property>
<property name="upper">20</property> <property name="upper">20</property>
...@@ -12,18 +12,21 @@ ...@@ -12,18 +12,21 @@
<object class="GtkImage" id="image1"> <object class="GtkImage" id="image1">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="pixbuf">svx/res/zetlhor2.png</property> <property name="icon_name">svx/res/zetlhor2.png</property>
</object> </object>
<object class="GtkImage" id="image2"> <object class="GtkImage" id="image2">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="pixbuf">svx/res/zetlver2.png</property> <property name="icon_name">svx/res/zetlver2.png</property>
</object> </object>
<object class="GtkDialog" id="SplitCellsDialog"> <object class="GtkDialog" id="SplitCellsDialog">
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="border_width">6</property> <property name="border_width">6</property>
<property name="title" translatable="yes" context="splitcellsdialog|SplitCellsDialog">Split Cells</property> <property name="title" translatable="yes" context="splitcellsdialog|SplitCellsDialog">Split Cells</property>
<property name="resizable">False</property> <property name="resizable">False</property>
<property name="modal">True</property>
<property name="default_width">0</property>
<property name="default_height">0</property>
<property name="type_hint">dialog</property> <property name="type_hint">dialog</property>
<child internal-child="vbox"> <child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1"> <object class="GtkBox" id="dialog-vbox1">
...@@ -182,6 +185,7 @@ ...@@ -182,6 +185,7 @@
<property name="image">image1</property> <property name="image">image1</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<property name="always_show_image">True</property>
<property name="active">True</property> <property name="active">True</property>
<property name="draw_indicator">True</property> <property name="draw_indicator">True</property>
<property name="group">vert</property> <property name="group">vert</property>
...@@ -200,6 +204,7 @@ ...@@ -200,6 +204,7 @@
<property name="image">image2</property> <property name="image">image2</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<property name="always_show_image">True</property>
<property name="draw_indicator">True</property> <property name="draw_indicator">True</property>
<property name="group">hori</property> <property name="group">hori</property>
</object> </object>
...@@ -265,5 +270,8 @@ ...@@ -265,5 +270,8 @@
<action-widget response="-6">cancel</action-widget> <action-widget response="-6">cancel</action-widget>
<action-widget response="-11">help</action-widget> <action-widget response="-11">help</action-widget>
</action-widgets> </action-widgets>
<child>
<placeholder/>
</child>
</object> </object>
</interface> </interface>
...@@ -470,7 +470,7 @@ public: ...@@ -470,7 +470,7 @@ public:
virtual VclPtr<SfxAbstractTabDialog> CreateSvxFormatCellsDialog( const SfxItemSet* pAttr, SdrModel* pModel, const SdrObject* pObj )=0; virtual VclPtr<SfxAbstractTabDialog> CreateSvxFormatCellsDialog( const SfxItemSet* pAttr, SdrModel* pModel, const SdrObject* pObj )=0;
virtual VclPtr<SvxAbstractSplittTableDialog> CreateSvxSplittTableDialog( vcl::Window* pParent, bool bIsTableVertical, long nMaxVertical )=0; virtual VclPtr<SvxAbstractSplittTableDialog> CreateSvxSplittTableDialog(weld::Window* pParent, bool bIsTableVertical, long nMaxVertical) = 0;
virtual VclPtr<SvxAbstractNewTableDialog> CreateSvxNewTableDialog() = 0; virtual VclPtr<SvxAbstractNewTableDialog> CreateSvxNewTableDialog() = 0;
......
...@@ -47,6 +47,12 @@ public: ...@@ -47,6 +47,12 @@ public:
virtual OString get_buildable_name() const = 0; virtual OString get_buildable_name() const = 0;
virtual void set_help_id(const OString& rName) = 0; virtual void set_help_id(const OString& rName) = 0;
virtual OString get_help_id() const = 0; virtual OString get_help_id() const = 0;
virtual void set_grid_left_attach(int nAttach) = 0;
virtual int get_grid_left_attach() const = 0;
virtual void set_grid_top_attach(int nAttach) = 0;
virtual int get_grid_top_attach() const = 0;
virtual Container* weld_parent() const = 0; virtual Container* weld_parent() const = 0;
virtual ~Widget() {} virtual ~Widget() {}
......
...@@ -990,7 +990,8 @@ void SwTableShell::Execute(SfxRequest &rReq) ...@@ -990,7 +990,8 @@ void SwTableShell::Execute(SfxRequest &rReq)
if( pFact ) if( pFact )
{ {
const long nMaxVert = rSh.GetAnyCurRect( CurRectType::Frame ).Width() / MINLAY; const long nMaxVert = rSh.GetAnyCurRect( CurRectType::Frame ).Width() / MINLAY;
ScopedVclPtr<SvxAbstractSplittTableDialog> pDlg(pFact->CreateSvxSplittTableDialog( GetView().GetWindow(), rSh.IsTableVertical(), nMaxVert )); vcl::Window* pWin = GetView().GetWindow();
ScopedVclPtr<SvxAbstractSplittTableDialog> pDlg(pFact->CreateSvxSplittTableDialog(pWin ? pWin->GetFrameWeld() : nullptr, rSh.IsTableVertical(), nMaxVert));
if( pDlg && (pDlg->Execute() == RET_OK) ) if( pDlg && (pDlg->Execute() == RET_OK) )
{ {
nCount = pDlg->GetCount(); nCount = pDlg->GetCount();
......
...@@ -268,6 +268,26 @@ public: ...@@ -268,6 +268,26 @@ public:
return m_xWidget->GetHelpId(); return m_xWidget->GetHelpId();
} }
virtual void set_grid_left_attach(int nAttach) override
{
m_xWidget->set_grid_left_attach(nAttach);
}
virtual int get_grid_left_attach() const override
{
return m_xWidget->get_grid_left_attach();
}
virtual void set_grid_top_attach(int nAttach) override
{
m_xWidget->set_grid_top_attach(nAttach);
}
virtual int get_grid_top_attach() const override
{
return m_xWidget->get_grid_top_attach();
}
virtual weld::Container* weld_parent() const override; virtual weld::Container* weld_parent() const override;
virtual ~SalInstanceWidget() override virtual ~SalInstanceWidget() override
......
...@@ -972,7 +972,7 @@ Image FixedImage::loadThemeImage(const OUString &rFileName) ...@@ -972,7 +972,7 @@ Image FixedImage::loadThemeImage(const OUString &rFileName)
bool FixedImage::set_property(const OString &rKey, const OUString &rValue) bool FixedImage::set_property(const OString &rKey, const OUString &rValue)
{ {
if (rKey == "pixbuf") if (rKey == "pixbuf" || rKey == "icon-name")
{ {
SetImage(loadThemeImage(rValue)); SetImage(loadThemeImage(rValue));
} }
......
...@@ -1272,6 +1272,34 @@ public: ...@@ -1272,6 +1272,34 @@ public:
return Size(nWidth, nHeight); return Size(nWidth, nHeight);
} }
virtual void set_grid_left_attach(int nAttach) override
{
GtkContainer* pParent = GTK_CONTAINER(gtk_widget_get_parent(m_pWidget));
gtk_container_child_set(pParent, m_pWidget, "left-attach", nAttach, nullptr);
}
virtual int get_grid_left_attach() const override
{
GtkContainer* pParent = GTK_CONTAINER(gtk_widget_get_parent(m_pWidget));
gint nAttach(0);
gtk_container_child_get(pParent, m_pWidget, "left-attach", &nAttach, nullptr);
return nAttach;
}
virtual void set_grid_top_attach(int nAttach) override
{
GtkContainer* pParent = GTK_CONTAINER(gtk_widget_get_parent(m_pWidget));
gtk_container_child_set(pParent, m_pWidget, "top-attach", nAttach, nullptr);
}
virtual int get_grid_top_attach() const override
{
GtkContainer* pParent = GTK_CONTAINER(gtk_widget_get_parent(m_pWidget));
gint nAttach(0);
gtk_container_child_get(pParent, m_pWidget, "top-attach", &nAttach, nullptr);
return nAttach;
}
virtual weld::Container* weld_parent() const override; virtual weld::Container* weld_parent() const override;
virtual OString get_buildable_name() const override virtual OString get_buildable_name() 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