summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorJustin Luth <justin.luth@collabora.com>2019-10-04 11:47:57 +0300
committerMiklos Vajna <vmiklos@collabora.com>2019-10-28 15:09:09 +0100
commit9b8052bba91ed616de77006cd0d3dee3965caece (patch)
tree65b543882e3afde2537845894914ac58ca8b727e /writerfilter
parenta991ad93dcd6807d0eacd11a50c2ae43a2cfb882 (diff)
related tdf#99602 writerfilter TODO: subscript - use CharStyle fontsize
GetAnyProperty was missing a check for character style properties. This patch depends on commit 875793d841165aaaaefa2c34b855e8f0f8a8c214 related tdf#99602 writerfilter TODO: subscript - use ParaStyle fontsize and on commit 5e97d1a57717f8dbf69b987d2bda8616972eec52 NFC writerfilter: preparation for adding CharProps to GetAnyProperty Change-Id: I4e28589917e41fa545d5aab05f97a67502486136 Reviewed-on: https://gerrit.libreoffice.org/80216 Tested-by: Jenkins Reviewed-by: Justin Luth <justin_luth@sil.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx31
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.hxx4
2 files changed, 30 insertions, 5 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index d41330700b0c..76aca3880e00 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -746,7 +746,7 @@ OUString DomainMapper_Impl::GetDefaultParaStyleName()
return m_sDefaultParaStyleName;
}
-uno::Any DomainMapper_Impl::GetPropertyFromStyleSheet(PropertyIds eId, StyleSheetEntryPtr pEntry, const bool bPara)
+uno::Any DomainMapper_Impl::GetPropertyFromStyleSheet(PropertyIds eId, StyleSheetEntryPtr pEntry, const bool bDocDefaults, const bool bPara)
{
while(pEntry.get( ) )
{
@@ -772,7 +772,7 @@ uno::Any DomainMapper_Impl::GetPropertyFromStyleSheet(PropertyIds eId, StyleShee
pEntry = pNewEntry;
}
// not found in style, try the document's DocDefault properties
- if ( bPara )
+ if ( bDocDefaults && bPara )
{
const PropertyMapPtr& pDefaultParaProps = GetStyleSheetTable()->GetDefaultParaProps();
if ( pDefaultParaProps )
@@ -782,7 +782,7 @@ uno::Any DomainMapper_Impl::GetPropertyFromStyleSheet(PropertyIds eId, StyleShee
return aProperty->second;
}
}
- if ( isCharacterProperty(eId) )
+ if ( bDocDefaults && isCharacterProperty(eId) )
{
const PropertyMapPtr& pDefaultCharProps = GetStyleSheetTable()->GetDefaultCharProps();
if ( pDefaultCharProps )
@@ -802,17 +802,40 @@ uno::Any DomainMapper_Impl::GetPropertyFromParaStyleSheet(PropertyIds eId)
pEntry = GetStyleSheetTable()->GetCurrentEntry();
else
pEntry = GetStyleSheetTable()->FindStyleSheetByConvertedStyleName(GetCurrentParaStyleName());
- return GetPropertyFromStyleSheet(eId, pEntry, /*bPara=*/true);
+ return GetPropertyFromStyleSheet(eId, pEntry, /*bDocDefaults=*/true, /*bPara=*/true);
+}
+
+uno::Any DomainMapper_Impl::GetPropertyFromCharStyleSheet(PropertyIds eId, const PropertyMapPtr& rContext)
+{
+ if ( m_bInStyleSheetImport || eId == PROP_CHAR_STYLE_NAME || !isCharacterProperty(eId) )
+ return uno::Any();
+
+ StyleSheetEntryPtr pEntry;
+ OUString sCharStyleName;
+ if ( GetAnyProperty(PROP_CHAR_STYLE_NAME, rContext) >>= sCharStyleName )
+ pEntry = GetStyleSheetTable()->FindStyleSheetByConvertedStyleName(sCharStyleName);
+ return GetPropertyFromStyleSheet(eId, pEntry, /*bDocDefaults=*/false, /*bPara=*/false);
}
uno::Any DomainMapper_Impl::GetAnyProperty(PropertyIds eId, const PropertyMapPtr& rContext)
{
+ // first look in directly applied attributes
if ( rContext )
{
boost::optional<PropertyMap::Property> aProperty = rContext->getProperty(eId);
if ( aProperty )
return aProperty->second;
}
+
+ // then look whether it was inherited from a directly applied character style
+ if ( eId != PROP_CHAR_STYLE_NAME && isCharacterProperty(eId) )
+ {
+ uno::Any aRet = GetPropertyFromCharStyleSheet(eId, rContext);
+ if ( aRet.hasValue() )
+ return aRet;
+ }
+
+ // then look in current paragraph style, and docDefaults
return GetPropertyFromParaStyleSheet(eId);
}
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index 92cef81c495c..c11ef87202ab 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -715,9 +715,11 @@ public:
OUString GetDefaultParaStyleName();
// specified style - including inherited properties. Indicate whether paragraph defaults should be checked.
- css::uno::Any GetPropertyFromStyleSheet(PropertyIds eId, StyleSheetEntryPtr pEntry, const bool bPara);
+ css::uno::Any GetPropertyFromStyleSheet(PropertyIds eId, StyleSheetEntryPtr pEntry, const bool bDocDefaults, const bool bPara);
// current paragraph style - including inherited properties
css::uno::Any GetPropertyFromParaStyleSheet(PropertyIds eId);
+ // context's character style - including inherited properties
+ css::uno::Any GetPropertyFromCharStyleSheet(PropertyIds eId, const PropertyMapPtr& rContext);
// get property first from the given context, or secondly via inheritance from styles/docDefaults
css::uno::Any GetAnyProperty(PropertyIds eId, const PropertyMapPtr& rContext);
void SetStyleSheetImport( bool bSet ) { m_bInStyleSheetImport = bSet;}