[Libreoffice-commits] core.git: writerfilter/source

Tomaž Vajngerl tomaz.vajngerl at collabora.co.uk
Thu Mar 8 11:57:46 UTC 2018


 writerfilter/source/rtftok/rtfdocumentimpl.cxx |   45 ++++++++-----------------
 1 file changed, 16 insertions(+), 29 deletions(-)

New commits:
commit 060b0fb4b93ee09770ed9398cca46e365dda5be8
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Thu Mar 8 16:37:46 2018 +0900

    change RTFDocumentImpl to use Graphic instead of GraphicURL
    
    Change-Id: I4d2f7dd540651a54e4da3dedf315a61a4f8a75cc
    Reviewed-on: https://gerrit.libreoffice.org/50924
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

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.


More information about the Libreoffice-commits mailing list