[PATCH libreoffice-4-0] Resolves: #i120017, filter button is not shown in merged cel...

Fridrich Strba (via Code Review) gerrit at gerrit.libreoffice.org
Mon Mar 11 22:00:03 PDT 2013


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/2674

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/74/2674/1

Resolves: #i120017, filter button is not shown in merged cell

Patch by: zhao shao zhi, aoo.zhaoshzh at gmail.com
Found by: Yan Ji,<yanji.yj at gmail.com>
Review by: zhangjf
(cherry picked from commit bcf01fd794ec169aaf2a3f8b86f986ec60e5beb8)

Signed-off-by: Fridrich Štrba <fridrich.strba at bluewin.ch>

Conflicts:
	sc/source/ui/view/gridwin.cxx

Change-Id: Ie8a529c697979cf75c303bddcaddd2776f5b8047
(cherry picked from commit aaab3a79dfd762a64fa4c1d19dd29ae46c0b9dd0)
---
M sc/source/ui/view/gridwin.cxx
M sc/source/ui/view/gridwin2.cxx
M sc/source/ui/view/gridwin4.cxx
3 files changed, 25 insertions(+), 2 deletions(-)



diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index a7033fe..5d85831 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -927,6 +927,8 @@
     long nSizeY  = 0;
     long nHeight = 0;
     pViewData->GetMergeSizePixel( nCol, nRow, nSizeX, nSizeY );
+    // The button height should not use the merged cell height, should still use single row height
+    nSizeY = pViewData->ToPixel(pDoc->GetRowHeight(nRow, nTab), pViewData->GetPPTY());
     Point aPos = pViewData->GetScrPos( nCol, nRow, eWhich );
     if ( bLayoutRTL )
         aPos.X() -= nSizeX;
@@ -1813,8 +1815,19 @@
 
     if ( !bDouble && !bFormulaMode && rMEvt.IsLeft() )
     {
+        SCsCOL nRealPosX;
+        SCsROW nRealPosY;
+        pViewData->GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nRealPosX, nRealPosY, false );//the real row/col
+        ScMergeFlagAttr* pRealPosAttr = (ScMergeFlagAttr*)
+                                    pDoc->GetAttr( nRealPosX, nRealPosY, nTab, ATTR_MERGE_FLAG );
         ScMergeFlagAttr* pAttr = (ScMergeFlagAttr*)
                                     pDoc->GetAttr( nPosX, nPosY, nTab, ATTR_MERGE_FLAG );
+        if( pRealPosAttr->HasAutoFilter() )
+        {
+            SC_MOD()->InputEnterHandler();
+            if (DoAutoFilterButton( nRealPosX, nRealPosY, rMEvt))
+                return;
+        }
         if (pAttr->HasAutoFilter())
         {
             if (DoAutoFilterButton(nPosX, nPosY, rMEvt))
diff --git a/sc/source/ui/view/gridwin2.cxx b/sc/source/ui/view/gridwin2.cxx
index 3ec36a2..406e64f 100644
--- a/sc/source/ui/view/gridwin2.cxx
+++ b/sc/source/ui/view/gridwin2.cxx
@@ -125,6 +125,8 @@
 
     long nSizeX, nSizeY;
     pViewData->GetMergeSizePixel( nCol, nRow, nSizeX, nSizeY );
+    // The button height should not use the merged cell height, should still use single row height
+    nSizeY = pViewData->ToPixel(pDoc->GetRowHeight(nRow, nTab), pViewData->GetPPTY());
     Size aScrSize(nSizeX-1, nSizeY-1);
 
     // Check if the mouse cursor is clicking on the popup arrow box.
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 64e4bbc..7c060f7 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -1145,7 +1145,9 @@
             for (nCol=nX1; nCol<=nX2; nCol++)
             {
                 CellInfo* pInfo = &pThisRowInfo->pCellInfo[nCol+1];
-                if ( pInfo->bAutoFilter && !pInfo->bHOverlapped && !pInfo->bVOverlapped )
+                //if several columns merged on a row, there should be only one auto button at the end of the columns.
+                //if several rows merged on a column, the button may be in the middle, so "!pInfo->bVOverlapped" should not be used
+                if ( pInfo->bAutoFilter && !pInfo->bHOverlapped )
                 {
                     if (!pQueryParam)
                         pQueryParam = new ScQueryParam;
@@ -1198,7 +1200,13 @@
                     bool bArrowState = bSimpleQuery && bColumnFound;
                     long    nSizeX;
                     long    nSizeY;
-                    pViewData->GetMergeSizePixel( nCol, nRow, nSizeX, nSizeY );
+                    SCCOL nStartCol= nCol;
+                    SCROW nStartRow = nRow;
+                    //if address(nCol,nRow) is not the start pos of the merge area, the value of the nSizeX will be incorrect, it will be the length of the cell.
+                    //should first get the start pos of the merge area, then get the nSizeX through the start pos.
+                    pDoc->ExtendOverlapped(nStartCol, nStartRow,nCol, nRow, nTab);//get nStartCol,nStartRow
+                    pViewData->GetMergeSizePixel( nStartCol, nStartRow, nSizeX, nSizeY );//get nSizeX
+                    nSizeY = pViewData->ToPixel(pDoc->GetRowHeight(nRow, nTab), pViewData->GetPPTY());
                     Point aScrPos = pViewData->GetScrPos( nCol, nRow, eWhich );
 
                     aCellBtn.setBoundingBox(aScrPos, Size(nSizeX-1, nSizeY-1), bLayoutRTL);

-- 
To view, visit https://gerrit.libreoffice.org/2674
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie8a529c697979cf75c303bddcaddd2776f5b8047
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: libreoffice-4-0
Gerrit-Owner: Fridrich Strba <fridrich at documentfoundation.org>



More information about the LibreOffice mailing list