summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-03-29 14:03:00 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-03-29 13:26:57 +0000
commiteae2331f83bd58bacccd898d60f6c5f54856c036 (patch)
treef73e187dfc7d8673b15a0bee475ccdb98270a85c /writerfilter
parentdde79dd5044f6b5d6d9973f8f335956bfcb6fb4c (diff)
tdf#98882 DOCX import: set default para properties on the Standard para style
That's what the DOC import does, and that's the reason e.g. the strange unwanted crop of the as-char anchored picture doesn't happen there. This also needs the "reset all existing style properties back to default" logic to be adapted: the Standard style has to be reset before the default are set, and later it should be left alone, otherwise the defaults are lost. Change-Id: Ie422a0b64b80a826fa4f469145a26283fb32d734 Reviewed-on: https://gerrit.libreoffice.org/23593 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/dmapper/StyleSheetTable.cxx72
1 files changed, 45 insertions, 27 deletions
diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx b/writerfilter/source/dmapper/StyleSheetTable.cxx
index 8a6aca5c04b4..3f29ecb9ed84 100644
--- a/writerfilter/source/dmapper/StyleSheetTable.cxx
+++ b/writerfilter/source/dmapper/StyleSheetTable.cxx
@@ -275,6 +275,8 @@ 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& rValue);
+ /// Sets all properties of xStyle back to default.
+ void SetPropertiesToDefault(const uno::Reference<style::XStyle>& xStyle);
};
@@ -349,6 +351,35 @@ void StyleSheetTable_Impl::AppendLatentStyleProperty(const OUString& aName, Valu
m_pCurrentEntry->aLatentStyles.push_back(aValue);
}
+void StyleSheetTable_Impl::SetPropertiesToDefault(const uno::Reference<style::XStyle>& 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::Sequence<beans::Property> aProperties = xPropertySetInfo->getProperties();
+ std::vector<OUString> aPropertyNames;
+ for (sal_Int32 i = 0; i < aProperties.getLength(); ++i)
+ {
+ aPropertyNames.push_back(aProperties[i].Name);
+ }
+
+ uno::Reference<beans::XPropertyState> xPropertyState(xStyle, uno::UNO_QUERY);
+ uno::Sequence<beans::PropertyState> aStates = xPropertyState->getPropertyStates(comphelper::containerToSequence(aPropertyNames));
+ for (sal_Int32 i = 0; i < aStates.getLength(); ++i)
+ {
+ if (aStates[i] == beans::PropertyState_DIRECT_VALUE)
+ {
+ try
+ {
+ xPropertyState->setPropertyToDefault(aPropertyNames[i]);
+ }
+ catch(const uno::Exception& rException)
+ {
+ SAL_INFO("writerfilter", "setPropertyToDefault(" << aPropertyNames[i] << ") failed: " << rException.Message);
+ }
+ }
+ }
+}
StyleSheetTable::StyleSheetTable(DomainMapper& rDMapper,
uno::Reference< text::XTextDocument> const& xTextDocument,
@@ -909,32 +940,9 @@ void StyleSheetTable::ApplyStyleSheets( FontTablePtr rFontTable )
}
xStyles->getByName( sConvertedStyleName ) >>= 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::Sequence<beans::Property> aProperties = xPropertySetInfo->getProperties();
- std::vector<OUString> aPropertyNames;
- for (sal_Int32 i = 0; i < aProperties.getLength(); ++i)
- {
- aPropertyNames.push_back(aProperties[i].Name);
- }
-
- uno::Reference<beans::XPropertyState> xPropertyState(xStyle, uno::UNO_QUERY);
- uno::Sequence<beans::PropertyState> aStates = xPropertyState->getPropertyStates(comphelper::containerToSequence(aPropertyNames));
- for (sal_Int32 i = 0; i < aStates.getLength(); ++i)
- {
- if (aStates[i] == beans::PropertyState_DIRECT_VALUE)
- {
- try
- {
- xPropertyState->setPropertyToDefault(aPropertyNames[i]);
- }
- catch(const uno::Exception& rException)
- {
- SAL_INFO("writerfilter", "setPropertyToDefault(" << aPropertyNames[i] << ") failed: " << rException.Message);
- }
- }
- }
+ // Standard is handled already in applyDefaults().
+ if (sConvertedStyleName != "Standard")
+ m_pImpl->SetPropertiesToDefault(xStyle);
}
else
{
@@ -1462,12 +1470,22 @@ void StyleSheetTable::applyDefaults(bool bParaProperties)
}
if( bParaProperties && m_pImpl->m_pDefaultParaProps.get())
{
+ uno::Reference<style::XStyleFamiliesSupplier> xStylesSupplier(m_pImpl->m_xTextDocument, uno::UNO_QUERY);
+ uno::Reference<container::XNameAccess> xStyleFamilies = xStylesSupplier->getStyleFamilies();
+ uno::Reference<container::XNameAccess> xParagraphStyles;
+ xStyleFamilies->getByName("ParagraphStyles") >>= xParagraphStyles;
+ uno::Reference<beans::XPropertySet> xStandard;
+ xParagraphStyles->getByName("Standard") >>= xStandard;
+
+ uno::Reference<style::XStyle> xStyle(xStandard, uno::UNO_QUERY);
+ m_pImpl->SetPropertiesToDefault(xStyle);
+
uno::Sequence< beans::PropertyValue > aPropValues = m_pImpl->m_pDefaultParaProps->GetPropertyValues();
for( sal_Int32 i = 0; i < aPropValues.getLength(); ++i )
{
try
{
- m_pImpl->m_xTextDefaults->setPropertyValue( aPropValues[i].Name, aPropValues[i].Value );
+ xStandard->setPropertyValue(aPropValues[i].Name, aPropValues[i].Value);
}
catch( const uno::Exception& )
{