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

Miklos Vajna vmiklos at collabora.co.uk
Thu Nov 7 14:22:15 CET 2013


 sw/qa/extras/ooxmlexport/ooxmlexport.cxx        |    4 +
 sw/source/filter/ww8/docxattributeoutput.cxx    |   86 +++++++++++++-----------
 writerfilter/source/dmapper/StyleSheetTable.cxx |   22 +++---
 writerfilter/source/dmapper/StyleSheetTable.hxx |    1 
 4 files changed, 68 insertions(+), 45 deletions(-)

New commits:
commit 00ab87f80f6f720b34f166be2069e82147c844a9
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Nov 7 14:19:26 2013 +0100

    DOCX export: handle semiHidden para style
    
    Change-Id: Icde4d5af2398a241c628f16225f1d427a2f27cfc

diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 15bcff1..4ca41e4 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -3593,7 +3593,7 @@ oox::drawingml::DrawingML& DocxAttributeOutput::GetDrawingML()
 void DocxAttributeOutput::StartStyle( const OUString& rName, StyleType eType,
         sal_uInt16 nBase, sal_uInt16 nNext, sal_uInt16 /*nWwId*/, sal_uInt16 nId, bool bAutoUpdate )
 {
-    bool bQFormat = false, bUnhideWhenUsed = false, bLocked = false, bDefault = false, bCustomStyle = false;
+    bool bQFormat = false, bUnhideWhenUsed = false, bSemiHidden = false, bLocked = false, bDefault = false, bCustomStyle = false;
     OUString aLink, aRsid, aUiPriority;
     FastAttributeList* pStyleAttributeList = m_pSerializer->createAttrList();
     if (eType == STYLE_TYPE_PARA)
@@ -3615,6 +3615,8 @@ void DocxAttributeOutput::StartStyle( const OUString& rName, StyleType eType,
                 aRsid = rGrabBag[i].Value.get<OUString>();
             else if (rGrabBag[i].Name == "unhideWhenUsed")
                 bUnhideWhenUsed = true;
+            else if (rGrabBag[i].Name == "semiHidden")
+                bSemiHidden = true;
             else if (rGrabBag[i].Name == "locked")
                 bLocked = true;
             else if (rGrabBag[i].Name == "default")
@@ -3653,6 +3655,8 @@ void DocxAttributeOutput::StartStyle( const OUString& rName, StyleType eType,
                 FSEND);
     if (bQFormat)
         m_pSerializer->singleElementNS(XML_w, XML_qFormat, FSEND);
+    if (bSemiHidden)
+        m_pSerializer->singleElementNS(XML_w, XML_semiHidden, FSEND);
     if (bUnhideWhenUsed)
         m_pSerializer->singleElementNS(XML_w, XML_unhideWhenUsed, FSEND);
     if (!aLink.isEmpty())
commit b4577903f572ebb21641b4444c630c76ef5accf4
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Nov 7 13:16:30 2013 +0100

    DOCX import: handle NS_ooxml::LN_CT_Style_autoRedefine
    
    Change-Id: I8c2c0ca8d060e2c460d0f36aed3050ed335fb3a3

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 432aae1..f96095d 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -1310,6 +1310,7 @@ DECLARE_OOXML_TEST(testStyleInheritance, "style-inheritance.docx")
     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Heading1']/w:locked", 1);
 
     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Heading11']", "customStyle", "1");
+    assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Heading11']/w:autoRedefine", 1);
 }
 
 DECLARE_OOXML_TEST(testCalendar1, "calendar1.docx")
diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx b/writerfilter/source/dmapper/StyleSheetTable.cxx
index fcb04fb..b34273a 100644
--- a/writerfilter/source/dmapper/StyleSheetTable.cxx
+++ b/writerfilter/source/dmapper/StyleSheetTable.cxx
@@ -64,6 +64,7 @@ StyleSheetEntry::StyleSheetEntry() :
         ,sBaseStyleIdentifier()
         ,sNextStyleIdentifier()
         ,pProperties(new StyleSheetPropertyMap)
+        ,bAutoRedefine(false)
 {
 }
 
@@ -586,12 +587,14 @@ void StyleSheetTable::lcl_sprm(Sprm & rSprm)
             m_pImpl->m_pCurrentEntry->sNextStyleIdentifier = sStringValue;
             break;
         case NS_ooxml::LN_CT_Style_aliases:
-        case NS_ooxml::LN_CT_Style_autoRedefine:
         case NS_ooxml::LN_CT_Style_hidden:
         case NS_ooxml::LN_CT_Style_personal:
         case NS_ooxml::LN_CT_Style_personalCompose:
         case NS_ooxml::LN_CT_Style_personalReply:
         break;
+        case NS_ooxml::LN_CT_Style_autoRedefine:
+        m_pImpl->m_pCurrentEntry->bAutoRedefine = nIntValue;
+        break;
         case NS_ooxml::LN_CT_Style_tcPr:
         {
             writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
@@ -1198,11 +1201,14 @@ void StyleSheetTable::ApplyStyleSheets( FontTablePtr rFontTable )
                     }
 
                     beans::PropertyValues aGrabBag = pEntry->GetInteropGrabBagSeq();
+                    uno::Reference<beans::XPropertySet> xPropertySet(xStyle, uno::UNO_QUERY);
                     if (aGrabBag.hasElements())
                     {
-                        uno::Reference<beans::XPropertySet> xPropertySet(xStyle, uno::UNO_QUERY);
                         xPropertySet->setPropertyValue("StyleInteropGrabBag", uno::makeAny(aGrabBag));
                     }
+
+                    if (pEntry->bAutoRedefine)
+                        xPropertySet->setPropertyValue("IsAutoUpdate", uno::makeAny(sal_True));
                 }
                 else if(pEntry->nStyleTypeCode == STYLE_TYPE_TABLE)
                 {
diff --git a/writerfilter/source/dmapper/StyleSheetTable.hxx b/writerfilter/source/dmapper/StyleSheetTable.hxx
index 25c3065..d74eadf 100644
--- a/writerfilter/source/dmapper/StyleSheetTable.hxx
+++ b/writerfilter/source/dmapper/StyleSheetTable.hxx
@@ -67,6 +67,7 @@ public:
     OUString sConvertedStyleName;
     std::vector<beans::PropertyValue> aLatentStyles; ///< Attributes of latentStyles
     std::vector<beans::PropertyValue> aLsdExceptions; ///< List of lsdException attribute lists
+    bool           bAutoRedefine; ///< Writer calls this auto-update.
 
     void AppendInteropGrabBag(beans::PropertyValue aValue);
     beans::PropertyValue GetInteropGrabBag(); ///< Used for table styles, has a name.
commit 14641f650e548ad3341809a22deb46f5ec93fa24
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Nov 7 12:00:58 2013 +0100

    DOCX filter: roundtrip paragraph customStyle
    
    Change-Id: I7fec154ff3b39845e91301b4fb607381e80e13f7

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 0714c16..432aae1 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -1308,6 +1308,8 @@ DECLARE_OOXML_TEST(testStyleInheritance, "style-inheritance.docx")
 
     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Heading1']/w:link", "val", "Heading1Char");
     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Heading1']/w:locked", 1);
+
+    assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Heading11']", "customStyle", "1");
 }
 
 DECLARE_OOXML_TEST(testCalendar1, "calendar1.docx")
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 8721dbf..15bcff1 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -3593,7 +3593,7 @@ oox::drawingml::DrawingML& DocxAttributeOutput::GetDrawingML()
 void DocxAttributeOutput::StartStyle( const OUString& rName, StyleType eType,
         sal_uInt16 nBase, sal_uInt16 nNext, sal_uInt16 /*nWwId*/, sal_uInt16 nId, bool bAutoUpdate )
 {
-    bool bQFormat = false, bUnhideWhenUsed = false, bLocked = false, bDefault = false;
+    bool bQFormat = false, bUnhideWhenUsed = false, bLocked = false, bDefault = false, bCustomStyle = false;
     OUString aLink, aRsid, aUiPriority;
     FastAttributeList* pStyleAttributeList = m_pSerializer->createAttrList();
     if (eType == STYLE_TYPE_PARA)
@@ -3619,6 +3619,8 @@ void DocxAttributeOutput::StartStyle( const OUString& rName, StyleType eType,
                 bLocked = true;
             else if (rGrabBag[i].Name == "default")
                 bDefault = rGrabBag[i].Value.get<sal_Bool>();
+            else if (rGrabBag[i].Name == "customStyle")
+                bCustomStyle = rGrabBag[i].Value.get<sal_Bool>();
             else
                 SAL_WARN("sw.ww8", "Unhandled style property: " << rGrabBag[i].Name);
         }
@@ -3635,6 +3637,8 @@ void DocxAttributeOutput::StartStyle( const OUString& rName, StyleType eType,
     pStyleAttributeList->add(FSNS( XML_w, XML_styleId ), m_rExport.pStyles->GetStyleId(nId).getStr());
     if (bDefault)
         pStyleAttributeList->add(FSNS(XML_w, XML_default), "1");
+    if (bCustomStyle)
+        pStyleAttributeList->add(FSNS(XML_w, XML_customStyle), "1");
     XFastAttributeListRef xStyleAttributeList(pStyleAttributeList);
     m_pSerializer->startElementNS( XML_w, XML_style, xStyleAttributeList);
 
diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx b/writerfilter/source/dmapper/StyleSheetTable.cxx
index bf035d6..fcb04fb 100644
--- a/writerfilter/source/dmapper/StyleSheetTable.cxx
+++ b/writerfilter/source/dmapper/StyleSheetTable.cxx
@@ -493,13 +493,12 @@ void StyleSheetTable::lcl_attribute(Id Name, Value & val)
             }
         break;
         case NS_ooxml::LN_CT_Style_customStyle:
-            if(m_pImpl->m_pCurrentEntry->nStyleTypeCode == STYLE_TYPE_TABLE)
+            if(m_pImpl->m_pCurrentEntry->nStyleTypeCode == STYLE_TYPE_TABLE || m_pImpl->m_pCurrentEntry->nStyleTypeCode == STYLE_TYPE_PARA)
             {
-                TableStyleSheetEntry* pTableEntry = static_cast<TableStyleSheetEntry *>(m_pImpl->m_pCurrentEntry.get());
                 beans::PropertyValue aValue;
                 aValue.Name = "customStyle";
                 aValue.Value = uno::makeAny(sal_Bool(nIntValue != 0));
-                pTableEntry->AppendInteropGrabBag(aValue);
+                m_pImpl->m_pCurrentEntry->AppendInteropGrabBag(aValue);
             }
         break;
         case NS_ooxml::LN_CT_Style_styleId:
commit c367a7e3cab3753eba3e0647cc4f013d882c521f
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Nov 7 11:52:39 2013 +0100

    DOCX filter: roundtrip paragraph style default
    
    Change-Id: I93495b4a2f85fe9729f8e1c810532717783756e4

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 974be7e..0714c16 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -1304,6 +1304,7 @@ DECLARE_OOXML_TEST(testStyleInheritance, "style-inheritance.docx")
     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='ListParagraph']/w:uiPriority", "val", "34");
     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Normal']/w:qFormat", 1);
     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Normal']/w:rsid", "val", "00780346");
