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:
/************************************************************************/
struct SvxColorTabPageShadow;
class SvxColorTabPage : public SfxTabPage, public SvxLoadSaveEmbed
{
using TabPage::ActivatePage;
using TabPage::DeactivatePage;
private:
SvxColorTabPageShadow *pShadow;
FixedLine aFlProp;
FixedText aFtName;
Edit aEdtName;
......@@ -752,6 +754,7 @@ private:
void UpdateModified();
public:
SvxColorTabPage( Window* pParent, const SfxItemSet& rInAttrs );
~SvxColorTabPage();
void Construct();
......@@ -762,7 +765,13 @@ public:
virtual void ActivatePage( const SfxItemSet& rSet );
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 SetDlgType( sal_uInt16* pInType ) { pDlgType = pInType; }
......
......@@ -172,6 +172,7 @@ namespace com { namespace sun { namespace star { namespace awt { class XContaine
struct OptionsPageInfo;
struct Module;
class ExtensionsTabPage;
class SvxColorTabPage;
typedef std::vector< ExtensionsTabPage* > VectorOfPages;
class OfaTreeOptionsDialog : public SfxModalDialog
......@@ -201,11 +202,7 @@ private:
// for the ColorTabPage
SfxItemSet* pColorPageItemSet;
XColorListRef pColorList;
sal_uInt16 nChangeType;
sal_uInt16 nUnknownType;
sal_uInt16 nUnknownPos;
sal_Bool bIsAreaTP;
SvxColorTabPage *mpColorPage;;
sal_Bool bForgetSelection;
sal_Bool bExternBrowserActive;
......@@ -272,9 +269,6 @@ public:
void ActivatePage( const String& rPageURL );
void ApplyItemSets();
sal_uInt16 GetColorChanged() const { return nChangeType; }
XColorListRef GetColorList() { return pColorList; }
// helper functions to call the language settings TabPage from the SpellDialog
static void ApplyLanguageOptions(const SfxItemSet& rSet);
};
......
......@@ -154,7 +154,6 @@ using namespace ::com::sun::star::util;
#define HINT_TIMEOUT 200
#define SELECT_FIRST_TIMEOUT 0
#define SELECT_TIMEOUT 300
#define COLORPAGE_UNKNOWN ((sal_uInt16)0xFFFF)
#define EXPAND_PROTOCOL "vnd.sun.star.expand:"
LastPageSaver* OfaTreeOptionsDialog::pLastPageSaver = NULL;
......@@ -553,10 +552,7 @@ sal_Bool OfaOptionsTreeListBox::Collapse( SvLBoxEntry* pParent )
sNotLoadedError ( CUI_RES( ST_LOAD_ERROR ) ),\
pCurrentPageEntry ( NULL ),\
pColorPageItemSet ( NULL ),\
nChangeType ( CT_NONE ),\
nUnknownType ( COLORPAGE_UNKNOWN ),\
nUnknownPos ( COLORPAGE_UNKNOWN ),\
bIsAreaTP ( sal_False ),\
mpColorPage ( NULL ),\
bForgetSelection ( sal_False ),\
bImageResized ( sal_False ),\
bInSelectHdl_Impl ( false ),\
......@@ -1159,20 +1155,8 @@ IMPL_LINK( OfaTreeOptionsDialog, SelectHdl_Impl, Timer*, EMPTYARG )
{
pPageInfo->m_pPage = ::CreateGeneralTabPage(
pPageInfo->m_nPageId, this, *pColorPageItemSet );
SvxColorTabPage& rColPage = *(SvxColorTabPage*)pPageInfo->m_pPage;
const OfaRefItem<XColorList> *pPtr = NULL;
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();
mpColorPage = (SvxColorTabPage*)pPageInfo->m_pPage;
mpColorPage->SetupForViewFrame( SfxViewFrame::Current() );
}
DBG_ASSERT( pPageInfo->m_pPage, "tabpage could not created");
......@@ -2605,26 +2589,8 @@ short OfaTreeOptionsDialog::Execute()
if( RET_OK == nRet )
{
ApplyItemSets();
if( GetColorList().is() )
{
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 ) );
}
}
}
if( mpColorPage )
mpColorPage->SaveToViewFrame( SfxViewFrame::Current() );
utl::ConfigManager::GetConfigManager().StoreConfigItems();
}
......
......@@ -74,7 +74,6 @@ SvxAreaTabDialog::SvxAreaTabDialog
mnHatchingListState ( CT_NONE ),
mnPageType( PT_AREA ),
mnDlgType( 0 ),
mnPos( 0 ),
mbAreaTP( sal_False )
{
FreeResource();
......
......@@ -31,9 +31,14 @@
#include <unotools/pathoptions.hxx>
#include <sfx2/app.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 <vcl/msgbox.hxx>
#include <sfx2/filedlghelper.hxx>
#include <svx/ofaitem.hxx>
#include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
#define _SVX_TPCOLOR_CXX
......@@ -96,6 +101,13 @@ XPropertyListRef SvxLoadSaveEmbed::GetList()
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() ) );
}
......@@ -133,6 +145,8 @@ void SvxLoadSaveEmbed::UpdateTableName()
aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) );
XPropertyListRef pList = GetList();
if( !pList.is() )
return;
INetURLObject aURL( pList->GetPath() );
aURL.Append( pList->GetName() );
......@@ -294,6 +308,26 @@ void SvxColorTabPage::Update(bool bLoaded)
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
......@@ -308,6 +342,7 @@ SvxColorTabPage::SvxColorTabPage
CUI_RES( BTN_EMBED ), CUI_RES( FT_TABLE_NAME ),
XCOLOR_LIST, (XOutdevItemPool*) rInAttrs.GetPool() ),
pShadow ( new SvxColorTabPageShadow() ),
aFlProp ( this, CUI_RES( FL_PROP ) ),
aFtName ( this, CUI_RES( FT_NAME ) ),
aEdtName ( this, CUI_RES( EDT_NAME ) ),
......@@ -335,11 +370,16 @@ SvxColorTabPage::SvxColorTabPage
rOutAttrs ( rInAttrs ),
// All the horrific pointers we store and should not
pPageType ( NULL ),
pDlgType ( NULL ),
pPos ( NULL ),
pbAreaTP ( NULL ),
aXFStyleItem ( XFILL_SOLID ),
aXFillColorItem ( String(), Color( COL_BLACK ) ),
aXFillAttr ( (XOutdevItemPool*) rInAttrs.GetPool() ),
rXFSet ( aXFillAttr.GetItemSet() ),
eCM ( CM_RGB )
{
FreeResource();
......@@ -389,12 +429,18 @@ SvxColorTabPage::SvxColorTabPage
aBtnDelete.SetAccessibleRelationMemberOf( &aFlProp );
}
SvxColorTabPage::~SvxColorTabPage()
{
delete pShadow;
}
// -----------------------------------------------------------------------
void SvxColorTabPage::Construct()
{
aLbColor.Fill( pColorList );
FillValueSet_Impl( aValSetColorList );
UpdateTableName();
}
// -----------------------------------------------------------------------
......@@ -1202,4 +1248,70 @@ void SvxColorTabPage::FillUserData()
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: */
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