[Libreoffice-commits] .: 2 commits - sw/qa writerfilter/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Oct 1 06:14:14 PDT 2012


 sw/qa/extras/ooxmlimport/data/n782345.docx    |binary
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx      |   13 +++++++++++++
 writerfilter/source/dmapper/DomainMapper.cxx  |   10 ++++++++++
 writerfilter/source/dmapper/SettingsTable.cxx |   10 ++++++++++
 writerfilter/source/dmapper/SettingsTable.hxx |    1 +
 5 files changed, 34 insertions(+)

New commits:
commit 738d5dab435084737aab2e0519fd817f62f1e83b
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Mon Oct 1 15:06:25 2012 +0200

    n#782345 testcase
    
    Change-Id: Id5204572ab9fddf3f15b5fd1b96d8f25e7166878

diff --git a/sw/qa/extras/ooxmlimport/data/n782345.docx b/sw/qa/extras/ooxmlimport/data/n782345.docx
new file mode 100644
index 0000000..f25709f
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/n782345.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index a83a398..c545a89 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -47,6 +47,7 @@
 #include <com/sun/star/text/XTextFrame.hpp>
 #include <com/sun/star/text/XTextFramesSupplier.hpp>
 #include <com/sun/star/text/XTextViewCursorSupplier.hpp>
+#include <com/sun/star/style/BreakType.hpp>
 #include <com/sun/star/style/ParagraphAdjust.hpp>
 #include <com/sun/star/table/ShadowFormat.hpp>
 
@@ -97,6 +98,7 @@ public:
     void testN780843();
     void testShadow();
     void testN782061();
+    void testN782345();
 
     CPPUNIT_TEST_SUITE(Test);
 #if !defined(MACOSX) && !defined(WNT)
@@ -140,6 +142,7 @@ public:
     CPPUNIT_TEST(testN780843);
     CPPUNIT_TEST(testShadow);
     CPPUNIT_TEST(testN782061);
+    CPPUNIT_TEST(testN782345);
 #endif
     CPPUNIT_TEST_SUITE_END();
 
@@ -993,6 +996,16 @@ void Test::testN782061()
     CPPUNIT_ASSERT_EQUAL(sal_Int32(-9), getProperty<sal_Int32>(getRun(getParagraph(1), 2), "CharEscapement"));
 }
 
+void Test::testN782345()
+{
+    /*
+     * The problem was that the page break was inserted before the 3rd para, instead of before the 2nd para.
+     */
+    load("n782345.docx");
+
+    CPPUNIT_ASSERT_EQUAL(style::BreakType_PAGE_BEFORE, getProperty<style::BreakType>(getParagraph(2), "BreakType"));
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
commit 40d93d978d4f8fa709bdeb061b106122789d8e32
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Mon Oct 1 13:42:02 2012 +0200

    n#782345 import DOCX w:splitPgBreakAndParaMark compat option
    
    This fixes docx import of page breaks in empty paragraphs, when the
    compat option in question is set.
    
    Even empty paragraphs have an "end of paragraph" character in dmapper:
    import page breaks there, instead of delaying the import till the
    all-catcher importer at the start of the next paragraph.
    
    Change-Id: Ie5c37042b3c445e0669771d15c8eb46380192db3

diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 8b51034..64618bf 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -3542,6 +3542,16 @@ void DomainMapper::lcl_utext(const sal_uInt8 * data_, size_t len)
 
         if(len == 1 && (sText[0] == 0x0d || sText[0] == 0x07))
         {
+            PropertyMapPtr pContext = m_pImpl->GetTopContextOfType(CONTEXT_PARAGRAPH);
+            if (pContext && m_pImpl->GetSettingsTable()->GetSplitPgBreakAndParaMark())
+            {
+                if (m_pImpl->isBreakDeferred(PAGE_BREAK))
+                    pContext->Insert(PROP_BREAK_TYPE, true, uno::makeAny( com::sun::star::style::BreakType_PAGE_BEFORE));
+                else if (m_pImpl->isBreakDeferred(COLUMN_BREAK))
+                    pContext->Insert(PROP_BREAK_TYPE, true, uno::makeAny( com::sun::star::style::BreakType_COLUMN_BEFORE));
+                m_pImpl->clearDeferredBreaks();
+            }
+
             bool bSingleParagraph = m_pImpl->GetIsFirstParagraphInSection() && m_pImpl->GetIsLastParagraphInSection();
             // If the paragraph contains only the section properties and it has
             // no runs, we should not create a paragraph for it in Writer, unless that would remove the whole section.
diff --git a/writerfilter/source/dmapper/SettingsTable.cxx b/writerfilter/source/dmapper/SettingsTable.cxx
index 18bef92..b01047a 100644
--- a/writerfilter/source/dmapper/SettingsTable.cxx
+++ b/writerfilter/source/dmapper/SettingsTable.cxx
@@ -72,6 +72,7 @@ struct SettingsTable_Impl
     bool                embedTrueTypeFonts;
     bool                embedSystemFonts;
     bool                m_bDoNotUseHTMLParagraphAutoSpacing;
+    bool                m_bSplitPgBreakAndParaMark;
 
     SettingsTable_Impl( DomainMapper& rDMapper, const uno::Reference< lang::XMultiServiceFactory > xTextFactory ) :
     m_rDMapper( rDMapper )
@@ -95,6 +96,7 @@ struct SettingsTable_Impl
     , embedTrueTypeFonts(false)
     , embedSystemFonts(false)
     , m_bDoNotUseHTMLParagraphAutoSpacing(false)
+    , m_bSplitPgBreakAndParaMark(false)
     {}
 
 };
@@ -214,6 +216,9 @@ void SettingsTable::lcl_sprm(Sprm& rSprm)
     case NS_ooxml::LN_CT_Compat_doNotUseHTMLParagraphAutoSpacing:
         m_pImpl->m_bDoNotUseHTMLParagraphAutoSpacing = nIntValue;
         break;
+    case NS_ooxml::LN_CT_Compat_splitPgBreakAndParaMark:
+        m_pImpl->m_bSplitPgBreakAndParaMark = nIntValue;
+        break;
     default:
     {
 #ifdef DEBUG_DMAPPER_SETTINGS_TABLE
@@ -271,6 +276,11 @@ bool SettingsTable::GetDoNotUseHTMLParagraphAutoSpacing() const
     return m_pImpl->m_bDoNotUseHTMLParagraphAutoSpacing;
 }
 
+bool SettingsTable::GetSplitPgBreakAndParaMark() const
+{
+    return m_pImpl->m_bSplitPgBreakAndParaMark;
+}
+
 void SettingsTable::ApplyProperties( uno::Reference< text::XTextDocument > xDoc )
 {
     uno::Reference< beans::XPropertySet> xDocProps( xDoc, uno::UNO_QUERY );
diff --git a/writerfilter/source/dmapper/SettingsTable.hxx b/writerfilter/source/dmapper/SettingsTable.hxx
index 6a250a7..14b7552 100644
--- a/writerfilter/source/dmapper/SettingsTable.hxx
+++ b/writerfilter/source/dmapper/SettingsTable.hxx
@@ -69,6 +69,7 @@ class WRITERFILTER_DLLPRIVATE SettingsTable : public LoggedProperties, public Lo
     bool GetEmbedSystemFonts() const;
 
     bool GetDoNotUseHTMLParagraphAutoSpacing() const;
+    bool GetSplitPgBreakAndParaMark() const;
 
     void ApplyProperties( uno::Reference< text::XTextDocument > xDoc );
 


More information about the Libreoffice-commits mailing list