summaryrefslogtreecommitdiff
path: root/sw/source/core/layout
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2019-02-12 16:38:47 +0100
committerMiklos Vajna <vmiklos@collabora.com>2019-02-12 18:18:53 +0100
commite8b9572bf89f55463f2c879a401ed62efc165d95 (patch)
treebb14bef40f4ee43df2249c0e9ea43a449e84f331 /sw/source/core/layout
parent4bbb0bcb88614d3ccaaab4bea4fe2309c92b881e (diff)
sw btlr writing mode: implement initial layout
The bulk of this commit is reasonably straightforward, the interesting parts are: - SwFrame::CheckDir() is where the layout reads the doc model, i.e. sets the new SwFrame::mbVertLRBT. - We had 3 text directions previously: horizontal, vertical (implicitly RL) and vertical LR (implicitly TB). This adds a 4th text direction for the LRBT case. - SwTextFrame::SwitchHorizontalToVertical() is responsible for re-locating the origo of a string to be painted from the top left to the bottom left corner (in addition to the height/width swap that's done for all vertical directions). - Finally MapDirection() is the place where we map Writer's new btlr mode (with no character rotation) to VCL's 900 (90 degrees) rotated direction. No functional changes intended for existing text directions. Lots of places are still not yet adapted, but this is good enough to paint a single word in a table cell at the correct position with the correct direction. Change-Id: I465c62db6562d8a2be140c3d37473e590830139e Reviewed-on: https://gerrit.libreoffice.org/67740 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'sw/source/core/layout')
-rw-r--r--sw/source/core/layout/calcmove.cxx2
-rw-r--r--sw/source/core/layout/colfrm.cxx2
-rw-r--r--sw/source/core/layout/findfrm.cxx1
-rw-r--r--sw/source/core/layout/newfrm.cxx61
-rw-r--r--sw/source/core/layout/paintfrm.cxx4
-rw-r--r--sw/source/core/layout/ssfrm.cxx4
-rw-r--r--sw/source/core/layout/wsfrm.cxx14
7 files changed, 78 insertions, 10 deletions
diff --git a/sw/source/core/layout/calcmove.cxx b/sw/source/core/layout/calcmove.cxx
index c8541459aeda..05260abf2dad 100644
--- a/sw/source/core/layout/calcmove.cxx
+++ b/sw/source/core/layout/calcmove.cxx
@@ -893,7 +893,7 @@ void SwLayoutFrame::MakeAll(vcl::RenderContext* /*pRenderContext*/)
const SwLayNotify aNotify( this );
bool bVert = IsVertical();
- SwRectFn fnRect = ( IsNeighbourFrame() == bVert )? fnRectHori : ( IsVertLR() ? fnRectVertL2R : fnRectVert );
+ SwRectFn fnRect = ( IsNeighbourFrame() == bVert )? fnRectHori : ( IsVertLR() ? (IsVertLRBT() ? fnRectVertL2RB2T : fnRectVertL2R) : fnRectVert );
std::unique_ptr<SwBorderAttrAccess> pAccess;
const SwBorderAttrs*pAttrs = nullptr;
diff --git a/sw/source/core/layout/colfrm.cxx b/sw/source/core/layout/colfrm.cxx
index 3a695b136734..6339d026fafb 100644
--- a/sw/source/core/layout/colfrm.cxx
+++ b/sw/source/core/layout/colfrm.cxx
@@ -300,7 +300,7 @@ void SwLayoutFrame::AdjustColumns( const SwFormatCol *pAttr, bool bAdjustAttribu
const bool bVert = IsVertical();
- SwRectFn fnRect = bVert ? ( IsVertLR() ? fnRectVertL2R : fnRectVert ) : fnRectHori;
+ SwRectFn fnRect = bVert ? ( IsVertLR() ? (IsVertLRBT() ? fnRectVertL2RB2T : fnRectVertL2R) : fnRectVert ) : fnRectHori;
//If we have a pointer or we have to configure an attribute, we set the
//column widths in any case. Otherwise we check if a configuration is needed.
diff --git a/sw/source/core/layout/findfrm.cxx b/sw/source/core/layout/findfrm.cxx
index 3ed0dede61f5..a0af09b2ad37 100644
--- a/sw/source/core/layout/findfrm.cxx
+++ b/sw/source/core/layout/findfrm.cxx
@@ -1476,6 +1476,7 @@ void SwFrame::SetDirFlags( bool bVert )
{
mbVertical = pAsk->IsVertical();
mbVertLR = pAsk->IsVertLR();
+ mbVertLRBT = pAsk->IsVertLRBT();
if ( !pAsk->mbInvalidVert )
mbInvalidVert = false;
diff --git a/sw/source/core/layout/newfrm.cxx b/sw/source/core/layout/newfrm.cxx
index adc2909c38a5..0971c2d95a8e 100644
--- a/sw/source/core/layout/newfrm.cxx
+++ b/sw/source/core/layout/newfrm.cxx
@@ -224,9 +224,70 @@ static SwRectFnCollection aVerticalLeftToRight = {
/*.fnSetTopAndHeight =*/&SwRect::SetLeftAndWidth
};
+/**
+ * This is the same as horizontal, but rotated counter-clockwise by 90 degrees.
+ * This means logical top is physical right, bottom is left, left is top,
+ * finally right is bottom.
+ */
+static SwRectFnCollection aVerticalLeftToRightBottomToTop = {
+ /*.fnGetTop =*/&SwRect::Right_,
+ /*.fnGetBottom =*/&SwRect::Left_,
+ /*.fnGetLeft =*/&SwRect::Top_,
+ /*.fnGetRight =*/&SwRect::Bottom_,
+ /*.fnGetWidth =*/&SwRect::Height_,
+ /*.fnGetHeight =*/&SwRect::Width_,
+ /*.fnGetPos =*/&SwRect::TopRight,
+ /*.fnGetSize =*/&SwRect::SwappedSize,
+
+ /*.fnSetTop =*/&SwRect::Right_,
+ /*.fnSetBottom =*/&SwRect::Left_,
+ /*.fnSetLeft =*/&SwRect::Top_,
+ /*.fnSetRight =*/&SwRect::Bottom_,
+ /*.fnSetWidth =*/&SwRect::Height_,
+ /*.fnSetHeight =*/&SwRect::Width_,
+
+ /*.fnSubTop =*/&SwRect::AddRight,
+ /*.fnAddBottom =*/&SwRect::SubLeft,
+ /*.fnSubLeft =*/&SwRect::SubTop,
+ /*.fnAddRight =*/&SwRect::AddBottom,
+ /*.fnAddWidth =*/&SwRect::AddHeight,
+ /*.fnAddHeight =*/&SwRect::AddWidth,
+
+ /*.fnSetPosX =*/&SwRect::SetPosY,
+ /*.fnSetPosY =*/&SwRect::SetPosX,
+
+ /*.fnGetTopMargin =*/&SwFrame::GetRightMargin,
+ /*.fnGetBottomMargin =*/&SwFrame::GetLeftMargin,
+ /*.fnGetLeftMargin =*/&SwFrame::GetTopMargin,
+ /*.fnGetRightMargin =*/&SwFrame::GetBottomMargin,
+ /*.fnSetXMargins =*/&SwFrame::SetTopBottomMargins,
+ /*.fnSetYMargins =*/&SwFrame::SetLeftRightMargins,
+ /*.fnGetPrtTop =*/&SwFrame::GetPrtRight,
+ /*.fnGetPrtBottom =*/&SwFrame::GetPrtLeft,
+ /*.fnGetPrtLeft =*/&SwFrame::GetPrtTop,
+ /*.fnGetPrtRight =*/&SwFrame::GetPrtBottom,
+ /*.fnTopDist =*/&SwRect::GetRightDistance,
+ /*.fnBottomDist =*/&SwRect::GetLeftDistance,
+ /*.fnLeftDist =*/&SwRect::GetTopDistance,
+ /*.fnRightDist =*/&SwRect::GetBottomDistance,
+ /*.fnSetLimit =*/&SwFrame::SetMinLeft,
+ /*.fnOverStep =*/&SwRect::OverStepLeft,
+
+ /*.fnSetPos =*/&SwRect::SetUpperRightCorner,
+ /*.fnMakePos =*/&SwFrame::MakeLeftPos,
+ /*.fnXDiff =*/&FirstMinusSecond,
+ /*.fnYDiff =*/&FirstMinusSecond,
+ /*.fnXInc =*/&SwIncrement,
+ /*.fnYInc =*/&SwIncrement,
+
+ /*.fnSetLeftAndWidth =*/&SwRect::SetTopAndHeight,
+ /*.fnSetTopAndHeight =*/&SwRect::SetRightAndWidth
+};
+
SwRectFn fnRectHori = &aHorizontal;
SwRectFn fnRectVert = &aVertical;
SwRectFn fnRectVertL2R = &aVerticalLeftToRight;
+SwRectFn fnRectVertL2RB2T = &aVerticalLeftToRightBottomToTop;
// #i65250#
sal_uInt32 SwFrameAreaDefinition::mnLastFrameId=0;
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index b3fc9e8843b3..9db67c8b292d 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -1255,7 +1255,7 @@ static void lcl_CalcBorderRect( SwRect &rRect, const SwFrame *pFrame,
rRect = pFrame->getFramePrintArea();
rRect.Pos() += pFrame->getFrameArea().Pos();
- SwRectFn fnRect = pFrame->IsVertical() ? ( pFrame->IsVertLR() ? fnRectVertL2R : fnRectVert ) : fnRectHori;
+ SwRectFn fnRect = pFrame->IsVertical() ? ( pFrame->IsVertLR() ? (pFrame->IsVertLRBT() ? fnRectVertL2RB2T : fnRectVertL2R) : fnRectVert ) : fnRectHori;
const SvxBoxItem &rBox = rAttrs.GetBox();
const bool bTop = 0 != (pFrame->*fnRect->fnGetTopMargin)();
@@ -5218,7 +5218,7 @@ void SwLayoutFrame::PaintColLines( const SwRect &rRect, const SwFormatCol &rForm
if ( !pCol || !pCol->IsColumnFrame() )
return;
- SwRectFn fnRect = pCol->IsVertical() ? ( pCol->IsVertLR() ? fnRectVertL2R : fnRectVert ) : fnRectHori;
+ SwRectFn fnRect = pCol->IsVertical() ? ( pCol->IsVertLR() ? (pCol->IsVertLRBT() ? fnRectVertL2RB2T : fnRectVertL2R) : fnRectVert ) : fnRectHori;
SwRect aLineRect = getFramePrintArea();
aLineRect += getFrameArea().Pos();
diff --git a/sw/source/core/layout/ssfrm.cxx b/sw/source/core/layout/ssfrm.cxx
index f309693befc2..46cf019acbc4 100644
--- a/sw/source/core/layout/ssfrm.cxx
+++ b/sw/source/core/layout/ssfrm.cxx
@@ -584,7 +584,7 @@ const SwRect SwFrame::GetPaintArea() const
// Cell frames may not leave their upper:
SwRect aRect = IsRowFrame() ? GetUpper()->getFrameArea() : getFrameArea();
const bool bVert = IsVertical();
- SwRectFn fnRect = bVert ? ( IsVertLR() ? fnRectVertL2R : fnRectVert ) : fnRectHori;
+ SwRectFn fnRect = bVert ? ( IsVertLR() ? (IsVertLRBT() ? fnRectVertL2RB2T : fnRectVertL2R) : fnRectVert ) : fnRectHori;
long nRight = (aRect.*fnRect->fnGetRight)();
long nLeft = (aRect.*fnRect->fnGetLeft)();
const SwFrame* pTmp = this;
@@ -675,7 +675,7 @@ const SwRect SwFrame::GetPaintArea() const
const SwRect SwFrame::UnionFrame( bool bBorder ) const
{
bool bVert = IsVertical();
- SwRectFn fnRect = bVert ? ( IsVertLR() ? fnRectVertL2R : fnRectVert ) : fnRectHori;
+ SwRectFn fnRect = bVert ? ( IsVertLR() ? (IsVertLRBT() ? fnRectVertL2RB2T : fnRectVertL2R) : fnRectVert ) : fnRectHori;
long nLeft = (getFrameArea().*fnRect->fnGetLeft)();
long nWidth = (getFrameArea().*fnRect->fnGetWidth)();
long nPrtLeft = (getFramePrintArea().*fnRect->fnGetLeft)();
diff --git a/sw/source/core/layout/wsfrm.cxx b/sw/source/core/layout/wsfrm.cxx
index 39b9fbb8009d..c76f70110990 100644
--- a/sw/source/core/layout/wsfrm.cxx
+++ b/sw/source/core/layout/wsfrm.cxx
@@ -300,6 +300,7 @@ SwFrame::SwFrame( SwModify *pMod, SwFrame* pSib )
mbDerivedVert(false),
mbVertical(false),
mbVertLR(false),
+ mbVertLRBT(false),
mbValidLineNum(false),
mbFixSize(false),
mbCompletePaint(true),
@@ -357,6 +358,11 @@ void SwFrame::CheckDir( SvxFrameDirection nDir, bool bVert, bool bOnlyBiDi, bool
mbVertLR = false;
else if(SvxFrameDirection::Vertical_LR_TB==nDir)
mbVertLR = true;
+ else if (nDir == SvxFrameDirection::Vertical_LR_BT)
+ {
+ mbVertLR = true;
+ mbVertLRBT = true;
+ }
}
}
else
@@ -712,7 +718,7 @@ Size SwFrame::ChgSize( const Size& aNewSize )
if ( GetUpper() )
{
bool bNeighb = IsNeighbourFrame();
- SwRectFn fnRect = IsVertical() == bNeighb ? fnRectHori : ( IsVertLR() ? fnRectVertL2R : fnRectVert );
+ SwRectFn fnRect = IsVertical() == bNeighb ? fnRectHori : ( IsVertLR() ? (IsVertLRBT() ? fnRectVertL2RB2T : fnRectVertL2R) : fnRectVert );
SwRect aNew( Point(0,0), aNewSize );
{
@@ -1319,9 +1325,9 @@ void SwLayoutFrame::Paste( SwFrame* pParent, SwFrame* pSibling)
if ( IsHeaderFrame() || IsFooterFrame() )
fnRect = fnRectHori;
else if ( IsCellFrame() || IsColumnFrame() )
- fnRect = GetUpper()->IsVertical() ? fnRectHori : ( GetUpper()->IsVertLR() ? fnRectVertL2R : fnRectVert );
+ fnRect = GetUpper()->IsVertical() ? fnRectHori : ( GetUpper()->IsVertLR() ? (GetUpper()->IsVertLRBT() ? fnRectVertL2RB2T : fnRectVertL2R) : fnRectVert );
else
- fnRect = GetUpper()->IsVertical() ? ( GetUpper()->IsVertLR() ? fnRectVertL2R : fnRectVert ) : fnRectHori;
+ fnRect = GetUpper()->IsVertical() ? ( GetUpper()->IsVertLR() ? (GetUpper()->IsVertLRBT() ? fnRectVertL2RB2T : fnRectVertL2R) : fnRectVert ) : fnRectHori;
if( (getFrameArea().*fnRect->fnGetWidth)() != (pParent->getFramePrintArea().*fnRect->fnGetWidth)())
InvalidateSize_();
@@ -3364,7 +3370,7 @@ void SwLayoutFrame::Format( vcl::RenderContext* /*pRenderContext*/, const SwBord
const sal_uInt16 nLower = bHideWhitespace ? 0 : pAttrs->CalcBottom();
const bool bVert = IsVertical() && !IsPageFrame();
- SwRectFn fnRect = bVert ? ( IsVertLR() ? fnRectVertL2R : fnRectVert ) : fnRectHori;
+ SwRectFn fnRect = bVert ? ( IsVertLR() ? (IsVertLRBT() ? fnRectVertL2RB2T : fnRectVertL2R) : fnRectVert ) : fnRectHori;
if ( !isFramePrintAreaValid() )
{
setFramePrintAreaValid(true);