Kaydet (Commit) 14e163b0 authored tarafından Miklos Vajna's avatar Miklos Vajna

import RTF_BACKGROUND

That destination contains a whole shape, but the only interesing detail
of it is the fill color, which is the page background color.

Change-Id: I9527db8954c48c980f8734c9bbeaa6ccd3c48fbc
üst 9edaf808
{\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
}
......@@ -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();
......
......@@ -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)
{
}
......
......@@ -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;
......
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment