Kaydet (Commit) 0f61a89e authored tarafından Armin Le Grand's avatar Armin Le Grand Kaydeden (comit) Caolán McNamara

Resolves: #i125065# handle critical cases in FillStyle/FillProperties...

toolbar combination
(cherry picked from commit 0ce4a90e)

Conflicts:
	include/svx/fillctrl.hxx
	svx/source/tbxctrls/fillctrl.cxx

Change-Id: I9a1b2490a7e9285559dddd4df7fb20c2216fd450
üst 7b811b68
...@@ -40,32 +40,33 @@ class ListBox; ...@@ -40,32 +40,33 @@ class ListBox;
|* |*
\************************************************************************/ \************************************************************************/
class SVX_DLLPUBLIC SvxFillToolBoxControl: public SfxToolBoxControl class SVX_DLLPUBLIC SvxFillToolBoxControl : public SfxToolBoxControl
{ {
private: private:
XFillStyleItem* pStyleItem; XFillStyleItem* mpStyleItem;
XFillColorItem* pColorItem; XFillColorItem* mpColorItem;
XFillGradientItem* pGradientItem; XFillGradientItem* mpGradientItem;
XFillHatchItem* pHatchItem; XFillHatchItem* mpHatchItem;
XFillBitmapItem* pBitmapItem; XFillBitmapItem* mpBitmapItem;
FillControl* pFillControl; FillControl* mpFillControl;
SvxFillTypeBox* pFillTypeLB; SvxFillTypeBox* mpFillTypeLB;
SvxFillAttrBox* pFillAttrLB; SvxFillAttrBox* mpFillAttrLB;
bool bUpdate; XFillStyle meLastXFS;
sal_uInt16 eLastXFS;
/// bitfield
bool mbUpdate:1;
public: public:
SFX_DECL_TOOLBOX_CONTROL(); SFX_DECL_TOOLBOX_CONTROL();
SvxFillToolBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ); SvxFillToolBoxControl(sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx);
virtual ~SvxFillToolBoxControl(); virtual ~SvxFillToolBoxControl();
virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, virtual void StateChanged(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState) SAL_OVERRIDE;
const SfxPoolItem* pState ) SAL_OVERRIDE; void Update(const SfxPoolItem* pState);
void Update( const SfxPoolItem* pState ); virtual Window* CreateItemWindow(Window* pParent) SAL_OVERRIDE;
virtual Window* CreateItemWindow( Window *pParent ) SAL_OVERRIDE;
}; };
...@@ -75,18 +76,29 @@ class FillControl : public Window ...@@ -75,18 +76,29 @@ class FillControl : public Window
private: private:
friend class SvxFillToolBoxControl; friend class SvxFillToolBoxControl;
SvxFillTypeBox* pLbFillType; SvxFillTypeBox* mpLbFillType;
SvxFillAttrBox* pLbFillAttr; SvxFillAttrBox* mpLbFillAttr;
Size aLogicalFillSize; Size maLogicalFillSize;
Size aLogicalAttrSize; Size maLogicalAttrSize;
Timer aDelayTimer;
//
sal_uInt16 mnLastFillTypeControlSelectEntryPos;
sal_uInt16 mnLastFillAttrControlSelectEntryPos;
/// bitfield
bool mbFillTypeChanged : 1;
DECL_LINK(SelectFillTypeHdl,ListBox *);
DECL_LINK(SelectFillAttrHdl,ListBox *);
virtual void DataChanged(const DataChangedEvent& rDCEvt) SAL_OVERRIDE;
void InitializeFillStyleAccordingToGivenFillType(XFillStyle eFillStyle);
void updateLastFillTypeControlSelectEntryPos();
void updateLastFillAttrControlSelectEntryPos();
DECL_LINK( DelayHdl, void * );
DECL_LINK( SelectFillTypeHdl, ListBox * );
DECL_LINK( SelectFillAttrHdl, ListBox * );
virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
public: public:
FillControl( Window* pParent, WinBits nStyle = 0 ); FillControl(Window* pParent, WinBits nStyle = 0);
virtual ~FillControl(); virtual ~FillControl();
virtual void Resize() SAL_OVERRIDE; virtual void Resize() SAL_OVERRIDE;
......
...@@ -26,8 +26,6 @@ ...@@ -26,8 +26,6 @@
#include <vcl/settings.hxx> #include <vcl/settings.hxx>
#include <svx/dialogs.hrc> #include <svx/dialogs.hrc>
#define DELAY_TIMEOUT 300
#define TMP_STR_BEGIN "[" #define TMP_STR_BEGIN "["
#define TMP_STR_END "]" #define TMP_STR_END "]"
...@@ -52,20 +50,21 @@ SFX_IMPL_TOOLBOX_CONTROL( SvxFillToolBoxControl, XFillStyleItem ); ...@@ -52,20 +50,21 @@ SFX_IMPL_TOOLBOX_CONTROL( SvxFillToolBoxControl, XFillStyleItem );
|* SvxFillToolBoxControl |* SvxFillToolBoxControl
|* |*
\************************************************************************/ \************************************************************************/
SvxFillToolBoxControl::SvxFillToolBoxControl(
SvxFillToolBoxControl::SvxFillToolBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) : sal_uInt16 nSlotId,
SfxToolBoxControl( nSlotId, nId, rTbx ), sal_uInt16 nId,
ToolBox& rTbx )
pStyleItem ( NULL ), : SfxToolBoxControl( nSlotId, nId, rTbx )
pColorItem ( NULL ), , mpStyleItem(0)
pGradientItem ( NULL ), , mpColorItem(0)
pHatchItem ( NULL ), , mpGradientItem(0)
pBitmapItem ( NULL ), , mpHatchItem(0)
pFillControl ( NULL ), , mpBitmapItem(0)
pFillTypeLB ( NULL ), , mpFillControl(0)
pFillAttrLB ( NULL ), , mpFillTypeLB(0)
bUpdate ( false ), , mpFillAttrLB(0)
eLastXFS ( XFILL_NONE ) , meLastXFS(XFILL_NONE)
, mbUpdate(false)
{ {
addStatusListener( OUString( ".uno:FillColor" )); addStatusListener( OUString( ".uno:FillColor" ));
addStatusListener( OUString( ".uno:FillGradient" )); addStatusListener( OUString( ".uno:FillGradient" ));
...@@ -81,134 +80,146 @@ SvxFillToolBoxControl::SvxFillToolBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId ...@@ -81,134 +80,146 @@ SvxFillToolBoxControl::SvxFillToolBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId
SvxFillToolBoxControl::~SvxFillToolBoxControl() SvxFillToolBoxControl::~SvxFillToolBoxControl()
{ {
delete pStyleItem; delete mpStyleItem;
delete pColorItem; delete mpColorItem;
delete pGradientItem; delete mpGradientItem;
delete pHatchItem; delete mpHatchItem;
delete pBitmapItem; delete mpBitmapItem;
} }
void SvxFillToolBoxControl::StateChanged( void SvxFillToolBoxControl::StateChanged(
sal_uInt16 nSID,
sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState ) SfxItemState eState,
const SfxPoolItem* pState)
{ {
if(eState == SFX_ITEM_DISABLED)
if( eState == SFX_ITEM_DISABLED )
{ {
if( nSID == SID_ATTR_FILL_STYLE ) // slot disable state
if(nSID == SID_ATTR_FILL_STYLE)
{ {
pFillTypeLB->Disable(); mpFillTypeLB->Disable();
pFillTypeLB->SetNoSelection(); mpFillTypeLB->SetNoSelection();
} }
pFillAttrLB->Disable();
pFillAttrLB->SetNoSelection(); mpFillAttrLB->Disable();
mpFillAttrLB->SetNoSelection();
} }
else else if(SFX_ITEM_AVAILABLE == eState)
{ {
if ( SFX_ITEM_AVAILABLE == eState ) bool bEnableControls(false);
// slot available state
if(nSID == SID_ATTR_FILL_STYLE)
{ {
bool bEnableControls = false; delete mpStyleItem;
if( nSID == SID_ATTR_FILL_STYLE ) mpStyleItem = static_cast< XFillStyleItem* >(pState->Clone());
{ mpFillTypeLB->Enable();
delete pStyleItem; }
pStyleItem = (XFillStyleItem*) pState->Clone(); else if(mpStyleItem)
pFillTypeLB->Enable(); {
} const XFillStyle eXFS(static_cast< XFillStyle >(mpStyleItem->GetValue()));
else if( pStyleItem )
if(nSID == SID_ATTR_FILL_COLOR)
{ {
XFillStyle eXFS = (XFillStyle)pStyleItem->GetValue(); delete mpColorItem;
mpColorItem = static_cast< XFillColorItem* >(pState->Clone());
if( nSID == SID_ATTR_FILL_COLOR ) if(eXFS == XFILL_SOLID)
{ {
delete pColorItem; bEnableControls = true;
pColorItem = (XFillColorItem*) pState->Clone();
if( eXFS == XFILL_SOLID )
bEnableControls = true;
} }
else if( nSID == SID_ATTR_FILL_GRADIENT ) }
{ else if(nSID == SID_ATTR_FILL_GRADIENT)
delete pGradientItem; {
pGradientItem = (XFillGradientItem*) pState->Clone(); delete mpGradientItem;
mpGradientItem = static_cast< XFillGradientItem* >(pState->Clone());
if( eXFS == XFILL_GRADIENT ) if(eXFS == XFILL_GRADIENT)
bEnableControls = true;
}
else if( nSID == SID_ATTR_FILL_HATCH )
{ {
delete pHatchItem; bEnableControls = true;
pHatchItem = (XFillHatchItem*) pState->Clone();
if( eXFS == XFILL_HATCH )
bEnableControls = true;
} }
else if( nSID == SID_ATTR_FILL_BITMAP ) }
{ else if(nSID == SID_ATTR_FILL_HATCH)
delete pBitmapItem; {
pBitmapItem = (XFillBitmapItem*) pState->Clone(); delete mpHatchItem;
mpHatchItem = static_cast< XFillHatchItem* >(pState->Clone());
if( eXFS == XFILL_BITMAP ) if(eXFS == XFILL_HATCH)
bEnableControls = true; {
bEnableControls = true;
} }
} }
else if(nSID == SID_ATTR_FILL_BITMAP)
if( pStyleItem )
{ {
// ensure that the correct entry is selected in pFillTypeLB. It delete mpBitmapItem;
// might have been changed by nSID == SID_ATTR_FILL_STYLE, but mpBitmapItem = static_cast< XFillBitmapItem* >(pState->Clone());
// it might also be in an in-between state when user had started to
// change fillstyle, but not yet changed fillvalue for new style if(eXFS == XFILL_BITMAP)
// 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();
if(eLastXFS != eXFS)
{ {
bUpdate = true; bEnableControls = true;
pFillTypeLB->SelectEntryPos( eXFS );
} }
pFillAttrLB->Enable();
} }
}
if(mpStyleItem)
{
// ensure that the correct entry is selected in mpFillTypeLB
XFillStyle eXFS(static_cast< XFillStyle >(mpStyleItem->GetValue()));
const bool bFillTypeChangedByUser(mpFillControl->mbFillTypeChanged);
if( bEnableControls ) if(bFillTypeChangedByUser)
{ {
//pFillTypeLB->Enable(); meLastXFS = static_cast< XFillStyle >(mpFillControl->mnLastFillTypeControlSelectEntryPos);
pFillAttrLB->Enable(); mpFillControl->mbFillTypeChanged = false;
}
bUpdate = true; if(meLastXFS != eXFS)
{
mbUpdate = true;
mpFillTypeLB->SelectEntryPos(sal::static_int_cast<sal_uInt16>(eXFS));
} }
Update( pState ); mpFillAttrLB->Enable();
}
if(bEnableControls)
{
mpFillAttrLB->Enable();
mbUpdate = true;
}
Update(pState);
}
else
{
// slot empty or ambigous
if(nSID == SID_ATTR_FILL_STYLE)
{
mpFillTypeLB->SetNoSelection();
mpFillAttrLB->Disable();
mpFillAttrLB->SetNoSelection();
delete mpStyleItem;
mpStyleItem = 0;
mbUpdate = false;
} }
else else
{ {
// empty or ambiguous status XFillStyle eXFS(XFILL_NONE);
if( nSID == SID_ATTR_FILL_STYLE )
if(mpStyleItem)
{ {
pFillTypeLB->SetNoSelection(); eXFS = static_cast< XFillStyle >(mpStyleItem->GetValue());
pFillAttrLB->Disable();
pFillAttrLB->SetNoSelection();
bUpdate = false;
} }
else
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))
{ {
XFillStyle eXFS = XFILL_NONE; mpFillAttrLB->SetNoSelection();
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;
}
} }
} }
} }
...@@ -216,102 +227,106 @@ void SvxFillToolBoxControl::StateChanged( ...@@ -216,102 +227,106 @@ void SvxFillToolBoxControl::StateChanged(
void SvxFillToolBoxControl::Update( const SfxPoolItem* pState ) void SvxFillToolBoxControl::Update(const SfxPoolItem* pState)
{ {
if ( pStyleItem && pState && bUpdate ) if(mpStyleItem && pState && mbUpdate)
{ {
bUpdate = false; mbUpdate = false;
const XFillStyle eXFS(static_cast< XFillStyle >(mpStyleItem->GetValue()));
XFillStyle eXFS = (XFillStyle)pStyleItem->GetValue();
// Check if the fill style was already active // Check if the fill style was already active
//if( eTmpXFS != eXFS ) if(meLastXFS != eXFS)
if( (XFillStyle) eLastXFS != eXFS ) {
pFillControl->SelectFillTypeHdl( NULL ); // update mnLastFillTypeControlSelectEntryPos and fill style list
//eLastXFS = eXFS; mpFillControl->updateLastFillTypeControlSelectEntryPos();
mpFillControl->InitializeFillStyleAccordingToGivenFillType(eXFS);
meLastXFS = eXFS;
}
switch( eXFS ) switch(eXFS)
{ {
case XFILL_NONE: case XFILL_NONE:
break; {
break;
}
case XFILL_SOLID: case XFILL_SOLID:
{ {
if ( pColorItem ) if(mpColorItem)
{ {
OUString aString( pColorItem->GetName() ); OUString aString(mpColorItem->GetName());
::Color aColor = pColorItem->GetColorValue(); ::Color aColor = mpColorItem->GetColorValue();
pFillAttrLB->SelectEntry( aString ); mpFillAttrLB->SelectEntry(aString);
if ( pFillAttrLB->GetSelectEntryPos() == LISTBOX_ENTRY_NOTFOUND || if(mpFillAttrLB->GetSelectEntryPos() == LISTBOX_ENTRY_NOTFOUND || mpFillAttrLB->GetSelectEntryColor() != aColor)
pFillAttrLB->GetSelectEntryColor() != aColor ) {
pFillAttrLB->SelectEntry( aColor ); mpFillAttrLB->SelectEntry(aColor);
}
// Check if the entry is not in the list // Check if the entry is not in the list
if( pFillAttrLB->GetSelectEntryPos() == if( mpFillAttrLB->GetSelectEntryPos() ==
LISTBOX_ENTRY_NOTFOUND || LISTBOX_ENTRY_NOTFOUND ||
pFillAttrLB->GetSelectEntryColor() != aColor ) mpFillAttrLB->GetSelectEntryColor() != aColor )
{ {
sal_Int32 nCount = pFillAttrLB->GetEntryCount(); sal_Int32 nCount = mpFillAttrLB->GetEntryCount();
OUString aTmpStr; OUString aTmpStr;
if( nCount > 0 ) if( nCount > 0 )
{ {
// Last entry gets tested against temporary color // Last entry gets tested against temporary color
aTmpStr = pFillAttrLB->GetEntry( nCount - 1 ); aTmpStr = mpFillAttrLB->GetEntry( nCount - 1 );
if( aTmpStr.startsWith(TMP_STR_BEGIN) && if( aTmpStr.startsWith(TMP_STR_BEGIN) &&
aTmpStr.endsWith(TMP_STR_END) ) aTmpStr.endsWith(TMP_STR_END) )
{ {
pFillAttrLB->RemoveEntry( nCount - 1 ); mpFillAttrLB->RemoveEntry(nCount - 1);
} }
} }
aTmpStr = TMP_STR_BEGIN + aString + TMP_STR_END; aTmpStr = TMP_STR_BEGIN + aString + TMP_STR_END;
//pFillAttrLB->SetUpdateMode( sal_False ); sal_Int32 nPos = mpFillAttrLB->InsertEntry(aColor, aTmpStr);
sal_Int32 nPos = pFillAttrLB->InsertEntry( aColor, aTmpStr ); mpFillAttrLB->SelectEntryPos(nPos);
//pFillAttrLB->SetUpdateMode( sal_True );
pFillAttrLB->SelectEntryPos( nPos );
} }
} }
else else
pFillAttrLB->SetNoSelection(); {
mpFillAttrLB->SetNoSelection();
}
break;
} }
break;
case XFILL_GRADIENT: case XFILL_GRADIENT:
{ {
if ( pGradientItem ) if(mpGradientItem)
{ {
OUString aString( pGradientItem->GetName() ); OUString aString(mpGradientItem->GetName());
pFillAttrLB->SelectEntry( aString ); mpFillAttrLB->SelectEntry( aString );
// Check if the entry is not in the list // Check if the entry is not in the list
if( pFillAttrLB->GetSelectEntry() != aString ) if (mpFillAttrLB->GetSelectEntry() != aString)
{ {
sal_Int32 nCount = pFillAttrLB->GetEntryCount(); sal_Int32 nCount = mpFillAttrLB->GetEntryCount();
OUString aTmpStr; OUString aTmpStr;
if( nCount > 0 ) if( nCount > 0 )
{ {
// Last entry gets tested against temporary entry // Last entry gets tested against temporary entry
aTmpStr = pFillAttrLB->GetEntry( nCount - 1 ); aTmpStr = mpFillAttrLB->GetEntry( nCount - 1 );
if( aTmpStr.startsWith(TMP_STR_BEGIN) && if( aTmpStr.startsWith(TMP_STR_BEGIN) &&
aTmpStr.endsWith(TMP_STR_END) ) aTmpStr.endsWith(TMP_STR_END) )
{ {
pFillAttrLB->RemoveEntry( nCount - 1 ); mpFillAttrLB->RemoveEntry(nCount - 1);
} }
} }
aTmpStr = TMP_STR_BEGIN + aString + TMP_STR_END; aTmpStr = TMP_STR_BEGIN + aString + TMP_STR_END;
XGradientEntry* pEntry = new XGradientEntry( pGradientItem->GetGradientValue(), aTmpStr ); XGradientEntry* pEntry = new XGradientEntry(mpGradientItem->GetGradientValue(), aTmpStr);
XGradientList aGradientList( "", ""/*TODO?*/ ); XGradientList aGradientList( "", ""/*TODO?*/ );
aGradientList.Insert( pEntry ); aGradientList.Insert( pEntry );
aGradientList.SetDirty( false ); aGradientList.SetDirty( false );
const Bitmap aBmp = aGradientList.GetUiBitmap( 0 ); const Bitmap aBmp = aGradientList.GetUiBitmap( 0 );
if( !aBmp.IsEmpty() ) if(!aBmp.IsEmpty())
{ {
pFillAttrLB->InsertEntry(pEntry->GetName(), Image(aBmp)); mpFillAttrLB->InsertEntry(pEntry->GetName(), Image(aBmp));
pFillAttrLB->SelectEntryPos( pFillAttrLB->GetEntryCount() - 1 ); mpFillAttrLB->SelectEntryPos(mpFillAttrLB->GetEntryCount() - 1);
//delete pBmp;
} }
aGradientList.Remove( 0 ); aGradientList.Remove( 0 );
...@@ -319,44 +334,45 @@ void SvxFillToolBoxControl::Update( const SfxPoolItem* pState ) ...@@ -319,44 +334,45 @@ void SvxFillToolBoxControl::Update( const SfxPoolItem* pState )
} }
} }
else else
pFillAttrLB->SetNoSelection(); {
mpFillAttrLB->SetNoSelection();
}
break;
} }
break;
case XFILL_HATCH: case XFILL_HATCH:
{ {
if ( pHatchItem ) if(mpHatchItem)
{ {
OUString aString( pHatchItem->GetName() ); OUString aString(mpHatchItem->GetName());
pFillAttrLB->SelectEntry( aString ); mpFillAttrLB->SelectEntry( aString );
// Check if the entry is not in the list // Check if the entry is not in the list
if( pFillAttrLB->GetSelectEntry() != aString ) if (mpFillAttrLB->GetSelectEntry() != aString)
{ {
sal_Int32 nCount = pFillAttrLB->GetEntryCount(); sal_Int32 nCount = mpFillAttrLB->GetEntryCount();
OUString aTmpStr; OUString aTmpStr;
if( nCount > 0 ) if( nCount > 0 )
{ {
// Last entry gets tested against temporary entry // Last entry gets tested against temporary entry
aTmpStr = pFillAttrLB->GetEntry( nCount - 1 ); aTmpStr = mpFillAttrLB->GetEntry( nCount - 1 );
if( aTmpStr.startsWith(TMP_STR_BEGIN) && if( aTmpStr.startsWith(TMP_STR_BEGIN) &&
aTmpStr.endsWith(TMP_STR_END) ) aTmpStr.endsWith(TMP_STR_END) )
{ {
pFillAttrLB->RemoveEntry( nCount - 1 ); mpFillAttrLB->RemoveEntry(nCount - 1);
} }
} }
aTmpStr = TMP_STR_BEGIN + aString + TMP_STR_END; aTmpStr = TMP_STR_BEGIN + aString + TMP_STR_END;
XHatchEntry* pEntry = new XHatchEntry( pHatchItem->GetHatchValue(), aTmpStr ); XHatchEntry* pEntry = new XHatchEntry(mpHatchItem->GetHatchValue(), aTmpStr);
XHatchList aHatchList( "", ""/*TODO?*/ ); XHatchList aHatchList( "", ""/*TODO?*/ );
aHatchList.Insert( pEntry ); aHatchList.Insert( pEntry );
aHatchList.SetDirty( false ); aHatchList.SetDirty( false );
const Bitmap aBmp = aHatchList.GetUiBitmap( 0 ); const Bitmap aBmp = aHatchList.GetUiBitmap( 0 );
if( !aBmp.IsEmpty() ) if(!aBmp.IsEmpty())
{ {
pFillAttrLB->InsertEntry(pEntry->GetName(), Image(aBmp)); mpFillAttrLB->InsertEntry(pEntry->GetName(), Image(aBmp));
pFillAttrLB->SelectEntryPos( pFillAttrLB->GetEntryCount() - 1 ); mpFillAttrLB->SelectEntryPos(mpFillAttrLB->GetEntryCount() - 1);
//delete pBmp;
} }
aHatchList.Remove( 0 ); aHatchList.Remove( 0 );
...@@ -364,121 +380,159 @@ void SvxFillToolBoxControl::Update( const SfxPoolItem* pState ) ...@@ -364,121 +380,159 @@ void SvxFillToolBoxControl::Update( const SfxPoolItem* pState )
} }
} }
else else
pFillAttrLB->SetNoSelection(); {
mpFillAttrLB->SetNoSelection();
}
break;
} }
break;
case XFILL_BITMAP: case XFILL_BITMAP:
{ {
if ( pBitmapItem ) if(mpBitmapItem)
// &&
// SfxObjectShell::Current() &&
// SfxObjectShell::Current()->GetItem( SID_BITMAP_LIST ) )
{ {
OUString aString( pBitmapItem->GetName() ); OUString aString(mpBitmapItem->GetName());
// Bitmap aBitmap( pBitmapItem->GetValue() ); mpFillAttrLB->SelectEntry( aString );
// SvxBitmapListItem aItem( *(const SvxBitmapListItem*)(
// SfxObjectShell::Current()->GetItem( SID_BITMAP_LIST ) ) );
pFillAttrLB->SelectEntry( aString );
// Check if the entry is not in the list // Check if the entry is not in the list
if( pFillAttrLB->GetSelectEntry() != aString ) if (mpFillAttrLB->GetSelectEntry() != aString)
{ {
sal_Int32 nCount = pFillAttrLB->GetEntryCount(); sal_Int32 nCount = mpFillAttrLB->GetEntryCount();
OUString aTmpStr; OUString aTmpStr;
if( nCount > 0 ) if( nCount > 0 )
{ {
// Last entry gets tested against temporary entry // Last entry gets tested against temporary entry
aTmpStr = pFillAttrLB->GetEntry( nCount - 1 ); aTmpStr = mpFillAttrLB->GetEntry(nCount - 1);
if( aTmpStr.startsWith(TMP_STR_BEGIN) && if( aTmpStr.startsWith(TMP_STR_BEGIN) &&
aTmpStr.endsWith(TMP_STR_END) ) aTmpStr.endsWith(TMP_STR_END) )
{ {
pFillAttrLB->RemoveEntry( nCount - 1 ); mpFillAttrLB->RemoveEntry(nCount - 1);
} }
} }
aTmpStr = TMP_STR_BEGIN + aString + TMP_STR_END; aTmpStr = TMP_STR_BEGIN + aString + TMP_STR_END;
XBitmapEntry* pEntry = new XBitmapEntry(pBitmapItem->GetGraphicObject(), aTmpStr); XBitmapEntry* pEntry = new XBitmapEntry(mpBitmapItem->GetGraphicObject(), aTmpStr);
XBitmapListRef xBitmapList = XBitmapListRef xBitmapList =
XPropertyList::CreatePropertyList(XBITMAP_LIST, XPropertyList::CreatePropertyList(XBITMAP_LIST,
OUString("TmpList"), ""/*TODO?*/)->AsBitmapList(); OUString("TmpList"), ""/*TODO?*/)->AsBitmapList();
xBitmapList->Insert( pEntry ); xBitmapList->Insert( pEntry );
xBitmapList->SetDirty( false ); xBitmapList->SetDirty( false );
pFillAttrLB->Fill( xBitmapList ); mpFillAttrLB->Fill( xBitmapList );
pFillAttrLB->SelectEntryPos( pFillAttrLB->GetEntryCount() - 1 ); mpFillAttrLB->SelectEntryPos(mpFillAttrLB->GetEntryCount() - 1);
xBitmapList->Remove( 0 ); xBitmapList->Remove( 0 );
delete pEntry; delete pEntry;
} }
} }
else else
pFillAttrLB->SetNoSelection(); {
mpFillAttrLB->SetNoSelection();
}
break;
} }
break;
default: default:
{
OSL_FAIL( "Unsupported fill type" ); OSL_FAIL( "Unsupported fill type" );
break; break;
}
} }
// update mnLastFillAttrControlSelectEntryPos
mpFillControl->updateLastFillAttrControlSelectEntryPos();
} }
if( pState && pStyleItem ) if(pState && mpStyleItem)
{ {
XFillStyle eXFS = (XFillStyle) pStyleItem->GetValue(); XFillStyle eXFS = static_cast< XFillStyle >(mpStyleItem->GetValue());
// Does the lists have changed? // Does the lists have changed?
if( pState->ISA( SvxColorListItem ) && switch(eXFS)
eXFS == XFILL_SOLID )
{ {
::Color aTmpColor( pFillAttrLB->GetSelectEntryColor() ); case XFILL_SOLID:
pFillAttrLB->Clear(); {
pFillAttrLB->Fill( ( (SvxColorListItem*)pState )->GetColorList() ); const SvxColorListItem* pItem = dynamic_cast< const SvxColorListItem* >(pState);
pFillAttrLB->SelectEntry( aTmpColor );
} if(pItem)
if( pState->ISA( SvxGradientListItem ) && {
eXFS == XFILL_GRADIENT ) ::Color aTmpColor(mpFillAttrLB->GetSelectEntryColor());
{ mpFillAttrLB->Clear();
OUString aString( pFillAttrLB->GetSelectEntry() ); mpFillAttrLB->Fill(pItem->GetColorList());
pFillAttrLB->Clear(); mpFillAttrLB->SelectEntry(aTmpColor);
pFillAttrLB->Fill( ( (SvxGradientListItem*)pState )->GetGradientList() ); }
pFillAttrLB->SelectEntry( aString ); break;
} }
if( pState->ISA( SvxHatchListItem ) && case XFILL_GRADIENT:
eXFS == XFILL_HATCH ) {
{ const SvxGradientListItem* pItem = dynamic_cast< const SvxGradientListItem* >(pState);
OUString aString( pFillAttrLB->GetSelectEntry() );
pFillAttrLB->Clear(); if(pItem)
pFillAttrLB->Fill( ( (SvxHatchListItem*)pState )->GetHatchList() ); {
pFillAttrLB->SelectEntry( aString ); OUString aString(mpFillAttrLB->GetSelectEntry());
} mpFillAttrLB->Clear();
if( pState->ISA( SvxBitmapListItem ) && mpFillAttrLB->Fill(pItem->GetGradientList());
eXFS == XFILL_BITMAP ) mpFillAttrLB->SelectEntry(aString);
{ }
OUString aString( pFillAttrLB->GetSelectEntry() ); break;
pFillAttrLB->Clear(); }
pFillAttrLB->Fill( ( (SvxBitmapListItem*)pState )->GetBitmapList() ); case XFILL_HATCH:
pFillAttrLB->SelectEntry( aString ); {
const SvxHatchListItem* pItem = dynamic_cast< const SvxHatchListItem* >(pState);
if(pItem)
{
OUString aString(mpFillAttrLB->GetSelectEntry());
mpFillAttrLB->Clear();
mpFillAttrLB->Fill(pItem->GetHatchList());
mpFillAttrLB->SelectEntry(aString);
}
break;
}
case XFILL_BITMAP:
{
const SvxBitmapListItem* pItem = dynamic_cast< const SvxBitmapListItem* >(pState);
if(pItem)
{
OUString aString(mpFillAttrLB->GetSelectEntry());
mpFillAttrLB->Clear();
mpFillAttrLB->Fill(pItem->GetBitmapList());
mpFillAttrLB->SelectEntry(aString);
}
break;
}
default: // XFILL_NONE
{
break;
}
} }
} }
} }
Window* SvxFillToolBoxControl::CreateItemWindow(Window *pParent)
Window* SvxFillToolBoxControl::CreateItemWindow( Window *pParent )
{ {
if ( GetSlotId() == SID_ATTR_FILL_STYLE ) if(GetSlotId() == SID_ATTR_FILL_STYLE)
{ {
pFillControl = new FillControl( pParent ); mpFillControl = new FillControl(pParent);
// Thus the FillControl is known by SvxFillToolBoxControl // Thus the FillControl is known by SvxFillToolBoxControl
// (and in order to remain compatible) // (and in order to remain compatible)
pFillControl->SetData( this ); mpFillControl->SetData(this);
mpFillAttrLB = (SvxFillAttrBox*)mpFillControl->mpLbFillAttr;
mpFillTypeLB = (SvxFillTypeBox*)mpFillControl->mpLbFillType;
pFillAttrLB = (SvxFillAttrBox*)pFillControl->pLbFillAttr; mpFillAttrLB->SetUniqueId(HID_FILL_ATTR_LISTBOX);
pFillTypeLB = (SvxFillTypeBox*)pFillControl->pLbFillType; mpFillTypeLB->SetUniqueId(HID_FILL_TYPE_LISTBOX);
pFillAttrLB->SetUniqueId( HID_FILL_ATTR_LISTBOX ); if(!mpStyleItem)
pFillTypeLB->SetUniqueId( HID_FILL_TYPE_LISTBOX ); {
// 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 pFillControl; return mpFillControl;
} }
return NULL; return NULL;
} }
...@@ -489,280 +543,328 @@ Window* SvxFillToolBoxControl::CreateItemWindow( Window *pParent ) ...@@ -489,280 +543,328 @@ Window* SvxFillToolBoxControl::CreateItemWindow( Window *pParent )
|* |*
\************************************************************************/ \************************************************************************/
FillControl::FillControl( Window* pParent, WinBits nStyle ) : FillControl::FillControl(Window* pParent,WinBits nStyle)
Window( pParent, nStyle | WB_DIALOGCONTROL ), : Window(pParent,nStyle | WB_DIALOGCONTROL),
pLbFillType(new SvxFillTypeBox( this )), mpLbFillType(new SvxFillTypeBox(this)),
aLogicalFillSize(40,80), mpLbFillAttr(new SvxFillAttrBox(this)),
aLogicalAttrSize(50,80) maLogicalFillSize(40,80),
maLogicalAttrSize(50,80),
mnLastFillTypeControlSelectEntryPos(mpLbFillType->GetSelectEntryPos()),
mnLastFillAttrControlSelectEntryPos(mpLbFillAttr->GetSelectEntryPos()),
mbFillTypeChanged(false)
{ {
pLbFillAttr = new SvxFillAttrBox( this ); Size aTypeSize(LogicToPixel(maLogicalFillSize,MAP_APPFONT));
Size aTypeSize(LogicToPixel(aLogicalFillSize, MAP_APPFONT)); Size aAttrSize(LogicToPixel(maLogicalAttrSize,MAP_APPFONT));
Size aAttrSize(LogicToPixel(aLogicalAttrSize, MAP_APPFONT)); mpLbFillType->SetSizePixel(aTypeSize);
pLbFillType->SetSizePixel(aTypeSize); mpLbFillAttr->SetSizePixel(aAttrSize);
pLbFillAttr->SetSizePixel(aAttrSize);
//to get the base height //to get the base height
aTypeSize = pLbFillType->GetSizePixel(); aTypeSize = mpLbFillType->GetSizePixel();
aAttrSize = pLbFillAttr->GetSizePixel(); aAttrSize = mpLbFillAttr->GetSizePixel();
Point aAttrPnt = pLbFillAttr->GetPosPixel(); Point aAttrPnt = mpLbFillAttr->GetPosPixel();
SetSizePixel( SetSizePixel(
Size( aAttrPnt.X() + aAttrSize.Width(), Size(aAttrPnt.X() + aAttrSize.Width(),
std::max( aAttrSize.Height(), aTypeSize.Height() ) ) ); std::max(aAttrSize.Height(),aTypeSize.Height())));
pLbFillType->SetSelectHdl( LINK( this, FillControl, SelectFillTypeHdl ) );
pLbFillAttr->SetSelectHdl( LINK( this, FillControl, SelectFillAttrHdl ) );
aDelayTimer.SetTimeout( DELAY_TIMEOUT ); mpLbFillType->SetSelectHdl(LINK(this,FillControl,SelectFillTypeHdl));
aDelayTimer.SetTimeoutHdl( LINK( this, FillControl, DelayHdl ) ); mpLbFillAttr->SetSelectHdl(LINK(this,FillControl,SelectFillAttrHdl));
aDelayTimer.Start();
} }
FillControl::~FillControl() FillControl::~FillControl()
{ {
delete pLbFillType; delete mpLbFillType;
delete pLbFillAttr; delete mpLbFillAttr;
} }
void FillControl::InitializeFillStyleAccordingToGivenFillType(XFillStyle aFillStyle)
IMPL_LINK_NOARG_INLINE_START(FillControl, DelayHdl)
{ {
SelectFillTypeHdl( NULL ); SfxObjectShell* pSh = SfxObjectShell::Current();
( (SvxFillToolBoxControl*)GetData() )->updateStatus( OUString( ".uno:FillStyle" )); bool bDone(false);
// ( (SvxFillToolBoxControl*)GetData() )->GetBindings().Invalidate( SID_ATTR_FILL_STYLE );
return 0;
}
IMPL_LINK_INLINE_END( FillControl, DelayHdl, Timer *, pTimer )
IMPL_LINK( FillControl, SelectFillTypeHdl, ListBox *, pBox )
{
XFillStyle eXFS = (XFillStyle)pLbFillType->GetSelectEntryPos();
// Later, an optimization should be accomplished,
// that the lists or tables can only be deleted and rebuilt
// when the lists, or tables have actually changed (in the LBs of course).
if ( ( pBox && !pBox->IsTravelSelect() ) || !pBox ) if(pSh)
{ {
// So that we can show a status in the following case: // clear in all cases, else we would risk a mix of FillStyles in the Style list
// One type was selected but no attribute. mpLbFillAttr->Clear();
// The selection has exactly the same attributes as the previous one.
// SvxFillToolBoxControl* pControlerItem = (SvxFillToolBoxControl*)GetData();
// if( pControlerItem )
// pControlerItem->ClearCache();
pLbFillAttr->Clear();
SfxObjectShell* pSh = SfxObjectShell::Current();
switch( eXFS ) switch (aFillStyle)
{ {
case XFILL_NONE:
{
pLbFillType->Selected();
SelectFillAttrHdl( pBox );
pLbFillAttr->Disable();
}
break;
case XFILL_SOLID: case XFILL_SOLID:
{ {
if ( pSh && pSh->GetItem( SID_COLOR_TABLE ) ) if(pSh->GetItem(SID_COLOR_TABLE))
{ {
SvxColorListItem aItem( *(const SvxColorListItem*)( const SvxColorListItem* pItem = static_cast<const SvxColorListItem*>(pSh->GetItem(SID_COLOR_TABLE));
pSh->GetItem( SID_COLOR_TABLE ) ) ); mpLbFillAttr->Enable();
pLbFillAttr->Enable(); mpLbFillAttr->Fill(pItem->GetColorList());
pLbFillAttr->Fill( aItem.GetColorList() ); bDone = true;
} }
else break;
pLbFillAttr->Disable();
} }
break;
case XFILL_GRADIENT: case XFILL_GRADIENT:
{ {
if ( pSh && pSh->GetItem( SID_GRADIENT_LIST ) ) if(pSh->GetItem(SID_GRADIENT_LIST))
{ {
SvxGradientListItem aItem( *(const SvxGradientListItem*)( const SvxGradientListItem* pItem = static_cast< const SvxGradientListItem* >(pSh->GetItem(SID_GRADIENT_LIST));
pSh->GetItem( SID_GRADIENT_LIST ) ) ); mpLbFillAttr->Enable();
pLbFillAttr->Enable(); mpLbFillAttr->Fill(pItem->GetGradientList());
pLbFillAttr->Fill( aItem.GetGradientList() ); bDone = true;
} }
else break;
pLbFillAttr->Disable();
} }
break;
case XFILL_HATCH: case XFILL_HATCH:
{ {
if ( pSh && pSh->GetItem( SID_HATCH_LIST ) ) if(pSh->GetItem(SID_HATCH_LIST))
{ {
SvxHatchListItem aItem( *(const SvxHatchListItem*)( const SvxHatchListItem* pItem = static_cast< const SvxHatchListItem* >(pSh->GetItem(SID_HATCH_LIST));
pSh->GetItem( SID_HATCH_LIST ) ) ); mpLbFillAttr->Enable();
pLbFillAttr->Enable(); mpLbFillAttr->Fill(pItem->GetHatchList());
pLbFillAttr->Fill( aItem.GetHatchList() ); bDone = true;
} }
else break;
pLbFillAttr->Disable();
} }
break;
case XFILL_BITMAP: case XFILL_BITMAP:
{ {
if ( pSh && pSh->GetItem( SID_BITMAP_LIST ) ) if(pSh->GetItem(SID_BITMAP_LIST))
{ {
SvxBitmapListItem aItem( *(const SvxBitmapListItem*)( const SvxBitmapListItem* pItem = static_cast< const SvxBitmapListItem* >(pSh->GetItem(SID_BITMAP_LIST));
pSh->GetItem( SID_BITMAP_LIST ) ) ); mpLbFillAttr->Enable();
pLbFillAttr->Enable(); mpLbFillAttr->Fill(pItem->GetBitmapList());
pLbFillAttr->Fill( aItem.GetBitmapList() ); bDone = true;
} }
else break;
pLbFillAttr->Disable(); }
default: // XFILL_NONE
{
// accept disable (no styles for XFILL_NONE)
break;
} }
break;
} }
}
if( eXFS != XFILL_NONE ) // Has already been done if (!bDone)
{ {
if ( pBox ) mpLbFillAttr->Disable();
pLbFillType->Selected(); }
}
// release focus void FillControl::updateLastFillTypeControlSelectEntryPos()
if ( pBox && pLbFillType->IsRelease() ) {
{ mnLastFillTypeControlSelectEntryPos = mpLbFillType->GetSelectEntryPos();
SfxViewShell* pViewShell = SfxViewShell::Current(); }
if( pViewShell && pViewShell->GetWindow() )
pViewShell->GetWindow()->GrabFocus(); IMPL_LINK(FillControl,SelectFillTypeHdl,ListBox *,pBox)
} {
if(!pBox) // only work with real calls from ListBox, do not accept direct calls with zeros here
{
return 0;
}
const bool bAction(
!mpLbFillType->IsTravelSelect() // keep TravelSelect, this means keyboard up/down in the list
&& mpLbFillType->GetSelectEntryCount()
&& mpLbFillType->GetSelectEntryPos() != mnLastFillTypeControlSelectEntryPos);
updateLastFillTypeControlSelectEntryPos();
XFillStyle eXFS = static_cast< XFillStyle >(mpLbFillType->GetSelectEntryPos());
if(bAction && XFILL_NONE != eXFS)
{
mbFillTypeChanged = true;
}
// update list of FillStyles in any case
InitializeFillStyleAccordingToGivenFillType(eXFS);
// for XFILL_NONE do no longer call SelectFillAttrHdl (as done before),
// trigger needed actions directly. This is the only action this handler
// can trigger directly as the user action is finished in this case
if(XFILL_NONE == eXFS && bAction)
{
// for XFILL_NONE do no longer call SelectFillAttrHdl,
// trigger needed actions directly
Any a;
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);
}
mpLbFillType->Selected();
// release focus. Needed to get focus automatically back to EditView
if(mpLbFillType->IsRelease())
{
SfxViewShell* pViewShell = SfxViewShell::Current();
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(); mnLastFillAttrControlSelectEntryPos = mpLbFillAttr->GetSelectEntryPos();
XFillStyleItem aXFillStyleItem( eXFS ); }
bool bAction = pBox && !pLbFillAttr->IsTravelSelect();
SfxObjectShell* pSh = SfxObjectShell::Current(); IMPL_LINK(FillControl, SelectFillAttrHdl, ListBox *, pBox)
if ( bAction ) {
if(!pBox) // only work with real calls from ListBox, do not accept direct calls with zeros here
{ {
Any a; return 0;
Sequence< PropertyValue > aArgs( 1 ); }
// First set the style const bool bAction(
aArgs[0].Name = "FillStyle"; !mpLbFillAttr->IsTravelSelect() // keep TravelSelect, this means keyboard up/down in the list
aXFillStyleItem.QueryValue( a ); && mpLbFillAttr->GetSelectEntryCount()
aArgs[0].Value = a; && mpLbFillAttr->GetSelectEntryPos() != mnLastFillAttrControlSelectEntryPos);
((SvxFillToolBoxControl*)GetData())->Dispatch(
OUString( ".uno:FillStyle" ), aArgs );
switch( eXFS ) 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 > aArgsFillAttr(1);
OUString aFillAttrCommand;
XFillStyle eXFS(static_cast< XFillStyle >(mpLbFillType->GetSelectEntryPos()));
switch(eXFS)
{ {
case XFILL_NONE: case XFILL_NONE:
{ {
// handled in SelectFillTypeHdl, nothing to do here
break;
} }
break;
case XFILL_SOLID: case XFILL_SOLID:
{ {
// Entry gets tested against temporary color // Entry gets tested against temporary color
OUString aTmpStr = pLbFillAttr->GetSelectEntry(); OUString aTmpStr = mpLbFillAttr->GetSelectEntry();
if( aTmpStr.startsWith(TMP_STR_BEGIN) && aTmpStr.endsWith(TMP_STR_END) ) if( aTmpStr.startsWith(TMP_STR_BEGIN) && aTmpStr.endsWith(TMP_STR_END) )
{ {
aTmpStr = aTmpStr.copy(1, aTmpStr.getLength()-2); aTmpStr = aTmpStr.copy(1, aTmpStr.getLength()-2);
} }
XFillColorItem aXFillColorItem( aTmpStr, pLbFillAttr->GetSelectEntryColor() ); XFillColorItem aXFillColorItem(aTmpStr, mpLbFillAttr->GetSelectEntryColor());
aArgsFillAttr[0].Name = "FillColor";
aArgs[0].Name = "FillColor"; aXFillColorItem.QueryValue(a);
aXFillColorItem.QueryValue( a ); aArgsFillAttr[0].Value = a;
aArgs[0].Value = a; aFillAttrCommand = ".uno:FillColor";
((SvxFillToolBoxControl*)GetData())->Dispatch( ".uno:FillColor", break;
aArgs );
} }
break;
case XFILL_GRADIENT: case XFILL_GRADIENT:
{ {
sal_Int32 nPos = pLbFillAttr->GetSelectEntryPos(); sal_Int32 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* pItem = static_cast< const SvxGradientListItem* >(pSh->GetItem(SID_GRADIENT_LIST));
*(const SvxGradientListItem*)( pSh->GetItem( SID_GRADIENT_LIST ) ) );
if ( nPos < aItem.GetGradientList()->Count() ) // no temporary entry? if (nPos < pItem->GetGradientList()->Count()) // no temporary entry?
{ {
XGradient aGradient = aItem.GetGradientList()->GetGradient( nPos )->GetGradient(); XGradient aGradient = pItem->GetGradientList()->GetGradient(nPos)->GetGradient();
XFillGradientItem aXFillGradientItem( pLbFillAttr->GetSelectEntry(), aGradient ); XFillGradientItem aXFillGradientItem(mpLbFillAttr->GetSelectEntry(),aGradient);
aArgsFillAttr[0].Name = "FillGradient";
aArgs[0].Name = "FillGradient"; aXFillGradientItem.QueryValue(a);
aXFillGradientItem.QueryValue( a ); aArgsFillAttr[0].Value = a;
aArgs[0].Value = a; aFillAttrCommand = ".uno:FillGradient";
((SvxFillToolBoxControl*)GetData())->Dispatch( OUString( ".uno:FillGradient" ),
aArgs );
} }
} }
break;
} }
break;
case XFILL_HATCH: case XFILL_HATCH:
{ {
sal_Int32 nPos = pLbFillAttr->GetSelectEntryPos(); sal_Int32 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 ) ) ); const SvxHatchListItem* pItem = static_cast< const SvxHatchListItem* >(pSh->GetItem(SID_HATCH_LIST));
if ( nPos < aItem.GetHatchList()->Count() ) // no temporary entry? if (nPos < pItem->GetHatchList()->Count()) // no temporary entry?
{ {
XHatch aHatch = aItem.GetHatchList()->GetHatch( nPos )->GetHatch(); XHatch aHatch = pItem->GetHatchList()->GetHatch(nPos)->GetHatch();
XFillHatchItem aXFillHatchItem( pLbFillAttr->GetSelectEntry(), aHatch ); XFillHatchItem aXFillHatchItem(mpLbFillAttr->GetSelectEntry(), aHatch);
aArgs[0].Name = "FillHatch"; aArgsFillAttr[0].Name = "FillHatch";
aXFillHatchItem.QueryValue( a ); aXFillHatchItem.QueryValue(a);
aArgs[0].Value = a; aArgsFillAttr[0].Value = a;
((SvxFillToolBoxControl*)GetData())->Dispatch( OUString( ".uno:FillHatch" ), aFillAttrCommand = ".uno:FillHatch";
aArgs );
} }
} }
break;
} }
break;
case XFILL_BITMAP: case XFILL_BITMAP:
{ {
sal_Int32 nPos = pLbFillAttr->GetSelectEntryPos(); sal_Int32 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* pItem = static_cast< const SvxBitmapListItem* >(pSh->GetItem(SID_BITMAP_LIST));
*(const SvxBitmapListItem*)( pSh->GetItem( SID_BITMAP_LIST ) ) );
if ( nPos < aItem.GetBitmapList()->Count() ) // no temporary entry? if (nPos < pItem->GetBitmapList()->Count()) // no temporary entry?
{ {
const XBitmapEntry* pXBitmapEntry = aItem.GetBitmapList()->GetBitmap(nPos); const XBitmapEntry* pXBitmapEntry = pItem->GetBitmapList()->GetBitmap(nPos);
const XFillBitmapItem aXFillBitmapItem(pLbFillAttr->GetSelectEntry(), pXBitmapEntry->GetGraphicObject()); const XFillBitmapItem aXFillBitmapItem(mpLbFillAttr->GetSelectEntry(),pXBitmapEntry->GetGraphicObject());
aArgs[0].Name = "FillBitmap"; aArgsFillAttr[0].Name = "FillBitmap";
aXFillBitmapItem.QueryValue( a ); aXFillBitmapItem.QueryValue(a);
aArgs[0].Value = a; aArgsFillAttr[0].Value = a;
((SvxFillToolBoxControl*)GetData())->Dispatch(OUString(".uno:FillBitmap"), aArgs); aFillAttrCommand = ".uno:FillBitmap";
} }
} }
break;
} }
break;
} }
// release focus // this is the place where evtl. a new slot action may be introduced to avoid the
if ( pLbFillAttr->IsRelease() && pBox ) // two undo entries. Reason for this is that indeed two actions are executed, the fill style
// and the fill attribute change. The sidebar already handles both separately, so
// changing the fill style already changes the object and adds a default fill attribute for
// the newly choosen fill style.
// This control uses the older user's two-step action to select a fill style and a fill attribute. In
// this case a lot of things may go wrong (e.g. the user stops that action and does something
// different), thus the solution of the sidebar should be preferred from my POV in the future
// 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;
}
// second set fill attribute when a change was detected and prepared
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(); SfxViewShell* pViewShell = SfxViewShell::Current();
if( pViewShell && pViewShell->GetWindow() )
if(pViewShell && pViewShell->GetWindow())
{ {
pViewShell->GetWindow()->GrabFocus(); pViewShell->GetWindow()->GrabFocus();
} }
...@@ -781,29 +883,30 @@ void FillControl::Resize() ...@@ -781,29 +883,30 @@ void FillControl::Resize()
long nH = 180; long nH = 180;
long nSep = 0; // was previously 4 long nSep = 0; // was previously 4
pLbFillType->SetSizePixel( Size( nW * 2 - nSep, nH ) ); mpLbFillType->SetSizePixel(Size(nW * 2 - nSep,nH));
pLbFillAttr->SetPosSizePixel( Point( nW * 2 + nSep, 0 ), Size( nW * 3 - nSep, nH ) ); mpLbFillAttr->SetPosSizePixel(Point(nW * 2 + nSep,0),Size(nW * 3 - nSep,nH));
} }
void FillControl::DataChanged( const DataChangedEvent& rDCEvt ) void FillControl::DataChanged(const DataChangedEvent& rDCEvt)
{ {
if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && if((rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
(rDCEvt.GetFlags() & SETTINGS_STYLE) ) (rDCEvt.GetFlags() & SETTINGS_STYLE))
{ {
Size aTypeSize(LogicToPixel(aLogicalFillSize, MAP_APPFONT)); Size aTypeSize(LogicToPixel(maLogicalFillSize,MAP_APPFONT));
Size aAttrSize(LogicToPixel(aLogicalAttrSize, MAP_APPFONT)); Size aAttrSize(LogicToPixel(maLogicalAttrSize,MAP_APPFONT));
pLbFillType->SetSizePixel(aTypeSize); mpLbFillType->SetSizePixel(aTypeSize);
pLbFillAttr->SetSizePixel(aAttrSize); mpLbFillAttr->SetSizePixel(aAttrSize);
//to get the base height //to get the base height
aTypeSize = pLbFillType->GetSizePixel(); aTypeSize = mpLbFillType->GetSizePixel();
aAttrSize = pLbFillAttr->GetSizePixel(); aAttrSize = mpLbFillAttr->GetSizePixel();
Point aAttrPnt = pLbFillAttr->GetPosPixel(); Point aAttrPnt = mpLbFillAttr->GetPosPixel();
SetSizePixel( SetSizePixel(
Size( aAttrPnt.X() + aAttrSize.Width(), Size(aAttrPnt.X() + aAttrSize.Width(),
std::max( aAttrSize.Height(), aTypeSize.Height() ) ) ); std::max(aAttrSize.Height(), aTypeSize.Height())));
} }
Window::DataChanged( rDCEvt ); Window::DataChanged(rDCEvt);
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment