Index: sc/inc/document.hxx =================================================================== --- sc/inc/document.hxx (revision 1391359) +++ sc/inc/document.hxx (working copy) @@ -232,6 +232,7 @@ // ----------------------------------------------------------------------- +enum { E_MEDIUM_FLAG_NONE = 0, E_MEDIUM_FLAG_EXCEL = 1, E_MEDIUM_FLAG_MSXML = 2 }; class ScDocument { @@ -390,6 +391,7 @@ sal_Bool bInsertingFromOtherDoc; bool bLoadingMedium; bool bImportingXML; // special handling of formula text + bool mbImportingMSXML; sal_Bool bXMLFromWrapper; // distinguish ScXMLImportWrapper from external component sal_Bool bCalcingAfterLoad; // in CalcAfterLoad TRUE // wenn temporaer keine Listener auf/abgebaut werden sollen @@ -1570,6 +1572,8 @@ void SetLoadingMedium( bool bVal ); void SetImportingXML( bool bVal ); bool IsImportingXML() const { return bImportingXML; } + void SetImportingMSXML( bool bVal ); + bool IsImportingMSXML() const { return mbImportingMSXML; } void SetXMLFromWrapper( sal_Bool bVal ); sal_Bool IsXMLFromWrapper() const { return bXMLFromWrapper; } void SetCalcingAfterLoad( sal_Bool bVal ) { bCalcingAfterLoad = bVal; } Index: sc/inc/drwlayer.hxx =================================================================== --- sc/inc/drwlayer.hxx (revision 1390863) +++ sc/inc/drwlayer.hxx (working copy) @@ -101,6 +101,7 @@ sal_Bool bRecording; sal_Bool bAdjustEnabled; sal_Bool bHyphenatorSet; + bool mbUndoAllowed; private: void MoveAreaTwips( SCTAB nTab, const Rectangle& rArea, const Point& rMove, @@ -150,6 +151,21 @@ sal_Bool IsRecording() const { return bRecording; } void AddCalcUndo( SdrUndoAction* pUndo ); + template< typename TUndoAction, typename TArg > + inline void AddCalcUndo( const TArg & rArg ) { if( this->IsUndoAllowed() ) this->AddCalcUndo( new TUndoAction( rArg ) ); } + + template< typename TUndoAction, typename TArg > + inline void AddCalcUndo( TArg & rArg ) { if( this->IsUndoAllowed() ) this->AddCalcUndo( new TUndoAction( rArg ) ); } + + template< typename TUndoAction, typename TArg1, typename TArg2 > + inline void AddCalcUndo( TArg1 & rArg1, TArg2 & rArg2 ) { if( this->IsUndoAllowed() ) this->AddCalcUndo( new TUndoAction( rArg1, rArg2 ) ); } + + template< typename TUndoAction, typename TArg1, typename TArg2 > + inline void AddCalcUndo( const TArg1 & rArg1, const TArg2 & rArg2 ) { if( this->IsUndoAllowed() ) this->AddCalcUndo( new TUndoAction( rArg1, rArg2 ) ); } + + template< typename TUndoAction, typename TArg1, typename TArg2, typename TArg3, typename TArg4, typename TArg5 > + inline void AddCalcUndo( const TArg1 & rArg1, const TArg2 & rArg2, const TArg3 & rArg3, const TArg4 & rArg4, const TArg5 & rArg5 ) { if( this->IsUndoAllowed() ) this->AddCalcUndo( new TUndoAction( rArg1, rArg2, rArg3, rArg4, rArg5 ) ); } + void MoveArea( SCTAB nTab, SCCOL nCol1,SCROW nRow1, SCCOL nCol2,SCROW nRow2, SCsCOL nDx,SCsROW nDy, sal_Bool bInsDel, bool bUpdateNoteCaptionPos = true ); void WidthChanged( SCTAB nTab, SCCOL nCol, long nDifTwips ); @@ -221,6 +237,9 @@ static void SetGlobalDrawPersist(SfxObjectShell* pPersist); protected: virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > createUnoModel(); +public: + inline void SetUndoAllowed( bool bUndoAllowed ){ mbUndoAllowed = bUndoAllowed; } + inline bool IsUndoAllowed() const{ return mbUndoAllowed; } }; Index: sc/source/core/data/documen2.cxx =================================================================== --- sc/source/core/data/documen2.cxx (revision 1390863) +++ sc/source/core/data/documen2.cxx (working copy) @@ -188,6 +188,7 @@ bInsertingFromOtherDoc( sal_False ), bLoadingMedium( false ), bImportingXML( false ), + mbImportingMSXML( false ), bXMLFromWrapper( sal_False ), bCalcingAfterLoad( sal_False ), bNoListening( sal_False ), Index: sc/source/core/data/documen9.cxx =================================================================== --- sc/source/core/data/documen9.cxx (revision 1390863) +++ sc/source/core/data/documen9.cxx (working copy) @@ -131,7 +131,7 @@ pNewPage->InsertObject( pNewObject ); if (pDrawLayer->IsRecording()) - pDrawLayer->AddCalcUndo( new SdrUndoInsertObj( *pNewObject ) ); + pDrawLayer->AddCalcUndo< SdrUndoInsertObj >( *pNewObject ); } pOldObject = aIter.Next(); @@ -197,6 +197,9 @@ if (bImportingXML) pDrawLayer->EnableAdjust(sal_False); + if( IsImportingMSXML( ) ) + pDrawLayer->SetUndoAllowed( false ); + pDrawLayer->SetForbiddenCharsTable( xForbiddenCharacters ); pDrawLayer->SetCharCompressType( GetAsianCompression() ); pDrawLayer->SetKernAsianPunctuation( GetAsianKerning() ); @@ -768,6 +771,14 @@ SetLoadingMedium(bVal); } +void ScDocument::SetImportingMSXML( bool bVal ) +{ + mbImportingMSXML = bVal; + + if (pDrawLayer) + pDrawLayer->SetUndoAllowed( !mbImportingMSXML ); +} + void ScDocument::SetXMLFromWrapper( sal_Bool bVal ) { bXMLFromWrapper = bVal; Index: sc/source/core/data/drwlayer.cxx =================================================================== --- sc/source/core/data/drwlayer.cxx (revision 1390863) +++ sc/source/core/data/drwlayer.cxx (working copy) @@ -213,7 +213,8 @@ pUndoGroup( NULL ), bRecording( sal_False ), bAdjustEnabled( sal_True ), - bHyphenatorSet( sal_False ) + bHyphenatorSet( sal_False ), + mbUndoAllowed( sal_True ) { pGlobalDrawPersist = NULL; // nur einmal benutzen @@ -379,7 +380,7 @@ ScDrawPage* pPage = (ScDrawPage*)AllocPage( sal_False ); InsertPage(pPage, static_cast(nTab)); if (bRecording) - AddCalcUndo(new SdrUndoNewPage(*pPage)); + AddCalcUndo< SdrUndoNewPage >(*pPage); return sal_True; // inserted } @@ -393,7 +394,7 @@ if (bRecording) { SdrPage* pPage = GetPage(static_cast(nTab)); - AddCalcUndo(new SdrUndoDelPage(*pPage)); // Undo-Action wird Owner der Page + AddCalcUndo< SdrUndoDelPage >(*pPage); // Undo-Action wird Owner der Page RemovePage( static_cast(nTab) ); // nur austragen, nicht loeschen } else @@ -442,7 +443,7 @@ pNewObject->NbcMove(Size(0,0)); pNewPage->InsertObject( pNewObject ); if (bRecording) - AddCalcUndo( new SdrUndoInsertObj( *pNewObject ) ); + AddCalcUndo< SdrUndoInsertObj >( *pNewObject ); } pOldObject = aIter.Next(); @@ -495,7 +496,7 @@ { if ( pObj->ISA( SdrRectObj ) && pData->maStart.IsValid() && pData->maEnd.IsValid() ) pData->maStart.PutInOrder( pData->maEnd ); - AddCalcUndo( new ScUndoObjData( pObj, aOldStt, aOldEnd, pData->maStart, pData->maEnd ) ); + AddCalcUndo< ScUndoObjData >( pObj, aOldStt, aOldEnd, pData->maStart, pData->maEnd ); RecalcPos( pObj, *pData, bNegativePage, bUpdateNoteCaptionPos ); } } @@ -588,7 +589,7 @@ if ( pObj->GetLogicRect() != aRect ) { if (bRecording) - AddCalcUndo( new SdrUndoGeoObj( *pObj ) ); + AddCalcUndo( *pObj ); pObj->SetLogicRect(aRect); } } @@ -613,7 +614,7 @@ if ( pObj->GetPoint( 0 ) != aStartPos ) { if (bRecording) - AddCalcUndo( new SdrUndoGeoObj( *pObj ) ); + AddCalcUndo< SdrUndoGeoObj> ( *pObj ); pObj->SetPoint( aStartPos, 0 ); } @@ -627,7 +628,7 @@ if ( pObj->GetPoint( 1 ) != aEndPos ) { if (bRecording) - AddCalcUndo( new SdrUndoGeoObj( *pObj ) ); + AddCalcUndo< SdrUndoGeoObj >( *pObj ); pObj->SetPoint( aEndPos, 1 ); } } @@ -647,7 +648,7 @@ if ( pObj->GetPoint( 1 ) != aEndPos ) { if (bRecording) - AddCalcUndo( new SdrUndoGeoObj( *pObj ) ); + AddCalcUndo< SdrUndoGeoObj> ( *pObj ); pObj->SetPoint( aEndPos, 1 ); } @@ -663,7 +664,7 @@ if ( pObj->GetPoint( 0 ) != aStartPos ) { if (bRecording) - AddCalcUndo( new SdrUndoGeoObj( *pObj ) ); + AddCalcUndo< SdrUndoGeoObj >( *pObj ); pObj->SetPoint( aStartPos, 0 ); } } @@ -688,7 +689,7 @@ if ( pObj->GetLogicRect() != aNew ) { if (bRecording) - AddCalcUndo( new SdrUndoGeoObj( *pObj ) ); + AddCalcUndo< SdrUndoGeoObj >( *pObj ); pObj->SetLogicRect(aNew); } } @@ -699,7 +700,7 @@ if ( pObj->GetRelativePos() != aPos ) { if (bRecording) - AddCalcUndo( new SdrUndoGeoObj( *pObj ) ); + AddCalcUndo< SdrUndoGeoObj >( *pObj ); pObj->SetRelativePos( aPos ); } } @@ -948,7 +949,7 @@ } if( bMoved ) { - AddCalcUndo( new SdrUndoGeoObj( *pObject ) ); + AddCalcUndo< SdrUndoGeoObj >( *pObject ); lcl_TwipsToMM( aPoint ); pObject->SetPoint( aPoint, i ); } @@ -1002,7 +1003,7 @@ lcl_TwipsToMM( aNewPos ); aMoveSize = Size( aNewPos.X() - aOldMMPos.X(), aNewPos.Y() - aOldMMPos.Y() ); // millimeters - AddCalcUndo( new SdrUndoMoveObj( *pObject, aMoveSize ) ); + AddCalcUndo< SdrUndoMoveObj >( *pObject, aMoveSize ); pObject->Move( aMoveSize ); } else if ( rArea.IsInside( bNegativePage ? aObjRect.BottomLeft() : aObjRect.BottomRight() ) && @@ -1010,7 +1011,7 @@ { // geschuetzte Groessen werden nicht veraendert // (Positionen schon, weil sie ja an der Zelle "verankert" sind) - AddCalcUndo( new SdrUndoGeoObj( *pObject ) ); + AddCalcUndo< SdrUndoGeoObj >( *pObject ); long nOldSizeX = aObjRect.Right() - aObjRect.Left() + 1; long nOldSizeY = aObjRect.Bottom() - aObjRect.Top() + 1; long nLogMoveX = rMove.X() * ( bNegativePage ? -1 : 1 ); // logical direction @@ -1235,7 +1236,7 @@ long i; if (bRecording) for (i=1; i<=nDelCount; i++) - AddCalcUndo( new SdrUndoRemoveObj( *ppObj[nDelCount-i] ) ); + AddCalcUndo< SdrUndoRemoveObj >( *ppObj[nDelCount-i] ); for (i=1; i<=nDelCount; i++) pPage->RemoveObject( ppObj[nDelCount-i]->GetOrdNum() ); @@ -1286,7 +1287,7 @@ long i; if (bRecording) for (i=1; i<=nDelCount; i++) - AddCalcUndo( new SdrUndoRemoveObj( *ppObj[nDelCount-i] ) ); + AddCalcUndo< SdrUndoRemoveObj >( *ppObj[nDelCount-i] ); for (i=1; i<=nDelCount; i++) pPage->RemoveObject( ppObj[nDelCount-i]->GetOrdNum() ); @@ -1351,7 +1352,7 @@ long i; if (bRecording) for (i=1; i<=nDelCount; i++) - AddCalcUndo( new SdrUndoRemoveObj( *ppObj[nDelCount-i] ) ); + AddCalcUndo< SdrUndoRemoveObj >( *ppObj[nDelCount-i] ); for (i=1; i<=nDelCount; i++) pPage->RemoveObject( ppObj[nDelCount-i]->GetOrdNum() ); @@ -1582,7 +1583,7 @@ pDestPage->InsertObject( pNewObject ); if (bRecording) - AddCalcUndo( new SdrUndoInsertObj( *pNewObject ) ); + AddCalcUndo< SdrUndoInsertObj >( *pNewObject ); //#i110034# handle chart data references (after InsertObject) @@ -1692,7 +1693,7 @@ Point aRef1( 0, 0 ); Point aRef2( 0, 1 ); if (bRecording) - AddCalcUndo( new SdrUndoGeoObj( *pObj ) ); + AddCalcUndo< SdrUndoGeoObj >( *pObj ); pObj->Mirror( aRef1, aRef2 ); } else @@ -1703,7 +1704,7 @@ Rectangle aObjRect = pObj->GetLogicRect(); Size aMoveSize( -(aObjRect.Left() + aObjRect.Right()), 0 ); if (bRecording) - AddCalcUndo( new SdrUndoMoveObj( *pObj, aMoveSize ) ); + AddCalcUndo< SdrUndoMoveObj >( *pObj, aMoveSize ); pObj->Move( aMoveSize ); } } Index: sc/source/core/data/postit.cxx =================================================================== --- sc/source/core/data/postit.cxx (revision 1390863) +++ sc/source/core/data/postit.cxx (working copy) @@ -347,8 +347,11 @@ if( rOldTailPos != aTailPos ) { // create drawing undo action - if( pDrawLayer && pDrawLayer->IsRecording() ) - pDrawLayer->AddCalcUndo( pDrawLayer->GetSdrUndoFactory().CreateUndoGeoObject( *mpCaption ) ); + if( pDrawLayer ) + if( pDrawLayer->IsUndoAllowed() ) + if( pDrawLayer->IsRecording() ) + pDrawLayer->AddCalcUndo( pDrawLayer->GetSdrUndoFactory().CreateUndoGeoObject( *mpCaption ) ); + // calculate new caption rectangle (#i98141# handle LTR<->RTL switch correctly) Rectangle aCaptRect = mpCaption->GetLogicRect(); long nDiffX = (rOldTailPos.X() >= 0) ? (aCaptRect.Left() - rOldTailPos.X()) : (rOldTailPos.X() - aCaptRect.Right()); @@ -368,7 +371,7 @@ { // create drawing undo action if( pDrawLayer && pDrawLayer->IsRecording() ) - pDrawLayer->AddCalcUndo( new ScUndoObjData( mpCaption, pCaptData->maStart, pCaptData->maEnd, maPos, pCaptData->maEnd ) ); + pDrawLayer->AddCalcUndo< ScUndoObjData >(mpCaption, pCaptData->maStart, pCaptData->maEnd, maPos, pCaptData->maEnd ); // set new position pCaptData->maStart = maPos; } @@ -737,8 +740,9 @@ // create undo action if( ScDrawLayer* pDrawLayer = mrDoc.GetDrawLayer() ) - if( pDrawLayer->IsRecording() ) - pDrawLayer->AddCalcUndo( pDrawLayer->GetSdrUndoFactory().CreateUndoNewObject( *maNoteData.mpCaption ) ); + if( pDrawLayer->IsUndoAllowed() ) + if( pDrawLayer->IsRecording() ) + pDrawLayer->AddCalcUndo( pDrawLayer->GetSdrUndoFactory().CreateUndoNewObject( *maNoteData.mpCaption ) ); } } @@ -758,7 +762,7 @@ { pDrawPage->RecalcObjOrdNums(); // create drawing undo action (before removing the object to have valid draw page in undo action) - bool bRecording = ( pDrawLayer && pDrawLayer->IsRecording() ); + bool bRecording = ( pDrawLayer && pDrawLayer->IsUndoAllowed() && pDrawLayer->IsRecording() ); if( bRecording ) pDrawLayer->AddCalcUndo( pDrawLayer->GetSdrUndoFactory().CreateUndoDeleteObject( *maNoteData.mpCaption ) ); // remove the object from the drawing page, delete if undo is disabled Index: sc/source/core/tool/detfunc.cxx =================================================================== --- sc/source/core/tool/detfunc.cxx (revision 1390863) +++ sc/source/core/tool/detfunc.cxx (working copy) @@ -494,7 +494,7 @@ ScDrawLayer::SetAnchor( pBox, SCA_CELL ); pBox->SetLayer( SC_LAYER_INTERN ); pPage->InsertObject( pBox ); - pModel->AddCalcUndo( new SdrUndoInsertObj( *pBox ) ); + pModel->AddCalcUndo< SdrUndoInsertObj >( *pBox ); ScDrawObjData* pData = ScDrawLayer::GetObjData( pBox, sal_True ); pData->maStart.Set( nRefStartCol, nRefStartRow, nTab); @@ -536,7 +536,7 @@ ScDrawLayer::SetAnchor( pArrow, SCA_CELL ); pArrow->SetLayer( SC_LAYER_INTERN ); pPage->InsertObject( pArrow ); - pModel->AddCalcUndo( new SdrUndoInsertObj( *pArrow ) ); + pModel->AddCalcUndo< SdrUndoInsertObj >( *pArrow ); ScDrawObjData* pData = ScDrawLayer::GetObjData( pArrow, sal_True ); if (bFromOtherTab) @@ -568,7 +568,7 @@ ScDrawLayer::SetAnchor( pBox, SCA_CELL ); pBox->SetLayer( SC_LAYER_INTERN ); pPage->InsertObject( pBox ); - pModel->AddCalcUndo( new SdrUndoInsertObj( *pBox ) ); + pModel->AddCalcUndo< SdrUndoInsertObj >( *pBox ); ScDrawObjData* pData = ScDrawLayer::GetObjData( pBox, sal_True ); pData->maStart.Set( nStartCol, nStartRow, nTab); @@ -603,7 +603,7 @@ ScDrawLayer::SetAnchor( pArrow, SCA_CELL ); pArrow->SetLayer( SC_LAYER_INTERN ); pPage->InsertObject( pArrow ); - pModel->AddCalcUndo( new SdrUndoInsertObj( *pArrow ) ); + pModel->AddCalcUndo< SdrUndoInsertObj >( *pArrow ); ScDrawObjData* pData = ScDrawLayer::GetObjData( pArrow, sal_True ); pData->maStart.Set( nStartCol, nStartRow, nTab); @@ -672,7 +672,7 @@ ScDrawLayer::SetAnchor( pCircle, SCA_CELL ); pCircle->SetLayer( SC_LAYER_INTERN ); pPage->InsertObject( pCircle ); - pModel->AddCalcUndo( new SdrUndoInsertObj( *pCircle ) ); + pModel->AddCalcUndo< SdrUndoInsertObj >( *pCircle ); ScDrawObjData* pData = ScDrawLayer::GetObjData( pCircle, sal_True ); pData->maStart.Set( nCol, nRow, nTab); @@ -713,7 +713,7 @@ long i; for (i=1; i<=nDelCount; i++) - pModel->AddCalcUndo( new SdrUndoRemoveObj( *ppObj[nDelCount-i] ) ); + pModel->AddCalcUndo< SdrUndoRemoveObj >( *ppObj[nDelCount-i] ); for (i=1; i<=nDelCount; i++) pPage->RemoveObject( ppObj[nDelCount-i]->GetOrdNum() ); @@ -790,7 +790,7 @@ long i; for (i=1; i<=nDelCount; i++) - pModel->AddCalcUndo( new SdrUndoRemoveObj( *ppObj[nDelCount-i] ) ); + pModel->AddCalcUndo< SdrUndoRemoveObj >( *ppObj[nDelCount-i] ); for (i=1; i<=nDelCount; i++) pPage->RemoveObject( ppObj[nDelCount-i]->GetOrdNum() ); @@ -1334,7 +1334,7 @@ long i; for (i=1; i<=nDelCount; i++) - pModel->AddCalcUndo( new SdrUndoRemoveObj( *ppObj[nDelCount-i] ) ); + pModel->AddCalcUndo< SdrUndoRemoveObj >( *ppObj[nDelCount-i] ); for (i=1; i<=nDelCount; i++) pPage->RemoveObject( ppObj[nDelCount-i]->GetOrdNum() ); Index: sc/source/ui/docshell/docfunc.cxx =================================================================== --- sc/source/ui/docshell/docfunc.cxx (revision 1390863) +++ sc/source/ui/docshell/docfunc.cxx (working copy) @@ -111,7 +111,7 @@ { // #i101118# if drawing layer collects the undo actions, add it there ScDrawLayer* pDrawLayer = rDocShell.GetDocument()->GetDrawLayer(); - if( pDrawLayer && pDrawLayer->IsRecording() ) + if( pDrawLayer && pDrawLayer->IsUndoAllowed() && pDrawLayer->IsRecording() ) pDrawLayer->AddCalcUndo( pUndoAction ); else rDocShell.GetUndoManager()->AddUndoAction( new ScUndoDraw( pUndoAction, &rDocShell ) ); Index: sc/source/ui/docshell/docsh.cxx =================================================================== --- sc/source/ui/docshell/docsh.cxx (revision 1390863) +++ sc/source/ui/docshell/docsh.cxx (working copy) @@ -66,6 +66,7 @@ #include #include #include +#include #include #include @@ -171,7 +172,98 @@ #define ScDocShell #include "scslots.hxx" +namespace +{ + template< bool bByName > + inline sal_uInt8 GetMediumFlag( const String & rName ) + { + sal_uInt8 bResult = E_MEDIUM_FLAG_NONE; +#define SFX2_FILTER_ENTRY( entry ) { #entry, (sizeof #entry)/sizeof((#entry)[0]) - 1 }, + static const struct + { + const char * mpFilterTypeName; + unsigned mnFilterTypeLen; + } szMSFilterTypes [] = + { + SFX2_FILTER_ENTRY(calc_MS_Excel_40) + SFX2_FILTER_ENTRY(calc_MS_Excel_40_VorlageTemplate) + SFX2_FILTER_ENTRY(calc_MS_Excel_5095) + SFX2_FILTER_ENTRY(calc_MS_Excel_5095_VorlageTemplate) + SFX2_FILTER_ENTRY(calc_MS_Excel_95) + SFX2_FILTER_ENTRY(calc_MS_Excel_95_VorlageTemplate) + SFX2_FILTER_ENTRY(calc_MS_Excel_97) + SFX2_FILTER_ENTRY(calc_MS_Excel_97_VorlageTemplate) + SFX2_FILTER_ENTRY(calc_MS_Excel_2003_XML) + SFX2_FILTER_ENTRY(MS Excel 2007 XML) + SFX2_FILTER_ENTRY(MS Excel 2007 XML Template) + SFX2_FILTER_ENTRY(MS Excel 2007 Binary) + }; + + static const struct + { + const char * mpFilterName; + unsigned mnFilterNameLen; + } szMSFilterNames [] = + { + { pFilterExcel4, strlen( pFilterExcel4 ) }, + { pFilterEx4Temp, strlen( pFilterEx4Temp ) }, + { pFilterExcel95, strlen( pFilterExcel95 ) }, + { pFilterEx95Temp, strlen( pFilterEx95Temp ) }, + { pFilterExcel5, strlen( pFilterExcel5 ) }, + { pFilterEx5Temp, strlen( pFilterEx5Temp ) }, + { pFilterExcel97, strlen( pFilterExcel97 ) }, + { pFilterEx97Temp, strlen( pFilterEx97Temp ) }, + SFX2_FILTER_ENTRY(Microsoft Excel 2003 XML) + { pFilterEx07Xml, strlen( pFilterEx07Xml ) }, + SFX2_FILTER_ENTRY(Microsoft Excel 2007 XML Template) + SFX2_FILTER_ENTRY(Microsoft Excel 2007 Binary) + }; + + enum{ + e_calc_MS_Excel_40, + e_calc_MS_Excel_40_VorlageTemplate, + e_calc_MS_Excel_5095, + e_calc_MS_Excel_5095_VorlageTemplate, + e_calc_MS_Excel_95, + Se_calc_MS_Excel_95_VorlageTemplate, + e_calc_MS_Excel_97, + e_calc_MS_Excel_97_VorlageTemplate, + e_calc_MS_Excel_2003_XML, + e_MS_Excel_2007_XML, + e_MS_Excel_2007_XML_Template, + e_MS_Excel_2007_Binary + }; + +#undef SFX2_FILTER_ENTRY + + if( bByName ) + { + for( unsigned i = 0; i < (sizeof szMSFilterNames)/sizeof(szMSFilterNames[0] ); i++ ) + if( rName.Len() == szMSFilterNames[i].mnFilterNameLen + && std::equal( szMSFilterNames[i].mpFilterName, szMSFilterNames[i].mpFilterName + szMSFilterNames[i].mnFilterNameLen, rName.GetBuffer() ) ) + bResult |= ( E_MEDIUM_FLAG_EXCEL | ( ( i == e_MS_Excel_2007_XML ) * E_MEDIUM_FLAG_MSXML ) ); + } + else + { + for( unsigned i = 0; i < (sizeof szMSFilterTypes)/sizeof(szMSFilterTypes[0] ); i++ ) + if( rName.Len() == szMSFilterTypes[i].mnFilterTypeLen + && std::equal( szMSFilterTypes[i].mpFilterTypeName, szMSFilterTypes[i].mpFilterTypeName + szMSFilterTypes[i].mnFilterTypeLen, rName.GetBuffer() ) ) + bResult |= ( E_MEDIUM_FLAG_EXCEL | ( ( i == e_MS_Excel_2007_XML ) * E_MEDIUM_FLAG_MSXML ) ); + } + + return bResult; + } + + inline sal_uInt8 GetMediumFlag( const SfxMedium * pMedium ) + { + if( const SfxFilter * pFilter = pMedium ? pMedium->GetFilter() : NULL ) + return GetMediumFlag( pFilter->GetTypeName() ); + + return E_MEDIUM_FLAG_NONE; + } +} + SFX_IMPL_INTERFACE(ScDocShell,SfxObjectShell, ScResId(SCSTR_DOCSHELL)) { SFX_CHILDWINDOW_REGISTRATION( SID_HYPERLINK_INSERT ); @@ -2907,4 +2999,53 @@ return bRes; } +void ScDocShell::BeforeLoading( SfxMedium& rMedium, const ::rtl::OUString & rstrTypeName, const ::rtl::OUString & rstrFilterName ) +{ + const sal_uInt8 nMediumFlag = GetMediumFlag( rstrTypeName ); + + if( nMediumFlag & E_MEDIUM_FLAG_MSXML ) + { + aDocument.SetImportingMSXML( true ); + + if ( GetCreateMode() != SFX_CREATE_MODE_ORGANIZER ) + ScColumn::bDoubleAlloc = sal_True; + } +} + +void ScDocShell::AfterLoading( SfxMedium& rMedium, const ::rtl::OUString & rstrTypeName, const ::rtl::OUString & rstrFilterName ) +{ + const sal_uInt8 nMediumFlag = GetMediumFlag( rstrTypeName ); + + if( nMediumFlag & E_MEDIUM_FLAG_MSXML ) + { + aDocument.SetImportingMSXML( false ); + + if ( GetCreateMode() != SFX_CREATE_MODE_ORGANIZER ) + ScColumn::bDoubleAlloc = sal_False; + + // After loading, the XEmbeddedObject was probably set modified flag, so reset the flag to false. + uno::Sequence < ::rtl::OUString > aNames = GetEmbeddedObjectContainer().GetObjectNames(); + for ( sal_Int32 n = 0; n < aNames.getLength(); n++ ) + { + ::rtl::OUString aName = aNames[n]; + uno::Reference < embed::XEmbeddedObject > xObj = GetEmbeddedObjectContainer().GetEmbeddedObject( aName ); + OSL_ENSURE( xObj.is(), "An empty entry in the embedded objects list!\n" ); + if ( xObj.is() ) + { + try + { + sal_Int32 nState = xObj->getCurrentState(); + if ( nState != embed::EmbedStates::LOADED ) + { + uno::Reference< util::XModifiable > xModifiable( xObj->getComponent(), uno::UNO_QUERY ); + if ( xModifiable.is() ) + xModifiable->setModified(sal_False); + } + } + catch( uno::Exception& ) + {} + } + } + } +} Index: sc/source/ui/inc/docsh.hxx =================================================================== --- sc/source/ui/inc/docsh.hxx (revision 1390863) +++ sc/source/ui/inc/docsh.hxx (working copy) @@ -420,6 +420,8 @@ virtual void SetChangeRecording( bool bActivate ); virtual bool SetProtectionPassword( const String &rPassword ); virtual bool GetProtectionHash( /*out*/ ::com::sun::star::uno::Sequence< sal_Int8 > &rPasswordHash ); + void BeforeLoading( SfxMedium&, const ::rtl::OUString &, const ::rtl::OUString & ); + void AfterLoading( SfxMedium&, const ::rtl::OUString &, const ::rtl::OUString & ); }; Index: sfx2/inc/sfx2/objsh.hxx =================================================================== --- sfx2/inc/sfx2/objsh.hxx (revision 1390863) +++ sfx2/inc/sfx2/objsh.hxx (working copy) @@ -204,6 +204,8 @@ sal_Bool bHasName :1, // sal_True := bestehendes Objekt, sal_False := es ist ein neues Objekt bIsTmp :1; // temp. Storage sal_Bool bIsInGenerateThumbnail; //optimize thumbnail generate and store procedure to improve odt saving performance, i120030 + virtual void BeforeLoading( SfxMedium&, const ::rtl::OUString &, const ::rtl::OUString & ){}; + virtual void AfterLoading( SfxMedium&, const ::rtl::OUString &, const ::rtl::OUString & ){}; private: //#if 0 // _SOLAR__PRIVATE Index: sfx2/source/doc/objstor.cxx =================================================================== --- sfx2/source/doc/objstor.cxx (revision 1390863) +++ sfx2/source/doc/objstor.cxx (working copy) @@ -2364,6 +2364,7 @@ ::rtl::OUString aTypeName( rMedium.GetFilter()->GetTypeName() ); ::rtl::OUString aFilterName( rMedium.GetFilter()->GetFilterName() ); + BeforeLoading( rMedium, aTypeName, aFilterName ); uno::Reference< lang::XMultiServiceFactory > xMan = ::comphelper::getProcessServiceFactory(); uno::Reference < lang::XMultiServiceFactory > xFilterFact ( xMan->createInstance( DEFINE_CONST_UNICODE( "com.sun.star.document.FilterFactory" ) ), uno::UNO_QUERY ); @@ -2463,6 +2464,8 @@ } } } + AfterLoading( rMedium, aTypeName, aFilterName ); + return bRtn; //<- #i119492 }catch(const uno::Exception&)