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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Jul 31 05:53:31 UTC 2018


 writerfilter/source/dmapper/DomainMapperTableHandler.cxx |   32 ---------------
 writerfilter/source/dmapper/StyleSheetTable.cxx          |   18 ++++++++
 writerfilter/source/dmapper/StyleSheetTable.hxx          |    6 ++
 3 files changed, 24 insertions(+), 32 deletions(-)

New commits:
commit 108d4a6391eee22642fcb18ba429c2c9f4d8c818
Author:     Justin Luth <justin.luth at collabora.com>
AuthorDate: Sat Jul 28 22:17:36 2018 +0300
Commit:     Justin Luth <justin_luth at sil.org>
CommitDate: Tue Jul 31 07:53:10 2018 +0200

    writerfilter: create StyleSheetEntry::GetMergedInheritedProperties
    
    This is a useful function. Make it more widely available.
    
    Change-Id: I729c908eaf26e17c16198d14dcb89069ec6ca70c
    Reviewed-on: https://gerrit.libreoffice.org/58261
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <justin_luth at sil.org>

diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
index 2e9bfa959249..3c4bb61457e7 100644
--- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
@@ -78,36 +78,6 @@ void DomainMapperTableHandler::startTable(const TablePropertyMapPtr& pProps)
 #endif
 }
 
-
-PropertyMapPtr lcl_SearchParentStyleSheetAndMergeProperties(const StyleSheetEntryPtr& rStyleSheet, const StyleSheetTablePtr& pStyleSheetTable)
-{
-    PropertyMapPtr pRet;
-
-    if (!rStyleSheet)
-        return pRet;
-
-    if(!rStyleSheet->sBaseStyleIdentifier.isEmpty())
-    {
-        const StyleSheetEntryPtr pParentStyleSheet = pStyleSheetTable->FindStyleSheetByISTD(rStyleSheet->sBaseStyleIdentifier);
-        //a loop in the style hierarchy, bail out
-        if (pParentStyleSheet == rStyleSheet)
-            return pRet;
-
-        pRet = lcl_SearchParentStyleSheetAndMergeProperties( pParentStyleSheet, pStyleSheetTable );
-    }
-    else
-    {
-        pRet = new PropertyMap;
-    }
-
-    if (pRet)
-    {
-        pRet->InsertProps(rStyleSheet->pProperties);
-    }
-
-    return pRet;
-}
-
 void lcl_mergeBorder( PropertyIds nId, const PropertyMapPtr& pOrig, const PropertyMapPtr& pDest )
 {
     boost::optional<PropertyMap::Property> pOrigVal = pOrig->getProperty(nId);
@@ -388,7 +358,7 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo
 
                 m_aTableProperties = pEmptyProps;
 
-                PropertyMapPtr pMergedProperties = lcl_SearchParentStyleSheetAndMergeProperties(pStyleSheet, pStyleSheetTable);
+                PropertyMapPtr pMergedProperties = pStyleSheet->GetMergedInheritedProperties(pStyleSheetTable);
 
                 table::BorderLine2 aBorderLine;
                 TableInfo rStyleInfo;
diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx b/writerfilter/source/dmapper/StyleSheetTable.cxx
index 8e71f5f28f2d..95d645a08bb1 100644
--- a/writerfilter/source/dmapper/StyleSheetTable.cxx
+++ b/writerfilter/source/dmapper/StyleSheetTable.cxx
@@ -161,6 +161,24 @@ void StyleSheetEntry::AppendInteropGrabBag(const beans::PropertyValue& rValue)
     m_aInteropGrabBag.push_back(rValue);
 }
 
+PropertyMapPtr StyleSheetEntry::GetMergedInheritedProperties(const StyleSheetTablePtr& pStyleSheetTable)
+{
+    PropertyMapPtr pRet;
+    if ( pStyleSheetTable && !sBaseStyleIdentifier.isEmpty() && sBaseStyleIdentifier != sStyleIdentifierD )
+    {
+        const StyleSheetEntryPtr pParentStyleSheet = pStyleSheetTable->FindStyleSheetByISTD(sBaseStyleIdentifier);
+        if ( pParentStyleSheet )
+            pRet = pParentStyleSheet->GetMergedInheritedProperties(pStyleSheetTable);
+    }
+
+    if ( !pRet )
+        pRet = new PropertyMap;
+
+    pRet->InsertProps(pProperties);
+
+    return pRet;
+}
+
 void lcl_mergeProps( const PropertyMapPtr& pToFill, const PropertyMapPtr& pToAdd, TblStyleType nStyleId )
 {
     static const PropertyIds pPropsToCheck[] =
diff --git a/writerfilter/source/dmapper/StyleSheetTable.hxx b/writerfilter/source/dmapper/StyleSheetTable.hxx
index a5e1df2685d6..686779acbd71 100644
--- a/writerfilter/source/dmapper/StyleSheetTable.hxx
+++ b/writerfilter/source/dmapper/StyleSheetTable.hxx
@@ -47,6 +47,8 @@ enum StyleType
     STYLE_TYPE_TABLE,
     STYLE_TYPE_LIST
 };
+class StyleSheetTable;
+typedef tools::SvRef<StyleSheetTable> StyleSheetTablePtr;
 
 struct StyleSheetTable_Impl;
 class StyleSheetEntry : public virtual SvRefBase
@@ -71,6 +73,9 @@ public:
     css::beans::PropertyValue GetInteropGrabBag(); ///< Used for table styles, has a name.
     css::beans::PropertyValues GetInteropGrabBagSeq(); ///< Used for existing styles, just a list of properties.
 
+    // Get all properties, merged with the all of the parent's properties
+    PropertyMapPtr GetMergedInheritedProperties(const StyleSheetTablePtr& pStyleSheetTable);
+
     StyleSheetEntry();
     virtual ~StyleSheetEntry() override;
 };
@@ -113,7 +118,6 @@ private:
 
     void applyDefaults(bool bParaProperties);
 };
-typedef tools::SvRef< StyleSheetTable >    StyleSheetTablePtr;
 
 
 class TableStyleSheetEntry :


More information about the Libreoffice-commits mailing list