incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r1381548 - in /incubator/ooo/trunk/main/sc: inc/styleuno.hxx source/filter/excel/xestyle.cxx source/filter/inc/xestyle.hxx source/ui/unoobj/styleuno.cxx
Date Thu, 06 Sep 2012 10:17:46 GMT
Author: alg
Date: Thu Sep  6 10:17:46 2012
New Revision: 1381548

URL: http://svn.apache.org/viewvc?rev=1381548&view=rev
Log:
#120824# improve load/sve performance for spreadsheet

Modified:
    incubator/ooo/trunk/main/sc/inc/styleuno.hxx
    incubator/ooo/trunk/main/sc/source/filter/excel/xestyle.cxx
    incubator/ooo/trunk/main/sc/source/filter/inc/xestyle.hxx
    incubator/ooo/trunk/main/sc/source/ui/unoobj/styleuno.cxx

Modified: incubator/ooo/trunk/main/sc/inc/styleuno.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/inc/styleuno.hxx?rev=1381548&r1=1381547&r2=1381548&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/inc/styleuno.hxx (original)
+++ incubator/ooo/trunk/main/sc/inc/styleuno.hxx Thu Sep  6 10:17:46 2012
@@ -230,6 +230,15 @@ private:
 											throw(::com::sun::star::lang::IllegalArgumentException,
 													::com::sun::star::uno::RuntimeException);
 
+    // enhance ODS load performance
+	bool StyleSheetChangedUpdate();
+	void SetOnePropertyValueWithoutUpdate(  const ::rtl::OUString& rPropertyName,
+													const SfxItemPropertySimpleEntry* pEntry,
+													const ::com::sun::star::uno::Any* pValue )
+											throw(::com::sun::star::lang::IllegalArgumentException,
+													::com::sun::star::uno::RuntimeException);
+	//end add 
+
 	ScStyleObj(); // disabled
 public:
 							ScStyleObj(ScDocShell* pDocSh, SfxStyleFamily eFam, const String& rName);

Modified: incubator/ooo/trunk/main/sc/source/filter/excel/xestyle.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/source/filter/excel/xestyle.cxx?rev=1381548&r1=1381547&r2=1381548&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/source/filter/excel/xestyle.cxx (original)
+++ incubator/ooo/trunk/main/sc/source/filter/excel/xestyle.cxx Thu Sep  6 10:17:46 2012
@@ -1896,18 +1896,43 @@ void XclExpXFId::ConvertXFIndex( const X
 
 XclExpXF::XclExpXF(
         const XclExpRoot& rRoot, const ScPatternAttr& rPattern, sal_Int16 nScript,
-        sal_uLong nForceScNumFmt, sal_uInt16 nForceXclFont, bool bForceLineBreak ) :
-    XclXFBase( true ),
-    XclExpRoot( rRoot )
+        sal_uLong nForceScNumFmt, sal_uInt16 nForceXclFont, bool bForceLineBreak ) 
+:   XclXFBase(true),
+    XclExpRecord(),
+    XclExpRoot(rRoot),
+    mpItemSet(0),
+    maProtection(),
+    maAlignment(),
+    maBorder(),
+    maArea(),
+    mnParentXFId(),
+    mnScNumFmt(),
+    mnXclFont(),
+    mnXclNumFmt(),
+    mnBorderId(),
+    mnFillId(),
+    mnIndexInXFList(0)
 {
     mnParentXFId = GetXFBuffer().InsertStyle( rPattern.GetStyleSheet() );
     Init( rPattern.GetItemSet(), nScript, nForceScNumFmt, nForceXclFont, bForceLineBreak,
false );
 }
 
