summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2015-09-29 10:47:31 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-09-29 11:08:03 +0200
commitd355207b45755cfe1eef0147bc25ead931741684 (patch)
treecc3bf2d9f6d45c35dfebe46ad4fd1424052dd795 /desktop
parent264c6e4c522d828e7f3f6ac106763278f30c7e9b (diff)
lok: add Document::getPartPageRectangles()
Change-Id: I20acd44f7a81471982ba96ad3894a9124e035c5f
Diffstat (limited to 'desktop')
-rw-r--r--desktop/qa/desktop_lib/test_desktop_lib.cxx25
-rw-r--r--desktop/source/lib/init.cxx19
2 files changed, 44 insertions, 0 deletions
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index d7b93472c1b5..a7696d824bee 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -52,12 +52,14 @@ public:
void testGetFonts();
void testCreateView();
void testGetFilterTypes();
+ void testGetPartPageRectangles();
CPPUNIT_TEST_SUITE(DesktopLOKTest);
CPPUNIT_TEST(testGetStyles);
CPPUNIT_TEST(testGetFonts);
CPPUNIT_TEST(testCreateView);
CPPUNIT_TEST(testGetFilterTypes);
+ CPPUNIT_TEST(testGetPartPageRectangles);
CPPUNIT_TEST_SUITE_END();
uno::Reference<lang::XComponent> mxComponent;
@@ -152,6 +154,29 @@ void DesktopLOKTest::testCreateView()
closeDoc();
}
+void DesktopLOKTest::testGetPartPageRectangles()
+{
+ // Test that we get as many page rectangles as expected: blank document is
+ // one page.
+ LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
+ char* pRectangles = pDocument->pClass->getPartPageRectangles(pDocument);
+ OUString sRectangles = OUString::fromUtf8(pRectangles);
+
+ std::vector<OUString> aRectangles;
+ sal_Int32 nIndex = 0;
+ do
+ {
+ OUString aRectangle = sRectangles.getToken(0, ';', nIndex);
+ if (!aRectangle.isEmpty())
+ aRectangles.push_back(aRectangle);
+ }
+ while (nIndex >= 0);
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), aRectangles.size());
+
+ free(pRectangles);
+ closeDoc();
+}
+
void DesktopLOKTest::testGetFilterTypes()
{
LibLibreOffice_Impl aOffice;
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index b581bca5d011..509983c1c8ac 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -204,6 +204,7 @@ static void doc_destroy(LibreOfficeKitDocument* pThis);
static int doc_saveAs(LibreOfficeKitDocument* pThis, const char* pUrl, const char* pFormat, const char* pFilterOptions);
static int doc_getDocumentType(LibreOfficeKitDocument* pThis);
static int doc_getParts(LibreOfficeKitDocument* pThis);
+static char* doc_getPartPageRectangles(LibreOfficeKitDocument* pThis);
static int doc_getPart(LibreOfficeKitDocument* pThis);
static void doc_setPart(LibreOfficeKitDocument* pThis, int nPart);
static char* doc_getPartName(LibreOfficeKitDocument* pThis, int nPart);
@@ -266,6 +267,7 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone
m_pDocumentClass->saveAs = doc_saveAs;
m_pDocumentClass->getDocumentType = doc_getDocumentType;
m_pDocumentClass->getParts = doc_getParts;
+ m_pDocumentClass->getPartPageRectangles = doc_getPartPageRectangles;
m_pDocumentClass->getPart = doc_getPart;
m_pDocumentClass->setPart = doc_setPart;
m_pDocumentClass->getPartName = doc_getPartName;
@@ -659,6 +661,23 @@ static void doc_setPart(LibreOfficeKitDocument* pThis, int nPart)
pDoc->setPart( nPart );
}
+static char* doc_getPartPageRectangles(LibreOfficeKitDocument* pThis)
+{
+ ITiledRenderable* pDoc = getTiledRenderable(pThis);
+ if (!pDoc)
+ {
+ gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering";
+ return 0;
+ }
+
+ OUString sRectangles = pDoc->getPartPageRectangles();
+ OString aString = OUStringToOString(sRectangles, RTL_TEXTENCODING_UTF8);
+ char* pMemory = static_cast<char*>(malloc(aString.getLength() + 1));
+ strcpy(pMemory, aString.getStr());
+ return pMemory;
+
+}
+
static char* doc_getPartName(LibreOfficeKitDocument* pThis, int nPart)
{
ITiledRenderable* pDoc = getTiledRenderable(pThis);