[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.1' - 17 commits - cui/source cui/uiconfig editeng/source filter/source hwpfilter/qa hwpfilter/source lotuswordpro/source oox/source sc/source starmath/qa starmath/source svx/source sw/source sw/uiconfig tools/source vcl/qa vcl/source

Caolán McNamara caolanm at redhat.com
Mon Mar 6 17:48:35 UTC 2017


 cui/source/inc/paragrph.hxx                                    |    3 
 cui/source/tabpages/paragrph.cxx                               |   85 +++++++---
 cui/uiconfig/ui/textflowpage.ui                                |   10 -
 editeng/source/editeng/editview.cxx                            |   11 +
 filter/source/graphicfilter/ipsd/ipsd.cxx                      |   14 -
 filter/source/graphicfilter/itiff/ccidecom.cxx                 |    5 
 hwpfilter/qa/cppunit/data/fail/skipblock-1.hwp                 |binary
 hwpfilter/qa/cppunit/test_hwpfilter.cxx                        |   16 -
 hwpfilter/source/hstream.cxx                                   |   21 +-
 hwpfilter/source/hstream.hxx                                   |   11 -
 lotuswordpro/source/filter/lwpfilter.cxx                       |    5 
 lotuswordpro/source/filter/lwpidxmgr.cxx                       |    4 
 lotuswordpro/source/filter/tocread.cxx                         |    5 
 oox/source/export/drawingml.cxx                                |   12 +
 sc/source/ui/undo/undoblk3.cxx                                 |    8 
 starmath/qa/cppunit/test_starmath.cxx                          |    8 
 starmath/source/edit.cxx                                       |   36 +---
 svx/source/stbctrls/stbctrls.src                               |    3 
 sw/source/filter/ww8/wrtww8.cxx                                |    8 
 sw/source/filter/xml/xmlimpit.cxx                              |    2 
 sw/source/ui/table/tabledlg.cxx                                |   63 ++++---
 sw/source/uibase/table/tablepg.hxx                             |    3 
 sw/source/uibase/utlui/uitool.cxx                              |   21 ++
 sw/uiconfig/swriter/ui/tabletextflowpage.ui                    |   10 -
 tools/source/zcodec/zcodec.cxx                                 |    2 
 vcl/qa/cppunit/graphicfilter/data/bmp/fail/nodict-compress.bmp |binary
 vcl/source/gdi/dibtools.cxx                                    |    5 
 27 files changed, 238 insertions(+), 133 deletions(-)

New commits:
commit f4e6a22c27ef5ce3ecb046ecd88a1dc0b37c7870
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sat Mar 4 20:58:26 2017 +0000

    Resolves: ofz#727 don't allow negative sizes or indexes
    
    remove extra size in favour of vector size and don't resize
    and memcpy data, just use vector::insert
    
    Change-Id: I8efb91a8c11fbd862c0458042554cf7e94b813cd
    Reviewed-on: https://gerrit.libreoffice.org/34893
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Michael Stahl <mstahl at redhat.com>
    (cherry picked from commit 789dc289b8b7ff79a6195e8648d0ac6be5cf13bb)

diff --git a/hwpfilter/source/hstream.cxx b/hwpfilter/source/hstream.cxx
index 6a0d59f..6b5bf98 100644
--- a/hwpfilter/source/hstream.cxx
+++ b/hwpfilter/source/hstream.cxx
@@ -22,38 +22,37 @@
 #include "hstream.hxx"
 
 HStream::HStream()
-    : size(0)
-    , pos(0)
+    : pos(0)
 {
 }
 
-void HStream::addData(const byte *buf, int aToAdd)
+void HStream::addData(const byte *buf, size_t aToAdd)
 {
-    seq.resize(size + aToAdd);
-    memcpy(seq.data() + size, buf, aToAdd);
-    size += aToAdd;
+    seq.insert(seq.end(), buf, buf + aToAdd);
 }
 
-int HStream::readBytes(byte * buf, int aToRead)
+size_t HStream::readBytes(byte * buf, size_t aToRead)
 {
+    auto size = seq.size();
     if (aToRead >= (size - pos))
         aToRead = size - pos;
-    for (int i = 0; i < aToRead; i++)
+    for (size_t i = 0; i < aToRead; ++i)
         buf[i] = seq[pos++];
     return aToRead;
 }
 
-int HStream::skipBytes(int aToSkip)
+size_t HStream::skipBytes(size_t aToSkip)
 {
+    auto size = seq.size();
     if (aToSkip >= (size - pos))
         aToSkip = size - pos;
     pos += aToSkip;
     return aToSkip;
 }
 
-int HStream::available() const
+size_t HStream::available() const
 {
-    return size - pos;
+    return seq.size() - pos;
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/hstream.hxx b/hwpfilter/source/hstream.hxx
index 4374b92..e6654f7 100644
--- a/hwpfilter/source/hstream.hxx
+++ b/hwpfilter/source/hstream.hxx
@@ -34,24 +34,23 @@ class HStream
 /**
  *
  */
-        void addData( const byte *buf, int aToAdd);
+        void addData( const byte *buf, size_t aToAdd);
 /**
  * Read some byte to buf as given size
  */
-        int readBytes( byte *buf, int aToRead);
+        size_t readBytes( byte *buf, size_t aToRead);
 /**
  * Skip some byte from stream as given size
  */
-        int skipBytes( int aToSkip );
+        size_t skipBytes( size_t aToSkip );
 /**
  * @returns Size of remained stream
  */
-        int available() const;
+        size_t available() const;
 
     private:
-        int size;
         std::vector<byte> seq;
-        int pos;
+        size_t pos;
 };
 #endif
 
commit 1d1f26386b3eff6af20bf05f57bd7b0959a0e926
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sat Mar 4 21:20:48 2017 +0000

    fail on unknown version flags
    
    Change-Id: Icbd2608a3341652b1b40f6bdebb66c4caf6e810a
    Reviewed-on: https://gerrit.libreoffice.org/34896
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Michael Stahl <mstahl at redhat.com>
    (cherry picked from commit 90643e244cbd42866a49a7cf878dc9473ab2e6c0)

diff --git a/lotuswordpro/source/filter/tocread.cxx b/lotuswordpro/source/filter/tocread.cxx
index 192a636..73f9ccb 100644
--- a/lotuswordpro/source/filter/tocread.cxx
+++ b/lotuswordpro/source/filter/tocread.cxx
@@ -109,13 +109,12 @@ CBenTOCReader::ReadLabel(unsigned long * pTOCOffset, unsigned long * pTOCSize)
 
     BenByte * pCurrLabel = Label + BEN_MAGIC_BYTES_SIZE;
 
-#ifndef NDEBUG
     BenWord Flags =
-#endif
         UtGetIntelWord(pCurrLabel); pCurrLabel += 2; // Flags
     // Newer files are 0x0101--indicates if big or little endian.  Older
     // files are 0x0 for flags
-    assert(Flags == 0x0101 || Flags == 0x0);
+    if (Flags != 0x0101 && Flags != 0x0)
+        return BenErr_UnknownBentoFormatVersion;
 
     cBlockSize = UtGetIntelWord(pCurrLabel) * 1024; pCurrLabel += 2;
     if (cBlockSize == 0)
commit 3e95ca44f8c6d0ba34a53b10365d3debc206192d
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Feb 24 13:57:53 2017 +0000

    Resolves: tdf#106123 store and restore the PaM around the menu Execute
    
    because the loss of focus in the current editeng causes writer annotations to
    save their contents, making the pContent of the current EditMaps invalid
    
    (cherry picked from commit 71a84b69ae30458a941f38869aa994118051a063)
    
    Change-Id: Ic01379291fa66dd58246d33287b18801f5da49c0
    Reviewed-on: https://gerrit.libreoffice.org/34614
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Michael Stahl <mstahl at redhat.com>
    (cherry picked from commit 612903384bbe68dfb3be1b36111e28b869aa0be8)

diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx
index c2cadb8..bd3bc6c 100644
--- a/editeng/source/editeng/editview.cxx
+++ b/editeng/source/editeng/editview.cxx
@@ -990,7 +990,18 @@ void EditView::ExecuteSpellPopup( const Point& rPosPixel, Link<SpellCallbackInfo
         aScreenPos = pImpEditView->GetWindow()->OutputToScreenPixel( aScreenPos );
         aTempRect = pImpEditView->GetWindow()->LogicToPixel( Rectangle(aScreenPos, aTempRect.GetSize() ));
 
+        //tdf#106123 store and restore the EditPaM around the menu Execute
+        //because the loss of focus in the current editeng causes writer
+        //annotations to save their contents, making the pContent of the
+        //current EditPams invalid
+        EPaM aP = pImpEditView->pEditEngine->pImpEditEngine->CreateEPaM(aPaM);
+        EPaM aP2 = pImpEditView->pEditEngine->pImpEditEngine->CreateEPaM(aPaM2);
+
         sal_uInt16 nId = aPopupMenu.Execute( pImpEditView->GetWindow(), aTempRect, PopupMenuFlags::NoMouseUpClose );
+
+        aPaM2 = pImpEditView->pEditEngine->pImpEditEngine->CreateEditPaM(aP2);
+        aPaM = pImpEditView->pEditEngine->pImpEditEngine->CreateEditPaM(aP);
+
         if ( nId == MN_IGNORE )
         {
             OUString aWord = pImpEditView->SpellIgnoreWord();
commit 701d1dc040399e02ab83e6011d8e254c60dd5497
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Mar 1 17:24:21 2017 +0000

    Resolves: tdf#106261 throw away old node map for table
    
    when generating a new one, otherwise on exporting the same table
    twice to two consecutive .doc footnotes will think the second
    export of the table is a level lower because it will find it
    in the map and
    
    WW8TableNodeInfo::Pointer_t WW8TableInfo::insertTableNodeInfo
    
    does pNodeInfo->setDepth(nDepth + pNodeInfo->getDepth());
    using the cached pNodeInfo depth and not a new fresh pNodeInfo of
    depth 0
    
    Change-Id: I7aa7ac6a19814910c1d19d78f04cfd9886c444c5
    (cherry picked from commit 6f3e24ad64dd40b3ef8def7d879ba395a16874a1)
    Reviewed-on: https://gerrit.libreoffice.org/34766
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Michael Stahl <mstahl at redhat.com>
    (cherry picked from commit c496b67a52ee4b5c7f9053cfe3dc54290e8d6392)

diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx
index 2e33088..a005cbe 100644
--- a/sw/source/filter/ww8/wrtww8.cxx
+++ b/sw/source/filter/ww8/wrtww8.cxx
@@ -1839,8 +1839,16 @@ void MSWordExportBase::WriteSpecialText( sal_uLong nStart, sal_uLong nEnd, sal_u
     // clear linked textboxes since old ones can't be linked to frames in this section
     m_aLinkedTextboxesHelper.clear();
 
+    // tdf#106261 Reset table infos, otherwise the depth of the cells will be
+    // incorrect, in case the header/footer had table(s) and we try to export
+    // the same table second time.
+    ww8::WW8TableInfo::Pointer_t pOldTableInfo = m_pTableInfo;
+    m_pTableInfo = std::make_shared<ww8::WW8TableInfo>();
+
     WriteText();
 
+    m_pTableInfo = pOldTableInfo;
+
     m_bOutPageDescs = bOldPageDescs;
     delete m_pCurPam;                    // delete Pam
     m_pCurPam = pOldPam;
commit b779e000d979b61ad0d238cb14365151fdb2622b
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Mar 1 11:12:45 2017 +0000

    ofz: Z_NEED_DICT is unsupported
    
    Change-Id: Ib0945d5a4606915aff9ee3019203caaf2a3cc7c5
    (cherry picked from commit aacaacc16938b030a1341d8dbaf56c6a2efeb1dc)
    Reviewed-on: https://gerrit.libreoffice.org/34744
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Michael Stahl <mstahl at redhat.com>
    (cherry picked from commit 92fcd775ef67df1c96a417151a60a94530379b8f)

diff --git a/tools/source/zcodec/zcodec.cxx b/tools/source/zcodec/zcodec.cxx
index 7a983aaf..afeacab 100644
--- a/tools/source/zcodec/zcodec.cxx
+++ b/tools/source/zcodec/zcodec.cxx
@@ -221,7 +221,7 @@ long ZCodec::Read( SvStream& rIStm, sal_uInt8* pData, sal_uIntPtr nSize )
 
         }
         err = mbStatus ? inflate(PZSTREAM, Z_NO_FLUSH) : Z_ERRNO;
-        if ( err < 0 )
+        if (err < 0 || err == Z_NEED_DICT)
         {
             // Accept Z_BUF_ERROR as EAGAIN or EWOULDBLOCK.
             mbStatus = (err == Z_BUF_ERROR);
diff --git a/vcl/qa/cppunit/graphicfilter/data/bmp/fail/nodict-compress.bmp b/vcl/qa/cppunit/graphicfilter/data/bmp/fail/nodict-compress.bmp
new file mode 100644
index 0000000..a75d6eb
Binary files /dev/null and b/vcl/qa/cppunit/graphicfilter/data/bmp/fail/nodict-compress.bmp differ
diff --git a/vcl/source/gdi/dibtools.cxx b/vcl/source/gdi/dibtools.cxx
index 5416da4..ab5d36f 100644
--- a/vcl/source/gdi/dibtools.cxx
+++ b/vcl/source/gdi/dibtools.cxx
@@ -856,7 +856,8 @@ bool ImplReadDIBBody( SvStream& rIStm, Bitmap& rBmp, AlphaMask* pBmpAlpha, sal_u
                 // Seek behind the encoded block. There might have been bytes left or the codec might have read more than necessary.
                 rIStm.Seek(nCodedSize + nCodedPos);
             }
-            else
+
+            if (aData.empty())
             {
                 // add something so we can take address of the first element
                 aData.resize(1);
@@ -865,7 +866,7 @@ bool ImplReadDIBBody( SvStream& rIStm, Bitmap& rBmp, AlphaMask* pBmpAlpha, sal_u
 
             // set decoded bytes to memory stream,
             // from which we will read the bitmap data
-            pMemStm.reset( new SvMemoryStream);
+            pMemStm.reset(new SvMemoryStream);
             pIStm = pMemStm.get();
             assert(!aData.empty());
             pMemStm->SetBuffer( &aData.front(), nUncodedSize, false, nUncodedSize );
commit 6dc4a3b254e4cf852e7e1c4d17117df55e0c160b
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Mar 1 14:11:47 2017 +0000

    ofz: oom on seeks past end of SvMemoryStream
    
    cause it grows to fit if its a resizable stream
    
    Change-Id: I28b42becdfc8eb591d19d2512cdc1f1ec32c3bbe
    (cherry picked from commit a42d9c5b541d637dcf24086e30f341b30e03c4c7)
    Reviewed-on: https://gerrit.libreoffice.org/34754
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Michael Stahl <mstahl at redhat.com>
    (cherry picked from commit 19561b0a54d0753db860e3b06b7b2ebba45a801c)

diff --git a/lotuswordpro/source/filter/lwpfilter.cxx b/lotuswordpro/source/filter/lwpfilter.cxx
index 5326e0c..1a551c2 100644
--- a/lotuswordpro/source/filter/lwpfilter.cxx
+++ b/lotuswordpro/source/filter/lwpfilter.cxx
@@ -105,7 +105,7 @@ using namespace OpenStormBento;
  bool Decompress(SvStream *pCompressed, SvStream * & pOutDecompressed)
 {
     pCompressed->Seek(0);
-    std::unique_ptr<SvStream> aDecompressed(new SvMemoryStream(4096, 4096));
+    std::unique_ptr<SvMemoryStream> aDecompressed(new SvMemoryStream(4096, 4096));
     unsigned char buffer[512];
     pCompressed->Read(buffer, 16);
     aDecompressed->Write(buffer, 16);
@@ -133,6 +133,9 @@ using namespace OpenStormBento;
     while (sal_uInt32 iRead = pCompressed->Read(buffer, 512))
         aDecompressed->Write(buffer, iRead);
 
+    // disable stream growing past its current size
+    aDecompressed->SetResizeOffset(0);
+
     //transfer ownership of aDecompressed's ptr
     pOutDecompressed = aDecompressed.release();
     return true;
commit 83e479913cbcb38bd75ed60bf1389af62c7d5841
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Mar 2 09:48:42 2017 +0000

    ofz: init vars
    
    Change-Id: Ie35617997845de25af9e528668bce4c332ac408a
    (cherry picked from commit 1c29456c9c9007b788297aebea58a1a765f77c84)
    Reviewed-on: https://gerrit.libreoffice.org/34786
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
    Tested-by: Jenkins <ci at libreoffice.org>
    (cherry picked from commit f96840d17562250aa7ac55f99934ee938008ce0c)

diff --git a/filter/source/graphicfilter/ipsd/ipsd.cxx b/filter/source/graphicfilter/ipsd/ipsd.cxx
index 3556aa7..008dad4 100644
--- a/filter/source/graphicfilter/ipsd/ipsd.cxx
+++ b/filter/source/graphicfilter/ipsd/ipsd.cxx
@@ -276,17 +276,17 @@ bool PSDReader::ImplReadHeader()
     // this is a loop over the resource entries to get the resolution info
     while( m_rPSD.Tell() < nLayerPos )
     {
-        sal_uInt8 n8;
-        sal_uInt32 nType, nPStringLen, nResEntryLen;
-        sal_uInt16 nUniqueID;
-
-        m_rPSD.ReadUInt32( nType ).ReadUInt16( nUniqueID ).ReadUChar( n8 );
-        nPStringLen = n8;
-        if ( nType != 0x3842494d )
+        sal_uInt32 nType(0);
+        sal_uInt16 nUniqueID(0);
+        sal_uInt8 n8(0);
+        m_rPSD.ReadUInt32(nType).ReadUInt16(nUniqueID).ReadUChar(n8);
+        if (nType != 0x3842494d)
             break;
+        sal_uInt32 nPStringLen = n8;
         if ( ! ( nPStringLen & 1 ) )
             nPStringLen++;
         m_rPSD.SeekRel( nPStringLen );  // skipping the pstring
+        sal_uInt32 nResEntryLen(0);
         m_rPSD.ReadUInt32( nResEntryLen );
         if ( nResEntryLen & 1 )
             nResEntryLen++;             // the resource entries are padded
commit 68f29d2a899a78b60f9600c2878052aa81728a4b
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Mar 3 09:44:24 2017 +0000

    ofz#721 use vector::at to check index
    
    Change-Id: I786b5d6fb10afe3ebb8482f999115fe72ffe2d4c
    Reviewed-on: https://gerrit.libreoffice.org/34853
    Reviewed-by: Michael Stahl <mstahl at redhat.com>
    Tested-by: Michael Stahl <mstahl at redhat.com>
    (cherry picked from commit f8de39789767f58c03b149371388a92722cb0427)

diff --git a/lotuswordpro/source/filter/lwpidxmgr.cxx b/lotuswordpro/source/filter/lwpidxmgr.cxx
index 8d02521..94cd789 100644
--- a/lotuswordpro/source/filter/lwpidxmgr.cxx
+++ b/lotuswordpro/source/filter/lwpidxmgr.cxx
@@ -194,7 +194,7 @@ void LwpIndexManager::ReadObjIndexData(LwpObjectStream* pObjStrm)
 
     std::vector<LwpKey*> vObjIndexs;
 
-    if(KeyCount)
+    if (KeyCount)
     {
         LwpKey* akey = new LwpKey();
         akey->id.Read(pObjStrm);
@@ -218,7 +218,7 @@ void LwpIndexManager::ReadObjIndexData(LwpObjectStream* pObjStrm)
 
     for( sal_uInt16 j=0; j<LeafCount; j++ )
     {
-        sal_Int64 nPos = m_TempVec[j]+LwpSvStream::LWP_STREAM_BASE;
+        sal_Int64 nPos = m_TempVec.at(j) + LwpSvStream::LWP_STREAM_BASE;
         sal_Int64 nActualPos = pObjStrm->GetStream()->Seek(nPos);
 
         if (nPos != nActualPos)
commit 7198c0f14c8059d602b91685317ccbc7f2e8bfbc
Author: Tor Lillqvist <tml at collabora.com>
Date:   Fri Feb 17 11:21:02 2017 +0200

    tdf#90407: Export Text AutoFit to .pptx
    
    (cherry picked from commit 7277991e78c264025b4894ae07b40fb12cd57ce6)
    Reviewed-on: https://gerrit.libreoffice.org/34374
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>
    (cherry picked from commit 3d9e1d16b884417ec892f67da625cf02d897f2cc)
    
    Change-Id: I2120f13fff58d4736ab55071236e0c2f80ba2eb0

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 3070af1..ae4f9e3 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -50,6 +50,7 @@
 #include <com/sun/star/drawing/LineDash.hpp>
 #include <com/sun/star/drawing/LineJoint.hpp>
 #include <com/sun/star/drawing/LineStyle.hpp>
+#include <com/sun/star/drawing/TextFitToSizeType.hpp>
 #include <com/sun/star/drawing/TextHorizontalAdjust.hpp>
 #include <com/sun/star/drawing/TextVerticalAdjust.hpp>
 #include <com/sun/star/drawing/XShape.hpp>
@@ -81,8 +82,9 @@
 #include <filter/msfilter/util.hxx>
 #include <editeng/outlobj.hxx>
 #include <editeng/svxenum.hxx>
-#include <svx/unoapi.hxx>
+#include <svx/sdtfsitm.hxx>
 #include <svx/svdoashp.hxx>
+#include <svx/unoapi.hxx>
 #include <svx/unoshape.hxx>
 
 using namespace ::css;
@@ -2081,6 +2083,14 @@ void DrawingML::WriteText( Reference< XInterface > rXIface, const OUString& pres
             GET(bTextAutoGrowHeight, TextAutoGrowHeight);
             mpFS->singleElementNS(XML_a, (bTextAutoGrowHeight ? XML_spAutoFit : XML_noAutofit), FSEND);
         }
+        if (GetDocumentType() == DOCUMENT_PPTX)
+        {
+            TextFitToSizeType eFit = TextFitToSizeType_NONE;
+            if (GETA(TextFitToSize))
+                mAny >>= eFit;
+            if (eFit == TextFitToSizeType_AUTOFIT)
+                mpFS->singleElementNS(XML_a, XML_normAutofit, FSEND);
+        }
         mpFS->endElementNS((nXmlNamespace ? nXmlNamespace : XML_a), XML_bodyPr);
     }
 
commit 23910b2eae6a078387c41bce54ee01db2e77fee7
Author: Michael Stahl <mstahl at redhat.com>
Date:   Wed Mar 1 17:20:41 2017 +0100

    tdf#77111 sw: fix page number offset on table dialog "Text Flow"
    
    Commit c2ccd20c0fd92bddfff76447754541705e3eb8f3 introduced 0 as a valid
    value for page number offset in sw core.
    
    Unfortunately the table dialog was not changed then; previously
    page number 0 would do automatic numbering, but since then 0 was set as
    the offset, and once you have a 0 offset there's no easy way to remove
    it, you have to remove the whole page break.
    
    * change the label before the text number edit widget to a checkbox
      that disables the edit widget
    * keep the id "pagenoft" so that translations still work
    * set initial value to 1; 0 is a really bad default since we can't
      export it to ODF
    * add a little bit of left margin so the line is indented below the
      upper line
    
    (cherry picked from commit c1e7fc6f497d7570cb0832c43647d295f8592567)
    Reviewed-on: https://gerrit.libreoffice.org/34763
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>
    (cherry picked from commit 362ff67556cca0890ca01f2de44596491c0e9bc8)
    
    Change-Id: I70cf5a66d4191acd2c19b3d0a83609e2b348a886
    Reviewed-on: https://gerrit.libreoffice.org/34811
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>
    (cherry picked from commit e4f50efd000734c8259ed2915bf0dd1c71700ceb)

diff --git a/sw/source/ui/table/tabledlg.cxx b/sw/source/ui/table/tabledlg.cxx
index 28c7a58..e153d69 100644
--- a/sw/source/ui/table/tabledlg.cxx
+++ b/sw/source/ui/table/tabledlg.cxx
@@ -1288,7 +1288,7 @@ SwTextFlowPage::SwTextFlowPage(vcl::Window* pParent, const SfxItemSet& rSet)
 
     get(m_pPageCollCB, "pagestyle");
     get(m_pPageCollLB, "pagestylelb");
-    get(m_pPageNoFT, "pagenoft");
+    get(m_pPageNoCB, "pagenoft");
     get(m_pPageNoNF, "pagenonf");
 
     get(m_pSplitCB, "split");
@@ -1319,6 +1319,8 @@ SwTextFlowPage::SwTextFlowPage(vcl::Window* pParent, const SfxItemSet& rSet)
         LINK( this, SwTextFlowPage, PageBreakTypeHdl_Impl ) );
     m_pPgBrkRB->SetClickHdl(
         LINK( this, SwTextFlowPage, PageBreakTypeHdl_Impl ) );
+    m_pPageNoCB->SetClickHdl(
+        LINK(this, SwTextFlowPage, PageNoClickHdl_Impl));
     m_pSplitCB->SetClickHdl(
         LINK( this, SwTextFlowPage, SplitHdl_Impl));
     m_pSplitRowCB->SetClickHdl(
@@ -1353,7 +1355,7 @@ void SwTextFlowPage::dispose()
     m_pPgBrkAfterRB.clear();
     m_pPageCollCB.clear();
     m_pPageCollLB.clear();
-    m_pPageNoFT.clear();
+    m_pPageNoCB.clear();
     m_pPageNoNF.clear();
     m_pSplitCB.clear();
     m_pSplitRowCB.clear();
@@ -1399,10 +1401,10 @@ bool  SwTextFlowPage::FillItemSet( SfxItemSet* rSet )
 
     //If we have a page style, then there's no break
     bool bPageItemPut = false;
-    if ( bState != (m_pPageCollCB->GetSavedValue() == 1) ||
-         ( bState &&
-           m_pPageCollLB->IsValueChangedFromSaved() )
-           || (m_pPageNoNF->IsEnabled() && m_pPageNoNF->IsValueModified()) )
+    if (   bState != (m_pPageCollCB->GetSavedValue() == TRISTATE_TRUE)
+        || (bState && m_pPageCollLB->IsValueChangedFromSaved())
+        || (m_pPageNoCB->IsEnabled() && m_pPageNoCB->IsValueChangedFromSaved())
+        || (m_pPageNoNF->IsEnabled() && m_pPageNoNF->IsValueModified()))
     {
         OUString sPage;
 
@@ -1411,12 +1413,15 @@ bool  SwTextFlowPage::FillItemSet( SfxItemSet* rSet )
             sPage = m_pPageCollLB->GetSelectEntry();
         }
         sal_uInt16 nPgNum = static_cast< sal_uInt16 >(m_pPageNoNF->GetValue());
-        if ( !pDesc || !pDesc->GetPageDesc() ||
-            ( pDesc->GetPageDesc() && ((pDesc->GetPageDesc()->GetName() != sPage) ||
-                    !comphelper::string::equals(m_pPageNoNF->GetSavedValue(), nPgNum))))
+        bool const usePageNo(bState && m_pPageNoCB->IsChecked());
+        boost::optional<sal_uInt16> const oPageNum(
+                (usePageNo) ? nPgNum : boost::optional<sal_Int16>());
+        if (!pDesc || !pDesc->GetPageDesc()
+            || (pDesc->GetPageDesc()->GetName() != sPage)
+            || (pDesc->GetNumOffset() != oPageNum))
         {
             SwFormatPageDesc aFormat( pShell->FindPageDescByName( sPage, true ) );
-            aFormat.SetNumOffset(bState ? nPgNum : 0);
+            aFormat.SetNumOffset(oPageNum);
             bModified |= nullptr != rSet->Put( aFormat );
             bPageItemPut = bState;
         }
@@ -1538,12 +1543,18 @@ void   SwTextFlowPage::Reset( const SfxItemSet* rSet )
                 OUString sPageDesc;
                 const SwPageDesc* pDesc = static_cast<const SwFormatPageDesc*>(pItem)->GetPageDesc();
 
-                //m_pPageNoNF->SetValue(static_cast<const SwFormatPageDesc*>(pItem)->GetNumOffset());
                 ::boost::optional<sal_uInt16> oNumOffset = static_cast<const SwFormatPageDesc*>(pItem)->GetNumOffset();
                 if (oNumOffset)
+                {
+                    m_pPageNoCB->Check();
+                    m_pPageNoNF->Enable(true);
                     m_pPageNoNF->SetValue(oNumOffset.get());
+                }
                 else
+                {
+                    m_pPageNoCB->Check(false);
                     m_pPageNoNF->Enable(false);
+                }
 
                 if(pDesc)
                     sPageDesc = pDesc->GetName();
@@ -1583,7 +1594,7 @@ void   SwTextFlowPage::Reset( const SfxItemSet* rSet )
                     m_pPgBrkCB->Check();
                     m_pPageCollCB->Enable(false);
                     m_pPageCollLB->Enable(false);
-                    m_pPageNoFT->Enable(false);
+                    m_pPageNoCB->Enable(false);
                     m_pPageNoNF->Enable(false);
                 }
                 switch ( eBreak )
@@ -1671,6 +1682,7 @@ void   SwTextFlowPage::Reset( const SfxItemSet* rSet )
     m_pColBrkRB->SaveValue();
     m_pPgBrkBeforeRB->SaveValue();
     m_pPgBrkAfterRB->SaveValue();
+    m_pPageNoCB->SaveValue();
     m_pPageNoNF->SaveValue();
     m_pTextDirectionLB->SaveValue();
     m_pVertOrientLB->SaveValue();
@@ -1685,7 +1697,7 @@ void SwTextFlowPage::SetShell(SwWrtShell* pSh)
     if(bHtmlMode)
     {
         m_pPageNoNF->Enable(false);
-        m_pPageNoFT->Enable(false);
+        m_pPageNoCB->Enable(false);
     }
 }
 
@@ -1707,8 +1719,8 @@ IMPL_LINK_NOARG_TYPED(SwTextFlowPage, PageBreakHdl_Impl, Button*, void)
                 m_pPageCollLB->Enable(bEnable);
                 if(!bHtmlMode)
                 {
-                    m_pPageNoFT->Enable(bEnable);
-                    m_pPageNoNF->Enable(bEnable);
+                    m_pPageNoCB->Enable(bEnable);
+                    m_pPageNoNF->Enable(bEnable && m_pPageNoCB->IsChecked());
                 }
             }
     }
@@ -1717,7 +1729,7 @@ IMPL_LINK_NOARG_TYPED(SwTextFlowPage, PageBreakHdl_Impl, Button*, void)
             m_pPageCollCB->Check( false );
             m_pPageCollCB->Enable(false);
             m_pPageCollLB->Enable(false);
-            m_pPageNoFT->Enable(false);
+            m_pPageNoCB->Enable(false);
             m_pPageNoNF->Enable(false);
             m_pPgBrkRB->       Enable(false);
             m_pColBrkRB->      Enable(false);
@@ -1742,8 +1754,8 @@ IMPL_LINK_NOARG_TYPED(SwTextFlowPage, ApplyCollClickHdl_Impl, Button*, void)
     m_pPageCollLB->Enable(bEnable);
     if(!bHtmlMode)
     {
-        m_pPageNoFT->Enable(bEnable);
-        m_pPageNoNF->Enable(bEnable);
+        m_pPageNoCB->Enable(bEnable);
+        m_pPageNoNF->Enable(bEnable && m_pPageNoCB->IsChecked());
     }
 }
 
@@ -1761,8 +1773,8 @@ IMPL_LINK_TYPED( SwTextFlowPage, PageBreakPosHdl_Impl, Button*, pBtn, void )
             m_pPageCollLB->Enable(bEnable);
             if(!bHtmlMode)
             {
-                m_pPageNoFT->Enable(bEnable);
-                m_pPageNoNF->Enable(bEnable);
+                m_pPageNoCB->Enable(bEnable);
+                m_pPageNoNF->Enable(bEnable && m_pPageNoCB->IsChecked());
             }
         }
         else if (pBtn == m_pPgBrkAfterRB)
@@ -1770,7 +1782,7 @@ IMPL_LINK_TYPED( SwTextFlowPage, PageBreakPosHdl_Impl, Button*, pBtn, void )
             m_pPageCollCB->Check( false );
             m_pPageCollCB->Enable(false);
             m_pPageCollLB->Enable(false);
-            m_pPageNoFT->Enable(false);
+            m_pPageNoCB->Enable(false);
             m_pPageNoNF->Enable(false);
         }
     }
@@ -1783,13 +1795,18 @@ IMPL_LINK_TYPED( SwTextFlowPage, PageBreakTypeHdl_Impl, Button*, pBtn, void )
         m_pPageCollCB->Check(false);
         m_pPageCollCB->Enable(false);
         m_pPageCollLB->Enable(false);
-        m_pPageNoFT->Enable(false);
+        m_pPageNoCB->Enable(false);
         m_pPageNoNF->Enable(false);
     }
     else if ( m_pPgBrkBeforeRB->IsChecked() )
         PageBreakPosHdl_Impl(m_pPgBrkBeforeRB);
 }
 
