Kaydet (Commit) 0b891c85 authored tarafından Mihai Varga's avatar Mihai Varga Kaydeden (comit) Jan Holesovsky

LOK: moved the decalaration of LibLODocument_Impl to make it visible

We needed a better way to test LOK methods that are not app specific,
but are defined in /desktop/source/lib/init.cxx. So the decalaration
needs to be visible.

I also moved the `getStyles` test in the new test file

Change-Id: I98d97dc17a66e72732ca7bd848c131610790f48e
üst e068b3c1
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#*************************************************************************
#
# This file is part of the LibreOffice project.
#
# 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/.
#
#*************************************************************************
$(eval $(call gb_CppunitTest_CppunitTest,desktop_lib))
$(eval $(call gb_CppunitTest_add_exception_objects,desktop_lib, \
desktop/qa/desktop_lib/test_desktop_lib \
))
$(eval $(call gb_CppunitTest_use_libraries,desktop_lib, \
comphelper \
cppu \
cppuhelper \
sal \
sfx \
sofficeapp \
subsequenttest \
sw \
test \
unotest \
vcl \
$(gb_UWINAPI) \
))
$(eval $(call gb_CppunitTest_use_external,desktop_lib,boost_headers))
$(eval $(call gb_CppunitTest_use_api,desktop_lib,\
offapi \
udkapi \
))
$(eval $(call gb_CppunitTest_use_ure,desktop_lib))
$(eval $(call gb_CppunitTest_use_vcl,desktop_lib))
$(eval $(call gb_CppunitTest_use_components,desktop_lib,\
comphelper/util/comphelp \
configmgr/source/configmgr \
filter/source/config/cache/filterconfig1 \
filter/source/storagefilterdetect/storagefd \
framework/util/fwk \
i18npool/util/i18npool \
package/source/xstor/xstor \
package/util/package2 \
sax/source/expatwrap/expwrap \
sfx2/util/sfx \
svl/source/fsstor/fsstorage \
svtools/util/svt \
sw/util/sw \
sw/util/swd \
toolkit/util/tk \
ucb/source/core/ucb1 \
ucb/source/ucp/file/ucpfile1 \
unoxml/source/service/unoxml \
xmloff/util/xo \
))
$(eval $(call gb_CppunitTest_use_configuration,desktop_lib))
# vim: set noet sw=4 ts=4:
...@@ -130,4 +130,8 @@ $(eval $(call gb_Module_add_check_targets,desktop, \ ...@@ -130,4 +130,8 @@ $(eval $(call gb_Module_add_check_targets,desktop, \
CppunitTest_desktop_version \ CppunitTest_desktop_version \
)) ))
$(eval $(call gb_Module_add_check_targets,desktop, \
CppunitTest_desktop_lib \
))
# vim: set ts=4 sw=4 et: # vim: set ts=4 sw=4 et:
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* 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/.
*/
#include <LibreOfficeKit/LibreOfficeKit.h>
#include <com/sun/star/frame/XStorable.hpp>
#include <com/sun/star/lang/XComponent.hpp>
#include <boost/shared_ptr.hpp>
#include "../../source/inc/desktopdllapi.h"
using namespace css;
using namespace boost;
namespace desktop {
struct DESKTOP_DLLPUBLIC LibLODocument_Impl : public _LibreOfficeKitDocument
{
uno::Reference<css::lang::XComponent> mxComponent;
shared_ptr< LibreOfficeKitDocumentClass > m_pDocumentClass;
explicit LibLODocument_Impl(const uno::Reference <css::lang::XComponent> &xComponent);
~LibLODocument_Impl();
};
}
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* 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/.
*/
#include <com/sun/star/frame/Desktop.hpp>
#include <com/sun/star/lang/XComponent.hpp>
#include <com/sun/star/frame/XComponentLoader.hpp>
#include <boost/property_tree/json_parser.hpp>
#include <comphelper/processfactory.hxx>
#include <sfx2/objsh.hxx>
#include <test/unoapi_test.hxx>
#include "../../inc/lib/init.hxx"
using namespace com::sun::star;
using namespace desktop;
class DesktopLOKTest : public UnoApiTest
{
public:
DesktopLOKTest() : UnoApiTest("/desktop/qa/data/")
{
}
virtual ~DesktopLOKTest()
{
}
virtual void setUp() SAL_OVERRIDE
{
UnoApiTest::setUp();
mxDesktop.set(frame::Desktop::create(comphelper::getComponentContext(getMultiServiceFactory())));
};
virtual void tearDown() SAL_OVERRIDE
{
closeDoc();
UnoApiTest::tearDown();
};
LibLODocument_Impl* loadDoc(const char* pName);
void closeDoc();
void runAllTests();
void testGetStyles();
CPPUNIT_TEST_SUITE(DesktopLOKTest);
CPPUNIT_TEST(runAllTests);
CPPUNIT_TEST_SUITE_END();
uno::Reference<lang::XComponent> mxComponent;
};
LibLODocument_Impl* DesktopLOKTest::loadDoc(const char* pName)
{
OUString aFileURL;
createFileURL(OUString::createFromAscii(pName), aFileURL);
mxComponent = loadFromDesktop(aFileURL, "com.sun.star.text.TextDocument");
if (!mxComponent.is())
{
CPPUNIT_ASSERT(false);
}
return new LibLODocument_Impl(mxComponent);
}
void DesktopLOKTest::closeDoc()
{
if (mxComponent.is())
{
closeDocument(mxComponent);
mxComponent.clear();
}
}
void DesktopLOKTest::runAllTests()
{
testGetStyles();
}
void DesktopLOKTest::testGetStyles()
{
LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
boost::property_tree::ptree aTree;
char* pJSON = pDocument->m_pDocumentClass->getStyles(pDocument);
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);
}
}
closeDoc();
}
CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -64,6 +64,7 @@ ...@@ -64,6 +64,7 @@
// We also need to hackily be able to start the main libreoffice thread: // We also need to hackily be able to start the main libreoffice thread:
#include "../app/sofficemain.h" #include "../app/sofficemain.h"
#include "../app/officeipcthread.hxx" #include "../app/officeipcthread.hxx"
#include "../../inc/lib/init.hxx"
using namespace css; using namespace css;
using namespace vcl; using namespace vcl;
...@@ -72,7 +73,6 @@ using namespace utl; ...@@ -72,7 +73,6 @@ using namespace utl;
using namespace boost; using namespace boost;
struct LibLODocument_Impl;
struct LibLibreOffice_Impl; struct LibLibreOffice_Impl;
static LibLibreOffice_Impl *gImpl = NULL; static LibLibreOffice_Impl *gImpl = NULL;
...@@ -237,14 +237,10 @@ static void doc_setGraphicSelection (LibreOfficeKitDocument* pThis, ...@@ -237,14 +237,10 @@ static void doc_setGraphicSelection (LibreOfficeKitDocument* pThis,
static void doc_resetSelection (LibreOfficeKitDocument* pThis); static void doc_resetSelection (LibreOfficeKitDocument* pThis);
static char* doc_getStyles(LibreOfficeKitDocument* pThis); static char* doc_getStyles(LibreOfficeKitDocument* pThis);
struct LibLODocument_Impl : public _LibreOfficeKitDocument
{
uno::Reference<css::lang::XComponent> mxComponent;
shared_ptr< LibreOfficeKitDocumentClass > m_pDocumentClass;
explicit LibLODocument_Impl(const uno::Reference <css::lang::XComponent> &xComponent) : LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XComponent> &xComponent) :
mxComponent( xComponent ) mxComponent( xComponent )
{ {
if (!(m_pDocumentClass = gDocumentClass.lock())) if (!(m_pDocumentClass = gDocumentClass.lock()))
{ {
m_pDocumentClass.reset(new LibreOfficeKitDocumentClass); m_pDocumentClass.reset(new LibreOfficeKitDocumentClass);
...@@ -275,13 +271,12 @@ struct LibLODocument_Impl : public _LibreOfficeKitDocument ...@@ -275,13 +271,12 @@ struct LibLODocument_Impl : public _LibreOfficeKitDocument
gDocumentClass = m_pDocumentClass; gDocumentClass = m_pDocumentClass;
} }
pClass = m_pDocumentClass.get(); pClass = m_pDocumentClass.get();
} }
~LibLODocument_Impl() LibLODocument_Impl::~LibLODocument_Impl()
{ {
mxComponent->dispose(); mxComponent->dispose();
} }
};
static void doc_destroy(LibreOfficeKitDocument *pThis) static void doc_destroy(LibreOfficeKitDocument *pThis)
{ {
......
...@@ -68,7 +68,6 @@ public: ...@@ -68,7 +68,6 @@ public:
void testDocumentTypes( Office* pOffice ); void testDocumentTypes( Office* pOffice );
void testImpressSlideNames( Office* pOffice ); void testImpressSlideNames( Office* pOffice );
void testCalcSheetNames( Office* pOffice ); void testCalcSheetNames( Office* pOffice );
void testGetStyles( Office* pOffice );
#if 0 #if 0
void testOverlay( Office* pOffice ); void testOverlay( Office* pOffice );
#endif #endif
...@@ -95,7 +94,6 @@ void TiledRenderingTest::runAllTests() ...@@ -95,7 +94,6 @@ void TiledRenderingTest::runAllTests()
testDocumentTypes( pOffice.get() ); testDocumentTypes( pOffice.get() );
testImpressSlideNames( pOffice.get() ); testImpressSlideNames( pOffice.get() );
testCalcSheetNames( pOffice.get() ); testCalcSheetNames( pOffice.get() );
testGetStyles( pOffice.get() );
#if 0 #if 0
testOverlay( pOffice.get() ); testOverlay( pOffice.get() );
#endif #endif
...@@ -184,38 +182,6 @@ void TiledRenderingTest::testCalcSheetNames( Office* pOffice ) ...@@ -184,38 +182,6 @@ void TiledRenderingTest::testCalcSheetNames( Office* pOffice )
CPPUNIT_ASSERT( strcmp( pDocument->getPartName( 2 ), "Sheet3" ) == 0 ); 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 #if 0
static void dumpRGBABitmap( const OUString& rPath, const unsigned char* pBuffer, static void dumpRGBABitmap( const OUString& rPath, const unsigned char* pBuffer,
const int nWidth, const int nHeight ) const int nWidth, const int nHeight )
......
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