--- /dev/null	2002-08-31 00:31:37.000000000 +0100
+++ sd/source/filter/html/htmltheme.hxx	2003-08-16 16:56:34.000000000 +0100
@@ -0,0 +1,27 @@
+#ifndef _SD_HTML_THEME_HXX
+#define _SD_HTML_THEME_HXX
+
+#include <sddllapi.h>
+#include <list>
+
+class SD_DLLPUBLIC SdHtmlTheme {
+public:
+	static const SdHtmlTheme &getTheme();
+public:
+	SdHtmlTheme();
+	~SdHtmlTheme();
+	static const int nButtonsPerTheme = 13;
+	int      getThemeCount() const;
+	Bitmap   getThumbnail( int nThemeId ) const;
+	long     getBitmap( int nThemeId, int nImage, BitmapEx &rBitmap ) const;
+private:
+	/* list */
+	void loadDirectory( String aPath );
+	struct Theme {
+		ByteString aName;
+		BitmapEx   aImages[nButtonsPerTheme];
+	};
+	std::list<Theme> m_aThemes;
+};
+
+#endif // _SD_SIMPLE_THEME_HXX


--- /dev/null	2002-08-31 00:31:37.000000000 +0100
+++ sd/source/filter/html/htmltheme.cxx	2003-08-18 13:34:43.000000000 +0100
@@ -0,0 +1,256 @@
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
+#include <com/sun/star/beans/PropertyValue.hpp>
+#endif
+#ifndef _UNTOOLS_UCBSTREAMHELPER_HXX 
+#include <unotools/ucbstreamhelper.hxx>
+#endif
+#ifndef _SV_LSTBOX_HXX
+#include <vcl/lstbox.hxx>
+#endif
+#ifndef _FILTER_CONFIG_ITEM_HXX_
+#include <svtools/FilterConfigItem.hxx>
+#endif
+#ifndef _SV_BUTTON_HXX
+#include <vcl/button.hxx>
+#endif
+#ifndef _SV_FIXED_HXX
+#include <vcl/fixed.hxx>
+#endif
+#ifndef _SV_COMBOBOX_HXX
+#include <vcl/combobox.hxx>
+#endif
+#ifndef _SVEDIT_HXX
+#include <svtools/svmedit.hxx>
+#endif
+#ifndef _SFXINTITEM_HXX
+#include <svtools/intitem.hxx>
+#endif
+#ifndef _AEITEM_HXX
+#include <svtools/aeitem.hxx>
+#endif
+#ifndef _SFXITEMSET_HXX
+#include <svtools/itemset.hxx>
+#endif
+#ifndef _SFXSTRITEM_HXX
+#include <svtools/stritem.hxx>
+#endif
+#ifndef _SV_MSGBOX_HXX
+#include <vcl/msgbox.hxx>
+#endif
+#ifndef _VALUESET_HXX
+#include <svtools/valueset.hxx>
+#endif
+#ifndef _GALLERY_HXX_
+#include <svx/gallery.hxx>
+#endif
+#ifndef _SV_GRAPH_HXX
+#include <vcl/graph.hxx>
+#endif
+#ifndef _SFXENUMITEM_HXX
+#include <svtools/eitem.hxx>
+#endif
+#include <svx/impgrf.hxx>
+#ifndef _SV_COLRDLG_HXX
+#include <svtools/colrdlg.hxx>
+#endif
+#ifndef _EEITEMID_HXX
+#include <svx/eeitemid.hxx>
+#endif
+#ifndef _SVX_COLRITEM_HXX
+#include <svx/colritem.hxx>
+#endif
+#ifndef _SVX_ADRITEM_HXX //autogen
+//#include <svx/adritem.hxx>
+#endif
+#ifndef _LIST_HXX
+#include <tools/list.hxx>
+#endif
+#ifndef _SD_SDIOCMPT_HXX
+#include <sdiocmpt.hxx>
+#endif
+#ifndef _SFXDOCFILE_HXX //autogen
+#include <sfx2/docfile.hxx>
+#endif
+#ifndef _SFXAPP_HXX
+#include <sfx2/app.hxx>
+#endif
+#ifndef _PRESENTATION_HXX
+#include <pres.hxx>
+#endif
+#ifndef INCLUDED_SVTOOLS_USEROPTIONS_HXX
+#include <svtools/useroptions.hxx>
+#endif
+#include <svtools/pathoptions.hxx>
+
+#include <stdio.h>
+#include "htmltheme.hxx"
+
+
+// ::std::list< const SwFrm * >::const_iterator aIter = aParents.begin();
+// ::std::list< const SwFrm * >::const_iterator aEndIter = aParents.end();
+// while( aIter != aEndIter )
+// 
+
+const SdHtmlTheme &
+SdHtmlTheme::getTheme()
+{
+	/* FIXME: could do with some fun locking action */
+	static SdHtmlTheme aTheme;
+
+	return aTheme;
+}
+
+void
+SdHtmlTheme::loadDirectory( String aPath )
+{
+	INetURLObject aURI( aPath );
+
+	aURI.Append( String( RTL_CONSTASCII_USTRINGPARAM( "htmltheme" ) ) );
+
+	SvStream *pIStm = ::utl::UcbStreamHelper::CreateStream
+		( aURI.GetMainURL( INetURLObject::NO_DECODE ), STREAM_READ );
+
+	if( pIStm ) {
+		int nIdx = 0;
+		Theme aTheme;
+
+		while( !pIStm->IsEof() ) {
+			ByteString aLine;
+				
+			if( !pIStm->ReadLine( aLine ) )
+				break;
+
+			aLine.EraseTrailingChars();
+			aLine.EraseLeadingChars();
+
+			if( aLine.Search('#') < STRING_MAXLEN) {
+				/* comment; ignore */
+
+			} else if( aLine.Search(']') < STRING_MAXLEN ) {
+				aTheme.aName = aLine;
+
+			} else if( !aLine.Len() ) {
+				nIdx = 0;
+				if (aTheme.aName.Len()) {
+					int i;
+					for( i = 0; i < nButtonsPerTheme; i++ ) {
+						if( !aTheme.aImages[ i ].IsEmpty() )
+							break;
+					}
+					if( i < nButtonsPerTheme )
+						m_aThemes.push_back( aTheme );
+
+					for( i = 0; i < nButtonsPerTheme; i++)
+						aTheme.aImages[i] = BitmapEx();
+					aTheme.aName = ByteString();
+				}
+
+			} else {
+				String aBmpPath = aPath;
+				aBmpPath += String( RTL_CONSTASCII_USTRINGPARAM( "/" ) );
+				aBmpPath += String( aLine, RTL_TEXTENCODING_UTF8 );
+				INetURLObject aBmpURI( aBmpPath );
+				SvStream *pBmpStm = ::utl::UcbStreamHelper::CreateStream
+					( aBmpURI.GetMainURL( INetURLObject::NO_DECODE ), STREAM_READ );
+
+				GraphicFilter *pGraphicFilter = GetGrfFilter();
+				Graphic aGraphic;
+
+				if( !pGraphicFilter->ImportGraphic( aGraphic, aBmpURI.GetMainURL( INetURLObject::NO_DECODE ),
+								    *pBmpStm, GRFILTER_FORMAT_DONTKNOW, 0 ) ) {
+					if( nIdx < nButtonsPerTheme ) {
+						aTheme.aImages[ nIdx ] = aGraphic.GetBitmapEx();
+						/*							fprintf (stderr, "Icon path '%s': '%s'\n",
+													(const sal_Char *)rtl::OUStringToOString 
+													(aBmpURI.GetMainURL(INetURLObject::NO_DECODE), RTL_TEXTENCODING_UTF8),
+													aTheme.aImages[nIdx].IsEmpty() ? "load failed" : "loaded ok"); */
+					}
+				}
+
+				nIdx++;
+
+				delete pBmpStm;
+			}
+		}
+
+		delete pIStm;
+	}
+}
+
+
+SdHtmlTheme::SdHtmlTheme()
+{
+	String aMultiPath = SvtPathOptions().GetGalleryPath();
+
+	const int nTokenCount = aMultiPath.GetTokenCount( ';' );
+
+	if (nTokenCount <= 0)
+		loadDirectory( aMultiPath );
+	else 
+		for( int i = 0; i < nTokenCount; i++ ) {
+			String aCurURL = aMultiPath.GetToken( i, ';' );
+
+			loadDirectory( aCurURL );
+		}
+}
+
+SdHtmlTheme::~SdHtmlTheme()
+{
+}
+
+int
+SdHtmlTheme::getThemeCount() const
+{
+	return m_aThemes.size();
+}
+
+Bitmap
+SdHtmlTheme::getThumbnail( int nThemeId ) const
+{
+	USHORT nItem = 1;
+	Size aSize( (8*40) - 8, 32 );
+	Point aOrigin( 0,0 );
+	Size aDestSize( 32, 32 );
+
+	VirtualDevice aVDev;
+	aVDev.SetMapMode(MapMode(MAP_PIXEL));
+	aVDev.SetOutputSizePixel( aSize );
+
+	static int nPreviewBitmapOffsets[] = { 1,3,5,7,8,9,10,11 };
+
+	for( int nImage = 0; nImage < 8; nImage++ )
+	{
+		BitmapEx aBitmap;
+
+		if( getBitmap( nThemeId, nPreviewBitmapOffsets[ nImage ], aBitmap ) )
+			continue;
+		
+		Point aDestPt( nImage * 40, 0 );
+		aVDev.DrawBitmapEx( aDestPt, aDestSize, aBitmap );
+	}
+
+	Bitmap aBitmap( aVDev.GetBitmap( aOrigin, aSize ) );
+	
+	return aBitmap;
+}
+
+long
+SdHtmlTheme::getBitmap( int nThemeId, int nImage, BitmapEx &rBitmap ) const
+{
+	::std::list< Theme >::const_iterator aIter = m_aThemes.begin();
+
+	while (nThemeId-- > 0)
+		aIter++;
+
+	if( aIter == m_aThemes.end() ) {
+		fprintf( stderr, "Overrun end ...\n");
+		rBitmap = BitmapEx();
+
+	} else if( nImage < 0  || nImage >= nButtonsPerTheme )
+		rBitmap = BitmapEx();
+
+	else
+		rBitmap = (*aIter).aImages [nImage];
+
+	return rBitmap.IsEmpty();
+}
