Kaydet (Commit) b33b2afe authored tarafından Markus Mohrhard's avatar Markus Mohrhard

big step towards real chart sidebar

Change-Id: I9b7d1f963746f7689b02099fbae77c9c943bad58
üst 5a72bbd4
......@@ -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
......
......@@ -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>
/* -*- 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: */
/* -*- 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: */
......@@ -132,6 +132,20 @@
<value>org.apache.openoffice.comp.sw.sidebar.SwPanelFactory</value>
</prop>
</node>
<node oor:name="ChartPanelFactory" oor:op="replace">
<prop oor:name="Type">
<value>toolpanel</value>
</prop>
<prop oor:name="Name">
<value>ChartPanelFactory</value>
</prop>
<prop oor:name="Module">
<value></value>
</prop>
<prop oor:name="FactoryImplementation">
<value>org.libreoffice.comp.chart2.sidebar.ChartPanelFactory</value>
</prop>
</node>
</node>
</node>
</oor:component-data>
......@@ -231,6 +231,26 @@
</prop>
</node>
<node oor:name="ChartDeck" oor:op="replace">
<prop oor:name="Title" oor:type="xs:string">
<value xml:lang="en-US">Chart</value>
</prop>
<prop oor:name="Id" oor:type="xs:string">
<value>ChartDeck</value>
</prop>
<prop oor:name="IconURL" oor:type="xs:string">
<value>private:graphicrepository/sfx2/res/symphony/sidebar-style-large.png</value>
</prop>
<prop oor:name="ContextList">
<value oor:separator=";">
Chart, any, visible ;
</value>
</prop>
<prop oor:name="OrderIndex" oor:type="xs:int">
<value>10</value>
</prop>
</node>
</node>
<node oor:name="PanelList">
......@@ -1118,6 +1138,122 @@
<value>true</value>
</prop>
</node>
<node oor:name="ChartElementsPanel" oor:op="replace">
<prop oor:name="Title" oor:type="xs:string">
<value xml:lang="en-US">Elements</value>
</prop>
<prop oor:name="Id" oor:type="xs:string">
<value>ChartElementsPanel</value>
</prop>
<prop oor:name="DeckId" oor:type="xs:string">
<value>ChartDeck</value>
</prop>
<prop oor:name="ContextList">
<value oor:separator=";">
Chart, any, visible ;
</value>
</prop>
<prop oor:name="ImplementationURL" oor:type="xs:string">
<value>private:resource/toolpanel/ChartPanelFactory/ElementsPanel</value>
</prop>
<prop oor:name="OrderIndex" oor:type="xs:int">
<value>1</value>
</prop>
</node>
<node oor:name="ChartAreaPanel" oor:op="replace">
<prop oor:name="Title" oor:type="xs:string">
<value xml:lang="en-US">Area</value>
</prop>
<prop oor:name="Id" oor:type="xs:string">
<value>ChartAreaPanel</value>
</prop>
<prop oor:name="DeckId" oor:type="xs:string">
<value>ChartDeck</value>
</prop>
<prop oor:name="ContextList">
<value oor:separator=";">
Chart, any, visible ;
</value>
</prop>
<prop oor:name="ImplementationURL" oor:type="xs:string">
<value>private:resource/toolpanel/ChartPanelFactory/AreaPanel</value>
</prop>
<prop oor:name="OrderIndex" oor:type="xs:int">
<value>2</value>
</prop>
</node>
<node oor:name="ChartLinePanel" oor:op="replace">
<prop oor:name="Title" oor:type="xs:string">
<value xml:lang="en-US">Line</value>
</prop>
<prop oor:name="Id" oor:type="xs:string">
<value>ChartLinePanel</value>
</prop>
<prop oor:name="DeckId" oor:type="xs:string">
<value>ChartDeck</value>
</prop>
<prop oor:name="ContextList">
<value oor:separator=";">
Chart, any, visible ;
</value>
</prop>
<prop oor:name="ImplementationURL" oor:type="xs:string">
<value>private:resource/toolpanel/ChartPanelFactory/LinePanel</value>
</prop>
<prop oor:name="OrderIndex" oor:type="xs:int">
<value>3</value>
</prop>
</node>
<node oor:name="ChartCharacterPanel" oor:op="replace">
<prop oor:name="Title" oor:type="xs:string">
<value xml:lang="en-US">Character</value>
</prop>
<prop oor:name="Id" oor:type="xs:string">
<value>ChartCharacterPanel</value>
</prop>
<prop oor:name="DeckId" oor:type="xs:string">
<value>ChartDeck</value>
</prop>
<prop oor:name="ContextList">
<value oor:separator=";">
Chart, any, visible ;
</value>
</prop>
<prop oor:name="ImplementationURL" oor:type="xs:string">
<value>private:resource/toolpanel/ChartPanelFactory/CharacterPanel</value>
</prop>
<prop oor:name="OrderIndex" oor:type="xs:int">
<value>4</value>
</prop>
</node>
<node oor:name="ChartAxisPanel" oor:op="replace">
<prop oor:name="Title" oor:type="xs:string">
<value xml:lang="en-US">Axis</value>
</prop>
<prop oor:name="Id" oor:type="xs:string">
<value>ChartAxisPanel</value>
</prop>
<prop oor:name="DeckId" oor:type="xs:string">
<value>ChartDeck</value>
</prop>
<prop oor:name="ContextList">
<value oor:separator=";">
Chart, any, visible ;
</value>
</prop>
<prop oor:name="ImplementationURL" oor:type="xs:string">
<value>private:resource/toolpanel/ChartPanelFactory/AxisPanel</value>
</prop>
<prop oor:name="OrderIndex" oor:type="xs:int">
<value>5</value>
</prop>
</node>
</node>
</node>
</oor:component-data>
......@@ -86,12 +86,14 @@
com.sun.star.sheet.SpreadsheetDocument
com.sun.star.presentation.PresentationDocument
com.sun.star.drawing.DrawingDocument
com.sun.star.chart2.ChartDocument
Recognized shortcuts:
Writer
Calc
Impress
Draw
Chart
Shortcuts for multiple applications:
DrawImpress
......
......@@ -46,7 +46,14 @@ Context::Context (
sal_Int32 Context::EvaluateMatch (
const Context& rOther) const
{
const bool bApplicationNameIsAny (rOther.msApplication == AnyApplicationName);
bool bApplicationNameIsAny (rOther.msApplication == AnyApplicationName);
// special case for charts which use a whole own set of decks
if (msApplication == "com.sun.star.chart2.ChartDocument")
{
bApplicationNameIsAny = false;
}
if (rOther.msApplication.equals(msApplication) || bApplicationNameIsAny)
{
// Application name matches.
......
......@@ -416,6 +416,8 @@ void ResourceManager::ReadContextList (
aApplications.push_back(EnumContext::Application_Draw);
else if (sApplicationName == "Impress")
aApplications.push_back(EnumContext::Application_Impress);
else if (sApplicationName == "Chart")
aApplications.push_back(EnumContext::Application_Chart);
else if (sApplicationName == "DrawImpress")
{
// A special case among the special names: it is
......
......@@ -548,7 +548,6 @@ void SidebarController::CreateDeck(const ::rtl::OUString& rDeckId)
::boost::bind(&SidebarController::RequestCloseDeck, this));
mpResourceManager->SetDeckToDescriptor(rDeckId, aDeck);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment