diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-04-04 12:26:11 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-04-04 13:33:41 +0000 |
commit | e0f9bb795251d950b5dd960fcd030170c8eb67aa (patch) | |
tree | dd635a714a93a32de40242be77f99821ec596512 | |
parent | ac8c392dc42534adf1dcfe23c9c850b05124f7a6 (diff) |
tdf#99074 DOCX import: handle <w:view w:val="web"/>
Instead of always using the Normal view, use the Web view when the DOCX
file contains Web Layout.
For this to work, expose sw's DocumentSettingId::BROWSE_MODE via
css.document.Settings.
Change-Id: I7787ca058d8cb8a346b2001a2bd70c3df86d8673
Reviewed-on: https://gerrit.libreoffice.org/23806
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
-rw-r--r-- | sw/qa/extras/ooxmlimport/data/tdf99074.docx | bin | 0 -> 12608 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 8 | ||||
-rw-r--r-- | sw/source/uibase/uno/SwXDocumentSettings.cxx | 16 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.cxx | 4 |
4 files changed, 28 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlimport/data/tdf99074.docx b/sw/qa/extras/ooxmlimport/data/tdf99074.docx Binary files differnew file mode 100644 index 000000000000..d7be418fb153 --- /dev/null +++ b/sw/qa/extras/ooxmlimport/data/tdf99074.docx diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index 39b5efb5ca2a..25008a343229 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -3216,6 +3216,14 @@ DECLARE_OOXMLIMPORT_TEST(testTdf98882, "tdf98882.docx") CPPUNIT_ASSERT_EQUAL(nFlyHeight, nContentHeight); } +DECLARE_OOXMLIMPORT_TEST(testTdf99074, "tdf99074.docx") +{ + uno::Reference<lang::XMultiServiceFactory> xFactory(mxComponent, uno::UNO_QUERY); + uno::Reference<uno::XInterface> xSettings = xFactory->createInstance("com.sun.star.document.Settings"); + // This was false, Web Layout was ignored on import. + CPPUNIT_ASSERT(getProperty<bool>(xSettings, "InBrowseMode")); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/uno/SwXDocumentSettings.cxx b/sw/source/uibase/uno/SwXDocumentSettings.cxx index 0ef134d0a09b..d5168c179adc 100644 --- a/sw/source/uibase/uno/SwXDocumentSettings.cxx +++ b/sw/source/uibase/uno/SwXDocumentSettings.cxx @@ -131,6 +131,7 @@ enum SwDocumentSettingsPropertyHandles HANDLE_APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING, HANDLE_PROP_LINE_SPACING_SHRINKS_FIRST_LINE, HANDLE_SUBTRACT_FLYS, + HANDLE_BROWSE_MODE, }; static MasterPropertySetInfo * lcl_createSettingsInfo() @@ -205,6 +206,7 @@ static MasterPropertySetInfo * lcl_createSettingsInfo() { OUString("ApplyParagraphMarkFormatToNumbering"), HANDLE_APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING, cppu::UnoType<bool>::get(), 0}, { OUString("PropLineSpacingShrinksFirstLine"), HANDLE_PROP_LINE_SPACING_SHRINKS_FIRST_LINE, cppu::UnoType<bool>::get(), 0}, { OUString("SubtractFlysAnchoredAtFlys"), HANDLE_SUBTRACT_FLYS, cppu::UnoType<bool>::get(), 0}, + { OUString("InBrowseMode"), HANDLE_BROWSE_MODE, cppu::UnoType<bool>::get(), 0}, /* * As OS said, we don't have a view when we need to set this, so I have to * find another solution before adding them to this property set - MTG @@ -844,6 +846,15 @@ void SwXDocumentSettings::_setSingleValue( const comphelper::PropertyInfo & rInf } } break; + case HANDLE_BROWSE_MODE: + { + bool bTmp; + if (rValue >>= bTmp) + { + mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::BROWSE_MODE, bTmp); + } + } + break; default: throw UnknownPropertyException(); } @@ -1248,6 +1259,11 @@ void SwXDocumentSettings::_getSingleValue( const comphelper::PropertyInfo & rInf rValue <<= mpDoc->getIDocumentSettingAccess().get(DocumentSettingId::SUBTRACT_FLYS); } break; + case HANDLE_BROWSE_MODE: + { + rValue <<= mpDoc->getIDocumentSettingAccess().get(DocumentSettingId::BROWSE_MODE); + } + break; default: throw UnknownPropertyException(); } diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index bfa18c4175f3..8eee3596aa8c 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -5028,6 +5028,10 @@ void DomainMapper_Impl::ApplySettingsTable() if( m_pSettingsTable->GetEmbedSystemFonts()) xSettings->setPropertyValue( getPropertyName( PROP_EMBED_SYSTEM_FONTS ), uno::makeAny(true) ); xSettings->setPropertyValue("AddParaTableSpacing", uno::makeAny(m_pSettingsTable->GetDoNotUseHTMLParagraphAutoSpacing())); + + // Web Layout. + if (m_pSettingsTable->GetView() == NS_ooxml::LN_Value_doc_ST_View_web) + xSettings->setPropertyValue("InBrowseMode", uno::makeAny(true)); } catch(const uno::Exception&) { |