summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2024-04-25 16:26:59 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2024-05-01 09:09:07 +0200
commited015246b9b27e1ea1f87bc125262850d7128c0f (patch)
tree70e2096a138a4b7dbd75d93db9642429f334460f /sw/source
parentc85c534befc1a68f405fc2ad508ae9363d7ebb91 (diff)
use more concrete UNO classes in writerfilter (SwXStyle)
Change-Id: Ic1eb574efa2e4ce57185670d6570f24d1d8c9bb3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166936 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/uibase/uno/unotxdoc.cxx14
-rw-r--r--sw/source/writerfilter/dmapper/StyleSheetTable.cxx20
2 files changed, 24 insertions, 10 deletions
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index d9debd315fab..156f9aabad1f 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -1729,6 +1729,20 @@ rtl::Reference< SwXStyle > SwXTextDocument::createNumberingStyle()
return SwXStyleFamilies::CreateStyleCharOrParaOrPseudo(SfxStyleFamily::Pseudo, GetDocOrThrow());
}
+rtl::Reference< SwXStyle > SwXTextDocument::createCharacterStyle()
+{
+ SolarMutexGuard aGuard;
+ ThrowIfInvalid();
+ return SwXStyleFamilies::CreateStyleCharOrParaOrPseudo(SfxStyleFamily::Char, GetDocOrThrow());
+}
+
+rtl::Reference< SwXStyle > SwXTextDocument::createParagraphStyle()
+{
+ SolarMutexGuard aGuard;
+ ThrowIfInvalid();
+ return SwXStyleFamilies::CreateStyleCharOrParaOrPseudo(SfxStyleFamily::Para, GetDocOrThrow());
+}
+
rtl::Reference< SwXPageStyle > SwXTextDocument::createPageStyle()
{
SolarMutexGuard aGuard;
diff --git a/sw/source/writerfilter/dmapper/StyleSheetTable.cxx b/sw/source/writerfilter/dmapper/StyleSheetTable.cxx
index 6fb1b60c6d91..51bb40ddbc8c 100644
--- a/sw/source/writerfilter/dmapper/StyleSheetTable.cxx
+++ b/sw/source/writerfilter/dmapper/StyleSheetTable.cxx
@@ -53,6 +53,7 @@
#include <comphelper/diagnose_ex.hxx>
#include <o3tl/sorted_vector.hxx>
#include <unotxdoc.hxx>
+#include <unoxstyle.hxx>
#include <SwXTextDefaults.hxx>
using namespace ::com::sun::star;
@@ -1153,11 +1154,12 @@ void StyleSheetTable::ApplyStyleSheetsImpl(const FontTablePtr& rFontTable, std::
else
{
bInsert = true;
- xStyle.set(m_pImpl->m_xTextDocument->createInstance(
- bParaStyle ?
- getPropertyName( PROP_SERVICE_PARA_STYLE ) :
- (bListStyle ? OUString("com.sun.star.style.NumberingStyle") : getPropertyName( PROP_SERVICE_CHAR_STYLE ))),
- uno::UNO_QUERY_THROW);
+ if (bParaStyle)
+ xStyle = m_pImpl->m_xTextDocument->createParagraphStyle();
+ else if (bListStyle)
+ xStyle = m_pImpl->m_xTextDocument->createNumberingStyle();
+ else
+ xStyle = m_pImpl->m_xTextDocument->createCharacterStyle();
// Numbering styles have to be inserted early, as e.g. the NumberingRules property is only available after insertion.
if (bListStyle)
@@ -1799,21 +1801,19 @@ OUString StyleSheetTable::getOrCreateCharStyle( PropertyValueVector_t& rCharProp
throw uno::RuntimeException();
try
{
- uno::Reference< style::XStyle > xStyle( m_pImpl->m_xTextDocument->createInstance(
- getPropertyName( PROP_SERVICE_CHAR_STYLE )), uno::UNO_QUERY_THROW);
- uno::Reference< beans::XPropertySet > xStyleProps(xStyle, uno::UNO_QUERY_THROW );
+ rtl::Reference< SwXStyle > xStyle = m_pImpl->m_xTextDocument->createCharacterStyle();
for( const auto& rCharProp : rCharProperties)
{
try
{
- xStyleProps->setPropertyValue( rCharProp.Name, rCharProp.Value );
+ xStyle->setPropertyValue( rCharProp.Name, rCharProp.Value );
}
catch( const uno::Exception& )
{
TOOLS_WARN_EXCEPTION( "writerfilter", "StyleSheetTable::getOrCreateCharStyle - Style::setPropertyValue");
}
}
- xCharStyles->insertByName( sListLabel, uno::Any( xStyle) );
+ xCharStyles->insertByName( sListLabel, uno::Any( uno::Reference<style::XStyle>(xStyle) ) );
m_pImpl->m_aListCharStylePropertyVector.emplace_back( sListLabel, std::vector(rCharProperties) );
}
catch( const uno::Exception& )