2016-06-30 17:12:23 +02:00
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project .
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License , v . 2.0 . If a copy of the MPL was not distributed with this
* file , You can obtain one at http : //mozilla.org/MPL/2.0/.
*/
2020-12-11 17:44:34 +01:00
# include <sal/config.h>
# include <string_view>
2016-06-30 17:12:23 +02:00
# include <officecfg/Office/Common.hxx>
# include "sdmodeltestbase.hxx"
2017-10-23 22:32:55 +02:00
# include <Outliner.hxx>
2019-04-13 15:10:23 +02:00
# include <editeng/eeitem.hxx>
2016-06-30 17:12:23 +02:00
# include <editeng/editobj.hxx>
# include <editeng/outlobj.hxx>
# include <editeng/fhgtitem.hxx>
# include <editeng/escapementitem.hxx>
# include <editeng/colritem.hxx>
# include <editeng/fontitem.hxx>
# include <editeng/wghtitem.hxx>
# include <editeng/numitem.hxx>
# include <editeng/postitem.hxx>
# include <oox/drawingml/drawingmltypes.hxx>
# include <svx/svdoutl.hxx>
# include <svx/svdotext.hxx>
# include <svx/svdoashp.hxx>
# include <svx/svdogrp.hxx>
# include <svx/xflclit.hxx>
2019-06-04 22:49:21 +02:00
# include <svx/xlineit0.hxx>
2019-05-01 22:12:48 +02:00
# include <svx/sdooitm.hxx>
# include <svx/sdmetitm.hxx>
2016-06-30 17:12:23 +02:00
# include <unotools/mediadescriptor.hxx>
# include <rtl/ustring.hxx>
# include <com/sun/star/drawing/XDrawPage.hpp>
# include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
# include <com/sun/star/beans/XPropertySet.hpp>
2019-06-04 22:49:21 +02:00
# include <com/sun/star/awt/Gradient.hpp>
2016-06-30 17:12:23 +02:00
# include <com/sun/star/awt/FontDescriptor.hpp>
# include <com/sun/star/frame/XStorable.hpp>
# include <com/sun/star/drawing/FillStyle.hpp>
2019-09-01 19:26:40 +02:00
# include <com/sun/star/drawing/LineDash.hpp>
2016-06-30 17:12:23 +02:00
# include <com/sun/star/text/WritingMode2.hpp>
# include <com/sun/star/table/BorderLine2.hpp>
# include <com/sun/star/table/XTable.hpp>
# include <com/sun/star/table/XMergeableCell.hpp>
# include <svx/svdotable.hxx>
# include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
2021-01-21 15:08:13 +01:00
# include <rtl/uri.hxx>
# include <vcl/pngread.hxx>
2016-06-30 17:12:23 +02:00
using namespace css ;
2016-07-25 11:47:25 +02:00
class SdOOXMLExportTest1 : public SdModelTestBaseXML
2016-06-30 17:12:23 +02:00
{
public :
2016-06-30 20:52:34 +02:00
void testFdo90607 ( ) ;
2019-09-02 10:29:12 +08:00
void testTdf127237 ( ) ;
2020-10-13 13:26:53 +02:00
void testBnc887230 ( ) ;
2016-06-30 17:12:23 +02:00
void testBnc870233_1 ( ) ;
void testBnc870233_2 ( ) ;
void testN828390_4 ( ) ;
void testN828390_5 ( ) ;
void testFdo71961 ( ) ;
void testN828390 ( ) ;
void testBnc880763 ( ) ;
void testBnc862510_5 ( ) ;
void testBnc822347_EmptyBullet ( ) ;
void testFdo83751 ( ) ;
void testFdo79731 ( ) ;
void testTableCellFillProperties ( ) ;
void testBulletStartNumber ( ) ;
void testLineStyle ( ) ;
void testCellLeftAndRightMargin ( ) ;
void testRightToLeftParaghraph ( ) ;
void testTextboxWithHyperlink ( ) ;
void testMergedCells ( ) ;
void testTableCellBorder ( ) ;
void testBulletColor ( ) ;
void testBulletCharAndFont ( ) ;
void testBulletMarginAndIndentation ( ) ;
void testParaMarginAndindentation ( ) ;
2017-08-31 18:50:16 +02:00
void testTdf111884 ( ) ;
2017-10-12 13:30:47 +02:00
void testTdf112633 ( ) ;
2019-11-22 14:05:24 +03:00
void testTdf128952 ( ) ;
2019-11-27 13:35:29 +03:00
void testTdf127090 ( ) ;
2018-02-26 07:46:09 -05:00
void testCustomXml ( ) ;
2019-02-04 17:34:39 +01:00
void testTdf94238 ( ) ;
2019-05-06 20:52:16 +02:00
void testPictureTransparency ( ) ;
2019-07-01 21:10:01 +02:00
void testTdf125554 ( ) ;
2019-09-01 19:26:40 +02:00
void testRoundtripOwnLineStyles ( ) ;
void testRoundtripPrstDash ( ) ;
void testDashOnHairline ( ) ;
2020-06-10 14:51:04 +02:00
void testCustomshapeBitmapfillSrcrect ( ) ;
2020-07-04 15:11:03 +02:00
void testTdf100348FontworkBitmapFill ( ) ;
void testTdf100348FontworkGradientGlow ( ) ;
2020-07-14 22:52:56 +02:00
void testTdf128345FullTransparentGradient ( ) ;
void testTdf128345GradientLinear ( ) ;
void testTdf128345GradientRadial ( ) ;
void testTdf128345GradientAxial ( ) ;
2020-07-21 15:46:51 +02:00
void testTdf134969TransparencyOnColorGradient ( ) ;
2020-09-21 14:07:44 +08:00
void testTdf136911 ( ) ;
2021-01-06 13:24:10 +01:00
void testArcTo ( ) ;
2021-01-15 15:53:19 +01:00
void testNarrationMimeType ( ) ;
2016-06-30 17:12:23 +02:00
2016-06-30 20:52:34 +02:00
CPPUNIT_TEST_SUITE ( SdOOXMLExportTest1 ) ;
2016-06-30 17:12:23 +02:00
CPPUNIT_TEST ( testFdo90607 ) ;
2019-09-02 10:29:12 +08:00
CPPUNIT_TEST ( testTdf127237 ) ;
2020-10-13 13:26:53 +02:00
CPPUNIT_TEST ( testBnc887230 ) ;
2016-06-30 17:12:23 +02:00
CPPUNIT_TEST ( testBnc870233_1 ) ;
CPPUNIT_TEST ( testBnc870233_2 ) ;
CPPUNIT_TEST ( testN828390_4 ) ;
CPPUNIT_TEST ( testN828390_5 ) ;
CPPUNIT_TEST ( testFdo71961 ) ;
CPPUNIT_TEST ( testN828390 ) ;
CPPUNIT_TEST ( testBnc880763 ) ;
CPPUNIT_TEST ( testBnc862510_5 ) ;
CPPUNIT_TEST ( testBnc822347_EmptyBullet ) ;
CPPUNIT_TEST ( testFdo83751 ) ;
CPPUNIT_TEST ( testFdo79731 ) ;
CPPUNIT_TEST ( testTableCellFillProperties ) ;
CPPUNIT_TEST ( testBulletStartNumber ) ;
CPPUNIT_TEST ( testLineStyle ) ;
CPPUNIT_TEST ( testCellLeftAndRightMargin ) ;
CPPUNIT_TEST ( testRightToLeftParaghraph ) ;
CPPUNIT_TEST ( testTextboxWithHyperlink ) ;
CPPUNIT_TEST ( testMergedCells ) ;
CPPUNIT_TEST ( testTableCellBorder ) ;
CPPUNIT_TEST ( testBulletColor ) ;
CPPUNIT_TEST ( testBulletCharAndFont ) ;
CPPUNIT_TEST ( testBulletMarginAndIndentation ) ;
CPPUNIT_TEST ( testParaMarginAndindentation ) ;
2017-08-31 18:50:16 +02:00
CPPUNIT_TEST ( testTdf111884 ) ;
2017-10-12 13:30:47 +02:00
CPPUNIT_TEST ( testTdf112633 ) ;
2019-11-22 14:05:24 +03:00
CPPUNIT_TEST ( testTdf128952 ) ;
2019-11-27 13:35:29 +03:00
CPPUNIT_TEST ( testTdf127090 ) ;
2018-02-26 07:46:09 -05:00
CPPUNIT_TEST ( testCustomXml ) ;
2019-02-04 17:34:39 +01:00
CPPUNIT_TEST ( testTdf94238 ) ;
2019-07-01 21:10:01 +02:00
CPPUNIT_TEST ( testTdf125554 ) ;
2019-05-06 20:52:16 +02:00
CPPUNIT_TEST ( testPictureTransparency ) ;
2019-09-01 19:26:40 +02:00
CPPUNIT_TEST ( testRoundtripOwnLineStyles ) ;
CPPUNIT_TEST ( testRoundtripPrstDash ) ;
CPPUNIT_TEST ( testDashOnHairline ) ;
2020-06-10 14:51:04 +02:00
CPPUNIT_TEST ( testCustomshapeBitmapfillSrcrect ) ;
2020-07-04 15:11:03 +02:00
CPPUNIT_TEST ( testTdf100348FontworkBitmapFill ) ;
CPPUNIT_TEST ( testTdf100348FontworkGradientGlow ) ;
2020-07-14 22:52:56 +02:00
CPPUNIT_TEST ( testTdf128345FullTransparentGradient ) ;
CPPUNIT_TEST ( testTdf128345GradientLinear ) ;
CPPUNIT_TEST ( testTdf128345GradientRadial ) ;
CPPUNIT_TEST ( testTdf128345GradientAxial ) ;
2020-07-21 15:46:51 +02:00
CPPUNIT_TEST ( testTdf134969TransparencyOnColorGradient ) ;
2020-09-21 14:07:44 +08:00
CPPUNIT_TEST ( testTdf136911 ) ;
2021-01-06 13:24:10 +01:00
CPPUNIT_TEST ( testArcTo ) ;
2021-01-15 15:53:19 +01:00
CPPUNIT_TEST ( testNarrationMimeType ) ;
2016-06-30 17:12:23 +02:00
CPPUNIT_TEST_SUITE_END ( ) ;
virtual void registerNamespaces ( xmlXPathContextPtr & pXmlXPathCtx ) override
{
2018-10-18 09:32:50 +02:00
static const struct { char const * pPrefix ; char const * pURI ; } namespaces [ ] =
2016-06-30 17:12:23 +02:00
{
// OOXML
{ " ContentType " , " http://schemas.openxmlformats.org/package/2006/content-types " } ,
{ " rels " , " http://schemas.openxmlformats.org/package/2006/relationships " } ,
{ " mc " , " http://schemas.openxmlformats.org/markup-compatibility/2006 " } ,
{ " v " , " urn:schemas-microsoft-com:vml " } ,
{ " a " , " http://schemas.openxmlformats.org/drawingml/2006/main " } ,
{ " c " , " http://schemas.openxmlformats.org/drawingml/2006/chart " } ,
{ " m " , " http://schemas.openxmlformats.org/officeDocument/2006/math " } ,
{ " pic " , " http://schemas.openxmlformats.org/drawingml/2006/picture " } ,
{ " wp " , " http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing " } ,
{ " p " , " http://schemas.openxmlformats.org/presentationml/2006/main " } ,
{ " w " , " http://schemas.openxmlformats.org/wordprocessingml/2006/main " } ,
{ " a14 " , " http://schemas.microsoft.com/office/drawing/2010/main " } ,
{ " wps " , " http://schemas.microsoft.com/office/word/2010/wordprocessingShape " } ,
{ " wpg " , " http://schemas.microsoft.com/office/word/2010/wordprocessingGroup " } ,
} ;
for ( size_t i = 0 ; i < SAL_N_ELEMENTS ( namespaces ) ; + + i )
{
xmlXPathRegisterNs ( pXmlXPathCtx ,
reinterpret_cast < xmlChar const * > ( namespaces [ i ] . pPrefix ) ,
reinterpret_cast < xmlChar const * > ( namespaces [ i ] . pURI ) ) ;
}
}
} ;
namespace {
template < typename ItemValue , typename ItemType >
void checkFontAttributes ( const SdrTextObj * pObj , ItemValue nVal )
{
CPPUNIT_ASSERT_MESSAGE ( " no object " , pObj ! = nullptr ) ;
const EditTextObject & aEdit = pObj - > GetOutlinerParaObject ( ) - > GetTextObject ( ) ;
std : : vector < EECharAttrib > rLst ;
aEdit . GetCharAttribs ( 0 , rLst ) ;
for ( std : : vector < EECharAttrib > : : reverse_iterator it = rLst . rbegin ( ) ; it ! = rLst . rend ( ) ; + + it )
{
const ItemType * pAttrib = dynamic_cast < const ItemType * > ( ( * it ) . pAttr ) ;
if ( pAttrib )
{
CPPUNIT_ASSERT_EQUAL ( nVal , static_cast < ItemValue > ( pAttrib - > GetValue ( ) ) ) ;
}
}
}
}
2019-09-02 10:29:12 +08:00
void SdOOXMLExportTest1 : : testTdf127237 ( )
{
2020-12-28 17:56:40 +01:00
sd : : DrawDocShellRef xDocShRef = loadURL ( m_directories . getURLFromSrc ( u " /sd/qa/unit/data/pptx/tdf127237.pptx " ) , PPTX ) ;
2019-09-02 10:29:12 +08:00
xDocShRef = saveAndReload ( xDocShRef . get ( ) , ODP ) ;
const SdrPage * pPage = GetPage ( 1 , xDocShRef ) ;
CPPUNIT_ASSERT ( pPage ! = nullptr ) ;
sdr : : table : : SdrTableObj * pTableObj = dynamic_cast < sdr : : table : : SdrTableObj * > ( pPage - > GetObj ( 0 ) ) ;
CPPUNIT_ASSERT ( pTableObj ! = nullptr ) ;
uno : : Reference < table : : XCellRange > xTable ( pTableObj - > getTable ( ) , uno : : UNO_QUERY_THROW ) ;
sal_Int32 nFillColor = 0 ;
uno : : Reference < beans : : XPropertySet > xCell ( xTable - > getCellByPosition ( 0 , 0 ) , uno : : UNO_QUERY_THROW ) ;
xCell - > getPropertyValue ( " FillColor " ) > > = nFillColor ;
CPPUNIT_ASSERT_EQUAL ( sal_Int32 ( 0x0070C0 ) , nFillColor ) ;
xDocShRef - > DoClose ( ) ;
}
2020-10-13 13:26:53 +02:00
void SdOOXMLExportTest1 : : testBnc887230 ( )
{
2020-12-28 17:56:40 +01:00
: : sd : : DrawDocShellRef xDocShRef = loadURL ( m_directories . getURLFromSrc ( u " /sd/qa/unit/data/pptx/bnc887230.pptx " ) , PPTX ) ;
2020-10-13 13:26:53 +02:00
xDocShRef = saveAndReload ( xDocShRef . get ( ) , PPTX ) ;
const SdrPage * pPage = GetPage ( 1 , xDocShRef ) ;
const SdrTextObj * pObj = dynamic_cast < SdrTextObj * > ( pPage - > GetObj ( 0 ) ) ;
// Without the fix in place, this test would have failed with
//- Expected: 255
//- Actual : 13421823
checkFontAttributes < Color , SvxColorItem > ( pObj , Color ( 0x0000ff ) ) ;
xDocShRef - > DoClose ( ) ;
}
2016-06-30 20:52:34 +02:00
void SdOOXMLExportTest1 : : testBnc870233_1 ( )
2016-06-30 17:12:23 +02:00
{
2020-12-28 17:56:40 +01:00
: : sd : : DrawDocShellRef xDocShRef = loadURL ( m_directories . getURLFromSrc ( u " /sd/qa/unit/data/pptx/bnc870233_1.pptx " ) , PPTX ) ;
2016-10-05 22:00:51 +02:00
xDocShRef = saveAndReload ( xDocShRef . get ( ) , PPTX ) ;
2016-06-30 17:12:23 +02:00
const SdrPage * pPage = GetPage ( 1 , xDocShRef ) ;
// The problem was all shapes had the same font (the last parsed font attributes overwrote all previous ones)
// First shape has red, bold font
{
const SdrTextObj * pObj = dynamic_cast < SdrTextObj * > ( pPage - > GetObj ( 0 ) ) ;
checkFontAttributes < Color , SvxColorItem > ( pObj , Color ( 0xff0000 ) ) ;
checkFontAttributes < FontWeight , SvxWeightItem > ( pObj , WEIGHT_BOLD ) ;
}
// Second shape has blue, italic font
{
const SdrTextObj * pObj = dynamic_cast < SdrTextObj * > ( pPage - > GetObj ( 1 ) ) ;
checkFontAttributes < Color , SvxColorItem > ( pObj , Color ( 0x0000ff ) ) ;
checkFontAttributes < FontItalic , SvxPostureItem > ( pObj , ITALIC_NORMAL ) ;
}
xDocShRef - > DoClose ( ) ;
}
2016-06-30 20:52:34 +02:00
void SdOOXMLExportTest1 : : testBnc870233_2 ( )
2016-06-30 17:12:23 +02:00
{
2020-12-28 17:56:40 +01:00
: : sd : : DrawDocShellRef xDocShRef = loadURL ( m_directories . getURLFromSrc ( u " /sd/qa/unit/data/pptx/bnc870233_2.pptx " ) , PPTX ) ;
2016-10-05 22:00:51 +02:00
xDocShRef = saveAndReload ( xDocShRef . get ( ) , PPTX ) ;
2016-06-30 17:12:23 +02:00
const SdrPage * pPage = GetPage ( 1 , xDocShRef ) ;
// The problem was in some SmartArts font color was wrong
// First smart art has blue font color (direct formatting)
{
2019-03-14 08:25:12 +01:00
const SdrObjGroup * pObjGroup = dynamic_cast < SdrObjGroup * > ( pPage - > GetObj ( 0 ) ) ;
2017-08-31 18:32:58 +02:00
CPPUNIT_ASSERT ( pObjGroup ) ;
const SdrTextObj * pObj = dynamic_cast < SdrTextObj * > ( pObjGroup - > GetSubList ( ) - > GetObj ( 0 ) ) ;
checkFontAttributes < Color , SvxColorItem > ( pObj , Color ( 0x0000ff ) ) ;
2016-06-30 17:12:23 +02:00
}
// Second smart art has "dk2" font color (style)
{
2019-03-14 08:25:12 +01:00
const SdrObjGroup * pObjGroup = dynamic_cast < SdrObjGroup * > ( pPage - > GetObj ( 1 ) ) ;
2017-08-31 18:32:58 +02:00
CPPUNIT_ASSERT ( pObjGroup ) ;
const SdrTextObj * pObj = dynamic_cast < SdrTextObj * > ( pObjGroup - > GetSubList ( ) - > GetObj ( 0 ) ) ;
2016-06-30 17:12:23 +02:00
checkFontAttributes < Color , SvxColorItem > ( pObj , Color ( 0x1F497D ) ) ;
}
// Third smart art has white font color (style)
{
2019-03-14 08:25:12 +01:00
const SdrObjGroup * pObjGroup = dynamic_cast < SdrObjGroup * > ( pPage - > GetObj ( 2 ) ) ;
2017-08-31 18:32:58 +02:00
CPPUNIT_ASSERT ( pObjGroup ) ;
const SdrTextObj * pObj = dynamic_cast < SdrTextObj * > ( pObjGroup - > GetSubList ( ) - > GetObj ( 0 ) ) ;
checkFontAttributes < Color , SvxColorItem > ( pObj , Color ( 0xffffff ) ) ;
2016-06-30 17:12:23 +02:00
}
xDocShRef - > DoClose ( ) ;
}
2016-06-30 20:52:34 +02:00
void SdOOXMLExportTest1 : : testN828390_4 ( )
2016-06-30 17:12:23 +02:00
{
bool bPassed = false ;
2020-12-28 17:56:40 +01:00
: : sd : : DrawDocShellRef xDocShRef = loadURL ( m_directories . getURLFromSrc ( u " /sd/qa/unit/data/n828390_4.odp " ) , ODP ) ;
2016-06-30 17:12:23 +02:00
2016-10-05 22:00:51 +02:00
xDocShRef = saveAndReload ( xDocShRef . get ( ) , PPTX ) ;
2016-06-30 17:12:23 +02:00
const SdrPage * pPage = GetPage ( 1 , xDocShRef ) ;
{
std : : vector < EECharAttrib > rLst ;
SdrObject * pObj = pPage - > GetObj ( 0 ) ;
SdrTextObj * pTxtObj = dynamic_cast < SdrTextObj * > ( pObj ) ;
CPPUNIT_ASSERT ( pTxtObj ) ;
const EditTextObject & aEdit = pTxtObj - > GetOutlinerParaObject ( ) - > GetTextObject ( ) ;
2017-02-15 19:21:06 +02:00
aEdit . GetCharAttribs ( 0 , rLst ) ;
2016-06-30 17:12:23 +02:00
for ( std : : vector < EECharAttrib > : : reverse_iterator it = rLst . rbegin ( ) ; it ! = rLst . rend ( ) ; + + it )
{
const SvxFontHeightItem * pFontHeight = dynamic_cast < const SvxFontHeightItem * > ( ( * it ) . pAttr ) ;
2017-02-15 19:21:06 +02:00
if ( pFontHeight & & ( * it ) . nStart = = 18 )
2016-10-28 09:04:39 +02:00
CPPUNIT_ASSERT_EQUAL_MESSAGE ( " Font height is wrong " , static_cast < sal_uInt32 > ( 1129 ) , pFontHeight - > GetHeight ( ) ) ;
2016-06-30 17:12:23 +02:00
const SvxFontItem * pFont = dynamic_cast < const SvxFontItem * > ( ( * it ) . pAttr ) ;
if ( pFont )
{
2016-10-28 09:04:39 +02:00
CPPUNIT_ASSERT_EQUAL_MESSAGE ( " Font is wrong " , OUString ( " Arial " ) , pFont - > GetFamilyName ( ) ) ;
2016-06-30 17:12:23 +02:00
bPassed = true ;
}
const SvxWeightItem * pWeight = dynamic_cast < const SvxWeightItem * > ( ( * it ) . pAttr ) ;
2017-02-15 19:21:06 +02:00
if ( pWeight & & ( * it ) . nStart = = 18 )
2016-10-28 09:04:39 +02:00
CPPUNIT_ASSERT_EQUAL_MESSAGE ( " Font Weight is wrong " , WEIGHT_BOLD , pWeight - > GetWeight ( ) ) ;
2016-06-30 17:12:23 +02:00
}
}
CPPUNIT_ASSERT ( bPassed ) ;
xDocShRef - > DoClose ( ) ;
}
2016-06-30 20:52:34 +02:00
void SdOOXMLExportTest1 : : testN828390_5 ( )
2016-06-30 17:12:23 +02:00
{
2020-12-28 17:56:40 +01:00
: : sd : : DrawDocShellRef xDocShRef = loadURL ( m_directories . getURLFromSrc ( u " /sd/qa/unit/data/n828390_5.odp " ) , ODP ) ;
2016-06-30 17:12:23 +02:00
2016-10-05 22:00:51 +02:00
xDocShRef = saveAndReload ( xDocShRef . get ( ) , PPTX ) ;
2016-06-30 17:12:23 +02:00
const SdrPage * pPage = GetPage ( 1 , xDocShRef ) ;
{
SdrObject * pObj = pPage - > GetObj ( 0 ) ;
SdrTextObj * pTxtObj = dynamic_cast < SdrTextObj * > ( pObj ) ;
CPPUNIT_ASSERT ( pTxtObj ) ;
const EditTextObject & aEdit = pTxtObj - > GetOutlinerParaObject ( ) - > GetTextObject ( ) ;
2019-04-17 15:19:25 +02:00
const SvxNumBulletItem & rNumFmt = aEdit . GetParaAttribs ( 3 ) . Get ( EE_PARA_NUMBULLET ) ;
CPPUNIT_ASSERT_EQUAL_MESSAGE ( " Bullet's relative size is wrong! " , sal_uInt16 ( 75 ) , rNumFmt . GetNumRule ( ) - > GetLevel ( 1 ) . GetBulletRelSize ( ) ) ; // != 25
2016-06-30 17:12:23 +02:00
}
xDocShRef - > DoClose ( ) ;
}
2016-06-30 20:52:34 +02:00
void SdOOXMLExportTest1 : : testFdo71961 ( )
2016-06-30 17:12:23 +02:00
{
2020-12-28 17:56:40 +01:00
: : sd : : DrawDocShellRef xDocShRef = loadURL ( m_directories . getURLFromSrc ( u " /sd/qa/unit/data/fdo71961.odp " ) , ODP ) ;
2016-06-30 17:12:23 +02:00
2016-10-05 22:00:51 +02:00
xDocShRef = saveAndReload ( xDocShRef . get ( ) , PPTX ) ;
2016-06-30 17:12:23 +02:00
const SdrPage * pPage = GetPage ( 1 , xDocShRef ) ;
// Export to .pptx changes all text frames to custom shape objects, which obey TextWordWrap property
// (which is false for text frames otherwise and is ignored). Check that frames that should wrap still do.
SdrObjCustomShape * pTxtObj = dynamic_cast < SdrObjCustomShape * > ( pPage - > GetObj ( 1 ) ) ;
CPPUNIT_ASSERT_MESSAGE ( " no text object " , pTxtObj ! = nullptr ) ;
CPPUNIT_ASSERT_EQUAL ( OUString ( " Text to be always wrapped " ) , pTxtObj - > GetOutlinerParaObject ( ) - > GetTextObject ( ) . GetText ( 0 ) ) ;
2017-11-17 11:36:24 +02:00
CPPUNIT_ASSERT_EQUAL ( true , pTxtObj - > GetMergedItem ( SDRATTR_TEXT_WORDWRAP ) . GetValue ( ) ) ;
2016-06-30 17:12:23 +02:00
pTxtObj = dynamic_cast < SdrObjCustomShape * > ( pPage - > GetObj ( 2 ) ) ;
CPPUNIT_ASSERT_MESSAGE ( " no text object " , pTxtObj ! = nullptr ) ;
CPPUNIT_ASSERT_EQUAL ( OUString ( " Custom shape non-wrapped text " ) , pTxtObj - > GetOutlinerParaObject ( ) - > GetTextObject ( ) . GetText ( 0 ) ) ;
2017-11-17 11:36:24 +02:00
CPPUNIT_ASSERT_EQUAL ( false , pTxtObj - > GetMergedItem ( SDRATTR_TEXT_WORDWRAP ) . GetValue ( ) ) ;
2016-06-30 17:12:23 +02:00
pTxtObj = dynamic_cast < SdrObjCustomShape * > ( pPage - > GetObj ( 3 ) ) ;
CPPUNIT_ASSERT_MESSAGE ( " no text object " , pTxtObj ! = nullptr ) ;
CPPUNIT_ASSERT_EQUAL ( OUString ( " Custom shape wrapped text " ) , pTxtObj - > GetOutlinerParaObject ( ) - > GetTextObject ( ) . GetText ( 0 ) ) ;
2017-11-17 11:36:24 +02:00
CPPUNIT_ASSERT_EQUAL ( true , pTxtObj - > GetMergedItem ( SDRATTR_TEXT_WORDWRAP ) . GetValue ( ) ) ;
2016-06-30 17:12:23 +02:00
xDocShRef - > DoClose ( ) ;
}
2016-06-30 20:52:34 +02:00
void SdOOXMLExportTest1 : : testN828390 ( )
2016-06-30 17:12:23 +02:00
{
bool bPassed = false ;
2020-12-28 17:56:40 +01:00
: : sd : : DrawDocShellRef xDocShRef = loadURL ( m_directories . getURLFromSrc ( u " /sd/qa/unit/data/pptx/n828390.pptx " ) , PPTX ) ;
2016-06-30 17:12:23 +02:00
2016-10-05 22:00:51 +02:00
xDocShRef = saveAndReload ( xDocShRef . get ( ) , PPTX ) ;
2016-06-30 17:12:23 +02:00
const SdrPage * pPage = GetPage ( 1 , xDocShRef ) ;
{
std : : vector < EECharAttrib > rLst ;
// Get the object
SdrObject * pObj = pPage - > GetObj ( 0 ) ;
SdrTextObj * pTxtObj = dynamic_cast < SdrTextObj * > ( pObj ) ;
CPPUNIT_ASSERT ( pTxtObj ) ;
const EditTextObject & aEdit = pTxtObj - > GetOutlinerParaObject ( ) - > GetTextObject ( ) ;
aEdit . GetCharAttribs ( 0 , rLst ) ;
2018-12-15 20:47:43 +03:00
bPassed = std : : any_of ( rLst . rbegin ( ) , rLst . rend ( ) ,
[ ] ( const EECharAttrib & rCharAttr ) {
const SvxEscapementItem * pFontEscapement = dynamic_cast < const SvxEscapementItem * > ( rCharAttr . pAttr ) ;
return pFontEscapement & & ( pFontEscapement - > GetEsc ( ) = = - 25 ) ;
} ) ;
2016-06-30 17:12:23 +02:00
}
CPPUNIT_ASSERT_MESSAGE ( " Subscript not exported properly " , bPassed ) ;
xDocShRef - > DoClose ( ) ;
}
2016-06-30 20:52:34 +02:00
void SdOOXMLExportTest1 : : testBnc880763 ( )
2016-06-30 17:12:23 +02:00
{
2020-12-28 17:56:40 +01:00
: : sd : : DrawDocShellRef xDocShRef = loadURL ( m_directories . getURLFromSrc ( u " /sd/qa/unit/data/pptx/bnc880763.pptx " ) , PPTX ) ;
2016-10-05 22:00:51 +02:00
xDocShRef = saveAndReload ( xDocShRef . get ( ) , PPTX ) ;
2016-06-30 17:12:23 +02:00
const SdrPage * pPage = GetPage ( 1 , xDocShRef ) ;
// Check z-order of the two shapes, use background color to identify them
// First object in the background has blue background color
2019-03-14 08:25:12 +01:00
const SdrObjGroup * pObjGroup = dynamic_cast < SdrObjGroup * > ( pPage - > GetObj ( 0 ) ) ;
2017-08-31 18:32:58 +02:00
CPPUNIT_ASSERT ( pObjGroup ) ;
2019-05-08 21:49:34 +02:00
const SdrObject * pObj = pObjGroup - > GetSubList ( ) - > GetObj ( 1 ) ;
2016-06-30 17:12:23 +02:00
CPPUNIT_ASSERT_MESSAGE ( " no object " , pObj ! = nullptr ) ;
2018-03-08 10:06:35 +02:00
CPPUNIT_ASSERT_EQUAL ( Color ( 0x0000ff ) , ( static_cast < const XColorItem & > ( pObj - > GetMergedItem ( XATTR_FILLCOLOR ) ) ) . GetColorValue ( ) ) ;
2016-06-30 17:12:23 +02:00
// Second object at the front has green background color
2019-03-14 08:25:12 +01:00
pObj = pPage - > GetObj ( 1 ) ;
2016-06-30 17:12:23 +02:00
CPPUNIT_ASSERT_MESSAGE ( " no object " , pObj ! = nullptr ) ;
2018-03-08 10:06:35 +02:00
CPPUNIT_ASSERT_EQUAL ( Color ( 0x00ff00 ) , ( static_cast < const XColorItem & > ( pObj - > GetMergedItem ( XATTR_FILLCOLOR ) ) ) . GetColorValue ( ) ) ;
2016-06-30 17:12:23 +02:00
xDocShRef - > DoClose ( ) ;
}
2016-06-30 20:52:34 +02:00
void SdOOXMLExportTest1 : : testBnc862510_5 ( )
2016-06-30 17:12:23 +02:00
{
2020-12-28 17:56:40 +01:00
: : sd : : DrawDocShellRef xDocShRef = loadURL ( m_directories . getURLFromSrc ( u " /sd/qa/unit/data/pptx/bnc862510_5.pptx " ) , PPTX ) ;
2016-10-05 22:00:51 +02:00
xDocShRef = saveAndReload ( xDocShRef . get ( ) , PPTX ) ;
2016-06-30 17:12:23 +02:00
const SdrPage * pPage = GetPage ( 1 , xDocShRef ) ;
// Same as testBnc870237, but here we check the horizontal spacing
2019-03-14 08:25:12 +01:00
const SdrObjGroup * pObjGroup = dynamic_cast < SdrObjGroup * > ( pPage - > GetObj ( 0 ) ) ;
2017-08-31 18:32:58 +02:00
CPPUNIT_ASSERT ( pObjGroup ) ;
2019-05-08 21:49:34 +02:00
const SdrObject * pObj = pObjGroup - > GetSubList ( ) - > GetObj ( 2 ) ;
2016-06-30 17:12:23 +02:00
CPPUNIT_ASSERT_MESSAGE ( " no object " , pObj ! = nullptr ) ;
2017-11-17 11:36:24 +02:00
CPPUNIT_ASSERT_EQUAL ( sal_Int32 ( 0 ) , pObj - > GetMergedItem ( SDRATTR_TEXT_UPPERDIST ) . GetValue ( ) ) ;
CPPUNIT_ASSERT_EQUAL ( sal_Int32 ( 0 ) , pObj - > GetMergedItem ( SDRATTR_TEXT_LOWERDIST ) . GetValue ( ) ) ;
CPPUNIT_ASSERT_EQUAL ( sal_Int32 ( 7510 ) , pObj - > GetMergedItem ( SDRATTR_TEXT_RIGHTDIST ) . GetValue ( ) ) ;
CPPUNIT_ASSERT_EQUAL ( sal_Int32 ( 0 ) , pObj - > GetMergedItem ( SDRATTR_TEXT_LEFTDIST ) . GetValue ( ) ) ;
2016-06-30 17:12:23 +02:00
xDocShRef - > DoClose ( ) ;
}
// In numbering a bullet could be defined as empty (no character).
// When exporting to OOXML make sure that the bullet is ignored and
// not written into the file.
2016-06-30 20:52:34 +02:00
void SdOOXMLExportTest1 : : testBnc822347_EmptyBullet ( )
2016-06-30 17:12:23 +02:00
{
2020-12-28 17:56:40 +01:00
sd : : DrawDocShellRef xDocShRef = loadURL ( m_directories . getURLFromSrc ( u " /sd/qa/unit/data/bnc822347_EmptyBullet.odp " ) , ODP ) ;
2016-10-05 22:00:51 +02:00
xDocShRef = saveAndReload ( xDocShRef . get ( ) , PPTX ) ;
2016-06-30 17:12:23 +02:00
SdDrawDocument * pDoc = xDocShRef - > GetDoc ( ) ;
SdrOutliner * pOutliner = pDoc - > GetInternalOutliner ( ) ;
const SdrPage * pPage = pDoc - > GetPage ( 1 ) ;
SdrObject * pObject = pPage - > GetObj ( 0 ) ;
SdrTextObj * pTextObject = dynamic_cast < SdrTextObj * > ( pObject ) ;
CPPUNIT_ASSERT ( pTextObject ) ;
OutlinerParaObject * pOutlinerParagraphObject = pTextObject - > GetOutlinerParaObject ( ) ;
const EditTextObject & aEdit = pOutlinerParagraphObject - > GetTextObject ( ) ;
OUString sText = aEdit . GetText ( 0 ) ;
CPPUNIT_ASSERT_EQUAL ( OUString ( " M3 Feature Test " ) , sText ) ;
pOutliner - > SetText ( * pOutlinerParagraphObject ) ;
CPPUNIT_ASSERT_EQUAL ( sal_Int32 ( 1 ) , pOutliner - > GetParagraphCount ( ) ) ;
const sal_Int16 nDepth = pOutliner - > GetDepth ( 0 ) ;
CPPUNIT_ASSERT_EQUAL ( sal_Int16 ( - 1 ) , nDepth ) ; // depth >= 0 means that the paragraph has bullets enabled
xDocShRef - > DoClose ( ) ;
}
//Bullets not having any text following them are not getting exported to pptx correctly.
2016-06-30 20:52:34 +02:00
void SdOOXMLExportTest1 : : testFdo90607 ( )
2016-06-30 17:12:23 +02:00
{
2020-12-28 17:56:40 +01:00
sd : : DrawDocShellRef xDocShRef = loadURL ( m_directories . getURLFromSrc ( u " /sd/qa/unit/data/fdo90607.pptx " ) , PPTX ) ;
2016-10-05 22:00:51 +02:00
xDocShRef = saveAndReload ( xDocShRef . get ( ) , PPTX ) ;
2016-06-30 17:12:23 +02:00
const SdrPage * pPage = GetPage ( 1 , xDocShRef ) ;
SdrTextObj * pTxtObj = dynamic_cast < SdrTextObj * > ( pPage - > GetObj ( 1 ) ) ;
CPPUNIT_ASSERT_MESSAGE ( " no text object " , pTxtObj ! = nullptr ) ;
OutlinerParaObject * pOutlinerParagraphObject = pTxtObj - > GetOutlinerParaObject ( ) ;
const sal_Int16 nDepth = pOutlinerParagraphObject - > GetDepth ( 0 ) ;
CPPUNIT_ASSERT_MESSAGE ( " not equal " , nDepth ! = - 1 ) ;
xDocShRef - > DoClose ( ) ;
}
2016-06-30 20:52:34 +02:00
void SdOOXMLExportTest1 : : testFdo83751 ( )
2016-06-30 17:12:23 +02:00
{
2020-12-28 17:56:40 +01:00
: : sd : : DrawDocShellRef xDocShRef = loadURL ( m_directories . getURLFromSrc ( u " /sd/qa/unit/data/pptx/fdo83751.pptx " ) , PPTX ) ;
2016-10-05 22:00:51 +02:00
xDocShRef = saveAndReload ( xDocShRef . get ( ) , PPTX ) ;
2016-06-30 17:12:23 +02:00
SdDrawDocument * pDoc = xDocShRef - > GetDoc ( ) ;
CPPUNIT_ASSERT_MESSAGE ( " no document " , pDoc ! = nullptr ) ;
uno : : Reference < document : : XDocumentPropertiesSupplier > xDocumentPropertiesSupplier ( xDocShRef - > GetModel ( ) , uno : : UNO_QUERY ) ;
2019-07-19 20:10:21 +02:00
uno : : Reference < document : : XDocumentProperties > xProps = xDocumentPropertiesSupplier - > getDocumentProperties ( ) ;
2016-06-30 17:12:23 +02:00
uno : : Reference < beans : : XPropertySet > xUDProps ( xProps - > getUserDefinedProperties ( ) , uno : : UNO_QUERY ) ;
OUString propValue ;
xUDProps - > getPropertyValue ( " Testing " ) > > = propValue ;
CPPUNIT_ASSERT_EQUAL ( OUString ( " Document " ) , propValue ) ;
xDocShRef - > DoClose ( ) ;
}
2016-06-30 20:52:34 +02:00
void SdOOXMLExportTest1 : : testFdo79731 ( )
2016-06-30 17:12:23 +02:00
{
2020-12-28 17:56:40 +01:00
: : sd : : DrawDocShellRef xDocShRef = loadURL ( m_directories . getURLFromSrc ( u " /sd/qa/unit/data/fdo79731.odp " ) , ODP ) ;
2016-10-05 22:00:51 +02:00
xDocShRef = saveAndReload ( xDocShRef . get ( ) , PPTX ) ;
2016-06-30 17:12:23 +02:00
SdDrawDocument * pDoc = xDocShRef - > GetDoc ( ) ;
CPPUNIT_ASSERT ( pDoc ) ;
xDocShRef - > DoClose ( ) ;
}
2016-06-30 20:52:34 +02:00
void SdOOXMLExportTest1 : : testTableCellFillProperties ( )
2016-06-30 17:12:23 +02:00
{
std : : shared_ptr < comphelper : : ConfigurationChanges > batch ( comphelper : : ConfigurationChanges : : create ( ) ) ;
officecfg : : Office : : Common : : Cache : : GraphicManager : : TotalCacheSize : : set ( sal_Int32 ( 1 ) , batch ) ;
batch - > commit ( ) ;
// Load the original file
2020-12-28 17:56:40 +01:00
: : sd : : DrawDocShellRef xDocShRef = loadURL ( m_directories . getURLFromSrc ( u " /sd/qa/unit/data/odp/Table_with_Cell_Fill.odp " ) , ODP ) ;
2016-06-30 17:12:23 +02:00
// Export the document and import again for a check
2019-07-19 20:10:21 +02:00
uno : : Reference < lang : : XComponent > xComponent = xDocShRef - > GetModel ( ) ;
2016-06-30 17:12:23 +02:00
uno : : Reference < frame : : XStorable > xStorable ( xComponent , uno : : UNO_QUERY ) ;
utl : : MediaDescriptor aMediaDescriptor ;
2020-12-11 17:44:34 +01:00
aMediaDescriptor [ " FilterName " ] < < = OStringToOUString ( std : : string_view ( aFileFormats [ PPTX ] . pFilterName ) , RTL_TEXTENCODING_UTF8 ) ;
2016-06-30 17:12:23 +02:00
utl : : TempFile aTempFile ;
aTempFile . EnableKillingFile ( ) ;
xStorable - > storeToURL ( aTempFile . GetURL ( ) , aMediaDescriptor . getAsConstPropertyValueList ( ) ) ;
xComponent . set ( xStorable , uno : : UNO_QUERY ) ;
xComponent - > dispose ( ) ;
xDocShRef = loadURL ( aTempFile . GetURL ( ) , PPTX ) ;
const SdrPage * pPage = GetPage ( 1 , xDocShRef ) ;
sdr : : table : : SdrTableObj * pTableObj = dynamic_cast < sdr : : table : : SdrTableObj * > ( pPage - > GetObj ( 0 ) ) ;
CPPUNIT_ASSERT ( pTableObj ) ;
uno : : Reference < table : : XCellRange > xTable ( pTableObj - > getTable ( ) , uno : : UNO_QUERY_THROW ) ;
uno : : Reference < beans : : XPropertySet > xCell ;
// Test Solid fill color
sal_Int32 nColor ;
xCell . set ( xTable - > getCellByPosition ( 0 , 0 ) , uno : : UNO_QUERY_THROW ) ;
xCell - > getPropertyValue ( " FillColor " ) > > = nColor ;
CPPUNIT_ASSERT_EQUAL ( sal_Int32 ( 6750207 ) , nColor ) ;
// Test Picture fill type for cell
drawing : : FillStyle aFillStyle ( drawing : : FillStyle_NONE ) ;
xCell . set ( xTable - > getCellByPosition ( 0 , 1 ) , uno : : UNO_QUERY_THROW ) ;
xCell - > getPropertyValue ( " FillStyle " ) > > = aFillStyle ;
2018-01-15 09:03:36 +01:00
CPPUNIT_ASSERT_EQUAL ( int ( drawing : : FillStyle_BITMAP ) , static_cast < int > ( aFillStyle ) ) ;
2016-06-30 17:12:23 +02:00
// Test Gradient fill type for cell
xCell . set ( xTable - > getCellByPosition ( 1 , 0 ) , uno : : UNO_QUERY_THROW ) ;
xCell - > getPropertyValue ( " FillStyle " ) > > = aFillStyle ;
2018-01-15 09:03:36 +01:00
CPPUNIT_ASSERT_EQUAL ( int ( drawing : : FillStyle_GRADIENT ) , static_cast < int > ( aFillStyle ) ) ;
2016-06-30 17:12:23 +02:00
xDocShRef - > DoClose ( ) ;
}
2016-06-30 20:52:34 +02:00
void SdOOXMLExportTest1 : : testBulletStartNumber ( )
2016-06-30 17:12:23 +02:00
{
2020-12-28 17:56:40 +01:00
: : sd : : DrawDocShellRef xDocShRef = loadURL ( m_directories . getURLFromSrc ( u " /sd/qa/unit/data/pptx/n90255.pptx " ) , PPTX ) ;
2016-10-05 22:00:51 +02:00
xDocShRef = saveAndReload ( xDocShRef . get ( ) , PPTX ) ;
2016-06-30 17:12:23 +02:00
const SdrPage * pPage = GetPage ( 1 , xDocShRef ) ;
SdrTextObj * pTxtObj = dynamic_cast < SdrTextObj * > ( pPage - > GetObj ( 0 ) ) ;
CPPUNIT_ASSERT_MESSAGE ( " no text object " , pTxtObj ! = nullptr ) ;
const EditTextObject & aEdit = pTxtObj - > GetOutlinerParaObject ( ) - > GetTextObject ( ) ;
2017-11-10 12:48:21 +02:00
const SvxNumBulletItem * pNumFmt = aEdit . GetParaAttribs ( 0 ) . GetItem ( EE_PARA_NUMBULLET ) ;
2016-06-30 17:12:23 +02:00
CPPUNIT_ASSERT ( pNumFmt ) ;
2018-05-31 13:20:41 +02:00
CPPUNIT_ASSERT_EQUAL_MESSAGE ( " Bullet's start number is wrong! " , sal_Int16 ( 3 ) , sal_Int16 ( pNumFmt - > GetNumRule ( ) - > GetLevel ( 0 ) . GetStart ( ) ) ) ;
2016-06-30 17:12:23 +02:00
xDocShRef - > DoClose ( ) ;
}
2016-06-30 20:52:34 +02:00
void SdOOXMLExportTest1 : : testLineStyle ( )
2016-06-30 17:12:23 +02:00
{
2020-12-28 17:56:40 +01:00
: : sd : : DrawDocShellRef xDocShRef = loadURL ( m_directories . getURLFromSrc ( u " sd/qa/unit/data/pptx/lineStyle.pptx " ) , PPTX ) ;
2016-10-05 22:00:51 +02:00
xDocShRef = saveAndReload ( xDocShRef . get ( ) , PPTX ) ;
2016-06-30 17:12:23 +02:00
const SdrPage * pPage = GetPage ( 1 , xDocShRef ) ;
SdrObject const * pShape = pPage - > GetObj ( 0 ) ;
CPPUNIT_ASSERT_MESSAGE ( " no shape " , pShape ! = nullptr ) ;
const XLineStyleItem & rStyleItem = dynamic_cast < const XLineStyleItem & > (
pShape - > GetMergedItem ( XATTR_LINESTYLE ) ) ;
2018-01-15 09:03:36 +01:00
CPPUNIT_ASSERT_EQUAL_MESSAGE ( " Wrong style " , int ( drawing : : LineStyle_SOLID ) , static_cast < int > ( rStyleItem . GetValue ( ) ) ) ;
2016-06-30 17:12:23 +02:00
xDocShRef - > DoClose ( ) ;
}
2016-06-30 20:52:34 +02:00
void SdOOXMLExportTest1 : : testRightToLeftParaghraph ( )
2016-06-30 17:12:23 +02:00
{
2020-12-28 17:56:40 +01:00
: : sd : : DrawDocShellRef xDocShRef = loadURL ( m_directories . getURLFromSrc ( u " /sd/qa/unit/data/pptx/rightToLeftParagraph.pptx " ) , PPTX ) ;
2016-06-30 17:12:23 +02:00
2016-10-05 22:00:51 +02:00
xDocShRef = saveAndReload ( xDocShRef . get ( ) , PPTX ) ;
2016-06-30 17:12:23 +02:00
uno : : Reference < beans : : XPropertySet > xShape ( getShapeFromPage ( 0 , 0 , xDocShRef ) ) ;
// Get first paragraph
uno : : Reference < text : : XTextRange > const xParagraph ( getParagraphFromShape ( 0 , xShape ) ) ;
uno : : Reference < beans : : XPropertySet > xPropSet ( xParagraph , uno : : UNO_QUERY_THROW ) ;
sal_Int16 nWritingMode = 0 ;
xPropSet - > getPropertyValue ( " WritingMode " ) > > = nWritingMode ;
CPPUNIT_ASSERT_EQUAL_MESSAGE ( " Wrong paragraph WritingMode " , text : : WritingMode2 : : RL_TB , nWritingMode ) ;
xDocShRef - > DoClose ( ) ;
}
2016-06-30 20:52:34 +02:00
void SdOOXMLExportTest1 : : testTextboxWithHyperlink ( )
2016-06-30 17:12:23 +02:00
{
2020-12-28 17:56:40 +01:00
: : sd : : DrawDocShellRef xDocShRef = loadURL ( m_directories . getURLFromSrc ( u " /sd/qa/unit/data/pptx/hyperlinktest.pptx " ) , PPTX ) ;
2016-06-30 17:12:23 +02:00
2016-10-05 22:00:51 +02:00
xDocShRef = saveAndReload ( xDocShRef . get ( ) , PPTX ) ;
2016-06-30 17:12:23 +02:00
uno : : Reference < beans : : XPropertySet > xShape ( getShapeFromPage ( 0 , 0 , xDocShRef ) ) ;
// Get first paragraph
uno : : Reference < text : : XTextRange > const xParagraph ( getParagraphFromShape ( 0 , xShape ) ) ;
// first chunk of text
uno : : Reference < text : : XTextRange > xRun ( getRunFromParagraph ( 0 , xParagraph ) ) ;
uno : : Reference < beans : : XPropertySet > xPropSet ( xRun , uno : : UNO_QUERY_THROW ) ;
uno : : Reference < text : : XTextField > xField ;
xPropSet - > getPropertyValue ( " TextField " ) > > = xField ;
CPPUNIT_ASSERT_MESSAGE ( " Where is the text field? " , xField . is ( ) ) ;
xPropSet . set ( xField , uno : : UNO_QUERY ) ;
OUString aURL ;
xPropSet - > getPropertyValue ( " URL " ) > > = aURL ;
CPPUNIT_ASSERT_EQUAL_MESSAGE ( " URLs don't match " , OUString ( " http://www.xkcd.com/ " ) , aURL ) ;
xDocShRef - > DoClose ( ) ;
}
2020-09-21 14:07:44 +08:00
void SdOOXMLExportTest1 : : testTdf136911 ( )
{
2020-12-28 17:56:40 +01:00
: : sd : : DrawDocShellRef xDocShRef = loadURL ( m_directories . getURLFromSrc ( u " /sd/qa/unit/data/ppt/tdf136911.ppt " ) , PPT ) ;
2020-09-21 14:07:44 +08:00
xDocShRef = saveAndReload ( xDocShRef . get ( ) , PPTX ) ;
uno : : Reference < beans : : XPropertySet > xShape ( getShapeFromPage ( 0 , 0 , xDocShRef ) ) ;
// Get second paragraph
uno : : Reference < text : : XTextRange > const xParagraph ( getParagraphFromShape ( 0 , xShape ) ) ;
// first chunk of text
uno : : Reference < text : : XTextRange > xRun ( getRunFromParagraph ( 0 , xParagraph ) ) ;
uno : : Reference < beans : : XPropertySet > xPropSet ( xRun , uno : : UNO_QUERY_THROW ) ;
uno : : Reference < text : : XTextField > xField ;
xPropSet - > getPropertyValue ( " TextField " ) > > = xField ;
CPPUNIT_ASSERT_MESSAGE ( " Where is the text field? " , xField . is ( ) ) ;
xPropSet . set ( xField , uno : : UNO_QUERY ) ;
OUString aURL ;
xPropSet - > getPropertyValue ( " URL " ) > > = aURL ;
CPPUNIT_ASSERT_EQUAL_MESSAGE ( " URLs don't match " , OUString ( " http://google.com " ) , aURL ) ;
xDocShRef - > DoClose ( ) ;
}
2016-06-30 20:52:34 +02:00
void SdOOXMLExportTest1 : : testBulletColor ( )
2016-06-30 17:12:23 +02:00
{
2020-12-28 17:56:40 +01:00
: : sd : : DrawDocShellRef xDocShRef = loadURL ( m_directories . getURLFromSrc ( u " /sd/qa/unit/data/pptx/bulletColor.pptx " ) , PPTX ) ;
2016-06-30 17:12:23 +02:00
2016-10-05 22:00:51 +02:00
xDocShRef = saveAndReload ( xDocShRef . get ( ) , PPTX ) ;
2016-06-30 17:12:23 +02:00
const SdrPage * pPage = GetPage ( 1 , xDocShRef ) ;
SdrTextObj * pTxtObj = dynamic_cast < SdrTextObj * > ( pPage - > GetObj ( 0 ) ) ;
CPPUNIT_ASSERT_MESSAGE ( " no text object " , pTxtObj ! = nullptr ) ;
const EditTextObject & aEdit = pTxtObj - > GetOutlinerParaObject ( ) - > GetTextObject ( ) ;
2017-11-10 12:48:21 +02:00
const SvxNumBulletItem * pNumFmt = aEdit . GetParaAttribs ( 0 ) . GetItem ( EE_PARA_NUMBULLET ) ;
2016-06-30 17:12:23 +02:00
CPPUNIT_ASSERT ( pNumFmt ) ;
2018-03-08 10:06:35 +02:00
CPPUNIT_ASSERT_EQUAL_MESSAGE ( " Bullet's color is wrong! " , Color ( 0xff0000 ) , pNumFmt - > GetNumRule ( ) - > GetLevel ( 0 ) . GetBulletColor ( ) ) ;
2016-06-30 17:12:23 +02:00
xDocShRef - > DoClose ( ) ;
}
2016-06-30 20:52:34 +02:00
void SdOOXMLExportTest1 : : testBulletCharAndFont ( )
2016-06-30 17:12:23 +02:00
{
2020-12-28 17:56:40 +01:00
: : sd : : DrawDocShellRef xDocShRef = loadURL ( m_directories . getURLFromSrc ( u " /sd/qa/unit/data/odp/bulletCharAndFont.odp " ) , ODP ) ;
2016-10-05 22:00:51 +02:00
xDocShRef = saveAndReload ( xDocShRef . get ( ) , PPTX ) ;
2016-06-30 17:12:23 +02:00
uno : : Reference < beans : : XPropertySet > xShape ( getShapeFromPage ( 0 , 0 , xDocShRef ) ) ;
uno : : Reference < text : : XTextRange > const xParagraph ( getParagraphFromShape ( 0 , xShape ) ) ;
uno : : Reference < beans : : XPropertySet > xPropSet ( xParagraph , uno : : UNO_QUERY_THROW ) ;
uno : : Reference < container : : XIndexAccess > xLevels ( xPropSet - > getPropertyValue ( " NumberingRules " ) , uno : : UNO_QUERY ) ;
uno : : Sequence < beans : : PropertyValue > aProps ;
xLevels - > getByIndex ( 0 ) > > = aProps ; // 1st level
2017-04-28 17:55:22 +02:00
OUString sBulletChar ( u ' \ xf06c ' ) ;
2020-05-21 09:05:51 +02:00
for ( beans : : PropertyValue const & rProp : std : : as_const ( aProps ) )
2016-06-30 17:12:23 +02:00
{
if ( rProp . Name = = " BulletChar " )
CPPUNIT_ASSERT_EQUAL_MESSAGE ( " BulletChar incorrect. " , sBulletChar , rProp . Value . get < OUString > ( ) ) ;
if ( rProp . Name = = " BulletFont " )
{
awt : : FontDescriptor aFontDescriptor ;
rProp . Value > > = aFontDescriptor ;
CPPUNIT_ASSERT_EQUAL_MESSAGE ( " BulletFont incorrect. " , OUString ( " Wingdings " ) , aFontDescriptor . Name ) ;
}
}
xDocShRef - > DoClose ( ) ;
}
2016-06-30 20:52:34 +02:00
void SdOOXMLExportTest1 : : testBulletMarginAndIndentation ( )
2016-06-30 17:12:23 +02:00
{
2020-12-28 17:56:40 +01:00
: : sd : : DrawDocShellRef xDocShRef = loadURL ( m_directories . getURLFromSrc ( u " /sd/qa/unit/data/pptx/bulletMarginAndIndent.pptx " ) , PPTX ) ;
2016-10-05 22:00:51 +02:00
xDocShRef = saveAndReload ( xDocShRef . get ( ) , PPTX ) ;
2016-06-30 17:12:23 +02:00
const SdrPage * pPage = GetPage ( 1 , xDocShRef ) ;
SdrTextObj * pTxtObj = dynamic_cast < SdrTextObj * > ( pPage - > GetObj ( 0 ) ) ;
CPPUNIT_ASSERT_MESSAGE ( " no text object " , pTxtObj ! = nullptr ) ;
const EditTextObject & aEdit = pTxtObj - > GetOutlinerParaObject ( ) - > GetTextObject ( ) ;
2017-11-10 12:48:21 +02:00
const SvxNumBulletItem * pNumFmt = aEdit . GetParaAttribs ( 0 ) . GetItem ( EE_PARA_NUMBULLET ) ;
2016-06-30 17:12:23 +02:00
CPPUNIT_ASSERT ( pNumFmt ) ;
SvxNumberFormat::nAbsLSpace should have a larger type
...as is seen when executing CppunitTest_sd_filters_test with Clang's new
-fsanitize=implicit-conversion (see below). The next larger natural choice
after short is sal_Int32, and some of the code calling GetAbsLSpace actually
already supported the value to be as wide (but not wider than) sal_Int32; code
calling GetAbsLSpace that expected the value to be no wider than short has
either been adapted or at least been marked with a TODO. (Other choices could
have been sal_Int64 or long.)
Some dependent function's parameter types have also been changed accordingly.
> Testing file:///home/sbergman/lo/core/sd/qa/unit/data/ppt/pass/hang-10.ppt:
[...]
> filter/source/msfilter/svdfppt.cxx:3792:33: runtime error: implicit conversion from type 'sal_uInt32' (aka 'unsigned int') of value 144780 (32-bit, unsigned) to type 'short' changed the value to 13708 (16-bit, signed)
> #0 in PPTNumberFormatCreator::ImplGetNumberFormat(SdrPowerPointImport const&, SvxNumberFormat&) at filter/source/msfilter/svdfppt.cxx:3792:33 (instdir/program/libmsfilterlo.so +0x7992cc)
> #1 in PPTNumberFormatCreator::GetNumberFormat(SdrPowerPointImport const&, SvxNumberFormat&, unsigned int, PPTParaLevel const&, PPTCharLevel const&, TSS_Type) at filter/source/msfilter/svdfppt.cxx:3674:5 (instdir/program/libmsfilterlo.so +0x797c6d)
> #2 in PPTStyleSheet::PPTStyleSheet(DffRecordHeader const&, SvStream&, SdrPowerPointImport&, PPTTextParagraphStyleAtomInterpreter const&, PPTTextSpecInfo const&) at filter/source/msfilter/svdfppt.cxx:4395:13 (instdir/program/libmsfilterlo.so +0x7ac38d)
> #3 in SdrPowerPointImport::SdrPowerPointImport(PowerPointImportParam&, rtl::OUString const&) at filter/source/msfilter/svdfppt.cxx:1618:59 (instdir/program/libmsfilterlo.so +0x74762f)
> #4 in ImplSdPPTImport::ImplSdPPTImport(SdDrawDocument*, SotStorage&, SfxMedium&, PowerPointImportParam&) at sd/source/filter/ppt/pptin.cxx:175:7 (instdir/program/libsdfiltlo.so +0x5f2be8)
> #5 in SdPPTImport::SdPPTImport(SdDrawDocument*, SvStream&, SotStorage&, SfxMedium&) at sd/source/filter/ppt/pptin.cxx:162:23 (instdir/program/libsdfiltlo.so +0x5ce2bb)
> #6 in ImportPPT at sd/source/filter/ppt/pptin.cxx:2760:47 (instdir/program/libsdfiltlo.so +0x617c79)
> #7 in SdPPTFilter::Import() at sd/source/filter/sdpptwrp.cxx:106:32 (instdir/program/libsdlo.so +0x2878413)
> #8 in sd::DrawDocShell::ConvertFrom(SfxMedium&) at sd/source/ui/docshell/docshel4.cxx:474:46 (instdir/program/libsdlo.so +0x2e165bc)
> #9 in SfxObjectShell::DoLoad(SfxMedium*) at sfx2/source/doc/objstor.cxx:786:23 (instdir/program/libsfxlo.so +0x2c8cb12)
> #10 in SdFiltersTest::load(rtl::OUString const&, rtl::OUString const&, rtl::OUString const&, SfxFilterFlags, SotClipboardFormatId, unsigned int) at sd/qa/unit/filters-test.cxx:75:31 (workdir/LinkTarget/CppunitTest/libtest_sd_filters_test.so +0x19771)
> #11 in test::FiltersTest::recursiveScan(test::filterStatus, rtl::OUString const&, rtl::OUString const&, rtl::OUString const&, SfxFilterFlags, SotClipboardFormatId, unsigned int, bool) at unotest/source/cpp/filters-test.cxx:130:20 (workdir/LinkTarget/CppunitTest/../Library/libunotest.so +0x5724c)
> #12 in test::FiltersTest::testDir(rtl::OUString const&, rtl::OUString const&, rtl::OUString const&, SfxFilterFlags, SotClipboardFormatId, unsigned int, bool) at unotest/source/cpp/filters-test.cxx:155:5 (workdir/LinkTarget/CppunitTest/../Library/libunotest.so +0x57ec9)
> #13 in SdFiltersTest::testCVEs() at sd/qa/unit/filters-test.cxx:83:5 (workdir/LinkTarget/CppunitTest/libtest_sd_filters_test.so +0x19d6d)
Change-Id: Ifa298a51bb62b7cbee9249b8289963f3427721f5
Reviewed-on: https://gerrit.libreoffice.org/59116
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2018-08-15 16:48:09 +02:00
CPPUNIT_ASSERT_EQUAL_MESSAGE ( " Bullet's left margin is wrong! " , sal_Int32 ( 1000 ) , pNumFmt - > GetNumRule ( ) - > GetLevel ( 0 ) . GetAbsLSpace ( ) ) ; // left margin is 0.79 cm
SvxNumberFormat::nFirstLineOffset should have a larger type
...similar to 0d227c96e11d7d03829144183bc66d229e059a4b
"SvxNumberFormat::nAbsLSpace should have a larger type", this time due to:
> Testing file:///home/sbergman/lo/core/sd/qa/unit/data/ppt/pass/hang-10.ppt:
[...]
> filter/source/msfilter/svdfppt.cxx:3793:39: runtime error: implicit conversion from type 'sal_Int32' (aka 'int') of value -142240 (32-bit, signed) to type 'short' changed the value to -11168 (16-bit, signed)
> #0 in PPTNumberFormatCreator::ImplGetNumberFormat(SdrPowerPointImport const&, SvxNumberFormat&) at filter/source/msfilter/svdfppt.cxx:3793:39 (instdir/program/libmsfilterlo.so +0x79930d)
> #1 in PPTNumberFormatCreator::GetNumberFormat(SdrPowerPointImport const&, SvxNumberFormat&, unsigned int, PPTParaLevel const&, PPTCharLevel const&, TSS_Type) at filter/source/msfilter/svdfppt.cxx:3674:5 (instdir/program/libmsfilterlo.so +0x797bad)
> #2 in PPTStyleSheet::PPTStyleSheet(DffRecordHeader const&, SvStream&, SdrPowerPointImport&, PPTTextParagraphStyleAtomInterpreter const&, PPTTextSpecInfo const&) at filter/source/msfilter/svdfppt.cxx:4395:13 (instdir/program/libmsfilterlo.so +0x7ac27d)
> #3 in SdrPowerPointImport::SdrPowerPointImport(PowerPointImportParam&, rtl::OUString const&) at filter/source/msfilter/svdfppt.cxx:1618:59 (instdir/program/libmsfilterlo.so +0x74759f)
> #4 in ImplSdPPTImport::ImplSdPPTImport(SdDrawDocument*, SotStorage&, SfxMedium&, PowerPointImportParam&) at sd/source/filter/ppt/pptin.cxx:175:7 (instdir/program/libsdfiltlo.so +0x5f2be8)
> #5 in SdPPTImport::SdPPTImport(SdDrawDocument*, SvStream&, SotStorage&, SfxMedium&) at sd/source/filter/ppt/pptin.cxx:162:23 (instdir/program/libsdfiltlo.so +0x5ce2bb)
> #6 in ImportPPT at sd/source/filter/ppt/pptin.cxx:2760:47 (instdir/program/libsdfiltlo.so +0x617c79)
> #7 in SdPPTFilter::Import() at sd/source/filter/sdpptwrp.cxx:106:32 (instdir/program/libsdlo.so +0x2878233)
> #8 in sd::DrawDocShell::ConvertFrom(SfxMedium&) at sd/source/ui/docshell/docshel4.cxx:474:46 (instdir/program/libsdlo.so +0x2e163dc)
> #9 in SfxObjectShell::DoLoad(SfxMedium*) at sfx2/source/doc/objstor.cxx:786:23 (instdir/program/libsfxlo.so +0x2c8c492)
> #10 in SdFiltersTest::load(rtl::OUString const&, rtl::OUString const&, rtl::OUString const&, SfxFilterFlags, SotClipboardFormatId, unsigned int) at sd/qa/unit/filters-test.cxx:75:31 (workdir/LinkTarget/CppunitTest/libtest_sd_filters_test.so +0x19771)
> #11 in test::FiltersTest::recursiveScan(test::filterStatus, rtl::OUString const&, rtl::OUString const&, rtl::OUString const&, SfxFilterFlags, SotClipboardFormatId, unsigned int, bool) at unotest/source/cpp/filters-test.cxx:130:20 (workdir/LinkTarget/CppunitTest/../Library/libunotest.so +0x5724c)
> #12 in test::FiltersTest::testDir(rtl::OUString const&, rtl::OUString const&, rtl::OUString const&, SfxFilterFlags, SotClipboardFormatId, unsigned int, bool) at unotest/source/cpp/filters-test.cxx:155:5 (workdir/LinkTarget/CppunitTest/../Library/libunotest.so +0x57ec9)
> #13 in SdFiltersTest::testCVEs() at sd/qa/unit/filters-test.cxx:83:5 (workdir/LinkTarget/CppunitTest/libtest_sd_filters_test.so +0x19d6d)
Change-Id: Icd83120e99ac8e7181d75e2cf9d13f49064e65e1
Reviewed-on: https://gerrit.libreoffice.org/59212
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2018-08-16 18:06:22 +02:00
CPPUNIT_ASSERT_EQUAL_MESSAGE ( " Bullet's indentation is wrong! " , sal_Int32 ( - 998 ) , pNumFmt - > GetNumRule ( ) - > GetLevel ( 0 ) . GetFirstLineOffset ( ) ) ;
2016-06-30 17:12:23 +02:00
xDocShRef - > DoClose ( ) ;
}
2016-06-30 20:52:34 +02:00
void SdOOXMLExportTest1 : : testParaMarginAndindentation ( )
2016-06-30 17:12:23 +02:00
{
2020-12-28 17:56:40 +01:00
: : sd : : DrawDocShellRef xDocShRef = loadURL ( m_directories . getURLFromSrc ( u " /sd/qa/unit/data/pptx/paraMarginAndIndentation.pptx " ) , PPTX ) ;
2016-06-30 17:12:23 +02:00
2016-10-05 22:00:51 +02:00
xDocShRef = saveAndReload ( xDocShRef . get ( ) , PPTX ) ;
2016-06-30 17:12:23 +02:00
uno : : Reference < beans : : XPropertySet > xShape ( getShapeFromPage ( 0 , 0 , xDocShRef ) ) ;
// Get first paragraph
uno : : Reference < text : : XTextRange > const xParagraph ( getParagraphFromShape ( 0 , xShape ) ) ;
uno : : Reference < beans : : XPropertySet > xPropSet ( xParagraph , uno : : UNO_QUERY_THROW ) ;
sal_Int32 nParaLeftMargin = 0 ;
xPropSet - > getPropertyValue ( " ParaLeftMargin " ) > > = nParaLeftMargin ;
CPPUNIT_ASSERT_EQUAL ( sal_uInt32 ( 1000 ) , sal_uInt32 ( nParaLeftMargin ) ) ;
sal_Int32 nParaFirstLineIndent = 0 ;
xPropSet - > getPropertyValue ( " ParaFirstLineIndent " ) > > = nParaFirstLineIndent ;
2017-05-22 15:55:38 +02:00
CPPUNIT_ASSERT_EQUAL ( sal_Int32 ( - 1268 ) , nParaFirstLineIndent ) ;
2016-06-30 17:12:23 +02:00
xDocShRef - > DoClose ( ) ;
}
2016-06-30 20:52:34 +02:00
void SdOOXMLExportTest1 : : testCellLeftAndRightMargin ( )
2016-06-30 17:12:23 +02:00
{
2020-12-28 17:56:40 +01:00
: : sd : : DrawDocShellRef xDocShRef = loadURL ( m_directories . getURLFromSrc ( u " sd/qa/unit/data/pptx/n90223.pptx " ) , PPTX ) ;
2016-10-05 22:00:51 +02:00
xDocShRef = saveAndReload ( xDocShRef . get ( ) , PPTX ) ;
2016-06-30 17:12:23 +02:00
sal_Int32 nLeftMargin , nRightMargin ;
const SdrPage * pPage = GetPage ( 1 , xDocShRef ) ;
sdr : : table : : SdrTableObj * pTableObj = dynamic_cast < sdr : : table : : SdrTableObj * > ( pPage - > GetObj ( 0 ) ) ;
CPPUNIT_ASSERT ( pTableObj ) ;
2019-05-10 10:13:12 +02:00
uno : : Reference < css : : table : : XTable > xTable ( pTableObj - > getTable ( ) , uno : : UNO_SET_THROW ) ;
2016-06-30 17:12:23 +02:00
uno : : Reference < css : : table : : XMergeableCell > xCell ( xTable - > getCellByPosition ( 0 , 0 ) , uno : : UNO_QUERY_THROW ) ;
uno : : Reference < beans : : XPropertySet > xCellPropSet ( xCell , uno : : UNO_QUERY_THROW ) ;
uno : : Any aLeftMargin = xCellPropSet - > getPropertyValue ( " TextLeftDistance " ) ;
aLeftMargin > > = nLeftMargin ;
uno : : Any aRightMargin = xCellPropSet - > getPropertyValue ( " TextRightDistance " ) ;
aRightMargin > > = nRightMargin ;
// Convert values to EMU
nLeftMargin = oox : : drawingml : : convertHmmToEmu ( nLeftMargin ) ;
nRightMargin = oox : : drawingml : : convertHmmToEmu ( nRightMargin ) ;
CPPUNIT_ASSERT_EQUAL ( sal_Int32 ( 45720 ) , nLeftMargin ) ;
CPPUNIT_ASSERT_EQUAL ( sal_Int32 ( 45720 ) , nRightMargin ) ;
xDocShRef - > DoClose ( ) ;
}
2016-06-30 20:52:34 +02:00
void SdOOXMLExportTest1 : : testMergedCells ( )
2016-06-30 17:12:23 +02:00
{
2020-12-28 17:56:40 +01:00
: : sd : : DrawDocShellRef xDocShRef = loadURL ( m_directories . getURLFromSrc ( u " sd/qa/unit/data/odp/cellspan.odp " ) , ODP ) ;
2016-10-05 22:00:51 +02:00
xDocShRef = saveAndReload ( xDocShRef . get ( ) , PPTX ) ;
2016-06-30 17:12:23 +02:00
const SdrPage * pPage = GetPage ( 1 , xDocShRef ) ;
sdr : : table : : SdrTableObj * pTableObj = dynamic_cast < sdr : : table : : SdrTableObj * > ( pPage - > GetObj ( 0 ) ) ;
CPPUNIT_ASSERT ( pTableObj ) ;
2019-05-10 10:13:12 +02:00
uno : : Reference < table : : XTable > xTable ( pTableObj - > getTable ( ) , uno : : UNO_SET_THROW ) ;
2016-06-30 17:12:23 +02:00
uno : : Reference < text : : XTextRange > xText1 ( xTable - > getCellByPosition ( 3 , 0 ) , uno : : UNO_QUERY_THROW ) ;
CPPUNIT_ASSERT_EQUAL ( OUString ( " 0,3 " ) , xText1 - > getString ( ) ) ;
uno : : Reference < text : : XTextRange > xText2 ( xTable - > getCellByPosition ( 3 , 2 ) , uno : : UNO_QUERY_THROW ) ;
CPPUNIT_ASSERT_EQUAL ( OUString ( " 2,3 " ) , xText2 - > getString ( ) ) ;
}
2016-06-30 20:52:34 +02:00
void SdOOXMLExportTest1 : : testTableCellBorder ( )
2016-06-30 17:12:23 +02:00
{
2020-12-28 17:56:40 +01:00
: : sd : : DrawDocShellRef xDocShRef = loadURL ( m_directories . getURLFromSrc ( u " sd/qa/unit/data/pptx/n90190.pptx " ) , PPTX ) ;
2016-10-05 22:00:51 +02:00
xDocShRef = saveAndReload ( xDocShRef . get ( ) , PPTX ) ;
2016-06-30 17:12:23 +02:00
const SdrPage * pPage = GetPage ( 1 , xDocShRef ) ;
sdr : : table : : SdrTableObj * pTableObj = dynamic_cast < sdr : : table : : SdrTableObj * > ( pPage - > GetObj ( 0 ) ) ;
CPPUNIT_ASSERT ( pTableObj ) ;
table : : BorderLine2 aBorderLine ;
2019-05-10 10:13:12 +02:00
uno : : Reference < table : : XTable > xTable ( pTableObj - > getTable ( ) , uno : : UNO_SET_THROW ) ;
2016-06-30 17:12:23 +02:00
uno : : Reference < css : : table : : XMergeableCell > xCell ( xTable - > getCellByPosition ( 0 , 0 ) , uno : : UNO_QUERY_THROW ) ;
uno : : Reference < beans : : XPropertySet > xCellPropSet ( xCell , uno : : UNO_QUERY_THROW ) ;
xCellPropSet - > getPropertyValue ( " LeftBorder " ) > > = aBorderLine ;
// While importing the table cell border line width, it converts EMU->Hmm then divided result by 2.
// To get original value of LineWidth need to multiple by 2.
2019-04-13 21:25:10 +02:00
sal_Int32 nLeftBorder = aBorderLine . LineWidth * 2 ;
2016-06-30 17:12:23 +02:00
nLeftBorder = oox : : drawingml : : convertHmmToEmu ( nLeftBorder ) ;
CPPUNIT_ASSERT ( nLeftBorder ) ;
CPPUNIT_ASSERT_EQUAL ( util : : Color ( 45296 ) , aBorderLine . Color ) ;
xCellPropSet - > getPropertyValue ( " RightBorder " ) > > = aBorderLine ;
2019-04-13 21:25:10 +02:00
sal_Int32 nRightBorder = aBorderLine . LineWidth * 2 ;
2016-06-30 17:12:23 +02:00
nRightBorder = oox : : drawingml : : convertHmmToEmu ( nRightBorder ) ;
CPPUNIT_ASSERT ( nRightBorder ) ;
CPPUNIT_ASSERT_EQUAL ( util : : Color ( 16777215 ) , aBorderLine . Color ) ;
xCellPropSet - > getPropertyValue ( " TopBorder " ) > > = aBorderLine ;
2019-04-13 21:25:10 +02:00
sal_Int32 nTopBorder = aBorderLine . LineWidth * 2 ;
2016-06-30 17:12:23 +02:00
nTopBorder = oox : : drawingml : : convertHmmToEmu ( nTopBorder ) ;
CPPUNIT_ASSERT ( nTopBorder ) ;
CPPUNIT_ASSERT_EQUAL ( util : : Color ( 45296 ) , aBorderLine . Color ) ;
xCellPropSet - > getPropertyValue ( " BottomBorder " ) > > = aBorderLine ;
2019-04-13 21:25:10 +02:00
sal_Int32 nBottomBorder = aBorderLine . LineWidth * 2 ;
2016-06-30 17:12:23 +02:00
nBottomBorder = oox : : drawingml : : convertHmmToEmu ( nBottomBorder ) ;
CPPUNIT_ASSERT ( nBottomBorder ) ;
CPPUNIT_ASSERT_EQUAL ( util : : Color ( 45296 ) , aBorderLine . Color ) ;
xDocShRef - > DoClose ( ) ;
}
2017-08-31 18:50:16 +02:00
void SdOOXMLExportTest1 : : testTdf111884 ( )
{
2020-12-28 17:56:40 +01:00
: : sd : : DrawDocShellRef xDocShRef = loadURL ( m_directories . getURLFromSrc ( u " sd/qa/unit/data/pptx/tdf111884.pptx " ) , PPTX ) ;
2017-08-31 18:50:16 +02:00
xDocShRef = saveAndReload ( xDocShRef . get ( ) , PPTX ) ;
const SdrPage * pPage = GetPage ( 1 , xDocShRef ) ;
SdrObject const * pShape = pPage - > GetObj ( 2 ) ;
CPPUNIT_ASSERT_MESSAGE ( " no shape " , pShape ! = nullptr ) ;
// must be a group shape
2020-11-05 14:04:04 +00:00
CPPUNIT_ASSERT_EQUAL ( OBJ_GRUP , pShape - > GetObjIdentifier ( ) ) ;
2017-08-31 18:50:16 +02:00
xDocShRef - > DoClose ( ) ;
}
2017-10-12 13:30:47 +02:00
void SdOOXMLExportTest1 : : testTdf112633 ( )
{
// Load document and export it to a temporary file
2020-12-28 17:56:40 +01:00
: : sd : : DrawDocShellRef xDocShRef = loadURL ( m_directories . getURLFromSrc ( u " sd/qa/unit/data/pptx/tdf112633.pptx " ) , PPTX ) ;
2017-10-12 13:30:47 +02:00
utl : : TempFile tempFile ;
xDocShRef = saveAndReload ( xDocShRef . get ( ) , PPTX , & tempFile ) ;
xDocShRef - > DoClose ( ) ;
2020-05-05 19:10:16 +02:00
xmlDocUniquePtr pXmlDoc = parseExport ( tempFile , " ppt/slides/slide1.xml " ) ;
xmlDocUniquePtr pRelsDoc = parseExport ( tempFile , " ppt/slides/_rels/slide1.xml.rels " ) ;
2017-10-12 13:30:47 +02:00
// Check image with artistic effect exists in the slide
assertXPath ( pXmlDoc , " /p:sld/p:cSld/p:spTree/p:pic/p:blipFill/a:blip/a:extLst/a:ext/a14:imgProps/ "
" a14:imgLayer/a14:imgEffect/a14:artisticPencilGrayscale " ,
" pencilSize " , " 80 " ) ;
// Check there is a relation with the .wdp file that contains the backed up image
OUString sEmbedId1 = getXPath ( pXmlDoc , " /p:sld/p:cSld/p:spTree/p:pic/p:blipFill/a:blip/a:extLst/ "
" a:ext/a14:imgProps/a14:imgLayer " , " embed " ) ;
OUString sXmlPath = " /rels:Relationships/rels:Relationship[@Id=' " + sEmbedId1 + " '] " ;
assertXPath ( pRelsDoc , OUStringToOString ( sXmlPath , RTL_TEXTENCODING_UTF8 ) , " Target " , " ../media/hdphoto1.wdp " ) ;
// Check the .wdp file exists
uno : : Reference < packages : : zip : : XZipFileAccess2 > xNameAccess = packages : : zip : : ZipFileAccess : : createWithURL (
comphelper : : getComponentContext ( m_xSFactory ) , tempFile . GetURL ( ) ) ;
CPPUNIT_ASSERT_EQUAL ( true , bool ( xNameAccess - > hasByName ( " ppt/media/hdphoto1.wdp " ) ) ) ;
}
2019-11-22 14:05:24 +03:00
void SdOOXMLExportTest1 : : testTdf128952 ( )
{
2020-12-28 17:56:40 +01:00
: : sd : : DrawDocShellRef xDocShRef = loadURL ( m_directories . getURLFromSrc ( u " sd/qa/unit/data/pptx/tdf128952.pptx " ) , PPTX ) ;
2019-11-22 14:05:24 +03:00
utl : : TempFile tempFile ;
xDocShRef = saveAndReload ( xDocShRef . get ( ) , PPTX , & tempFile ) ;
xDocShRef - > DoClose ( ) ;
2020-05-05 19:10:16 +02:00
xmlDocUniquePtr pXmlDoc = parseExport ( tempFile , " ppt/slides/slide1.xml " ) ;
2019-11-22 14:05:24 +03:00
assertXPath ( pXmlDoc , " /p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:xfrm/a:off " , " x " , " 360 " ) ;
assertXPath ( pXmlDoc , " /p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:xfrm/a:off " , " y " , " -360 " ) ;
assertXPath ( pXmlDoc , " /p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:xfrm/a:ext " , " cx " , " 1919880 " ) ;
assertXPath ( pXmlDoc , " /p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:xfrm/a:ext " , " cy " , " 1462680 " ) ;
}
2019-11-27 13:35:29 +03:00
void SdOOXMLExportTest1 : : testTdf127090 ( )
{
2020-12-28 17:56:40 +01:00
: : sd : : DrawDocShellRef xDocShRef = loadURL ( m_directories . getURLFromSrc ( u " sd/qa/unit/data/pptx/tdf127090.odp " ) , ODP ) ;
2019-11-27 13:35:29 +03:00
utl : : TempFile tempFile ;
xDocShRef = saveAndReload ( xDocShRef . get ( ) , PPTX , & tempFile ) ;
xDocShRef - > DoClose ( ) ;
2020-05-05 19:10:16 +02:00
xmlDocUniquePtr pXmlDoc = parseExport ( tempFile , " ppt/slides/slide1.xml " ) ;
2019-11-27 13:35:29 +03:00
assertXPath ( pXmlDoc , " /p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:bodyPr " , " rot " , " -5400000 " ) ;
}
2018-02-26 07:46:09 -05:00
void SdOOXMLExportTest1 : : testCustomXml ( )
{
// Load document and export it to a temporary file
2020-12-28 17:56:40 +01:00
: : sd : : DrawDocShellRef xDocShRef = loadURL ( m_directories . getURLFromSrc ( u " sd/qa/unit/data/pptx/customxml.pptx " ) , PPTX ) ;
2018-02-26 07:46:09 -05:00
utl : : TempFile tempFile ;
xDocShRef = saveAndReload ( xDocShRef . get ( ) , PPTX , & tempFile ) ;
xDocShRef - > DoClose ( ) ;
2020-05-05 19:10:16 +02:00
xmlDocUniquePtr pXmlDoc = parseExport ( tempFile , " customXml/item1.xml " ) ;
2018-02-26 07:46:09 -05:00
CPPUNIT_ASSERT ( pXmlDoc ) ;
2020-05-05 19:10:16 +02:00
xmlDocUniquePtr pRelsDoc = parseExport ( tempFile , " customXml/_rels/item1.xml.rels " ) ;
2018-02-26 07:46:09 -05:00
CPPUNIT_ASSERT ( pRelsDoc ) ;
// Check there is a relation to itemProps1.xml.
2018-03-08 12:24:48 +01:00
assertXPath ( pRelsDoc , " /rels:Relationships/rels:Relationship " , 1 ) ;
assertXPath ( pRelsDoc , " /rels:Relationships/rels:Relationship[@Id='rId1'] " , " Target " , " itemProps1.xml " ) ;
2018-02-26 07:46:09 -05:00
2020-04-21 07:51:25 +02:00
std : : unique_ptr < SvStream > pStream = parseExportStream ( tempFile , " ddp/ddpfile.xen " ) ;
2018-02-26 07:46:09 -05:00
CPPUNIT_ASSERT ( pStream ) ;
}
2019-02-04 17:34:39 +01:00
void SdOOXMLExportTest1 : : testTdf94238 ( )
{
// Load document and export it to a temporary file.
: : sd : : DrawDocShellRef xDocShRef
2020-12-28 17:56:40 +01:00
= loadURL ( m_directories . getURLFromSrc ( u " sd/qa/unit/data/pptx/tdf94238.pptx " ) , PPTX ) ;
2019-02-04 17:34:39 +01:00
utl : : TempFile tempFile ;
xDocShRef = saveAndReload ( xDocShRef . get ( ) , PPTX , & tempFile ) ;
uno : : Reference < drawing : : XDrawPagesSupplier > xDoc ( xDocShRef - > GetDoc ( ) - > getUnoModel ( ) ,
uno : : UNO_QUERY ) ;
CPPUNIT_ASSERT ( xDoc . is ( ) ) ;
uno : : Reference < drawing : : XDrawPage > xPage ( xDoc - > getDrawPages ( ) - > getByIndex ( 0 ) , uno : : UNO_QUERY ) ;
CPPUNIT_ASSERT ( xPage . is ( ) ) ;
uno : : Reference < beans : : XPropertySet > xShape ( getShape ( 0 , xPage ) ) ;
CPPUNIT_ASSERT ( xShape . is ( ) ) ;
awt : : Gradient aGradient ;
CPPUNIT_ASSERT ( xShape - > getPropertyValue ( " FillGradient " ) > > = aGradient ) ;
// Without the accompanying fix in place, this test would have failed with
// the following details:
// - aGradient.Style was awt::GradientStyle_ELLIPTICAL
// - aGradient.YOffset was 70
// - aGradient.Border was 0
CPPUNIT_ASSERT_EQUAL ( awt : : GradientStyle_RADIAL , aGradient . Style ) ;
CPPUNIT_ASSERT_EQUAL ( static_cast < sal_Int16 > ( 100 ) , aGradient . YOffset ) ;
CPPUNIT_ASSERT_EQUAL ( static_cast < sal_Int16 > ( 39 ) , aGradient . Border ) ;
2019-02-05 09:32:35 +01:00
// Without the accompanying fix in place, this test would have failed with
// 'Expected: 0, Actual : 10592673', i.e. the start color of the gradient
// was incorrect.
CPPUNIT_ASSERT_EQUAL ( static_cast < sal_Int32 > ( 0 ) , aGradient . StartColor ) ;
CPPUNIT_ASSERT_EQUAL ( static_cast < sal_Int32 > ( 0x8B8B8B ) , aGradient . EndColor ) ;
2019-02-04 17:34:39 +01:00
xDocShRef - > DoClose ( ) ;
}
2019-05-06 20:52:16 +02:00
void SdOOXMLExportTest1 : : testPictureTransparency ( )
{
// Load document and export it to a temporary file.
: : sd : : DrawDocShellRef xDocShRef
2020-12-28 17:56:40 +01:00
= loadURL ( m_directories . getURLFromSrc ( u " sd/qa/unit/data/odp/image_transparency.odp " ) , ODP ) ;
2019-05-06 20:52:16 +02:00
utl : : TempFile tempFile ;
xDocShRef = saveAndReload ( xDocShRef . get ( ) , PPTX , & tempFile ) ;
uno : : Reference < drawing : : XDrawPagesSupplier > xDoc ( xDocShRef - > GetDoc ( ) - > getUnoModel ( ) ,
uno : : UNO_QUERY ) ;
CPPUNIT_ASSERT ( xDoc . is ( ) ) ;
uno : : Reference < drawing : : XDrawPage > xPage ( xDoc - > getDrawPages ( ) - > getByIndex ( 0 ) , uno : : UNO_QUERY ) ;
CPPUNIT_ASSERT ( xPage . is ( ) ) ;
uno : : Reference < beans : : XPropertySet > xGraphicShape ( getShape ( 0 , xPage ) ) ;
CPPUNIT_ASSERT ( xGraphicShape . is ( ) ) ;
sal_Int16 nTransparency = 0 ;
CPPUNIT_ASSERT ( xGraphicShape - > getPropertyValue ( " Transparency " ) > > = nTransparency ) ;
CPPUNIT_ASSERT_EQUAL ( static_cast < sal_Int16 > ( 51 ) , nTransparency ) ;
xDocShRef - > DoClose ( ) ;
}
2019-07-01 21:10:01 +02:00
void SdOOXMLExportTest1 : : testTdf125554 ( )
{
: : sd : : DrawDocShellRef xDocShRef
2020-12-28 17:56:40 +01:00
= loadURL ( m_directories . getURLFromSrc ( u " sd/qa/unit/data/pptx/tdf125554.pptx " ) , PPTX ) ;
2019-07-01 21:10:01 +02:00
xDocShRef = saveAndReload ( xDocShRef . get ( ) , PPTX ) ;
uno : : Reference < beans : : XPropertySet > xShape = getShapeFromPage ( 0 , 0 , xDocShRef ) ;
uno : : Any aFillTransparenceGradientName
= xShape - > getPropertyValue ( " FillTransparenceGradientName " ) ;
CPPUNIT_ASSERT ( aFillTransparenceGradientName . has < OUString > ( ) ) ;
// Without the accompanying fix in place, this test would have failed, i.e. the transparency of
// the shape has no gradient, so it looked like a solid fill instead of a gradient fill.
CPPUNIT_ASSERT ( ! aFillTransparenceGradientName . get < OUString > ( ) . isEmpty ( ) ) ;
xDocShRef - > DoClose ( ) ;
}
2019-09-01 19:26:40 +02:00
void SdOOXMLExportTest1 : : testRoundtripOwnLineStyles ( )
{
// Load odp document and read the LineDash values.
: : sd : : DrawDocShellRef xDocShRef
2020-12-28 17:56:40 +01:00
= loadURL ( m_directories . getURLFromSrc ( u " sd/qa/unit/data/odp/LineStylesOwn.odp " ) , ODP ) ;
2019-09-01 19:26:40 +02:00
uno : : Reference < drawing : : XDrawPagesSupplier > xDocodp ( xDocShRef - > GetDoc ( ) - > getUnoModel ( ) , uno : : UNO_QUERY ) ;
CPPUNIT_ASSERT ( xDocodp . is ( ) ) ;
uno : : Reference < drawing : : XDrawPage > xPageodp ( xDocodp - > getDrawPages ( ) - > getByIndex ( 0 ) , uno : : UNO_QUERY ) ;
CPPUNIT_ASSERT ( xPageodp . is ( ) ) ;
drawing : : LineDash aLineDashodp [ 10 ] ;
for ( sal_uInt16 i = 0 ; i < 10 ; i + + )
{
uno : : Reference < beans : : XPropertySet > xShapeodp ( getShape ( i , xPageodp ) ) ;
CPPUNIT_ASSERT ( xShapeodp . is ( ) ) ;
xShapeodp - > getPropertyValue ( " LineDash " ) > > = aLineDashodp [ i ] ;
}
// Save to pptx, reload and compare the LineDash values
utl : : TempFile tempFile ;
xDocShRef = saveAndReload ( xDocShRef . get ( ) , PPTX , & tempFile ) ;
uno : : Reference < drawing : : XDrawPagesSupplier > xDocpptx ( xDocShRef - > GetDoc ( ) - > getUnoModel ( ) , uno : : UNO_QUERY ) ;
CPPUNIT_ASSERT ( xDocpptx . is ( ) ) ;
uno : : Reference < drawing : : XDrawPage > xPagepptx ( xDocpptx - > getDrawPages ( ) - > getByIndex ( 0 ) , uno : : UNO_QUERY ) ;
CPPUNIT_ASSERT ( xPagepptx . is ( ) ) ;
for ( sal_uInt16 i = 0 ; i < 10 ; i + + )
{
drawing : : LineDash aLineDashpptx ;
uno : : Reference < beans : : XPropertySet > xShapepptx ( getShape ( i , xPagepptx ) ) ;
CPPUNIT_ASSERT ( xShapepptx . is ( ) ) ;
xShapepptx - > getPropertyValue ( " LineDash " ) > > = aLineDashpptx ;
bool bIsSameLineDash = ( aLineDashodp [ i ] . Style = = aLineDashpptx . Style
& & aLineDashodp [ i ] . Dots = = aLineDashpptx . Dots
& & aLineDashodp [ i ] . DotLen = = aLineDashpptx . DotLen
& & aLineDashodp [ i ] . Dashes = = aLineDashpptx . Dashes
& & aLineDashodp [ i ] . DashLen = = aLineDashpptx . DashLen
& & aLineDashodp [ i ] . Distance = = aLineDashpptx . Distance ) ;
CPPUNIT_ASSERT_MESSAGE ( " LineDash differ " , bIsSameLineDash ) ;
}
xDocShRef - > DoClose ( ) ;
}
void SdOOXMLExportTest1 : : testRoundtripPrstDash ( )
{
// load and save document, compare prstDash values in saved document with original.
: : sd : : DrawDocShellRef xDocShRef
2020-12-28 17:56:40 +01:00
= loadURL ( m_directories . getURLFromSrc ( u " sd/qa/unit/data/pptx/presetDashDot.pptx " ) , PPTX ) ;
2019-09-01 19:26:40 +02:00
utl : : TempFile tempFile ;
xDocShRef = saveAndReload ( xDocShRef . get ( ) , PPTX , & tempFile ) ;
const OUString sOriginal [ ] = {
" dash " ,
" dashDot " ,
" dot " ,
" lgDash " ,
" lgDashDot " ,
" lgDashDotDot " ,
" sysDash " ,
" sysDashDot " ,
" sysDashDotDot " ,
" sysDot "
} ;
2020-05-05 19:10:16 +02:00
xmlDocUniquePtr pXmlDoc = parseExport ( tempFile , " ppt/slides/slide1.xml " ) ;
2019-09-01 19:26:40 +02:00
const OString sStart = " /p:sld/p:cSld/p:spTree/p:sp[ " ;
const OString sEnd = " ]/p:spPr/a:ln/a:prstDash " ;
for ( sal_uInt16 i = 0 ; i < 10 ; i + + )
{
OString sXmlPath = sStart + OString : : number ( i + 1 ) + sEnd ;
OUString sResaved = getXPath ( pXmlDoc , sXmlPath , " val " ) ;
CPPUNIT_ASSERT_EQUAL_MESSAGE ( " wrong prstDash " , sOriginal [ i ] , sResaved ) ;
}
// tdf#126746: Make sure that dash-dot pattern starts with the longer dash, as defined in OOXML
// Make sure Style is drawing::DashStyle_RECTRELATIVE
uno : : Reference < drawing : : XDrawPagesSupplier > xDoc ( xDocShRef - > GetDoc ( ) - > getUnoModel ( ) , uno : : UNO_QUERY ) ;
CPPUNIT_ASSERT ( xDoc . is ( ) ) ;
uno : : Reference < drawing : : XDrawPage > xPage ( xDoc - > getDrawPages ( ) - > getByIndex ( 0 ) , uno : : UNO_QUERY ) ;
CPPUNIT_ASSERT ( xPage . is ( ) ) ;
for ( sal_uInt16 i = 0 ; i < 10 ; i + + )
{
drawing : : LineDash aLineDash ;
uno : : Reference < beans : : XPropertySet > xShape ( getShape ( i , xPage ) ) ;
CPPUNIT_ASSERT ( xShape . is ( ) ) ;
xShape - > getPropertyValue ( " LineDash " ) > > = aLineDash ;
CPPUNIT_ASSERT_MESSAGE ( " First dash is short " , aLineDash . DotLen > = aLineDash . DashLen ) ;
bool bIsRectRelative = aLineDash . Style = = drawing : : DashStyle_RECTRELATIVE ;
CPPUNIT_ASSERT_MESSAGE ( " not RECTRELATIVE " , bIsRectRelative ) ;
}
xDocShRef - > DoClose ( ) ;
}
void SdOOXMLExportTest1 : : testDashOnHairline ( )
{
// load and save document, make sure the custDash has 11 child elements.
: : sd : : DrawDocShellRef xDocShRef
2020-12-28 17:56:40 +01:00
= loadURL ( m_directories . getURLFromSrc ( u " sd/qa/unit/data/odp/tdf127267DashOnHairline.odp " ) , ODP ) ;
2019-09-01 19:26:40 +02:00
utl : : TempFile tempFile ;
xDocShRef = saveAndReload ( xDocShRef . get ( ) , PPTX , & tempFile ) ;
xDocShRef - > DoClose ( ) ;
2020-05-05 19:10:16 +02:00
xmlDocUniquePtr pXmlDoc = parseExport ( tempFile , " ppt/slides/slide1.xml " ) ;
2020-10-27 23:18:23 +01:00
assertXPath ( pXmlDoc , " /p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:ln/a:custDash/a:ds " , 11 ) ;
2019-09-01 19:26:40 +02:00
}
2020-06-10 14:51:04 +02:00
void SdOOXMLExportTest1 : : testCustomshapeBitmapfillSrcrect ( )
{
: : sd : : DrawDocShellRef xDocShRef = loadURL (
2020-12-28 17:56:40 +01:00
m_directories . getURLFromSrc ( u " sd/qa/unit/data/pptx/customshape-bitmapfill-srcrect.pptx " ) ,
2020-06-10 14:51:04 +02:00
PPTX ) ;
utl : : TempFile tempFile ;
xDocShRef = saveAndReload ( xDocShRef . get ( ) , PPTX , & tempFile ) ;
xDocShRef - > DoClose ( ) ;
xmlDocUniquePtr pXmlDoc = parseExport ( tempFile , " ppt/slides/slide1.xml " ) ;
const OString sXmlPath = " //a:blipFill/a:srcRect " ;
// Without the accompanying fix in place, this test would have failed with:
// - Expected: 1
// - Actual : 0
// - XPath '//a:blipFill/a:srcRect' number of nodes is incorrect
// i.e. <a:srcRect> was exported as <a:fillRect> in <a:stretch>, which made part of the image
// invisible.
double fLeftPercent = std : : round ( getXPath ( pXmlDoc , sXmlPath , " l " ) . toDouble ( ) / 1000 ) ;
CPPUNIT_ASSERT_EQUAL ( 4.0 , fLeftPercent ) ;
double fRightPercent = std : : round ( getXPath ( pXmlDoc , sXmlPath , " r " ) . toDouble ( ) / 1000 ) ;
CPPUNIT_ASSERT_EQUAL ( 4.0 , fRightPercent ) ;
}
2020-07-04 15:11:03 +02:00
void SdOOXMLExportTest1 : : testTdf100348FontworkBitmapFill ( )
{
: : sd : : DrawDocShellRef xDocShRef
2020-12-28 17:56:40 +01:00
= loadURL ( m_directories . getURLFromSrc ( u " sd/qa/unit/data/odp/tdf100348_FontworkBitmapFill.odp " ) , ODP ) ;
2020-07-04 15:11:03 +02:00
utl : : TempFile tempFile ;
xDocShRef = saveAndReload ( xDocShRef . get ( ) , PPTX , & tempFile ) ;
xDocShRef - > DoClose ( ) ;
// Make sure the fontwork shape has a blip bitmap fill and a colored outline.
// Without the patch, fill and outline were black.
xmlDocUniquePtr pXmlDoc = parseExport ( tempFile , " ppt/slides/slide1.xml " ) ;
const OString sPathStart ( " //p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:r/a:rPr " ) ;
assertXPath ( pXmlDoc , sPathStart + " /a:blipFill/a:blip " , 1 ) ;
assertXPath ( pXmlDoc , sPathStart + " /a:ln/a:solidFill/a:srgbClr " , " val " , " ffbf00 " ) ;
}
void SdOOXMLExportTest1 : : testTdf100348FontworkGradientGlow ( )
{
: : sd : : DrawDocShellRef xDocShRef
2020-12-28 17:56:40 +01:00
= loadURL ( m_directories . getURLFromSrc ( u " sd/qa/unit/data/odp/tdf100348_FontworkGradientGlow.odp " ) , ODP ) ;
2020-07-04 15:11:03 +02:00
utl : : TempFile tempFile ;
xDocShRef = saveAndReload ( xDocShRef . get ( ) , PPTX , & tempFile ) ;
xDocShRef - > DoClose ( ) ;
// Make sure the fontwork shape has a gradient fill and a colored glow.
// Without the patch, fill was black and no glow applied.
xmlDocUniquePtr pXmlDoc = parseExport ( tempFile , " ppt/slides/slide1.xml " ) ;
const OString sPathStart ( " //p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:r/a:rPr " ) ;
assertXPath ( pXmlDoc , sPathStart + " /a:gradFill/a:gsLst/a:gs[1]/a:srgbClr " , " val " , " 8d281e " ) ;
assertXPath ( pXmlDoc , sPathStart + " /a:effectLst/a:glow " , " rad " , " 63360 " ) ;
assertXPath ( pXmlDoc , sPathStart + " /a:effectLst/a:glow/a:srgbClr " , " val " , " ff4500 " ) ;
}
2020-07-14 22:52:56 +02:00
void SdOOXMLExportTest1 : : testTdf128345FullTransparentGradient ( )
{
: : sd : : DrawDocShellRef xDocShRef
2020-12-28 17:56:40 +01:00
= loadURL ( m_directories . getURLFromSrc ( u " sd/qa/unit/data/odp/tdf128345_FullTransparentGradient.odp " ) , ODP ) ;
2020-07-14 22:52:56 +02:00
utl : : TempFile tempFile ;
xDocShRef = saveAndReload ( xDocShRef . get ( ) , PPTX , & tempFile ) ;
xDocShRef - > DoClose ( ) ;
// Make sure the shape has no fill. Without the patch, fill was solid red.
xmlDocUniquePtr pXmlDoc = parseExport ( tempFile , " ppt/slides/slide1.xml " ) ;
2020-10-27 23:18:23 +01:00
assertXPath ( pXmlDoc , " //p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:noFill " ) ;
2020-07-14 22:52:56 +02:00
}
void SdOOXMLExportTest1 : : testTdf128345GradientLinear ( )
{
: : sd : : DrawDocShellRef xDocShRef
2020-12-28 17:56:40 +01:00
= loadURL ( m_directories . getURLFromSrc ( u " sd/qa/unit/data/odp/tdf128345_GradientLinear.odp " ) , ODP ) ;
2020-07-14 22:52:56 +02:00
utl : : TempFile tempFile ;
xDocShRef = saveAndReload ( xDocShRef . get ( ) , PPTX , & tempFile ) ;
xDocShRef - > DoClose ( ) ;
// Make sure the shape has a lin fill. Without the patch, fill was solid red.
xmlDocUniquePtr pXmlDoc = parseExport ( tempFile , " ppt/slides/slide1.xml " ) ;
const OString sPathStart ( " //p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:gradFill " ) ;
assertXPath ( pXmlDoc , sPathStart + " /a:lin " , " ang " , " 3600000 " ) ;
assertXPath ( pXmlDoc , sPathStart + " /a:gsLst/a:gs " , 2 ) ;
assertXPath ( pXmlDoc , sPathStart + " /a:gsLst/a:gs[1] " , " pos " , " 25000 " ) ;
assertXPath ( pXmlDoc , sPathStart + " /a:gsLst/a:gs[1]/a:srgbClr " , " val " , " ff0000 " ) ;
assertXPath ( pXmlDoc , sPathStart + " /a:gsLst/a:gs[1]/a:srgbClr/a:alpha " , " val " , " 20000 " ) ;
assertXPath ( pXmlDoc , sPathStart + " /a:gsLst/a:gs[2] " , " pos " , " 100000 " ) ;
assertXPath ( pXmlDoc , sPathStart + " /a:gsLst/a:gs[2]/a:srgbClr " , " val " , " ff0000 " ) ;
assertXPath ( pXmlDoc , sPathStart + " /a:gsLst/a:gs[2]/a:srgbClr/a:alpha " , " val " , " 80000 " ) ;
}
void SdOOXMLExportTest1 : : testTdf128345GradientRadial ( )
{
: : sd : : DrawDocShellRef xDocShRef
2020-12-28 17:56:40 +01:00
= loadURL ( m_directories . getURLFromSrc ( u " sd/qa/unit/data/odp/tdf128345_GradientRadial.odp " ) , ODP ) ;
2020-07-14 22:52:56 +02:00
utl : : TempFile tempFile ;
xDocShRef = saveAndReload ( xDocShRef . get ( ) , PPTX , & tempFile ) ;
xDocShRef - > DoClose ( ) ;
// Make sure the shape has transparency. In OOXML alpha means 'opacity' with default
// 100000 for full opak, so only the full transparency with val 0 should be written.
xmlDocUniquePtr pXmlDoc = parseExport ( tempFile , " ppt/slides/slide1.xml " ) ;
const OString sPathStart ( " //p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:gradFill " ) ;
assertXPath ( pXmlDoc , sPathStart + " /a:gsLst/a:gs " , 2 ) ;
assertXPath ( pXmlDoc , sPathStart + " /a:gsLst/a:gs[1]/a:srgbClr " , " val " , " ff0000 " ) ;
assertXPath ( pXmlDoc , sPathStart + " /a:gsLst/a:gs[1]/a:srgbClr/a:alpha " , 0 ) ;
assertXPath ( pXmlDoc , sPathStart + " /a:gsLst/a:gs[2]/a:srgbClr " , " val " , " ffffff " ) ;
assertXPath ( pXmlDoc , sPathStart + " /a:gsLst/a:gs[2]/a:srgbClr/a:alpha " , " val " , " 0 " ) ;
}
void SdOOXMLExportTest1 : : testTdf128345GradientAxial ( )
{
2020-07-29 16:29:35 +02:00
// Without the patch, symmetric linear gradient with full transparence outside and
2020-07-14 22:52:56 +02:00
// full opak in the middle were imported as full transparent.
: : sd : : DrawDocShellRef xDocShRef
2020-12-28 17:56:40 +01:00
= loadURL ( m_directories . getURLFromSrc ( u " sd/qa/unit/data/odp/tdf128345_GradientAxial.odp " ) , ODP ) ;
2020-07-14 22:52:56 +02:00
xDocShRef = saveAndReload ( xDocShRef . get ( ) , PPTX ) ;
uno : : Reference < beans : : XPropertySet > xShapePropSet ( getShapeFromPage ( 0 , 0 , xDocShRef ) ) ;
awt : : Gradient aTransparenceGradient ;
xShapePropSet - > getPropertyValue ( " FillTransparenceGradient " ) > > = aTransparenceGradient ;
CPPUNIT_ASSERT_EQUAL ( sal_Int32 ( 0x000000 ) , aTransparenceGradient . StartColor ) ;
CPPUNIT_ASSERT_EQUAL ( sal_Int32 ( 0xffffff ) , aTransparenceGradient . EndColor ) ;
CPPUNIT_ASSERT_EQUAL ( awt : : GradientStyle_AXIAL , aTransparenceGradient . Style ) ;
xDocShRef - > DoClose ( ) ;
}
2020-07-21 15:46:51 +02:00
void SdOOXMLExportTest1 : : testTdf134969TransparencyOnColorGradient ( )
{
: : sd : : DrawDocShellRef xDocShRef
2020-12-28 17:56:40 +01:00
= loadURL ( m_directories . getURLFromSrc ( u " sd/qa/unit/data/odp/tdf134969_TransparencyOnColorGradient.odp " ) , ODP ) ;
2020-07-21 15:46:51 +02:00
utl : : TempFile tempFile ;
xDocShRef = saveAndReload ( xDocShRef . get ( ) , PPTX , & tempFile ) ;
xDocShRef - > DoClose ( ) ;
// Make sure the shape has a transparency in gradient stops.
xmlDocUniquePtr pXmlDoc = parseExport ( tempFile , " ppt/slides/slide1.xml " ) ;
const OString sPathStart ( " //p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:gradFill " ) ;
assertXPath ( pXmlDoc , sPathStart + " /a:gsLst/a:gs " , 2 ) ;
assertXPath ( pXmlDoc , sPathStart + " /a:gsLst/a:gs[1]/a:srgbClr/a:alpha " , " val " , " 60000 " ) ;
assertXPath ( pXmlDoc , sPathStart + " /a:gsLst/a:gs[2]/a:srgbClr/a:alpha " , " val " , " 60000 " ) ;
}
2021-01-06 13:24:10 +01:00
void SdOOXMLExportTest1 : : testArcTo ( )
{
: : sd : : DrawDocShellRef xDocShRef
= loadURL ( m_directories . getURLFromSrc ( u " sd/qa/unit/data/pptx/arc-validiert.pptx " ) , PPTX ) ;
utl : : TempFile tempFile ;
xDocShRef = saveAndReload ( xDocShRef . get ( ) , PPTX , & tempFile ) ;
xDocShRef - > DoClose ( ) ;
xmlDocUniquePtr pXmlDoc = parseExport ( tempFile , " ppt/slides/slide1.xml " ) ;
const OString sPath ( " //a:custGeom/a:pathLst/a:path/a:arcTo " ) ;
assertXPath ( pXmlDoc , sPath , " wR " , " 3 " ) ;
assertXPath ( pXmlDoc , sPath , " hR " , " 3 " ) ;
assertXPath ( pXmlDoc , sPath , " stAng " , " 1800000 " ) ;
assertXPath ( pXmlDoc , sPath , " swAng " , " 2700000 " ) ;
}
2021-01-15 15:53:19 +01:00
void SdOOXMLExportTest1 : : testNarrationMimeType ( )
{
sd : : DrawDocShellRef xDocShRef
= loadURL ( m_directories . getURLFromSrc ( u " sd/qa/unit/data/pptx/narration.pptx " ) , PPTX ) ;
utl : : TempFile aTempFile ;
xDocShRef = saveAndReload ( xDocShRef . get ( ) , PPTX , & aTempFile ) ;
xmlDocUniquePtr pXmlDoc = parseExport ( aTempFile , " [Content_Types].xml " ) ;
// Without the accompanying fix in place, this test would have failed with:
// - Expected: audio/mp4
// - Actual : application/vnd.sun.star.media
// i.e. the mime type of the narration was incorrect.
assertXPath ( pXmlDoc ,
" /ContentType:Types/ContentType:Override[@PartName='/ppt/media/media1.m4a'] " ,
" ContentType " , " audio/mp4 " ) ;
2021-01-21 15:08:13 +01:00
// Check if the bitmap of the media shape is exported correctly.
xmlDocUniquePtr pSlideDoc = parseExport ( aTempFile , " ppt/slides/slide1.xml " ) ;
OUString aImageId = getXPath ( pSlideDoc , " /p:sld/p:cSld/p:spTree/p:pic/p:blipFill/a:blip " , " embed " ) ;
xmlDocUniquePtr pRelsDoc = parseExport ( aTempFile , " ppt/slides/_rels/slide1.xml.rels " ) ;
OUString aImagePath = " /rels:Relationships/rels:Relationship[@Id=' " + aImageId + " '] " ;
// Something like ../media/image2.png.
OUString aImageStreamName = getXPath ( pRelsDoc , aImagePath . toUtf8 ( ) , " Target " ) ;
OUString aImageAbsName = rtl : : Uri : : convertRelToAbs ( " file:///ppt/slides/ " , aImageStreamName ) ;
// Something like ppt/media/image2.png.
OUString aImageRelName ;
CPPUNIT_ASSERT ( aImageAbsName . startsWith ( " file:/// " , & aImageRelName ) ) ;
std : : unique_ptr < SvStream > pImageStream = parseExportStream ( aTempFile , aImageRelName ) ;
vcl : : PNGReader aReader ( * pImageStream ) ;
BitmapEx aBitmapEx = aReader . Read ( ) ;
// Without the accompanying fix in place, this test would have failed with:
// - Expected: 256
// - Actual : 120
// i.e. the bitmap of the narration was lost, some default placeholder was exported instead.
CPPUNIT_ASSERT_EQUAL ( static_cast < tools : : Long > ( 256 ) , aBitmapEx . GetSizePixel ( ) . Height ( ) ) ;
2021-01-22 09:19:00 +01:00
// Without the accompanying fix in place, this test would have failed with:
// - Expected: 1
// - Actual : 0
// i.e. p:blipFill was missing its a:stretch child element, so the shape was invisible.
assertXPath ( pSlideDoc , " /p:sld/p:cSld/p:spTree/p:pic/p:blipFill/a:stretch/a:fillRect " , 1 ) ;
2021-01-15 15:53:19 +01:00
xDocShRef - > DoClose ( ) ;
}
2016-06-30 20:52:34 +02:00
CPPUNIT_TEST_SUITE_REGISTRATION ( SdOOXMLExportTest1 ) ;
2016-06-30 17:12:23 +02:00
CPPUNIT_PLUGIN_IMPLEMENT ( ) ;
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */