Kaydet (Commit) bc67bda7 authored tarafından Justin Luth's avatar Justin Luth Kaydeden (comit) Miklos Vajna

related tdf#106174 writerfilter: replace broken FindParentStyleSheet

FindParentStyleSheet didn't do anything right. An empty stylename
was supposed to check currentEntry, but instead it just returned
null. The passed stylename was completely ignored if there was
a currentEntry. And on top of that, the stylename itself was
returned, not its parent. Even worse, the currentEntry properties
were ignored because in that case it DID return the parent.
Even the comments were totally bogus. Amazing...

GetPropertyFromStyleSheet() has the potential for LOTS of use
in writerfilter. I'm surprised it has hardly been used. Perhaps
the completely wrong results led people to ignore it rather than
investigate why it didn't give the expected results.

Change-Id: I89a6b02877ab7990aa4eb58e5e0b6a572f3d10e3
Reviewed-on: https://gerrit.libreoffice.org/57195
Tested-by: Jenkins
Reviewed-by: 's avatarJustin Luth <justin_luth@sil.org>
Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
üst 23793a08
......@@ -660,19 +660,17 @@ const OUString DomainMapper_Impl::GetCurrentParaStyleName()
}
/*-------------------------------------------------------------------------
returns a the value from the current paragraph style - if available
TODO: What about parent styles?
returns the value from the current paragraph style - if available
-----------------------------------------------------------------------*/
uno::Any DomainMapper_Impl::GetPropertyFromStyleSheet(PropertyIds eId)
{
StyleSheetEntryPtr pEntry;
if( m_bInStyleSheetImport )
pEntry = GetStyleSheetTable()->FindParentStyleSheet(OUString());
pEntry = GetStyleSheetTable()->GetCurrentEntry();
else
pEntry = GetStyleSheetTable()->FindStyleSheetByConvertedStyleName(GetCurrentParaStyleName());
while(pEntry.get( ) )
{
//is there a tab stop set?
if(pEntry->pProperties)
{
boost::optional<PropertyMap::Property> aProperty =
......@@ -683,7 +681,7 @@ uno::Any DomainMapper_Impl::GetPropertyFromStyleSheet(PropertyIds eId)
}
}
//search until the property is set or no parent is available
StyleSheetEntryPtr pNewEntry = GetStyleSheetTable()->FindParentStyleSheet(pEntry->sBaseStyleIdentifier);
StyleSheetEntryPtr pNewEntry = GetStyleSheetTable()->FindStyleSheetByISTD(pEntry->sBaseStyleIdentifier);
SAL_WARN_IF( pEntry == pNewEntry, "writerfilter.dmapper", "circular loop in style hierarchy?");
......
......@@ -1280,18 +1280,9 @@ const StyleSheetEntryPtr StyleSheetTable::FindDefaultParaStyle()
return pRet;
}
const StyleSheetEntryPtr StyleSheetTable::FindParentStyleSheet(const OUString& _sBaseStyle)
const StyleSheetEntryPtr StyleSheetTable::GetCurrentEntry()
{
if( _sBaseStyle.isEmpty() )
{
StyleSheetEntryPtr pEmptyPtr;
return pEmptyPtr;
}
OUString sBaseStyle = _sBaseStyle;
if( m_pImpl->m_pCurrentEntry)
sBaseStyle = m_pImpl->m_pCurrentEntry->sBaseStyleIdentifier;
return FindStyleSheetByISTD( sBaseStyle );
return m_pImpl->m_pCurrentEntry;
}
......
......@@ -92,8 +92,6 @@ public:
const StyleSheetEntryPtr FindStyleSheetByISTD(const OUString& sIndex);
const StyleSheetEntryPtr FindStyleSheetByConvertedStyleName(const OUString& rIndex);
const StyleSheetEntryPtr FindDefaultParaStyle();
// returns the parent of the one with the given name - if empty the parent of the current style sheet is returned
const StyleSheetEntryPtr FindParentStyleSheet(const OUString& sBaseStyle);
OUString ConvertStyleName( const OUString& rWWName, bool bExtendedSearch = false );
......@@ -102,6 +100,8 @@ public:
/// Returns the default character properties.
PropertyMapPtr const & GetDefaultCharProps();
const StyleSheetEntryPtr GetCurrentEntry();
private:
// Properties
virtual void lcl_attribute(Id Name, Value & val) override;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment