// Test drawing a dotted line in Impress presentation mode. void testTdf136957()
{ // Impress presentation mode first draws the slide to a metafile.
GDIMetaFile metafile; // I got these values by adding debug output to cppcanvas::internal::ImplRenderer::ImplRenderer().
metafile.SetPrefMapMode(MapMode(MapUnit::Map100thMM));
metafile.SetPrefSize(Size(14548, 3350));
ScopedVclPtrInstance<VirtualDevice> metadevice;
metafile.Record(metadevice);
drawinglayer::geometry::ViewInformation2D view;
std::unique_ptr<processor2d::BaseProcessor2D> processor(
processor2d::createProcessor2DFromOutputDevice(*metadevice, view));
CPPUNIT_ASSERT(processor); // Match the values Impress uses.
basegfx::B2DPolygon polygon = { { 15601, 0 }, { 15602, 5832 } };
attribute::LineAttribute lineAttributes(
basegfx::BColor(0.047058823529411764, 0.19607843137254902, 0.17254901960784313), 35,
basegfx::B2DLineJoin::Miter, css::drawing::LineCap_ROUND);
attribute::StrokeAttribute strokeAttributes({ 0.35, 69.65 });
rtl::Reference<primitive2d::PolygonStrokePrimitive2D> strokePrimitive( new primitive2d::PolygonStrokePrimitive2D(polygon, lineAttributes, strokeAttributes));
primitive2d::Primitive2DContainer primitives;
primitives.push_back(strokePrimitive);
processor->process(primitives);
metafile.Stop();
metafile.WindStart();
// Now verify that the metafile has the one PolyLine action with the right dashing. int lineActionCount = 0; for (std::size_t i = 0; i < metafile.GetActionSize(); ++i)
{ const MetaAction* metaAction = metafile.GetAction(i); if (metaAction->GetType() == MetaActionType::POLYLINE)
{ const MetaPolyLineAction* action
= static_cast<const MetaPolyLineAction*>(metaAction);
// Now draw the metafile using canvas and verify that the line is drawn.
setupCanvas(Size(1920, 1080));
cppcanvas::CanvasSharedPtr cppCanvas = cppcanvas::VCLFactory::createCanvas(mCanvas); // I got these matrices from a breakpoint in drawing the polyline, and walking up // the stack to the canvas code.
cppCanvas->setTransformation(
basegfx::B2DHomMatrix(0.056662828121770453, 0, 0, 0, 0.056640419947506564, 0));
cppcanvas::RendererSharedPtr renderer = cppcanvas::VCLFactory::createRenderer(
cppCanvas, metafile, cppcanvas::Renderer::Parameters());
renderer->setTransformation(basegfx::B2DHomMatrix(14548, 0, -2, 0, 3350, 3431));
CPPUNIT_ASSERT(renderer->draw());
exportDevice(u"test-tdf136957"_ustr, mVclDevice);
Bitmap bitmap = mVclDevice->GetBitmap(Point(), Size(1920, 1080));
BitmapScopedReadAccess access(bitmap); // There should be a dotted line, without the fix it wouldn't be there, so check // there's a sufficient amount of non-white pixels and that's the line. int nonWhiteCount = 0; for (tools::Long y = 193; y <= 524; ++y) for (tools::Long x = 883; x <= 885; ++x) if (access->GetColor(y, x) != COL_WHITE)
++nonWhiteCount;
CPPUNIT_ASSERT_GREATER(100, nonWhiteCount);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.