Kaydet (Commit) 8025a41b authored tarafından Michael Meeks's avatar Michael Meeks

fix XColorList related crasher in tools->options, and try to clean more

üst ab389546
...@@ -672,12 +672,14 @@ public: ...@@ -672,12 +672,14 @@ public:
/************************************************************************/ /************************************************************************/
struct SvxColorTabPageShadow;
class SvxColorTabPage : public SfxTabPage, public SvxLoadSaveEmbed class SvxColorTabPage : public SfxTabPage, public SvxLoadSaveEmbed
{ {
using TabPage::ActivatePage; using TabPage::ActivatePage;
using TabPage::DeactivatePage; using TabPage::DeactivatePage;
private: private:
SvxColorTabPageShadow *pShadow;
FixedLine aFlProp; FixedLine aFlProp;
FixedText aFtName; FixedText aFtName;
Edit aEdtName; Edit aEdtName;
...@@ -751,7 +753,8 @@ private: ...@@ -751,7 +753,8 @@ private:
void UpdateModified(); void UpdateModified();
public: public:
SvxColorTabPage( Window* pParent, const SfxItemSet& rInAttrs ); SvxColorTabPage( Window* pParent, const SfxItemSet& rInAttrs );
~SvxColorTabPage();
void Construct(); void Construct();
...@@ -762,7 +765,13 @@ public: ...@@ -762,7 +765,13 @@ public:
virtual void ActivatePage( const SfxItemSet& rSet ); virtual void ActivatePage( const SfxItemSet& rSet );
virtual int DeactivatePage( SfxItemSet* pSet ); virtual int DeactivatePage( SfxItemSet* pSet );
void SetColorList( XColorListRef pColTab ) { pColorList = pColTab; } virtual XPropertyListRef GetPropertyList( XPropertyListType t );
virtual void SetPropertyList( XPropertyListType t, const XPropertyListRef &xRef );
void SetColorList( XColorListRef pColList );
XColorListRef GetColorList() { return pColorList; }
void SaveToViewFrame( SfxViewFrame *pViewFrame );
void SetupForViewFrame( SfxViewFrame *pViewFrame );
void SetPageType( sal_uInt16* pInType ) { pPageType = pInType; } void SetPageType( sal_uInt16* pInType ) { pPageType = pInType; }
void SetDlgType( sal_uInt16* pInType ) { pDlgType = pInType; } void SetDlgType( sal_uInt16* pInType ) { pDlgType = pInType; }
......
...@@ -172,6 +172,7 @@ namespace com { namespace sun { namespace star { namespace awt { class XContaine ...@@ -172,6 +172,7 @@ namespace com { namespace sun { namespace star { namespace awt { class XContaine
struct OptionsPageInfo; struct OptionsPageInfo;
struct Module; struct Module;
class ExtensionsTabPage; class ExtensionsTabPage;
class SvxColorTabPage;
typedef std::vector< ExtensionsTabPage* > VectorOfPages; typedef std::vector< ExtensionsTabPage* > VectorOfPages;
class OfaTreeOptionsDialog : public SfxModalDialog class OfaTreeOptionsDialog : public SfxModalDialog
...@@ -201,15 +202,11 @@ private: ...@@ -201,15 +202,11 @@ private:
// for the ColorTabPage // for the ColorTabPage
SfxItemSet* pColorPageItemSet; SfxItemSet* pColorPageItemSet;
XColorListRef pColorList; SvxColorTabPage *mpColorPage;;
sal_uInt16 nChangeType;
sal_uInt16 nUnknownType; sal_Bool bForgetSelection;
sal_uInt16 nUnknownPos; sal_Bool bExternBrowserActive;
sal_Bool bIsAreaTP; sal_Bool bImageResized;
sal_Bool bForgetSelection;
sal_Bool bExternBrowserActive;
sal_Bool bImageResized;
bool bInSelectHdl_Impl; bool bInSelectHdl_Impl;
bool bIsFromExtensionManager; bool bIsFromExtensionManager;
...@@ -272,9 +269,6 @@ public: ...@@ -272,9 +269,6 @@ public:
void ActivatePage( const String& rPageURL ); void ActivatePage( const String& rPageURL );
void ApplyItemSets(); void ApplyItemSets();
sal_uInt16 GetColorChanged() const { return nChangeType; }
XColorListRef GetColorList() { return pColorList; }
// helper functions to call the language settings TabPage from the SpellDialog // helper functions to call the language settings TabPage from the SpellDialog
static void ApplyLanguageOptions(const SfxItemSet& rSet); static void ApplyLanguageOptions(const SfxItemSet& rSet);
}; };
......
...@@ -154,7 +154,6 @@ using namespace ::com::sun::star::util; ...@@ -154,7 +154,6 @@ using namespace ::com::sun::star::util;
#define HINT_TIMEOUT 200 #define HINT_TIMEOUT 200
#define SELECT_FIRST_TIMEOUT 0 #define SELECT_FIRST_TIMEOUT 0
#define SELECT_TIMEOUT 300 #define SELECT_TIMEOUT 300
#define COLORPAGE_UNKNOWN ((sal_uInt16)0xFFFF)
#define EXPAND_PROTOCOL "vnd.sun.star.expand:" #define EXPAND_PROTOCOL "vnd.sun.star.expand:"
LastPageSaver* OfaTreeOptionsDialog::pLastPageSaver = NULL; LastPageSaver* OfaTreeOptionsDialog::pLastPageSaver = NULL;
...@@ -553,10 +552,7 @@ sal_Bool OfaOptionsTreeListBox::Collapse( SvLBoxEntry* pParent ) ...@@ -553,10 +552,7 @@ sal_Bool OfaOptionsTreeListBox::Collapse( SvLBoxEntry* pParent )
sNotLoadedError ( CUI_RES( ST_LOAD_ERROR ) ),\ sNotLoadedError ( CUI_RES( ST_LOAD_ERROR ) ),\
pCurrentPageEntry ( NULL ),\ pCurrentPageEntry ( NULL ),\
pColorPageItemSet ( NULL ),\ pColorPageItemSet ( NULL ),\
nChangeType ( CT_NONE ),\ mpColorPage ( NULL ),\
nUnknownType ( COLORPAGE_UNKNOWN ),\
nUnknownPos ( COLORPAGE_UNKNOWN ),\
bIsAreaTP ( sal_False ),\
bForgetSelection ( sal_False ),\ bForgetSelection ( sal_False ),\
bImageResized ( sal_False ),\ bImageResized ( sal_False ),\
bInSelectHdl_Impl ( false ),\ bInSelectHdl_Impl ( false ),\
...@@ -1159,20 +1155,8 @@ IMPL_LINK( OfaTreeOptionsDialog, SelectHdl_Impl, Timer*, EMPTYARG ) ...@@ -1159,20 +1155,8 @@ IMPL_LINK( OfaTreeOptionsDialog, SelectHdl_Impl, Timer*, EMPTYARG )
{ {
pPageInfo->m_pPage = ::CreateGeneralTabPage( pPageInfo->m_pPage = ::CreateGeneralTabPage(
pPageInfo->m_nPageId, this, *pColorPageItemSet ); pPageInfo->m_nPageId, this, *pColorPageItemSet );
SvxColorTabPage& rColPage = *(SvxColorTabPage*)pPageInfo->m_pPage; mpColorPage = (SvxColorTabPage*)pPageInfo->m_pPage;
const OfaRefItem<XColorList> *pPtr = NULL; mpColorPage->SetupForViewFrame( SfxViewFrame::Current() );
if ( SfxViewFrame::Current() && SfxViewFrame::Current()->GetDispatcher() )
pPtr = (const OfaRefItem<XColorList> *)SfxViewFrame::Current()->
GetDispatcher()->Execute( SID_GET_COLORLIST, SFX_CALLMODE_SYNCHRON );
pColorList = pPtr ? pPtr->GetValue() : XColorList::GetStdColorList();
rColPage.SetColorList( pColorList );
rColPage.SetPageType( &nUnknownType );
rColPage.SetDlgType( &nUnknownType );
rColPage.SetPos( &nUnknownPos );
rColPage.SetAreaTP( &bIsAreaTP );
rColPage.SetColorChgd( (ChangeType*)&nChangeType );
rColPage.Construct();
} }
DBG_ASSERT( pPageInfo->m_pPage, "tabpage could not created"); DBG_ASSERT( pPageInfo->m_pPage, "tabpage could not created");
...@@ -2605,26 +2589,8 @@ short OfaTreeOptionsDialog::Execute() ...@@ -2605,26 +2589,8 @@ short OfaTreeOptionsDialog::Execute()
if( RET_OK == nRet ) if( RET_OK == nRet )
{ {
ApplyItemSets(); ApplyItemSets();
if( GetColorList().is() ) if( mpColorPage )
{ mpColorPage->SaveToViewFrame( SfxViewFrame::Current() );
GetColorList()->Save();
// notify current viewframe that it uses the same color table
if ( SfxViewFrame::Current() && SfxViewFrame::Current()->GetDispatcher() )
{
const OfaRefItem<XColorList> * pPtr = (const OfaRefItem<XColorList>*)SfxViewFrame::Current()->GetDispatcher()->Execute( SID_GET_COLORLIST, SFX_CALLMODE_SYNCHRON );
if( pPtr )
{
XColorListRef _pColorList = pPtr->GetValue();
if( _pColorList.is() &&
_pColorList->GetPath() == GetColorList()->GetPath() &&
_pColorList->GetName() == GetColorList()->GetName() )
SfxObjectShell::Current()->PutItem( SvxColorListItem( GetColorList(), SID_COLOR_TABLE ) );
}
}
}
utl::ConfigManager::GetConfigManager().StoreConfigItems(); utl::ConfigManager::GetConfigManager().StoreConfigItems();
} }
......
...@@ -74,7 +74,6 @@ SvxAreaTabDialog::SvxAreaTabDialog ...@@ -74,7 +74,6 @@ SvxAreaTabDialog::SvxAreaTabDialog
mnHatchingListState ( CT_NONE ), mnHatchingListState ( CT_NONE ),
mnPageType( PT_AREA ), mnPageType( PT_AREA ),
mnDlgType( 0 ), mnDlgType( 0 ),
mnPos( 0 ),
mbAreaTP( sal_False ) mbAreaTP( sal_False )
{ {
FreeResource(); FreeResource();
......
...@@ -31,9 +31,14 @@ ...@@ -31,9 +31,14 @@
#include <unotools/pathoptions.hxx> #include <unotools/pathoptions.hxx>
#include <sfx2/app.hxx> #include <sfx2/app.hxx>
#include <sfx2/module.hxx> #include <sfx2/module.hxx>
#include <sfx2/objsh.hxx>
#include <sfx2/viewsh.hxx>
#include <sfx2/viewfrm.hxx>
#include <sfx2/dispatch.hxx>
#include <svtools/colrdlg.hxx> #include <svtools/colrdlg.hxx>
#include <vcl/msgbox.hxx> #include <vcl/msgbox.hxx>
#include <sfx2/filedlghelper.hxx> #include <sfx2/filedlghelper.hxx>
#include <svx/ofaitem.hxx>
#include "com/sun/star/ui/dialogs/TemplateDescription.hpp" #include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
#define _SVX_TPCOLOR_CXX #define _SVX_TPCOLOR_CXX
...@@ -96,6 +101,13 @@ XPropertyListRef SvxLoadSaveEmbed::GetList() ...@@ -96,6 +101,13 @@ XPropertyListRef SvxLoadSaveEmbed::GetList()
pList = pLine->GetColorList(); pList = pLine->GetColorList();
} }
// URGH - abstract this nicely ... for re-using SvxLoadSaveEmbed
if( !pList.is() ) {
SvxColorTabPage *pPage = dynamic_cast< SvxColorTabPage *>( this );
if( pPage )
pList = pPage->GetColorList();
}
return XPropertyListRef( static_cast< XPropertyList * >( pList.get() ) ); return XPropertyListRef( static_cast< XPropertyList * >( pList.get() ) );
} }
...@@ -133,6 +145,8 @@ void SvxLoadSaveEmbed::UpdateTableName() ...@@ -133,6 +145,8 @@ void SvxLoadSaveEmbed::UpdateTableName()
aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) ); aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) );
XPropertyListRef pList = GetList(); XPropertyListRef pList = GetList();
if( !pList.is() )
return;
INetURLObject aURL( pList->GetPath() ); INetURLObject aURL( pList->GetPath() );
aURL.Append( pList->GetName() ); aURL.Append( pList->GetName() );
...@@ -294,6 +308,26 @@ void SvxColorTabPage::Update(bool bLoaded) ...@@ -294,6 +308,26 @@ void SvxColorTabPage::Update(bool bLoaded)
UpdateModified(); UpdateModified();
} }
// FIXME: you have to hate yourself for this - all this
// horrible and broadly unused pointer based coupling
// needs to die. cf SetupForViewFrame
#define COLORPAGE_UNKNOWN ((sal_uInt16)0xFFFF)
struct SvxColorTabPageShadow
{
sal_uInt16 nUnknownType;
sal_uInt16 nUnknownPos;
sal_Bool bIsAreaTP;
sal_uInt16 nChangeType;
SvxColorTabPageShadow()
: nUnknownType( COLORPAGE_UNKNOWN )
, nUnknownPos( COLORPAGE_UNKNOWN )
, bIsAreaTP( sal_False )
, nChangeType( 0 )
{
}
};
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
SvxColorTabPage::SvxColorTabPage SvxColorTabPage::SvxColorTabPage
...@@ -308,6 +342,7 @@ SvxColorTabPage::SvxColorTabPage ...@@ -308,6 +342,7 @@ SvxColorTabPage::SvxColorTabPage
CUI_RES( BTN_EMBED ), CUI_RES( FT_TABLE_NAME ), CUI_RES( BTN_EMBED ), CUI_RES( FT_TABLE_NAME ),
XCOLOR_LIST, (XOutdevItemPool*) rInAttrs.GetPool() ), XCOLOR_LIST, (XOutdevItemPool*) rInAttrs.GetPool() ),
pShadow ( new SvxColorTabPageShadow() ),
aFlProp ( this, CUI_RES( FL_PROP ) ), aFlProp ( this, CUI_RES( FL_PROP ) ),
aFtName ( this, CUI_RES( FT_NAME ) ), aFtName ( this, CUI_RES( FT_NAME ) ),
aEdtName ( this, CUI_RES( EDT_NAME ) ), aEdtName ( this, CUI_RES( EDT_NAME ) ),
...@@ -335,11 +370,16 @@ SvxColorTabPage::SvxColorTabPage ...@@ -335,11 +370,16 @@ SvxColorTabPage::SvxColorTabPage
rOutAttrs ( rInAttrs ), rOutAttrs ( rInAttrs ),
// All the horrific pointers we store and should not
pPageType ( NULL ),
pDlgType ( NULL ),
pPos ( NULL ),
pbAreaTP ( NULL ),
aXFStyleItem ( XFILL_SOLID ), aXFStyleItem ( XFILL_SOLID ),
aXFillColorItem ( String(), Color( COL_BLACK ) ), aXFillColorItem ( String(), Color( COL_BLACK ) ),
aXFillAttr ( (XOutdevItemPool*) rInAttrs.GetPool() ), aXFillAttr ( (XOutdevItemPool*) rInAttrs.GetPool() ),
rXFSet ( aXFillAttr.GetItemSet() ), rXFSet ( aXFillAttr.GetItemSet() ),
eCM ( CM_RGB ) eCM ( CM_RGB )
{ {
FreeResource(); FreeResource();
...@@ -389,12 +429,18 @@ SvxColorTabPage::SvxColorTabPage ...@@ -389,12 +429,18 @@ SvxColorTabPage::SvxColorTabPage
aBtnDelete.SetAccessibleRelationMemberOf( &aFlProp ); aBtnDelete.SetAccessibleRelationMemberOf( &aFlProp );
} }
SvxColorTabPage::~SvxColorTabPage()
{
delete pShadow;
}
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
void SvxColorTabPage::Construct() void SvxColorTabPage::Construct()
{ {
aLbColor.Fill( pColorList ); aLbColor.Fill( pColorList );
FillValueSet_Impl( aValSetColorList ); FillValueSet_Impl( aValSetColorList );
UpdateTableName();
} }
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
...@@ -1202,4 +1248,70 @@ void SvxColorTabPage::FillUserData() ...@@ -1202,4 +1248,70 @@ void SvxColorTabPage::FillUserData()
SetUserData( UniString::CreateFromInt32( eCM ) ); SetUserData( UniString::CreateFromInt32( eCM ) );
} }
//------------------------------------------------------------------------
void SvxColorTabPage::SetupForViewFrame( SfxViewFrame *pViewFrame )
{
const OfaRefItem<XColorList> *pPtr = NULL;
if ( pViewFrame != NULL && pViewFrame->GetDispatcher() )
pPtr = (const OfaRefItem<XColorList> *)pViewFrame->
GetDispatcher()->Execute( SID_GET_COLORLIST,
SFX_CALLMODE_SYNCHRON );
pColorList = pPtr ? pPtr->GetValue() : XColorList::GetStdColorList();
SetPageType( &pShadow->nUnknownType );
SetDlgType( &pShadow->nUnknownType );
SetPos( &pShadow->nUnknownPos );
SetAreaTP( &pShadow->bIsAreaTP );
SetColorChgd( (ChangeType*)&pShadow->nChangeType );
Construct();
}
void SvxColorTabPage::SaveToViewFrame( SfxViewFrame *pViewFrame )
{
if( !pColorList.is() )
return;
pColorList->Save();
if( !pViewFrame )
return;
// notify current viewframe that it uses the same color table
if ( !pViewFrame->GetDispatcher() )
return;
const OfaRefItem<XColorList> * pPtr;
pPtr = (const OfaRefItem<XColorList>*)pViewFrame->GetDispatcher()->Execute( SID_GET_COLORLIST, SFX_CALLMODE_SYNCHRON );
if( pPtr )
{
XColorListRef pReference = pPtr->GetValue();
if( pReference.is() &&
pReference->GetPath() == pColorList->GetPath() &&
pReference->GetName() == pColorList->GetName() )
SfxObjectShell::Current()->PutItem( SvxColorListItem( pColorList,
SID_COLOR_TABLE ) );
}
}
void SvxColorTabPage::SetPropertyList( XPropertyListType t, const XPropertyListRef &xRef )
{
OSL_ASSERT( t == XCOLOR_LIST );
pColorList = XColorListRef( static_cast<XColorList *>(xRef.get() ) );
}
void SvxColorTabPage::SetColorList( XColorListRef pColList )
{
SetPropertyList( XCOLOR_LIST, XPropertyListRef( ( pColList.get() ) ) );
}
XPropertyListRef SvxColorTabPage::GetPropertyList( XPropertyListType t )
{
OSL_ASSERT( t == XCOLOR_LIST );
return XPropertyListRef( pColorList.get() );
}
/* 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