Unregister sidebar ControllerItems at the right time.

Otherwise they linger post-dispose, wreaking havoc.

Change-Id: I6d0981ee15e82111bc825c75d28b703e5a5d266b
diff --git a/include/sfx2/ctrlitem.hxx b/include/sfx2/ctrlitem.hxx
index aa38dc0..24f64d9 100644
--- a/include/sfx2/ctrlitem.hxx
+++ b/include/sfx2/ctrlitem.hxx
@@ -56,6 +56,7 @@ public:
                        SfxControllerItem(); // for arrays
                        SfxControllerItem( sal_uInt16 nId, SfxBindings & );
    virtual             ~SfxControllerItem();
    virtual void        dispose();

    void                Bind( sal_uInt16 nNewId, SfxBindings * = 0);    // Register in SfxBindings
    void                UnBind();
diff --git a/include/sfx2/sidebar/ControllerItem.hxx b/include/sfx2/sidebar/ControllerItem.hxx
index f06ae5e..025106e 100644
--- a/include/sfx2/sidebar/ControllerItem.hxx
+++ b/include/sfx2/sidebar/ControllerItem.hxx
@@ -80,6 +80,9 @@ public:
        SfxBindings &rBindings,
        ItemUpdateReceiverInterface& rItemUpdateReceiver);

    /// releases our action listener
    virtual void dispose() SAL_OVERRIDE;

    virtual ~ControllerItem();

    /** Returns </TRUE> when the slot/command has not been disabled.
diff --git a/sc/source/ui/sidebar/AlignmentPropertyPanel.cxx b/sc/source/ui/sidebar/AlignmentPropertyPanel.cxx
index 75d054c..c9d7d4af 100644
--- a/sc/source/ui/sidebar/AlignmentPropertyPanel.cxx
+++ b/sc/source/ui/sidebar/AlignmentPropertyPanel.cxx
@@ -81,6 +81,14 @@ void AlignmentPropertyPanel::dispose()
    mpCtrlDial.clear();
    mpMtrAngle.clear();
    mpCbStacked.clear();

    maAlignHorControl.dispose();
    maLeftIndentControl.dispose();
    maMergeCellControl.dispose();
    maWrapTextControl.dispose();
    maAngleControl.dispose();
    maStackControl.dispose();

    PanelLayout::dispose();
}

diff --git a/sc/source/ui/sidebar/CellAppearancePropertyPanel.cxx b/sc/source/ui/sidebar/CellAppearancePropertyPanel.cxx
index 4410c79..5dae73b 100644
--- a/sc/source/ui/sidebar/CellAppearancePropertyPanel.cxx
+++ b/sc/source/ui/sidebar/CellAppearancePropertyPanel.cxx
@@ -151,6 +151,14 @@ void CellAppearancePropertyPanel::dispose()
    mpTBLineStyle.clear();
    mpTBLineColor.clear();
    mpCBXShowGrid.clear();

    maLineStyleControl.dispose();
    maBorderOuterControl.dispose();
    maBorderInnerControl.dispose();
    maGridShowControl.dispose();
    maBorderTLBRControl.dispose();
    maBorderBLTRControl.dispose();

    PanelLayout::dispose();
}

diff --git a/sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx b/sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx
index 6efc79d..035b65b 100644
--- a/sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx
+++ b/sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx
@@ -81,6 +81,10 @@ void NumberFormatPropertyPanel::dispose()
    mpEdLeadZeroes.clear();
    mpBtnNegRed.clear();
    mpBtnThousand.clear();

    maNumFormatControl.dispose();
    maFormatControl.dispose();

    PanelLayout::dispose();
}

diff --git a/sfx2/source/control/ctrlitem.cxx b/sfx2/source/control/ctrlitem.cxx
index c1fa162..0be5e36 100644
--- a/sfx2/source/control/ctrlitem.cxx
+++ b/sfx2/source/control/ctrlitem.cxx
@@ -218,16 +218,19 @@ SfxControllerItem::SfxControllerItem( sal_uInt16 nID, SfxBindings &rBindings ):
}


// unregisteres the item in the bindings
// unregisters the item in the bindings

SfxControllerItem::~SfxControllerItem()
{
    dispose();
}

void SfxControllerItem::dispose()
{
    if ( IsBound() )
        pBindings->Release(*this);
}



void SfxControllerItem::StateChanged
(
    sal_uInt16,          // <SID> of the triggering slot
diff --git a/sfx2/source/sidebar/ControllerItem.cxx b/sfx2/source/sidebar/ControllerItem.cxx
index db7f155..b91c383 100644
--- a/sfx2/source/sidebar/ControllerItem.cxx
+++ b/sfx2/source/sidebar/ControllerItem.cxx
@@ -117,8 +117,16 @@ ControllerItem::ControllerItem (

ControllerItem::~ControllerItem (void)
{
    dispose();
}

void ControllerItem::dispose()
{
    if (mxFrameActionListener.is())
        mxFrameActionListener->dispose();
    mxFrameActionListener.clear();

    SfxControllerItem::dispose();
}

void ControllerItem::StateChanged (
diff --git a/svx/source/sidebar/area/AreaPropertyPanel.cxx b/svx/source/sidebar/area/AreaPropertyPanel.cxx
index bc731f9..2232e5f2 100644
--- a/svx/source/sidebar/area/AreaPropertyPanel.cxx
+++ b/svx/source/sidebar/area/AreaPropertyPanel.cxx
@@ -128,6 +128,18 @@ void AreaPropertyPanel::dispose()
    mpLBTransType.clear();
    mpMTRTransparent.clear();
    mpBTNGradient.clear();

    maStyleControl.dispose();
    maColorControl.dispose();
    maGradientControl.dispose();
    maHatchControl.dispose();
    maBitmapControl.dispose();
    maGradientListControl.dispose();
    maHatchListControl.dispose();
    maBitmapListControl.dispose();
    maFillTransparenceController.dispose();
    maFillFloatTransparenceController.dispose();

    PanelLayout::dispose();
}

diff --git a/svx/source/sidebar/graphic/GraphicPropertyPanel.cxx b/svx/source/sidebar/graphic/GraphicPropertyPanel.cxx
index 933b5f3..d048416 100644
--- a/svx/source/sidebar/graphic/GraphicPropertyPanel.cxx
+++ b/svx/source/sidebar/graphic/GraphicPropertyPanel.cxx
@@ -81,6 +81,16 @@ void GraphicPropertyPanel::dispose()
    mpMtrGreen.clear();
    mpMtrBlue.clear();
    mpMtrGamma.clear();

    maBrightControl.dispose();
    maContrastControl.dispose();
    maTransparenceControl.dispose();
    maRedControl.dispose();
    maGreenControl.dispose();
    maBlueControl.dispose();
    maGammaControl.dispose();
    maModeControl.dispose();

    PanelLayout::dispose();
}

diff --git a/svx/source/sidebar/line/LinePropertyPanel.cxx b/svx/source/sidebar/line/LinePropertyPanel.cxx
index 12b0f33..f05c92a 100644
--- a/svx/source/sidebar/line/LinePropertyPanel.cxx
+++ b/svx/source/sidebar/line/LinePropertyPanel.cxx
@@ -212,6 +212,18 @@ void LinePropertyPanel::dispose()
    mpLBEdgeStyle.clear();
    mpFTCapStyle.clear();
    mpLBCapStyle.clear();

    maStyleControl.dispose();
    maDashControl.dispose();
    maWidthControl.dispose();
    maStartControl.dispose();
    maEndControl.dispose();
    maLineEndListControl.dispose();
    maLineStyleListControl.dispose();
    maTransControl.dispose();
    maEdgeStyle.dispose();
    maCapStyle.dispose();

    PanelLayout::dispose();
}

diff --git a/svx/source/sidebar/paragraph/ParaPropertyPanel.cxx b/svx/source/sidebar/paragraph/ParaPropertyPanel.cxx
index 8ba3f99..7dfb3f6 100644
--- a/svx/source/sidebar/paragraph/ParaPropertyPanel.cxx
+++ b/svx/source/sidebar/paragraph/ParaPropertyPanel.cxx
@@ -765,6 +765,15 @@ void ParaPropertyPanel::dispose()
    mpLeftIndent.clear();
    mpRightIndent.clear();
    mpFLineIndent.clear();

    maLRSpaceControl.dispose();
    maULSpaceControl.dispose();
    maOutLineLeftControl.dispose();
    maOutLineRightControl.dispose();
    maDecIndentControl.dispose();
    maIncIndentControl.dispose();
    m_aMetricCtl.dispose();

    PanelLayout::dispose();
}

diff --git a/svx/source/sidebar/possize/PosSizePropertyPanel.cxx b/svx/source/sidebar/possize/PosSizePropertyPanel.cxx
index b352332..c9684c6 100644
--- a/svx/source/sidebar/possize/PosSizePropertyPanel.cxx
+++ b/svx/source/sidebar/possize/PosSizePropertyPanel.cxx
@@ -136,6 +136,21 @@ void PosSizePropertyPanel::dispose()
    mpDial.clear();
    mpFtFlip.clear();
    mpFlipTbx.clear();

    maTransfPosXControl.dispose();
    maTransfPosYControl.dispose();
    maTransfWidthControl.dispose();
    maTransfHeightControl.dispose();

    maSvxAngleControl.dispose();
    maRotXControl.dispose();
    maRotYControl.dispose();
    maProPosControl.dispose();
    maProSizeControl.dispose();
    maAutoWidthControl.dispose();
    maAutoHeightControl.dispose();
    m_aMetricCtl.dispose();

    PanelLayout::dispose();
}

diff --git a/svx/source/sidebar/text/TextPropertyPanel.cxx b/svx/source/sidebar/text/TextPropertyPanel.cxx
index 57ebb7d..af7c2b6 100644
--- a/svx/source/sidebar/text/TextPropertyPanel.cxx
+++ b/svx/source/sidebar/text/TextPropertyPanel.cxx
@@ -128,6 +128,11 @@ void TextPropertyPanel::dispose()
    mpToolBoxSpacing.clear();
    mpToolBoxFontColorSw.clear();
    mpToolBoxFontColor.clear();

    maFontSizeControl.dispose();
    maUnderlineControl.dispose();
    maSpacingControl.dispose();

    PanelLayout::dispose();
}

diff --git a/sw/source/uibase/sidebar/PagePropertyPanel.cxx b/sw/source/uibase/sidebar/PagePropertyPanel.cxx
index 53fd3af..d35ac67 100644
--- a/sw/source/uibase/sidebar/PagePropertyPanel.cxx
+++ b/sw/source/uibase/sidebar/PagePropertyPanel.cxx
@@ -221,6 +221,14 @@ void PagePropertyPanel::dispose()
    mpToolBoxMargin.clear();
    mpToolBoxSize.clear();
    mpToolBoxColumn.clear();

    m_aSwPagePgULControl.dispose();
    m_aSwPagePgLRControl.dispose();
    m_aSwPagePgSizeControl.dispose();
    m_aSwPagePgControl.dispose();
    m_aSwPageColControl.dispose();
    m_aSwPagePgMetricControl.dispose();

    PanelLayout::dispose();
}

@@ -482,6 +490,9 @@ void PagePropertyPanel::NotifyItemUpdate(
{
    (void)bIsEnabled;

    if (IsDisposed())
        return;

    switch( nSId )
    {
    case SID_ATTR_PAGE_COLUMN:
diff --git a/sw/source/uibase/sidebar/WrapPropertyPanel.cxx b/sw/source/uibase/sidebar/WrapPropertyPanel.cxx
index 39f68c3..a388d42 100644
--- a/sw/source/uibase/sidebar/WrapPropertyPanel.cxx
+++ b/sw/source/uibase/sidebar/WrapPropertyPanel.cxx
@@ -102,6 +102,14 @@ void WrapPropertyPanel::dispose()
    mpRBWrapParallel.clear();
    mpRBWrapThrough.clear();
    mpRBIdealWrap.clear();

    maSwNoWrapControl.dispose();
    maSwWrapLeftControl.dispose();
    maSwWrapRightControl.dispose();
    maSwWrapParallelControl.dispose();
    maSwWrapThroughControl.dispose();
    maSwWrapIdealControl.dispose();

    PanelLayout::dispose();
}