Kaydet (Commit) 060b0fb4 authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl Kaydeden (comit) Tomaž Vajngerl

change RTFDocumentImpl to use Graphic instead of GraphicURL

Change-Id: I4d2f7dd540651a54e4da3dedf315a61a4f8a75cc
Reviewed-on: https://gerrit.libreoffice.org/50924Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarTomaž Vajngerl <quikee@gmail.com>
üst dfee7d93
...@@ -840,18 +840,16 @@ void RTFDocumentImpl::resolvePict(bool const bInline, uno::Reference<drawing::XS ...@@ -840,18 +840,16 @@ void RTFDocumentImpl::resolvePict(bool const bInline, uno::Reference<drawing::XS
uno::UNO_QUERY); uno::UNO_QUERY);
if (xServiceInfo.is() && xServiceInfo->supportsService("com.sun.star.text.TextFrame")) if (xServiceInfo.is() && xServiceInfo->supportsService("com.sun.star.text.TextFrame"))
pExtHeader = nullptr; 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) if (m_aStates.top().aPicture.eStyle != RTFBmpStyle::NONE)
{ {
// In case of PNG/JPEG, the real size is known, don't use the values // In case of PNG/JPEG, the real size is known, don't use the values
// provided by picw and pich. // provided by picw and pich.
OString aURLBS(OUStringToOString(aGraphicUrl, RTL_TEXTENCODING_UTF8));
const char aURLBegin[] = "vnd.sun.star.GraphicObject:"; Graphic aGraphic(xGraphic);
if (aURLBS.startsWith(aURLBegin))
{
Graphic aGraphic = GraphicObject(aURLBS.copy(RTL_CONSTASCII_LENGTH(aURLBegin)))
.GetTransformedGraphic();
Size aSize(aGraphic.GetPrefSize()); Size aSize(aGraphic.GetPrefSize());
MapMode aMap(MapUnit::Map100thMM); MapMode aMap(MapUnit::Map100thMM);
if (aGraphic.GetPrefMapMode().GetMapUnit() == MapUnit::MapPixel) if (aGraphic.GetPrefMapMode().GetMapUnit() == MapUnit::MapPixel)
...@@ -861,7 +859,6 @@ void RTFDocumentImpl::resolvePict(bool const bInline, uno::Reference<drawing::XS ...@@ -861,7 +859,6 @@ void RTFDocumentImpl::resolvePict(bool const bInline, uno::Reference<drawing::XS
m_aStates.top().aPicture.nWidth = aSize.Width(); m_aStates.top().aPicture.nWidth = aSize.Width();
m_aStates.top().aPicture.nHeight = aSize.Height(); m_aStates.top().aPicture.nHeight = aSize.Height();
} }
}
// Wrap it in an XShape. // Wrap it in an XShape.
uno::Reference<drawing::XShape> xShape(rShape); uno::Reference<drawing::XShape> xShape(rShape);
...@@ -895,20 +892,13 @@ void RTFDocumentImpl::resolvePict(bool const bInline, uno::Reference<drawing::XS ...@@ -895,20 +892,13 @@ void RTFDocumentImpl::resolvePict(bool const bInline, uno::Reference<drawing::XS
uno::Reference<beans::XPropertySet> xPropertySet(xShape, uno::UNO_QUERY); 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 // check if the picture is in an OLE object and if the \objdata element is used
// (see RTF_OBJECT in RTFDocumentImpl::dispatchDestination) // (see RTF_OBJECT in RTFDocumentImpl::dispatchDestination)
if (m_bObject) 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 // Set the object size
awt::Size aSize; awt::Size aSize;
aSize.Width = (m_aStates.top().aPicture.nGoalWidth ? m_aStates.top().aPicture.nGoalWidth 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 ...@@ -926,9 +916,6 @@ void RTFDocumentImpl::resolvePict(bool const bInline, uno::Reference<drawing::XS
return; return;
} }
if (xPropertySet.is())
xPropertySet->setPropertyValue("GraphicURL", uno::Any(aGraphicUrl));
if (m_aStates.top().bInListpicture) if (m_aStates.top().bInListpicture)
{ {
// Send the shape directly, no section is started, to additional properties will be ignored anyway. // Send the shape directly, no section is started, to additional properties will be ignored anyway.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment