[Libreoffice-commits] core.git: Branch 'feature/borderline2' - drawinglayer/source svx/source sw/source
arminl
arminl at KRANIX
Thu Jul 27 14:03:17 UTC 2017
drawinglayer/source/primitive2d/borderlineprimitive2d.cxx | 28 +-
svx/source/dialog/framelink.cxx | 20 +
svx/source/dialog/framelinkarray.cxx | 8
sw/source/core/layout/paintfrm.cxx | 142 --------------
4 files changed, 48 insertions(+), 150 deletions(-)
New commits:
commit b6cdad8a0cbb3c4b0ef8984179502daa054d8518
Author: arminl <arminl at KRANIX>
Date: Thu Jul 27 16:03:48 2017 +0200
borderline: corrections for calc and writer
Made corrections/finetuning for Calc and Writer.
Had to remove some former code which tried to do
corrections
Change-Id: Ia7669c9eb7f3338d250cd350bfa5c2bc8e61763b
diff --git a/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx b/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx
index 724ba8772c44..1dfa77a80f7c 100644
--- a/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx
@@ -104,13 +104,17 @@ namespace drawinglayer
// double line with gap. Use mfDiscreteGapDistance (see get2DDecomposition) as distance.
// That value is prepared to be at least one pixel (discrete unit) so that the
// decomposition is view-dependent in this cases
+ const BorderLine& rLeft(getBorderLines()[0]);
+ const BorderLine& rGap(getBorderLines()[1]);
+ const BorderLine& rRight(getBorderLines()[2]);
+ const double fFullWidth(rLeft.getWidth() + mfDiscreteGapDistance + rRight.getWidth());
+
{
- // inside line (left of vector). Create stroke primitive centered on line width
- const BorderLine& rLeft(getBorderLines()[0]);
- const double fDeltaY((mfDiscreteGapDistance + rLeft.getWidth()) * 0.5);
+ // inside line (left of vector). Create stroke primitive centered on left line width
+ const double fDeltaY((rLeft.getWidth() - fFullWidth) * 0.5);
const basegfx::B2DVector aDeltaY(aPerpendicular * fDeltaY);
- const basegfx::B2DPoint aStart(getStart() - (aVector * rLeft.getExtendStart()) - aDeltaY);
- const basegfx::B2DPoint aEnd(getEnd() + (aVector * rLeft.getExtendEnd()) - aDeltaY);
+ const basegfx::B2DPoint aStart(getStart() - (aVector * rLeft.getExtendStart()) + aDeltaY);
+ const basegfx::B2DPoint aEnd(getEnd() + (aVector * rLeft.getExtendEnd()) + aDeltaY);
const attribute::LineAttribute aLineAttribute(rLeft.getRGBColor(), rLeft.getWidth());
addPolygonStrokePrimitive2D(
@@ -124,10 +128,11 @@ namespace drawinglayer
if (hasGapColor())
{
// gap (if visible, found practical usage in Writer MultiColorBorderLines).
- // Create stroke primitive on vector with given color
- const BorderLine& rGap(getBorderLines()[1]);
- const basegfx::B2DPoint aStart(getStart() - (aVector * rGap.getExtendStart()));
- const basegfx::B2DPoint aEnd(getEnd() + (aVector * rGap.getExtendEnd()));
+ // Create stroke primitive on vector with given color centered on gap position
+ const double fDeltaY(((fFullWidth - mfDiscreteGapDistance) * 0.5) - rRight.getWidth());
+ const basegfx::B2DVector aDeltaY(aPerpendicular * fDeltaY);
+ const basegfx::B2DPoint aStart(getStart() - (aVector * rGap.getExtendStart()) + aDeltaY);
+ const basegfx::B2DPoint aEnd(getEnd() + (aVector * rGap.getExtendEnd()) + aDeltaY);
const attribute::LineAttribute aLineAttribute(rGap.getRGBColor(), mfDiscreteGapDistance);
addPolygonStrokePrimitive2D(
@@ -139,9 +144,8 @@ namespace drawinglayer
}
{
- // outside line (right of vector). Create stroke primitive centered on line width
- const BorderLine& rRight(getBorderLines()[2]);
- const double fDeltaY((mfDiscreteGapDistance + rRight.getWidth()) * 0.5);
+ // outside line (right of vector). Create stroke primitive centered on right line width
+ const double fDeltaY((fFullWidth - rRight.getWidth()) * 0.5);
const basegfx::B2DVector aDeltaY(aPerpendicular * fDeltaY);
const basegfx::B2DPoint aStart(getStart() - (aVector * rRight.getExtendStart()) + aDeltaY);
const basegfx::B2DPoint aEnd(getEnd() + (aVector * rRight.getExtendEnd()) + aDeltaY);
diff --git a/svx/source/dialog/framelink.cxx b/svx/source/dialog/framelink.cxx
index c746e881679c..faa408c29dcc 100644
--- a/svx/source/dialog/framelink.cxx
+++ b/svx/source/dialog/framelink.cxx
@@ -523,7 +523,14 @@ double getSimpleExtendedLineValues(
if (pResult)
{
- return (pResult->mfLeftRight + pResult->mfRightRight) * 0.5 * (bEdgeStart ? -fLength : fLength);
+ if (bEdgeStart)
+ {
+ return (pResult->mfLeftRight + pResult->mfRightRight) * -0.5 * fLength;
+ }
+ else
+ {
+ return (pResult->mfLeftLeft + pResult->mfRightLeft) * 0.5 * fLength;
+ }
}
return 0.0;
@@ -552,8 +559,17 @@ double getComplexExtendedLineValues(
if (pResult)
{
- return (pResult->mfLeftRight + pResult->mfRightRight) * 0.5 * (bEdgeStart ? -fLength : fLength);
+ if (bEdgeStart)
+ {
+ return (pResult->mfLeftRight + pResult->mfRightRight) * 0.5 * -fLength;
+ }
+ else
+ {
+ return (pResult->mfLeftLeft + pResult->mfRightLeft) * 0.5 * fLength;
+ }
}
+
+ return 0.0;
}
void CreateBorderPrimitives(
diff --git a/svx/source/dialog/framelinkarray.cxx b/svx/source/dialog/framelinkarray.cxx
index 839e9bef5d77..0817a474320a 100644
--- a/svx/source/dialog/framelinkarray.cxx
+++ b/svx/source/dialog/framelinkarray.cxx
@@ -1122,7 +1122,7 @@ void Array::DrawRange( drawinglayer::processor2d::BaseProcessor2D& rProcessor,
aY.normalize();
}
- drawinglayer::primitive2d::Primitive2DContainer aSequence(1);
+ drawinglayer::primitive2d::Primitive2DContainer aSequence;
CreateBorderPrimitives(
aSequence,
aOrigin,
@@ -1188,7 +1188,7 @@ void Array::DrawRange( drawinglayer::processor2d::BaseProcessor2D& rProcessor,
aY.normalize();
}
- drawinglayer::primitive2d::Primitive2DContainer aSequence(1);
+ drawinglayer::primitive2d::Primitive2DContainer aSequence;
CreateBorderPrimitives(
aSequence,
aOrigin,
@@ -1288,7 +1288,7 @@ void Array::DrawRange( drawinglayer::processor2d::BaseProcessor2D& rProcessor,
aY = -aY;
}
- drawinglayer::primitive2d::Primitive2DContainer aSequence(1);
+ drawinglayer::primitive2d::Primitive2DContainer aSequence;
CreateBorderPrimitives(
// This replaces DrawVerFrameBorder which went from top to bottom. To be able to use
// the same method as for horizontal (CreateBorderPrimitives), the given borders
@@ -1367,7 +1367,7 @@ void Array::DrawRange( drawinglayer::processor2d::BaseProcessor2D& rProcessor,
aY = -aY;
}
- drawinglayer::primitive2d::Primitive2DContainer aSequence(1);
+ drawinglayer::primitive2d::Primitive2DContainer aSequence;
CreateBorderPrimitives(
// also reordered, see call to CreateBorderPrimitives above
aSequence,
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index 407ac441ecf7..493eb8ea3185 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -2448,11 +2448,6 @@ struct SwLineEntry
SwTwips mnKey;
SwTwips mnStartPos;
SwTwips mnEndPos;
- SwTwips mnOffset;
-
- bool mbOffsetPerp;
- bool mbOffsetStart;
- bool mbOffsetEnd;
svx::frame::Style maAttribute;
@@ -2474,10 +2469,6 @@ SwLineEntry::SwLineEntry( SwTwips nKey,
: mnKey( nKey ),
mnStartPos( nStartPos ),
mnEndPos( nEndPos ),
- mnOffset( 0 ),
- mbOffsetPerp(false),
- mbOffsetStart(false),
- mbOffsetEnd(false),
maAttribute( rAttribute )
{
}
@@ -2556,8 +2547,6 @@ class SwTabFramePainter
svx::frame::Style*,
bool bHori ) const;
- void AdjustTopLeftFrames();
-
public:
explicit SwTabFramePainter( const SwTabFrame& rTabFrame );
@@ -2568,7 +2557,6 @@ SwTabFramePainter::SwTabFramePainter( const SwTabFrame& rTabFrame )
: mrTabFrame( rTabFrame )
{
HandleFrame( rTabFrame );
- AdjustTopLeftFrames();
}
void SwTabFramePainter::HandleFrame( const SwLayoutFrame& rLayoutFrame )
@@ -2666,42 +2654,6 @@ void SwTabFramePainter::PaintLines(OutputDevice& rDev, const SwRect& rRect) cons
svx::frame::Style aStyles[ 7 ];
aStyles[ 0 ] = rEntryStyle;
FindStylesForLine( aStart, aEnd, aStyles, bHori );
-
- // Account for double line thicknesses for the top- and left-most borders.
- if (rEntry.mnOffset)
- {
- if (bHori)
- {
- if (rEntry.mbOffsetPerp)
- {
- // Apply offset in perpendicular direction.
- aStart.Y() -= rEntry.mnOffset;
- aEnd.Y() -= rEntry.mnOffset;
- }
- if (rEntry.mbOffsetStart)
- // Apply offset at the start of a border.
- aStart.X() -= rEntry.mnOffset;
- if (rEntry.mbOffsetEnd)
- // Apply offset at the end of a border.
- aEnd.X() += rEntry.mnOffset;
- }
- else
- {
- if (rEntry.mbOffsetPerp)
- {
- // Apply offset in perpendicular direction.
- aStart.X() -= rEntry.mnOffset;
- aEnd.X() -= rEntry.mnOffset;
- }
- if (rEntry.mbOffsetStart)
- // Apply offset at the start of a border.
- aStart.Y() -= rEntry.mnOffset;
- if (rEntry.mbOffsetEnd)
- // Apply offset at the end of a border.
- aEnd.Y() += rEntry.mnOffset;
- }
- }
-
SwRect aRepaintRect( aStart, aEnd );
// the repaint rectangle has to be moved a bit for the centered lines:
@@ -2769,47 +2721,25 @@ void SwTabFramePainter::PaintLines(OutputDevice& rDev, const SwRect& rRect) cons
aPaintEnd.Y() = aUpperAligned.Bottom_();
}
- // logically vertical lines are painted centered on the line,
- // logically horizontal lines are painted "below" the line
- //
- // This does not need to be done here, it is set in SwTabFramePainter::Insert
- // already using SetRefMode(...) as property of the BorderLine Style, see there.
- // When additionally adding the offset here manually, it will be applied
- // double and will be rendered wrong. This did not happen before because
- // the setting of the svx::frame::RefMode at svx::frame::Style was ignored there.
- //
- // bool const isBelow((mrTabFrame.IsVertical()) ? !bHori : bHori);
- // double const offsetStart = (isBelow)
- // ? aStyles[0].GetWidth() / 2.0
- // : std::max<double>(aStyles[1].GetWidth(),
- // aStyles[3].GetWidth()) / 2.0;
- // double const offsetEnd = (isBelow)
- // ? aStyles[0].GetWidth() / 2.0
- // : std::max<double>(aStyles[4].GetWidth(),
- // aStyles[6].GetWidth()) / 2.0;
- // if (mrTabFrame.IsVertical())
- // {
- // aPaintStart.X() -= static_cast<long>(offsetStart + 0.5);
- // aPaintEnd.X() -= static_cast<long>(offsetEnd + 0.5);
- // }
- // else
- // {
- // aPaintStart.Y() += static_cast<long>(offsetStart + 0.5);
- // aPaintEnd.Y() += static_cast<long>(offsetEnd + 0.5);
- // }
-
if (bHori)
{
const basegfx::B2DPoint aOrigin(aPaintStart.X(), aPaintStart.Y());
const basegfx::B2DVector aX(basegfx::B2DPoint(aPaintEnd.X(), aPaintEnd.Y()) - aOrigin);
const basegfx::B2DVector aY(basegfx::getNormalizedPerpendicular(aX));
- drawinglayer::primitive2d::Primitive2DContainer aSequence(1);
+ drawinglayer::primitive2d::Primitive2DContainer aSequence;
svx::frame::CreateBorderPrimitives(
aSequence,
aOrigin,
aX,
- aY,
+
+ // Writer creates it's vertical BorderLines bottom-to-top (see below).
+ // To make the horizontal lines correctly 'guess' the line extensions
+ // for the then mirrored svx::frame::Style for irregular double lines,
+ // hand over the for that case correct orientatoin of the 'other'
+ // incoming edges
+ -aY,
+
aStyles[ 0 ], // current style
aStyles[ 1 ], // aLFromT
aStyles[ 2 ], // aLFromL
@@ -2825,7 +2755,7 @@ void SwTabFramePainter::PaintLines(OutputDevice& rDev, const SwRect& rRect) cons
const basegfx::B2DPoint aOrigin(aPaintEnd.X(), aPaintEnd.Y());
const basegfx::B2DVector aX(basegfx::B2DPoint(aPaintStart.X(), aPaintStart.Y()) - aOrigin);
const basegfx::B2DVector aY(basegfx::getNormalizedPerpendicular(aX));
- drawinglayer::primitive2d::Primitive2DContainer aSequence(1);
+ drawinglayer::primitive2d::Primitive2DContainer aSequence;
svx::frame::CreateBorderPrimitives(
aSequence,
@@ -2954,58 +2884,6 @@ void SwTabFramePainter::FindStylesForLine( const Point& rStartPoint,
}
}
-namespace {
-
-void calcOffsetForDoubleLine( SwLineEntryMap& rLines )
-{
- SwLineEntryMap aNewLines;
- SwLineEntryMap::iterator it = rLines.begin(), itEnd = rLines.end();
- bool bFirst = true;
- for (; it != itEnd; ++it)
- {
- if (bFirst)
- {
- // First line needs to be offset to account for double line thickness.
- SwLineEntrySet aNewSet;
- const SwLineEntrySet& rSet = it->second;
- SwLineEntrySet::iterator itSet = rSet.begin(), itSetEnd = rSet.end();
- size_t nEntryCount = rSet.size();
- for (size_t i = 0; itSet != itSetEnd; ++itSet, ++i)
- {
- SwLineEntry aLine = *itSet;
- if (aLine.maAttribute.Secn())
- {
- // Apply offset only for double lines.
- aLine.mnOffset = static_cast<SwTwips>(aLine.maAttribute.Dist());
- aLine.mbOffsetPerp = true;
-
- if (i == 0)
- aLine.mbOffsetStart = true;
- if (i == nEntryCount - 1)
- aLine.mbOffsetEnd = true;
- }
-
- aNewSet.insert(aLine);
- }
-
- aNewLines.insert(SwLineEntryMap::value_type(it->first, aNewSet));
- }
- else
- aNewLines.insert(SwLineEntryMap::value_type(it->first, it->second));
-
- bFirst = false;
- }
- rLines.swap(aNewLines);
-}
-
-}
-
-void SwTabFramePainter::AdjustTopLeftFrames()
-{
- calcOffsetForDoubleLine(maHoriLines);
- calcOffsetForDoubleLine(maVertLines);
-}
-
/**
* Special case: #i9860#
* first line in follow table without repeated headlines
More information about the Libreoffice-commits
mailing list