diff options
author | Andrzej Hunt <andrzej.hunt@collabora.com> | 2014-08-27 14:24:18 +0200 |
---|---|---|
committer | Andrzej Hunt <andrzej.hunt@collabora.com> | 2014-08-30 21:37:10 +0200 |
commit | d8c049fa8d32b8d7250c421c93153873e10db1cb (patch) | |
tree | 00b3f88849c51c6fd19d51f3ffae57fec6b01d6d /sc | |
parent | 49870ccb9b405573595b43df95a6704108c276d6 (diff) |
Use MapMode instead of PPT for ScEditUtil::GetEditArea
Change-Id: I3fbc33da3f32723e37c5004f7883fa6ab4107921
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/editutil.hxx | 7 | ||||
-rw-r--r-- | sc/source/core/tool/editutil.cxx | 57 | ||||
-rw-r--r-- | sc/source/ui/view/output2.cxx | 18 | ||||
-rw-r--r-- | sc/source/ui/view/viewdata.cxx | 12 |
4 files changed, 55 insertions, 39 deletions
diff --git a/sc/inc/editutil.hxx b/sc/inc/editutil.hxx index 4acb1834b590..95f1fa802bd9 100644 --- a/sc/inc/editutil.hxx +++ b/sc/inc/editutil.hxx @@ -42,8 +42,7 @@ class ScEditUtil SCTAB nTab; Point aScrPos; OutputDevice* pDev; // MapMode has to be set - double nPPTX; - double nPPTY; + const MapMode& maPaintMapMode; Fraction aZoomX; Fraction aZoomY; @@ -81,11 +80,11 @@ public: public: ScEditUtil( ScDocument* pDocument, SCCOL nX, SCROW nY, SCTAB nZ, const Point& rScrPosPixel, - OutputDevice* pDevice, double nScaleX, double nScaleY, + OutputDevice* pDevice, const MapMode& aPaintMapMode, const Fraction& rX, const Fraction& rY ) : pDoc(pDocument),nCol(nX),nRow(nY),nTab(nZ), aScrPos(rScrPosPixel),pDev(pDevice), - nPPTX(nScaleX),nPPTY(nScaleY),aZoomX(rX),aZoomY(rY) {} + maPaintMapMode(aPaintMapMode),aZoomX(rX),aZoomY(rY) {} Rectangle GetEditArea( const ScPatternAttr* pPattern, bool bForceToTop ); }; diff --git a/sc/source/core/tool/editutil.cxx b/sc/source/core/tool/editutil.cxx index e3aa845cffe0..744dc379b1c1 100644 --- a/sc/source/core/tool/editutil.cxx +++ b/sc/source/core/tool/editutil.cxx @@ -280,24 +280,27 @@ Rectangle ScEditUtil::GetEditArea( const ScPatternAttr* pPattern, bool bForceToT if (!pPattern) pPattern = pDoc->GetPattern( nCol, nRow, nTab ); - Point aStartPos = aScrPos; + Point aStartPosTwips = pDev->PixelToLogic( aScrPos, maPaintMapMode ); bool bLayoutRTL = pDoc->IsLayoutRTL( nTab ); long nLayoutSign = bLayoutRTL ? -1 : 1; const ScMergeAttr* pMerge = (const ScMergeAttr*)&pPattern->GetItem(ATTR_MERGE); - long nCellX = (long) ( pDoc->GetColWidth(nCol,nTab) * nPPTX ); + long nCellXTwips = pDoc->GetColWidth(nCol,nTab); if ( pMerge->GetColMerge() > 1 ) { SCCOL nCountX = pMerge->GetColMerge(); for (SCCOL i=1; i<nCountX; i++) - nCellX += (long) ( pDoc->GetColWidth(nCol+i,nTab) * nPPTX ); + nCellXTwips += pDoc->GetColWidth(nCol+i,nTab); } - long nCellY = (long) ( pDoc->GetRowHeight(nRow,nTab) * nPPTY ); + long nCellYTwips = pDoc->GetRowHeight(nRow,nTab); if ( pMerge->GetRowMerge() > 1 ) { SCROW nCountY = pMerge->GetRowMerge(); - nCellY += (long) pDoc->GetScaledRowHeight( nRow+1, nRow+nCountY-1, nTab, nPPTY); + for ( SCROW i = nRow + 1; i <= nRow + nCountY - 1; i++ ) + { + nCellYTwips += pDoc->GetRowHeight( i, nTab ); + } } const SvxMarginItem* pMargin = (const SvxMarginItem*)&pPattern->GetItem(ATTR_MARGIN); @@ -305,14 +308,14 @@ Rectangle ScEditUtil::GetEditArea( const ScPatternAttr* pPattern, bool bForceToT if ( ((const SvxHorJustifyItem&)pPattern->GetItem(ATTR_HOR_JUSTIFY)).GetValue() == SVX_HOR_JUSTIFY_LEFT ) nIndent = ((const SfxUInt16Item&)pPattern->GetItem(ATTR_INDENT)).GetValue(); - long nPixDifX = (long) ( ( pMargin->GetLeftMargin() + nIndent ) * nPPTX ); - aStartPos.X() += nPixDifX * nLayoutSign; - nCellX -= nPixDifX + (long) ( pMargin->GetRightMargin() * nPPTX ); // wegen Umbruch etc. + long nLogicDifX = pMargin->GetLeftMargin() + nIndent; + aStartPosTwips.X () += nLogicDifX * nLayoutSign; + nCellXTwips -= nLogicDifX + pMargin->GetRightMargin(); // wegen Umbruch etc. // vertikale Position auf die in der Tabelle anpassen - long nPixDifY; - long nTopMargin = (long) ( pMargin->GetTopMargin() * nPPTY ); + long nLogicDifY; + long nTopMargin = pMargin->GetTopMargin(); SvxCellVerJustify eJust = (SvxCellVerJustify) ((const SvxVerJustifyItem&)pPattern-> GetItem(ATTR_VER_JUSTIFY)).GetValue(); @@ -322,45 +325,51 @@ Rectangle ScEditUtil::GetEditArea( const ScPatternAttr* pPattern, bool bForceToT if ( eJust == SVX_VER_JUSTIFY_TOP || ( bForceToTop && ( SC_MOD()->GetInputOptions().GetTextWysiwyg() || bAsianVertical ) ) ) - nPixDifY = nTopMargin; + nLogicDifY = nTopMargin; else { MapMode aMode = pDev->GetMapMode(); pDev->SetMapMode( MAP_PIXEL ); - long nTextHeight = pDoc->GetNeededSize( nCol, nRow, nTab, - pDev, nPPTX, nPPTY, aZoomX, aZoomY, false ); - if (!nTextHeight) + // TODO: continue from here... + long nTextHeightTwips = pDoc->GetNeededSize( nCol, nRow, nTab, + pDev, 1, 1, aZoomX, aZoomY, false ); + if (!nTextHeightTwips) { // leere Zelle Font aFont; // font color doesn't matter here pPattern->GetFont( aFont, SC_AUTOCOL_BLACK, pDev, &aZoomY ); pDev->SetFont(aFont); - nTextHeight = pDev->GetTextHeight() + nTopMargin + - (long) ( pMargin->GetBottomMargin() * nPPTY ); + // TODO: also fix this + nTextHeightTwips = pDev->PixelToLogic( Size( 0, pDev->GetTextHeight() ), + maPaintMapMode ).getWidth() + + nTopMargin + pMargin->GetBottomMargin(); } pDev->SetMapMode(aMode); - if ( nTextHeight > nCellY + nTopMargin || bForceToTop ) - nPixDifY = 0; // zu gross -> oben anfangen + if ( nTextHeightTwips > nCellYTwips + nTopMargin || bForceToTop ) + nLogicDifY = 0; // zu gross -> oben anfangen else { if ( eJust == SVX_VER_JUSTIFY_CENTER ) - nPixDifY = nTopMargin + ( nCellY - nTextHeight ) / 2; + nLogicDifY = nTopMargin + ( nCellYTwips - nTextHeightTwips ) / 2; else - nPixDifY = nCellY - nTextHeight + nTopMargin; // JUSTIFY_BOTTOM + nLogicDifY = nCellYTwips - nTextHeightTwips + nTopMargin; // JUSTIFY_BOTTOM } } - aStartPos.Y() += nPixDifY; - nCellY -= nPixDifY; + aStartPosTwips.Y() += nLogicDifY; + nCellYTwips -= nLogicDifY; if ( bLayoutRTL ) - aStartPos.X() -= nCellX - 2; // excluding grid on both sides + aStartPosTwips.X() -= nCellXTwips - 2; // excluding grid on both sides // -1 -> Gitter nicht ueberschreiben - return Rectangle( aStartPos, Size(nCellX-1,nCellY-1) ); + return pDev->LogicToPixel( + Rectangle( aStartPosTwips, + Size( nCellXTwips - 1, nCellYTwips - 1 ) ), + maPaintMapMode ); } ScEditAttrTester::ScEditAttrTester( ScEditEngineDefaulter* pEng ) : diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx index 23300387d009..bc1b258909c5 100644 --- a/sc/source/ui/view/output2.cxx +++ b/sc/source/ui/view/output2.cxx @@ -2790,8 +2790,10 @@ void ScOutputData::DrawEditStandard(DrawEditParam& rParam) // use same GetEditArea call as in ScViewData::SetEditEngine Fraction aFract(1,1); - Rectangle aUtilRect = ScEditUtil( mpDoc, rParam.mnCellX, rParam.mnCellY, nTab, Point(0,0), pFmtDevice, - HMM_PER_TWIPS, HMM_PER_TWIPS, aFract, aFract ).GetEditArea( rParam.mpPattern, false ); + Rectangle aUtilRect = ScEditUtil( mpDoc, rParam.mnCellX, rParam.mnCellY, + nTab, Point(0,0), pFmtDevice, + mpViewData->GetPaintMapMode(), + aFract, aFract ).GetEditArea( rParam.mpPattern, false ); aLogicSize.Width() = aUtilRect.GetWidth(); } rParam.mpEngine->SetPaperSize(aLogicSize); @@ -3812,8 +3814,10 @@ void ScOutputData::DrawEditStacked(DrawEditParam& rParam) // use same GetEditArea call as in ScViewData::SetEditEngine Fraction aFract(1,1); - Rectangle aUtilRect = ScEditUtil( mpDoc, rParam.mnCellX, rParam.mnCellY, nTab, Point(0,0), pFmtDevice, - HMM_PER_TWIPS, HMM_PER_TWIPS, aFract, aFract ).GetEditArea( rParam.mpPattern, false ); + Rectangle aUtilRect = ScEditUtil( mpDoc, rParam.mnCellX, rParam.mnCellY, + nTab, Point(0,0), pFmtDevice, + mpViewData->GetPaintMapMode(), + aFract, aFract ).GetEditArea( rParam.mpPattern, false ); aLogicSize.Width() = aUtilRect.GetWidth(); } rParam.mpEngine->SetPaperSize(aLogicSize); @@ -4168,8 +4172,10 @@ void ScOutputData::DrawEditAsianVertical(DrawEditParam& rParam) // use same GetEditArea call as in ScViewData::SetEditEngine Fraction aFract(1,1); - Rectangle aUtilRect = ScEditUtil( mpDoc, rParam.mnCellX, rParam.mnCellY, nTab, Point(0,0), pFmtDevice, - HMM_PER_TWIPS, HMM_PER_TWIPS, aFract, aFract ).GetEditArea( rParam.mpPattern, false ); + Rectangle aUtilRect = ScEditUtil( mpDoc, rParam.mnCellX, rParam.mnCellY, + nTab, Point(0,0), pFmtDevice, + mpViewData->GetPaintMapMode(), + aFract, aFract ).GetEditArea( rParam.mpPattern, false ); aLogicSize.Width() = aUtilRect.GetWidth(); } rParam.mpEngine->SetPaperSize(aLogicSize); diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx index 8ba9b7e95766..a63f003526e3 100644 --- a/sc/source/ui/view/viewdata.cxx +++ b/sc/source/ui/view/viewdata.cxx @@ -919,8 +919,8 @@ Rectangle ScViewData::GetEditArea( ScSplitPos eWhich, SCCOL nPosX, SCROW nPosY, bool bForceToTop ) { return ScEditUtil( pDoc, nPosX, nPosY, nTabNo, GetScrPos(nPosX,nPosY,eWhich,true), - pWin, nPPTX, nPPTY, GetZoomX(), GetZoomY() ). - GetEditArea( pPattern, bForceToTop ); + pWin, maPaintMapMode, GetZoomX(), GetZoomY() ). + GetEditArea( pPattern, bForceToTop ); } void ScViewData::SetEditEngine( ScSplitPos eWhich, @@ -970,8 +970,9 @@ void ScViewData::SetEditEngine( ScSplitPos eWhich, bool bAsianVertical = pNewEngine->IsVertical(); // set by InputHandler Rectangle aPixRect = ScEditUtil( pDoc, nNewX,nNewY,nTabNo, GetScrPos(nNewX,nNewY,eWhich), - pWin, nPPTX,nPPTY,GetZoomX(),GetZoomY() ). - GetEditArea( pPattern, true ); + pWin, maPaintMapMode, + GetZoomX(),GetZoomY() ). + GetEditArea( pPattern, true ); // when right-aligned, leave space for the cursor // in vertical mode, editing is always right-aligned @@ -1045,7 +1046,8 @@ void ScViewData::SetEditEngine( ScSplitPos eWhich, Fraction aFract(1,1); Rectangle aUtilRect = ScEditUtil( pDoc,nNewX,nNewY,nTabNo, Point(0,0), pWin, - HMM_PER_TWIPS, HMM_PER_TWIPS, aFract, aFract ).GetEditArea( pPattern, false ); + maPaintMapMode, aFract, aFract ). + GetEditArea( pPattern, false ); aPaperSize.Width() = aUtilRect.GetWidth(); } pNewEngine->SetPaperSize( aPaperSize ); |