/*************************************************************************
 *
 *  $RCSfile: msocximp.cxx,v $
 *
 *  $Revision: 1.1.1.1 $
 *
 *  last change: $Author: hr $ $Date: 2000/09/18 17:14:58 $
 *
 *  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): _______________________________________
 *
 *
 ************************************************************************/

#ifdef PCH
#include "filt_pch.hxx"
#endif

#pragma hdrstop

#ifndef _UNOCOLL_HXX
#include <unoobj.hxx>
#endif
#ifndef _COM_SUN_STAR_UNO_ANY_H_
#include <com/sun/star/uno/Any.h>
#endif
#ifndef _COM_SUN_STAR_TEXT_VERTORIENTATION_HPP_
#include <com/sun/star/text/VertOrientation.hpp>
#endif
#ifndef _COM_SUN_STAR_TEXT_XTEXT_HPP_
#include <com/sun/star/text/XText.hpp>
#endif
#ifndef _COM_SUN_STAR_TEXT_XTEXTRANGE_HPP_
#include <com/sun/star/text/XTextRange.hpp>
#endif
#ifndef _COM_SUN_STAR_TEXT_TEXTCONTENTANCHORTYPE_HPP_
#include <com/sun/star/text/TextContentAnchorType.hpp>
#endif
#ifndef _COM_SUN_STAR_DRAWING_XCONTROLSHAPE_HPP_
#include <com/sun/star/drawing/XControlShape.hpp>
#endif
#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
#include <com/sun/star/beans/XPropertySet.hpp>
#endif
#ifndef _COM_SUN_STAR_DRAWING_XDRAWPAGE_HPP_
#include <com/sun/star/drawing/XDrawPage.hpp>
#endif
#ifndef _COM_SUN_STAR_DRAWING_XSHAPES_HPP_
#include <com/sun/star/drawing/XShapes.hpp>
#endif
#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#endif
#ifndef _COM_SUN_STAR_CONTAINER_XINDEXCONTAINER_HPP_
#include <com/sun/star/container/XIndexContainer.hpp>
#endif
#ifndef _COM_SUN_STAR_DRAWING_XDRAWPAGESUPPLIER_HPP_
#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
#endif
#ifndef _COM_SUN_STAR_FORM_XFORMSSUPPLIER_HPP_
#include <com/sun/star/form/XFormsSupplier.hpp>
#endif
#ifndef _COM_SUN_STAR_FORM_XFORM_HPP_
#include <com/sun/star/form/XForm.hpp>
#endif
#ifndef _CPPUHELPER_EXTRACT_HXX_
#include <cppuhelper/extract.hxx>
#endif
#ifndef _SVDOOLE2_HXX 
#include <svx/svdoole2.hxx>
#endif
#ifndef _MSDFFIMP_HXX
#include <svx/msdffimp.hxx>
#endif
#ifndef _GLOBNAME_HXX
#include <tools/globname.hxx>
#endif
#ifndef _DOCSH_HXX
#include <docsh.hxx>
#endif
#ifndef _MSOCXIMP_HXX
#include <msocximp.hxx>
#endif

using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::awt;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::drawing;
using namespace ::com::sun::star::form;
using namespace ::com::sun::star::text;
using namespace ::com::sun::star::container;
using namespace cppu;


#define WW8_ASCII2STR(s) String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(s))


static char sWW8_form[] = "WW-Standard";


sal_uInt32 OCX_Control::pColor[25] = {
0xC0C0C0, 0x008080, 0x000080, 0x808080, 0xC0C0C0, 0xFFFFFF, 0x000000,
0x000000, 0x000000, 0xFFFFFF, 0xC0C0C0, 0xC0C0C0, 0x808080, 0x000080,
0xFFFFFF, 0xC0C0C0, 0x808080, 0x808080, 0x000000, 0xC0C0C0, 0xFFFFFF,
0x000000, 0xC0C0C0, 0x000000, 0xFFFFC0 };

static const int NO_OCX=8;

void Align(SvStorageStream *pS,int nAmount)
{
	if (pS->Tell()%nAmount)
		pS->SeekRel(nAmount-(pS->Tell()%nAmount));
}

sal_uInt16 OCX_Control::nStandardId(0x0200);

sal_uInt32 OCX_Control::ConvertColor(sal_uInt32 nColor) const
{
	sal_uInt8 nUpper = (sal_uInt8)( nColor >> 24 );
	if (nUpper & 0x80) //Palette color, should be switch on bottom 24 bits
	{
		/*Might as well use my systems ones in the absence of any other ideas*/
		nColor = nColor&0x00FFFFFF;
		ASSERT (nColor <= 24,"Unknown Palette Index");
		if (nColor > 24)
			nColor = 0xFFFFFF;
		else
			nColor = pColor[nColor];
	}
	else
	{
		//Stored in bgr! rather than rgb
		sal_uInt8 r(nColor&0xFF),g(((nColor)>>8)&0xFF),b((nColor>>16)&0xFF);
		nColor = (r<<16) + (g<<8) + b;
	}
	return nColor;
}

sal_Int16 OCX_Control::ConvertBorder(sal_uInt16 nSpecialEffect,
		sal_uInt16 nBorderStyle) const
{
	if ((nSpecialEffect == 0) && (nBorderStyle == 0))
		return 0;	//No Border
	else if ((nSpecialEffect == 0) && (nBorderStyle == 1))
		return 2;	//Flat Border
	return 1;	//3D Border
}

const Reference< XDrawPage > & SwImportOCX::GetDrawPage()
{
	if( !xDrawPage.is() && pDocSh )
	{
		Reference< XDrawPageSupplier >  xTxtDoc( pDocSh->GetModel(), UNO_QUERY );
		ASSERT( xTxtDoc.is(), "XDrawPageSupplier nicht vom XModel erhalten" );
		xDrawPage = xTxtDoc->getDrawPage();
		ASSERT( xDrawPage.is(), "XDrawPage nicht erhalten" );
	}

	return xDrawPage;
}


const Reference< XMultiServiceFactory > & SwImportOCX::GetServiceFactory()
{
	if( !xServiceFactory.is() && pDocSh )
	{
		xServiceFactory = Reference<XMultiServiceFactory>(pDocSh->GetBaseModel(), UNO_QUERY);
		//pDocSh->GetModel()->queryInterface( ::getCppuType((const Reference< XMultiServiceFactory >*)0), xServiceFactory );
		ASSERT( xServiceFactory.is(),
				"XMultiServiceFactory nicht vom Model erhalten" );
	}

	return xServiceFactory;
}

const Reference< XShapes > & SwImportOCX::GetShapes()
{
	if( !xShapes.is() )
	{
		GetDrawPage();
		if( xDrawPage.is() )
		{

			xShapes = Reference<XShapes>(xDrawPage, UNO_QUERY);
// automatisch auskommentiert - [getIdlClass(es) or queryInterface] - Bitte XTypeProvider benutzen!
			//xDrawPage->queryInterface( ::getCppuType((const Reference< XShapes >*)0), xShapes );

			ASSERT( xShapes.is(),
					"XShapes nicht vom XDrawPage erhalten" );
		}
	}
	return xShapes;
}

const Reference< XIndexContainer > & SwImportOCX::GetFormComps()
{
	if( !xFormComps.is() )
	{
		GetDrawPage();
		if( xDrawPage.is() )
		{
			Reference< XFormsSupplier >  xFormsSupplier( xDrawPage, UNO_QUERY );
			ASSERT( xFormsSupplier.is(),
					"XFormsSupplier nicht vom XDrawPage erhalten" );

			Reference< XNameContainer >  xNameCont = xFormsSupplier->getForms();

			// Das Formular bekommt einen Namen wie "WW-Standard[n]" und
			// wird in jedem Fall neu angelegt.
			UniString sName( sWW8_form, RTL_TEXTENCODING_ASCII_US );
			sal_uInt16 n = 0;

			while( xNameCont->hasByName( sName ) )
			{
				sName.AssignAscii( sWW8_form );
				sName += String::CreateFromInt32( ++n );
			}

			const Reference< XMultiServiceFactory > & rServiceFactory =
				GetServiceFactory();
			if( !rServiceFactory.is() )
				return xFormComps;

			Reference< XInterface >  xCreate = rServiceFactory
				->createInstance( WW8_ASCII2STR("com.sun.star.form.component.Form") );
			if( xCreate.is() )
			{
				Reference< XPropertySet >  xFormPropSet( xCreate, UNO_QUERY );

				//Any aTmp( sName.GetStr() );
				Any aTmp(&sName,getCppuType((rtl::OUString *)0));
				xFormPropSet->setPropertyValue( WW8_ASCII2STR("Name"), aTmp );

				Reference< XForm >  xForm( xCreate, UNO_QUERY );
				DBG_ASSERT(xForm.is(), "keine Form?")

				Reference< XIndexContainer > 	xForms( xNameCont, UNO_QUERY );
				ASSERT( xForms.is(), "XForms nicht erhalten" );

				aTmp.setValue( &xForm, ::getCppuType((Reference < XForm >*)0));
				xForms->insertByIndex( xForms->getCount(), aTmp );

// automatisch auskommentiert - [getIdlClass(es) or queryInterface] - Bitte XTypeProvider benutzen!
				//xCreate->queryInterface( ::getCppuType((const Reference< XIndexContainer >*)0), xFormComps );
				xFormComps = Reference<XIndexContainer>(xCreate, UNO_QUERY);
			}
		}
	}

	return xFormComps;
}

Reference< XShape >  SwImportOCX::InsertControl(
	const Reference< XFormComponent > & rFComp, 
	const ::com::sun::star::awt::Size& rSize,
	//const com::sun::star::awt::Size& rSize,
	BOOL bFloatingCtrl)
{
	Reference< XShape >  xShape;

	const Reference< XIndexContainer > & rFormComps = GetFormComps();
	Any aTmp( &rFComp, ::getCppuType((const Reference< XFormComponent >*)0) );
	rFormComps->insertByIndex( rFormComps->getCount(), aTmp );

	const Reference< XMultiServiceFactory > & rServiceFactory =
		GetServiceFactory();
	if( !rServiceFactory.is() )
		return xShape;

	Reference< XInterface >  xCreate = rServiceFactory
		->createInstance(WW8_ASCII2STR("com.sun.star.drawing.ControlShape"));
	if( !xCreate.is() )
		return xShape;

// automatisch auskommentiert - [getIdlClass(es) or queryInterface] - Bitte XTypeProvider benutzen!
	//xCreate->queryInterface( ::getCppuType((const Reference< XShape >*)0), xShape );
	xShape = Reference<XShape>(xCreate, UNO_QUERY);

	DBG_ASSERT(xShape.is(), "XShape nicht erhalten")
	xShape->setSize(rSize);

	Reference< XPropertySet >  xShapePropSet( xCreate, UNO_QUERY );

	//I lay a small bet that this will change soon to
	//INT16 nTemp=TextContentAnchorType::AS_CHARACTER;
	INT16 nTemp;
	if (bFloatingCtrl)
		nTemp=TextContentAnchorType_AT_PARAGRAPH;
	else
		nTemp=TextContentAnchorType_AS_CHARACTER;

	aTmp <<= nTemp;
	xShapePropSet->setPropertyValue( WW8_ASCII2STR("AnchorType"), aTmp );

	nTemp=VertOrientation::TOP;
	//nTemp=VertOrientation_TOP;
	aTmp <<= nTemp;
	xShapePropSet->setPropertyValue( WW8_ASCII2STR("VertOrient"), aTmp );

	Reference< XText >  xDummyTxtRef; // unsauber, aber laut OS geht das ...
	Reference< XTextRange >  xTxtRg = new SwXTextRange( *pPaM, xDummyTxtRef );

	aTmp.setValue( &xTxtRg, ::getCppuType((Reference < XTextRange >*)0) );
	xShapePropSet->setPropertyValue( WW8_ASCII2STR("TextRange"), aTmp );

	GetShapes()->add( xShape );

	// Das Control-Model am Control-Shape setzen
	Reference< XControlShape >  xControlShape( xShape, UNO_QUERY );
	Reference< XControlModel >  xControlModel( rFComp, UNO_QUERY );
	xControlShape->setControl( xControlModel );

	return xShape;
}

sal_Bool OCX_CommandButton::Convert(const Reference< XMultiServiceFactory >  &rServiceFactory,
		Reference< XFormComponent >  &rFComp,com::sun::star::awt::Size &rSz)
{
	rtl::OUString sServiceName = WW8_ASCII2STR("com.sun.star.form.component.CommandButton");
	Reference< XInterface >  xCreate = rServiceFactory->createInstance( sServiceName );
	if( !xCreate.is() )
		return sal_False;

	rFComp = Reference< XFormComponent > (xCreate,UNO_QUERY);
	if( !rFComp.is() )
		return sal_False;

	Reference< XPropertySet >  xPropSet( xCreate, UNO_QUERY );

	rSz.Width = nWidth;
	rSz.Height = nHeight;
	
	//Any aTmp( sName.GetStr() );
	Any aTmp(&sName,getCppuType((rtl::OUString *)0));
	xPropSet->setPropertyValue( WW8_ASCII2STR("Name"), aTmp );

	aTmp <<= ConvertColor(nForeColor);
	xPropSet->setPropertyValue( WW8_ASCII2STR("TextColor"), aTmp);

	aTmp <<= ConvertColor(nBackColor);
	xPropSet->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp);
	
	sal_Bool bTemp;
	if ((!(fEnabled)) || (fLocked))
		bTemp = sal_False;
	else
		bTemp = sal_True;
	aTmp = bool2any(bTemp);

	xPropSet->setPropertyValue( WW8_ASCII2STR("Enabled"), aTmp);

	if (pCaption)
	{
		UniString sTmp(pCaption,RTL_TEXTENCODING_ASCII_US);
		rtl::OUString sStr = sTmp;
		aTmp.setValue(&sStr,getCppuType((rtl::OUString *)0));
		//aTmp.setString( sTmp.GetStr() );
		xPropSet->setPropertyValue( WW8_ASCII2STR("Label"), aTmp);
	}

	aFontData.Convert(xPropSet);
	return sal_True;
}

sal_Bool OCX_OptionButton::Convert(const Reference< XMultiServiceFactory >  &rServiceFactory,
		Reference< XFormComponent >  &rFComp,com::sun::star::awt::Size &rSz)
{

	rtl::OUString sServiceName = WW8_ASCII2STR("com.sun.star.form.component.RadioButton");
	Reference< XInterface >  xCreate = rServiceFactory->createInstance( sServiceName );
	if( !xCreate.is() )
		return sal_False;

	rFComp = Reference< XFormComponent > (xCreate,UNO_QUERY);
	if( !rFComp.is() )
		return sal_False;

	Reference< XPropertySet >  xPropSet( xCreate, UNO_QUERY );

	rSz.Width = nWidth;
	rSz.Height = nHeight;
	
	//Any aTmp( sName.GetStr() );
	Any aTmp(&sName,getCppuType((rtl::OUString *)0));
	xPropSet->setPropertyValue( WW8_ASCII2STR("Name"), aTmp );

	sal_Bool bTemp;
	if ((!(fEnabled)) || (fLocked))
		bTemp = sal_False;
	else
		bTemp = sal_True;
	aTmp = bool2any(bTemp);
	xPropSet->setPropertyValue( WW8_ASCII2STR("Enabled"), aTmp);

	aTmp <<= ConvertColor(nForeColor);
	xPropSet->setPropertyValue( WW8_ASCII2STR("TextColor"), aTmp);

	if (pValue)
	{
		INT16 nTmp = pValue[0]-0x30;
		aTmp <<= nTmp;
		xPropSet->setPropertyValue( WW8_ASCII2STR("DefaultState"), aTmp);
	}

	if (pCaption)
	{
		UniString sTmp(pCaption,RTL_TEXTENCODING_ASCII_US);
		//aTmp.setString( sTmp.GetStr() );
		rtl::OUString sStr = sTmp;
		aTmp.setValue(&sStr,getCppuType((rtl::OUString *)0));
		xPropSet->setPropertyValue( WW8_ASCII2STR("Label"), aTmp);
	}

	aFontData.Convert(xPropSet);
	return sal_True;
}

sal_Bool OCX_TextBox::Convert(const Reference< XMultiServiceFactory >  &rServiceFactory,
		Reference< XFormComponent >  &rFComp,com::sun::star::awt::Size &rSz)
{
	rtl::OUString sServiceName = WW8_ASCII2STR("com.sun.star.form.component.TextField");
	Reference< XInterface >  xCreate = rServiceFactory->createInstance( sServiceName );
	if( !xCreate.is() )
		return sal_False;

	rFComp = Reference< XFormComponent > (xCreate,UNO_QUERY);
	if( !rFComp.is() )
		return sal_False;

	Reference< XPropertySet >  xPropSet( xCreate, UNO_QUERY );

	rSz.Width = nWidth;
	rSz.Height = nHeight;
	
	//Any aTmp( sName.GetStr() );
	Any aTmp(&sName,getCppuType((rtl::OUString *)0));
	xPropSet->setPropertyValue( WW8_ASCII2STR("Name"), aTmp );

	sal_Bool bTemp;
	if ((!(fEnabled)) || (fLocked))
		bTemp = sal_False;
	else
		bTemp = sal_True;
	aTmp = bool2any(bTemp);
	xPropSet->setPropertyValue( WW8_ASCII2STR("Enabled"), aTmp);

	aTmp <<= ConvertColor(nForeColor);
	xPropSet->setPropertyValue( WW8_ASCII2STR("TextColor"), aTmp);

	aTmp <<= ConvertColor(nBackColor);
	xPropSet->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp);

	sal_Bool bTmp=fMultiLine;
	aTmp = bool2any(bTmp);
	xPropSet->setPropertyValue( WW8_ASCII2STR("MultiLine"), aTmp);

	INT16 nTmp = nMaxLength;
	aTmp <<= nTmp;
	xPropSet->setPropertyValue( WW8_ASCII2STR("MaxTextLen"), aTmp);


	sal_Bool bTemp1,bTemp2;
	Any aBarsH,aBarsV;
	switch(nScrollBars)
	{
		case 1:
			bTemp1 = sal_True;
			bTemp2 = sal_False;
			break;
		case 2:
			bTemp1 = sal_False;
			bTemp2 = sal_True;
			break;
		case 3:
			bTemp1 = sal_True;
			bTemp2 = sal_True;
			break;
		case 0:
		default:
			bTemp1 = sal_False;
			bTemp2 = sal_False;
			break;
	}

	aBarsH = bool2any(bTemp1);
	aBarsV = bool2any(bTemp2);
	xPropSet->setPropertyValue( WW8_ASCII2STR("HScroll"), aBarsH);
	xPropSet->setPropertyValue( WW8_ASCII2STR("VScroll"), aBarsV);

	nTmp = nPasswordChar;
	aTmp <<= nTmp;
	xPropSet->setPropertyValue( WW8_ASCII2STR("EchoChar"), aTmp);


	aTmp <<= ConvertBorder(nSpecialEffect,nBorderStyle);
	xPropSet->setPropertyValue( WW8_ASCII2STR("Border"), aTmp);


	if (pCaption)
	{
		UniString sTmp(pCaption,RTL_TEXTENCODING_ASCII_US);
		//aTmp.setString( sTmp.GetStr() );
		rtl::OUString sStr = sTmp;
		aTmp.setValue(&sStr,getCppuType((rtl::OUString *)0));
		xPropSet->setPropertyValue( WW8_ASCII2STR("DefaultText"), aTmp);
	}

	aFontData.Convert(xPropSet);
	return sal_True;
}

sal_Bool OCX_ToggleButton::Convert(const Reference< XMultiServiceFactory >  &rServiceFactory,
		Reference< XFormComponent >  &rFComp,com::sun::star::awt::Size &rSz)
{

	rtl::OUString sServiceName = WW8_ASCII2STR("com.sun.star.form.component.CheckBox");
	Reference< XInterface >  xCreate = rServiceFactory->createInstance( sServiceName );
	if( !xCreate.is() )
		return sal_False;

	rFComp = Reference< XFormComponent > (xCreate,UNO_QUERY);
	if( !rFComp.is() )
		return sal_False;

	Reference< XPropertySet >  xPropSet( xCreate, UNO_QUERY );

	rSz.Width = nWidth;
	rSz.Height = nHeight;
	
	//Any aTmp( sName.GetStr() );
	Any aTmp(&sName,getCppuType((rtl::OUString *)0));
	xPropSet->setPropertyValue( WW8_ASCII2STR("Name"), aTmp );

	sal_Bool bTemp;
	if ((!(fEnabled)) || (fLocked))
		bTemp = sal_False;
	else
		bTemp = sal_True;
	aTmp = bool2any(bTemp);
	xPropSet->setPropertyValue( WW8_ASCII2STR("Enabled"), aTmp);

	aTmp <<= ConvertColor(nForeColor);
	xPropSet->setPropertyValue( WW8_ASCII2STR("TextColor"), aTmp);

	if (pValue)
	{
		INT16 nTmp=pValue[0]-0x30;
		aTmp <<= nTmp;
		xPropSet->setPropertyValue( WW8_ASCII2STR("DefaultState"), aTmp);
	}

	if (pCaption)
	{
		UniString sTmp(pCaption,RTL_TEXTENCODING_ASCII_US);
		//aTmp.setString( sTmp.GetStr() );
		rtl::OUString sStr = sTmp;
		aTmp.setValue(&sStr,getCppuType((rtl::OUString *)0));
		xPropSet->setPropertyValue( WW8_ASCII2STR("Label"), aTmp);
	}

	aFontData.Convert(xPropSet);
	return sal_True;
}

sal_Bool OCX_Label::Convert(const Reference< XMultiServiceFactory >  &rServiceFactory,
		Reference< XFormComponent >  &rFComp,com::sun::star::awt::Size &rSz)
{

	rtl::OUString sServiceName = WW8_ASCII2STR("com.sun.star.form.component.FixedText");
	Reference< XInterface >  xCreate = rServiceFactory->createInstance( sServiceName );
	if( !xCreate.is() )
		return sal_False;

	rFComp = Reference< XFormComponent > (xCreate,UNO_QUERY);
	if( !rFComp.is() )
		return sal_False;

	Reference< XPropertySet >  xPropSet( xCreate, UNO_QUERY );

	rSz.Width = nWidth;
	rSz.Height = nHeight;
	
	//Any aTmp( sName.GetStr() );
	Any aTmp(&sName,getCppuType((rtl::OUString *)0));
	xPropSet->setPropertyValue( WW8_ASCII2STR("Name"), aTmp );

	sal_Bool bTemp;
	if ((!(fEnabled)) || (fLocked))
		bTemp = sal_False;
	else
		bTemp = sal_True;
	aTmp = bool2any(bTemp);
	xPropSet->setPropertyValue( WW8_ASCII2STR("Enabled"), aTmp);

	aTmp <<= ConvertColor(nForeColor);
	xPropSet->setPropertyValue( WW8_ASCII2STR("TextColor"), aTmp);

	aTmp <<= ConvertBorder(nSpecialEffect,nBorderStyle);
	xPropSet->setPropertyValue( WW8_ASCII2STR("Border"), aTmp);

	if (pCaption)
	{
		UniString sTmp(pCaption,RTL_TEXTENCODING_ASCII_US);
		//aTmp.setString( sTmp.GetStr() );
		rtl::OUString sStr = sTmp;
		aTmp.setValue(&sStr,getCppuType((rtl::OUString *)0));
		xPropSet->setPropertyValue( WW8_ASCII2STR("Label"), aTmp);
	}

	aFontData.Convert(xPropSet);
	return sal_True;
}

