/* -*- 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/.
*/
namespace
{ /// Sample interception implementation that asserts getInterceptedURLs() and queryDispatch() is in sync. class MyInterceptor
: public cppu::WeakImplHelper<frame::XDispatchProviderInterceptor, frame::XInterceptorInfo>
{
std::mutex maMutex;
uno::Reference<frame::XDispatchProvider> m_xMaster;
uno::Reference<frame::XDispatchProvider> m_xSlave;
uno::Sequence<OUString> m_aDisabledCommands; int m_nExpected; int m_nUnexpected;
public:
MyInterceptor();
/// Number of queryDispatch() calls that operate on a command advertised by getInterceptedURLs(). int getExpected(); /// Number of queryDispatch() calls that operate on a command not advertised by getInterceptedURLs(). int getUnexpected();
dispatchCommand(mxComponent, u".uno:Bold"_ustr, {});
CPPUNIT_ASSERT_GREATER(0, pInterceptor->getExpected());
CPPUNIT_ASSERT_EQUAL(0, pInterceptor->getUnexpected());
dispatchCommand(mxComponent, u".uno:Italic"_ustr, {}); // This was 1: MyInterceptor::queryDispatch() was called for .uno:Italic.
CPPUNIT_ASSERT_EQUAL(0, pInterceptor->getUnexpected());
}
CPPUNIT_TEST_FIXTURE(DispatchTest, testSfxOfficeDispatchDispose)
{ // this test doesn't work with a new document because of aURL.Main check in SfxBaseController::dispatch()
loadFromFile(u"empty.fodp");
uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
CPPUNIT_ASSERT(xModel.is());
uno::Reference<frame::XController> xController(xModel->getCurrentController());
CPPUNIT_ASSERT(xController.is());
uno::Reference<frame::XDispatchProvider> xFrame(xController->getFrame(), uno::UNO_QUERY);
CPPUNIT_ASSERT(xFrame.is());
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.