fdo#85179 RTF filter: import image border

Also adjust CppunitTest_sw_htmlexport that implicitly tested that there
is no color around the image.

Change-Id: I8e14dfa7e7be80c4f8c492999071decae6a492e8
This commit is contained in:
Miklos Vajna
2014-10-23 17:09:25 +02:00
parent a2b5ead0dc
commit 01a32b7d07
5 changed files with 67 additions and 10 deletions

View File

@@ -122,7 +122,7 @@ DECLARE_HTMLEXPORT_TEST(testExportOfImages, "textAndImage.docx")
CPPUNIT_ASSERT(pDoc);
assertXPath(pDoc, "/html/body", 1);
assertXPath(pDoc, "/html/body/p/img", 1);
assertXPath(pDoc, "/html/body/p/font/img", 1);
}
DECLARE_HTMLEXPORT_TEST(testExportOfImagesWithSkipImageEnabled, "textAndImage.docx")
@@ -131,7 +131,7 @@ DECLARE_HTMLEXPORT_TEST(testExportOfImagesWithSkipImageEnabled, "textAndImage.do
CPPUNIT_ASSERT(pDoc);
assertXPath(pDoc, "/html/body", 1);
assertXPath(pDoc, "/html/body/p/img", 0);
assertXPath(pDoc, "/html/body/p/font/img", 0);
}
DECLARE_HTMLEXPORT_TEST(testSkipImageEmbedded, "skipimage-embedded.doc")

View File

@@ -0,0 +1,33 @@
{\rtf1
\pard\plain
{\*\shppict
{\pict
{\*\picprop\shplid1025
{\sp
{\sn shapeType}
{\sv 75}
}
{\sp
{\sn lineColor}
{\sv 65535}
}
{\sp
{\sn lineWidth}
{\sv 50800}
}
}
\picscalex100\picscaley100\piccropl0\piccropr0\piccropt0\piccropb0\picw1806\pich1806\picwgoal1024\pichgoal1024\pngblip
89504e470d0a1a0a0000000d49484452000000400000004008040000000060b9550000000467414d410000b18f0bfc6105000000017352474200aece1ce90000
00206348524d00007a26000080840000fa00000080e8000075300000ea6000003a98000017709cba513c00000002624b47440000aa8d2332000000096f464673
0000000600000000000c7355d3000000097048597300000dd700000dd70142289b7800000009767041670000004c00000040009d31381b000001cd4944415468
deedd93d4fc24018c0f17f89c6cdc44940e3e222be2c0e7e0417e3a8113571707632514012a320c6f84d34be2c2ec2b750f40be8e6e4a00113cfe14a5b69b108
f4589ee71652eefafce0b9f42e3d7063822aaac3f641d173a75d3efee85b6582c0c8749c5eb7332cfb4e6f213d336ed29807304477b1c7a94db80ae9e9c934d0
fcdd12e7ffcefcc9168f9a0059143b8cb0d2de581f609854073fbecc220f60b18722479d0d14abed8c8cb5d3293ce2949903b0d8a7047cb1c98541008cba840c
a736e1d2200046b967567f740961d3b197008873cf74835002eaac7363100009ca0d4296121675d2dc1a0440d2256428625163ed2f42cf011e8245d621b42c44
0400485261a699706d1000092fa100d4490713220240dc25e438b1090185880ca09f8ece5c28d9843b009e82471ca25069d5cb785529bd007fdbfb8541b65b2f
531100947a51530d42c1d92f9829818e31ca4ce9421c70e427440e80712a7a89b7c8fb0906003046a5311df31cf501a01f4d0ee1b80f00bd4c398558ee0340ff
0b939a30df17002459f05d330a080a0108400002108000042000010840000210800004200001f8ce0ddf798e30dd7b38e0ce7ea16d2abc25a819cbda225337c7
f7ff69bf8eef7f0084e08d42bdf8a03e00000025744558746372656174652d6461746500323031302d31322d32305431373a30383a33362b30313a30307ae51b1c00000025744558746d6f646966792d6461746500323031302d31322d32305431373a30383a33372b30313a30308323669c0000000049454e44ae4260820a}
}
\par
}

View File

