[Libreoffice-commits] core.git: Branch 'libreoffice-4-3' - 2 commits - svx/source vcl/inc vcl/source

Matúš Kukan matus.kukan at collabora.com
Tue May 27 23:48:02 PDT 2014


 svx/source/table/cell.cxx  |   14 +++++++++-----
 svx/source/table/cell.hxx  |    1 +
 vcl/inc/outdev.h           |    2 +-
 vcl/source/outdev/font.cxx |   12 +++++++-----
 4 files changed, 18 insertions(+), 11 deletions(-)

New commits:
commit da5ab383bd4695956b338e176de55f3a163aecbd
Author: Matúš Kukan <matus.kukan at collabora.com>
Date:   Tue May 27 16:37:30 2014 +0200

    Related bnc#822625: Cache FontEntry with the original FontSelectPattern.
    
    Otherwise we never hit cache directly, only after expensive call to
    ImplFindByFont.
    
    Change-Id: If15b368feeba94c8fff8ee7cbe049fc4a2069768
    (cherry picked from commit a6b00d16eb27a5e7e31c721671001a909ecef960)

diff --git a/vcl/inc/outdev.h b/vcl/inc/outdev.h
index dcde57c..e468ae2 100644
--- a/vcl/inc/outdev.h
+++ b/vcl/inc/outdev.h
@@ -149,7 +149,7 @@ public:
 
     ImplFontEntry*      GetFontEntry( PhysicalFontCollection*,
                              const Font&, const Size& rPixelSize, float fExactHeight);
-    ImplFontEntry*      GetFontEntry( PhysicalFontCollection*, FontSelectPattern& );
+    ImplFontEntry*      GetFontEntry( PhysicalFontCollection*, const FontSelectPattern& );
     ImplFontEntry*      GetGlyphFallbackFont( PhysicalFontCollection*, FontSelectPattern&,
                             int nFallbackLevel, OUString& rMissingCodes );
     void                Release( ImplFontEntry* );
diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx
index 9e40712..d8b77db 100644
--- a/vcl/source/outdev/font.cxx
+++ b/vcl/source/outdev/font.cxx
@@ -1227,22 +1227,23 @@ ImplFontEntry* ImplFontCache::GetFontEntry( PhysicalFontCollection* pFontList,
 }
 
 ImplFontEntry* ImplFontCache::GetFontEntry( PhysicalFontCollection* pFontList,
-    FontSelectPattern& aFontSelData )
+    const FontSelectPattern& rFontSelData )
 {
     // check if a directly matching logical font instance is already cached,
     // the most recently used font usually has a hit rate of >50%
     ImplFontEntry *pEntry = NULL;
     PhysicalFontFamily* pFontFamily = NULL;
     IFSD_Equal aIFSD_Equal;
-    if( mpFirstEntry && aIFSD_Equal( aFontSelData, mpFirstEntry->maFontSelData ) )
+    if( mpFirstEntry && aIFSD_Equal( rFontSelData, mpFirstEntry->maFontSelData ) )
         pEntry = mpFirstEntry;
     else
     {
-        FontInstanceList::iterator it = maFontInstanceList.find( aFontSelData );
+        FontInstanceList::iterator it = maFontInstanceList.find( rFontSelData );
         if( it != maFontInstanceList.end() )
             pEntry = (*it).second;
     }
 
+    FontSelectPattern aFontSelData(rFontSelData);
     if( !pEntry ) // no direct cache hit
     {
         // find the best matching logical font family and update font selector accordingly
@@ -1315,8 +1316,9 @@ ImplFontEntry* ImplFontCache::GetFontEntry( PhysicalFontCollection* pFontList,
         }
 #endif
 
-        // add the new entry to the cache
-        maFontInstanceList[ aFontSelData ] = pEntry;
+        // Add the new entry to the cache with the original FontSelectPattern,
+        // so that we can find it next time as a direct cache hit.
+        maFontInstanceList[ rFontSelData ] = pEntry;
     }
 
     mpFirstEntry = pEntry;
commit 1d0447c2d1b2ce41edf2972b72ba1d59349ef62e
Author: Matúš Kukan <matus.kukan at collabora.com>
Date:   Tue May 27 10:39:45 2014 +0200

    Related bnc#822625: Cache minimum height for table cells.
    
    Change-Id: I35e295347a046376289f5d4fd5468860d0b8f0ae
    (cherry picked from commit 5792e76cb5beb630c135f57b74f57d74dd2dc2b0)

diff --git a/svx/source/table/cell.cxx b/svx/source/table/cell.cxx
index 3ab9b68..e0f85c2 100644
--- a/svx/source/table/cell.cxx
+++ b/svx/source/table/cell.cxx
@@ -359,6 +359,7 @@ Cell::Cell( SdrTableObj& rTableObj, OutlinerParaObject* pOutlinerParaObject ) th
 , mbMerged( false )
 , mnRowSpan( 1 )
 , mnColSpan( 1 )
+, mnCachedMinHeight( -1 )
 , mxTable( rTableObj.getTable() )
 {
     if( rTableObj.GetModel() )
@@ -525,6 +526,7 @@ void Cell::setMerged()
 
 void Cell::notifyModified()
 {
+    mnCachedMinHeight = -1;
     if( mxTable.is() )
         mxTable->setModified( sal_True );
 }
@@ -681,8 +683,10 @@ sal_Int32 Cell::getMinimumHeight()
     if( !mpProperties )
         return 0;
 
+    if( mnCachedMinHeight != -1 )
+        return mnCachedMinHeight;
+
     SdrTableObj& rTableObj = dynamic_cast< SdrTableObj& >( GetObject() );
-    sal_Int32 nMinimumHeight = 0;
 
     Rectangle aTextRect;
     TakeTextAnchorRect( aTextRect );
@@ -693,7 +697,7 @@ sal_Int32 Cell::getMinimumHeight()
     if(pEditOutliner)
     {
         pEditOutliner->SetMaxAutoPaperSize(aSize);
-        nMinimumHeight = pEditOutliner->GetTextHeight()+1;
+        mnCachedMinHeight = pEditOutliner->GetTextHeight()+1;
     }
     else /*if ( hasText() )*/
     {
@@ -706,12 +710,12 @@ sal_Int32 Cell::getMinimumHeight()
         {
             rOutliner.SetText(*GetOutlinerParaObject());
         }
-        nMinimumHeight=rOutliner.GetTextHeight()+1;
+        mnCachedMinHeight=rOutliner.GetTextHeight()+1;
         rOutliner.Clear();
     }
 
-    nMinimumHeight += GetTextUpperDistance() + GetTextLowerDistance();
-    return nMinimumHeight;
+    mnCachedMinHeight += GetTextUpperDistance() + GetTextLowerDistance();
+    return mnCachedMinHeight;
 }
 
 
diff --git a/svx/source/table/cell.hxx b/svx/source/table/cell.hxx
index c5a0078..2927a87 100644
--- a/svx/source/table/cell.hxx
+++ b/svx/source/table/cell.hxx
@@ -226,6 +226,7 @@ private:
     bool      mbMerged;
     ::sal_Int32     mnRowSpan;
     ::sal_Int32     mnColSpan;
+    ::sal_Int32     mnCachedMinHeight;
 
     Rectangle maCellRect;
 


More information about the Libreoffice-commits mailing list