diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2015-07-09 20:39:06 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2015-07-12 18:56:49 +0200 |
commit | b33b2afe6a8b4224450da7c686beb81dbf5cd24a (patch) | |
tree | 17c0970756a0c9b9f6a9968acee641a4bdc2802a /chart2 | |
parent | 5a72bbd483ddf6c7cc949a8708d1697654cc9ce2 (diff) |
big step towards real chart sidebar
Change-Id: I9b7d1f963746f7689b02099fbae77c9c943bad58
Diffstat (limited to 'chart2')
-rw-r--r-- | chart2/Library_chartcontroller.mk | 1 | ||||
-rw-r--r-- | chart2/source/controller/chartcontroller.component | 4 | ||||
-rw-r--r-- | chart2/source/controller/sidebar/Chart2PanelFactory.cxx | 149 | ||||
-rw-r--r-- | chart2/source/controller/sidebar/Chart2PanelFactory.hxx | 71 |
4 files changed, 225 insertions, 0 deletions
diff --git a/chart2/Library_chartcontroller.mk b/chart2/Library_chartcontroller.mk index f77ef70b9056..be73e1e4d842 100644 --- a/chart2/Library_chartcontroller.mk +++ b/chart2/Library_chartcontroller.mk @@ -188,6 +188,7 @@ $(eval $(call gb_Library_add_exception_objects,chartcontroller,\ chart2/source/controller/main/UndoActions \ chart2/source/controller/main/UndoCommandDispatch \ chart2/source/controller/main/UndoGuard \ + chart2/source/controller/sidebar/Chart2PanelFactory \ )) # Runtime dependency for unit-tests diff --git a/chart2/source/controller/chartcontroller.component b/chart2/source/controller/chartcontroller.component index 396656db1e1b..045d61f244dc 100644 --- a/chart2/source/controller/chartcontroller.component +++ b/chart2/source/controller/chartcontroller.component @@ -51,4 +51,8 @@ constructor="com_sun_star_comp_chart2_WizardDialog_get_implementation"> <service name="com.sun.star.chart2.WizardDialog"/> </implementation> + <implementation name="org.libreoffice.comp.chart2.sidebar.ChartPanelFactory" + constructor="org_libreoffice_comp_chart2_sidebar_ChartPanelFactory"> + <service name="com.sun.star.ui.UIElementFactory"/> + </implementation> </component> diff --git a/chart2/source/controller/sidebar/Chart2PanelFactory.cxx b/chart2/source/controller/sidebar/Chart2PanelFactory.cxx new file mode 100644 index 000000000000..13df31f0ed31 --- /dev/null +++ b/chart2/source/controller/sidebar/Chart2PanelFactory.cxx @@ -0,0 +1,149 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include "Chart2PanelFactory.hxx" + +#include <sfx2/sidebar/SidebarPanelBase.hxx> +#include <sfx2/sfxbasecontroller.hxx> +#include <toolkit/helper/vclunohelper.hxx> +#include <vcl/window.hxx> +#include <rtl/ref.hxx> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp> +#include <comphelper/namedvaluecollection.hxx> +#include <cppuhelper/supportsservice.hxx> + +using namespace css; +using namespace css::uno; +using ::rtl::OUString; + +namespace chart { namespace sidebar { + +ChartPanelFactory::ChartPanelFactory() + : PanelFactoryInterfaceBase(m_aMutex) +{ +} + +ChartPanelFactory::~ChartPanelFactory() +{ +} + +Reference<ui::XUIElement> SAL_CALL ChartPanelFactory::createUIElement ( + const ::rtl::OUString& rsResourceURL, + const ::css::uno::Sequence<css::beans::PropertyValue>& rArguments) + throw( + container::NoSuchElementException, + lang::IllegalArgumentException, + RuntimeException, std::exception) +{ + Reference<ui::XUIElement> xElement; + + try + { + const ::comphelper::NamedValueCollection aArguments (rArguments); + Reference<frame::XFrame> xFrame (aArguments.getOrDefault("Frame", Reference<frame::XFrame>())); + Reference<awt::XWindow> xParentWindow (aArguments.getOrDefault("ParentWindow", Reference<awt::XWindow>())); + const sal_uInt64 nBindingsValue (aArguments.getOrDefault("SfxBindings", sal_uInt64(0))); + SfxBindings* pBindings = reinterpret_cast<SfxBindings*>(nBindingsValue); + + vcl::Window* pParentWindow = VCLUnoHelper::GetWindow(xParentWindow); + if ( ! xParentWindow.is() || pParentWindow==NULL) + throw RuntimeException( + "PanelFactory::createUIElement called without ParentWindow", + NULL); + if ( ! xFrame.is()) + throw RuntimeException( + "PanelFactory::createUIElement called without Frame", + NULL); + if (pBindings == NULL) + throw RuntimeException( + "PanelFactory::createUIElement called without SfxBindings", + NULL); + + sal_Int32 nMinimumSize = -1; + VclPtr<vcl::Window> pPanel; + /* + if (rsResourceURL.endsWith("/AlignmentPropertyPanel")) + pPanel = AlignmentPropertyPanel::Create( pParentWindow, xFrame, pBindings ); + else if (rsResourceURL.endsWith("/CellAppearancePropertyPanel")) + pPanel = CellAppearancePropertyPanel::Create( pParentWindow, xFrame, pBindings ); + else if (rsResourceURL.endsWith("/NumberFormatPropertyPanel")) + pPanel = NumberFormatPropertyPanel::Create( pParentWindow, xFrame, pBindings ); + else if (rsResourceURL.endsWith("/NavigatorPanel")) + { + pPanel = VclPtr<ScNavigatorDlg>::Create(pBindings, nullptr, pParentWindow, false); + nMinimumSize = 0; + } + else if (rsResourceURL.endsWith("/FunctionsPanel")) + { + pPanel = VclPtr<ScFunctionDockWin>::Create(pBindings, nullptr, pParentWindow, ScResId(FID_FUNCTION_BOX)); + nMinimumSize = 0; + } + */ + + if (pPanel) + xElement = sfx2::sidebar::SidebarPanelBase::Create( + rsResourceURL, + xFrame, + pPanel, + ui::LayoutSize(nMinimumSize,-1,-1)); + } + catch (const uno::RuntimeException &) + { + throw; + } + catch (const uno::Exception& e) + { + throw lang::WrappedTargetRuntimeException( + OUString("ChartPanelFactory::createUIElement exception"), + 0, uno::makeAny(e)); + } + + return xElement; +} + +OUString ChartPanelFactory::getImplementationName() + throw (css::uno::RuntimeException, std::exception) +{ + return OUString("org.libreoffice.comp.chart2.sidebar.ChartPanelFactory"); +} + +sal_Bool ChartPanelFactory::supportsService(OUString const & ServiceName) + throw (css::uno::RuntimeException, std::exception) +{ + return cppu::supportsService(this, ServiceName); +} + +css::uno::Sequence<OUString> ChartPanelFactory::getSupportedServiceNames() + throw (css::uno::RuntimeException, std::exception) +{ + css::uno::Sequence<OUString> aServiceNames(1); + aServiceNames[0] = "com.sun.star.ui.UIElementFactory"; + return aServiceNames; +} + +} } // end of namespace chart::sidebar + +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* SAL_CALL +org_libreoffice_comp_chart2_sidebar_ChartPanelFactory(css::uno::XComponentContext*, css::uno::Sequence<css::uno::Any> const &) +{ + return cppu::acquire(new chart::sidebar::ChartPanelFactory()); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/sidebar/Chart2PanelFactory.hxx b/chart2/source/controller/sidebar/Chart2PanelFactory.hxx new file mode 100644 index 000000000000..c96813ce6a3e --- /dev/null +++ b/chart2/source/controller/sidebar/Chart2PanelFactory.hxx @@ -0,0 +1,71 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SC_INC_SCPANELFACTORY_HXX +#define INCLUDED_SC_INC_SCPANELFACTORY_HXX + +#include <cppuhelper/compbase.hxx> +#include <cppuhelper/basemutex.hxx> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/ui/XUIElementFactory.hpp> +#include <boost/noncopyable.hpp> + + +namespace chart { namespace sidebar { + +namespace +{ + typedef ::cppu::WeakComponentImplHelper < + css::ui::XUIElementFactory, css::lang::XServiceInfo + > PanelFactoryInterfaceBase; +} + +class ChartPanelFactory + : private ::boost::noncopyable, + private ::cppu::BaseMutex, + public PanelFactoryInterfaceBase +{ +public: + ChartPanelFactory(); + virtual ~ChartPanelFactory(); + + // XUIElementFactory + virtual css::uno::Reference<css::ui::XUIElement> SAL_CALL createUIElement( + const ::rtl::OUString& rsResourceURL, + const ::css::uno::Sequence<css::beans::PropertyValue>& rArguments) + throw( + css::container::NoSuchElementException, + css::lang::IllegalArgumentException, + css::uno::RuntimeException, std::exception ) SAL_OVERRIDE; + + virtual OUString SAL_CALL getImplementationName() + throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + + virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName) + throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + + virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() + throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE; +}; + +} } // end of namespace sc::sidebar + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |