diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2018-02-17 18:10:11 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2018-02-18 11:48:13 +0100 |
commit | 7273bb3534264867e818c13baffcdf3862189cd2 (patch) | |
tree | 88a90410fe4afa9f487d8854b898fbb6733c3ad7 | |
parent | 82ab7a1559170889c5647a04dc3e85edc38a4e0f (diff) |
in numbering use "GraphicBitmap" property for image transport
Change-Id: I43abef3fe4a177f9f7867fe86e18beac812c626b
Reviewed-on: https://gerrit.libreoffice.org/49923
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
-rw-r--r-- | editeng/source/uno/unonrule.cxx | 14 | ||||
-rw-r--r-- | oox/source/export/drawingml.cxx | 51 | ||||
-rw-r--r-- | svx/source/xml/xmlxtimp.cxx | 11 |
3 files changed, 44 insertions, 32 deletions
diff --git a/editeng/source/uno/unonrule.cxx b/editeng/source/uno/unonrule.cxx index d7364ad35619..50fcd053ebcd 100644 --- a/editeng/source/uno/unonrule.cxx +++ b/editeng/source/uno/unonrule.cxx @@ -220,15 +220,15 @@ Sequence<beans::PropertyValue> SvxUnoNumberingRules::getNumberingRuleByIndex(sal { const SvxBrushItem* pBrush = rFmt.GetBrush(); - if(pBrush && pBrush->GetGraphicObject()) + const Graphic* pGraphic = nullptr; + if (pBrush) + pGraphic = pBrush->GetGraphic(); + if (pGraphic) { - const GraphicObject* pGrafObj = pBrush->GetGraphicObject(); - OUString aURL( UNO_NAME_GRAPHOBJ_URLPREFIX); - aURL += OStringToOUString(pGrafObj->GetUniqueID(), - RTL_TEXTENCODING_ASCII_US); + uno::Reference<awt::XBitmap> xBitmap = VCLUnoHelper::CreateBitmap(pGraphic->GetBitmapEx()); + aVal <<= xBitmap; - aVal <<= aURL; - const beans::PropertyValue aGraphicProp( "GraphicURL", -1, aVal, beans::PropertyState_DIRECT_VALUE); + const beans::PropertyValue aGraphicProp("GraphicBitmap", -1, aVal, beans::PropertyState_DIRECT_VALUE); pArray[nIdx++] = aGraphicProp; } } diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index f71e0879effb..987533e186b2 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -2075,6 +2075,7 @@ void DrawingML::WriteParagraphNumbering(const Reference< XPropertySet >& rXPropS awt::FontDescriptor aFontDesc; bool bHasFontDesc = false; OUString aGraphicURL; + uno::Reference<graphic::XGraphic> xGraphic; sal_Int16 nBulletRelSize = 0; sal_Int16 nStartWith = 1; sal_uInt32 nBulletColor = 0; @@ -2132,6 +2133,11 @@ void DrawingML::WriteParagraphNumbering(const Reference< XPropertySet >& rXPropS { nStartWith = *o3tl::doAccess<sal_Int16>(pPropValue[i].Value); } + else if (aPropName == "GraphicBitmap") + { + auto xBitmap = pPropValue[i].Value.get<uno::Reference<awt::XBitmap>>(); + xGraphic.set(xBitmap, uno::UNO_QUERY); + } else if ( aPropName == "GraphicURL" ) { aGraphicURL = *o3tl::doAccess<OUString>(pPropValue[i].Value); @@ -2147,39 +2153,38 @@ void DrawingML::WriteParagraphNumbering(const Reference< XPropertySet >& rXPropS if (nNumberingType == SVX_NUM_NUMBER_NONE) return; - if( !aGraphicURL.isEmpty() ) + Graphic aGraphic(xGraphic); + if (xGraphic.is() && aGraphic.GetType() != GraphicType::NONE) { long nFirstCharHeightMm = TransformMetric(fFirstCharHeight * 100.f, FUNIT_POINT, FUNIT_MM); float fBulletSizeRel = aGraphicSize.Height / static_cast<float>(nFirstCharHeightMm) / OOX_BULLET_LIST_SCALE_FACTOR; OUString sRelationId; - if(fBulletSizeRel < 1.f) + if (fBulletSizeRel < 1.0f) { // Add padding to get the bullet point centered in PPT - Graphic aGraphic; - if (lcl_URLToGraphic(aGraphicURL, aGraphic)) - { - Size aDestSize(64, 64); - float fBulletSizeRelX = fBulletSizeRel / aGraphicSize.Height * aGraphicSize.Width; - long nPaddingX = std::max<long>(0, std::lround((aDestSize.Width() - fBulletSizeRelX * aDestSize.Width()) / 2.f)); - long nPaddingY = std::lround((aDestSize.Height() - fBulletSizeRel * aDestSize.Height()) / 2.f); - tools::Rectangle aDestRect(nPaddingX, nPaddingY, aDestSize.Width() - nPaddingX, aDestSize.Height() - nPaddingY); - - AlphaMask aMask(aDestSize); - aMask.Erase(255); - BitmapEx aSourceBitmap(aGraphic.GetBitmapEx()); - aSourceBitmap.Scale(aDestRect.GetSize()); - tools::Rectangle aSourceRect(Point(0, 0), aDestRect.GetSize()); - BitmapEx aDestBitmap(Bitmap(aDestSize, 24), aMask); - aDestBitmap.CopyPixel(aDestRect, aSourceRect, &aSourceBitmap); - Graphic aDestGraphic(aDestBitmap); - sRelationId = WriteImage(aDestGraphic); - fBulletSizeRel = 1.f; - } + Size aDestSize(64, 64); + float fBulletSizeRelX = fBulletSizeRel / aGraphicSize.Height * aGraphicSize.Width; + long nPaddingX = std::max<long>(0, std::lround((aDestSize.Width() - fBulletSizeRelX * aDestSize.Width()) / 2.f)); + long nPaddingY = std::lround((aDestSize.Height() - fBulletSizeRel * aDestSize.Height()) / 2.f); + tools::Rectangle aDestRect(nPaddingX, nPaddingY, aDestSize.Width() - nPaddingX, aDestSize.Height() - nPaddingY); + + AlphaMask aMask(aDestSize); + aMask.Erase(255); + BitmapEx aSourceBitmap(aGraphic.GetBitmapEx()); + aSourceBitmap.Scale(aDestRect.GetSize()); + tools::Rectangle aSourceRect(Point(0, 0), aDestRect.GetSize()); + BitmapEx aDestBitmap(Bitmap(aDestSize, 24), aMask); + aDestBitmap.CopyPixel(aDestRect, aSourceRect, &aSourceBitmap); + Graphic aDestGraphic(aDestBitmap); + sRelationId = WriteImage(aDestGraphic); + fBulletSizeRel = 1.0f; } else - sRelationId = WriteImage(aGraphicURL); + { + sRelationId = WriteImage(aGraphic); + } mpFS->singleElementNS( XML_a, XML_buSzPct, XML_val, IS( std::min(static_cast<sal_Int32>(std::lround(100000.f * fBulletSizeRel)), static_cast<sal_Int32>(400000))), FSEND); diff --git a/svx/source/xml/xmlxtimp.cxx b/svx/source/xml/xmlxtimp.cxx index 5cfc80c7ced8..6005a5c0199d 100644 --- a/svx/source/xml/xmlxtimp.cxx +++ b/svx/source/xml/xmlxtimp.cxx @@ -281,8 +281,15 @@ void SvxXMLTableImportContext::importBitmap( const uno::Reference< XAttributeLis if (aGraphicAny.has<uno::Reference<graphic::XGraphic>>()) { auto xGraphic = aGraphicAny.get<uno::Reference<graphic::XGraphic>>(); - uno::Reference<awt::XBitmap> xBitmap(xGraphic, uno::UNO_QUERY_THROW); - rAny <<= xBitmap; + uno::Reference<awt::XBitmap> xBitmap(xGraphic, uno::UNO_QUERY); + if (xBitmap.is()) + rAny <<= xBitmap; + } + else if (aGraphicAny.has<uno::Reference<awt::XBitmap>>()) + { + auto xBitmap = aGraphicAny.get<uno::Reference<awt::XBitmap>>(); + if (xBitmap.is()) + rAny <<= xBitmap; } } catch (const Exception&) |