summaryrefslogtreecommitdiff
path: root/cui
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@suse.com>2011-10-11 14:05:42 +0100
committerMichael Meeks <michael.meeks@suse.com>2011-10-11 17:23:59 +0100
commit8025a41b80d0de2c5fddc3d2d74d2ad34181afe5 (patch)
treecd018223c211e6b9be6691f376c4aa1c51ed581e /cui
parentab3895465a6cf0a8a41c7432ad9a8f77df7ae572 (diff)
fix XColorList related crasher in tools->options, and try to clean more
Diffstat (limited to 'cui')
-rw-r--r--cui/source/inc/cuitabarea.hxx13
-rw-r--r--cui/source/inc/treeopt.hxx18
-rw-r--r--cui/source/options/treeopt.cxx44
-rw-r--r--cui/source/tabpages/tabarea.cxx1
-rw-r--r--cui/source/tabpages/tpcolor.cxx114
5 files changed, 135 insertions, 55 deletions
diff --git a/cui/source/inc/cuitabarea.hxx b/cui/source/inc/cuitabarea.hxx
index 64801cadd047..1f76ce0ad609 100644
--- a/cui/source/inc/cuitabarea.hxx
+++ b/cui/source/inc/cuitabarea.hxx
@@ -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;
@@ -751,7 +753,8 @@ private:
void UpdateModified();
public:
- SvxColorTabPage( Window* pParent, const SfxItemSet& rInAttrs );
+ 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; }
diff --git a/cui/source/inc/treeopt.hxx b/cui/source/inc/treeopt.hxx
index a5b7fd312848..ac12fc2abbbb 100644
--- a/cui/source/inc/treeopt.hxx
+++ b/cui/source/inc/treeopt.hxx
@@ -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,15 +202,11 @@ private:
// for the ColorTabPage
SfxItemSet* pColorPageItemSet;
- XColorListRef pColorList;
- sal_uInt16 nChangeType;
- sal_uInt16 nUnknownType;
- sal_uInt16 nUnknownPos;
- sal_Bool bIsAreaTP;
-
- sal_Bool bForgetSelection;
- sal_Bool bExternBrowserActive;
- sal_Bool bImageResized;
+ SvxColorTabPage *mpColorPage;;
+
+ sal_Bool bForgetSelection;
+ sal_Bool bExternBrowserActive;
+ sal_Bool bImageResized;
bool bInSelectHdl_Impl;
bool bIsFromExtensionManager;
@@ -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);
};
diff --git a/cui/source/options/treeopt.cxx b/cui/source/options/treeopt.cxx
index 76dca3bc8d7a..57b8976c3f62 100644
--- a/cui/source/options/treeopt.cxx
+++ b/cui/source/options/treeopt.cxx
@@ -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();
}
diff --git a/cui/source/tabpages/tabarea.cxx b/cui/source/tabpages/tabarea.cxx
index cda945abe5af..497af51e725f 100644
--- a/cui/source/tabpages/tabarea.cxx
+++ b/cui/source/tabpages/tabarea.cxx
@@ -74,7 +74,6 @@ SvxAreaTabDialog::SvxAreaTabDialog
mnHatchingListState ( CT_NONE ),
mnPageType( PT_AREA ),
mnDlgType( 0 ),
- mnPos( 0 ),
mbAreaTP( sal_False )
{
FreeResource();
diff --git a/cui/source/tabpages/tpcolor.cxx b/cui/source/tabpages/tpcolor.cxx
index 9e9daa727b9e..c63c799009a5 100644
--- a/cui/source/tabpages/tpcolor.cxx
+++ b/cui/source/tabpages/tpcolor.cxx
@@ -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: */
+