summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorJianyuan Li <lijiany@apache.org>2012-09-25 04:48:42 +0000
committerNoel Power <noel.power@suse.com>2013-06-11 14:10:01 +0100
commit74d631dfb37ec870575d873c82e982a58f65d60c (patch)
treeb5924443650c01a1bfc1d6fc8129619ff813fb06 /sc
parent0b84b7d0f2bdd2d8c0620f3eafca8f0dd0761ed3 (diff)
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
Diffstat (limited to 'sc')
-rw-r--r--sc/source/filter/excel/xeescher.cxx9
-rw-r--r--sc/source/filter/excel/xiescher.cxx74
-rw-r--r--sc/source/filter/inc/xcl97esc.hxx14
-rw-r--r--sc/source/filter/inc/xeescher.hxx7
-rw-r--r--sc/source/filter/xcl97/xcl97esc.cxx66
5 files changed, 139 insertions, 31 deletions
diff --git a/sc/source/filter/excel/xeescher.cxx b/sc/source/filter/excel/xeescher.cxx
index 77bfcb78bce5..54f9eac08f06 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 3c530f023005..241a7158eb8c 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 4ce70eea5330..7d0b501976dc 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 9c91e7246a46..cfb396a1459e 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 6d7a15b41a45..4ffad4065066 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()
{