From aa2e63bec26cbcc4d9defa78a46959fb380dec72 Mon Sep 17 00:00:00 2001 From: Andrzej Hunt Date: Wed, 27 Aug 2014 20:32:38 +0200 Subject: Kill use of PPT for DrawEditParam. Instead use our MapMode using code. Change-Id: I41a4fda036fa94f1ea7e5feed669df39e9ca8ebe --- sc/source/ui/inc/output.hxx | 11 ++++++++--- sc/source/ui/view/output2.cxx | 39 ++++++++++++++++++++++++++------------- 2 files changed, 34 insertions(+), 16 deletions(-) diff --git a/sc/source/ui/inc/output.hxx b/sc/source/ui/inc/output.hxx index 4e3042560c44..b1c35abefa6e 100644 --- a/sc/source/ui/inc/output.hxx +++ b/sc/source/ui/inc/output.hxx @@ -77,6 +77,8 @@ private: class DrawEditParam { + private: + const ScOutputData* mpOutputData; public: SvxCellHorJustify meHorJustAttr; ///< alignment attribute SvxCellHorJustify meHorJustContext; ///< context depending on attribute, content and direction @@ -110,12 +112,15 @@ private: const RowInfo* mpThisRowInfo; const std::vector* mpMisspellRanges; - explicit DrawEditParam(const ScPatternAttr* pPattern, const SfxItemSet* pCondSet, bool bCellIsValue); + explicit DrawEditParam( const ScOutputData* pOutputData, + const ScPatternAttr* pPattern, + const SfxItemSet* pCondSet, + bool bCellIsValue); bool readCellContent(ScDocument* pDoc, bool bShowNullValues, bool bShowFormulas, bool bSyntaxMode, bool bUseStyleColor, bool bForceAutoColor, bool& rWrapFields); void setPatternToEngine(bool bUseStyleColor); - void calcMargins(long& rTop, long& rLeft, long& rBottom, long& rRight, double nPPTX, double nPPTY) const; - void calcPaperSize(Size& rPaperSize, const Rectangle& rAlignRect, double nPPTX, double nPPTY) const; + void calcMargins( long& rTop, long& rLeft, long& rBottom, long& rRight ) const; + void calcPaperSize( Size& rPaperSize, const Rectangle& rAlignRect ) const; void getEngineSize(ScFieldEditEngine* pEngine, long& rWidth, long& rHeight) const; bool hasLineBreak() const; bool isHyperlinkCell() const; diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx index bc1b258909c5..00626333d3c7 100644 --- a/sc/source/ui/view/output2.cxx +++ b/sc/source/ui/view/output2.cxx @@ -2286,7 +2286,12 @@ void ScOutputData::ShrinkEditEngine( EditEngine& rEngine, const Rectangle& rAlig } } -ScOutputData::DrawEditParam::DrawEditParam(const ScPatternAttr* pPattern, const SfxItemSet* pCondSet, bool bCellIsValue) : +ScOutputData::DrawEditParam::DrawEditParam( + const ScOutputData* pOutputData, + const ScPatternAttr* pPattern, + const SfxItemSet* pCondSet, + bool bCellIsValue) : + mpOutputData( pOutputData ), meHorJustAttr( lcl_GetValue(*pPattern, ATTR_HOR_JUSTIFY, pCondSet) ), meHorJustContext( meHorJustAttr ), meHorJustResult( meHorJustAttr ), @@ -2424,7 +2429,8 @@ void ScOutputData::DrawEditParam::setPatternToEngine(bool bUseStyleColor) mpEngine->SetBackgroundColor( aBackCol ); } -void ScOutputData::DrawEditParam::calcMargins(long& rTopM, long& rLeftM, long& rBottomM, long& rRightM, double nPPTX, double nPPTY) const +void ScOutputData::DrawEditParam::calcMargins( + long& rTopM, long& rLeftM, long& rBottomM, long& rRightM ) const { const SvxMarginItem& rMargin = static_cast(mpPattern->GetItem(ATTR_MARGIN, mpCondSet)); @@ -2433,22 +2439,29 @@ void ScOutputData::DrawEditParam::calcMargins(long& rTopM, long& rLeftM, long& r if (meHorJustAttr == SVX_HOR_JUSTIFY_LEFT || meHorJustAttr == SVX_HOR_JUSTIFY_RIGHT) nIndent = lcl_GetValue(*mpPattern, ATTR_INDENT, mpCondSet); - rLeftM = static_cast(((rMargin.GetLeftMargin() + nIndent) * nPPTX)); - rTopM = static_cast((rMargin.GetTopMargin() * nPPTY)); - rRightM = static_cast((rMargin.GetRightMargin() * nPPTX)); - rBottomM = static_cast((rMargin.GetBottomMargin() * nPPTY)); + rLeftM = mpOutputData->LogicToPixelHorizontal( + static_cast( rMargin.GetLeftMargin() + nIndent ) ); + rTopM = mpOutputData->LogicToPixelHorizontal( + static_cast( rMargin.GetTopMargin() ) ); + rRightM = mpOutputData->LogicToPixelHorizontal( + static_cast( rMargin.GetRightMargin() ) ); + rBottomM = mpOutputData->LogicToPixelHorizontal( + static_cast( rMargin.GetBottomMargin() ) ); + // TODO: these need converting to pixels form logic if(meHorJustAttr == SVX_HOR_JUSTIFY_RIGHT) { - rLeftM = static_cast((rMargin.GetLeftMargin() * nPPTX)); - rRightM = static_cast(((rMargin.GetRightMargin() + nIndent) * nPPTX)); + rLeftM = mpOutputData->LogicToPixelHorizontal( + static_cast( rMargin.GetLeftMargin() ) ); + rRightM = mpOutputData->LogicToPixelHorizontal( + static_cast( rMargin.GetRightMargin() + nIndent ) ); } } void ScOutputData::DrawEditParam::calcPaperSize( - Size& rPaperSize, const Rectangle& rAlignRect, double nPPTX, double nPPTY) const + Size& rPaperSize, const Rectangle& rAlignRect ) const { long nTopM, nLeftM, nBottomM, nRightM; - calcMargins(nTopM, nLeftM, nBottomM, nRightM, nPPTX, nPPTY); + calcMargins( nTopM, nLeftM, nBottomM, nRightM ); if (isVerticallyOriented()) { @@ -2749,7 +2762,7 @@ void ScOutputData::DrawEditStandard(DrawEditParam& rParam) //! mirror margin values for RTL? //! move margin down to after final GetOutputArea call long nTopM, nLeftM, nBottomM, nRightM; - rParam.calcMargins(nTopM, nLeftM, nBottomM, nRightM, mnPPTX, mnPPTY); + rParam.calcMargins( nTopM, nLeftM, nBottomM, nRightM ); SCCOL nXForPos = rParam.mnX; if ( nXForPos < nX1 ) @@ -2779,7 +2792,7 @@ void ScOutputData::DrawEditStandard(DrawEditParam& rParam) rParam.mbCellIsValue, true, false, aAreaParam ); //! special ScEditUtil handling if formatting for printer - rParam.calcPaperSize(aPaperSize, aAreaParam.maAlignRect, mnPPTX, mnPPTY); + rParam.calcPaperSize( aPaperSize, aAreaParam.maAlignRect ); } if (rParam.mbPixelToLogic) { @@ -4548,7 +4561,7 @@ void ScOutputData::DrawEdit(bool bPixelToLogic) // fdo#32530: Check if the first character is RTL. OUString aStr = mpDoc->GetString(nCellX, nCellY, nTab); - DrawEditParam aParam(pPattern, pCondSet, lcl_SafeIsValue(aCell)); + DrawEditParam aParam( this, pPattern, pCondSet, lcl_SafeIsValue(aCell) ); aParam.meHorJustContext = getAlignmentFromContext( aParam.meHorJustAttr, aParam.mbCellIsValue, aStr, *pPattern, pCondSet, mpDoc, nTab); aParam.meHorJustResult = (aParam.meHorJustAttr == SVX_HOR_JUSTIFY_BLOCK) ? -- cgit v1.2.3