[Libreoffice-commits] .: 2 commits - sc/inc sc/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Nov 28 09:10:54 PST 2012


 sc/inc/conditio.hxx              |   11 +++++++++
 sc/inc/sccommands.h              |    1 
 sc/source/core/data/conditio.cxx |   47 ++++++++++++++++++++++++---------------
 sc/source/ui/src/popup.src       |    6 ++++
 4 files changed, 48 insertions(+), 17 deletions(-)

New commits:
commit 5dcf5e9b888257a01045fe746214e2ed0d7db657
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Nov 28 18:06:29 2012 +0100

    cache calls to Date::SYSTEM
    
    Change-Id: Iccdfeb45519dfc7e1373bf1303ecfc0c83f4cbc0

diff --git a/sc/inc/conditio.hxx b/sc/inc/conditio.hxx
index ee30be1..af571fd 100644
--- a/sc/inc/conditio.hxx
+++ b/sc/inc/conditio.hxx
@@ -36,6 +36,7 @@
 #include "rangelst.hxx"
 
 #include <rtl/math.hxx>
+#include <tools/date.hxx>
 
 #include <map>
 
@@ -375,9 +376,19 @@ public:
     virtual void dumpInfo(rtl::OUStringBuffer& rBuf) const;
 #endif
 
+    virtual void startRendering();
+    virtual void endRendering();
+
 private:
     condformat::ScCondFormatDateType meType;
 
+    struct ScCondDateFormatCache
+    {
+        Date aCachedDate;
+    };
+
+    boost::scoped_ptr<ScCondDateFormatCache> mpCache;
+
     rtl::OUString maStyleName;
 };
 
diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index f2d4aa0..987e75e 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -1662,9 +1662,12 @@ bool ScCondDateFormatEntry::IsValid( const ScAddress& rPos ) const
     if(pBaseCell->GetCellType() != CELLTYPE_VALUE && pBaseCell->GetCellType() != CELLTYPE_FORMULA)
         return false;
 
-    Date aActDate( Date::SYSTEM );
+    if( !mpCache )
+        mpCache->aCachedDate = Date( Date::SYSTEM );
+
+    const Date& rActDate = mpCache->aCachedDate;
     SvNumberFormatter* pFormatter = mpDoc->GetFormatTable();
-    long nCurrentDate = aActDate - *(pFormatter->GetNullDate());
+    long nCurrentDate = rActDate - *(pFormatter->GetNullDate());
 
     double nVal = mpDoc->GetValue(rPos);
     long nCellDate = (long) ::rtl::math::approxFloor(nVal);
@@ -1690,57 +1693,57 @@ bool ScCondDateFormatEntry::IsValid( const ScAddress& rPos ) const
                 return true;
             break;
         case condformat::LASTWEEK:
-            if( aActDate.GetYear() == aCellDate.GetYear() && aActDate.GetMonth() == aCellDate.GetMonth() )
+            if( rActDate.GetYear() == aCellDate.GetYear() && rActDate.GetMonth() == aCellDate.GetMonth() )
             {
-                if( aActDate.GetWeekOfYear( SUNDAY ) == aCellDate.GetWeekOfYear( SUNDAY ) + 1 )
+                if( rActDate.GetWeekOfYear( SUNDAY ) == aCellDate.GetWeekOfYear( SUNDAY ) + 1 )
                     return true;
             }
             break;
         case condformat::THISWEEK:
-            if( aActDate.GetYear() == aCellDate.GetYear() && aActDate.GetMonth() == aCellDate.GetMonth() )
+            if( rActDate.GetYear() == aCellDate.GetYear() && rActDate.GetMonth() == aCellDate.GetMonth() )
             {
-                if( aActDate.GetWeekOfYear( SUNDAY ) == aCellDate.GetWeekOfYear( SUNDAY ) )
+                if( rActDate.GetWeekOfYear( SUNDAY ) == aCellDate.GetWeekOfYear( SUNDAY ) )
                     return true;
             }
             break;
         case condformat::NEXTWEEK:
-            if( aActDate.GetYear() == aCellDate.GetYear() && aActDate.GetMonth() == aCellDate.GetMonth() )
+            if( rActDate.GetYear() == aCellDate.GetYear() && rActDate.GetMonth() == aCellDate.GetMonth() )
             {
-                if( aActDate.GetWeekOfYear( SUNDAY ) == aCellDate.GetWeekOfYear( SUNDAY ) - 1 )
+                if( rActDate.GetWeekOfYear( SUNDAY ) == aCellDate.GetWeekOfYear( SUNDAY ) - 1 )
                     return true;
             }
             break;
         case condformat::LASTMONTH:
