summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorParis Oplopoios <paris.oplopoios@collabora.com>2023-06-14 01:49:07 +0300
committerParis Oplopoios <parisoplop@gmail.com>2023-06-14 01:47:47 +0200
commit63627c174778f7d435a540c43ec0498c76e739ab (patch)
tree76ae2c8171a5a15fd181b12342c2decb84e5b3be /sw
parent5e9eaaf6f298bced76ddef7bc37efcd75a224520 (diff)
Remove hardcoded values in pagenumberdlg
Removed hardcoded text width/heights and margins in pagenumberdlg to create the preview image and also added a different text preview for IncludePageTotal mode Change-Id: Ib4f4f9ba702f87babf13c1435dc3845add1f43cf Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153030 Tested-by: Jenkins Reviewed-by: Paris Oplopoios <parisoplop@gmail.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/ui/misc/pagenumberdlg.cxx32
-rw-r--r--sw/source/uibase/inc/pagenumberdlg.hxx1
2 files changed, 26 insertions, 7 deletions
diff --git a/sw/source/ui/misc/pagenumberdlg.cxx b/sw/source/ui/misc/pagenumberdlg.cxx
index 1b5084c5e94b..fe965d69db19 100644
--- a/sw/source/ui/misc/pagenumberdlg.cxx
+++ b/sw/source/ui/misc/pagenumberdlg.cxx
@@ -23,6 +23,7 @@
#include <vcl/graph.hxx>
#include <vcl/BitmapTools.hxx>
#include <vcl/virdev.hxx>
+#include <tools/gen.hxx>
SwPageNumberDlg::SwPageNumberDlg(weld::Window* pParent)
: SfxDialogController(pParent, "modules/swriter/ui/pagenumberdlg.ui", "PageNumberDialog")
@@ -49,6 +50,7 @@ SwPageNumberDlg::SwPageNumberDlg(weld::Window* pParent)
SvxNumOptionsTabPageHelper::GetI18nNumbering(m_xPageNumberTypeLB->get_widget(),
::std::numeric_limits<sal_uInt16>::max());
m_xPageNumberTypeLB->connect_changed(LINK(this, SwPageNumberDlg, NumberTypeSelectHdl));
+ m_xIncludePageTotal->connect_toggled(LINK(this, SwPageNumberDlg, IncludePageTotalChangeHdl));
updateImage();
}
@@ -76,6 +78,11 @@ IMPL_LINK_NOARG(SwPageNumberDlg, NumberTypeSelectHdl, weld::ComboBox&, void)
m_nPageNumberType = m_xPageNumberTypeLB->get_active_id();
}
+IMPL_LINK_NOARG(SwPageNumberDlg, IncludePageTotalChangeHdl, weld::Toggleable&, void)
+{
+ updateImage();
+}
+
bool SwPageNumberDlg::GetMirrorOnEvenPages()
{
return m_xMirrorOnEvenPages->get_sensitive()
@@ -98,8 +105,7 @@ void SwPageNumberDlg::updateImage()
int nBackgroundWidth = 75;
int nBackgroundHeight = 105;
- int nSpriteWidth = 10;
- int nSpriteHeight = 14;
+ int nMargin = 7;
ScopedVclPtrInstance<VirtualDevice> pVirtualDev;
Size aVDSize(nBackgroundWidth, nBackgroundHeight);
@@ -107,17 +113,29 @@ void SwPageNumberDlg::updateImage()
pVirtualDev->SetBackground(Color(0xF0, 0xF0, 0xF0));
pVirtualDev->Erase();
- int y = m_aPageNumberPosition ? (nBackgroundHeight - nSpriteHeight - 5) : 5;
- int x = 5;
+ OUString sText = "#";
+
+ if (m_xIncludePageTotal->get_state() == TRISTATE_TRUE)
+ {
+ sText += " / #";
+ }
+
+ DrawTextFlags eFlags = DrawTextFlags::Left;
+
if (m_aPageNumberAlignment == 1)
{
- x = (nBackgroundWidth - nSpriteWidth) / 2;
+ eFlags = DrawTextFlags::Center;
}
else if (m_aPageNumberAlignment == 2)
{
- x = nBackgroundWidth - nSpriteWidth - 5;
+ eFlags = DrawTextFlags::Right;
}
- pVirtualDev->DrawText(Point(x, y), "#");
+
+ eFlags |= m_aPageNumberPosition ? DrawTextFlags::Bottom : DrawTextFlags::Top;
+
+ pVirtualDev->DrawText(
+ tools::Rectangle(nMargin, nMargin, nBackgroundWidth - nMargin, nBackgroundHeight - nMargin),
+ sText, eFlags);
m_xPreviewImage->set_image(pVirtualDev);
}
diff --git a/sw/source/uibase/inc/pagenumberdlg.hxx b/sw/source/uibase/inc/pagenumberdlg.hxx
index cf719b492a33..169c9209dbf5 100644
--- a/sw/source/uibase/inc/pagenumberdlg.hxx
+++ b/sw/source/uibase/inc/pagenumberdlg.hxx
@@ -42,6 +42,7 @@ class SwPageNumberDlg final : public SfxDialogController
SvxNumType m_nPageNumberType;
DECL_LINK(OkHdl, weld::Button&, void);
+ DECL_LINK(IncludePageTotalChangeHdl, weld::Toggleable&, void);
DECL_LINK(PositionSelectHdl, weld::ComboBox&, void);
DECL_LINK(AlignmentSelectHdl, weld::ComboBox&, void);
DECL_LINK(NumberTypeSelectHdl, weld::ComboBox&, void);