[Libreoffice-commits] core.git: Branch 'libreoffice-5-1' - filter/source sd/CppunitTest_sd_import_tests.mk sd/qa
Mike Kaganski
mike.kaganski at collabora.com
Fri May 6 09:01:28 UTC 2016
filter/source/msfilter/svdfppt.cxx | 54 +++++++++++++++++--------------------
sd/CppunitTest_sd_import_tests.mk | 1
sd/qa/unit/data/ppt/tdf93124.ppt |binary
sd/qa/unit/import-tests.cxx | 51 ++++++++++++++++++++++++++++++++++
4 files changed, 78 insertions(+), 28 deletions(-)
New commits:
commit ac2732bdc63fa687909fdf03e2a91081003f109e
Author: Mike Kaganski <mike.kaganski at collabora.com>
Date: Wed Apr 13 20:07:52 2016 +1000
tdf#93124: Fix incorrect text fit in imported PPT - take two
This patch just fixes incorrect decision when the block alignment must
be applied.
Also, unit test is included.
Reviewed-on: https://gerrit.libreoffice.org/24648
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
(cherry picked from commit 940b21a87cffffca0985c33e9ebb78ddf3aa0c3b)
Change-Id: I458184778c5e9e115d1a4eac749ecb6991b227a8
Reviewed-on: https://gerrit.libreoffice.org/24678
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx
index f9d14e8..127e779 100644
--- a/filter/source/msfilter/svdfppt.cxx
+++ b/filter/source/msfilter/svdfppt.cxx
@@ -889,7 +889,6 @@ SdrObject* SdrEscherImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, voi
eTHA = SDRTEXTHORZADJUST_LEFT;
break;
}
- // if there is a 100% use of following attributes, the textbox can been aligned also in vertical direction
switch ( eTextAnchor )
{
case mso_anchorTopCentered :
@@ -899,20 +898,20 @@ SdrObject* SdrEscherImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, voi
case mso_anchorBottomCenteredBaseline:
{
// check if it is sensible to use the centered alignment
- sal_uInt32 nMask = PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT;
- if ( ( nTextFlags & nMask ) != nMask ) // if the textobject has left and also right aligned pararagraphs
- eTVA = SDRTEXTVERTADJUST_CENTER; // the text has to be displayed using the full width;
- }
- break;
-
- default :
- {
- if ( nTextFlags == PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT )
- eTVA = SDRTEXTVERTADJUST_TOP;
- else if ( nTextFlags == PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT )
- eTVA = SDRTEXTVERTADJUST_BOTTOM;
+ const sal_uInt32 nMask = PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_CENTER | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_BLOCK;
+ switch (nTextFlags & nMask)
+ {
+ case PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT:
+ case PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_CENTER:
+ case PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT:
+ case PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_BLOCK:
+ eTVA = SDRTEXTVERTADJUST_CENTER; // If the textobject has only one type of alignment, then the text has not to be displayed using the full width;
+ break;
+ }
+ break;
}
- break;
+ default:
+ break;
}
nMinFrameWidth = rTextRect.GetWidth() - ( nTextLeft + nTextRight );
}
@@ -945,7 +944,6 @@ SdrObject* SdrEscherImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, voi
eTVA = SDRTEXTVERTADJUST_BOTTOM;
break;
}
- // if there is a 100% usage of following attributes, the textbox can be aligned also in horizontal direction
switch ( eTextAnchor )
{
case mso_anchorTopCentered :
@@ -955,20 +953,20 @@ SdrObject* SdrEscherImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, voi
case mso_anchorBottomCenteredBaseline:
{
// check if it is sensible to use the centered alignment
- sal_uInt32 nMask = PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT;
- if ( ( nTextFlags & nMask ) != nMask ) // if the textobject has left and also right aligned pararagraphs
- eTHA = SDRTEXTHORZADJUST_CENTER; // the text has to be displayed using the full width;
- }
- break;
-
- default :
- {
- if ( nTextFlags == PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT )
- eTHA = SDRTEXTHORZADJUST_LEFT;
- else if ( nTextFlags == PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT )
- eTHA = SDRTEXTHORZADJUST_RIGHT;
+ const sal_uInt32 nMask = PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_CENTER | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_BLOCK;
+ switch (nTextFlags & nMask)
+ {
+ case PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT:
+ case PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_CENTER:
+ case PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT:
+ case PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_BLOCK:
+ eTHA = SDRTEXTHORZADJUST_CENTER; // If the textobject has only one type of alignment, then the text has not to be displayed using the full width;
+ break;
+ }
+ break;
}
- break;
+ default:
+ break;
}
nMinFrameHeight = rTextRect.GetHeight() - ( nTextTop + nTextBottom );
}
diff --git a/sd/CppunitTest_sd_import_tests.mk b/sd/CppunitTest_sd_import_tests.mk
index 6058e8e..33a7ad2 100644
--- a/sd/CppunitTest_sd_import_tests.mk
+++ b/sd/CppunitTest_sd_import_tests.mk
@@ -96,6 +96,7 @@ $(eval $(call gb_CppunitTest_use_components,sd_import_tests,\
sot/util/sot \
svl/source/fsstor/fsstorage \
svtools/util/svt \
+ svx/util/svxcore \
toolkit/util/tk \
ucb/source/core/ucb1 \
ucb/source/ucp/expand/ucpexpand1 \
diff --git a/sd/qa/unit/data/ppt/tdf93124.ppt b/sd/qa/unit/data/ppt/tdf93124.ppt
new file mode 100644
index 0000000..fad8478
Binary files /dev/null and b/sd/qa/unit/data/ppt/tdf93124.ppt differ
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index 4ae4e4e..2f74f13 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -41,6 +41,7 @@
#include <sax/tools/converter.hxx>
#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
+#include <com/sun/star/drawing/GraphicExportFilter.hpp>
#include <com/sun/star/drawing/XDrawPage.hpp>
#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
#include <com/sun/star/animations/XAnimationNodeSupplier.hpp>
@@ -61,6 +62,9 @@
#include <com/sun/star/table/XTableRows.hpp>
#include <stlpool.hxx>
+#include <comphelper/processfactory.hxx>
+#include <vcl/pngread.hxx>
+#include <vcl/bmpacc.hxx>
using namespace ::com::sun::star;
@@ -107,6 +111,7 @@ public:
void testRowHeight();
void testTdf93830();
void testTdf93097();
+ void testTdf93124();
CPPUNIT_TEST_SUITE(SdImportTest);
@@ -149,6 +154,7 @@ public:
CPPUNIT_TEST(testRowHeight);
CPPUNIT_TEST(testTdf93830);
CPPUNIT_TEST(testTdf93097);
+ CPPUNIT_TEST(testTdf93124);
CPPUNIT_TEST_SUITE_END();
};
@@ -1165,6 +1171,51 @@ void SdImportTest::testTdf93097()
xDocShRef->DoClose();
}
+void SdImportTest::testTdf93124()
+{
+ sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/ppt/tdf93124.ppt"), PPT);
+ uno::Reference < uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
+ uno::Reference< drawing::XGraphicExportFilter > xGraphicExporter = drawing::GraphicExportFilter::create(xContext);
+
+ uno::Sequence< beans::PropertyValue > aFilterData(2);
+ aFilterData[0].Name = "PixelWidth";
+ aFilterData[0].Value <<= (sal_Int32)(320);
+ aFilterData[1].Name = "PixelHeight";
+ aFilterData[1].Value <<= (sal_Int32)(180);
+
+ utl::TempFile aTempFile;
+ aTempFile.EnableKillingFile();
+
+ uno::Sequence< beans::PropertyValue > aDescriptor(3);
+ aDescriptor[0].Name = "URL";
+ aDescriptor[0].Value <<= aTempFile.GetURL();
+ aDescriptor[1].Name = "FilterName";
+ aDescriptor[1].Value <<= OUString("PNG");
+ aDescriptor[2].Name = "FilterData";
+ aDescriptor[2].Value <<= aFilterData;
+
+ uno::Reference< lang::XComponent > xPage(getPage(0, xDocShRef), uno::UNO_QUERY);
+ xGraphicExporter->setSourceDocument(xPage);
+ xGraphicExporter->filter(aDescriptor);
+
+ SvFileStream aFileStream(aTempFile.GetURL(), StreamMode::READ);
+ vcl::PNGReader aPNGReader(aFileStream);
+ BitmapEx aBMPEx = aPNGReader.Read();
+ Bitmap aBMP = aBMPEx.GetBitmap();
+ BitmapReadAccess* pRead = aBMP.AcquireReadAccess();
+ int nNonWhiteCount = 0;
+ // The word "Top" should be in rectangle 34,4 - 76,30. If text alignment is wrong, the rectangle will be white.
+ for (long nX = 34; nX < (34 + 43); ++nX)
+ for (long nY = 4; nY < (4 + 26); ++nY)
+ {
+ const Color aColor = pRead->GetColor(nY, nX);
+ if ((aColor.GetRed() != 0xff) || (aColor.GetGreen() != 0xff) || (aColor.GetBlue() != 0xff))
+ ++nNonWhiteCount;
+ }
+ CPPUNIT_ASSERT_MESSAGE("Tdf93124: vertical alignment of text is incorrect!", nNonWhiteCount>100);
+ xDocShRef->DoClose();
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTest);
CPPUNIT_PLUGIN_IMPLEMENT();
More information about the Libreoffice-commits
mailing list