-            if( aActDate.GetYear() == aCellDate.GetYear() )
+            if( rActDate.GetYear() == aCellDate.GetYear() )
             {
-                if( aActDate.GetMonth() == aCellDate.GetMonth() + 1)
+                if( rActDate.GetMonth() == aCellDate.GetMonth() + 1)
                     return true;
             }
             break;
         case condformat::THISMONTH:
-            if( aActDate.GetYear() == aCellDate.GetYear() )
+            if( rActDate.GetYear() == aCellDate.GetYear() )
             {
-                if( aActDate.GetMonth() == aCellDate.GetMonth() )
+                if( rActDate.GetMonth() == aCellDate.GetMonth() )
                     return true;
             }
             break;
         case condformat::NEXTMONTH:
-            if( aActDate.GetYear() == aCellDate.GetYear() )
+            if( rActDate.GetYear() == aCellDate.GetYear() )
             {
-                if( aActDate.GetMonth() == aCellDate.GetMonth() - 1)
+                if( rActDate.GetMonth() == aCellDate.GetMonth() - 1)
                     return true;
             }
             break;
         case condformat::LASTYEAR:
-            if( aActDate.GetYear() == aCellDate.GetYear() + 1 )
+            if( rActDate.GetYear() == aCellDate.GetYear() + 1 )
                 return true;
             break;
         case condformat::THISYEAR:
-            if( aActDate.GetYear() == aCellDate.GetYear() )
+            if( rActDate.GetYear() == aCellDate.GetYear() )
                 return true;
             break;
         case condformat::NEXTYEAR:
-            if( aActDate.GetYear() == aCellDate.GetYear() - 1 )
+            if( rActDate.GetYear() == aCellDate.GetYear() - 1 )
                 return true;
             break;
     }
@@ -1791,6 +1794,16 @@ void ScCondDateFormatEntry::dumpInfo( rtl::OUStringBuffer& rBuffer ) const
     rBuffer.append("Date Format");
 }
 
+void ScCondDateFormatEntry::startRendering()
+{
+    mpCache.reset();
+}
+
+void ScCondDateFormatEntry::endRendering()
+{
+    mpCache.reset();
+}
+
 //------------------------------------------------------------------------
 
 ScConditionalFormat::ScConditionalFormat(sal_uInt32 nNewKey, ScDocument* pDocument) :
commit 03949c87206046d3a2ed2bf41f5c020458d07a8f
Author: Laurent Godard <lgodard.libre at laposte.net>
Date:   Wed Nov 28 17:18:27 2012 +0100

    fdo#49704 add split cells menu entry in calc popup
    
    Change-Id: Ia4f80cba29f30d4c684de6f78d8831513afa445c

diff --git a/sc/inc/sccommands.h b/sc/inc/sccommands.h
index 1350c0c..be8f411 100644
--- a/sc/inc/sccommands.h
+++ b/sc/inc/sccommands.h
@@ -61,6 +61,7 @@
 #define CMD_FID_INS_ROWBRK                          ".uno:InsertRowBreak"
 #define CMD_FID_INS_ROW                             ".uno:InsertRows"
 #define CMD_FID_MERGE_ON                            ".uno:MergeCells"
+#define CMD_FID_MERGE_OFF                           ".uno:SplitCell"
 #define CMD_SID_OBJECT_MIRROR                       ".uno:Mirror"
 #define CMD_FID_TAB_MOVE                            ".uno:Move"
 #define CMD_SID_PREVIEW_NEXT                        ".uno:NextPage"
diff --git a/sc/source/ui/src/popup.src b/sc/source/ui/src/popup.src
index f0f85f1..2b17e8e 100644
--- a/sc/source/ui/src/popup.src
+++ b/sc/source/ui/src/popup.src
@@ -82,6 +82,12 @@ Menu RID_POPUP_CELLS
             HelpId = CMD_FID_MERGE_ON ;
             Text [ en-US ] = "~Merge Cells..." ;
         };
+        MenuItem
+        {
+            Identifier = FID_MERGE_OFF ;
+            HelpId = CMD_FID_MERGE_OFF ;
+            Text [ en-US ] = "Split Cells..." ;
+        };
          //------------------------------
         MenuItem { Separator = TRUE ; };
          //------------------------------


More information about the Libreoffice-commits mailing list