+IMPL_LINK_NOARG_TYPED(SwTextFlowPage, PageNoClickHdl_Impl, Button*, void)
+{
+    m_pPageNoNF->Enable(m_pPageNoCB->IsChecked());
+}
+
 IMPL_LINK_TYPED( SwTextFlowPage, SplitHdl_Impl, Button*, pBox, void )
 {
     m_pSplitRowCB->Enable(static_cast<CheckBox*>(pBox)->IsChecked());
@@ -1816,7 +1833,7 @@ void SwTextFlowPage::DisablePageBreak()
     m_pPgBrkAfterRB->Disable();
     m_pPageCollCB->Disable();
     m_pPageCollLB->Disable();
-    m_pPageNoFT->Disable();
+    m_pPageNoCB->Disable();
     m_pPageNoNF->Disable();
 }
 
diff --git a/sw/source/uibase/table/tablepg.hxx b/sw/source/uibase/table/tablepg.hxx
index d832099..350c0ba 100644
--- a/sw/source/uibase/table/tablepg.hxx
+++ b/sw/source/uibase/table/tablepg.hxx
@@ -156,7 +156,7 @@ class SwTextFlowPage : public SfxTabPage
 
     VclPtr<CheckBox>       m_pPageCollCB;
     VclPtr<ListBox>        m_pPageCollLB;
