diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2019-02-12 17:50:59 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2019-02-13 09:02:37 +0100 |
commit | cb9f393a5293c0f39d76b703154f8392c45f8047 (patch) | |
tree | c772c9afd86d11aefabcb2e36b9fe62bbe8cd65e | |
parent | 16780939141031632d04603a148859dc8a1ef3e1 (diff) |
sw btlr writing mode layout: implement unmapping of this direction
Fix various cases which trigger this warning:
warn:legacy.osl:10975:10975:sw/source/core/txtnode/swfont.cxx:427: Unsupported direction
Which means that we tried to work with a VCL direction of 900, without
passing around the btlr flag accordingly.
Change-Id: I96374fc949f60e8324c5a84de48b710b6461bafb
Reviewed-on: https://gerrit.libreoffice.org/67746
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
-rw-r--r-- | sw/source/core/inc/frmtool.hxx | 7 | ||||
-rw-r--r-- | sw/source/core/inc/swfont.hxx | 26 | ||||
-rw-r--r-- | sw/source/core/layout/paintfrm.cxx | 22 | ||||
-rw-r--r-- | sw/source/core/text/inftxt.cxx | 23 | ||||
-rw-r--r-- | sw/source/core/txtnode/fntcache.cxx | 25 | ||||
-rw-r--r-- | sw/source/core/txtnode/swfont.cxx | 72 |
6 files changed, 117 insertions, 58 deletions
diff --git a/sw/source/core/inc/frmtool.hxx b/sw/source/core/inc/frmtool.hxx index 507dca39313d..0790582777bf 100644 --- a/sw/source/core/inc/frmtool.hxx +++ b/sw/source/core/inc/frmtool.hxx @@ -111,12 +111,13 @@ void SwAlignGrfRect( SwRect *pGrfRect, const OutputDevice &rOut ); * @param[in] rFont font object of actual text, which specify the border * @param[in] rPaintArea rectangle area in which line portion takes place * @param[in] bVerticalLayout corresponding text frame verticality + * @param[in] bVerticalLayoutLRBT corresponding text frame verticality (LRBT subset) * @param[in] bJoinWithPrev leave border with which actual border joins to the previous portion * @param[in] bJoinWithNext leave border with which actual border joins to the next portion **/ -void PaintCharacterBorder( - const SwFont& rFont, const SwRect& rPaintArea, const bool bVerticalLayout, - const bool bJoinWithPrev, const bool bJoinWithNext ); +void PaintCharacterBorder(const SwFont& rFont, const SwRect& rPaintArea, const bool bVerticalLayout, + const bool bVerticalLayoutLRBT, const bool bJoinWithPrev, + const bool bJoinWithNext); // get Fly, if no List is given use the current shell // Implementation in feshview.cxx diff --git a/sw/source/core/inc/swfont.hxx b/sw/source/core/inc/swfont.hxx index cc299a1d3fba..2e1369450c89 100644 --- a/sw/source/core/inc/swfont.hxx +++ b/sw/source/core/inc/swfont.hxx @@ -46,7 +46,7 @@ const sal_Unicode CH_TAB = '\t'; // \t const sal_Unicode CH_PAR = 0xB6; // paragraph const sal_Unicode CH_BULLET = 0xB7; // centered dot -sal_uInt16 UnMapDirection( sal_uInt16 nDir, const bool bVertFormat ); +sal_uInt16 UnMapDirection( sal_uInt16 nDir, const bool bVertFormat, const bool bVertFormatLRBT ); class SwSubFont : public SvxFont { @@ -282,7 +282,8 @@ public: FontWeight GetWeight() const { return m_aSub[m_nActual].GetWeight(); } FontEmphasisMark GetEmphasisMark() const { return m_aSub[m_nActual].GetEmphasisMark(); } - sal_uInt16 GetOrientation( const bool bVertLayout = false ) const; + sal_uInt16 GetOrientation(const bool bVertLayout = false, + const bool bVertFormatLRBT = false) const; const OUString& GetName( const SwFontScript nWhich ) const { return m_aSub[nWhich].GetFamilyName(); } @@ -339,10 +340,14 @@ public: const boost::optional<editeng::SvxBorderLine>& GetLeftBorder() const { return m_aLeftBorder; } // Get absolute border correspond to the layout verticality and orientation. - const boost::optional<editeng::SvxBorderLine>& GetAbsTopBorder( const bool bVertLayout ) const; - const boost::optional<editeng::SvxBorderLine>& GetAbsBottomBorder( const bool bVertLayout ) const; - const boost::optional<editeng::SvxBorderLine>& GetAbsRightBorder( const bool bVertLayout ) const; - const boost::optional<editeng::SvxBorderLine>& GetAbsLeftBorder( const bool bVertLayout ) const; + const boost::optional<editeng::SvxBorderLine>& + GetAbsTopBorder(const bool bVertLayout, const bool bVertLayoutLRBT) const; + const boost::optional<editeng::SvxBorderLine>& + GetAbsBottomBorder(const bool bVertLayout, const bool bVertLayoutLRBT) const; + const boost::optional<editeng::SvxBorderLine>& + GetAbsRightBorder(const bool bVertLayout, const bool bVertLayoutLRBT) const; + const boost::optional<editeng::SvxBorderLine>& + GetAbsLeftBorder(const bool bVertLayout, const bool bVertLayoutLRBT) const; void SetTopBorderDist( const sal_uInt16 nTopDist ); void SetBottomBorderDist( const sal_uInt16 nBottomDist ); @@ -376,9 +381,12 @@ public: * * @param[in] bVertLayout true, if the container layout is vertical * false, otherwise + * @param[in] bVertLayoutLRBT true if the container layout is vertical + * (bottom to top, left to right), false otherwise * @return absolute location **/ - SvxShadowLocation GetAbsShadowLocation( const bool bVertLayout ) const; + SvxShadowLocation GetAbsShadowLocation(const bool bVertLayout, + const bool bVertLayoutLRBT) const; /** * Calculate the shadow space on the specified side dependent from @@ -388,12 +396,14 @@ public: * @param[in] nShadow specify the side * @param[in] bVertLayout true, if the container layout is vertical * false, otherwise + * @param[in] bVertLayoutLRBT true if the container layout is vertical + * (bottom to top, left to right), false otherwise * @param[in] bSkipLeft relative left shadow space is skipped * @param[in] bSkipRight relative right shadow space is skipped * @return the shadow space **/ sal_uInt16 CalcShadowSpace( - const SvxShadowItemSide nShadow, const bool bVertLayout, + const SvxShadowItemSide nShadow, const bool bVertLayout, const bool bVertLayoutLRBT, const bool bSkipLeft, const bool bSkipRight ) const; void dumpAsXml( xmlTextWriterPtr writer ) const; diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx index 9db67c8b292d..28244dab159f 100644 --- a/sw/source/core/layout/paintfrm.cxx +++ b/sw/source/core/layout/paintfrm.cxx @@ -4694,6 +4694,7 @@ void PaintCharacterBorder( const SwFont& rFont, const SwRect& rPaintArea, const bool bVerticalLayout, + const bool bVerticalLayoutLRBT, const bool bJoinWithPrev, const bool bJoinWithNext ) { @@ -4705,7 +4706,7 @@ void PaintCharacterBorder( bool bLeft = true; bool bRight = true; - switch( rFont.GetOrientation(bVerticalLayout) ) + switch (rFont.GetOrientation(bVerticalLayout, bVerticalLayoutLRBT)) { case 0 : bLeft = !bJoinWithPrev; @@ -4729,7 +4730,7 @@ void PaintCharacterBorder( { const SvxShadowItem aShadow( 0, &rFont.GetShadowColor(), rFont.GetShadowWidth(), - rFont.GetAbsShadowLocation(bVerticalLayout)); + rFont.GetAbsShadowLocation(bVerticalLayout, bVerticalLayoutLRBT)); if( aShadow.GetLocation() != SvxShadowLocation::NONE ) { @@ -4742,10 +4743,19 @@ void PaintCharacterBorder( basegfx::utils::createScaleTranslateB2DHomMatrix( aAlignedRect.Width(), aAlignedRect.Height(), aAlignedRect.Left(), aAlignedRect.Top())); - const svx::frame::Style aStyleTop(bTop ? rFont.GetAbsTopBorder(bVerticalLayout).get_ptr() : nullptr, 1.0); - const svx::frame::Style aStyleRight(bRight ? rFont.GetAbsRightBorder(bVerticalLayout).get_ptr() : nullptr, 1.0); - const svx::frame::Style aStyleBottom(bBottom ? rFont.GetAbsBottomBorder(bVerticalLayout).get_ptr() : nullptr, 1.0); - const svx::frame::Style aStyleLeft(bLeft ? rFont.GetAbsLeftBorder(bVerticalLayout).get_ptr() : nullptr, 1.0); + const svx::frame::Style aStyleTop( + bTop ? rFont.GetAbsTopBorder(bVerticalLayout, bVerticalLayoutLRBT).get_ptr() : nullptr, + 1.0); + const svx::frame::Style aStyleRight( + bRight ? rFont.GetAbsRightBorder(bVerticalLayout, bVerticalLayoutLRBT).get_ptr() : nullptr, + 1.0); + const svx::frame::Style aStyleBottom( + bBottom ? rFont.GetAbsBottomBorder(bVerticalLayout, bVerticalLayoutLRBT).get_ptr() + : nullptr, + 1.0); + const svx::frame::Style aStyleLeft( + bLeft ? rFont.GetAbsLeftBorder(bVerticalLayout, bVerticalLayoutLRBT).get_ptr() : nullptr, + 1.0); drawinglayer::primitive2d::Primitive2DContainer aBorderLineTarget; aBorderLineTarget.append( diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx index cb3668dbb710..b18e7273672c 100644 --- a/sw/source/core/text/inftxt.cxx +++ b/sw/source/core/text/inftxt.cxx @@ -778,10 +778,19 @@ void SwTextPaintInfo::CalcRect( const SwLinePortion& rPor, const bool bJoinWithNext = static_cast<const SwTextPortion&>(rPor).GetJoinBorderWithNext(); const bool bIsVert = GetTextFrame()->IsVertical(); - aRect.Top(aRect.Top() + GetFont()->CalcShadowSpace(SvxShadowItemSide::TOP, bIsVert, bJoinWithPrev, bJoinWithNext )); - aRect.Bottom(aRect.Bottom() - GetFont()->CalcShadowSpace(SvxShadowItemSide::BOTTOM, bIsVert, bJoinWithPrev, bJoinWithNext )); - aRect.Left(aRect.Left() + GetFont()->CalcShadowSpace(SvxShadowItemSide::LEFT, bIsVert, bJoinWithPrev, bJoinWithNext )); - aRect.Right(aRect.Right() - GetFont()->CalcShadowSpace(SvxShadowItemSide::RIGHT, bIsVert, bJoinWithPrev, bJoinWithNext )); + const bool bIsVertLRBT = GetTextFrame()->IsVertLRBT(); + aRect.Top(aRect.Top() + + GetFont()->CalcShadowSpace(SvxShadowItemSide::TOP, bIsVert, bIsVertLRBT, + bJoinWithPrev, bJoinWithNext)); + aRect.Bottom(aRect.Bottom() + - GetFont()->CalcShadowSpace(SvxShadowItemSide::BOTTOM, bIsVert, bIsVertLRBT, + bJoinWithPrev, bJoinWithNext)); + aRect.Left(aRect.Left() + + GetFont()->CalcShadowSpace(SvxShadowItemSide::LEFT, bIsVert, bIsVertLRBT, + bJoinWithPrev, bJoinWithNext)); + aRect.Right(aRect.Right() + - GetFont()->CalcShadowSpace(SvxShadowItemSide::RIGHT, bIsVert, bIsVertLRBT, + bJoinWithPrev, bJoinWithNext)); } if ( pRect ) @@ -1263,9 +1272,9 @@ void SwTextPaintInfo::DrawBorder( const SwLinePortion &rPor ) const CalcRect( rPor, &aDrawArea ); if ( aDrawArea.HasArea() ) { - PaintCharacterBorder( - *m_pFnt, aDrawArea, GetTextFrame()->IsVertical(), - rPor.GetJoinBorderWithPrev(), rPor.GetJoinBorderWithNext()); + PaintCharacterBorder(*m_pFnt, aDrawArea, GetTextFrame()->IsVertical(), + GetTextFrame()->IsVertLRBT(), rPor.GetJoinBorderWithPrev(), + rPor.GetJoinBorderWithNext()); } } diff --git a/sw/source/core/txtnode/fntcache.cxx b/sw/source/core/txtnode/fntcache.cxx index 8cdcf5478392..1a9ad25b933c 100644 --- a/sw/source/core/txtnode/fntcache.cxx +++ b/sw/source/core/txtnode/fntcache.cxx @@ -252,18 +252,20 @@ struct CalcLinePosData vcl::Font& rFont; TextFrameIndex const nCnt; const bool bSwitchH2V; + const bool bSwitchH2VLRBT; const bool bSwitchL2R; long const nHalfSpace; long* const pKernArray; const bool bBidiPor; CalcLinePosData( SwDrawTextInfo& _rInf, vcl::Font& _rFont, - TextFrameIndex const _nCnt, const bool _bSwitchH2V, const bool _bSwitchL2R, + TextFrameIndex const _nCnt, const bool _bSwitchH2V, const bool _bSwitchH2VLRBT, const bool _bSwitchL2R, long _nHalfSpace, long* _pKernArray, const bool _bBidiPor) : rInf( _rInf ), rFont( _rFont ), nCnt( _nCnt ), bSwitchH2V( _bSwitchH2V ), + bSwitchH2VLRBT( _bSwitchH2VLRBT ), bSwitchL2R( _bSwitchL2R ), nHalfSpace( _nHalfSpace ), pKernArray( _pKernArray ), @@ -294,8 +296,9 @@ static void lcl_calcLinePos( const CalcLinePosData &rData, sal_Int32 nKernStart = nStart ? rData.pKernArray[sal_Int32(nStart) - 1] : 0; sal_Int32 nKernEnd = rData.pKernArray[sal_Int32(nEnd) - 1]; - const sal_uInt16 nDir = rData.bBidiPor ? 1800 : - UnMapDirection( rData.rFont.GetOrientation(), rData.bSwitchH2V ); + const sal_uInt16 nDir = rData.bBidiPor ? 1800 + : UnMapDirection(rData.rFont.GetOrientation(), + rData.bSwitchH2V, rData.bSwitchH2VLRBT); switch ( nDir ) { @@ -934,6 +937,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf ) // line of the ExtendedAttributeSets will appear in the font color first const bool bSwitchH2V = rInf.GetFrame() && rInf.GetFrame()->IsVertical(); + const bool bSwitchH2VLRBT = rInf.GetFrame() && rInf.GetFrame()->IsVertLRBT(); const bool bSwitchL2R = rInf.GetFrame() && rInf.GetFrame()->IsRightToLeft() && ! rInf.IsIgnoreFrameRTL(); const ComplexTextLayoutFlags nMode = rInf.GetOut().GetLayoutMode(); @@ -1724,11 +1728,10 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf ) Point aEnd; long nKernVal = pKernArray[sal_Int32(rInf.GetLen()) - 1]; - const sal_uInt16 nDir = bBidiPor ? - 1800 : - UnMapDirection( - GetFont().GetOrientation(), - bSwitchH2V ); + const sal_uInt16 nDir = bBidiPor + ? 1800 + : UnMapDirection(GetFont().GetOrientation(), + bSwitchH2V, bSwitchH2VLRBT); switch ( nDir ) { @@ -1778,9 +1781,9 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf ) // anything to do? if (rInf.GetWrong() || rInf.GetGrammarCheck() || rInf.GetSmartTags()) { - CalcLinePosData aCalcLinePosData(rInf, GetFont(), - nCnt, bSwitchH2V, bSwitchL2R, - nHalfSpace, pKernArray.get(), bBidiPor); + CalcLinePosData aCalcLinePosData(rInf, GetFont(), nCnt, bSwitchH2V, + bSwitchH2VLRBT, bSwitchL2R, nHalfSpace, + pKernArray.get(), bBidiPor); SwForbidden aForbidden; // draw line for smart tag data diff --git a/sw/source/core/txtnode/swfont.cxx b/sw/source/core/txtnode/swfont.cxx index 8c0e97cd30a7..4de9b2b2ee90 100644 --- a/sw/source/core/txtnode/swfont.cxx +++ b/sw/source/core/txtnode/swfont.cxx @@ -125,9 +125,9 @@ void SwFont::SetLeftBorder( const editeng::SvxBorderLine* pLeftBorder ) } const boost::optional<editeng::SvxBorderLine>& -SwFont::GetAbsTopBorder( const bool bVertLayout ) const +SwFont::GetAbsTopBorder(const bool bVertLayout, const bool bVertLayoutLRBT) const { - switch( GetOrientation( bVertLayout ) ) + switch (GetOrientation(bVertLayout, bVertLayoutLRBT)) { case 0 : return m_aTopBorder; @@ -149,9 +149,9 @@ SwFont::GetAbsTopBorder( const bool bVertLayout ) const } const boost::optional<editeng::SvxBorderLine>& -SwFont::GetAbsBottomBorder( const bool bVertLayout ) const +SwFont::GetAbsBottomBorder(const bool bVertLayout, const bool bVertLayoutLRBT) const { - switch( GetOrientation( bVertLayout ) ) + switch (GetOrientation(bVertLayout, bVertLayoutLRBT)) { case 0 : return m_aBottomBorder; @@ -173,9 +173,9 @@ SwFont::GetAbsBottomBorder( const bool bVertLayout ) const } const boost::optional<editeng::SvxBorderLine>& -SwFont::GetAbsLeftBorder( const bool bVertLayout ) const +SwFont::GetAbsLeftBorder(const bool bVertLayout, const bool bVertLayoutLRBT) const { - switch( GetOrientation( bVertLayout ) ) + switch (GetOrientation(bVertLayout, bVertLayoutLRBT)) { case 0 : return m_aLeftBorder; @@ -197,9 +197,9 @@ SwFont::GetAbsLeftBorder( const bool bVertLayout ) const } const boost::optional<editeng::SvxBorderLine>& -SwFont::GetAbsRightBorder( const bool bVertLayout ) const +SwFont::GetAbsRightBorder(const bool bVertLayout, const bool bVertLayoutLRBT) const { - switch( GetOrientation( bVertLayout ) ) + switch (GetOrientation(bVertLayout, bVertLayoutLRBT)) { case 0 : return m_aRightBorder; @@ -220,10 +220,11 @@ SwFont::GetAbsRightBorder( const bool bVertLayout ) const } } -SvxShadowLocation SwFont::GetAbsShadowLocation( const bool bVertLayout ) const +SvxShadowLocation SwFont::GetAbsShadowLocation(const bool bVertLayout, + const bool bVertLayoutLRBT) const { SvxShadowLocation aLocation = SvxShadowLocation::NONE; - switch( GetOrientation( bVertLayout ) ) + switch (GetOrientation(bVertLayout, bVertLayoutLRBT)) { case 0: aLocation = m_aShadowLocation; @@ -302,13 +303,13 @@ SvxShadowLocation SwFont::GetAbsShadowLocation( const bool bVertLayout ) const return aLocation; } -sal_uInt16 SwFont::CalcShadowSpace( - const SvxShadowItemSide nShadow, const bool bVertLayout, - const bool bSkipLeft, const bool bSkipRight ) const +sal_uInt16 SwFont::CalcShadowSpace(const SvxShadowItemSide nShadow, const bool bVertLayout, + const bool bVertLayoutLRBT, const bool bSkipLeft, + const bool bSkipRight) const { sal_uInt16 nSpace = 0; - const sal_uInt16 nOrient = GetOrientation( bVertLayout ); - const SvxShadowLocation aLoc = GetAbsShadowLocation( bVertLayout ); + const sal_uInt16 nOrient = GetOrientation(bVertLayout, bVertLayoutLRBT); + const SvxShadowLocation aLoc = GetAbsShadowLocation(bVertLayout, bVertLayoutLRBT); switch( nShadow ) { case SvxShadowItemSide::TOP: @@ -393,8 +394,22 @@ static sal_uInt16 MapDirection(sal_uInt16 nDir, const bool bVertFormat, const bo // maps the absolute direction set at the font to its logical counterpart // in the rotated environment -sal_uInt16 UnMapDirection( sal_uInt16 nDir, const bool bVertFormat ) +sal_uInt16 UnMapDirection(sal_uInt16 nDir, const bool bVertFormat, const bool bVertFormatLRBT) { + if (bVertFormatLRBT) + { + switch (nDir) + { + case 900: + nDir = 0; + break; + default: + SAL_WARN("sw.core", "unsupported direction for VertLRBT"); + break; + } + return nDir; + } + if ( bVertFormat ) { switch ( nDir ) @@ -418,9 +433,9 @@ sal_uInt16 UnMapDirection( sal_uInt16 nDir, const bool bVertFormat ) return nDir; } -sal_uInt16 SwFont::GetOrientation( const bool bVertFormat ) const +sal_uInt16 SwFont::GetOrientation(const bool bVertFormat, const bool bVertFormatLRBT) const { - return UnMapDirection( m_aSub[m_nActual].GetOrientation(), bVertFormat ); + return UnMapDirection(m_aSub[m_nActual].GetOrientation(), bVertFormat, bVertFormatLRBT); } void SwFont::SetVertical(sal_uInt16 nDir, const bool bVertFormat, const bool bVertLayoutLRBT) @@ -1382,8 +1397,14 @@ void SwSubFont::CalcEsc( SwDrawTextInfo const & rInf, Point& rPos ) { long nOfst; - const sal_uInt16 nDir = UnMapDirection( - GetOrientation(), rInf.GetFrame() && rInf.GetFrame()->IsVertical() ); + bool bVert = false; + bool bVertLRBT = false; + if (rInf.GetFrame()) + { + bVert = rInf.GetFrame()->IsVertical(); + bVertLRBT = rInf.GetFrame()->IsVertLRBT(); + } + const sal_uInt16 nDir = UnMapDirection(GetOrientation(), bVert, bVertLRBT); switch ( GetEscapement() ) { @@ -1453,9 +1474,14 @@ void SwDrawTextInfo::Shift( sal_uInt16 nDir ) const bool bBidiPor = ( GetFrame() && GetFrame()->IsRightToLeft() ) != ( ComplexTextLayoutFlags::Default != ( ComplexTextLayoutFlags::BiDiRtl & GetpOut()->GetLayoutMode() ) ); - nDir = bBidiPor ? - 1800 : - UnMapDirection( nDir, GetFrame() && GetFrame()->IsVertical() ); + bool bVert = false; + bool bVertLRBT = false; + if (GetFrame()) + { + bVert = GetFrame()->IsVertical(); + bVertLRBT = GetFrame()->IsVertLRBT(); + } + nDir = bBidiPor ? 1800 : UnMapDirection(nDir, bVert, bVertLRBT); switch ( nDir ) { |