2000-09-18 16:07:07 +00:00
|
|
|
/*************************************************************************
|
|
|
|
|
*
|
|
|
|
|
* $RCSfile: imgmgr.cxx,v $
|
|
|
|
|
*
|
2002-06-27 07:19:39 +00:00
|
|
|
* $Revision: 1.10 $
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2002-06-27 07:19:39 +00:00
|
|
|
* last change: $Author: mba $ $Date: 2002-06-27 08:19:39 $
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
|
|
|
|
* The Contents of this file are made available subject to the terms of
|
|
|
|
|
* either of the following licenses
|
|
|
|
|
*
|
|
|
|
|
* - GNU Lesser General Public License Version 2.1
|
|
|
|
|
* - Sun Industry Standards Source License Version 1.1
|
|
|
|
|
*
|
|
|
|
|
* Sun Microsystems Inc., October, 2000
|
|
|
|
|
*
|
|
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
|
* =============================================
|
|
|
|
|
* Copyright 2000 by Sun Microsystems, Inc.
|
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
|
|
|
|
*
|
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
* License version 2.1, as published by the Free Software Foundation.
|
|
|
|
|
*
|
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
|
* MA 02111-1307 USA
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* Sun Industry Standards Source License Version 1.1
|
|
|
|
|
* =================================================
|
|
|
|
|
* The contents of this file are subject to the Sun Industry Standards
|
|
|
|
|
* Source License Version 1.1 (the "License"); You may not use this file
|
|
|
|
|
* except in compliance with the License. You may obtain a copy of the
|
|
|
|
|
* License at http://www.openoffice.org/license.html.
|
|
|
|
|
*
|
|
|
|
|
* Software provided under this License is provided on an "AS IS" basis,
|
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
|
|
|
|
|
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
|
|
|
|
|
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
|
|
|
|
|
* See the License for the specific provisions governing your rights and
|
|
|
|
|
* obligations concerning the Software.
|
|
|
|
|
*
|
|
|
|
|
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
|
|
|
|
|
*
|
|
|
|
|
* Copyright: 2000 by Sun Microsystems, Inc.
|
|
|
|
|
*
|
|
|
|
|
* All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Contributor(s): _______________________________________
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
************************************************************************/
|
|
|
|
|
|
2002-04-11 10:49:39 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
#ifndef _STREAM_HXX //autogen
|
|
|
|
|
#include <tools/stream.hxx>
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef _SV_WRKWIN_HXX //autogen
|
|
|
|
|
#include <vcl/wrkwin.hxx>
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef _SV_BITMAP_HXX
|
|
|
|
|
#include <vcl/bitmap.hxx>
|
|
|
|
|
#endif
|
2001-06-11 09:09:07 +00:00
|
|
|
|
|
|
|
|
#include <tools/link.hxx>
|
|
|
|
|
#include <tools/list.hxx>
|
2001-11-27 10:00:49 +00:00
|
|
|
#include <tools/urlobj.hxx>
|
|
|
|
|
#include <unotools/ucbstreamhelper.hxx>
|
2001-06-11 09:09:07 +00:00
|
|
|
#include <svtools/miscopt.hxx>
|
2001-11-28 10:47:00 +00:00
|
|
|
#include <framework/imagesconfiguration.hxx>
|
2001-06-11 09:09:07 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
#pragma hdrstop
|
|
|
|
|
|
|
|
|
|
#include "imgmgr.hxx"
|
|
|
|
|
#include "sfx.hrc"
|
|
|
|
|
#include "app.hxx"
|
|
|
|
|
#include "sfxresid.hxx"
|
|
|
|
|
#include "tbxmgr.hxx"
|
|
|
|
|
#include "bindings.hxx"
|
|
|
|
|
#include "statcach.hxx"
|
|
|
|
|
#include "module.hxx"
|
|
|
|
|
#include "sfxtypes.hxx"
|
|
|
|
|
#include "viewfrm.hxx"
|
2001-06-11 09:09:07 +00:00
|
|
|
#include "objsh.hxx"
|
|
|
|
|
#include "cfgmgr.hxx"
|
2001-11-27 10:00:49 +00:00
|
|
|
#include "macrconf.hxx"
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
|
static const USHORT nVersion = 5;
|
2001-06-11 09:09:07 +00:00
|
|
|
DECLARE_LIST( LinkList, Link * );
|
|
|
|
|
|
|
|
|
|
class SfxToolBoxArr_Impl;
|
|
|
|
|
struct SfxImageManagerData_Impl
|
|
|
|
|
{
|
|
|
|
|
sal_Int16 nOutStyle;
|
|
|
|
|
sal_Int16 nSet;
|
|
|
|
|
SfxToolBoxArr_Impl* pToolBoxList;
|
|
|
|
|
SfxObjectShell* pDoc;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class SfxBitmapList_Impl;
|
|
|
|
|
class SfxImageManager_Impl : public SfxConfigItem
|
|
|
|
|
{
|
|
|
|
|
public:
|
2002-04-11 10:49:39 +00:00
|
|
|
LinkList m_aList;
|
|
|
|
|
SvtMiscOptions m_aOpt;
|
|
|
|
|
SfxBitmapList_Impl* m_pUserDefList;
|
|
|
|
|
ImageList* m_pUserImageList;
|
|
|
|
|
ImageList* m_pHCUserImageList;
|
|
|
|
|
int m_nUserRef;
|
|
|
|
|
|
|
|
|
|
void MakeDefaultImageList( BOOL bHiContrast = FALSE );
|
2001-06-11 09:09:07 +00:00
|
|
|
void MakeUserList();
|
|
|
|
|
void RebuildUserList();
|
2002-04-11 10:49:39 +00:00
|
|
|
Image GetImage( USHORT nId, SfxModule*, BOOL bBig, BOOL bHiContrast ) const;
|
|
|
|
|
Image SeekImage(USHORT nId, SfxModule* pModule, BOOL bHiContrast ) const;
|
2001-06-11 09:09:07 +00:00
|
|
|
|
|
|
|
|
virtual BOOL ReInitialize();
|
|
|
|
|
int Load( SvStream& );
|
|
|
|
|
BOOL Store( SvStream& );
|
|
|
|
|
virtual void UseDefault();
|
|
|
|
|
virtual String GetStreamName() const;
|
|
|
|
|
virtual int Load(SotStorage&);
|
|
|
|
|
virtual BOOL Store(SotStorage&);
|
|
|
|
|
void AddLink( const Link& );
|
|
|
|
|
void RemoveLink( const Link& );
|
2001-11-27 10:00:49 +00:00
|
|
|
void LoadBitmap( Bitmap&, SotStorage&, const String& );
|
2001-06-11 09:09:07 +00:00
|
|
|
|
|
|
|
|
SfxImageManager_Impl( SfxConfigManager* pCfg );
|
|
|
|
|
~SfxImageManager_Impl();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// elements common to all ImageManager instances
|
|
|
|
|
static ImageList* pImageListSmall=0;
|
|
|
|
|
static ImageList* pImageListBig=0;
|
2002-04-11 10:49:39 +00:00
|
|
|
static ImageList* pImageListHiSmall=0;
|
|
|
|
|
static ImageList* pImageListHiBig=0;
|
|
|
|
|
//static ImageList* pOffImageList;
|
|
|
|
|
//static ImageList* pOffHiImageList;
|
2001-06-11 09:09:07 +00:00
|
|
|
static ImageList* pImageList;
|
2002-04-11 10:49:39 +00:00
|
|
|
static ImageList* pHiImageList;
|
2001-06-11 09:09:07 +00:00
|
|
|
static SfxImageManager_Impl* pGlobalConfig=NULL;
|
|
|
|
|
static nRef=0;
|
|
|
|
|
static nGlobalRef=0;
|
|
|
|
|
|
|
|
|
|
// we need a static list of all pImp instances, so all operations that should change all instances can be performed
|
|
|
|
|
// which operations ?!
|
|
|
|
|
|
2002-04-11 10:49:39 +00:00
|
|
|
ImageList* GetImageList( BOOL bBig, BOOL bHiContrast = FALSE )
|
2001-06-11 09:09:07 +00:00
|
|
|
{
|
2002-04-11 10:49:39 +00:00
|
|
|
// Has to be changed if we know how the IDs are named!!!
|
|
|
|
|
ImageList*& rpList = bBig ? ( bHiContrast ? pImageListHiBig : pImageListBig ) :
|
|
|
|
|
( bHiContrast ? pImageListHiSmall : pImageListSmall );
|
2001-06-11 09:09:07 +00:00
|
|
|
if ( !rpList )
|
|
|
|
|
{
|
|
|
|
|
ResMgr *pResMgr = Resource::GetResManager();
|
2002-04-11 10:49:39 +00:00
|
|
|
ResId aResId( bBig ? ( bHiContrast ? RID_DEFAULTIMAGELIST_LCH : RID_DEFAULTIMAGELIST_LC ) :
|
|
|
|
|
( bHiContrast ? RID_DEFAULTIMAGELIST_SCH : RID_DEFAULTIMAGELIST_SC ));
|
|
|
|
|
|
2001-06-11 09:09:07 +00:00
|
|
|
aResId.SetRT( RSC_IMAGELIST );
|
|
|
|
|
|
|
|
|
|
DBG_ASSERT( pResMgr->IsAvailable(aResId), "No default ImageList!" );
|
|
|
|
|
|
|
|
|
|
if ( pResMgr->IsAvailable(aResId) )
|
|
|
|
|
rpList = new ImageList( aResId );
|
|
|
|
|
else
|
|
|
|
|
rpList = new ImageList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return rpList;
|
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
|
//=========================================================================
|
|
|
|
|
|
|
|
|
|
// Enth"alt eine Kombination aus Bitmap und zugeordneter SlotId
|
|
|
|
|
struct ToolboxBitmap_Impl
|
|
|
|
|
{
|
|
|
|
|
USHORT nId;
|
|
|
|
|
Bitmap* pBitmap;
|
|
|
|
|
|
|
|
|
|
ToolboxBitmap_Impl( USHORT n, const Bitmap& rBmp ) : nId( n )
|
|
|
|
|
{
|
|
|
|
|
pBitmap = new Bitmap( rBmp );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
~ToolboxBitmap_Impl() { delete pBitmap; }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Enth"alt einen Ptr auf eine registrierte Toolbox und Flags f"ur die
|
|
|
|
|
// Ereignisse, bei denen die Toolbox upgedatet werden soll
|
|
|
|
|
struct ToolBoxInf_Impl
|
|
|
|
|
{
|
|
|
|
|
SfxToolBoxManager* pMgr;
|
|
|
|
|
SfxModule* pModule;
|
|
|
|
|
ToolBox *pToolBox;
|
|
|
|
|
USHORT nFlags;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
DECL_PTRARRAY( SfxBitmapArr_Impl, ToolboxBitmap_Impl*, 4, 4 );
|
|
|
|
|
DECL_PTRARRAY( SfxToolBoxArr_Impl, ToolBoxInf_Impl*, 4, 4 );
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
// Liste der geladenen Userdef-Bitmaps
|
|
|
|
|
class SfxBitmapList_Impl
|
|
|
|
|
{
|
|
|
|
|
SfxBitmapArr_Impl* pList;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
friend SvStream& operator >> (SvStream& rStream, SfxBitmapList_Impl& rList);
|
|
|
|
|
friend SvStream& operator << (SvStream& rStream, const SfxBitmapList_Impl& rList);
|
|
|
|
|
|
|
|
|
|
SfxBitmapList_Impl()
|
|
|
|
|
{ pList = new SfxBitmapArr_Impl; }
|
|
|
|
|
|
|
|
|
|
~SfxBitmapList_Impl()
|
|
|
|
|
{
|
|
|
|
|
for (USHORT n=0; n<pList->Count(); n++)
|
|
|
|
|
delete (*pList)[n];
|
|
|
|
|
delete pList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
USHORT GetBitmapCount() const
|
|
|
|
|
{ return pList->Count(); }
|
|
|
|
|
|
|
|
|
|
USHORT GetBitmapId(USHORT n) const
|
|
|
|
|
{ return (*pList)[n]->nId; }
|
|
|
|
|
|
|
|
|
|
USHORT GetBitmapPos(USHORT nId) const;
|
|
|
|
|
Bitmap* GetBitmap(USHORT nId) const;
|
|
|
|
|
void AddBitmap (USHORT nId, const Bitmap& rpBmp);
|
|
|
|
|
void ReplaceBitmap (USHORT nId, const Bitmap& rpBmp);
|
|
|
|
|
void RemoveBitmap (USHORT nId);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//=========================================================================
|
|
|
|
|
|
|
|
|
|
/* [Beschreibung]
|
|
|
|
|
|
|
|
|
|
Liefert die Position einer Bitmap in der internen Bitmapliste
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
USHORT SfxBitmapList_Impl::GetBitmapPos( USHORT nId ) const
|
|
|
|
|
{
|
|
|
|
|
USHORT nPos;
|
|
|
|
|
for ( nPos=0; nPos<pList->Count(); nPos++ )
|
|
|
|
|
if ( (*pList)[nPos]->nId == nId ) break;
|
|
|
|
|
|
|
|
|
|
if ( nPos < pList->Count() )
|
|
|
|
|
return nPos;
|
|
|
|
|
else
|
|
|
|
|
return USHRT_MAX;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
/* [Beschreibung]
|
|
|
|
|
|
|
|
|
|
Liefert die Bitmap an der "uebergebenen Position der internen Bitmapliste
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
Bitmap* SfxBitmapList_Impl::GetBitmap(USHORT nId) const
|
|
|
|
|
{
|
|
|
|
|
USHORT nPos;
|
|
|
|
|
for ( nPos=0; nPos<pList->Count(); nPos++ )
|
|
|
|
|
if ( (*pList)[nPos]->nId == nId ) break;
|
|
|
|
|
|
|
|
|
|
if ( nPos < pList->Count() )
|
|
|
|
|
return (*pList)[nPos]->pBitmap;
|
|
|
|
|
else
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
/* [Beschreibung]
|
|
|
|
|
|
|
|
|
|
F"ugt der internen Bitmapliste eine Bitmap hinzu, die f"ur die "ubergebene
|
|
|
|
|
SlotId registriert wird. Die Bitmap geht in den Besitz des ImageManagers
|
|
|
|
|
"uber.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
void SfxBitmapList_Impl::AddBitmap( USHORT nId, const Bitmap& rBmp )
|
|
|
|
|
{
|
|
|
|
|
for ( USHORT nPos=0; nPos<pList->Count(); nPos++ )
|
|
|
|
|
if ( (*pList)[nPos]->nId == nId ) break;
|
|
|
|
|
|
|
|
|
|
DBG_ASSERT( nPos>=pList->Count(), "Bitmap mit dieser Id schon vorhanden!" );
|
|
|
|
|
|
|
|
|
|
ToolboxBitmap_Impl *pTbBmp = new ToolboxBitmap_Impl( nId, rBmp );
|
|
|
|
|
pList->Append( pTbBmp );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
/* [Beschreibung]
|
|
|
|
|
|
|
|
|
|
Ersetzt die Bitmap in der internen Bitmapliste, die f"ur die "ubergebene
|
|
|
|
|
SlotId registriert ist, durch die "ubergebene Bitmap.
|
|
|
|
|
Die Bitmap geht in den Besitz des ImageManagers "uber.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
void SfxBitmapList_Impl::ReplaceBitmap( USHORT nId, const Bitmap& rBmp )
|
|
|
|
|
{
|
|
|
|
|
RemoveBitmap( nId );
|
|
|
|
|
AddBitmap( nId, rBmp );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
/* [Beschreibung]
|
|
|
|
|
|
|
|
|
|
Entfernt die Bitmap in der internen Bitmapliste, die f"ur die "ubergebene
|
|
|
|
|
SlotId registriert ist.
|
|
|
|
|
Da die Bitmap dem ImageManagers geh"ort, wird sie zerst"ort.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
void SfxBitmapList_Impl::RemoveBitmap( USHORT nId )
|
|
|
|
|
{
|
|
|
|
|
USHORT nPos;
|
|
|
|
|
for (nPos=0; nPos<pList->Count(); nPos++)
|
|
|
|
|
if ((*pList)[nPos]->nId == nId) break;
|
|
|
|
|
|
|
|
|
|
DBG_ASSERT(nPos<pList->Count(), "Bitmap mit dieser Id unbekannt!");
|
|
|
|
|
|
|
|
|
|
if (nPos<pList->Count())
|
|
|
|
|
{
|
|
|
|
|
delete (*pList)[nPos];
|
|
|
|
|
pList->Remove(nPos);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
/* [Beschreibung]
|
|
|
|
|
|
|
|
|
|
Liest die interne Bitmapliste aus einem Stream.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
SvStream& operator >> (SvStream& rStream, SfxBitmapList_Impl& rList)
|
|
|
|
|
{
|
|
|
|
|
USHORT nCount, nId;
|
|
|
|
|
rStream >> nCount;
|
|
|
|
|
for (USHORT n=0; n<nCount; n++)
|
|
|
|
|
{
|
|
|
|
|
Bitmap aBmp;
|
|
|
|
|
rStream >> nId >> aBmp;
|
|
|
|
|
rList.AddBitmap(nId, aBmp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return rStream;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
/* [Beschreibung]
|
|
|
|
|
|
|
|
|
|
Speichert die interne Bitmapliste in einem Stream,
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
SvStream& operator << (SvStream& rStream, const SfxBitmapList_Impl& rList)
|
|
|
|
|
{
|
|
|
|
|
rStream << rList.GetBitmapCount();
|
|
|
|
|
for (USHORT n=0; n<rList.GetBitmapCount(); n++)
|
|
|
|
|
rStream << (*rList.pList)[n]->nId << *((*rList.pList)[n]->pBitmap);
|
|
|
|
|
|
|
|
|
|
return rStream;
|
|
|
|
|
}
|
|
|
|
|
|
2001-06-11 09:09:07 +00:00
|
|
|
SfxImageManager_Impl::SfxImageManager_Impl( SfxConfigManager* pCfgMgr )
|
|
|
|
|
: SfxConfigItem( SFX_ITEMTYPE_IMAGELIST, pCfgMgr )
|
2002-04-11 10:49:39 +00:00
|
|
|
, m_pUserDefList( 0 )
|
|
|
|
|
, m_pUserImageList( 0 )
|
|
|
|
|
, m_pHCUserImageList( 0 )
|
2001-06-11 09:09:07 +00:00
|
|
|
{
|
|
|
|
|
// SetInternal( TRUE );
|
|
|
|
|
Initialize();
|
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2001-06-11 09:09:07 +00:00
|
|
|
SfxImageManager_Impl::~SfxImageManager_Impl()
|
|
|
|
|
{
|
2002-04-11 10:49:39 +00:00
|
|
|
delete m_pUserDefList;
|
|
|
|
|
delete m_pUserImageList;
|
|
|
|
|
delete m_pHCUserImageList;
|
|
|
|
|
|
2001-06-11 09:09:07 +00:00
|
|
|
if ( this == pGlobalConfig )
|
|
|
|
|
pGlobalConfig = NULL;
|
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2001-06-11 09:09:07 +00:00
|
|
|
void SfxImageManager_Impl::AddLink( const Link& rLink )
|
|
|
|
|
{
|
2002-04-11 10:49:39 +00:00
|
|
|
m_aList.Insert( new Link( rLink ) );
|
2001-06-11 09:09:07 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2001-06-11 09:09:07 +00:00
|
|
|
void SfxImageManager_Impl::RemoveLink( const Link& rLink )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2002-04-11 10:49:39 +00:00
|
|
|
for ( USHORT n=0; n<m_aList.Count(); n++ )
|
2001-06-11 09:09:07 +00:00
|
|
|
{
|
2002-04-11 10:49:39 +00:00
|
|
|
if ( (*m_aList.GetObject(n) ) == rLink )
|
2001-06-11 09:09:07 +00:00
|
|
|
{
|
2002-04-11 10:49:39 +00:00
|
|
|
delete m_aList.Remove(n);
|
2001-06-11 09:09:07 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
2001-11-27 10:00:49 +00:00
|
|
|
void SfxImageManager_Impl::LoadBitmap( Bitmap& rBmp, SotStorage& rStorage, const String& rURL )
|
|
|
|
|
{
|
|
|
|
|
// locate and open bitmap for ImageList
|
|
|
|
|
SotStorageStreamRef xBitmapStream;
|
|
|
|
|
SvStream* pStream = NULL;
|
|
|
|
|
|
|
|
|
|
// bitmap may be internal (relative URL) or external (absolute URL)
|
|
|
|
|
INetURLObject aObj( rURL );
|
|
|
|
|
if ( aObj.GetProtocol() != INET_PROT_NOT_VALID )
|
|
|
|
|
{
|
|
|
|
|
// get external stream for bitmap
|
|
|
|
|
pStream = ::utl::UcbStreamHelper::CreateStream( aObj.GetMainURL( INetURLObject::NO_DECODE ), STREAM_STD_READ );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// find internal stream by parsing URL, starting in the root of rStorage
|
|
|
|
|
SotStorageRef xBitmapStorage = &rStorage;
|
|
|
|
|
|
|
|
|
|
// every string followed by a slash is a directory
|
|
|
|
|
USHORT nTokenCount = rURL.GetTokenCount( '/' );
|
|
|
|
|
|
|
|
|
|
// open directories
|
|
|
|
|
for ( USHORT nToken=0; nToken<nTokenCount-1; nToken++ )
|
|
|
|
|
xBitmapStorage = xBitmapStorage->OpenSotStorage( rURL.GetToken( nToken, '/' ), STREAM_STD_READ );
|
|
|
|
|
|
|
|
|
|
// now get the stream
|
|
|
|
|
xBitmapStream = xBitmapStorage->OpenSotStream( rURL.GetToken( nToken, '/' ), STREAM_STD_READ );
|
|
|
|
|
pStream = xBitmapStream;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*pStream >> rBmp;
|
|
|
|
|
if ( !xBitmapStream.Is() )
|
|
|
|
|
DELETEZ( pStream );
|
|
|
|
|
}
|
|
|
|
|
|
2001-06-11 09:09:07 +00:00
|
|
|
int SfxImageManager_Impl::Load( SotStorage& rStorage )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-06-11 09:09:07 +00:00
|
|
|
SotStorageStreamRef xStream =
|
|
|
|
|
rStorage.OpenSotStream( GetStreamName(), STREAM_STD_READ );
|
|
|
|
|
if ( xStream->GetError() )
|
|
|
|
|
return ERR_READ;
|
2001-11-27 10:00:49 +00:00
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
SfxMacroConfig* pCfg = SfxMacroConfig::GetOrCreate();
|
|
|
|
|
::framework::ImageListsDescriptor aDescriptor;
|
|
|
|
|
if ( !::framework::ImagesConfiguration::LoadImages( *xStream, aDescriptor ) )
|
|
|
|
|
return ERR_READ;
|
|
|
|
|
|
|
|
|
|
if ( !aDescriptor.pImageList || !aDescriptor.pImageList->Count() )
|
|
|
|
|
return ERR_READ;
|
|
|
|
|
|
|
|
|
|
::framework::ImageListItemDescriptor* pList = aDescriptor.pImageList->GetObject(0);
|
|
|
|
|
USHORT nCount = pList->pImageItemList->Count();
|
|
|
|
|
if ( !nCount )
|
|
|
|
|
return ERR_READ;
|
|
|
|
|
|
|
|
|
|
Bitmap aBmp;
|
2002-04-11 10:49:39 +00:00
|
|
|
Bitmap aHCBmp;
|
2001-11-27 10:00:49 +00:00
|
|
|
LoadBitmap( aBmp, rStorage, pList->aURL );
|
2002-05-02 06:41:58 +00:00
|
|
|
|
|
|
|
|
if ( pList->aHighContrastURL.Len() == 0 )
|
|
|
|
|
{
|
|
|
|
|
// Use normal images for high contrast mode as we need the same number of images
|
|
|
|
|
// for the high contrast image list!! The normal case for 6.1 should be that both
|
|
|
|
|
// lists are filled, so this document was created by 6.0.
|
|
|
|
|
// #98979#
|
|
|
|
|
LoadBitmap( aHCBmp, rStorage, pList->aURL );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
LoadBitmap( aHCBmp, rStorage, pList->aHighContrastURL );
|
2001-11-27 10:00:49 +00:00
|
|
|
|
|
|
|
|
// get the Ids of the ImageList
|
|
|
|
|
USHORT* pIds = new USHORT[nCount];
|
|
|
|
|
for ( USHORT i=0; i<nCount; i++ )
|
|
|
|
|
{
|
|
|
|
|
const ::framework::ImageItemDescriptor* pItem = pList->pImageItemList->GetObject(i);
|
|
|
|
|
if ( pItem->aCommandURL.CompareToAscii("slot:",5) == COMPARE_EQUAL )
|
|
|
|
|
{
|
|
|
|
|
pIds[i] = (USHORT) pItem->aCommandURL.Copy( 5 ).ToInt32();
|
|
|
|
|
}
|
2002-06-27 07:19:39 +00:00
|
|
|
else if ( pItem->aCommandURL.Len() )
|
|
|
|
|
//else if ( pItem->aCommandURL.CompareToAscii("macro:",6) == COMPARE_EQUAL )
|
2001-11-27 10:00:49 +00:00
|
|
|
{
|
|
|
|
|
SfxMacroInfo aInfo( pItem->aCommandURL );
|
|
|
|
|
pCfg->GetSlotId( &aInfo );
|
|
|
|
|
pIds[i] = aInfo.GetSlotId();
|
|
|
|
|
}
|
|
|
|
|
}
|
2001-06-11 09:09:07 +00:00
|
|
|
|
2002-04-11 10:49:39 +00:00
|
|
|
delete m_pUserImageList;
|
|
|
|
|
delete m_pHCUserImageList;
|
|
|
|
|
|
2001-11-27 10:00:49 +00:00
|
|
|
if ( pList->nMaskMode = ::framework::ImageMaskMode_Color )
|
2002-04-11 10:49:39 +00:00
|
|
|
{
|
|
|
|
|
m_pUserImageList = new ImageList( aBmp, pList->aMaskColor, nCount, pIds );
|
|
|
|
|
m_pHCUserImageList = new ImageList( aHCBmp, pList->aMaskColor, nCount, pIds );
|
|
|
|
|
}
|
2001-11-27 10:00:49 +00:00
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Bitmap aMask;
|
|
|
|
|
LoadBitmap( aMask, rStorage, pList->aMaskURL );
|
2002-04-11 10:49:39 +00:00
|
|
|
m_pUserImageList = new ImageList( aBmp, aMask, nCount, pIds );
|
2002-05-02 06:41:58 +00:00
|
|
|
|
|
|
|
|
if ( pList->aHighContrastMaskURL.Len() == 0 )
|
|
|
|
|
{
|
|
|
|
|
// Use normal mask images for high contrast mode as we need the same number of images
|
|
|
|
|
// for the high contrast image list!! The normal case for 6.1 should be that both
|
|
|
|
|
// lists are filled, so this document was created by 6.0.
|
|
|
|
|
// #98979#
|
|
|
|
|
LoadBitmap( aMask, rStorage, pList->aMaskURL );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
LoadBitmap( aMask, rStorage, pList->aHighContrastMaskURL );
|
|
|
|
|
|
2002-04-11 10:49:39 +00:00
|
|
|
m_pHCUserImageList = new ImageList( aHCBmp, aMask, nCount, pIds );
|
2001-11-27 10:00:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DELETEZ( pIds );
|
2002-04-11 10:49:39 +00:00
|
|
|
m_pUserDefList = new SfxBitmapList_Impl;
|
2001-11-27 10:00:49 +00:00
|
|
|
|
|
|
|
|
nCount = aDescriptor.pExternalImageList ? aDescriptor.pExternalImageList->Count() : 0;
|
|
|
|
|
for ( USHORT n=0; n<nCount; n++ )
|
|
|
|
|
{
|
|
|
|
|
::framework::ExternalImageItemDescriptor* pItem = aDescriptor.pExternalImageList->GetObject(n);
|
|
|
|
|
USHORT nId = 0;
|
|
|
|
|
if ( pItem->aCommandURL.CompareToAscii("slot:",5) == COMPARE_EQUAL )
|
|
|
|
|
{
|
|
|
|
|
nId = (USHORT) pItem->aCommandURL.Copy( 5 ).ToInt32();
|
|
|
|
|
}
|
2002-06-27 07:19:39 +00:00
|
|
|
else if ( pItem->aCommandURL.Len() )
|
|
|
|
|
//else if ( pItem->aCommandURL.CompareToAscii("macro:",6) == COMPARE_EQUAL )
|
2001-11-27 10:00:49 +00:00
|
|
|
{
|
|
|
|
|
SfxMacroInfo aInfo( pItem->aCommandURL );
|
|
|
|
|
pCfg->GetSlotId( &aInfo );
|
|
|
|
|
nId = aInfo.GetSlotId();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Bitmap aBmp;
|
|
|
|
|
LoadBitmap( aBmp, rStorage, pItem->aURL );
|
2002-04-11 10:49:39 +00:00
|
|
|
m_pUserDefList->AddBitmap( nId, aBmp );
|
2001-11-27 10:00:49 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MakeDefaultImageList();
|
|
|
|
|
SetDefault( FALSE );
|
|
|
|
|
return ERR_OK;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
2001-06-11 09:09:07 +00:00
|
|
|
BOOL SfxImageManager_Impl::Store( SotStorage& rStorage )
|
|
|
|
|
{
|
|
|
|
|
SotStorageStreamRef xStream = rStorage.OpenSotStream( SfxImageManager_Impl::GetStreamName(), STREAM_STD_READWRITE|STREAM_TRUNC );
|
|
|
|
|
if ( xStream->GetError() )
|
|
|
|
|
return FALSE;
|
|
|
|
|
else
|
2001-11-27 10:00:49 +00:00
|
|
|
{
|
|
|
|
|
// create a descriptor
|
|
|
|
|
SfxMacroConfig* pCfg = SfxMacroConfig::GetOrCreate();
|
|
|
|
|
::framework::ImageListsDescriptor aDescriptor;
|
|
|
|
|
aDescriptor.pImageList = new ::framework::ImageListDescriptor;
|
|
|
|
|
|
|
|
|
|
// insert userimagelist as one and only list (more is not supported currently, default lists remain in resource)
|
|
|
|
|
::framework::ImageListItemDescriptor* pList = new ::framework::ImageListItemDescriptor;
|
|
|
|
|
aDescriptor.pImageList->Insert( pList, 0 );
|
|
|
|
|
|
|
|
|
|
// bitmaps are stored in an internal bitmap directory
|
|
|
|
|
SotStorageRef xBitmapStorage = rStorage.OpenSotStorage( String::CreateFromAscii("Bitmaps"), STREAM_STD_READWRITE );
|
|
|
|
|
|
2002-04-11 10:49:39 +00:00
|
|
|
if ( m_pUserImageList->HasMaskColor() )
|
2001-11-27 10:00:49 +00:00
|
|
|
{
|
|
|
|
|
// mask color
|
|
|
|
|
pList->nMaskMode = ::framework::ImageMaskMode_Color;
|
2002-04-11 10:49:39 +00:00
|
|
|
pList->aMaskColor = m_pUserImageList->GetMaskColor();
|
2001-11-27 10:00:49 +00:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// masking is done by a mask bitmap, store bitmap and set URL
|
|
|
|
|
pList->nMaskMode = ::framework::ImageMaskMode_Bitmap;
|
|
|
|
|
|
|
|
|
|
pList->aMaskURL = String::CreateFromAscii("Bitmaps/");
|
|
|
|
|
String aStreamName = String::CreateFromAscii("userimagesmask.bmp");
|
|
|
|
|
pList->aMaskURL += aStreamName;
|
|
|
|
|
|
|
|
|
|
// store bitmap
|
|
|
|
|
SotStorageStreamRef xBitmapStream = xBitmapStorage->OpenSotStream( aStreamName, STREAM_STD_READWRITE | STREAM_TRUNC );
|
2002-04-11 10:49:39 +00:00
|
|
|
*xBitmapStream << m_pUserImageList->GetMaskBitmap();
|
|
|
|
|
|
|
|
|
|
pList->aHighContrastMaskURL = String::CreateFromAscii( "Bitmaps/" );
|
|
|
|
|
aStreamName = String::CreateFromAscii( "hcuserimagesmask.bmp" );
|
|
|
|
|
pList->aHighContrastMaskURL += aStreamName;
|
|
|
|
|
|
|
|
|
|
// store bitmap
|
|
|
|
|
xBitmapStream = xBitmapStorage->OpenSotStream( aStreamName, STREAM_STD_READWRITE | STREAM_TRUNC );
|
|
|
|
|
*xBitmapStream << m_pHCUserImageList->GetMaskBitmap();
|
2001-11-27 10:00:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// a modified list always contains a userlist
|
|
|
|
|
pList->pImageItemList = new ::framework::ImageItemListDescriptor;
|
2002-04-11 10:49:39 +00:00
|
|
|
for ( USHORT i=0; i<m_pUserImageList->GetImageCount(); i++ )
|
2001-11-27 10:00:49 +00:00
|
|
|
{
|
|
|
|
|
::framework::ImageItemDescriptor* pItem = new ::framework::ImageItemDescriptor;
|
|
|
|
|
|
|
|
|
|
pItem->nIndex = i;
|
2002-04-11 10:49:39 +00:00
|
|
|
USHORT nId = m_pUserImageList->GetImageId(i);
|
2001-11-27 10:00:49 +00:00
|
|
|
if ( SfxMacroConfig::IsMacroSlot( nId ) )
|
|
|
|
|
{
|
|
|
|
|
const SfxMacroInfo* pInfo = pCfg->GetMacroInfo( nId );
|
|
|
|
|
pItem->aCommandURL = pInfo->GetURL();
|
|
|
|
|
}
|
|
|
|
|
else if ( nId )
|
|
|
|
|
{
|
|
|
|
|
pItem->aCommandURL = String::CreateFromAscii("slot:");
|
|
|
|
|
pItem->aCommandURL += String::CreateFromInt32( nId );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pList->pImageItemList->Insert( pItem, pList->pImageItemList->Count() );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// store URL of bitmap relative to configuration storage; name is "BitmapXXX.bmp", where XXX is an index
|
|
|
|
|
pList->aURL = String::CreateFromAscii("Bitmaps/");
|
|
|
|
|
String aStreamName = String::CreateFromAscii("userimages.bmp");
|
|
|
|
|
pList->aURL += aStreamName;
|
|
|
|
|
|
|
|
|
|
// store bitmap
|
|
|
|
|
SotStorageStreamRef xBitmapStream = xBitmapStorage->OpenSotStream( aStreamName, STREAM_STD_READWRITE | STREAM_TRUNC );
|
2002-04-11 10:49:39 +00:00
|
|
|
*xBitmapStream << m_pUserImageList->GetBitmap();
|
|
|
|
|
|
|
|
|
|
// store high contrast URL of bitmap relative to configuration storage; name is "BitmapXXX.bmp", where XXX is an index
|
|
|
|
|
pList->aHighContrastURL = String::CreateFromAscii("Bitmaps/");
|
|
|
|
|
aStreamName = String::CreateFromAscii("hcuserimages.bmp");
|
|
|
|
|
pList->aHighContrastURL += aStreamName;
|
|
|
|
|
|
|
|
|
|
// store high contrast bitmap
|
|
|
|
|
xBitmapStream = xBitmapStorage->OpenSotStream( aStreamName, STREAM_STD_READWRITE | STREAM_TRUNC );
|
|
|
|
|
*xBitmapStream << m_pHCUserImageList->GetBitmap();
|
2001-11-27 10:00:49 +00:00
|
|
|
|
|
|
|
|
// collect all external bitmaps
|
2002-04-11 10:49:39 +00:00
|
|
|
USHORT nCount = m_pUserDefList->GetBitmapCount();
|
2001-11-27 10:00:49 +00:00
|
|
|
if ( nCount )
|
|
|
|
|
{
|
|
|
|
|
aDescriptor.pExternalImageList = new ::framework::ExternalImageItemListDescriptor;
|
|
|
|
|
for ( USHORT i=0; i<nCount; i++ )
|
|
|
|
|
{
|
|
|
|
|
::framework::ExternalImageItemDescriptor* pItem = new ::framework::ExternalImageItemDescriptor;
|
2002-04-11 10:49:39 +00:00
|
|
|
USHORT nId = m_pUserDefList->GetBitmapId(i);
|
2001-11-27 10:00:49 +00:00
|
|
|
if ( SfxMacroConfig::IsMacroSlot( nId ) )
|
|
|
|
|
{
|
|
|
|
|
const SfxMacroInfo* pInfo = pCfg->GetMacroInfo( nId );
|
|
|
|
|
pItem->aCommandURL = pInfo->GetURL();
|
|
|
|
|
}
|
|
|
|
|
else if ( nId )
|
|
|
|
|
{
|
|
|
|
|
pItem->aCommandURL = String::CreateFromAscii("slot:");
|
|
|
|
|
pItem->aCommandURL += String::CreateFromInt32( nId );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// store URL of bitmap relative to configuration storage; name is "BitmapXXX.bmp", where XXX is an index
|
|
|
|
|
pItem->aURL = String::CreateFromAscii("Bitmaps/");
|
|
|
|
|
String aStreamName = String::CreateFromAscii("image");
|
|
|
|
|
aStreamName += String::CreateFromInt32(i);
|
|
|
|
|
aStreamName += String::CreateFromAscii(".bmp");
|
|
|
|
|
pItem->aURL += aStreamName;
|
|
|
|
|
|
|
|
|
|
aDescriptor.pExternalImageList->Insert( pItem, aDescriptor.pExternalImageList->Count() );
|
|
|
|
|
|
|
|
|
|
// store bitmap
|
|
|
|
|
SotStorageStreamRef xBitmapStream = xBitmapStorage->OpenSotStream( aStreamName, STREAM_STD_READWRITE | STREAM_TRUNC );
|
2002-04-11 10:49:39 +00:00
|
|
|
*xBitmapStream << *m_pUserDefList->GetBitmap( nId );
|
2001-11-27 10:00:49 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// store configuration
|
|
|
|
|
xBitmapStorage->Commit();
|
|
|
|
|
return ::framework::ImagesConfiguration::StoreImages( *xStream, aDescriptor );
|
|
|
|
|
}
|
2001-06-11 09:09:07 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
|
|
2001-06-11 09:09:07 +00:00
|
|
|
int SfxImageManager_Impl::Load(SvStream& rStream)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
|
USHORT nFileVersion, nSymbolSet;
|
|
|
|
|
ULONG nColorCount = Application::GetDefaultDevice()->GetColorCount();
|
|
|
|
|
|
|
|
|
|
rStream >> nFileVersion;
|
|
|
|
|
if ( nFileVersion < nVersion)
|
|
|
|
|
return SfxConfigItem::WARNING_VERSION;
|
|
|
|
|
|
2001-06-11 09:09:07 +00:00
|
|
|
rStream >> nSymbolSet // ignore !
|
|
|
|
|
>> nColorCount; // evaluate for possible rebuild of userlist
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2001-06-11 09:09:07 +00:00
|
|
|
MakeUserList();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
|
// Userdef-Listen einlesen
|
2002-04-11 10:49:39 +00:00
|
|
|
rStream >> *m_pUserImageList;
|
|
|
|
|
rStream >> *m_pUserDefList;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
|
if ( nColorCount != Application::GetDefaultDevice()->GetColorCount() )
|
2001-06-11 09:09:07 +00:00
|
|
|
RebuildUserList();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
|
// SvFileStream aBitmapStream( String("d:\\INPUT.BMP"), STREAM_STD_WRITE);
|
|
|
|
|
// aBitmapStream << pUserImageList->GetBitmap();
|
|
|
|
|
|
2001-11-27 10:00:49 +00:00
|
|
|
SetDefault( FALSE );
|
2000-09-18 16:07:07 +00:00
|
|
|
return SfxConfigItem::ERR_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2001-06-11 09:09:07 +00:00
|
|
|
BOOL SfxImageManager_Impl::ReInitialize()
|
|
|
|
|
{
|
|
|
|
|
BOOL bRet = SfxConfigItem::ReInitialize();
|
|
|
|
|
if ( bRet )
|
2002-04-11 10:49:39 +00:00
|
|
|
for ( USHORT n=0; n<m_aList.Count(); n++ )
|
|
|
|
|
m_aList.GetObject(n)->Call( this );
|
2001-06-11 09:09:07 +00:00
|
|
|
return bRet;
|
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
2001-11-27 10:00:49 +00:00
|
|
|
|
2001-06-11 09:09:07 +00:00
|
|
|
BOOL SfxImageManager_Impl::Store(SvStream& rStream)
|
|
|
|
|
{
|
|
|
|
|
// SvFileStream aBitmapStream(String("d:\\OUTPUT.BMP"), STREAM_STD_WRITE);
|
|
|
|
|
// aBitmapStream << pUserImageList->GetBitmap();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2001-06-11 09:09:07 +00:00
|
|
|
rStream << nVersion
|
2002-04-11 10:49:39 +00:00
|
|
|
<< m_aOpt.GetSymbolSet()
|
2001-06-11 09:09:07 +00:00
|
|
|
<< Application::GetDefaultDevice()->GetColorCount();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2002-04-11 10:49:39 +00:00
|
|
|
rStream << *m_pUserImageList;
|
|
|
|
|
rStream << *m_pUserDefList;
|
2001-06-11 09:09:07 +00:00
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
void SfxImageManager_Impl::UseDefault()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-06-11 09:09:07 +00:00
|
|
|
MakeDefaultImageList();
|
|
|
|
|
MakeUserList();
|
|
|
|
|
SetDefault( TRUE );
|
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2001-06-11 09:09:07 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
String SfxImageManager_Impl::GetStreamName() const
|
|
|
|
|
{
|
|
|
|
|
return SfxConfigItem::GetStreamName( GetType() );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
void SfxImageManager_Impl::MakeUserList()
|
|
|
|
|
{
|
2002-04-11 10:49:39 +00:00
|
|
|
if ( m_pUserImageList )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2002-04-11 10:49:39 +00:00
|
|
|
DELETEZ( m_pUserImageList );
|
|
|
|
|
DELETEZ( m_pHCUserImageList );
|
|
|
|
|
DELETEZ( m_pUserDefList );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
2002-04-11 10:49:39 +00:00
|
|
|
m_pUserDefList = new SfxBitmapList_Impl;
|
|
|
|
|
m_pUserImageList = new ImageList;
|
|
|
|
|
m_pHCUserImageList = new ImageList;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
2002-04-11 10:49:39 +00:00
|
|
|
void SfxImageManager_Impl::MakeDefaultImageList( BOOL bHiContrast )
|
2001-06-11 09:09:07 +00:00
|
|
|
{
|
|
|
|
|
USHORT nType=0;
|
|
|
|
|
{
|
2002-04-11 10:49:39 +00:00
|
|
|
switch ( m_aOpt.GetSymbolSet() )
|
|
|
|
|
{
|
|
|
|
|
case SFX_SYMBOLS_SMALL:
|
|
|
|
|
if ( bHiContrast )
|
|
|
|
|
pHiImageList = GetImageList( FALSE, TRUE );
|
|
|
|
|
else
|
|
|
|
|
pImageList = GetImageList( FALSE, FALSE );
|
|
|
|
|
break;
|
|
|
|
|
case SFX_SYMBOLS_LARGE:
|
|
|
|
|
if ( bHiContrast )
|
|
|
|
|
pHiImageList = GetImageList( TRUE, TRUE );
|
|
|
|
|
else
|
|
|
|
|
pImageList = GetImageList( TRUE, FALSE );
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
DBG_ERROR("Unknown Symboltype!");
|
|
|
|
|
break;
|
|
|
|
|
}
|
2001-06-11 09:09:07 +00:00
|
|
|
}
|
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2001-06-11 09:09:07 +00:00
|
|
|
//-------------------------------------------------------------------------
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2001-06-11 09:09:07 +00:00
|
|
|
void SfxImageManager::ExchangeItemImage_Impl( USHORT nId, const Image& rImage )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-06-11 09:09:07 +00:00
|
|
|
for ( USHORT n=0; n<pData->pToolBoxList->Count(); n++ )
|
|
|
|
|
{
|
|
|
|
|
ToolBox *pBox = (*pData->pToolBoxList)[n]->pToolBox;
|
|
|
|
|
pBox->SetItemImage( nId, rImage );
|
|
|
|
|
}
|
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2001-06-11 09:09:07 +00:00
|
|
|
void SfxImageManager_Impl::RebuildUserList()
|
|
|
|
|
{
|
|
|
|
|
// Userliste neu aufbauen
|
|
|
|
|
Color aColor (0xC0, 0xC0, 0xC0);
|
|
|
|
|
VirtualDevice aDev;
|
|
|
|
|
Size aNewSize = pImageList->GetImageSize();
|
|
|
|
|
aDev.SetOutputSizePixel(aNewSize);
|
|
|
|
|
|
2002-04-11 10:49:39 +00:00
|
|
|
ImageList *pOldList = m_pUserImageList;
|
|
|
|
|
ImageList *pOldHCList = m_pHCUserImageList;
|
|
|
|
|
m_pUserImageList = new ImageList( pOldList->GetImageCount() );
|
|
|
|
|
m_pHCUserImageList = new ImageList( pOldHCList->GetImageCount() );
|
|
|
|
|
|
2001-06-11 09:09:07 +00:00
|
|
|
for ( USHORT i=0; i<pOldList->GetImageCount(); i++ )
|
|
|
|
|
{
|
|
|
|
|
USHORT nId = pOldList->GetImageId( i );
|
|
|
|
|
Image aImage;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2001-06-11 09:09:07 +00:00
|
|
|
// Image benutzerdefiniert ?
|
2002-04-11 10:49:39 +00:00
|
|
|
if ( m_pUserDefList->GetBitmapPos(nId) != USHRT_MAX )
|
2001-06-11 09:09:07 +00:00
|
|
|
{
|
2002-04-11 10:49:39 +00:00
|
|
|
Bitmap *pBmp = m_pUserDefList->GetBitmap( nId );
|
2001-06-11 09:09:07 +00:00
|
|
|
if ( pBmp->GetSizePixel() != aNewSize )
|
|
|
|
|
{
|
|
|
|
|
aDev.DrawBitmap( Point(), aNewSize, *pBmp );
|
|
|
|
|
aImage = Image( aDev.GetBitmap(Point(), aNewSize), aColor );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
aImage = Image( *pBmp, aColor );
|
2002-04-11 10:49:39 +00:00
|
|
|
|
|
|
|
|
if ( aImage.GetSizePixel() == aNewSize )
|
|
|
|
|
{
|
|
|
|
|
m_pUserImageList->AddImage( nId, aImage );
|
|
|
|
|
m_pHCUserImageList->AddImage( nId, aImage ); // user images are always used as non high contrast
|
|
|
|
|
}
|
2001-06-11 09:09:07 +00:00
|
|
|
}
|
|
|
|
|
else
|
2002-04-11 10:49:39 +00:00
|
|
|
{
|
|
|
|
|
aImage = SeekImage( nId, NULL, FALSE ); // look for non high contrast mode image
|
|
|
|
|
m_pUserImageList->AddImage( nId, aImage );
|
|
|
|
|
aImage = SeekImage( nId, NULL, TRUE ); // look for high contrast mode image
|
|
|
|
|
m_pHCUserImageList->AddImage( nId, aImage );
|
|
|
|
|
}
|
2001-06-11 09:09:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
delete pOldList;
|
2002-04-11 10:49:39 +00:00
|
|
|
delete pOldHCList;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
2002-04-11 10:49:39 +00:00
|
|
|
Image SfxImageManager_Impl::GetImage( USHORT nId, SfxModule *pModule, BOOL bBig, BOOL bHiContrast ) const
|
2001-06-11 09:09:07 +00:00
|
|
|
{
|
|
|
|
|
if ( !pModule )
|
|
|
|
|
pModule = SFX_APP()->GetActiveModule();
|
|
|
|
|
ImageList *pList=0;
|
|
|
|
|
if ( pModule )
|
2002-04-11 10:49:39 +00:00
|
|
|
pList = pModule->GetImageList_Impl( bBig, bHiContrast );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2002-04-11 10:49:39 +00:00
|
|
|
if ( bHiContrast )
|
|
|
|
|
{
|
|
|
|
|
if ( m_pHCUserImageList->GetImagePos( nId ) != IMAGELIST_IMAGE_NOTFOUND )
|
|
|
|
|
return m_pHCUserImageList->GetImage( nId );
|
|
|
|
|
else if ( pList && pList->GetImagePos( nId ) != IMAGELIST_IMAGE_NOTFOUND )
|
|
|
|
|
return pList->GetImage( nId );
|
|
|
|
|
else
|
|
|
|
|
return GetImageList( bBig, bHiContrast )->GetImage( nId );
|
|
|
|
|
}
|
2001-06-11 09:09:07 +00:00
|
|
|
else
|
2002-04-11 10:49:39 +00:00
|
|
|
{
|
|
|
|
|
if ( m_pUserImageList->GetImagePos( nId ) != IMAGELIST_IMAGE_NOTFOUND )
|
|
|
|
|
return m_pUserImageList->GetImage( nId );
|
|
|
|
|
else if ( pList && pList->GetImagePos( nId ) != IMAGELIST_IMAGE_NOTFOUND )
|
|
|
|
|
return pList->GetImage( nId );
|
|
|
|
|
else
|
|
|
|
|
return GetImageList( bBig, bHiContrast )->GetImage( nId );
|
|
|
|
|
}
|
2001-06-11 09:09:07 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2002-04-11 10:49:39 +00:00
|
|
|
Image SfxImageManager_Impl::SeekImage( USHORT nId, SfxModule *pModule, BOOL bHiContrast ) const
|
2001-06-11 09:09:07 +00:00
|
|
|
{
|
2002-04-11 10:49:39 +00:00
|
|
|
BOOL bBig = ( m_aOpt.GetSymbolSet() == SFX_SYMBOLS_LARGE );
|
|
|
|
|
|
2001-06-11 09:09:07 +00:00
|
|
|
if ( !pModule )
|
|
|
|
|
pModule = SFX_APP()->GetActiveModule();
|
|
|
|
|
ImageList *pList=0;
|
|
|
|
|
if ( pModule )
|
2002-04-11 10:49:39 +00:00
|
|
|
pList = pModule->GetImageList_Impl( bBig, bHiContrast );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2002-04-11 10:49:39 +00:00
|
|
|
if ( bHiContrast )
|
|
|
|
|
{
|
|
|
|
|
if ( m_pHCUserImageList->GetImagePos( nId ) != IMAGELIST_IMAGE_NOTFOUND )
|
|
|
|
|
return m_pHCUserImageList->GetImage( nId );
|
|
|
|
|
else if ( pList && pList->GetImagePos( nId ) != IMAGELIST_IMAGE_NOTFOUND )
|
|
|
|
|
return pList->GetImage( nId );
|
|
|
|
|
else
|
|
|
|
|
return GetImageList( bBig, bHiContrast )->GetImage( nId );
|
|
|
|
|
}
|
2001-06-11 09:09:07 +00:00
|
|
|
else
|
2002-04-11 10:49:39 +00:00
|
|
|
{
|
|
|
|
|
if ( m_pUserImageList->GetImagePos( nId ) != IMAGELIST_IMAGE_NOTFOUND )
|
|
|
|
|
return m_pUserImageList->GetImage( nId );
|
|
|
|
|
else if ( pList && pList->GetImagePos( nId ) != IMAGELIST_IMAGE_NOTFOUND )
|
|
|
|
|
return pList->GetImage( nId );
|
|
|
|
|
else
|
|
|
|
|
return GetImageList( bBig, bHiContrast )->GetImage( nId );
|
|
|
|
|
}
|
2001-06-11 09:09:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
SfxImageManager::SfxImageManager( SfxObjectShell* pDoc )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-06-11 09:09:07 +00:00
|
|
|
DBG_MEMTEST();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2001-06-11 09:09:07 +00:00
|
|
|
// every ImageManager has its own list of toolboxes, so even if it gets a new configuration, the list
|
|
|
|
|
// remains the same!
|
|
|
|
|
pData = new SfxImageManagerData_Impl;
|
|
|
|
|
pData->pToolBoxList = new SfxToolBoxArr_Impl;
|
|
|
|
|
pData->pDoc = pDoc;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2001-06-11 09:09:07 +00:00
|
|
|
if ( pDoc && pDoc->GetConfigManager() && pDoc->GetConfigManager()->HasConfigItem(SFX_ITEMTYPE_IMAGELIST) )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-06-11 09:09:07 +00:00
|
|
|
pImp = new SfxImageManager_Impl( pDoc->GetConfigManager() );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if ( !pGlobalConfig )
|
|
|
|
|
pGlobalConfig = new SfxImageManager_Impl( SFX_APP()->GetConfigManager_Impl() );
|
|
|
|
|
pImp = pGlobalConfig;
|
|
|
|
|
nGlobalRef++;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2001-06-11 09:09:07 +00:00
|
|
|
|
|
|
|
|
// internal cached data for comparision in callback
|
2002-04-11 10:49:39 +00:00
|
|
|
pData->nSet = pImp->m_aOpt.GetSymbolSet();
|
|
|
|
|
pData->nOutStyle = pImp->m_aOpt.GetToolboxStyle();
|
2001-06-11 09:09:07 +00:00
|
|
|
|
|
|
|
|
// register callback for changes of SymbolSet or ToolboxStyle
|
2002-04-11 10:49:39 +00:00
|
|
|
pImp->m_aOpt.AddListener( LINK( this, SfxImageManager, OptionsChanged_Impl ) );
|
2001-06-11 09:09:07 +00:00
|
|
|
|
|
|
|
|
// SetInternal( TRUE );
|
|
|
|
|
nRef++;
|
|
|
|
|
pImp->AddLink( LINK( this, SfxImageManager, OptionsChanged_Impl ) );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
2001-06-11 09:09:07 +00:00
|
|
|
SfxImageManager::~SfxImageManager()
|
|
|
|
|
{
|
|
|
|
|
pImp->RemoveLink( LINK( this, SfxImageManager, OptionsChanged_Impl ) );
|
|
|
|
|
|
|
|
|
|
if ( !--nRef )
|
|
|
|
|
{
|
|
|
|
|
DELETEZ( pImageListSmall );
|
|
|
|
|
DELETEZ( pImageListBig );
|
2002-04-11 10:49:39 +00:00
|
|
|
DELETEZ( pImageListHiSmall );
|
|
|
|
|
DELETEZ( pImageListHiBig );
|
2001-06-11 09:09:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DELETEZ( pData->pToolBoxList );
|
2002-04-11 10:49:39 +00:00
|
|
|
pImp->m_aOpt.RemoveListener( LINK( this, SfxImageManager, OptionsChanged_Impl ) );
|
2001-06-11 09:09:07 +00:00
|
|
|
if ( pImp != pGlobalConfig || !--nGlobalRef )
|
|
|
|
|
delete pImp;
|
|
|
|
|
delete pData;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BOOL SfxImageManager::Import( SvStream& rInStream, SotStorage& rOutStorage )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-06-11 09:09:07 +00:00
|
|
|
SfxImageManager_Impl aImpl( NULL );
|
2001-11-27 10:00:49 +00:00
|
|
|
if ( aImpl.Load( rInStream ) == SfxConfigItem::ERR_OK )
|
|
|
|
|
return aImpl.Store( rOutStorage );
|
|
|
|
|
return FALSE;
|
2001-06-11 09:09:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BOOL SfxImageManager::Export( SotStorage& rInStorage, SvStream& rOutStream )
|
|
|
|
|
{
|
|
|
|
|
SfxImageManager_Impl aImpl( NULL );
|
2001-11-27 10:00:49 +00:00
|
|
|
if ( aImpl.Load( rInStorage ) == SfxConfigItem::ERR_OK )
|
|
|
|
|
return aImpl.Store( rOutStream );
|
|
|
|
|
return FALSE;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
/* [Beschreibung]
|
|
|
|
|
|
|
|
|
|
Nimmt eine Referenz auf ein Image auf und erweitert die aktuelle ImageList
|
|
|
|
|
ggf. um ein weiteres Image. Der Zweck dieser Methode ist, da\s verhindert
|
|
|
|
|
werden mu\s, da\s die Toolbox "uber das Image eine Referenz auf die
|
|
|
|
|
Quell-Liste diese am Leben erh"alt.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
void SfxImageManager::LockImage( USHORT nId, ToolBox *pBox )
|
|
|
|
|
{
|
2002-04-11 10:49:39 +00:00
|
|
|
LockImage( nId, pBox, FALSE );
|
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2002-04-11 10:49:39 +00:00
|
|
|
void SfxImageManager::LockImage( USHORT nId, ToolBox *pBox, BOOL bHiContrast )
|
|
|
|
|
{
|
2000-09-18 16:07:07 +00:00
|
|
|
// Das Image mu\s die richtige Gr"o\e haben
|
|
|
|
|
if ( pBox->GetItemImage(nId).GetSizePixel() == pImageList->GetImageSize() )
|
|
|
|
|
{
|
|
|
|
|
// Ist das Image schon vorhanden ?
|
2002-04-11 10:49:39 +00:00
|
|
|
ImageList *pUserImageList = pImp->m_pUserImageList;
|
|
|
|
|
ImageList *pHCUserImageList = pImp->m_pHCUserImageList;
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( pUserImageList->GetImagePos( nId ) == IMAGELIST_IMAGE_NOTFOUND )
|
|
|
|
|
{
|
2002-04-11 10:49:39 +00:00
|
|
|
// Eine physikalische Kopie des Images in der User-Listen machen
|
2000-09-18 16:07:07 +00:00
|
|
|
pUserImageList->AddImage( nId, pBox->GetItemImage( nId ) );
|
2002-04-11 10:49:39 +00:00
|
|
|
pHCUserImageList->AddImage( nId, pBox->GetItemImage( nId ) );
|
|
|
|
|
|
2001-11-27 10:00:49 +00:00
|
|
|
if ( SfxMacroConfig::IsMacroSlot(nId) )
|
|
|
|
|
SfxMacroConfig::GetOrCreate()->RegisterSlotId( nId );
|
|
|
|
|
|
2001-06-11 09:09:07 +00:00
|
|
|
pImp->SetDefault( FALSE );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
2002-04-11 10:49:39 +00:00
|
|
|
// Toolbox should use image from the user image list so that the reference to
|
|
|
|
|
// the source image list will be released!
|
|
|
|
|
if ( bHiContrast )
|
|
|
|
|
pBox->SetItemImage( nId, pHCUserImageList->GetImage( nId ) );
|
|
|
|
|
else
|
|
|
|
|
pBox->SetItemImage( nId, pUserImageList->GetImage( nId ) );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
2002-04-11 10:49:39 +00:00
|
|
|
Image SfxImageManager::MakeUserImage( USHORT nId, Image& aImage, BOOL bHiContrast )
|
2002-02-22 07:09:54 +00:00
|
|
|
{
|
|
|
|
|
// Das Image mu\s die richtige Gr"o\e haben
|
|
|
|
|
if ( aImage.GetSizePixel() == pImageList->GetImageSize() )
|
|
|
|
|
{
|
|
|
|
|
// Ist das Image schon vorhanden ?
|
2002-04-11 10:49:39 +00:00
|
|
|
ImageList *pUserImageList = pImp->m_pUserImageList;
|
|
|
|
|
ImageList *pHCUserImageList = pImp->m_pHCUserImageList;
|
|
|
|
|
|
2002-02-22 07:09:54 +00:00
|
|
|
if ( pUserImageList->GetImagePos( nId ) == IMAGELIST_IMAGE_NOTFOUND )
|
|
|
|
|
{
|
2002-04-11 10:49:39 +00:00
|
|
|
// Eine physikalische Kopie des Images in den User-Listen machen
|
2002-02-22 07:09:54 +00:00
|
|
|
pUserImageList->AddImage( nId, aImage );
|
2002-04-11 10:49:39 +00:00
|
|
|
pHCUserImageList->AddImage( nId, aImage );
|
|
|
|
|
|
2002-02-22 07:09:54 +00:00
|
|
|
if ( SfxMacroConfig::IsMacroSlot(nId) )
|
|
|
|
|
SfxMacroConfig::GetOrCreate()->RegisterSlotId( nId );
|
|
|
|
|
|
|
|
|
|
pImp->SetDefault( FALSE );
|
|
|
|
|
}
|
|
|
|
|
|
2002-04-11 10:49:39 +00:00
|
|
|
// Return image from the user image list so that the reference to
|
|
|
|
|
// the source image list will be released!
|
|
|
|
|
if ( bHiContrast )
|
|
|
|
|
return pHCUserImageList->GetImage( nId );
|
|
|
|
|
else
|
|
|
|
|
return pUserImageList->GetImage( nId );
|
2002-02-22 07:09:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Image();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
2001-06-11 09:09:07 +00:00
|
|
|
void SfxImageManager::SetSymbolSet_Impl( sal_Int16 nNewSet )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-06-11 09:09:07 +00:00
|
|
|
if ( nNewSet != pData->nSet && pImageList )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-06-11 09:09:07 +00:00
|
|
|
pData->nSet = nNewSet;
|
2000-09-18 16:07:07 +00:00
|
|
|
Size aOldSize = pImageList->GetImageSize();
|
|
|
|
|
|
|
|
|
|
// neue DefaultList erzeugen
|
2001-06-11 09:09:07 +00:00
|
|
|
pImageList = NULL;
|
|
|
|
|
pImp->MakeDefaultImageList();
|
2000-09-18 16:07:07 +00:00
|
|
|
Size aNewSize = pImageList->GetImageSize();
|
|
|
|
|
|
2001-06-11 09:09:07 +00:00
|
|
|
if ( !pImp->IsDefault() )
|
|
|
|
|
pImp->RebuildUserList();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2001-06-11 09:09:07 +00:00
|
|
|
for ( USHORT n=0; n<pData->pToolBoxList->Count(); n++ )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-06-11 09:09:07 +00:00
|
|
|
ToolBoxInf_Impl *pInf = (*pData->pToolBoxList)[n];
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( pInf->nFlags & SFX_TOOLBOX_CHANGESYMBOLSET )
|
|
|
|
|
{
|
|
|
|
|
ToolBox *pBox = pInf->pToolBox;
|
|
|
|
|
SfxToolBoxManager* pMgr = pInf->pMgr;
|
|
|
|
|
|
|
|
|
|
if ( pMgr )
|
|
|
|
|
{
|
|
|
|
|
pMgr->RefreshImages_Impl();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
USHORT nCount = pBox->GetItemCount();
|
|
|
|
|
for ( USHORT nPos=0; nPos<nCount; nPos++ )
|
|
|
|
|
{
|
|
|
|
|
USHORT nId = pBox->GetItemId( nPos );
|
|
|
|
|
if ( pBox->GetItemType(nPos) == TOOLBOXITEM_BUTTON )
|
|
|
|
|
{
|
|
|
|
|
pBox->SetItemImage( nId, GetImage( nId, pInf->pModule ) );
|
|
|
|
|
SfxStateCache *pCache = SfxViewFrame::Current()->GetBindings().GetStateCache( nId );
|
|
|
|
|
if ( pCache )
|
|
|
|
|
pCache->SetCachedState();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( !pBox->IsFloatingMode() )
|
|
|
|
|
{
|
|
|
|
|
Size aActSize( pBox->GetSizePixel() );
|
|
|
|
|
Size aSize( pBox->CalcWindowSizePixel() );
|
|
|
|
|
if ( pBox->IsHorizontal() )
|
|
|
|
|
aSize.Width() = aActSize.Width();
|
|
|
|
|
else
|
|
|
|
|
aSize.Height() = aActSize.Height();
|
|
|
|
|
|
|
|
|
|
pBox->SetSizePixel( aSize );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
/* [Beschreibung]
|
|
|
|
|
|
|
|
|
|
Sucht das Image der uebergebenen Id. Suchreihenfolge:
|
|
|
|
|
|
|
|
|
|
UserDefListe, Modul-Imageliste( sofern vorhanden ), Default-Liste,
|
|
|
|
|
Officeliste( sofern vorhanden ).
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
Image SfxImageManager::SeekImage( USHORT nId, SfxModule *pModule ) const
|
|
|
|
|
{
|
2002-04-11 10:49:39 +00:00
|
|
|
return SeekImage( nId, FALSE, pModule );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Image SfxImageManager::SeekImage( USHORT nId, BOOL bHiContrast, SfxModule *pModule ) const
|
|
|
|
|
{
|
|
|
|
|
return pImp->SeekImage( nId, pModule, bHiContrast );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
/* [Beschreibung]
|
|
|
|
|
|
|
|
|
|
Sucht das Image der uebergebenen Id genauso wie SeekImage, allerdings
|
|
|
|
|
wird die Office-liste nicht durchsucht, d.h. es werden nur die aktuell
|
|
|
|
|
konfigurierten Images ber"ucksichtigt.
|
|
|
|
|
*/
|
|
|
|
|
Image SfxImageManager::GetImage( USHORT nId, SfxModule *pModule ) const
|
|
|
|
|
{
|
2002-04-11 10:49:39 +00:00
|
|
|
return GetImage( nId, FALSE, pModule );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Image SfxImageManager::GetImage( USHORT nId, BOOL bHiContrast, SfxModule *pModule ) const
|
|
|
|
|
{
|
|
|
|
|
return pImp->GetImage( nId, pModule, ( pImp->m_aOpt.GetSymbolSet() == SFX_SYMBOLS_LARGE ), bHiContrast );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Image SfxImageManager::GetImage(USHORT nId, SfxModule* pMod, BOOL bBig ) const
|
|
|
|
|
{
|
|
|
|
|
return GetImage( nId, pMod, bBig, FALSE );
|
2001-06-11 09:09:07 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2002-04-11 10:49:39 +00:00
|
|
|
Image SfxImageManager::GetImage( USHORT nId, SfxModule *pModule, BOOL bBig, BOOL bHiContrast ) const
|
2001-06-11 09:09:07 +00:00
|
|
|
{
|
2002-04-11 10:49:39 +00:00
|
|
|
return pImp->GetImage( nId, pModule, bBig, bHiContrast );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Image SfxImageManager::GetImageFromModule_Impl( USHORT nId, SfxModule *pModule )
|
2002-04-11 10:49:39 +00:00
|
|
|
{
|
|
|
|
|
return GetImageFromModule_Impl( nId, pModule, FALSE );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Image SfxImageManager::GetImageFromModule_Impl( USHORT nId, SfxModule *pModule, BOOL bHiContrast )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
|
if ( pModule )
|
|
|
|
|
{
|
2002-04-11 10:49:39 +00:00
|
|
|
ImageList *pList = pModule->GetImageList_Impl(( pImp->m_aOpt.GetSymbolSet() == SFX_SYMBOLS_LARGE ), bHiContrast );
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( pList )
|
|
|
|
|
return pList->GetImage( nId );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2002-04-11 10:49:39 +00:00
|
|
|
if ( bHiContrast )
|
2000-09-18 16:07:07 +00:00
|
|
|
return pImageList->GetImage( nId );
|
2002-04-11 10:49:39 +00:00
|
|
|
else
|
|
|
|
|
return pHiImageList->GetImage( nId );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2001-06-11 09:09:07 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
return Image();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Image SfxImageManager::GetAndLockImage_Impl( USHORT nId, SfxModule *pModule )
|
|
|
|
|
{
|
2002-04-11 10:49:39 +00:00
|
|
|
return GetAndLockImage_Impl( nId, FALSE, pModule );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Image SfxImageManager::GetAndLockImage_Impl( USHORT nId, BOOL bHiContrast, SfxModule *pModule )
|
|
|
|
|
{
|
|
|
|
|
BOOL bBig = ( pImp->m_aOpt.GetSymbolSet() == SFX_SYMBOLS_LARGE );
|
|
|
|
|
ImageList *pUserImageList = pImp->m_pUserImageList;
|
|
|
|
|
ImageList *pHCUserImageList = pImp->m_pHCUserImageList;
|
2001-06-11 09:09:07 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
// Zuerst in der UserImagelist suchen
|
2002-04-11 10:49:39 +00:00
|
|
|
if ( bHiContrast )
|
|
|
|
|
{
|
|
|
|
|
if ( pHCUserImageList->GetImagePos( nId ) != IMAGELIST_IMAGE_NOTFOUND )
|
|
|
|
|
return pHCUserImageList->GetImage( nId );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if ( pUserImageList->GetImagePos( nId ) != IMAGELIST_IMAGE_NOTFOUND )
|
|
|
|
|
return pUserImageList->GetImage( nId );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( pModule )
|
|
|
|
|
return GetImage( nId, pModule, bBig, bHiContrast );
|
2000-09-18 16:07:07 +00:00
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
pModule = SFX_APP()->GetActiveModule();
|
|
|
|
|
|
|
|
|
|
// Wenn das Image nicht in der default-Liste steht, das Image aber
|
|
|
|
|
// f"ur diese Liste angefordert wird
|
|
|
|
|
if ( pModule && pImageList->GetImagePos( nId ) == IMAGELIST_IMAGE_NOTFOUND )
|
|
|
|
|
{
|
|
|
|
|
// Dann in der Liste des aktiven Moduls suchen
|
2002-04-11 10:49:39 +00:00
|
|
|
ImageList *pList = pModule->GetImageList_Impl( bBig, bHiContrast );
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( pList && pList->GetImagePos( nId ) != IMAGELIST_IMAGE_NOTFOUND )
|
|
|
|
|
{
|
|
|
|
|
// Das Image in die UserImageList "ubertragen
|
2002-04-11 10:49:39 +00:00
|
|
|
if ( bHiContrast )
|
|
|
|
|
{
|
|
|
|
|
// Add it to the high contrast user image list
|
|
|
|
|
pHCUserImageList->AddImage( nId, pList->GetImage( nId ) );
|
|
|
|
|
|
|
|
|
|
// Do it for the NON high contrast user image list, too!!
|
|
|
|
|
ImageList *pNonList = pModule->GetImageList_Impl( bBig, FALSE );
|
|
|
|
|
if ( pNonList )
|
|
|
|
|
pUserImageList->AddImage( nId, pNonList->GetImage( nId ) );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Add it to the user image list
|
|
|
|
|
pUserImageList->AddImage( nId, pList->GetImage( nId ) );
|
|
|
|
|
|
|
|
|
|
// Do it for the high contrast user image list, too!!
|
|
|
|
|
ImageList *pHiList = pModule->GetImageList_Impl( bBig, TRUE );
|
|
|
|
|
if ( pHiList )
|
|
|
|
|
pHCUserImageList->AddImage( nId, pHiList->GetImage( nId ) );
|
|
|
|
|
}
|
|
|
|
|
|
2001-11-27 10:00:49 +00:00
|
|
|
if ( SfxMacroConfig::IsMacroSlot(nId) )
|
|
|
|
|
SfxMacroConfig::GetOrCreate()->RegisterSlotId( nId );
|
2001-06-11 09:09:07 +00:00
|
|
|
pImp->SetDefault( FALSE );
|
2002-04-11 10:49:39 +00:00
|
|
|
|
|
|
|
|
if ( bHiContrast )
|
|
|
|
|
return pHCUserImageList->GetImage( nId );
|
|
|
|
|
else
|
|
|
|
|
return pUserImageList->GetImage( nId );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return pImageList->GetImage( nId );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
/* [Beschreibung]
|
|
|
|
|
|
|
|
|
|
Erzeugt die Office-Liste, die f"ur das Konfigurieren ben"otigt wird.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
void SfxImageManager::StartCustomize()
|
|
|
|
|
{
|
2002-04-11 10:49:39 +00:00
|
|
|
// no more office list
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
/* [Beschreibung]
|
|
|
|
|
|
|
|
|
|
Entfernt die nachgeladenen ImageLists wieder aus dem Speicher.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
void SfxImageManager::EndCustomize()
|
|
|
|
|
{
|
2002-04-11 10:49:39 +00:00
|
|
|
// no more office list
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
/* [Beschreibung]
|
|
|
|
|
|
|
|
|
|
Ersetzt das Image f"ur die "ubergebene Id durch die "ubergebene Bitmap
|
|
|
|
|
bzw. entfernt die Bindung an eine Bitmap.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
void SfxImageManager::ReplaceImage( USHORT nId, Bitmap* pBmp )
|
|
|
|
|
{
|
2002-04-11 10:49:39 +00:00
|
|
|
ImageList *pUserImageList = pImp->m_pUserImageList;
|
|
|
|
|
ImageList *pHCUserImageList = pImp->m_pHCUserImageList;
|
|
|
|
|
|
|
|
|
|
SfxBitmapList_Impl* pUserDefList = pImp->m_pUserDefList;
|
2000-09-18 16:07:07 +00:00
|
|
|
BOOL bReplaced = FALSE;
|
|
|
|
|
if ( !pBmp && GetImage( nId ).GetSizePixel().Width() )
|
|
|
|
|
{
|
|
|
|
|
// Auf default zuruecksetzen; zuerst das Userdef-Image entfernen
|
|
|
|
|
pUserImageList->RemoveImage( nId );
|
2002-04-11 10:49:39 +00:00
|
|
|
pHCUserImageList->RemoveImage( nId );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
|
// Falls zu der "ubergebenen Id eine UserBitmap vorliegt, wird sie
|
|
|
|
|
// jetzt wieder entfernt
|
|
|
|
|
for ( USHORT i=0; i<pUserDefList->GetBitmapCount(); i++ )
|
|
|
|
|
if ( pUserDefList->GetBitmapId(i) == nId )
|
|
|
|
|
pUserDefList->RemoveBitmap( nId );
|
|
|
|
|
|
|
|
|
|
Image aImage = GetImage( nId );
|
|
|
|
|
|
|
|
|
|
if ( aImage.GetSizePixel().Width() )
|
|
|
|
|
{
|
|
|
|
|
// F"ur die Id soll wieder ein Image aktiviert werden, das nicht
|
|
|
|
|
// defaultm"assig vorhanden ist
|
|
|
|
|
pUserImageList->AddImage( nId, aImage );
|
|
|
|
|
}
|
2001-11-27 10:00:49 +00:00
|
|
|
else if ( SfxMacroConfig::IsMacroSlot(nId) )
|
|
|
|
|
SfxMacroConfig::GetOrCreate()->ReleaseSlotId( nId );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
|
bReplaced = TRUE;
|
|
|
|
|
}
|
|
|
|
|
else if ( pBmp )
|
|
|
|
|
{
|
|
|
|
|
// Eine neue Bitmap aufnehmen
|
|
|
|
|
Size aSize = pBmp->GetSizePixel();
|
|
|
|
|
if ( aSize.Width() > 208 || aSize.Height() > 208 )
|
|
|
|
|
{
|
|
|
|
|
// Maximale Gr"o\se, die f"ur 16x16 und 26x26-BMP n"otig ist
|
|
|
|
|
VirtualDevice aDev;
|
|
|
|
|
Size aSz( 208, 208 );
|
|
|
|
|
aDev.SetOutputSizePixel( aSz );
|
|
|
|
|
aDev.DrawBitmap( Point(), aSz, *pBmp );
|
|
|
|
|
delete pBmp;
|
|
|
|
|
pBmp = new Bitmap( aDev.GetBitmap( Point(), aSz ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( pUserDefList->GetBitmapPos( nId ) == USHRT_MAX )
|
|
|
|
|
pUserDefList->AddBitmap( nId, *pBmp );
|
|
|
|
|
else
|
|
|
|
|
pUserDefList->ReplaceBitmap( nId, *pBmp );
|
|
|
|
|
|
|
|
|
|
Color aColor ( 0xC0, 0xC0, 0xC0 );
|
|
|
|
|
Image aImage( *pBmp, aColor );
|
|
|
|
|
if ( pBmp->GetSizePixel() != pImageList->GetImageSize() )
|
|
|
|
|
{
|
|
|
|
|
// Evtl. Imagegr"o\se anpassen
|
|
|
|
|
VirtualDevice aDev;
|
|
|
|
|
Size aSize = pImageList->GetImageSize();
|
|
|
|
|
aDev.SetOutputSizePixel( aSize );
|
|
|
|
|
aDev.DrawBitmap( Point(), aSize, *pBmp );
|
|
|
|
|
aImage = Image( aDev.GetBitmap(Point(), aSize), aColor );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// In die User-Liste aufnehmen
|
|
|
|
|
if ( pUserImageList->GetImagePos( nId ) == IMAGELIST_IMAGE_NOTFOUND )
|
2002-04-11 10:49:39 +00:00
|
|
|
{
|
2000-09-18 16:07:07 +00:00
|
|
|
pUserImageList->AddImage( nId, aImage );
|
2002-04-11 10:49:39 +00:00
|
|
|
pHCUserImageList->AddImage( nId, aImage );
|
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
else
|
2002-04-11 10:49:39 +00:00
|
|
|
{
|
2000-09-18 16:07:07 +00:00
|
|
|
pUserImageList->ReplaceImage( nId, aImage );
|
2002-04-11 10:49:39 +00:00
|
|
|
pHCUserImageList->ReplaceImage( nId, aImage );
|
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2001-11-27 10:00:49 +00:00
|
|
|
if ( SfxMacroConfig::IsMacroSlot(nId) )
|
|
|
|
|
SfxMacroConfig::GetOrCreate()->RegisterSlotId( nId );
|
2000-09-18 16:07:07 +00:00
|
|
|
bReplaced = TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( bReplaced )
|
|
|
|
|
{
|
|
|
|
|
// Alle registrierten Toolboxen auf den Stand bringen
|
|
|
|
|
ExchangeItemImage_Impl( nId, GetImage( nId ) );
|
|
|
|
|
|
|
|
|
|
if ( pUserImageList->GetImageCount() )
|
2001-06-11 09:09:07 +00:00
|
|
|
pImp->SetDefault( FALSE );
|
2000-09-18 16:07:07 +00:00
|
|
|
else
|
2001-06-11 09:09:07 +00:00
|
|
|
pImp->SetDefault( TRUE );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// SvFileStream aBitmapStream(String("d:\\REPLACE.BMP"), STREAM_STD_WRITE);
|
|
|
|
|
// aBitmapStream << pUserImageList->GetBitmap();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* [Beschreibung]
|
|
|
|
|
|
|
|
|
|
Meldet eine Toolbox an, damit sie (je nach Flags) bei "Anderungen von
|
|
|
|
|
Symbolset oder OutStyle benachrichtigt werden kann.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
void SfxImageManager::RegisterToolBox( ToolBox *pBox, USHORT nFlags )
|
|
|
|
|
{
|
|
|
|
|
ToolBoxInf_Impl *pInf = new ToolBoxInf_Impl;
|
|
|
|
|
pInf->pToolBox = pBox;
|
|
|
|
|
pInf->pMgr = NULL;
|
|
|
|
|
pInf->nFlags = nFlags;
|
|
|
|
|
pInf->pModule = NULL;
|
2001-06-11 09:09:07 +00:00
|
|
|
pData->pToolBoxList->Append( pInf );
|
2002-04-11 10:49:39 +00:00
|
|
|
pBox->SetOutStyle( pImp->m_aOpt.GetToolboxStyle() );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SfxImageManager::RegisterToolBox( ToolBox *pBox, SfxModule* pModule, USHORT nFlags )
|
|
|
|
|
{
|
|
|
|
|
ToolBoxInf_Impl *pInf = new ToolBoxInf_Impl;
|
|
|
|
|
pInf->pToolBox = pBox;
|
|
|
|
|
pInf->pMgr = NULL;
|
|
|
|
|
pInf->nFlags = nFlags;
|
|
|
|
|
pInf->pModule = pModule;
|
2001-06-11 09:09:07 +00:00
|
|
|
pData->pToolBoxList->Append( pInf );
|
2002-04-11 10:49:39 +00:00
|
|
|
pBox->SetOutStyle( pImp->m_aOpt.GetToolboxStyle() );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
/* [Beschreibung]
|
|
|
|
|
|
|
|
|
|
Meldet eine Toolbox wieder ab.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
void SfxImageManager::ReleaseToolBox( ToolBox *pBox )
|
|
|
|
|
{
|
2001-06-11 09:09:07 +00:00
|
|
|
for ( USHORT n=0; n<pData->pToolBoxList->Count(); n++ )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-06-11 09:09:07 +00:00
|
|
|
if ( (*pData->pToolBoxList)[n]->pToolBox == pBox )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-06-11 09:09:07 +00:00
|
|
|
delete (*pData->pToolBoxList)[n];
|
|
|
|
|
pData->pToolBoxList->Remove( n );
|
2000-09-18 16:07:07 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SfxImageManager::RegisterToolBoxManager( SfxToolBoxManager *pMgr, USHORT nFlags )
|
|
|
|
|
{
|
|
|
|
|
ToolBoxInf_Impl *pInf = new ToolBoxInf_Impl;
|
|
|
|
|
pInf->pToolBox = &pMgr->GetToolBox();
|
|
|
|
|
pInf->pMgr = pMgr;
|
|
|
|
|
pInf->nFlags = nFlags;
|
2001-06-11 09:09:07 +00:00
|
|
|
pData->pToolBoxList->Append( pInf );
|
2002-04-11 10:49:39 +00:00
|
|
|
pInf->pToolBox->SetOutStyle( pImp->m_aOpt.GetToolboxStyle() );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
/* [Beschreibung]
|
|
|
|
|
|
|
|
|
|
Meldet eine Toolbox wieder ab.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
void SfxImageManager::ReleaseToolBoxManager( SfxToolBoxManager *pMgr )
|
|
|
|
|
{
|
2001-06-11 09:09:07 +00:00
|
|
|
for ( USHORT n=0; n<pData->pToolBoxList->Count(); n++ )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-06-11 09:09:07 +00:00
|
|
|
if ( (*pData->pToolBoxList)[n]->pMgr == pMgr )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-06-11 09:09:07 +00:00
|
|
|
delete (*pData->pToolBoxList)[n];
|
|
|
|
|
pData->pToolBoxList->Remove( n );
|
2000-09-18 16:07:07 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
/* [Beschreibung]
|
|
|
|
|
|
|
|
|
|
Gibt die Color zu"ruck, die als Maskenfarbe verwendet wird.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
Color SfxImageManager::GetMaskColor() const
|
|
|
|
|
{
|
2001-06-11 09:09:07 +00:00
|
|
|
if ( pImageList->HasMaskColor() )
|
2000-09-18 16:07:07 +00:00
|
|
|
return pImageList->GetMaskColor();
|
|
|
|
|
else
|
|
|
|
|
return Color(0xC0, 0xC0, 0xC0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
/* [Beschreibung]
|
|
|
|
|
|
|
|
|
|
Versorgt die "ubergebene Toolbox mit allen Images, die f"ur die enthaltenen
|
|
|
|
|
Ids konfiguriert sind.
|
|
|
|
|
Es wird ( genauso wie bei GetImage ) nicht in der Office-Liste gesucht.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
void SfxImageManager::SetImages( ToolBox& rToolBox, SfxModule *pModule )
|
|
|
|
|
{
|
2002-04-11 10:49:39 +00:00
|
|
|
SetImages( rToolBox, pModule, FALSE );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SfxImageManager::SetImages( ToolBox& rToolBox, SfxModule *pModule, BOOL bHiContrast )
|
|
|
|
|
{
|
|
|
|
|
BOOL bBig = pImp->m_aOpt.GetSymbolSet() == SFX_SYMBOLS_LARGE;
|
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( !pModule )
|
|
|
|
|
pModule = SFX_APP()->GetActiveModule();
|
|
|
|
|
ImageList *pList=0;
|
|
|
|
|
if ( pModule )
|
2002-04-11 10:49:39 +00:00
|
|
|
pList = pModule->GetImageList_Impl( bBig, bHiContrast );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2002-04-11 10:49:39 +00:00
|
|
|
ImageList *pUserImageList = bHiContrast ? pImp->m_pHCUserImageList : pImp->m_pUserImageList;
|
|
|
|
|
ImageList *pWorkImageList = GetImageList( bBig, bHiContrast );
|
2000-09-18 16:07:07 +00:00
|
|
|
USHORT nCount = rToolBox.GetItemCount();
|
|
|
|
|
for (USHORT n=0; n<nCount; n++)
|
|
|
|
|
{
|
|
|
|
|
USHORT nId = rToolBox.GetItemId(n);
|
|
|
|
|
switch ( rToolBox.GetItemType(n) )
|
|
|
|
|
{
|
|
|
|
|
case TOOLBOXITEM_BUTTON:
|
|
|
|
|
{
|
|
|
|
|
if ( pUserImageList->GetImagePos( nId ) != IMAGELIST_IMAGE_NOTFOUND )
|
|
|
|
|
rToolBox.SetItemImage(nId, pUserImageList->GetImage(nId));
|
|
|
|
|
else if ( pList && pList->GetImagePos( nId ) != IMAGELIST_IMAGE_NOTFOUND )
|
|
|
|
|
rToolBox.SetItemImage(nId, pList->GetImage(nId));
|
2002-04-11 10:49:39 +00:00
|
|
|
else if ( pWorkImageList->GetImagePos( nId ) != IMAGELIST_IMAGE_NOTFOUND )
|
|
|
|
|
rToolBox.SetItemImage(nId, pWorkImageList->GetImage(nId));
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case TOOLBOXITEM_SEPARATOR:
|
|
|
|
|
case TOOLBOXITEM_SPACE:
|
|
|
|
|
case TOOLBOXITEM_BREAK:
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
DBG_ERROR( "invalid item-type in toolbox config" );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
/* [Beschreibung]
|
|
|
|
|
|
|
|
|
|
Gibt zur"uck, ob f"ur die angegebene Id eine Bitmap konfiguriert wurde.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
BOOL SfxImageManager::IsUserDef_Impl(USHORT nId) const
|
|
|
|
|
{
|
2002-04-11 10:49:39 +00:00
|
|
|
return ( pImp->m_pUserDefList->GetBitmapPos(nId) != USHRT_MAX );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
/* [Beschreibung]
|
|
|
|
|
|
|
|
|
|
Gibt die konfigurierte Bitmap f"ur die angegebene Id zur"uck. Wichtig:
|
|
|
|
|
vorher mu\s mit IsUserDef_Impl "uberpr"uft werden, ob es auch eine gibt.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
const Bitmap& SfxImageManager::GetUserDefBitmap_Impl( USHORT nId ) const
|
|
|
|
|
{
|
2002-04-11 10:49:39 +00:00
|
|
|
SfxBitmapList_Impl* pUserDefList = pImp->m_pUserDefList;
|
2000-09-18 16:07:07 +00:00
|
|
|
USHORT nPos = pUserDefList->GetBitmapPos( nId );
|
|
|
|
|
DBG_ASSERT( nPos != USHRT_MAX, "Bitmap nicht vorhanden!" );
|
|
|
|
|
return ( *pUserDefList->GetBitmap(nId) );
|
|
|
|
|
}
|
|
|
|
|
|
2001-06-11 09:09:07 +00:00
|
|
|
void SfxImageManager::SetOutStyle_Impl( sal_Int16 nNewStyle )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-06-11 09:09:07 +00:00
|
|
|
if ( pData->nOutStyle != nNewStyle )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-06-11 09:09:07 +00:00
|
|
|
pData->nOutStyle = nNewStyle;
|
|
|
|
|
for ( USHORT n=0; n<pData->pToolBoxList->Count(); n++ )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-06-11 09:09:07 +00:00
|
|
|
ToolBoxInf_Impl *pInf = (*pData->pToolBoxList)[n];
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( pInf->nFlags & SFX_TOOLBOX_CHANGEOUTSTYLE )
|
|
|
|
|
{
|
|
|
|
|
ToolBox *pBox = pInf->pToolBox;
|
2001-06-11 09:09:07 +00:00
|
|
|
pBox->SetOutStyle( nNewStyle );
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( !pBox->IsFloatingMode() )
|
|
|
|
|
{
|
|
|
|
|
Size aActSize( pBox->GetSizePixel() );
|
|
|
|
|
Size aSize( pBox->CalcWindowSizePixel() );
|
|
|
|
|
if ( pBox->IsHorizontal() )
|
|
|
|
|
aSize.Width() = aActSize.Width();
|
|
|
|
|
else
|
|
|
|
|
aSize.Height() = aActSize.Height();
|
|
|
|
|
|
|
|
|
|
pBox->SetSizePixel( aSize );
|
|
|
|
|
}
|
|
|
|
|
pBox->Invalidate();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2001-06-11 09:09:07 +00:00
|
|
|
Size SfxImageManager::GetImageSize() const
|
|
|
|
|
{
|
|
|
|
|
return pImageList->GetImageSize();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IMPL_LINK( SfxImageManager, OptionsChanged_Impl, void*, pVoid )
|
|
|
|
|
{
|
2002-04-11 10:49:39 +00:00
|
|
|
SetOutStyle_Impl( pImp->m_aOpt.GetToolboxStyle() );
|
|
|
|
|
SetSymbolSet_Impl( pImp->m_aOpt.GetSymbolSet() );
|
2001-06-11 09:09:07 +00:00
|
|
|
|
|
|
|
|
return 0L;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Image SfxImageManager::GetGlobalImage( USHORT nId, BOOL bBig )
|
|
|
|
|
{
|
|
|
|
|
if ( !pGlobalConfig )
|
|
|
|
|
return Image();
|
2002-04-11 10:49:39 +00:00
|
|
|
return pGlobalConfig->GetImage( nId, NULL, bBig, FALSE );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Image SfxImageManager::GetGlobalImage( USHORT nId, BOOL bBig, BOOL bHiContrast )
|
|
|
|
|
{
|
|
|
|
|
if ( !pGlobalConfig )
|
|
|
|
|
return Image();
|
|
|
|
|
return pGlobalConfig->GetImage( nId, NULL, bBig, bHiContrast );
|
2001-06-11 09:09:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IMPL_LINK( SfxImageManager, ConfigChanged_Impl, void*, pVoid )
|
|
|
|
|
{
|
2002-04-11 10:49:39 +00:00
|
|
|
BOOL bHiContrast = FALSE;
|
|
|
|
|
|
|
|
|
|
if ( pData->pToolBoxList->Count() > 0 )
|
|
|
|
|
{
|
|
|
|
|
// Check whether toolbox is in high contrast mode or not!
|
|
|
|
|
ToolBox *pBox = (*pData->pToolBoxList)[0]->pToolBox;
|
|
|
|
|
Color aBackColor = pBox->GetBackground().GetColor();
|
|
|
|
|
if ( aBackColor.IsDark() )
|
|
|
|
|
bHiContrast = TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2001-06-11 09:09:07 +00:00
|
|
|
for ( USHORT i=0; i<pImageList->GetImageCount(); i++ )
|
|
|
|
|
{
|
|
|
|
|
USHORT nId = pImageList->GetImageId(i);
|
2002-04-11 10:49:39 +00:00
|
|
|
ExchangeItemImage_Impl( nId, pImp->GetImage( nId,
|
|
|
|
|
pData->pDoc->GetModule(),
|
|
|
|
|
( pData->nSet == SFX_SYMBOLS_LARGE ),
|
|
|
|
|
bHiContrast ) );
|
2001-06-11 09:09:07 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2001-06-11 09:09:07 +00:00
|
|
|
return TRUE;
|
|
|
|
|
}
|
2001-11-27 10:00:49 +00:00
|
|
|
|
|
|
|
|
BOOL SfxImageManager::CopyConfiguration_Impl( SfxConfigManager& rSource, SfxConfigManager& rDest )
|
|
|
|
|
{
|
|
|
|
|
SfxImageManager_Impl aTmp( &rDest );
|
|
|
|
|
aTmp.ReConnect( &rSource );
|
|
|
|
|
return rDest.StoreConfigItem( aTmp );
|
|
|
|
|
}
|