forms/source/component/FormComponent.cxx | 38 ++++++++++++++- forms/source/inc/FormComponent.hxx | 5 ++ forms/source/inc/frm_strings.hxx | 2 forms/source/inc/property.hrc | 2 include/oox/ole/olehelper.hxx | 4 + oox/source/helper/binaryoutputstream.cxx | 3 - oox/source/ole/olehelper.cxx | 31 ++++++++++++ sc/source/filter/excel/xeescher.cxx | 9 ++- sc/source/filter/excel/xiescher.cxx | 74 +++++++++++++++++++++++++++++ sc/source/filter/inc/xcl97esc.hxx | 14 ----- sc/source/filter/inc/xeescher.hxx | 7 +- sc/source/filter/xcl97/xcl97esc.cxx | 77 +++++++++++++++++++++++-------- svx/source/unodraw/unoshap2.cxx | 3 + 13 files changed, 228 insertions(+), 41 deletions(-)
New commits: commit a8bb1fd10a39c692dd475e2e89dd2c6902c091d8 Author: Noel Power <[email protected]> Date: Tue Jun 11 11:29:21 2013 +0100 honour mbAutoClose in BinaryXOutputStream presumably this mbAutoClose usages got clobbered mistakenly in some merging operation Change-Id: I7116827269cdbb555753f6678528c83ab804de46 diff --git a/oox/source/helper/binaryoutputstream.cxx b/oox/source/helper/binaryoutputstream.cxx index 23f89ae..790c250 100644 --- a/oox/source/helper/binaryoutputstream.cxx +++ b/oox/source/helper/binaryoutputstream.cxx @@ -60,7 +60,8 @@ void BinaryXOutputStream::close() if( mxOutStrm.is() ) try { mxOutStrm->flush(); - mxOutStrm->closeOutput(); + if ( mbAutoClose ) + mxOutStrm->closeOutput(); } catch( Exception& ) { commit 866845356629dd51660b73330bb9c8a2696147dd Author: Noel Power <[email protected]> Date: Mon Jun 10 17:30:07 2013 +0100 fix build error, reinstate WriteOCXExcelKludgeStream to export ole control new ole export used WriteOCXExcelKludgeStream but that function dissapeared when msocximex was stripped of ocx control import ( now we use the new filters in oox ) When that stuff was moved WriteOCXExcelKludgeStream was #ifdef'ed out Change-Id: I370983efa5e8c4ba2b210dfb7535ea211d13a8c1 diff --git a/include/oox/ole/olehelper.hxx b/include/oox/ole/olehelper.hxx index e75a0cd..85cca19 100644 --- a/include/oox/ole/olehelper.hxx +++ b/include/oox/ole/olehelper.hxx @@ -39,6 +39,8 @@ #include "oox/dllapi.h" #include "sot/storage.hxx" +class SvGlobalName; + namespace oox { class BinaryInputStream; class BinaryOutputStream; @@ -122,6 +124,7 @@ public: representation (in uppercase characters). */ static OUString importGuid( BinaryInputStream& rInStrm ); + static void exportGuid( BinaryOutputStream& rOutStrm, const SvGlobalName& rId ); /** Imports an OLE StdFont font structure from the current position of the passed binary stream. @@ -175,6 +178,7 @@ public: sal_Bool ReadOCXCtlsStream(SotStorageStreamRef& rSrc1, ::com::sun::star::uno::Reference< com::sun::star::form::XFormComponent > & rxFormComp, sal_Int32 nPos, sal_Int32 nSize ); static sal_Bool WriteOCXStream( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rxModel, SotStorageRef &rSrc1, const com::sun::star::uno::Reference< com::sun::star::awt::XControlModel > &rControlModel, const com::sun::star::awt::Size& rSize,OUString &rName); + static sal_Bool WriteOCXExcelKludgeStream( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rxModel, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& xOutStrm, const com::sun::star::uno::Reference< com::sun::star::awt::XControlModel > &rControlModel, const com::sun::star::awt::Size& rSize,OUString &rName); #ifdef SvxMSConvertOCXControlsRemoved const com::sun::star::uno::Reference< com::sun::star::drawing::XShapes > & GetShapes(); diff --git a/oox/source/ole/olehelper.cxx b/oox/source/ole/olehelper.cxx index e87f2cd..58aa67e 100644 --- a/oox/source/ole/olehelper.cxx +++ b/oox/source/ole/olehelper.cxx @@ -284,6 +284,22 @@ sal_uInt32 OleHelper::encodeOleColor( sal_Int32 nRgbColor ) return OLE_COLORTYPE_BGR | lclSwapRedBlue( static_cast< sal_uInt32 >( nRgbColor & 0xFFFFFF ) ); } +void OleHelper::exportGuid( BinaryOutputStream& rOStr, const SvGlobalName& rId ) +{ + const sal_uInt8* pBytes = rId.GetBytes(); + sal_uInt32 a; + memcpy(&a, pBytes, sizeof(sal_uInt32)); + rOStr<< a; + + sal_uInt16 b; + memcpy(&b, pBytes+4, sizeof(sal_uInt16)); + rOStr << b; + + memcpy(&b, pBytes+6, sizeof(sal_uInt16)); + rOStr << b; + + rOStr.writeArray( (sal_Char *)&pBytes[ 8 ], 8 ); +} OUString OleHelper::importGuid( BinaryInputStream& rInStrm ) { OUStringBuffer aBuffer; @@ -569,6 +585,21 @@ sal_Bool MSConvertOCXControls::ReadOCXStorage( SotStorageRef& xOleStg, return sal_False; } +sal_Bool MSConvertOCXControls::WriteOCXExcelKludgeStream( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rxModel, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& xOutStrm, const com::sun::star::uno::Reference< com::sun::star::awt::XControlModel > &rxControlModel, const com::sun::star::awt::Size& rSize,OUString &rName ) +{ + OleFormCtrlExportHelper exportHelper( comphelper::getProcessComponentContext(), rxModel, rxControlModel ); + if ( !exportHelper.isValid() ) + return sal_False; + rName = exportHelper.getTypeName(); + SvGlobalName aName; + OUString sId = exportHelper.getGUID(); + aName.MakeId(sId); + BinaryXOutputStream xOut( xOutStrm, false ); + OleHelper::exportGuid( xOut, aName ); + exportHelper.exportControl( xOutStrm, rSize ); + return sal_True; +} + sal_Bool MSConvertOCXControls::WriteOCXStream( const Reference< XModel >& rxModel, SotStorageRef &xOleStg, const Reference< XControlModel > &rxControlModel, const com::sun::star::awt::Size& rSize, OUString &rName) diff --git a/sc/source/filter/xcl97/xcl97esc.cxx b/sc/source/filter/xcl97/xcl97esc.cxx index 4ffad40..bcdec46 100644 --- a/sc/source/filter/xcl97/xcl97esc.cxx +++ b/sc/source/filter/xcl97/xcl97esc.cxx @@ -52,6 +52,9 @@ #include "xehelper.hxx" #include "xechart.hxx" #include "xcl97esc.hxx" +#include <unotools/streamwrap.hxx> +#include <oox/ole/olehelper.hxx> +#include <sfx2/objsh.hxx> using ::com::sun::star::uno::Any; using ::com::sun::star::uno::Exception; @@ -68,6 +71,7 @@ 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::io::XOutputStream; using ::com::sun::star::script::ScriptEventDescriptor; using ::com::sun::star::script::XEventAttacherManager; @@ -410,9 +414,6 @@ void XclEscherEx::EndDocument() mpOutStrm->Seek( 0 ); } -//delete for exporting OCX -//#if EXC_EXP_OCX_CTRL - XclExpOcxControlObj* XclEscherEx::CreateOCXCtrlObj( Reference< XShape > xShape, const Rectangle* pChildAnchor ) { ::std::auto_ptr< XclExpOcxControlObj > xOcxCtrl; @@ -425,15 +426,17 @@ XclExpOcxControlObj* XclEscherEx::CreateOCXCtrlObj( Reference< XShape > xShape, mxCtlsStrm = OpenStream( EXC_STREAM_CTLS ); if( mxCtlsStrm.Is() ) { - String aClassName; + OUString aClassName; sal_uInt32 nStrmStart = static_cast< sal_uInt32 >( mxCtlsStrm->Tell() ); // writes from xCtrlModel into mxCtlsStrm, raw class name returned in aClassName - if( SvxMSConvertOCXControls::WriteOCXExcelKludgeStream( mxCtlsStrm, xCtrlModel, xShape->getSize(), aClassName ) ) + Reference< XOutputStream > xOut( new utl::OSeekableOutputStreamWrapper( *mxCtlsStrm ) ); + Reference< com::sun::star::frame::XModel > xModel( GetDocShell() ? GetDocShell()->GetModel() : NULL ); + if( xModel.is() && xOut.is() && oox::ole::MSConvertOCXControls::WriteOCXExcelKludgeStream( xModel, xOut, xCtrlModel, xShape->getSize(), aClassName ) ) { sal_uInt32 nStrmSize = static_cast< sal_uInt32 >( mxCtlsStrm->Tell() - nStrmStart ); // adjust the class name to "Forms.***.1" - aClassName.InsertAscii( "Forms.", 0 ).AppendAscii( ".1" ); + aClassName = "Forms." + aClassName + ".1"; xOcxCtrl.reset( new XclExpOcxControlObj( mrObjMgr, xShape, pChildAnchor, aClassName, nStrmStart, nStrmSize ) ); } } @@ -441,8 +444,6 @@ XclExpOcxControlObj* XclEscherEx::CreateOCXCtrlObj( Reference< XShape > xShape, return xOcxCtrl.release(); } -//#else - XclExpTbxControlObj* XclEscherEx::CreateTBXCtrlObj( Reference< XShape > xShape, const Rectangle* pChildAnchor ) { ::std::auto_ptr< XclExpTbxControlObj > xTbxCtrl( new XclExpTbxControlObj( mrObjMgr, xShape, pChildAnchor ) ); @@ -511,8 +512,6 @@ void XclEscherEx::ConvertTbxMacro( XclExpTbxControlObj& rTbxCtrlObj, Reference< } } -//#endif - void XclEscherEx::DeleteCurrAppData() { if ( pCurrAppData ) commit 74d631dfb37ec870575d873c82e982a58f65d60c Author: Jianyuan Li <[email protected]> Date: Tue Sep 25 04:48:42 2012 +0000 Resolves: #i121045 After save a xls file contain marco in AOO, macor can't... Reported by: binguo Reviewed by: sunying Patched by: Jianyuan Li Change-Id: Ie728ce5185082334e3ce250d73e0660a6097f494 diff --git a/forms/source/component/FormComponent.cxx b/forms/source/component/FormComponent.cxx index eb32945..7f70fc8 100644 --- a/forms/source/component/FormComponent.cxx +++ b/forms/source/component/FormComponent.cxx @@ -585,6 +585,8 @@ OControlModel::OControlModel( ,m_nClassId(FormComponentType::CONTROL) ,m_bNativeLook( sal_False ) ,m_bGenerateVbEvents( 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# @@ -641,6 +643,8 @@ OControlModel::OControlModel( const OControlModel* _pOriginal, const Reference< m_nClassId = _pOriginal->m_nClassId; m_bNativeLook = _pOriginal->m_bNativeLook; m_bGenerateVbEvents = _pOriginal->m_bGenerateVbEvents; + m_nControlTypeinMSO = _pOriginal->m_nControlTypeinMSO; + m_nObjIDinMSO = _pOriginal->m_nObjIDinMSO; if ( _bCloneAggregate ) { @@ -982,8 +986,13 @@ Any OControlModel::getPropertyDefaultByHandle( sal_Int32 _nHandle ) const case PROPERTY_ID_GENERATEVBAEVENTS: aReturn <<= (sal_Bool)sal_False; 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 +1024,13 @@ void OControlModel::getFastPropertyValue( Any& _rValue, sal_Int32 _nHandle ) con break; case PROPERTY_ID_GENERATEVBAEVENTS: _rValue <<= (sal_Bool)m_bGenerateVbEvents; + //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 ); @@ -1047,6 +1063,13 @@ sal_Bool OControlModel::convertFastPropertyValue( case PROPERTY_ID_GENERATEVBAEVENTS: bModified = tryPropertyValue(_rConvertedValue, _rOldValue, _rValue, m_bGenerateVbEvents); 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 ); @@ -1084,6 +1107,13 @@ void OControlModel::setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle, const A case PROPERTY_ID_GENERATEVBAEVENTS: OSL_VERIFY( _rValue >>= m_bGenerateVbEvents ); 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 ); @@ -1096,12 +1126,14 @@ void OControlModel::setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle, const A //------------------------------------------------------------------------------ void OControlModel::describeFixedProperties( Sequence< Property >& _rProps ) const { - BEGIN_DESCRIBE_BASE_PROPERTIES( 5 ) + BEGIN_DESCRIBE_BASE_PROPERTIES( 7 ) DECL_PROP2 (CLASSID, sal_Int16, READONLY, TRANSIENT); DECL_PROP1 (NAME, OUString, BOUND); DECL_BOOL_PROP2 (NATIVE_LOOK, BOUND, TRANSIENT); DECL_PROP1 (TAG, OUString, BOUND); DECL_PROP1 (GENERATEVBAEVENTS, sal_Bool, TRANSIENT); + DECL_PROP1 (CONTROL_TYPE_IN_MSO,sal_Int16, BOUND); + DECL_PROP1 (OBJ_ID_IN_MSO,sal_uInt16, BOUND); END_DESCRIBE_PROPERTIES() } diff --git a/forms/source/inc/FormComponent.hxx b/forms/source/inc/FormComponent.hxx index 5429c36..a89043f 100644 --- a/forms/source/inc/FormComponent.hxx +++ b/forms/source/inc/FormComponent.hxx @@ -329,6 +329,8 @@ protected: //= 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 @@ -366,6 +368,9 @@ protected: sal_Int16 m_nClassId; // type of the control sal_Bool m_bNativeLook; // should the control use the native platform look? sal_Bool m_bGenerateVbEvents; // should the control generate fake vba events + //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 // </properties> diff --git a/forms/source/inc/frm_strings.hxx b/forms/source/inc/frm_strings.hxx index 7de3f24..2171815 100644 --- a/forms/source/inc/frm_strings.hxx +++ b/forms/source/inc/frm_strings.hxx @@ -267,6 +267,8 @@ namespace frm #define PROPERTY_CONTROL_BORDER_COLOR_MOUSE "ControlBorderColorOnHover" #define PROPERTY_CONTROL_BORDER_COLOR_INVALID "ControlBorderColorOnInvalid" #define PROPERTY_GENERATEVBAEVENTS "GenerateVbaEvents" + #define PROPERTY_CONTROL_TYPE_IN_MSO "ControlTypeinMSO" + #define PROPERTY_OBJ_ID_IN_MSO "ObjIDinMSO" //-------------------------------------------------------------------------- //- URLs diff --git a/forms/source/inc/property.hrc b/forms/source/inc/property.hrc index af0ed33..a35aa65 100644 --- a/forms/source/inc/property.hrc +++ b/forms/source/inc/property.hrc @@ -291,6 +291,8 @@ namespace frm #define PROPERTY_ID_LINEEND_FORMAT ( PROPERTY_ID_START + 259 ) // css.awt.LineEndFormat #define PROPERTY_ID_GENERATEVBAEVENTS ( PROPERTY_ID_START + 260 ) +#define PROPERTY_ID_CONTROL_TYPE_IN_MSO ( PROPERTY_ID_START + 261 ) +#define PROPERTY_ID_OBJ_ID_IN_MSO ( PROPERTY_ID_START + 262 ) // start ID fuer aggregierte Properties #define PROPERTY_ID_AGGREGATE_ID (PROPERTY_ID_START + 10000) diff --git a/sc/source/filter/excel/xeescher.cxx b/sc/source/filter/excel/xeescher.cxx index 77bfcb7..54f9eac 100644 --- a/sc/source/filter/excel/xeescher.cxx +++ b/sc/source/filter/excel/xeescher.cxx @@ -505,7 +505,8 @@ void XclExpControlHelper::WriteFormulaSubRec( XclExpStream& rStrm, sal_uInt16 nS // ---------------------------------------------------------------------------- -#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 ) : @@ -527,7 +528,7 @@ XclExpOcxControlObj::XclExpOcxControlObj( XclExpObjectManager& rObjMgr, Referenc 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 @@ -610,7 +611,7 @@ void XclExpOcxControlObj::WriteSubRecs( XclExpStream& rStrm ) rStrm.EndRecord(); } -#else +//#else XclExpTbxControlObj::XclExpTbxControlObj( XclExpObjectManager& rRoot, Reference< XShape > xShape , const Rectangle* pChildAnchor ) : XclObj( rRoot, EXC_OBJTYPE_UNKNOWN, true ), @@ -1035,7 +1036,7 @@ void XclExpTbxControlObj::WriteSbs( XclExpStream& rStrm ) rStrm.EndRecord(); } -#endif +//#endif // ---------------------------------------------------------------------------- diff --git a/sc/source/filter/excel/xiescher.cxx b/sc/source/filter/excel/xiescher.cxx index 3c530f0..241a715 100644 --- a/sc/source/filter/excel/xiescher.cxx +++ b/sc/source/filter/excel/xiescher.cxx @@ -39,6 +39,7 @@ #include <com/sun/star/form/binding/XListEntrySource.hpp> #include <com/sun/star/script/ScriptEventDescriptor.hpp> #include <com/sun/star/script/XEventAttacherManager.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> #include <rtl/logfile.hxx> #include <sfx2/objsh.hxx> @@ -110,6 +111,8 @@ 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; @@ -455,6 +458,77 @@ SdrObject* XclImpDrawObjBase::CreateSdrObject( XclImpDffConverter& rDffConv, con 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 { eCreateFromOffice = 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(const Exception&) + { + 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(const Exception&) + { + OSL_TRACE("XclImpDrawObjBase::CreateSdrObject, this control can't be set the property ObjIDinMSO!"); + } + } + } + + } + } } return xSdrObj.release(); } diff --git a/sc/source/filter/inc/xcl97esc.hxx b/sc/source/filter/inc/xcl97esc.hxx index 4ce70ee..7d0b501 100644 --- a/sc/source/filter/inc/xcl97esc.hxx +++ b/sc/source/filter/inc/xcl97esc.hxx @@ -27,9 +27,6 @@ #include "xeroot.hxx" #include <vector> -// 0 = Export TBX form controls, 1 = Export OCX form controls. -#define EXC_EXP_OCX_CTRL 0 - namespace utl { class TempFile; } // ============================================================================ @@ -59,11 +56,8 @@ class XclExpDffAnchorBase; class XclEscherHostAppData; class XclEscherClientData; class XclEscherClientTextbox; -#if EXC_EXP_OCX_CTRL class XclExpOcxControlObj; -#else class XclExpTbxControlObj; -#endif class XclExpShapeObj; class EscherExHostAppData; class ShapeInteractionHelper @@ -111,19 +105,16 @@ public: /// Flush and merge PicStream into EscherStream void EndDocument(); - -#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 ); @@ -133,7 +124,6 @@ private: XclExpTbxControlObj& rTbxCtrlObj, ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > xCtrlModel ); -#endif void DeleteCurrAppData(); diff --git a/sc/source/filter/inc/xeescher.hxx b/sc/source/filter/inc/xeescher.hxx index 9c91e72..cfb396a 100644 --- a/sc/source/filter/inc/xeescher.hxx +++ b/sc/source/filter/inc/xeescher.hxx @@ -236,7 +236,8 @@ private: // ---------------------------------------------------------------------------- -#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 @@ -258,7 +259,7 @@ private: sal_uInt32 mnStrmSize; /// Size in 'Ctls' stream. }; -#else +//#else /** Represents an OBJ record for an TBX form control. */ class XclExpTbxControlObj : public XclObj, public XclMacroHelper @@ -299,7 +300,7 @@ private: bool mbScrollHor; /// Scrollbar: true = horizontal. }; -#endif +//#endif // ---------------------------------------------------------------------------- diff --git a/sc/source/filter/xcl97/xcl97esc.cxx b/sc/source/filter/xcl97/xcl97esc.cxx index 6d7a15b..4ffad40 100644 --- a/sc/source/filter/xcl97/xcl97esc.cxx +++ b/sc/source/filter/xcl97/xcl97esc.cxx @@ -23,6 +23,8 @@ #include <com/sun/star/form/XFormsSupplier.hpp> #include <com/sun/star/script/ScriptEventDescriptor.hpp> #include <com/sun/star/script/XEventAttacherManager.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/form/XForm.hpp> #include <svx/svdpage.hxx> #include <editeng/outlobj.hxx> @@ -61,6 +63,10 @@ using ::com::sun::star::container::XIndexAccess; 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; @@ -200,6 +206,8 @@ EscherExHostAppData* XclEscherEx::StartShape( const Reference< XShape >& rxShape aStack.push( std::make_pair( pCurrXclObj, pCurrAppData ) ); pCurrAppData = new XclEscherHostAppData; SdrObject* pObj = GetSdrObjectFromXShape( rxShape ); + //added for exporting OCX control + sal_Int16 nMsCtlType = 0; if ( !pObj ) pCurrXclObj = new XclObjAny( mrObjMgr, rxShape ); // just what is it?!? else @@ -233,13 +241,22 @@ EscherExHostAppData* XclEscherEx::StartShape( const Reference< XShape >& rxShape } 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")); + aAny >>= nMsCtlType; + } + catch(const Exception&) + { + OSL_TRACE("XclEscherEx::StartShape, this control can't get the property ControlTypeinMSO!"); + } + if( nMsCtlType == 2 ) //OCX Form Control + pCurrXclObj = CreateOCXCtrlObj( rxShape, pChildAnchor ); + else //TBX Form Control + pCurrXclObj = CreateTBXCtrlObj( rxShape, pChildAnchor ); if( !pCurrXclObj ) pCurrXclObj = new XclObjAny( mrObjMgr, rxShape ); // just a metafile } @@ -298,6 +315,30 @@ EscherExHostAppData* XclEscherEx::StartShape( const Reference< XShape >& rxShape } } } + //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 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(const Exception&) + { + 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; @@ -369,9 +410,10 @@ void XclEscherEx::EndDocument() 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; @@ -399,9 +441,9 @@ XclExpOcxControlObj* XclEscherEx::CreateCtrlObj( Reference< XShape > xShape, con 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 ) @@ -469,7 +511,7 @@ void XclEscherEx::ConvertTbxMacro( XclExpTbxControlObj& rTbxCtrlObj, Reference< } } -#endif +//#endif void XclEscherEx::DeleteCurrAppData() { diff --git a/svx/source/unodraw/unoshap2.cxx b/svx/source/unodraw/unoshap2.cxx index 0b89df2..546b890 100644 --- a/svx/source/unodraw/unoshap2.cxx +++ b/svx/source/unodraw/unoshap2.cxx @@ -688,6 +688,9 @@ SvxShapeControlPropertyMapping[] = { 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 } }; _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
