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