From 01a32b7d074511bed24044dc94e1159aea62722b Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 23 Oct 2014 17:09:25 +0200 Subject: 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 --- writerfilter/source/dmapper/GraphicImport.cxx | 31 +++++++++++++++++++++------ writerfilter/source/dmapper/GraphicImport.hxx | 2 +- 2 files changed, 25 insertions(+), 8 deletions(-) (limited to 'writerfilter') diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx index 995a7a401069..0b58ddcc16ab 100644 --- a/writerfilter/source/dmapper/GraphicImport.cxx +++ b/writerfilter/source/dmapper/GraphicImport.cxx @@ -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:: { } -uno::Reference< text::XTextContent > GraphicImport::createGraphicObject( const beans::PropertyValues& aMediaProperties ) +uno::Reference< text::XTextContent > GraphicImport::createGraphicObject( const beans::PropertyValues& aMediaProperties, const uno::Reference& 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(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(); + aBorderLine.LineWidth = xShapeProps->getPropertyValue("LineWidth").get(); + } + 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 xPropertySet; + m_xGraphicObject = createGraphicObject( aMediaProperties, xPropertySet ); } diff --git a/writerfilter/source/dmapper/GraphicImport.hxx b/writerfilter/source/dmapper/GraphicImport.hxx index 160e41794f52..5b8e10177c33 100644 --- a/writerfilter/source/dmapper/GraphicImport.hxx +++ b/writerfilter/source/dmapper/GraphicImport.hxx @@ -76,7 +76,7 @@ class GraphicImport : public LoggedProperties, public LoggedTable css::uno::Reference m_xShape; void ProcessShapeOptions(Value & val); - css::uno::Reference createGraphicObject(const css::beans::PropertyValues& aMediaProperties ); + css::uno::Reference createGraphicObject(const css::beans::PropertyValues& aMediaProperties, const css::uno::Reference& xShapeProps); void putPropertyToFrameGrabBag( const OUString& sPropertyName, const css::uno::Any& aPropertyValue ); -- cgit