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

in numbering use "GraphicBitmap" property for image transport

Change-Id: I43abef3fe4a177f9f7867fe86e18beac812c626b
Reviewed-on: https://gerrit.libreoffice.org/49923Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarTomaž Vajngerl <quikee@gmail.com>
üst 82ab7a15
......@@ -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;
}
}
......
......@@ -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);
......
......@@ -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&)
......
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