include/svx/svdotable.hxx                  |    7 ---
 svx/source/table/viewcontactoftableobj.cxx |   59 +++++++++++++++++++++++++++--
 svx/source/table/viewcontactoftableobj.hxx |    1 
 3 files changed, 58 insertions(+), 9 deletions(-)

New commits:
commit 4bfa3edaeea444d46f9470d415667fb8df54c32d
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Thu Dec 1 13:35:32 2022 +0100
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Thu Dec 1 17:02:00 2022 +0100

    tdf#135192 svx: PDF/UA export: table tag primitives only if necessary
    
    Introduce a ViewObjectContactOfTableObj which is able to check that a
    tagged PDF export is in progress.
    
    For the non-PDF case, for performance, fall back to calling
    ViewContact::createViewIndependentPrimitive2DSequence().
    
    Change-Id: I87c86cc862c96868858f9f8617efeeab3846020f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143522
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/include/svx/svdotable.hxx b/include/svx/svdotable.hxx
index 9eea4930aff5..3e0da9a72708 100644
--- a/include/svx/svdotable.hxx
+++ b/include/svx/svdotable.hxx
@@ -262,6 +262,8 @@ public:
 
     virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override;
 
+    const TableLayouter& getTableLayouter() const;
+
 private:
     void init( sal_Int32 nColumns, sal_Int32 nRows );
 
@@ -274,11 +276,6 @@ private:
 
     SdrOutliner* GetCellTextEditOutliner( const sdr::table::Cell& rCell ) 
const;
 
-    // For the ViewContactOfTableObj to build the primitive representation, it 
is necessary to access the
-    // TableLayouter for position and attribute information
-    friend class sdr::contact::ViewContactOfTableObj;
-    const TableLayouter& getTableLayouter() const;
-
     tools::Rectangle   maLogicRect;
     rtl::Reference<SdrTableObjImpl> mpImpl;
 };
diff --git a/svx/source/table/viewcontactoftableobj.cxx 
b/svx/source/table/viewcontactoftableobj.cxx
index da11d1741789..3f17c5ccae21 100644
--- a/svx/source/table/viewcontactoftableobj.cxx
+++ b/svx/source/table/viewcontactoftableobj.cxx
@@ -36,6 +36,8 @@
 #include <drawinglayer/primitive2d/structuretagprimitive2d.hxx>
 #include <drawinglayer/primitive2d/transformprimitive2d.hxx>
 #include <basegfx/matrix/b2dhommatrixtools.hxx>
+#include <svx/sdr/contact/viewobjectcontactofsdrobj.hxx>
+#include <svx/sdr/contact/objectcontact.hxx>
 #include <svx/svdpage.hxx>
 #include <svx/framelink.hxx>
 #include <svx/framelinkarray.hxx>
@@ -153,6 +155,21 @@ namespace drawinglayer::primitive2d
 
 namespace sdr::contact
 {
+
+    namespace {
+        class ViewObjectContactOfTableObj : public ViewObjectContactOfSdrObj
+        {
+            public:
+                ViewObjectContactOfTableObj(ObjectContact& rObjectContact, 
ViewContact& rViewContact)
+                    : ViewObjectContactOfSdrObj(rObjectContact, rViewContact)
+                {
+                }
+
+            protected:
+                virtual void createPrimitive2DSequence(DisplayInfo const& 
rDisplayInfo, drawinglayer::primitive2d::Primitive2DDecompositionVisitor& 
rVisitor) const override;
+        };
+    } // namespace
+
         static svx::frame::Style impGetLineStyle(
             const sdr::table::TableLayouter& rLayouter,
             sal_Int32 nX,
@@ -204,9 +221,11 @@ namespace sdr::contact
             return svx::frame::Style();
         }
 
-        void 
ViewContactOfTableObj::createViewIndependentPrimitive2DSequence(drawinglayer::primitive2d::Primitive2DDecompositionVisitor&
 rVisitor) const
+        static void createPrimitive2DSequenceImpl(
+                sdr::table::SdrTableObj const& rTableObj,
+                bool const isTaggedPDF,
+                drawinglayer::primitive2d::Primitive2DDecompositionVisitor& 
rVisitor)
         {
-            const sdr::table::SdrTableObj& rTableObj = static_cast<const 
sdr::table::SdrTableObj&>(GetSdrObject());
             const uno::Reference< css::table::XTable > xTable = 
rTableObj.getTable();
 
             if(xTable.is())
@@ -352,7 +371,7 @@ namespace sdr::contact
                                     aRetvalForShadow.append(xCellReference);
                                 }
                             }
