[Libreoffice-commits] core.git: cui/source cui/uiconfig

Rishabh Kumar kris.kr296 at gmail.com
Wed Oct 12 08:39:44 UTC 2016


 cui/source/dialogs/sdrcelldlg.cxx |    4 
 cui/source/inc/cuitabarea.hxx     |  181 +++----
 cui/source/tabpages/tabarea.cxx   |   34 -
 cui/source/tabpages/tparea.cxx    |  971 +++++++++-----------------------------
 cui/source/tabpages/tpbitmap.cxx  |  148 ++---
 cui/source/tabpages/tpcolor.cxx   |  108 ++--
 cui/source/tabpages/tpgradnt.cxx  |  222 +++++---
 cui/source/tabpages/tphatch.cxx   |  161 ++----
 cui/source/tabpages/tppattern.cxx |  205 +++-----
 cui/uiconfig/ui/areatabpage.ui    |  283 +++--------
 10 files changed, 873 insertions(+), 1444 deletions(-)

New commits:
commit 686349476e03f951f4a9ff9755b9f71951b64ea5
Author: Rishabh Kumar <kris.kr296 at gmail.com>
Date:   Mon Aug 22 16:48:05 2016 +0530

    [GSoC] Move all fill style tabs inside area tab
    
    Change-Id: I89e84b7b3c7075ad4107e7bc444ea5c07bc90795
    Reviewed-on: https://gerrit.libreoffice.org/27866
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Katarina Behrens <Katarina.Behrens at cib.de>

diff --git a/cui/source/dialogs/sdrcelldlg.cxx b/cui/source/dialogs/sdrcelldlg.cxx
index 3fd53db..d6e9244 100644
--- a/cui/source/dialogs/sdrcelldlg.cxx
+++ b/cui/source/dialogs/sdrcelldlg.cxx
@@ -51,10 +51,6 @@ void SvxFormatCellsDialog::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
         rAreaPage.SetGradientList( mpGradientList );
         rAreaPage.SetHatchingList( mpHatchingList );
         rAreaPage.SetBitmapList( mpBitmapList );
-        rAreaPage.SetPageType( PageType::Area );
-        rAreaPage.SetDlgType( 1 );
-        rAreaPage.SetPos( 0 );
-        rAreaPage.Construct();
         rAreaPage.ActivatePage( mrOutAttrs );
     }
     else if (nId == m_nBorderPageId)
diff --git a/cui/source/inc/cuitabarea.hxx b/cui/source/inc/cuitabarea.hxx
index 0c103cc..7f1decb 100644
--- a/cui/source/inc/cuitabarea.hxx
+++ b/cui/source/inc/cuitabarea.hxx
@@ -35,9 +35,60 @@
 #include <svx/PaletteManager.hxx>
 #include <svx/svdview.hxx>
 
+#define NO_BUTTON_SELECTED -1
+
 class SdrModel;
 class SvxBitmapCtl;
 
+/************************************************************************/
+class ButtonBox
+{
+    private:
+        sal_Int32 mnCurrentButton;
+        std::vector< VclPtr<PushButton> > maButtonList;
+        std::map< VclPtr<PushButton>, sal_Int32 > maButtonToPos;
+        void SelectButtonImpl( sal_Int32 nPos )
+        {
+            if(mnCurrentButton != NO_BUTTON_SELECTED)
+            {
+                maButtonList[mnCurrentButton]->SetPressed(false);
+            }
+            mnCurrentButton = nPos;
+            maButtonList[mnCurrentButton]->SetPressed(true);
+        };
+    public:
+        ButtonBox()
+        {
+            mnCurrentButton = NO_BUTTON_SELECTED;
+        };
+        ~ButtonBox() {};
+        void AddButton(VclPtr<PushButton> pButton)
+        {
+            maButtonList.push_back(pButton);
+            maButtonToPos.insert( std::make_pair(pButton, maButtonList.size() - 1) );
+        }
+        sal_Int32 GetCurrentButtonPos() { return mnCurrentButton; }
+        sal_Int32 GetButtonPos( VclPtr<PushButton> pButton )
+        {
+            std::map< VclPtr<PushButton>, sal_Int32 >::const_iterator aBtnPos = maButtonToPos.find(pButton);
+            if(aBtnPos != maButtonToPos.end())
+                return aBtnPos->second;
+            else
+                return -1;
+        }
+        void SelectButton( VclPtr<PushButton> pButton)
+        {
+            sal_Int32 nPos = GetButtonPos(pButton);
+            if(nPos != -1)
+                SelectButtonImpl(nPos);
+        }
+        void clear()
+        {
+            mnCurrentButton = NO_BUTTON_SELECTED;
+            maButtonList.clear();
+        };
+};
+
 enum class PageType
 {
     Area,
@@ -47,12 +98,9 @@ enum class PageType
     Color,
     Shadow,
     Transparence,
-    Unknown = 0xFFFF
+    Unknown = 0xFFF
 };
 
-
-/************************************************************************/
-
 class SvxAreaTabDialog : public SfxTabDialog
 {
     sal_uInt16            m_nAreaTabPage;
@@ -86,9 +134,7 @@ private:
     ChangeType          mnGradientListState;
     ChangeType          mnHatchingListState;
 
-    PageType            mnPageType;
     sal_Int32           mnPos;
-    bool                mbAreaTP;
 
     virtual void        PageCreated( sal_uInt16 nId, SfxTabPage &rPage ) override;
 
@@ -199,74 +245,57 @@ class SvxAreaTabPage : public SvxTabPage
     using TabPage::DeactivatePage;
     static const sal_uInt16 pAreaRanges[];
 private:
-    VclPtr<ListBox>            m_pTypeLB;
-
-    VclPtr<VclBox>             m_pFillLB;
-    VclPtr<ColorLB>            m_pLbColor;
-    VclPtr<GradientLB>         m_pLbGradient;
-    VclPtr<HatchingLB>         m_pLbHatching;
-    VclPtr<BitmapLB>           m_pLbBitmap;
-    VclPtr<SvxXRectPreview>    m_pCtlBitmapPreview;
-    VclPtr<SvxXRectPreview>    m_pCtlXRectPreview;
-
-    const SfxItemSet&   m_rOutAttrs;
+    ScopedVclPtr<SfxTabPage>   m_pFillTabPage;
+    VclPtr<VclBox>             m_pFillTab;
+    VclPtr<PushButton>         m_pBtnNone;
+    VclPtr<PushButton>         m_pBtnColor;
+    VclPtr<PushButton>         m_pBtnGradient;
+    VclPtr<PushButton>         m_pBtnHatch;
+    VclPtr<PushButton>         m_pBtnBitmap;
+    VclPtr<PushButton>         m_pBtnPattern;
+    ButtonBox                  maBox;
 
+    SdrModel*           mpDrawModel;
     XColorListRef         m_pColorList;
     XGradientListRef      m_pGradientList;
     XHatchListRef         m_pHatchingList;
     XBitmapListRef        m_pBitmapList;
+    XPatternListRef       m_pPatternList;
 
     // Placeholders for pointer-based entries; these will be inited
     // to point to these so that the page is usable without that
     // SvxAreaTabDialog has to call the setter methods (e.g. SetColorChgd).
     // Without that the pages used in SvxAreaTabDialog are not usable
     ChangeType          maFixed_ChangeType;
-    bool                maFixed_sal_Bool;
 
     ChangeType*         m_pnColorListState;
     ChangeType*         m_pnBitmapListState;
+    ChangeType*         m_pnPatternListState;
     ChangeType*         m_pnGradientListState;
     ChangeType*         m_pnHatchingListState;
 
-    PageType   m_nPageType;
-    sal_uInt16 m_nDlgType;
-    sal_Int32  m_nPos;
-
-    bool*               m_pbAreaTP;
-
+    sal_Int32           m_nPos;
     XFillAttrSetItem    m_aXFillAttr;
     SfxItemSet&         m_rXFSet;
 
-    MapUnit             m_ePoolUnit;
-
-    DECL_LINK(SelectDialogTypeHdl_Impl, ListBox&, void);
-    DECL_LINK( ModifyColorHdl_Impl, ListBox&, void );
-    DECL_LINK( ModifyGradientHdl_Impl, ListBox&, void );
-    DECL_LINK( ModifyHatchingHdl_Impl, ListBox&, void );
-    DECL_LINK( ModifyBitmapHdl_Impl, ListBox&, void );
-
-    DECL_LINK( ModifyTileHdl_Impl, Edit&, void );
-    DECL_LINK( ModifyTileClickHdl_Impl, Button*, void );
-    DECL_LINK( ClickScaleHdl_Impl, Button*, void );
-    void ClickInvisibleHdl_Impl();
-    void ClickHatchingHdl_Impl();
-    void ClickGradientHdl_Impl();
-    void ClickColorHdl_Impl();
-    void ClickBitmapHdl_Impl();
+    DECL_LINK(SelectFillTypeHdl_Impl, Button*, void);
 
+    template< typename TabPage >
+    bool FillItemSet_Impl( SfxItemSet* );
+    template< typename TabPage >
+    void Reset_Impl( const SfxItemSet* );
+    template< typename TabPage >
+    DeactivateRC DeactivatePage_Impl( SfxItemSet* pSet );
 public:
     SvxAreaTabPage( vcl::Window* pParent, const SfxItemSet& rInAttrs );
     virtual ~SvxAreaTabPage() override;
     virtual void dispose() override;
 
-    void    Construct();
-
     static VclPtr<SfxTabPage> Create( vcl::Window*, const SfxItemSet* );
     static const sal_uInt16* GetRanges() { return pAreaRanges; }
 
     virtual bool FillItemSet( SfxItemSet* ) override;
     virtual void Reset( const SfxItemSet * ) override;
-    virtual void ChangesApplied() override;
     virtual void ActivatePage( const SfxItemSet& rSet ) override;
     virtual DeactivateRC DeactivatePage( SfxItemSet* pSet ) override;
     virtual void PointChanged( vcl::Window* pWindow, RectPoint eRP ) override;
@@ -277,12 +306,11 @@ public:
     void    SetHatchingList( XHatchListRef const & pHtchLst)
                 { m_pHatchingList = pHtchLst; }
     void    SetBitmapList( XBitmapListRef const & pBmpLst) { m_pBitmapList = pBmpLst; }
+    void    SetPatternList( XPatternListRef const &pPtrnLst ) { m_pPatternList = pPtrnLst; }
+    void    SetDrawModel( SdrModel* pModel ) { mpDrawModel = pModel; }
 
-    void    SetPageType( PageType nInType ) { m_nPageType = nInType; }
-    void    SetDlgType( sal_uInt16 nInType ) { m_nDlgType = nInType; }
-    void    SetPos( sal_uInt16 nInPos ) { m_nPos = nInPos; }
-    void    SetAreaTP( bool* pIn ) { m_pbAreaTP = pIn; }
     virtual void PageCreated(const SfxAllItemSet& aSet) override;
+    void    CreatePage(sal_Int32 nId, SfxTabPage& pTab);
     void    SetColorChgd( ChangeType* pIn ) { m_pnColorListState = pIn; }
     void    SetGrdChgd( ChangeType* pIn ) { m_pnGradientListState = pIn; }
     void    SetHtchChgd( ChangeType* pIn ) { m_pnHatchingListState = pIn; }
@@ -379,10 +407,7 @@ private:
 
     ChangeType*         m_pnGradientListState;
     ChangeType*         m_pnColorListState;
-    PageType*           m_pPageType;
-    sal_uInt16          m_nDlgType;
     sal_Int32*          m_pPos;
-    bool*               m_pbAreaTP;
 
     XFillStyleItem      m_aXFStyleItem;
     XFillGradientItem   m_aXGradientItem;
@@ -400,6 +425,7 @@ private:
     DECL_LINK( ChangeAutoStepHdl_Impl, CheckBox&, void );
     DECL_LINK( ModifiedSliderHdl_Impl, Slider*, void );
     void ModifiedHdl_Impl(void*);
+    long CheckChanges_Impl();
 
     void SetControlState_Impl( css::awt::GradientStyle eXGS );
     sal_Int32 SearchGradientList(const OUString& rGradientName);
@@ -421,12 +447,7 @@ public:
     void    SetColorList( XColorListRef const & pColorList ) { m_pColorList = pColorList; }
     void    SetGradientList( XGradientListRef const & pGrdLst)
                 { m_pGradientList = pGrdLst; }
-
-    void    SetPageType( PageType* pInType ) { m_pPageType = pInType; }
-    void    SetDlgType( sal_uInt16 nInType ) { m_nDlgType = nInType; }
-    void    SetPos( sal_Int32* pInPos ) { m_pPos = pInPos; }
-    void    SetAreaTP( bool* pIn ) { m_pbAreaTP = pIn; }
-
+    void    SetPos( sal_Int32* pPos ) { m_pPos = pPos; }
     void    SetGrdChgd( ChangeType* pIn ) { m_pnGradientListState = pIn; }
     void    SetColorChgd( ChangeType* pIn ) { m_pnColorListState = pIn; }
 };
@@ -458,10 +479,7 @@ private:
 
     ChangeType*         m_pnHatchingListState;
     ChangeType*         m_pnColorListState;
-    PageType*           m_pPageType;
-    sal_uInt16          m_nDlgType;
     sal_Int32*          m_pPos;
-    bool*               m_pbAreaTP;
 
     XFillStyleItem      m_aXFStyleItem;
     XFillHatchItem      m_aXHatchItem;
@@ -505,11 +523,7 @@ public:
     void    SetHatchingList( XHatchListRef const & pHtchLst)
                 { m_pHatchingList = pHtchLst; }
 
-    void    SetPageType( PageType* pInType ) { m_pPageType = pInType; }
-    void    SetDlgType( sal_uInt16 nInType ) { m_nDlgType = nInType; }
-    void    SetPos( sal_Int32* pInPos ) { m_pPos = pInPos; }
-    void    SetAreaTP( bool* pIn ) { m_pbAreaTP = pIn; }
-
+    void    SetPos( sal_Int32* pPos ) { m_pPos = pPos; }
     void    SetHtchChgd( ChangeType* pIn ) { m_pnHatchingListState = pIn; }
     void    SetColorChgd( ChangeType* pIn ) { m_pnColorListState = pIn; }
 
@@ -551,16 +565,13 @@ private:
 
     double                     m_fObjectWidth;
     double                     m_fObjectHeight;
-    PageType*                  m_nPageType;
-    sal_uInt16                 m_nDlgType;
-    sal_Int32*                 m_nPos;
-
-    bool*                      m_pbAreaTP;
+    sal_Int32*                 m_pPos;
 
     XFillAttrSetItem           m_aXFillAttr;
     SfxItemSet&                m_rXFSet;
     const SdrView*             mpView;
     MapUnit                    mePoolUnit;
+    FieldUnit                  meDlgUnit;
     Size                       rBitmapSize;
     Size                       rFilledSize;
     Size                       rZoomedSize;
@@ -599,11 +610,7 @@ public:
     virtual void PointChanged( vcl::Window* pWindow, RectPoint eRP ) override;
 
     void    SetBitmapList( const XBitmapListRef& pBmpLst) { m_pBitmapList = pBmpLst; }
-
-    void    SetPageType( PageType* pInType ) { m_nPageType = pInType; }
-    void    SetDlgType( sal_uInt16 nInType ) { m_nDlgType = nInType; }
-    void    SetPos( sal_Int32* pInPos ) { m_nPos = pInPos; }
-    void    SetAreaTP( bool* pIn ) { m_pbAreaTP = pIn; }
+    void    SetPos( sal_Int32* pPos ) { m_pPos = pPos; }
     void    SetBmpChgd( ChangeType* pIn ) { m_pnBitmapListState = pIn; }
 };
 
@@ -634,10 +641,7 @@ private:
 
     ChangeType*         m_pnPatternListState;
     ChangeType*         m_pnColorListState;
-    PageType*           m_pPageType;
-    sal_uInt16          m_nDlgType;
     sal_Int32*          m_pPos;
-    bool*               m_pbAreaTP;
 
     bool                m_bPtrnChanged;
 
@@ -653,6 +657,9 @@ private:
     DECL_LINK( ClickRenameHdl_Impl, SvxPresetListBox*, void );
     DECL_LINK( ClickDeleteHdl_Impl, SvxPresetListBox*, void );
 
+    long CheckChanges_Impl();
+    sal_Int32 SearchPatternList(const OUString& rPatternName);
+
 public:
     SvxPatternTabPage( vcl::Window* pParent, const SfxItemSet& rInAttrs  );
     virtual ~SvxPatternTabPage() override;
@@ -671,12 +678,7 @@ public:
 
     void    SetColorList( XColorListRef const & pColorList ) { m_pColorList = pColorList; }
     void    SetPatternList( XPatternListRef const & pPatternList) { m_pPatternList = pPatternList; }
-
-    void    SetPageType( PageType* pInType ) { m_pPageType = pInType; }
-    void    SetDlgType( sal_uInt16 nInType ) { m_nDlgType = nInType; }
-    void    SetPos( sal_Int32* pInPos ) { m_pPos = pInPos; }
-    void    SetAreaTP( bool* pIn ) { m_pbAreaTP = pIn; }
-
+    void    SetPos( sal_Int32* pPos ) { m_pPos = pPos; }
     void    SetPtrnChgd( ChangeType* pIn ) { m_pnPatternListState = pIn; }
     void    SetColorChgd( ChangeType* pIn ) { m_pnColorListState = pIn; }
     void    ChangeColor_Impl();
@@ -687,7 +689,7 @@ public:
 enum class ColorModel
 {
     RGB,
-    CMYK // can be extend with more models, e.g. HSV
+    CMYK
 };
 
 class SvxColorTabPage : public SfxTabPage
@@ -742,10 +744,7 @@ private:
     XColorListRef         pColorList;
 
     ChangeType*         pnColorListState;
-    PageType*           pPageType;
-    sal_uInt16          nDlgType;
     sal_Int32*          pPos;
-    bool*               pbAreaTP;
 
     XFillStyleItem      aXFStyleItem;
     XFillColorItem      aXFillColorItem;
@@ -797,13 +796,11 @@ public:
     virtual DeactivateRC DeactivatePage( SfxItemSet* pSet ) override;
 
     void             SetPropertyList( XPropertyListType t, const XPropertyListRef &xRef );
-
+    void    SetPos( sal_Int32* pInPos ) { pPos = pInPos; }
     void    SetColorList( const XColorListRef& pColList );
+    void    SaveToViewFrame( SfxViewFrame *pViewFrame );
+    void    SetupForViewFrame( SfxViewFrame *pViewFrame );
 
-    void    SetPageType( PageType* pInType ) { pPageType = pInType; }
-    void    SetDlgType( sal_uInt16 nInType ) { nDlgType = nInType; }
-    void    SetPos( sal_Int32* pInPos ) { pPos = pInPos; }
-    void    SetAreaTP( bool* pIn ) { pbAreaTP = pIn; }
 
     void    SetColorChgd( ChangeType* pIn ) { pnColorListState = pIn; }
 
diff --git a/cui/source/tabpages/tabarea.cxx b/cui/source/tabpages/tabarea.cxx
index 787fa76..06acf58 100644
--- a/cui/source/tabpages/tabarea.cxx
+++ b/cui/source/tabpages/tabarea.cxx
@@ -73,9 +73,7 @@ SvxAreaTabDialog::SvxAreaTabDialog
     mnPatternListState ( ChangeType::NONE ),
     mnGradientListState ( ChangeType::NONE ),
     mnHatchingListState ( ChangeType::NONE ),
-    mnPageType( PageType::Area ),
-    mnPos( 0 ),
-    mbAreaTP( false )
+    mnPos( 0 )
 {
     m_nAreaTabPage = AddTabPage( "RID_SVXPAGE_AREA", SvxAreaTabPage::Create, nullptr );
 
@@ -262,24 +260,18 @@ void SvxAreaTabDialog::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
             static_cast<SvxAreaTabPage&>(rPage).SetGradientList( mpGradientList );
             static_cast<SvxAreaTabPage&>(rPage).SetHatchingList( mpHatchingList );
             static_cast<SvxAreaTabPage&>(rPage).SetBitmapList( mpBitmapList );
-            static_cast<SvxAreaTabPage&>(rPage).SetPageType( mnPageType );
-            static_cast<SvxAreaTabPage&>(rPage).SetDlgType( 0 );
-            static_cast<SvxAreaTabPage&>(rPage).SetPos( mnPos );
-            static_cast<SvxAreaTabPage&>(rPage).SetAreaTP( &mbAreaTP );
+            static_cast<SvxAreaTabPage&>(rPage).SetPatternList( mpPatternList );
+            static_cast<SvxAreaTabPage&>(rPage).SetDrawModel( mpDrawModel );
             static_cast<SvxAreaTabPage&>(rPage).SetGrdChgd( &mnGradientListState );
             static_cast<SvxAreaTabPage&>(rPage).SetHtchChgd( &mnHatchingListState );
             static_cast<SvxAreaTabPage&>(rPage).SetBmpChgd( &mnBitmapListState );
             static_cast<SvxAreaTabPage&>(rPage).SetColorChgd( &mnColorListState );
-            static_cast<SvxAreaTabPage&>(rPage).Construct();
             // ActivatePge() is not called the first time
             static_cast<SvxAreaTabPage&>(rPage).ActivatePage( mrOutAttrs );
     }
     else if (nId == m_nShadowTabPage)
     {
             static_cast<SvxShadowTabPage&>(rPage).SetColorList( mpColorList );
-            static_cast<SvxShadowTabPage&>(rPage).SetPageType( mnPageType );
-            static_cast<SvxShadowTabPage&>(rPage).SetDlgType( 0 );
-            static_cast<SvxShadowTabPage&>(rPage).SetAreaTP( &mbAreaTP );
             static_cast<SvxShadowTabPage&>(rPage).SetColorChgd( &mnColorListState );
             static_cast<SvxShadowTabPage&>(rPage).Construct();
     }