-    VclPtr<FixedText>      m_pPageNoFT;
+    VclPtr<CheckBox>       m_pPageNoCB;
     VclPtr<NumericField>   m_pPageNoNF;
     VclPtr<CheckBox>       m_pSplitCB;
     VclPtr<TriStateBox>    m_pSplitRowCB;
@@ -177,6 +177,7 @@ class SwTextFlowPage : public SfxTabPage
     DECL_LINK_TYPED(ApplyCollClickHdl_Impl, Button*, void);
     DECL_LINK_TYPED( PageBreakPosHdl_Impl, Button*, void );
     DECL_LINK_TYPED( PageBreakTypeHdl_Impl, Button*, void );
+    DECL_LINK_TYPED(PageNoClickHdl_Impl, Button*, void);
     DECL_LINK_TYPED( SplitHdl_Impl, Button*, void );
     DECL_STATIC_LINK_TYPED( SwTextFlowPage, SplitRowHdl_Impl, Button*, void );
     DECL_LINK_TYPED( HeadLineCBClickHdl, Button* = nullptr, void );
diff --git a/sw/uiconfig/swriter/ui/tabletextflowpage.ui b/sw/uiconfig/swriter/ui/tabletextflowpage.ui
index 9af0800..9b34ddd 100644
--- a/sw/uiconfig/swriter/ui/tabletextflowpage.ui
+++ b/sw/uiconfig/swriter/ui/tabletextflowpage.ui
@@ -5,6 +5,7 @@
     <property name="upper">9999</property>
     <property name="step_increment">1</property>
     <property name="page_increment">10</property>
+    <property name="value">1</property>
   </object>
   <object class="GtkAdjustment" id="adjustment2">
     <property name="upper">100</property>
@@ -202,6 +203,7 @@
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="receives_default">False</property>
+                        <property name="margin_left">22</property>
                         <property name="use_underline">True</property>
                         <property name="xalign">0</property>
                         <property name="draw_indicator">True</property>
@@ -217,12 +219,11 @@
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkLabel" id="pagenoft">
+                      <object class="GtkCheckButton" id="pagenoft">
                         <property name="visible">True</property>
-                        <property name="can_focus">False</property>
+                        <property name="can_focus">True</property>
                         <property name="label" translatable="yes">Page _number</property>
                         <property name="use_underline">True</property>
-                        <property name="mnemonic_widget">pagenonf</property>
                       </object>
                       <packing>
                         <property name="left_attach">2</property>
@@ -238,6 +239,9 @@
                         <property name="invisible_char">•</property>
                         <property name="invisible_char_set">True</property>
                         <property name="adjustment">adjustment1</property>
+                        <accessibility>
+                          <relation type="labelled-by" target="pagenoft"/>
+                        </accessibility>
                       </object>
                       <packing>
                         <property name="left_attach">3</property>
commit 3ea00521762dd3527865fd9010409a83c9adbb1f
Author: Michael Stahl <mstahl at redhat.com>
Date:   Wed Mar 1 12:39:54 2017 +0100

    tdf#77111 cui,sw: fix page number offset on paragraph dialog "Text Flow"
    
    Commit c2ccd20c0fd92bddfff76447754541705e3eb8f3 introduced 0 as a valid
    value for page number offset in sw core.
    
    Unfortunately the paragraph dialog was not changed then; previously
    page number 0 would do automatic numbering, but since then 0 was set as
    the offset, and once you have a 0 offset there's no easy way to remove
    it, you have to remove the whole page break.
    
    * change the label before the text number edit widget to a checkbox
      that disables the edit widget
    
    * keep the id "labelPageNum" so that translations still work
    
    * adapt SfxToSwPageDescAttr so it can not just set but also clear the
      page number
    
    * set initial value to 1; 0 is a really bad default since we can't
      export it to ODF (see tdf#91306)
    
    (cherry picked from commit d36fa0589ab822dc617c65b4d0d3bf68c092ad37)
    Reviewed-on: https://gerrit.libreoffice.org/34745
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>
    (cherry picked from commit a5104f575a5acf8aea957cb79aa0fd67bc74f141)
    
    Change-Id: Ic4ca9e2562bb65ac359b305a2202f782e8598307
    Reviewed-on: https://gerrit.libreoffice.org/34810
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>
    (cherry picked from commit c43cc2d70a8083c70e615335d19780bd59f40fd8)

diff --git a/cui/source/inc/paragrph.hxx b/cui/source/inc/paragrph.hxx
index 6397f82..1e79a0c 100644
--- a/cui/source/inc/paragrph.hxx
+++ b/cui/source/inc/paragrph.hxx
@@ -236,7 +236,7 @@ private:
     VclPtr<ListBox>            m_pBreakPositionLB;
     VclPtr<TriStateBox>        m_pApplyCollBtn;
     VclPtr<ListBox>            m_pApplyCollBox;
-    VclPtr<FixedText>          m_pPagenumText;
+    VclPtr<TriStateBox>        m_pPageNumBox;
     VclPtr<NumericField>       m_pPagenumEdit;
 
     // paragraph division
@@ -264,6 +264,7 @@ private:
     DECL_LINK_TYPED(ApplyCollClickHdl_Impl, Button*, void);
     DECL_LINK_TYPED( PageBreakPosHdl_Impl, ListBox&, void );
     DECL_LINK_TYPED( PageBreakTypeHdl_Impl, ListBox&, void );
+    DECL_LINK_TYPED(PageNumBoxClickHdl_Impl, Button*, void);
 
     virtual void            PageCreated(const SfxAllItemSet& aSet) override;
 };
