diff options
-rw-r--r-- | sw/qa/extras/rtfimport/data/page-background.rtf | 30 | ||||
-rw-r--r-- | sw/qa/extras/rtfimport/rtfimport.cxx | 9 | ||||
-rw-r--r-- | writerfilter/source/rtftok/rtfdocumentimpl.cxx | 7 | ||||
-rw-r--r-- | writerfilter/source/rtftok/rtfdocumentimpl.hxx | 4 | ||||
-rw-r--r-- | writerfilter/source/rtftok/rtfsdrimport.cxx | 13 |
5 files changed, 62 insertions, 1 deletions
diff --git a/sw/qa/extras/rtfimport/data/page-background.rtf b/sw/qa/extras/rtfimport/data/page-background.rtf new file mode 100644 index 000000000000..e19d2d4c3547 --- /dev/null +++ b/sw/qa/extras/rtfimport/data/page-background.rtf @@ -0,0 +1,30 @@ +{\rtf1\adeflang1025\ansi\ansicpg1252\uc1\adeff31507\deff0\stshfdbch31506\stshfloch31506\stshfhich31506\stshfbi31507\deflang1033\deflangfe1033\themelang1033\themelangfe0\themelangcs0 +\viewbksp1 +{\*\background +{\shp +{\*\shpinst\shpleft0\shptop0\shpright0\shpbottom0\shpfhdr0\shpbxmargin\shpbxignore\shpbymargin\shpbyignore\shpwr0\shpwrk0\shpfblwtxt1 +{\sp +{\sn shapeType} +{\sv 1} +} +{\sp +{\sn fillColor} +{\sv 5296274} +} +{\sp +{\sn fFilled} +{\sv 1} +} +{\sp +{\sn bWMode} +{\sv 9} +} +{\sp +{\sn fBackground} +{\sv 1} +} +} +} +} +\par +} diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx index 5aadfa64b72b..bb0b0145a512 100644 --- a/sw/qa/extras/rtfimport/rtfimport.cxx +++ b/sw/qa/extras/rtfimport/rtfimport.cxx @@ -137,6 +137,7 @@ public: void testFdo62977(); void testN818997(); void testFdo64671(); + void testPageBackground(); CPPUNIT_TEST_SUITE(Test); #if !defined(MACOSX) && !defined(WNT) @@ -263,6 +264,7 @@ void Test::run() {"fdo62977.rtf", &Test::testFdo62977}, {"n818997.rtf", &Test::testN818997}, {"fdo64671.rtf", &Test::testFdo64671}, + {"page-background.rtf", &Test::testPageBackground}, }; header(); for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i) @@ -1248,6 +1250,13 @@ void Test::testFdo64671() getRun(getParagraph(1), 1, OUString("\xC5\xBD", 2, RTL_TEXTENCODING_UTF8)); } +void Test::testPageBackground() +{ + // The problem was that \background was ignored. + uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0x92D050), getProperty<sal_Int32>(xPageStyle, "BackColor")); +} + CPPUNIT_TEST_SUITE_REGISTRATION(Test); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index fcd0ef5db2b1..921f30eb746c 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -1672,6 +1672,10 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword) // Anything inside \ud is just normal Unicode content. m_aStates.top().nDestinationState = DESTINATION_NORMAL; break; + case RTF_BACKGROUND: + m_aStates.top().nDestinationState = DESTINATION_BACKGROUND; + m_aStates.top().bInBackground = true; + break; default: SAL_INFO("writerfilter", "TODO handle destination '" << lcl_RtfToString(nKeyword) << "'"); // Make sure we skip destinations (even without \*) till we don't handle them @@ -4707,7 +4711,8 @@ RTFParserState::RTFParserState(RTFDocumentImpl *pDocumentImpl) nCurrentStyleIndex(-1), pCurrentBuffer(0), bHasTableStyle(false), - bInListpicture(false) + bInListpicture(false), + bInBackground(false) { } diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx index d6216f48ee6d..76752d7e42bf 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx @@ -163,6 +163,7 @@ namespace writerfilter { DESTINATION_MEQARR, DESTINATION_UPR, DESTINATION_LFOLEVEL, + DESTINATION_BACKGROUND, }; enum RTFBorderState @@ -399,6 +400,9 @@ namespace writerfilter { /// If we're inside a \listpicture group. bool bInListpicture; + + /// If we're inside a \background group. + bool bInBackground; }; class RTFTokenizer; diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx index d3bda96929f4..24d7ca1aa6f4 100644 --- a/writerfilter/source/rtftok/rtfsdrimport.cxx +++ b/writerfilter/source/rtftok/rtfsdrimport.cxx @@ -29,6 +29,7 @@ #include <dmapper/DomainMapper.hxx> #include "../dmapper/GraphicHelpers.hxx" #include <rtfsdrimport.hxx> +#include <rtfreferenceproperties.hxx> #include <oox/vml/vmlformatting.hxx> #include <oox/helper/modelobjecthelper.hxx> @@ -526,6 +527,18 @@ void RTFSdrImport::resolve(RTFShape& rShape) } } + if (m_rImport.getState().bInBackground) + { + RTFSprms aAttributes; + aAttributes.set(NS_ooxml::LN_CT_Background_color, RTFValue::Pointer_t(new RTFValue(xPropertySet->getPropertyValue("FillColor").get<sal_Int32>()))); + writerfilter::Reference<Properties>::Pointer_t const pProperties(new RTFReferenceProperties(aAttributes)); + m_rImport.Mapper().props(pProperties); + + uno::Reference<lang::XComponent> xComponent(xShape, uno::UNO_QUERY); + xComponent->dispose(); + return; + } + // Send it to dmapper m_rImport.Mapper().startShape(xShape); m_rImport.replayShapetext(); |