summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorJustin Luth <justin.luth@collabora.com>2018-07-28 22:17:36 +0300
committerJustin Luth <justin_luth@sil.org>2018-07-31 07:53:10 +0200
commit108d4a6391eee22642fcb18ba429c2c9f4d8c818 (patch)
treedb0d7f2ee0543519671a9607f8c5e034bc6b4eab /writerfilter
parent7e65a0794b7c57210779bb9a6d1f2b2e49eb86e9 (diff)
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@sil.org>
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/dmapper/DomainMapperTableHandler.cxx32
-rw-r--r--writerfilter/source/dmapper/StyleSheetTable.cxx18
-rw-r--r--writerfilter/source/dmapper/StyleSheetTable.hxx6
3 files changed, 24 insertions, 32 deletions
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 :