2012-01-13 04:30:48 +01:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/*
|
2013-04-19 21:10:42 +01:00
|
|
|
* This file is part of the LibreOffice project.
|
2012-01-13 04:30:48 +01:00
|
|
|
*
|
2013-04-19 21:10:42 +01:00
|
|
|
* 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/.
|
2012-01-13 04:30:48 +01:00
|
|
|
*/
|
|
|
|
|
2013-05-14 11:47:34 +02:00
|
|
|
#include "sdmodeltestbase.hxx"
|
2012-01-13 04:30:48 +01:00
|
|
|
|
|
|
|
#include <svl/stritem.hxx>
|
2012-08-14 17:04:40 +05:30
|
|
|
#include <editeng/editobj.hxx>
|
|
|
|
#include <editeng/outlobj.hxx>
|
|
|
|
#include <editeng/ulspitem.hxx>
|
|
|
|
#include <editeng/fhgtitem.hxx>
|
|
|
|
|
2013-05-14 11:47:34 +02:00
|
|
|
#include <svx/svdotext.hxx>
|
2012-01-13 04:30:48 +01:00
|
|
|
|
|
|
|
using namespace ::com::sun::star;
|
|
|
|
|
2013-05-14 11:47:34 +02:00
|
|
|
/// Impress import filters tests.
|
|
|
|
class SdFiltersTest : public SdModelTestBase
|
2012-01-13 04:30:48 +01:00
|
|
|
{
|
|
|
|
public:
|
2013-05-14 11:47:34 +02:00
|
|
|
void testDocumentLayout();
|
2013-05-14 11:54:37 +02:00
|
|
|
void testSmoketest();
|
2012-08-14 17:04:40 +05:30
|
|
|
void testN759180();
|
2013-05-14 12:06:11 +02:00
|
|
|
void testN778859();
|
2012-01-13 04:30:48 +01:00
|
|
|
|
|
|
|
CPPUNIT_TEST_SUITE(SdFiltersTest);
|
2013-05-14 11:47:34 +02:00
|
|
|
CPPUNIT_TEST(testDocumentLayout);
|
2013-05-14 11:54:37 +02:00
|
|
|
CPPUNIT_TEST(testSmoketest);
|
2012-08-14 17:04:40 +05:30
|
|
|
CPPUNIT_TEST(testN759180);
|
2013-05-14 12:06:11 +02:00
|
|
|
CPPUNIT_TEST(testN778859);
|
2012-01-13 04:30:48 +01:00
|
|
|
CPPUNIT_TEST_SUITE_END();
|
|
|
|
};
|
|
|
|
|
2013-05-14 11:47:34 +02:00
|
|
|
/** Test document against a reference XML dump of shapes.
|
2012-01-13 04:30:48 +01:00
|
|
|
|
2013-05-14 16:39:14 +02:00
|
|
|
If you want to update one of these tests, set the nUpdateMe to the index of
|
|
|
|
the test, the dump XML's will be created (or rewritten) instead of checking.
|
|
|
|
Use with care - when the test is failing, first find out why, instead of just
|
|
|
|
updating .xml's blindly.
|
|
|
|
|
|
|
|
NOTE: This approach is suitable only for tests of fixes that actually change
|
|
|
|
the layout - best to check by reverting your fix locally after having added
|
|
|
|
the test, and re-running; it should break.
|
2013-05-14 11:47:34 +02:00
|
|
|
*/
|
|
|
|
void SdFiltersTest::testDocumentLayout()
|
2012-01-13 04:30:48 +01:00
|
|
|
{
|
2013-05-14 11:47:34 +02:00
|
|
|
struct { const char *pInput, *pDump; } aFilesToCompare[] =
|
2012-01-13 04:30:48 +01:00
|
|
|
{
|
2013-05-14 11:47:34 +02:00
|
|
|
{ "odp/shapes-test.odp", "xml/shapes-test_page" },
|
2013-05-14 16:39:14 +02:00
|
|
|
{ "pptx/fdo47434-all.pptx", "pptx/xml/fdo47434_page" },
|
2013-05-15 09:37:27 +02:00
|
|
|
{ "n758621.ppt", "xml/n758621_" },
|
2013-05-15 16:10:40 +02:00
|
|
|
{ "fdo64586.ppt", "xml/fdo64586_" },
|
|
|
|
{ "n819614.pptx", "xml/n819614_" },
|
2013-05-14 11:47:34 +02:00
|
|
|
};
|
2012-01-13 04:30:48 +01:00
|
|
|
|
2013-05-14 16:39:14 +02:00
|
|
|
for ( int i = 0; i < static_cast< int >( SAL_N_ELEMENTS( aFilesToCompare ) ); ++i )
|
2012-01-13 04:30:48 +01:00
|
|
|
{
|
2013-05-14 16:39:14 +02:00
|
|
|
int nUpdateMe = -1; // index of test we want to update; supposedly only when the test is created
|
|
|
|
|
2013-05-14 11:47:34 +02:00
|
|
|
::sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc( "/sd/qa/unit/data/" ) + OUString::createFromAscii( aFilesToCompare[i].pInput ) );
|
2013-05-14 16:39:14 +02:00
|
|
|
compareWithShapesDump( xDocShRef,
|
|
|
|
getPathFromSrc( "/sd/qa/unit/data/" ) + OUString::createFromAscii( aFilesToCompare[i].pDump ),
|
|
|
|
i == nUpdateMe );
|
2012-01-13 04:30:48 +01:00
|
|
|
}
|
2012-06-15 16:12:52 +02:00
|
|
|
}
|
|
|
|
|
2013-05-14 11:54:37 +02:00
|
|
|
void SdFiltersTest::testSmoketest()
|
|
|
|
{
|
|
|
|
::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/smoketest.pptx"));
|
|
|
|
CPPUNIT_ASSERT_MESSAGE( "failed to load", xDocShRef.Is() );
|
|
|
|
CPPUNIT_ASSERT_MESSAGE( "not in destruction", !xDocShRef->IsInDestruction() );
|
|
|
|
|
|
|
|
SdDrawDocument *pDoc = xDocShRef->GetDoc();
|
|
|
|
CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
|
|
|
|
|
|
|
|
// cf. SdrModel svx/svdmodel.hxx ...
|
|
|
|
|
|
|
|
CPPUNIT_ASSERT_MESSAGE( "wrong page count", pDoc->GetPageCount() == 3);
|
|
|
|
|
|
|
|
const SdrPage *pPage = pDoc->GetPage (1);
|
|
|
|
CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL );
|
|
|
|
|
|
|
|
sal_uIntPtr nObjs = pPage->GetObjCount();
|
|
|
|
for (sal_uIntPtr i = 0; i < nObjs; i++)
|
|
|
|
{
|
|
|
|
SdrObject *pObj = pPage->GetObj(i);
|
|
|
|
SdrObjKind eKind = (SdrObjKind) pObj->GetObjIdentifier();
|
|
|
|
SdrTextObj *pTxt = dynamic_cast<SdrTextObj *>( pObj );
|
|
|
|
(void)pTxt; (void)eKind;
|
|
|
|
}
|
|
|
|
|
|
|
|
CPPUNIT_ASSERT_MESSAGE( "changed", !pDoc->IsChanged() );
|
|
|
|
xDocShRef->DoClose();
|
|
|
|
}
|
|
|
|
|
2012-08-14 17:04:40 +05:30
|
|
|
void SdFiltersTest::testN759180()
|
|
|
|
{
|
|
|
|
::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/n759180.pptx"));
|
|
|
|
CPPUNIT_ASSERT_MESSAGE( "failed to load", xDocShRef.Is() );
|
|
|
|
CPPUNIT_ASSERT_MESSAGE( "not in destruction", !xDocShRef->IsInDestruction() );
|
|
|
|
|
|
|
|
SdDrawDocument *pDoc = xDocShRef->GetDoc();
|
|
|
|
CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
|
|
|
|
const SdrPage *pPage = pDoc->GetPage (1);
|
|
|
|
CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL );
|
|
|
|
|
|
|
|
//sal_uIntPtr nObjs = pPage->GetObjCount();
|
|
|
|
//for (sal_uIntPtr i = 0; i < nObjs; i++)
|
|
|
|
{
|
|
|
|
// Get the object
|
|
|
|
SdrObject *pObj = pPage->GetObj(0);
|
|
|
|
SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pObj );
|
|
|
|
CPPUNIT_ASSERT(pTxtObj);
|
|
|
|
std::vector<EECharAttrib> rLst;
|
|
|
|
const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject();
|
|
|
|
const SvxULSpaceItem *pULSpace = dynamic_cast<const SvxULSpaceItem *>(aEdit.GetParaAttribs(0).GetItem(EE_PARA_ULSPACE));
|
|
|
|
CPPUNIT_ASSERT(pULSpace);
|
|
|
|
CPPUNIT_ASSERT_MESSAGE( "Para bottom spacing is wrong!", pULSpace->GetLower() == 0 );
|
|
|
|
aEdit.GetCharAttribs(1, rLst);
|
2012-09-16 00:48:05 +02:00
|
|
|
for( std::vector<EECharAttrib>::reverse_iterator it = rLst.rbegin(); it!=rLst.rend(); ++it)
|
2012-08-14 17:04:40 +05:30
|
|
|
{
|
|
|
|
const SvxFontHeightItem * pFontHeight = dynamic_cast<const SvxFontHeightItem *>((*it).pAttr);
|
|
|
|
if(pFontHeight)
|
|
|
|
{
|
|
|
|
// nStart == 9
|
|
|
|
// font height = 5 => 5*2540/72
|
|
|
|
CPPUNIT_ASSERT_MESSAGE( "Font height is wrong", pFontHeight->GetHeight() == 176 );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-14 12:06:11 +02:00
|
|
|
void SdFiltersTest::testN778859()
|
|
|
|
{
|
|
|
|
::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/n778859.pptx"));
|
|
|
|
CPPUNIT_ASSERT_MESSAGE( "failed to load", xDocShRef.Is() );
|
|
|
|
CPPUNIT_ASSERT_MESSAGE( "not in destruction", !xDocShRef->IsInDestruction() );
|
|
|
|
|
|
|
|
SdDrawDocument *pDoc = xDocShRef->GetDoc();
|
|
|
|
CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
|
|
|
|
const SdrPage *pPage = pDoc->GetPage(1);
|
|
|
|
CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL );
|
|
|
|
{
|
|
|
|
// Get the object
|
|
|
|
SdrObject *pObj = pPage->GetObj(1);
|
|
|
|
SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pObj );
|
|
|
|
CPPUNIT_ASSERT(!pTxtObj->IsAutoFit());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-13 04:30:48 +01:00
|
|
|
CPPUNIT_TEST_SUITE_REGISTRATION(SdFiltersTest);
|
|
|
|
|
|
|
|
CPPUNIT_PLUGIN_IMPLEMENT();
|
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|