diff --git a/cui/source/tabpages/paragrph.cxx b/cui/source/tabpages/paragrph.cxx
index b00e6b4..39889a8 100644
--- a/cui/source/tabpages/paragrph.cxx
+++ b/cui/source/tabpages/paragrph.cxx
@@ -1397,18 +1397,27 @@ bool SvxExtParagraphTabPage::FillItemSet( SfxItemSet* rOutSet )
         }
     }
 
-    if (m_pPagenumEdit->IsEnabled() && m_pPagenumEdit->IsValueModified())
+    if (m_pPageNumBox->IsEnabled()
+        && (m_pPageNumBox->IsValueChangedFromSaved() || m_pPagenumEdit->IsValueModified()))
     {
-        SfxUInt16Item aPageNum( SID_ATTR_PARA_PAGENUM,
-                                (sal_uInt16)m_pPagenumEdit->GetValue() );
-
         pOld = GetOldItem( *rOutSet, SID_ATTR_PARA_PAGENUM );
 
-        if ( !pOld || static_cast<const SfxUInt16Item*>(pOld)->GetValue() != aPageNum.GetValue() )
+        if (TRISTATE_TRUE == m_pPageNumBox->GetState()
+            && (!pOld || IsInvalidItem(pOld)
+                || static_cast<const SfxUInt16Item*>(pOld)->GetValue() != m_pPagenumEdit->GetValue()))
         {
+            SfxUInt16Item aPageNum(SID_ATTR_PARA_PAGENUM,
+                    static_cast<sal_uInt16>(m_pPagenumEdit->GetValue()));
             rOutSet->Put( aPageNum );
             bModified = true;
         }
+        else if (TRISTATE_FALSE == m_pPageNumBox->GetState()
+                && (pOld || IsInvalidItem(pOld)))
+        {
+            // need to tell sw to remove the item
+            rOutSet->DisableItem(SID_ATTR_PARA_PAGENUM);
+            bModified = true;
+        }
     }
 
     // pagebreak
@@ -1600,11 +1609,34 @@ void SvxExtParagraphTabPage::Reset( const SfxItemSet* rSet )
 
     _nWhich = GetWhich( SID_ATTR_PARA_PAGENUM );
 