-XclExpXF::XclExpXF( const XclExpRoot& rRoot, const SfxStyleSheetBase& rStyleSheet
) :
-    XclXFBase( false ),
-    XclExpRoot( rRoot ),
-    mnParentXFId( XclExpXFBuffer::GetXFIdFromIndex( EXC_XF_STYLEPARENT ) )
+XclExpXF::XclExpXF( const XclExpRoot& rRoot, const SfxStyleSheetBase& rStyleSheet
) 
+:   XclXFBase(false),
+    XclExpRecord(),
+    XclExpRoot(rRoot),
+    mpItemSet(0),
+    maProtection(),
+    maAlignment(),
+    maBorder(),
+    maArea(),
+    mnParentXFId(XclExpXFBuffer::GetXFIdFromIndex(EXC_XF_STYLEPARENT)),
+    mnScNumFmt(),
+    mnXclFont(),
+    mnXclNumFmt(),
+    mnBorderId(),
+    mnFillId(),
+    mnIndexInXFList(0)
 {
     bool bDefStyle = (rStyleSheet.GetName() == ScGlobal::GetRscString( STR_STYLENAME_STANDARD
));
     sal_Int16 nScript = bDefStyle ? GetDefApiScript() : ::com::sun::star::i18n::ScriptType::WEAK;
@@ -1915,10 +1940,22 @@ XclExpXF::XclExpXF( const XclExpRoot& rR
         NUMBERFORMAT_ENTRY_NOT_FOUND, EXC_FONT_NOTFOUND, false, bDefStyle );
 }
 
-XclExpXF::XclExpXF( const XclExpRoot& rRoot, bool bCellXF ) :
-    XclXFBase( bCellXF ),
-    XclExpRoot( rRoot ),
-    mnParentXFId( XclExpXFBuffer::GetXFIdFromIndex( EXC_XF_STYLEPARENT ) )
+XclExpXF::XclExpXF( const XclExpRoot& rRoot, bool bCellXF ) 
+:   XclXFBase(bCellXF),
+    XclExpRecord(),
+    XclExpRoot(rRoot),
+    mpItemSet(0),
+    maProtection(),
+    maAlignment(),
+    maBorder(),
+    maArea(),
+    mnParentXFId(XclExpXFBuffer::GetXFIdFromIndex(EXC_XF_STYLEPARENT)),
+    mnScNumFmt(),
+    mnXclFont(),
+    mnXclNumFmt(),
+    mnBorderId(),
+    mnFillId(),
+    mnIndexInXFList(0)
 {
     InitDefault();
 }
@@ -2323,8 +2360,21 @@ bool XclExpFillPred::operator()( const X
         mrFill.mnBackColorId    == rFill.mnBackColorId;
 }
 
-XclExpXFBuffer::XclExpXFBuffer( const XclExpRoot& rRoot ) :
-    XclExpRoot( rRoot )
+static bool XclExpXFBuffer_mbUseMultimapBuffer = true;
+
+XclExpXFBuffer::XclExpXFBuffer( const XclExpRoot& rRoot ) 
+:   XclExpRecordBase(),
+    XclExpRoot(rRoot),
+    maXFList(),
+    maStyleList(),
+    maBuiltInMap(),
+    maXFIndexVec(),
+    maStyleIndexes(),
+    maCellIndexes(),
+    maSortedXFList(),
+    maBorders(),
+    maFills(),
+    maXclExpXFMap()
 {
 }
 
@@ -2603,20 +2653,90 @@ void XclExpXFBuffer::SaveXFXml( XclExpXm
     rXF.SaveXml( rStrm );
 }
 
-sal_uInt32 XclExpXFBuffer::FindXF( const ScPatternAttr& rPattern,
-        sal_uLong nForceScNumFmt, sal_uInt16 nForceXclFont, bool bForceLineBreak ) const
+void XclExpXFBuffer::impAddMissingValuesFromXFListToXclExpXFMap()
 {
-    for( size_t nPos = 0, nSize = maXFList.GetSize(); nPos < nSize; ++nPos )
-        if( maXFList.GetRecord( nPos )->Equals( rPattern, nForceScNumFmt, nForceXclFont,
bForceLineBreak ) )
-            return static_cast< sal_uInt32 >( nPos );
-    return EXC_XFID_NOTFOUND;
+    for(size_t nPos(maXclExpXFMap.size()); nPos < maXFList.GetSize(); ++nPos)
+    {
+        XclExpXF* pValue = maXFList.GetRecord(nPos).get();
+
+        if(pValue)
+        {
+            const SfxItemSet* pKey = maXFList.GetRecord(nPos)->getItemSet();
+
+            maXclExpXFMap.insert(std::pair< const SfxItemSet*, XclExpXF* >(pKey, pValue));
+            pValue->setIndexInXFList(nPos);
+        }
+        else
+        {
+            OSL_ENSURE(false, "maXFList has empty entries (!)");
+        }
+    }
+}
+
+sal_uInt32 XclExpXFBuffer::FindXF(const ScPatternAttr& rPattern, sal_uLong nForceScNumFmt,
sal_uInt16 nForceXclFont, bool bForceLineBreak) const
+{
+    // define return value
+    sal_uInt32 nXFId(EXC_XFID_NOTFOUND);
+
+    if(XclExpXFBuffer_mbUseMultimapBuffer)
+    {
+        // add values from maXFList which are not yet in maXclExpXFMap
+        const_cast< XclExpXFBuffer* >(this)->impAddMissingValuesFromXFListToXclExpXFMap();
+
+        // get the full range for the pattern set
+        typedef std::multimap< const SfxItemSet*, XclExpXF* >::const_iterator CIT;
+        typedef std::pair< CIT, CIT > Range;
+        const SfxItemSet* pPatternSet = &(rPattern.GetItemSet());
+        const Range range(maXclExpXFMap.equal_range(pPatternSet));
+
+        // iterate over evtl. multiple candidates using the pattern set
+        for(CIT ite(range.first); ite != range.second; ++ite) 
+        {
+            XclExpXF* pIte = ite->second;
+
+            if(pIte->Equals(rPattern, nForceScNumFmt, nForceXclFont, bForceLineBreak))
+            {
+                nXFId = pIte->getIndexInXFList();
+                break;
+            }
+        }
+    }
+    else
+    {
+        // old, unbuffered implementation
+        for( size_t nPos = 0, nSize = maXFList.GetSize(); nPos < nSize; ++nPos )
+            if( maXFList.GetRecord( nPos )->Equals( rPattern, nForceScNumFmt, nForceXclFont,
bForceLineBreak ) )
+                return static_cast< sal_uInt32 >( nPos );
+    }
+
+    return nXFId;
 }
 
 sal_uInt32 XclExpXFBuffer::FindXF( const SfxStyleSheetBase& rStyleSheet ) const
 {
-    for( size_t nPos = 0, nSize = maXFList.GetSize(); nPos < nSize; ++nPos )
-        if( maXFList.GetRecord( nPos )->Equals( rStyleSheet ) )
-            return static_cast< sal_uInt32 >( nPos );
+    if(XclExpXFBuffer_mbUseMultimapBuffer)
+    {
+        // add values from maXFList which are not yet in maXclExpXFMap
+        const_cast< XclExpXFBuffer* >(this)->impAddMissingValuesFromXFListToXclExpXFMap();
+
+        // find entry with given ItemSet (by StyleSheet)
+        const SfxItemSet& rItemSet = const_cast< SfxStyleSheetBase& >(rStyleSheet).GetItemSet();
+        typedef std::multimap< const SfxItemSet*, XclExpXF* >::const_iterator CIT;
+        const CIT aFound(maXclExpXFMap.find(&rItemSet));
+
+        if(aFound != maXclExpXFMap.end())
+        {
+            return aFound->second->getIndexInXFList();
+        }
+    }
+    else
+    {
+        // old, unbuffered implementation
+        for( size_t nPos = 0, nSize = maXFList.GetSize(); nPos < nSize; ++nPos )
+            if( maXFList.GetRecord( nPos )->Equals( rStyleSheet ) )
+                return static_cast< sal_uInt32 >( nPos );
+    }
+
     return EXC_XFID_NOTFOUND;
 }
 
@@ -2647,6 +2767,13 @@ sal_uInt32 XclExpXFBuffer::InsertCellXF(
             // replace default cell pattern
             XclExpXFRef xNewXF( new XclExpXF( GetRoot(), *pPattern, nScript ) );
             maXFList.ReplaceRecord( xNewXF, EXC_XF_DEFAULTCELL );
+
+            // need to clear the multimap buffer to force reinsertin of the new element
+            if(XclExpXFBuffer_mbUseMultimapBuffer)
+            {
+                    maXclExpXFMap.clear();
+            }
+
             rbPredefined = false;
         }
         return GetDefCellXFId();
