diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2018-03-08 16:37:46 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2018-03-08 12:57:19 +0100 |
commit | 060b0fb4b93ee09770ed9398cca46e365dda5be8 (patch) | |
tree | 599f2ab222e8d1d230c57bb103bd6839830ca496 | |
parent | dfee7d93b4e863d673c45921f79bb876b5738ea6 (diff) |
change RTFDocumentImpl to use Graphic instead of GraphicURL
Change-Id: I4d2f7dd540651a54e4da3dedf315a61a4f8a75cc
Reviewed-on: https://gerrit.libreoffice.org/50924
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
-rw-r--r-- | writerfilter/source/rtftok/rtfdocumentimpl.cxx | 45 |
1 files changed, 16 insertions, 29 deletions
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index a499234f1d80..c5d603bd1fa4 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -840,27 +840,24 @@ void RTFDocumentImpl::resolvePict(bool const bInline, uno::Reference<drawing::XS uno::UNO_QUERY); if (xServiceInfo.is() && xServiceInfo->supportsService("com.sun.star.text.TextFrame")) pExtHeader = nullptr; - OUString aGraphicUrl = m_pGraphicHelper->importGraphicObject(xInputStream, pExtHeader); + + uno::Reference<graphic::XGraphic> xGraphic; + xGraphic = m_pGraphicHelper->importGraphic(xInputStream, pExtHeader); if (m_aStates.top().aPicture.eStyle != RTFBmpStyle::NONE) { // In case of PNG/JPEG, the real size is known, don't use the values // provided by picw and pich. - OString aURLBS(OUStringToOString(aGraphicUrl, RTL_TEXTENCODING_UTF8)); - const char aURLBegin[] = "vnd.sun.star.GraphicObject:"; - if (aURLBS.startsWith(aURLBegin)) - { - Graphic aGraphic = GraphicObject(aURLBS.copy(RTL_CONSTASCII_LENGTH(aURLBegin))) - .GetTransformedGraphic(); - Size aSize(aGraphic.GetPrefSize()); - MapMode aMap(MapUnit::Map100thMM); - if (aGraphic.GetPrefMapMode().GetMapUnit() == MapUnit::MapPixel) - aSize = Application::GetDefaultDevice()->PixelToLogic(aSize, aMap); - else - aSize = OutputDevice::LogicToLogic(aSize, aGraphic.GetPrefMapMode(), aMap); - m_aStates.top().aPicture.nWidth = aSize.Width(); - m_aStates.top().aPicture.nHeight = aSize.Height(); - } + + Graphic aGraphic(xGraphic); + Size aSize(aGraphic.GetPrefSize()); + MapMode aMap(MapUnit::Map100thMM); + if (aGraphic.GetPrefMapMode().GetMapUnit() == MapUnit::MapPixel) + aSize = Application::GetDefaultDevice()->PixelToLogic(aSize, aMap); + else + aSize = OutputDevice::LogicToLogic(aSize, aGraphic.GetPrefMapMode(), aMap); + m_aStates.top().aPicture.nWidth = aSize.Width(); + m_aStates.top().aPicture.nHeight = aSize.Height(); } // Wrap it in an XShape. @@ -895,20 +892,13 @@ void RTFDocumentImpl::resolvePict(bool const bInline, uno::Reference<drawing::XS uno::Reference<beans::XPropertySet> xPropertySet(xShape, uno::UNO_QUERY); + if (xPropertySet.is()) + xPropertySet->setPropertyValue("Graphic", uno::Any(xGraphic)); + // check if the picture is in an OLE object and if the \objdata element is used // (see RTF_OBJECT in RTFDocumentImpl::dispatchDestination) if (m_bObject) { - // Set bitmap - beans::PropertyValues aMediaProperties(1); - aMediaProperties[0].Name = "URL"; - aMediaProperties[0].Value <<= aGraphicUrl; - uno::Reference<graphic::XGraphicProvider> xGraphicProvider( - graphic::GraphicProvider::create(m_xContext)); - uno::Reference<graphic::XGraphic> xGraphic - = xGraphicProvider->queryGraphic(aMediaProperties); - xPropertySet->setPropertyValue("Graphic", uno::Any(xGraphic)); - // Set the object size awt::Size aSize; aSize.Width = (m_aStates.top().aPicture.nGoalWidth ? m_aStates.top().aPicture.nGoalWidth @@ -926,9 +916,6 @@ void RTFDocumentImpl::resolvePict(bool const bInline, uno::Reference<drawing::XS return; } - if (xPropertySet.is()) - xPropertySet->setPropertyValue("GraphicURL", uno::Any(aGraphicUrl)); - if (m_aStates.top().bInListpicture) { // Send the shape directly, no section is started, to additional properties will be ignored anyway. |