diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2024-08-09 12:38:54 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-08-09 17:31:11 +0200 |
commit | 1e8ace631fb8518cea3fdf94b54e73616d7229c5 (patch) | |
tree | d6f5c8b39ea919b9ba76c853f9ff0766cff992cd /sw | |
parent | a32457632ffc236a7505c7ef9d5c6433482577a9 (diff) |
use more concrete UNO type in writerfilter
Change-Id: I22b22eebdbff24389e1a4aecb5a089904483207e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171690
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/writerfilter/dmapper/PropertyMap.cxx | 33 | ||||
-rw-r--r-- | sw/source/writerfilter/dmapper/PropertyMap.hxx | 6 | ||||
-rw-r--r-- | sw/source/writerfilter/dmapper/StyleSheetTable.cxx | 10 |
3 files changed, 22 insertions, 27 deletions
diff --git a/sw/source/writerfilter/dmapper/PropertyMap.cxx b/sw/source/writerfilter/dmapper/PropertyMap.cxx index 99db7cc7522c..7a3611bd6624 100644 --- a/sw/source/writerfilter/dmapper/PropertyMap.cxx +++ b/sw/source/writerfilter/dmapper/PropertyMap.cxx @@ -713,7 +713,7 @@ table::ShadowFormat PropertyMap::getShadowFromBorder( const table::BorderLine2& return aFormat; } -void SectionPropertyMap::SetBorderDistance( const uno::Reference< beans::XPropertySet >& xStyle, +void SectionPropertyMap::SetBorderDistance( const rtl::Reference<SwXPageStyle>& xStyle, PropertyIds eMarginId, PropertyIds eDistId, sal_Int32 nDistance, @@ -751,10 +751,9 @@ void SectionPropertyMap::SetBorderDistance( const uno::Reference< beans::XProper } // Change the margins with the border distance - uno::Reference< beans::XMultiPropertySet > xMultiSet( xStyle, uno::UNO_QUERY_THROW ); uno::Sequence<OUString> aProperties { sMarginName, sBorderDistanceName }; uno::Sequence<uno::Any> aValues { uno::Any( nMargin ), uno::Any( nDistance ) }; - xMultiSet->setPropertyValues( aProperties, aValues ); + xStyle->setPropertyValues( aProperties, aValues ); } void SectionPropertyMap::DontBalanceTextColumns() @@ -770,7 +769,7 @@ void SectionPropertyMap::DontBalanceTextColumns() } } -void SectionPropertyMap::ApplySectionProperties( const uno::Reference< beans::XPropertySet >& xSection, DomainMapper_Impl& rDM_Impl ) +void SectionPropertyMap::ApplySectionProperties( const rtl::Reference< SwXTextSection >& xSection, DomainMapper_Impl& rDM_Impl ) { try { @@ -2038,10 +2037,10 @@ public: } -void SectionPropertyMap::ApplyProperties_( const uno::Reference< beans::XPropertySet >& xStyle ) +void SectionPropertyMap::ApplyProperties_( const rtl::Reference<SwXPageStyle>& xStyle ) { - uno::Reference< beans::XMultiPropertySet > const xMultiSet( xStyle, uno::UNO_QUERY ); - + if ( !xStyle.is() ) + return; std::vector< OUString > vNames; std::vector< uno::Any > vValues; { @@ -2079,24 +2078,20 @@ void SectionPropertyMap::ApplyProperties_( const uno::Reference< beans::XPropert vValues.push_back( v.Value ); } } - if ( xMultiSet.is() ) + try { - try - { - xMultiSet->setPropertyValues( comphelper::containerToSequence( vNames ), comphelper::containerToSequence( vValues ) ); - return; - } - catch ( const uno::Exception& ) - { - TOOLS_WARN_EXCEPTION( "writerfilter", "SectionPropertyMap::ApplyProperties_" ); - } + xStyle->setPropertyValues( comphelper::containerToSequence( vNames ), comphelper::containerToSequence( vValues ) ); + return; + } + catch ( const uno::Exception& ) + { + TOOLS_WARN_EXCEPTION( "writerfilter", "SectionPropertyMap::ApplyProperties_" ); } for ( size_t i = 0; i < vNames.size(); ++i ) { try { - if ( xStyle.is() ) - xStyle->setPropertyValue( vNames[i], vValues[i] ); + xStyle->setPropertyValue( vNames[i], vValues[i] ); } catch ( const uno::Exception& ) { diff --git a/sw/source/writerfilter/dmapper/PropertyMap.hxx b/sw/source/writerfilter/dmapper/PropertyMap.hxx index e03224125859..a70c628c3de0 100644 --- a/sw/source/writerfilter/dmapper/PropertyMap.hxx +++ b/sw/source/writerfilter/dmapper/PropertyMap.hxx @@ -316,12 +316,12 @@ private: bool m_bEvenPageFooterLinkToPrevious = true; bool m_bFirstPageFooterLinkToPrevious = true; - void ApplyProperties_( const css::uno::Reference< css::beans::XPropertySet >& xStyle ); + void ApplyProperties_( const rtl::Reference<SwXPageStyle>& xStyle ); void DontBalanceTextColumns(); /// Apply section-specific properties: only valid to use after PageStyle has been determined by InheritOrFinalizePageStyles - void ApplySectionProperties( const css::uno::Reference< css::beans::XPropertySet >& xSection, DomainMapper_Impl& rDM_Impl ); + void ApplySectionProperties( const rtl::Reference< SwXTextSection >& xSection, DomainMapper_Impl& rDM_Impl ); /// Check if document is protected. If so, ensure a section exists, and apply its protected value. void ApplyProtectionProperties( rtl::Reference<SwXTextSection>& xSection, DomainMapper_Impl& rDM_Impl ); @@ -338,7 +338,7 @@ private: bool HasHeader() const; bool HasFooter() const; - static void SetBorderDistance( const css::uno::Reference< css::beans::XPropertySet >& xStyle, + static void SetBorderDistance( const rtl::Reference<SwXPageStyle>& xStyle, PropertyIds eMarginId, PropertyIds eDistId, sal_Int32 nDistance, diff --git a/sw/source/writerfilter/dmapper/StyleSheetTable.cxx b/sw/source/writerfilter/dmapper/StyleSheetTable.cxx index 03e2de0eda80..f0db6d3fafa7 100644 --- a/sw/source/writerfilter/dmapper/StyleSheetTable.cxx +++ b/sw/source/writerfilter/dmapper/StyleSheetTable.cxx @@ -52,6 +52,7 @@ #include <comphelper/sequence.hxx> #include <comphelper/diagnose_ex.hxx> #include <o3tl/sorted_vector.hxx> +#include <unobasestyle.hxx> #include <unotxdoc.hxx> #include <unoxstyle.hxx> #include <unostyle.hxx> @@ -296,7 +297,7 @@ struct StyleSheetTable_Impl /// Appends the given key-value pair to the list of latent style properties of the current entry. void AppendLatentStyleProperty(const OUString& aName, Value const & rValue); /// Sets all properties of xStyle back to default. - static void SetPropertiesToDefault(const uno::Reference<style::XStyle>& xStyle); + static void SetPropertiesToDefault(const rtl::Reference<SwXBaseStyle>& xStyle); void ApplyClonedTOCStylesToXText(uno::Reference<text::XText> const& xText); }; @@ -359,18 +360,17 @@ void StyleSheetTable_Impl::AppendLatentStyleProperty(const OUString& aName, Valu m_pCurrentEntry->m_aLatentStyles.push_back(aValue); } -void StyleSheetTable_Impl::SetPropertiesToDefault(const uno::Reference<style::XStyle>& xStyle) +void StyleSheetTable_Impl::SetPropertiesToDefault(const rtl::Reference<SwXBaseStyle>& xStyle) { // See if the existing style has any non-default properties. If so, reset them back to default. - uno::Reference<beans::XPropertySet> xPropertySet(xStyle, uno::UNO_QUERY); - uno::Reference<beans::XPropertySetInfo> xPropertySetInfo = xPropertySet->getPropertySetInfo(); + uno::Reference<beans::XPropertySetInfo> xPropertySetInfo = xStyle->getPropertySetInfo(); const uno::Sequence<beans::Property> aProperties = xPropertySetInfo->getProperties(); std::vector<OUString> aPropertyNames; aPropertyNames.reserve(aProperties.getLength()); std::transform(aProperties.begin(), aProperties.end(), std::back_inserter(aPropertyNames), [](const beans::Property& rProp) { return rProp.Name; }); - uno::Reference<beans::XPropertyState> xPropertyState(xStyle, uno::UNO_QUERY); + uno::Reference<beans::XPropertyState> xPropertyState(static_cast<cppu::OWeakObject*>(xStyle.get()), uno::UNO_QUERY); uno::Sequence<beans::PropertyState> aStates = xPropertyState->getPropertyStates(comphelper::containerToSequence(aPropertyNames)); for (sal_Int32 i = 0; i < aStates.getLength(); ++i) { |