sal_Bool OCX_ComboBox::Convert(const Reference< XMultiServiceFactory >  &rServiceFactory,
		Reference< XFormComponent >  &rFComp,com::sun::star::awt::Size &rSz)
{

	rtl::OUString sServiceName = WW8_ASCII2STR("com.sun.star.form.component.ComboBox");
	Reference< XInterface >  xCreate = rServiceFactory->createInstance( sServiceName );
	if( !xCreate.is() )
		return sal_False;

	rFComp = Reference< XFormComponent > (xCreate,UNO_QUERY);
	if( !rFComp.is() )
		return sal_False;

	Reference< XPropertySet >  xPropSet( xCreate, UNO_QUERY );

	rSz.Width = nWidth;
	rSz.Height = nHeight;
	
	//Any aTmp( sName.GetStr() );
	Any aTmp(&sName,getCppuType((rtl::OUString *)0));
	xPropSet->setPropertyValue( WW8_ASCII2STR("Name"), aTmp );

	sal_Bool bTmp=fEnabled;
	aTmp = bool2any(bTmp);
	xPropSet->setPropertyValue( WW8_ASCII2STR("Enabled"), aTmp);

	bTmp=fLocked;
	aTmp = bool2any(bTmp);
	xPropSet->setPropertyValue( WW8_ASCII2STR("ReadOnly"), aTmp);

	bTmp=sal_True;
	aTmp = bool2any(bTmp);
	xPropSet->setPropertyValue( WW8_ASCII2STR("Dropdown"), aTmp);

	aTmp <<= ConvertColor(nForeColor);
	xPropSet->setPropertyValue( WW8_ASCII2STR("TextColor"), aTmp);

	if (pValue)
		{
			UniString sTmp(pValue,RTL_TEXTENCODING_ASCII_US);
			//aTmp.setString( sTmp.GetStr() );
			rtl::OUString sStr = sTmp;
			aTmp.setValue(&sStr,getCppuType((rtl::OUString *)0));
			xPropSet->setPropertyValue( WW8_ASCII2STR("DefaultText"), aTmp);
		}

	aTmp <<= ConvertColor(nBackColor);
	xPropSet->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp);

	aTmp <<= ConvertBorder(nSpecialEffect,nBorderStyle);
	xPropSet->setPropertyValue( WW8_ASCII2STR("Border"), aTmp);

	INT16 nTmp=nMaxLength;
	aTmp <<= nTmp;
	xPropSet->setPropertyValue( WW8_ASCII2STR("MaxTextLen"), aTmp);

	aFontData.Convert(xPropSet);
	return sal_True;
}


sal_Bool OCX_ListBox::Convert(const Reference< XMultiServiceFactory >  &rServiceFactory,
		Reference< XFormComponent >  &rFComp,com::sun::star::awt::Size &rSz)
{
	rtl::OUString sServiceName = WW8_ASCII2STR("com.sun.star.form.component.ListBox");
	Reference< XInterface >  xCreate = rServiceFactory->createInstance( sServiceName );
	if( !xCreate.is() )
		return sal_False;

	rFComp = Reference< XFormComponent > (xCreate,UNO_QUERY);
	if( !rFComp.is() )
		return sal_False;

	Reference< XPropertySet >  xPropSet( xCreate, UNO_QUERY );

	rSz.Width = nWidth;
	rSz.Height = nHeight;
	
	//Any aTmp( sName.GetStr() );
	Any aTmp(&sName,getCppuType((rtl::OUString *)0));
	xPropSet->setPropertyValue( WW8_ASCII2STR("Name"), aTmp );

	sal_Bool bTmp=fEnabled;
	aTmp = bool2any(bTmp);
	xPropSet->setPropertyValue( WW8_ASCII2STR("Enabled"), aTmp);

	bTmp=fLocked;
	aTmp = bool2any(bTmp);
	xPropSet->setPropertyValue( WW8_ASCII2STR("ReadOnly"), aTmp);

	aTmp <<= ConvertColor(nForeColor);
	xPropSet->setPropertyValue( WW8_ASCII2STR("TextColor"), aTmp);

	if (pValue)
		{
			UniString sTmp(pValue,RTL_TEXTENCODING_ASCII_US);
			//aTmp.setString( sTmp.GetStr() );
			rtl::OUString sStr = sTmp;
			aTmp.setValue(&sStr,getCppuType((rtl::OUString *)0));
			xPropSet->setPropertyValue( WW8_ASCII2STR("DefaultText"), aTmp);
		}

	aTmp <<= ConvertColor(nBackColor);
	xPropSet->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp);

	aTmp <<= ConvertBorder(nSpecialEffect,nBorderStyle);
	xPropSet->setPropertyValue( WW8_ASCII2STR("Border"), aTmp);

	aFontData.Convert(xPropSet);
	return sal_True;
}

