[Libreoffice-commits] core.git: sw/source

Mark Hung (via logerrit) logerrit at kemper.freedesktop.org
Tue Jun 4 04:45:06 UTC 2019


 sw/source/ui/misc/pggrid.cxx |   13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

New commits:
commit c1c3a3c619bd596e2a64e2c9b9328b4adfa990eb
Author:     Mark Hung <marklh9 at gmail.com>
AuthorDate: Fri May 31 23:22:43 2019 +0800
Commit:     Mark Hung <marklh9 at gmail.com>
CommitDate: Tue Jun 4 06:44:31 2019 +0200

    tdf#104922 recover text grid setting properly.
    
    Lines per page and chars per line can not be set before the
    max values determined, otherwise we may get incorrect result
    because of truncating to incorrect max values.
    
    Change-Id: I9829af0dcfd744f4383a5f9034270b00fdfb15b8
    Reviewed-on: https://gerrit.libreoffice.org/73280
    Tested-by: Jenkins
    Reviewed-by: Mark Hung <marklh9 at gmail.com>

diff --git a/sw/source/ui/misc/pggrid.cxx b/sw/source/ui/misc/pggrid.cxx
index dbef0e81300b..860f913985cd 100644
--- a/sw/source/ui/misc/pggrid.cxx
+++ b/sw/source/ui/misc/pggrid.cxx
@@ -171,6 +171,8 @@ bool SwTextGridPage::FillItemSet(SfxItemSet *rSet)
 
 void    SwTextGridPage::Reset(const SfxItemSet *rSet)
 {
+    sal_Int32 nLinesPerPage = 0;
+
     if(SfxItemState::DEFAULT <= rSet->GetItemState(RES_TEXTGRID))
     {
         const SwTextGridItem& rGridItem = rSet->Get(RES_TEXTGRID);
@@ -185,7 +187,8 @@ void    SwTextGridPage::Reset(const SfxItemSet *rSet)
         m_xDisplayCB->set_active(rGridItem.IsDisplayGrid());
         GridTypeHdl(*pButton);
         m_xSnapToCharsCB->set_active(rGridItem.IsSnapToChars());
-        m_xLinesPerPageNF->set_value(rGridItem.GetLines());
+        nLinesPerPage = rGridItem.GetLines();
+
         SetLinesOrCharsRanges(*m_xLinesRangeFT , m_xLinesPerPageNF->get_max());
         m_nRubyUserValue = rGridItem.GetBaseHeight();
         m_bRubyUserValue = true;
@@ -198,6 +201,9 @@ void    SwTextGridPage::Reset(const SfxItemSet *rSet)
     }
     UpdatePageSize(*rSet);
 
+    if (nLinesPerPage > 0)
+        m_xLinesPerPageNF->set_value(nLinesPerPage);
+
     m_xNoGridRB->save_state();
     m_xLinesGridRB->save_state();
     m_xSnapToCharsCB->save_state();
@@ -301,8 +307,9 @@ void SwTextGridPage::UpdatePageSize(const SfxItemSet& rSet)
 
     if ( m_bSquaredMode )
     {
-        m_xCharsPerLineNF->set_value(m_aPageSize.Width() / nTextSize);
-        m_xCharsPerLineNF->set_max(m_xCharsPerLineNF->get_value());
+        sal_Int32 nCharsPerLine = m_aPageSize.Width() / nTextSize;
+        m_xCharsPerLineNF->set_max(nCharsPerLine);
+        m_xCharsPerLineNF->set_value(nCharsPerLine);
         m_xLinesPerPageNF->set_max(m_aPageSize.Height() /
         (   m_xTextSizeMF->denormalize(m_xTextSizeMF->get_value(FieldUnit::TWIP)) +
                     m_xRubySizeMF->denormalize(m_xRubySizeMF->get_value(FieldUnit::TWIP))));


More information about the Libreoffice-commits mailing list