+    assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Normal']", "default", "1");
 
     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Heading1']/w:link", "val", "Heading1Char");
     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Heading1']/w:locked", 1);
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index d51fb00..8721dbf 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -3593,22 +3593,9 @@ oox::drawingml::DrawingML& DocxAttributeOutput::GetDrawingML()
 void DocxAttributeOutput::StartStyle( const OUString& rName, StyleType eType,
         sal_uInt16 nBase, sal_uInt16 nNext, sal_uInt16 /*nWwId*/, sal_uInt16 nId, bool bAutoUpdate )
 {
-    const char* pType = 0;
-    switch (eType)
-    {
-        case STYLE_TYPE_PARA: pType = "paragraph"; break;
-        case STYLE_TYPE_CHAR: pType = "character"; break;
-        case STYLE_TYPE_LIST: pType = "numbering"; break;
-    }
-    m_pSerializer->startElementNS( XML_w, XML_style,
-            FSNS( XML_w, XML_type ), pType,
-            FSNS( XML_w, XML_styleId ), m_rExport.pStyles->GetStyleId(nId).getStr(),
-            FSEND );
-
-    m_pSerializer->singleElementNS( XML_w, XML_name,
-            FSNS( XML_w, XML_val ), OUStringToOString( OUString( rName ), RTL_TEXTENCODING_UTF8 ).getStr(),
-            FSEND );
-
+    bool bQFormat = false, bUnhideWhenUsed = false, bLocked = false, bDefault = false;
+    OUString aLink, aRsid, aUiPriority;
+    FastAttributeList* pStyleAttributeList = m_pSerializer->createAttrList();
     if (eType == STYLE_TYPE_PARA)
     {
         const SwFmt* pFmt = m_rExport.pStyles->GetSwFmt(nId);
@@ -3616,8 +3603,6 @@ void DocxAttributeOutput::StartStyle( const OUString& rName, StyleType eType,
         pFmt->GetGrabBagItem(aAny);
         const uno::Sequence<beans::PropertyValue>& rGrabBag = aAny.get< uno::Sequence<beans::PropertyValue> >();
 
-        bool bQFormat = false, bUnhideWhenUsed = false, bLocked = false;
-        OUString aLink, aRsid, aUiPriority;
         for (sal_Int32 i = 0; i < rGrabBag.getLength(); ++i)
         {
             if (rGrabBag[i].Name == "uiPriority")
@@ -3632,29 +3617,50 @@ void DocxAttributeOutput::StartStyle( const OUString& rName, StyleType eType,
                 bUnhideWhenUsed = true;
             else if (rGrabBag[i].Name == "locked")
                 bLocked = true;
+            else if (rGrabBag[i].Name == "default")
+                bDefault = rGrabBag[i].Value.get<sal_Bool>();
             else
                 SAL_WARN("sw.ww8", "Unhandled style property: " << rGrabBag[i].Name);
         }
+    }
 
-        if (!aUiPriority.isEmpty())
-            m_pSerializer->singleElementNS(XML_w, XML_uiPriority,
-                    FSNS(XML_w, XML_val), OUStringToOString(aUiPriority, RTL_TEXTENCODING_UTF8).getStr(),
-                    FSEND);
-        if (bQFormat)
-            m_pSerializer->singleElementNS(XML_w, XML_qFormat, FSEND);
-        if (bUnhideWhenUsed)
-            m_pSerializer->singleElementNS(XML_w, XML_unhideWhenUsed, FSEND);
-        if (!aLink.isEmpty())
-            m_pSerializer->singleElementNS(XML_w, XML_link,
-                    FSNS(XML_w, XML_val), OUStringToOString(aLink, RTL_TEXTENCODING_UTF8).getStr(),
-                    FSEND);
-        if (bLocked)
-            m_pSerializer->singleElementNS(XML_w, XML_locked, FSEND);
-        if (!aRsid.isEmpty())
-            m_pSerializer->singleElementNS(XML_w, XML_rsid,
-                    FSNS(XML_w, XML_val), OUStringToOString(aRsid, RTL_TEXTENCODING_UTF8).getStr(),
-                    FSEND);
+    const char* pType = 0;
+    switch (eType)
+    {
+        case STYLE_TYPE_PARA: pType = "paragraph"; break;
+        case STYLE_TYPE_CHAR: pType = "character"; break;
+        case STYLE_TYPE_LIST: pType = "numbering"; break;
     }
+    pStyleAttributeList->add(FSNS( XML_w, XML_type ), pType);
+    pStyleAttributeList->add(FSNS( XML_w, XML_styleId ), m_rExport.pStyles->GetStyleId(nId).getStr());
+    if (bDefault)
+        pStyleAttributeList->add(FSNS(XML_w, XML_default), "1");
+    XFastAttributeListRef xStyleAttributeList(pStyleAttributeList);
+    m_pSerializer->startElementNS( XML_w, XML_style, xStyleAttributeList);
+
+    m_pSerializer->singleElementNS( XML_w, XML_name,
+            FSNS( XML_w, XML_val ), OUStringToOString( OUString( rName ), RTL_TEXTENCODING_UTF8 ).getStr(),
+            FSEND );
+
+    // Output properties from grab-bag.
+    if (!aUiPriority.isEmpty())
+        m_pSerializer->singleElementNS(XML_w, XML_uiPriority,
+                FSNS(XML_w, XML_val), OUStringToOString(aUiPriority, RTL_TEXTENCODING_UTF8).getStr(),
+                FSEND);
+    if (bQFormat)
+        m_pSerializer->singleElementNS(XML_w, XML_qFormat, FSEND);
+    if (bUnhideWhenUsed)
+        m_pSerializer->singleElementNS(XML_w, XML_unhideWhenUsed, FSEND);
+    if (!aLink.isEmpty())
+        m_pSerializer->singleElementNS(XML_w, XML_link,
+                FSNS(XML_w, XML_val), OUStringToOString(aLink, RTL_TEXTENCODING_UTF8).getStr(),
+                FSEND);
+    if (bLocked)
+        m_pSerializer->singleElementNS(XML_w, XML_locked, FSEND);
+    if (!aRsid.isEmpty())
+        m_pSerializer->singleElementNS(XML_w, XML_rsid,
+                FSNS(XML_w, XML_val), OUStringToOString(aRsid, RTL_TEXTENCODING_UTF8).getStr(),
+                FSEND);
 
     if ( nBase != 0x0FFF && eType != STYLE_TYPE_LIST)
     {
diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx b/writerfilter/source/dmapper/StyleSheetTable.cxx
index 1092bac..bf035d6 100644
--- a/writerfilter/source/dmapper/StyleSheetTable.cxx
+++ b/writerfilter/source/dmapper/StyleSheetTable.cxx
@@ -484,13 +484,12 @@ void StyleSheetTable::lcl_attribute(Id Name, Value & val)
         break;
         case NS_ooxml::LN_CT_Style_default:
             m_pImpl->m_pCurrentEntry->bIsDefaultStyle = (nIntValue != 0);
-            if(m_pImpl->m_pCurrentEntry->nStyleTypeCode == STYLE_TYPE_TABLE)
+            if(m_pImpl->m_pCurrentEntry->nStyleTypeCode == STYLE_TYPE_TABLE || m_pImpl->m_pCurrentEntry->nStyleTypeCode == STYLE_TYPE_PARA)
             {
-                TableStyleSheetEntry* pTableEntry = static_cast<TableStyleSheetEntry *>(m_pImpl->m_pCurrentEntry.get());
                 beans::PropertyValue aValue;
                 aValue.Name = "default";
-                aValue.Value = uno::makeAny(sal_Bool(pTableEntry->bIsDefaultStyle));
-                pTableEntry->AppendInteropGrabBag(aValue);
+                aValue.Value = uno::makeAny(sal_Bool(m_pImpl->m_pCurrentEntry->bIsDefaultStyle));
+                m_pImpl->m_pCurrentEntry->AppendInteropGrabBag(aValue);
             }
         break;
         case NS_ooxml::LN_CT_Style_customStyle:


More information about the Libreoffice-commits mailing list