diff options
Diffstat (limited to 'cui/source/tabpages/tparea.cxx')
-rw-r--r-- | cui/source/tabpages/tparea.cxx | 971 |
1 files changed, 244 insertions, 727 deletions
diff --git a/cui/source/tabpages/tparea.cxx b/cui/source/tabpages/tparea.cxx index d89945dbd8e3..c9b66a189195 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: */ |