-    if (rSet->GetItemState(_nWhich) >= SfxItemState::SET)
+    switch (rSet->GetItemState(_nWhich))
     {
-        const sal_uInt16 nPageNum =
-            static_cast<const SfxUInt16Item&>(rSet->Get( _nWhich ) ).GetValue();
-        m_pPagenumEdit->SetValue( nPageNum );
+        case SfxItemState::SET:
+        {
+            m_pPageNumBox->EnableTriState(false);
+            m_pPageNumBox->SetState(TRISTATE_TRUE);
+            SfxUInt16Item const*const pItem(static_cast<const SfxUInt16Item*>(rSet->GetItem(_nWhich)));
+            const sal_uInt16 nPageNum(pItem->GetValue());
+            m_pPagenumEdit->SetValue( nPageNum );
+            break;
+        }
+        case SfxItemState::DONTCARE:
+        {
+            m_pPageNumBox->EnableTriState();
+            m_pPageNumBox->SetState(TRISTATE_INDET);
+            break;
+        }
+        case SfxItemState::UNKNOWN:
+        case SfxItemState::DEFAULT:
+        case SfxItemState::DISABLED:
+        {
+            m_pPageNumBox->EnableTriState(false);
+            m_pPageNumBox->SetState(TRISTATE_FALSE);
+            break;
+        }
+        default:
+            assert(false); // unexpected
+            break;
     }
 
     if ( bPageBreak )
@@ -1660,7 +1692,7 @@ void SvxExtParagraphTabPage::Reset( const SfxItemSet* rSet )
             m_pApplyCollBtn->Enable(false);
             m_pApplyCollBox->Enable(false);
             m_pPagenumEdit->Enable(false);
-            m_pPagenumText->Enable(false);
+            m_pPageNumBox->Enable(false);
         }
 
         if ( !bIsPageModel )
@@ -1693,6 +1725,7 @@ void SvxExtParagraphTabPage::Reset( const SfxItemSet* rSet )
                 if(!_bEnable)
                 {
                     m_pApplyCollBox->Enable(_bEnable);
+                    m_pPageNumBox->Enable(false);
                     m_pPagenumEdit->Enable(_bEnable);
                 }
 
@@ -1840,6 +1873,7 @@ void SvxExtParagraphTabPage::ChangesApplied()
     m_pBreakTypeLB->SaveValue();
     m_pApplyCollBtn->SaveValue();
     m_pApplyCollBox->SaveValue();
+    m_pPageNumBox->SaveValue();
     m_pPagenumEdit->SaveValue();
     m_pKeepTogetherBox->SaveValue();
     m_pKeepParaBox->SaveValue();
@@ -1865,6 +1899,7 @@ void SvxExtParagraphTabPage::DisablePageBreak()
     m_pBreakPositionLB->Enable(false);
     m_pApplyCollBtn->Enable(false);
     m_pApplyCollBox->Enable(false);
+    m_pPageNumBox->Enable(false);
     m_pPagenumEdit->Enable(false);
 }
 
@@ -1893,7 +1928,7 @@ SvxExtParagraphTabPage::SvxExtParagraphTabPage( vcl::Window* pParent, const SfxI
     get(m_pPagenumEdit,"spinPageNumber");
     get(m_pBreakTypeFT,"labelType");
     get(m_pBreakPositionFT,"labelPosition");
-    get(m_pPagenumText,"labelPageNum");
+    get(m_pPageNumBox,"labelPageNum");
 
     // Options
     get(m_pKeepTogetherBox,"checkSplitPara");
@@ -1924,6 +1959,7 @@ SvxExtParagraphTabPage::SvxExtParagraphTabPage( vcl::Window* pParent, const SfxI
     m_pApplyCollBtn->SetClickHdl(      LINK( this, SvxExtParagraphTabPage, ApplyCollClickHdl_Impl ) );
     m_pBreakTypeLB->SetSelectHdl(      LINK( this, SvxExtParagraphTabPage, PageBreakTypeHdl_Impl ) );
     m_pBreakPositionLB->SetSelectHdl(  LINK( this, SvxExtParagraphTabPage, PageBreakPosHdl_Impl ) );
+    m_pPageNumBox->SetClickHdl(        LINK( this, SvxExtParagraphTabPage, PageNumBoxClickHdl_Impl ) );
 
     SfxObjectShell* pSh = SfxObjectShell::Current();
     if ( pSh )
@@ -1955,7 +1991,7 @@ SvxExtParagraphTabPage::SvxExtParagraphTabPage( vcl::Window* pParent, const SfxI
         m_pExtHyphenAfterBox   ->Enable(false);
         m_pMaxHyphenLabel      ->Enable(false);
         m_pMaxHyphenEdit       ->Enable(false);
-        m_pPagenumText         ->Enable(false);
+        m_pPageNumBox          ->Enable(false);
         m_pPagenumEdit         ->Enable(false);
         // no column break in HTML
         m_pBreakTypeLB->RemoveEntry(1);
@@ -1983,7 +2019,7 @@ void SvxExtParagraphTabPage::dispose()
     m_pBreakPositionLB.clear();
     m_pApplyCollBtn.clear();
     m_pApplyCollBox.clear();
-    m_pPagenumText.clear();
+    m_pPageNumBox.clear();
     m_pPagenumEdit.clear();
     m_pKeepTogetherBox.clear();
     m_pKeepParaBox.clear();
@@ -2016,8 +2052,8 @@ IMPL_LINK_NOARG_TYPED(SvxExtParagraphTabPage, PageBreakHdl_Impl, Button*, void)
                 m_pApplyCollBox->Enable(bEnable);
                 if(!bHtmlMode)
                 {
-                    m_pPagenumText->Enable(bEnable);
-                    m_pPagenumEdit->Enable(bEnable);
+                    m_pPageNumBox->Enable(bEnable);
+                    m_pPagenumEdit->Enable(bEnable && m_pPageNumBox->GetState() == TRISTATE_TRUE);
                 }
             }
             break;
@@ -2027,7 +2063,7 @@ IMPL_LINK_NOARG_TYPED(SvxExtParagraphTabPage, PageBreakHdl_Impl, Button*, void)
             m_pApplyCollBtn->SetState( TRISTATE_FALSE );
             m_pApplyCollBtn->Enable(false);
             m_pApplyCollBox->Enable(false);
-            m_pPagenumText->Enable(false);
+            m_pPageNumBox->Enable(false);
             m_pPagenumEdit->Enable(false);
             m_pBreakTypeFT->Enable(false);
             m_pBreakTypeLB->Enable(false);
@@ -2117,8 +2153,8 @@ IMPL_LINK_NOARG_TYPED(SvxExtParagraphTabPage, ApplyCollClickHdl_Impl, Button*, v
     m_pApplyCollBox->Enable(bEnable);
     if(!bHtmlMode)
     {
-        m_pPagenumText->Enable(bEnable);
-        m_pPagenumEdit->Enable(bEnable);
+        m_pPageNumBox->Enable(bEnable);
+        m_pPagenumEdit->Enable(bEnable && m_pPageNumBox->GetState() == TRISTATE_TRUE);
     }
 }
 
@@ -2134,8 +2170,8 @@ IMPL_LINK_TYPED( SvxExtParagraphTabPage, PageBreakPosHdl_Impl, ListBox&, rListBo
         m_pApplyCollBox->Enable(bEnable);
         if(!bHtmlMode)
         {
-            m_pPagenumText->Enable(bEnable);
-            m_pPagenumEdit->Enable(bEnable);
+            m_pPageNumBox->Enable(bEnable);
+            m_pPagenumEdit->Enable(bEnable && m_pPageNumBox->GetState() == TRISTATE_TRUE);
         }
     }
     else if ( 1 == rListBox.GetSelectEntryPos() )
@@ -2143,7 +2179,7 @@ IMPL_LINK_TYPED( SvxExtParagraphTabPage, PageBreakPosHdl_Impl, ListBox&, rListBo
         m_pApplyCollBtn->SetState( TRISTATE_FALSE );
         m_pApplyCollBtn->Enable(false);
         m_pApplyCollBox->Enable(false);
-        m_pPagenumText->Enable(false);
+        m_pPageNumBox->Enable(false);
         m_pPagenumEdit->Enable(false);
     }
 }
@@ -2157,13 +2193,18 @@ IMPL_LINK_TYPED( SvxExtParagraphTabPage, PageBreakTypeHdl_Impl, ListBox&, rListB
         m_pApplyCollBtn->SetState( TRISTATE_FALSE );
         m_pApplyCollBtn->Enable(false);
         m_pApplyCollBox->Enable(false);
-        m_pPagenumText->Enable(false);
+        m_pPageNumBox->Enable(false);
         m_pPagenumEdit->Enable(false);
     }
     else
         PageBreakPosHdl_Impl( *m_pBreakPositionLB );
 }
 
