[Libreoffice-commits] core.git: Branch 'feature/chart-sidebar' - 4 commits - chart2/source include/svx svx/source
Markus Mohrhard
markus.mohrhard at googlemail.com
Tue Jul 21 10:02:15 PDT 2015
chart2/source/controller/sidebar/ChartAreaPanel.cxx | 21 -
include/svx/sidebar/AreaPropertyPanelBase.hxx | 8
svx/source/sidebar/area/AreaPropertyPanelBase.cxx | 406 ++++++++++----------
3 files changed, 242 insertions(+), 193 deletions(-)
New commits:
commit 1e81c2c80d552e388ff600cef40c5ca6652e2015
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Tue Jul 21 19:01:26 2015 +0200
avoid crash with color listbox for now
Change-Id: I36ac6513546961ec8d8d1e9437a8ef88574acbf4
diff --git a/svx/source/sidebar/area/AreaPropertyPanelBase.cxx b/svx/source/sidebar/area/AreaPropertyPanelBase.cxx
index bf48573..3b94efc 100644
--- a/svx/source/sidebar/area/AreaPropertyPanelBase.cxx
+++ b/svx/source/sidebar/area/AreaPropertyPanelBase.cxx
@@ -207,7 +207,7 @@ IMPL_LINK(AreaPropertyPanelBase, SelectFillTypeHdl, ListBox *, pToolBox)
mpLbFillAttr->Hide();
mpToolBoxColor->Show();
const OUString aTmpStr;
- const Color aColor = mpColorItem->GetColorValue();
+ const Color aColor = mpColorItem ? mpColorItem->GetColorValue() : COL_AUTO;
const XFillColorItem aXFillColorItem( aTmpStr, aColor );
// #i122676# change FillStyle and Color in one call
commit 352e5f6a6c797eb0677a24b9cdc7a73306e8e6f6
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Tue Jul 21 19:01:06 2015 +0200
avoid a crash that occures sometimes
Change-Id: Iccbdfdb8a46b45b76756ff8080757db3770d691c
diff --git a/chart2/source/controller/sidebar/ChartAreaPanel.cxx b/chart2/source/controller/sidebar/ChartAreaPanel.cxx
index 89eb74b..13c4a7c 100644
--- a/chart2/source/controller/sidebar/ChartAreaPanel.cxx
+++ b/chart2/source/controller/sidebar/ChartAreaPanel.cxx
@@ -23,7 +23,9 @@ OUString getCID(css::uno::Reference<css::frame::XModel> xModel)
return OUString();
css::uno::Any aAny = xSelectionSupplier->getSelection();
- assert(aAny.hasValue());
+ if (!aAny.hasValue())
+ return OUString();
+
OUString aCID;
aAny >>= aCID;
@@ -94,6 +96,9 @@ void ChartAreaPanel::setFillFloatTransparence(const XFillFloatTransparenceItem&
void ChartAreaPanel::setFillStyle(const XFillStyleItem& rItem)
{
css::uno::Reference<css::beans::XPropertySet> xPropSet = getPropSet(mxModel);
+ if (!xPropSet.is())
+ return;
+
xPropSet->setPropertyValue("FillStyle", css::uno::makeAny(rItem.GetValue()));
}
@@ -101,6 +106,9 @@ void ChartAreaPanel::setFillStyleAndColor(const XFillStyleItem* pStyleItem,
const XFillColorItem& rColorItem)
{
css::uno::Reference<css::beans::XPropertySet> xPropSet = getPropSet(mxModel);
+ if (!xPropSet.is())
+ return;
+
if (pStyleItem)
xPropSet->setPropertyValue("FillStyle", css::uno::makeAny(pStyleItem->GetValue()));
xPropSet->setPropertyValue("Color", css::uno::makeAny(rColorItem.GetValue()));
@@ -110,6 +118,9 @@ void ChartAreaPanel::setFillStyleAndGradient(const XFillStyleItem* pStyleItem,
const XFillGradientItem& rGradientItem)
{
css::uno::Reference<css::beans::XPropertySet> xPropSet = getPropSet(mxModel);
+ if (!xPropSet.is())
+ return;
+
if (pStyleItem)
xPropSet->setPropertyValue("FillStyle", css::uno::makeAny(pStyleItem->GetValue()));
xPropSet->setPropertyValue("GradientName", css::uno::makeAny(rGradientItem.GetValue()));
@@ -119,6 +130,9 @@ void ChartAreaPanel::setFillStyleAndHatch(const XFillStyleItem* pStyleItem,
const XFillHatchItem& rHatchItem)
{
css::uno::Reference<css::beans::XPropertySet> xPropSet = getPropSet(mxModel);
+ if (!xPropSet.is())
+ return;
+
if (pStyleItem)
xPropSet->setPropertyValue("FillStyle", css::uno::makeAny(pStyleItem->GetValue()));
xPropSet->setPropertyValue("HatchName", css::uno::makeAny(rHatchItem.GetValue()));
@@ -128,6 +142,9 @@ void ChartAreaPanel::setFillStyleAndBitmap(const XFillStyleItem* pStyleItem,
const XFillBitmapItem& rBitmapItem)
{
css::uno::Reference<css::beans::XPropertySet> xPropSet = getPropSet(mxModel);
+ if (!xPropSet.is())
+ return;
+
if (pStyleItem)
xPropSet->setPropertyValue("FillStyle", css::uno::makeAny(pStyleItem->GetValue()));
xPropSet->setPropertyValue("FillBitmapName", css::uno::makeAny(rBitmapItem.GetValue()));
commit 9b679334504dabaeecc60d64f6507cd781b744cf
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Tue Jul 21 19:00:37 2015 +0200
dispose all children
Change-Id: I96501640bc15836476eaa6ff7784ab299277ced9
diff --git a/chart2/source/controller/sidebar/ChartAreaPanel.cxx b/chart2/source/controller/sidebar/ChartAreaPanel.cxx
index 3319bf5..89eb74b 100644
--- a/chart2/source/controller/sidebar/ChartAreaPanel.cxx
+++ b/chart2/source/controller/sidebar/ChartAreaPanel.cxx
@@ -71,6 +71,8 @@ void ChartAreaPanel::dispose()
{
css::uno::Reference<css::util::XModifyBroadcaster> xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW);
xBroadcaster->removeModifyListener(mxListener);
+
+ AreaPropertyPanelBase::dispose();
}
void ChartAreaPanel::Initialize()
commit 3c0868fcfc80355e916ad06c9cca912a7e8143bb
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Tue Jul 21 18:11:08 2015 +0200
extract some code for reuse by chart2 sidebar
Change-Id: I44e2378dafa66f53588027cca56dc52cb4cec794
diff --git a/include/svx/sidebar/AreaPropertyPanelBase.hxx b/include/svx/sidebar/AreaPropertyPanelBase.hxx
index 45bda7d..3f7d574 100644
--- a/include/svx/sidebar/AreaPropertyPanelBase.hxx
+++ b/include/svx/sidebar/AreaPropertyPanelBase.hxx
@@ -97,6 +97,14 @@ public:
virtual void setFillStyleAndHatch(const XFillStyleItem* pStyleItem, const XFillHatchItem& aHatchItem) = 0;
virtual void setFillStyleAndBitmap(const XFillStyleItem* pStyleItem, const XFillBitmapItem& aHatchItem) = 0;
+ void updateFillTransparence(bool bDisabled, bool bDefault, const SfxUInt16Item* pItem);
+ void updateFillFloatTransparence(bool bDisabled, bool bDefault, const XFillFloatTransparenceItem* pItem);
+ void updateFillStyle(bool bDisabled, bool bDefault, const XFillStyleItem* pItem);
+ void updateFillGradient(bool bDisabled, bool bDefault, const XFillGradientItem* pItem);
+ void updateFillHatch(bool bDisabled, bool bDefault, const XFillHatchItem* pItem);
+ void updateFillColor(bool bDefault, const XFillColorItem* pItem);
+ void updateFillBitmap(bool BDisabled, bool bDefault, const XFillBitmapItem* pItem);
+
protected:
sal_uInt16 meLastXFS;
diff --git a/svx/source/sidebar/area/AreaPropertyPanelBase.cxx b/svx/source/sidebar/area/AreaPropertyPanelBase.cxx
index 890abe3..bf48573 100644
--- a/svx/source/sidebar/area/AreaPropertyPanelBase.cxx
+++ b/svx/source/sidebar/area/AreaPropertyPanelBase.cxx
@@ -592,226 +592,248 @@ void AreaPropertyPanelBase::ImpUpdateTransparencies()
}
}
-void AreaPropertyPanelBase::NotifyItemUpdate(
- sal_uInt16 nSID,
- SfxItemState eState,
- const SfxPoolItem* pState,
- const bool /*bIsEnabled*/)
+void AreaPropertyPanelBase::updateFillTransparence(bool bDisabled, bool bDefault, const SfxUInt16Item* pItem)
{
- const bool bDisabled(SfxItemState::DISABLED == eState);
+ if (bDisabled)
+ {
+ mpTransparanceItem.reset();
+ return;
+ }
+ else if(bDefault)
+ {
+ if(pItem && (!mpTransparanceItem || *pItem != *mpTransparanceItem))
+ {
+ mpTransparanceItem.reset(static_cast<SfxUInt16Item*>(pItem->Clone()));
+ }
+ else
+ {
+ mpTransparanceItem.reset();
+ }
+ }
+ else
+ {
+ mpTransparanceItem.reset();
+ }
- switch(nSID)
+ // update transparency settings dependent of mpTransparanceItem and mpFloatTransparenceItem
+ ImpUpdateTransparencies();
+}
+
+void AreaPropertyPanelBase::updateFillFloatTransparence(bool bDisabled, bool bDefault, const XFillFloatTransparenceItem* pItem)
+{
+ if (bDisabled)
{
- case SID_ATTR_FILL_TRANSPARENCE:
- case SID_ATTR_FILL_FLOATTRANSPARENCE:
+ mpFloatTransparenceItem.reset();
+ return;
+ }
+
+ if(bDefault)
+ {
+ if(pItem && (!mpFloatTransparenceItem || *pItem != *mpFloatTransparenceItem))
+ {
+ mpFloatTransparenceItem.reset(static_cast<XFillFloatTransparenceItem*>(pItem->Clone()));
+ }
+ else
{
- bool bFillTransparenceChanged(false);
+ mpFloatTransparenceItem.reset();
+ }
+ }
+ else
+ {
+ mpFloatTransparenceItem.reset();
+ }
- if(SID_ATTR_FILL_TRANSPARENCE == nSID)
- {
- bFillTransparenceChanged = true;
+ // update transparency settings dependent of mpTransparanceItem and mpFloatTransparenceItem
+ ImpUpdateTransparencies();
+}
- if(eState >= SfxItemState::DEFAULT)
- {
- const SfxUInt16Item* pItem = dynamic_cast< const SfxUInt16Item* >(pState);
+void AreaPropertyPanelBase::updateFillStyle(bool bDisabled, bool bDefault, const XFillStyleItem* pItem)
+{
+ if(bDisabled)
+ {
+ mpLbFillType->Disable();
+ mpColorTextFT->Disable();
+ mpLbFillType->SetNoSelection();
+ mpLbFillAttr->Show();
+ mpLbFillAttr->Disable();
+ mpLbFillAttr->SetNoSelection();
+ mpToolBoxColor->Hide();
+ meLastXFS = static_cast<sal_uInt16>(-1);
+ mpStyleItem.reset();
+ }
+ else if(bDefault && pItem)
+ {
+ mpStyleItem.reset(dynamic_cast< XFillStyleItem* >(pItem->Clone()));
+ mpLbFillType->Enable();
+ mpColorTextFT->Enable();
+ drawing::FillStyle eXFS = (drawing::FillStyle)mpStyleItem->GetValue();
+ meLastXFS = eXFS;
+ mpLbFillType->SelectEntryPos(sal::static_int_cast< sal_Int32 >(eXFS));
+
+ if(drawing::FillStyle_NONE == eXFS)
+ {
+ mpLbFillAttr->SetNoSelection();
+ mpLbFillAttr->Disable();
+ }
- if(pItem && (!mpTransparanceItem || *pItem != *mpTransparanceItem))
- {
- mpTransparanceItem.reset(static_cast<SfxUInt16Item*>(pItem->Clone()));
- }
- else
- {
- mpTransparanceItem.reset();
- }
- }
- else
- {
- mpTransparanceItem.reset();
- }
- }
- else // if(SID_ATTR_FILL_FLOATTRANSPARENCE == nSID)
- {
- bFillTransparenceChanged = true;
+ Update();
+ return;
+ }
- if(eState >= SfxItemState::DEFAULT)
- {
- const XFillFloatTransparenceItem* pItem = dynamic_cast< const XFillFloatTransparenceItem* >(pState);
+ mpLbFillType->SetNoSelection();
+ mpLbFillAttr->Show();
+ mpLbFillAttr->Disable();
+ mpLbFillAttr->SetNoSelection();
+ mpToolBoxColor->Hide();
+ meLastXFS = static_cast<sal_uInt16>(-1);
+ mpStyleItem.reset();
+}
- if(pItem && (!mpFloatTransparenceItem || *pItem != *mpFloatTransparenceItem))
- {
- mpFloatTransparenceItem.reset(static_cast<XFillFloatTransparenceItem*>(pItem->Clone()));
- }
- else
- {
- mpFloatTransparenceItem.reset();
- }
- }
- else
- {
- mpFloatTransparenceItem.reset();
- }
- }
+void AreaPropertyPanelBase::updateFillGradient(bool bDisabled, bool bDefault, const XFillGradientItem* pItem)
+{
+ if(bDefault)
+ {
+ mpFillGradientItem.reset(pItem ? static_cast<XFillGradientItem*>(pItem->Clone()) : 0);
+ }
- if(bFillTransparenceChanged)
- {
- // update transparency settings dependent of mpTransparanceItem and mpFloatTransparenceItem
- ImpUpdateTransparencies();
- }
- break;
+ if(mpStyleItem && drawing::FillStyle_GRADIENT == (drawing::FillStyle)mpStyleItem->GetValue())
+ {
+ mpLbFillAttr->Show();
+ mpToolBoxColor->Hide();
+
+ if(bDefault)
+ {
+ mpLbFillAttr->Enable();
+ Update();
}
- case SID_ATTR_FILL_STYLE:
+ else if(bDisabled)
{
- if(bDisabled)
- {
- mpLbFillType->Disable();
- mpColorTextFT->Disable();
- mpLbFillType->SetNoSelection();
- mpLbFillAttr->Show();
- mpLbFillAttr->Disable();
- mpLbFillAttr->SetNoSelection();
- mpToolBoxColor->Hide();
- meLastXFS = static_cast<sal_uInt16>(-1);
- mpStyleItem.reset();
- }
- else if(eState >= SfxItemState::DEFAULT)
- {
- const XFillStyleItem* pItem = dynamic_cast< const XFillStyleItem* >(pState);
+ mpLbFillAttr->Disable();
+ mpLbFillAttr->SetNoSelection();
+ }
+ else
+ {
+ mpLbFillAttr->SetNoSelection();
+ }
+ }
+}
- if(pItem)
- {
- mpStyleItem.reset(dynamic_cast< XFillStyleItem* >(pItem->Clone()));
- mpLbFillType->Enable();
- mpColorTextFT->Enable();
- drawing::FillStyle eXFS = (drawing::FillStyle)mpStyleItem->GetValue();
- meLastXFS = eXFS;
- mpLbFillType->SelectEntryPos(sal::static_int_cast< sal_Int32 >(eXFS));
-
- if(drawing::FillStyle_NONE == eXFS)
- {
- mpLbFillAttr->SetNoSelection();
- mpLbFillAttr->Disable();
- }
+void AreaPropertyPanelBase::updateFillHatch(bool bDisabled, bool bDefault, const XFillHatchItem* pItem)
+{
+ if(bDefault)
+ {
+ mpHatchItem.reset(pItem ? static_cast<XFillHatchItem*>(pItem->Clone()) : 0);
+ }
- Update();
- break;
- }
- }
+ if(mpStyleItem && drawing::FillStyle_HATCH == (drawing::FillStyle)mpStyleItem->GetValue())
+ {
+ mpLbFillAttr->Show();
+ mpToolBoxColor->Hide();
- mpLbFillType->SetNoSelection();
- mpLbFillAttr->Show();
+ if(bDefault)
+ {
+ mpLbFillAttr->Enable();
+ Update();
+ }
+ else if(bDisabled)
+ {
mpLbFillAttr->Disable();
mpLbFillAttr->SetNoSelection();
- mpToolBoxColor->Hide();
- meLastXFS = static_cast<sal_uInt16>(-1);
- mpStyleItem.reset();
- break;
}
- case SID_ATTR_FILL_COLOR:
+ else
{
- if(SfxItemState::DEFAULT == eState)
- {
- mpColorItem.reset(pState ? static_cast<XFillColorItem*>(pState->Clone()) : 0);
- }
+ mpLbFillAttr->SetNoSelection();
+ }
+ }
+}
- if(mpStyleItem && drawing::FillStyle_SOLID == (drawing::FillStyle)mpStyleItem->GetValue())
- {
- mpLbFillAttr->Hide();
- mpToolBoxColor->Show();
+void AreaPropertyPanelBase::updateFillColor(bool bDefault, const XFillColorItem* pItem)
+{
+ if(bDefault)
+ {
+ mpColorItem.reset(pItem ? static_cast<XFillColorItem*>(pItem->Clone()) : 0);
+ }
- Update();
- }
- break;
- }
- case SID_ATTR_FILL_GRADIENT:
- {
- if(SfxItemState::DEFAULT == eState)
- {
- mpFillGradientItem.reset(pState ? static_cast<XFillGradientItem*>(pState->Clone()) : 0);
- }
+ if(mpStyleItem && drawing::FillStyle_SOLID == (drawing::FillStyle)mpStyleItem->GetValue())
+ {
+ mpLbFillAttr->Hide();
+ mpToolBoxColor->Show();
- if(mpStyleItem && drawing::FillStyle_GRADIENT == (drawing::FillStyle)mpStyleItem->GetValue())
- {
- mpLbFillAttr->Show();
- mpToolBoxColor->Hide();
+ Update();
+ }
+}
- if(SfxItemState::DEFAULT == eState)
- {
- mpLbFillAttr->Enable();
- Update();
- }
- else if(SfxItemState::DISABLED == eState )
- {
- mpLbFillAttr->Disable();
- mpLbFillAttr->SetNoSelection();
- }
- else
- {
- mpLbFillAttr->SetNoSelection();
- }
- }
- break;
- }
- case SID_ATTR_FILL_HATCH:
- {
- if(SfxItemState::DEFAULT == eState)
- {
- mpHatchItem.reset(pState ? static_cast<XFillHatchItem*>(pState->Clone()) : 0);
- }
+void AreaPropertyPanelBase::updateFillBitmap(bool bDisabled, bool bDefault, const XFillBitmapItem* pItem)
+{
+ if(bDefault)
+ {
+ mpBitmapItem.reset(pItem ? static_cast<XFillBitmapItem*>(pItem->Clone()) : 0);
+ }
- if(mpStyleItem && drawing::FillStyle_HATCH == (drawing::FillStyle)mpStyleItem->GetValue())
- {
- mpLbFillAttr->Show();
- mpToolBoxColor->Hide();
+ if(mpStyleItem && drawing::FillStyle_BITMAP == (drawing::FillStyle)mpStyleItem->GetValue())
+ {
+ mpLbFillAttr->Show();
+ mpToolBoxColor->Hide();
- if(SfxItemState::DEFAULT == eState)
- {
- mpLbFillAttr->Enable();
- Update();
- }
- else if(SfxItemState::DISABLED == eState )
- {
- mpLbFillAttr->Disable();
- mpLbFillAttr->SetNoSelection();
- }
- else
- {
- mpLbFillAttr->SetNoSelection();
- }
- }
- break;
+ if(bDefault)
+ {
+ mpLbFillAttr->Enable();
+ Update();
}
- case SID_ATTR_FILL_BITMAP:
+ else if(bDisabled)
{
- if(SfxItemState::DEFAULT == eState)
- {
- mpBitmapItem.reset(pState ? static_cast<XFillBitmapItem*>(pState->Clone()) : 0);
- }
+ mpLbFillAttr->Disable();
+ mpLbFillAttr->SetNoSelection();
+ }
+ else
+ {
+ mpLbFillAttr->SetNoSelection();
+ }
+ }
+}
- if(mpStyleItem && drawing::FillStyle_BITMAP == (drawing::FillStyle)mpStyleItem->GetValue())
- {
- mpLbFillAttr->Show();
- mpToolBoxColor->Hide();
+void AreaPropertyPanelBase::NotifyItemUpdate(
+ sal_uInt16 nSID,
+ SfxItemState eState,
+ const SfxPoolItem* pState,
+ const bool /*bIsEnabled*/)
+{
+ const bool bDisabled(SfxItemState::DISABLED == eState);
+ const bool bDefault(SfxItemState::DEFAULT == eState);
- if(SfxItemState::DEFAULT == eState)
- {
- mpLbFillAttr->Enable();
- Update();
- }
- else if(SfxItemState::DISABLED == eState )
- {
- mpLbFillAttr->Disable();
- mpLbFillAttr->SetNoSelection();
- }
- else
- {
- mpLbFillAttr->SetNoSelection();
- }
- }
- break;
- }
+ switch(nSID)
+ {
+ case SID_ATTR_FILL_TRANSPARENCE:
+ updateFillTransparence(bDisabled, bDefault,
+ static_cast<const SfxUInt16Item*>(pState));
+ break;
+ case SID_ATTR_FILL_FLOATTRANSPARENCE:
+ updateFillFloatTransparence(bDisabled, bDefault,
+ static_cast<const XFillFloatTransparenceItem*>(pState));
+ break;
+ case SID_ATTR_FILL_STYLE:
+ updateFillStyle(bDisabled, bDefault,
+ static_cast<const XFillStyleItem*>(pState));
+ break;
+ case SID_ATTR_FILL_COLOR:
+ updateFillColor(bDefault,
+ static_cast<const XFillColorItem*>(pState));
+ break;
+ case SID_ATTR_FILL_GRADIENT:
+ updateFillGradient(bDisabled, bDefault,
+ static_cast<const XFillGradientItem*>(pState));
+ break;
+ case SID_ATTR_FILL_HATCH:
+ updateFillHatch(bDisabled, bDefault,
+ static_cast<const XFillHatchItem*>(pState));
+ break;
+ case SID_ATTR_FILL_BITMAP:
+ updateFillBitmap(bDisabled, bDefault,
+ static_cast<const XFillBitmapItem*>(pState));
+ break;
case SID_GRADIENT_LIST:
{
- if(SfxItemState::DEFAULT == eState)
+ if(bDefault)
{
if(mpStyleItem && drawing::FillStyle_GRADIENT == (drawing::FillStyle)mpStyleItem->GetValue())
{
@@ -836,7 +858,7 @@ void AreaPropertyPanelBase::NotifyItemUpdate(
}
case SID_HATCH_LIST:
{
- if(SfxItemState::DEFAULT == eState)
+ if(bDefault)
{
if(mpStyleItem && drawing::FillStyle_HATCH == (drawing::FillStyle)mpStyleItem->GetValue())
{
@@ -861,7 +883,7 @@ void AreaPropertyPanelBase::NotifyItemUpdate(
}
case SID_BITMAP_LIST:
{
- if(SfxItemState::DEFAULT == eState)
+ if(bDefault)
{
if(mpStyleItem && drawing::FillStyle_BITMAP == (drawing::FillStyle)mpStyleItem->GetValue())
{
More information about the Libreoffice-commits
mailing list