From 8ba44dd1abbe31c1235f3b840bf27a61c3401236 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 14 Mar 2012 17:12:35 +0100 Subject: n#751020 implement DOCX import of linked styles This is just initial support: the default template and paragraph properties are included. --- writerfilter/source/dmapper/DomainMapper_Impl.cxx | 12 ++++++++++++ writerfilter/source/dmapper/SettingsTable.cxx | 10 ++++++++++ writerfilter/source/dmapper/SettingsTable.hxx | 3 +++ writerfilter/source/ooxml/model.xml | 5 +++++ 4 files changed, 30 insertions(+) (limited to 'writerfilter') diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 066416e495ea..2f0dd2bcf7f1 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -41,6 +41,8 @@ #include #include #include +#include +#include #include #include #include @@ -3504,6 +3506,16 @@ void DomainMapper_Impl::ApplySettingsTable() m_xTextFactory->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.Defaults"))), uno::UNO_QUERY_THROW ); sal_Int32 nDefTab = m_pSettingsTable->GetDefaultTabStop(); xTextDefaults->setPropertyValue( PropertyNameSupplier::GetPropertyNameSupplier().GetName( PROP_TAB_STOP_DISTANCE ), uno::makeAny(nDefTab) ); + if (m_pSettingsTable->GetLinkStyles()) + { + PropertyNameSupplier& rSupplier = PropertyNameSupplier::GetPropertyNameSupplier(); + // If linked styles are enabled, set paragraph defaults from Word's default template + xTextDefaults->setPropertyValue(rSupplier.GetName(PROP_PARA_BOTTOM_MARGIN), uno::makeAny(ConversionHelper::convertTwipToMM100(200))); + style::LineSpacing aSpacing; + aSpacing.Mode = style::LineSpacingMode::PROP; + aSpacing.Height = sal_Int16(115); + xTextDefaults->setPropertyValue(rSupplier.GetName(PROP_PARA_LINE_SPACING), uno::makeAny(aSpacing)); + } } catch(const uno::Exception& ) { diff --git a/writerfilter/source/dmapper/SettingsTable.cxx b/writerfilter/source/dmapper/SettingsTable.cxx index 87b6f9ebb9d7..6e336171eb1b 100644 --- a/writerfilter/source/dmapper/SettingsTable.cxx +++ b/writerfilter/source/dmapper/SettingsTable.cxx @@ -75,6 +75,7 @@ struct SettingsTable_Impl ::rtl::OUString m_sCryptProviderTypeExtSource; ::rtl::OUString m_sHash; ::rtl::OUString m_sSalt; + bool m_bLinkStyles; SettingsTable_Impl( DomainMapper& rDMapper, const uno::Reference< lang::XMultiServiceFactory > xTextFactory ) : m_rDMapper( rDMapper ) @@ -91,6 +92,7 @@ struct SettingsTable_Impl , m_nCryptAlgorithmClass(NS_ooxml::LN_Value_wordprocessingml_ST_AlgClass_hash) , m_nCryptAlgorithmType(NS_ooxml::LN_Value_wordprocessingml_ST_AlgType_typeAny) , m_nCryptSpinCount(0) + , m_bLinkStyles(false) {} }; @@ -162,6 +164,9 @@ void SettingsTable::lcl_sprm(Sprm& rSprm) case NS_ooxml::LN_CT_Settings_defaultTabStop: // 92505; m_pImpl->m_nDefaultTabStop = nIntValue; break; + case NS_ooxml::LN_CT_Settings_linkStyles: // 92663; + m_pImpl->m_bLinkStyles = nIntValue; + break; case NS_ooxml::LN_CT_Settings_noPunctuationKerning: // 92526; m_pImpl->m_bNoPunctuationKerning = nIntValue ? true : false; break; @@ -217,6 +222,11 @@ int SettingsTable::GetDefaultTabStop() const return ConversionHelper::convertTwipToMM100( m_pImpl->m_nDefaultTabStop ); } +bool SettingsTable::GetLinkStyles() const +{ + return m_pImpl->m_bLinkStyles; +} + void SettingsTable::ApplyProperties( uno::Reference< text::XTextDocument > xDoc ) { uno::Reference< beans::XPropertySet> xDocProps( xDoc, uno::UNO_QUERY ); diff --git a/writerfilter/source/dmapper/SettingsTable.hxx b/writerfilter/source/dmapper/SettingsTable.hxx index 2b50d5112ee1..79e095a12b3c 100644 --- a/writerfilter/source/dmapper/SettingsTable.hxx +++ b/writerfilter/source/dmapper/SettingsTable.hxx @@ -64,6 +64,9 @@ class WRITERFILTER_DLLPRIVATE SettingsTable : public LoggedProperties, public Lo //returns default TabStop in 1/100th mm int GetDefaultTabStop() const; + /// Automatically update styles from document template? + bool GetLinkStyles() const; + void ApplyProperties( uno::Reference< text::XTextDocument > xDoc ); private: diff --git a/writerfilter/source/ooxml/model.xml b/writerfilter/source/ooxml/model.xml index 4dc8c49d2bdb..98f35a15dfb4 100644 --- a/writerfilter/source/ooxml/model.xml +++ b/writerfilter/source/ooxml/model.xml @@ -19063,6 +19063,11 @@ + + + + + -- cgit v1.2.3