Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
949279c8
Kaydet (Commit)
949279c8
authored
Agu 05, 2014
tarafından
Laurent Godard
Kaydeden (comit)
Markus Mohrhard
Agu 07, 2014
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
XStyleLoader2 loadStylesFromDocument - unit tests
Change-Id: Id143689f573e6f8585db9bc48a252e311ff0e721
üst
41e05f48
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
380 additions
and
1 deletion
+380
-1
xstyleloader.hxx
include/test/sheet/xstyleloader.hxx
+41
-0
CppunitTest_sc_styleloaderobj.mk
sc/CppunitTest_sc_styleloaderobj.mk
+109
-0
Module_sc.mk
sc/Module_sc.mk
+2
-1
scstyleloaderobj.cxx
sc/qa/extras/scstyleloaderobj.cxx
+126
-0
ScStyleLoaderObj.ods
sc/qa/extras/testdocuments/ScStyleLoaderObj.ods
+0
-0
Library_subsequenttest.mk
test/Library_subsequenttest.mk
+1
-0
xstyleloader.cxx
test/source/sheet/xstyleloader.cxx
+101
-0
No files found.
include/test/sheet/xstyleloader.hxx
0 → 100644
Dosyayı görüntüle @
949279c8
/* -*- 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/.
*/
#ifndef INCLUDED_TEST_SHEET_XSTYLELOADER_HXX
#define INCLUDED_TEST_SHEET_XSTYLELOADER_HXX
#include <rtl/ustring.hxx>
#include <com/sun/star/style/XStyleLoader2.hpp>
#include <test/testdllapi.hxx>
namespace
apitest
{
class
OOO_DLLPUBLIC_TEST
XStyleLoader
{
public
:
virtual
css
::
uno
::
Reference
<
css
::
uno
::
XInterface
>
init
()
=
0
;
virtual
OUString
getTestURL
()
=
0
;
virtual
css
::
uno
::
Reference
<
css
::
lang
::
XComponent
>
getTargetComponent
()
=
0
;
virtual
css
::
uno
::
Reference
<
css
::
lang
::
XComponent
>
getSourceComponent
()
=
0
;
// XStyleLoader
void
testLoadStylesFromURL
();
// XStyleLoader2
void
testLoadStylesFromDocument
();
protected
:
~
XStyleLoader
()
{}
};
}
#endif // INCLUDED_TEST_SHEET_XSTYLELOADER_HXX
\ No newline at end of file
sc/CppunitTest_sc_styleloaderobj.mk
0 → 100644
Dosyayı görüntüle @
949279c8
# -*- 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,sc_styleloaderobj))
$(eval $(call gb_CppunitTest_use_external,sc_styleloaderobj,boost_headers))
$(eval $(call gb_CppunitTest_add_exception_objects,sc_styleloaderobj, \
sc/qa/extras/scstyleloaderobj \
))
$(eval $(call gb_CppunitTest_use_libraries,sc_styleloaderobj, \
basegfx \
comphelper \
cppu \
cppuhelper \
drawinglayer \
editeng \
for \
forui \
i18nlangtag \
msfilter \
oox \
sal \
salhelper \
sax \
sb \
sc \
sfx \
sot \
subsequenttest \
svl \
svt \
svx \
svxcore \
test \
tk \
tl \
ucbhelper \
unotest \
utl \
vbahelper \
vcl \
xo \
$(gb_UWINAPI) \
))
$(eval $(call gb_CppunitTest_set_include,sc_styleloaderobj,\
-I$(SRCDIR)/sc/source/ui/inc \
-I$(SRCDIR)/sc/inc \
$$(INCLUDE) \
))
$(eval $(call gb_CppunitTest_use_api,sc_styleloaderobj,\
offapi \
udkapi \
))
$(eval $(call gb_CppunitTest_use_ure,sc_styleloaderobj))
$(eval $(call gb_CppunitTest_use_vcl,sc_styleloaderobj))
$(eval $(call gb_CppunitTest_use_components,sc_styleloaderobj,\
basic/util/sb \
comphelper/util/comphelp \
configmgr/source/configmgr \
dbaccess/util/dba \
filter/source/config/cache/filterconfig1 \
filter/source/storagefilterdetect/storagefd \
forms/util/frm \
framework/util/fwk \
i18npool/util/i18npool \
linguistic/source/lng \
oox/util/oox \
package/source/xstor/xstor \
package/util/package2 \
sax/source/expatwrap/expwrap \
scripting/source/basprov/basprov \
scripting/util/scriptframe \
sc/util/sc \
sc/util/scd \
sc/util/scfilt \
$(if $(filter TRUE,$(DISABLE_SCRIPTING)),, \
sc/util/vbaobj) \
sfx2/util/sfx \
sot/util/sot \
svl/source/fsstor/fsstorage \
toolkit/util/tk \
ucb/source/core/ucb1 \
ucb/source/ucp/file/ucpfile1 \
ucb/source/ucp/tdoc/ucptdoc1 \
unotools/util/utl \
unoxml/source/rdf/unordf \
unoxml/source/service/unoxml \
xmloff/util/xo \
))
$(eval $(call gb_CppunitTest_use_configuration,sc_styleloaderobj))
$(eval $(call gb_CppunitTest_use_unittest_configuration,sc_styleloaderobj))
# vim: set noet sw=4 ts=4:
sc/Module_sc.mk
Dosyayı görüntüle @
949279c8
...
...
@@ -72,11 +72,12 @@ $(eval $(call gb_Module_add_subsequentcheck_targets,sc,\
JunitTest_sc_complex \
JunitTest_sc_unoapi \
CppunitTest_sc_outlineobj \
CppunitTest_sc_styleloaderobj \
CppunitTest_sc_annotationobj \
CppunitTest_sc_annotationsobj \
CppunitTest_sc_cellrangeobj \
$(if $(filter-out $(OS),IOS), \
CppunitTest_sc_databaserangeobj) \
CppunitTest_sc_databaserangeobj) \
CppunitTest_sc_datapilottableobj \
CppunitTest_sc_datapilotfieldobj \
CppunitTest_sc_macros_test \
...
...
sc/qa/extras/scstyleloaderobj.cxx
0 → 100644
Dosyayı görüntüle @
949279c8
/* -*- 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 <test/calc_unoapi_test.hxx>
#include <test/sheet/xstyleloader.hxx>
#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
using
namespace
css
;
using
namespace
css
::
uno
;
namespace
sc_apitest
{
#define NUMBER_OF_TESTS 2
class
ScStyleLoaderObj
:
public
CalcUnoApiTest
,
apitest
::
XStyleLoader
{
public
:
ScStyleLoaderObj
();
virtual
void
setUp
();
virtual
void
tearDown
();
virtual
uno
::
Reference
<
uno
::
XInterface
>
init
();
virtual
uno
::
Reference
<
lang
::
XComponent
>
getTargetComponent
();
virtual
uno
::
Reference
<
lang
::
XComponent
>
getSourceComponent
();
virtual
OUString
getTestURL
();
CPPUNIT_TEST_SUITE
(
ScStyleLoaderObj
);
CPPUNIT_TEST
(
testLoadStylesFromURL
);
CPPUNIT_TEST
(
testLoadStylesFromDocument
);
CPPUNIT_TEST_SUITE_END
();
private
:
static
sal_Int32
nTest
;
static
uno
::
Reference
<
lang
::
XComponent
>
mxSourceComponent
;
static
uno
::
Reference
<
lang
::
XComponent
>
mxTargetComponent
;
};
sal_Int32
ScStyleLoaderObj
::
nTest
=
0
;
uno
::
Reference
<
lang
::
XComponent
>
ScStyleLoaderObj
::
mxSourceComponent
;
uno
::
Reference
<
lang
::
XComponent
>
ScStyleLoaderObj
::
mxTargetComponent
;
ScStyleLoaderObj
::
ScStyleLoaderObj
()
:
CalcUnoApiTest
(
"sc/qa/extras/testdocuments"
)
{
}
uno
::
Reference
<
uno
::
XInterface
>
ScStyleLoaderObj
::
init
()
{
return
getTargetComponent
();
}
uno
::
Reference
<
lang
::
XComponent
>
ScStyleLoaderObj
::
getTargetComponent
(){
// target is always an empty document
if
(
mxTargetComponent
.
is
())
closeDocument
(
mxTargetComponent
);
mxTargetComponent
=
loadFromDesktop
(
"private:factory/scalc"
);
return
mxTargetComponent
;
}
uno
::
Reference
<
lang
::
XComponent
>
ScStyleLoaderObj
::
getSourceComponent
(){
if
(
mxSourceComponent
.
is
())
closeDocument
(
mxSourceComponent
);
// get the test file url
OUString
aFileURL
=
getTestURL
();
if
(
!
mxSourceComponent
.
is
())
mxSourceComponent
=
loadFromDesktop
(
aFileURL
);
CPPUNIT_ASSERT_MESSAGE
(
"Component not loaded"
,
mxSourceComponent
.
is
());
return
mxSourceComponent
;
}
OUString
ScStyleLoaderObj
::
getTestURL
(){
OUString
aFileURL
;
createFileURL
(
OUString
(
"ScStyleLoaderObj.ods"
),
aFileURL
);
return
aFileURL
;
}
void
ScStyleLoaderObj
::
setUp
()
{
nTest
++
;
CalcUnoApiTest
::
setUp
();
}
void
ScStyleLoaderObj
::
tearDown
()
{
if
(
nTest
==
NUMBER_OF_TESTS
)
{
if
(
mxSourceComponent
.
is
())
closeDocument
(
mxSourceComponent
);
if
(
mxTargetComponent
.
is
())
closeDocument
(
mxTargetComponent
);
}
CalcUnoApiTest
::
tearDown
();
}
CPPUNIT_TEST_SUITE_REGISTRATION
(
ScStyleLoaderObj
);
}
CPPUNIT_PLUGIN_IMPLEMENT
();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file
sc/qa/extras/testdocuments/ScStyleLoaderObj.ods
0 → 100644
Dosyayı görüntüle @
949279c8
File added
test/Library_subsequenttest.mk
Dosyayı görüntüle @
949279c8
...
...
@@ -62,6 +62,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\
test/source/sheet/xsheetannotation \
test/source/sheet/xsheetannotations \
test/source/sheet/xsheetoutline \
test/source/sheet/xstyleloader \
test/source/text/xtext \
test/source/text/xtextfield \
test/source/text/xtextcontent \
...
...
test/source/sheet/xstyleloader.cxx
0 → 100644
Dosyayı görüntüle @
949279c8
/* -*- 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 <test/sheet/xstyleloader.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
#include <com/sun/star/container/XNameContainer.hpp>
#include <com/sun/star/style/XStyleLoader.hpp>
#include <com/sun/star/style/XStyleLoader2.hpp>
#include <com/sun/star/style/XStyle.hpp>
#include <rtl/ustring.hxx>
#include "cppunit/extensions/HelperMacros.h"
using
namespace
css
;
using
namespace
css
::
uno
;
namespace
apitest
{
void
XStyleLoader
::
testLoadStylesFromURL
()
{
uno
::
Reference
<
sheet
::
XSpreadsheetDocument
>
xTargetDoc
(
init
(),
UNO_QUERY_THROW
);
OUString
aFileURL
=
getTestURL
();
uno
::
Reference
<
style
::
XStyleFamiliesSupplier
>
xFamilySupplier
(
xTargetDoc
,
UNO_QUERY_THROW
);
uno
::
Reference
<
style
::
XStyleLoader
>
xTargetStyleLoader
(
xFamilySupplier
->
getStyleFamilies
(),
UNO_QUERY_THROW
);
uno
::
Sequence
<
beans
::
PropertyValue
>
aOptions
=
xTargetStyleLoader
->
getStyleLoaderOptions
();
xTargetStyleLoader
->
loadStylesFromURL
(
aFileURL
,
aOptions
);
// check if targetDocument has myStyle
uno
::
Reference
<
container
::
XNameAccess
>
xFamilies
(
xFamilySupplier
->
getStyleFamilies
(),
UNO_QUERY_THROW
);
uno
::
Reference
<
container
::
XNameContainer
>
xCellStyles
(
xFamilies
->
getByName
(
"CellStyles"
),
UNO_QUERY_THROW
);
CPPUNIT_ASSERT_MESSAGE
(
"Style not imported"
,
xCellStyles
->
hasByName
(
"myStyle"
));
// test the backgroundcolor is correctly imported
uno
::
Reference
<
style
::
XStyle
>
xMyStyle
(
xCellStyles
->
getByName
(
"myStyle"
),
UNO_QUERY_THROW
);
uno
::
Reference
<
beans
::
XPropertySet
>
xPropSet
(
xMyStyle
,
UNO_QUERY_THROW
);
OUString
aCellStyleName
(
"CellBackColor"
);
uno
::
Any
aBackColor
=
xPropSet
->
getPropertyValue
(
aCellStyleName
);
uno
::
Any
expectedBackColor
(
16724787
);
CPPUNIT_ASSERT_EQUAL_MESSAGE
(
"Wrong CellBackColor"
,
expectedBackColor
,
aBackColor
);
}
void
XStyleLoader
::
testLoadStylesFromDocument
()
{
uno
::
Reference
<
sheet
::
XSpreadsheetDocument
>
xTargetDoc
(
init
(),
UNO_QUERY_THROW
);
uno
::
Reference
<
lang
::
XComponent
>
xSourceDoc
(
getSourceComponent
(),
UNO_QUERY_THROW
);
uno
::
Reference
<
style
::
XStyleFamiliesSupplier
>
xFamilySupplier
(
xTargetDoc
,
UNO_QUERY_THROW
);
uno
::
Reference
<
style
::
XStyleLoader2
>
xTargetStyleLoader
(
xFamilySupplier
->
getStyleFamilies
(),
UNO_QUERY_THROW
);
uno
::
Sequence
<
beans
::
PropertyValue
>
aOptions
=
xTargetStyleLoader
->
getStyleLoaderOptions
();
xTargetStyleLoader
->
loadStylesFromDocument
(
xSourceDoc
,
aOptions
);
// check if targetDocument has myStyle
uno
::
Reference
<
container
::
XNameAccess
>
xFamilies
(
xFamilySupplier
->
getStyleFamilies
(),
UNO_QUERY_THROW
);
uno
::
Reference
<
container
::
XNameContainer
>
xCellStyles
(
xFamilies
->
getByName
(
"CellStyles"
),
UNO_QUERY_THROW
);
CPPUNIT_ASSERT_MESSAGE
(
"Style not imported"
,
xCellStyles
->
hasByName
(
"myStyle"
));
// test the backgroundcolor is correctly imported
uno
::
Reference
<
style
::
XStyle
>
xMyStyle
(
xCellStyles
->
getByName
(
"myStyle"
),
UNO_QUERY_THROW
);
uno
::
Reference
<
beans
::
XPropertySet
>
xPropSet
(
xMyStyle
,
UNO_QUERY_THROW
);
OUString
aCellStyleName
(
"CellBackColor"
);
uno
::
Any
aBackColor
=
xPropSet
->
getPropertyValue
(
aCellStyleName
);
uno
::
Any
expectedBackColor
(
16724787
);
CPPUNIT_ASSERT_EQUAL_MESSAGE
(
"Wrong CellBackColor"
,
expectedBackColor
,
aBackColor
);
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment