Index: forms/source/component/FormComponent.cxx =================================================================== --- forms/source/component/FormComponent.cxx (revision 1387468) +++ forms/source/component/FormComponent.cxx (working copy) @@ -595,6 +595,8 @@ ,m_nTabIndex(FRM_DEFAULT_TABINDEX) ,m_nClassId(FormComponentType::CONTROL) ,m_bNativeLook( sal_False ) + ,m_nControlTypeinMSO(0) // 0 : default value is create from AOO + ,m_nObjIDinMSO(INVALID_OBJ_ID_IN_MSO) // form controls are usually embedded into documents, not dialogs, and in documents // the native look is ugly .... // #i37342# / 2004-11-19 / frank.schoenheit@sun.com @@ -649,6 +651,8 @@ m_nTabIndex = _pOriginal->m_nTabIndex; m_nClassId = _pOriginal->m_nClassId; m_bNativeLook = _pOriginal->m_bNativeLook; + m_nControlTypeinMSO = _pOriginal->m_nControlTypeinMSO; + m_nObjIDinMSO = _pOriginal->m_nObjIDinMSO; if ( _bCloneAggregate ) { @@ -985,7 +989,13 @@ case PROPERTY_ID_NATIVE_LOOK: aReturn <<= (sal_Bool)sal_True; break; - + //added for exporting OCX control + case PROPERTY_ID_CONTROL_TYPE_IN_MSO: + aReturn <<= (sal_Int16)0; + break; + case PROPERTY_ID_OBJ_ID_IN_MSO: + aReturn <<= (sal_uInt16)INVALID_OBJ_ID_IN_MSO; + break; default: if ( m_aPropertyBagHelper.hasDynamicPropertyByHandle( _nHandle ) ) m_aPropertyBagHelper.getDynamicPropertyDefaultByHandle( _nHandle, aReturn ); @@ -1015,6 +1025,13 @@ case PROPERTY_ID_NATIVE_LOOK: _rValue <<= (sal_Bool)m_bNativeLook; break; + //added for exporting OCX control + case PROPERTY_ID_CONTROL_TYPE_IN_MSO: + _rValue <<= (sal_Int16)m_nControlTypeinMSO; + break; + case PROPERTY_ID_OBJ_ID_IN_MSO: + _rValue <<= (sal_uInt16)m_nObjIDinMSO; + break; default: if ( m_aPropertyBagHelper.hasDynamicPropertyByHandle( _nHandle ) ) m_aPropertyBagHelper.getDynamicFastPropertyValue( _nHandle, _rValue ); @@ -1044,6 +1061,13 @@ case PROPERTY_ID_NATIVE_LOOK: bModified = tryPropertyValue(_rConvertedValue, _rOldValue, _rValue, m_bNativeLook); break; + //added for exporting OCX control + case PROPERTY_ID_CONTROL_TYPE_IN_MSO: + bModified = tryPropertyValue(_rConvertedValue, _rOldValue, _rValue, m_nControlTypeinMSO); + break; + case PROPERTY_ID_OBJ_ID_IN_MSO: + bModified = tryPropertyValue(_rConvertedValue, _rOldValue, _rValue, m_nObjIDinMSO); + break; default: if ( m_aPropertyBagHelper.hasDynamicPropertyByHandle( _nHandle ) ) bModified = m_aPropertyBagHelper.convertDynamicFastPropertyValue( _nHandle, _rValue, _rConvertedValue, _rOldValue ); @@ -1078,6 +1102,13 @@ case PROPERTY_ID_NATIVE_LOOK: OSL_VERIFY( _rValue >>= m_bNativeLook ); break; + //added for exporting OCX control + case PROPERTY_ID_CONTROL_TYPE_IN_MSO: + OSL_VERIFY( _rValue >>= m_nControlTypeinMSO ); + break; + case PROPERTY_ID_OBJ_ID_IN_MSO: + OSL_VERIFY( _rValue >>= m_nObjIDinMSO ); + break; default: if ( m_aPropertyBagHelper.hasDynamicPropertyByHandle( _nHandle ) ) m_aPropertyBagHelper.setDynamicFastPropertyValue( _nHandle, _rValue ); @@ -1090,11 +1121,14 @@ //------------------------------------------------------------------------------ void OControlModel::describeFixedProperties( Sequence< Property >& _rProps ) const { - BEGIN_DESCRIBE_BASE_PROPERTIES( 4 ) + //BEGIN_DESCRIBE_BASE_PROPERTIES( 4 ) + BEGIN_DESCRIBE_BASE_PROPERTIES( 6 ) DECL_PROP2 (CLASSID, sal_Int16, READONLY, TRANSIENT); DECL_PROP1 (NAME, ::rtl::OUString, BOUND); DECL_BOOL_PROP2 (NATIVE_LOOK, BOUND, TRANSIENT); DECL_PROP1 (TAG, ::rtl::OUString, BOUND); + DECL_PROP1 (CONTROL_TYPE_IN_MSO,sal_Int16, BOUND); + DECL_PROP1 (OBJ_ID_IN_MSO,sal_uInt16, BOUND); END_DESCRIBE_PROPERTIES() } Index: forms/source/inc/FormComponent.hxx =================================================================== --- forms/source/inc/FormComponent.hxx (revision 1387468) +++ forms/source/inc/FormComponent.hxx (working copy) @@ -335,6 +335,8 @@ //= OControlModel //= model of a form layer control //================================================================== +//added for exporting OCX control +#define INVALID_OBJ_ID_IN_MSO 0xFFFF typedef ::cppu::ImplHelper7 < ::com::sun::star::form::XFormComponent , ::com::sun::star::io::XPersistObject @@ -371,6 +373,9 @@ sal_Int16 m_nTabIndex; // index within the taborder sal_Int16 m_nClassId; // type of the control sal_Bool m_bNativeLook; // should the control use the native platform look? + //added for exporting OCX control + sal_Int16 m_nControlTypeinMSO; //keep the MS office control type for exporting to MS binarary file + sal_uInt16 m_nObjIDinMSO; //keep the OCX control obj id for exporting to MS binarary file // Index: forms/source/inc/frm_strings.hxx =================================================================== --- forms/source/inc/frm_strings.hxx (revision 1387468) +++ forms/source/inc/frm_strings.hxx (working copy) @@ -321,6 +321,9 @@ FORMS_CONSTASCII_STRING( PROPERTY_CONTROL_BORDER_COLOR_FOCUS, "ControlBorderColorOnFocus" ); FORMS_CONSTASCII_STRING( PROPERTY_CONTROL_BORDER_COLOR_MOUSE, "ControlBorderColorOnHover" ); FORMS_CONSTASCII_STRING( PROPERTY_CONTROL_BORDER_COLOR_INVALID,"ControlBorderColorOnInvalid" ); + //added for exporting OCX control + FORMS_CONSTASCII_STRING( PROPERTY_CONTROL_TYPE_IN_MSO, "ControlTypeinMSO" ); + FORMS_CONSTASCII_STRING( PROPERTY_OBJ_ID_IN_MSO, "ObjIDinMSO" ); //-------------------------------------------------------------------------- //- URLs Index: forms/source/inc/property.hrc =================================================================== --- forms/source/inc/property.hrc (revision 1387468) +++ forms/source/inc/property.hrc (working copy) @@ -299,6 +299,8 @@ #define PROPERTY_ID_XSD_TYPE_CLASS ( PROPERTY_ID_START + 258 ) #define PROPERTY_ID_LINEEND_FORMAT ( PROPERTY_ID_START + 259 ) // css.awt.LineEndFormat +#define PROPERTY_ID_CONTROL_TYPE_IN_MSO ( PROPERTY_ID_START + 260 ) +#define PROPERTY_ID_OBJ_ID_IN_MSO ( PROPERTY_ID_START + 261 ) // start ID fuer aggregierte Properties #define PROPERTY_ID_AGGREGATE_ID (PROPERTY_ID_START + 10000) Index: sc/source/filter/excel/xeescher.cxx =================================================================== --- sc/source/filter/excel/xeescher.cxx (revision 1387468) +++ sc/source/filter/excel/xeescher.cxx (working copy) @@ -373,7 +373,8 @@ // ---------------------------------------------------------------------------- -#if EXC_EXP_OCX_CTRL +//delete for exporting OCX +//#if EXC_EXP_OCX_CTRL XclExpOcxControlObj::XclExpOcxControlObj( XclExpObjectManager& rObjMgr, Reference< XShape > xShape, const Rectangle* pChildAnchor, const String& rClassName, sal_uInt32 nStrmStart, sal_uInt32 nStrmSize ) : @@ -395,7 +396,7 @@ mrEscherEx.OpenContainer( ESCHER_SpContainer ); mrEscherEx.AddShape( ESCHER_ShpInst_HostControl, SHAPEFLAG_HAVESPT | SHAPEFLAG_HAVEANCHOR | SHAPEFLAG_OLESHAPE ); Rectangle aDummyRect; - EscherPropertyContainer aPropOpt( mrEscherEx, mrEscherEx.QueryPicStream(), aDummyRect ); + EscherPropertyContainer aPropOpt( mrEscherEx.GetGraphicProvider(), mrEscherEx.QueryPictureStream(), aDummyRect ); aPropOpt.AddOpt( ESCHER_Prop_FitTextToShape, 0x00080008 ); // bool field aPropOpt.AddOpt( ESCHER_Prop_lineColor, 0x08000040 ); aPropOpt.AddOpt( ESCHER_Prop_fNoLineDrawDash, 0x00080000 ); // bool field @@ -478,7 +479,7 @@ rStrm.EndRecord(); } -#else +//#else XclExpTbxControlObj::XclExpTbxControlObj( XclExpObjectManager& rObjMgr, Reference< XShape > xShape, const Rectangle* pChildAnchor ) : XclObj( rObjMgr, EXC_OBJTYPE_UNKNOWN, true ), @@ -917,7 +918,7 @@ rStrm.EndRecord(); } -#endif +//#endif // ---------------------------------------------------------------------------- Index: sc/source/filter/excel/xiescher.cxx =================================================================== --- sc/source/filter/excel/xiescher.cxx (revision 1387468) +++ sc/source/filter/excel/xiescher.cxx (working copy) @@ -46,6 +46,7 @@ #include #include #include +#include #include #include @@ -111,6 +112,8 @@ using ::rtl::OUStringBuffer; using ::com::sun::star::uno::makeAny; using ::com::sun::star::uno::Any; +using ::com::sun::star::beans::XPropertySet; +using ::com::sun::star::uno::makeAny; using ::com::sun::star::uno::Exception; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Sequence; @@ -450,6 +453,73 @@ xSdrObj.reset( DoCreateSdrObj( rDffConv, rAnchorRect ) ); if( xSdrObj.is() ) xSdrObj->SetModel( rDffConv.GetModel() ); + //added for exporting OCX control + /* mnObjType value set should be as below table: + 0x0000 Group 0x0001 Line + 0x0002 Rectangle 0x0003 Oval + 0x0004 Arc 0x0005 Chart + 0x0006 Text 0x0009 Polygon + +-----------------------------------------------------+ + OCX ==>| 0x0008 Picture | + +-----------------------------------------------------+ + | 0x0007 Button | + | 0x000B Checkbox 0x000C Radio button | + | 0x000D Edit box 0x000E Label | + TBX ==> | 0x000F Dialog box 0x0010 Spin control | + | 0x0011 Scrollbar 0x0012 List | + | 0x0013 Group box 0x0014 Dropdown list | + +-----------------------------------------------------+ + 0x0019 Note 0x001E OfficeArt object + */ + if( xSdrObj.is() && xSdrObj->IsUnoObj() && + ( (mnObjType < 25 && mnObjType > 10) || mnObjType == 7 || mnObjType == 8 ) ) + { + SdrUnoObj* pSdrUnoObj = dynamic_cast< SdrUnoObj* >( xSdrObj.get() ); + if( pSdrUnoObj != NULL ) + { + Reference< XControlModel > xCtrlModel = pSdrUnoObj->GetUnoControlModel(); + Reference< XPropertySet > xPropSet(xCtrlModel,UNO_QUERY); + const static rtl::OUString sPropertyName = rtl::OUString::createFromAscii("ControlTypeinMSO"); + + enum ControlType { eCreateFromAOO = 0, eCreateFromMSTBXControl, eCreateFromMSOCXControl }; + + if( mnObjType == 7 || (mnObjType < 25 && mnObjType > 10) )//TBX + { + //Need summary type for export. Detail type(checkbox, button ...) has been contained by mnObjType + const sal_Int16 nTBXControlType = eCreateFromMSTBXControl ; + Any aAny; + aAny <<= nTBXControlType; + try{ + xPropSet->setPropertyValue(sPropertyName, aAny); + }catch(...) + { + OSL_TRACE("XclImpDrawObjBase::CreateSdrObject, this control can't be set the property ControlTypeinMSO!"); + } + } + if( mnObjType == 8 )//OCX + { + //Need summary type for export + const static rtl::OUString sObjIdPropertyName = rtl::OUString::createFromAscii("ObjIDinMSO"); + const XclImpPictureObj* const pObj = dynamic_cast< const XclImpPictureObj* const >(this); + if( pObj != NULL && pObj->IsOcxControl() ) + { + const sal_Int16 nOCXControlType = eCreateFromMSOCXControl; + Any aAny; + try{ + aAny <<= nOCXControlType; + xPropSet->setPropertyValue(sPropertyName, aAny); + //Detail type(checkbox, button ...) + aAny<<= mnObjId; + xPropSet->setPropertyValue(sObjIdPropertyName, aAny); + }catch(...) + { + OSL_TRACE("XclImpDrawObjBase::CreateSdrObject, this control can't be set the property ObjIDinMSO!"); + } + } + } + + } + } } return xSdrObj.release(); } Index: sc/source/filter/inc/xcl97esc.hxx =================================================================== --- sc/source/filter/inc/xcl97esc.hxx (revision 1387468) +++ sc/source/filter/inc/xcl97esc.hxx (working copy) @@ -32,7 +32,7 @@ #include "xeroot.hxx" // 0 = Export TBX form controls, 1 = Export OCX form controls. -#define EXC_EXP_OCX_CTRL 0 +//#define EXC_EXP_OCX_CTRL 0 namespace utl { class TempFile; } @@ -61,11 +61,12 @@ class XclEscherHostAppData; class XclEscherClientData; class XclEscherClientTextbox; -#if EXC_EXP_OCX_CTRL +//delete for exporting OCX +//#if EXC_EXP_OCX_CTRL class XclExpOcxControlObj; -#else +//#else class XclExpTbxControlObj; -#endif +//#endif class XclEscherEx : public EscherEx, protected XclExpRoot { @@ -104,29 +105,30 @@ /// Flush and merge PicStream into EscherStream void EndDocument(); - -#if EXC_EXP_OCX_CTRL +//delete for exporting OCX +//#if EXC_EXP_OCX_CTRL /** Creates an OCX form control OBJ record from the passed form control. @descr Writes the form control data to the 'Ctls' stream. */ - XclExpOcxControlObj* CreateCtrlObj( + XclExpOcxControlObj* CreateOCXCtrlObj( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape, const Rectangle* pChildAnchor ); - -private: - SotStorageStreamRef mxCtlsStrm; /// The 'Ctls' stream. -#else /** Creates a TBX form control OBJ record from the passed form control. */ - XclExpTbxControlObj* CreateCtrlObj( + XclExpTbxControlObj* CreateTBXCtrlObj( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape, const Rectangle* pChildAnchor ); + private: + SotStorageStreamRef mxCtlsStrm; /// The 'Ctls' stream. +//#else + +private: /** Tries to get the name of a Basic macro from a control. */ void ConvertTbxMacro( XclExpTbxControlObj& rTbxCtrlObj, ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > xCtrlModel ); -#endif +//#endif void DeleteCurrAppData(); Index: sc/source/filter/inc/xeescher.hxx =================================================================== --- sc/source/filter/inc/xeescher.hxx (revision 1387468) +++ sc/source/filter/inc/xeescher.hxx (working copy) @@ -205,7 +205,8 @@ // ---------------------------------------------------------------------------- -#if EXC_EXP_OCX_CTRL +//delete for exporting OCX +//#if EXC_EXP_OCX_CTRL /** Represents an OBJ record for an OCX form control. */ class XclExpOcxControlObj : public XclObj, public XclExpControlHelper @@ -227,7 +228,7 @@ sal_uInt32 mnStrmSize; /// Size in 'Ctls' stream. }; -#else +//#else /** Represents an OBJ record for an TBX form control. */ class XclExpTbxControlObj : public XclObj, public XclExpControlHelper @@ -271,7 +272,7 @@ bool mbScrollHor; /// Scrollbar: true = horizontal. }; -#endif +//#endif // ---------------------------------------------------------------------------- Index: sc/source/filter/xcl97/xcl97esc.cxx =================================================================== --- sc/source/filter/xcl97/xcl97esc.cxx (revision 1387468) +++ sc/source/filter/xcl97/xcl97esc.cxx (working copy) @@ -29,6 +29,8 @@ #include #include #include +#include +#include #include #include @@ -67,6 +69,10 @@ using ::com::sun::star::embed::XClassifiedObject; using ::com::sun::star::drawing::XShape; using ::com::sun::star::awt::XControlModel; +using ::com::sun::star::beans::XPropertySet; +using ::com::sun::star::uno::Any; +using ::com::sun::star::form::XForm; +using ::com::sun::star::form::XFormComponent; using ::com::sun::star::form::XFormsSupplier; using ::com::sun::star::script::ScriptEventDescriptor; using ::com::sun::star::script::XEventAttacherManager; @@ -207,6 +213,8 @@ aStack.Push( pCurrAppData ); pCurrAppData = new XclEscherHostAppData; SdrObject* pObj = GetSdrObjectFromXShape( rxShape ); + //added for exporting OCX control + sal_Int16 nMsCtlType = 0; if ( !pObj ) pCurrXclObj = new XclObjAny( mrObjMgr ); // just what is it?!? else @@ -240,13 +248,21 @@ } else if( nObjType == OBJ_UNO ) { -#if EXC_EXP_OCX_CTRL - // no ActiveX controls in embedded drawings (chart shapes) - if( mbIsRootDff ) - pCurrXclObj = CreateCtrlObj( rxShape, pChildAnchor ); -#else - pCurrXclObj = CreateCtrlObj( rxShape, pChildAnchor ); -#endif + //added for exporting OCX control + Reference< XPropertySet > xPropSet( rxShape, UNO_QUERY ); + Any aAny; + try{ + aAny = xPropSet->getPropertyValue(rtl::OUString::createFromAscii("ControlTypeinMSO")); + }catch(...) + { + OSL_TRACE("XclEscherEx::StartShape, this control can't get the property ControlTypeinMSO!"); + } + aAny >>= nMsCtlType; + + if( nMsCtlType == 2 ) //OCX Form Control + pCurrXclObj = CreateOCXCtrlObj( rxShape, pChildAnchor ); + else //TBX Form Control + pCurrXclObj = CreateTBXCtrlObj( rxShape, pChildAnchor ); if( !pCurrXclObj ) pCurrXclObj = new XclObjAny( mrObjMgr ); // just a metafile } @@ -304,6 +320,28 @@ } } } + //add for exporting OCX control + //for OCX control import from MS office file,we need keep the id value as MS office file. + //GetOldRoot().pObjRecs->Add( pCurrXclObj ) statement has generated the id value as aoo obj id rule; + //but we trick it here. + sal_uInt16 nObjType = pObj->GetObjIdentifier(); + if( nObjType == OBJ_UNO && pCurrXclObj ) + { + Reference< XPropertySet > xPropSet( rxShape, UNO_QUERY ); + Any aAny; + try{ + aAny = xPropSet->getPropertyValue(rtl::OUString::createFromAscii("ObjIDinMSO")); + }catch(...) + { + OSL_TRACE("XclEscherEx::StartShape, this control can't get the property ObjIDinMSO!"); + } + sal_uInt16 nObjIDinMSO = 0xFFFF; + aAny >>= nObjIDinMSO; + if( nObjIDinMSO != 0xFFFF && nMsCtlType == 2) //OCX + { + pCurrXclObj->SetId(nObjIDinMSO); + } + } if ( !pCurrXclObj ) pCurrAppData->SetDontWriteShape( sal_True ); return pCurrAppData; @@ -367,9 +405,10 @@ mpOutStrm->Seek( 0 ); } -#if EXC_EXP_OCX_CTRL +//delete for exporting OCX +//#if EXC_EXP_OCX_CTRL -XclExpOcxControlObj* XclEscherEx::CreateCtrlObj( Reference< XShape > xShape, const Rectangle* pChildAnchor ) +XclExpOcxControlObj* XclEscherEx::CreateOCXCtrlObj( Reference< XShape > xShape, const Rectangle* pChildAnchor ) { ::std::auto_ptr< XclExpOcxControlObj > xOcxCtrl; @@ -397,9 +436,9 @@ return xOcxCtrl.release(); } -#else +//#else -XclExpTbxControlObj* XclEscherEx::CreateCtrlObj( Reference< XShape > xShape, const Rectangle* pChildAnchor ) +XclExpTbxControlObj* XclEscherEx::CreateTBXCtrlObj( Reference< XShape > xShape, const Rectangle* pChildAnchor ) { ::std::auto_ptr< XclExpTbxControlObj > xTbxCtrl( new XclExpTbxControlObj( mrObjMgr, xShape, pChildAnchor ) ); if( xTbxCtrl->GetObjType() == EXC_OBJTYPE_UNKNOWN ) @@ -467,7 +506,7 @@ } } -#endif +//#endif void XclEscherEx::DeleteCurrAppData() { Index: svx/source/unodraw/unoshap2.cxx =================================================================== --- svx/source/unodraw/unoshap2.cxx (revision 1387468) +++ svx/source/unodraw/unoshap2.cxx (working copy) @@ -710,6 +710,9 @@ { MAP_CHAR_LEN("ControlTextEmphasis"), MAP_CHAR_LEN("FontEmphasisMark") }, { MAP_CHAR_LEN("ImageScaleMode"), MAP_CHAR_LEN("ScaleMode") }, { MAP_CHAR_LEN("ControlWritingMode"), MAP_CHAR_LEN("WritingMode") }, + //added for exporting OCX control + { MAP_CHAR_LEN("ControlTypeinMSO"), MAP_CHAR_LEN("ControlTypeinMSO") }, + { MAP_CHAR_LEN("ObjIDinMSO"), MAP_CHAR_LEN("ObjIDinMSO") }, { NULL,0, NULL, 0 } };