summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/qa/extras/ooxmlimport/data/tdf98882.docxbin0 -> 18390 bytes
-rw-r--r--sw/qa/extras/ooxmlimport/ooxmlimport.cxx8
-rw-r--r--writerfilter/source/dmapper/StyleSheetTable.cxx72
3 files changed, 53 insertions, 27 deletions
diff --git a/sw/qa/extras/ooxmlimport/data/tdf98882.docx b/sw/qa/extras/ooxmlimport/data/tdf98882.docx
new file mode 100644
index 000000000000..53c1098dc78a
--- /dev/null
+++ b/sw/qa/extras/ooxmlimport/data/tdf98882.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index c280b5487048..a5b5cac303e7 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -2909,6 +2909,14 @@ DECLARE_OOXMLIMPORT_TEST(testTdf95213, "tdf95213.docx")
CPPUNIT_ASSERT_EQUAL(awt::FontWeight::NORMAL, getProperty<float>(xStyle, "CharWeight"));
}
+DECLARE_OOXMLIMPORT_TEST(testTdf98882, "tdf98882.docx")
+{
+ sal_Int32 nFlyHeight = parseDump("//fly/infos/bounds", "height").toInt32();
+ sal_Int32 nContentHeight = parseDump("//notxt/infos/bounds", "height").toInt32();
+ // The content height was 600, not 360, so the frame and the content height did not match.
+ CPPUNIT_ASSERT_EQUAL(nFlyHeight, nContentHeight);
+}
+
#endif
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx b/writerfilter/source/dmapper/StyleSheetTable.cxx
index f7e632d72490..017f11479848 100644
--- a/writerfilter/source/dmapper/StyleSheetTable.cxx
+++ b/writerfilter/source/dmapper/StyleSheetTable.cxx
@@ -304,6 +304,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);
};
@@ -378,6 +380,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,
@@ -961,32 +992,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
{
@@ -1514,12 +1522,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& )
{