[Libreoffice-commits] core.git: 5 commits - chart2/source desktop/source include/sal postprocess/CppunitTest_services.mk postprocess/qa svx/source
Stephan Bergmann
sbergman at redhat.com
Thu Feb 12 07:02:28 PST 2015
chart2/source/model/template/ChartType.hxx | 5
chart2/source/model/template/GL3DBarChartTypeTemplate.cxx | 22
chart2/source/model/template/_serviceregistration_charttypes.cxx | 9
desktop/source/splash/spl.component | 3
include/sal/log-areas.dox | 1
postprocess/CppunitTest_services.mk | 2
postprocess/qa/services.cxx | 265 +++++++---
svx/source/tbxctrls/tbunosearchcontrollers.cxx | 9
8 files changed, 217 insertions(+), 99 deletions(-)
New commits:
commit f7cd7b2ce40d39fd890d7bd3d098c9001fb477e5
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Feb 12 16:00:17 2015 +0100
Make CppunitTest_services instantiate even more services
Change-Id: Id9bfb3886e4a9cbc15a7bf7ef3aefa73bd160e3b
diff --git a/include/sal/log-areas.dox b/include/sal/log-areas.dox
index 1612719..783ef4d 100644
--- a/include/sal/log-areas.dox
+++ b/include/sal/log-areas.dox
@@ -494,7 +494,6 @@ certain functionality.
@li @c jvmaccess
@li @c linguistic
@li @c mysqlc
- at li @c postprocess.cppunit
@li @c registry
@li @c reportdesign
@li @c rsc
diff --git a/postprocess/CppunitTest_services.mk b/postprocess/CppunitTest_services.mk
index 00ac87f..afd940a 100644
--- a/postprocess/CppunitTest_services.mk
+++ b/postprocess/CppunitTest_services.mk
@@ -19,6 +19,7 @@ $(eval $(call gb_CppunitTest_use_externals,services, \
$(eval $(call gb_CppunitTest_use_libraries,services, \
cppu \
+ cppuhelper \
sal \
test \
vcl \
@@ -26,6 +27,7 @@ $(eval $(call gb_CppunitTest_use_libraries,services, \
))
$(eval $(call gb_CppunitTest_use_sdk_api,services))
+$(eval $(call gb_CppunitTest_use_api,services,oovbaapi))
$(eval $(call gb_CppunitTest_use_ure,services))
$(eval $(call gb_CppunitTest_use_vcl,services))
diff --git a/postprocess/qa/services.cxx b/postprocess/qa/services.cxx
index 7e3207e..57ee985 100644
--- a/postprocess/qa/services.cxx
+++ b/postprocess/qa/services.cxx
@@ -7,42 +7,61 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+// Try to instantiate as many implementations as possible. Finds all
+// implementations reachable via the service manager. If a given implementation
+// is the only implementor of some service that has a zero-parameter
+// constructor, instantiate the implementation through that service name. If a
+// given implementation does not offer any such contructors (because it does not
+// support any single-interface--based service, or because for each relevant
+// service there are multiple implementations or it does not have an appropriate
+// constructor) but does support at least one accumulation-based service, then
+// instantiate it through its implementation name (a heuristic to identify
+// instantiatable implementations that appears to work well).
+
#include <sal/config.h>
#include <algorithm>
+#include <cassert>
+#include <iostream>
+#include <map>
+#include <utility>
#include <vector>
+#include <com/sun/star/container/XContentEnumerationAccess.hpp>
#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/reflection/XServiceConstructorDescription.hpp>
#include <com/sun/star/reflection/XServiceTypeDescription2.hpp>
+#include <cppuhelper/exc_hlp.hxx>
#include <test/bootstrapfixture.hxx>
#include <vcl/svapp.hxx>
-using namespace css::container;
-using namespace css::reflection;
-using namespace css::uno;
-
namespace {
-class ServicesTest: public test::BootstrapFixture
-{
+OString msg(OUString const & string) {
+ return OUStringToOString(string, osl_getThreadTextEncoding());
+}
+
+class Test: public test::BootstrapFixture {
public:
void test();
- CPPUNIT_TEST_SUITE(ServicesTest);
+ CPPUNIT_TEST_SUITE(Test);
CPPUNIT_TEST(test);
CPPUNIT_TEST_SUITE_END();
-};
-void ServicesTest::test()
-{
- std::vector<OUString> blacklist;
+private:
+ void createInstance(
+ OUString const & name, bool withArguments,
+ std::vector<css::uno::Reference<css::lang::XComponent>> * components);
+};
- // On Windows, blacklist the com.sun.star.report.ReportDefinition service,
- // as its reportdesign::OReportDefinition implementation (in
- // reportdesign/source/core/api/ReportDefinition.cxx) spawns a thread that
- // forever blocks in SendMessageW when no VCL event loop is running
+void Test::test() {
+ // On Windows, blacklist the com.sun.star.comp.report.OReportDefinition
+ // implementation (reportdesign::OReportDefinition in
+ // reportdesign/source/core/api/ReportDefinition.cxx), as it spawns a thread
+ // that forever blocks in SendMessageW when no VCL event loop is running
// (reportdesign::<anon>::FactoryLoader::execute ->
// framework::Desktop::findFrame -> framework::TaskCreator::createTask ->
// <anon>::TaskCreatorService::createInstanceWithArguments ->
@@ -53,76 +72,174 @@ void ServicesTest::test()
// WorkWindow::ImplInit -> ImplBorderWindow::ImplBorderWindow ->
// ImplBorderWindow::ImplInit -> Window::ImplInit ->
// WinSalInstance::CreateFrame -> ImplSendMessage -> SendMessageW):
- blacklist.push_back("com.sun.star.report.ReportDefinition");
-
- Reference< XHierarchicalNameAccess > xTypeManager(
- m_xContext->getValueByName(
- "/singletons/com.sun.star.reflection.theTypeDescriptionManager"),
- UNO_QUERY_THROW );
- Sequence<OUString> s = m_xContext->getServiceManager()->getAvailableServiceNames();
- std::vector< css::uno::Reference<css::lang::XComponent> > comps;
- for (sal_Int32 i = 0; i < s.getLength(); i++)
- {
- if (std::find(blacklist.begin(), blacklist.end(), s[i])
- != blacklist.end())
- {
- continue;
+ std::vector<OUString> blacklist;
+ blacklist.push_back("com.sun.star.comp.report.OReportDefinition");
+
+ //TODO: bug ID
+ blacklist.push_back("SwXMailMerge");
+
+ css::uno::Reference<css::container::XContentEnumerationAccess> enumAcc(
+ m_xContext->getServiceManager(), css::uno::UNO_QUERY_THROW);
+ css::uno::Reference<css::container::XHierarchicalNameAccess> typeMgr(
+ m_xContext->getValueByName(
+ "/singletons/com.sun.star.reflection.theTypeDescriptionManager"),
+ css::uno::UNO_QUERY_THROW);
+ css::uno::Sequence<OUString> serviceNames(
+ m_xContext->getServiceManager()->getAvailableServiceNames());
+ struct Constructor {
+ Constructor(
+ OUString const & theServiceName, bool theDefaultConstructor):
+ serviceName(theServiceName),
+ defaultConstructor(theDefaultConstructor)
+ {}
+ OUString serviceName;
+ bool defaultConstructor;
+ };
+ struct Implementation {
+ Implementation(css::uno::Reference<css::lang::XServiceInfo> theFactory):
+ factory(theFactory), accumulationBased(false) {}
+ css::uno::Reference<css::lang::XServiceInfo> factory;
+ std::vector<Constructor> constructors;
+ bool accumulationBased;
+ };
+ std::map<OUString, Implementation> impls;
+ for (sal_Int32 i = 0; i != serviceNames.getLength(); ++i) {
+ css::uno::Reference<css::container::XEnumeration> serviceImpls1(
+ enumAcc->createContentEnumeration(serviceNames[i]),
+ css::uno::UNO_SET_THROW);
+ std::vector<css::uno::Reference<css::lang::XServiceInfo>> serviceImpls2;
+ while (serviceImpls1->hasMoreElements()) {
+ serviceImpls2.push_back(
+ css::uno::Reference<css::lang::XServiceInfo>(
+ serviceImpls1->nextElement(), css::uno::UNO_QUERY_THROW));
}
- if (!xTypeManager->hasByHierarchicalName(s[i]))
- {
- SAL_WARN(
- "postprocess.cppunit",
- "fantasy service name \"" << s[i] << "\"");
- continue;
+ css::uno::Reference<css::reflection::XServiceTypeDescription2> desc;
+ if (typeMgr->hasByHierarchicalName(serviceNames[i])) {
+ desc.set(
+ typeMgr->getByHierarchicalName(serviceNames[i]),
+ css::uno::UNO_QUERY_THROW);
}
- SAL_WARN(
- "postprocess.cppunit",
- "trying (index: " << i << ") \"" << s[i] << "\"");
- Reference< XServiceTypeDescription2 > xDesc(
- xTypeManager->getByHierarchicalName(s[i]), UNO_QUERY_THROW);
- Sequence< Reference< XServiceConstructorDescription > > xseq = xDesc->getConstructors();
- SAL_WARN_IF(xseq.getLength() == 0, "postprocess.cppunit", "not tested because there is no constructor");
- for (sal_Int32 c = 0; c < xseq.getLength(); c++)
- if (!xseq[c]->getParameters().hasElements())
- {
- Reference< XInterface > instance;
- try
- {
- OString message = OUStringToOString(s[i], RTL_TEXTENCODING_UTF8);
- bool bDefConstructor = xseq[c]->isDefaultConstructor();
- Reference< css::lang::XMultiComponentFactory > serviceManager = m_xContext->getServiceManager();
-
- if( bDefConstructor )
- instance = serviceManager->createInstanceWithContext(s[i], m_xContext);
- else
- instance = serviceManager->createInstanceWithArgumentsAndContext(
- s[i], css::uno::Sequence<css::uno::Any>(), m_xContext);
-
- CPPUNIT_ASSERT_MESSAGE( message.getStr(), instance.is() );
+ if (serviceImpls2.empty()) {
+ if (desc.is()) {
+ CPPUNIT_ASSERT_MESSAGE(
+ (OString(
+ "no implementations of singlie-interface--based \""
+ + msg(serviceNames[i]) + "\"")
+ .getStr()),
+ !desc->isSingleInterfaceBased());
+ std::cout
+ << "accumulation-based service \"" << serviceNames[i]
+ << "\" without implementations\n";
+ } else {
+ std::cout
+ << "fantasy service name \"" << serviceNames[i]
+ << "\" without implementations\n";
+ }
+ } else {
+ for (auto const & j: serviceImpls2) {
+ OUString name(j->getImplementationName());
+ auto k = impls.find(name);
+ if (k == impls.end()) {
+ k = impls.insert(std::make_pair(name, Implementation(j)))
+ .first;
+ } else {
+ CPPUNIT_ASSERT_MESSAGE(
+ (OString(
+ "multiple implementations named \"" + msg(name)
+ + "\"")
+ .getStr()),
+ j == k->second.factory);
}
- catch(const Exception & e)
- {
- OString exc = "Exception thrown while creating " +
- OUStringToOString(s[i] + ": " + e.Message, RTL_TEXTENCODING_UTF8);
- CPPUNIT_FAIL(exc.getStr());
+ if (desc.is()) {
+ if (desc->isSingleInterfaceBased()) {
+ if (serviceImpls2.size() == 1) {
+ css::uno::Sequence<
+ css::uno::Reference<
+ css::reflection::XServiceConstructorDescription>>
+ ctors(desc->getConstructors());
+ for (sal_Int32 l = 0; l != ctors.getLength(); ++l) {
+ if (!ctors[l]->getParameters().hasElements()) {
+ k->second.constructors.push_back(
+ Constructor(
+ serviceNames[i],
+ ctors[l]->isDefaultConstructor()));
+ break;
+ }
+ }
+ }
+ } else {
+ k->second.accumulationBased = true;
+ }
+ } else {
+ std::cout
+ << "implementation \"" << name
+ << "\" supports fantasy service name \""
+ << serviceNames[i] << "\"\n";
}
- css::uno::Reference<css::lang::XComponent> comp(
- instance, css::uno::UNO_QUERY);
- if (comp.is()) {
- comps.push_back(comp);
+ }
+ }
+ }
+ std::vector<css::uno::Reference<css::lang::XComponent>> comps;
+ for (auto const & i: impls) {
+ if (std::find(blacklist.begin(), blacklist.end(), i.first)
+ == blacklist.end())
+ {
+ if (i.second.constructors.empty()) {
+ if (i.second.accumulationBased) {
+ createInstance(i.first, false, &comps);
+ } else {
+ std::cout
+ << "no obvious way to instantiate implementation \""
+ << i.first << "\"\n";
+ }
+ } else {
+ for (auto const & j: i.second.constructors) {
+ createInstance(
+ j.serviceName, !j.defaultConstructor, &comps);
}
}
+ }
}
SolarMutexReleaser rel;
- for (std::vector< css::uno::Reference<css::lang::XComponent> >::iterator i(
- comps.begin());
- i != comps.end(); ++i)
- {
- (*i)->dispose();
+ for (auto const & i: comps) {
+ i->dispose();
+ }
+}
+
+void Test::createInstance(
+ OUString const & name, bool withArguments,
+ std::vector<css::uno::Reference<css::lang::XComponent>> * components)
+{
+ assert(components != nullptr);
+ css::uno::Reference<css::uno::XInterface> inst;
+ try {
+ if (withArguments) {
+ inst = m_xContext->getServiceManager()
+ ->createInstanceWithArgumentsAndContext(
+ name, css::uno::Sequence<css::uno::Any>(), m_xContext);
+ } else {
+ inst = m_xContext->getServiceManager()->createInstanceWithContext(
+ name, m_xContext);
+ }
+ } catch (css::uno::Exception & e) {
+ css::uno::Any a(cppu::getCaughtException());
+ CPPUNIT_FAIL(
+ OString(
+ "creating \"" + msg(name) + "\" caused "
+ + msg(a.getValueTypeName()) + " \"" + msg(e.Message) + "\"")
+ .getStr());
+ }
+ CPPUNIT_ASSERT_MESSAGE(
+ (OString("creating \"" + msg(name) + "\" returned null reference")
+ .getStr()),
+ inst.is());
+ css::uno::Reference<css::lang::XComponent> comp(inst, css::uno::UNO_QUERY);
+ if (comp.is()) {
+ components->push_back(comp);
}
}
-CPPUNIT_TEST_SUITE_REGISTRATION(ServicesTest);
+CPPUNIT_TEST_SUITE_REGISTRATION(Test);
}
commit 5d8dc045f1aafd60a74b781f693d3c168615470b
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Feb 12 15:58:55 2015 +0100
But then again, no need to go via UNO here anyway (cf. previous commit)
Change-Id: I2e5015b9c360fadb6747b5e2e0bd0a62b252312d
diff --git a/chart2/source/model/template/ChartType.hxx b/chart2/source/model/template/ChartType.hxx
index 8b0670a..84831b0 100644
--- a/chart2/source/model/template/ChartType.hxx
+++ b/chart2/source/model/template/ChartType.hxx
@@ -58,6 +58,9 @@ public:
::com::sun::star::uno::XComponentContext > const & xContext );
virtual ~ChartType();
+ /// merge XInterface implementations
+ DECLARE_XINTERFACE()
+
protected:
explicit ChartType( const ChartType & rOther );
@@ -133,8 +136,6 @@ protected:
getPropertySetInfo()
throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
- /// merge XInterface implementations
- DECLARE_XINTERFACE()
/// merge XTypeProvider implementations
DECLARE_XTYPEPROVIDER()
diff --git a/chart2/source/model/template/GL3DBarChartTypeTemplate.cxx b/chart2/source/model/template/GL3DBarChartTypeTemplate.cxx
index 5f373ba..f027fa5 100644
--- a/chart2/source/model/template/GL3DBarChartTypeTemplate.cxx
+++ b/chart2/source/model/template/GL3DBarChartTypeTemplate.cxx
@@ -154,16 +154,12 @@ GL3DBarChartTypeTemplate::getChartTypeForNewSeries( const uno::Sequence<uno::Ref
try
{
- uno::Reference<lang::XMultiServiceFactory> xFact(
- GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW);
- xResult.set(xFact->createInstance(CHART2_SERVICE_NAME_CHARTTYPE_GL3DBAR), uno::UNO_QUERY_THROW);
- uno::Reference<beans::XPropertySet> xCTProp(xResult, uno::UNO_QUERY);
- if (xCTProp.is())
- {
- bool bVal = false;
- getFastPropertyValue(PROP_GL3DCHARTTYPE_ROUNDED_EDGE) >>= bVal;
- xCTProp->setPropertyValue(CHART_UNONAME_ROUNDED_EDGE, uno::makeAny(bVal));
- }
+ rtl::Reference<GL3DBarChartType> chart(
+ new GL3DBarChartType(GetComponentContext()));
+ bool bVal = false;
+ getFastPropertyValue(PROP_GL3DCHARTTYPE_ROUNDED_EDGE) >>= bVal;
+ chart->setPropertyValue(CHART_UNONAME_ROUNDED_EDGE, uno::makeAny(bVal));
+ xResult = chart.get();
}
catch (const uno::Exception & ex)
{
commit e47f9d0e8beb8ea1f6f36f3983c8405bd4a25533
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Feb 12 15:38:14 2015 +0100
Add missing registration of GL3DBarChartType in g_entries_chart2_charttypes
...looks like it just got forgotten in 05efb605b36ea340762ef1583b3aea6a6b5cdddb
"Add a new skeleton plotter for the GL3D bar chart."
Change-Id: I54b7164d3702de6bdbcc3c3e21ea5569ada0336b
diff --git a/chart2/source/model/template/GL3DBarChartTypeTemplate.cxx b/chart2/source/model/template/GL3DBarChartTypeTemplate.cxx
index 4440db5..5f373ba 100644
--- a/chart2/source/model/template/GL3DBarChartTypeTemplate.cxx
+++ b/chart2/source/model/template/GL3DBarChartTypeTemplate.cxx
@@ -154,9 +154,9 @@ GL3DBarChartTypeTemplate::getChartTypeForNewSeries( const uno::Sequence<uno::Ref
try
{
-#if 1
- // I gave up trying to use UNO just to instantiate this little thing...
- xResult.set(new GL3DBarChartType(GetComponentContext()));
+ uno::Reference<lang::XMultiServiceFactory> xFact(
+ GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW);
+ xResult.set(xFact->createInstance(CHART2_SERVICE_NAME_CHARTTYPE_GL3DBAR), uno::UNO_QUERY_THROW);
uno::Reference<beans::XPropertySet> xCTProp(xResult, uno::UNO_QUERY);
if (xCTProp.is())
{
@@ -164,12 +164,6 @@ GL3DBarChartTypeTemplate::getChartTypeForNewSeries( const uno::Sequence<uno::Ref
getFastPropertyValue(PROP_GL3DCHARTTYPE_ROUNDED_EDGE) >>= bVal;
xCTProp->setPropertyValue(CHART_UNONAME_ROUNDED_EDGE, uno::makeAny(bVal));
}
-#else
- // This never works for me.
- uno::Reference<lang::XMultiServiceFactory> xFact(
- GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW);
- xResult.set(xFact->createInstance(CHART2_SERVICE_NAME_CHARTTYPE_GL3DBAR), uno::UNO_QUERY_THROW);
-#endif
}
catch (const uno::Exception & ex)
{
diff --git a/chart2/source/model/template/_serviceregistration_charttypes.cxx b/chart2/source/model/template/_serviceregistration_charttypes.cxx
index 299f162..52b829b 100644
--- a/chart2/source/model/template/_serviceregistration_charttypes.cxx
+++ b/chart2/source/model/template/_serviceregistration_charttypes.cxx
@@ -23,6 +23,7 @@
#include "BarChartType.hxx"
#include "CandleStickChartType.hxx"
#include "ColumnChartType.hxx"
+#include "GL3DBarChartType.hxx"
#include "LineChartType.hxx"
#include "NetChartType.hxx"
#include "FilledNetChartType.hxx"
@@ -114,6 +115,14 @@ static const struct ::cppu::ImplementationEntry g_entries_chart2_charttypes[] =
, 0
, 0
}
+ ,{
+ ::chart::GL3DBarChartType::create
+ , ::chart::GL3DBarChartType::getImplementationName_Static
+ , ::chart::GL3DBarChartType::getSupportedServiceNames_Static
+ , ::cppu::createSingleComponentFactory
+ , 0
+ , 0
+ }
,{ 0, 0, 0, 0, 0, 0 }
};
commit 5a28f236523b8fa81f793264cd27a02668c94dd3
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Feb 12 14:52:10 2015 +0100
Fix null pointer dereference
...when FindTextToolbarController instance is immediately disposed after
creation (as will happen in to-be-updated CppunitTest_services).
Change-Id: I459f2b2ac3eecc728b45e8493c3f8988a6c121a1
diff --git a/svx/source/tbxctrls/tbunosearchcontrollers.cxx b/svx/source/tbxctrls/tbunosearchcontrollers.cxx
index 617d660..a60f9cc 100644
--- a/svx/source/tbxctrls/tbunosearchcontrollers.cxx
+++ b/svx/source/tbxctrls/tbunosearchcontrollers.cxx
@@ -416,9 +416,12 @@ void SAL_CALL FindTextToolbarController::dispose() throw ( css::uno::RuntimeExce
SearchToolbarControllersManager::createControllersManager().freeController(m_xFrame, css::uno::Reference< css::frame::XStatusListener >(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY), m_aCommandURL);
svt::ToolboxController::dispose();
- SearchToolbarControllersManager::createControllersManager().saveSearchHistory(m_pFindTextFieldControl);
- delete m_pFindTextFieldControl;
- m_pFindTextFieldControl = 0;
+ if (m_pFindTextFieldControl != nullptr) {
+ SearchToolbarControllersManager::createControllersManager()
+ .saveSearchHistory(m_pFindTextFieldControl);
+ delete m_pFindTextFieldControl;
+ m_pFindTextFieldControl = 0;
+ }
}
// XInitialization
commit 8d704bb8672eb95e8cbce260668cb2ebe81f2834
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Feb 12 14:09:29 2015 +0100
Remove dead implementation specification
...left over from 287bc0aab7a848b991266586737b53630332b987 "Kill the migration
wizard for good."
Change-Id: I3f4ba5147f3bf840c47078d20152988a0e40e45d
diff --git a/desktop/source/splash/spl.component b/desktop/source/splash/spl.component
index d69c451..bc0ff98 100644
--- a/desktop/source/splash/spl.component
+++ b/desktop/source/splash/spl.component
@@ -19,9 +19,6 @@
<component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
prefix="spl" xmlns="http://openoffice.org/2010/uno-components">
- <implementation name="com.sun.star.comp.desktop.FirstStart">
- <service name="com.sun.star.task.Job"/>
- </implementation>
<implementation name="com.sun.star.office.comp.SplashScreen">
<service name="com.sun.star.office.SplashScreen"/>
</implementation>
More information about the Libreoffice-commits
mailing list