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

we need access to the chart model in the chart sidebar

Change-Id: I607b5ada047f84cd7a229640772a332702f93f1e
üst faed29ca
......@@ -30,8 +30,8 @@
#include <cppuhelper/supportsservice.hxx>
#include "ChartElementsPanel.hxx"
#include "ChartController.hxx"
using namespace css;
using namespace css::uno;
using ::rtl::OUString;
......@@ -46,23 +46,24 @@ ChartPanelFactory::~ChartPanelFactory()
{
}
Reference<ui::XUIElement> SAL_CALL ChartPanelFactory::createUIElement (
Reference<css::ui::XUIElement> SAL_CALL ChartPanelFactory::createUIElement (
const ::rtl::OUString& rsResourceURL,
const ::css::uno::Sequence<css::beans::PropertyValue>& rArguments)
throw(
container::NoSuchElementException,
lang::IllegalArgumentException,
css::container::NoSuchElementException,
css::lang::IllegalArgumentException,
RuntimeException, std::exception)
{
Reference<ui::XUIElement> xElement;
Reference<css::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>()));
Reference<css::frame::XFrame> xFrame (aArguments.getOrDefault("Frame", Reference<css::frame::XFrame>()));
Reference<css::awt::XWindow> xParentWindow (aArguments.getOrDefault("ParentWindow", Reference<css::awt::XWindow>()));
const sal_uInt64 nBindingsValue (aArguments.getOrDefault("SfxBindings", sal_uInt64(0)));
SfxBindings* pBindings = reinterpret_cast<SfxBindings*>(nBindingsValue);
Reference<css::frame::XController> xController (aArguments.getOrDefault("Controller", Reference<css::frame::XController>()));
vcl::Window* pParentWindow = VCLUnoHelper::GetWindow(xParentWindow);
if ( ! xParentWindow.is() || pParentWindow==NULL)
......@@ -77,11 +78,21 @@ Reference<ui::XUIElement> SAL_CALL ChartPanelFactory::createUIElement (
throw RuntimeException(
"PanelFactory::createUIElement called without SfxBindings",
NULL);
if (!xController.is())
throw RuntimeException(
"ChartPanelFactory::createUIElement called without Controller",
NULL);
ChartController* pController = dynamic_cast<ChartController*>(xController.get());
if (!pController)
throw RuntimeException(
"ChartPanelFactory::createUIElement called without valid ChartController",
NULL);
sal_Int32 nMinimumSize = -1;
VclPtr<vcl::Window> pPanel;
if (rsResourceURL.endsWith("/ElementsPanel"))
pPanel = ChartElementsPanel::Create( pParentWindow, xFrame, pBindings );
pPanel = ChartElementsPanel::Create( pParentWindow, xFrame, pBindings, pController );
/*
else if (rsResourceURL.endsWith("/CellAppearancePropertyPanel"))
pPanel = CellAppearancePropertyPanel::Create( pParentWindow, xFrame, pBindings );
......@@ -104,17 +115,17 @@ Reference<ui::XUIElement> SAL_CALL ChartPanelFactory::createUIElement (
rsResourceURL,
xFrame,
pPanel,
ui::LayoutSize(nMinimumSize,-1,-1));
css::ui::LayoutSize(nMinimumSize,-1,-1));
}
catch (const uno::RuntimeException &)
catch (const css::uno::RuntimeException &)
{
throw;
}
catch (const uno::Exception& e)
catch (const css::uno::Exception& e)
{
throw lang::WrappedTargetRuntimeException(
throw css::lang::WrappedTargetRuntimeException(
OUString("ChartPanelFactory::createUIElement exception"),
0, uno::makeAny(e));
0, css::uno::makeAny(e));
}
return xElement;
......
......@@ -21,6 +21,7 @@
#include <sfx2/sidebar/Theme.hxx>
#include <sfx2/sidebar/ControlFactory.hxx>
#include "ChartElementsPanel.hxx"
#include "ChartController.hxx"
#include <sfx2/bindings.hxx>
#include <sfx2/dispatch.hxx>
#include <sfx2/imagemgr.hxx>
......@@ -40,11 +41,13 @@ namespace chart { namespace sidebar {
ChartElementsPanel::ChartElementsPanel(
vcl::Window* pParent,
const css::uno::Reference<css::frame::XFrame>& rxFrame,
SfxBindings* pBindings)
SfxBindings* pBindings,
ChartController* pController)
: PanelLayout(pParent, "ChartElementsPanel", "modules/schart/ui/sidebarelements.ui", rxFrame),
mxFrame(rxFrame),
maContext(),
mpBindings(pBindings)
mpBindings(pBindings),
mxModel(pController->getModel())
{
get(mpCBTitle, "checkbutton_title");
get(mpCBSubtitle, "checkbutton_subtitle");
......@@ -93,10 +96,27 @@ void ChartElementsPanel::dispose()
PanelLayout::dispose();
}
void ChartElementsPanel::Initialize()
{
updateData();
}
void ChartElementsPanel::updateData()
{
mpCBLegend->Check(isLegendVisible(mxModel));
mpCBTitle->Check(isTitleVisisble(mxModel, TitleHelper::MAIN_TITLE));
mpCBSubtitle->Check(isTitleVisisble(mxModel, TitleHelper::SUB_TITLE));
mpCBXAxisTitle->Check(isTitleVisisble(mxModel, TitleHelper::X_AXIS_TITLE));
mpCBYAxisTitle->Check(isTitleVisisble(mxModel, TitleHelper::Y_AXIS_TITLE));
mpCBZAxisTitle->Check(isTitleVisisble(mxModel, TitleHelper::Z_AXIS_TITLE));
mpCB2ndXAxisTitle->Check(isTitleVisisble(mxModel, TitleHelper::SECONDARY_X_AXIS_TITLE));
mpCB2ndYAxisTitle->Check(isTitleVisisble(mxModel, TitleHelper::SECONDARY_Y_AXIS_TITLE));
}
VclPtr<vcl::Window> ChartElementsPanel::Create (
vcl::Window* pParent,
const css::uno::Reference<css::frame::XFrame>& rxFrame,
SfxBindings* pBindings)
SfxBindings* pBindings, ChartController* pController)
{
if (pParent == NULL)
throw lang::IllegalArgumentException("no parent Window given to ChartElementsPanel::Create", NULL, 0);
......@@ -106,7 +126,7 @@ VclPtr<vcl::Window> ChartElementsPanel::Create (
throw lang::IllegalArgumentException("no SfxBindings given to ChartElementsPanel::Create", NULL, 2);
return VclPtr<ChartElementsPanel>::Create(
pParent, rxFrame, pBindings);
pParent, rxFrame, pBindings, pController);
}
void ChartElementsPanel::DataChanged(
......
......@@ -28,7 +28,11 @@ class FixedText;
class ListBox;
class NumericField;
namespace chart { namespace sidebar {
namespace chart {
class ChartController;
namespace sidebar {
class ChartElementsPanel : public PanelLayout,
public ::sfx2::sidebar::IContextChangeReceiver,
......@@ -38,7 +42,7 @@ public:
static VclPtr<vcl::Window> Create(
vcl::Window* pParent,
const css::uno::Reference<css::frame::XFrame>& rxFrame,
SfxBindings* pBindings);
SfxBindings* pBindings, ChartController* pController);
virtual void DataChanged(
const DataChangedEvent& rEvent) SAL_OVERRIDE;
......@@ -58,7 +62,7 @@ public:
ChartElementsPanel(
vcl::Window* pParent,
const css::uno::Reference<css::frame::XFrame>& rxFrame,
SfxBindings* pBindings);
SfxBindings* pBindings, ChartController* pController);
virtual ~ChartElementsPanel();
virtual void dispose() SAL_OVERRIDE;
private:
......@@ -88,6 +92,10 @@ private:
css::uno::Reference<css::frame::XFrame> mxFrame;
::sfx2::sidebar::EnumContext maContext;
SfxBindings* mpBindings;
css::uno::Reference<css::frame::XModel> mxModel;
void Initialize();
};
} } // end of namespace ::chart::sidebar
......
......@@ -802,6 +802,7 @@ Reference<ui::XUIElement> SidebarController::CreateUIElement (
{
aCreationArguments.put("Module", makeAny(aModule));
}
aCreationArguments.put("Controller", makeAny(mxCurrentController));
}
aCreationArguments.put("ApplicationName", makeAny(rContext.msApplication));
......
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