desktop/source/lib/init.cxx | 49 ++++++++++++++++++++++++++++++++++++++----- oox/source/export/shapes.cxx | 3 +- 2 files changed, 46 insertions(+), 6 deletions(-)
New commits: commit e36e716e877c707c991db7bad87724c4a20af27c Author: Paul Trojahn <paul.troj...@gmail.com> Date: Sat Jun 24 13:46:46 2017 +0200 Fix PageShape export to pptx The export code is not called, because the PageShape is actually of type presentation.PageShape and not drawing.PageShape. A PageShape has no text at all, which results in an empty p:txBody element that fails validation, so it needs to be checked first if the shape actually has text. Change-Id: I559f15c2396739c74d5c4f36eb952754bc040ce8 Reviewed-on: https://gerrit.libreoffice.org/38574 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Thorsten Behrens <thorsten.behr...@cib.de> Reviewed-on: https://gerrit.libreoffice.org/42002 Reviewed-by: Jan Holesovsky <ke...@collabora.com> Tested-by: Jan Holesovsky <ke...@collabora.com> (cherry picked from commit 9d43654080fcc5942610f57cbfec9827b9da2102) Reviewed-on: https://gerrit.libreoffice.org/42018 diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx index 7bd85a8cd39f..1d4f4a20a217 100644 --- a/oox/source/export/shapes.cxx +++ b/oox/source/export/shapes.cxx @@ -1448,7 +1448,8 @@ ShapeExport& ShapeExport::WriteTextBox( const Reference< XInterface >& xIface, s } } - if( NonEmptyText( xIface ) ) + Reference< XText > xXText( xIface, UNO_QUERY ); + if( NonEmptyText( xIface ) && xXText.is() ) { FSHelperPtr pFS = GetFS(); commit 24f04330cd789349ced8e7beeb6b007ec0d2d834 Author: Marco Cecchetti <marco.cecche...@collabora.com> Date: Sun Sep 3 20:29:05 2017 +0200 lok - support for watermark Extends doc_renderFont in order to generate text of requested size. Change-Id: I0ebd48f8714b7772b764f3aba3e13754869c5117 Reviewed-on: https://gerrit.libreoffice.org/42015 Reviewed-by: Jan Holesovsky <ke...@collabora.com> Tested-by: Jan Holesovsky <ke...@collabora.com> (cherry picked from commit 8d2c21e31220540af83665b5e8ad2d9b66be6b3e) Reviewed-on: https://gerrit.libreoffice.org/42019 diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 9d9749469420..f146a050d336 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -2880,6 +2880,8 @@ unsigned char* doc_renderFont(LibreOfficeKitDocument* /*pThis*/, pDocSh->GetItem(SID_ATTR_CHAR_FONTLIST)); const FontList* pList = pFonts ? pFonts->GetFontList() : nullptr; + const int nDefaultFontSize = 25; + if ( pList ) { sal_uInt16 nFontCount = pList->GetFontNameCount(); @@ -2898,30 +2900,67 @@ unsigned char* doc_renderFont(LibreOfficeKitDocument* /*pThis*/, nullptr, Size(1, 1), DeviceFormat::DEFAULT)); ::Rectangle aRect; vcl::Font aFont(rFontMetric); - aFont.SetFontSize(Size(0, 25)); + aFont.SetFontSize(Size(0, nDefaultFontSize)); aDevice->SetFont(aFont); aDevice->GetTextBoundRect(aRect, aText); if (aRect.IsEmpty()) break; int nFontWidth = aRect.BottomRight().X() + 1; - *pFontWidth = nFontWidth; int nFontHeight = aRect.BottomRight().Y() + 1; - *pFontHeight = nFontHeight; + if (!(nFontWidth > 0 && nFontHeight > 0)) break; + if (*pFontWidth > 0 && *pFontHeight > 0) + { + double fScaleX = *pFontWidth / static_cast<double>(nFontWidth); + double fScaleY = *pFontHeight / static_cast<double>(nFontHeight); + + double fScale = std::min(fScaleX, fScaleY); + + if (fScale >= 1.0) + { + int nFontSize = fScale * nDefaultFontSize; + aFont.SetFontSize(Size(0, nFontSize)); + aDevice->SetFont(aFont); + } + + aRect = tools::Rectangle(0, 0, *pFontWidth, *pFontHeight); + + nFontWidth = *pFontWidth; + nFontHeight = *pFontHeight; + + } + unsigned char* pBuffer = static_cast<unsigned char*>(malloc(4 * nFontWidth * nFontHeight)); if (!pBuffer) break; memset(pBuffer, 0, nFontWidth * nFontHeight * 4); - aDevice->SetBackground(Wallpaper(COL_TRANSPARENT)); aDevice->SetOutputSizePixelScaleOffsetAndBuffer( Size(nFontWidth, nFontHeight), Fraction(1.0), Point(), pBuffer); - aDevice->DrawText(Point(0,0), aText); + + if (*pFontWidth > 0 && *pFontHeight > 0) + { + DrawTextFlags nStyle = + DrawTextFlags::Center + | DrawTextFlags::VCenter + | DrawTextFlags::MultiLine + | DrawTextFlags::WordBreakHyphenation;// | DrawTextFlags::WordBreak ; + + aDevice->DrawText(aRect, aText, nStyle); + } + else + { + *pFontWidth = nFontWidth; + *pFontHeight = nFontHeight; + + aDevice->DrawText(Point(0,0), aText); + } + return pBuffer; } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits