Remove unused ReadOnlyModeObserver

Change-Id: I572aea574eeba411441559e538d2438de12e9581
This commit is contained in:
Julien Nabet
2012-10-06 09:23:38 +02:00
parent 27fafb78f1
commit 2d45ed51ea
3 changed files with 0 additions and 348 deletions

View File

@@ -257,7 +257,6 @@ $(eval $(call gb_Library_add_exception_objects,sd,\
sd/source/ui/framework/module/ImpressModule \
sd/source/ui/framework/module/ModuleController \
sd/source/ui/framework/module/PresentationModule \
sd/source/ui/framework/module/ReadOnlyModeObserver \
sd/source/ui/framework/module/ResourceManager \
sd/source/ui/framework/module/ShellStackGuard \
sd/source/ui/framework/module/SlideSorterModule \

View File

@@ -1,215 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#include "ReadOnlyModeObserver.hxx"
#include <com/sun/star/drawing/framework/XControllerManager.hpp>
#include <com/sun/star/lang/DisposedException.hpp>
#include <com/sun/star/util/URLTransformer.hpp>
#include <com/sun/star/util/XURLTransformer.hpp>
#include <comphelper/processfactory.hxx>
#include <cppuhelper/interfacecontainer.hxx>
#include "tools/SlotStateListener.hxx"
#include "framework/FrameworkHelper.hxx"
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star;
using namespace ::com::sun::star::drawing::framework;
using ::rtl::OUString;
namespace sd { namespace framework {
class ReadOnlyModeObserver::ModifyBroadcaster
: public ::cppu::OBroadcastHelper
{
public:
explicit ModifyBroadcaster (::osl::Mutex& rOslMutex) : ::cppu::OBroadcastHelper(rOslMutex) {}
};
ReadOnlyModeObserver::ReadOnlyModeObserver (
const Reference<frame::XController>& rxController)
: ReadOnlyModeObserverInterfaceBase(maMutex),
maSlotNameURL(),
mxController(rxController),
mxConfigurationController(NULL),
mxDispatch(NULL),
mpBroadcaster(new ModifyBroadcaster(maMutex))
{
// Create a URL object for the slot name.
maSlotNameURL.Complete = ".uno:EditDoc";
Reference<util::XURLTransformer> xTransformer(util::URLTransformer::create(::comphelper::getProcessComponentContext()));
xTransformer->parseStrict(maSlotNameURL);
if ( ! ConnectToDispatch())
{
// The controller is not yet connected to a frame. This means that
// the dispatcher is not yet set up. We wait for this to happen by
// waiting for configuration updates and try again.
Reference<XControllerManager> xControllerManager (rxController, UNO_QUERY);
if (xControllerManager.is())
{
mxConfigurationController = xControllerManager->getConfigurationController();
if (mxConfigurationController.is())
{
mxConfigurationController->addConfigurationChangeListener(
this,
FrameworkHelper::msConfigurationUpdateStartEvent,
Any());
}
}
}
}
ReadOnlyModeObserver::~ReadOnlyModeObserver (void)
{
}
void SAL_CALL ReadOnlyModeObserver::disposing (void)
{
if (mxController.is())
{
mxController = NULL;
}
if (mxConfigurationController.is())
{
mxConfigurationController->removeConfigurationChangeListener(this);
mxConfigurationController = NULL;
}
if (mxDispatch.is())
{
mxDispatch->removeStatusListener(this, maSlotNameURL);
mxDispatch = NULL;
}
lang::EventObject aEvent;
aEvent.Source = static_cast<XWeak*>(this);
::cppu::OInterfaceContainerHelper* pIterator
= mpBroadcaster->getContainer(getCppuType((Reference<frame::XStatusListener>*)NULL));
pIterator->disposeAndClear(aEvent);
}
void ReadOnlyModeObserver::AddStatusListener (
const Reference<frame::XStatusListener>& rxListener)
{
mpBroadcaster->addListener(
getCppuType((Reference<frame::XStatusListener>*)NULL),
rxListener);
}
bool ReadOnlyModeObserver::ConnectToDispatch (void)
{
if ( ! mxDispatch.is())
{
// Get the dispatch object.
Reference<frame::XDispatchProvider> xProvider (mxController->getFrame(), UNO_QUERY);
if (xProvider.is())
{
mxDispatch = xProvider->queryDispatch(maSlotNameURL, OUString(), 0);
if (mxDispatch.is())
{
mxDispatch->addStatusListener(this, maSlotNameURL);
}
}
}
return mxDispatch.is();
}
void ReadOnlyModeObserver::statusChanged (const frame::FeatureStateEvent& rEvent)
throw (RuntimeException)
{
::cppu::OInterfaceContainerHelper* pIterator
= mpBroadcaster->getContainer(getCppuType((Reference<frame::XStatusListener>*)NULL));
if (pIterator != NULL)
{
pIterator->notifyEach(&frame::XStatusListener::statusChanged, rEvent);
}
}
//----- XEventListener --------------------------------------------------------
void SAL_CALL ReadOnlyModeObserver::disposing (
const lang::EventObject& rEvent)
throw (RuntimeException)
{
if (rEvent.Source == mxConfigurationController)
mxConfigurationController = NULL;
else if (rEvent.Source == mxDispatch)
mxDispatch = NULL;
dispose();
}
void SAL_CALL ReadOnlyModeObserver::notifyConfigurationChange (
const ConfigurationChangeEvent& rEvent)
throw (RuntimeException)
{
if (rEvent.Type.equals(FrameworkHelper::msConfigurationUpdateStartEvent))
{
if (mxController.is() && mxController->getFrame().is())
{
if (ConnectToDispatch())
{
// We have connected successfully to the dispatcher and
// therefore can disconnect from the configuration controller.
mxConfigurationController->removeConfigurationChangeListener(this);
mxConfigurationController = NULL;
}
}
}
}
} } // end of namespace sd::framework
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -1,132 +0,0 @@
/* -*- 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/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef SD_FRAMEWORK_READ_ONLY_MODE_OBSERVER_HXX
#define SD_FRAMEWORK_READ_ONLY_MODE_OBSERVER_HXX
#include "MutexOwner.hxx"
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/frame/XController.hpp>
#include <com/sun/star/frame/XStatusListener.hpp>
#include <com/sun/star/frame/XDispatch.hpp>
#include <com/sun/star/lang/XEventListener.hpp>
#include <com/sun/star/util/XModifyListener.hpp>
#include <com/sun/star/drawing/framework/XConfigurationController.hpp>
#include <com/sun/star/drawing/framework/XConfigurationChangeListener.hpp>
#include <osl/mutex.hxx>
#include <cppuhelper/compbase2.hxx>
#include <boost/function.hpp>
#include <boost/scoped_ptr.hpp>
#include <boost/shared_ptr.hpp>
namespace {
typedef ::cppu::WeakComponentImplHelper2 <
::com::sun::star::drawing::framework::XConfigurationChangeListener,
::com::sun::star::frame::XStatusListener
> ReadOnlyModeObserverInterfaceBase;
} // end of anonymous namespace.
namespace sd { namespace framework {
/** Wait for changes of the read-only mode. On switching between read-only
mode and read-write the registered listeners are called.
This class handles the case that the given controller is not yet
connected to a frame and that the dispatcher is not yet set up. It
waits for this to happen and then registers at the .uno:EditDoc command
and waits for state changes.
*/
class ReadOnlyModeObserver
: private sd::MutexOwner,
public ReadOnlyModeObserverInterfaceBase
{
public:
/** Create a new read-only mode observer for the given controller.
*/
ReadOnlyModeObserver (
const ::com::sun::star::uno::Reference<com::sun::star::frame::XController>& rxController);
virtual ~ReadOnlyModeObserver (void);
virtual void SAL_CALL disposing (void);
/** Add a status listener that is called when the state of the
.uno:EditDoc command changes. Note that the listener has to take
into account both the IsEnabled and the State fields of the
FeatureStateEvent. Only when IsEnabled is true then the State field
is valid.
*/
void AddStatusListener (
const ::com::sun::star::uno::Reference<
com::sun::star::frame::XStatusListener>& rxListener);
// XEventListener
virtual void SAL_CALL disposing (
const com::sun::star::lang::EventObject& rEvent)
throw (com::sun::star::uno::RuntimeException);
// frame::XStatusListener
/** Called by slot state change broadcasters.
@throws DisposedException
*/
virtual void SAL_CALL
statusChanged (
const ::com::sun::star::frame::FeatureStateEvent& rState)
throw (::com::sun::star::uno::RuntimeException);
// XConfigurationChangeListener
virtual void SAL_CALL notifyConfigurationChange (
const ::com::sun::star::drawing::framework::ConfigurationChangeEvent& rEvent)
throw (::com::sun::star::uno::RuntimeException);
private:
::com::sun::star::util::URL maSlotNameURL;
/** The XController is stored to enable repeated calls to
ConnectToDispatch() (get access to the XDispatchProvider.
*/
::com::sun::star::uno::Reference<com::sun::star::frame::XController>
mxController;
::com::sun::star::uno::Reference<com::sun::star::drawing::framework::XConfigurationController>
mxConfigurationController;
::com::sun::star::uno::Reference<com::sun::star::frame::XDispatch>
mxDispatch;
class ModifyBroadcaster;
::boost::scoped_ptr<ModifyBroadcaster> mpBroadcaster;
/** Listen for the .uno:EditMode command. Returns <TRUE/> when the connection
has been established.
*/
bool ConnectToDispatch (void);
};
} } // end of namespace sd::framework
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */