incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l...@apache.org
Subject svn commit: r1395911 - in /incubator/ooo/trunk/main: sc/inc/ sc/source/core/data/ sc/source/core/tool/ sc/source/ui/docshell/ sc/source/ui/inc/ sfx2/inc/sfx2/ sfx2/source/doc/
Date Tue, 09 Oct 2012 08:36:00 GMT
Author: leiw
Date: Tue Oct  9 08:35:59 2012
New Revision: 1395911

URL: http://svn.apache.org/viewvc?rev=1395911&view=rev
Log:
#i121136 Improve Spreadsheet performance in some area (Patch 2)

          Patch by: Wang Lei
          Review by: Wang Lei

Modified:
    incubator/ooo/trunk/main/sc/inc/document.hxx
    incubator/ooo/trunk/main/sc/inc/drwlayer.hxx
    incubator/ooo/trunk/main/sc/source/core/data/documen2.cxx
    incubator/ooo/trunk/main/sc/source/core/data/documen9.cxx
    incubator/ooo/trunk/main/sc/source/core/data/drwlayer.cxx
    incubator/ooo/trunk/main/sc/source/core/data/postit.cxx
    incubator/ooo/trunk/main/sc/source/core/tool/detfunc.cxx
    incubator/ooo/trunk/main/sc/source/ui/docshell/docfunc.cxx
    incubator/ooo/trunk/main/sc/source/ui/docshell/docsh.cxx
    incubator/ooo/trunk/main/sc/source/ui/inc/docsh.hxx
    incubator/ooo/trunk/main/sfx2/inc/sfx2/objsh.hxx
    incubator/ooo/trunk/main/sfx2/source/doc/objstor.cxx

Modified: incubator/ooo/trunk/main/sc/inc/document.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/inc/document.hxx?rev=1395911&r1=1395910&r2=1395911&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/inc/document.hxx (original)
+++ incubator/ooo/trunk/main/sc/inc/document.hxx Tue Oct  9 08:35:59 2012
@@ -232,6 +232,7 @@ const sal_uInt8 SC_DDE_IGNOREMODE    = 2
 
 
 // -----------------------------------------------------------------------
+enum { E_MEDIUM_FLAG_NONE = 0, E_MEDIUM_FLAG_EXCEL = 1, E_MEDIUM_FLAG_MSXML = 2 };
 
 class ScDocument
 {
@@ -390,6 +391,7 @@ private:
 	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 @@ public:
     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; }

Modified: incubator/ooo/trunk/main/sc/inc/drwlayer.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/inc/drwlayer.hxx?rev=1395911&r1=1395910&r2=1395911&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/inc/drwlayer.hxx (original)
+++ incubator/ooo/trunk/main/sc/inc/drwlayer.hxx Tue Oct  9 08:35:59 2012
@@ -101,6 +101,7 @@ private:
 	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 @@ public:
 	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 @@ public:
 	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; }
 };
 
 