sal_Bool OCX_ModernControl::Read(SvStorageStream *pS)
{
	*pS >> nIdentifier;
	ASSERT(nIdentifier==nStandardId, 
			"A control that has a different identifier");
	*pS >> nFixedAreaLen;
	pS->Read(pBlockFlags,8);

	if (pBlockFlags[0] & 0x01)
	{
		sal_uInt8 nTemp;
		*pS >> nTemp;

		fEnabled = (nTemp & 0x02) >> 1;
		fLocked = (nTemp & 0x04) >> 2;
		fBackStyle = (nTemp & 0x02) >> 3;

		*pS >> nTemp;

		fColumnHeads = (nTemp & 0x04) >> 2;
		fIntegralHeight = (nTemp & 0x08) >> 3;
		fMatchRequired = (nTemp & 0x10) >> 4;
		fAlignment = (nTemp & 0x20) >> 5;

		*pS >> nTemp;

		fDragBehaviour = (nTemp & 0x08) >> 3;
		fEnterKeyBehaviour = (nTemp & 0x10) >> 4;
		fEnterFieldBehaviour = (nTemp & 0x20) >> 5;
		fTabKeyBehaviour = (nTemp & 0x40) >> 6;
		fWordWrap = (nTemp & 0x80) >> 7;

		*pS >> nTemp;
		fSelectionMargin = (nTemp & 0x04) >> 2;
		fAutoWordSelect = (nTemp & 0x08) >> 3;
		fAutoSize = (nTemp & 0x10) >> 4;
		fHideSelection = (nTemp & 0x20) >> 5;
		fAutoTab = (nTemp & 0x40) >> 6;
		fMultiLine = (nTemp & 0x80) >> 7;

	}

	/*If any of these are set they follow eachother in this order one after
	another padded out to the next U32 boundary with 0's
	U8 can abut each other U16 must start on a U16 boundary and are padded to 
	that with 0's. A standardish word alignment structure*/

	if (pBlockFlags[0] & 0x02)
		*pS >> nBackColor;
	if (pBlockFlags[0] & 0x04)
		*pS >> nForeColor;
	if (pBlockFlags[0] & 0x08)
		*pS >> nMaxLength;

	if (pBlockFlags[0] & 0x10) 
		*pS >> nBorderStyle;	
	if (pBlockFlags[0] & 0x20) 
		*pS >> nScrollBars;	
	if (pBlockFlags[0] & 0x40)
		*pS >> nStyle;// (UI 0 == Data 3, UI 2 = Data 7)
	if (pBlockFlags[0] & 0x80)
		*pS >> nMousePointer;

	if (pBlockFlags[1] & 0x02)
		*pS >> nPasswordChar; //HUH ??? always 0 ??? not sure maybe just padding

	if (pBlockFlags[1] & 0x04)
	{
		Align(pS,4);
		*pS >> nListWidth;
	}

	if (pBlockFlags[1] & 0x08)
	{
		Align(pS,2);
		*pS >> nBoundColumn;
	}
	if (pBlockFlags[1] & 0x10)
	{
		Align(pS,2);
		*pS >> nTextColumn;
	}
	if (pBlockFlags[1] & 0x20)
	{
		Align(pS,2);
		*pS >> nColumnCount;
	}
	if (pBlockFlags[1] & 0x40)
	{
		Align(pS,2);
		*pS >> nListRows;
	}
	if (pBlockFlags[1] & 0x80)
	{
		Align(pS,2);
		*pS >> nUnknown8; //something to do with ColumnWidths
	}
	if (pBlockFlags[2] & 0x01)
		*pS >> nMatchEntry;
	if (pBlockFlags[2] & 0x02)
		*pS >> nListStyle;
	if (pBlockFlags[2] & 0x04)
		*pS >> nShowDropButtonWhen;
	if (pBlockFlags[2] & 0x10)
		*pS >> nDropButtonStyle;
	if (pBlockFlags[2] & 0x20)
		*pS >> nMultiState;

	if (pBlockFlags[2] & 0x40)
	{
		Align(pS,4);
		*pS >> nValueLen; //bit 0x80000000L set
	}
	if (pBlockFlags[2] & 0x80)
	{
		Align(pS,4);
		*pS >> nCaptionLen; //bit 0x80000000L set
	}
	if (pBlockFlags[3] & 0x01)
	{
		Align(pS,4);
		*pS >> nHorzPos;
		*pS >> nVertPos;
	}
	if (pBlockFlags[3] & 0x02)
	{
		Align(pS,4);
		*pS >> nBorderColor;
	}
	if (pBlockFlags[3] & 0x04)
		*pS >> nSpecialEffect;
	if (pBlockFlags[3] & 0x08)
	{
		Align(pS,2);
		*pS >> nIcon; 
		ASSERT(nIcon == 0xFFFF, "Unexpected nIcon");
	}
	if (pBlockFlags[3] & 0x10)
	{
		Align(pS,2);
		*pS >> nPicture;
		ASSERT(nPicture == 0xFFFF, "Unexpected nIcon");
	}
	if (pBlockFlags[3] & 0x20)
		*pS >> nAccelerator;
	/*
	if (pBlockFlags[3] & 0x80)
		*pS >> nUnknown9; 
	*/
	if (pBlockFlags[4] & 0x01)
	{
		Align(pS,4);
		*pS >> nGroupNameLen; // bit 0x80000000L set 
	}
	//End

	Align(pS,4);
	*pS >> nWidth;
	*pS >> nHeight;

	if (nValueLen)
	{
		nValueLen &= 0x7FFFFFFF;
		pValue= new char[nValueLen+1];
		pS->Read(pValue,nValueLen);
		pValue[nValueLen]=0;
		Align(pS,4);
	}

	if (nCaptionLen)
	{
		nCaptionLen &= 0x7FFFFFFF;
		pCaption = new char[nCaptionLen+1];
		pS->Read(pCaption,nCaptionLen);
		pCaption[nCaptionLen]=0;
		Align(pS,4);
	}

	if (nGroupNameLen)
	{
		nGroupNameLen &= 0x7FFFFFFF;
		pGroupName = new char[nGroupNameLen+1];
		pS->Read(pGroupName,nGroupNameLen);
		pGroupName[nGroupNameLen]=0;
		Align(pS,4);
	}

	if (nIcon)
	{
		pS->Read(pIconHeader,20);
		*pS >> nIconLen;
		pIcon = new sal_uInt8[nIconLen];
		pS->Read(pIcon,nIconLen);
	}

	if (nPicture)
	{
		pS->Read(pPictureHeader,20);
		*pS >> nPictureLen;
		pPicture = new sal_uInt8[nPictureLen];
		pS->Read(pPicture,nPictureLen);
	}

	return sal_True;
}


sal_Bool OCX_CommandButton::Read(SvStorageStream *pS)
{
	*pS >> nIdentifier;
	ASSERT(nStandardId==nIdentifier,
		"A control that has a different identifier");
	*pS >> nFixedAreaLen;
	pS->Read(pBlockFlags,4);


	if (pBlockFlags[0] & 0x01)
		*pS >> nForeColor;
	if (pBlockFlags[0] & 0x02)
		*pS >> nBackColor;

	if (pBlockFlags[0] & 0x04) 
	{
		sal_uInt8 nTemp;
		*pS >> nTemp;
		fEnabled = (nTemp&0x02)>>1;
		fLocked = (nTemp&0x04)>>2;
		fBackStyle = (nTemp&0x08)>>3;
		*pS >> nTemp;
		*pS >> nTemp;
		fWordWrap = (nTemp&0x80)>>7;
		*pS >> nTemp;
		fAutoSize = (nTemp&0x10)>>4;
	}

	if (pBlockFlags[0] & 0x08)
		*pS >> nCaptionLen;

	if (pBlockFlags[0] & 0x10) /*Picture Position, a strange mechanism here*/
	{
		*pS >> nVertPos;
		*pS >> nHorzPos;
	}

	if (pBlockFlags[0] & 0x40) /*MousePointer*/
		*pS >> nMousePointer;

	if (pBlockFlags[0] & 0x80)
	{
		Align(pS,2);
		*pS >> nPicture;
	}

	if (pBlockFlags[1] & 0x01)
	{
		Align(pS,2);
		*pS >> nAccelerator;
	}

	if (pBlockFlags[1] & 0x04)
	{
		Align(pS,2);
		*pS >> nIcon;
	}

	if (nCaptionLen)
	{
		Align(pS,4);
		nCaptionLen &= 0x7FFFFFFF;
		pCaption = new char[nCaptionLen+1];
		pS->Read(pCaption,nCaptionLen);
		pCaption[nCaptionLen]=0;
	}

	Align(pS,4);
	*pS >> nWidth;
	*pS >> nHeight;

	if (nIcon)
	{
		pS->Read(pIconHeader,20);
		*pS >> nIconLen;
		pIcon = new sal_uInt8[nIconLen];
		pS->Read(pIcon,nIconLen);
	}

	if (nPicture)
	{
		pS->Read(pPictureHeader,20);
		*pS >> nPictureLen;
		pPicture = new sal_uInt8[nPictureLen];
		pS->Read(pPicture,nPictureLen);
	}

	return sal_True;
}

