Kaydet (Commit) a0fd6c4d authored tarafından Katarina Behrens's avatar Katarina Behrens

Limit tagging of background objects to images

i.e. don't tag custom shapes and other than bitmap background fills

Change-Id: I1d42012420f59e1e7b62affb8aca5a8c85688423
Reviewed-on: https://gerrit.libreoffice.org/69258
Tested-by: Jenkins
Reviewed-by: 's avatarKatarina Behrens <Katarina.Behrens@cib.de>
üst c312dfb5
......@@ -31,10 +31,12 @@ namespace drawinglayer
StructureTagPrimitive2D::StructureTagPrimitive2D(
const vcl::PDFWriter::StructElement& rStructureElement,
bool bBackground,
bool bIsImage,
const Primitive2DContainer& rChildren)
: GroupPrimitive2D(rChildren),
maStructureElement(rStructureElement),
mbBackground(bBackground)
mbBackground(bBackground),
mbIsImage(bIsImage)
{
}
......@@ -44,7 +46,8 @@ namespace drawinglayer
{
const StructureTagPrimitive2D& rCompare = static_cast<const StructureTagPrimitive2D&>(rPrimitive);
return (isBackground() == rCompare.isBackground());
return (isBackground() == rCompare.isBackground() &&
isImage() == rCompare.isImage());
}
return false;
......
......@@ -2213,20 +2213,31 @@ namespace drawinglayer
{
// structured tag primitive
const vcl::PDFWriter::StructElement& rTagElement(rStructureTagCandidate.getStructureElement());
const bool bTagUsed(vcl::PDFWriter::NonStructElement != rTagElement);
const bool bIsBackground(rStructureTagCandidate.isBackground());
bool bTagUsed((vcl::PDFWriter::NonStructElement != rTagElement));
if(mpPDFExtOutDevData && bTagUsed)
{
// Write start tag. For background elements use NonStructElement instead of real element type (e.g. Figure)
// to guarantee it gets exported as artifact (tagged PDF)
mpPDFExtOutDevData->BeginStructureElement(bIsBackground ? vcl::PDFWriter::NonStructElement : rTagElement);
// foreground object: tag as regular structure element
if (!rStructureTagCandidate.isBackground())
{
mpPDFExtOutDevData->BeginStructureElement(rTagElement);
}
// background object
else
{
// background image: tag as artifact
if (rStructureTagCandidate.isImage())
mpPDFExtOutDevData->BeginStructureElement(vcl::PDFWriter::NonStructElement);
// any other background object: do not tag
else
bTagUsed = false;
}
}
// process children normally
process(rStructureTagCandidate.getChildren());
if(mpPDFExtOutDevData && bTagUsed)
if(mpPDFExtOutDevData && bTagUsed)
{
// write end tag
mpPDFExtOutDevData->EndStructureElement();
......
......@@ -48,20 +48,23 @@ namespace drawinglayer
/// the PDF structure element this grouping represents
vcl::PDFWriter::StructElement maStructureElement;
///Z flag for background contenht that may be handled as
/// Tagged PDF '/Artifact'
/// flag for background object
bool mbBackground;
/// flag for image (OBJ_GRAF)
bool mbIsImage;
public:
/// constructor
StructureTagPrimitive2D(
const vcl::PDFWriter::StructElement& rStructureElement,
bool bBackground,
bool bIsImage,
const Primitive2DContainer& rChildren);
/// data read access
const vcl::PDFWriter::StructElement& getStructureElement() const { return maStructureElement; }
bool isBackground() const { return mbBackground; }
bool isImage() const { return mbIsImage; }
/// compare operator
virtual bool operator==(const BasePrimitive2D& rPrimitive) const override;
......
......@@ -1804,14 +1804,15 @@ drawinglayer::primitive2d::Primitive2DContainer ImplRenderPaintProc::createRedir
// embed Primitive2DSequence in a structure tag element for
// exactly this purpose (StructureTagPrimitive2D)
//Z
const SdrPage* pSdrPage(pObject->getSdrPageFromSdrObject());
const bool bBackground(nullptr != pSdrPage && pSdrPage->IsMasterPage());
const bool bImage(pObject->GetObjIdentifier() == OBJ_GRAF);
const drawinglayer::primitive2d::Primitive2DReference xReference(
new drawinglayer::primitive2d::StructureTagPrimitive2D(
eElement,
bBackground,
bImage,
xRetval));
xRetval = drawinglayer::primitive2d::Primitive2DContainer { xReference };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment