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

Miklos Vajna vmiklos at collabora.co.uk
Sun Mar 15 06:23:09 PDT 2015


 editeng/source/rtf/rtfitem.cxx                 |   12 ++--
 sw/qa/extras/rtfexport/data/sautoupd.rtf       |    7 ++
 sw/qa/extras/rtfexport/rtfexport.cxx           |    9 +++
 sw/source/filter/ww8/rtfattributeoutput.cxx    |    5 +
 writerfilter/source/dmapper/PropertyMap.cxx    |   75 +++++++++++--------------
 writerfilter/source/dmapper/PropertyMap.hxx    |    8 +-
 writerfilter/source/rtftok/rtfdocumentimpl.cxx |    3 +
 7 files changed, 68 insertions(+), 51 deletions(-)

New commits:
commit 9537ddcfc6711d864f442f280f0a82a8ccb00f0a
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Sun Mar 15 14:07:18 2015 +0100

    editeng: nAnz -> nCount
    
    Change-Id: Ieda943586c95e3edcd277dfa5e8586cc8c27867a

diff --git a/editeng/source/rtf/rtfitem.cxx b/editeng/source/rtf/rtfitem.cxx
index 2444a60..6083cf1 100644
--- a/editeng/source/rtf/rtfitem.cxx
+++ b/editeng/source/rtf/rtfitem.cxx
@@ -1863,19 +1863,19 @@ void SvxRTFParser::SetDefault( int nToken, int nValue )
             // Calculate the ratio of default TabWidth / Tabs and
             // calculate the corresponding new number.
             // ?? how did one come up with 13 ??
-            sal_uInt16 nAnzTabs = (SVX_TAB_DEFDIST * 13 ) / sal_uInt16(nValue);
+            sal_uInt16 nTabCount = (SVX_TAB_DEFDIST * 13 ) / sal_uInt16(nValue);
             /*
              cmc, make sure we have at least one, or all hell breaks loose in
              everybodies exporters, #i8247#
             */
-            if (nAnzTabs < 1)
-                nAnzTabs = 1;
+            if (nTabCount < 1)
+                nTabCount = 1;
 
             // we want Defaulttabs
-            SvxTabStopItem aNewTab( nAnzTabs, sal_uInt16(nValue),
+            SvxTabStopItem aNewTab( nTabCount, sal_uInt16(nValue),
                                 SVX_TAB_ADJUST_DEFAULT, aPardMap.nTabStop );
-            while( nAnzTabs )
-                ((SvxTabStop&)aNewTab[ --nAnzTabs ]).GetAdjustment() = SVX_TAB_ADJUST_DEFAULT;
+            while( nTabCount )
+                ((SvxTabStop&)aNewTab[ --nTabCount ]).GetAdjustment() = SVX_TAB_ADJUST_DEFAULT;
 
             pAttrPool->SetPoolDefaultItem( aNewTab );
         }
commit a936658e6cd92d8f073227cd5c586bcecc7124e0
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Sun Mar 15 13:56:35 2015 +0100

    RTF export: handle \sautoupd
    
    Change-Id: Ifddb3fda827aef0a95649bf074dad7d9cc797edb

diff --git a/sw/qa/extras/rtfexport/data/sautoupd.rtf b/sw/qa/extras/rtfexport/data/sautoupd.rtf
new file mode 100644
index 0000000..960855d
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/sautoupd.rtf
@@ -0,0 +1,7 @@
+{\rtf1
+{\stylesheet
+{\s1\sautoupd heading 1;}
+{\s2 heading 2;}
+}
+\pard\plain hello\par
+}
diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx
index f056208..de571a2 100644
--- a/sw/qa/extras/rtfexport/rtfexport.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport.cxx
@@ -867,6 +867,15 @@ DECLARE_RTFEXPORT_TEST(testMargmirror, "margmirror.rtf")
     CPPUNIT_ASSERT_EQUAL(style::PageStyleLayout_MIRRORED, getProperty<style::PageStyleLayout>(xPageStyle, "PageStyleLayout"));
 }
 
