summaryrefslogtreecommitdiff
path: root/libreofficekit/qa/unit
diff options
context:
space:
mode:
authorMihai Varga <mihai.varga@collabora.com>2015-08-17 18:49:40 +0300
committerMihai Varga <mihai.varga@collabora.com>2015-08-18 13:04:35 +0300
commitc5a516bd1bf0216ee39f31322369f6bffdf464eb (patch)
treeb4641152ef602ac4f03a17062aec4a9c91c928b1 /libreofficekit/qa/unit
parent0405975042e91e5cca56068ad0d16ad8ab910737 (diff)
lok::Document getStyles method
This method returns a JSON mapping of style families to a list of styles from the corresponding family. Will be used to know and apply styles in tiledrendering. Change-Id: I0aa395c40b9573920ade44255f97c077475ae5f1
Diffstat (limited to 'libreofficekit/qa/unit')
-rw-r--r--libreofficekit/qa/unit/tiledrendering.cxx35
1 files changed, 35 insertions, 0 deletions
diff --git a/libreofficekit/qa/unit/tiledrendering.cxx b/libreofficekit/qa/unit/tiledrendering.cxx
index 0ebbc6a09a1e..a4e552507c39 100644
--- a/libreofficekit/qa/unit/tiledrendering.cxx
+++ b/libreofficekit/qa/unit/tiledrendering.cxx
@@ -9,6 +9,7 @@
#include <memory>
#include <boost/scoped_ptr.hpp>
+#include <boost/property_tree/json_parser.hpp>
#include <cppunit/TestFixture.h>
#include <cppunit/plugin/TestPlugIn.h>
#include <cppunit/extensions/HelperMacros.h>
@@ -67,6 +68,7 @@ public:
void testDocumentTypes( Office* pOffice );
void testImpressSlideNames( Office* pOffice );
void testCalcSheetNames( Office* pOffice );
+ void testGetStyles( Office* pOffice );
#if 0
void testOverlay( Office* pOffice );
#endif
@@ -93,6 +95,7 @@ void TiledRenderingTest::runAllTests()
testDocumentTypes( pOffice.get() );
testImpressSlideNames( pOffice.get() );
testCalcSheetNames( pOffice.get() );
+ testGetStyles( pOffice.get() );
#if 0
testOverlay( pOffice.get() );
#endif
@@ -181,6 +184,38 @@ void TiledRenderingTest::testCalcSheetNames( Office* pOffice )
CPPUNIT_ASSERT( strcmp( pDocument->getPartName( 2 ), "Sheet3" ) == 0 );
}
+void TiledRenderingTest::testGetStyles( Office* pOffice )
+{
+ const string sDocPath = m_sSrcRoot + "/libreofficekit/qa/data/blank_text.odt";
+ const string sLockFile = m_sSrcRoot +"/libreofficekit/qa/data/.~lock.blank_text.odt#";
+
+ // FIXME: LOK will fail when trying to open a locked file
+ remove( sLockFile.c_str() );
+
+ scoped_ptr< Document> pDocument( pOffice->documentLoad( sDocPath.c_str() ) );
+
+ boost::property_tree::ptree aTree;
+ char* pJSON = pDocument->getStyles();
+ std::stringstream aStream(pJSON);
+ boost::property_tree::read_json(aStream, aTree);
+ CPPUNIT_ASSERT( aTree.size() > 0 );
+
+ for (const std::pair<std::string, boost::property_tree::ptree>& rPair : aTree)
+ {
+ CPPUNIT_ASSERT( rPair.second.size() > 0);
+ if (rPair.first != "CharacterStyles" &&
+ rPair.first != "ParagraphStyles" &&
+ rPair.first != "FrameStyles" &&
+ rPair.first != "PageStyles" &&
+ rPair.first != "NumberingStyles" &&
+ rPair.first != "CellStyles" &&
+ rPair.first != "ShapeStyles")
+ {
+ CPPUNIT_FAIL("Unknown style family: " + rPair.first);
+ }
+ }
+}
+
#if 0
static void dumpRGBABitmap( const OUString& rPath, const unsigned char* pBuffer,
const int nWidth, const int nHeight )