sal_Bool OCX_Label::Read(SvStorageStream *pS)
{
	*pS >> nIdentifier;
	ASSERT(nStandardId==nIdentifier, 
			"A control that has a different identifier");
	*pS >> nFixedAreaLen;
	pS->Read(pBlockFlags,4);
	

	if (pBlockFlags[0] & 0x01)
		*pS >> nForeColor;
	if (pBlockFlags[0] & 0x02)
		*pS >> nBackColor;


	if (pBlockFlags[0] & 0x04) 
	{
		sal_uInt8 nTemp;
		*pS >> nTemp;
		fEnabled = (nTemp&0x02)>>1;
		fLocked = (nTemp&0x04)>>2;
		fBackStyle = (nTemp&0x08)>>3;
		*pS >> nTemp;
		*pS >> nTemp;
		fWordWrap = (nTemp&0x80)>>7;
		*pS >> nTemp;
		fAutoSize = (nTemp&0x10)>>4;
	}
	if (pBlockFlags[0] & 0x08)
		*pS >> nCaptionLen;

	if (pBlockFlags[0] & 0x10) 
	{
		*pS >> nVertPos;
		*pS >> nHorzPos;
	}

	if (pBlockFlags[0] & 0x40) 
		*pS >> nMousePointer;

	if (pBlockFlags[0] & 0x80) 
	{
		Align(pS,4);
		*pS >> nBorderColor;
	}

	if (pBlockFlags[1] & 0x01) 
	{
		Align(pS,2);
		*pS >> nBorderStyle;
	}

	if (pBlockFlags[1] & 0x02) 
	{
		Align(pS,2);
		*pS >> nSpecialEffect;
	}

	if (pBlockFlags[1] & 0x04) 
	{
		Align(pS,2);
		*pS >> nPicture;
	}

	if (pBlockFlags[1] & 0x08) 
	{
		Align(pS,2);
		*pS >> nAccelerator;
	}

	if (pBlockFlags[1] & 0x10) 
	{
		Align(pS,2);
		*pS >> nIcon;
	}
	
	if (nCaptionLen)
	{
		Align(pS,4);
		nCaptionLen &= 0x7FFFFFFF;
		pCaption = new char[nCaptionLen+1];
		pS->Read(pCaption,nCaptionLen);
		pCaption[nCaptionLen]=0;
		Align(pS,4);
	}

	*pS >> nWidth;
	*pS >> nHeight;

	if (nIcon)
	{
		pS->Read(pIconHeader,20);
		*pS >> nIconLen;
		pIcon = new sal_uInt8[nIconLen];
		pS->Read(pIcon,nIconLen);
	}

	if (nPicture)
	{
		pS->Read(pPictureHeader,20);
		*pS >> nPictureLen;
		pPicture = new sal_uInt8[nPictureLen];
		pS->Read(pPicture,nPictureLen);
	}

	return sal_True;
}

typedef OCX_Control *(*FNCreate)();


struct OCX_map
{
	FNCreate pCreate;
	const sal_Char *id;
};

OCX_map aOCXTab[NO_OCX] =
{
	{&OCX_CommandButton::Create,"D7053240-CE69-11CD-a777-00dd01143c57"},
	{&OCX_Label::Create, "978C9E23-D4B0-11CE-bf2d-00aa003f40d0"},

	{&OCX_TextBox::Create,"8BD21D10-EC42-11CE-9e0d-00aa006002f3"},
	{&OCX_ListBox::Create,"8BD21D20-EC42-11CE-9e0d-00aa006002f3"},
	{&OCX_ComboBox::Create,"8BD21D30-EC42-11CE-9e0d-00aa006002f3"},
	{&OCX_CheckBox::Create, "8BD21D40-EC42-11CE-9e0d-00aa006002f3"},
	{&OCX_OptionButton::Create,"8BD21D50-EC42-11CE-9e0d-00aa006002f3"},
	{&OCX_ToggleButton::Create,"8BD21D60-EC42-11CE-9e0d-00aa006002f3"}
};


OCX_Control * SwImportOCX::OCX_Factory(const String &sName)
{
	for (int i=0;i<NO_OCX;i++)
	{
		if ( sName.EqualsAscii( aOCXTab[i].id ))
			return(aOCXTab[i].pCreate());
	}
	return(NULL);
}

sal_Bool SwImportOCX::ReadOCXStream( SvStorageRef& rSrc1,
	Reference < XShape > *pShapeRef,BOOL bFloatingCtrl)
{
	Reference < XShape > xRef;
	sal_Bool bRet=sal_False;
	
	SvStorageStreamRef xSrc2 = rSrc1->OpenStream( WW8_ASCII2STR("\3OCXNAME") );
	SvStorageStream* pSt = xSrc2;
	pSt->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
	xSrc2 = rSrc1->OpenStream( WW8_ASCII2STR("contents") );
	pSt = xSrc2;
	pSt->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
	/*Get Class Id of this object, see if it is one of the types
	 *that this importer can handle, call the appropiate handler
	 to read that control, and call the appropiate handler to
	 insert that control
	 */
	//SvGlobalName aClassName(rSrc1->GetClassName());
	OCX_Control *pObj=NULL;
	//if (pObj = LookupName(aClassName.GetHexName()))
	if (pObj = OCX_Factory(rSrc1->GetClassName().GetHexName()))
	{

		com::sun::star::awt::Size aSz;
		Reference< XFormComponent >  xFComp;
		const Reference< XMultiServiceFactory > & rServiceFactory =
			GetServiceFactory();
		if(!rServiceFactory.is())
			return(sal_False);
		if(bRet = pObj->Read(pSt))
			if (pObj->Convert(rServiceFactory,xFComp,aSz))
			{
				xRef = InsertControl( xFComp, aSz,bFloatingCtrl );
				if (pShapeRef)
					*pShapeRef = xRef;
			}
		delete pObj;
	}
	return bRet;
}



sal_Bool OCX_CheckBox::Convert(const Reference< XMultiServiceFactory >  &rServiceFactory,
		Reference< XFormComponent >  &rFComp,com::sun::star::awt::Size &rSz)
{
	rtl::OUString sServiceName = WW8_ASCII2STR("com.sun.star.form.component.CheckBox");
	Reference< XInterface >  xCreate = rServiceFactory->createInstance( sServiceName );
	if( !xCreate.is() )
		return(sal_False);

	rFComp = Reference< XFormComponent > (xCreate,UNO_QUERY);
	if( !rFComp.is() )
		return(sal_False);

	Reference< XPropertySet >  xPropSet( xCreate, UNO_QUERY );

	rSz.Width = nWidth;
	rSz.Height = nHeight;
	
	//Any aTmp( sName.GetStr() );
	Any aTmp(&sName,getCppuType((rtl::OUString *)0));
	xPropSet->setPropertyValue( WW8_ASCII2STR("Name"), aTmp );

	sal_Bool bTemp;
	if ((!(fEnabled)) || (fLocked))
		bTemp = sal_False;
	else
		bTemp = sal_True;
	aTmp = bool2any(bTemp);
	xPropSet->setPropertyValue( WW8_ASCII2STR("Enabled"), aTmp);

	aTmp <<= ConvertColor(nForeColor);
	xPropSet->setPropertyValue( WW8_ASCII2STR("TextColor"), aTmp);

	bTemp = nMultiState;
	aTmp = bool2any(bTemp);
	xPropSet->setPropertyValue( WW8_ASCII2STR("TriState"), aTmp);

	if (pValue)
	{
		INT16 nTmp=pValue[0]-0x30;
		aTmp <<= nTmp;
		xPropSet->setPropertyValue( WW8_ASCII2STR("DefaultState"), aTmp);
	}

	if (pCaption)
	{
		UniString sTmp(pCaption,RTL_TEXTENCODING_ASCII_US);
		//aTmp.setString( sTmp.GetStr() );
		rtl::OUString sStr = sTmp;
		aTmp.setValue(&sStr,getCppuType((rtl::OUString *)0));
		xPropSet->setPropertyValue( WW8_ASCII2STR("Label"), aTmp);
	}

	aFontData.Convert(xPropSet);
	return(sal_True);
}

sal_Bool OCX_FontData::Read(SvStorageStream *pS)
{
	*pS >> nIdentifier;
	*pS >> nFixedAreaLen;
	pS->Read(pBlockFlags,4);

	if (pBlockFlags[0] & 0x01)
		*pS >> nFontNameLen;
	if (pBlockFlags[0] & 0x02)
	{
		sal_uInt8 nTmp;
		*pS >> nTmp;
		fBold = nTmp & 0x01;
		fItalic = (nTmp & 0x02) >> 1;
		fUnderline = (nTmp & 0x04) >> 2;
		fStrike = (nTmp & 0x08) >> 3;
		fUnknown1 = (nTmp & 0xF0) >> 4;
		*pS >> nUnknown2;
		*pS >> nUnknown3;
		*pS >> nUnknown4;
	}
	if (pBlockFlags[0] & 0x04)
	{
		Align(pS,4);
		*pS >> nFontSize;
	}
	if (pBlockFlags[0] & 0x10)
	{
		Align(pS,2);
		*pS >> nLanguageID;
	}
	if (pBlockFlags[0] & 0x40)
		*pS >> nJustification;

	/*
	nFontNameLen &= 0x7FFFFFFF;

	UINT32 nCount = nFontNameLen;
	if (nFontNameLen%4)	
		nCount += (4-nFontNameLen%4);
	pS->SeekRel(nFixedAreaLen-8-nCount);
	*/

	if (nFontNameLen)
	{
		Align(pS,4);
		nFontNameLen &= 0x7FFFFFFF;
		pFontName = new char[nFontNameLen+1];
		pS->Read(pFontName,nFontNameLen);
		pFontName[nFontNameLen]=0;
	}

	return(TRUE);
}

void OCX_FontData::Convert(Reference< XPropertySet > &rPropSet)
{
	Any aTmp;
	if (pFontName)
	{
		UniString sTmp(pFontName,RTL_TEXTENCODING_ASCII_US);
		//aTmp.setString( sTmp.GetStr() );
		rtl::OUString sStr = sTmp;
		aTmp.setValue(&sStr,getCppuType((rtl::OUString *)0));
		rPropSet->setPropertyValue( WW8_ASCII2STR("FontName"), aTmp);
	}

	if (fBold)
	{
		float nBold=150;
		aTmp.setValue(&nBold,getCppuType((float *)0));
		rPropSet->setPropertyValue( WW8_ASCII2STR("FontWeight"), aTmp);
	}
}

/*************************************************************************
 
 Source Code Control System - Header
 
 $Header: /cvs/oo/sw/sw/source/filter/ww8/Attic/msocximp.cxx,v 1.1.1.1 2000/09/18 17:14:58 hr Exp $
 

 Source Code Control System - Update
 
 $Log: msocximp.cxx,v $
 Revision 1.1.1.1  2000/09/18 17:14:58  hr
 initial import

 Revision 1.11  2000/09/18 16:04:57  willem.vandorp
 OpenOffice header added.

 Revision 1.10  2000/06/15 15:23:38  cmc
 #75669# 97Controls Import fixes

 Revision 1.9  2000/05/22 08:52:09  khz
 Unicode code-conversion: use rtl::OUString instead of UString

 Revision 1.8  2000/05/16 11:07:55  khz
 Unicode code-conversion

 Revision 1.7  2000/05/12 10:48:20  cmc
 #75358# Branch Commited as Main error fix

 Revision 1.5  2000/04/10 14:00:33  cmc
 #74329# uno3 for WW97 Controls Import

 Revision 1.4  2000/04/04 15:02:39  khz
 UNO changes

 Revision 1.3  2000/03/27 15:35:00  cmc
 #74329# Ported WW97 Controls to uno codebase


*************************************************************************/