+DECLARE_RTFEXPORT_TEST(testSautoupd, "sautoupd.rtf")
+{
+    // \sautoupd was ignored during import and export.
+    uno::Reference<beans::XPropertySet> xHeading1(getStyles("ParagraphStyles")->getByName("Heading 1"), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xHeading1, "IsAutoUpdate"));
+    uno::Reference<beans::XPropertySet> xHeading2(getStyles("ParagraphStyles")->getByName("Heading 2"), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(xHeading2, "IsAutoUpdate"));
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx
index 191bff0..83ef2ba 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -1016,7 +1016,7 @@ void RtfAttributeOutput::DefaultStyle(sal_uInt16 /*nStyle*/)
 
 void RtfAttributeOutput::StartStyle(const OUString& rName, StyleType eType,
                                     sal_uInt16 nBase, sal_uInt16 nNext, sal_uInt16 /*nWwId*/, sal_uInt16 nId,
-                                    bool /* bAutoUpdate */)
+                                    bool bAutoUpdate)
 {
     SAL_INFO("sw.rtf", OSL_THIS_FUNC << ", rName = '" << rName << "'");
 
@@ -1036,6 +1036,9 @@ void RtfAttributeOutput::StartStyle(const OUString& rName, StyleType eType,
     m_aStylesheet.append(OOO_STRING_SVTOOLS_RTF_SNEXT);
     m_aStylesheet.append((sal_Int32)nNext);
 
+    if (bAutoUpdate)
+        m_aStylesheet.append(OOO_STRING_SVTOOLS_RTF_SAUTOUPD);
+
     m_rStyleName = rName;
     m_nStyleId = nId;
 }
commit fb83e8a5a421f751b06faf991177ad3b2100976c
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Sun Mar 15 13:52:43 2015 +0100

    RTF import: handle \sautoupd
    
    Change-Id: I6254401ad8023263b29feb382ddda3637611a813

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index ddf1e52..2abd5c7 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -3491,6 +3491,9 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
     case RTF_MARGMIRROR:
         m_aSettingsTableSprms.set(NS_ooxml::LN_CT_Settings_mirrorMargins, std::make_shared<RTFValue>(1));
         break;
+    case RTF_SAUTOUPD:
+        m_aStates.top().aTableSprms.set(NS_ooxml::LN_CT_Style_autoRedefine, std::make_shared<RTFValue>(1));
+        break;
     default:
     {
         SAL_INFO("writerfilter", "TODO handle flag '" << lcl_RtfToString(nKeyword) << "'");
commit 4c171779cad4bd97942523950331c381100281ec
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Sun Mar 15 10:55:55 2015 +0100

    Use comphelper::containerToSequence() instead of manual realloc
    
    Change-Id: I88e8050055e53e0da8ac32e049c5ab793096f687

diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx
index 9cd85d4..2fc7567 100644
--- a/writerfilter/source/dmapper/PropertyMap.cxx
+++ b/writerfilter/source/dmapper/PropertyMap.cxx
@@ -41,6 +41,7 @@
 #include <com/sun/star/text/XText.hpp>
 #include <com/sun/star/text/TextGridMode.hpp>
 #include <com/sun/star/text/XTextCopy.hpp>
+#include <comphelper/sequence.hxx>
 #include "dmapperLoggers.hxx"
 #include "PropertyMapHelper.hxx"
 
@@ -65,7 +66,7 @@ PropertyMap::~PropertyMap()
 
 uno::Sequence< beans::PropertyValue > PropertyMap::GetPropertyValues(bool bCharGrabBag)
 {
-    if(!m_aValues.getLength() && !m_vMap.empty())
+    if(m_aValues.empty() && !m_vMap.empty())
     {
         size_t nCharGrabBag = 0;
         size_t nParaGrabBag = 0;
@@ -94,20 +95,7 @@ uno::Sequence< beans::PropertyValue > PropertyMap::GetPropertyValues(bool bCharG
                 nRowGrabBag++;
         }
 
-        // In case there are properties to be grab-bagged and we can have a char grab-bag, allocate one slot for it.
-        size_t nCharGrabBagSize = 0;
-        if (bCharGrabBag)
-            nCharGrabBagSize = nCharGrabBag ? 1 : 0;
-        size_t nParaGrabBagSize = nParaGrabBag ? 1 : 0;
-        size_t nCellGrabBagSize = nCellGrabBag ? 1 : 0;
-        size_t nRowGrabBagSize = nRowGrabBag ? 1 : 0;
-
         // If there are any grab bag properties, we need one slot for them.
-        m_aValues.realloc( m_vMap.size() - nCharGrabBag + nCharGrabBagSize
-                                  - nParaGrabBag + nParaGrabBagSize
-                                  - nCellGrabBagSaved + nCellGrabBagSize
-                                  - nRowGrabBag + nRowGrabBagSize);
-        ::com::sun::star::beans::PropertyValue* pValues = m_aValues.getArray();
         uno::Sequence<beans::PropertyValue> aCharGrabBagValues(nCharGrabBag);
         uno::Sequence<beans::PropertyValue> aParaGrabBagValues(nParaGrabBag);
         uno::Sequence<beans::PropertyValue> aCellGrabBagValues(nCellGrabBag);
@@ -118,7 +106,6 @@ uno::Sequence< beans::PropertyValue > PropertyMap::GetPropertyValues(bool bCharG
         beans::PropertyValue* pRowGrabBagValues = aRowGrabBagValues.getArray();
         //style names have to be the first elements within the property sequence
         //otherwise they will overwrite 'hard' attributes
-        sal_Int32 nValue = 0;
         sal_Int32 nRowGrabBagValue = 0;
         sal_Int32 nCellGrabBagValue = 0;
         sal_Int32 nParaGrabBagValue = 0;
@@ -127,24 +114,27 @@ uno::Sequence< beans::PropertyValue > PropertyMap::GetPropertyValues(bool bCharG
         MapIterator aParaStyleIter = m_vMap.find(PROP_PARA_STYLE_NAME);
         if( aParaStyleIter != m_vMap.end())
         {
-            pValues[nValue].Name = rPropNameSupplier.GetName( aParaStyleIter->first );
-            pValues[nValue].Value = aParaStyleIter->second.getValue();
-            ++nValue;
+            beans::PropertyValue aValue;
+            aValue.Name = rPropNameSupplier.GetName( aParaStyleIter->first );
+            aValue.Value = aParaStyleIter->second.getValue();
+            m_aValues.push_back(aValue);
         }
 
         MapIterator aCharStyleIter = m_vMap.find(PROP_CHAR_STYLE_NAME);
         if( aCharStyleIter != m_vMap.end())
         {
-            pValues[nValue].Name = rPropNameSupplier.GetName( aCharStyleIter->first );
-            pValues[nValue].Value = aCharStyleIter->second.getValue();
-            ++nValue;
+            beans::PropertyValue aValue;
+            aValue.Name = rPropNameSupplier.GetName( aCharStyleIter->first );
+            aValue.Value = aCharStyleIter->second.getValue();
+            m_aValues.push_back(aValue);
         }
         MapIterator aNumRuleIter = m_vMap.find(PROP_NUMBERING_RULES);
         if( aNumRuleIter != m_vMap.end())
         {
-            pValues[nValue].Name = rPropNameSupplier.GetName( aNumRuleIter->first );
-            pValues[nValue].Value = aNumRuleIter->second.getValue();
-            ++nValue;
+            beans::PropertyValue aValue;
+            aValue.Name = rPropNameSupplier.GetName( aNumRuleIter->first );
+            aValue.Value = aNumRuleIter->second.getValue();
+            m_aValues.push_back(aValue);
         }
         MapIterator aMapIter = m_vMap.begin();
         for( ; aMapIter != m_vMap.end(); ++aMapIter )
@@ -192,39 +182,44 @@ uno::Sequence< beans::PropertyValue > PropertyMap::GetPropertyValues(bool bCharG
                     }
                     else
                     {
-                        pValues[nValue].Name = rPropNameSupplier.GetName( aMapIter->first );
-                        pValues[nValue].Value = aMapIter->second.getValue();
-                        ++nValue;
+                        beans::PropertyValue aValue;
+                        aValue.Name = rPropNameSupplier.GetName( aMapIter->first );
+                        aValue.Value = aMapIter->second.getValue();
+                        m_aValues.push_back(aValue);
                     }
                 }
             }
         }
         if (nCharGrabBag && bCharGrabBag)
         {
-            pValues[nValue].Name = "CharInteropGrabBag";
-            pValues[nValue].Value = uno::makeAny(aCharGrabBagValues);
-            ++nValue;
+            beans::PropertyValue aValue;
+            aValue.Name = "CharInteropGrabBag";
+            aValue.Value = uno::makeAny(aCharGrabBagValues);
+            m_aValues.push_back(aValue);
         }
         if (nParaGrabBag)
         {
-            pValues[nValue].Name = "ParaInteropGrabBag";
-            pValues[nValue].Value = uno::makeAny(aParaGrabBagValues);
-            ++nValue;
+            beans::PropertyValue aValue;
+            aValue.Name = "ParaInteropGrabBag";
+            aValue.Value = uno::makeAny(aParaGrabBagValues);
+            m_aValues.push_back(aValue);
         }
         if (nCellGrabBag)
         {
-            pValues[nValue].Name = "CellInteropGrabBag";
-            pValues[nValue].Value = uno::makeAny(aCellGrabBagValues);
-            ++nValue;
+            beans::PropertyValue aValue;
+            aValue.Name = "CellInteropGrabBag";
+            aValue.Value = uno::makeAny(aCellGrabBagValues);
+            m_aValues.push_back(aValue);
         }
         if (nRowGrabBag)
         {
-            pValues[nValue].Name = "RowInteropGrabBag";
-            pValues[nValue].Value = uno::makeAny(aRowGrabBagValues);
-            ++nValue;
+            beans::PropertyValue aValue;
+            aValue.Name = "RowInteropGrabBag";
+            aValue.Value = uno::makeAny(aRowGrabBagValues);
+            m_aValues.push_back(aValue);
         }
     }
-    return m_aValues;
+    return comphelper::containerToSequence(m_aValues);
 }
 
 #ifdef DEBUG_WRITERFILTER
diff --git a/writerfilter/source/dmapper/PropertyMap.hxx b/writerfilter/source/dmapper/PropertyMap.hxx
index e430af5..c413d8c 100644
--- a/writerfilter/source/dmapper/PropertyMap.hxx
+++ b/writerfilter/source/dmapper/PropertyMap.hxx
@@ -105,7 +105,7 @@ public:
 class PropertyMap
 {
     /// Cache the property values for the GetPropertyValues() call(s).
-    ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >   m_aValues;
+    std::vector< ::com::sun::star::beans::PropertyValue >   m_aValues;
 
     //marks context as footnote context - ::text( ) events contain either the footnote character or can be ignored
     //depending on sprmCSymbol
@@ -123,8 +123,8 @@ class PropertyMap
 protected:
     void Invalidate()
     {
-        if(m_aValues.getLength())
-            m_aValues.realloc( 0 );
+        if(m_aValues.size())
+            m_aValues.clear();
     }
 
 public:
@@ -136,7 +136,7 @@ public:
     ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > GetPropertyValues(bool bCharGrabBag = true);
         //Sequence: Grab Bags: The CHAR_GRAB_BAG has Name "CharInteropGrabBag" and the PARA_GRAB_BAG has Name "ParaInteropGrabBag"
         //  the contained properties are their Value.
-    bool hasEmptyPropertyValues() const {return !m_aValues.getLength();}
+    bool hasEmptyPropertyValues() const {return m_aValues.empty();}
 
     //Add property, optionally overwriting existing attributes
     void Insert( PropertyIds eId, const ::com::sun::star::uno::Any& rAny, bool bOverwrite = true, GrabBagType i_GrabBagType = NO_GRAB_BAG );


More information about the Libreoffice-commits mailing list