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 ...@@ -31,10 +31,12 @@ namespace drawinglayer
StructureTagPrimitive2D::StructureTagPrimitive2D( StructureTagPrimitive2D::StructureTagPrimitive2D(
const vcl::PDFWriter::StructElement& rStructureElement, const vcl::PDFWriter::StructElement& rStructureElement,
bool bBackground, bool bBackground,
bool bIsImage,
const Primitive2DContainer& rChildren) const Primitive2DContainer& rChildren)
: GroupPrimitive2D(rChildren), : GroupPrimitive2D(rChildren),
maStructureElement(rStructureElement), maStructureElement(rStructureElement),
mbBackground(bBackground) mbBackground(bBackground),
mbIsImage(bIsImage)
{ {
} }
...@@ -44,7 +46,8 @@ namespace drawinglayer ...@@ -44,7 +46,8 @@ namespace drawinglayer
{ {
const StructureTagPrimitive2D& rCompare = static_cast<const StructureTagPrimitive2D&>(rPrimitive); const StructureTagPrimitive2D& rCompare = static_cast<const StructureTagPrimitive2D&>(rPrimitive);
return (isBackground() == rCompare.isBackground()); return (isBackground() == rCompare.isBackground() &&
isImage() == rCompare.isImage());
} }
return false; return false;
......
...@@ -2213,20 +2213,31 @@ namespace drawinglayer ...@@ -2213,20 +2213,31 @@ namespace drawinglayer
{ {
// structured tag primitive // structured tag primitive
const vcl::PDFWriter::StructElement& rTagElement(rStructureTagCandidate.getStructureElement()); const vcl::PDFWriter::StructElement& rTagElement(rStructureTagCandidate.getStructureElement());
const bool bTagUsed(vcl::PDFWriter::NonStructElement != rTagElement); bool bTagUsed((vcl::PDFWriter::NonStructElement != rTagElement));
const bool bIsBackground(rStructureTagCandidate.isBackground());
if(mpPDFExtOutDevData && bTagUsed) if(mpPDFExtOutDevData && bTagUsed)
{ {
// Write start tag. For background elements use NonStructElement instead of real element type (e.g. Figure) // foreground object: tag as regular structure element
// to guarantee it gets exported as artifact (tagged PDF) if (!rStructureTagCandidate.isBackground())
mpPDFExtOutDevData->BeginStructureElement(bIsBackground ? vcl::PDFWriter::NonStructElement : rTagElement); {
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 children normally
process(rStructureTagCandidate.getChildren()); process(rStructureTagCandidate.getChildren());
if(mpPDFExtOutDevData && bTagUsed) if(mpPDFExtOutDevData && bTagUsed)
{ {
// write end tag // write end tag
mpPDFExtOutDevData->EndStructureElement(); mpPDFExtOutDevData->EndStructureElement();
......
...@@ -48,20 +48,23 @@ namespace drawinglayer ...@@ -48,20 +48,23 @@ namespace drawinglayer
/// the PDF structure element this grouping represents /// the PDF structure element this grouping represents
vcl::PDFWriter::StructElement maStructureElement; vcl::PDFWriter::StructElement maStructureElement;
///Z flag for background contenht that may be handled as /// flag for background object
/// Tagged PDF '/Artifact'
bool mbBackground; bool mbBackground;
/// flag for image (OBJ_GRAF)
bool mbIsImage;
public: public:
/// constructor /// constructor
StructureTagPrimitive2D( StructureTagPrimitive2D(
const vcl::PDFWriter::StructElement& rStructureElement, const vcl::PDFWriter::StructElement& rStructureElement,
bool bBackground, bool bBackground,
bool bIsImage,
const Primitive2DContainer& rChildren); const Primitive2DContainer& rChildren);
/// data read access /// data read access
const vcl::PDFWriter::StructElement& getStructureElement() const { return maStructureElement; } const vcl::PDFWriter::StructElement& getStructureElement() const { return maStructureElement; }
bool isBackground() const { return mbBackground; } bool isBackground() const { return mbBackground; }
bool isImage() const { return mbIsImage; }
/// compare operator /// compare operator
virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; virtual bool operator==(const BasePrimitive2D& rPrimitive) const override;
......
...@@ -1804,14 +1804,15 @@ drawinglayer::primitive2d::Primitive2DContainer ImplRenderPaintProc::createRedir ...@@ -1804,14 +1804,15 @@ drawinglayer::primitive2d::Primitive2DContainer ImplRenderPaintProc::createRedir
// embed Primitive2DSequence in a structure tag element for // embed Primitive2DSequence in a structure tag element for
// exactly this purpose (StructureTagPrimitive2D) // exactly this purpose (StructureTagPrimitive2D)
//Z
const SdrPage* pSdrPage(pObject->getSdrPageFromSdrObject()); const SdrPage* pSdrPage(pObject->getSdrPageFromSdrObject());
const bool bBackground(nullptr != pSdrPage && pSdrPage->IsMasterPage()); const bool bBackground(nullptr != pSdrPage && pSdrPage->IsMasterPage());
const bool bImage(pObject->GetObjIdentifier() == OBJ_GRAF);
const drawinglayer::primitive2d::Primitive2DReference xReference( const drawinglayer::primitive2d::Primitive2DReference xReference(
new drawinglayer::primitive2d::StructureTagPrimitive2D( new drawinglayer::primitive2d::StructureTagPrimitive2D(
eElement, eElement,
bBackground, bBackground,
bImage,
xRetval)); xRetval));
xRetval = drawinglayer::primitive2d::Primitive2DContainer { xReference }; 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