diff options
Diffstat (limited to 'sc/source/filter')
-rw-r--r-- | sc/source/filter/excel/excimp8.cxx | 28 | ||||
-rw-r--r-- | sc/source/filter/excel/makefile.mk | 4 | ||||
-rw-r--r-- | sc/source/filter/excel/read.cxx | 65 | ||||
-rw-r--r-- | sc/source/filter/excel/xecontent.cxx | 11 | ||||
-rw-r--r-- | sc/source/filter/excel/xeescher.cxx | 86 | ||||
-rw-r--r-- | sc/source/filter/excel/xiescher.cxx | 145 | ||||
-rw-r--r-- | sc/source/filter/excel/xiname.cxx | 23 | ||||
-rw-r--r-- | sc/source/filter/excel/xistyle.cxx | 63 | ||||
-rw-r--r-- | sc/source/filter/excel/xlescher.cxx | 2 | ||||
-rw-r--r-- | sc/source/filter/excel/xltools.cxx | 7 | ||||
-rw-r--r-- | sc/source/filter/inc/excimp8.hxx | 3 | ||||
-rw-r--r-- | sc/source/filter/inc/xcl97esc.hxx | 9 | ||||
-rw-r--r-- | sc/source/filter/inc/xcl97rec.hxx | 2 | ||||
-rw-r--r-- | sc/source/filter/inc/xecontent.hxx | 2 | ||||
-rw-r--r-- | sc/source/filter/inc/xeescher.hxx | 33 | ||||
-rw-r--r-- | sc/source/filter/inc/xiescher.hxx | 51 | ||||
-rw-r--r-- | sc/source/filter/inc/xistyle.hxx | 2 | ||||
-rw-r--r-- | sc/source/filter/inc/xlescher.hxx | 2 | ||||
-rw-r--r-- | sc/source/filter/xcl97/xcl97esc.cxx | 44 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlexprt.cxx | 27 |
20 files changed, 546 insertions, 63 deletions
diff --git a/sc/source/filter/excel/excimp8.cxx b/sc/source/filter/excel/excimp8.cxx index d75a0e669603..cea32d5ce23e 100644 --- a/sc/source/filter/excel/excimp8.cxx +++ b/sc/source/filter/excel/excimp8.cxx @@ -99,15 +99,20 @@ #include "stlpool.hxx" #include "stlsheet.hxx" #include "detfunc.hxx" +#include "macromgr.hxx" #include <com/sun/star/document/XDocumentProperties.hpp> #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> +#include <com/sun/star/script/ModuleInfo.hpp> #include <cppuhelper/component_context.hxx> #include <sfx2/app.hxx> +#include "xltoolbar.hxx" using namespace com::sun::star; using ::rtl::OUString; +// defined in docfunc.cxx ( really this needs a new name ) +script::ModuleInfo lcl_InitModuleInfo( SfxObjectShell& rDocSh, String& sModule ); ImportExcel8::ImportExcel8( XclImpRootData& rImpData, SvStream& rStrm ) : ImportExcel( rImpData, rStrm ) @@ -242,7 +247,30 @@ void ImportExcel8::ReadBasic( void ) { SvxImportMSVBasic aBasicImport( *pShell, *xRootStrg, bLoadCode, bLoadStrg ); bool bAsComment = !bLoadExecutable; + + if ( !bAsComment ) + { + ScDocument& rDoc = GetDoc(); +#if 1 + // see if we have the XCB stream + SvStorageStreamRef xXCB = xRootStrg->OpenSotStream( String( RTL_CONSTASCII_USTRINGPARAM( "XCB" ) ), STREAM_STD_READ | STREAM_NOCREATE ); + if ( xXCB.Is()|| SVSTREAM_OK == xXCB->GetError() ) + { + CTBWrapper wrapper; + if ( wrapper.Read( xXCB ) ) + { +#if DEBUG + wrapper.Print( stderr ); +#endif + wrapper.ImportCustomToolBar( *pShell ); + } + } +#endif + + } aBasicImport.Import( EXC_STORAGE_VBA_PROJECT, EXC_STORAGE_VBA, bAsComment ); + if ( !bAsComment ) + GetObjectManager().SetOleNameOverrideInfo( aBasicImport.ControlNameForObjectId() ); } } } diff --git a/sc/source/filter/excel/makefile.mk b/sc/source/filter/excel/makefile.mk index 04ba76d4a68a..a84f4aaa907e 100644 --- a/sc/source/filter/excel/makefile.mk +++ b/sc/source/filter/excel/makefile.mk @@ -102,7 +102,8 @@ SLOFILES = \ $(SLO)$/xlstyle.obj \ $(SLO)$/xltools.obj \ $(SLO)$/xltracer.obj \ - $(SLO)$/xlview.obj + $(SLO)$/xlview.obj \ + $(SLO)$/xltoolbar.obj \ .IF "$(OS)$(COM)$(CPUNAME)"=="LINUXGCCSPARC" NOOPTFILES = \ @@ -151,6 +152,7 @@ EXCEPTIONSFILES = \ $(SLO)$/xlpivot.obj \ $(SLO)$/xlroot.obj \ $(SLO)$/xlstyle.obj \ + $(SLO)$/xltoolbar.obj \ $(SLO)$/xltools.obj \ $(SLO)$/xlview.obj diff --git a/sc/source/filter/excel/read.cxx b/sc/source/filter/excel/read.cxx index e035d4d37c8f..54e1b99f321e 100644 --- a/sc/source/filter/excel/read.cxx +++ b/sc/source/filter/excel/read.cxx @@ -831,6 +831,12 @@ FltError ImportExcel8::Read( void ) sal_Size nProgressBasePos = 0; sal_Size nProgressBaseSize = 0; + bool bSheetHasCodeName = false; + + std::vector< String > CodeNames; + + std::vector < SCTAB > nTabsWithNoCodeName; + while( eAkt != EXC_STATE_END ) { if( eAkt == EXC_STATE_BEFORE_SHEET ) @@ -912,6 +918,7 @@ FltError ImportExcel8::Read( void ) // #i62752# possible to have BIFF8 sheet without globals NeueTabelle(); eAkt = EXC_STATE_SHEET_PRE; // Shrfmla Prefetch, Row-Prefetch + bSheetHasCodeName = false; // reset aIn.StoreGlobalPosition(); } } @@ -1082,12 +1089,32 @@ FltError ImportExcel8::Read( void ) case EXC_ID2_DIMENSIONS: case EXC_ID3_DIMENSIONS: ReadDimensions(); break; - case EXC_ID_CODENAME: ReadCodeName( aIn, false ); break; + case EXC_ID_CODENAME: ReadCodeName( aIn, false ); bSheetHasCodeName = true; break; case 0x0A: // EOF [ 2345 ] + { eAkt = EXC_STATE_SHEET; + String sName; + GetDoc().GetName( GetCurrScTab(), sName ); + if ( !bSheetHasCodeName ) + { + nTabsWithNoCodeName.push_back( GetCurrScTab() ); + OSL_TRACE("No Codename for %d", GetCurrScTab() ); + } + else + { + String sCodeName; + GetDoc().GetCodeName( GetCurrScTab(), sCodeName ); + OSL_TRACE("Have CodeName %s for SheetName %s", + rtl::OUStringToOString( sCodeName, RTL_TEXTENCODING_UTF8 ).getStr(), rtl::OUStringToOString( sName, RTL_TEXTENCODING_UTF8 ).getStr() ); + CodeNames.push_back( sCodeName ); + } + + bSheetHasCodeName = false; // reset + aIn.SeekGlobalPosition(); // und zurueck an alte Position break; + } case 0x12: SheetProtect(); break; case 0x13: SheetPassword(); break; case 0x42: Codepage(); break; // CODEPAGE [ 2345 ] @@ -1206,6 +1233,42 @@ FltError ImportExcel8::Read( void ) if( eLastErr == eERR_OK ) { + // In some strange circumstances a the codename might be missing + // # Create any missing Sheet CodeNames + std::vector < SCTAB >::iterator it_end = nTabsWithNoCodeName.end(); + for ( std::vector < SCTAB >::iterator it = nTabsWithNoCodeName.begin(); it != it_end; ++it ) + { + bool bGotCodeName = false; + SCTAB nTab = 1; + OSL_TRACE("Trying to find suitable codename for %d", *it ); + while ( true ) + { + String sTmpName( RTL_CONSTASCII_USTRINGPARAM("Sheet" ) ); + sTmpName += String::CreateFromInt32( sal_Int32(nTab++) ); + std::vector< String >::iterator codeName_It = CodeNames.begin(); + std::vector< String >::iterator codeName_It_end = CodeNames.end(); + // search for codename + for ( ; codeName_It != codeName_It_end; ++codeName_It ) + { + if ( *codeName_It == sTmpName ) + break; + } + + if ( codeName_It == codeName_It_end ) // generated codename not found + { + OSL_TRACE("Using generated codename %s", rtl::OUStringToOString( sTmpName, RTL_TEXTENCODING_UTF8 ).getStr() ); + // Set new codename + GetDoc().SetCodeName( *it, sTmpName ); + // Record newly used codename + CodeNames.push_back( sTmpName ); + // Record those we have created so they can be created in + // basic + AutoGeneratedCodeNames.push_back( sTmpName ); + break; + } + } + + } // #i45843# Convert pivot tables before calculation, so they are available // for the GETPIVOTDATA function. if( GetBiff() == EXC_BIFF8 ) diff --git a/sc/source/filter/excel/xecontent.cxx b/sc/source/filter/excel/xecontent.cxx index 7bfd57be7290..0ac140fd124e 100644 --- a/sc/source/filter/excel/xecontent.cxx +++ b/sc/source/filter/excel/xecontent.cxx @@ -516,12 +516,17 @@ void XclExpHyperlink::WriteBody( XclExpStream& rStrm ) { sal_uInt16 nXclCol = static_cast< sal_uInt16 >( maScPos.Col() ); sal_uInt16 nXclRow = static_cast< sal_uInt16 >( maScPos.Row() ); - mxVarData->Seek( STREAM_SEEK_TO_BEGIN ); + rStrm << nXclRow << nXclRow << nXclCol << nXclCol; + WriteEmbeddedData( rStrm ); +} - rStrm << nXclRow << nXclRow << nXclCol << nXclCol - << XclTools::maGuidStdLink +void XclExpHyperlink::WriteEmbeddedData( XclExpStream& rStrm ) +{ + rStrm << XclTools::maGuidStdLink << sal_uInt32( 2 ) << mnFlags; + + mxVarData->Seek( STREAM_SEEK_TO_BEGIN ); rStrm.CopyFromStream( *mxVarData ); } diff --git a/sc/source/filter/excel/xeescher.cxx b/sc/source/filter/excel/xeescher.cxx index 0509f2afa5fa..5edc3e3e823a 100644 --- a/sc/source/filter/excel/xeescher.cxx +++ b/sc/source/filter/excel/xeescher.cxx @@ -63,6 +63,9 @@ #include "xelink.hxx" #include "xename.hxx" #include "xestyle.hxx" +#include "userdat.hxx" +#include "drwlayer.hxx" +#include "svx/unoapi.hxx" #include <oox/core/tokens.hxx> @@ -484,9 +487,9 @@ void XclExpOcxControlObj::WriteSubRecs( XclExpStream& rStrm ) #else -XclExpTbxControlObj::XclExpTbxControlObj( XclExpObjectManager& rObjMgr, Reference< XShape > xShape, const Rectangle* pChildAnchor ) : - XclObj( rObjMgr, EXC_OBJTYPE_UNKNOWN, true ), - XclExpControlHelper( rObjMgr.GetRoot() ), +XclExpTbxControlObj::XclExpTbxControlObj( XclExpObjectManager& rRoot, Reference< XShape > xShape , const Rectangle* pChildAnchor ) : + XclObj( rRoot, EXC_OBJTYPE_UNKNOWN, true ), + XclMacroHelper( rRoot ), mnHeight( 0 ), mnState( 0 ), mnLineCount( 0 ), @@ -735,6 +738,8 @@ XclExpTbxControlObj::XclExpTbxControlObj( XclExpObjectManager& rObjMgr, Referenc bool XclExpTbxControlObj::SetMacroLink( const ScriptEventDescriptor& rEvent ) { + return XclMacroHelper::SetMacroLink( rEvent, meEventType ); +/* String aMacroName = XclControlHelper::ExtractFromMacroDescriptor( rEvent, meEventType ); if( aMacroName.Len() ) { @@ -744,6 +749,7 @@ bool XclExpTbxControlObj::SetMacroLink( const ScriptEventDescriptor& rEvent ) return true; } return false; +*/ } void XclExpTbxControlObj::WriteSubRecs( XclExpStream& rStrm ) @@ -882,12 +888,6 @@ void XclExpTbxControlObj::WriteSubRecs( XclExpStream& rStrm ) } } -void XclExpTbxControlObj::WriteMacroSubRec( XclExpStream& rStrm ) -{ - if( mxMacroLink.is() ) - WriteFormulaSubRec( rStrm, EXC_ID_OBJMACRO, *mxMacroLink ); -} - void XclExpTbxControlObj::WriteCellLinkSubRec( XclExpStream& rStrm, sal_uInt16 nSubRecId ) { if( const XclTokenArray* pCellLink = GetCellLinkTokArr() ) @@ -916,6 +916,7 @@ void XclExpTbxControlObj::WriteSbs( XclExpStream& rStrm ) #endif + // ---------------------------------------------------------------------------- XclExpChartObj::XclExpChartObj( XclExpObjectManager& rObjMgr, Reference< XShape > xShape, const Rectangle* pChildAnchor ) : @@ -1059,6 +1060,7 @@ void XclExpNote::Save( XclExpStream& rStrm ) } } + void XclExpNote::WriteBody( XclExpStream& rStrm ) { // BIFF5/BIFF7 is written separately @@ -1095,6 +1097,72 @@ void XclExpNote::WriteXml( sal_Int32 nAuthorId, XclExpXmlStream& rStrm ) // ============================================================================ +XclMacroHelper::XclMacroHelper( const XclExpRoot& rRoot ) : + XclExpControlHelper( rRoot ) +{ +} + +XclMacroHelper::~XclMacroHelper() +{ +} + +void XclMacroHelper::WriteMacroSubRec( XclExpStream& rStrm ) +{ + if( mxMacroLink.is() ) + WriteFormulaSubRec( rStrm, EXC_ID_OBJMACRO, *mxMacroLink ); +} + +bool +XclMacroHelper::SetMacroLink( const ScriptEventDescriptor& rEvent, const XclTbxEventType& nEventType ) +{ + String aMacroName = XclControlHelper::ExtractFromMacroDescriptor( rEvent, nEventType, GetDocShell() ); + if( aMacroName.Len() ) + { + return SetMacroLink( aMacroName ); + } + return false; +} + +bool +XclMacroHelper::SetMacroLink( const String& rMacroName ) +{ + OSL_TRACE("SetMacroLink( macroname:=%s )", rtl::OUStringToOString( rMacroName, RTL_TEXTENCODING_UTF8 ).getStr() ); + if( rMacroName.Len() ) + { + sal_uInt16 nExtSheet = GetLocalLinkManager().FindExtSheet( EXC_EXTSH_OWNDOC ); + sal_uInt16 nNameIdx = GetNameManager().InsertMacroCall( rMacroName, true, false ); + mxMacroLink = GetFormulaCompiler().CreateNameXFormula( nExtSheet, nNameIdx ); + return true; + } + return false; +} + +XclExpShapeObj::XclExpShapeObj( XclExpObjectManager& rRoot, ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape ) : + XclObjAny( rRoot ), + XclMacroHelper( rRoot ) +{ + if( SdrObject* pSdrObj = ::GetSdrObjectFromXShape( xShape ) ) + { + ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( pSdrObj ); + if ( pInfo && pInfo->GetMacro().getLength() ) +// FIXME ooo330-m2: XclControlHelper::GetXclMacroName was removed in upstream sources; they started to call XclTools::GetXclMacroName instead; is this enough? it has only one parameter +// SetMacroLink( XclControlHelper::GetXclMacroName( pInfo->GetMacro(), rRoot.GetDocShell() ) ); + SetMacroLink( XclTools::GetXclMacroName( pInfo->GetMacro() ) ); + } +} + +XclExpShapeObj::~XclExpShapeObj() +{ +} + +void XclExpShapeObj::WriteSubRecs( XclExpStream& rStrm ) +{ + XclObjAny::WriteSubRecs( rStrm ); + WriteMacroSubRec( rStrm ); +} + +// ============================================================================ + XclExpComments::XclExpComments( SCTAB nTab, XclExpRecordList< XclExpNote >& rNotes ) : mnTab( nTab ), mrNotes( rNotes ) { diff --git a/sc/source/filter/excel/xiescher.cxx b/sc/source/filter/excel/xiescher.cxx index 557f59654f92..ff56a9262ae9 100644 --- a/sc/source/filter/excel/xiescher.cxx +++ b/sc/source/filter/excel/xiescher.cxx @@ -109,6 +109,8 @@ #include "xipage.hxx" #include "xichart.hxx" #include "xicontent.hxx" +#include "scextopt.hxx" + #include "namebuff.hxx" using ::rtl::OUString; @@ -236,6 +238,7 @@ XclImpDrawObjBase::~XclImpDrawObjBase() } } + xDrawObj->mnTab = rRoot.GetCurrScTab(); xDrawObj->ImplReadObj3( rStrm ); return xDrawObj; } @@ -268,6 +271,7 @@ XclImpDrawObjBase::~XclImpDrawObjBase() } } + xDrawObj->mnTab = rRoot.GetCurrScTab(); xDrawObj->ImplReadObj4( rStrm ); return xDrawObj; } @@ -310,6 +314,7 @@ XclImpDrawObjBase::~XclImpDrawObjBase() } } + xDrawObj->mnTab = rRoot.GetCurrScTab(); xDrawObj->ImplReadObj5( rStrm ); return xDrawObj; } @@ -368,6 +373,7 @@ XclImpDrawObjBase::~XclImpDrawObjBase() } } + xDrawObj->mnTab = rRoot.GetCurrScTab(); xDrawObj->ImplReadObj8( rStrm ); return xDrawObj; } @@ -468,8 +474,9 @@ void XclImpDrawObjBase::PreProcessSdrObject( XclImpDffConverter& rDffConv, SdrOb } // macro and hyperlink -#ifdef ISSUE66550_HLINK_FOR_SHAPES - if( mbSimpleMacro && ((maMacroName.Len() > 0) || (maHyperlink.getLength() > 0)) ) + // removed oracle/sun check for mbSimpleMacro ( no idea what its for ) + if( (maMacroName.Len() > 0 ) || + (maHyperlink.Len() > 0) ) { if( ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( &rSdrObj, TRUE ) ) { @@ -477,11 +484,6 @@ void XclImpDrawObjBase::PreProcessSdrObject( XclImpDffConverter& rDffConv, SdrOb pInfo->SetHlink( maHyperlink ); } } -#else - if( mbSimpleMacro && (maMacroName.Len() > 0) ) - if( ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( &rSdrObj, TRUE ) ) - pInfo->SetMacro( XclTools::GetSbMacroUrl( maMacroName, GetDocShell() ) ); -#endif // call virtual function for object type specific processing DoPreProcessSdrObj( rDffConv, rSdrObj ); @@ -1761,22 +1763,15 @@ SdrObject* XclImpControlHelper::CreateSdrObjectFromShape( return xSdrObj.release(); } -void XclImpControlHelper::ProcessControl( const XclImpDrawObjBase& rDrawObj ) const +void XclImpControlHelper::ApplySheetLinkProps() const { + Reference< XControlModel > xCtrlModel = XclControlHelper::GetControlModel( mxShape ); if( !xCtrlModel.is() ) return; - ScfPropertySet aPropSet( xCtrlModel ); - // #118053# #i51348# set object name at control model - aPropSet.SetStringProperty( CREATE_OUSTRING( "Name" ), rDrawObj.GetObjName() ); - - // control visible and printable? - aPropSet.SetBoolProperty( CREATE_OUSTRING( "EnableVisible" ), rDrawObj.IsVisible() ); - aPropSet.SetBoolProperty( CREATE_OUSTRING( "Printable" ), rDrawObj.IsPrintable() ); - - // sheet links + // sheet links if( SfxObjectShell* pDocShell = mrRoot.GetDocShell() ) { Reference< XMultiServiceFactory > xFactory( pDocShell->GetModel(), UNO_QUERY ); @@ -1839,6 +1834,25 @@ void XclImpControlHelper::ProcessControl( const XclImpDrawObjBase& rDrawObj ) co } } } +} + +void XclImpControlHelper::ProcessControl( const XclImpDrawObjBase& rDrawObj ) const +{ + Reference< XControlModel > xCtrlModel = XclControlHelper::GetControlModel( mxShape ); + if( !xCtrlModel.is() ) + return; + + ApplySheetLinkProps(); + + ScfPropertySet aPropSet( xCtrlModel ); + + // #118053# #i51348# set object name at control model + aPropSet.SetStringProperty( CREATE_OUSTRING( "Name" ), rDrawObj.GetObjName() ); + + // control visible and printable? + aPropSet.SetBoolProperty( CREATE_OUSTRING( "EnableVisible" ), rDrawObj.IsVisible() ); + aPropSet.SetBoolProperty( CREATE_OUSTRING( "Printable" ), rDrawObj.IsPrintable() ); + // virtual call for type specific processing DoProcessControl( aPropSet ); @@ -2170,6 +2184,45 @@ void XclImpOptionButtonObj::DoProcessControl( ScfPropertySet& rPropSet ) const { XclImpCheckBoxObj::DoProcessControl( rPropSet ); // TODO: grouping + XclImpOptionButtonObj* pTbxObj = dynamic_cast< XclImpOptionButtonObj* >( GetObjectManager().GetSheetDrawing( GetTab() ).FindDrawObj( mnNextInGroup ).get() ); + if ( ( pTbxObj && pTbxObj->mnFirstInGroup ) ) + { + // Group has terminated + // traverse each RadioButton in group and + // a) apply the groupname + // b) propagate the linked cell from the lead radiobutton + // c) apply the correct Ref value + XclImpOptionButtonObj* pLeader = pTbxObj; + ; + sal_Int32 nRefVal = 1; + OSL_TRACE( "0x%x start group ", pLeader->GetObjId()/*.mnObjId */); + do + { + + Reference< XControlModel > xCtrlModel = XclControlHelper::GetControlModel( pTbxObj->mxShape ); + if ( xCtrlModel.is() ) + { + ScfPropertySet aProps( xCtrlModel ); + rtl::OUString sGroupName = rtl::OUString::valueOf( static_cast< sal_Int32 >( pLeader->GetDffShapeId() ) ); + + aProps.SetStringProperty( CREATE_OUSTRING( "GroupName" ), sGroupName ); + aProps.SetStringProperty( CREATE_OUSTRING( "RefValue" ), rtl::OUString::valueOf( nRefVal++ ) ); + if ( pLeader->HasCellLink() && !pTbxObj->HasCellLink() ) + { + // propagate cell link info + pTbxObj->mxCellLink.reset( new ScAddress( *pLeader->mxCellLink.get() ) ); + pTbxObj->ApplySheetLinkProps(); + } + pTbxObj = dynamic_cast< XclImpOptionButtonObj* >( GetObjectManager().GetSheetDrawing( GetTab() ).FindDrawObj( pTbxObj->mnNextInGroup ).get() ); + } + else + pTbxObj = NULL; + } while ( pTbxObj && !( pTbxObj->mnFirstInGroup == 1 ) ); + } + else + { + // not the leader? try and find it + } } OUString XclImpOptionButtonObj::DoGetServiceName() const @@ -2806,6 +2859,17 @@ SdrObject* XclImpPictureObj::DoCreateSdrObj( XclImpDffConverter& rDffConv, const return xSdrObj.release(); } +String XclImpPictureObj::GetObjName() const +{ + if( IsOcxControl() ) + { + String sName( GetObjectManager().GetOleNameOverride( GetTab(), GetObjId() ) ); + if ( sName.Len() > 0 ) + return sName; + } + return XclImpDrawObjBase::GetObjName(); +} + void XclImpPictureObj::DoPreProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const { if( IsOcxControl() ) @@ -3115,6 +3179,27 @@ XclImpDffConverter::~XclImpDffConverter() { } +String XclImpObjectManager::GetOleNameOverride( SCTAB nTab, sal_uInt16 nObjId ) +{ + String sOleName; + String sCodeName = GetExtDocOptions().GetCodeName( nTab ); + + CodeNameToCntrlObjIdInfo::iterator it = maOleCtrlNameOverride.find( sCodeName ); + if ( it != maOleCtrlNameOverride.end() ) + { + CntrlObjIdToName::iterator it_id = it->second.find( nObjId ); + if ( it_id != it->second.end() ) + { + sOleName = it_id->second; + } + } + OSL_TRACE("XclImpObjectManager::GetOleNameOverride tab %d, ( module %s ) object id ( %d ) is %s", nTab, + rtl::OUStringToOString( sCodeName, RTL_TEXTENCODING_UTF8 ).getStr(), nObjId, + rtl::OUStringToOString( sOleName, RTL_TEXTENCODING_UTF8 ).getStr() ); + + return sOleName; +} + void XclImpDffConverter::StartProgressBar( sal_Size nProgressSize ) { mxProgress.reset( new ScfProgressBar( GetDocShell(), STR_PROGRESS_CALCULATING ) ); @@ -3985,27 +4070,27 @@ XclImpObjectManager::XclImpObjectManager( const XclImpRoot& rRoot ) : XclImpRoot( rRoot ) { maDefObjNames[ EXC_OBJTYPE_GROUP ] = CREATE_STRING( "Group" ); - maDefObjNames[ EXC_OBJTYPE_LINE ] = CREATE_STRING( "Line" ); - maDefObjNames[ EXC_OBJTYPE_RECTANGLE ] = CREATE_STRING( "Rectangle" ); - maDefObjNames[ EXC_OBJTYPE_OVAL ] = CREATE_STRING( "Oval" ); + maDefObjNames[ EXC_OBJTYPE_LINE ] = ScGlobal::GetRscString( STR_SHAPE_LINE ); + maDefObjNames[ EXC_OBJTYPE_RECTANGLE ] = ScGlobal::GetRscString( STR_SHAPE_RECTANGLE ); + maDefObjNames[ EXC_OBJTYPE_OVAL ] = ScGlobal::GetRscString( STR_SHAPE_OVAL ); maDefObjNames[ EXC_OBJTYPE_ARC ] = CREATE_STRING( "Arc" ); maDefObjNames[ EXC_OBJTYPE_CHART ] = CREATE_STRING( "Chart" ); maDefObjNames[ EXC_OBJTYPE_TEXT ] = CREATE_STRING( "Text" ); - maDefObjNames[ EXC_OBJTYPE_BUTTON ] = CREATE_STRING( "Button" ); + maDefObjNames[ EXC_OBJTYPE_BUTTON ] = ScGlobal::GetRscString( STR_FORM_BUTTON ); maDefObjNames[ EXC_OBJTYPE_PICTURE ] = CREATE_STRING( "Picture" ); maDefObjNames[ EXC_OBJTYPE_POLYGON ] = CREATE_STRING( "Freeform" ); - maDefObjNames[ EXC_OBJTYPE_CHECKBOX ] = CREATE_STRING( "Check Box" ); - maDefObjNames[ EXC_OBJTYPE_OPTIONBUTTON ] = CREATE_STRING( "Option Button" ); + maDefObjNames[ EXC_OBJTYPE_CHECKBOX ] = ScGlobal::GetRscString( STR_FORM_CHECKBOX ); + maDefObjNames[ EXC_OBJTYPE_OPTIONBUTTON ] = ScGlobal::GetRscString( STR_FORM_OPTIONBUTTON ); maDefObjNames[ EXC_OBJTYPE_EDIT ] = CREATE_STRING( "Edit Box" ); - maDefObjNames[ EXC_OBJTYPE_LABEL ] = CREATE_STRING( "Label" ); + maDefObjNames[ EXC_OBJTYPE_LABEL ] = ScGlobal::GetRscString( STR_FORM_LABEL ); maDefObjNames[ EXC_OBJTYPE_DIALOG ] = CREATE_STRING( "Dialog Frame" ); - maDefObjNames[ EXC_OBJTYPE_SPIN ] = CREATE_STRING( "Spinner" ); - maDefObjNames[ EXC_OBJTYPE_SCROLLBAR ] = CREATE_STRING( "Scroll Bar" ); - maDefObjNames[ EXC_OBJTYPE_LISTBOX ] = CREATE_STRING( "List Box" ); - maDefObjNames[ EXC_OBJTYPE_GROUPBOX ] = CREATE_STRING( "Group Box" ); - maDefObjNames[ EXC_OBJTYPE_DROPDOWN ] = CREATE_STRING( "Drop Down" ); + maDefObjNames[ EXC_OBJTYPE_SPIN ] = ScGlobal::GetRscString( STR_FORM_SPINNER ); + maDefObjNames[ EXC_OBJTYPE_SCROLLBAR ] = ScGlobal::GetRscString( STR_FORM_SCROLLBAR ); + maDefObjNames[ EXC_OBJTYPE_LISTBOX ] = ScGlobal::GetRscString( STR_FORM_LISTBOX ); + maDefObjNames[ EXC_OBJTYPE_GROUPBOX ] = ScGlobal::GetRscString( STR_FORM_GROUPBOX ); + maDefObjNames[ EXC_OBJTYPE_DROPDOWN ] = ScGlobal::GetRscString( STR_FORM_DROPDOWN ); maDefObjNames[ EXC_OBJTYPE_NOTE ] = CREATE_STRING( "Comment" ); - maDefObjNames[ EXC_OBJTYPE_DRAWING ] = CREATE_STRING( "AutoShape" ); + maDefObjNames[ EXC_OBJTYPE_DRAWING ] = ScGlobal::GetRscString( STR_SHAPE_AUTOSHAPE ); } XclImpObjectManager::~XclImpObjectManager() diff --git a/sc/source/filter/excel/xiname.cxx b/sc/source/filter/excel/xiname.cxx index 5c0eac63de92..779edc5c990a 100644 --- a/sc/source/filter/excel/xiname.cxx +++ b/sc/source/filter/excel/xiname.cxx @@ -35,7 +35,8 @@ #include "excform.hxx" // for filter manager #include "excimp8.hxx" - +#include "scextopt.hxx" +#include "document.hxx" // ============================================================================ // *** Implementation *** // ============================================================================ @@ -127,6 +128,7 @@ XclImpName::XclImpName( XclImpStream& rStrm, sal_uInt16 nXclNameIdx ) : maScName = maXclName; ScfTools::ConvertToScDefinedName( maScName ); } + rtl::OUString aRealOrigName = maScName; // add index for local names if( nXclTab != EXC_NAME_GLOBAL ) @@ -219,6 +221,25 @@ XclImpName::XclImpName( XclImpStream& rStrm, sal_uInt16 nXclNameIdx ) : pData->GuessPosition(); // calculate base position for relative refs pData->SetIndex( nXclNameIdx ); // used as unique identifier in formulas rRangeNames.Insert( pData ); // takes ownership of pData + if( nXclTab != EXC_NAME_GLOBAL ) + { + if (GetBiff() == EXC_BIFF8) + { + ScRange aRange; + // discard deleted ranges ( for the moment at least ) + if ( pData->IsValidReference( aRange ) ) + { + ScExtTabSettings& rTabSett = GetExtDocOptions().GetOrCreateTabSettings( nXclTab ); + // create a mapping between the unmodified localname to + // the name in the global name container for named ranges + OSL_TRACE(" mapping local name to global name for tab %d which exists? %s", nXclTab, GetDoc().HasTable( mnScTab ) ? "true" : "false" ); + SCTAB nTab( static_cast< SCTAB >( mnScTab ) ); + NameToNameMap* pMap = GetDoc().GetLocalNameMap( nTab ); + if ( pMap ) + (*pMap)[ aRealOrigName ] = maScName; + } + } + } mpScData = pData; // cache for later use } } diff --git a/sc/source/filter/excel/xistyle.cxx b/sc/source/filter/excel/xistyle.cxx index 1559ef5530f5..bcca95e6e29f 100644 --- a/sc/source/filter/excel/xistyle.cxx +++ b/sc/source/filter/excel/xistyle.cxx @@ -65,10 +65,70 @@ #include "root.hxx" #include "colrowst.hxx" +#include <cppuhelper/implbase1.hxx> +#include <com/sun/star/container/XIndexAccess.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +using namespace ::com::sun::star; + +typedef ::cppu::WeakImplHelper1< container::XIndexAccess > XIndexAccess_BASE; +typedef ::std::vector< ColorData > ColorDataVec; + +class PaletteIndex : public XIndexAccess_BASE +{ +public: + PaletteIndex( const ColorDataVec& rColorDataTable ) : maColorData( rColorDataTable ) {} + + // Methods XIndexAccess + virtual ::sal_Int32 SAL_CALL getCount() throw (uno::RuntimeException) + { + return maColorData.size(); + } + + virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) + { + //--Index; // apparently the palette is already 1 based + return uno::makeAny( sal_Int32( maColorData[ Index ] ) ); + } + + // Methods XElementAcess + virtual uno::Type SAL_CALL getElementType() throw (uno::RuntimeException) + { + return ::getCppuType( (sal_Int32*)0 ); + } + virtual ::sal_Bool SAL_CALL hasElements() throw (uno::RuntimeException) + { + return (maColorData.size() > 0); + } + +private: + ColorDataVec maColorData; +}; + +void +XclImpPalette::ExportPalette() +{ + if( SfxObjectShell* pDocShell = mrRoot.GetDocShell() ) + { + // copy values in color palette + sal_Int16 nColors = maColorTable.size(); + ColorDataVec aColors; + aColors.resize( nColors ); + for( sal_uInt16 nIndex = 0; nIndex < nColors; ++nIndex ) + aColors[ nIndex ] = GetColorData( nIndex ); + + uno::Reference< beans::XPropertySet > xProps( pDocShell->GetModel(), uno::UNO_QUERY ); + if ( xProps.is() ) + { + uno::Reference< container::XIndexAccess > xIndex( new PaletteIndex( aColors ) ); + xProps->setPropertyValue( CREATE_OUSTRING("ColorPalette"), uno::makeAny( xIndex ) ); + } + } + +} // PALETTE record - color information ========================================= XclImpPalette::XclImpPalette( const XclImpRoot& rRoot ) : - XclDefaultPalette( rRoot ) + XclDefaultPalette( rRoot ), mrRoot( rRoot ) { } @@ -102,6 +162,7 @@ void XclImpPalette::ReadPalette( XclImpStream& rStrm ) rStrm >> aColor; maColorTable[ nIndex ] = aColor.GetColor(); } + ExportPalette(); } // FONT record - font information ============================================= diff --git a/sc/source/filter/excel/xlescher.cxx b/sc/source/filter/excel/xlescher.cxx index 153a5d5ed3cc..0f8c363074b4 100644 --- a/sc/source/filter/excel/xlescher.cxx +++ b/sc/source/filter/excel/xlescher.cxx @@ -366,7 +366,7 @@ bool XclControlHelper::FillMacroDescriptor( ScriptEventDescriptor& rDescriptor, } String XclControlHelper::ExtractFromMacroDescriptor( - const ScriptEventDescriptor& rDescriptor, XclTbxEventType eEventType ) + const ScriptEventDescriptor& rDescriptor, XclTbxEventType eEventType, SfxObjectShell* pShell ) { if( (rDescriptor.ScriptCode.getLength() > 0) && rDescriptor.ScriptType.equalsIgnoreAsciiCaseAscii( "Script" ) && diff --git a/sc/source/filter/excel/xltools.cxx b/sc/source/filter/excel/xltools.cxx index 0dd988d67586..5fbcdc4db855 100644 --- a/sc/source/filter/excel/xltools.cxx +++ b/sc/source/filter/excel/xltools.cxx @@ -689,7 +689,7 @@ void XclTools::SkipSubStream( XclImpStream& rStrm ) // Basic macro names ---------------------------------------------------------- -const OUString XclTools::maSbMacroPrefix( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.script:Standard." ) ); +const OUString XclTools::maSbMacroPrefix( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.script:" ) ); const OUString XclTools::maSbMacroSuffix( RTL_CONSTASCII_USTRINGPARAM( "?language=Basic&location=document" ) ); OUString XclTools::GetSbMacroUrl( const String& rMacroName, SfxObjectShell* pDocShell ) @@ -714,7 +714,10 @@ String XclTools::GetXclMacroName( const OUString& rSbMacroUrl ) sal_Int32 nMacroNameLen = nSbMacroUrlLen - maSbMacroPrefix.getLength() - maSbMacroSuffix.getLength(); if( (nMacroNameLen > 0) && rSbMacroUrl.matchIgnoreAsciiCase( maSbMacroPrefix, 0 ) && rSbMacroUrl.matchIgnoreAsciiCase( maSbMacroSuffix, nSbMacroUrlLen - maSbMacroSuffix.getLength() ) ) - return rSbMacroUrl.copy( maSbMacroPrefix.getLength(), nMacroNameLen ); + { + sal_Int32 nPrjDot = rSbMacroUrl.indexOf( '.', maSbMacroPrefix.getLength() ) + 1; + return rSbMacroUrl.copy( nPrjDot, nSbMacroUrlLen - nPrjDot - maSbMacroSuffix.getLength() ); + } return String::EmptyString(); } diff --git a/sc/source/filter/inc/excimp8.hxx b/sc/source/filter/inc/excimp8.hxx index 7e4cca15dfe1..0f46a125b12c 100644 --- a/sc/source/filter/inc/excimp8.hxx +++ b/sc/source/filter/inc/excimp8.hxx @@ -57,6 +57,9 @@ public: virtual FltError Read( void ); protected: + // represents codename ( and associated modules ) + // not speficied directly in the binary format + std::vector< String > AutoGeneratedCodeNames; ExcScenarioList aScenList; void Calccount( void ); // 0x0C diff --git a/sc/source/filter/inc/xcl97esc.hxx b/sc/source/filter/inc/xcl97esc.hxx index fde03337cc0f..d590e44b15ed 100644 --- a/sc/source/filter/inc/xcl97esc.hxx +++ b/sc/source/filter/inc/xcl97esc.hxx @@ -70,6 +70,15 @@ class XclExpOcxControlObj; #else class XclExpTbxControlObj; #endif +class XclExpShapeObj; +class EscherExHostAppData; +class ShapeInteractionHelper +{ +public: + static XclExpShapeObj* CreateShapeObj( XclExpObjectManager& rObjMgr, const ::com::sun::star::uno::Reference< + ::com::sun::star::drawing::XShape >& xShape ); + static void PopulateShapeInteractionInfo( XclExpObjectManager& rObjMgr, const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape, EscherExHostAppData& rHostAppData ); +}; class XclEscherEx : public EscherEx, protected XclExpRoot { diff --git a/sc/source/filter/inc/xcl97rec.hxx b/sc/source/filter/inc/xcl97rec.hxx index 201562fa752c..0c35433760d0 100644 --- a/sc/source/filter/inc/xcl97rec.hxx +++ b/sc/source/filter/inc/xcl97rec.hxx @@ -220,7 +220,7 @@ public: class XclObjAny : public XclObj { -private: +protected: virtual void WriteSubRecs( XclExpStream& rStrm ); public: diff --git a/sc/source/filter/inc/xecontent.hxx b/sc/source/filter/inc/xecontent.hxx index 50c9466d2801..a999d97cb1f2 100644 --- a/sc/source/filter/inc/xecontent.hxx +++ b/sc/source/filter/inc/xecontent.hxx @@ -113,6 +113,8 @@ public: inline const String* GetRepr() const { return mxRepr.get(); } virtual void SaveXml( XclExpXmlStream& rStrm ); + + virtual void WriteEmbeddedData( XclExpStream& rStrm ); private: /** Builds file name from the passed file URL. Tries to convert to relative file name. @param rnLevel (out-param) The parent directory level. diff --git a/sc/source/filter/inc/xeescher.hxx b/sc/source/filter/inc/xeescher.hxx index d227db184f1a..51f1c8a12311 100644 --- a/sc/source/filter/inc/xeescher.hxx +++ b/sc/source/filter/inc/xeescher.hxx @@ -207,6 +207,34 @@ private: sal_uInt16 mnEntryCount; /// Number of entries in source range. }; +class XclMacroHelper : public XclExpControlHelper +{ +protected: + XclTokenArrayRef mxMacroLink; /// Token array containing a link to an attached macro. + +public: + explicit XclMacroHelper( const XclExpRoot& rRoot ); + virtual ~XclMacroHelper(); + /** Writes an ftMacro subrecord containing a macro link, or nothing, if no macro present. */ + void WriteMacroSubRec( XclExpStream& rStrm ); + /** Sets the name of a macro for object of passed type + @return true = The passed event descriptor was valid, macro name has been found. */ + bool SetMacroLink( const ::com::sun::star::script::ScriptEventDescriptor& rEvent, const XclTbxEventType& nEventType ); + + /** Sets the name of a macro + @return true = The passed macro name has been found. */ + bool SetMacroLink( const String& rMacro ); +}; + +class XclExpShapeObj : public XclObjAny, public XclMacroHelper +{ +public: + explicit XclExpShapeObj( XclExpObjectManager& rRoot, ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape ); + virtual ~XclExpShapeObj(); +private: + virtual void WriteSubRecs( XclExpStream& rStrm ); +}; + // ---------------------------------------------------------------------------- #if EXC_EXP_OCX_CTRL @@ -234,7 +262,7 @@ private: #else /** Represents an OBJ record for an TBX form control. */ -class XclExpTbxControlObj : public XclObj, public XclExpControlHelper +class XclExpTbxControlObj : public XclObj, public XclMacroHelper { public: explicit XclExpTbxControlObj( @@ -249,8 +277,6 @@ public: private: virtual void WriteSubRecs( XclExpStream& rStrm ); - /** Writes an ftMacro subrecord containing a macro link, or nothing, if no macro present. */ - void WriteMacroSubRec( XclExpStream& rStrm ); /** Writes a subrecord containing a cell link, or nothing, if no link present. */ void WriteCellLinkSubRec( XclExpStream& rStrm, sal_uInt16 nSubRecId ); /** Writes the ftSbs sub structure containing scrollbar data. */ @@ -258,7 +284,6 @@ private: private: ScfInt16Vec maMultiSel; /// Indexes of all selected entries in a multi selection. - XclTokenArrayRef mxMacroLink; /// Token array containing a link to an attached macro. XclTbxEventType meEventType; /// Type of supported macro event. sal_Int32 mnHeight; /// Height of the control. sal_uInt16 mnState; /// Checked/unchecked state. diff --git a/sc/source/filter/inc/xiescher.hxx b/sc/source/filter/inc/xiescher.hxx index 5f482909f982..ef6a0c790b28 100644 --- a/sc/source/filter/inc/xiescher.hxx +++ b/sc/source/filter/inc/xiescher.hxx @@ -30,6 +30,7 @@ #include <vector> #include <map> +#include <hash_map> #include <filter/msfilter/msdffimp.hxx> #include <filter/msfilter/msocximex.hxx> #include <vcl/graph.hxx> @@ -92,7 +93,7 @@ public: /** Returns the Excel object type from OBJ record. */ inline sal_uInt16 GetObjType() const { return mnObjType; } /** Returns the name of this object, may generate a default name. */ - String GetObjName() const; + virtual String GetObjName() const; /** Returns associated macro name, if set, otherwise zero length string. */ inline const String& GetMacroName() const { return maMacroName; } @@ -172,7 +173,7 @@ protected: virtual void DoPreProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const; /** Derived classes may perform additional processing for the passed SdrObject after insertion. */ virtual void DoPostProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const; - + SCTAB GetTab() const { return mnTab; } private: /** Reads the contents of a BIFF3 OBJ record. */ void ImplReadObj3( XclImpStream& rStrm ); @@ -186,6 +187,7 @@ private: private: XclObjAnchor maAnchor; /// The position of the object in its parent. sal_uInt16 mnObjId; /// The object identifier (unique per drawing). + SCTAB mnTab; /// Location of object sal_uInt16 mnObjType; /// The Excel object type from OBJ record. sal_uInt32 mnDffShapeId; /// Shape ID from DFF stream. sal_uInt32 mnDffFlags; /// Shape flags from DFF stream. @@ -502,6 +504,10 @@ protected: /** Derived classes will set additional properties for the current form control. */ virtual void DoProcessControl( ScfPropertySet& rPropSet ) const; + void ApplySheetLinkProps() const; + mutable ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > + mxShape; /// The UNO wrapper of the control shape. + ScfRef< ScAddress > mxCellLink; /// Linked cell in the Calc document. private: /** Reads a list of cell ranges from a formula at the current stream position. */ void ReadRangeList( ScRangeList& rScRanges, XclImpStream& rStrm ); @@ -510,9 +516,6 @@ private: private: const XclImpRoot& mrRoot; /// Not derived from XclImpRoot to allow multiple inheritance. - mutable ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > - mxShape; /// The UNO wrapper of the control shape. - ScfRef< ScAddress > mxCellLink; /// Linked cell in the Calc document. ScfRef< ScRange > mxSrcRange; /// Source data range in the Calc document. XclCtrlBindMode meBindMode; /// Value binding mode. }; @@ -614,6 +617,7 @@ protected: virtual XclTbxEventType DoGetEventType() const; protected: + void ApplyGrouping( XclImpOptionButtonObj& rLeader, sal_Int32 nRefVal ); sal_uInt16 mnNextInGroup; /// Next option button in a group. sal_uInt16 mnFirstInGroup; /// 1 = Button is the first in a group. }; @@ -862,7 +866,8 @@ class XclImpPictureObj : public XclImpRectObj, public XclImpControlHelper { public: explicit XclImpPictureObj( const XclImpRoot& rRoot ); - + /** Returns the ObjectName - can use non-obvious lookup for override in the associated vba document module stream**/ + virtual String GetObjName() const; /** Returns the graphic imported from the IMGDATA record. */ inline const Graphic& GetGraphic() const { return maGraphic; } /** Returns the visible area of the imported graphic. */ @@ -1207,6 +1212,8 @@ private: /** Stores all drawing and OLE objects and additional data related to these objects. */ class XclImpObjectManager : protected XclImpRoot { +typedef std::hash_map< sal_Int32, String > CntrlObjIdToName; +typedef std::map< String, CntrlObjIdToName > CodeNameToCntrlObjIdInfo; public: explicit XclImpObjectManager( const XclImpRoot& rRoot ); virtual ~XclImpObjectManager(); @@ -1223,9 +1230,41 @@ public: String GetDefaultObjName( const XclImpDrawObjBase& rDrawObj ) const; /** Returns the used area in the sheet with the passed index. */ ScRange GetUsedArea( SCTAB nScTab ) const; + void SetOleNameOverrideInfo( const CodeNameToCntrlObjIdInfo& rOverrideInfo ) { maOleCtrlNameOverride = rOverrideInfo; } + String GetOleNameOverride( SCTAB nTab, sal_uInt16 nObjId ); + // ------------------------------------------------------------------------ +private: + + CodeNameToCntrlObjIdInfo maOleCtrlNameOverride; + + /** Reads and returns a bitmap from WMF/PICT format. */ + static void ReadWmf( Graphic& rGraphic, XclImpStream& rStrm ); + /** Reads and returns a bitmap from BMP format. */ + static void ReadBmp( Graphic& rGraphic, XclImpStream& rStrm ); + + /** Reads contents of an DFF record and append data to internal DFF stream. */ + void ReadDffRecord( XclImpStream& rStrm ); + /** Reads a BIFF8 OBJ record following an MSODRAWING record. */ + void ReadObj8( XclImpStream& rStrm ); + /** Reads the TXO record and following CONTINUE records containing string and formatting. */ + void ReadTxo( XclImpStream& rStrm ); + + /** Reads a BIFF3-BIFF5 NOTE record. */ + void ReadNote3( XclImpStream& rStrm ); + /** Reads a BIFF8 NOTE record. */ + void ReadNote8( XclImpStream& rStrm ); + + /** Returns the size of the progress bar shown while processing all objects. */ + sal_Size GetProgressSize() const; // ------------------------------------------------------------------------ private: + typedef ::std::map< sal_Size, XclImpDrawObjRef > XclImpObjMap; + typedef ::std::map< XclObjId, XclImpDrawObjRef > XclImpObjMapById; + typedef ScfRef< XclImpObjTextData > XclImpObjTextRef; + typedef ::std::map< sal_Size, XclImpObjTextRef > XclImpObjTextMap; + typedef ::std::vector< XclObjId > XclObjIdVec; + typedef ::std::map< sal_uInt16, String > DefObjNameMap; typedef ScfRef< XclImpSheetDrawing > XclImpSheetDrawingRef; typedef ::std::map< SCTAB, XclImpSheetDrawingRef > XclImpSheetDrawingMap; diff --git a/sc/source/filter/inc/xistyle.hxx b/sc/source/filter/inc/xistyle.hxx index 104002542a17..eb656fa64eed 100644 --- a/sc/source/filter/inc/xistyle.hxx +++ b/sc/source/filter/inc/xistyle.hxx @@ -69,8 +69,10 @@ public: void ReadPalette( XclImpStream& rStrm ); private: + void ExportPalette(); typedef ::std::vector< ColorData > ColorDataVec; ColorDataVec maColorTable; /// Colors read from file. + const XclImpRoot& mrRoot; }; // FONT record - font information ============================================= diff --git a/sc/source/filter/inc/xlescher.hxx b/sc/source/filter/inc/xlescher.hxx index 921da6b8741b..b1fe7410ecea 100644 --- a/sc/source/filter/inc/xlescher.hxx +++ b/sc/source/filter/inc/xlescher.hxx @@ -441,7 +441,7 @@ public: /** Tries to extract an Excel macro name from the passed macro descriptor. */ static String ExtractFromMacroDescriptor( const ::com::sun::star::script::ScriptEventDescriptor& rDescriptor, - XclTbxEventType eEventType ); + XclTbxEventType eEventType, SfxObjectShell* pShell = NULL ); }; // ============================================================================ diff --git a/sc/source/filter/xcl97/xcl97esc.cxx b/sc/source/filter/xcl97/xcl97esc.cxx index a7c6dee67dc5..2f1e65297bfa 100644 --- a/sc/source/filter/xcl97/xcl97esc.cxx +++ b/sc/source/filter/xcl97/xcl97esc.cxx @@ -54,6 +54,9 @@ #include "global.hxx" #include "document.hxx" #include "drwlayer.hxx" +#include "xecontent.hxx" +#include <editeng/flditem.hxx> +#include "userdat.hxx" #include "xcl97rec.hxx" #include "xehelper.hxx" #include "xechart.hxx" @@ -256,7 +259,8 @@ EscherExHostAppData* XclEscherEx::StartShape( const Reference< XShape >& rxShape { // #107540# ignore permanent note shapes // #i12190# do not ignore callouts (do not filter by object type ID) - pCurrXclObj = new XclObjAny( mrObjMgr ); // just a metafile + pCurrXclObj = ShapeInteractionHelper::CreateShapeObj( mrObjMgr, rxShape ); + ShapeInteractionHelper::PopulateShapeInteractionInfo( mrObjMgr, rxShape, *pCurrAppData ); } } if ( pCurrXclObj ) @@ -359,7 +363,6 @@ EscherExHostAppData* XclEscherEx::EnterAdditionalTextGroup() return pCurrAppData; } - void XclEscherEx::EndDocument() { if( mbIsRootDff ) @@ -478,6 +481,7 @@ void XclEscherEx::DeleteCurrAppData() delete pCurrAppData->GetClientAnchor(); // delete pCurrAppData->GetClientData(); delete pCurrAppData->GetClientTextbox(); + delete pCurrAppData->GetInteractionInfo(); delete pCurrAppData; } } @@ -509,4 +513,40 @@ void XclEscherClientTextbox::WriteData( EscherEx& /*rEx*/ ) const pXclObj->SetText( GetRoot(), rTextObj ); } +XclExpShapeObj* +ShapeInteractionHelper::CreateShapeObj( XclExpObjectManager& rObjMgr, const Reference< XShape >& xShape ) +{ + return new XclExpShapeObj( rObjMgr, xShape ); +} + +void +ShapeInteractionHelper::PopulateShapeInteractionInfo( XclExpObjectManager& rObjMgr, const Reference< XShape >& xShape, EscherExHostAppData& rHostAppData ) +{ + try + { + SvMemoryStream* pMemStrm = NULL; + rtl::OUString sHyperLink; + rtl::OUString sMacro; + if ( ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( ::GetSdrObjectFromXShape( xShape ) ) ) + { + sHyperLink = pInfo->GetHlink(); + sMacro = pInfo->GetMacro(); + } + if ( sHyperLink.getLength() > 0 ) + { + pMemStrm = new SvMemoryStream(); + XclExpStream tmpStream( *pMemStrm, rObjMgr.GetRoot() ); + ScAddress dummyAddress; + SvxURLField aUrlField; + aUrlField.SetURL( sHyperLink ); + XclExpHyperlink hExpHlink( rObjMgr.GetRoot(), aUrlField, dummyAddress ); + hExpHlink.WriteEmbeddedData( tmpStream ); + } + if ( ( sHyperLink.getLength() > 0 ) || ( sMacro.getLength() > 0 ) ) + rHostAppData.SetInteractionInfo( new InteractionInfo( pMemStrm, true ) ); + } + catch( Exception& ) + { + } +} diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx index 6a72dfbc60fb..b7bd7876413d 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -3204,7 +3204,34 @@ void ScXMLExport::ExportShape(const uno::Reference < drawing::XShape >& xShape, } } if (!bIsChart) + { + // #i66550 HLINK_FOR_SHAPES + rtl::OUString sHlink; + uno::Reference< beans::XPropertySet > xProps( xShape, uno::UNO_QUERY ); + if ( xProps.is() ) + xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_HYPERLINK ) ) ) >>= sHlink; + + std::auto_ptr< SvXMLElementExport > pDrawA; + // enlose shapes with <draw:a> element only if sHlink contains something + if ( sHlink.getLength() > 0 ) + { + // need to get delete the attributes that are pre-loaded + // for the shape export ( otherwise they will become + // attributes of the draw:a element ) This *shouldn't* + // affect performance adversely as there are only a + // couple of attributes involved + uno::Reference< xml::sax::XAttributeList > xSaveAttribs( new SvXMLAttributeList( GetAttrList() ) ); + ClearAttrList(); + // Add Hlink + AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE ); + AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, sHlink); + pDrawA.reset( new SvXMLElementExport( *this, XML_NAMESPACE_DRAW, XML_A, sal_False, sal_False ) ); + // Attribute list has been cleared by previous operation + // re-add pre-loaded attributes + AddAttributeList( xSaveAttribs ); + } GetShapeExport()->exportShape(xShape, SEF_DEFAULT, pPoint); + } IncrementProgressBar(sal_False); } |