-                            if (pPage)
+                            if (isTaggedPDF && pPage)
                             {
                                 // heuristic: if there's a special formatting 
on
                                 // first row, assume that it's a header row
@@ -370,7 +389,7 @@ namespace sdr::contact
                             row.append(cell);
                         }
 
-                        if (pPage)
+                        if (isTaggedPDF && pPage)
                         {
                             row = 
drawinglayer::primitive2d::Primitive2DContainer {
                                 new 
drawinglayer::primitive2d::StructureTagPrimitive2D(
@@ -484,6 +503,38 @@ namespace sdr::contact
             }
         }
 
+        void ViewObjectContactOfTableObj::createPrimitive2DSequence(
+                DisplayInfo const& rDisplayInfo,
+                drawinglayer::primitive2d::Primitive2DDecompositionVisitor& 
rVisitor) const
+        {
+            bool const isTaggedPDF(GetObjectContact().isExportTaggedPDF());
+            if (isTaggedPDF)
+            {
+                // this will be unbuffered and contain structure tags
+                const sdr::table::SdrTableObj& rTableObj =
+                    static_cast<const 
sdr::table::SdrTableObj&>(*GetViewContact().TryToGetSdrObject());
+                return createPrimitive2DSequenceImpl(rTableObj, true, 
rVisitor);
+            }
+            else
+            {
+                // call it via the base class - this is supposed to be buffered
+                return 
sdr::contact::ViewObjectContactOfSdrObj::createPrimitive2DSequence(rDisplayInfo,
 rVisitor);
+            }
+        }
+
+        void ViewContactOfTableObj::createViewIndependentPrimitive2DSequence(
+                drawinglayer::primitive2d::Primitive2DDecompositionVisitor& 
rVisitor) const
+        {
+            const sdr::table::SdrTableObj& rTableObj =
+                static_cast<const sdr::table::SdrTableObj&>(GetSdrObject());
+            return createPrimitive2DSequenceImpl(rTableObj, false, rVisitor);
+        }
+
+        ViewObjectContact& 
ViewContactOfTableObj::CreateObjectSpecificViewObjectContact(ObjectContact& 
rObjectContact)
+        {
+            return *new ViewObjectContactOfTableObj(rObjectContact, *this);
+        }
+
         ViewContactOfTableObj::ViewContactOfTableObj(sdr::table::SdrTableObj& 
rTableObj)
         :   ViewContactOfSdrObj(rTableObj)
         {
diff --git a/svx/source/table/viewcontactoftableobj.hxx 
b/svx/source/table/viewcontactoftableobj.hxx
index 63f45ab4505d..fbdd80538210 100644
--- a/svx/source/table/viewcontactoftableobj.hxx
+++ b/svx/source/table/viewcontactoftableobj.hxx
@@ -31,6 +31,7 @@ namespace sdr::contact
             // This method is responsible for creating the graphical 
visualisation data derived ONLY from
             // the model data
             virtual void 
createViewIndependentPrimitive2DSequence(drawinglayer::primitive2d::Primitive2DDecompositionVisitor&
 rVisitor) const override;
+            virtual ViewObjectContact& 
CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact) override;
 
         public:
             // basic constructor, used from SdrObject.

Reply via email to