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

Miklos Vajna vmiklos at collabora.co.uk
Mon Aug 18 02:59:05 PDT 2014


 sw/qa/extras/ooxmlexport/ooxmlexport.cxx     |    6 +++
 sw/source/filter/ww8/docxattributeoutput.cxx |   53 +++++++++++++++++++++++++--
 sw/source/filter/ww8/ww8par.hxx              |    2 -
 sw/source/filter/ww8/ww8par6.cxx             |    6 +--
 4 files changed, 60 insertions(+), 7 deletions(-)

New commits:
commit be515af4d9e86c8bc13a47413676bda80cee6a3e
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Aug 18 11:20:20 2014 +0200

    DOCX filter: improve qFormat export handling
    
    The old rule was: write qFormat for everything that's not a custom
    style.
    
    The new rule: write qFormat for everything that's a custom style + have
    a whitelist of non-custom, but qFormat styles.
    
    This matches better what Word does (whitelist is from the latent style
    section of an empty document, created by Word).
    
    Change-Id: Ie7a0802e886c41b8d26ca9aa154913aa2f3ff87a

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 2d47c8c..593358e 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -1191,6 +1191,12 @@ DECLARE_OOXMLEXPORT_TEST(testCharacterBorder, "charborder.odt")
         CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadow.Location);
         CPPUNIT_ASSERT_EQUAL(sal_Int16(318), aShadow.ShadowWidth);
     }
+
+    if (xmlDocPtr pXmlStyles = parseExport("word/styles.xml"))
+    {
+        // Make sure we write qFormat for custom style names.
+        assertXPath(pXmlStyles, "//w:style[@w:styleId='Heading']/w:qFormat", 1);
+    }
 }
 
 DECLARE_OOXMLEXPORT_TEST(testStyleInheritance, "style-inheritance.docx")
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index f8f2d00..4ead526 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -5054,6 +5054,55 @@ oox::drawingml::DrawingML& DocxAttributeOutput::GetDrawingML()
     return m_rDrawingML;
 }
 
+/// Functor to do case-insensitive ordering of OUString instances.
+struct OUStringIgnoreCase
+{
+    bool operator() (const OUString& lhs, const OUString& rhs) const
+    {
+        return lhs.compareToIgnoreAsciiCase(rhs) < 0;
+    }
+};
+
+/// Guesses if a style created in Writer (no grab-bag) should be qFormat or not.
+static bool lcl_guessQFormat(const OUString& rName, sal_uInt16 nWwId)
+{
+    // If the style has no dedicated STI number, then it's probably a custom style -> qFormat.
+    if (nWwId == ww::stiUser)
+        return true;
+
+    static std::set<OUString, OUStringIgnoreCase> aWhitelist;
+    if (aWhitelist.empty())
+    {
+        aWhitelist.insert("Normal");
+        aWhitelist.insert("Heading 1");
+        aWhitelist.insert("Heading 2");
+        aWhitelist.insert("Heading 3");
+        aWhitelist.insert("Heading 4");
+        aWhitelist.insert("Heading 5");
+        aWhitelist.insert("Heading 6");
+        aWhitelist.insert("Heading 7");
+        aWhitelist.insert("Heading 8");
+        aWhitelist.insert("Heading 9");
+        aWhitelist.insert("Caption");
+        aWhitelist.insert("Title");
+        aWhitelist.insert("Subtitle");
+        aWhitelist.insert("Strong");
+        aWhitelist.insert("Emphasis");
+        aWhitelist.insert("No Spacing");
+        aWhitelist.insert("List Paragraph");
+        aWhitelist.insert("Quote");
+        aWhitelist.insert("Intense Quote");
+        aWhitelist.insert("Subtle Emphasis,");
+        aWhitelist.insert("Intense Emphasis");
+        aWhitelist.insert("Subtle Reference");
+        aWhitelist.insert("Intense Reference");
+        aWhitelist.insert("Book Title");
+        aWhitelist.insert("TOC Heading");
+    }
+    // Not custom style? Then we have a list of standard styles which should be qFormat.
+    return aWhitelist.find(rName) != aWhitelist.end();
+}
+
 void DocxAttributeOutput::StartStyle( const OUString& rName, StyleType eType,
         sal_uInt16 nBase, sal_uInt16 nNext, sal_uInt16 nWwId, sal_uInt16 nId, bool bAutoUpdate )
 {
@@ -5148,9 +5197,7 @@ void DocxAttributeOutput::StartStyle( const OUString& rName, StyleType eType,
     if (bUnhideWhenUsed)
         m_pSerializer->singleElementNS(XML_w, XML_unhideWhenUsed, FSEND);
 
-    // If the style has a dedicated STI number, then chances are high that Word
-    // will have qFormat enabled for it, so let's do the same.
-    if (bQFormat || nWwId != ww::stiUser)
+    if (bQFormat || lcl_guessQFormat(rName, nWwId))
         m_pSerializer->singleElementNS(XML_w, XML_qFormat, FSEND);
     if (bLocked)
         m_pSerializer->singleElementNS(XML_w, XML_locked, FSEND);
commit f1095b41c6506b153199a72b36fc720804ea9ebc
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Aug 18 10:37:25 2014 +0200

    Fix missing prefix
    
    Change-Id: I0a9df00f90b63059e6446278d7a98d1cd902de4b

diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx
index 0f50969..d44e508 100644
--- a/sw/source/filter/ww8/ww8par.hxx
+++ b/sw/source/filter/ww8/ww8par.hxx
@@ -1383,7 +1383,7 @@ private:
     // a document position recorded the after-position of TOC section, managed by Read_F_TOX() and End_Field()
     SwPaM* mpPosAfterTOC;
 
-    boost::scoped_ptr< SwPosition > lastAnchorPos;
+    boost::scoped_ptr< SwPosition > mpLastAnchorPos;
 
     bool mbCareFirstParaEndInToc;
     bool mbCareLastParaEndInToc;
diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index fb35194..69f8582 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -795,10 +795,10 @@ void wwSectionManager::CreateSep(const long nTxtPos, bool /*bMustHaveBreak*/)
     if (!pSep)
         return;
 
-    if (!maSegments.empty() && mrReader.lastAnchorPos.get() && *mrReader.lastAnchorPos == *mrReader.pPaM->GetPoint())
+    if (!maSegments.empty() && mrReader.mpLastAnchorPos.get() && *mrReader.mpLastAnchorPos == *mrReader.pPaM->GetPoint())
     {
         bool insert = true;
-        SwPaM pam( *mrReader.lastAnchorPos );
+        SwPaM pam( *mrReader.mpLastAnchorPos );
         if( pam.Move(fnMoveBackward, fnGoNode))
             if( SwTxtNode* txtNode = pam.GetPoint()->nNode.GetNode().GetTxtNode())
                 if( txtNode->Len() == 0 )
@@ -1815,7 +1815,7 @@ WW8SwFlyPara::WW8SwFlyPara( SwPaM& rPaM,
     //#i53725# - absolute positioned objects have to be
     // anchored at-paragraph to assure its correct anchor position.
     eAnchor = FLY_AT_PARA;
-    rIo.lastAnchorPos.reset( new SwPosition(*rPaM.GetPoint()));
+    rIo.mpLastAnchorPos.reset( new SwPosition(*rPaM.GetPoint()));
 
     switch (nYBind)
     {


More information about the Libreoffice-commits mailing list