Kaydet (Commit) 0f330ea2 authored tarafından Miklos Vajna's avatar Miklos Vajna

RtfModelTest: introduce common getPages() method

üst 7b58fc3d
...@@ -103,6 +103,8 @@ private: ...@@ -103,6 +103,8 @@ private:
void load(const OUString& rURL); void load(const OUString& rURL);
/// Get the length of the whole document. /// Get the length of the whole document.
int getLength(); int getLength();
/// Get page count.
int getPages();
uno::Reference<lang::XComponent> mxComponent; uno::Reference<lang::XComponent> mxComponent;
}; };
...@@ -130,6 +132,15 @@ int RtfModelTest::getLength() ...@@ -130,6 +132,15 @@ int RtfModelTest::getLength()
return aBuf.getLength(); return aBuf.getLength();
} }
int RtfModelTest::getPages()
{
uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY);
uno::Reference<text::XPageCursor> xCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY);
xCursor->jumpToLastPage();
return xCursor->getPage();
}
void RtfModelTest::setUp() void RtfModelTest::setUp()
{ {
test::BootstrapFixture::setUp(); test::BootstrapFixture::setUp();
...@@ -382,11 +393,7 @@ void RtfModelTest::testFdo43965() ...@@ -382,11 +393,7 @@ void RtfModelTest::testFdo43965()
CPPUNIT_ASSERT_EQUAL(sal_uInt32(26), aBorder.LineWidth); CPPUNIT_ASSERT_EQUAL(sal_uInt32(26), aBorder.LineWidth);
// Finally, make sure that we have two pages // Finally, make sure that we have two pages
uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(2, getPages());
uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY);
uno::Reference<text::XPageCursor> xCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY);
xCursor->jumpToLastPage();
CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xCursor->getPage());
} }
void RtfModelTest::testN751020() void RtfModelTest::testN751020()
...@@ -476,11 +483,7 @@ void RtfModelTest::testFdo45394() ...@@ -476,11 +483,7 @@ void RtfModelTest::testFdo45394()
void RtfModelTest::testFdo48104() void RtfModelTest::testFdo48104()
{ {
load(OUString(RTL_CONSTASCII_USTRINGPARAM("fdo48104.rtf"))); load(OUString(RTL_CONSTASCII_USTRINGPARAM("fdo48104.rtf")));
uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(2, getPages());
uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY);
uno::Reference<text::XPageCursor> xCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY);
xCursor->jumpToLastPage();
CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xCursor->getPage());
} }
CPPUNIT_TEST_SUITE_REGISTRATION(RtfModelTest); CPPUNIT_TEST_SUITE_REGISTRATION(RtfModelTest);
......
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