@@ -287,10 +279,7 @@ void SvxAreaTabDialog::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
     {
             static_cast<SvxGradientTabPage&>(rPage).SetColorList( mpColorList );
             static_cast<SvxGradientTabPage&>(rPage).SetGradientList( mpGradientList );
-            static_cast<SvxGradientTabPage&>(rPage).SetPageType( &mnPageType );
-            static_cast<SvxGradientTabPage&>(rPage).SetDlgType( 0 );
             static_cast<SvxGradientTabPage&>(rPage).SetPos( &mnPos );
-            static_cast<SvxGradientTabPage&>(rPage).SetAreaTP( &mbAreaTP );
             static_cast<SvxGradientTabPage&>(rPage).SetGrdChgd( &mnGradientListState );
             static_cast<SvxGradientTabPage&>(rPage).SetColorChgd( &mnColorListState );
             static_cast<SvxGradientTabPage&>(rPage).Construct();
@@ -299,10 +288,7 @@ void SvxAreaTabDialog::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
     {
             static_cast<SvxHatchTabPage&>(rPage).SetColorList( mpColorList );
             static_cast<SvxHatchTabPage&>(rPage).SetHatchingList( mpHatchingList );
-            static_cast<SvxHatchTabPage&>(rPage).SetPageType( &mnPageType );
-            static_cast<SvxHatchTabPage&>(rPage).SetDlgType( 0 );
             static_cast<SvxHatchTabPage&>(rPage).SetPos( &mnPos );
-            static_cast<SvxHatchTabPage&>(rPage).SetAreaTP( &mbAreaTP );
             static_cast<SvxHatchTabPage&>(rPage).SetHtchChgd( &mnHatchingListState );
             static_cast<SvxHatchTabPage&>(rPage).SetColorChgd( &mnColorListState );
             static_cast<SvxHatchTabPage&>(rPage).Construct();
@@ -310,10 +296,7 @@ void SvxAreaTabDialog::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
     else if (nId == m_nBitmapTabPage )
     {
             static_cast<SvxBitmapTabPage&>(rPage).SetBitmapList( mpBitmapList );
-            static_cast<SvxBitmapTabPage&>(rPage).SetPageType( &mnPageType );
-            static_cast<SvxBitmapTabPage&>(rPage).SetDlgType( 0 );
             static_cast<SvxBitmapTabPage&>(rPage).SetPos( &mnPos );
-            static_cast<SvxBitmapTabPage&>(rPage).SetAreaTP( &mbAreaTP );
             static_cast<SvxBitmapTabPage&>(rPage).SetBmpChgd( &mnBitmapListState );
             static_cast<SvxBitmapTabPage&>(rPage).Construct();
     }
@@ -321,10 +304,7 @@ void SvxAreaTabDialog::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
     {
             static_cast<SvxPatternTabPage&>(rPage).SetColorList( mpColorList );
             static_cast<SvxPatternTabPage&>(rPage).SetPatternList( mpPatternList );
-            static_cast<SvxPatternTabPage&>(rPage).SetPageType( &mnPageType );
-            static_cast<SvxPatternTabPage&>(rPage).SetDlgType( 0 );
             static_cast<SvxPatternTabPage&>(rPage).SetPos( &mnPos );
-            static_cast<SvxPatternTabPage&>(rPage).SetAreaTP( &mbAreaTP );
             static_cast<SvxPatternTabPage&>(rPage).SetPtrnChgd( &mnPatternListState );
             static_cast<SvxPatternTabPage&>(rPage).SetColorChgd( &mnColorListState );
             static_cast<SvxPatternTabPage&>(rPage).Construct();
@@ -332,18 +312,10 @@ void SvxAreaTabDialog::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
     else if (nId == m_nColorTabPage)
     {
             static_cast<SvxColorTabPage&>(rPage).SetColorList( mpColorList );
-            static_cast<SvxColorTabPage&>(rPage).SetPageType( &mnPageType );
-            static_cast<SvxColorTabPage&>(rPage).SetDlgType( 0 );
             static_cast<SvxColorTabPage&>(rPage).SetPos( &mnPos );
-            static_cast<SvxColorTabPage&>(rPage).SetAreaTP( &mbAreaTP );
             static_cast<SvxColorTabPage&>(rPage).SetColorChgd( &mnColorListState );
             static_cast<SvxColorTabPage&>(rPage).Construct();
     }
-    else if (nId == m_nTransparenceTabPage)
-    {
-            static_cast<SvxTransparenceTabPage&>(rPage).SetPageType( mnPageType );
-            static_cast<SvxTransparenceTabPage&>(rPage).SetDlgType( 0 );
-    }
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cui/source/tabpages/tparea.cxx b/cui/source/tabpages/tparea.cxx
index d89945d..c9b66a1 100644
--- a/cui/source/tabpages/tparea.cxx
+++ b/cui/source/tabpages/tparea.cxx
@@ -39,17 +39,24 @@
 #include <svl/intitem.hxx>
 #include <sfx2/request.hxx>
 #include "paragrph.hrc"
-
-//UUUU
+#include <sfx2/tabdlg.hxx>
 #include "sfx2/opengrf.hxx"
 #include <vcl/layout.hxx>
 
-#define DEFAULT_GRADIENTSTEP 64
-
 using namespace com::sun::star;
 
 // static ----------------------------------------------------------------
 
+enum FillType
+{
+    TRANSPARENT,
+    SOLID,
+    GRADIENT,
+    HATCH,
+    BITMAP,
+    PATTERN
+};
+
 const sal_uInt16 SvxAreaTabPage::pAreaRanges[] =
 {
     XATTR_GRADIENTSTEPCOUNT,
@@ -71,91 +78,50 @@ SvxAreaTabPage::SvxAreaTabPage( vcl::Window* pParent, const SfxItemSet& rInAttrs
                 "AreaTabPage",
                 "cui/ui/areatabpage.ui",
                rInAttrs ),
-    m_rOutAttrs (rInAttrs ),
-
+    m_pFillTabPage( nullptr ),
     m_pColorList( nullptr ),
     m_pGradientList( nullptr ),
     m_pHatchingList( nullptr ),
     m_pBitmapList( nullptr ),
+    m_pPatternList( nullptr ),
 
     // local fixed not o be changed values for local pointers
     maFixed_ChangeType(ChangeType::NONE),
-    maFixed_sal_Bool(false),
 
     // init with pointers to fixed ChangeType
     m_pnColorListState(&maFixed_ChangeType),
     m_pnBitmapListState(&maFixed_ChangeType),
+    m_pnPatternListState(&maFixed_ChangeType),
     m_pnGradientListState(&maFixed_ChangeType),
     m_pnHatchingListState(&maFixed_ChangeType),
-
-    m_nPageType(PageType::Area),
-    m_nDlgType(0),
     m_nPos(0),
-
-    // init with pointer to fixed bool
-    m_pbAreaTP(&maFixed_sal_Bool),
-
     m_aXFillAttr          ( rInAttrs.GetPool() ),
     m_rXFSet              ( m_aXFillAttr.GetItemSet() )
 {
-    get(m_pTypeLB,"LB_AREA_TYPE");
-    get(m_pFillLB,"boxLB_FILL");
-    get(m_pLbColor,"LB_COLOR");
-    get(m_pLbGradient,"LB_GRADIENT");
-    get(m_pLbHatching,"LB_HATCHING");
-    get(m_pLbBitmap,"LB_BITMAP");
-    get(m_pCtlBitmapPreview,"CTL_BITMAP_PREVIEW");
-    get(m_pCtlXRectPreview,"CTL_COLOR_PREVIEW");
-
-
-    // groups that overlay each other
-    m_pLbBitmap->Hide();
-    m_pCtlBitmapPreview->Hide();
-
-    // this page needs ExchangeSupport
-    SetExchangeSupport();
-
-    // get PoolUnit
-    SfxItemPool* pPool = m_rOutAttrs.GetPool();
-    DBG_ASSERT( pPool, "Wo ist der Pool?" );
-    m_ePoolUnit = pPool->GetMetric( XATTR_FILLBMP_SIZEX );
-
-    // setting the output device
-    m_rXFSet.Put( XFillStyleItem( drawing::FillStyle_SOLID ) );
-    m_rXFSet.Put( XFillColorItem( OUString(), COL_BLACK ) );
-    m_pCtlXRectPreview->SetAttributes( m_aXFillAttr.GetItemSet() );
-    m_pCtlBitmapPreview->SetAttributes( m_aXFillAttr.GetItemSet() );
-
-    m_pLbColor->SetSelectHdl( LINK( this, SvxAreaTabPage, ModifyColorHdl_Impl ) );
-    m_pLbGradient->SetSelectHdl( LINK( this, SvxAreaTabPage, ModifyGradientHdl_Impl ) );
-    m_pLbHatching->SetSelectHdl( LINK( this, SvxAreaTabPage, ModifyHatchingHdl_Impl ) );
-    m_pLbBitmap->SetSelectHdl(   LINK( this, SvxAreaTabPage, ModifyBitmapHdl_Impl ) );
-
-    m_pTypeLB->SetSelectHdl( LINK( this, SvxAreaTabPage, SelectDialogTypeHdl_Impl ) );
-
-    // #i76307# always paint the preview in LTR, because this is what the document does
-    m_pCtlXRectPreview->EnableRTL(false);
-
-    // Calculate size of dropdown listboxes
-    Size aSize = LogicToPixel(Size(108, 103), MapUnit::MapAppFont);
-
-    m_pLbColor->set_width_request(aSize.Width());
-    m_pLbColor->set_height_request(aSize.Height());
-    //m_pLbColor->
-
-    m_pLbGradient->set_width_request(aSize.Width());
-    m_pLbGradient->set_height_request(aSize.Height());
-    m_pLbHatching->set_width_request(aSize.Width());
-    m_pLbHatching->set_height_request(aSize.Height());
-    m_pLbBitmap->set_width_request(aSize.Width());
-    m_pLbBitmap->set_height_request(aSize.Height());
-
-    // Calculate size of display boxes
-    Size aSize2 = LogicToPixel(Size(110, 42), MapUnit::MapAppFont);
-    m_pCtlBitmapPreview->set_width_request(aSize2.Width());
-    m_pCtlBitmapPreview->set_height_request(aSize2.Height());
-    m_pCtlXRectPreview->set_width_request(aSize2.Width());
-    m_pCtlXRectPreview->set_height_request(aSize2.Height());
+
+    get(m_pBtnNone, "btnnone");
+    get(m_pBtnColor, "btncolor");
+    get(m_pBtnGradient, "btngradient");
+    get(m_pBtnHatch, "btnhatch");
+    get(m_pBtnBitmap, "btnbitmap");
+    get(m_pBtnPattern, "btnpattern");
+    get(m_pFillTab, "fillstylebox");
+    maBox.AddButton( m_pBtnNone );
+    maBox.AddButton( m_pBtnColor );
+    maBox.AddButton( m_pBtnGradient );
+    maBox.AddButton( m_pBtnHatch );
+    maBox.AddButton( m_pBtnBitmap );
+    maBox.AddButton( m_pBtnPattern );
+    Link< Button*, void > aLink = LINK(this, SvxAreaTabPage, SelectFillTypeHdl_Impl);
+    m_pBtnNone->SetClickHdl(aLink);
+    m_pBtnColor->SetClickHdl(aLink);
+    m_pBtnGradient->SetClickHdl(aLink);
+    m_pBtnHatch->SetClickHdl(aLink);
+    m_pBtnBitmap->SetClickHdl(aLink);
+    m_pBtnPattern->SetClickHdl(aLink);
+
+    m_pFillTab->set_width_request(700);
+    m_pFillTab->set_height_request(400);
 }
 
 SvxAreaTabPage::~SvxAreaTabPage()
@@ -165,504 +131,187 @@ SvxAreaTabPage::~SvxAreaTabPage()
 
 void SvxAreaTabPage::dispose()
 {
-    m_pTypeLB.clear();
-    m_pFillLB.clear();
-    m_pLbColor.clear();
-    m_pLbGradient.clear();
-    m_pLbHatching.clear();
-    m_pLbBitmap.clear();
-    m_pCtlBitmapPreview.clear();
-    m_pCtlXRectPreview.clear();
+    m_pBtnNone.clear();
+    m_pBtnColor.clear();
+    m_pBtnGradient.clear();
+    m_pBtnHatch.clear();
+    m_pBtnBitmap.clear();
+    m_pBtnPattern.clear();
+    m_pFillTab.clear();
+    m_pFillTabPage.disposeAndClear();
     SvxTabPage::dispose();
 }
 
-void SvxAreaTabPage::Construct()
-{
-    // fill colortables / lists
-    m_pLbColor->Fill( m_pColorList );
-    m_pLbGradient->Fill( m_pGradientList );
-    m_pLbHatching->Fill( m_pHatchingList );
-    m_pLbBitmap->Fill( m_pBitmapList );
-}
-
-
 void SvxAreaTabPage::ActivatePage( const SfxItemSet& rSet )
 {
-    sal_Int32 nCount(0);
-    const SfxUInt16Item* pPageTypeItem = rSet.GetItem<SfxUInt16Item>(SID_PAGE_TYPE, false);
-    const SfxUInt16Item* pPosItem = rSet.GetItem<SfxUInt16Item>(SID_TABPAGE_POS, false);
-    if (pPageTypeItem)
-        SetPageType((PageType) pPageTypeItem->GetValue());
-    if (pPosItem)
-        SetPos(pPosItem->GetValue());
-    if( m_nDlgType == 0 ) // area dialog
+    drawing::FillStyle eXFS = drawing::FillStyle_NONE;
+    if( rSet.GetItemState( XATTR_FILLSTYLE ) != SfxItemState::DONTCARE )
     {
-        *m_pbAreaTP = true;
-
-        if( m_pColorList.is() )
-        {
-            //UUUU use evtl. previously selected entry to avoid changing values just by
-            // switching TabPages in dialogs using this TabPage
-            sal_Int32 _nPos(m_nPos);
-
-            if( *m_pnBitmapListState != ChangeType::NONE )
-            {
-                if( *m_pnBitmapListState & ChangeType::CHANGED )
-                    m_pBitmapList = static_cast<SvxAreaTabDialog*>( GetParentDialog() )->GetNewBitmapList();
-
-                _nPos = m_pLbBitmap->GetSelectEntryPos();
-
-                m_pLbBitmap->Clear();
-                m_pLbBitmap->Fill( m_pBitmapList );
-                nCount = m_pLbBitmap->GetEntryCount();
-                if( nCount == 0 )
-                    ; // This case should never occur
-                else if( nCount <= _nPos )
-                    m_pLbBitmap->SelectEntryPos( 0 );
-                else
-                    m_pLbBitmap->SelectEntryPos( _nPos );
-            }
-
-            if( *m_pnHatchingListState != ChangeType::NONE )
-            {
-                if( *m_pnHatchingListState & ChangeType::CHANGED )
-                    m_pHatchingList = static_cast<SvxAreaTabDialog*>( GetParentDialog() )->GetNewHatchingList();
-
-                _nPos = m_pLbHatching->GetSelectEntryPos();
-
-                m_pLbHatching->Clear();
-                m_pLbHatching->Fill( m_pHatchingList );
-                nCount = m_pLbHatching->GetEntryCount();
-                if( nCount == 0 )
-                    ; // This case should never occur
-                else if( nCount <= _nPos )
-                    m_pLbHatching->SelectEntryPos( 0 );
-                else
-                    m_pLbHatching->SelectEntryPos( _nPos );
-                ModifyHatchingHdl_Impl( *m_pLbHatching );
-            }
-
-            if( *m_pnGradientListState != ChangeType::NONE )
-            {
-                if( *m_pnGradientListState & ChangeType::CHANGED )
-                    m_pGradientList = static_cast<SvxAreaTabDialog*>( GetParentDialog() )->GetNewGradientList();
-
-                _nPos = m_pLbGradient->GetSelectEntryPos();
-
-                m_pLbGradient->Clear();
-                m_pLbGradient->Fill( m_pGradientList );
-                nCount = m_pLbGradient->GetEntryCount();
-                if( nCount == 0 )
-                    ; // This case should never occur
-                else if( nCount <= _nPos )
-                    m_pLbGradient->SelectEntryPos( 0 );
-                else
-                    m_pLbGradient->SelectEntryPos( _nPos );
-                ModifyGradientHdl_Impl( *m_pLbGradient );
-            }
-
-            if( *m_pnColorListState != ChangeType::NONE )
-            {
-                if( *m_pnColorListState & ChangeType::CHANGED )
-                    m_pColorList = static_cast<SvxAreaTabDialog*>( GetParentDialog() )->GetNewColorList();
-                // aLbColor
-                _nPos = m_pLbColor->GetSelectEntryPos();
-                m_pLbColor->Clear();
-                m_pLbColor->Fill( m_pColorList );
-                nCount = m_pLbColor->GetEntryCount();
-                if( nCount == 0 )
-                    ; // This case should never occur
-                else if( nCount <= _nPos )
-                    m_pLbColor->SelectEntryPos( 0 );
-                else
-                    m_pLbColor->SelectEntryPos( _nPos );
-
-                ModifyColorHdl_Impl( *m_pLbColor );
-            }
-
-            // evaluate if any other Tabpage set another filltype
-            if( m_pTypeLB->GetSelectEntryPos() > drawing::FillStyle_NONE)
-            {
-                switch( m_nPageType )
-                {
-                    case PageType::Gradient:
-                        m_pTypeLB->SelectEntryPos( drawing::FillStyle_GRADIENT );
-                        m_pLbGradient->SelectEntryPos( _nPos );
-                        ClickGradientHdl_Impl();
-                    break;
-
-                    case PageType::Hatch:
-                        m_pTypeLB->SelectEntryPos( drawing::FillStyle_HATCH );
-                        m_pLbHatching->SelectEntryPos( _nPos );
-                        ClickHatchingHdl_Impl();
-                    break;
-
-                    case PageType::Bitmap:
-                        m_pTypeLB->SelectEntryPos( drawing::FillStyle_BITMAP );
-                        m_pLbBitmap->SelectEntryPos( _nPos );
-                        ClickBitmapHdl_Impl();
-                    break;
-
-                    case PageType::Color:
-                        m_pTypeLB->SelectEntryPos( drawing::FillStyle_SOLID );
-                        m_pLbColor->SelectEntryPos( _nPos );
-                        ClickColorHdl_Impl();
-                    break;
-                    default: break;
-                }
-            }
-            m_nPageType = PageType::Area;
-        }
+        eXFS = (drawing::FillStyle) ( static_cast<const XFillStyleItem&>( rSet.Get( GetWhich( XATTR_FILLSTYLE ) ) ).GetValue() );
     }
-}
-
-
-DeactivateRC SvxAreaTabPage::DeactivatePage( SfxItemSet* _pSet )
-{
-    if( m_nDlgType == 0 ) // area dialog
+    switch(eXFS)
     {
-        sal_Int32 nPosOrig = m_nPos;
-        drawing::FillStyle eStyle = (drawing::FillStyle) m_pTypeLB->GetSelectEntryPos();
-        switch( eStyle )
+        default:
+        case drawing::FillStyle_NONE:
         {
-            case drawing::FillStyle_GRADIENT:
-            {
-                        m_nPageType = PageType::Gradient;
-                        m_nPos = m_pLbGradient->GetSelectEntryPos();
-                        if( nPosOrig != m_nPos )
-                            *m_pnGradientListState |= ChangeType::MODIFIED;
-            }
+            SelectFillTypeHdl_Impl( m_pBtnNone );
             break;
-            case drawing::FillStyle_HATCH:
-            {
-                m_nPageType = PageType::Hatch;
-                m_nPos = m_pLbHatching->GetSelectEntryPos();
-                if( nPosOrig != m_nPos )
-                    *m_pnHatchingListState |= ChangeType::MODIFIED;
-            }
+        }
+        case drawing::FillStyle_SOLID:
+        {
+            m_rXFSet.Put( static_cast<const XFillColorItem&>( rSet.Get( GetWhich( XATTR_FILLCOLOR ) ) ) );
+            SelectFillTypeHdl_Impl( m_pBtnColor );
             break;
-            case drawing::FillStyle_BITMAP:
-            {
-                m_nPageType = PageType::Bitmap;
-                m_nPos = m_pLbBitmap->GetSelectEntryPos();
-                if( nPosOrig != m_nPos )
-                    *m_pnBitmapListState |= ChangeType::MODIFIED;
-            }
+        }
+        case drawing::FillStyle_GRADIENT:
+        {
+            m_rXFSet.Put( static_cast<const XFillGradientItem&>( rSet.Get( GetWhich( XATTR_FILLGRADIENT ) ) ) );
+            SelectFillTypeHdl_Impl( m_pBtnGradient );
             break;
-            case drawing::FillStyle_SOLID:
-            {
-                m_nPageType = PageType::Color;
-                m_nPos = m_pLbColor->GetSelectEntryPos();
-                if( nPosOrig != m_nPos )
-                    *m_pnColorListState |= ChangeType::MODIFIED;
-            }
+        }
+        case drawing::FillStyle_HATCH:
+        {
+            m_rXFSet.Put( static_cast<const XFillHatchItem&>( rSet.Get(XATTR_FILLHATCH) ) );
+            SelectFillTypeHdl_Impl( m_pBtnHatch );
+            break;
+        }
+        case drawing::FillStyle_BITMAP:
+        {
+            XFillBitmapItem aItem(static_cast<const XFillBitmapItem&>( rSet.Get( GetWhich( XATTR_FILLBITMAP ) ) ));
+            m_rXFSet.Put( aItem );
+            if(!aItem.isPattern())
+                SelectFillTypeHdl_Impl( m_pBtnBitmap );
+            else
+                SelectFillTypeHdl_Impl( m_pBtnPattern );
             break;
-            default: ;//prevent warning
         }
     }
-
-    if( _pSet )
-        FillItemSet( _pSet );
-
-    return DeactivateRC::LeavePage;
 }
 
-
-bool SvxAreaTabPage::FillItemSet( SfxItemSet* rAttrs )
+template< typename TTabPage >
+DeactivateRC SvxAreaTabPage::DeactivatePage_Impl( SfxItemSet* _pSet )
 {
-    sal_Int32  _nPos;
-    bool    bModified = false;
+    return static_cast<TTabPage&>(*m_pFillTabPage).DeactivatePage(_pSet);
+}
 
-    if( m_nDlgType != 0 || *m_pbAreaTP )
+DeactivateRC SvxAreaTabPage::DeactivatePage( SfxItemSet* _pSet )
+{
+    FillType eFillType = static_cast<FillType>(maBox.GetCurrentButtonPos());
+    switch( eFillType )
     {
-        const SfxPoolItem* pOld = nullptr;
-        drawing::FillStyle eStyle = (drawing::FillStyle) m_pTypeLB->GetSelectEntryPos();
-        drawing::FillStyle eSavedStyle = (drawing::FillStyle) m_pTypeLB->GetSavedValue();
-        switch( eStyle )
+        case SOLID:
         {
-            default:
-            case drawing::FillStyle_NONE:
-            {
-                if(  eSavedStyle != eStyle )
-                {
-                    XFillStyleItem aStyleItem( drawing::FillStyle_NONE );
-                    pOld = GetOldItem( *rAttrs, XATTR_FILLSTYLE );
-                    if ( !pOld || !( *static_cast<const XFillStyleItem*>(pOld) == aStyleItem ) )
-                    {
-                        rAttrs->Put( aStyleItem );
-                        bModified = true;
-                    }
-                }
-            }
+            return DeactivatePage_Impl<SvxColorTabPage>(_pSet);
             break;
-            case drawing::FillStyle_SOLID:
-            {
-                _nPos = m_pLbColor->GetSelectEntryPos();
-                 if( _nPos != LISTBOX_ENTRY_NOTFOUND &&
-                     m_pLbColor->IsValueChangedFromSaved() )
-                 {
-                     XFillColorItem aItem( m_pLbColor->GetSelectEntry(),
-                                           m_pLbColor->GetSelectEntryColor() );
-                     pOld = GetOldItem( *rAttrs, XATTR_FILLCOLOR );
-                     if ( !pOld || !( *static_cast<const XFillColorItem*>(pOld) == aItem ) )
-                     {
-                         rAttrs->Put( aItem );
-                         bModified = true;
-                     }
-                 }
-                 // NEW
-                 if( (eSavedStyle != eStyle) &&
-                     ( bModified ||
-                       SfxItemState::SET == m_rOutAttrs.GetItemState( GetWhich( XATTR_FILLCOLOR ) ) ) )
-                 {
-                     XFillStyleItem aStyleItem( drawing::FillStyle_SOLID );
-                     pOld = GetOldItem( *rAttrs, XATTR_FILLSTYLE );
-                     if ( !pOld || !( *static_cast<const XFillStyleItem*>(pOld) == aStyleItem ) )
-                     {
-                         rAttrs->Put( aStyleItem );
-                         bModified = true;
-                     }
-                 }
-            }
+        }
+        case GRADIENT:
+        {
+            return DeactivatePage_Impl<SvxGradientTabPage>(_pSet);
             break;
-            case drawing::FillStyle_GRADIENT:
-            {
-                _nPos = m_pLbGradient->GetSelectEntryPos();
-                if( _nPos != LISTBOX_ENTRY_NOTFOUND &&
-                    m_pLbGradient->IsValueChangedFromSaved() )
-                {
-                    XGradient aGradient = m_pGradientList->GetGradient( _nPos )->GetGradient();
-                    OUString aString = m_pLbGradient->GetSelectEntry();
-                    XFillGradientItem aItem( aString, aGradient );
-                    pOld = GetOldItem( *rAttrs, XATTR_FILLGRADIENT );
-                    if ( !pOld || !( *static_cast<const XFillGradientItem*>(pOld) == aItem ) )
-                    {
-                        rAttrs->Put( aItem );
-                        bModified = true;
-                    }
-                }
-                // NEW
-                if( (eSavedStyle != eStyle) &&
-                    ( bModified ||
-                      SfxItemState::SET == m_rOutAttrs.GetItemState( GetWhich( XATTR_FILLGRADIENT ) ) ) )
-                {
-                    XFillStyleItem aStyleItem( drawing::FillStyle_GRADIENT );
-                    pOld = GetOldItem( *rAttrs, XATTR_FILLSTYLE );
-                    if ( !pOld || !( *static_cast<const XFillStyleItem*>(pOld) == aStyleItem ) )
-                    {
-                        rAttrs->Put( aStyleItem );
-                        bModified = true;
-                    }
-                }
-            }
+        }
+        case HATCH:
+        {
+            return DeactivatePage_Impl<SvxHatchTabPage>(_pSet);
             break;
-            case drawing::FillStyle_HATCH:
-            {
-                _nPos = m_pLbHatching->GetSelectEntryPos();
-                if( _nPos != LISTBOX_ENTRY_NOTFOUND &&
-                   m_pLbHatching->IsValueChangedFromSaved() )
-                {
-                    XHatch aHatching = m_pHatchingList->GetHatch( _nPos )->GetHatch();
-                    OUString aString = m_pLbHatching->GetSelectEntry();
-                    XFillHatchItem aItem( aString, aHatching );
-                    pOld = GetOldItem( *rAttrs, XATTR_FILLHATCH );
-                    if ( !pOld || !( *static_cast<const XFillHatchItem*>(pOld) == aItem ) )
-                    {
-                        rAttrs->Put( aItem );
-                        bModified = true;
-                    }
-                }
-                // NEW
-                if( (eSavedStyle != eStyle) &&
-                    ( bModified ||
-                      SfxItemState::SET == m_rOutAttrs.GetItemState( GetWhich( XATTR_FILLHATCH ) ) ) )
-                {
-                    XFillStyleItem aStyleItem( drawing::FillStyle_HATCH );
-                    pOld = GetOldItem( *rAttrs, XATTR_FILLSTYLE );
-                    if ( !pOld || !( *static_cast<const XFillStyleItem*>(pOld) == aStyleItem ) )
-                    {
-                        rAttrs->Put( aStyleItem );
-                        bModified = true;
-                    }
-                }
-            }
+        }
+        case BITMAP:
+        {
+            return DeactivatePage_Impl<SvxBitmapTabPage&>(_pSet);
             break;
-            case drawing::FillStyle_BITMAP:
-            {
-                //UUUU
-                m_nPos = m_pLbBitmap->GetSelectEntryPos();
-                if( m_nPos != LISTBOX_ENTRY_NOTFOUND &&
-                    m_pLbBitmap->IsValueChangedFromSaved() )
-                {
-                    const XBitmapEntry* pXBitmapEntry = m_pBitmapList->GetBitmap(m_nPos);
-                    const OUString aString(m_pLbBitmap->GetSelectEntry());
-                    const XFillBitmapItem aFillBitmapItem(aString, pXBitmapEntry->GetGraphicObject());
-                    pOld = GetOldItem( *rAttrs, XATTR_FILLBITMAP );
-                    if ( !pOld || !( *static_cast<const XFillBitmapItem*>(pOld) == aFillBitmapItem ) )
-                    {
-                        rAttrs->Put( aFillBitmapItem );
-                        bModified = true;
-                    }
-                }
-                // NEW
-                if( (eSavedStyle != eStyle) &&
-                    ( bModified ||
-                      SfxItemState::SET == m_rOutAttrs.GetItemState( GetWhich( XATTR_FILLBITMAP ) ) ) )
-                {
-                        XFillStyleItem aStyleItem( drawing::FillStyle_BITMAP );
-                        pOld = GetOldItem( *rAttrs, XATTR_FILLSTYLE );
-                        if ( !pOld || !( *static_cast<const XFillStyleItem*>(pOld) == aStyleItem ) )
-                        {
-                            rAttrs->Put( aStyleItem );
-                            bModified = true;
-                        }
-                }
-            }
+        }
+        case PATTERN:
+        {
+            return DeactivatePage_Impl<SvxPatternTabPage>(_pSet);
             break;
         }
-        rAttrs->Put (SfxUInt16Item(SID_PAGE_TYPE, (sal_uInt16)m_nPageType));
-        rAttrs->Put (SfxUInt16Item(SID_TABPAGE_POS,m_nPos));
+        default:
+            break;
     }
-
-    return bModified;
+    return DeactivateRC::LeavePage;
 }
 
+template< typename TTabPage >
+bool SvxAreaTabPage::FillItemSet_Impl( SfxItemSet* rAttrs)
+{
+    return static_cast<TTabPage&>( *m_pFillTabPage ).FillItemSet( rAttrs );
+}
 
-void SvxAreaTabPage::Reset( const SfxItemSet* rAttrs )
+bool SvxAreaTabPage::FillItemSet( SfxItemSet* rAttrs )
 {
-    bool isMissingHatching(false);
-    bool isMissingGradient(false);
-    bool isMissingBitmap(false);
-    drawing::FillStyle eXFS = drawing::FillStyle_NONE;
-    if( rAttrs->GetItemState( XATTR_FILLSTYLE ) != SfxItemState::DONTCARE )
+    FillType eFillType = static_cast<FillType>(maBox.GetCurrentButtonPos());
+    switch( eFillType )
     {
-        eXFS = (drawing::FillStyle) ( static_cast<const XFillStyleItem&>( rAttrs->
-                                Get( GetWhich( XATTR_FILLSTYLE ) ) ).GetValue() );
-        m_pTypeLB->SelectEntryPos( sal::static_int_cast< sal_Int32 >( eXFS ) );
-
-        if (SfxItemState::DONTCARE != rAttrs->GetItemState(XATTR_FILLCOLOR))
+        case TRANSPARENT:
         {
-            XFillColorItem const& rColorItem(static_cast<const XFillColorItem&>(
-                                rAttrs->Get(XATTR_FILLCOLOR)) );
-            m_pLbColor->SelectEntry( rColorItem.GetColorValue() );
+            rAttrs->Put( XFillStyleItem( drawing::FillStyle_NONE ) );
+            return true;
         }
-
-        SfxItemState const eGradState(rAttrs->GetItemState(XATTR_FILLGRADIENT));
-        XFillGradientItem const* pGradientItem(nullptr);
-        if (SfxItemState::DONTCARE != eGradState)
+        case SOLID:
         {
-            pGradientItem = &static_cast<const XFillGradientItem&>(
-                                    rAttrs->Get(XATTR_FILLGRADIENT));
-            OUString  const aString( pGradientItem->GetName() );
-            XGradient const aGradient( pGradientItem->GetGradientValue() );
-            m_pLbGradient->SelectEntryByList(m_pGradientList, aString, aGradient);
-        }
-        if (!m_pLbGradient->GetSelectEntryCount()
-            && (SfxItemState::DEFAULT == eGradState
-                || (pGradientItem && pGradientItem->GetName().isEmpty())))
-        {   // avoid relying on pool default - cannot export that
-            m_pLbGradient->SelectEntryPos(0); // anything better than nothing
-            isMissingGradient = true;
+            return FillItemSet_Impl<SvxColorTabPage>( rAttrs );
         }
-
-        SfxItemState const eHatchState(rAttrs->GetItemState(XATTR_FILLHATCH));
-        XFillHatchItem const* pHatch(nullptr);
-        if (SfxItemState::DONTCARE != eHatchState)
+        case GRADIENT:
         {
-            pHatch = &static_cast<const XFillHatchItem&>(
-                                rAttrs->Get(XATTR_FILLHATCH));
-            m_pLbHatching->SelectEntry(pHatch->GetName());
+            return FillItemSet_Impl<SvxGradientTabPage>( rAttrs );
         }
-        if (!m_pLbHatching->GetSelectEntryCount()
-            && (SfxItemState::DEFAULT == eHatchState
-                || (pHatch && pHatch->GetName().isEmpty())))
-        {   // avoid relying on pool default - cannot export that
-            m_pLbHatching->SelectEntryPos(0); // anything better than nothing
-            isMissingHatching = true;
+        case HATCH:
+        {
+            return FillItemSet_Impl<SvxHatchTabPage>( rAttrs );
         }
-
-        SfxItemState const eBitmapState(rAttrs->GetItemState(XATTR_FILLBITMAP));
-        XFillBitmapItem const* pBitmapItem(nullptr);
-        if (SfxItemState::DONTCARE != eBitmapState)
+        case BITMAP:
         {
-            pBitmapItem = &static_cast<const XFillBitmapItem&>(
-                            rAttrs->Get(XATTR_FILLBITMAP));
-            m_pLbBitmap->SelectEntry(pBitmapItem->GetName());
+            return FillItemSet_Impl<SvxBitmapTabPage>( rAttrs );
         }
-        if (!m_pLbBitmap->GetSelectEntryCount()
-            && (SfxItemState::DEFAULT == eBitmapState
-                || (pBitmapItem && pBitmapItem->GetName().isEmpty())))
-        {   // avoid relying on pool default - cannot export that
-            m_pLbBitmap->SelectEntryPos(0); // anything better than nothing
-            isMissingBitmap = true;
+        case PATTERN:
+        {
+            return FillItemSet_Impl<SvxPatternTabPage>( rAttrs );
         }
+        default:
+            return false;
+    }
+}
 
-        switch( eXFS )
-        {
-            case drawing::FillStyle_NONE:
-                ClickInvisibleHdl_Impl();
-            break;
+template< typename TTabPage >
+void SvxAreaTabPage::Reset_Impl( const SfxItemSet* rAttrs )
+{
+    static_cast<TTabPage&>( *m_pFillTabPage ).Reset( rAttrs );
+}
 
-            case drawing::FillStyle_SOLID:
-                ClickColorHdl_Impl();
+void SvxAreaTabPage::Reset( const SfxItemSet* rAttrs )
+{
+    FillType eFillType = static_cast<FillType>(maBox.GetCurrentButtonPos());
+    switch(eFillType)
+    {
+        case SOLID:
+        {
+            Reset_Impl<SvxColorTabPage>( rAttrs );
             break;
-
-            case drawing::FillStyle_GRADIENT:
-                ClickGradientHdl_Impl();
+        }
+        case GRADIENT:
+        {
+            Reset_Impl<SvxGradientTabPage>( rAttrs );
             break;
-
-            case drawing::FillStyle_HATCH:
-                ClickHatchingHdl_Impl();
+        }
+        case HATCH:
+        {
+            Reset_Impl<SvxHatchTabPage>( rAttrs );
             break;
-
-            case drawing::FillStyle_BITMAP:
-            {
-                ClickBitmapHdl_Impl();
-            }
+        }
+        case BITMAP:
+        {
+            Reset_Impl<SvxBitmapTabPage>( rAttrs );
             break;
-
-            default:
-                assert(false);
+        }
+        case PATTERN:
+        {
+            Reset_Impl<SvxPatternTabPage>( rAttrs );
             break;
         }
+        default:
+            break;
     }
-    else
-    {
-        // make all LBs not accessible
-        m_pFillLB->Hide();
-
-        m_pCtlBitmapPreview->Hide();
-        m_pLbColor->Disable();
-        m_pLbColor->Show();
-
-        // so that Reset() also works correctly with Back
-        m_pTypeLB->SetNoSelection();
-    }
-
-    if( m_pTypeLB->GetSelectEntryPos() == drawing::FillStyle_BITMAP )
-        ClickBitmapHdl_Impl();
-
-    m_pTypeLB->SaveValue();
-    if(eXFS == drawing::FillStyle_SOLID)
-        m_pLbColor->SaveValue();
-    if (!isMissingGradient)
-        m_pLbGradient->SaveValue();
-    if (!isMissingHatching)
-        m_pLbHatching->SaveValue();
-    if (!isMissingBitmap)
-        m_pLbBitmap->SaveValue();
-}
-
-void SvxAreaTabPage::ChangesApplied()
-{
-    m_pTypeLB->SaveValue();
-    m_pLbColor->SaveValue();
-    m_pLbGradient->SaveValue();
-    m_pLbHatching->SaveValue();
-    m_pLbBitmap->SaveValue();
 }
 
-
 VclPtr<SfxTabPage> SvxAreaTabPage::Create( vcl::Window* pWindow,
                                            const SfxItemSet* rAttrs )
 {
@@ -670,245 +319,113 @@ VclPtr<SfxTabPage> SvxAreaTabPage::Create( vcl::Window* pWindow,
 }
 
 
-IMPL_LINK_NOARG(SvxAreaTabPage, SelectDialogTypeHdl_Impl, ListBox&, void)
+VclPtr<SfxTabPage> CreateFillStyleTabPage( sal_uInt16 nId, vcl::Window* pParent, const SfxItemSet& rSet )
 {
-    switch( (drawing::FillStyle)m_pTypeLB->GetSelectEntryPos() )
+    CreateTabPage fnCreate = nullptr;
+    switch(nId)
     {
-        default:
-        case drawing::FillStyle_NONE: ClickInvisibleHdl_Impl(); break;
-        case drawing::FillStyle_SOLID: ClickColorHdl_Impl(); break;
-        case drawing::FillStyle_GRADIENT: ClickGradientHdl_Impl(); break;
-        case drawing::FillStyle_HATCH: ClickHatchingHdl_Impl(); break;
-        case drawing::FillStyle_BITMAP: ClickBitmapHdl_Impl(); break;
+        case TRANSPARENT: fnCreate = nullptr; break;
+        case SOLID: fnCreate = &SvxColorTabPage::Create; break;
+        case GRADIENT: fnCreate = &SvxGradientTabPage::Create; break;
+        case HATCH: fnCreate = &SvxHatchTabPage::Create; break;
+        case BITMAP: fnCreate = &SvxBitmapTabPage::Create; break;
+        case PATTERN: fnCreate = &SvxPatternTabPage::Create; break;
     }
+    VclPtr<SfxTabPage> pRet = fnCreate ? (*fnCreate)( pParent, &rSet ) : nullptr;
+    return pRet;
 }
 
-void SvxAreaTabPage::ClickInvisibleHdl_Impl()
-{
-    m_pFillLB->Hide();
-
-    m_pCtlXRectPreview->Hide();
-    m_pCtlBitmapPreview->Hide();
-
-    m_rXFSet.Put( XFillStyleItem( drawing::FillStyle_NONE ) );
-    m_pCtlXRectPreview->SetAttributes( m_aXFillAttr.GetItemSet() );
-    m_pCtlBitmapPreview->SetAttributes( m_aXFillAttr.GetItemSet() );
-
-    m_pCtlXRectPreview->Invalidate();
-    m_pCtlBitmapPreview->Invalidate();
-}
-
-
-void SvxAreaTabPage::ClickColorHdl_Impl()
-{
-    m_pFillLB->Show();
-    m_pLbColor->Enable();
-    m_pLbColor->Show();
-    m_pLbGradient->Hide();
-    m_pLbHatching->Hide();
-    m_pLbBitmap->Hide();
-    m_pCtlXRectPreview->Enable();
-    m_pCtlXRectPreview->Show();
-    m_pCtlBitmapPreview->Hide();
-
-    ModifyColorHdl_Impl( *m_pLbColor );
-}
-
-
-IMPL_LINK_NOARG(SvxAreaTabPage, ModifyColorHdl_Impl, ListBox&, void)
+IMPL_LINK(SvxAreaTabPage, SelectFillTypeHdl_Impl, Button*, pButton, void)
 {
-    const SfxPoolItem* pPoolItem = nullptr;
-    sal_Int32 _nPos = m_pLbColor->GetSelectEntryPos();
-    if( _nPos != LISTBOX_ENTRY_NOTFOUND )
-    {
-        m_rXFSet.Put( XFillStyleItem( drawing::FillStyle_SOLID ) );
-        m_rXFSet.Put( XFillColorItem( OUString(), m_pLbColor->GetSelectEntryColor() ) );
-    }
-    // NEW
-    else if( SfxItemState::SET == m_rOutAttrs.GetItemState( GetWhich( XATTR_FILLCOLOR ), true, &pPoolItem ) )
+    sal_Int32 nPos = maBox.GetButtonPos( static_cast<PushButton*>(pButton) );
+    if(nPos != -1 && nPos != maBox.GetCurrentButtonPos())
     {
-        m_rXFSet.Put( XFillStyleItem( drawing::FillStyle_SOLID ) );
-        Color aColor( static_cast<const XFillColorItem*>( pPoolItem )->GetColorValue() );
-        m_rXFSet.Put( XFillColorItem( OUString(), aColor ) );
+        maBox.SelectButton(static_cast<PushButton*>(pButton));
+        FillType eFillType = static_cast<FillType>(maBox.GetCurrentButtonPos());
+        m_pFillTabPage.disposeAndReset( CreateFillStyleTabPage(eFillType, m_pFillTab, m_rXFSet) );
+        CreatePage( eFillType , *m_pFillTabPage);
     }
-    else
-        m_rXFSet.Put( XFillStyleItem( drawing::FillStyle_NONE ) );
-
-    m_pCtlXRectPreview->SetAttributes( m_aXFillAttr.GetItemSet() );
-    m_pCtlXRectPreview->Invalidate();
 }
 
-
-void SvxAreaTabPage::ClickGradientHdl_Impl()
-{
-    m_pFillLB->Show();
-    m_pLbColor->Hide();
-    m_pLbGradient->Enable();
-    m_pLbGradient->Show();
-    m_pLbHatching->Hide();
-    m_pLbBitmap->Hide();
-    m_pCtlXRectPreview->Enable();
-    m_pCtlXRectPreview->Show();
-    m_pCtlBitmapPreview->Hide();
-
-    ModifyGradientHdl_Impl( *m_pLbGradient );
-}
-
-
-IMPL_LINK_NOARG(SvxAreaTabPage, ModifyGradientHdl_Impl, ListBox&, void)
+void SvxAreaTabPage::PageCreated(const SfxAllItemSet& aSet)
 {
-    const SfxPoolItem* pPoolItem = nullptr;
-    sal_Int32 _nPos = m_pLbGradient->GetSelectEntryPos();
-    if( _nPos != LISTBOX_ENTRY_NOTFOUND )
-    {
-        // fill ItemSet and pass it on to aCtlXRectPreview
-        const XGradientEntry* pEntry = m_pGradientList->GetGradient(_nPos);
-
-        m_rXFSet.Put( XFillStyleItem( drawing::FillStyle_GRADIENT ) );
-        m_rXFSet.Put( XFillGradientItem( OUString(), pEntry->GetGradient() ) );
-    }
-    else if( SfxItemState::SET == m_rOutAttrs.GetItemState( GetWhich( XATTR_FILLGRADIENT ), true, &pPoolItem ) )
-    {
-        m_rXFSet.Put( XFillStyleItem( drawing::FillStyle_GRADIENT ) );
-        m_rXFSet.Put( XFillGradientItem( OUString(), static_cast<const XFillGradientItem*>( pPoolItem )->GetGradientValue() ) );
-    }
-    else
-        m_rXFSet.Put( XFillStyleItem( drawing::FillStyle_NONE ) );
-
-    sal_uInt16 nValue = static_cast<const XGradientStepCountItem&>( m_rOutAttrs.Get( XATTR_GRADIENTSTEPCOUNT ) ).GetValue();
-    if( nValue == 0 )
-        nValue = DEFAULT_GRADIENTSTEP;
-    m_rXFSet.Put( XGradientStepCountItem( nValue ) );
+    const SvxColorListItem* pColorListItem = aSet.GetItem<SvxColorListItem>(SID_COLOR_TABLE, false);
+    const SvxGradientListItem* pGradientListItem = aSet.GetItem<SvxGradientListItem>(SID_GRADIENT_LIST, false);
+    const SvxHatchListItem* pHatchingListItem = aSet.GetItem<SvxHatchListItem>(SID_HATCH_LIST, false);
+    const SvxBitmapListItem* pBitmapListItem = aSet.GetItem<SvxBitmapListItem>(SID_BITMAP_LIST, false);
 
-    m_pCtlXRectPreview->SetAttributes( m_aXFillAttr.GetItemSet() );
-    m_pCtlXRectPreview->Invalidate();
+    if (pColorListItem)
+        SetColorList(pColorListItem->GetColorList());
+    if (pGradientListItem)
+        SetGradientList(pGradientListItem->GetGradientList());
+    if (pHatchingListItem)
+        SetHatchingList(pHatchingListItem->GetHatchList());
+    if (pBitmapListItem)
+        SetBitmapList(pBitmapListItem->GetBitmapList());
 }
 
-
-void SvxAreaTabPage::ClickHatchingHdl_Impl()
+void SvxAreaTabPage::PointChanged( vcl::Window* , RectPoint )
 {
-    m_pFillLB->Show();
-    m_pLbColor->Hide();
-    m_pLbGradient->Hide();
-    m_pLbHatching->Enable();
-    m_pLbHatching->Show();
-    m_pLbBitmap->Hide();
-    m_pCtlXRectPreview->Enable();
-    m_pCtlXRectPreview->Show();
-    m_pCtlBitmapPreview->Hide();
-
-    ModifyHatchingHdl_Impl( *m_pLbHatching );
 }
 
-IMPL_LINK_NOARG(SvxAreaTabPage, ModifyHatchingHdl_Impl, ListBox&, void)
+void SvxAreaTabPage::CreatePage( sal_Int32 nId, SfxTabPage& pTab )
 {
-    // fill Hatch ItemSet
-    const SfxPoolItem* pPoolItem = nullptr;
-    sal_Int32 _nPos = m_pLbHatching->GetSelectEntryPos();
-    if( _nPos != LISTBOX_ENTRY_NOTFOUND )
+    if(nId == SOLID )
     {
-        // fill ItemSet and pass it on to aCtlXRectPreview
-        const XHatchEntry* pEntry = m_pHatchingList->GetHatch(_nPos);
-
-        m_rXFSet.Put( XFillStyleItem( drawing::FillStyle_HATCH ) );
-        m_rXFSet.Put( XFillHatchItem( OUString(), pEntry->GetHatch() ) );
+        static_cast<SvxColorTabPage&>(pTab).SetColorList( m_pColorList );
+        static_cast<SvxColorTabPage&>(pTab).SetPos( &m_nPos );
+        static_cast<SvxColorTabPage&>(pTab).SetColorChgd( m_pnColorListState );
+        static_cast<SvxColorTabPage&>(pTab).Construct();
+        static_cast<SvxColorTabPage&>(pTab).ActivatePage( m_rXFSet );
+        static_cast<SvxColorTabPage&>(pTab).Reset(&m_rXFSet);
+        static_cast<SvxColorTabPage&>(pTab).Show();
     }
-    else if( SfxItemState::SET == m_rOutAttrs.GetItemState( GetWhich( XATTR_FILLHATCH ), true, &pPoolItem ) )
+    else if(nId == GRADIENT)
     {
-        m_rXFSet.Put( XFillStyleItem( drawing::FillStyle_HATCH ) );
-        m_rXFSet.Put( XFillHatchItem( OUString(), static_cast<const XFillHatchItem*>( pPoolItem )->GetHatchValue() ) );
+        static_cast<SvxGradientTabPage&>(pTab).SetColorList( m_pColorList );
+        static_cast<SvxGradientTabPage&>(pTab).SetGradientList( m_pGradientList );
+        static_cast<SvxGradientTabPage&>(pTab).SetPos( &m_nPos );
+        static_cast<SvxGradientTabPage&>(pTab).SetGrdChgd( m_pnGradientListState );
+        static_cast<SvxGradientTabPage&>(pTab).SetColorChgd( m_pnColorListState );
+        static_cast<SvxGradientTabPage&>(pTab).Construct();
+        static_cast<SvxGradientTabPage&>(pTab).ActivatePage( m_rXFSet );
+        static_cast<SvxGradientTabPage&>(pTab).Reset(&m_rXFSet);
+        static_cast<SvxGradientTabPage&>(pTab).Show();
     }
-    else
-        m_rXFSet.Put( XFillStyleItem( drawing::FillStyle_NONE ) );
-
-    // fill Hatch background ItemSet
-    XFillBackgroundItem aItem(static_cast<const XFillBackgroundItem&>(m_rOutAttrs.Get( XATTR_FILLBACKGROUND )));
-    aItem.SetWhich( XATTR_FILLBACKGROUND );
-    m_rXFSet.Put ( aItem );
-    if(aItem.GetValue())
+    else if(nId == HATCH)
     {
-        if( SfxItemState::SET == m_rOutAttrs.GetItemState( GetWhich( XATTR_FILLCOLOR ), true, &pPoolItem ) )
-        {
-            Color aColor( static_cast<const XFillColorItem*>( pPoolItem )->GetColorValue() );
-            m_rXFSet.Put( XFillColorItem( OUString(), aColor ) );
-        }
-        else
-            m_rXFSet.Put( XFillStyleItem( drawing::FillStyle_NONE ) );
+        static_cast<SvxHatchTabPage&>(pTab).SetColorList( m_pColorList );
+        static_cast<SvxHatchTabPage&>(pTab).SetHatchingList( m_pHatchingList );
+        static_cast<SvxHatchTabPage&>(pTab).SetPos(&m_nPos);
+        static_cast<SvxHatchTabPage&>(pTab).SetHtchChgd( m_pnHatchingListState );
+        static_cast<SvxHatchTabPage&>(pTab).SetColorChgd( m_pnColorListState );
+        static_cast<SvxHatchTabPage&>(pTab).Construct();
+        static_cast<SvxHatchTabPage&>(pTab).ActivatePage( m_rXFSet );
+        static_cast<SvxHatchTabPage&>(pTab).Reset(&m_rXFSet);
+        static_cast<SvxHatchTabPage&>(pTab).Show();
     }
-
-    m_pCtlXRectPreview->SetAttributes( m_aXFillAttr.GetItemSet() );
-    m_pCtlXRectPreview->Invalidate();
-}
-
-void SvxAreaTabPage::ClickBitmapHdl_Impl()
-{
-    m_pFillLB->Show();
-    m_pLbColor->Hide();
-    m_pLbGradient->Hide();
-    m_pLbHatching->Hide();
-    m_pLbBitmap->Show();
-    m_pCtlBitmapPreview->Enable();
-    m_pCtlBitmapPreview->Show();
-    m_pCtlXRectPreview->Hide();
-
-    ModifyBitmapHdl_Impl( *m_pLbBitmap );
-}
-
-
-IMPL_LINK_NOARG(SvxAreaTabPage, ModifyBitmapHdl_Impl, ListBox&, void)
-{
-    const SfxPoolItem* pPoolItem = nullptr;
-    sal_Int32 _nPos = m_pLbBitmap->GetSelectEntryPos();
-    if( _nPos != LISTBOX_ENTRY_NOTFOUND )
+    else if(nId == BITMAP)
     {
-        // fill ItemSet and pass it on to aCtlXRectPreview
-        const XBitmapEntry* pEntry = m_pBitmapList->GetBitmap(_nPos);
-
-        m_rXFSet.Put(XFillStyleItem(drawing::FillStyle_BITMAP));
-        m_rXFSet.Put(XFillBitmapItem(OUString(), pEntry->GetGraphicObject()));
+        static_cast<SvxBitmapTabPage&>(pTab).SetBitmapList( m_pBitmapList );
+        static_cast<SvxBitmapTabPage&>(pTab).SetPos( &m_nPos );
+        static_cast<SvxBitmapTabPage&>(pTab).SetBmpChgd( m_pnBitmapListState );
+        static_cast<SvxBitmapTabPage&>(pTab).Construct();
+        static_cast<SvxBitmapTabPage&>(pTab).ActivatePage( m_rXFSet );
+        static_cast<SvxBitmapTabPage&>(pTab).Reset(&m_rXFSet);
+        static_cast<SvxBitmapTabPage&>(pTab).Show();
     }
-    else if( SfxItemState::SET == m_rOutAttrs.GetItemState( GetWhich( XATTR_FILLBITMAP ), true, &pPoolItem ) )
+    else if(nId == PATTERN)
     {
-        m_rXFSet.Put(XFillStyleItem(drawing::FillStyle_BITMAP));
-        m_rXFSet.Put(XFillBitmapItem(OUString(), static_cast<const XFillBitmapItem*>(pPoolItem)->GetGraphicObject()));
+        static_cast<SvxPatternTabPage&>(pTab).SetColorList( m_pColorList );
+        static_cast<SvxPatternTabPage&>(pTab).SetPatternList( m_pPatternList );
+        static_cast<SvxPatternTabPage&>(pTab).SetPos( &m_nPos );
+        static_cast<SvxPatternTabPage&>(pTab).SetPtrnChgd( m_pnPatternListState );
+        static_cast<SvxPatternTabPage&>(pTab).SetColorChgd( m_pnColorListState );
+        static_cast<SvxPatternTabPage&>(pTab).Construct();
+        static_cast<SvxPatternTabPage&>(pTab).ActivatePage( m_rXFSet );
+        static_cast<SvxPatternTabPage&>(pTab).Reset( &m_rXFSet );
+        static_cast<SvxPatternTabPage&>(pTab).Show();
     }
-    else
-        m_rXFSet.Put( XFillStyleItem( drawing::FillStyle_NONE ) );
-
-    m_pCtlBitmapPreview->SetAttributes( m_aXFillAttr.GetItemSet() );
-    m_pCtlBitmapPreview->Invalidate();
-}
-
-void SvxAreaTabPage::PointChanged( vcl::Window* , RectPoint )
-{
-}
-
-void SvxAreaTabPage::PageCreated(const SfxAllItemSet& aSet)
-{
-    const SvxColorListItem* pColorListItem = aSet.GetItem<SvxColorListItem>(SID_COLOR_TABLE, false);
-    const SvxGradientListItem* pGradientListItem = aSet.GetItem<SvxGradientListItem>(SID_GRADIENT_LIST, false);
-    const SvxHatchListItem* pHatchingListItem = aSet.GetItem<SvxHatchListItem>(SID_HATCH_LIST, false);
-    const SvxBitmapListItem* pBitmapListItem = aSet.GetItem<SvxBitmapListItem>(SID_BITMAP_LIST, false);
-    const SfxUInt16Item* pPageTypeItem = aSet.GetItem<SfxUInt16Item>(SID_PAGE_TYPE, false);
-    const SfxUInt16Item* pDlgTypeItem = aSet.GetItem<SfxUInt16Item>(SID_DLG_TYPE, false);
-    const SfxUInt16Item* pPosItem = aSet.GetItem<SfxUInt16Item>(SID_TABPAGE_POS, false);
-
-    if (pColorListItem)
-        SetColorList(pColorListItem->GetColorList());
-    if (pGradientListItem)
-        SetGradientList(pGradientListItem->GetGradientList());
-    if (pHatchingListItem)
-        SetHatchingList(pHatchingListItem->GetHatchList());
-    if (pBitmapListItem)
-        SetBitmapList(pBitmapListItem->GetBitmapList());
-    if (pPageTypeItem)
-        SetPageType((PageType) pPageTypeItem->GetValue());
-    if (pDlgTypeItem)
-        SetDlgType(pDlgTypeItem->GetValue());
-    if (pPosItem)
-        SetPos(pPosItem->GetValue());
-
-    Construct();
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cui/source/tabpages/tpbitmap.cxx b/cui/source/tabpages/tpbitmap.cxx
index 55f8ea5..a462892 100644
--- a/cui/source/tabpages/tpbitmap.cxx
+++ b/cui/source/tabpages/tpbitmap.cxx
@@ -84,15 +84,12 @@ SvxBitmapTabPage::SvxBitmapTabPage( vcl::Window* pParent, const SfxItemSet& rInA
     m_aXBitmapItem( OUString(), Graphic() ),
     m_fObjectWidth(0.0),
     m_fObjectHeight(0.0),
-    m_nPageType(nullptr),
-    m_nDlgType(0),
-    m_nPos(nullptr),
-
-    m_pbAreaTP( nullptr ),
+    m_pPos(nullptr),
 
     m_aXFillAttr          ( rInAttrs.GetPool() ),
     m_rXFSet              ( m_aXFillAttr.GetItemSet() ),
     mpView(nullptr),
+    meDlgUnit(GetModuleFieldUnit( GetItemSet() )),
     nFilledWidthPercent(0),
     nFilledHeightPercent(0),
     nZoomedWidthPercent(0),
@@ -185,18 +182,12 @@ void SvxBitmapTabPage::Construct()
 
 void SvxBitmapTabPage::ActivatePage( const SfxItemSet& )
 {
-    if( m_nDlgType == 0 ) // area dialog
+    if( *m_pPos != LISTBOX_ENTRY_NOTFOUND )
     {
-        *m_pbAreaTP = false;
-
-        if( *m_nPageType == PageType::Bitmap && *m_nPos != LISTBOX_ENTRY_NOTFOUND )
-        {
-            sal_uInt16 nId = m_pBitmapLB->GetItemId( static_cast<size_t>( *m_nPos ) );
-            m_pBitmapLB->SelectItem(nId);
-        }
-        *m_nPageType = PageType::Bitmap;
-        *m_nPos = LISTBOX_ENTRY_NOTFOUND;
+        sal_uInt16 nId = m_pBitmapLB->GetItemId( static_cast<size_t>( *m_pPos ) );
+        m_pBitmapLB->SelectItem(nId);
     }
+    *m_pPos = LISTBOX_ENTRY_NOTFOUND;
 }
 
 
@@ -211,80 +202,73 @@ DeactivateRC SvxBitmapTabPage::DeactivatePage( SfxItemSet* _pSet )
 
 bool SvxBitmapTabPage::FillItemSet( SfxItemSet* rAttrs )
 {
-    if( m_nDlgType == 0 && !*m_pbAreaTP )
+    rAttrs->Put(XFillStyleItem(drawing::FillStyle_BITMAP));
+    size_t nPos = m_pBitmapLB->GetSelectItemPos();
+    if(VALUESET_ITEM_NOTFOUND != nPos)
     {
-        if(PageType::Bitmap == *m_nPageType)
-        {
-            rAttrs->Put(XFillStyleItem(drawing::FillStyle_BITMAP));
-            size_t nPos = m_pBitmapLB->GetSelectItemPos();
-            if(VALUESET_ITEM_NOTFOUND != nPos)
-            {
-                const XBitmapEntry* pXBitmapEntry = m_pBitmapList->GetBitmap(nPos);
-                const OUString aString(m_pBitmapLB->GetItemText( m_pBitmapLB->GetSelectItemId() ));
-                rAttrs->Put(XFillBitmapItem(aString, pXBitmapEntry->GetGraphicObject()));
-            }
+        const XBitmapEntry* pXBitmapEntry = m_pBitmapList->GetBitmap(nPos);
+        const OUString aString(m_pBitmapLB->GetItemText( m_pBitmapLB->GetSelectItemId() ));
+        rAttrs->Put(XFillBitmapItem(aString, pXBitmapEntry->GetGraphicObject()));
+    }
 
-            BitmapStyle eStylePos = (BitmapStyle)m_pBitmapStyleLB->GetSelectEntryPos();
-            bool bIsStretched( eStylePos == STRETCHED );
-            bool bIsTiled( eStylePos == TILED );
+    BitmapStyle eStylePos = (BitmapStyle)m_pBitmapStyleLB->GetSelectEntryPos();        bool bIsStretched( eStylePos == STRETCHED );
+    bool bIsTiled( eStylePos == TILED );
 
-            rAttrs->Put( XFillBmpTileItem(bIsTiled) );
-            rAttrs->Put( XFillBmpStretchItem(bIsStretched) );
+    rAttrs->Put( XFillBmpTileItem(bIsTiled) );
+    rAttrs->Put( XFillBmpStretchItem(bIsStretched) );
 
-            if(!bIsStretched)
+    if(!bIsStretched)
+    {
+        Size aSetBitmapSize;
+        switch(eStylePos)
+        {
+            case ORIGINAL:
+                aSetBitmapSize = rBitmapSize;
+                break;
+            case FILLED:
+                aSetBitmapSize = rFilledSize;
+                break;
+            case ZOOMED:
+                aSetBitmapSize = rZoomedSize;
+                break;
+            case CUSTOM:
+            case TILED:
             {
-                Size aSetBitmapSize;
-                switch(eStylePos)
+                sal_Int64 nWidthPercent = m_pBitmapWidth->Denormalize(m_pBitmapWidth->GetValue());
+                sal_Int64 nHeightPercent = m_pBitmapHeight->Denormalize(m_pBitmapHeight->GetValue());
+                if(eStylePos == CUSTOM && m_pTsbScale->IsEnabled() && m_pTsbScale->GetState() == TRISTATE_TRUE)
                 {
-                    case ORIGINAL:
-                        aSetBitmapSize = rBitmapSize;
-                        break;
-                    case FILLED:
-                        aSetBitmapSize = rFilledSize;
-                        break;
-                    case ZOOMED:
-                        aSetBitmapSize = rZoomedSize;
-                        break;
-                    case CUSTOM:
-                    case TILED:
-                    {
-                        sal_Int64 nWidthPercent = m_pBitmapWidth->Denormalize(m_pBitmapWidth->GetValue());
-                        sal_Int64 nHeightPercent = m_pBitmapHeight->Denormalize(m_pBitmapHeight->GetValue());
-                        if(eStylePos == CUSTOM && m_pTsbScale->IsEnabled() && m_pTsbScale->GetState() == TRISTATE_TRUE)
-                        {
-                            aSetBitmapSize.Width() = -nWidthPercent;
-                            aSetBitmapSize.Height() = -nHeightPercent;
-                        }
-                        else
-                        {
-                            aSetBitmapSize.Width() = static_cast<long>(nWidthPercent*rBitmapSize.Width()/100);
-                            aSetBitmapSize.Height() = static_cast<long>(nHeightPercent*rBitmapSize.Height()/100);
-                        }
-                        break;
-                    }
-                    default:
-                        break;
+                    aSetBitmapSize.Width() = -nWidthPercent;
+                    aSetBitmapSize.Height() = -nHeightPercent;
                 }
-                rAttrs->Put( XFillBmpSizeXItem( aSetBitmapSize.Width() ) );
-                rAttrs->Put( XFillBmpSizeYItem( aSetBitmapSize.Height() ) );
-            }
-
-            if(m_pPositionLB->IsEnabled())
-                rAttrs->Put( XFillBmpPosItem( static_cast<RectPoint>( m_pPositionLB->GetSelectEntryPos() ) ) );
-            if(m_pPositionOffX->IsEnabled())
-                rAttrs->Put( XFillBmpPosOffsetXItem( m_pPositionOffX->GetValue() ) );
-            if(m_pPositionOffY->IsEnabled())
-                rAttrs->Put( XFillBmpPosOffsetYItem( m_pPositionOffY->GetValue() ) );
-            if(m_pTileOffBox->IsEnabled())
-            {
-                TileOffset eValue = static_cast<TileOffset>(m_pTileOffLB->GetSelectEntryPos());
-                sal_uInt16 nOffsetValue = static_cast<sal_uInt16>(m_pTileOffset->GetValue());
-                sal_uInt16 nRowOff = (eValue == ROW) ? nOffsetValue : 0;
-                sal_uInt16 nColOff = (eValue == COLUMN) ? nOffsetValue : 0;
-                rAttrs->Put( XFillBmpTileOffsetXItem(nRowOff) );
-                rAttrs->Put( XFillBmpTileOffsetYItem(nColOff) );
+                else
+                {
+                    aSetBitmapSize.Width() = static_cast<long>(nWidthPercent*rBitmapSize.Width()/100);
+                    aSetBitmapSize.Height() = static_cast<long>(nHeightPercent*rBitmapSize.Height()/100);
+                }
+                break;
             }
+            default:
+                break;
         }
+        rAttrs->Put( XFillBmpSizeXItem( aSetBitmapSize.Width() ) );
+        rAttrs->Put( XFillBmpSizeYItem( aSetBitmapSize.Height() ) );
+    }
+
+    if(m_pPositionLB->IsEnabled())
+        rAttrs->Put( XFillBmpPosItem( static_cast<RectPoint>( m_pPositionLB->GetSelectEntryPos() ) ) );
+    if(m_pPositionOffX->IsEnabled())
+        rAttrs->Put( XFillBmpPosOffsetXItem( m_pPositionOffX->GetValue() ) );
+    if(m_pPositionOffY->IsEnabled())
+        rAttrs->Put( XFillBmpPosOffsetYItem( m_pPositionOffY->GetValue() ) );
+    if(m_pTileOffBox->IsEnabled())
+    {
+        TileOffset eValue = static_cast<TileOffset>(m_pTileOffLB->GetSelectEntryPos());
+        sal_uInt16 nOffsetValue = static_cast<sal_uInt16>(m_pTileOffset->GetValue());
+        sal_uInt16 nRowOff = (eValue == ROW) ? nOffsetValue : 0;
+        sal_uInt16 nColOff = (eValue == COLUMN) ? nOffsetValue : 0;
+        rAttrs->Put( XFillBmpTileOffsetXItem(nRowOff) );
+        rAttrs->Put( XFillBmpTileOffsetYItem(nColOff) );
     }
     return true;
 }
@@ -505,7 +489,7 @@ IMPL_LINK_NOARG(SvxBitmapTabPage, ModifyBitmapHdl, ValueSet*, void)
 
     if( nPos != VALUESET_ITEM_NOTFOUND )
     {
-        pGraphicObject.reset(new GraphicObject(m_pBitmapList->GetBitmap(nPos)->GetGraphicObject()));
+        pGraphicObject.reset(new GraphicObject(m_pBitmapList->GetBitmap( static_cast<sal_uInt16>(nPos) )->GetGraphicObject()));
     }
     else
     {
@@ -604,7 +588,7 @@ IMPL_LINK_NOARG(SvxBitmapTabPage, ClickDeleteHdl, SvxPresetListBox*, void)
 
         if( aQueryBox->Execute() == RET_YES )
         {
-            m_pBitmapList->Remove(nPos);
+            m_pBitmapList->Remove( static_cast<sal_uInt16>(nPos) );
             m_pBitmapLB->RemoveItem( nId );
             nId = m_pBitmapLB->GetItemId(0);
             m_pBitmapLB->SelectItem( nId );
diff --git a/cui/source/tabpages/tpcolor.cxx b/cui/source/tabpages/tpcolor.cxx
index 36abaf5..9f06f9c 100644
--- a/cui/source/tabpages/tpcolor.cxx
+++ b/cui/source/tabpages/tpcolor.cxx
@@ -59,10 +59,7 @@ SvxColorTabPage::SvxColorTabPage(vcl::Window* pParent, const SfxItemSet& rInAttr
     , rOutAttrs           ( rInAttrs )
     // All the horrific pointers we store and should not
     , pnColorListState( nullptr )
-    , pPageType( nullptr )
-    , nDlgType( 0 )
     , pPos( nullptr )
-    , pbAreaTP( nullptr )
     , aXFStyleItem( drawing::FillStyle_SOLID )
     , aXFillColorItem( OUString(), Color( COL_BLACK ) )
     , aXFillAttr( static_cast<XOutdevItemPool*>( rInAttrs.GetPool() ))
@@ -238,47 +235,40 @@ void SvxColorTabPage::Construct()
 
 void SvxColorTabPage::ActivatePage( const SfxItemSet& )
 {
-    if( nDlgType == 0 ) // area dialog
+    if( pColorList.is() )
     {
-        *pbAreaTP = false;
-
-        if( pColorList.is() )
+        if( *pPos != LISTBOX_ENTRY_NOTFOUND )
         {
-            if( *pPageType == PageType::Color && *pPos != LISTBOX_ENTRY_NOTFOUND )
-            {
-                m_pValSetColorList->SelectItem( m_pValSetColorList->GetItemId( static_cast<size_t>(*pPos) ) );
-                const XColorEntry* pEntry = pColorList->GetColor(*pPos);
-                aPreviousColor = pEntry->GetColor();
-                ChangeColor(pEntry->GetColor());
-            }
-            else if( *pPageType == PageType::Color && *pPos == LISTBOX_ENTRY_NOTFOUND )
+            m_pValSetColorList->SelectItem( m_pValSetColorList->GetItemId( static_cast<size_t>(*pPos) ) );
+            const XColorEntry* pEntry = pColorList->GetColor(*pPos);
+            aPreviousColor = pEntry->GetColor();
+            ChangeColor(pEntry->GetColor());
+        }
+        else if( *pPos == LISTBOX_ENTRY_NOTFOUND )
+        {
+            const SfxPoolItem* pPoolItem = nullptr;
+            if( SfxItemState::SET == rOutAttrs.GetItemState( GetWhich( XATTR_FILLCOLOR ), true, &pPoolItem ) )
             {
-                const SfxPoolItem* pPoolItem = nullptr;
-                if( SfxItemState::SET == rOutAttrs.GetItemState( GetWhich( XATTR_FILLCOLOR ), true, &pPoolItem ) )
-                {
-                    SetColorModel( ColorModel::RGB );
-                    ChangeColorModel();
-
-                    aPreviousColor = static_cast<const XFillColorItem*>(pPoolItem)->GetColorValue();
-                    ChangeColor( aPreviousColor );
+                SetColorModel( ColorModel::RGB );
+                ChangeColorModel();
 
+                aPreviousColor = static_cast<const XFillColorItem*>(pPoolItem)->GetColorValue();
+                ChangeColor( aPreviousColor );
 
-                    m_pRcustom->SetValue( ColorToPercent_Impl( aCurrentColor.GetRed() ) );
-                    m_pGcustom->SetValue( ColorToPercent_Impl( aCurrentColor.GetGreen() ) );
-                    m_pBcustom->SetValue( ColorToPercent_Impl( aCurrentColor.GetBlue() ) );
-                    m_pHexcustom->SetColor( aCurrentColor.GetColor() );
+                m_pRcustom->SetValue( ColorToPercent_Impl( aCurrentColor.GetRed() ) );
+                m_pGcustom->SetValue( ColorToPercent_Impl( aCurrentColor.GetGreen() ) );
+                m_pBcustom->SetValue( ColorToPercent_Impl( aCurrentColor.GetBlue() ) );
+                m_pHexcustom->SetColor( aCurrentColor.GetColor() );
 
-                }
             }
+        }
 
-            m_pCtlPreviewOld->SetAttributes( aXFillAttr.GetItemSet() );
-            m_pCtlPreviewOld->Invalidate();
+        m_pCtlPreviewOld->SetAttributes( aXFillAttr.GetItemSet() );
+        m_pCtlPreviewOld->Invalidate();
 
-            SelectValSetHdl_Impl( m_pValSetColorList );
+        SelectValSetHdl_Impl( m_pValSetColorList );
 
-            *pPageType = PageType::Color;
-            *pPos = LISTBOX_ENTRY_NOTFOUND;
-        }
+        *pPos = LISTBOX_ENTRY_NOTFOUND;
     }
 }
 
@@ -293,13 +283,9 @@ DeactivateRC SvxColorTabPage::DeactivatePage( SfxItemSet* _pSet )
 
 bool SvxColorTabPage::FillItemSet( SfxItemSet* rSet )
 {
-    if( ( nDlgType != 0 ) ||
-        ( *pPageType == PageType::Color && !*pbAreaTP ) )
-    {
-        maPaletteManager.AddRecentColor(aCurrentColor, "#" + aCurrentColor.AsRGBHexString().toAsciiUpperCase());
-        rSet->Put( XFillColorItem( OUString(), aCurrentColor ) );
-        rSet->Put( XFillStyleItem( drawing::FillStyle_SOLID ) );
-    }
+    maPaletteManager.AddRecentColor( aCurrentColor, OUString() );
+    rSet->Put( XFillColorItem( OUString(), aCurrentColor ) );
+    rSet->Put( XFillStyleItem( drawing::FillStyle_SOLID ) );
     return true;
 }
 
@@ -774,6 +760,46 @@ void SvxColorTabPage::FillUserData()
 }
 
 
+void SvxColorTabPage::SetupForViewFrame( SfxViewFrame *pViewFrame )
+{
+    const OfaRefItem<XColorList> *pPtr = nullptr;
+    if ( pViewFrame != nullptr && pViewFrame->GetDispatcher() )
+        pPtr = static_cast<const OfaRefItem<XColorList> *>(pViewFrame->
+            GetDispatcher()->Execute( SID_GET_COLORLIST,
+                                      SfxCallMode::SYNCHRON ));
+    pColorList = pPtr ? pPtr->GetValue() : XColorList::GetStdColorList();
+
+    //SetPos( &pShadow->nUnknownPos );
+    //SetColorChgd( &pShadow->nChangeType );
+    Construct();
+}
+
+void SvxColorTabPage::SaveToViewFrame( SfxViewFrame *pViewFrame )
+{
+    if( !pColorList.is() )
+        return;
+
+    if( !pViewFrame )
+        return;
+
+    // notify current viewframe that it uses the same color table
+    if ( !pViewFrame->GetDispatcher() )
+        return;
+
+    const OfaRefItem<XColorList> * pPtr;
+    pPtr = static_cast<const OfaRefItem<XColorList>*>(pViewFrame->GetDispatcher()->Execute( SID_GET_COLORLIST, SfxCallMode::SYNCHRON ));
+    if( pPtr )
+    {
+        XColorListRef pReference = pPtr->GetValue();
+
+        if( pReference.is() &&
+            pReference->GetPath() == pColorList->GetPath() &&
+            pReference->GetName() == pColorList->GetName() )
+            SfxObjectShell::Current()->PutItem( SvxColorListItem( pColorList,
+                                                                  SID_COLOR_TABLE ) );
+    }
+}
+
 void SvxColorTabPage::SetPropertyList( XPropertyListType t, const XPropertyListRef &xRef )
 {
     (void) t;
diff --git a/cui/source/tabpages/tpgradnt.cxx b/cui/source/tabpages/tpgradnt.cxx
index 11effdd..d1b50c7 100644
--- a/cui/source/tabpages/tpgradnt.cxx
+++ b/cui/source/tabpages/tpgradnt.cxx
@@ -58,10 +58,7 @@ SvxGradientTabPage::SvxGradientTabPage
 
     m_pnGradientListState ( nullptr ),
     m_pnColorListState    ( nullptr ),
-    m_pPageType           ( nullptr ),
-    m_nDlgType            ( 0 ),
     m_pPos                ( nullptr ),
-    m_pbAreaTP            ( nullptr ),
 
     m_aXFStyleItem        ( drawing::FillStyle_GRADIENT ),
     m_aXGradientItem      ( OUString(), XGradient( COL_BLACK, COL_WHITE ) ),
@@ -176,78 +173,73 @@ void SvxGradientTabPage::Construct()
 }
 
 
-void SvxGradientTabPage::ActivatePage( const SfxItemSet&  )
+void SvxGradientTabPage::ActivatePage( const SfxItemSet& rSet )
 {
     sal_Int32 nPos;
     sal_Int32 nCount;
 
-    if( m_nDlgType == 0 ) // area dialog
+    if( m_pColorList.is() )
     {
-        *m_pbAreaTP = false;
-
-        if( m_pColorList.is() )
+        // ColorList
+        if( *m_pnColorListState & ChangeType::CHANGED ||
+            *m_pnColorListState & ChangeType::MODIFIED )
         {
-            // ColorList
-            if( *m_pnColorListState & ChangeType::CHANGED ||
-                *m_pnColorListState & ChangeType::MODIFIED )
-            {
-                if( *m_pnColorListState & ChangeType::CHANGED )
-                    m_pColorList = static_cast<SvxAreaTabDialog*>( GetParentDialog() )->GetNewColorList();
-
-                // LbColorFrom
-                nPos = m_pLbColorFrom->GetSelectEntryPos();
-                m_pLbColorFrom->Clear();
-                m_pLbColorFrom->Fill( m_pColorList );
-                nCount = m_pLbColorFrom->GetEntryCount();
-                if( nCount == 0 )
-                    ; // this case should not occur
-                else if( nCount <= nPos )
-                    m_pLbColorFrom->SelectEntryPos( 0 );
-                else
-                    m_pLbColorFrom->SelectEntryPos( nPos );
-
-                // LbColorTo
-                nPos = m_pLbColorTo->GetSelectEntryPos();
-                m_pLbColorTo->Clear();
-                m_pLbColorTo->CopyEntries( *m_pLbColorFrom );
-                nCount = m_pLbColorTo->GetEntryCount();
-                if( nCount == 0 )
-                    ; // this case should not occur
-                else if( nCount <= nPos )
-                    m_pLbColorTo->SelectEntryPos( 0 );
-                else
-                    m_pLbColorTo->SelectEntryPos( nPos );
-
-                ModifiedHdl_Impl( this );
-            }
+            if( *m_pnColorListState & ChangeType::CHANGED )
+                m_pColorList = static_cast<SvxAreaTabDialog*>( GetParentDialog() )->GetNewColorList();
+
+            // LbColorFrom
+            nPos = m_pLbColorFrom->GetSelectEntryPos();
+            m_pLbColorFrom->Clear();
+            m_pLbColorFrom->Fill( m_pColorList );
+            nCount = m_pLbColorFrom->GetEntryCount();
+            if( nCount == 0 )
+                ; // this case should not occur
+            else if( nCount <= nPos )
+                m_pLbColorFrom->SelectEntryPos( 0 );
+            else
+                m_pLbColorFrom->SelectEntryPos( nPos );
+
+            // LbColorTo
+            nPos = m_pLbColorTo->GetSelectEntryPos();
+            m_pLbColorTo->Clear();
+            m_pLbColorTo->CopyEntries( *m_pLbColorFrom );
+            nCount = m_pLbColorTo->GetEntryCount();
+            if( nCount == 0 )
+                ; // this case should not occur
+            else if( nCount <= nPos )
+                m_pLbColorTo->SelectEntryPos( 0 );
+            else
+                m_pLbColorTo->SelectEntryPos( nPos );
 
-            // determining (and possibly cutting) the name and
-            // displaying it in the GroupBox
-            OUString        aString( CUI_RES( RID_SVXSTR_TABLE ) );
-            aString         += ": ";
-            INetURLObject   aURL( m_pGradientList->GetPath() );
+            ModifiedHdl_Impl( this );
+        }
 
-            aURL.Append( m_pGradientList->GetName() );
-            SAL_WARN_IF( aURL.GetProtocol() == INetProtocol::NotValid, "cui.tabpages", "invalid URL" );
+        // determining (and possibly cutting) the name and
+        // displaying it in the GroupBox
+        OUString        aString( CUI_RES( RID_SVXSTR_TABLE ) );
+        aString         += ": ";
+        INetURLObject   aURL( m_pGradientList->GetPath() );
 
-            if ( aURL.getBase().getLength() > 18 )
-            {
-                aString += aURL.getBase().copy( 0, 15 ) + "...";
-            }
-            else
-                aString += aURL.getBase();
+        aURL.Append( m_pGradientList->GetName() );
+        SAL_WARN_IF( aURL.GetProtocol() == INetProtocol::NotValid, "cui.tabpages", "invalid URL" );
 
-            if ( *m_pPageType == PageType::Gradient && *m_pPos != LISTBOX_ENTRY_NOTFOUND )
-            {
-                sal_uInt16 nId = m_pGradientLB->GetItemId( static_cast<size_t>( *m_pPos ) );
-                m_pGradientLB->SelectItem( nId );
-            }
-            // colors could have been deleted
-            ChangeGradientHdl_Impl();
+        if ( aURL.getBase().getLength() > 18 )
+        {
+            aString += aURL.getBase().copy( 0, 15 ) + "...";
+        }
+        else
+            aString += aURL.getBase();
 
-            *m_pPageType = PageType::Gradient;
-            *m_pPos = LISTBOX_ENTRY_NOTFOUND;
+        *m_pPos = SearchGradientList( ( &static_cast<const XFillGradientItem&>( rSet.Get(XATTR_FILLGRADIENT) ) )->GetName() );
+        if ( *m_pPos != LISTBOX_ENTRY_NOTFOUND )
+        {
+            sal_uInt16 nId = m_pGradientLB->GetItemId( static_cast<size_t>( *m_pPos ) );
+            m_pGradientLB->SelectItem( nId );
         }
+        // colors could have been deleted
+        ChangeGradientHdl_Impl();
+
+        *m_pPos = LISTBOX_ENTRY_NOTFOUND;
     }
 }
 
@@ -260,12 +252,81 @@ DeactivateRC SvxGradientTabPage::DeactivatePage( SfxItemSet* _pSet )
     return DeactivateRC::LeavePage;
 }
 
+long SvxGradientTabPage::CheckChanges_Impl()
+{
+    // is used here in order to NOT lose changes
+    XGradient aTmpGradient( m_pLbColorFrom->GetSelectEntryColor(),
+                          m_pLbColorTo->GetSelectEntryColor(),
+                          (css::awt::GradientStyle) m_pLbGradientType->GetSelectEntryPos(),
+                          static_cast<long>(m_pMtrAngle->GetValue() * 10), // should be changed in resource
+                          (sal_uInt16) m_pMtrCenterX->GetValue(),
+                          (sal_uInt16) m_pMtrCenterY->GetValue(),
+                          (sal_uInt16) m_pMtrBorder->GetValue(),
+                          (sal_uInt16) m_pMtrColorFrom->GetValue(),
+                          (sal_uInt16) m_pMtrColorTo->GetValue() );
+
+    size_t nPos = m_pGradientLB->GetSelectItemPos();
+    if( nPos != VALUESET_ITEM_NOTFOUND )
+    {
+        XGradient aGradient = m_pGradientList->GetGradient( static_cast<sal_uInt16>(nPos) )->GetGradient();
+
+        if( !( aTmpGradient == aGradient ) )
+        {
+            ResMgr& rMgr = CUI_MGR();
+            Image aWarningBoxImage = WarningBox::GetStandardImage();
+            ScopedVclPtrInstance<SvxMessDialog> aMessDlg( GetParentDialog(),
+                                                          SVX_RESSTR( RID_SVXSTR_GRADIENT ),
+                                                          CUI_RESSTR( RID_SVXSTR_ASK_CHANGE_GRADIENT ),
+                                                          &aWarningBoxImage );
+            assert(aMessDlg && "Dialog creation failed!");
+            aMessDlg->SetButtonText( SvxMessDialogButton::N1,
+                                    OUString( ResId( RID_SVXSTR_CHANGE, rMgr ) ) );
+            aMessDlg->SetButtonText( SvxMessDialogButton::N2,
+                                    OUString( ResId( RID_SVXSTR_ADD, rMgr ) ) );
+
+            short nRet = aMessDlg->Execute();
+
+            switch( nRet )
+            {
+                case RET_BTN_1:
+                {
+                    ClickModifyHdl_Impl( nullptr );
+                }
+                break;
+
+                case RET_BTN_2:
+                {
+                    ClickAddHdl_Impl( nullptr );
+                }
+                break;
+
+                case RET_CANCEL:
+                break;
+            }
+        }
+    }
+    nPos = m_pGradientLB->GetSelectItemPos();
+    if( nPos != VALUESET_ITEM_NOTFOUND )
+    {
+        *m_pPos = static_cast<sal_Int32>(nPos);
+    }
+    return 0L;
+}
+
 
 bool SvxGradientTabPage::FillItemSet( SfxItemSet* rSet )
 {
-    if( m_nDlgType == 0 && *m_pPageType == PageType::Gradient && !*m_pbAreaTP )
+    std::unique_ptr<XGradient> pXGradient;
+    OUString      aString;
+    size_t        nPos = m_pGradientLB->GetSelectItemPos();
+    if( nPos != VALUESET_ITEM_NOTFOUND )
+    {
+        pXGradient.reset(new XGradient( m_pGradientList->GetGradient( static_cast<sal_uInt16>(nPos) )->GetGradient() ));
+        aString = m_pGradientLB->GetItemText( m_pGradientLB->GetSelectItemId() );
+    }
+    else
+    // gradient was passed (unidentified)
     {
-        std::unique_ptr<XGradient> pXGradient;
         pXGradient.reset(new XGradient( m_pLbColorFrom->GetSelectEntryColor(),
                     m_pLbColorTo->GetSelectEntryColor(),
                     (css::awt::GradientStyle) m_pLbGradientType->GetSelectEntryPos(),
@@ -275,25 +336,16 @@ bool SvxGradientTabPage::FillItemSet( SfxItemSet* rSet )
                     (sal_uInt16) m_pMtrBorder->GetValue(),
                     (sal_uInt16) m_pMtrColorFrom->GetValue(),
                     (sal_uInt16) m_pMtrColorTo->GetValue() ));
+    }
 
-        OUString      aString;
-        size_t        nPos = m_pGradientLB->GetSelectItemPos();
-        if( nPos != VALUESET_ITEM_NOTFOUND )
-        {
-            XGradient aTmpGradient = m_pGradientList->GetGradient( static_cast<sal_uInt16>(nPos) )->GetGradient();
-            if( *pXGradient ==  aTmpGradient )
-                aString = m_pGradientLB->GetItemText( m_pGradientLB->GetSelectItemId() );
-        }
-
-        sal_uInt16 nValue = 0;
-        if( !m_pCbIncrement->IsChecked() )
-            nValue = m_pMtrIncrement->GetValue();
+    sal_uInt16 nValue = 0;
+    if( !m_pCbIncrement->IsChecked() )
+        nValue = m_pMtrIncrement->GetValue();
 
-        assert( pXGradient && "XGradient could not be created" );
-        rSet->Put( XFillStyleItem( drawing::FillStyle_GRADIENT ) );
-        rSet->Put( XFillGradientItem( aString, *pXGradient ) );
-        rSet->Put( XGradientStepCountItem( nValue ) );
-    }
+    assert( pXGradient && "XGradient could not be created" );
+    rSet->Put( XFillStyleItem( drawing::FillStyle_GRADIENT ) );
+    rSet->Put( XFillGradientItem( aString, *pXGradient ) );
+    rSet->Put( XGradientStepCountItem( nValue ) );
     return true;
 }
 
@@ -473,7 +525,7 @@ IMPL_LINK_NOARG(SvxGradientTabPage, ClickModifyHdl_Impl, Button*, void)
 
     if ( nPos != VALUESET_ITEM_NOTFOUND )
     {
-        OUString aName(m_pGradientList->GetGradient(nPos)->GetName());
+        OUString aName( m_pGradientList->GetGradient( static_cast<sal_uInt16>(nPos) )->GetName() );
 
         XGradient aXGradient( m_pLbColorFrom->GetSelectEntryColor(),
                               m_pLbColorTo->GetSelectEntryColor(),
@@ -487,7 +539,7 @@ IMPL_LINK_NOARG(SvxGradientTabPage, ClickModifyHdl_Impl, Button*, void)
 
         m_pGradientList->Replace(o3tl::make_unique<XGradientEntry>(aXGradient, aName), nPos);
 
-        Bitmap aBitmap = m_pGradientList->GetBitmapForPreview(nPos, m_pGradientLB->GetIconSize());
+        Bitmap aBitmap = m_pGradientList->GetBitmapForPreview( static_cast<sal_uInt16>(nPos), m_pGradientLB->GetIconSize() );
         m_pGradientLB->RemoveItem( nId );
         m_pGradientLB->InsertItem( nId, Image(aBitmap), aName, static_cast<sal_uInt16>(nPos) );
         m_pGradientLB->SelectItem( nId );
@@ -579,7 +631,7 @@ void SvxGradientTabPage::ChangeGradientHdl_Impl()
     size_t nPos = m_pGradientLB->GetSelectItemPos();
 
     if( nPos != VALUESET_ITEM_NOTFOUND )
-        pGradient.reset(new XGradient(m_pGradientList->GetGradient(nPos)->GetGradient()));
+        pGradient.reset(new XGradient( m_pGradientList->GetGradient( static_cast<sal_uInt16>( nPos ) )->GetGradient() ));
     else
     {
         const SfxPoolItem* pPoolItem = nullptr;
diff --git a/cui/source/tabpages/tphatch.cxx b/cui/source/tabpages/tphatch.cxx
index 6d8d456..9b6c5ad 100644
--- a/cui/source/tabpages/tphatch.cxx
+++ b/cui/source/tabpages/tphatch.cxx
@@ -58,10 +58,7 @@ SvxHatchTabPage::SvxHatchTabPage
     m_rOutAttrs           ( rInAttrs ),
     m_pnHatchingListState ( nullptr ),
     m_pnColorListState    ( nullptr ),
-    m_pPageType           ( nullptr ),
-    m_nDlgType            ( 0 ),
     m_pPos                ( nullptr ),
-    m_pbAreaTP            ( nullptr ),
 
     m_aXFStyleItem        ( drawing::FillStyle_HATCH ),
     m_aXHatchItem         ( OUString(), XHatch() ),
@@ -167,61 +164,56 @@ void SvxHatchTabPage::ActivatePage( const SfxItemSet& rSet )
     sal_Int32 nPos;
     sal_Int32 nCount;
 
-    if( m_nDlgType == 0 ) // area dialog
+    if( m_pColorList.is() )
     {
-        *m_pbAreaTP = false;
-
-        if( m_pColorList.is() )
+        // ColorList
+        if( *m_pnColorListState & ChangeType::CHANGED ||
+            *m_pnColorListState & ChangeType::MODIFIED )
         {
-            // ColorList
-            if( *m_pnColorListState & ChangeType::CHANGED ||
-                *m_pnColorListState & ChangeType::MODIFIED )
-            {
-                if( *m_pnColorListState & ChangeType::CHANGED )
-                    m_pColorList = static_cast<SvxAreaTabDialog*>( GetParentDialog() )->GetNewColorList();
-
-                // LbLineColor
-                nPos = m_pLbLineColor->GetSelectEntryPos();
-                m_pLbLineColor->Clear();
-                m_pLbLineColor->Fill( m_pColorList );
-                nCount = m_pLbLineColor->GetEntryCount();
-                if( nCount == 0 )
-                    ; // this case should not occur
-                else if( nCount <= nPos )
-                    m_pLbLineColor->SelectEntryPos( 0 );
-                else
-                    m_pLbLineColor->SelectEntryPos( nPos );
-
-                ModifiedHdl_Impl( this );
-            }
+            if( *m_pnColorListState & ChangeType::CHANGED )
+                m_pColorList = static_cast<SvxAreaTabDialog*>( GetParentDialog() )->GetNewColorList();
+
+            // LbLineColor
+            nPos = m_pLbLineColor->GetSelectEntryPos();
+            m_pLbLineColor->Clear();
+            m_pLbLineColor->Fill( m_pColorList );
+            nCount = m_pLbLineColor->GetEntryCount();
+            if( nCount == 0 )
+                ; // this case should not occur
+            else if( nCount <= nPos )
+                m_pLbLineColor->SelectEntryPos( 0 );
+            else
+                m_pLbLineColor->SelectEntryPos( nPos );
 
-            // determining (possibly cutting) the name
-            // and displaying it in the GroupBox
-            OUString        aString( CUI_RES( RID_SVXSTR_TABLE ) );
-            aString         += ": ";
-            INetURLObject   aURL( m_pHatchingList->GetPath() );
+            ModifiedHdl_Impl( this );
+        }
 
-            aURL.Append( m_pHatchingList->GetName() );
-            SAL_WARN_IF( aURL.GetProtocol() == INetProtocol::NotValid, "cui.tabpages", "invalid URL" );
+        // determining (possibly cutting) the name
+        // and displaying it in the GroupBox
+        OUString        aString( CUI_RES( RID_SVXSTR_TABLE ) );
+        aString         += ": ";
+        INetURLObject   aURL( m_pHatchingList->GetPath() );
 
-            if ( aURL.getBase().getLength() > 18 )
-            {
-                aString += aURL.getBase().copy( 0, 15 ) + "...";
-            }
-            else
-                aString += aURL.getBase();
+        aURL.Append( m_pHatchingList->GetName() );
+        SAL_WARN_IF( aURL.GetProtocol() == INetProtocol::NotValid, "cui.tabpages", "invalid URL" );
 
-            if( *m_pPageType == PageType::Hatch && *m_pPos != LISTBOX_ENTRY_NOTFOUND )
-            {
-                sal_uInt16 nId = m_pHatchLB->GetItemId( static_cast<size_t>( *m_pPos ) );
-                m_pHatchLB->SelectItem( nId );
-            }
-            // colors could have been deleted
-            ChangeHatchHdl_Impl();
+        if ( aURL.getBase().getLength() > 18 )
+        {
+            aString += aURL.getBase().copy( 0, 15 ) + "...";
+        }
+        else
+            aString += aURL.getBase();
 
-            *m_pPageType = PageType::Hatch;
-            *m_pPos = LISTBOX_ENTRY_NOTFOUND;
+        *m_pPos = SearchHatchList( ( &static_cast<const XFillHatchItem&>( rSet.Get(XATTR_FILLHATCH)) )->GetName() );
+        if( *m_pPos != LISTBOX_ENTRY_NOTFOUND )
+        {
+            sal_uInt16 nId = m_pHatchLB->GetItemId( static_cast<size_t>( *m_pPos ) );
+            m_pHatchLB->SelectItem( nId );
         }
+        // colors could have been deleted
+        ChangeHatchHdl_Impl();
+
+        *m_pPos = LISTBOX_ENTRY_NOTFOUND;
     }
 
     XFillBackgroundItem aBckItem( static_cast<const XFillBackgroundItem&>(rSet.Get(XATTR_FILLBACKGROUND)));
@@ -281,42 +273,35 @@ sal_Int32 SvxHatchTabPage::SearchHatchList(const OUString& rHatchName)
 
 bool SvxHatchTabPage::FillItemSet( SfxItemSet* rSet )
 {
-    if( m_nDlgType == 0 && !*m_pbAreaTP ) // area dialog
+    std::unique_ptr<XHatch> pXHatch;
+    OUString  aString;
+    size_t nPos = m_pHatchLB->GetSelectItemPos();
+    if( nPos != VALUESET_ITEM_NOTFOUND )
     {
-        if( *m_pPageType == PageType::Hatch )
-        {
-            std::unique_ptr<XHatch> pXHatch;
-            pXHatch.reset(new XHatch( m_pLbLineColor->GetSelectEntryColor(),
-                            (css::drawing::HatchStyle) m_pLbLineType->GetSelectEntryPos(),
-                            GetCoreValue( *m_pMtrDistance, m_ePoolUnit ),
-                            static_cast<long>(m_pMtrAngle->GetValue() * 10) ));
-
-            OUString  aString;
-            if( !( m_pMtrDistance->IsValueChangedFromSaved() ||
-                m_pMtrAngle->IsValueChangedFromSaved() ||
-                m_pLbLineType->IsValueChangedFromSaved() ||
-                m_pLbLineColor->IsValueChangedFromSaved() ||
-                m_pHatchLB->IsValueChangedFromSaved() ) )
-            {
-                aString = m_pHatchLB->GetItemText( m_pHatchLB->GetSelectItemId() );;
-            }
-
-            assert( pXHatch && "XHatch couldn't be created" );
-            rSet->Put( XFillStyleItem( drawing::FillStyle_HATCH ) );
-            rSet->Put( XFillHatchItem( aString, *pXHatch ) );
-
-            rSet->Put( XFillBackgroundItem( m_pCbBackgroundColor->IsChecked() ) );
-            if(m_pCbBackgroundColor->IsChecked())
-            {
-                sal_uInt32 nPosBckColor = m_pLbBackgroundColor->GetSelectEntryPos();
-                OUString aBckColorString;
-                if( nPosBckColor != LISTBOX_ENTRY_NOTFOUND )
-                    aBckColorString = m_pLbBackgroundColor->GetSelectEntry();
-                else
-                    aBckColorString = OUString();
-                rSet->Put( XFillColorItem( aBckColorString, m_pLbBackgroundColor->GetSelectEntryColor() ) );
-            }
-        }
+        pXHatch.reset(new XHatch( m_pHatchingList->GetHatch( static_cast<sal_uInt16>(nPos) )->GetHatch() ));
+        aString = m_pHatchLB->GetItemText( m_pHatchLB->GetSelectItemId() );

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list