Files
loongoffice/drawinglayer/source/processor2d/vclprocessor2d.hxx
Michael Stahl 78681cd082 tdf#57423 drawinglayer: PDF/UA export: more Alt texts for SdrObjects
Currently /Alt texts are generated from ObjectInfoPrimitive2D, but this
is only evaluated in VclMetafileProcessor2D::processGraphicPrimitive2D()
so while it's created for every SdrObject, it's ignored in most cases.

There doesn't appear to be a reason why this is done in
processGraphicPrimitive2D() and not a more generic location, the special
conditions that are checked there don't have anything to do with Alt
texts, they effectively guard some optimisation done to bitmaps in
PageSyncData::PlaySyncPageAct().

There is another issue in that not every SdrObject gets a
StructureTagPrimitive2D, and even if there is a StructureTagPrimitive2D
it may be ignored if it's in the background.

The Alt text must only be produced if there is a structure element for
the same SdrObject, else it would end up on some unrelated structure
element.

Fix all this by moving processing to a new function which checks that
there is a current StructureTagPrimitive2D for a SdrObject in effect.

The only problem with this is that previously Writer images produced Alt
text, and now they don't - but Writer needs some fixing anyway.

Change-Id: I2a362e8a9cd93e5bc817c6eed546c46b46e14980
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143189
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
2022-11-25 11:47:13 +01:00

124 lines
5.0 KiB
C++

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#pragma once
#include <drawinglayer/processor2d/baseprocessor2d.hxx>
#include <basegfx/matrix/b2dhommatrix.hxx>
#include <basegfx/color/bcolormodifier.hxx>
#include <vcl/vclptr.hxx>
class OutputDevice;
namespace drawinglayer::primitive2d
{
class TextSimplePortionPrimitive2D;
class PolygonHairlinePrimitive2D;
class BitmapPrimitive2D;
class FillGraphicPrimitive2D;
class PolyPolygonGradientPrimitive2D;
class PolyPolygonGraphicPrimitive2D;
class MetafilePrimitive2D;
class MaskPrimitive2D;
class UnifiedTransparencePrimitive2D;
class TransparencePrimitive2D;
class TransformPrimitive2D;
class MarkerArrayPrimitive2D;
class PointArrayPrimitive2D;
class ModifiedColorPrimitive2D;
class PolygonStrokePrimitive2D;
class ControlPrimitive2D;
class PagePreviewPrimitive2D;
class EpsPrimitive2D;
class SvgLinearAtomPrimitive2D;
class SvgRadialAtomPrimitive2D;
}
namespace drawinglayer::processor2d
{
/** VclProcessor2D class
This processor is the base class for VCL-Based processors. It has no
processBasePrimitive2D implementation and thus is not usable directly.
*/
class VclProcessor2D : public BaseProcessor2D
{
protected:
// the destination OutDev
VclPtr<OutputDevice> mpOutputDevice;
// the modifiedColorPrimitive stack
basegfx::BColorModifierStack maBColorModifierStack;
// the current transformation. Since VCL pixel renderer transforms to pixels
// and VCL MetaFile renderer to World (logic) coordinates, the local
// ViewInformation2D cannot directly be used, but needs to be kept up to date
basegfx::B2DHomMatrix maCurrentTransformation;
// stack value (increment and decrement) to count how deep we are in
// PolygonStrokePrimitive2D's decompositions (normally only one)
sal_uInt32 mnPolygonStrokePrimitive2D;
// common VCL rendering support
void RenderTextSimpleOrDecoratedPortionPrimitive2D(
const primitive2d::TextSimplePortionPrimitive2D& rTextCandidate);
void RenderPolygonHairlinePrimitive2D(
const primitive2d::PolygonHairlinePrimitive2D& rPolygonCandidate, bool bPixelBased);
void RenderBitmapPrimitive2D(const primitive2d::BitmapPrimitive2D& rBitmapCandidate);
void
RenderFillGraphicPrimitive2D(const primitive2d::FillGraphicPrimitive2D& rFillBitmapCandidate);
void RenderPolyPolygonGraphicPrimitive2D(
const primitive2d::PolyPolygonGraphicPrimitive2D& rPolygonCandidate);
void RenderMaskPrimitive2DPixel(const primitive2d::MaskPrimitive2D& rMaskCandidate);
void
RenderModifiedColorPrimitive2D(const primitive2d::ModifiedColorPrimitive2D& rModifiedCandidate);
void RenderUnifiedTransparencePrimitive2D(
const primitive2d::UnifiedTransparencePrimitive2D& rTransCandidate);
void RenderTransparencePrimitive2D(const primitive2d::TransparencePrimitive2D& rTransCandidate);
void RenderTransformPrimitive2D(const primitive2d::TransformPrimitive2D& rTransformCandidate);
void
RenderPagePreviewPrimitive2D(const primitive2d::PagePreviewPrimitive2D& rPagePreviewCandidate);
void
RenderMarkerArrayPrimitive2D(const primitive2d::MarkerArrayPrimitive2D& rMarkerArrayCandidate);
void
RenderPointArrayPrimitive2D(const primitive2d::PointArrayPrimitive2D& rPointArrayCandidate);
void RenderPolygonStrokePrimitive2D(
const primitive2d::PolygonStrokePrimitive2D& rPolygonStrokeCandidate);
void RenderEpsPrimitive2D(const primitive2d::EpsPrimitive2D& rEpsPrimitive2D);
void RenderSvgLinearAtomPrimitive2D(const primitive2d::SvgLinearAtomPrimitive2D& rCandidate);
void RenderSvgRadialAtomPrimitive2D(const primitive2d::SvgRadialAtomPrimitive2D& rCandidate);
// DrawMode adaptation support
void adaptLineToFillDrawMode() const;
void adaptTextToFillDrawMode() const;
public:
// constructor/destructor
VclProcessor2D(const geometry::ViewInformation2D& rViewInformation, OutputDevice& rOutDev,
basegfx::BColorModifierStack aInitStack = basegfx::BColorModifierStack());
virtual ~VclProcessor2D() override;
private:
bool RenderFillGraphicPrimitive2DImpl(
const primitive2d::FillGraphicPrimitive2D& rFillBitmapCandidate);
};
} // end of namespace drawinglayer::processor2d
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */