Kaydet (Commit) b3362fc9 authored tarafından Andres Gomez's avatar Andres Gomez Kaydeden (comit) Miklos Vajna

sw: Smart-Art related UTs updated to new option

The "ooxmlexport" unit test for Smart-Art has been updated to just
check for the new rendered bitmap that substitutes the generated basic
shapes.

The "ooxmlimport" has been updated with a new "testSmartart" unit
tests which checks that the importing has been done to just basic
shapes.

For this, the "run" method has been customized so we can set the
proper filter option.

Slightly modified the expected results in the "testChartProp" unit
test since linking it to additional libraries has modified the
dimmensions of the imported chart in few units.

Made the "ooxmlimport" C++ unit tests in the "sw" module to depend on
the "drawinglayer" and "svx" components and the "utl" library.

Conflicts:
	sw/qa/extras/ooxmlimport/ooxmlimport.cxx

Change-Id: I0900a50cfee07999511d071bc9932477ad9430c5
üst 09edaa05
...@@ -22,6 +22,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_ooxmlimport, \ ...@@ -22,6 +22,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_ooxmlimport, \
sal \ sal \
test \ test \
unotest \ unotest \
utl \
sw \ sw \
vcl \ vcl \
$(gb_UWINAPI) \ $(gb_UWINAPI) \
...@@ -52,6 +53,7 @@ $(eval $(call gb_CppunitTest_use_components,sw_ooxmlimport,\ ...@@ -52,6 +53,7 @@ $(eval $(call gb_CppunitTest_use_components,sw_ooxmlimport,\
chart2/source/chartcore \ chart2/source/chartcore \
comphelper/util/comphelp \ comphelper/util/comphelp \
configmgr/source/configmgr \ configmgr/source/configmgr \
drawinglayer/drawinglayer \
embeddedobj/util/embobj \ embeddedobj/util/embobj \
fileaccess/source/fileacc \ fileaccess/source/fileacc \
filter/source/config/cache/filterconfig1 \ filter/source/config/cache/filterconfig1 \
...@@ -71,6 +73,7 @@ $(eval $(call gb_CppunitTest_use_components,sw_ooxmlimport,\ ...@@ -71,6 +73,7 @@ $(eval $(call gb_CppunitTest_use_components,sw_ooxmlimport,\
svl/source/fsstor/fsstorage \ svl/source/fsstor/fsstorage \
svl/util/svl \ svl/util/svl \
svtools/util/svt \ svtools/util/svt \
svx/util/svx \
toolkit/util/tk \ toolkit/util/tk \
ucb/source/core/ucb1 \ ucb/source/core/ucb1 \
ucb/source/ucp/file/ucpfile1 \ ucb/source/ucp/file/ucpfile1 \
......
...@@ -1468,7 +1468,7 @@ void Test::testSmartart() ...@@ -1468,7 +1468,7 @@ void Test::testSmartart()
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDraws->getCount()); // One groupshape in the doc CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDraws->getCount()); // One groupshape in the doc
uno::Reference<container::XIndexAccess> xGroup(getShape(1), uno::UNO_QUERY); uno::Reference<container::XIndexAccess> xGroup(getShape(1), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xGroup->getCount()); // 3 rectangles and an arrow in the group CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xGroup->getCount()); // 1 rendered bitmap from the original shapes
uno::Reference<beans::XPropertySet> xGroupPropertySet(getShape(1), uno::UNO_QUERY); uno::Reference<beans::XPropertySet> xGroupPropertySet(getShape(1), uno::UNO_QUERY);
xGroupPropertySet->getPropertyValue(OUString("InteropGrabBag")) >>= aGrabBag; xGroupPropertySet->getPropertyValue(OUString("InteropGrabBag")) >>= aGrabBag;
...@@ -1515,19 +1515,10 @@ void Test::testSmartart() ...@@ -1515,19 +1515,10 @@ void Test::testSmartart()
} }
CPPUNIT_ASSERT(bData && bLayout && bQStyle && bColor && bDrawing); // Grab Bag has all the expected elements CPPUNIT_ASSERT(bData && bLayout && bQStyle && bColor && bDrawing); // Grab Bag has all the expected elements
uno::Reference<beans::XPropertySet> xPropertySet(xGroup->getByIndex(1), uno::UNO_QUERY); uno::Reference<beans::XPropertySet> xPropertySet(xGroup->getByIndex(0), uno::UNO_QUERY);
sal_Int32 nValue(0); OUString nValue;
xPropertySet->getPropertyValue("FillColor") >>= nValue; xPropertySet->getPropertyValue("Name") >>= nValue;
CPPUNIT_ASSERT_EQUAL(sal_Int32(0x4f81bd), nValue); // If fill color is right, theme import is OK CPPUNIT_ASSERT_EQUAL(OUString("RenderedShapes"), nValue); // Rendered bitmap has the proper name
uno::Reference<text::XTextRange> xTextRange(xGroup->getByIndex(1), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(OUString("Sample"), xTextRange->getString()); // Shape has text
uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextRange->getText(), uno::UNO_QUERY);
uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
xPropertySet.set(xParaEnum->nextElement(), uno::UNO_QUERY);
xPropertySet->getPropertyValue("ParaAdjust") >>= nValue;
CPPUNIT_ASSERT_EQUAL(sal_Int32(style::ParagraphAdjust_CENTER), nValue); // Paragraph properties are imported
} }
void Test::testFdo69636() void Test::testFdo69636()
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include <com/sun/star/xml/dom/XDocument.hpp> #include <com/sun/star/xml/dom/XDocument.hpp>
#include <vcl/svapp.hxx> #include <vcl/svapp.hxx>
#include <unotools/fltrcfg.hxx>
#include <swmodeltestbase.hxx> #include <swmodeltestbase.hxx>
#include <bordertest.hxx> #include <bordertest.hxx>
...@@ -140,6 +141,7 @@ public: ...@@ -140,6 +141,7 @@ public:
void testBnc779620(); void testBnc779620();
void testFdo43093(); void testFdo43093();
void testMultiColumnSeparator(); void testMultiColumnSeparator();
void testSmartart();
CPPUNIT_TEST_SUITE(Test); CPPUNIT_TEST_SUITE(Test);
#if !defined(WNT) #if !defined(WNT)
...@@ -244,12 +246,17 @@ void Test::run() ...@@ -244,12 +246,17 @@ void Test::run()
{"bnc779620.docx", &Test::testBnc779620}, {"bnc779620.docx", &Test::testBnc779620},
{"fdo43093.docx", &Test::testFdo43093}, {"fdo43093.docx", &Test::testFdo43093},
{"multi-column-separator-with-line.docx", &Test::testMultiColumnSeparator}, {"multi-column-separator-with-line.docx", &Test::testMultiColumnSeparator},
{"smartart.docx", &Test::testSmartart},
}; };
header(); header();
for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i) for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
{ {
MethodEntry<Test>& rEntry = aMethods[i]; MethodEntry<Test>& rEntry = aMethods[i];
if (OString(rEntry.pName) == "smartart.docx")
SvtFilterOptions::Get().SetSmartArt2Shape(sal_True);
load("/sw/qa/extras/ooxmlimport/data/", rEntry.pName); load("/sw/qa/extras/ooxmlimport/data/", rEntry.pName);
if (OString(rEntry.pName) == "smartart.docx")
SvtFilterOptions::Get().SetSmartArt2Shape(sal_False);
(this->*rEntry.pMethod)(); (this->*rEntry.pMethod)();
finish(); finish();
} }
...@@ -1594,8 +1601,8 @@ void Test::testChartProp() ...@@ -1594,8 +1601,8 @@ void Test::testChartProp()
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDrawPage->getCount()); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDrawPage->getCount());
uno::Reference<beans::XPropertySet> xPropertySet(getShape(1), uno::UNO_QUERY); uno::Reference<beans::XPropertySet> xPropertySet(getShape(1), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(sal_Int32(15236), getProperty<sal_Int32>(xPropertySet, "Width")); CPPUNIT_ASSERT_EQUAL(sal_Int32(15240), getProperty<sal_Int32>(xPropertySet, "Width"));
CPPUNIT_ASSERT_EQUAL(sal_Int32(8886), getProperty<sal_Int32>(xPropertySet, "Height")); CPPUNIT_ASSERT_EQUAL(sal_Int32(8890), getProperty<sal_Int32>(xPropertySet, "Height"));
} }
void Test::testBnc779620() void Test::testBnc779620()
...@@ -1639,6 +1646,31 @@ void Test::testFdo43093() ...@@ -1639,6 +1646,31 @@ void Test::testFdo43093()
CPPUNIT_ASSERT_EQUAL(text::WritingMode2::LR_TB, nLLDir); CPPUNIT_ASSERT_EQUAL(text::WritingMode2::LR_TB, nLLDir);
} }
void Test::testSmartart()
{
uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
uno::Reference<beans::XPropertySet> xTextDocumentPropertySet(xTextDocument, uno::UNO_QUERY);
uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDraws->getCount()); // One groupshape in the doc
uno::Reference<container::XIndexAccess> xGroup(getShape(1), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xGroup->getCount()); // 3 rectangles and an arrow in the group
uno::Reference<beans::XPropertySet> xPropertySet(xGroup->getByIndex(1), uno::UNO_QUERY);
sal_Int32 nValue(0);
xPropertySet->getPropertyValue("FillColor") >>= nValue;
CPPUNIT_ASSERT_EQUAL(sal_Int32(0x4f81bd), nValue); // If fill color is right, theme import is OK
uno::Reference<text::XTextRange> xTextRange(xGroup->getByIndex(1), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(OUString("Sample"), xTextRange->getString()); // Shape has text
uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextRange->getText(), uno::UNO_QUERY);
uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
xPropertySet.set(xParaEnum->nextElement(), uno::UNO_QUERY);
xPropertySet->getPropertyValue("ParaAdjust") >>= nValue;
CPPUNIT_ASSERT_EQUAL(sal_Int32(style::ParagraphAdjust_CENTER), nValue); // Paragraph properties are imported
}
void Test::testMultiColumnSeparator() void Test::testMultiColumnSeparator()
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment