summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/svtools/unitconv.hxx2
-rw-r--r--sd/inc/sdabstdlg.hxx2
-rw-r--r--sd/qa/unit/dialogs-test.cxx3
-rw-r--r--sd/source/ui/dlg/dlgsnap.cxx165
-rw-r--r--sd/source/ui/dlg/sddlgfact.cxx20
-rw-r--r--sd/source/ui/dlg/sddlgfact.hxx11
-rw-r--r--sd/source/ui/func/fusnapln.cxx3
-rw-r--r--sd/source/ui/inc/dlgsnap.hxx40
-rw-r--r--sd/uiconfig/sdraw/ui/dlgsnap.ui60
-rw-r--r--svtools/source/misc/unitconv.cxx31
10 files changed, 181 insertions, 156 deletions
diff --git a/include/svtools/unitconv.hxx b/include/svtools/unitconv.hxx
index 6d663df72b1c..056bc8ae9404 100644
--- a/include/svtools/unitconv.hxx
+++ b/include/svtools/unitconv.hxx
@@ -44,7 +44,9 @@ SVT_DLLPUBLIC long ControlToItem( long nIn, FieldUnit eCtrl, MapUnit eItem
SVT_DLLPUBLIC FieldUnit MapToFieldUnit( const MapUnit eUnit );
+SVT_DLLPUBLIC void SetMetricValue(weld::MetricSpinButton& rField, int lCoreValue, MapUnit eUnit);
SVT_DLLPUBLIC void SetMetricValue( MetricField& rField, long lCoreValue, MapUnit eUnit );
+SVT_DLLPUBLIC int GetCoreValue(const weld::MetricSpinButton& rField, MapUnit eUnit);
SVT_DLLPUBLIC long GetCoreValue( const MetricField& rField, MapUnit eUnit );
SVT_DLLPUBLIC long PointToTwips( long nIn );
diff --git a/sd/inc/sdabstdlg.hxx b/sd/inc/sdabstdlg.hxx
index 8587d9dc256e..4b1e402f6eb7 100644
--- a/sd/inc/sdabstdlg.hxx
+++ b/sd/inc/sdabstdlg.hxx
@@ -184,7 +184,7 @@ public:
virtual VclPtr<SfxAbstractTabDialog> CreateSdTabCharDialog(vcl::Window* pWindow, const SfxItemSet* pAttr, SfxObjectShell* pDocShell) = 0;
virtual VclPtr<SfxAbstractTabDialog> CreateSdTabPageDialog(vcl::Window* pWindow, const SfxItemSet* pAttr, SfxObjectShell* pDocShell, bool bAreaPage) = 0;
virtual VclPtr<AbstractSdModifyFieldDlg> CreateSdModifyFieldDlg(vcl::Window* pWindow, const SvxFieldData* pInField, const SfxItemSet& rSet) = 0;
- virtual VclPtr<AbstractSdSnapLineDlg> CreateSdSnapLineDlg(vcl::Window* pParent, const SfxItemSet& rInAttrs, ::sd::View* pView) = 0;
+ virtual VclPtr<AbstractSdSnapLineDlg> CreateSdSnapLineDlg(weld::Window* pParent, const SfxItemSet& rInAttrs, ::sd::View* pView) = 0;
virtual VclPtr<AbstractSdInsertLayerDlg> CreateSdInsertLayerDlg(weld::Window* pParent, const SfxItemSet& rInAttrs, bool bDeletable, const OUString& rStr) = 0;
virtual VclPtr<AbstractSdInsertPagesObjsDlg> CreateSdInsertPagesObjsDlg(vcl::Window* pParent, const SdDrawDocument* pDoc, SfxMedium* pSfxMedium, const OUString& rFileName) = 0;
virtual VclPtr<AbstractMorphDlg> CreateMorphDlg(weld::Window* pParent, const SdrObject* pObj1, const SdrObject* pObj2) = 0;
diff --git a/sd/qa/unit/dialogs-test.cxx b/sd/qa/unit/dialogs-test.cxx
index 260b22ce7fc0..868388102e07 100644
--- a/sd/qa/unit/dialogs-test.cxx
+++ b/sd/qa/unit/dialogs-test.cxx
@@ -352,8 +352,9 @@ VclPtr<VclAbstractDialog> SdDialogsTest::createDialogByID(sal_uInt32 nID)
SfxItemSet aNewAttr(pDrawDoc->GetItemPool(), svl::Items<ATTR_SNAPLINE_START, ATTR_SNAPLINE_END>{});
aNewAttr.Put(SfxInt32Item(ATTR_SNAPLINE_X, 0));
aNewAttr.Put(SfxInt32Item(ATTR_SNAPLINE_Y, 0));
+ auto const parent = getViewShell()->GetActiveWindow();
pRetval = getSdAbstractDialogFactory()->CreateSdSnapLineDlg(
- getViewShell()->GetActiveWindow(),
+ parent == nullptr ? nullptr : parent->GetFrameWeld(),
aNewAttr,
getDrawView());
break;
diff --git a/sd/source/ui/dlg/dlgsnap.cxx b/sd/source/ui/dlg/dlgsnap.cxx
index 58a893078aa1..40de52f786e0 100644
--- a/sd/source/ui/dlg/dlgsnap.cxx
+++ b/sd/source/ui/dlg/dlgsnap.cxx
@@ -30,32 +30,28 @@
/**
* dialog to adjust grid (scarcely ESO!)
*/
-SdSnapLineDlg::SdSnapLineDlg(
- vcl::Window* pWindow,
- const SfxItemSet& rInAttrs,
- ::sd::View const * pView)
- : ModalDialog(pWindow, "SnapObjectDialog", "modules/sdraw/ui/dlgsnap.ui")
+SdSnapLineDlg::SdSnapLineDlg(weld::Window* pWindow, const SfxItemSet& rInAttrs, ::sd::View const * pView)
+ : GenericDialogController(pWindow, "modules/sdraw/ui/dlgsnap.ui", "SnapObjectDialog")
, eUIUnit(pView->GetDoc().GetUIUnit())
, aUIScale(pView->GetDoc().GetUIScale())
+ , m_xFtX(m_xBuilder->weld_label("xlabel"))
+ , m_xMtrFldX(m_xBuilder->weld_metric_spin_button("x", FUNIT_CM))
+ , m_xFtY(m_xBuilder->weld_label("ylabel"))
+ , m_xMtrFldY(m_xBuilder->weld_metric_spin_button("y", FUNIT_CM))
+ , m_xRadioGroup(m_xBuilder->weld_widget("radiogroup"))
+ , m_xRbPoint(m_xBuilder->weld_radio_button("point"))
+ , m_xRbVert(m_xBuilder->weld_radio_button("vert"))
+ , m_xRbHorz(m_xBuilder->weld_radio_button("horz"))
+ , m_xBtnDelete(m_xBuilder->weld_button("delete"))
{
- get(m_pFtX, "xlabel");
- get(m_pMtrFldX, "x");
- get(m_pFtY, "ylabel");
- get(m_pMtrFldY, "y");
- get(m_pRadioGroup, "radiogroup");
- get(m_pRbPoint, "point");
- get(m_pRbVert, "vert");
- get(m_pRbHorz, "horz");
- get(m_pBtnDelete, "delete");
+ m_xRbHorz->connect_clicked(LINK(this, SdSnapLineDlg, ClickHdl));
+ m_xRbVert->connect_clicked(LINK(this, SdSnapLineDlg, ClickHdl));
+ m_xRbPoint->connect_clicked(LINK(this, SdSnapLineDlg, ClickHdl));
- m_pRbHorz->SetClickHdl(LINK(this, SdSnapLineDlg, ClickHdl));
- m_pRbVert->SetClickHdl(LINK(this, SdSnapLineDlg, ClickHdl));
- m_pRbPoint->SetClickHdl(LINK(this, SdSnapLineDlg, ClickHdl));
+ m_xBtnDelete->connect_clicked(LINK(this, SdSnapLineDlg, ClickHdl));
- m_pBtnDelete->SetClickHdl(LINK(this, SdSnapLineDlg, ClickHdl));
-
- SetFieldUnit( *m_pMtrFldX, eUIUnit, true );
- SetFieldUnit( *m_pMtrFldY, eUIUnit, true );
+ SetFieldUnit(*m_xMtrFldX, eUIUnit, true);
+ SetFieldUnit(*m_xMtrFldY, eUIUnit, true);
// get WorkArea
::tools::Rectangle aWorkArea = pView->GetWorkArea();
@@ -74,70 +70,51 @@ SdSnapLineDlg::SdSnapLineDlg(
// determine max and min values depending on
// WorkArea, PoolUnit and FieldUnit:
- SetMetricValue( *m_pMtrFldX, aLeftTop.X(), ePoolUnit );
-
- long nValue = static_cast<long>(m_pMtrFldX->GetValue());
- nValue = long( nValue / aUIScale);
- m_pMtrFldX->SetMin( nValue );
- m_pMtrFldX->SetFirst( nValue );
-
- SetMetricValue( *m_pMtrFldX, aRightBottom.X(), ePoolUnit );
- nValue = static_cast<long>(m_pMtrFldX->GetValue());
- nValue = long( nValue / aUIScale);
- m_pMtrFldX->SetMax( nValue );
- m_pMtrFldX->SetLast( nValue );
-
- SetMetricValue( *m_pMtrFldY, aLeftTop.Y(), ePoolUnit );
- nValue = static_cast<long>(m_pMtrFldY->GetValue());
- nValue = long( nValue / aUIScale);
- m_pMtrFldY->SetMin( nValue );
- m_pMtrFldY->SetFirst( nValue );
-
- SetMetricValue( *m_pMtrFldY, aRightBottom.Y(), ePoolUnit );
- nValue = static_cast<long>(m_pMtrFldY->GetValue());
- nValue = long( nValue / aUIScale);
- m_pMtrFldY->SetMax( nValue );
- m_pMtrFldY->SetLast( nValue );
+ SetMetricValue(*m_xMtrFldX, aLeftTop.X(), ePoolUnit );
+
+ int nValue = m_xMtrFldX->get_value(FUNIT_NONE);
+ nValue = sal_Int32(nValue / aUIScale);
+ m_xMtrFldX->set_min(nValue, FUNIT_NONE);
+
+ SetMetricValue(*m_xMtrFldX, aRightBottom.X(), ePoolUnit);
+ nValue = m_xMtrFldX->get_value(FUNIT_NONE);
+ nValue = sal_Int32(nValue / aUIScale);
+ m_xMtrFldX->set_max(nValue, FUNIT_NONE);
+
+ SetMetricValue(*m_xMtrFldY, aLeftTop.Y(), ePoolUnit);
+ nValue = m_xMtrFldY->get_value(FUNIT_NONE);
+ nValue = sal_Int32(nValue / aUIScale);
+ m_xMtrFldY->set_min(nValue, FUNIT_NONE);
+
+ SetMetricValue(*m_xMtrFldY, aRightBottom.Y(), ePoolUnit);
+ nValue = m_xMtrFldY->get_value(FUNIT_NONE);
+ nValue = sal_Int32(nValue / aUIScale);
+ m_xMtrFldY->set_max(nValue, FUNIT_NONE);
// set values
nXValue = static_cast<const SfxInt32Item&>( rInAttrs.Get(ATTR_SNAPLINE_X)).GetValue();
nYValue = static_cast<const SfxInt32Item&>( rInAttrs.Get(ATTR_SNAPLINE_Y)).GetValue();
- nXValue = long(nXValue / aUIScale);
- nYValue = long(nYValue / aUIScale);
- SetMetricValue( *m_pMtrFldX, nXValue, MapUnit::Map100thMM);
- SetMetricValue( *m_pMtrFldY, nYValue, MapUnit::Map100thMM);
+ nXValue = sal_Int32(nXValue / aUIScale);
+ nYValue = sal_Int32(nYValue / aUIScale);
+ SetMetricValue(*m_xMtrFldX, nXValue, MapUnit::Map100thMM);
+ SetMetricValue(*m_xMtrFldY, nYValue, MapUnit::Map100thMM);
- m_pRbPoint->Check();
+ m_xRbPoint->set_active(true);
}
SdSnapLineDlg::~SdSnapLineDlg()
{
- disposeOnce();
-}
-
-void SdSnapLineDlg::dispose()
-{
- m_pFtX.clear();
- m_pMtrFldX.clear();
- m_pFtY.clear();
- m_pMtrFldY.clear();
- m_pRadioGroup.clear();
- m_pRbPoint.clear();
- m_pRbVert.clear();
- m_pRbHorz.clear();
- m_pBtnDelete.clear();
- ModalDialog::dispose();
}
/**
* fills provided item sets with dialog box attributes
*/
-IMPL_LINK( SdSnapLineDlg, ClickHdl, Button *, pBtn, void )
+IMPL_LINK( SdSnapLineDlg, ClickHdl, weld::Button&, rBtn, void )
{
- if ( pBtn == m_pRbPoint ) SetInputFields(true, true);
- else if ( pBtn == m_pRbHorz ) SetInputFields(false, true);
- else if ( pBtn == m_pRbVert ) SetInputFields(true, false);
- else if ( pBtn == m_pBtnDelete ) EndDialog(RET_SNAP_DELETE);
+ if (&rBtn == m_xRbPoint.get()) SetInputFields(true, true);
+ else if (&rBtn == m_xRbHorz.get()) SetInputFields(false, true);
+ else if (&rBtn == m_xRbVert.get()) SetInputFields(true, false);
+ else if (&rBtn == m_xBtnDelete.get()) m_xDialog->response(RET_SNAP_DELETE);
}
/**
@@ -147,12 +124,12 @@ void SdSnapLineDlg::GetAttr(SfxItemSet& rOutAttrs)
{
SnapKind eKind;
- if ( m_pRbHorz->IsChecked() ) eKind = SK_HORIZONTAL;
- else if ( m_pRbVert->IsChecked() ) eKind = SK_VERTICAL;
- else eKind = SK_POINT;
+ if (m_xRbHorz->get_active()) eKind = SK_HORIZONTAL;
+ else if (m_xRbVert->get_active()) eKind = SK_VERTICAL;
+ else eKind = SK_POINT;
- nXValue = long( GetCoreValue( *m_pMtrFldX, MapUnit::Map100thMM) * aUIScale);
- nYValue = long( GetCoreValue( *m_pMtrFldY, MapUnit::Map100thMM) * aUIScale);
+ nXValue = sal_Int32(GetCoreValue(*m_xMtrFldX, MapUnit::Map100thMM) * aUIScale);
+ nYValue = sal_Int32(GetCoreValue(*m_xMtrFldY, MapUnit::Map100thMM) * aUIScale);
rOutAttrs.Put(SfxAllEnumItem(ATTR_SNAPLINE_KIND, static_cast<sal_uInt16>(eKind)));
rOutAttrs.Put(SfxInt32Item(ATTR_SNAPLINE_X, nXValue));
@@ -161,7 +138,7 @@ void SdSnapLineDlg::GetAttr(SfxItemSet& rOutAttrs)
void SdSnapLineDlg::HideRadioGroup()
{
- m_pRadioGroup->Hide();
+ m_xRadioGroup->hide();
}
/**
@@ -171,31 +148,31 @@ void SdSnapLineDlg::SetInputFields(bool bEnableX, bool bEnableY)
{
if ( bEnableX )
{
- if ( !m_pMtrFldX->IsEnabled() )
- m_pMtrFldX->SetValue(nXValue);
- m_pMtrFldX->Enable();
- m_pFtX->Enable();
+ if (!m_xMtrFldX->get_sensitive())
+ m_xMtrFldX->set_value(nXValue, FUNIT_NONE);
+ m_xMtrFldX->set_sensitive(true);
+ m_xFtX->set_sensitive(true);
}
- else if ( m_pMtrFldX->IsEnabled() )
+ else if (m_xMtrFldX->get_sensitive())
{
- nXValue = static_cast<long>(m_pMtrFldX->GetValue());
- m_pMtrFldX->SetText(OUString());
- m_pMtrFldX->Disable();
- m_pFtX->Disable();
+ nXValue = m_xMtrFldX->get_value(FUNIT_NONE);
+ m_xMtrFldX->set_text(OUString());
+ m_xMtrFldX->set_sensitive(false);
+ m_xFtX->set_sensitive(false);
}
if ( bEnableY )
{
- if ( !m_pMtrFldY->IsEnabled() )
- m_pMtrFldY->SetValue(nYValue);
- m_pMtrFldY->Enable();
- m_pFtY->Enable();
+ if (!m_xMtrFldY->get_sensitive())
+ m_xMtrFldY->set_value(nYValue, FUNIT_NONE);
+ m_xMtrFldY->set_sensitive(true);
+ m_xFtY->set_sensitive(true);
}
- else if ( m_pMtrFldY->IsEnabled() )
+ else if (m_xMtrFldY->get_sensitive())
{
- nYValue = static_cast<long>(m_pMtrFldY->GetValue());
- m_pMtrFldY->SetText(OUString());
- m_pMtrFldY->Disable();
- m_pFtY->Disable();
+ nYValue = m_xMtrFldY->get_value(FUNIT_NONE);
+ m_xMtrFldY->set_text(OUString());
+ m_xMtrFldY->set_sensitive(false);
+ m_xFtY->set_sensitive(false);
}
}
diff --git a/sd/source/ui/dlg/sddlgfact.cxx b/sd/source/ui/dlg/sddlgfact.cxx
index dca60841af70..2c6131f7fd4b 100644
--- a/sd/source/ui/dlg/sddlgfact.cxx
+++ b/sd/source/ui/dlg/sddlgfact.cxx
@@ -52,7 +52,11 @@ IMPL_ABSTDLG_BASE(AbstractSdCustomShowDlg_Impl);
IMPL_ABSTDLG_BASE(SdAbstractTabDialog_Impl);
IMPL_ABSTDLG_BASE(SdPresLayoutTemplateDlg_Impl);
IMPL_ABSTDLG_BASE(AbstractSdModifyFieldDlg_Impl);
-IMPL_ABSTDLG_BASE(AbstractSdSnapLineDlg_Impl);
+
+short AbstractSdSnapLineDlg_Impl::Execute()
+{
+ return m_xDlg->run();
+}
short AbstractSdInsertLayerDlg_Impl::Execute()
{
@@ -197,27 +201,27 @@ SfxItemSet AbstractSdModifyFieldDlg_Impl::GetItemSet()
void AbstractSdSnapLineDlg_Impl::GetAttr(SfxItemSet& rOutAttrs)
{
- pDlg->GetAttr(rOutAttrs);
+ m_xDlg->GetAttr(rOutAttrs);
}
void AbstractSdSnapLineDlg_Impl::HideRadioGroup()
{
- pDlg->HideRadioGroup();
+ m_xDlg->HideRadioGroup();
}
void AbstractSdSnapLineDlg_Impl::HideDeleteBtn()
{
- pDlg->HideDeleteBtn();
+ m_xDlg->HideDeleteBtn();
}
void AbstractSdSnapLineDlg_Impl::SetInputFields(bool bEnableX, bool bEnableY)
{
- pDlg->SetInputFields(bEnableX, bEnableY);
+ m_xDlg->SetInputFields(bEnableX, bEnableY);
}
void AbstractSdSnapLineDlg_Impl::SetText( const OUString& rStr )
{
- pDlg->SetText( rStr );
+ m_xDlg->set_title(rStr);
}
void AbstractSdInsertLayerDlg_Impl::GetAttr( SfxItemSet& rOutAttrs )
@@ -334,9 +338,9 @@ VclPtr<AbstractSdModifyFieldDlg> SdAbstractDialogFactory_Impl::CreateSdModifyFie
return VclPtr<AbstractSdModifyFieldDlg_Impl>::Create( VclPtr<SdModifyFieldDlg>::Create( pParent, pInField, rSet ) );
}
-VclPtr<AbstractSdSnapLineDlg> SdAbstractDialogFactory_Impl::CreateSdSnapLineDlg( vcl::Window* pParent, const SfxItemSet& rInAttrs, ::sd::View* pView)
+VclPtr<AbstractSdSnapLineDlg> SdAbstractDialogFactory_Impl::CreateSdSnapLineDlg(weld::Window* pParent, const SfxItemSet& rInAttrs, ::sd::View* pView)
{
- return VclPtr<AbstractSdSnapLineDlg_Impl>::Create( VclPtr<SdSnapLineDlg>::Create( pParent, rInAttrs, pView ) );
+ return VclPtr<AbstractSdSnapLineDlg_Impl>::Create(new SdSnapLineDlg(pParent, rInAttrs, pView));
}
VclPtr<AbstractSdInsertLayerDlg> SdAbstractDialogFactory_Impl::CreateSdInsertLayerDlg(weld::Window* pParent, const SfxItemSet& rInAttrs, bool bDeletable, const OUString& aStr)
diff --git a/sd/source/ui/dlg/sddlgfact.hxx b/sd/source/ui/dlg/sddlgfact.hxx
index 0367e9a8e192..d8bb3438f65f 100644
--- a/sd/source/ui/dlg/sddlgfact.hxx
+++ b/sd/source/ui/dlg/sddlgfact.hxx
@@ -142,7 +142,14 @@ class AbstractSdModifyFieldDlg_Impl : public AbstractSdModifyFieldDlg
class SdSnapLineDlg;
class AbstractSdSnapLineDlg_Impl : public AbstractSdSnapLineDlg
{
- DECL_ABSTDLG_BASE(AbstractSdSnapLineDlg_Impl,SdSnapLineDlg)
+private:
+ std::unique_ptr<SdSnapLineDlg> m_xDlg;
+public:
+ AbstractSdSnapLineDlg_Impl(SdSnapLineDlg* pDlg)
+ : m_xDlg(pDlg)
+ {
+ }
+ virtual short Execute() override;
virtual void GetAttr(SfxItemSet& rOutAttrs) override;
virtual void HideRadioGroup() override;
virtual void HideDeleteBtn() override;
@@ -245,7 +252,7 @@ public:
virtual VclPtr<SfxAbstractTabDialog> CreateSdTabCharDialog(vcl::Window* pWindow, const SfxItemSet* pAttr, SfxObjectShell* pDocShell) override;
virtual VclPtr<SfxAbstractTabDialog> CreateSdTabPageDialog(vcl::Window* pWindow, const SfxItemSet* pAttr, SfxObjectShell* pDocShell, bool bAreaPage) override;
virtual VclPtr<AbstractSdModifyFieldDlg> CreateSdModifyFieldDlg( vcl::Window* pWindow, const SvxFieldData* pInField, const SfxItemSet& rSet ) override;
- virtual VclPtr<AbstractSdSnapLineDlg> CreateSdSnapLineDlg(vcl::Window* pParent, const SfxItemSet& rInAttrs, ::sd::View* pView) override;
+ virtual VclPtr<AbstractSdSnapLineDlg> CreateSdSnapLineDlg(weld::Window* pParent, const SfxItemSet& rInAttrs, ::sd::View* pView) override;
virtual VclPtr<AbstractSdInsertLayerDlg> CreateSdInsertLayerDlg(weld::Window* pParent, const SfxItemSet& rInAttrs, bool bDeletable, const OUString& aStr) override;
virtual VclPtr<AbstractSdInsertPagesObjsDlg> CreateSdInsertPagesObjsDlg(vcl::Window* pParent, const SdDrawDocument* pDoc, SfxMedium* pSfxMedium, const OUString& rFileName ) override;
virtual VclPtr<AbstractMorphDlg> CreateMorphDlg(weld::Window* pParent, const SdrObject* pObj1, const SdrObject* pObj2) override;
diff --git a/sd/source/ui/func/fusnapln.cxx b/sd/source/ui/func/fusnapln.cxx
index f86710d28f62..a4719be2bcf9 100644
--- a/sd/source/ui/func/fusnapln.cxx
+++ b/sd/source/ui/func/fusnapln.cxx
@@ -109,7 +109,8 @@ void FuSnapLine::DoExecute( SfxRequest& rReq )
aNewAttr.Put(SfxInt32Item(ATTR_SNAPLINE_Y, aLinePos.Y()));
SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
- ScopedVclPtr<AbstractSdSnapLineDlg> pDlg(pFact ? pFact->CreateSdSnapLineDlg(mpViewShell->GetActiveWindow(), aNewAttr, mpView) : nullptr);
+ vcl::Window* pWin = mpViewShell->GetActiveWindow();
+ ScopedVclPtr<AbstractSdSnapLineDlg> pDlg(pFact ? pFact->CreateSdSnapLineDlg(pWin ? pWin->GetFrameWeld() : nullptr, aNewAttr, mpView) : nullptr);
OSL_ASSERT(pDlg);
if (!pDlg)
return;
diff --git a/sd/source/ui/inc/dlgsnap.hxx b/sd/source/ui/inc/dlgsnap.hxx
index 7444b561b649..25b1f248844d 100644
--- a/sd/source/ui/inc/dlgsnap.hxx
+++ b/sd/source/ui/inc/dlgsnap.hxx
@@ -20,14 +20,10 @@
#ifndef INCLUDED_SD_SOURCE_UI_INC_DLGSNAP_HXX
#define INCLUDED_SD_SOURCE_UI_INC_DLGSNAP_HXX
-#include <vcl/button.hxx>
-#include <vcl/fixed.hxx>
-#include <vcl/field.hxx>
-#include <vcl/group.hxx>
-#include <vcl/layout.hxx>
#include <tools/fract.hxx>
-#include <vcl/dialog.hxx>
#include <sdenumdef.hxx>
+#include <vcl/weld.hxx>
+
/************************************************************************/
class SfxItemSet;
@@ -38,34 +34,34 @@ namespace sd {
/**
* dialog to adjust snap- lines and points
*/
-class SdSnapLineDlg : public ModalDialog
+class SdSnapLineDlg : public weld::GenericDialogController
{
private:
- VclPtr<FixedText> m_pFtX;
- VclPtr<MetricField> m_pMtrFldX;
- VclPtr<FixedText> m_pFtY;
- VclPtr<MetricField> m_pMtrFldY;
- VclPtr<VclContainer> m_pRadioGroup;
- VclPtr<RadioButton> m_pRbPoint;
- VclPtr<RadioButton> m_pRbVert;
- VclPtr<RadioButton> m_pRbHorz;
- VclPtr<PushButton> m_pBtnDelete;
- long nXValue;
- long nYValue;
+ int nXValue;
+ int nYValue;
FieldUnit eUIUnit;
Fraction aUIScale;
- DECL_LINK( ClickHdl, Button *, void );
+ std::unique_ptr<weld::Label> m_xFtX;
+ std::unique_ptr<weld::MetricSpinButton> m_xMtrFldX;
+ std::unique_ptr<weld::Label> m_xFtY;
+ std::unique_ptr<weld::MetricSpinButton> m_xMtrFldY;
+ std::unique_ptr<weld::Widget> m_xRadioGroup;
+ std::unique_ptr<weld::RadioButton> m_xRbPoint;
+ std::unique_ptr<weld::RadioButton> m_xRbVert;
+ std::unique_ptr<weld::RadioButton> m_xRbHorz;
+ std::unique_ptr<weld::Button> m_xBtnDelete;
+
+ DECL_LINK(ClickHdl, weld::Button&, void);
public:
- SdSnapLineDlg(vcl::Window* pWindow, const SfxItemSet& rInAttrs, ::sd::View const * pView);
+ SdSnapLineDlg(weld::Window* pWindow, const SfxItemSet& rInAttrs, ::sd::View const * pView);
virtual ~SdSnapLineDlg() override;
- virtual void dispose() override;
void GetAttr(SfxItemSet& rOutAttrs);
void HideRadioGroup();
- void HideDeleteBtn() { m_pBtnDelete->Hide(); }
+ void HideDeleteBtn() { m_xBtnDelete->hide(); }
void SetInputFields(bool bEnableX, bool bEnableY);
};
diff --git a/sd/uiconfig/sdraw/ui/dlgsnap.ui b/sd/uiconfig/sdraw/ui/dlgsnap.ui
index d85e5bb01a83..24535f2692f3 100644
--- a/sd/uiconfig/sdraw/ui/dlgsnap.ui
+++ b/sd/uiconfig/sdraw/ui/dlgsnap.ui
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.20.0 -->
+<!-- Generated with glade 3.20.4 -->
<interface domain="sd">
<requires lib="gtk+" version="3.18"/>
<object class="GtkAdjustment" id="adjustment1">
@@ -17,22 +17,25 @@
<object class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="pixbuf">sd/res/hlppoint.png</property>
+ <property name="icon_name">sd/res/hlppoint.png</property>
</object>
<object class="GtkImage" id="image2">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="pixbuf">sd/res/hlplvert.png</property>
+ <property name="icon_name">sd/res/hlplvert.png</property>
</object>
<object class="GtkImage" id="image3">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="pixbuf">sd/res/hlplhorz.png</property>
+ <property name="icon_name">sd/res/hlplhorz.png</property>
</object>
<object class="GtkDialog" id="SnapObjectDialog">
<property name="can_focus">False</property>
<property name="border_width">6</property>
<property name="title" translatable="yes" context="dlgsnap|SnapObjectDialog">New Snap Object</property>
+ <property name="modal">True</property>
+ <property name="default_width">0</property>
+ <property name="default_height">0</property>
<property name="type_hint">dialog</property>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1">
@@ -44,13 +47,13 @@
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
- <object class="GtkButton" id="ok">
- <property name="label">gtk-ok</property>
+ <object class="GtkButton" id="delete">
+ <property name="label">gtk-delete</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="has_default">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
+ <property name="image_position">bottom</property>
</object>
<packing>
<property name="expand">False</property>
@@ -59,10 +62,12 @@
</packing>
</child>
<child>
- <object class="GtkButton" id="cancel">
- <property name="label">gtk-cancel</property>
+ <object class="GtkButton" id="ok">
+ <property name="label">gtk-ok</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="has_default">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
@@ -73,31 +78,29 @@
</packing>
</child>
<child>
- <object class="GtkButton" id="help">
- <property name="label">gtk-help</property>
+ <object class="GtkButton" id="cancel">
+ <property name="label">gtk-cancel</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="has_default">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
- <property name="image_position">top</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
- <property name="secondary">True</property>
</packing>
</child>
<child>
- <object class="GtkButton" id="delete">
- <property name="label">gtk-delete</property>
+ <object class="GtkButton" id="help">
+ <property name="label">gtk-help</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="has_default">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
- <property name="image_position">bottom</property>
+ <property name="image_position">top</property>
</object>
<packing>
<property name="expand">False</property>
@@ -138,9 +141,10 @@
<property name="row_spacing">6</property>
<property name="column_spacing">12</property>
<child>
- <object class="GtkSpinButton" id="x:0.00cm">
+ <object class="GtkSpinButton" id="x">
<property name="visible">True</property>
<property name="can_focus">True</property>
+ <property name="activates_default">True</property>
<property name="adjustment">adjustment1</property>
<property name="digits">2</property>
</object>
@@ -150,9 +154,10 @@
</packing>
</child>
<child>
- <object class="GtkSpinButton" id="y:0.00cm">
+ <object class="GtkSpinButton" id="y">
<property name="visible">True</property>
<property name="can_focus">True</property>
+ <property name="activates_default">True</property>
<property name="adjustment">adjustment2</property>
<property name="digits">2</property>
</object>
@@ -167,7 +172,7 @@
<property name="can_focus">False</property>
<property name="label" translatable="yes" context="dlgsnap|xlabel">_X:</property>
<property name="use_underline">True</property>
- <property name="mnemonic_widget">x:0.00cm</property>
+ <property name="mnemonic_widget">x</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -180,7 +185,7 @@
<property name="can_focus">False</property>
<property name="label" translatable="yes" context="dlgsnap|ylabel">_Y:</property>
<property name="use_underline">True</property>
- <property name="mnemonic_widget">y:0.00cm</property>
+ <property name="mnemonic_widget">y</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -235,9 +240,9 @@
<property name="image">image1</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
+ <property name="always_show_image">True</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
- <property name="group">vert</property>
</object>
<packing>
<property name="expand">False</property>
@@ -254,8 +259,9 @@
<property name="image">image2</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
+ <property name="always_show_image">True</property>
<property name="draw_indicator">True</property>
- <property name="group">horz</property>
+ <property name="group">point</property>
</object>
<packing>
<property name="expand">False</property>
@@ -272,6 +278,7 @@
<property name="image">image3</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
+ <property name="always_show_image">True</property>
<property name="draw_indicator">True</property>
<property name="group">point</property>
</object>
@@ -312,10 +319,13 @@
</object>
</child>
<action-widgets>
+ <action-widget response="0">delete</action-widget>
<action-widget response="-5">ok</action-widget>
<action-widget response="-6">cancel</action-widget>
<action-widget response="-11">help</action-widget>
- <action-widget response="0">delete</action-widget>
</action-widgets>
+ <child>
+ <placeholder/>
+ </child>
</object>
</interface>
diff --git a/svtools/source/misc/unitconv.cxx b/svtools/source/misc/unitconv.cxx
index f99b2806076c..64d1acb75330 100644
--- a/svtools/source/misc/unitconv.cxx
+++ b/svtools/source/misc/unitconv.cxx
@@ -132,7 +132,6 @@ void SetFieldUnit( MetricField& rField, FieldUnit eUnit, bool bAll )
}
}
-
void SetFieldUnit( MetricBox& rBox, FieldUnit eUnit )
{
sal_Int64 nMin = rBox.Denormalize( rBox.GetMin( FUNIT_TWIP ) );
@@ -162,6 +161,12 @@ void SetFieldUnit( MetricBox& rBox, FieldUnit eUnit )
rBox.SetMax( rBox.Normalize( nMax ), FUNIT_TWIP );
}
+void SetMetricValue(weld::MetricSpinButton& rField, int nCoreValue, MapUnit eUnit)
+{
+ auto nVal = OutputDevice::LogicToLogic(nCoreValue, eUnit, MapUnit::Map100thMM);
+ nVal = rField.normalize(nVal);
+ rField.set_value(nVal, FUNIT_100TH_MM);
+}
void SetMetricValue( MetricField& rField, long nCoreValue, MapUnit eUnit )
{
@@ -171,6 +176,29 @@ void SetMetricValue( MetricField& rField, long nCoreValue, MapUnit eUnit )
}
+int GetCoreValue(const weld::MetricSpinButton& rField, MapUnit eUnit)
+{
+ int nVal = rField.get_value(FUNIT_100TH_MM);
+ // avoid rounding issues
+ const int nSizeMask = 0xff000000;
+ bool bRoundBefore = true;
+ if( nVal >= 0 )
+ {
+ if( (nVal & nSizeMask) == 0 )
+ bRoundBefore = false;
+ }
+ else
+ {
+ if( ((-nVal) & nSizeMask ) == 0 )
+ bRoundBefore = false;
+ }
+ if( bRoundBefore )
+ nVal = rField.denormalize( nVal );
+ auto nUnitVal = OutputDevice::LogicToLogic(nVal, MapUnit::Map100thMM, eUnit);
+ if (!bRoundBefore)
+ nUnitVal = rField.denormalize(nUnitVal);
+ return nUnitVal;
+}
long GetCoreValue( const MetricField& rField, MapUnit eUnit )
{
@@ -196,7 +224,6 @@ long GetCoreValue( const MetricField& rField, MapUnit eUnit )
return static_cast<long>(nUnitVal);
}
-
long CalcToUnit( float nIn, MapUnit eUnit )
{
// nIn is in Points