Index: inc/svx/fillctrl.hxx =================================================================== --- inc/svx/fillctrl.hxx (revision 1599234) +++ inc/svx/fillctrl.hxx (working copy) @@ -19,8 +19,6 @@ * *************************************************************/ - - #ifndef _FILLCTRL_HXX #define _FILLCTRL_HXX @@ -44,32 +42,33 @@ |* \************************************************************************/ -class SVX_DLLPUBLIC SvxFillToolBoxControl: public SfxToolBoxControl +class SVX_DLLPUBLIC SvxFillToolBoxControl : public SfxToolBoxControl { private: - XFillStyleItem* pStyleItem; - XFillColorItem* pColorItem; - XFillGradientItem* pGradientItem; - XFillHatchItem* pHatchItem; - XFillBitmapItem* pBitmapItem; + XFillStyleItem* mpStyleItem; + XFillColorItem* mpColorItem; + XFillGradientItem* mpGradientItem; + XFillHatchItem* mpHatchItem; + XFillBitmapItem* mpBitmapItem; - FillControl* pFillControl; - SvxFillTypeBox* pFillTypeLB; - SvxFillAttrBox* pFillAttrLB; + FillControl* mpFillControl; + SvxFillTypeBox* mpFillTypeLB; + SvxFillAttrBox* mpFillAttrLB; - sal_Bool bUpdate; - sal_uInt16 eLastXFS; + XFillStyle meLastXFS; + /// bitfield + bool mbUpdate : 1; + public: - SFX_DECL_TOOLBOX_CONTROL(); + SFX_DECL_TOOLBOX_CONTROL(); - SvxFillToolBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ); - ~SvxFillToolBoxControl(); + SvxFillToolBoxControl(sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx); + ~SvxFillToolBoxControl(); - virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, - const SfxPoolItem* pState ); - void Update( const SfxPoolItem* pState ); - virtual Window* CreateItemWindow( Window *pParent ); + virtual void StateChanged(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState); + void Update(const SfxPoolItem* pState); + virtual Window* CreateItemWindow(Window* pParent); }; //======================================================================== @@ -77,26 +76,36 @@ class FillControl : public Window { private: - friend class SvxFillToolBoxControl; + friend class SvxFillToolBoxControl; - SvxFillTypeBox* pLbFillType; - SvxFillAttrBox* pLbFillAttr; - Size aLogicalFillSize; - Size aLogicalAttrSize; - Timer aDelayTimer; + SvxFillTypeBox* mpLbFillType; + SvxFillAttrBox* mpLbFillAttr; + Size maLogicalFillSize; + Size maLogicalAttrSize; -//#if 0 // _SOLAR__PRIVATE - DECL_LINK( DelayHdl, Timer * ); - DECL_LINK( SelectFillTypeHdl, ListBox * ); - DECL_LINK( SelectFillAttrHdl, ListBox * ); -//#endif - virtual void DataChanged( const DataChangedEvent& rDCEvt ); + // + sal_uInt16 mnLastFillTypeControlSelectEntryPos; + sal_uInt16 mnLastFillAttrControlSelectEntryPos; + + /// bitfield + bool mbFillTypeChanged : 1; + + DECL_LINK(SelectFillTypeHdl,ListBox *); + DECL_LINK(SelectFillAttrHdl,ListBox *); + + virtual void DataChanged(const DataChangedEvent& rDCEvt); + + void InitializeFillStyleAccordingToGivenFillType(XFillStyle aFillStyle); + void updateLastFillTypeControlSelectEntryPos(); + void updateLastFillAttrControlSelectEntryPos(); + public: - FillControl( Window* pParent, WinBits nStyle = 0 ); - ~FillControl(); + FillControl(Window* pParent, WinBits nStyle = 0); + ~FillControl(); - virtual void Resize(); + virtual void Resize(); }; -#endif // _FILLCTRL_HXX +#endif // _FILLCTRL_HXX +// eof Index: source/tbxctrls/fillctrl.cxx =================================================================== --- source/tbxctrls/fillctrl.cxx (revision 1599234) +++ source/tbxctrls/fillctrl.cxx (working copy) @@ -19,24 +19,17 @@ * *************************************************************/ - - // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_svx.hxx" -// include --------------------------------------------------------------- - #include // HACK: prevent conflict between STLPORT and Workshop headers #include #include #include #include #include - #include -#define DELAY_TIMEOUT 300 - #define TMP_STR_BEGIN '[' #define TMP_STR_END ']' @@ -62,19 +55,21 @@ |* \************************************************************************/ -SvxFillToolBoxControl::SvxFillToolBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) : - SfxToolBoxControl( nSlotId, nId, rTbx ), - - pStyleItem ( NULL ), - pColorItem ( NULL ), - pGradientItem ( NULL ), - pHatchItem ( NULL ), - pBitmapItem ( NULL ), - pFillControl ( NULL ), - pFillTypeLB ( NULL ), - pFillAttrLB ( NULL ), - bUpdate ( sal_False ), - eLastXFS ( XFILL_NONE ) +SvxFillToolBoxControl::SvxFillToolBoxControl( + sal_uInt16 nSlotId, + sal_uInt16 nId, + ToolBox& rTbx ) +: SfxToolBoxControl( nSlotId, nId, rTbx ), + mpStyleItem(0), + mpColorItem(0), + mpGradientItem(0), + mpHatchItem(0), + mpBitmapItem(0), + mpFillControl(0), + mpFillTypeLB(0), + mpFillAttrLB(0), + meLastXFS(XFILL_NONE), + mbUpdate(false) { addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillColor" ))); addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillGradient" ))); @@ -90,412 +85,433 @@ SvxFillToolBoxControl::~SvxFillToolBoxControl() { - delete pStyleItem; - delete pColorItem; - delete pGradientItem; - delete pHatchItem; - delete pBitmapItem; + delete mpStyleItem; + delete mpColorItem; + delete mpGradientItem; + delete mpHatchItem; + delete mpBitmapItem; } //======================================================================== void SvxFillToolBoxControl::StateChanged( + sal_uInt16 nSID, + SfxItemState eState, + const SfxPoolItem* pState) +{ + bool bEnableControls(false); - sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState ) + if(eState == SFX_ITEM_DISABLED) + { + if(nSID == SID_ATTR_FILL_STYLE) + { + mpFillTypeLB->Disable(); + mpFillTypeLB->SetNoSelection(); + } -{ - bool bEnableControls = sal_False; + mpFillAttrLB->Disable(); + mpFillAttrLB->SetNoSelection(); + } + else + { + if(SFX_ITEM_AVAILABLE == eState) + { + if(nSID == SID_ATTR_FILL_STYLE) + { + delete mpStyleItem; + mpStyleItem = static_cast< XFillStyleItem* >(pState->Clone()); + mpFillTypeLB->Enable(); + } + else if(mpStyleItem) + { + const XFillStyle eXFS(static_cast< XFillStyle >(mpStyleItem->GetValue())); - if( eState == SFX_ITEM_DISABLED ) - { - if( nSID == SID_ATTR_FILL_STYLE ) - { - pFillTypeLB->Disable(); - pFillTypeLB->SetNoSelection(); - } - pFillAttrLB->Disable(); - pFillAttrLB->SetNoSelection(); - } - else - { - if ( SFX_ITEM_AVAILABLE == eState ) - { - if( nSID == SID_ATTR_FILL_STYLE ) - { - delete pStyleItem; - pStyleItem = (XFillStyleItem*) pState->Clone(); - pFillTypeLB->Enable(); - } - else if( pStyleItem ) - { - XFillStyle eXFS = (XFillStyle)pStyleItem->GetValue(); + if(nSID == SID_ATTR_FILL_COLOR) + { + delete mpColorItem; + mpColorItem = static_cast< XFillColorItem* >(pState->Clone()); - if( nSID == SID_ATTR_FILL_COLOR ) - { - delete pColorItem; - pColorItem = (XFillColorItem*) pState->Clone(); + if(eXFS == XFILL_SOLID) + { + bEnableControls = true; + } + } + else if(nSID == SID_ATTR_FILL_GRADIENT) + { + delete mpGradientItem; + mpGradientItem = static_cast< XFillGradientItem* >(pState->Clone()); - if( eXFS == XFILL_SOLID ) - bEnableControls = sal_True; - } - else if( nSID == SID_ATTR_FILL_GRADIENT ) - { - delete pGradientItem; - pGradientItem = (XFillGradientItem*) pState->Clone(); + if(eXFS == XFILL_GRADIENT) + { + bEnableControls = true; + } + } + else if(nSID == SID_ATTR_FILL_HATCH) + { + delete mpHatchItem; + mpHatchItem = static_cast< XFillHatchItem* >(pState->Clone()); - if( eXFS == XFILL_GRADIENT ) - bEnableControls = sal_True; - } - else if( nSID == SID_ATTR_FILL_HATCH ) - { - delete pHatchItem; - pHatchItem = (XFillHatchItem*) pState->Clone(); + if(eXFS == XFILL_HATCH) + { + bEnableControls = true; + } + } + else if(nSID == SID_ATTR_FILL_BITMAP) + { + delete mpBitmapItem; + mpBitmapItem = static_cast< XFillBitmapItem* >(pState->Clone()); - if( eXFS == XFILL_HATCH ) - bEnableControls = sal_True; - } - else if( nSID == SID_ATTR_FILL_BITMAP ) - { - delete pBitmapItem; - pBitmapItem = (XFillBitmapItem*) pState->Clone(); + if(eXFS == XFILL_BITMAP) + { + bEnableControls = true; + } + } + } - if( eXFS == XFILL_BITMAP ) - bEnableControls = sal_True; - } - } - - if( pStyleItem ) + if(mpStyleItem) { - // ensure that the correct entry is selected in pFillTypeLB. It - // might have been changed by nSID == SID_ATTR_FILL_STYLE, but - // it might also be in an in-between state when user had started to - // change fillstyle, but not yet changed fillvalue for new style - // and when nSID == SID_ATTR_FILL_COLOR/SID_ATTR_FILL_GRADIENT/ - // SID_ATTR_FILL_HATCH/SID_ATTR_FILL_BITMAP value change is triggered - eLastXFS = pFillTypeLB->GetSelectEntryPos(); - XFillStyle eXFS = (XFillStyle)pStyleItem->GetValue(); + // ensure that the correct entry is selected in mpFillTypeLB. It + const XFillStyle eXFS(static_cast< XFillStyle >(mpStyleItem->GetValue())); - if(eLastXFS != eXFS) + if(meLastXFS != eXFS) { - bUpdate = sal_True; - pFillTypeLB->SelectEntryPos( sal::static_int_cast< sal_uInt16 >( eXFS ) ); + mbUpdate = true; + mpFillTypeLB->SelectEntryPos(sal::static_int_cast(eXFS)); } - pFillAttrLB->Enable(); + mpFillAttrLB->Enable(); } - if( bEnableControls ) - { - //pFillTypeLB->Enable(); - pFillAttrLB->Enable(); + if(bEnableControls) + { + mpFillAttrLB->Enable(); + mbUpdate = true; + } - bUpdate = sal_True; - } - - Update( pState ); + Update(pState); } - else - { - // leerer oder uneindeutiger Status - if( nSID == SID_ATTR_FILL_STYLE ) - { - pFillTypeLB->SetNoSelection(); - pFillAttrLB->Disable(); - pFillAttrLB->SetNoSelection(); - bUpdate = sal_False; - } - else - { - XFillStyle eXFS = XFILL_NONE; - if( pStyleItem ) - eXFS = (XFillStyle)pStyleItem->GetValue(); - if( !pStyleItem || - ( nSID == SID_ATTR_FILL_COLOR && eXFS == XFILL_SOLID ) || - ( nSID == SID_ATTR_FILL_GRADIENT && eXFS == XFILL_GRADIENT ) || - ( nSID == SID_ATTR_FILL_HATCH && eXFS == XFILL_HATCH ) || - ( nSID == SID_ATTR_FILL_BITMAP && eXFS == XFILL_BITMAP ) ) - { - pFillAttrLB->SetNoSelection(); - //bUpdate = sal_False; - } - } - } - } + else + { + // leerer oder uneindeutiger Status + if(nSID == SID_ATTR_FILL_STYLE) + { + mpFillTypeLB->SetNoSelection(); + mpFillAttrLB->Disable(); + mpFillAttrLB->SetNoSelection(); + delete mpStyleItem; + mpStyleItem = 0; + mbUpdate = false; + } + else + { + XFillStyle eXFS(XFILL_NONE); + + if(mpStyleItem) + { + eXFS = static_cast< XFillStyle >(mpStyleItem->GetValue()); + } + + if(!mpStyleItem || + (nSID == SID_ATTR_FILL_COLOR && eXFS == XFILL_SOLID) || + (nSID == SID_ATTR_FILL_GRADIENT && eXFS == XFILL_GRADIENT) || + (nSID == SID_ATTR_FILL_HATCH && eXFS == XFILL_HATCH) || + (nSID == SID_ATTR_FILL_BITMAP && eXFS == XFILL_BITMAP)) + { + mpFillAttrLB->SetNoSelection(); + } + } + } + } } //======================================================================== -void SvxFillToolBoxControl::Update( const SfxPoolItem* pState ) +void SvxFillToolBoxControl::Update(const SfxPoolItem* pState) { - if ( pStyleItem && pState && bUpdate ) - { - bUpdate = sal_False; + if(mpStyleItem && pState && mbUpdate) + { + mbUpdate = false; + const XFillStyle eXFS(static_cast< XFillStyle >(mpStyleItem->GetValue())); - XFillStyle eXFS = (XFillStyle)pStyleItem->GetValue(); + // Pruefen, ob Fuellstil schon vorher aktiv war + if(meLastXFS != eXFS) + { + // update mnLastFillTypeControlSelectEntryPos + mpFillControl->updateLastFillTypeControlSelectEntryPos(); + mpFillControl->InitializeFillStyleAccordingToGivenFillType(eXFS); + meLastXFS = eXFS; + } - // Pruefen, ob Fuellstil schon vorher aktiv war - //if( eTmpXFS != eXFS ) - if( (XFillStyle) eLastXFS != eXFS ) - pFillControl->SelectFillTypeHdl( NULL ); - //eLastXFS = eXFS; + switch(eXFS) + { + case XFILL_NONE: + { + break; + } - switch( eXFS ) - { - case XFILL_NONE: - break; + case XFILL_SOLID: + { + if(mpColorItem) + { + String aString(mpColorItem->GetName()); + ::Color aColor = mpColorItem->GetColorValue(); - case XFILL_SOLID: - { - if ( pColorItem ) - { - String aString( pColorItem->GetName() ); - ::Color aColor = pColorItem->GetColorValue(); + mpFillAttrLB->SelectEntry(aString); - pFillAttrLB->SelectEntry( aString ); + if(mpFillAttrLB->GetSelectEntryPos() == LISTBOX_ENTRY_NOTFOUND || + mpFillAttrLB->GetSelectEntryColor() != aColor) + mpFillAttrLB->SelectEntry(aColor); - if ( pFillAttrLB->GetSelectEntryPos() == LISTBOX_ENTRY_NOTFOUND || - pFillAttrLB->GetSelectEntryColor() != aColor ) - pFillAttrLB->SelectEntry( aColor ); + // Pruefen, ob Eintrag nicht in der Liste ist + if(mpFillAttrLB->GetSelectEntryPos() == LISTBOX_ENTRY_NOTFOUND || + mpFillAttrLB->GetSelectEntryColor() != aColor) + { + sal_uInt16 nCount = mpFillAttrLB->GetEntryCount(); + String aTmpStr; + if(nCount > 0) + { + //Letzter Eintrag wird auf temporaere Farbe geprueft + aTmpStr = mpFillAttrLB->GetEntry(nCount - 1); - // NEU - // Pruefen, ob Eintrag nicht in der Liste ist - if( pFillAttrLB->GetSelectEntryPos() == - LISTBOX_ENTRY_NOTFOUND || - pFillAttrLB->GetSelectEntryColor() != aColor ) - { - sal_uInt16 nCount = pFillAttrLB->GetEntryCount(); - String aTmpStr; - if( nCount > 0 ) - { - //Letzter Eintrag wird auf temporaere Farbe geprueft - aTmpStr = pFillAttrLB->GetEntry( nCount - 1 ); - if( aTmpStr.GetChar(0) == TMP_STR_BEGIN && - aTmpStr.GetChar(aTmpStr.Len()-1) == TMP_STR_END ) - { - pFillAttrLB->RemoveEntry( nCount - 1 ); - } - } - aTmpStr = TMP_STR_BEGIN; - aTmpStr += aString; - aTmpStr += TMP_STR_END; + if(aTmpStr.GetChar(0) == TMP_STR_BEGIN && aTmpStr.GetChar(aTmpStr.Len() - 1) == TMP_STR_END) + { + mpFillAttrLB->RemoveEntry(nCount - 1); + } + } - //pFillAttrLB->SetUpdateMode( sal_False ); - sal_uInt16 nPos = pFillAttrLB->InsertEntry( aColor, aTmpStr ); - //pFillAttrLB->SetUpdateMode( sal_True ); - pFillAttrLB->SelectEntryPos( nPos ); - } - // NEU - } - else - pFillAttrLB->SetNoSelection(); - } - break; + aTmpStr = TMP_STR_BEGIN; + aTmpStr += aString; + aTmpStr += TMP_STR_END; - case XFILL_GRADIENT: - { - if ( pGradientItem ) - { - String aString( pGradientItem->GetName() ); - pFillAttrLB->SelectEntry( aString ); - // NEU - // Pruefen, ob Eintrag nicht in der Liste ist - if( pFillAttrLB->GetSelectEntry() != aString ) - { - sal_uInt16 nCount = pFillAttrLB->GetEntryCount(); - String aTmpStr; - if( nCount > 0 ) - { - //Letzter Eintrag wird auf temporaeren Eintrag geprueft - aTmpStr = pFillAttrLB->GetEntry( nCount - 1 ); - if( aTmpStr.GetChar(0) == TMP_STR_BEGIN && - aTmpStr.GetChar(aTmpStr.Len()-1) == TMP_STR_END ) - { - pFillAttrLB->RemoveEntry( nCount - 1 ); - } - } - aTmpStr = TMP_STR_BEGIN; - aTmpStr += aString; - aTmpStr += TMP_STR_END; + sal_uInt16 nPos = mpFillAttrLB->InsertEntry(aColor,aTmpStr); + mpFillAttrLB->SelectEntryPos(nPos); + } + } + else + { + mpFillAttrLB->SetNoSelection(); + } + break; + } - XGradientEntry* pEntry = new XGradientEntry( pGradientItem->GetGradientValue(), aTmpStr ); + case XFILL_GRADIENT: + { + if(mpGradientItem) + { + String aString(mpGradientItem->GetName()); + mpFillAttrLB->SelectEntry(aString); + + // Pruefen, ob Eintrag nicht in der Liste ist + if(mpFillAttrLB->GetSelectEntry() != aString) + { + sal_uInt16 nCount = mpFillAttrLB->GetEntryCount(); + String aTmpStr; + + if(nCount > 0) + { + //Letzter Eintrag wird auf temporaeren Eintrag geprueft + aTmpStr = mpFillAttrLB->GetEntry(nCount - 1); + if(aTmpStr.GetChar(0) == TMP_STR_BEGIN && + aTmpStr.GetChar(aTmpStr.Len() - 1) == TMP_STR_END) + { + mpFillAttrLB->RemoveEntry(nCount - 1); + } + } + + aTmpStr = TMP_STR_BEGIN; + aTmpStr += aString; + aTmpStr += TMP_STR_END; + + XGradientEntry* pEntry = new XGradientEntry(mpGradientItem->GetGradientValue(),aTmpStr); XGradientListSharedPtr aGradientList(XPropertyListFactory::CreateSharedXGradientList(String::CreateFromAscii("TmpList"))); - + aGradientList->Insert(pEntry); - aGradientList->SetDirty(false); - const Bitmap aBmp = aGradientList->GetUiBitmap( 0 ); + aGradientList->SetDirty(false); + const Bitmap aBmp = aGradientList->GetUiBitmap(0); - if( !aBmp.IsEmpty() ) - { - ( (ListBox*)pFillAttrLB )->InsertEntry( pEntry->GetName(), aBmp ); - pFillAttrLB->SelectEntryPos( pFillAttrLB->GetEntryCount() - 1 ); - } - } - // NEU - } - else - pFillAttrLB->SetNoSelection(); - } - break; + if(!aBmp.IsEmpty()) + { + ((ListBox*)mpFillAttrLB)->InsertEntry(pEntry->GetName(),aBmp); + mpFillAttrLB->SelectEntryPos(mpFillAttrLB->GetEntryCount() - 1); + } + } + } + else + { + mpFillAttrLB->SetNoSelection(); + } + break; + } - case XFILL_HATCH: - { - if ( pHatchItem ) - { - String aString( pHatchItem->GetName() ); - pFillAttrLB->SelectEntry( aString ); - // NEU - // Pruefen, ob Eintrag nicht in der Liste ist - if( pFillAttrLB->GetSelectEntry() != aString ) - { - sal_uInt16 nCount = pFillAttrLB->GetEntryCount(); - String aTmpStr; - if( nCount > 0 ) - { - //Letzter Eintrag wird auf temporaeren Eintrag geprueft - aTmpStr = pFillAttrLB->GetEntry( nCount - 1 ); - if( aTmpStr.GetChar(0) == TMP_STR_BEGIN && - aTmpStr.GetChar(aTmpStr.Len()-1) == TMP_STR_END ) - { - pFillAttrLB->RemoveEntry( nCount - 1 ); - } - } - aTmpStr = TMP_STR_BEGIN; - aTmpStr += aString; - aTmpStr += TMP_STR_END; + case XFILL_HATCH: + { + if(mpHatchItem) + { + String aString(mpHatchItem->GetName()); + mpFillAttrLB->SelectEntry(aString); - XHatchEntry* pEntry = new XHatchEntry( pHatchItem->GetHatchValue(), aTmpStr ); - XHatchListSharedPtr aHatchList(XPropertyListFactory::CreateSharedXHatchList(String::CreateFromAscii("TmpList"))); + // Pruefen, ob Eintrag nicht in der Liste ist + if(mpFillAttrLB->GetSelectEntry() != aString) + { + sal_uInt16 nCount = mpFillAttrLB->GetEntryCount(); + String aTmpStr; + if(nCount > 0) + { + //Letzter Eintrag wird auf temporaeren Eintrag geprueft + aTmpStr = mpFillAttrLB->GetEntry(nCount - 1); + if(aTmpStr.GetChar(0) == TMP_STR_BEGIN && + aTmpStr.GetChar(aTmpStr.Len() - 1) == TMP_STR_END) + { + mpFillAttrLB->RemoveEntry(nCount - 1); + } + } - aHatchList->Insert( pEntry ); - aHatchList->SetDirty( sal_False ); - const Bitmap aBmp = aHatchList->GetUiBitmap( 0 ); + aTmpStr = TMP_STR_BEGIN; + aTmpStr += aString; + aTmpStr += TMP_STR_END; - if( !aBmp.IsEmpty() ) - { - ( (ListBox*)pFillAttrLB )->InsertEntry( pEntry->GetName(), aBmp ); - pFillAttrLB->SelectEntryPos( pFillAttrLB->GetEntryCount() - 1 ); - } - } - // NEU - } - else - pFillAttrLB->SetNoSelection(); - } - break; + XHatchEntry* pEntry = new XHatchEntry(mpHatchItem->GetHatchValue(),aTmpStr); + XHatchListSharedPtr aHatchList(XPropertyListFactory::CreateSharedXHatchList(String::CreateFromAscii("TmpList"))); - case XFILL_BITMAP: - { - if ( pBitmapItem ) - // && - // SfxObjectShell::Current() && - // SfxObjectShell::Current()->GetItem( SID_BITMAP_LIST ) ) - { - String aString( pBitmapItem->GetName() ); - // Bitmap aBitmap( pBitmapItem->GetValue() ); + aHatchList->Insert(pEntry); + aHatchList->SetDirty(sal_False); + const Bitmap aBmp = aHatchList->GetUiBitmap(0); - // SvxBitmapListItem aItem( *(const SvxBitmapListItem*)( - // SfxObjectShell::Current()->GetItem( SID_BITMAP_LIST ) ) ); - pFillAttrLB->SelectEntry( aString ); - // NEU - // Pruefen, ob Eintrag nicht in der Liste ist - if( pFillAttrLB->GetSelectEntry() != aString ) - { - sal_uInt16 nCount = pFillAttrLB->GetEntryCount(); - String aTmpStr; - if( nCount > 0 ) - { - //Letzter Eintrag wird auf temporaeren Eintrag geprueft - aTmpStr = pFillAttrLB->GetEntry( nCount - 1 ); - if( aTmpStr.GetChar(0) == TMP_STR_BEGIN && - aTmpStr.GetChar(aTmpStr.Len()-1) == TMP_STR_END ) - { - pFillAttrLB->RemoveEntry( nCount - 1 ); - } - } - aTmpStr = TMP_STR_BEGIN; - aTmpStr += aString; - aTmpStr += TMP_STR_END; + if(!aBmp.IsEmpty()) + { + ((ListBox*)mpFillAttrLB)->InsertEntry(pEntry->GetName(),aBmp); + mpFillAttrLB->SelectEntryPos(mpFillAttrLB->GetEntryCount() - 1); + } + } + } + else + { + mpFillAttrLB->SetNoSelection(); + } + break; + } + case XFILL_BITMAP: + { + if(mpBitmapItem) + { + String aString(mpBitmapItem->GetName()); + mpFillAttrLB->SelectEntry(aString); + + // Pruefen, ob Eintrag nicht in der Liste ist + if(mpFillAttrLB->GetSelectEntry() != aString) + { + sal_uInt16 nCount = mpFillAttrLB->GetEntryCount(); + String aTmpStr; + + if(nCount > 0) + { + //Letzter Eintrag wird auf temporaeren Eintrag geprueft + aTmpStr = mpFillAttrLB->GetEntry(nCount - 1); + if(aTmpStr.GetChar(0) == TMP_STR_BEGIN && + aTmpStr.GetChar(aTmpStr.Len() - 1) == TMP_STR_END) + { + mpFillAttrLB->RemoveEntry(nCount - 1); + } + } + + aTmpStr = TMP_STR_BEGIN; + aTmpStr += aString; + aTmpStr += TMP_STR_END; + XBitmapListSharedPtr aNew(XPropertyListFactory::CreateSharedXBitmapList(String::CreateFromAscii("TmpList"))); - aNew->Insert(new XBitmapEntry(pBitmapItem->GetGraphicObject(), aTmpStr)); + aNew->Insert(new XBitmapEntry(mpBitmapItem->GetGraphicObject(),aTmpStr)); aNew->SetDirty(false); - pFillAttrLB->Fill( aNew ); - pFillAttrLB->SelectEntryPos( pFillAttrLB->GetEntryCount() - 1 ); - } - // NEU - } - else - pFillAttrLB->SetNoSelection(); - } - break; + mpFillAttrLB->Fill(aNew); + mpFillAttrLB->SelectEntryPos(mpFillAttrLB->GetEntryCount() - 1); + } + } + else + { + mpFillAttrLB->SetNoSelection(); + } + break; + } - default: - DBG_ERROR( "Nicht unterstuetzter Flaechentyp" ); - break; - } - } + default: + { + DBG_ERROR("Nicht unterstuetzter Flaechentyp"); + break; + } + } - if( pState && pStyleItem ) - { - XFillStyle eXFS = (XFillStyle) pStyleItem->GetValue(); + // update mnLastFillAttrControlSelectEntryPos + mpFillControl->updateLastFillAttrControlSelectEntryPos(); + } - // Die Listen haben sich geaendert ? - if( pState->ISA( SvxColorTableItem ) && - eXFS == XFILL_SOLID ) - { - ::Color aTmpColor( pFillAttrLB->GetSelectEntryColor() ); - pFillAttrLB->Clear(); - pFillAttrLB->Fill( ( (SvxColorTableItem*)pState )->GetColorTable() ); - pFillAttrLB->SelectEntry( aTmpColor ); - } - if( pState->ISA( SvxGradientListItem ) && - eXFS == XFILL_GRADIENT ) - { - String aString( pFillAttrLB->GetSelectEntry() ); - pFillAttrLB->Clear(); - pFillAttrLB->Fill( ( (SvxGradientListItem*)pState )->GetGradientList() ); - pFillAttrLB->SelectEntry( aString ); - } - if( pState->ISA( SvxHatchListItem ) && - eXFS == XFILL_HATCH ) - { - String aString( pFillAttrLB->GetSelectEntry() ); - pFillAttrLB->Clear(); - pFillAttrLB->Fill( ( (SvxHatchListItem*)pState )->GetHatchList() ); - pFillAttrLB->SelectEntry( aString ); - } - if( pState->ISA( SvxBitmapListItem ) && - eXFS == XFILL_BITMAP ) - { - String aString( pFillAttrLB->GetSelectEntry() ); - pFillAttrLB->Clear(); - pFillAttrLB->Fill( ( (SvxBitmapListItem*)pState )->GetBitmapList() ); - pFillAttrLB->SelectEntry( aString ); - } - } + if(pState && mpStyleItem) + { + XFillStyle eXFS = static_cast< XFillStyle >(mpStyleItem->GetValue()); + + // Die Listen haben sich geaendert ? + if(pState->ISA(SvxColorTableItem) && eXFS == XFILL_SOLID) + { + ::Color aTmpColor(mpFillAttrLB->GetSelectEntryColor()); + mpFillAttrLB->Clear(); + mpFillAttrLB->Fill(((SvxColorTableItem*)pState)->GetColorTable()); + mpFillAttrLB->SelectEntry(aTmpColor); + } + if(pState->ISA(SvxGradientListItem) && eXFS == XFILL_GRADIENT) + { + String aString(mpFillAttrLB->GetSelectEntry()); + mpFillAttrLB->Clear(); + mpFillAttrLB->Fill(((SvxGradientListItem*)pState)->GetGradientList()); + mpFillAttrLB->SelectEntry(aString); + } + if(pState->ISA(SvxHatchListItem) && eXFS == XFILL_HATCH) + { + String aString(mpFillAttrLB->GetSelectEntry()); + mpFillAttrLB->Clear(); + mpFillAttrLB->Fill(((SvxHatchListItem*)pState)->GetHatchList()); + mpFillAttrLB->SelectEntry(aString); + } + if(pState->ISA(SvxBitmapListItem) && eXFS == XFILL_BITMAP) + { + String aString(mpFillAttrLB->GetSelectEntry()); + mpFillAttrLB->Clear(); + mpFillAttrLB->Fill(((SvxBitmapListItem*)pState)->GetBitmapList()); + mpFillAttrLB->SelectEntry(aString); + } + } } //======================================================================== -Window* SvxFillToolBoxControl::CreateItemWindow( Window *pParent ) +Window* SvxFillToolBoxControl::CreateItemWindow(Window *pParent) { - if ( GetSlotId() == SID_ATTR_FILL_STYLE ) - { - pFillControl = new FillControl( pParent ); - // Damit dem FillControl das SvxFillToolBoxControl bekannt ist - // (und um kompatibel zu bleiben) - pFillControl->SetData( this ); + if(GetSlotId() == SID_ATTR_FILL_STYLE) + { + mpFillControl = new FillControl(pParent); + // Damit dem FillControl das SvxFillToolBoxControl bekannt ist + // (und um kompatibel zu bleiben) + mpFillControl->SetData(this); - pFillAttrLB = (SvxFillAttrBox*)pFillControl->pLbFillAttr; - pFillTypeLB = (SvxFillTypeBox*)pFillControl->pLbFillType; + mpFillAttrLB = (SvxFillAttrBox*)mpFillControl->mpLbFillAttr; + mpFillTypeLB = (SvxFillTypeBox*)mpFillControl->mpLbFillType; - pFillAttrLB->SetUniqueId( HID_FILL_ATTR_LISTBOX ); - pFillTypeLB->SetUniqueId( HID_FILL_TYPE_LISTBOX ); + mpFillAttrLB->SetUniqueId(HID_FILL_ATTR_LISTBOX); + mpFillTypeLB->SetUniqueId(HID_FILL_TYPE_LISTBOX); - return pFillControl; - } - return NULL; + if(!mpStyleItem) + { + // for Writer and Calc it's not the same instance of + // SvxFillToolBoxControl which gets used after deselecting + // and selecting a DrawObject, thhus a useful initialization is + // needed to get the FillType and the FillStyle List inited + // correctly. This in combination with meLastXFS inited to + // XFILL_NONE do the trick + mpStyleItem = new XFillStyleItem(XFILL_SOLID); + } + + return mpFillControl; + } + return NULL; } /************************************************************************* @@ -504,287 +520,341 @@ |* \************************************************************************/ -FillControl::FillControl( Window* pParent, WinBits nStyle ) : - Window( pParent, nStyle | WB_DIALOGCONTROL ), - pLbFillType(new SvxFillTypeBox( this )), - aLogicalFillSize(40,80), - aLogicalAttrSize(50,80) +FillControl::FillControl(Window* pParent,WinBits nStyle) +: Window(pParent,nStyle | WB_DIALOGCONTROL), + mpLbFillType(new SvxFillTypeBox(this)), + mpLbFillAttr(new SvxFillAttrBox(this)), + maLogicalFillSize(40,80), + maLogicalAttrSize(50,80), + mnLastFillTypeControlSelectEntryPos(mpLbFillType->GetSelectEntryPos()), + mnLastFillAttrControlSelectEntryPos(mpLbFillAttr->GetSelectEntryPos()), + mbFillTypeChanged(false) { - pLbFillAttr = new SvxFillAttrBox( this ); - Size aTypeSize(LogicToPixel(aLogicalFillSize, MAP_APPFONT)); - Size aAttrSize(LogicToPixel(aLogicalAttrSize, MAP_APPFONT)); - pLbFillType->SetSizePixel(aTypeSize); - pLbFillAttr->SetSizePixel(aAttrSize); + Size aTypeSize(LogicToPixel(maLogicalFillSize,MAP_APPFONT)); + Size aAttrSize(LogicToPixel(maLogicalAttrSize,MAP_APPFONT)); + mpLbFillType->SetSizePixel(aTypeSize); + mpLbFillAttr->SetSizePixel(aAttrSize); + //to get the base height - aTypeSize = pLbFillType->GetSizePixel(); - aAttrSize = pLbFillAttr->GetSizePixel(); - Point aAttrPnt = pLbFillAttr->GetPosPixel(); - SetSizePixel( - Size( aAttrPnt.X() + aAttrSize.Width(), - Max( aAttrSize.Height(), aTypeSize.Height() ) ) ); + aTypeSize = mpLbFillType->GetSizePixel(); + aAttrSize = mpLbFillAttr->GetSizePixel(); + Point aAttrPnt = mpLbFillAttr->GetPosPixel(); + SetSizePixel( + Size(aAttrPnt.X() + aAttrSize.Width(), + Max(aAttrSize.Height(),aTypeSize.Height()))); - pLbFillType->SetSelectHdl( LINK( this, FillControl, SelectFillTypeHdl ) ); - pLbFillAttr->SetSelectHdl( LINK( this, FillControl, SelectFillAttrHdl ) ); - - aDelayTimer.SetTimeout( DELAY_TIMEOUT ); - aDelayTimer.SetTimeoutHdl( LINK( this, FillControl, DelayHdl ) ); - aDelayTimer.Start(); + mpLbFillType->SetSelectHdl(LINK(this,FillControl,SelectFillTypeHdl)); + mpLbFillAttr->SetSelectHdl(LINK(this,FillControl,SelectFillAttrHdl)); } //------------------------------------------------------------------------ FillControl::~FillControl() { - delete pLbFillType; - delete pLbFillAttr; + delete mpLbFillType; + delete mpLbFillAttr; } //------------------------------------------------------------------------ -IMPL_LINK_INLINE_START( FillControl, DelayHdl, Timer *, EMPTYARG ) +void FillControl::InitializeFillStyleAccordingToGivenFillType(XFillStyle aFillStyle) { - SelectFillTypeHdl( NULL ); - ( (SvxFillToolBoxControl*)GetData() )->updateStatus( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillStyle" ))); -// ( (SvxFillToolBoxControl*)GetData() )->GetBindings().Invalidate( SID_ATTR_FILL_STYLE ); - return 0; + SfxObjectShell* pSh = SfxObjectShell::Current(); + bool bDone(false); + + if(pSh) + { + switch(aFillStyle) + { + case XFILL_SOLID: + { + if(pSh->GetItem(SID_COLOR_TABLE)) + { + SvxColorTableItem aItem(*(const SvxColorTableItem*)(pSh->GetItem(SID_COLOR_TABLE))); + mpLbFillAttr->Enable(); + mpLbFillAttr->Fill(aItem.GetColorTable()); + bDone = true; + } + break; + } + + case XFILL_GRADIENT: + { + if(pSh->GetItem(SID_GRADIENT_LIST)) + { + SvxGradientListItem aItem(*(const SvxGradientListItem*)(pSh->GetItem(SID_GRADIENT_LIST))); + mpLbFillAttr->Enable(); + mpLbFillAttr->Fill(aItem.GetGradientList()); + bDone = true; + } + break; + } + + case XFILL_HATCH: + { + if(pSh->GetItem(SID_HATCH_LIST)) + { + SvxHatchListItem aItem(*(const SvxHatchListItem*)(pSh->GetItem(SID_HATCH_LIST))); + mpLbFillAttr->Enable(); + mpLbFillAttr->Fill(aItem.GetHatchList()); + bDone = true; + } + break; + } + + case XFILL_BITMAP: + { + if(pSh->GetItem(SID_BITMAP_LIST)) + { + SvxBitmapListItem aItem(*(const SvxBitmapListItem*)(pSh->GetItem(SID_BITMAP_LIST))); + mpLbFillAttr->Enable(); + mpLbFillAttr->Fill(aItem.GetBitmapList()); + bDone = true; + } + break; + } + default: // XFILL_NONE + { + // clear list and accept disable + mpLbFillAttr->Clear(); + break; + } + } + } + + if(!bDone) + { + mpLbFillAttr->Disable(); + } } -IMPL_LINK_INLINE_END( FillControl, DelayHdl, Timer *, pTimer ) -//------------------------------------------------------------------------ +void FillControl::updateLastFillTypeControlSelectEntryPos() +{ + mnLastFillTypeControlSelectEntryPos = mpLbFillType->GetSelectEntryPos(); +} -IMPL_LINK( FillControl, SelectFillTypeHdl, ListBox *, pBox ) +IMPL_LINK(FillControl,SelectFillTypeHdl,ListBox *,pBox) { - XFillStyle eXFS = (XFillStyle)pLbFillType->GetSelectEntryPos(); + if(!pBox) // only work with real calls from ListBox, do not accept direct calls with zeros here + { + return 0; + } - // Spaeter sollte eine Optimierung derart erfolgen, dass die - // Listen, bzw. Tables nur dann geloescht und wieder aufgebaut - // werden, wenn sich die Listen, bzw. Tables tatsaechlich geaendert - // haben (in den LBs natuerlich). + const bool bAction( + !mpLbFillType->IsTravelSelect() // keep TravelSelect, this means keyboard up/down in the list + && mpLbFillType->GetSelectEntryCount() + && mpLbFillType->GetSelectEntryPos() != mnLastFillTypeControlSelectEntryPos); - if ( ( pBox && !pBox->IsTravelSelect() ) || !pBox ) - { - // Damit wir in folgendem Fall einen Status anzeigen koennen: - // Ein Typ wurde ausgewaehlt aber kein Attribut. - // Die Selektion hat genau die gleichen Attribute wie die vorherige. -// SvxFillToolBoxControl* pControlerItem = (SvxFillToolBoxControl*)GetData(); -// if( pControlerItem ) -// pControlerItem->ClearCache(); + updateLastFillTypeControlSelectEntryPos(); + XFillStyle eXFS = static_cast< XFillStyle >(mpLbFillType->GetSelectEntryPos()); - pLbFillAttr->Clear(); - SfxObjectShell* pSh = SfxObjectShell::Current(); + if(bAction && XFILL_NONE != eXFS) + { + mbFillTypeChanged = true; + } - switch( eXFS ) - { - case XFILL_NONE: - { - pLbFillType->Selected(); - SelectFillAttrHdl( pBox ); - pLbFillAttr->Disable(); - } - break; + InitializeFillStyleAccordingToGivenFillType(eXFS); - case XFILL_SOLID: - { - if ( pSh && pSh->GetItem( SID_COLOR_TABLE ) ) - { - SvxColorTableItem aItem( *(const SvxColorTableItem*)( - pSh->GetItem( SID_COLOR_TABLE ) ) ); - pLbFillAttr->Enable(); - pLbFillAttr->Fill( aItem.GetColorTable() ); - } - else - pLbFillAttr->Disable(); - } - break; + switch(eXFS) + { + case XFILL_NONE: + { + if(bAction) + { + // for XFILL_NONE do no longer call SelectFillAttrHdl, + // trigger needed actions directly + Any a; + Sequence< PropertyValue > aArgsFillStyle(1); + XFillStyleItem aXFillStyleItem(eXFS); - case XFILL_GRADIENT: - { - if ( pSh && pSh->GetItem( SID_GRADIENT_LIST ) ) - { - SvxGradientListItem aItem( *(const SvxGradientListItem*)( - pSh->GetItem( SID_GRADIENT_LIST ) ) ); - pLbFillAttr->Enable(); - pLbFillAttr->Fill( aItem.GetGradientList() ); - } - else - pLbFillAttr->Disable(); - } - break; + aArgsFillStyle[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FillStyle")); + aXFillStyleItem.QueryValue(a); + aArgsFillStyle[0].Value = a; + ((SvxFillToolBoxControl*)GetData())->Dispatch(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:FillStyle")), aArgsFillStyle); + } + break; + } - case XFILL_HATCH: - { - if ( pSh && pSh->GetItem( SID_HATCH_LIST ) ) - { - SvxHatchListItem aItem( *(const SvxHatchListItem*)( - pSh->GetItem( SID_HATCH_LIST ) ) ); - pLbFillAttr->Enable(); - pLbFillAttr->Fill( aItem.GetHatchList() ); - } - else - pLbFillAttr->Disable(); - } - break; + case XFILL_SOLID: + case XFILL_GRADIENT: + case XFILL_HATCH: + case XFILL_BITMAP: + { + InitializeFillStyleAccordingToGivenFillType(eXFS); + break; + } + } - case XFILL_BITMAP: - { - if ( pSh && pSh->GetItem( SID_BITMAP_LIST ) ) - { - SvxBitmapListItem aItem( *(const SvxBitmapListItem*)( - pSh->GetItem( SID_BITMAP_LIST ) ) ); - pLbFillAttr->Enable(); - pLbFillAttr->Fill( aItem.GetBitmapList() ); - } - else - pLbFillAttr->Disable(); - } - break; - } + mpLbFillType->Selected(); - if( eXFS != XFILL_NONE ) // Wurde schon erledigt - { - if ( pBox ) - pLbFillType->Selected(); + // release focus. Needed to get focus automatically back to EditView + if(mpLbFillType->IsRelease()) + { + SfxViewShell* pViewShell = SfxViewShell::Current(); - // release focus - if ( pBox && pLbFillType->IsRelease() ) - { - SfxViewShell* pViewShell = SfxViewShell::Current(); - if( pViewShell && pViewShell->GetWindow() ) - pViewShell->GetWindow()->GrabFocus(); - } - } + if(pViewShell && pViewShell->GetWindow()) + { + pViewShell->GetWindow()->GrabFocus(); + } } - return 0; + + return 0; } //------------------------------------------------------------------------ -IMPL_LINK( FillControl, SelectFillAttrHdl, ListBox *, pBox ) +void FillControl::updateLastFillAttrControlSelectEntryPos() { - XFillStyle eXFS = (XFillStyle)pLbFillType->GetSelectEntryPos(); - XFillStyleItem aXFillStyleItem( eXFS ); - sal_Bool bAction = pBox && !pLbFillAttr->IsTravelSelect(); + mnLastFillAttrControlSelectEntryPos = mpLbFillAttr->GetSelectEntryPos(); +} - SfxObjectShell* pSh = SfxObjectShell::Current(); - if ( bAction ) +IMPL_LINK(FillControl, SelectFillAttrHdl, ListBox *, pBox) +{ + if(!pBox) // only work with real calls from ListBox, do not accept direct calls with zeros here { + return 0; + } + + const bool bAction( + !mpLbFillAttr->IsTravelSelect() // keep TravelSelect, this means keyboard up/down in the list + && mpLbFillAttr->GetSelectEntryCount() + && mpLbFillAttr->GetSelectEntryPos() != mnLastFillAttrControlSelectEntryPos); + + updateLastFillAttrControlSelectEntryPos(); + + if(bAction) + { + SfxObjectShell* pSh = SfxObjectShell::Current(); + + // Need to prepare the PropertyValue for the FillStyle dispatch action early, + // else the call for FillType to Dispatch(".uno:FillStyle") will already destroy the current state + // of selection in mpLbFillAttr again by calls to StateChanged which *will* set to no + // selection again (e.g. when two objects, same fill style, but different fill attributes) Any a; - Sequence< PropertyValue > aArgs( 1 ); - - // First set the style - aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FillStyle" )); - aXFillStyleItem.QueryValue( a ); - aArgs[0].Value = a; - ((SvxFillToolBoxControl*)GetData())->Dispatch( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillStyle" )), aArgs ); + Sequence< PropertyValue > aArgsFillAttr(1); + ::rtl::OUString aFillAttrCommand; + XFillStyle eXFS(static_cast< XFillStyle >(mpLbFillType->GetSelectEntryPos())); - switch( eXFS ) + switch(eXFS) { case XFILL_NONE: { + // handled in SelectFillTypeHdl, nothing to do here + break; } - break; case XFILL_SOLID: { - // NEU //Eintrag wird auf temporaere Farbe geprueft - String aTmpStr = pLbFillAttr->GetSelectEntry(); - if( aTmpStr.GetChar(0) == TMP_STR_BEGIN && aTmpStr.GetChar(aTmpStr.Len()-1) == TMP_STR_END ) + String aTmpStr = mpLbFillAttr->GetSelectEntry(); + + if(aTmpStr.GetChar(0) == TMP_STR_BEGIN && aTmpStr.GetChar(aTmpStr.Len() - 1) == TMP_STR_END) { - aTmpStr.Erase( aTmpStr.Len()-1, 1 ); - aTmpStr.Erase( 0, 1 ); + aTmpStr.Erase(aTmpStr.Len() - 1,1); + aTmpStr.Erase(0,1); } - XFillColorItem aXFillColorItem( aTmpStr, pLbFillAttr->GetSelectEntryColor() ); - - aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FillColor" )); - aXFillColorItem.QueryValue( a ); - aArgs[0].Value = a; - ((SvxFillToolBoxControl*)GetData())->Dispatch( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillColor" )), - aArgs ); + XFillColorItem aXFillColorItem(aTmpStr,mpLbFillAttr->GetSelectEntryColor()); + aArgsFillAttr[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FillColor")); + aXFillColorItem.QueryValue(a); + aArgsFillAttr[0].Value = a; + aFillAttrCommand = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:FillColor")); + break; } - break; case XFILL_GRADIENT: { - sal_uInt16 nPos = pLbFillAttr->GetSelectEntryPos(); + sal_uInt16 nPos = mpLbFillAttr->GetSelectEntryPos(); - if ( nPos != LISTBOX_ENTRY_NOTFOUND && pSh && pSh->GetItem( SID_GRADIENT_LIST ) ) + if(nPos != LISTBOX_ENTRY_NOTFOUND && pSh && pSh->GetItem(SID_GRADIENT_LIST)) { - SvxGradientListItem aItem( - *(const SvxGradientListItem*)( pSh->GetItem( SID_GRADIENT_LIST ) ) ); + SvxGradientListItem aItem(*(const SvxGradientListItem*)(pSh->GetItem(SID_GRADIENT_LIST))); - if ( nPos < aItem.GetGradientList()->Count() ) // kein temp. Eintrag ? + if(nPos < aItem.GetGradientList()->Count()) // kein temp. Eintrag ? { - XGradient aGradient = aItem.GetGradientList()->GetGradient( nPos )->GetGradient(); - XFillGradientItem aXFillGradientItem( pLbFillAttr->GetSelectEntry(), aGradient ); - - aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FillGradient" )); - aXFillGradientItem.QueryValue( a ); - aArgs[0].Value = a; - ((SvxFillToolBoxControl*)GetData())->Dispatch( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillGradient" )), - aArgs ); + XGradient aGradient = aItem.GetGradientList()->GetGradient(nPos)->GetGradient(); + XFillGradientItem aXFillGradientItem(mpLbFillAttr->GetSelectEntry(),aGradient); + aArgsFillAttr[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FillGradient")); + aXFillGradientItem.QueryValue(a); + aArgsFillAttr[0].Value = a; + aFillAttrCommand = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:FillGradient")); } } + break; } - break; case XFILL_HATCH: { - sal_uInt16 nPos = pLbFillAttr->GetSelectEntryPos(); + sal_uInt16 nPos = mpLbFillAttr->GetSelectEntryPos(); - if ( nPos != LISTBOX_ENTRY_NOTFOUND && pSh && pSh->GetItem( SID_HATCH_LIST ) ) + if(nPos != LISTBOX_ENTRY_NOTFOUND && pSh && pSh->GetItem(SID_HATCH_LIST)) { - SvxHatchListItem aItem( *(const SvxHatchListItem*)( pSh->GetItem( SID_HATCH_LIST ) ) ); + SvxHatchListItem aItem(*(const SvxHatchListItem*)(pSh->GetItem(SID_HATCH_LIST))); - if ( nPos < aItem.GetHatchList()->Count() ) // kein temp. Eintrag ? + if(nPos < aItem.GetHatchList()->Count()) // kein temp. Eintrag ? { - XHatch aHatch = aItem.GetHatchList()->GetHatch( nPos )->GetHatch(); - XFillHatchItem aXFillHatchItem( pLbFillAttr->GetSelectEntry(), aHatch ); + XHatch aHatch = aItem.GetHatchList()->GetHatch(nPos)->GetHatch(); + XFillHatchItem aXFillHatchItem(mpLbFillAttr->GetSelectEntry(),aHatch); - aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FillHatch" )); - aXFillHatchItem.QueryValue( a ); - aArgs[0].Value = a; - ((SvxFillToolBoxControl*)GetData())->Dispatch( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillHatch" )), - aArgs ); + aArgsFillAttr[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FillHatch")); + aXFillHatchItem.QueryValue(a); + aArgsFillAttr[0].Value = a; + aFillAttrCommand = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:FillHatch")); } } + break; } - break; case XFILL_BITMAP: { - sal_uInt16 nPos = pLbFillAttr->GetSelectEntryPos(); + sal_uInt16 nPos = mpLbFillAttr->GetSelectEntryPos(); - if ( nPos != LISTBOX_ENTRY_NOTFOUND && pSh && pSh->GetItem( SID_BITMAP_LIST ) ) + if(nPos != LISTBOX_ENTRY_NOTFOUND && pSh && pSh->GetItem(SID_BITMAP_LIST)) { - SvxBitmapListItem aItem( - *(const SvxBitmapListItem*)( pSh->GetItem( SID_BITMAP_LIST ) ) ); + SvxBitmapListItem aItem(*(const SvxBitmapListItem*)(pSh->GetItem(SID_BITMAP_LIST))); - if ( nPos < aItem.GetBitmapList()->Count() ) // kein temp. Eintrag ? + if(nPos < aItem.GetBitmapList()->Count()) // kein temp. Eintrag ? { const XBitmapEntry* pXBitmapEntry = aItem.GetBitmapList()->GetBitmap(nPos); - const XFillBitmapItem aXFillBitmapItem(pLbFillAttr->GetSelectEntry(), pXBitmapEntry->GetGraphicObject()); + const XFillBitmapItem aXFillBitmapItem(mpLbFillAttr->GetSelectEntry(),pXBitmapEntry->GetGraphicObject()); - aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FillBitmap" )); - aXFillBitmapItem.QueryValue( a ); - aArgs[0].Value = a; - ((SvxFillToolBoxControl*)GetData())->Dispatch(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:FillBitmap")), aArgs); + aArgsFillAttr[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FillBitmap")); + aXFillBitmapItem.QueryValue(a); + aArgsFillAttr[0].Value = a; + aFillAttrCommand = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:FillBitmap")); } } + break; } - break; } - // release focus - if ( pLbFillAttr->IsRelease() && pBox ) - { - SfxViewShell* pViewShell = SfxViewShell::Current(); - if( pViewShell && pViewShell->GetWindow() ) - { - pViewShell->GetWindow()->GrabFocus(); - } - } + // first set the fill style if changed + if(mbFillTypeChanged) + { + Sequence< PropertyValue > aArgsFillStyle(1); + XFillStyleItem aXFillStyleItem(eXFS); + + aArgsFillStyle[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FillStyle")); + aXFillStyleItem.QueryValue(a); + aArgsFillStyle[0].Value = a; + ((SvxFillToolBoxControl*)GetData())->Dispatch(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:FillStyle")), aArgsFillStyle); + mbFillTypeChanged = false; + } + + if(aFillAttrCommand.getLength()) + { + ((SvxFillToolBoxControl*)GetData())->Dispatch(aFillAttrCommand, aArgsFillAttr); + } + + // release focus. Needed to get focus automatically back to EditView + if(mpLbFillAttr->IsRelease() && pBox) + { + SfxViewShell* pViewShell = SfxViewShell::Current(); + + if(pViewShell && pViewShell->GetWindow()) + { + pViewShell->GetWindow()->GrabFocus(); + } + } } return 0; @@ -794,36 +864,38 @@ void FillControl::Resize() { - // Breite der beiden ListBoxen nicht 1/2 : 1/2, sondern 2/5 : 3/5 - long nW = GetOutputSizePixel().Width() / 5; - long nH = 180; - long nSep = 0; // war vorher 4 + // Breite der beiden ListBoxen nicht 1/2 : 1/2, sondern 2/5 : 3/5 + long nW = GetOutputSizePixel().Width() / 5; + long nH = 180; + long nSep = 0; // war vorher 4 - pLbFillType->SetSizePixel( Size( nW * 2 - nSep, nH ) ); - pLbFillAttr->SetPosSizePixel( Point( nW * 2 + nSep, 0 ), Size( nW * 3 - nSep, nH ) ); + mpLbFillType->SetSizePixel(Size(nW * 2 - nSep,nH)); + mpLbFillAttr->SetPosSizePixel(Point(nW * 2 + nSep,0),Size(nW * 3 - nSep,nH)); } -/* -----------------------------08.03.2002 15:04------------------------------ - ---------------------------------------------------------------------------*/ +//------------------------------------------------------------------------ -void FillControl::DataChanged( const DataChangedEvent& rDCEvt ) +void FillControl::DataChanged(const DataChangedEvent& rDCEvt) { - if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && - (rDCEvt.GetFlags() & SETTINGS_STYLE) ) + if((rDCEvt.GetType() == DATACHANGED_SETTINGS) && + (rDCEvt.GetFlags() & SETTINGS_STYLE)) { - Size aTypeSize(LogicToPixel(aLogicalFillSize, MAP_APPFONT)); - Size aAttrSize(LogicToPixel(aLogicalAttrSize, MAP_APPFONT)); - pLbFillType->SetSizePixel(aTypeSize); - pLbFillAttr->SetSizePixel(aAttrSize); + Size aTypeSize(LogicToPixel(maLogicalFillSize,MAP_APPFONT)); + Size aAttrSize(LogicToPixel(maLogicalAttrSize,MAP_APPFONT)); + mpLbFillType->SetSizePixel(aTypeSize); + mpLbFillAttr->SetSizePixel(aAttrSize); + //to get the base height - aTypeSize = pLbFillType->GetSizePixel(); - aAttrSize = pLbFillAttr->GetSizePixel(); - Point aAttrPnt = pLbFillAttr->GetPosPixel(); + aTypeSize = mpLbFillType->GetSizePixel(); + aAttrSize = mpLbFillAttr->GetSizePixel(); + Point aAttrPnt = mpLbFillAttr->GetPosPixel(); SetSizePixel( - Size( aAttrPnt.X() + aAttrSize.Width(), - Max( aAttrSize.Height(), aTypeSize.Height() ) ) ); + Size(aAttrPnt.X() + aAttrSize.Width(), + Max(aAttrSize.Height(),aTypeSize.Height()))); } - Window::DataChanged( rDCEvt ); + Window::DataChanged(rDCEvt); } +//------------------------------------------------------------------------ +//eof