2013-04-10 08:20:16 +00:00
|
|
|
/*
|
|
|
|
* 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 "text/TextPropertyPanel.hxx"
|
|
|
|
#include "paragraph/ParaPropertyPanel.hxx"
|
|
|
|
#include "area/AreaPropertyPanel.hxx"
|
|
|
|
#include "graphic/GraphicPropertyPanel.hxx"
|
|
|
|
#include "line/LinePropertyPanel.hxx"
|
|
|
|
#include "possize/PosSizePropertyPanel.hxx"
|
2013-05-03 13:01:13 +00:00
|
|
|
#include "insert/InsertPropertyPanel.hxx"
|
2013-04-10 08:20:16 +00:00
|
|
|
#include "GalleryControl.hxx"
|
|
|
|
#include "debug/ColorPanel.hxx"
|
|
|
|
#include "debug/ContextPanel.hxx"
|
|
|
|
#include "debug/NotYetImplementedPanel.hxx"
|
|
|
|
#include "EmptyPanel.hxx"
|
|
|
|
#include <sfx2/sidebar/SidebarPanelBase.hxx>
|
2013-09-05 21:58:31 +03:00
|
|
|
#include <sfx2/sidebar/Tools.hxx>
|
2013-04-10 08:20:16 +00:00
|
|
|
#include <sfx2/sfxbasecontroller.hxx>
|
|
|
|
#include <sfx2/templdlg.hxx>
|
|
|
|
#include <toolkit/helper/vclunohelper.hxx>
|
|
|
|
#include <vcl/window.hxx>
|
|
|
|
#include <rtl/ref.hxx>
|
|
|
|
#include <comphelper/namedvaluecollection.hxx>
|
2013-12-30 10:04:05 +01:00
|
|
|
#include <cppuhelper/basemutex.hxx>
|
|
|
|
#include <cppuhelper/compbase1.hxx>
|
2013-04-10 08:20:16 +00:00
|
|
|
#include <com/sun/star/ui/XSidebar.hpp>
|
2013-12-30 10:04:05 +01:00
|
|
|
#include <com/sun/star/ui/XUIElementFactory.hpp>
|
2013-04-10 08:20:16 +00:00
|
|
|
|
|
|
|
#include <boost/bind.hpp>
|
2013-12-30 10:04:05 +01:00
|
|
|
#include <boost/noncopyable.hpp>
|
2013-04-10 08:20:16 +00:00
|
|
|
|
2013-12-30 10:04:05 +01:00
|
|
|
namespace cssu = ::com::sun::star::uno;
|
2013-04-10 08:20:16 +00:00
|
|
|
using namespace css;
|
|
|
|
using namespace cssu;
|
2013-12-30 10:04:05 +01:00
|
|
|
using namespace svx::sidebar;
|
2013-12-20 22:41:38 +01:00
|
|
|
|
|
|
|
|
2013-12-30 10:04:05 +01:00
|
|
|
namespace {
|
2013-04-10 08:20:16 +00:00
|
|
|
|
2013-12-30 10:04:05 +01:00
|
|
|
/* Why this is not used ? Doesn't it need to inherit from XServiceInfo ?
|
2013-04-10 08:20:16 +00:00
|
|
|
#define IMPLEMENTATION_NAME "org.apache.openoffice.comp.svx.sidebar.PanelFactory"
|
|
|
|
#define SERVICE_NAME "com.sun.star.ui.UIElementFactory"
|
2013-12-30 10:04:05 +01:00
|
|
|
*/
|
2013-04-10 08:20:16 +00:00
|
|
|
|
2013-12-30 10:04:05 +01:00
|
|
|
typedef ::cppu::WeakComponentImplHelper1< css::ui::XUIElementFactory >
|
|
|
|
PanelFactoryInterfaceBase;
|
2013-04-10 08:20:16 +00:00
|
|
|
|
2013-12-30 10:04:05 +01:00
|
|
|
class PanelFactory
|
|
|
|
: private ::boost::noncopyable,
|
|
|
|
private ::cppu::BaseMutex,
|
|
|
|
public PanelFactoryInterfaceBase
|
2013-04-10 08:20:16 +00:00
|
|
|
{
|
2013-12-30 10:04:05 +01:00
|
|
|
public:
|
|
|
|
PanelFactory (void);
|
|
|
|
virtual ~PanelFactory (void);
|
|
|
|
|
|
|
|
// XUIElementFactory
|
|
|
|
cssu::Reference<css::ui::XUIElement> SAL_CALL createUIElement (
|
|
|
|
const ::rtl::OUString& rsResourceURL,
|
|
|
|
const ::cssu::Sequence<css::beans::PropertyValue>& rArguments)
|
|
|
|
throw(
|
|
|
|
css::container::NoSuchElementException,
|
|
|
|
css::lang::IllegalArgumentException,
|
|
|
|
cssu::RuntimeException);
|
|
|
|
};
|
2013-04-10 08:20:16 +00:00
|
|
|
|
|
|
|
PanelFactory::PanelFactory (void)
|
|
|
|
: PanelFactoryInterfaceBase(m_aMutex)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-12-20 22:41:38 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
2013-04-10 08:20:16 +00:00
|
|
|
PanelFactory::~PanelFactory (void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-12-20 22:41:38 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
2013-04-10 08:20:16 +00:00
|
|
|
Reference<ui::XUIElement> SAL_CALL PanelFactory::createUIElement (
|
|
|
|
const ::rtl::OUString& rsResourceURL,
|
|
|
|
const ::cssu::Sequence<css::beans::PropertyValue>& rArguments)
|
|
|
|
throw(
|
|
|
|
container::NoSuchElementException,
|
|
|
|
lang::IllegalArgumentException,
|
|
|
|
RuntimeException)
|
|
|
|
{
|
|
|
|
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>()));
|
|
|
|
Reference<ui::XSidebar> xSidebar (aArguments.getOrDefault("Sidebar", Reference<ui::XSidebar>()));
|
|
|
|
const sal_uInt64 nBindingsValue (aArguments.getOrDefault("SfxBindings", sal_uInt64(0)));
|
|
|
|
SfxBindings* pBindings = reinterpret_cast<SfxBindings*>(nBindingsValue);
|
2013-05-14 15:21:57 +00:00
|
|
|
::sfx2::sidebar::EnumContext aContext (
|
|
|
|
aArguments.getOrDefault("ApplicationName", OUString()),
|
|
|
|
aArguments.getOrDefault("ContextName", OUString()));
|
2013-04-10 08:20:16 +00:00
|
|
|
|
|
|
|
::Window* pParentWindow = VCLUnoHelper::GetWindow(xParentWindow);
|
|
|
|
if ( ! xParentWindow.is() || pParentWindow==NULL)
|
|
|
|
throw RuntimeException(
|
2013-11-12 09:33:27 +02:00
|
|
|
"PanelFactory::createUIElement called without ParentWindow",
|
2013-04-10 08:20:16 +00:00
|
|
|
NULL);
|
|
|
|
if ( ! xFrame.is())
|
|
|
|
throw RuntimeException(
|
2013-11-12 09:33:27 +02:00
|
|
|
"PanelFactory::createUIElement called without Frame",
|
2013-04-10 08:20:16 +00:00
|
|
|
NULL);
|
|
|
|
if (pBindings == NULL)
|
|
|
|
throw RuntimeException(
|
2013-11-12 09:33:27 +02:00
|
|
|
"PanelFactory::createUIElement called without SfxBindings",
|
2013-04-10 08:20:16 +00:00
|
|
|
NULL);
|
|
|
|
|
|
|
|
Window* pControl = NULL;
|
|
|
|
ui::LayoutSize aLayoutSize (-1,-1,-1);
|
|
|
|
|
|
|
|
#define DoesResourceEndWith(s) rsResourceURL.endsWithAsciiL(s,strlen(s))
|
|
|
|
if (DoesResourceEndWith("/TextPropertyPanel"))
|
|
|
|
{
|
2013-05-14 15:21:57 +00:00
|
|
|
pControl = TextPropertyPanel::Create(pParentWindow, xFrame, pBindings, aContext);
|
2013-04-10 08:20:16 +00:00
|
|
|
}
|
|
|
|
else if (DoesResourceEndWith("/ParaPropertyPanel"))
|
|
|
|
{
|
|
|
|
pControl = ParaPropertyPanel::Create(pParentWindow, xFrame, pBindings, xSidebar);
|
|
|
|
}
|
|
|
|
else if (DoesResourceEndWith("/AreaPropertyPanel"))
|
|
|
|
{
|
|
|
|
pControl = AreaPropertyPanel::Create(pParentWindow, xFrame, pBindings);
|
|
|
|
}
|
|
|
|
else if (DoesResourceEndWith("/GraphicPropertyPanel"))
|
|
|
|
{
|
|
|
|
pControl = GraphicPropertyPanel::Create(pParentWindow, xFrame, pBindings);
|
|
|
|
}
|
|
|
|
else if (DoesResourceEndWith("/LinePropertyPanel"))
|
|
|
|
{
|
|
|
|
pControl = LinePropertyPanel::Create(pParentWindow, xFrame, pBindings);
|
|
|
|
}
|
|
|
|
else if (DoesResourceEndWith("/PosSizePropertyPanel"))
|
|
|
|
{
|
|
|
|
pControl = PosSizePropertyPanel::Create(pParentWindow, xFrame, pBindings, xSidebar);
|
|
|
|
}
|
2013-05-03 13:01:13 +00:00
|
|
|
else if (DoesResourceEndWith("/InsertPropertyPanel"))
|
|
|
|
{
|
|
|
|
pControl = new InsertPropertyPanel(pParentWindow, xFrame);
|
|
|
|
}
|
2013-04-10 08:20:16 +00:00
|
|
|
else if (DoesResourceEndWith("/GalleryPanel"))
|
|
|
|
{
|
|
|
|
pControl = new GalleryControl(pBindings, pParentWindow);
|
|
|
|
aLayoutSize = ui::LayoutSize(300,-1,400);
|
|
|
|
}
|
|
|
|
else if (DoesResourceEndWith("/StyleListPanel"))
|
|
|
|
{
|
|
|
|
pControl = new SfxTemplatePanelControl(pBindings, pParentWindow);
|
|
|
|
aLayoutSize = ui::LayoutSize(0,-1,-1);
|
|
|
|
}
|
|
|
|
else if (DoesResourceEndWith("/Debug_ColorPanel"))
|
|
|
|
{
|
|
|
|
pControl = new ColorPanel(pParentWindow);
|
|
|
|
aLayoutSize = ui::LayoutSize(300,-1,400);
|
|
|
|
}
|
|
|
|
else if (DoesResourceEndWith("/Debug_ContextPanel"))
|
|
|
|
{
|
|
|
|
pControl = new ContextPanel(pParentWindow);
|
|
|
|
aLayoutSize = ui::LayoutSize(45,45,45);
|
|
|
|
}
|
|
|
|
else if (DoesResourceEndWith("/Debug_NotYetImplementedPanel"))
|
|
|
|
{
|
|
|
|
pControl = new NotYetImplementedPanel(pParentWindow);
|
|
|
|
aLayoutSize = ui::LayoutSize(20,25,25);
|
|
|
|
}
|
|
|
|
else if (DoesResourceEndWith("/EmptyPanel"))
|
|
|
|
{
|
|
|
|
pControl = new EmptyPanel(pParentWindow);
|
|
|
|
aLayoutSize = ui::LayoutSize(20,-1, 50);
|
|
|
|
}
|
|
|
|
#undef DoesResourceEndWith
|
|
|
|
|
|
|
|
if (pControl != NULL)
|
|
|
|
{
|
|
|
|
return sfx2::sidebar::SidebarPanelBase::Create(
|
|
|
|
rsResourceURL,
|
|
|
|
xFrame,
|
|
|
|
pControl,
|
|
|
|
aLayoutSize);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return Reference<ui::XUIElement>();
|
|
|
|
}
|
|
|
|
|
2013-12-30 10:04:05 +01:00
|
|
|
}
|
2013-04-10 08:20:16 +00:00
|
|
|
|
2013-12-30 10:04:05 +01:00
|
|
|
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
|
|
|
|
org_apache_openoffice_comp_svx_sidebar_PanelFactory_implementation_getFactory(
|
|
|
|
SAL_UNUSED_PARAMETER css::uno::XComponentContext *,
|
2014-01-14 15:41:32 +01:00
|
|
|
css::uno::Sequence<css::uno::Any> const &)
|
2013-12-30 10:04:05 +01:00
|
|
|
{
|
|
|
|
css::uno::Reference<css::uno::XInterface> x(
|
|
|
|
static_cast<cppu::OWeakObject *>(new PanelFactory));
|
|
|
|
x->acquire();
|
|
|
|
return x.get();
|
|
|
|
}
|