diff options
author | Armin Le Grand <Armin.Le.Grand@cib.de> | 2017-07-04 16:28:58 +0200 |
---|---|---|
committer | Armin Le Grand <Armin.Le.Grand@cib.de> | 2017-07-12 21:01:20 +0200 |
commit | f65cbae8947c0462b35c8d3c3d5124e431b100b6 (patch) | |
tree | e8248f034f7a97e1716f9477937b55ae31038a76 /drawinglayer/qa | |
parent | fc55711f01af172eb3a034454405fa941454c781 (diff) |
borderline: correct problems with border display
Borderline display with direct paint and with primitive direct
paint has quite some errors in the current state. Started to
unify usages, check deeper with creation/usage.
borderline: deep changes to BorderLine
Found basic error in determining the offset values
for BorderLinePrimitive creation, these were not
centered on the lines. Corrected that. This makes
it possible to remove the formally used clipping
which seems to have been used to correct that. Also
allows to go back to a 'normal' decomposition that
creates line primitives as expected. That again can
then be painted quite normally.
Also added view-dependent case to the decomposition
to guarantee a gap of one discrete unit (pixel).
Removed the direct painter, too. Checked and corrected
stroking.
borderline: Adapted previews to primitives
Added code to use the primitive representation in
all dialogs and apps using tables. The edit views
use these mostly, so the preview should do that,
too. Currently missing is a good visualization of
diagonals, but this is also true for edit views.
Checked all apps and table usages to not get worse
borderline: correct line dash visualization
When a dashed line is used, a factor of 10.0 was applied in the
original coded, added that. Also the orientation of vertical
borders was inverted since it was simpler to exchange Start/End,
but this also mirrors the line dash visualisation, corrected that
Change-Id: I4c1b380a76cb37389fab1259a53fb7cc9da982d1
e95e246d5563360617a2a2213e4d5ec7d0e736b9
62369b4de58fb0264aeb710ec6983ceddca5701d
77418cc6c84ebb0632f8c3448976e82ce612d6b6
b4eb28dc86ce05eb89b26517167305b994158ef8
borderline: adapt cppunittest and clang
Diffstat (limited to 'drawinglayer/qa')
-rw-r--r-- | drawinglayer/qa/unit/border.cxx | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/drawinglayer/qa/unit/border.cxx b/drawinglayer/qa/unit/border.cxx index 25264c46ee51..ce99965b13f9 100644 --- a/drawinglayer/qa/unit/border.cxx +++ b/drawinglayer/qa/unit/border.cxx @@ -17,6 +17,7 @@ #include <drawinglayer/geometry/viewinformation2d.hxx> #include <drawinglayer/primitive2d/borderlineprimitive2d.hxx> #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx> +#include <drawinglayer/primitive2d/polygonprimitive2d.hxx> #include <drawinglayer/processor2d/baseprocessor2d.hxx> #include <drawinglayer/processor2d/processorfromoutputdevice.hxx> #include <rtl/ref.hxx> @@ -70,17 +71,15 @@ void DrawinglayerBorderTest::testDoubleDecompositionSolid() // Make sure it results in two borders as it's a double one. CPPUNIT_ASSERT_EQUAL(static_cast<std::size_t>(2), aContainer.size()); - // Get the inside line. - auto pInside = dynamic_cast<const drawinglayer::primitive2d::PolyPolygonColorPrimitive2D*>(aContainer[0].get()); + // Get the inside line, now a PolygonStrokePrimitive2D + auto pInside = dynamic_cast<const drawinglayer::primitive2d::PolygonStrokePrimitive2D*>(aContainer[0].get()); CPPUNIT_ASSERT(pInside); // Make sure the inside line's height is fLeftWidth. - const basegfx::B2DPolyPolygon& rPolyPolygon = pInside->getB2DPolyPolygon(); - CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(1), rPolyPolygon.count()); - const basegfx::B2DPolygon& rPolygon = rPolyPolygon.getB2DPolygon(0); - const basegfx::B2DRange& rRange = rPolygon.getB2DRange(); + const double fLineWidthFromDecompose = pInside->getLineAttribute().getWidth(); + // This was 2.47, i.e. the width of the inner line was 1 unit (in the bugdoc's case: 1 pixel) wider than expected. - CPPUNIT_ASSERT_DOUBLES_EQUAL(fLeftWidth, rRange.getHeight(), basegfx::fTools::getSmallValue()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(fLeftWidth, fLineWidthFromDecompose, basegfx::fTools::getSmallValue()); } void DrawinglayerBorderTest::testDoublePixelProcessing() @@ -100,7 +99,7 @@ void DrawinglayerBorderTest::testDoublePixelProcessing() basegfx::B2DPoint aEnd(100, 20); double const fLeftWidth = 1.47; double const fDistance = 1.47; - double fRightWidth = 1.47; + double const fRightWidth = 1.47; double const fExtendLeftStart = 0; double const fExtendLeftEnd = 0; double const fExtendRightStart = 0; @@ -117,31 +116,33 @@ void DrawinglayerBorderTest::testDoublePixelProcessing() // Process the primitives. pProcessor->process(aPrimitives); - // Now assert the height of the outer (second) border polygon. + // Double line now gets decomposed in Metafile to painting four lines + // with width == 0 in a cross pattern due to real line width being between + // 1.0 and 2.0. Count created lines aMetaFile.Stop(); aMetaFile.WindStart(); - bool bFirst = true; - sal_Int32 nHeight = 0; + sal_uInt32 nPolyLineActionCount = 0; + for (std::size_t nAction = 0; nAction < aMetaFile.GetActionSize(); ++nAction) { MetaAction* pAction = aMetaFile.GetAction(nAction); - if (pAction->GetType() == MetaActionType::POLYPOLYGON) + + if (MetaActionType::POLYLINE == pAction->GetType()) { - if (bFirst) + auto pMPLAction = static_cast<MetaPolyLineAction*>(pAction); + + if (0 == pMPLAction->GetLineInfo().GetWidth() && LineStyle::Solid == pMPLAction->GetLineInfo().GetStyle()) { - bFirst = false; - continue; + nPolyLineActionCount++; } - - auto pMPPAction = static_cast<MetaPolyPolygonAction*>(pAction); - const tools::PolyPolygon& rPolyPolygon = pMPPAction->GetPolyPolygon(); - nHeight = rPolyPolygon.GetBoundRect().getHeight(); } } - sal_Int32 nExpectedHeight = std::round(fRightWidth); - // This was 2, and should be 1: if the logical requested width is 1.47, - // then that must be 1 px on the screen, not 2. - CPPUNIT_ASSERT_EQUAL(nExpectedHeight, nHeight); + + // Check if all eight (2x four) simple lines with width == 0 and + // solid were created + const sal_uInt32 nExpectedNumPolyLineActions = 8; + + CPPUNIT_ASSERT_EQUAL(nExpectedNumPolyLineActions, nPolyLineActionCount); } CPPUNIT_TEST_SUITE_REGISTRATION(DrawinglayerBorderTest); |