[Libreoffice-commits] core.git: Branch 'aoo/trunk' - 2 commits - svx/inc svx/source sw/inc sw/source
Oliver-Rainer Wittmann
orw at apache.org
Mon Jun 16 05:08:32 PDT 2014
svx/inc/svx/fillctrl.hxx | 73 +-
svx/source/tbxctrls/fillctrl.cxx | 993 +++++++++++++++++++-----------------
sw/inc/txtfld.hxx | 9
sw/source/core/txtnode/atrfld.cxx | 37 +
sw/source/core/unocore/unofield.cxx | 170 +++---
5 files changed, 722 insertions(+), 560 deletions(-)
New commits:
commit 90b633455a6e54300330e68e71e22e729b445f31
Author: Oliver-Rainer Wittmann <orw at apache.org>
Date: Mon Jun 16 12:01:46 2014 +0000
125086: correct UNO-API implementation for <com::sun::star::text::XTextField> in Writer to reflect changes made for the in-place editing of Input Fields
diff --git a/sw/inc/txtfld.hxx b/sw/inc/txtfld.hxx
index d86a447..48b7eb4 100644
--- a/sw/inc/txtfld.hxx
+++ b/sw/inc/txtfld.hxx
@@ -27,6 +27,8 @@
#include <tools/string.hxx>
#include <pam.hxx>
+#include <boost/shared_ptr.hpp>
+
class SwTxtNode;
// ATT_FLD ***********************************
@@ -68,6 +70,13 @@ public:
// enable notification that field content has changed and needs reformatting
virtual void NotifyContentChange( SwFmtFld& rFmtFld );
+ // deletes the given field via removing the corresponding text selection from the document's content
+ static void DeleteTxtFld( const SwTxtFld& rTxtFld );
+
+ // return text selection for the given field
+ static void GetPamForTxtFld( const SwTxtFld& rTxtFld,
+ boost::shared_ptr< SwPaM >& rPamForTxtFld );
+
};
class SwTxtInputFld : public SwTxtFld
diff --git a/sw/source/core/txtnode/atrfld.cxx b/sw/source/core/txtnode/atrfld.cxx
index d111950..f60d07c 100644
--- a/sw/source/core/txtnode/atrfld.cxx
+++ b/sw/source/core/txtnode/atrfld.cxx
@@ -456,6 +456,43 @@ void SwTxtFld::NotifyContentChange(SwFmtFld& rFmtFld)
}
+/*static*/
+void SwTxtFld::GetPamForTxtFld(
+ const SwTxtFld& rTxtFld,
+ boost::shared_ptr< SwPaM >& rPamForTxtFld )
+{
+ if ( rTxtFld.GetpTxtNode() == NULL )
+ {
+ ASSERT( false, "<SwTxtFld::GetPamForField> - missing <SwTxtNode>" );
+ return;
+ }
+
+ const SwTxtNode& rTxtNode = rTxtFld.GetTxtNode();
+
+ rPamForTxtFld.reset( new SwPaM( rTxtNode,
+ ( (rTxtFld.End() != NULL) ? *(rTxtFld.End()) : ( *(rTxtFld.GetStart()) + 1 ) ),
+ rTxtNode,
+ *(rTxtFld.GetStart()) ) );
+
+}
+
+
+/*static*/
+void SwTxtFld::DeleteTxtFld( const SwTxtFld& rTxtFld )
+{
+ if ( rTxtFld.GetpTxtNode() != NULL )
+ {
+ boost::shared_ptr< SwPaM > pPamForTxtFld;
+ GetPamForTxtFld( rTxtFld, pPamForTxtFld );
+ if ( pPamForTxtFld.get() != NULL )
+ {
+ rTxtFld.GetTxtNode().GetDoc()->DeleteAndJoin( *pPamForTxtFld );
+ }
+ }
+}
+
+
+
// input field in-place editing
SwTxtInputFld::SwTxtInputFld(
SwFmtFld & rAttr,
diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx
index ea9ef00..c64c839 100644
--- a/sw/source/core/unocore/unofield.cxx
+++ b/sw/source/core/unocore/unofield.cxx
@@ -910,37 +910,34 @@ void SwXFieldMaster::removeVetoableChangeListener(const OUString& /*PropertyName
void SwXFieldMaster::dispose(void) throw( uno::RuntimeException )
{
- vos::OGuard aGuard(Application::GetSolarMutex());
- SwFieldType* pFldType = GetFldType(sal_True);
- if(pFldType)
+ vos::OGuard aGuard( Application::GetSolarMutex() );
+
+ SwFieldType* pFldType = GetFldType( sal_True );
+ if ( pFldType != NULL )
{
sal_uInt16 nTypeIdx = USHRT_MAX;
const SwFldTypes* pTypes = GetDoc()->GetFldTypes();
- for( sal_uInt16 i = 0; i < pTypes->Count(); i++ )
+ for ( sal_uInt16 i = 0; i < pTypes->Count(); i++ )
{
- if((*pTypes)[i] == pFldType)
+ if ( ( *pTypes )[i] == pFldType )
nTypeIdx = i;
}
// zuerst alle Felder loeschen
- SwIterator<SwFmtFld,SwFieldType> aIter( *pFldType );
+ SwIterator< SwFmtFld, SwFieldType > aIter( *pFldType );
SwFmtFld* pFld = aIter.First();
- while(pFld)
+ while ( pFld != NULL )
{
- // Feld im Undo?
- SwTxtFld *pTxtFld = pFld->GetTxtFld();
- if(pTxtFld && pTxtFld->GetTxtNode().GetNodes().IsDocNodes() )
+ SwTxtFld* pTxtFld = pFld->GetTxtFld();
+ if ( pTxtFld != NULL
+ && pTxtFld->GetTxtNode().GetNodes().IsDocNodes() )
{
- SwTxtNode& rTxtNode = (SwTxtNode&)*pTxtFld->GetpTxtNode();
- SwPaM aPam(rTxtNode, *pTxtFld->GetStart());
- aPam.SetMark();
- aPam.Move();
- GetDoc()->DeleteAndJoin(aPam);
+ SwTxtFld::DeleteTxtFld( *pTxtFld );
}
pFld = aIter.Next();
}
// dann den FieldType loeschen
- GetDoc()->RemoveFldType(nTypeIdx);
+ GetDoc()->RemoveFldType( nTypeIdx );
}
else
throw uno::RuntimeException();
@@ -1891,38 +1888,41 @@ void SwXTextField::attach( const uno::Reference< text::XTextRange > & xTextRange
uno::Reference< text::XTextRange > SwXTextField::getAnchor(void) throw( uno::RuntimeException )
{
- vos::OGuard aGuard(Application::GetSolarMutex());
- uno::Reference< text::XTextRange > aRef;
- SwField* pField = (SwField*)GetField();
- if(pField)
+ vos::OGuard aGuard( Application::GetSolarMutex() );
+
+ uno::Reference< text::XTextRange > aRef;
+
+ SwField* pField = (SwField*) GetField();
+ if ( pField != NULL )
{
const SwTxtFld* pTxtFld = m_pFmtFld->GetTxtFld();
- if(!pTxtFld)
+ if ( !pTxtFld )
throw uno::RuntimeException();
- const SwTxtNode& rTxtNode = pTxtFld->GetTxtNode();
- SwPaM aPam(rTxtNode, *pTxtFld->GetStart() + 1, rTxtNode, *pTxtFld->GetStart());
-
- aRef = SwXTextRange::CreateXTextRange(
- *m_pDoc, *aPam.GetPoint(), aPam.GetMark());
+ boost::shared_ptr< SwPaM > pPamForTxtFld;
+ SwTxtFld::GetPamForTxtFld( *pTxtFld, pPamForTxtFld );
+ if ( pPamForTxtFld.get() != NULL )
+ {
+ aRef = SwXTextRange::CreateXTextRange( *m_pDoc,
+ *(pPamForTxtFld->GetPoint()),
+ pPamForTxtFld->GetMark() );
+ }
}
return aRef;
}
+
void SwXTextField::dispose(void) throw( uno::RuntimeException )
{
- vos::OGuard aGuard(Application::GetSolarMutex());
- SwField* pField = (SwField*)GetField();
- if(pField)
+ vos::OGuard aGuard( Application::GetSolarMutex() );
+ SwField* pField = (SwField*) GetField();
+ if ( pField != NULL )
{
- UnoActionContext aContext(GetDoc());
- const SwTxtFld* pTxtFld = m_pFmtFld->GetTxtFld();
- SwTxtNode& rTxtNode = (SwTxtNode&)*pTxtFld->GetpTxtNode();
- SwPaM aPam(rTxtNode, *pTxtFld->GetStart());
- aPam.SetMark();
- aPam.Move();
- GetDoc()->DeleteAndJoin(aPam);
+ UnoActionContext aContext( GetDoc() );
+
+ ASSERT( m_pFmtFld->GetTxtFld(), "<SwXTextField::dispose()> - missing <SwTxtFld> --> crash" );
+ SwTxtFld::DeleteTxtFld( *( m_pFmtFld->GetTxtFld() ) );
}
if ( m_pTextObject )
@@ -1983,19 +1983,19 @@ void SwXTextField::setPropertyValue(const OUString& rPropertyName, const uno::An
if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
throw beans::PropertyVetoException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
- if(pField)
+ if ( pField )
{
// Sonderbehandlung Serienbrieffeld
sal_uInt16 nWhich = pField->Which();
- if( RES_DBFLD == nWhich &&
- (rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_DATA_BASE_NAME)) ||
- rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_DATA_BASE_URL))||
- rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_DATA_TABLE_NAME))||
- rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_DATA_COLUMN_NAME))))
+ if ( RES_DBFLD == nWhich
+ && ( rPropertyName.equalsAsciiL( SW_PROP_NAME( UNO_NAME_DATA_BASE_NAME ) )
+ || rPropertyName.equalsAsciiL( SW_PROP_NAME( UNO_NAME_DATA_BASE_URL ) )
+ || rPropertyName.equalsAsciiL( SW_PROP_NAME( UNO_NAME_DATA_TABLE_NAME ) )
+ || rPropertyName.equalsAsciiL( SW_PROP_NAME( UNO_NAME_DATA_COLUMN_NAME ) ) ) )
{
// hier muss ein neuer Feldtyp angelegt werden und
// das Feld an den neuen Typ umgehaengt werden
- DBG_WARNING("not implemented");
+ DBG_WARNING( "not implemented" );
}
else
{
@@ -2015,30 +2015,30 @@ void SwXTextField::setPropertyValue(const OUString& rPropertyName, const uno::An
}
pField->PutValue( rValue, pEntry->nWID );
- //#i100374# notify SwPostIt about new field content
- if (RES_POSTITFLD== nWhich && m_pFmtFld)
- {
- const_cast<SwFmtFld*>(m_pFmtFld)->Broadcast(SwFmtFldHint( 0, SWFMTFLD_CHANGED ));
- }
+ //#i100374# notify SwPostIt about new field content
+ if ( RES_POSTITFLD == nWhich && m_pFmtFld )
+ {
+ const_cast< SwFmtFld* >( m_pFmtFld )->Broadcast( SwFmtFldHint( 0, SWFMTFLD_CHANGED ) );
+ }
//#114571# changes of the expanded string have to be notified
//#to the SwTxtFld
- if(RES_DBFLD == nWhich && m_pFmtFld->GetTxtFld())
+ if ( RES_DBFLD == nWhich && m_pFmtFld->GetTxtFld() )
{
m_pFmtFld->GetTxtFld()->ExpandTxtFld();
}
- //#i100374# changing a document field should set the modify flag
- SwDoc* pDoc = GetDoc();
- if (pDoc)
- pDoc->SetModified();
+ //#i100374# changing a document field should set the modify flag
+ SwDoc* pDoc = GetDoc();
+ if ( pDoc )
+ pDoc->SetModified();
}
- else if(m_pProps)
+ else if ( m_pProps )
{
String* pStr = 0;
sal_Bool* pBool = 0;
- switch(pEntry->nWID)
+ switch (pEntry->nWID)
{
case FIELD_PROP_PAR1:
pStr = &m_pProps->sPar1;
@@ -2059,54 +2059,54 @@ void SwXTextField::setPropertyValue(const OUString& rPropertyName, const uno::An
case FIELD_PROP_SUBTYPE:
m_pProps->nSubType = SWUnoHelper::GetEnumAsInt32( rValue );
break;
- case FIELD_PROP_BYTE1 :
+ case FIELD_PROP_BYTE1:
rValue >>= m_pProps->nByte1;
break;
- case FIELD_PROP_BOOL1 :
+ case FIELD_PROP_BOOL1:
pBool = &m_pProps->bBool1;
break;
- case FIELD_PROP_BOOL2 :
+ case FIELD_PROP_BOOL2:
pBool = &m_pProps->bBool2;
break;
- case FIELD_PROP_BOOL3 :
+ case FIELD_PROP_BOOL3:
pBool = &m_pProps->bBool3;
break;
case FIELD_PROP_BOOL4:
pBool = &m_pProps->bBool4;
- break;
- case FIELD_PROP_DATE :
- {
- if(rValue.getValueType() != ::getCppuType(static_cast<const util::Date*>(0)))
+ break;
+ case FIELD_PROP_DATE:
+ {
+ if ( rValue.getValueType() != ::getCppuType( static_cast< const util::Date* >( 0 ) ) )
throw lang::IllegalArgumentException();
- util::Date aTemp = *(const util::Date*)rValue.getValue();
- m_pProps->aDate = Date(aTemp.Day, aTemp.Month, aTemp.Year);
+ util::Date aTemp = *(const util::Date*) rValue.getValue();
+ m_pProps->aDate = Date( aTemp.Day, aTemp.Month, aTemp.Year );
}
- break;
+ break;
case FIELD_PROP_USHORT1:
- case FIELD_PROP_USHORT2:
+ case FIELD_PROP_USHORT2:
{
- sal_Int16 nVal = 0;
- rValue >>= nVal;
- if( FIELD_PROP_USHORT1 == pEntry->nWID)
- m_pProps->nUSHORT1 = nVal;
- else
- m_pProps->nUSHORT2 = nVal;
- }
+ sal_Int16 nVal = 0;
+ rValue >>= nVal;
+ if ( FIELD_PROP_USHORT1 == pEntry->nWID )
+ m_pProps->nUSHORT1 = nVal;
+ else
+ m_pProps->nUSHORT2 = nVal;
+ }
break;
case FIELD_PROP_SHORT1:
rValue >>= m_pProps->nSHORT1;
break;
case FIELD_PROP_DOUBLE:
- if(rValue.getValueType() != ::getCppuType(static_cast<const double*>(0)))
+ if ( rValue.getValueType() != ::getCppuType( static_cast< const double* >( 0 ) ) )
throw lang::IllegalArgumentException();
- m_pProps->fDouble = *(double*)rValue.getValue();
+ m_pProps->fDouble = *(double*) rValue.getValue();
break;
- case FIELD_PROP_DATE_TIME :
- if(!m_pProps->pDateTime)
+ case FIELD_PROP_DATE_TIME:
+ if ( !m_pProps->pDateTime )
m_pProps->pDateTime = new util::DateTime;
- rValue >>= (*m_pProps->pDateTime);
+ rValue >>= ( *m_pProps->pDateTime );
break;
case FIELD_PROP_PROP_SEQ:
rValue >>= m_pProps->aPropSeq;
@@ -2115,12 +2115,12 @@ void SwXTextField::setPropertyValue(const OUString& rPropertyName, const uno::An
rValue >>= m_pProps->aStrings;
break;
}
- if( pStr )
+ if ( pStr )
::GetString( rValue, *pStr );
- else if( pBool )
+ else if ( pBool )
{
- if( rValue.getValueType() == getCppuBooleanType() )
- *pBool = *(sal_Bool*)rValue.getValue();
+ if ( rValue.getValueType() == getCppuBooleanType() )
+ *pBool = *(sal_Bool*) rValue.getValue();
else
throw lang::IllegalArgumentException();
}
@@ -2383,10 +2383,8 @@ void SwXTextField::update( ) throw (uno::RuntimeException)
}
break;
}
- // --> FME 2004-10-06 #116480#
// Text formatting has to be triggered.
- const_cast<SwFmtFld*>(m_pFmtFld)->ModifyNotification( 0, 0 );
- // <--
+ const_cast< SwFmtFld* >( m_pFmtFld )->ModifyNotification( 0, 0 );
}
else
m_bCallUpdate = sal_True;
commit 0ce4a90e14ddc9067d014405235a36aa959c6ea2
Author: Armin Le Grand <alg at apache.org>
Date: Mon Jun 16 11:23:03 2014 +0000
i125065 handle critical cases in FillStyle/FillProperties toobar combination
diff --git a/svx/inc/svx/fillctrl.hxx b/svx/inc/svx/fillctrl.hxx
index daa2b20..48da9b1 100644
--- a/svx/inc/svx/fillctrl.hxx
+++ b/svx/inc/svx/fillctrl.hxx
@@ -19,8 +19,6 @@
*
*************************************************************/
-
-
#ifndef _FILLCTRL_HXX
#define _FILLCTRL_HXX
@@ -44,32 +42,33 @@ class ListBox;
|*
\************************************************************************/
-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* mpFillControl;
+ SvxFillTypeBox* mpFillTypeLB;
+ SvxFillAttrBox* mpFillAttrLB;
- FillControl* pFillControl;
- SvxFillTypeBox* pFillTypeLB;
- SvxFillAttrBox* pFillAttrLB;
+ XFillStyle meLastXFS;
- sal_Bool bUpdate;
- sal_uInt16 eLastXFS;
+ /// bitfield
+ bool mbUpdate : 1;
public:
SFX_DECL_TOOLBOX_CONTROL();
- SvxFillToolBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx );
+ 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);
};
//========================================================================
@@ -79,24 +78,34 @@ class FillControl : public Window
private:
friend class SvxFillToolBoxControl;
- SvxFillTypeBox* pLbFillType;
- SvxFillAttrBox* pLbFillAttr;
- Size aLogicalFillSize;
- Size aLogicalAttrSize;
- Timer aDelayTimer;
-
-//#if 0 // _SOLAR__PRIVATE
- DECL_LINK( DelayHdl, Timer * );
- DECL_LINK( SelectFillTypeHdl, ListBox * );
- DECL_LINK( SelectFillAttrHdl, ListBox * );
-//#endif
- virtual void DataChanged( const DataChangedEvent& rDCEvt );
+ SvxFillTypeBox* mpLbFillType;
+ SvxFillAttrBox* mpLbFillAttr;
+ Size maLogicalFillSize;
+ Size maLogicalAttrSize;
+
+ //
+ 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(Window* pParent, WinBits nStyle = 0);
~FillControl();
virtual void Resize();
};
-#endif // _FILLCTRL_HXX
+#endif // _FILLCTRL_HXX
+// eof
diff --git a/svx/source/tbxctrls/fillctrl.cxx b/svx/source/tbxctrls/fillctrl.cxx
index 1e00fe0..5c98d38 100644
--- a/svx/source/tbxctrls/fillctrl.cxx
+++ b/svx/source/tbxctrls/fillctrl.cxx
@@ -19,24 +19,17 @@
*
*************************************************************/
-
-
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_svx.hxx"
-// include ---------------------------------------------------------------
-
#include <string> // HACK: prevent conflict between STLPORT and Workshop headers
#include <sfx2/app.hxx>
#include <sfx2/dispatch.hxx>
#include <sfx2/objsh.hxx>
#include <sfx2/viewsh.hxx>
#include <rtl/ustring.hxx>
-
#include <svx/dialogs.hrc>
-#define DELAY_TIMEOUT 300
-
#define TMP_STR_BEGIN '['
#define TMP_STR_END ']'
@@ -62,19 +55,21 @@ SFX_IMPL_TOOLBOX_CONTROL( SvxFillToolBoxControl, XFillStyleItem );
|*
\************************************************************************/
-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,134 +85,146 @@ SvxFillToolBoxControl::SvxFillToolBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId
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 )
-
+ sal_uInt16 nSID,
+ SfxItemState eState,
+ const SfxPoolItem* pState)
{
- bool bEnableControls = sal_False;
+ bool bEnableControls(false);
- 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();
- pFillTypeLB->SetNoSelection();
+ mpFillTypeLB->Disable();
+ mpFillTypeLB->SetNoSelection();
}
- pFillAttrLB->Disable();
- pFillAttrLB->SetNoSelection();
+
+ mpFillAttrLB->Disable();
+ mpFillAttrLB->SetNoSelection();
}
- else
+ else if(SFX_ITEM_AVAILABLE == eState)
{
- if ( SFX_ITEM_AVAILABLE == eState )
+ // slot available state
+ if(nSID == SID_ATTR_FILL_STYLE)
{
- if( nSID == SID_ATTR_FILL_STYLE )
- {
- delete pStyleItem;
- pStyleItem = (XFillStyleItem*) pState->Clone();
- pFillTypeLB->Enable();
- }
- else if( pStyleItem )
+ delete mpStyleItem;
+ mpStyleItem = static_cast< XFillStyleItem* >(pState->Clone());
+ mpFillTypeLB->Enable();
+ }
+ else if(mpStyleItem)
+ {
+ const XFillStyle eXFS(static_cast< XFillStyle >(mpStyleItem->GetValue()));
+
+ 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;
- pColorItem = (XFillColorItem*) pState->Clone();
-
- if( eXFS == XFILL_SOLID )
- bEnableControls = sal_True;
+ bEnableControls = true;
}
- else if( nSID == SID_ATTR_FILL_GRADIENT )
- {
- delete pGradientItem;
- pGradientItem = (XFillGradientItem*) pState->Clone();
+ }
+ else if(nSID == SID_ATTR_FILL_GRADIENT)
+ {
+ delete mpGradientItem;
+ mpGradientItem = static_cast< XFillGradientItem* >(pState->Clone());
- if( eXFS == XFILL_GRADIENT )
- bEnableControls = sal_True;
- }
- else if( nSID == SID_ATTR_FILL_HATCH )
+ if(eXFS == XFILL_GRADIENT)
{
- delete pHatchItem;
- pHatchItem = (XFillHatchItem*) pState->Clone();
-
- if( eXFS == XFILL_HATCH )
- bEnableControls = sal_True;
+ bEnableControls = true;
}
- else if( nSID == SID_ATTR_FILL_BITMAP )
- {
- delete pBitmapItem;
- pBitmapItem = (XFillBitmapItem*) pState->Clone();
+ }
+ else if(nSID == SID_ATTR_FILL_HATCH)
+ {
+ delete mpHatchItem;
+ mpHatchItem = static_cast< XFillHatchItem* >(pState->Clone());
- if( eXFS == XFILL_BITMAP )
- bEnableControls = sal_True;
+ if(eXFS == XFILL_HATCH)
+ {
+ bEnableControls = true;
}
}
-
- if( pStyleItem )
+ else if(nSID == SID_ATTR_FILL_BITMAP)
{
- // 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();
-
- if(eLastXFS != eXFS)
+ delete mpBitmapItem;
+ mpBitmapItem = static_cast< XFillBitmapItem* >(pState->Clone());
+
+ if(eXFS == XFILL_BITMAP)
{
- bUpdate = sal_True;
- pFillTypeLB->SelectEntryPos( sal::static_int_cast< sal_uInt16 >( eXFS ) );
+ bEnableControls = true;
}
-
- 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();
- pFillAttrLB->Enable();
+ meLastXFS = static_cast< XFillStyle >(mpFillControl->mnLastFillTypeControlSelectEntryPos);
+ mpFillControl->mbFillTypeChanged = false;
+ }
- bUpdate = sal_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
{
- // leerer oder uneindeutiger Status
- if( nSID == SID_ATTR_FILL_STYLE )
+ XFillStyle eXFS(XFILL_NONE);
+
+ if(mpStyleItem)
{
- pFillTypeLB->SetNoSelection();
- pFillAttrLB->Disable();
- pFillAttrLB->SetNoSelection();
- bUpdate = sal_False;
+ eXFS = static_cast< XFillStyle >(mpStyleItem->GetValue());
}
- 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;
- 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;
- }
+ mpFillAttrLB->SetNoSelection();
}
}
}
@@ -225,275 +232,321 @@ void SvxFillToolBoxControl::StateChanged(
//========================================================================
-void SvxFillToolBoxControl::Update( const SfxPoolItem* pState )
+void SvxFillToolBoxControl::Update(const SfxPoolItem* pState)
{
- if ( pStyleItem && pState && bUpdate )
+ if(mpStyleItem && pState && mbUpdate)
{
- bUpdate = sal_False;
-
- XFillStyle eXFS = (XFillStyle)pStyleItem->GetValue();
+ mbUpdate = false;
+ const XFillStyle eXFS(static_cast< XFillStyle >(mpStyleItem->GetValue()));
// Pruefen, ob Fuellstil schon vorher aktiv war
- //if( eTmpXFS != eXFS )
- if( (XFillStyle) eLastXFS != eXFS )
- pFillControl->SelectFillTypeHdl( NULL );
- //eLastXFS = eXFS;
+ if(meLastXFS != eXFS)
+ {
+ // update mnLastFillTypeControlSelectEntryPos and fill style list
+ mpFillControl->updateLastFillTypeControlSelectEntryPos();
+ mpFillControl->InitializeFillStyleAccordingToGivenFillType(eXFS);
+ meLastXFS = eXFS;
+ }
- switch( eXFS )
+ switch(eXFS)
{
case XFILL_NONE:
- break;
+ {
+ break;
+ }
case XFILL_SOLID:
{
- if ( pColorItem )
+ if(mpColorItem)
{
- String aString( pColorItem->GetName() );
- ::Color aColor = pColorItem->GetColorValue();
+ String aString(mpColorItem->GetName());
+ ::Color aColor = mpColorItem->GetColorValue();
- pFillAttrLB->SelectEntry( aString );
+ mpFillAttrLB->SelectEntry(aString);
- if ( pFillAttrLB->GetSelectEntryPos() == LISTBOX_ENTRY_NOTFOUND ||
- pFillAttrLB->GetSelectEntryColor() != aColor )
- pFillAttrLB->SelectEntry( aColor );
+ if(mpFillAttrLB->GetSelectEntryPos() == LISTBOX_ENTRY_NOTFOUND || mpFillAttrLB->GetSelectEntryColor() != aColor)
+ {
+ mpFillAttrLB->SelectEntry(aColor);
+ }
- // NEU
// Pruefen, ob Eintrag nicht in der Liste ist
- if( pFillAttrLB->GetSelectEntryPos() ==
- LISTBOX_ENTRY_NOTFOUND ||
- pFillAttrLB->GetSelectEntryColor() != aColor )
+ if(mpFillAttrLB->GetSelectEntryPos() == LISTBOX_ENTRY_NOTFOUND || mpFillAttrLB->GetSelectEntryColor() != aColor)
{
- sal_uInt16 nCount = pFillAttrLB->GetEntryCount();
+ sal_uInt16 nCount = mpFillAttrLB->GetEntryCount();
String aTmpStr;
- if( nCount > 0 )
+ 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 )
+ aTmpStr = mpFillAttrLB->GetEntry(nCount - 1);
+
+ if(aTmpStr.GetChar(0) == TMP_STR_BEGIN && aTmpStr.GetChar(aTmpStr.Len() - 1) == TMP_STR_END)
{
- pFillAttrLB->RemoveEntry( nCount - 1 );
+ mpFillAttrLB->RemoveEntry(nCount - 1);
}
}
+
aTmpStr = TMP_STR_BEGIN;
aTmpStr += aString;
aTmpStr += TMP_STR_END;
- //pFillAttrLB->SetUpdateMode( sal_False );
- sal_uInt16 nPos = pFillAttrLB->InsertEntry( aColor, aTmpStr );
- //pFillAttrLB->SetUpdateMode( sal_True );
- pFillAttrLB->SelectEntryPos( nPos );
+ sal_uInt16 nPos = mpFillAttrLB->InsertEntry(aColor,aTmpStr);
+ mpFillAttrLB->SelectEntryPos(nPos);
}
- // NEU
}
else
- pFillAttrLB->SetNoSelection();
+ {
+ mpFillAttrLB->SetNoSelection();
+ }
+ break;
}
- break;
case XFILL_GRADIENT:
{
- if ( pGradientItem )
+ if(mpGradientItem)
{
- String aString( pGradientItem->GetName() );
- pFillAttrLB->SelectEntry( aString );
- // NEU
+ String aString(mpGradientItem->GetName());
+ mpFillAttrLB->SelectEntry(aString);
+
// Pruefen, ob Eintrag nicht in der Liste ist
- if( pFillAttrLB->GetSelectEntry() != aString )
+ if(mpFillAttrLB->GetSelectEntry() != aString)
{
- sal_uInt16 nCount = pFillAttrLB->GetEntryCount();
+ sal_uInt16 nCount = mpFillAttrLB->GetEntryCount();
String aTmpStr;
- if( nCount > 0 )
+
+ 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 )
+ aTmpStr = mpFillAttrLB->GetEntry(nCount - 1);
+
+ if(aTmpStr.GetChar(0) == TMP_STR_BEGIN && aTmpStr.GetChar(aTmpStr.Len() - 1) == TMP_STR_END)
{
- pFillAttrLB->RemoveEntry( nCount - 1 );
+ mpFillAttrLB->RemoveEntry(nCount - 1);
}
}
+
aTmpStr = TMP_STR_BEGIN;
aTmpStr += aString;
aTmpStr += TMP_STR_END;
- XGradientEntry* pEntry = new XGradientEntry( pGradientItem->GetGradientValue(), aTmpStr );
+ 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 );
+ const Bitmap aBmp = aGradientList->GetUiBitmap(0);
- if( !aBmp.IsEmpty() )
+ if(!aBmp.IsEmpty())
{
- ( (ListBox*)pFillAttrLB )->InsertEntry( pEntry->GetName(), aBmp );
- pFillAttrLB->SelectEntryPos( pFillAttrLB->GetEntryCount() - 1 );
+ ((ListBox*)mpFillAttrLB)->InsertEntry(pEntry->GetName(),aBmp);
+ mpFillAttrLB->SelectEntryPos(mpFillAttrLB->GetEntryCount() - 1);
}
}
- // NEU
}
else
- pFillAttrLB->SetNoSelection();
+ {
+ mpFillAttrLB->SetNoSelection();
+ }
+ break;
}
- break;
case XFILL_HATCH:
{
- if ( pHatchItem )
+ if(mpHatchItem)
{
- String aString( pHatchItem->GetName() );
- pFillAttrLB->SelectEntry( aString );
- // NEU
+ String aString(mpHatchItem->GetName());
+ mpFillAttrLB->SelectEntry(aString);
+
// Pruefen, ob Eintrag nicht in der Liste ist
- if( pFillAttrLB->GetSelectEntry() != aString )
+ if(mpFillAttrLB->GetSelectEntry() != aString)
{
- sal_uInt16 nCount = pFillAttrLB->GetEntryCount();
+ sal_uInt16 nCount = mpFillAttrLB->GetEntryCount();
String aTmpStr;
- if( nCount > 0 )
+ 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 )
+ aTmpStr = mpFillAttrLB->GetEntry(nCount - 1);
+ if(aTmpStr.GetChar(0) == TMP_STR_BEGIN &&
+ aTmpStr.GetChar(aTmpStr.Len() - 1) == TMP_STR_END)
{
- pFillAttrLB->RemoveEntry( nCount - 1 );
+ mpFillAttrLB->RemoveEntry(nCount - 1);
}
}
+
aTmpStr = TMP_STR_BEGIN;
aTmpStr += aString;
aTmpStr += TMP_STR_END;
- XHatchEntry* pEntry = new XHatchEntry( pHatchItem->GetHatchValue(), aTmpStr );
+ XHatchEntry* pEntry = new XHatchEntry(mpHatchItem->GetHatchValue(),aTmpStr);
XHatchListSharedPtr aHatchList(XPropertyListFactory::CreateSharedXHatchList(String::CreateFromAscii("TmpList")));
- aHatchList->Insert( pEntry );
- aHatchList->SetDirty( sal_False );
- const Bitmap aBmp = aHatchList->GetUiBitmap( 0 );
+ aHatchList->Insert(pEntry);
+ aHatchList->SetDirty(sal_False);
+ const Bitmap aBmp = aHatchList->GetUiBitmap(0);
- if( !aBmp.IsEmpty() )
+ if(!aBmp.IsEmpty())
{
- ( (ListBox*)pFillAttrLB )->InsertEntry( pEntry->GetName(), aBmp );
- pFillAttrLB->SelectEntryPos( pFillAttrLB->GetEntryCount() - 1 );
+ ((ListBox*)mpFillAttrLB)->InsertEntry(pEntry->GetName(),aBmp);
+ mpFillAttrLB->SelectEntryPos(mpFillAttrLB->GetEntryCount() - 1);
}
}
- // NEU
}
else
- pFillAttrLB->SetNoSelection();
+ {
+ mpFillAttrLB->SetNoSelection();
+ }
+ break;
}
- break;
case XFILL_BITMAP:
{
- if ( pBitmapItem )
- // &&
- // SfxObjectShell::Current() &&
- // SfxObjectShell::Current()->GetItem( SID_BITMAP_LIST ) )
+ if(mpBitmapItem)
{
- String aString( pBitmapItem->GetName() );
- // Bitmap aBitmap( pBitmapItem->GetValue() );
+ String aString(mpBitmapItem->GetName());
+ mpFillAttrLB->SelectEntry(aString);
- // 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 )
+ if(mpFillAttrLB->GetSelectEntry() != aString)
{
- sal_uInt16 nCount = pFillAttrLB->GetEntryCount();
+ sal_uInt16 nCount = mpFillAttrLB->GetEntryCount();
String aTmpStr;
- if( nCount > 0 )
+
+ 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 )
+ aTmpStr = mpFillAttrLB->GetEntry(nCount - 1);
+
+ if(aTmpStr.GetChar(0) == TMP_STR_BEGIN && aTmpStr.GetChar(aTmpStr.Len() - 1) == TMP_STR_END)
{
- pFillAttrLB->RemoveEntry( nCount - 1 );
+ 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 );
+ mpFillAttrLB->Fill(aNew);
+ mpFillAttrLB->SelectEntryPos(mpFillAttrLB->GetEntryCount() - 1);
}
- // NEU
}
else
- pFillAttrLB->SetNoSelection();
+ {
+ mpFillAttrLB->SetNoSelection();
+ }
+ break;
}
- break;
default:
- DBG_ERROR( "Nicht unterstuetzter Flaechentyp" );
- break;
+ {
+ DBG_ERROR("Nicht unterstuetzter Flaechentyp");
+ break;
+ }
}
+
+ // update mnLastFillAttrControlSelectEntryPos
+ mpFillControl->updateLastFillAttrControlSelectEntryPos();
}
- if( pState && pStyleItem )
+ if(pState && mpStyleItem)
{
- XFillStyle eXFS = (XFillStyle) pStyleItem->GetValue();
+ XFillStyle eXFS = static_cast< XFillStyle >(mpStyleItem->GetValue());
// 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 )
+ switch(eXFS)
{
- 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 );
+ case XFILL_SOLID:
+ {
+ const SvxColorTableItem* pItem = dynamic_cast< const SvxColorTableItem* >(pState);
+
+ if(pItem)
+ {
+ ::Color aTmpColor(mpFillAttrLB->GetSelectEntryColor());
+ mpFillAttrLB->Clear();
+ mpFillAttrLB->Fill(pItem->GetColorTable());
+ mpFillAttrLB->SelectEntry(aTmpColor);
+ }
+ break;
+ }
+ case XFILL_GRADIENT:
+ {
+ const SvxGradientListItem* pItem = dynamic_cast< const SvxGradientListItem* >(pState);
+
+ if(pItem)
+ {
+ String aString(mpFillAttrLB->GetSelectEntry());
+ mpFillAttrLB->Clear();
+ mpFillAttrLB->Fill(pItem->GetGradientList());
+ mpFillAttrLB->SelectEntry(aString);
+ }
+ break;
+ }
+ case XFILL_HATCH:
+ {
+ const SvxHatchListItem* pItem = dynamic_cast< const SvxHatchListItem* >(pState);
+
+ if(pItem)
+ {
+ String 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)
+ {
+ String 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);
// Damit dem FillControl das SvxFillToolBoxControl bekannt ist
// (und um kompatibel zu bleiben)
- pFillControl->SetData( this );
+ mpFillControl->SetData(this);
+
+ mpFillAttrLB = (SvxFillAttrBox*)mpFillControl->mpLbFillAttr;
+ mpFillTypeLB = (SvxFillTypeBox*)mpFillControl->mpLbFillType;
- pFillAttrLB = (SvxFillAttrBox*)pFillControl->pLbFillAttr;
- pFillTypeLB = (SvxFillTypeBox*)pFillControl->pLbFillType;
+ mpFillAttrLB->SetUniqueId(HID_FILL_ATTR_LISTBOX);
+ mpFillTypeLB->SetUniqueId(HID_FILL_TYPE_LISTBOX);
- pFillAttrLB->SetUniqueId( HID_FILL_ATTR_LISTBOX );
- pFillTypeLB->SetUniqueId( HID_FILL_TYPE_LISTBOX );
+ 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 pFillControl;
+ return mpFillControl;
}
return NULL;
}
@@ -504,283 +557,337 @@ Window* SvxFillToolBoxControl::CreateItemWindow( Window *pParent )
|*
\************************************************************************/
-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();
+ 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())));
- 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;
-}
-
-//------------------------------------------------------------------------
-
-IMPL_LINK_INLINE_START( FillControl, DelayHdl, Timer *, EMPTYARG )
-{
- SelectFillTypeHdl( NULL );
- ( (SvxFillToolBoxControl*)GetData() )->updateStatus( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillStyle" )));
-// ( (SvxFillToolBoxControl*)GetData() )->GetBindings().Invalidate( SID_ATTR_FILL_STYLE );
- return 0;
+ delete mpLbFillType;
+ delete mpLbFillAttr;
}
-IMPL_LINK_INLINE_END( FillControl, DelayHdl, Timer *, pTimer )
//------------------------------------------------------------------------
-IMPL_LINK( FillControl, SelectFillTypeHdl, ListBox *, pBox )
+void FillControl::InitializeFillStyleAccordingToGivenFillType(XFillStyle aFillStyle)
{
- XFillStyle eXFS = (XFillStyle)pLbFillType->GetSelectEntryPos();
-
- // 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).
+ SfxObjectShell* pSh = SfxObjectShell::Current();
+ bool bDone(false);
- if ( ( pBox && !pBox->IsTravelSelect() ) || !pBox )
+ if(pSh)
{
- // 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();
-
- pLbFillAttr->Clear();
- SfxObjectShell* pSh = SfxObjectShell::Current();
+ // clear in all cases, else we would risk a mix of FillStyles in the Style list
+ mpLbFillAttr->Clear();
- switch( eXFS )
+ switch(aFillStyle)
{
- case XFILL_NONE:
- {
- pLbFillType->Selected();
- SelectFillAttrHdl( pBox );
- pLbFillAttr->Disable();
- }
- break;
-
case XFILL_SOLID:
{
- if ( pSh && pSh->GetItem( SID_COLOR_TABLE ) )
+ if(pSh->GetItem(SID_COLOR_TABLE))
{
- SvxColorTableItem aItem( *(const SvxColorTableItem*)(
- pSh->GetItem( SID_COLOR_TABLE ) ) );
- pLbFillAttr->Enable();
- pLbFillAttr->Fill( aItem.GetColorTable() );
+ const SvxColorTableItem* pItem = static_cast< const SvxColorTableItem* >(pSh->GetItem(SID_COLOR_TABLE));
+ mpLbFillAttr->Enable();
+ mpLbFillAttr->Fill(pItem->GetColorTable());
+ bDone = true;
}
- else
- pLbFillAttr->Disable();
+ break;
}
- break;
case XFILL_GRADIENT:
{
- if ( pSh && pSh->GetItem( SID_GRADIENT_LIST ) )
+ if(pSh->GetItem(SID_GRADIENT_LIST))
{
- SvxGradientListItem aItem( *(const SvxGradientListItem*)(
- pSh->GetItem( SID_GRADIENT_LIST ) ) );
- pLbFillAttr->Enable();
- pLbFillAttr->Fill( aItem.GetGradientList() );
+ const SvxGradientListItem* pItem = static_cast< const SvxGradientListItem* >(pSh->GetItem(SID_GRADIENT_LIST));
+ mpLbFillAttr->Enable();
+ mpLbFillAttr->Fill(pItem->GetGradientList());
+ bDone = true;
}
- else
- pLbFillAttr->Disable();
+ break;
}
- break;
case XFILL_HATCH:
{
- if ( pSh && pSh->GetItem( SID_HATCH_LIST ) )
+ if(pSh->GetItem(SID_HATCH_LIST))
{
- SvxHatchListItem aItem( *(const SvxHatchListItem*)(
- pSh->GetItem( SID_HATCH_LIST ) ) );
- pLbFillAttr->Enable();
- pLbFillAttr->Fill( aItem.GetHatchList() );
+ const SvxHatchListItem* pItem = static_cast< const SvxHatchListItem* >(pSh->GetItem(SID_HATCH_LIST));
+ mpLbFillAttr->Enable();
+ mpLbFillAttr->Fill(pItem->GetHatchList());
+ bDone = true;
}
- else
- pLbFillAttr->Disable();
+ break;
}
- break;
case XFILL_BITMAP:
{
- if ( pSh && pSh->GetItem( SID_BITMAP_LIST ) )
+ if(pSh->GetItem(SID_BITMAP_LIST))
{
- SvxBitmapListItem aItem( *(const SvxBitmapListItem*)(
- pSh->GetItem( SID_BITMAP_LIST ) ) );
- pLbFillAttr->Enable();
- pLbFillAttr->Fill( aItem.GetBitmapList() );
+ const SvxBitmapListItem* pItem = static_cast< const SvxBitmapListItem* >(pSh->GetItem(SID_BITMAP_LIST));
+ mpLbFillAttr->Enable();
+ mpLbFillAttr->Fill(pItem->GetBitmapList());
+ bDone = true;
}
- else
- pLbFillAttr->Disable();
+ break;
+ }
+ default: // XFILL_NONE
+ {
+ // accept disable (no styles for XFILL_NONE)
+ break;
}
- break;
}
+ }
- if( eXFS != XFILL_NONE ) // Wurde schon erledigt
- {
- if ( pBox )
- pLbFillType->Selected();
+ if(!bDone)
+ {
+ mpLbFillAttr->Disable();
+ }
+}
- // release focus
- if ( pBox && pLbFillType->IsRelease() )
- {
- SfxViewShell* pViewShell = SfxViewShell::Current();
- if( pViewShell && pViewShell->GetWindow() )
- pViewShell->GetWindow()->GrabFocus();
- }
+void FillControl::updateLastFillTypeControlSelectEntryPos()
+{
+ mnLastFillTypeControlSelectEntryPos = mpLbFillType->GetSelectEntryPos();
+}
+
+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;
}
//------------------------------------------------------------------------
-IMPL_LINK( FillControl, SelectFillAttrHdl, ListBox *, pBox )
+void FillControl::updateLastFillAttrControlSelectEntryPos()
+{
+ mnLastFillAttrControlSelectEntryPos = mpLbFillAttr->GetSelectEntryPos();
+}
+
+IMPL_LINK(FillControl, SelectFillAttrHdl, ListBox *, pBox)
{
- XFillStyle eXFS = (XFillStyle)pLbFillType->GetSelectEntryPos();
- XFillStyleItem aXFillStyleItem( eXFS );
- sal_Bool bAction = pBox && !pLbFillAttr->IsTravelSelect();
+ if(!pBox) // only work with real calls from ListBox, do not accept direct calls with zeros here
+ {
+ return 0;
+ }
- SfxObjectShell* pSh = SfxObjectShell::Current();
- if ( bAction )
+ const bool bAction(
+ !mpLbFillAttr->IsTravelSelect() // keep TravelSelect, this means keyboard up/down in the list
+ && mpLbFillAttr->GetSelectEntryCount()
+ && mpLbFillAttr->GetSelectEntryPos() != mnLastFillAttrControlSelectEntryPos);
+
+ updateLastFillAttrControlSelectEntryPos();
+
+ if(bAction)
{
- Any a;
- Sequence< PropertyValue > aArgs( 1 );
+ SfxObjectShell* pSh = SfxObjectShell::Current();
- // 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 );
+ // 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);
+ ::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 ) ) );
+ const SvxGradientListItem* pItem = static_cast< const SvxGradientListItem* >(pSh->GetItem(SID_GRADIENT_LIST));
- if ( nPos < aItem.GetGradientList()->Count() ) // kein temp. Eintrag ?
+ if(nPos < pItem->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 = pItem->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 ) ) );
+ const SvxHatchListItem* pItem = static_cast< const SvxHatchListItem* >(pSh->GetItem(SID_HATCH_LIST));
- if ( nPos < aItem.GetHatchList()->Count() ) // kein temp. Eintrag ?
+ if(nPos < pItem->GetHatchList()->Count()) // kein temp. Eintrag ?
{
- XHatch aHatch = aItem.GetHatchList()->GetHatch( nPos )->GetHatch();
- XFillHatchItem aXFillHatchItem( pLbFillAttr->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 );
+ XHatch aHatch = pItem->GetHatchList()->GetHatch(nPos)->GetHatch();
+ XFillHatchItem aXFillHatchItem(mpLbFillAttr->GetSelectEntry(),aHatch);
+
+ 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 ) ) );
+ const SvxBitmapListItem* pItem = static_cast< const SvxBitmapListItem* >(pSh->GetItem(SID_BITMAP_LIST));
- if ( nPos < aItem.GetBitmapList()->Count() ) // kein temp. Eintrag ?
+ if(nPos < pItem->GetBitmapList()->Count()) // kein temp. Eintrag ?
{
- const XBitmapEntry* pXBitmapEntry = aItem.GetBitmapList()->GetBitmap(nPos);
- const XFillBitmapItem aXFillBitmapItem(pLbFillAttr->GetSelectEntry(), pXBitmapEntry->GetGraphicObject());
+ const XBitmapEntry* pXBitmapEntry = pItem->GetBitmapList()->GetBitmap(nPos);
+ 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 )
+ // this is the place where evtl. a new slot action may be introduced to avoid the
+ // 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();
- if( pViewShell && pViewShell->GetWindow() )
+
+ if(pViewShell && pViewShell->GetWindow())
{
pViewShell->GetWindow()->GrabFocus();
}
@@ -799,31 +906,33 @@ void FillControl::Resize()
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
More information about the Libreoffice-commits
mailing list