diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-10-23 17:09:25 +0200 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2014-11-23 14:30:30 +0100 |
commit | 3cb4a29f12bc02118a7950de419ffcf45fa72c1f (patch) | |
tree | 2d4e7927dad17a7b71846e08aefa4272f1e2e522 /writerfilter | |
parent | d4c3505ea0c41ae9fb6ed640eb59a3734fd4e02b (diff) |
fdo#85179 RTF filter: import image border
Also adjust CppunitTest_sw_htmlexport that implicitly tested that there
is no color around the image.
(cherry picked from commit 01a32b7d074511bed24044dc94e1159aea62722b)
Conflicts:
writerfilter/source/dmapper/GraphicImport.cxx
Change-Id: I8e14dfa7e7be80c4f8c492999071decae6a492e8
Reviewed-on: https://gerrit.libreoffice.org/12092
Reviewed-by: Michael Stahl <mstahl@redhat.com>
Tested-by: Michael Stahl <mstahl@redhat.com>
Diffstat (limited to 'writerfilter')
-rw-r--r-- | writerfilter/source/dmapper/GraphicImport.cxx | 32 | ||||
-rw-r--r-- | writerfilter/source/dmapper/GraphicImport.hxx | 2 |
2 files changed, 26 insertions, 8 deletions
diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx index 4c6890427c9b..f53f7f30d068 100644 --- a/writerfilter/source/dmapper/GraphicImport.cxx +++ b/writerfilter/source/dmapper/GraphicImport.cxx @@ -176,6 +176,11 @@ struct GraphicBorderLine ,bHasShadow(false) {} + bool isEmpty() + { + return nLineWidth == 0 && nLineColor == 0 && bHasShadow == false; + } + }; class GraphicImport_Impl @@ -679,7 +684,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( ); @@ -1089,7 +1094,7 @@ void lcl_CalcCrop( sal_Int32& nCrop, sal_Int32 nRef ) + (((nCrop & 0xffff) * nRef ) >> 16); } -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 @@ -1117,10 +1122,22 @@ uno::Reference< text::XTextContent > GraphicImport::createGraphicObject( const b { if( m_pImpl->eGraphicImportType == IMPORT_AS_GRAPHIC || !nBorder ) { - aBorderLine.Color = m_pImpl->aBorders[m_pImpl->eGraphicImportType == IMPORT_AS_SHAPE ? BORDER_TOP : static_cast<BorderPosition>(nBorder) ].nLineColor; - aBorderLine.InnerLineWidth = 0; - aBorderLine.OuterLineWidth = (sal_Int16)m_pImpl->aBorders[m_pImpl->eGraphicImportType == IMPORT_AS_SHAPE ? BORDER_TOP : static_cast<BorderPosition>(nBorder) ].nLineWidth; - aBorderLine.LineDistance = 0; + GraphicBorderLine& rBorderLine = m_pImpl->aBorders[m_pImpl->eGraphicImportType == IMPORT_AS_SHAPE ? BORDER_TOP : static_cast<BorderPosition>(nBorder)]; + 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 = m_pImpl->aBorders[m_pImpl->eGraphicImportType == IMPORT_AS_SHAPE ? BORDER_TOP : static_cast<BorderPosition>(nBorder) ].nLineColor; + aBorderLine.InnerLineWidth = 0; + aBorderLine.OuterLineWidth = (sal_Int16)m_pImpl->aBorders[m_pImpl->eGraphicImportType == IMPORT_AS_SHAPE ? BORDER_TOP : static_cast<BorderPosition>(nBorder) ].nLineWidth; + aBorderLine.LineDistance = 0; + } } PropertyIds aBorderProps[4] = { @@ -1350,7 +1367,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 ); } diff --git a/writerfilter/source/dmapper/GraphicImport.hxx b/writerfilter/source/dmapper/GraphicImport.hxx index 21612c060de3..dd0d00045fe0 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<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 ); |