summaryrefslogtreecommitdiff
path: root/sd/source/ui/framework/module
diff options
context:
space:
mode:
Diffstat (limited to 'sd/source/ui/framework/module')
-rw-r--r--sd/source/ui/framework/module/CenterViewFocusModule.cxx195
-rw-r--r--sd/source/ui/framework/module/CenterViewFocusModule.hxx112
-rw-r--r--sd/source/ui/framework/module/DrawModule.cxx56
-rwxr-xr-xsd/source/ui/framework/module/ImpressModule.cxx63
-rwxr-xr-xsd/source/ui/framework/module/ModuleController.cxx341
-rwxr-xr-xsd/source/ui/framework/module/PresentationModule.cxx47
-rwxr-xr-xsd/source/ui/framework/module/ReadOnlyModeObserver.cxx220
-rwxr-xr-xsd/source/ui/framework/module/ReadOnlyModeObserver.hxx139
-rwxr-xr-xsd/source/ui/framework/module/ResourceManager.cxx294
-rwxr-xr-xsd/source/ui/framework/module/ResourceManager.hxx133
-rw-r--r--sd/source/ui/framework/module/ShellStackGuard.cxx192
-rw-r--r--sd/source/ui/framework/module/ShellStackGuard.hxx116
-rw-r--r--sd/source/ui/framework/module/SlideSorterModule.cxx155
-rw-r--r--sd/source/ui/framework/module/SlideSorterModule.hxx69
-rw-r--r--sd/source/ui/framework/module/ToolBarModule.cxx234
-rw-r--r--sd/source/ui/framework/module/ToolBarModule.hxx102
-rw-r--r--sd/source/ui/framework/module/ToolPanelModule.cxx165
-rw-r--r--sd/source/ui/framework/module/ToolPanelModule.hxx49
-rw-r--r--sd/source/ui/framework/module/ViewTabBarModule.cxx220
-rw-r--r--sd/source/ui/framework/module/ViewTabBarModule.hxx107
-rwxr-xr-xsd/source/ui/framework/module/makefile.mk62
21 files changed, 3071 insertions, 0 deletions
diff --git a/sd/source/ui/framework/module/CenterViewFocusModule.cxx b/sd/source/ui/framework/module/CenterViewFocusModule.cxx
new file mode 100644
index 000000000000..32e055144fc3
--- /dev/null
+++ b/sd/source/ui/framework/module/CenterViewFocusModule.cxx
@@ -0,0 +1,195 @@
+/*************************************************************************
+ *
+ * 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 "precompiled_sd.hxx"
+
+#include "CenterViewFocusModule.hxx"
+
+#include "framework/ConfigurationController.hxx"
+#include "framework/FrameworkHelper.hxx"
+#include "framework/ViewShellWrapper.hxx"
+
+#include "DrawController.hxx"
+#include "ViewShellBase.hxx"
+#include "ViewShellManager.hxx"
+#include "strings.hrc"
+#include "sdresid.hxx"
+#include <com/sun/star/drawing/framework/XControllerManager.hpp>
+#include <com/sun/star/drawing/framework/XConfigurationController.hpp>
+
+#include <toolkit/awt/vclxdevice.hxx>
+#include <sfx2/viewfrm.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::drawing::framework;
+
+using ::rtl::OUString;
+using ::sd::framework::FrameworkHelper;
+
+
+namespace sd { namespace framework {
+
+//===== CenterViewFocusModule ====================================================
+
+CenterViewFocusModule::CenterViewFocusModule (Reference<frame::XController>& rxController)
+ : CenterViewFocusModuleInterfaceBase(MutexOwner::maMutex),
+ mbValid(false),
+ mxConfigurationController(),
+ mpBase(NULL),
+ mbNewViewCreated(false)
+{
+ Reference<XControllerManager> xControllerManager (rxController, UNO_QUERY);
+ if (xControllerManager.is())
+ {
+ mxConfigurationController = xControllerManager->getConfigurationController();
+
+ // Tunnel through the controller to obtain a ViewShellBase.
+ Reference<lang::XUnoTunnel> xTunnel (rxController, UNO_QUERY);
+ if (xTunnel.is())
+ {
+ ::sd::DrawController* pController = reinterpret_cast<sd::DrawController*>(
+ xTunnel->getSomething(sd::DrawController::getUnoTunnelId()));
+ if (pController != NULL)
+ mpBase = pController->GetViewShellBase();
+ }
+
+ // Check, if all required objects do exist.
+ if (mxConfigurationController.is() && mpBase!=NULL)
+ {
+ mbValid = true;
+ }
+ }
+
+ if (mbValid)
+ {
+ mxConfigurationController->addConfigurationChangeListener(
+ this,
+ FrameworkHelper::msConfigurationUpdateEndEvent,
+ Any());
+ mxConfigurationController->addConfigurationChangeListener(
+ this,
+ FrameworkHelper::msResourceActivationEvent,
+ Any());
+ }
+}
+
+
+
+
+CenterViewFocusModule::~CenterViewFocusModule (void)
+{
+}
+
+
+
+
+void SAL_CALL CenterViewFocusModule::disposing (void)
+{
+ if (mxConfigurationController.is())
+ mxConfigurationController->removeConfigurationChangeListener(this);
+
+ mbValid = false;
+ mxConfigurationController = NULL;
+ mpBase = NULL;
+}
+
+
+
+
+void SAL_CALL CenterViewFocusModule::notifyConfigurationChange (
+ const ConfigurationChangeEvent& rEvent)
+ throw (RuntimeException)
+{
+ if (mbValid)
+ {
+ if (rEvent.Type.equals(FrameworkHelper::msConfigurationUpdateEndEvent))
+ {
+ HandleNewView(rEvent.Configuration);
+ }
+ else if (rEvent.Type.equals(FrameworkHelper::msResourceActivationEvent))
+ {
+ if (rEvent.ResourceId->getResourceURL().match(FrameworkHelper::msViewURLPrefix))
+ mbNewViewCreated = true;
+ }
+ }
+}
+
+
+
+
+void CenterViewFocusModule::HandleNewView (
+ const Reference<XConfiguration>& rxConfiguration)
+{
+ if (mbNewViewCreated)
+ {
+ mbNewViewCreated = false;
+ // Make the center pane the active one. Tunnel through the
+ // controller to obtain a ViewShell pointer.
+
+ Sequence<Reference<XResourceId> > xViewIds (rxConfiguration->getResources(
+ FrameworkHelper::CreateResourceId(FrameworkHelper::msCenterPaneURL),
+ FrameworkHelper::msViewURLPrefix,
+ AnchorBindingMode_DIRECT));
+ Reference<XView> xView;
+ if (xViewIds.getLength() > 0)
+ xView = Reference<XView>(
+ mxConfigurationController->getResource(xViewIds[0]),UNO_QUERY);
+ Reference<lang::XUnoTunnel> xTunnel (xView, UNO_QUERY);
+ if (xTunnel.is() && mpBase!=NULL)
+ {
+ ViewShellWrapper* pViewShellWrapper = reinterpret_cast<ViewShellWrapper*>(
+ xTunnel->getSomething(ViewShellWrapper::getUnoTunnelId()));
+ if (pViewShellWrapper != NULL)
+ {
+ ::boost::shared_ptr<ViewShell> pViewShell = pViewShellWrapper->GetViewShell();
+ if (pViewShell.get() != NULL)
+ mpBase->GetViewShellManager()->MoveToTop(*pViewShell);
+ }
+ }
+ }
+}
+
+
+
+
+void SAL_CALL CenterViewFocusModule::disposing (
+ const lang::EventObject& rEvent)
+ throw (RuntimeException)
+{
+ if (mxConfigurationController.is())
+ if (rEvent.Source == mxConfigurationController)
+ {
+ mbValid = false;
+ mxConfigurationController = NULL;
+ mpBase = NULL;
+ }
+}
+
+
+
+} } // end of namespace sd::framework
diff --git a/sd/source/ui/framework/module/CenterViewFocusModule.hxx b/sd/source/ui/framework/module/CenterViewFocusModule.hxx
new file mode 100644
index 000000000000..e104b8971fb3
--- /dev/null
+++ b/sd/source/ui/framework/module/CenterViewFocusModule.hxx
@@ -0,0 +1,112 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef SD_FRAMEWORK_CENTER_VIEW_FOCUS_MODULE_HXX
+#define SD_FRAMEWORK_CENTER_VIEW_FOCUS_MODULE_HXX
+
+#include "MutexOwner.hxx"
+
+#include <com/sun/star/drawing/framework/XConfigurationChangeListener.hpp>
+#include <com/sun/star/drawing/framework/XConfigurationController.hpp>
+#include <com/sun/star/frame/XController.hpp>
+#include <osl/mutex.hxx>
+#include <cppuhelper/compbase1.hxx>
+
+
+namespace {
+
+typedef ::cppu::WeakComponentImplHelper1 <
+ ::com::sun::star::drawing::framework::XConfigurationChangeListener
+ > CenterViewFocusModuleInterfaceBase;
+
+} // end of anonymous namespace.
+
+namespace sd {
+
+class ViewShellBase;
+
+}
+
+
+
+
+namespace sd { namespace framework {
+
+/** This module waits for new views to be created for the center pane and
+ then moves the center view to the top most place on the shell stack. As
+ we are moving away from the shell stack this module may become obsolete
+ or has to be modified.
+*/
+class CenterViewFocusModule
+ : private sd::MutexOwner,
+ public CenterViewFocusModuleInterfaceBase
+{
+public:
+ CenterViewFocusModule (
+ ::com::sun::star::uno::Reference<com::sun::star::frame::XController>& rxController);
+ virtual ~CenterViewFocusModule (void);
+
+ virtual void SAL_CALL disposing (void);
+
+
+ // XConfigurationChangeListener
+
+ virtual void SAL_CALL notifyConfigurationChange (
+ const com::sun::star::drawing::framework::ConfigurationChangeEvent& rEvent)
+ throw (com::sun::star::uno::RuntimeException);
+
+ // XEventListener
+
+ virtual void SAL_CALL disposing (
+ const com::sun::star::lang::EventObject& rEvent)
+ throw (com::sun::star::uno::RuntimeException);
+
+private:
+ class ViewShellContainer;
+
+ bool mbValid;
+ ::com::sun::star::uno::Reference<com::sun::star::drawing::framework::XConfigurationController>
+ mxConfigurationController;
+ ViewShellBase* mpBase;
+ /** This flag indicates whether in the last configuration change cycle a
+ new view has been created and thus the center view has to be moved
+ to the top of the shell stack.
+ */
+ bool mbNewViewCreated;
+
+ /** At the end of an update of the current configuration this method
+ handles a new view in the center pane by moving the associated view
+ shell to the top of the shell stack.
+ */
+ void HandleNewView(
+ const ::com::sun::star::uno::Reference<
+ com::sun::star::drawing::framework::XConfiguration>& rxConfiguration);
+};
+
+} } // end of namespace sd::framework
+
+#endif
diff --git a/sd/source/ui/framework/module/DrawModule.cxx b/sd/source/ui/framework/module/DrawModule.cxx
new file mode 100644
index 000000000000..1f1604a3099c
--- /dev/null
+++ b/sd/source/ui/framework/module/DrawModule.cxx
@@ -0,0 +1,56 @@
+/*************************************************************************
+ *
+ * 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 "precompiled_sd.hxx"
+
+#include "framework/DrawModule.hxx"
+
+#include "framework/FrameworkHelper.hxx"
+#include "CenterViewFocusModule.hxx"
+#include "SlideSorterModule.hxx"
+#include "ToolBarModule.hxx"
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+
+
+namespace sd { namespace framework {
+
+
+
+void DrawModule::Initialize (Reference<frame::XController>& rxController)
+{
+ new sd::framework::CenterViewFocusModule(rxController);
+ new sd::framework::SlideSorterModule(
+ rxController,
+ FrameworkHelper::msLeftDrawPaneURL);
+ new ToolBarModule(rxController);
+}
+
+
+} } // end of namespace sd::framework
diff --git a/sd/source/ui/framework/module/ImpressModule.cxx b/sd/source/ui/framework/module/ImpressModule.cxx
new file mode 100755
index 000000000000..a5856bc3ebc9
--- /dev/null
+++ b/sd/source/ui/framework/module/ImpressModule.cxx
@@ -0,0 +1,63 @@
+/*************************************************************************
+ *
+ * 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 "precompiled_sd.hxx"
+
+#include "framework/ImpressModule.hxx"
+
+#include "framework/FrameworkHelper.hxx"
+#include "ViewTabBarModule.hxx"
+#include "CenterViewFocusModule.hxx"
+#include "SlideSorterModule.hxx"
+#include "ToolPanelModule.hxx"
+#include "ToolBarModule.hxx"
+#include "ShellStackGuard.hxx"
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+namespace sd { namespace framework {
+
+
+void ImpressModule::Initialize (Reference<frame::XController>& rxController)
+{
+ new CenterViewFocusModule(rxController);
+ new ViewTabBarModule(
+ rxController,
+ FrameworkHelper::CreateResourceId(
+ FrameworkHelper::msViewTabBarURL,
+ FrameworkHelper::msCenterPaneURL));
+ new SlideSorterModule(
+ rxController,
+ FrameworkHelper::msLeftImpressPaneURL);
+ ToolPanelModule::Initialize(rxController);
+ new ToolBarModule(rxController);
+ new ShellStackGuard(rxController);
+}
+
+
+} } // end of namespace sd::framework
diff --git a/sd/source/ui/framework/module/ModuleController.cxx b/sd/source/ui/framework/module/ModuleController.cxx
new file mode 100755
index 000000000000..e910a8df7496
--- /dev/null
+++ b/sd/source/ui/framework/module/ModuleController.cxx
@@ -0,0 +1,341 @@
+/*************************************************************************
+ *
+ * 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 "precompiled_sd.hxx"
+
+#include "framework/ModuleController.hxx"
+
+#include "tools/ConfigurationAccess.hxx"
+#include <comphelper/processfactory.hxx>
+#include <comphelper/stl_types.hxx>
+#include <boost/bind.hpp>
+#include <hash_map>
+
+#include <tools/diagnose_ex.h>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::drawing::framework;
+using ::rtl::OUString;
+using ::sd::tools::ConfigurationAccess;
+
+#undef VERBOSE
+//#define VERBOSE 2
+
+namespace sd { namespace framework {
+
+static const sal_uInt32 snFactoryPropertyCount (2);
+static const sal_uInt32 snStartupPropertyCount (1);
+
+
+
+
+class ModuleController::ResourceToFactoryMap
+ : public ::std::hash_map<
+ rtl::OUString,
+ rtl::OUString,
+ ::comphelper::UStringHash,
+ ::comphelper::UStringEqual>
+{
+public:
+ ResourceToFactoryMap (void) {}
+};
+
+
+class ModuleController::LoadedFactoryContainer
+ : public ::std::hash_map<
+ rtl::OUString,
+ WeakReference<XInterface>,
+ ::comphelper::UStringHash,
+ ::comphelper::UStringEqual>
+{
+public:
+ LoadedFactoryContainer (void) {}
+};
+
+
+
+
+
+Reference<XInterface> SAL_CALL ModuleController_createInstance (
+ const Reference<XComponentContext>& rxContext)
+{
+ return Reference<XInterface>(ModuleController::CreateInstance(rxContext), UNO_QUERY);
+}
+
+
+
+
+::rtl::OUString ModuleController_getImplementationName (void) throw(RuntimeException)
+{
+ return ::rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.Draw.framework.module.ModuleController"));
+}
+
+
+
+
+Sequence<rtl::OUString> SAL_CALL ModuleController_getSupportedServiceNames (void)
+ throw (RuntimeException)
+{
+ static const ::rtl::OUString sServiceName(
+ ::rtl::OUString::createFromAscii("com.sun.star.drawing.framework.ModuleController"));
+ return Sequence<rtl::OUString>(&sServiceName, 1);
+}
+
+
+
+
+//===== ModuleController ======================================================
+
+Reference<XModuleController> ModuleController::CreateInstance (
+ const Reference<XComponentContext>& rxContext)
+{
+ return new ModuleController(rxContext);
+}
+
+
+
+
+ModuleController::ModuleController (const Reference<XComponentContext>& rxContext) throw()
+ : ModuleControllerInterfaceBase(MutexOwner::maMutex),
+ mxController(),
+ mpResourceToFactoryMap(new ResourceToFactoryMap()),
+ mpLoadedFactories(new LoadedFactoryContainer())
+{
+ (void)rxContext;
+ LoadFactories(rxContext);
+}
+
+
+
+
+ModuleController::~ModuleController (void) throw()
+{
+}
+
+
+
+
+void SAL_CALL ModuleController::disposing (void)
+{
+}
+
+
+
+
+void ModuleController::LoadFactories (const Reference<XComponentContext>& rxContext)
+{
+ try
+ {
+ ConfigurationAccess aConfiguration (
+ rxContext,
+ OUString::createFromAscii("/org.openoffice.Office.Impress/"),
+ ConfigurationAccess::READ_ONLY);
+ Reference<container::XNameAccess> xFactories (
+ aConfiguration.GetConfigurationNode(
+ OUString::createFromAscii("MultiPaneGUI/Framework/ResourceFactories")),
+ UNO_QUERY);
+ ::std::vector<rtl::OUString> aProperties (snFactoryPropertyCount);
+ aProperties[0] = OUString::createFromAscii("ServiceName");
+ aProperties[1] = OUString::createFromAscii("ResourceList");
+ ConfigurationAccess::ForAll(
+ xFactories,
+ aProperties,
+ ::boost::bind(&ModuleController::ProcessFactory, this, _2));
+ }
+ catch (Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+
+
+
+void ModuleController::ProcessFactory (const ::std::vector<Any>& rValues)
+{
+ OSL_ASSERT(rValues.size() == snFactoryPropertyCount);
+
+ // Get the service name of the factory.
+ rtl::OUString sServiceName;
+ rValues[0] >>= sServiceName;
+
+ // Get all resource URLs that are created by the factory.
+ Reference<container::XNameAccess> xResources (rValues[1], UNO_QUERY);
+ ::std::vector<rtl::OUString> aURLs;
+ tools::ConfigurationAccess::FillList(
+ xResources,
+ OUString::createFromAscii("URL"),
+ aURLs);
+
+#if defined VERBOSE && VERBOSE>0
+ OSL_TRACE("ModuleController::adding factory %s",
+ OUStringToOString(sServiceName, RTL_TEXTENCODING_UTF8).getStr());
+#endif
+
+ // Add the resource URLs to the map.
+ ::std::vector<rtl::OUString>::const_iterator iResource;
+ for (iResource=aURLs.begin(); iResource!=aURLs.end(); ++iResource)
+ {
+ (*mpResourceToFactoryMap)[*iResource] = sServiceName;
+#if defined VERBOSE && VERBOSE>1
+ OSL_TRACE(" %s",
+ OUStringToOString(*iResource, RTL_TEXTENCODING_UTF8).getStr());
+#endif
+ }
+}
+
+
+
+
+void ModuleController::InstantiateStartupServices (void)
+{
+ try
+ {
+ tools::ConfigurationAccess aConfiguration (
+ OUString::createFromAscii("/org.openoffice.Office.Impress/"),
+ tools::ConfigurationAccess::READ_ONLY);
+ Reference<container::XNameAccess> xFactories (
+ aConfiguration.GetConfigurationNode(
+ OUString::createFromAscii("MultiPaneGUI/Framework/StartupServices")),
+ UNO_QUERY);
+ ::std::vector<rtl::OUString> aProperties (snStartupPropertyCount);
+ aProperties[0] = OUString::createFromAscii("ServiceName");
+ tools::ConfigurationAccess::ForAll(
+ xFactories,
+ aProperties,
+ ::boost::bind(&ModuleController::ProcessStartupService, this, _2));
+ }
+ catch (Exception&)
+ {
+ OSL_TRACE("ERROR in ModuleController::InstantiateStartupServices");
+ }
+}
+
+
+
+
+void ModuleController::ProcessStartupService (const ::std::vector<Any>& rValues)
+{
+ OSL_ASSERT(rValues.size() == snStartupPropertyCount);
+
+ try
+ {
+ // Get the service name of the startup service.
+ rtl::OUString sServiceName;
+ rValues[0] >>= sServiceName;
+
+ // Instantiate service.
+ Reference<lang::XMultiServiceFactory> xGlobalFactory (
+ ::comphelper::getProcessServiceFactory(), UNO_QUERY);
+ if (xGlobalFactory.is())
+ {
+ // Create the startup service.
+ Sequence<Any> aArguments(1);
+ aArguments[0] <<= mxController;
+ // Note that when the new object will be destroyed at the end of
+ // this scope when it does not register itself anywhere.
+ // Typically it will add itself as ConfigurationChangeListener
+ // at the configuration controller.
+ xGlobalFactory->createInstanceWithArguments(sServiceName, aArguments);
+
+#if defined VERBOSE && VERBOSE>0
+ OSL_TRACE("ModuleController::created startup service %s",
+ OUStringToOString(sServiceName, RTL_TEXTENCODING_UTF8).getStr());
+#endif
+ }
+ }
+ catch (Exception&)
+ {
+ OSL_TRACE("ERROR in ModuleController::ProcessStartupServices");
+ }
+}
+
+
+
+
+//----- XModuleController -----------------------------------------------------
+
+void SAL_CALL ModuleController::requestResource (const OUString& rsResourceURL)
+ throw (RuntimeException)
+{
+ ResourceToFactoryMap::const_iterator iFactory (mpResourceToFactoryMap->find(rsResourceURL));
+ if (iFactory != mpResourceToFactoryMap->end())
+ {
+ // Check that the factory has already been loaded and not been
+ // destroyed in the meantime.
+ Reference<XInterface> xFactory;
+ LoadedFactoryContainer::const_iterator iLoadedFactory (
+ mpLoadedFactories->find(iFactory->second));
+ if (iLoadedFactory != mpLoadedFactories->end())
+ xFactory = Reference<XInterface>(iLoadedFactory->second, UNO_QUERY);
+ if ( ! xFactory.is())
+ {
+ // Create a new instance of the factory.
+ Reference<lang::XMultiServiceFactory> xGlobalFactory (
+ ::comphelper::getProcessServiceFactory(), UNO_QUERY);
+ if (xGlobalFactory.is())
+ {
+ // Create the factory service.
+ Sequence<Any> aArguments(1);
+ aArguments[0] <<= mxController;
+ xFactory = xGlobalFactory->createInstanceWithArguments(
+ iFactory->second,
+ aArguments);
+
+ // Remember that this factory has been instanced.
+ (*mpLoadedFactories)[iFactory->second] = xFactory;
+ }
+ }
+ }
+}
+
+
+
+
+//----- XInitialization -------------------------------------------------------
+
+void SAL_CALL ModuleController::initialize (const Sequence<Any>& aArguments)
+ throw (Exception, RuntimeException)
+{
+ if (aArguments.getLength() > 0)
+ {
+ try
+ {
+ // Get the XController from the first argument.
+ mxController = Reference<frame::XController>(aArguments[0], UNO_QUERY_THROW);
+
+ InstantiateStartupServices();
+ }
+ catch (RuntimeException&)
+ {}
+ }
+}
+
+
+} } // end of namespace sd::framework
diff --git a/sd/source/ui/framework/module/PresentationModule.cxx b/sd/source/ui/framework/module/PresentationModule.cxx
new file mode 100755
index 000000000000..6a5ba5dc5e7f
--- /dev/null
+++ b/sd/source/ui/framework/module/PresentationModule.cxx
@@ -0,0 +1,47 @@
+/*************************************************************************
+ *
+ * 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 "precompiled_sd.hxx"
+
+#include "framework/PresentationModule.hxx"
+
+#include "CenterViewFocusModule.hxx"
+#include "SlideSorterModule.hxx"
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+namespace sd { namespace framework {
+
+
+void PresentationModule::Initialize (Reference<frame::XController>& rxController)
+{
+ new sd::framework::CenterViewFocusModule(rxController);
+}
+
+
+} } // end of namespace sd::framework
diff --git a/sd/source/ui/framework/module/ReadOnlyModeObserver.cxx b/sd/source/ui/framework/module/ReadOnlyModeObserver.cxx
new file mode 100755
index 000000000000..090247e7f68c
--- /dev/null
+++ b/sd/source/ui/framework/module/ReadOnlyModeObserver.cxx
@@ -0,0 +1,220 @@
+/*************************************************************************
+ *
+ * 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 "precompiled_sd.hxx"
+
+#include "ReadOnlyModeObserver.hxx"
+
+#include <com/sun/star/drawing/framework/XControllerManager.hpp>
+#include <com/sun/star/lang/DisposedException.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 = OUString::createFromAscii(".uno:EditDoc");
+ uno::Reference<lang::XMultiServiceFactory> xServiceManager (
+ ::comphelper::getProcessServiceFactory());
+ if (xServiceManager.is())
+ {
+ Reference<util::XURLTransformer> xTransformer(xServiceManager->createInstance(
+ OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.util.URLTransformer"))),
+ UNO_QUERY);
+ if (xTransformer.is())
+ 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
diff --git a/sd/source/ui/framework/module/ReadOnlyModeObserver.hxx b/sd/source/ui/framework/module/ReadOnlyModeObserver.hxx
new file mode 100755
index 000000000000..d783d6d83abf
--- /dev/null
+++ b/sd/source/ui/framework/module/ReadOnlyModeObserver.hxx
@@ -0,0 +1,139 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#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 <tools/link.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
diff --git a/sd/source/ui/framework/module/ResourceManager.cxx b/sd/source/ui/framework/module/ResourceManager.cxx
new file mode 100755
index 000000000000..fcd90ca6454b
--- /dev/null
+++ b/sd/source/ui/framework/module/ResourceManager.cxx
@@ -0,0 +1,294 @@
+/*************************************************************************
+ *
+ * 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 "precompiled_sd.hxx"
+
+#include "ResourceManager.hxx"
+
+#include "framework/FrameworkHelper.hxx"
+#include "framework/ConfigurationController.hxx"
+#include <com/sun/star/drawing/framework/XControllerManager.hpp>
+
+#include <comphelper/stl_types.hxx>
+#include <set>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::drawing::framework;
+
+using ::rtl::OUString;
+using ::sd::framework::FrameworkHelper;
+
+namespace {
+ static const sal_Int32 ResourceActivationRequestEvent = 0;
+ static const sal_Int32 ResourceDeactivationRequestEvent = 1;
+}
+
+
+
+
+namespace sd { namespace framework {
+
+class ResourceManager::MainViewContainer
+ : public ::std::set<OUString, ::comphelper::UStringLess>
+{
+public:
+ MainViewContainer (void) {}
+};
+
+
+
+
+//===== ResourceManager =======================================================
+
+ResourceManager::ResourceManager (
+ const Reference<frame::XController>& rxController,
+ const Reference<XResourceId>& rxResourceId)
+ : ResourceManagerInterfaceBase(MutexOwner::maMutex),
+ mxConfigurationController(),
+ mpActiveMainViewContainer(new MainViewContainer()),
+ mxResourceId(rxResourceId),
+ mxMainViewAnchorId(FrameworkHelper::Instance(rxController)->CreateResourceId(
+ FrameworkHelper::msCenterPaneURL)),
+ msCurrentMainViewURL(),
+ mbIsEnabled(true)
+{
+ Reference<XControllerManager> xControllerManager (rxController, UNO_QUERY);
+ if (xControllerManager.is())
+ {
+ mxConfigurationController = xControllerManager->getConfigurationController();
+
+ if (mxConfigurationController.is())
+ {
+ mxConfigurationController->addConfigurationChangeListener(
+ this,
+ FrameworkHelper::msResourceActivationRequestEvent,
+ makeAny(ResourceActivationRequestEvent));
+ mxConfigurationController->addConfigurationChangeListener(
+ this,
+ FrameworkHelper::msResourceDeactivationRequestEvent,
+ makeAny(ResourceDeactivationRequestEvent));
+ }
+ }
+}
+
+
+
+
+ResourceManager::~ResourceManager (void)
+{
+}
+
+
+
+
+void ResourceManager::AddActiveMainView (
+ const OUString& rsMainViewURL)
+{
+ mpActiveMainViewContainer->insert(rsMainViewURL);
+}
+
+
+
+
+void SAL_CALL ResourceManager::disposing (void)
+{
+ if (mxConfigurationController.is())
+ {
+ mxConfigurationController->removeConfigurationChangeListener(this);
+ mxConfigurationController = NULL;
+ }
+}
+
+
+
+
+void ResourceManager::Enable (void)
+{
+ mbIsEnabled = true;
+ UpdateForMainViewShell();
+}
+
+
+
+
+void ResourceManager::Disable (void)
+{
+ mbIsEnabled = false;
+ UpdateForMainViewShell();
+}
+
+
+
+
+void SAL_CALL ResourceManager::notifyConfigurationChange (
+ const ConfigurationChangeEvent& rEvent)
+ throw (RuntimeException)
+{
+ OSL_ASSERT(rEvent.ResourceId.is());
+
+ sal_Int32 nEventType = 0;
+ rEvent.UserData >>= nEventType;
+ switch (nEventType)
+ {
+ case ResourceActivationRequestEvent:
+ if (rEvent.ResourceId->isBoundToURL(
+ FrameworkHelper::msCenterPaneURL,
+ AnchorBindingMode_DIRECT))
+ {
+ // A resource directly bound to the center pane has been
+ // requested.
+ if (rEvent.ResourceId->getResourceTypePrefix().equals(
+ FrameworkHelper::msViewURLPrefix))
+ {
+ // The requested resource is a view. Show or hide the
+ // resource managed by this ResourceManager accordingly.
+ HandleMainViewSwitch(
+ rEvent.ResourceId->getResourceURL(),
+ rEvent.Configuration,
+ true);
+ }
+ }
+ else if (rEvent.ResourceId->compareTo(mxResourceId) == 0)
+ {
+ // The resource managed by this ResourceManager has been
+ // explicitly been requested (maybe by us). Remember this
+ // setting.
+ HandleResourceRequest(true, rEvent.Configuration);
+ }
+ break;
+
+ case ResourceDeactivationRequestEvent:
+ if (rEvent.ResourceId->compareTo(mxMainViewAnchorId) == 0)
+ {
+ HandleMainViewSwitch(
+ OUString(),
+ rEvent.Configuration,
+ false);
+ }
+ else if (rEvent.ResourceId->compareTo(mxResourceId) == 0)
+ {
+ // The resource managed by this ResourceManager has been
+ // explicitly been requested to be hidden (maybe by us).
+ // Remember this setting.
+ HandleResourceRequest(false, rEvent.Configuration);
+ }
+ break;
+ }
+}
+
+
+
+
+void ResourceManager::UpdateForMainViewShell (void)
+{
+ if (mxConfigurationController.is())
+ {
+ ConfigurationController::Lock aLock (mxConfigurationController);
+
+ if (mbIsEnabled
+ && mpActiveMainViewContainer->find(msCurrentMainViewURL)
+ != mpActiveMainViewContainer->end())
+ {
+ // Activate resource.
+ mxConfigurationController->requestResourceActivation(
+ mxResourceId->getAnchor(),
+ ResourceActivationMode_ADD);
+ mxConfigurationController->requestResourceActivation(
+ mxResourceId,
+ ResourceActivationMode_REPLACE);
+ }
+ else
+ {
+ mxConfigurationController->requestResourceDeactivation(mxResourceId);
+ }
+ }
+}
+
+
+
+
+void ResourceManager::HandleMainViewSwitch (
+ const OUString& rsViewURL,
+ const Reference<XConfiguration>& rxConfiguration,
+ const bool bIsActivated)
+{
+ (void)rxConfiguration;
+ if (bIsActivated)
+ msCurrentMainViewURL = rsViewURL;
+ else
+ msCurrentMainViewURL = OUString();
+ UpdateForMainViewShell();
+}
+
+
+
+
+void ResourceManager::HandleResourceRequest(
+ bool bActivation,
+ const Reference<XConfiguration>& rxConfiguration)
+{
+ if (mbIsEnabled)
+ {
+ Sequence<Reference<XResourceId> > aCenterViews = rxConfiguration->getResources(
+ FrameworkHelper::CreateResourceId(FrameworkHelper::msCenterPaneURL),
+ FrameworkHelper::msViewURLPrefix,
+ AnchorBindingMode_DIRECT);
+ if (aCenterViews.getLength() == 1)
+ {
+ if (bActivation)
+ {
+ mpActiveMainViewContainer->insert(aCenterViews[0]->getResourceURL());
+ }
+ else
+ {
+ MainViewContainer::iterator iElement (
+ mpActiveMainViewContainer->find(aCenterViews[0]->getResourceURL()));
+ if (iElement != mpActiveMainViewContainer->end())
+ mpActiveMainViewContainer->erase(iElement);
+ }
+ }
+ }
+}
+
+
+
+
+void SAL_CALL ResourceManager::disposing (
+ const lang::EventObject& rEvent)
+ throw (RuntimeException)
+{
+ if (mxConfigurationController.is()
+ && rEvent.Source == mxConfigurationController)
+ {
+ // Without the configuration controller this class can do nothing.
+ mxConfigurationController = NULL;
+ dispose();
+ }
+}
+
+} } // end of namespace sd::framework
diff --git a/sd/source/ui/framework/module/ResourceManager.hxx b/sd/source/ui/framework/module/ResourceManager.hxx
new file mode 100755
index 000000000000..d00ee78c2de3
--- /dev/null
+++ b/sd/source/ui/framework/module/ResourceManager.hxx
@@ -0,0 +1,133 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef SD_FRAMEWORK_RESOURCE_MANAGER_HXX
+#define SD_FRAMEWORK_RESOURCE_MANAGER_HXX
+
+#include "MutexOwner.hxx"
+#include <com/sun/star/drawing/framework/XConfigurationChangeListener.hpp>
+#include <com/sun/star/drawing/framework/XConfigurationController.hpp>
+#include <com/sun/star/frame/XController.hpp>
+#include <cppuhelper/compbase1.hxx>
+#include <boost/scoped_ptr.hpp>
+
+namespace css = ::com::sun::star;
+
+namespace {
+
+typedef ::cppu::WeakComponentImplHelper1 <
+ ::com::sun::star::drawing::framework::XConfigurationChangeListener
+ > ResourceManagerInterfaceBase;
+
+} // end of anonymous namespace.
+
+
+namespace sd { namespace framework {
+
+/** Manage the activation state of one resource depending on the view in the
+ center pane. The ResourceManager remembers in which configuration to
+ activate and in which to deactivate the resource. When the resource is
+ deactivated or activated manually by the user then the ResourceManager
+ detects this and remembers it for the future.
+*/
+class ResourceManager
+ : private sd::MutexOwner,
+ public ResourceManagerInterfaceBase
+{
+public:
+ ResourceManager (
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::frame::XController>& rxController,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::drawing::framework::XResourceId>& rxResourceId);
+ virtual ~ResourceManager (void);
+
+ /** Remember the given URL as one of a center pane view for which to
+ activate the resource managed by the called object.
+ */
+ void AddActiveMainView (const ::rtl::OUString& rsMainViewURL);
+
+ virtual void SAL_CALL disposing (void);
+
+ /** Allow the ResourceManager to make resource activation or
+ deactivation requests.
+ */
+ void Enable (void);
+
+ /** Disable the resource management. When called, the ResourceManager
+ requests the resource to be deactivated. Until enabled again it
+ does not make any further requests for resource activation or
+ deactivation.
+
+ Call this for example to hide resources in read-only mode.
+ */
+ void Disable (void);
+
+ // XConfigurationChangeListener
+
+ virtual void SAL_CALL notifyConfigurationChange (
+ const com::sun::star::drawing::framework::ConfigurationChangeEvent& rEvent)
+ throw (com::sun::star::uno::RuntimeException);
+
+ // XEventListener
+
+ virtual void SAL_CALL disposing (
+ const com::sun::star::lang::EventObject& rEvent)
+ throw (com::sun::star::uno::RuntimeException);
+
+protected:
+ ::com::sun::star::uno::Reference<com::sun::star::drawing::framework::XConfigurationController>
+ mxConfigurationController;
+
+private:
+ class MainViewContainer;
+ ::boost::scoped_ptr<MainViewContainer> mpActiveMainViewContainer;
+
+ /// The resource managed by this class.
+ css::uno::Reference<css::drawing::framework::XResourceId> mxResourceId;
+
+ /// The anchor of the main view.
+ css::uno::Reference<css::drawing::framework::XResourceId> mxMainViewAnchorId;
+
+ ::rtl::OUString msCurrentMainViewURL;
+ bool mbIsEnabled;
+
+ void HandleMainViewSwitch (
+ const ::rtl::OUString& rsViewURL,
+ const ::com::sun::star::uno::Reference<
+ com::sun::star::drawing::framework::XConfiguration>& rxConfiguration,
+ const bool bIsActivated);
+ void HandleResourceRequest(
+ bool bActivation,
+ const ::com::sun::star::uno::Reference<
+ com::sun::star::drawing::framework::XConfiguration>& rxConfiguration);
+ void UpdateForMainViewShell (void);
+};
+
+} } // end of namespace sd::framework
+
+#endif
diff --git a/sd/source/ui/framework/module/ShellStackGuard.cxx b/sd/source/ui/framework/module/ShellStackGuard.cxx
new file mode 100644
index 000000000000..79396a57f36a
--- /dev/null
+++ b/sd/source/ui/framework/module/ShellStackGuard.cxx
@@ -0,0 +1,192 @@
+/*************************************************************************
+ *
+ * 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 "precompiled_sd.hxx"
+
+#include "ShellStackGuard.hxx"
+
+#include "framework/ConfigurationController.hxx"
+#include "framework/FrameworkHelper.hxx"
+
+#include "DrawController.hxx"
+#include "ViewShellBase.hxx"
+#include <sfx2/printer.hxx>
+#include <com/sun/star/drawing/framework/XControllerManager.hpp>
+#include <com/sun/star/drawing/framework/XConfigurationController.hpp>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::drawing::framework;
+
+using ::rtl::OUString;
+using ::sd::framework::FrameworkHelper;
+
+
+namespace sd { namespace framework {
+
+//===== CenterViewFocusModule ====================================================
+
+ShellStackGuard::ShellStackGuard (Reference<frame::XController>& rxController)
+ : ShellStackGuardInterfaceBase(m_aMutex),
+ mxConfigurationController(),
+ mpBase(NULL),
+ mpUpdateLock(),
+ maPrinterPollingTimer()
+{
+ Reference<XControllerManager> xControllerManager (rxController, UNO_QUERY);
+ if (xControllerManager.is())
+ {
+ mxConfigurationController = xControllerManager->getConfigurationController();
+
+ // Tunnel through the controller to obtain a ViewShellBase.
+ Reference<lang::XUnoTunnel> xTunnel (rxController, UNO_QUERY);
+ if (xTunnel.is())
+ {
+ ::sd::DrawController* pController = reinterpret_cast<sd::DrawController*>(
+ xTunnel->getSomething(sd::DrawController::getUnoTunnelId()));
+ if (pController != NULL)
+ mpBase = pController->GetViewShellBase();
+ }
+ }
+
+ if (mxConfigurationController.is())
+ {
+ // Listen for update starts so that the following update can be
+ // prevented in case of a printing printer.
+ mxConfigurationController->addConfigurationChangeListener(
+ this,
+ FrameworkHelper::msConfigurationUpdateStartEvent,
+ Any());
+
+ // Prepare the printer polling.
+ maPrinterPollingTimer.SetTimeoutHdl(LINK(this,ShellStackGuard,TimeoutHandler));
+ maPrinterPollingTimer.SetTimeout(300);
+ }
+}
+
+
+
+
+ShellStackGuard::~ShellStackGuard (void)
+{
+}
+
+
+
+
+void SAL_CALL ShellStackGuard::disposing (void)
+{
+ if (mxConfigurationController.is())
+ mxConfigurationController->removeConfigurationChangeListener(this);
+
+ mxConfigurationController = NULL;
+ mpBase = NULL;
+}
+
+
+
+
+void SAL_CALL ShellStackGuard::notifyConfigurationChange (
+ const ConfigurationChangeEvent& rEvent)
+ throw (RuntimeException)
+{
+ if (rEvent.Type.equals(FrameworkHelper::msConfigurationUpdateStartEvent))
+ {
+ if (mpUpdateLock.get() == NULL && IsPrinting())
+ {
+ // Prevent configuration updates while the printer is printing.
+ mpUpdateLock.reset(new ConfigurationController::Lock(mxConfigurationController));
+
+ // Start polling for the printer having finished printing.
+ maPrinterPollingTimer.Start();
+ }
+ }
+}
+
+
+
+
+void SAL_CALL ShellStackGuard::disposing (
+ const lang::EventObject& rEvent)
+ throw (RuntimeException)
+{
+ if (mxConfigurationController.is())
+ if (rEvent.Source == mxConfigurationController)
+ {
+ mxConfigurationController = NULL;
+ mpBase = NULL;
+ }
+}
+
+
+
+
+IMPL_LINK(ShellStackGuard, TimeoutHandler, Timer*, pTimer)
+{
+#ifdef DEBUG
+ OSL_ASSERT(pTimer==&maPrinterPollingTimer);
+#else
+ (void)pTimer;
+#endif
+ if (mpUpdateLock.get() != NULL)
+ {
+ if ( ! IsPrinting())
+ {
+ // Printing finished. Release the update lock.
+ mpUpdateLock.reset();
+ }
+ else
+ {
+ // Wait long for the printing to finish.
+ maPrinterPollingTimer.Start();
+ }
+ }
+
+ return 0;
+}
+
+
+
+
+
+bool ShellStackGuard::IsPrinting (void) const
+{
+ if (mpBase != NULL)
+ {
+ SfxPrinter* pPrinter = mpBase->GetPrinter();
+ if (pPrinter != NULL
+ && pPrinter->IsPrinting())
+ {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+
+} } // end of namespace sd::framework
diff --git a/sd/source/ui/framework/module/ShellStackGuard.hxx b/sd/source/ui/framework/module/ShellStackGuard.hxx
new file mode 100644
index 000000000000..694e7fe5719f
--- /dev/null
+++ b/sd/source/ui/framework/module/ShellStackGuard.hxx
@@ -0,0 +1,116 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef SD_FRAMEWORK_SHELL_STACK_GUARD_HXX
+#define SD_FRAMEWORK_SHELL_STACK_GUARD_HXX
+
+#include <cppuhelper/basemutex.hxx>
+
+#include "framework/ConfigurationController.hxx"
+
+#include <com/sun/star/drawing/framework/XConfigurationChangeListener.hpp>
+#include <com/sun/star/drawing/framework/XConfigurationController.hpp>
+#include <com/sun/star/frame/XController.hpp>
+
+#include <vcl/timer.hxx>
+#include <cppuhelper/compbase1.hxx>
+#include <boost/scoped_ptr.hpp>
+
+
+namespace css = ::com::sun::star;
+
+
+namespace {
+
+typedef ::cppu::WeakComponentImplHelper1 <
+ css::drawing::framework::XConfigurationChangeListener
+ > ShellStackGuardInterfaceBase;
+
+} // end of anonymous namespace.
+
+namespace sd {
+
+class ViewShellBase;
+
+}
+
+
+
+
+namespace sd { namespace framework {
+
+/** This module locks updates of the current configuration in situations
+ when the shell stack must not be modified.
+
+ On every start of a configuration update the ShellStackGuard checks the
+ printer. If it is printing the configuration update is locked. It then
+ polls the printer and unlocks updates when printing finishes.
+
+ When in the future there are no resources left that use shells then this
+ module can be removed.
+*/
+class ShellStackGuard
+ : private ::cppu::BaseMutex,
+ public ShellStackGuardInterfaceBase
+{
+public:
+ ShellStackGuard (css::uno::Reference<css::frame::XController>& rxController);
+ virtual ~ShellStackGuard (void);
+
+ virtual void SAL_CALL disposing (void);
+
+
+ // XConfigurationChangeListener
+
+ virtual void SAL_CALL notifyConfigurationChange (
+ const css::drawing::framework::ConfigurationChangeEvent& rEvent)
+ throw (css::uno::RuntimeException);
+
+ // XEventListener
+
+ virtual void SAL_CALL disposing (const css::lang::EventObject& rEvent)
+ throw (css::uno::RuntimeException);
+
+private:
+ css::uno::Reference<css::drawing::framework::XConfigurationController>
+ mxConfigurationController;
+ ViewShellBase* mpBase;
+ ::boost::scoped_ptr<ConfigurationController::Lock> mpUpdateLock;
+ Timer maPrinterPollingTimer;
+
+ DECL_LINK(TimeoutHandler, Timer*);
+
+ /** Return <TRUE/> when the printer is printing. Return <FALSE/> when
+ the printer is not printing, or there is no printer, or someting
+ else went wrong.
+ */
+ bool IsPrinting (void) const;
+};
+
+} } // end of namespace sd::framework
+
+#endif
diff --git a/sd/source/ui/framework/module/SlideSorterModule.cxx b/sd/source/ui/framework/module/SlideSorterModule.cxx
new file mode 100644
index 000000000000..2a1aaa4ca771
--- /dev/null
+++ b/sd/source/ui/framework/module/SlideSorterModule.cxx
@@ -0,0 +1,155 @@
+/*************************************************************************
+ *
+ * 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 "precompiled_sd.hxx"
+
+#include "SlideSorterModule.hxx"
+
+#include "framework/FrameworkHelper.hxx"
+#include <com/sun/star/drawing/framework/XTabBar.hpp>
+#include <com/sun/star/drawing/framework/TabBarButton.hpp>
+
+#include "strings.hrc"
+#include "sdresid.hxx"
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::drawing::framework;
+
+using ::rtl::OUString;
+using ::sd::framework::FrameworkHelper;
+
+
+namespace sd { namespace framework {
+
+
+//===== SlideSorterModule ==================================================
+
+SlideSorterModule::SlideSorterModule (
+ const Reference<frame::XController>& rxController,
+ const OUString& rsLeftPaneURL)
+ : ResourceManager(rxController,
+ FrameworkHelper::CreateResourceId(FrameworkHelper::msSlideSorterURL, rsLeftPaneURL)),
+ mxViewTabBarId(FrameworkHelper::CreateResourceId(
+ FrameworkHelper::msViewTabBarURL,
+ FrameworkHelper::msCenterPaneURL)),
+ mxControllerManager(rxController,UNO_QUERY)
+{
+ if (mxConfigurationController.is())
+ {
+ UpdateViewTabBar(NULL);
+
+ AddActiveMainView(FrameworkHelper::msImpressViewURL);
+ AddActiveMainView(FrameworkHelper::msOutlineViewURL);
+ AddActiveMainView(FrameworkHelper::msNotesViewURL);
+
+ AddActiveMainView(FrameworkHelper::msDrawViewURL);
+
+ mxConfigurationController->addConfigurationChangeListener(
+ this,
+ FrameworkHelper::msResourceActivationEvent,
+ Any());
+ }
+}
+
+
+
+
+SlideSorterModule::~SlideSorterModule (void)
+{
+}
+
+
+
+
+void SAL_CALL SlideSorterModule::notifyConfigurationChange (
+ const ConfigurationChangeEvent& rEvent)
+ throw (RuntimeException)
+{
+ if (rEvent.Type.equals(FrameworkHelper::msResourceActivationEvent))
+ {
+ if (rEvent.ResourceId->compareTo(mxViewTabBarId) == 0)
+ {
+ // Update the view tab bar because the view tab bar has just
+ // become active.
+ UpdateViewTabBar(Reference<XTabBar>(rEvent.ResourceObject,UNO_QUERY));
+ }
+ else if (rEvent.ResourceId->getResourceTypePrefix().equals(
+ FrameworkHelper::msViewURLPrefix)
+ && rEvent.ResourceId->isBoundTo(
+ FrameworkHelper::CreateResourceId(FrameworkHelper::msCenterPaneURL),
+ AnchorBindingMode_DIRECT))
+ {
+ // Update the view tab bar because the view in the center pane
+ // has changed.
+ UpdateViewTabBar(NULL);
+ }
+ }
+ else
+ {
+ ResourceManager::notifyConfigurationChange(rEvent);
+ }
+}
+
+
+
+
+void SlideSorterModule::UpdateViewTabBar (const Reference<XTabBar>& rxTabBar)
+{
+ if ( ! mxControllerManager.is())
+ return;
+
+ Reference<XTabBar> xBar (rxTabBar);
+ if ( ! xBar.is())
+ {
+ Reference<XConfigurationController> xCC (
+ mxControllerManager->getConfigurationController());
+ if (xCC.is())
+ xBar = Reference<XTabBar>(xCC->getResource(mxViewTabBarId), UNO_QUERY);
+ }
+
+ if (xBar.is())
+ {
+ TabBarButton aButtonA;
+ aButtonA.ResourceId = FrameworkHelper::CreateResourceId(
+ FrameworkHelper::msSlideSorterURL,
+ FrameworkHelper::msCenterPaneURL);
+ aButtonA.ButtonLabel = String(SdResId(STR_SLIDE_MODE));
+
+ TabBarButton aButtonB;
+ aButtonB.ResourceId = FrameworkHelper::CreateResourceId(
+ FrameworkHelper::msHandoutViewURL,
+ FrameworkHelper::msCenterPaneURL);
+
+ if ( ! xBar->hasTabBarButton(aButtonA))
+ xBar->addTabBarButtonAfter(aButtonA, aButtonB);
+ }
+}
+
+
+
+} } // end of namespace sd::framework
diff --git a/sd/source/ui/framework/module/SlideSorterModule.hxx b/sd/source/ui/framework/module/SlideSorterModule.hxx
new file mode 100644
index 000000000000..c685c16d830b
--- /dev/null
+++ b/sd/source/ui/framework/module/SlideSorterModule.hxx
@@ -0,0 +1,69 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef SD_FRAMEWORK_SLIDE_SORTER_MODULE_HXX
+#define SD_FRAMEWORK_SLIDE_SORTER_MODULE_HXX
+
+#include "ResourceManager.hxx"
+
+#include <com/sun/star/drawing/framework/XControllerManager.hpp>
+#include <com/sun/star/drawing/framework/XTabBar.hpp>
+
+namespace css = ::com::sun::star;
+
+namespace sd { namespace framework {
+
+/** This module is responsible for showing the slide sorter bar and the the
+ slide sorter view in the center pane.
+*/
+class SlideSorterModule
+ : public ResourceManager
+{
+public:
+ SlideSorterModule (
+ const css::uno::Reference<css::frame::XController>& rxController,
+ const ::rtl::OUString& rsLeftPaneURL);
+ virtual ~SlideSorterModule (void);
+
+
+ // XConfigurationChangeListener
+
+ virtual void SAL_CALL notifyConfigurationChange (
+ const css::drawing::framework::ConfigurationChangeEvent& rEvent)
+ throw (css::uno::RuntimeException);
+
+private:
+ css::uno::Reference<css::drawing::framework::XResourceId> mxViewTabBarId;
+ css::uno::Reference<css::drawing::framework::XControllerManager> mxControllerManager;
+
+ void UpdateViewTabBar (
+ const css::uno::Reference<css::drawing::framework::XTabBar>& rxViewTabBar);
+};
+
+} } // end of namespace sd::framework
+
+#endif
diff --git a/sd/source/ui/framework/module/ToolBarModule.cxx b/sd/source/ui/framework/module/ToolBarModule.cxx
new file mode 100644
index 000000000000..b987009537b8
--- /dev/null
+++ b/sd/source/ui/framework/module/ToolBarModule.cxx
@@ -0,0 +1,234 @@
+/*************************************************************************
+ *
+ * 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 "precompiled_sd.hxx"
+
+#include "ToolBarModule.hxx"
+#include "ViewShellBase.hxx"
+#include "DrawController.hxx"
+#include "framework/FrameworkHelper.hxx"
+#include "framework/ConfigurationController.hxx"
+
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::drawing::framework;
+
+using ::rtl::OUString;
+using ::sd::framework::FrameworkHelper;
+
+namespace {
+ static const sal_Int32 gnConfigurationUpdateStartEvent(0);
+ static const sal_Int32 gnConfigurationUpdateEndEvent(1);
+ static const sal_Int32 gnResourceActivationRequestEvent(2);
+ static const sal_Int32 gnResourceDeactivationRequestEvent(3);
+}
+
+namespace sd { namespace framework {
+
+//===== ToolBarModule =========================================================
+
+ToolBarModule::ToolBarModule (
+ const Reference<frame::XController>& rxController)
+ : ToolBarModuleInterfaceBase(m_aMutex),
+ mxConfigurationController(),
+ mpBase(NULL),
+ mpToolBarManagerLock(),
+ mbMainViewSwitchUpdatePending(false)
+{
+ // Tunnel through the controller to obtain a ViewShellBase.
+ Reference<lang::XUnoTunnel> xTunnel (rxController, UNO_QUERY);
+ if (xTunnel.is())
+ {
+ ::sd::DrawController* pController = reinterpret_cast<sd::DrawController*>(
+ xTunnel->getSomething(sd::DrawController::getUnoTunnelId()));
+ if (pController != NULL)
+ mpBase = pController->GetViewShellBase();
+ }
+
+ Reference<XControllerManager> xControllerManager (rxController, UNO_QUERY);
+ if (xControllerManager.is())
+ {
+ mxConfigurationController = xControllerManager->getConfigurationController();
+ if (mxConfigurationController.is())
+ {
+ mxConfigurationController->addConfigurationChangeListener(
+ this,
+ FrameworkHelper::msConfigurationUpdateStartEvent,
+ makeAny(gnConfigurationUpdateStartEvent));
+ mxConfigurationController->addConfigurationChangeListener(
+ this,
+ FrameworkHelper::msConfigurationUpdateEndEvent,
+ makeAny(gnConfigurationUpdateEndEvent));
+ mxConfigurationController->addConfigurationChangeListener(
+ this,
+ FrameworkHelper::msResourceActivationRequestEvent,
+ makeAny(gnResourceActivationRequestEvent));
+ mxConfigurationController->addConfigurationChangeListener(
+ this,
+ FrameworkHelper::msResourceDeactivationRequestEvent,
+ makeAny(gnResourceDeactivationRequestEvent));
+ }
+ }
+}
+
+
+
+
+ToolBarModule::~ToolBarModule (void)
+{
+}
+
+
+
+
+void SAL_CALL ToolBarModule::disposing (void)
+{
+ if (mxConfigurationController.is())
+ mxConfigurationController->removeConfigurationChangeListener(this);
+
+ mxConfigurationController = NULL;
+}
+
+
+
+
+void SAL_CALL ToolBarModule::notifyConfigurationChange (
+ const ConfigurationChangeEvent& rEvent)
+ throw (RuntimeException)
+{
+ if (mxConfigurationController.is())
+ {
+ sal_Int32 nEventType = 0;
+ rEvent.UserData >>= nEventType;
+ switch (nEventType)
+ {
+ case gnConfigurationUpdateStartEvent:
+ HandleUpdateStart();
+ break;
+
+ case gnConfigurationUpdateEndEvent:
+ HandleUpdateEnd();
+ break;
+
+ case gnResourceActivationRequestEvent:
+ case gnResourceDeactivationRequestEvent:
+ // Remember the request for the activation or deactivation
+ // of the center pane view. When that happens then on end
+ // of the next configuration update the set of visible tool
+ // bars will be updated.
+ if ( ! mbMainViewSwitchUpdatePending)
+ if (rEvent.ResourceId->getResourceURL().match(
+ FrameworkHelper::msViewURLPrefix)
+ && rEvent.ResourceId->isBoundToURL(
+ FrameworkHelper::msCenterPaneURL, AnchorBindingMode_DIRECT))
+ {
+ mbMainViewSwitchUpdatePending = true;
+ }
+ break;
+ }
+ }
+}
+
+
+
+
+//-----------------------------------------------------------------------------
+
+
+void ToolBarModule::HandleUpdateStart (void)
+{
+ // Lock the ToolBarManager and tell it to lock the ViewShellManager as
+ // well. This way the ToolBarManager can optimize the releasing of
+ // locks and arranging of updates of both tool bars and the view shell
+ // stack.
+ if (mpBase != NULL)
+ {
+ ::boost::shared_ptr<ToolBarManager> pToolBarManager (mpBase->GetToolBarManager());
+ mpToolBarManagerLock.reset(new ToolBarManager::UpdateLock(pToolBarManager));
+ pToolBarManager->LockViewShellManager();
+ }
+}
+
+
+
+
+void ToolBarModule::HandleUpdateEnd (void)
+{
+ if (mbMainViewSwitchUpdatePending)
+ {
+ mbMainViewSwitchUpdatePending = false;
+ // Update the set of visible tool bars and deactivate those that are
+ // no longer visible. This is done before the old view shell is
+ // destroyed in order to avoid unnecessary updates of those tool
+ // bars.
+ ::boost::shared_ptr<ToolBarManager> pToolBarManager (mpBase->GetToolBarManager());
+ ::boost::shared_ptr<FrameworkHelper> pFrameworkHelper (
+ FrameworkHelper::Instance(*mpBase));
+ ViewShell* pViewShell
+ = pFrameworkHelper->GetViewShell(FrameworkHelper::msCenterPaneURL).get();
+ if (pViewShell != NULL)
+ {
+ pToolBarManager->MainViewShellChanged(*pViewShell);
+ pToolBarManager->SelectionHasChanged(
+ *pViewShell,
+ *pViewShell->GetView());
+ pToolBarManager->PreUpdate();
+ }
+ else
+ {
+ pToolBarManager->MainViewShellChanged(ViewShell::ST_NONE);
+ pToolBarManager->PreUpdate();
+ }
+ }
+
+ // Releasing the update lock of the ToolBarManager will let the
+ // ToolBarManager with the help of the ViewShellManager take care of
+ // updating tool bars and view shell with the minimal amount of
+ // shell stack modifications and tool bar updates.
+ mpToolBarManagerLock.reset();
+}
+
+
+
+
+void SAL_CALL ToolBarModule::disposing (const lang::EventObject& rEvent)
+ throw (RuntimeException)
+{
+ if (mxConfigurationController.is()
+ && rEvent.Source == mxConfigurationController)
+ {
+ // Without the configuration controller this class can do nothing.
+ mxConfigurationController = NULL;
+ dispose();
+ }
+}
+
+
+
+
+} } // end of namespace sd::framework
diff --git a/sd/source/ui/framework/module/ToolBarModule.hxx b/sd/source/ui/framework/module/ToolBarModule.hxx
new file mode 100644
index 000000000000..1e26cef6d435
--- /dev/null
+++ b/sd/source/ui/framework/module/ToolBarModule.hxx
@@ -0,0 +1,102 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef SD_FRAMEWORK_TOOL_BAR_MODULE_HXX
+#define SD_FRAMEWORK_TOOL_BAR_MODULE_HXX
+
+#include "ToolBarManager.hxx"
+#include <com/sun/star/drawing/framework/XConfigurationChangeListener.hpp>
+#include <com/sun/star/drawing/framework/XConfigurationController.hpp>
+#include <com/sun/star/drawing/framework/XTabBar.hpp>
+#include <com/sun/star/frame/XController.hpp>
+#include <osl/mutex.hxx>
+#include <cppuhelper/basemutex.hxx>
+#include <cppuhelper/compbase1.hxx>
+#include <boost/scoped_ptr.hpp>
+
+namespace css = ::com::sun::star;
+
+namespace sd {
+class ViewShellBase;
+}
+
+
+
+namespace sd { namespace framework {
+
+namespace {
+ typedef ::cppu::WeakComponentImplHelper1 <
+ ::css::drawing::framework::XConfigurationChangeListener
+ > ToolBarModuleInterfaceBase;
+}
+
+
+/** This module is responsible for locking the ToolBarManager during
+ configuration updates and for triggering ToolBarManager updates.
+*/
+class ToolBarModule
+ : private ::cppu::BaseMutex,
+ public ToolBarModuleInterfaceBase
+{
+public:
+ /** Create a new module.
+ @param rxController
+ This is the access point to the drawing framework.
+ */
+ ToolBarModule (
+ const css::uno::Reference<css::frame::XController>& rxController);
+ virtual ~ToolBarModule (void);
+
+ virtual void SAL_CALL disposing (void);
+
+
+ // XConfigurationChangeListener
+
+ virtual void SAL_CALL notifyConfigurationChange (
+ const css::drawing::framework::ConfigurationChangeEvent& rEvent)
+ throw (css::uno::RuntimeException);
+
+ // XEventListener
+
+ virtual void SAL_CALL disposing (
+ const css::lang::EventObject& rEvent)
+ throw (css::uno::RuntimeException);
+
+private:
+ css::uno::Reference<
+ css::drawing::framework::XConfigurationController> mxConfigurationController;
+ ViewShellBase* mpBase;
+ ::boost::scoped_ptr<ToolBarManager::UpdateLock> mpToolBarManagerLock;
+ bool mbMainViewSwitchUpdatePending;
+
+ void HandleUpdateStart (void);
+ void HandleUpdateEnd (void);
+};
+
+} } // end of namespace sd::framework
+
+#endif
diff --git a/sd/source/ui/framework/module/ToolPanelModule.cxx b/sd/source/ui/framework/module/ToolPanelModule.cxx
new file mode 100644
index 000000000000..888fa68ad708
--- /dev/null
+++ b/sd/source/ui/framework/module/ToolPanelModule.cxx
@@ -0,0 +1,165 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: ToolPanelModule.cxx,v $
+ * $Revision: 1.4 $
+ *
+ * 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 "precompiled_sd.hxx"
+
+#include "ToolPanelModule.hxx"
+#include "ReadOnlyModeObserver.hxx"
+#include "framework/FrameworkHelper.hxx"
+
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/drawing/framework/XControllerManager.hpp>
+
+#include <comphelper/processfactory.hxx>
+#include <cppuhelper/compbase1.hxx>
+#include <boost/enable_shared_from_this.hpp>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::drawing::framework;
+using ::rtl::OUString;
+using ::sd::framework::FrameworkHelper;
+
+
+namespace sd { namespace framework {
+
+namespace {
+
+typedef ::cppu::WeakComponentImplHelper1 <
+ ::com::sun::star::frame::XStatusListener
+ > LocalReadOnlyModeObserverInterfaceBase;
+
+/** This local class enables or disables the ResourceManager of a
+ ToolPanelModule. It connects to a ReadOnlyModeObserver and is called
+ when the state of the .uno:EditDoc command changes. When either the
+ ResourceManager or the ReadOnlyModeObserver are disposed then the
+ LocalReadOnlyModeObserver disposes itself. The link
+ between the ResourceManager and the ReadOnlyModeObserver is removed and
+ the ReadOnlyModeObserver typically looses its last reference and is
+ destroyed.
+*/
+class LocalReadOnlyModeObserver
+ : private MutexOwner,
+ public LocalReadOnlyModeObserverInterfaceBase
+{
+public:
+ LocalReadOnlyModeObserver (
+ const Reference<frame::XController>& rxController,
+ const ::rtl::Reference<ResourceManager>& rpResourceManager)
+ : MutexOwner(),
+ LocalReadOnlyModeObserverInterfaceBase(maMutex),
+ mpResourceManager(rpResourceManager),
+ mpObserver(new ReadOnlyModeObserver(rxController))
+ {
+ mpObserver->AddStatusListener(this);
+
+ Reference<lang::XComponent> xComponent (
+ static_cast<XWeak*>(mpResourceManager.get()), UNO_QUERY);
+ if (xComponent.is())
+ xComponent->addEventListener(this);
+ }
+
+ ~LocalReadOnlyModeObserver (void)
+ {
+ }
+
+ virtual void SAL_CALL disposing (void)
+ {
+ Reference<lang::XComponent> xComponent (static_cast<XWeak*>(mpObserver.get()), UNO_QUERY);
+ if (xComponent.is())
+ xComponent->dispose();
+
+ xComponent = Reference<lang::XComponent>(
+ static_cast<XWeak*>(mpResourceManager.get()), UNO_QUERY);
+ if (xComponent.is())
+ xComponent->removeEventListener(this);
+
+ }
+
+ virtual void SAL_CALL disposing (const com::sun::star::lang::EventObject& rEvent)
+ throw(RuntimeException)
+ {
+ if (rEvent.Source == Reference<XInterface>(static_cast<XWeak*>(mpObserver.get())))
+ {
+ mpObserver = NULL;
+ }
+ else if (rEvent.Source == Reference<XInterface>(
+ static_cast<XWeak*>(mpResourceManager.get())))
+ {
+ mpResourceManager = NULL;
+ }
+ dispose();
+ }
+
+ virtual void SAL_CALL statusChanged (const com::sun::star::frame::FeatureStateEvent& rEvent)
+ throw(RuntimeException)
+ {
+ bool bReadWrite (true);
+ if (rEvent.IsEnabled)
+ rEvent.State >>= bReadWrite;
+
+ if (bReadWrite)
+ mpResourceManager->Enable();
+ else
+ mpResourceManager->Disable();
+ }
+
+private:
+ ::rtl::Reference<ResourceManager> mpResourceManager;
+ ::rtl::Reference<ReadOnlyModeObserver> mpObserver;
+
+};
+}
+
+
+
+
+//===== ToolPanelModule ====================================================
+
+void ToolPanelModule::Initialize (const Reference<frame::XController>& rxController)
+{
+ ::rtl::Reference<ResourceManager> pResourceManager (
+ new ResourceManager(
+ rxController,
+ FrameworkHelper::CreateResourceId(
+ FrameworkHelper::msTaskPaneURL,
+ FrameworkHelper::msRightPaneURL)));
+ pResourceManager->AddActiveMainView(FrameworkHelper::msImpressViewURL);
+ pResourceManager->AddActiveMainView(FrameworkHelper::msNotesViewURL);
+ pResourceManager->AddActiveMainView(FrameworkHelper::msHandoutViewURL);
+ pResourceManager->AddActiveMainView(FrameworkHelper::msSlideSorterURL);
+
+ new LocalReadOnlyModeObserver(rxController, pResourceManager);
+}
+
+
+
+
+} } // end of namespace sd::framework
diff --git a/sd/source/ui/framework/module/ToolPanelModule.hxx b/sd/source/ui/framework/module/ToolPanelModule.hxx
new file mode 100644
index 000000000000..7d728e60e93d
--- /dev/null
+++ b/sd/source/ui/framework/module/ToolPanelModule.hxx
@@ -0,0 +1,49 @@
+/*************************************************************************
+ * 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.
+ *
+************************************************************************/
+
+#ifndef SD_FRAMEWORK_TOOL_PANEL_MODULE_HXX
+#define SD_FRAMEWORK_TOOL_PANEL_MODULE_HXX
+
+#include "ResourceManager.hxx"
+
+#include <rtl/ref.hxx>
+
+namespace sd { namespace framework {
+
+class ReadOnlyModeObserver;
+
+/** This module is responsible for showing the task pane.
+*/
+class ToolPanelModule
+{
+public:
+ static void Initialize (
+ const ::com::sun::star::uno::Reference<com::sun::star::frame::XController>& rxController);
+};
+
+} } // end of namespace sd::framework
+
+#endif
diff --git a/sd/source/ui/framework/module/ViewTabBarModule.cxx b/sd/source/ui/framework/module/ViewTabBarModule.cxx
new file mode 100644
index 000000000000..6a4db6246c1a
--- /dev/null
+++ b/sd/source/ui/framework/module/ViewTabBarModule.cxx
@@ -0,0 +1,220 @@
+/*************************************************************************
+ *
+ * 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 "precompiled_sd.hxx"
+
+#include "ViewTabBarModule.hxx"
+
+#include "framework/FrameworkHelper.hxx"
+#include "framework/ConfigurationController.hxx"
+#include <com/sun/star/drawing/framework/XControllerManager.hpp>
+#include <com/sun/star/drawing/framework/XTabBar.hpp>
+
+#include "strings.hrc"
+#include "sdresid.hxx"
+
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::drawing::framework;
+
+using ::rtl::OUString;
+using ::sd::framework::FrameworkHelper;
+
+namespace {
+
+static const sal_Int32 ResourceActivationRequestEvent = 0;
+static const sal_Int32 ResourceDeactivationRequestEvent = 1;
+static const sal_Int32 ResourceActivationEvent = 2;
+
+}
+
+namespace sd { namespace framework {
+
+//===== ViewTabBarModule ==================================================
+
+ViewTabBarModule::ViewTabBarModule (
+ const Reference<frame::XController>& rxController,
+ const Reference<XResourceId>& rxViewTabBarId)
+ : ViewTabBarModuleInterfaceBase(MutexOwner::maMutex),
+ mxConfigurationController(),
+ mxViewTabBarId(rxViewTabBarId)
+{
+ Reference<XControllerManager> xControllerManager (rxController, UNO_QUERY);
+
+ if (xControllerManager.is())
+ {
+ mxConfigurationController = xControllerManager->getConfigurationController();
+ if (mxConfigurationController.is())
+ {
+ mxConfigurationController->addConfigurationChangeListener(
+ this,
+ FrameworkHelper::msResourceActivationRequestEvent,
+ makeAny(ResourceActivationRequestEvent));
+ mxConfigurationController->addConfigurationChangeListener(
+ this,
+ FrameworkHelper::msResourceDeactivationRequestEvent,
+ makeAny(ResourceDeactivationRequestEvent));
+
+ UpdateViewTabBar(NULL);
+ mxConfigurationController->addConfigurationChangeListener(
+ this,
+ FrameworkHelper::msResourceActivationEvent,
+ makeAny(ResourceActivationEvent));
+ }
+ }
+}
+
+
+
+
+ViewTabBarModule::~ViewTabBarModule (void)
+{
+}
+
+
+
+
+void SAL_CALL ViewTabBarModule::disposing (void)
+{
+ if (mxConfigurationController.is())
+ mxConfigurationController->removeConfigurationChangeListener(this);
+
+ mxConfigurationController = NULL;
+}
+
+
+
+
+void SAL_CALL ViewTabBarModule::notifyConfigurationChange (
+ const ConfigurationChangeEvent& rEvent)
+ throw (RuntimeException)
+{
+ if (mxConfigurationController.is())
+ {
+ sal_Int32 nEventType = 0;
+ rEvent.UserData >>= nEventType;
+ switch (nEventType)
+ {
+ case ResourceActivationRequestEvent:
+ if (mxViewTabBarId->isBoundTo(rEvent.ResourceId, AnchorBindingMode_DIRECT))
+ {
+ mxConfigurationController->requestResourceActivation(
+ mxViewTabBarId,
+ ResourceActivationMode_ADD);
+ }
+ break;
+
+ case ResourceDeactivationRequestEvent:
+ if (mxViewTabBarId->isBoundTo(rEvent.ResourceId, AnchorBindingMode_DIRECT))
+ {
+ mxConfigurationController->requestResourceDeactivation(mxViewTabBarId);
+ }
+ break;
+
+ case ResourceActivationEvent:
+ if (rEvent.ResourceId->compareTo(mxViewTabBarId) == 0)
+ {
+ UpdateViewTabBar(Reference<XTabBar>(rEvent.ResourceObject,UNO_QUERY));
+ }
+ }
+ }
+}
+
+
+
+
+void SAL_CALL ViewTabBarModule::disposing (
+ const lang::EventObject& rEvent)
+ throw (RuntimeException)
+{
+ if (mxConfigurationController.is()
+ && rEvent.Source == mxConfigurationController)
+ {
+ // Without the configuration controller this class can do nothing.
+ mxConfigurationController = NULL;
+ disposing();
+ }
+}
+
+
+
+
+void ViewTabBarModule::UpdateViewTabBar (const Reference<XTabBar>& rxTabBar)
+{
+ if (mxConfigurationController.is())
+ {
+ Reference<XTabBar> xBar (rxTabBar);
+ if ( ! xBar.is())
+ xBar = Reference<XTabBar>(
+ mxConfigurationController->getResource(mxViewTabBarId), UNO_QUERY);
+
+ if (xBar.is())
+ {
+ TabBarButton aEmptyButton;
+
+ Reference<XResourceId> xAnchor (mxViewTabBarId->getAnchor());
+
+ TabBarButton aImpressViewButton;
+ aImpressViewButton.ResourceId = FrameworkHelper::CreateResourceId(
+ FrameworkHelper::msImpressViewURL,
+ xAnchor);
+ aImpressViewButton.ButtonLabel = String(SdResId(STR_DRAW_MODE));
+ if ( ! xBar->hasTabBarButton(aImpressViewButton))
+ xBar->addTabBarButtonAfter(aImpressViewButton, aEmptyButton);
+
+ TabBarButton aOutlineViewButton;
+ aOutlineViewButton.ResourceId = FrameworkHelper::CreateResourceId(
+ FrameworkHelper::msOutlineViewURL,
+ xAnchor);
+ aOutlineViewButton.ButtonLabel = String(SdResId(STR_OUTLINE_MODE));
+ if ( ! xBar->hasTabBarButton(aOutlineViewButton))
+ xBar->addTabBarButtonAfter(aOutlineViewButton, aImpressViewButton);
+
+ TabBarButton aNotesViewButton;
+ aNotesViewButton.ResourceId = FrameworkHelper::CreateResourceId(
+ FrameworkHelper::msNotesViewURL,
+ xAnchor);
+ aNotesViewButton.ButtonLabel = String(SdResId(STR_NOTES_MODE));
+ if ( ! xBar->hasTabBarButton(aNotesViewButton))
+ xBar->addTabBarButtonAfter(aNotesViewButton, aOutlineViewButton);
+
+ TabBarButton aHandoutViewButton;
+ aHandoutViewButton.ResourceId = FrameworkHelper::CreateResourceId(
+ FrameworkHelper::msHandoutViewURL,
+ xAnchor);
+ aHandoutViewButton.ButtonLabel = String(SdResId(STR_HANDOUT_MODE));
+ if ( ! xBar->hasTabBarButton(aHandoutViewButton))
+ xBar->addTabBarButtonAfter(aHandoutViewButton, aNotesViewButton);
+ }
+ }
+}
+
+
+
+
+} } // end of namespace sd::framework
diff --git a/sd/source/ui/framework/module/ViewTabBarModule.hxx b/sd/source/ui/framework/module/ViewTabBarModule.hxx
new file mode 100644
index 000000000000..f775bfb87c38
--- /dev/null
+++ b/sd/source/ui/framework/module/ViewTabBarModule.hxx
@@ -0,0 +1,107 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef SD_FRAMEWORK_VIEW_TAB_BAR_MODULE_HXX
+#define SD_FRAMEWORK_VIEW_TAB_BAR_MODULE_HXX
+
+#include "MutexOwner.hxx"
+
+#include <com/sun/star/drawing/framework/XConfigurationChangeListener.hpp>
+#include <com/sun/star/drawing/framework/XConfigurationController.hpp>
+#include <com/sun/star/drawing/framework/XTabBar.hpp>
+#include <com/sun/star/frame/XController.hpp>
+#include <osl/mutex.hxx>
+#include <cppuhelper/compbase1.hxx>
+
+namespace css = ::com::sun::star;
+
+namespace {
+
+typedef ::cppu::WeakComponentImplHelper1 <
+ ::css::drawing::framework::XConfigurationChangeListener
+ > ViewTabBarModuleInterfaceBase;
+
+} // end of anonymous namespace.
+
+
+
+
+namespace sd { namespace framework {
+
+/** This module is responsible for showing the ViewTabBar above the view in
+ the center pane.
+*/
+class ViewTabBarModule
+ : private sd::MutexOwner,
+ public ViewTabBarModuleInterfaceBase
+{
+public:
+ /** Create a new module that controlls the view tab bar above the view
+ in the specified pane.
+ @param rxController
+ This is the access point to the drawing framework.
+ @param rxViewTabBarId
+ This ResourceId specifies which tab bar is to be managed by the
+ new module.
+ */
+ ViewTabBarModule (
+ const css::uno::Reference<css::frame::XController>& rxController,
+ const css::uno::Reference<
+ css::drawing::framework::XResourceId>& rxViewTabBarId);
+ virtual ~ViewTabBarModule (void);
+
+ virtual void SAL_CALL disposing (void);
+
+
+ // XConfigurationChangeListener
+
+ virtual void SAL_CALL notifyConfigurationChange (
+ const css::drawing::framework::ConfigurationChangeEvent& rEvent)
+ throw (css::uno::RuntimeException);
+
+ // XEventListener
+
+ virtual void SAL_CALL disposing (
+ const css::lang::EventObject& rEvent)
+ throw (css::uno::RuntimeException);
+
+private:
+ css::uno::Reference<
+ css::drawing::framework::XConfigurationController> mxConfigurationController;
+ css::uno::Reference<css::drawing::framework::XResourceId> mxViewTabBarId;
+
+ /** This is the place where the view tab bar is filled. Only missing
+ buttons are added, so it is safe to call this method multiple
+ times.
+ */
+ void UpdateViewTabBar (
+ const css::uno::Reference<css::drawing::framework::XTabBar>& rxTabBar);
+};
+
+} } // end of namespace sd::framework
+
+#endif
diff --git a/sd/source/ui/framework/module/makefile.mk b/sd/source/ui/framework/module/makefile.mk
new file mode 100755
index 000000000000..bec9b1a04075
--- /dev/null
+++ b/sd/source/ui/framework/module/makefile.mk
@@ -0,0 +1,62 @@
+#*************************************************************************
+#
+# 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.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..$/..
+
+PROJECTPCH=sd
+PROJECTPCHSOURCE=$(PRJ)$/util$/sd
+PRJNAME=sd
+TARGET=framework_module
+ENABLE_EXCEPTIONS=TRUE
+AUTOSEG=true
+PRJINC=..$/..
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES = \
+ $(SLO)$/CenterViewFocusModule.obj \
+ $(SLO)$/DrawModule.obj \
+ $(SLO)$/ImpressModule.obj \
+ $(SLO)$/ModuleController.obj \
+ $(SLO)$/PresentationModule.obj \
+ $(SLO)$/ReadOnlyModeObserver.obj \
+ $(SLO)$/ResourceManager.obj \
+ $(SLO)$/ShellStackGuard.obj \
+ $(SLO)$/SlideSorterModule.obj \
+ $(SLO)$/ToolPanelModule.obj \
+ $(SLO)$/ToolBarModule.obj \
+ $(SLO)$/ViewTabBarModule.obj
+
+# --- Tagets -------------------------------------------------------
+
+.INCLUDE : target.mk
+