diff options
-rw-r--r-- | sw/Library_sw_writerfilter.mk | 1 | ||||
-rw-r--r-- | sw/inc/unotxdoc.hxx | 3 | ||||
-rw-r--r-- | sw/source/uibase/uno/SwXDocumentSettings.hxx | 4 | ||||
-rw-r--r-- | sw/source/uibase/uno/unotxdoc.cxx | 7 | ||||
-rw-r--r-- | sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx | 7 | ||||
-rw-r--r-- | sw/source/writerfilter/dmapper/DomainMapper_Impl.hxx | 6 | ||||
-rw-r--r-- | sw/source/writerfilter/dmapper/SettingsTable.cxx | 49 | ||||
-rw-r--r-- | sw/source/writerfilter/dmapper/SettingsTable.hxx | 4 | ||||
-rw-r--r-- | sw/source/writerfilter/filter/WriterFilter.cxx | 4 |
9 files changed, 46 insertions, 39 deletions
diff --git a/sw/Library_sw_writerfilter.mk b/sw/Library_sw_writerfilter.mk index 447752dabd43..3be1a2d937c6 100644 --- a/sw/Library_sw_writerfilter.mk +++ b/sw/Library_sw_writerfilter.mk @@ -20,6 +20,7 @@ $(eval $(call gb_Library_set_precompiled_header,sw_writerfilter,sw/inc/pch/preco $(eval $(call gb_Library_set_include,sw_writerfilter,\ $$(INCLUDE) \ -I$(SRCDIR)/sw/inc \ + -I$(SRCDIR)/sw/source/uibase/uno/ \ -I$(SRCDIR)/sw/source/writerfilter/inc \ -I$(SRCDIR)/sw/source/writerfilter \ )) diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx index 018784174cbb..ab655c6019c4 100644 --- a/sw/inc/unotxdoc.hxx +++ b/sw/inc/unotxdoc.hxx @@ -105,6 +105,7 @@ class SwXLineNumberingProperties; class SwXReferenceMarks; class SwXLinkTargetSupplier; class SwXRedlines; +class SwXDocumentSettings; namespace com::sun::star::container { class XNameContainer; } namespace com::sun::star::frame { class XController; } namespace com::sun::star::lang { struct Locale; } @@ -506,6 +507,8 @@ public: css::uno::Reference< css::uno::XInterface > const & xLastResult); SwDocShell* GetDocShell() {return m_pDocShell;} + + SW_DLLPUBLIC rtl::Reference<SwXDocumentSettings> createDocumentSettings(); }; class SwXLinkTargetSupplier final : public cppu::WeakImplHelper diff --git a/sw/source/uibase/uno/SwXDocumentSettings.hxx b/sw/source/uibase/uno/SwXDocumentSettings.hxx index 3d722e40ba80..067e2e8fbc1b 100644 --- a/sw/source/uibase/uno/SwXDocumentSettings.hxx +++ b/sw/source/uibase/uno/SwXDocumentSettings.hxx @@ -19,7 +19,9 @@ #pragma once +#include <swdllapi.h> #include <comphelper/MasterPropertySet.hxx> +#include <comphelper/MasterPropertySetInfo.hxx> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XTypeProvider.hpp> #include <cppuhelper/weak.hxx> @@ -30,7 +32,7 @@ class SwDocShell; class SwDoc; class SfxPrinter; -class SwXDocumentSettings final : +class SW_DLLPUBLIC SwXDocumentSettings final : public comphelper::MasterPropertySet, public css::lang::XServiceInfo, public css::lang::XTypeProvider, diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index d2641b6c4db4..f93d7438f363 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -1652,6 +1652,13 @@ css::uno::Reference<css::uno::XInterface> SwXTextDocument::create( return xTmp; } +rtl::Reference< SwXDocumentSettings > SwXTextDocument::createDocumentSettings() +{ + SolarMutexGuard aGuard; + ThrowIfInvalid(); + return new SwXDocumentSettings(this); +} + Reference< XInterface > SwXTextDocument::createInstance(const OUString& rServiceName) { return create(rServiceName, nullptr); diff --git a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx index aab27ef1a4bc..c9f8e4d2b077 100644 --- a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx +++ b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx @@ -132,6 +132,7 @@ #include <unicode/errorcode.h> #include <unicode/regex.h> #include <unotxdoc.hxx> +#include <SwXDocumentSettings.hxx> #define REFFLDFLAG_STYLE_FROM_BOTTOM 0xc100 #define REFFLDFLAG_STYLE_HIDE_NON_NUMERICAL 0xc200 @@ -523,11 +524,11 @@ uno::Reference< text::XText > const & DomainMapper_Impl::GetBodyText() } -uno::Reference< beans::XPropertySet > const & DomainMapper_Impl::GetDocumentSettings() +rtl::Reference<SwXDocumentSettings> const & DomainMapper_Impl::GetDocumentSettings() { if( !m_xDocumentSettings.is() && m_xTextDocument.is()) { - m_xDocumentSettings.set( m_xTextDocument->createInstance("com.sun.star.document.Settings"), uno::UNO_QUERY ); + m_xDocumentSettings = m_xTextDocument->createDocumentSettings(); } return m_xDocumentSettings; } @@ -9592,7 +9593,7 @@ void DomainMapper_Impl::ApplySettingsTable() m_xTextDocument->setViewData(xBox); } - uno::Reference< beans::XPropertySet > xSettings(m_xTextDocument->createInstance("com.sun.star.document.Settings"), uno::UNO_QUERY); + rtl::Reference<SwXDocumentSettings> xSettings(m_xTextDocument->createDocumentSettings()); if (m_pSettingsTable->GetDoNotExpandShiftReturn()) xSettings->setPropertyValue( "DoNotJustifyLinesWithManualBreak", uno::Any(true) ); diff --git a/sw/source/writerfilter/dmapper/DomainMapper_Impl.hxx b/sw/source/writerfilter/dmapper/DomainMapper_Impl.hxx index 76a861564d62..6ad54a050505 100644 --- a/sw/source/writerfilter/dmapper/DomainMapper_Impl.hxx +++ b/sw/source/writerfilter/dmapper/DomainMapper_Impl.hxx @@ -56,7 +56,7 @@ #include <map> class SwXTextDocument; - +class SwXDocumentSettings; namespace com::sun::star{ namespace awt{ struct Size; @@ -535,7 +535,7 @@ private: writerfilter::ooxml::OOXMLDocument* m_pOOXMLDocument; OUString m_aBaseUrl; rtl::Reference<SwXTextDocument> m_xTextDocument; - css::uno::Reference<css::beans::XPropertySet> m_xDocumentSettings; + rtl::Reference<SwXDocumentSettings> m_xDocumentSettings; css::uno::Reference<css::uno::XComponentContext> m_xComponentContext; css::uno::Reference<css::container::XNameContainer> m_xPageStyles1; // cache next available number, expensive to repeatedly compute @@ -670,7 +670,7 @@ private: void SetNumberFormat(const OUString& rCommand, css::uno::Reference<css::beans::XPropertySet> const& xPropertySet, bool bDetectFormat = false); /// @throws css::uno::Exception css::uno::Reference<css::beans::XPropertySet> FindOrCreateFieldMaster(const char* pFieldMasterService, const OUString& rFieldMasterName); - css::uno::Reference<css::beans::XPropertySet> const & GetDocumentSettings(); + rtl::Reference<SwXDocumentSettings> const & GetDocumentSettings(); SmartTagHandler m_aSmartTagHandler; diff --git a/sw/source/writerfilter/dmapper/SettingsTable.cxx b/sw/source/writerfilter/dmapper/SettingsTable.cxx index a665a01c7209..61db2bb03e18 100644 --- a/sw/source/writerfilter/dmapper/SettingsTable.cxx +++ b/sw/source/writerfilter/dmapper/SettingsTable.cxx @@ -43,6 +43,8 @@ #include "ConversionHelper.hxx" #include "DomainMapper.hxx" #include "util.hxx" +#include <SwXDocumentSettings.hxx> +#include <unotxdoc.hxx> using namespace com::sun::star; @@ -587,11 +589,11 @@ static bool lcl_isDefault(const uno::Reference<beans::XPropertyState>& xProperty return xPropertyState->getPropertyState(rPropertyName) == beans::PropertyState_DEFAULT_VALUE; } -void SettingsTable::ApplyProperties(uno::Reference<text::XTextDocument> const& xDoc) +void SettingsTable::ApplyProperties(rtl::Reference<SwXTextDocument> const& xDoc) { - uno::Reference< beans::XPropertySet> xDocProps( xDoc, uno::UNO_QUERY ); - uno::Reference<lang::XMultiServiceFactory> xTextFactory(xDoc, uno::UNO_QUERY_THROW); - uno::Reference<beans::XPropertySet> xDocumentSettings(xTextFactory->createInstance("com.sun.star.document.Settings"), uno::UNO_QUERY_THROW); + if (!xDoc) + throw uno::RuntimeException(); + rtl::Reference<SwXDocumentSettings> xDocumentSettings(xDoc->createDocumentSettings()); // Shared between DOCX and RTF, unconditional flags. xDocumentSettings->setPropertyValue("TableRowKeep", uno::Any(true)); @@ -604,32 +606,25 @@ void SettingsTable::ApplyProperties(uno::Reference<text::XTextDocument> const& x } // Show changes value - if (xDocProps.is()) - { - bool bHideChanges = !m_pImpl->m_bShowInsDelChanges || !m_pImpl->m_bShowMarkupChanges; - xDocProps->setPropertyValue("ShowChanges", uno::Any( !bHideChanges || m_pImpl->m_bShowFormattingChanges ) ); - } + bool bHideChanges = !m_pImpl->m_bShowInsDelChanges || !m_pImpl->m_bShowMarkupChanges; + xDoc->setPropertyValue("ShowChanges", uno::Any( !bHideChanges || m_pImpl->m_bShowFormattingChanges ) ); // Record changes value - if (xDocProps.is()) + xDoc->setPropertyValue("RecordChanges", uno::Any( m_pImpl->m_bRecordChanges ) ); + // Password protected Record changes + if (m_pImpl->m_bRecordChanges && m_pImpl->m_pDocumentProtection->getRedlineProtection() + && m_pImpl->m_pDocumentProtection->getEnforcement()) { - xDocProps->setPropertyValue("RecordChanges", uno::Any( m_pImpl->m_bRecordChanges ) ); - // Password protected Record changes - if (m_pImpl->m_bRecordChanges && m_pImpl->m_pDocumentProtection->getRedlineProtection() - && m_pImpl->m_pDocumentProtection->getEnforcement()) - { - // use dummy protection key to forbid disabling of Record changes without a notice - // (extending the recent GrabBag support) TODO support password verification... - css::uno::Sequence<sal_Int8> aDummyKey { 1 }; - xDocProps->setPropertyValue("RedlineProtectionKey", uno::Any( aDummyKey )); - } + // use dummy protection key to forbid disabling of Record changes without a notice + // (extending the recent GrabBag support) TODO support password verification... + css::uno::Sequence<sal_Int8> aDummyKey { 1 }; + xDoc->setPropertyValue("RedlineProtectionKey", uno::Any( aDummyKey )); } // Create or overwrite DocVars based on found in settings if (m_pImpl->m_aDocVars.size()) { - uno::Reference< text::XTextFieldsSupplier > xFieldsSupplier(xDoc, uno::UNO_QUERY_THROW); - uno::Reference< container::XNameAccess > xFieldMasterAccess = xFieldsSupplier->getTextFieldMasters(); + uno::Reference< container::XNameAccess > xFieldMasterAccess = xDoc->getTextFieldMasters(); for (const auto& docVar : m_pImpl->m_aDocVars) { uno::Reference< beans::XPropertySet > xMaster; @@ -642,10 +637,10 @@ void SettingsTable::ApplyProperties(uno::Reference<text::XTextDocument> const& x } else { - xMaster.set(xTextFactory->createInstance("com.sun.star.text.FieldMaster.User"), uno::UNO_QUERY_THROW); + xMaster.set(xDoc->createInstance("com.sun.star.text.FieldMaster.User"), uno::UNO_QUERY_THROW); xMaster->setPropertyValue(getPropertyName(PROP_NAME), uno::Any(docVar.first)); uno::Reference<text::XDependentTextField> xField( - xTextFactory->createInstance("com.sun.star.text.TextField.User"), + xDoc->createInstance("com.sun.star.text.TextField.User"), uno::UNO_QUERY); xField->attachTextFieldMaster(xMaster); } @@ -670,11 +665,7 @@ void SettingsTable::ApplyProperties(uno::Reference<text::XTextDocument> const& x if (!(m_pImpl->m_bAutoHyphenation || m_pImpl->m_bNoHyphenateCaps || m_pImpl->m_bWidowControl)) return; - uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(xDoc, uno::UNO_QUERY); - if (!xStyleFamiliesSupplier.is()) - return; - - uno::Reference<container::XNameAccess> xStyleFamilies = xStyleFamiliesSupplier->getStyleFamilies(); + uno::Reference<container::XNameAccess> xStyleFamilies = xDoc->getStyleFamilies(); uno::Reference<container::XNameContainer> xParagraphStyles = xStyleFamilies->getByName("ParagraphStyles").get< uno::Reference<container::XNameContainer> >(); uno::Reference<style::XStyle> xDefault = xParagraphStyles->getByName("Standard").get< uno::Reference<style::XStyle> >(); uno::Reference<beans::XPropertyState> xPropertyState(xDefault, uno::UNO_QUERY); diff --git a/sw/source/writerfilter/dmapper/SettingsTable.hxx b/sw/source/writerfilter/dmapper/SettingsTable.hxx index f5ccb1bec96e..7512a0cc25b9 100644 --- a/sw/source/writerfilter/dmapper/SettingsTable.hxx +++ b/sw/source/writerfilter/dmapper/SettingsTable.hxx @@ -21,8 +21,10 @@ #include "LoggedResources.hxx" #include <com/sun/star/text/XTextDocument.hpp> +#include <rtl/ref.hxx> #include <memory> +class SwXTextDocument; namespace com::sun::star::lang { class XMultiServiceFactory; @@ -89,7 +91,7 @@ public: css::uno::Sequence<css::beans::PropertyValue> GetWriteProtectionSettings() const; - void ApplyProperties(css::uno::Reference<css::text::XTextDocument> const& xDoc); + void ApplyProperties(rtl::Reference<SwXTextDocument> const& xDoc); std::pair<bool, bool> GetCompatSettingHasAndValue(std::u16string_view sCompatName) const; sal_Int32 GetWordCompatibilityMode() const; diff --git a/sw/source/writerfilter/filter/WriterFilter.cxx b/sw/source/writerfilter/filter/WriterFilter.cxx index edb20f0c7f47..7aee1060ac39 100644 --- a/sw/source/writerfilter/filter/WriterFilter.cxx +++ b/sw/source/writerfilter/filter/WriterFilter.cxx @@ -46,6 +46,7 @@ #include <comphelper/diagnose_ex.hxx> #include <comphelper/scopeguard.hxx> #include <unotxdoc.hxx> +#include <SwXDocumentSettings.hxx> using namespace ::com::sun::star; @@ -301,8 +302,7 @@ void WriterFilter::setTargetDocument(const uno::Reference<lang::XComponent>& xDo // Set some compatibility options that are valid for the DOCX format uno::Reference<lang::XMultiServiceFactory> xFactory(xDoc, uno::UNO_QUERY); - uno::Reference<beans::XPropertySet> xSettings( - xFactory->createInstance("com.sun.star.document.Settings"), uno::UNO_QUERY); + rtl::Reference<SwXDocumentSettings> xSettings = m_xDstDoc->createDocumentSettings(); xSettings->setPropertyValue("UseOldNumbering", uno::Any(false)); xSettings->setPropertyValue("IgnoreFirstLineIndentInNumbering", uno::Any(false)); |