Modified: incubator/ooo/trunk/main/sc/source/core/data/documen2.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/source/core/data/documen2.cxx?rev=1395911&r1=1395910&r2=1395911&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/source/core/data/documen2.cxx (original)
+++ incubator/ooo/trunk/main/sc/source/core/data/documen2.cxx Tue Oct  9 08:35:59 2012
@@ -188,6 +188,7 @@ ScDocument::ScDocument( ScDocumentMode	e
 		bInsertingFromOtherDoc( sal_False ),
         bLoadingMedium( false ),
 		bImportingXML( false ),
+        mbImportingMSXML( false ),
         bXMLFromWrapper( sal_False ),
 		bCalcingAfterLoad( sal_False ),
 		bNoListening( sal_False ),

Modified: incubator/ooo/trunk/main/sc/source/core/data/documen9.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/source/core/data/documen9.cxx?rev=1395911&r1=1395910&r2=1395911&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/source/core/data/documen9.cxx (original)
+++ incubator/ooo/trunk/main/sc/source/core/data/documen9.cxx Tue Oct  9 08:35:59 2012
@@ -131,7 +131,7 @@ void ScDocument::TransferDrawPage(ScDocu
                     pNewPage->InsertObject( pNewObject );
 
                     if (pDrawLayer->IsRecording())
-                        pDrawLayer->AddCalcUndo( new SdrUndoInsertObj( *pNewObject ) );
+			pDrawLayer->AddCalcUndo< SdrUndoInsertObj >( *pNewObject );
                 }
 
 				pOldObject = aIter.Next();
@@ -197,6 +197,9 @@ void ScDocument::InitDrawLayer( SfxObjec
 		if (bImportingXML)
 			pDrawLayer->EnableAdjust(sal_False);
 
+		if( IsImportingMSXML( ) )
+			pDrawLayer->SetUndoAllowed( false );
+
 		pDrawLayer->SetForbiddenCharsTable( xForbiddenCharacters );
 		pDrawLayer->SetCharCompressType( GetAsianCompression() );
 		pDrawLayer->SetKernAsianPunctuation( GetAsianKerning() );
@@ -768,6 +771,14 @@ void ScDocument::SetImportingXML( bool b
     SetLoadingMedium(bVal);
 }
 
+void ScDocument::SetImportingMSXML( bool bVal )
+{
+    mbImportingMSXML = bVal;
+
+    if (pDrawLayer)
+        pDrawLayer->SetUndoAllowed( !mbImportingMSXML );
+}
+
 void ScDocument::SetXMLFromWrapper( sal_Bool bVal )
 {
     bXMLFromWrapper = bVal;

Modified: incubator/ooo/trunk/main/sc/source/core/data/drwlayer.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/source/core/data/drwlayer.cxx?rev=1395911&r1=1395910&r2=1395911&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/source/core/data/drwlayer.cxx (original)
+++ incubator/ooo/trunk/main/sc/source/core/data/drwlayer.cxx Tue Oct  9 08:35:59 2012
@@ -213,7 +213,8 @@ ScDrawLayer::ScDrawLayer( ScDocument* pD
 	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 @@ sal_Bool ScDrawLayer::ScAddPage( SCTAB n
 	ScDrawPage* pPage = (ScDrawPage*)AllocPage( sal_False );
 	InsertPage(pPage, static_cast<sal_uInt16>(nTab));
 	if (bRecording)
-		AddCalcUndo(new SdrUndoNewPage(*pPage));
+	        AddCalcUndo< SdrUndoNewPage >(*pPage);
 
     return sal_True;        // inserted
 }
@@ -393,7 +394,7 @@ void ScDrawLayer::ScRemovePage( SCTAB nT
 	if (bRecording)
 	{
 		SdrPage* pPage = GetPage(static_cast<sal_uInt16>(nTab));
-		AddCalcUndo(new SdrUndoDelPage(*pPage));		// Undo-Action wird Owner der Page
+        AddCalcUndo< SdrUndoDelPage >(*pPage);		// Undo-Action wird Owner der Page
 		RemovePage( static_cast<sal_uInt16>(nTab) );							// nur austragen, nicht loeschen
 	}
 	else
@@ -442,7 +443,7 @@ void ScDrawLayer::ScCopyPage( sal_uInt16
                 pNewObject->NbcMove(Size(0,0));
                 pNewPage->InsertObject( pNewObject );
                 if (bRecording)
-                    AddCalcUndo( new SdrUndoInsertObj( *pNewObject ) );
+	                AddCalcUndo< SdrUndoInsertObj >( *pNewObject );
             }
 
 			pOldObject = aIter.Next();
@@ -495,7 +496,7 @@ void ScDrawLayer::MoveCells( SCTAB nTab,
 			{
 				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 @@ void ScDrawLayer::RecalcPos( SdrObject* 
 		if ( pObj->GetLogicRect() != aRect )
 		{
 			if (bRecording)
-				AddCalcUndo( new SdrUndoGeoObj( *pObj ) );
+		                AddCalcUndo<SdrUndoGeoObj>( *pObj );
 			pObj->SetLogicRect(aRect);
 		}
 	}
@@ -613,7 +614,7 @@ void ScDrawLayer::RecalcPos( SdrObject* 
 			if ( pObj->GetPoint( 0 ) != aStartPos )
 			{
 				if (bRecording)
-					AddCalcUndo( new SdrUndoGeoObj( *pObj ) );
+		                    AddCalcUndo< SdrUndoGeoObj> ( *pObj );
 				pObj->SetPoint( aStartPos, 0 );
 			}
 
@@ -627,7 +628,7 @@ void ScDrawLayer::RecalcPos( SdrObject* 
 				if ( pObj->GetPoint( 1 ) != aEndPos )
 				{
 					if (bRecording)
-						AddCalcUndo( new SdrUndoGeoObj( *pObj ) );
+		                        AddCalcUndo< SdrUndoGeoObj >( *pObj );
 					pObj->SetPoint( aEndPos, 1 );
 				}
 			}
@@ -647,7 +648,7 @@ void ScDrawLayer::RecalcPos( SdrObject* 
 			if ( pObj->GetPoint( 1 ) != aEndPos )
 			{
 				if (bRecording)
-					AddCalcUndo( new SdrUndoGeoObj( *pObj ) );
+		                    AddCalcUndo< SdrUndoGeoObj> ( *pObj  );
 				pObj->SetPoint( aEndPos, 1 );
 			}
 
@@ -663,7 +664,7 @@ void ScDrawLayer::RecalcPos( SdrObject* 
 				if ( pObj->GetPoint( 0 ) != aStartPos )
 				{
 					if (bRecording)
-						AddCalcUndo( new SdrUndoGeoObj( *pObj ) );
+			                        AddCalcUndo< SdrUndoGeoObj >( *pObj );
 					pObj->SetPoint( aStartPos, 0 );
 				}
 			}
@@ -688,7 +689,7 @@ void ScDrawLayer::RecalcPos( SdrObject* 
 			if ( pObj->GetLogicRect() != aNew )
 			{
 				if (bRecording)
-					AddCalcUndo( new SdrUndoGeoObj( *pObj ) );
+		                    AddCalcUndo< SdrUndoGeoObj >( *pObj );
 				pObj->SetLogicRect(aNew);
 			}
 		}
@@ -699,7 +700,7 @@ void ScDrawLayer::RecalcPos( SdrObject* 
 			if ( pObj->GetRelativePos() != aPos )
 			{
 				if (bRecording)
-					AddCalcUndo( new SdrUndoGeoObj( *pObj ) );
+		                    AddCalcUndo< SdrUndoGeoObj >( *pObj );
 				pObj->SetRelativePos( aPos );
 			}
 		}
@@ -948,7 +949,7 @@ void ScDrawLayer::MoveAreaTwips( SCTAB n
 					}
 					if( bMoved )
 					{
-						AddCalcUndo( new SdrUndoGeoObj( *pObject ) );
+			                        AddCalcUndo< SdrUndoGeoObj >( *pObject );						
 						lcl_TwipsToMM( aPoint );
 						pObject->SetPoint( aPoint, i );
 					}
@@ -1002,7 +1003,7 @@ void ScDrawLayer::MoveAreaTwips( SCTAB n
 					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 @@ void ScDrawLayer::MoveAreaTwips( SCTAB n
 				{
 					//	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 @@ void ScDrawLayer::DeleteObjects( SCTAB n
 		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 @@ void ScDrawLayer::DeleteObjectsInArea( S
 		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 @@ void ScDrawLayer::DeleteObjectsInSelecti
 					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 @@ void ScDrawLayer::CopyFromClip( ScDrawLa
 
 			pDestPage->InsertObject( pNewObject );
 			if (bRecording)
-				AddCalcUndo( new SdrUndoInsertObj( *pNewObject ) );
+		                AddCalcUndo< SdrUndoInsertObj >( *pNewObject );
 
 			//#i110034#	handle chart data references (after InsertObject)
 
@@ -1692,7 +1693,7 @@ void ScDrawLayer::MirrorRTL( SdrObject* 
 		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 @@ void ScDrawLayer::MirrorRTL( SdrObject* 
 		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 );
 	}
 }

Modified: incubator/ooo/trunk/main/sc/source/core/data/postit.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/source/core/data/postit.cxx?rev=1395911&r1=1395910&r2=1395911&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/source/core/data/postit.cxx (original)
+++ incubator/ooo/trunk/main/sc/source/core/data/postit.cxx Tue Oct  9 08:35:59 2012
@@ -347,8 +347,11 @@ void ScCaptionCreator::UpdateCaptionPos(
     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 @@ void ScCaptionCreator::UpdateCaptionPos(
     {
         // 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 @@ void ScPostIt::CreateCaption( const ScAd
 
         // 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 @@ void ScPostIt::RemoveCaption()
         {
             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

Modified: incubator/ooo/trunk/main/sc/source/core/tool/detfunc.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/source/core/tool/detfunc.cxx?rev=1395911&r1=1395910&r2=1395911&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/source/core/tool/detfunc.cxx (original)
+++ incubator/ooo/trunk/main/sc/source/core/tool/detfunc.cxx Tue Oct  9 08:35:59 2012
@@ -494,7 +494,7 @@ sal_Bool ScDetectiveFunc::InsertArrow( S
 		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 @@ sal_Bool ScDetectiveFunc::InsertArrow( S
 	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 @@ sal_Bool ScDetectiveFunc::InsertToOtherT
 		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 @@ sal_Bool ScDetectiveFunc::InsertToOtherT
 	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 @@ void ScDetectiveFunc::DrawCircle( SCCOL 
 	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 @@ void ScDetectiveFunc::DeleteArrowsAt( SC
 
 		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 @@ void ScDetectiveFunc::DeleteBox( SCCOL n
 
 		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 @@ sal_Bool ScDetectiveFunc::DeleteAll( ScD
 
 		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() );

Modified: incubator/ooo/trunk/main/sc/source/ui/docshell/docfunc.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/source/ui/docshell/docfunc.cxx?rev=1395911&r1=1395910&r2=1395911&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/source/ui/docshell/docfunc.cxx (original)
+++ incubator/ooo/trunk/main/sc/source/ui/docshell/docfunc.cxx Tue Oct  9 08:35:59 2012
@@ -111,7 +111,7 @@ IMPL_LINK( ScDocFunc, NotifyDrawUndo, Sd
 {
     // #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
) );

Modified: incubator/ooo/trunk/main/sc/source/ui/docshell/docsh.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/source/ui/docshell/docsh.cxx?rev=1395911&r1=1395910&r2=1395911&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/source/ui/docshell/docsh.cxx (original)
+++ incubator/ooo/trunk/main/sc/source/ui/docshell/docsh.cxx Tue Oct  9 08:35:59 2012
@@ -66,6 +66,7 @@
 #include <com/sun/star/script/vba/XVBAEventProcessor.hpp>
 #include <com/sun/star/sheet/XSpreadsheetView.hpp>
 #include <com/sun/star/task/XJob.hpp>
+#include <com/sun/star/embed/EmbedStates.hpp>
 #include <basic/sbstar.hxx>
 #include <basic/basmgr.hxx>
 
@@ -171,6 +172,97 @@ static const sal_Char __FAR_DATA pFilter
 #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<false>( pFilter->GetTypeName() );
+
+        return E_MEDIUM_FLAG_NONE;
+    }
+}
 
 SFX_IMPL_INTERFACE(ScDocShell,SfxObjectShell, ScResId(SCSTR_DOCSHELL))
 {
@@ -2907,4 +2999,53 @@ bool ScDocShell::GetProtectionHash( /*ou
     return bRes;
 }    
 
+void ScDocShell::BeforeLoading( SfxMedium& rMedium, const ::rtl::OUString & rstrTypeName,
const ::rtl::OUString & rstrFilterName )
+{
+    const sal_uInt8 nMediumFlag = GetMediumFlag<false>( 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<false>( 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& )
+				{}
+			}
+		}
+	}
+}
         

Modified: incubator/ooo/trunk/main/sc/source/ui/inc/docsh.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/source/ui/inc/docsh.hxx?rev=1395911&r1=1395910&r2=1395911&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/source/ui/inc/docsh.hxx (original)
+++ incubator/ooo/trunk/main/sc/source/ui/inc/docsh.hxx Tue Oct  9 08:35:59 2012
@@ -420,6 +420,8 @@ public:
     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
& );
 };
 
 

Modified: incubator/ooo/trunk/main/sfx2/inc/sfx2/objsh.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sfx2/inc/sfx2/objsh.hxx?rev=1395911&r1=1395910&r2=1395911&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sfx2/inc/sfx2/objsh.hxx (original)
+++ incubator/ooo/trunk/main/sfx2/inc/sfx2/objsh.hxx Tue Oct  9 08:35:59 2012
@@ -204,6 +204,8 @@ private:
 	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

Modified: incubator/ooo/trunk/main/sfx2/source/doc/objstor.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sfx2/source/doc/objstor.cxx?rev=1395911&r1=1395910&r2=1395911&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sfx2/source/doc/objstor.cxx (original)
+++ incubator/ooo/trunk/main/sfx2/source/doc/objstor.cxx Tue Oct  9 08:35:59 2012
@@ -2364,6 +2364,7 @@ sal_Bool SfxObjectShell::ImportFrom( Sfx
     ::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 @@ sal_Bool SfxObjectShell::ImportFrom( Sfx
                 }
             }
         }
+        AfterLoading( rMedium, aTypeName, aFilterName );
+
         return bRtn;
 //<- #i119492
         }catch(const uno::Exception&)



Mime
View raw message