@@ -1983,6 +1983,13 @@ DECLARE_RTFIMPORT_TEST(testFdo83464, "fdo83464.rtf")
CPPUNIT_ASSERT_EQUAL(OUString("Verdana"), getProperty<OUString>(getRun(getParagraphOfText(1, xFrameText->getText()), 1), "CharFontName"));
}
DECLARE_RTFIMPORT_TEST(testFdo85179, "fdo85179.rtf")
{
// This was 0, border around the picture was ignored on import.
// 360: EMU -> MM100
CPPUNIT_ASSERT_EQUAL(sal_uInt32(50800/360), getProperty<table::BorderLine2>(getShape(1), "TopBorder").LineWidth);
}
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -179,6 +179,11 @@ struct GraphicBorderLine
,bHasShadow(false)
{}
bool isEmpty()
{
return nLineWidth == 0 && nLineColor == 0 && bHasShadow == false;
}
};
class GraphicImport_Impl
@@ -704,7 +709,7 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue)
// fdo#70457: transform XShape into a SwXTextGraphicObject only if there's no rotation
if ( nRotation == 0 && !bContainsEffects )
m_xGraphicObject = createGraphicObject( aMediaProperties );
m_xGraphicObject = createGraphicObject( aMediaProperties, xShapeProps );
bUseShape = !m_xGraphicObject.is( );
@@ -1131,7 +1136,7 @@ void GraphicImport::lcl_entry(int /*pos*/, writerfilter::Reference<Properties>::
{
}
uno::Reference< text::XTextContent > GraphicImport::createGraphicObject( const beans::PropertyValues& aMediaProperties )
uno::Reference< text::XTextContent > GraphicImport::createGraphicObject( const beans::PropertyValues& aMediaProperties, const uno::Reference<beans::XPropertySet>& xShapeProps )
{
uno::Reference< text::XTextContent > xGraphicObject;
try
@@ -1160,10 +1165,21 @@ uno::Reference< text::XTextContent > GraphicImport::createGraphicObject( const b
if( m_pImpl->eGraphicImportType == IMPORT_AS_GRAPHIC || !nBorder )
{
GraphicBorderLine& rBorderLine = m_pImpl->aBorders[m_pImpl->eGraphicImportType == IMPORT_AS_SHAPE ? BORDER_TOP : static_cast<BorderPosition>(nBorder)];
aBorderLine.Color = rBorderLine.nLineColor;
aBorderLine.InnerLineWidth = 0;
aBorderLine.OuterLineWidth = (sal_Int16)rBorderLine.nLineWidth;
aBorderLine.LineDistance = 0;
if (rBorderLine.isEmpty() && xShapeProps.is())
{
// In case we got no border tokens and we have the
// original shape, then use its line properties as the
// border.
aBorderLine.Color = xShapeProps->getPropertyValue("LineColor").get<sal_Int32>();
aBorderLine.LineWidth = xShapeProps->getPropertyValue("LineWidth").get<sal_Int32>();
}
else
{
aBorderLine.Color = rBorderLine.nLineColor;
aBorderLine.InnerLineWidth = 0;
aBorderLine.OuterLineWidth = (sal_Int16)rBorderLine.nLineWidth;
aBorderLine.LineDistance = 0;
}
}
PropertyIds aBorderProps[4] =
{
@@ -1371,7 +1387,8 @@ void GraphicImport::data(const sal_uInt8* buf, size_t len, writerfilter::Referen
uno::Reference< io::XInputStream > xIStream = new XInputStreamHelper( buf, len, m_pImpl->bIsBitmap );
aMediaProperties[0].Value <<= xIStream;
m_xGraphicObject = createGraphicObject( aMediaProperties );
uno::Reference<beans::XPropertySet> xPropertySet;
m_xGraphicObject = createGraphicObject( aMediaProperties, xPropertySet );
}

View File

@@ -76,7 +76,7 @@ class GraphicImport : public LoggedProperties, public LoggedTable
css::uno::Reference<css::drawing::XShape> m_xShape;
void ProcessShapeOptions(Value & val);
css::uno::Reference<css::text::XTextContent > createGraphicObject(const css::beans::PropertyValues& aMediaProperties );
css::uno::Reference<css::text::XTextContent > createGraphicObject(const css::beans::PropertyValues& aMediaProperties, const css::uno::Reference<css::beans::XPropertySet>& xShapeProps);
void putPropertyToFrameGrabBag( const OUString& sPropertyName, const css::uno::Any& aPropertyValue );