+IMPL_LINK_NOARG_TYPED(SvxExtParagraphTabPage, PageNumBoxClickHdl_Impl, Button*, void)
+{
+    m_pPagenumEdit->Enable(m_pPageNumBox->GetState() == TRISTATE_TRUE);
+}
+
 void SvxExtParagraphTabPage::PageCreated(const SfxAllItemSet& aSet)
 {
     const SfxBoolItem* pDisablePageBreakItem = aSet.GetItem<SfxBoolItem>(SID_DISABLE_SVXEXTPARAGRAPHTABPAGE_PAGEBREAK, false);
diff --git a/cui/uiconfig/ui/textflowpage.ui b/cui/uiconfig/ui/textflowpage.ui
index 0674dbc..a5c3ed8 100644
--- a/cui/uiconfig/ui/textflowpage.ui
+++ b/cui/uiconfig/ui/textflowpage.ui
@@ -18,6 +18,7 @@
     <property name="upper">9999</property>
     <property name="step_increment">1</property>
     <property name="page_increment">10</property>
+    <property name="value">1</property>
   </object>
   <object class="GtkGrid" id="TextFlowPage">
     <property name="visible">True</property>
@@ -243,6 +244,9 @@
                     <property name="can_focus">True</property>
                     <property name="invisible_char">•</property>
                     <property name="adjustment">adjustment3</property>
+                    <accessibility>
+                      <relation type="labelled-by" target="labelPageNum"/>
+                    </accessibility>
                   </object>
                   <packing>
                     <property name="left_attach">4</property>
@@ -250,14 +254,14 @@
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkLabel" id="labelPageNum">
+                  <object class="GtkCheckButton" id="labelPageNum">
                     <property name="visible">True</property>
-                    <property name="can_focus">False</property>
+                    <property name="can_focus">True</property>
                     <property name="xalign">1</property>
                     <property name="label" translatable="yes">Page _number:</property>
                     <property name="use_underline">True</property>
+                    <property name="inconsistent">True</property>
                     <property name="justify">right</property>
-                    <property name="mnemonic_widget">spinPageNumber</property>
                   </object>
                   <packing>
                     <property name="left_attach">3</property>
diff --git a/sw/source/uibase/utlui/uitool.cxx b/sw/source/uibase/utlui/uitool.cxx
index 476cef8..e35daa8 100644
--- a/sw/source/uibase/utlui/uitool.cxx
+++ b/sw/source/uibase/utlui/uitool.cxx
@@ -601,10 +601,25 @@ void SfxToSwPageDescAttr( const SwWrtShell& rShell, SfxItemSet& rSet )
 
     bool bChanged = false;
     // Page number
-    if(SfxItemState::SET == rSet.GetItemState(SID_ATTR_PARA_PAGENUM, false, &pItem))
+    switch (rSet.GetItemState(SID_ATTR_PARA_PAGENUM, false, &pItem))
     {
-        aPgDesc.SetNumOffset(static_cast<const SfxUInt16Item*>(pItem)->GetValue());
-        bChanged = true;
+        case SfxItemState::SET:
+        {
+            aPgDesc.SetNumOffset(static_cast<const SfxUInt16Item*>(pItem)->GetValue());
+            bChanged = true;
+            break;
+        }
+        case SfxItemState::DISABLED:
+        {
+            bChanged = true; // default initialised aPgDesc clears the number
+            break;
+        }
+        case SfxItemState::UNKNOWN:
+        case SfxItemState::DEFAULT:
+            break;
+        default:
+            assert(false); // unexpected
+            break;
     }
     if( SfxItemState::SET == rSet.GetItemState( SID_ATTR_PARA_MODEL, false, &pItem ))
     {
commit f46e9e343524905ad819e26da33c24e0e1599710
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Feb 28 16:43:44 2017 +0000

    ofz#668: check nTargetBits size
    
    Change-Id: I5cc7499cfdee58ffa480bb31dfc262d5b781180d
    (cherry picked from commit 99c361be16eb3a21aa679a103db2d07ecd0f5d3c)
    Reviewed-on: https://gerrit.libreoffice.org/34724
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
    Tested-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
    (cherry picked from commit aa5efe3ca9167c60049292e32b2b7c731e799e42)

diff --git a/filter/source/graphicfilter/itiff/ccidecom.cxx b/filter/source/graphicfilter/itiff/ccidecom.cxx
index 1cb7d7d..4fcb6b9 100644
--- a/filter/source/graphicfilter/itiff/ccidecom.cxx
+++ b/filter/source/graphicfilter/itiff/ccidecom.cxx
@@ -627,7 +627,9 @@ void CCIDecompressor::StartDecompression( SvStream & rIStream )
 
 bool CCIDecompressor::DecompressScanline( sal_uInt8 * pTarget, sal_uLong nTargetBits, bool bLastLine )
 {
-    bool b2D;
+    //Read[1|2]DScanlineData take a sal_uInt16, so its either limit here or expand there
+    if (nTargetBits > SAL_MAX_UINT16)
+        return false;
 
     if ( nEOLCount >= 5 )   // RTC (Return To Controller)
         return true;
@@ -682,6 +684,7 @@ bool CCIDecompressor::DecompressScanline( sal_uInt8 * pTarget, sal_uLong nTarget
     if ( nOptions & CCI_OPTION_BYTEALIGNROW )
         nInputBitsBufSize &= 0xfff8;
 
+    bool b2D;
     // is it a 2D row?
     if ( nOptions & CCI_OPTION_2D )
     {
commit cafd41ed87b3f24caf12fbf6f142875c3ddf44c0
Author: Eike Rathke <erack at redhat.com>
Date:   Fri Feb 17 23:54:21 2017 +0100

    Resolves: tdf#105667 forget target area's caption pointer in Merge Undo
    
    It's the same that was copied to the Undo document, so don't delete the
    caption.
    
    (cherry picked from commit a627c44026fcf883918f84bddd1c3b745e1f898c)
    
    Change-Id: Ib89870ed6e392c4271de2f416c78d42135922609
    Reviewed-on: https://gerrit.libreoffice.org/34385
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Eike Rathke <erack at redhat.com>
    (cherry picked from commit 0eda0807f9b0ba81035cf4bd630e50a27ba2678b)

diff --git a/sc/source/ui/undo/undoblk3.cxx b/sc/source/ui/undo/undoblk3.cxx
index c1dbd34..2d64e9e 100644
--- a/sc/source/ui/undo/undoblk3.cxx
+++ b/sc/source/ui/undo/undoblk3.cxx
@@ -699,7 +699,13 @@ void ScUndoMerge::DoChange( bool bUndo ) const
         // undo -> copy back deleted contents
         if (bUndo && mpUndoDoc)
         {
-            rDoc.DeleteAreaTab( aRange, InsertDeleteFlags::CONTENTS|InsertDeleteFlags::NOCAPTIONS );
+            // If there are note captions to be deleted during Undo they were
+            // kept or moved during the merge and copied to the Undo document
+            // without cloning the caption. Forget the target area's caption
+            // pointer that is identical to the one in the Undo document
+            // instead of deleting it.
+            rDoc.DeleteAreaTab( aRange,
+                    InsertDeleteFlags::CONTENTS | InsertDeleteFlags::NOCAPTIONS | InsertDeleteFlags::FORGETCAPTIONS );
             mpUndoDoc->CopyToDocument( aRange, InsertDeleteFlags::ALL|InsertDeleteFlags::NOCAPTIONS, false, &rDoc );
         }
 
commit c3a8d5b87894dee5d5227608b9a66cecce9d5956
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date:   Tue Feb 21 12:48:33 2017 +0900

    tdf#106116 "Previous Marker" changes selection only when needed
    
    This fixes a hang caused by repeated Shift+F4. Although it seems
    a regression from 2af1f5691e8d64afd5246d245d7876b5a2cd5cd8,
    the original code of SmEditWindow::SelPrevMark() had been doomed
    due to conditional loop depending on obscure signed/unsigned
    conversion.
    
    Change-Id: I61f630eec44b285dc1f1c27097acde4b48ed2991
    Reviewed-on: https://gerrit.libreoffice.org/34503
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Takeshi Abe <tabe at fixedpoint.jp>
    (cherry picked from commit 3efdd925e0ae1c080fbef3f1f79865eb6e172c68)
    Reviewed-on: https://gerrit.libreoffice.org/34529
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>
    (cherry picked from commit 9168ae9b0463c27a6d5e4b53a9afbc29ba7e07e9)

diff --git a/starmath/qa/cppunit/test_starmath.cxx b/starmath/qa/cppunit/test_starmath.cxx
index 27e64d7..03d4728 100644
--- a/starmath/qa/cppunit/test_starmath.cxx
+++ b/starmath/qa/cppunit/test_starmath.cxx
@@ -131,6 +131,14 @@ void Test::editMarker()
         m_pEditWindow->Delete();
         m_pEditWindow->InsertText("b");
 
+        // tdf#106116: should be safe i.e. do nothing
+        m_pEditWindow->SelPrevMark();
+        auto aSelection = m_pEditWindow->GetSelection();
+        CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aSelection.nStartPara);
+        CPPUNIT_ASSERT_EQUAL(sal_Int32(9), aSelection.nStartPos);
+        CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aSelection.nEndPara);
+        CPPUNIT_ASSERT_EQUAL(sal_Int32(9), aSelection.nEndPos);
+
         m_pEditWindow->Flush();
         OUString sFinalText = m_pEditWindow->GetText();
         CPPUNIT_ASSERT_MESSAGE("Should be a under b under c", sFinalText == sTargetText);
diff --git a/starmath/source/edit.cxx b/starmath/source/edit.cxx
index 62deaa8..9b3faa8 100644
--- a/starmath/source/edit.cxx
+++ b/starmath/source/edit.cxx
@@ -869,36 +869,20 @@ void SmEditWindow::SelPrevMark()
     if (pEditEngine  &&  pEditView)
     {
         ESelection eSelection = pEditView->GetSelection();
-        sal_Int32 nPos = -1;
+        sal_Int32 nPara = eSelection.nStartPara;
         sal_Int32 nMax = eSelection.nStartPos;
-        OUString aText(pEditEngine->GetText(eSelection.nStartPara));
-        OUString aMark("<?>");
-        sal_Int32 nCounts = pEditEngine->GetParagraphCount();
-
-        do
-        {
-            sal_Int32 nMarkIndex = aText.indexOf(aMark);
-            while ((nMarkIndex < nMax) && (nMarkIndex != -1))
-            {
-                nPos = nMarkIndex;
-                nMarkIndex = aText.indexOf(aMark, nMarkIndex + 1);
-            }
-
-            if (nPos == -1)
-            {
-                eSelection.nStartPara--;
-                aText = pEditEngine->GetText(eSelection.nStartPara);
-                nMax = aText.getLength();
-            }
-        }
-        while ((eSelection.nStartPara < nCounts) &&
-            (nPos == -1));
+        OUString aText(pEditEngine->GetText(nPara));
+        const OUString aMark("<?>");
+        sal_Int32 nPos;
 
-        if (nPos != -1)
+        while ( (nPos = aText.lastIndexOf(aMark, nMax)) < 0 )
         {
-            pEditView->SetSelection(ESelection(
-                eSelection.nStartPara, nPos, eSelection.nStartPara, nPos + 3));
+            if (--nPara < 0)
+                return;
+            aText = pEditEngine->GetText(nPara);
+            nMax = aText.getLength();
         }
+        pEditView->SetSelection(ESelection(nPara, nPos, nPara, nPos + 3));
     }
 }
 
commit 4a9d48a3af0d703bad27fd40e7db26f4e843d7d5
Author: Justin Luth <justin_luth at sil.org>
Date:   Wed Jan 18 15:52:33 2017 +0300

    tdf#77111 odt import: treat PAGEDESC_PAGENUMOFFSET==0 as auto
    
    Ever since 2010 commit 7edaf190 zeroes have been saved as XML_AUTO.
    Ever since 2014 commit c2ccd20c, a numoffset of zero is no longer
    considered to be auto (for MS compatibility) but is still treated
    as auto during xml export. Thus, any older documents that had been
    saved with a zero should still xml import as auto instead of as 0.
    
    Change-Id: I1a0df32a8e2f1b30b2bedbf4c9bb07ebec239637
    Reviewed-on: https://gerrit.libreoffice.org/33267
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Justin Luth <justin_luth at sil.org>
    Reviewed-by: Michael Stahl <mstahl at redhat.com>
    (cherry picked from commit e36f0860f00af139a8fa94d36302f7b0c56383fe)
    Reviewed-on: https://gerrit.libreoffice.org/34695
    (cherry picked from commit 1f87318abb50e164aa4125747493c5ee02e8687c)

diff --git a/sw/source/filter/xml/xmlimpit.cxx b/sw/source/filter/xml/xmlimpit.cxx
index afc8004..05e609d 100644
--- a/sw/source/filter/xml/xmlimpit.cxx
+++ b/sw/source/filter/xml/xmlimpit.cxx
@@ -785,7 +785,7 @@ bool SvXMLImportItemMapper::PutXMLValue(
                 sal_Int32 nVal;
                 bOk = ::sax::Converter::convertNumber(
                         nVal, rValue, 0, USHRT_MAX);
-                if( bOk )
+                if( bOk && nVal > 0 )
                     rPageDesc.SetNumOffset( (sal_uInt16)nVal );
             }
         }
commit 4caa4877daeb98e90f993ac5b4778bdd6f45e6dc
Author: Christian Lohmaier <lohmaier+LibreOffice at googlemail.com>
Date:   Mon Feb 27 13:11:19 2017 +0100

    tdf#106082 fix missing statusbar translations (l10ntool is picky about syntax)
    
    having the ; on a separate line made all strings following that have the
    string-ID of the next unit, altering the msgctx and thus translations
    wouldn't apply anymore
    
    Change-Id: Ia1e3c36a9d2a57725c90e6c3f33de99bed85ec41
    (cherry picked from commit 9eaa17e6bb35a2cb71ec59c96ea4a39466789667)
    (cherry picked from commit 558c3d3c83c85c4392eae491165143736477216b)

diff --git a/svx/source/stbctrls/stbctrls.src b/svx/source/stbctrls/stbctrls.src
index 2be3e63..6ffb182 100644
--- a/svx/source/stbctrls/stbctrls.src
+++ b/svx/source/stbctrls/stbctrls.src
@@ -119,8 +119,7 @@ String RID_SVXSTR_DOC_LOAD
 String RID_SVXSTR_FIT_SLIDE
 {
     Text [ en-US ] = "Fit slide to current window.";
-}
-;
+};
 
 String RID_SVXSTR_WARN_MISSING_SMARTART
 {
commit 6208117ff1f5c38aa89949bc851a63a385577e53
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Feb 24 15:16:27 2017 +0000

    hwpfilter needs a new filter for each document
    
    setUp is called just once at the start of the sequence of loads
    so we're reusing the previous import state which isn't what this
    filter expects
    
    This reverts commit 0af436083e12516eb9251d4cc6f594f80ed06d3d.
    
    Change-Id: Iae355ed6099086fd3cc1c79203786017507d4ed4
    (cherry picked from commit 3cc3dc176e00062d8395d9f3d83b49ab24542a61)
    Reviewed-on: https://gerrit.libreoffice.org/34620
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Michael Stahl <mstahl at redhat.com>
    (cherry picked from commit ce9aecee57f8b852cbae8e4e24ee7fd2efabf44b)

diff --git a/hwpfilter/qa/cppunit/data/fail/skipblock-1.hwp b/hwpfilter/qa/cppunit/data/fail/skipblock-1.hwp
new file mode 100644
index 0000000..8fd8e7a
Binary files /dev/null and b/hwpfilter/qa/cppunit/data/fail/skipblock-1.hwp differ
diff --git a/hwpfilter/qa/cppunit/test_hwpfilter.cxx b/hwpfilter/qa/cppunit/test_hwpfilter.cxx
index 6fde479..41a6bfd 100644
--- a/hwpfilter/qa/cppunit/test_hwpfilter.cxx
+++ b/hwpfilter/qa/cppunit/test_hwpfilter.cxx
@@ -24,7 +24,6 @@ namespace
         , public test::BootstrapFixture
     {
     public:
-        virtual void setUp() override;
 
         virtual bool load(const OUString &,
             const OUString &rURL, const OUString &,
@@ -35,26 +34,19 @@ namespace
         CPPUNIT_TEST_SUITE(HwpFilterTest);
         CPPUNIT_TEST(test);
         CPPUNIT_TEST_SUITE_END();
-    private:
-        uno::Reference<document::XFilter> m_xFilter;
     };
 
-    void HwpFilterTest::setUp()
-    {
-        test::BootstrapFixture::setUp();
-
-        m_xFilter.set(m_xSFactory->createInstance("com.sun.comp.hwpimport.HwpImportFilter"),
-                      uno::UNO_QUERY_THROW);
-    }
-
     bool HwpFilterTest::load(const OUString &,
         const OUString &rURL, const OUString &,
         SfxFilterFlags, SotClipboardFormatId, unsigned int)
     {
+        uno::Reference<document::XFilter> xFilter(m_xSFactory->createInstance("com.sun.comp.hwpimport.HwpImportFilter"),
+                                                  uno::UNO_QUERY_THROW);
+
         uno::Sequence< beans::PropertyValue > aDescriptor(1);
         aDescriptor[0].Name = "URL";
         aDescriptor[0].Value <<= rURL;
-        return m_xFilter->filter(aDescriptor);
+        return xFilter->filter(aDescriptor);
     }
 
     void HwpFilterTest::test()


More information about the Libreoffice-commits mailing list