diff options
author | Rishabh Kumar <kris.kr296@gmail.com> | 2016-08-22 16:48:05 +0530 |
---|---|---|
committer | Katarina Behrens <Katarina.Behrens@cib.de> | 2016-10-12 08:36:13 +0000 |
commit | 686349476e03f951f4a9ff9755b9f71951b64ea5 (patch) | |
tree | 7cb559cca9cf88dc0a2e2a957244701ab0b4fe60 /cui/source/tabpages/tphatch.cxx | |
parent | da01e9ec5dfb7787b4a3669486b3940590933850 (diff) |
[GSoC] Move all fill style tabs inside area tab
Change-Id: I89e84b7b3c7075ad4107e7bc444ea5c07bc90795
Reviewed-on: https://gerrit.libreoffice.org/27866
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Katarina Behrens <Katarina.Behrens@cib.de>
Diffstat (limited to 'cui/source/tabpages/tphatch.cxx')
-rw-r--r-- | cui/source/tabpages/tphatch.cxx | 161 |
1 files changed, 73 insertions, 88 deletions
diff --git a/cui/source/tabpages/tphatch.cxx b/cui/source/tabpages/tphatch.cxx index 6d8d4567c0ea..9b6c5adf1ff1 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() ); + } + // gradient has been (unidentifiedly) passed + else + { + 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) )); + } + 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() ) ); } return true; } @@ -418,7 +403,7 @@ void SvxHatchTabPage::ChangeHatchHdl_Impl() size_t nPos = m_pHatchLB->GetSelectItemPos(); if( nPos != VALUESET_ITEM_NOTFOUND ) - pHatch.reset(new XHatch(m_pHatchingList->GetHatch(nPos)->GetHatch())); + pHatch.reset(new XHatch( m_pHatchingList->GetHatch( static_cast<sal_uInt16>(nPos) )->GetHatch() )); else { const SfxPoolItem* pPoolItem = nullptr; @@ -547,7 +532,7 @@ IMPL_LINK_NOARG(SvxHatchTabPage, ClickModifyHdl_Impl, Button*, void) if( nPos != VALUESET_ITEM_NOTFOUND ) { - OUString aName(m_pHatchingList->GetHatch(nPos)->GetName()); + OUString aName( m_pHatchingList->GetHatch( static_cast<sal_uInt16>(nPos) )->GetName() ); XHatch aXHatch( m_pLbLineColor->GetSelectEntryColor(), (css::drawing::HatchStyle) m_pLbLineType->GetSelectEntryPos(), @@ -556,7 +541,7 @@ IMPL_LINK_NOARG(SvxHatchTabPage, ClickModifyHdl_Impl, Button*, void) m_pHatchingList->Replace(o3tl::make_unique<XHatchEntry>(aXHatch, aName), nPos); - Bitmap aBitmap = m_pHatchingList->GetBitmapForPreview(nPos, m_pHatchLB->GetIconSize()); + Bitmap aBitmap = m_pHatchingList->GetBitmapForPreview( static_cast<sal_uInt16>(nPos), m_pHatchLB->GetIconSize() ); m_pHatchLB->RemoveItem( nId ); m_pHatchLB->InsertItem( nId, Image(aBitmap), aName, static_cast<sal_uInt16>(nPos) ); m_pHatchLB->SelectItem( nId ); |