summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJian Fang Zhang <zhangjf@apache.org>2012-06-21 07:19:34 +0000
committerJian Fang Zhang <zhangjf@apache.org>2012-06-21 07:19:34 +0000
commitbcf01fd794ec169aaf2a3f8b86f986ec60e5beb8 (patch)
tree5386a07726e0ef0e6eb11db03e86c33626966ca2
parent6b503294dc2304b79d8b4d7e04f8b1b909850aaa (diff)
#120017#, fix the problem that filter button is not shown in merged cell
Patch by: zhao shao zhi, aoo.zhaoshzh@gmail.com Found by: Yan Ji,<yanji.yj@gmail.com> Review by: zhangjf
Notes
-rw-r--r--sc/source/ui/view/gridwin.cxx17
-rw-r--r--sc/source/ui/view/gridwin2.cxx2
-rw-r--r--sc/source/ui/view/gridwin4.cxx12
3 files changed, 27 insertions, 4 deletions
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 09c6c4db5437..aa795c8e40db 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -880,6 +880,8 @@ void ScGridWindow::DoAutoFilterMenue( SCCOL nCol, SCROW nRow, sal_Bool bDataSele
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;
@@ -1674,12 +1676,23 @@ void ScGridWindow::HandleMouseButtonDown( const MouseEvent& rMEvt )
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 (pAttr->HasAutoFilter())
+ if( pRealPosAttr->HasAutoFilter() )
+ {
+ SC_MOD()->InputEnterHandler();
+ if (DoAutoFilterButton( nRealPosX, nRealPosY, rMEvt))
+ return;
+ }
+ if( pAttr->HasAutoFilter() )
{
SC_MOD()->InputEnterHandler(); //Add for i85305
- if (DoAutoFilterButton(nPosX, nPosY, rMEvt))
+ if (DoAutoFilterButton( nPosX, nPosY, rMEvt))
return;
}
if (pAttr->HasButton())
diff --git a/sc/source/ui/view/gridwin2.cxx b/sc/source/ui/view/gridwin2.cxx
index 12f369f9eeb6..b49ccccc308f 100644
--- a/sc/source/ui/view/gridwin2.cxx
+++ b/sc/source/ui/view/gridwin2.cxx
@@ -137,6 +137,8 @@ bool ScGridWindow::DoAutoFilterButton( SCCOL nCol, SCROW nRow, const MouseEvent&
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 cc95ade15215..0ad8c55b5511 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -1236,7 +1236,9 @@ void ScGridWindow::DrawButtons( SCCOL nX1, SCROW /*nY1*/, SCCOL nX2, SCROW /*nY2
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;
@@ -1288,7 +1290,13 @@ void ScGridWindow::DrawButtons( SCCOL nX1, SCROW /*nY1*/, SCCOL nX2, SCROW /*nY2
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);