sw/qa/extras/uiwriter/uiwriter.cxx                |   10 +++++++++-
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |    1 +
 writerfilter/source/dmapper/DomainMapper_Impl.hxx |    4 ++++
 writerfilter/source/dmapper/PropertyMap.cxx       |   11 +++++++----
 4 files changed, 21 insertions(+), 5 deletions(-)

New commits:
commit f6012e25cc5de8daf9d67e99c3edc48a3e4fbe91
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Wed Mar 13 17:51:07 2019 +0100
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Thu Mar 14 09:59:27 2019 +0100

    DOCX import: fix unexpected page break on autotext insert at end of doc
    
    The problem was that the page style was set on the first paragraph,
    which means a page break on the UI. So if you used a multi-paragraph
    autotext twice (insert autotext, press enter, insert autotext again)
    then you ended up with 2 pages instead of just 1.
    
    Fix the problem by tracking when we are in autotext import mode, and
    similar to pasting, don't set the page style in autotext import mode.
    
    (cherry picked from commit adcf656bb56e09fbb638a44b0cccc96f8cfced7f)
    
    Conflicts:
            writerfilter/source/dmapper/DomainMapper_Impl.hxx
    
    Change-Id: I4fc551b3c1b999687eb80242e261f186fd1b6f13
    Reviewed-on: https://gerrit.libreoffice.org/69254
    Reviewed-by: Andras Timar <andras.ti...@collabora.com>
    Tested-by: Andras Timar <andras.ti...@collabora.com>

diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx 
b/sw/qa/extras/uiwriter/uiwriter.cxx
index 4ea7de52b6a7..c69c03dfa15b 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -956,7 +956,15 @@ void SwUiWriterTest::testDOCXAutoTextMultiple()
 
     // first line
     SwNode& rNode = aStart.GetNode();
-    CPPUNIT_ASSERT_EQUAL(OUString("Another "), rNode.GetTextNode()->GetText());
+    CPPUNIT_ASSERT(rNode.IsTextNode());
+    SwTextNode& rTextNode = *rNode.GetTextNode();
+    CPPUNIT_ASSERT_EQUAL(OUString("Another "), rTextNode.GetText());
+
+    // Make sure that autotext does not set a custom page style, leading to an 
unexpected page break
+    // on insertion.
+    // Without the accompanying fix in place, this test would have failed: the 
text node had an
+    // attribute set containing a page style item.
+    CPPUNIT_ASSERT(!rTextNode.HasSwAttrSet() || 
!rTextNode.GetSwAttrSet().HasItem(RES_PAGEDESC));
 
     // last line
     SwNodeIndex aLast(*aDocEnd.GetNode().EndOfSectionNode(), -1);
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 1ea53b810609..f17a52da1697 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -233,6 +233,7 @@ DomainMapper_Impl::DomainMapper_Impl(
         m_aSmartTagHandler(m_xComponentContext, m_xTextDocument),
         
m_xInsertTextRange(rMediaDesc.getUnpackedValueOrDefault("TextInsertModeRange", 
uno::Reference<text::XTextRange>())),
         m_bIsNewDoc(!rMediaDesc.getUnpackedValueOrDefault("InsertMode", 
false)),
+        
m_bIsReadGlossaries(rMediaDesc.getUnpackedValueOrDefault("ReadGlossaries", 
false)),
         m_bInTableStyleRunProps(false),
         m_nTableDepth(0),
         m_nTableCellDepth(0),
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index 29b0cc22086f..3e08c252d6f0 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -541,6 +541,7 @@ public:
     css::uno::Reference<css::text::XTextRange> m_xInsertTextRange;
 private:
     bool m_bIsNewDoc;
+    bool const m_bIsReadGlossaries;
 public:
     DomainMapper_Impl(
             DomainMapper& rDMapper,
@@ -897,6 +898,9 @@ public:
     /// If we're importing into a new document, or just pasting to an existing 
one.
     bool IsNewDoc() { return m_bIsNewDoc;}
 
+    /// If we're importing autotext.
+    bool IsReadGlossaries() { return m_bIsReadGlossaries;}
+
     /// If we're inside <w:rPr>, inside <w:style w:type="table">
     bool m_bInTableStyleRunProps;
 
diff --git a/writerfilter/source/dmapper/PropertyMap.cxx 
b/writerfilter/source/dmapper/PropertyMap.cxx
index 4d3af4df742e..4117f029a8c1 100644
--- a/writerfilter/source/dmapper/PropertyMap.cxx
+++ b/writerfilter/source/dmapper/PropertyMap.cxx
@@ -1478,10 +1478,13 @@ void SectionPropertyMap::CloseSectionGroup( 
DomainMapper_Impl& rDM_Impl )
 
             if ( xRangeProperties.is() && rDM_Impl.IsNewDoc() )
             {
-                xRangeProperties->setPropertyValue(
-                    getPropertyName( PROP_PAGE_DESC_NAME ),
-                    uno::makeAny( m_bTitlePage ? m_sFirstPageStyleName
-                        : m_sFollowPageStyleName ) );
+                // Avoid setting page style in case of autotext: so inserting 
the autotext at the
+                // end of the document does not introduce an unwanted page 
break.
+                if (!rDM_Impl.IsReadGlossaries())
+                    xRangeProperties->setPropertyValue(
+                        getPropertyName( PROP_PAGE_DESC_NAME ),
+                        uno::makeAny( m_bTitlePage ? m_sFirstPageStyleName
+                            : m_sFollowPageStyleName ) );
 
                 if (0 <= m_nPageNumber)
                 {
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to