[Libreoffice-commits] core.git: editeng/source oox/source svx/source

Tomaž Vajngerl tomaz.vajngerl at collabora.co.uk
Sun Feb 18 10:48:34 UTC 2018


 editeng/source/uno/unonrule.cxx |   14 +++++-----
 oox/source/export/drawingml.cxx |   51 +++++++++++++++++++++-------------------
 svx/source/xml/xmlxtimp.cxx     |   11 +++++++-
 3 files changed, 44 insertions(+), 32 deletions(-)

New commits:
commit 7273bb3534264867e818c13baffcdf3862189cd2
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Sat Feb 17 18:10:11 2018 +0900

    in numbering use "GraphicBitmap" property for image transport
    
    Change-Id: I43abef3fe4a177f9f7867fe86e18beac812c626b
    Reviewed-on: https://gerrit.libreoffice.org/49923
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

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&)


More information about the Libreoffice-commits mailing list