@@ -2698,6 +2825,13 @@ sal_uInt32 XclExpXFBuffer::InsertStyleXF
             {
                 // replace predefined built-in style (ReplaceRecord() deletes old record)
                 maXFList.ReplaceRecord( XclExpXFRef( new XclExpXF( GetRoot(), rStyleSheet
) ), nXFId );
+
+                // need to clear the multimap buffer to force reinsertin of the new element
+                if(XclExpXFBuffer_mbUseMultimapBuffer)
+                {
+                    maXclExpXFMap.clear();
+                }
+
                 rbPredefined = false;
             }
         }

Modified: incubator/ooo/trunk/main/sc/source/filter/inc/xestyle.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/source/filter/inc/xestyle.hxx?rev=1381548&r1=1381547&r2=1381548&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/source/filter/inc/xestyle.hxx (original)
+++ incubator/ooo/trunk/main/sc/source/filter/inc/xestyle.hxx Thu Sep  6 10:17:46 2012
@@ -512,6 +512,11 @@ public:
 
     virtual void        SaveXml( XclExpXmlStream& rStrm );
 
+    // for buffered FindXF
+    const SfxItemSet* getItemSet() const { return mpItemSet; }
+    sal_uInt32 getIndexInXFList() const { return mnIndexInXFList; }
+    void setIndexInXFList(sal_uInt32 nNew) { mnIndexInXFList = nNew; }
+
 protected:
     explicit            XclExpXF( const XclExpRoot& rRoot, bool bCellXF );
 
@@ -523,12 +528,15 @@ protected:  // access for XclExpDefaultX
     XclExpCellBorder    maBorder;           /// Border line style.
     XclExpCellArea      maArea;             /// Background area style.
     sal_uInt32          mnParentXFId;       /// XF ID of parent XF record.
-    sal_uLong               mnScNumFmt;         /// Calc number format index.
+    sal_uLong           mnScNumFmt;         /// Calc number format index.
     sal_uInt16          mnXclFont;          /// Excel font index.
     sal_uInt16          mnXclNumFmt;        /// Excel number format index.
     sal_Int32           mnBorderId;         /// OOXML Border Index
     sal_Int32           mnFillId;           /// OOXML Fill Index
 
+    // for buffered FindXF, holds the index in XclExpXFBuffer::maXFList when object is added
to maXclExpXFMap
+    sal_uInt32          mnIndexInXFList;
+
 private:
     using               XclXFBase::Equals;
 
@@ -695,6 +703,9 @@ private:
     typedef XclExpRecordList< XclExpStyle > XclExpStyleList;
 
 private:
+    // helper to update the buffer for maXFList
+    void impAddMissingValuesFromXFListToXclExpXFMap();
+
     /** Returns the XF ID of the cell XF containing the passed format. */
     sal_uInt32          FindXF( const ScPatternAttr& rPattern, sal_uLong nForceScNumFmt,
                             sal_uInt16 nForceXclFont, bool bForceLineBreak ) const;
@@ -758,6 +769,8 @@ private:
     XclExpBorderList    maBorders;          /// List of borders used by XF records
     XclExpFillList      maFills;            /// List of fills used by XF records
 
+    // for optimized FindXF, buffered version of maXFList for fast access
+    std::multimap< const SfxItemSet*, XclExpXF* > maXclExpXFMap;
 };
 
 // ============================================================================

Modified: incubator/ooo/trunk/main/sc/source/ui/unoobj/styleuno.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/source/ui/unoobj/styleuno.cxx?rev=1381548&r1=1381547&r2=1381548&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/source/ui/unoobj/styleuno.cxx (original)
+++ incubator/ooo/trunk/main/sc/source/ui/unoobj/styleuno.cxx Thu Sep  6 10:17:46 2012
@@ -1531,8 +1531,13 @@ void SAL_CALL ScStyleObj::setPropertyVal
 		for (sal_Int32 i = 0; i < nCount; i++)
 		{
             const SfxItemPropertySimpleEntry*  pEntry = pPropertyMap->getByName( pNames[i]
);
-            SetOnePropertyValue( pNames[i], pEntry, &pValues[i] );
+
+            // enhance ODS load performance
+            SetOnePropertyValueWithoutUpdate( pNames[i], pEntry, &pValues[i] );
 		}
+
+        // enhance ODS load performance
+        StyleSheetChangedUpdate();
 	}
 }
 
@@ -1691,6 +1696,13 @@ void SAL_CALL ScStyleObj::setPropertyVal
 void ScStyleObj::SetOnePropertyValue( const ::rtl::OUString& rPropertyName, const SfxItemPropertySimpleEntry*
pEntry, const uno::Any* pValue )
 								throw(lang::IllegalArgumentException, uno::RuntimeException)
 {
+    SetOnePropertyValueWithoutUpdate(rPropertyName, pEntry, pValue);
+    StyleSheetChangedUpdate();
+}
+
+void ScStyleObj::SetOnePropertyValueWithoutUpdate( const ::rtl::OUString& rPropertyName,
const SfxItemPropertySimpleEntry* pEntry, const uno::Any* pValue )
+								throw(lang::IllegalArgumentException, uno::RuntimeException)
+{
 	SfxStyleSheetBase* pStyle = GetStyle_Impl();
     if ( pStyle && pEntry )
 	{
@@ -1943,31 +1955,43 @@ void ScStyleObj::SetOnePropertyValue( co
             }
 		}
 
-		//!	DocFunc-Funktion??
-		//!	Undo ?????????????
+        if(SFX_STYLE_FAMILY_PARA != eFamily)
+        {
+            //!	ModifyStyleSheet am Dokument (alte Werte merken)
 
-		ScDocument* pDoc = pDocShell->GetDocument();
-		if ( eFamily == SFX_STYLE_FAMILY_PARA )
-		{
-			//	Zeilenhoehen anpassen...
+            pDocShell->PageStyleModified( aStyleName, sal_True );
+		}
+	}
+}
 
-			VirtualDevice aVDev;
-			Point aLogic = aVDev.LogicToPixel( Point(1000,1000), MAP_TWIP );
-			double nPPTX = aLogic.X() / 1000.0;
-			double nPPTY = aLogic.Y() / 1000.0;
-			Fraction aZoom(1,1);
-			pDoc->StyleSheetChanged( pStyle, sal_False, &aVDev, nPPTX, nPPTY, aZoom, aZoom
);
+bool ScStyleObj::StyleSheetChangedUpdate()
+{
+    SfxStyleSheetBase* pStyle = GetStyle_Impl();
 
-			pDocShell->PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB, PAINT_GRID|PAINT_LEFT );
-			pDocShell->SetDocumentModified();
-		}
-		else
-		{
-			//!	ModifyStyleSheet am Dokument (alte Werte merken)
+    if(pStyle)
+    {
+        //!	DocFunc-Funktion??
+        //!	Undo ?????????????
 
-			pDocShell->PageStyleModified( aStyleName, sal_True );
-		}
-	}
+        if(SFX_STYLE_FAMILY_PARA == eFamily)
+        {
+            // adapt line heights
+            VirtualDevice aVDev;
+            const Point aLogic(aVDev.LogicToPixel(Point(1000,1000), MAP_TWIP));
+            const double nPPTX(aLogic.X() / 1000.0);
+            const double nPPTY(aLogic.Y() / 1000.0);
+            const Fraction aZoom(1,1);
+            ScDocument* pDoc = pDocShell->GetDocument();
+
+            pDoc->StyleSheetChanged(pStyle, sal_False, &aVDev, nPPTX, nPPTY, aZoom,
aZoom);
+            pDocShell->PostPaint(0,0,0, MAXCOL,MAXROW,MAXTAB, PAINT_GRID|PAINT_LEFT);
+            pDocShell->SetDocumentModified();
+        }
+
+        return true;
+    }
+
+    return false;
 }
 
 uno::Any SAL_CALL ScStyleObj::getPropertyValue( const rtl::OUString& aPropertyName )



Mime
View raw message