[Libreoffice-commits] core.git: sw/source vcl/qa

2023-11-02 Thread Michael Stahl (via logerrit)
 sw/source/core/crsr/viscrs.cxx  |4 
 sw/source/core/inc/rootfrm.hxx  |4 
 sw/source/core/layout/trvlfrm.cxx   |   49 +++
 sw/source/core/text/EnhancedPDFExportHelper.cxx |   18 +
 vcl/qa/cppunit/pdfexport/data/LinkWithFly.fodt  |  137 +
 vcl/qa/cppunit/pdfexport/pdfexport.cxx  |  348 +++-
 6 files changed, 548 insertions(+), 12 deletions(-)

New commits:
commit 5726be1314517d47dd733aabe64a3d85cce094c5
Author: Michael Stahl 
AuthorDate: Fri Oct 27 19:45:09 2023 +0200
Commit: Michael Stahl 
CommitDate: Thu Nov 2 10:47:20 2023 +0100

tdf#157816 sw: PDF export: filter out links on empty space, INetAttrs

Several problems here:
* As with fields, there may be selection rectangles with no text
* SwRootFrame::CalcFrameRects() adds flys that are anchored in the
  selection to the selection
* A fly text portion causes Link annotations to split, but not Link SE
* If a fly only partially overlaps a line vertically, then
  CalcFrameRects() produces a full-width half-height rectangle and
  another 2 half-width half-height rectangles on both sides.
  This is useless, the rectangles must be full line height.
  Add some code in CalcFrameRects() to use the fly portions in the
  SwParaPortion instead of the fly frame areas.

Change-Id: I93f0c12a5e5a3d5f51fcc4b33052a112e9174863
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158576
Tested-by: Michael Stahl 
Reviewed-by: Michael Stahl 

diff --git a/sw/source/core/crsr/viscrs.cxx b/sw/source/core/crsr/viscrs.cxx
index da9c043c6581..f681f3a32815 100644
--- a/sw/source/core/crsr/viscrs.cxx
+++ b/sw/source/core/crsr/viscrs.cxx
@@ -954,7 +954,9 @@ void SwShellCursor::FillRects()
 (GetMark()->GetNode() == GetPoint()->GetNode() ||
 (GetMark()->GetNode().IsContentNode() &&
  GetMark()->GetNode().GetContentNode()->getLayoutFrame( 
GetShell()->GetLayout() ) )   ))
-GetShell()->GetLayout()->CalcFrameRects( *this );
+{
+GetShell()->GetLayout()->CalcFrameRects(*this, *this);
+}
 }
 
 void SwShellCursor::Show(SfxViewShell const * pViewShell)
diff --git a/sw/source/core/inc/rootfrm.hxx b/sw/source/core/inc/rootfrm.hxx
index 29f813360d82..90d18fcf0ee4 100644
--- a/sw/source/core/inc/rootfrm.hxx
+++ b/sw/source/core/inc/rootfrm.hxx
@@ -20,6 +20,7 @@
 #define INCLUDED_SW_SOURCE_CORE_INC_ROOTFRM_HXX
 
 #include "layfrm.hxx"
+#include 
 #include 
 #include 
 #include 
@@ -343,7 +344,8 @@ public:
 */
 bool IsBetweenPages(const Point& rPt) const;
 
-void CalcFrameRects( SwShellCursor& );
+enum class RectsMode { Default, NoAnchoredFlys };
+void CalcFrameRects(SwShellCursor const&, SwRects &, RectsMode eMode = 
RectsMode::Default);
 
 /**
  * Calculates the cells included from the current selection
diff --git a/sw/source/core/layout/trvlfrm.cxx 
b/sw/source/core/layout/trvlfrm.cxx
index fab57c35c24b..d79ffab813aa 100644
--- a/sw/source/core/layout/trvlfrm.cxx
+++ b/sw/source/core/layout/trvlfrm.cxx
@@ -47,6 +47,8 @@
 #include 
 #include 
 #include 
+#include "../text/inftxt.hxx"
+#include "../text/itrpaint.hxx"
 #include 
 #include 
 
@@ -2016,7 +2018,7 @@ static void Add( SwRegionRects& rRegion, const SwRect& 
rRect )
  *  rectangles are available for highlighting.
  *  In the end the Flys are cut out of the region.
  */
-void SwRootFrame::CalcFrameRects(SwShellCursor )
+void SwRootFrame::CalcFrameRects(SwShellCursor const& rCursor, SwRects & 
rRects, RectsMode const eMode)
 {
 auto [pStartPos, pEndPos] = rCursor.StartEnd(); // SwPosition*
 
@@ -2570,7 +2572,46 @@ void SwRootFrame::CalcFrameRects(SwShellCursor )
 const SwPageFrame *pPage  = pStartFrame->FindPageFrame();
 const SwPageFrame *pEndPage   = pEndFrame->FindPageFrame();
 
-while ( pPage )
+// for link rectangles: just remove all the fly portions - this prevents
+// splitting of portions vertically (causes spurious extra PDF annotations)
+if (eMode == RectsMode::NoAnchoredFlys)
+{
+assert(pStartFrame == pEndFrame); // link or field all in 1 frame
+assert(pStartFrame->IsTextFrame());
+SwTextGridItem const*const 
pGrid(GetGridItem(pStartFrame->FindPageFrame()));
+SwTextPaintInfo info(static_cast(pStartFrame), 
pStartFrame->FindPageFrame()->getFrameArea());
+SwTextPainter painter(static_cast(pStartFrame), );
+// because nothing outside the start/end has been added, it doesn't
+// matter to match exactly the start/end, subtracting outside is no-op
+
painter.CharToLine(static_cast(pStartFrame)->MapModelToViewPos(*pStartPos));
+do
+{
+info.SetPos(painter.GetTopLeft());
+bool const bAdjustBaseLine(
+
painter.GetLineInfo().HasSpecialAlign(pStartFrame->IsVertical())
+|| nullptr != pGrid || 

[Libreoffice-commits] core.git: sw/source vcl/qa

2023-11-02 Thread Michael Stahl (via logerrit)
 sw/source/core/text/EnhancedPDFExportHelper.cxx |   38 ++
 vcl/qa/cppunit/pdfexport/data/tdf157816.fodt|  175 ++
 vcl/qa/cppunit/pdfexport/pdfexport.cxx  |  389 
 3 files changed, 598 insertions(+), 4 deletions(-)

New commits:
commit 6593d680e21c24501a58bac216de4a7c71541959
Author: Michael Stahl 
AuthorDate: Fri Oct 27 18:00:14 2023 +0200
Commit: Michael Stahl 
CommitDate: Thu Nov 2 10:46:30 2023 +0100

tdf#157816 sw: PDF export: filter out links on empty space, fields

If there is a fly overlapping a paragraph, it may happen (depending on
wrap settings and position) that there's an empty space on one side of
the fly; the cursor selection region has the flys removed, and this
region is used here for the PDF export.

So there is a rectangle on the text on one side of the fly, turned into
the desired Link annotation, and another rectangle on the other side of
the fly, turned into another undesired Link annotation that isn't
connected to any SE because without text there is no SE.

This is a tricky problem, and the only idea to fix it is to try to see
if there is text in the rectangle by first GetModelPositionForViewPoint()
resulting in a SwPosition and a SwSpecialPos with an index inside the
field; then see if GetCharRect() for this position returns a cursor
rectangle that intersects the original selection rectangle.

Change-Id: I6918eac16690e7194208a828108bfa968d28d12a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158571
Tested-by: Michael Stahl 
Reviewed-by: Michael Stahl 

diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx 
b/sw/source/core/text/EnhancedPDFExportHelper.cxx
index decdd4215f0b..946def82f719 100644
--- a/sw/source/core/text/EnhancedPDFExportHelper.cxx
+++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx
@@ -345,6 +345,35 @@ bool lcl_TryMoveToNonHiddenField(SwEditShell& rShell, 
const SwTextNode& rNd, con
 return true;
 };
 
+// tdf#157816: try to check if the rectangle contains actual text
+::std::vector GetCursorRectsContainingText(SwCursorShell const& rShell)
+{
+::std::vector ret;
+for (SwRect const& rRect : *rShell.GetCursor_())
+{
+Point center(rRect.Center());
+SwSpecialPos special;
+SwCursorMoveState cms(CursorMoveState::NONE);
+cms.m_pSpecialPos = 
+cms.m_bFieldInfo = true;
+SwPosition pos(rShell.GetDoc()->GetNodes());
+auto const [pStart, pEnd] = rShell.GetCursor_()->StartEnd();
+if (rShell.GetLayout()->GetModelPositionForViewPoint(, center, 
)
+&& *pStart <= pos && pos <= *pEnd)
+{
+SwRect charRect;
+if (rShell.GetCurrFrame(false)->GetCharRect(charRect, pos, , 
false)
+&& rRect.Overlaps(charRect))
+{
+ret.push_back(rRect);
+}
+}
+// reset stupid static var that may have gotten set now
+SwTextCursor::SetRightMargin(false); // WTF is this crap
+}
+return ret;
+}
+
 } // end namespace
 
 SwTaggedPDFHelper::SwTaggedPDFHelper( const Num_Info* pNumInfo,
@@ -2396,8 +2425,7 @@ void 
SwEnhancedPDFExportHelper::EnhancedPDFExport(LanguageType const eLanguageDe
 mrSh.SwCursorShell::Right( 1, SwCursorSkipMode::Chars );
 
 // Link Rectangles
-SwRects aTmp;
-aTmp.insert( aTmp.begin(), 
mrSh.SwCursorShell::GetCursor_()->begin(), 
mrSh.SwCursorShell::GetCursor_()->end() );
+SwRects const aTmp(GetCursorRectsContainingText(mrSh));
 OSL_ENSURE( !aTmp.empty(), "Enhanced pdf export - rectangles 
are missing" );
 
 mrSh.SwCursorShell::ClearMark();
@@ -2819,7 +2847,8 @@ void 
SwEnhancedPDFExportHelper::ExportAuthorityEntryLinks()
 mrSh.SwCursorShell::Right(1, SwCursorSkipMode::Chars);
 
 // Create the links.
-for (const auto& rLinkRect : *mrSh.SwCursorShell::GetCursor_())
+SwRects const rects(GetCursorRectsContainingText(mrSh));
+for (const auto& rLinkRect : rects)
 {
 for (const auto& rLinkPageNum : CalcOutputPageNums(rLinkRect))
 {
@@ -2869,7 +2898,8 @@ void 
SwEnhancedPDFExportHelper::ExportAuthorityEntryLinks()
 mrSh.SwCursorShell::Right(1, SwCursorSkipMode::Chars);
 
 // Create the links.
-for (const auto& rLinkRect : *mrSh.SwCursorShell::GetCursor_())
+SwRects const rects(GetCursorRectsContainingText(mrSh));
+for (const auto& rLinkRect : rects)
 {
 for (const auto& rLinkPageNum : CalcOutputPageNums(rLinkRect))
 {
diff --git a/vcl/qa/cppunit/pdfexport/data/tdf157816.fodt 
b/vcl/qa/cppunit/pdfexport/data/tdf157816.fodt
new file mode 100644
index ..5288f3aa75ca
--- /dev/null
+++ 

[Libreoffice-commits] core.git: sw/source vcl/qa

2023-10-25 Thread Michael Stahl (via logerrit)
 sw/source/core/text/itrpaint.cxx   |9 +++--
 vcl/qa/cppunit/pdfexport/pdfexport.cxx |9 ++---
 2 files changed, 9 insertions(+), 9 deletions(-)

New commits:
commit 5dfae9e00f245da78613224ed8e0dbd8b6633192
Author: Michael Stahl 
AuthorDate: Wed Oct 25 12:03:53 2023 +0200
Commit: Michael Stahl 
CommitDate: Wed Oct 25 13:37:10 2023 +0200

tdf#157703 sw: PDF/UA export: export heading labels as text

Been advised that a Lbl element is not much use in practice.

Change-Id: I4ea339d7b48a7ee8ae40f94a9fc71f3e409c07ad
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158421
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/sw/source/core/text/itrpaint.cxx b/sw/source/core/text/itrpaint.cxx
index 31bd418e94e2..4f0d412f2597 100644
--- a/sw/source/core/text/itrpaint.cxx
+++ b/sw/source/core/text/itrpaint.cxx
@@ -412,6 +412,7 @@ void SwTextPainter::DrawTextLine( const SwRect , 
SwSaveClip ,
 if ((pPor->InNumberGrp() // also footnote label
 // weird special case, bullet with soft hyphen
  || (pPor->InHyphGrp() && pNext && pNext->InNumberGrp()))
+&& 
!GetInfo().GetTextFrame()->GetTextNodeForParaProps()->IsOutline()
 && !roTaggedLabel) // note: CalcPaintOfst may skip some portions
 {
 assert(isPDFTaggingEnabled);
@@ -435,14 +436,18 @@ void SwTextPainter::DrawTextLine( const SwRect , 
SwSaveClip ,
 // note: numbering portion may be split if it has multiple scripts
 && !static_cast(pPor)->HasFollow()) // so 
wait for the last one
 {
-assert(roTaggedLabel);
-roTaggedLabel.reset(); // close Lbl
 if 
(!GetInfo().GetTextFrame()->GetTextNodeForParaProps()->IsOutline())
 {
+assert(roTaggedLabel);
+roTaggedLabel.reset(); // close Lbl
 assert(!roTaggedParagraph);
 Frame_Info aFrameInfo(*m_pFrame, false); // open LBody
 roTaggedParagraph.emplace(nullptr, , nullptr, 
*pOut);
 }
+else
+{
+assert(!roTaggedLabel);
+}
 }
 
 // reset underline font
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index 70da866889aa..10881186be42 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -3954,13 +3954,8 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf157703)
 CPPUNIT_ASSERT(pKidsD0);
 auto pKidsD0v = pKidsD0->GetElements();
 auto pRefKidD00 = 
dynamic_cast(pKidsD0v[0]);
-CPPUNIT_ASSERT(pRefKidD00);
-auto pObjectD00 = pRefKidD00->LookupObject();
-CPPUNIT_ASSERT(pObjectD00);
-auto pTypeD00 = 
dynamic_cast(pObjectD00->Lookup("Type"));
-CPPUNIT_ASSERT_EQUAL(OString("StructElem"), pTypeD00->GetValue());
-auto pSD00 = 
dynamic_cast(pObjectD00->Lookup("S"));
-CPPUNIT_ASSERT_EQUAL(OString("Lbl"), pSD00->GetValue());
+// MCID for label
+CPPUNIT_ASSERT(!pRefKidD00);
 
 // MCID for text
 auto pRefKidD01 = 
dynamic_cast(pKidsD0v[1]);


[Libreoffice-commits] core.git: sw/source vcl/qa

2023-10-24 Thread Michael Stahl (via logerrit)
 sw/source/core/text/EnhancedPDFExportHelper.cxx |   13 
 vcl/qa/cppunit/pdfexport/data/SimpleTOC.fodt|  323 
 vcl/qa/cppunit/pdfexport/pdfexport.cxx  |  128 +
 3 files changed, 463 insertions(+), 1 deletion(-)

New commits:
commit a5851d0a6fdc3e08e93daf8cf0ae7f6fc2d73ef6
Author: Michael Stahl 
AuthorDate: Fri Oct 20 20:03:11 2023 +0200
Commit: Michael Stahl 
CommitDate: Tue Oct 24 14:25:43 2023 +0200

tdf#157817 sw: PDF/UA export: fix ToX header sections

The problem was that a P or equivalent element is not allowed as child
of a TOC; previously the P was outside/before the TOC because the ToX
header was completely ignored but now it starts a SE for the ToC content
section before being ignored.

Tagged PDF Best Practice Guide suggests putting the header inside a
Caption element.

Another problem is that if the ToX header is on one page but the first
entry in the ToX content section is on the next page, BeginTag() created
a new SE for the ToX content section.

(regression from commit 033e37b49b5712df19dbfd2c307a102bce620de1)

Change-Id: I3c1f8fdda81c1f10198f5eaefc10bcd14f277a8b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158298
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx 
b/sw/source/core/text/EnhancedPDFExportHelper.cxx
index 46f8e1d07f84..ff47a693769f 100644
--- a/sw/source/core/text/EnhancedPDFExportHelper.cxx
+++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx
@@ -523,6 +523,7 @@ void SwTaggedPDFHelper::BeginTag( 
vcl::PDFWriter::StructElement eType, const OUS
 
 if ( ( rFrame.IsPageFrame() && !static_cast(rFrame).GetPrev() ) ||
  ( rFrame.IsFlowFrame() && 
!SwFlowFrame::CastFlowFrame()->IsFollow() && 
SwFlowFrame::CastFlowFrame()->HasFollow() ) ||
+ rFrame.IsSctFrame() || // all of them, so that opening parent 
sections works
  ( rFrame.IsTextFrame() && rFrame.GetDrawObjs() ) ||
  (rFrame.IsFootnoteFrame() && static_cast(rFrame).GetFollow()) ||
  ( rFrame.IsRowFrame() && rFrame.IsInSplitTableRow() ) ||
@@ -664,6 +665,12 @@ void SwTaggedPDFHelper::SetAttributes( 
vcl::PDFWriter::StructElement eType )
 bRowSpan = true;
 break;
 
+case vcl::PDFWriter::Caption:
+if (pFrame->IsSctFrame())
+{
+break;
+}
+[[fallthrough]];
 case vcl::PDFWriter::H1 :
 case vcl::PDFWriter::H2 :
 case vcl::PDFWriter::H3 :
@@ -672,7 +679,6 @@ void SwTaggedPDFHelper::SetAttributes( 
vcl::PDFWriter::StructElement eType )
 case vcl::PDFWriter::H6 :
 case vcl::PDFWriter::Paragraph :
 case vcl::PDFWriter::Heading :
-case vcl::PDFWriter::Caption :
 case vcl::PDFWriter::BlockQuote :
 
 bPlacement =
@@ -1270,6 +1276,11 @@ void SwTaggedPDFHelper::BeginBlockStructureElements()
 OpenTagImpl(pSection);
 break;
 }
+else if (SectionType::ToxHeader == pSection->GetType())
+{
+nPDFType = vcl::PDFWriter::Caption;
+aPDFType = aCaptionString;
+}
 else if (SectionType::ToxContent == pSection->GetType())
 {
 const SwTOXBase* pTOXBase = pSection->GetTOXBase();
diff --git a/vcl/qa/cppunit/pdfexport/data/SimpleTOC.fodt 
b/vcl/qa/cppunit/pdfexport/data/SimpleTOC.fodt
new file mode 100644
index ..6e7e88ffe9bc
--- /dev/null
+++ b/vcl/qa/cppunit/pdfexport/data/SimpleTOC.fodt
@@ -0,0 +1,323 @@
+
+http://www.w3.org/TR/css3-text/; 
xmlns:grddl="http://www.w3.org/2003/g/data-view#; 
xmlns:xhtml="http://www.w3.org/1999/xhtml; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema; 
xmlns:xforms="http://www.w3.org/2002/xforms; 
xmlns:dom="http://www.w3.org/2001/xml-events; 
xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" 
xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" 
xmlns:math="http://www.w3.org/1998/Math/MathML; 
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" 
xmlns:ooo="http://openoffice.org/2004/office; 
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" 
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" 
xmlns:ooow="http://openoffice.org/2004/writer; 
xmlns:xlink="http://www.w3.org/1999/xlink; 
xmlns:drawooo="http://openoffice.org/2010/draw; 
xmlns:oooc="http://openoffice.org/2004/calc; 
xmlns:dc="http://purl.org/dc/elements/1.1/; xmlns:c
 alcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" 
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 

[Libreoffice-commits] core.git: sw/source vcl/qa

2023-10-19 Thread Michael Stahl (via logerrit)
 sw/source/core/text/EnhancedPDFExportHelper.cxx|3 
 sw/source/core/text/frmpaint.cxx   |4 
 sw/source/core/text/itrpaint.cxx   |   21 +-
 vcl/qa/cppunit/pdfexport/data/LO_Lbl_Lbody_bug_report.fodt |  125 +
 vcl/qa/cppunit/pdfexport/pdfexport.cxx |   83 
 5 files changed, 227 insertions(+), 9 deletions(-)

New commits:
commit 7cb283cf0e92cba4bd53b1cd69816ac7037937e4
Author: Michael Stahl 
AuthorDate: Wed Oct 18 19:15:22 2023 +0200
Commit: Michael Stahl 
CommitDate: Thu Oct 19 17:15:48 2023 +0200

tdf#157703 sw: PDF/UA export: fix headings with labels

The problem is that the new Lbl/LBody elements are produced even for
outline nodes, but those aren't represented as lists at all, but as
headings H1..H10.

Plausible representation of the heading label could be in a Lbl element
inside H1, or simply as plain text; i can't find any recommendation
either way.

Let's try Lbl inside H1, neither veraPDF nor PAC3 complain about it.

(regression from commit 9b38beadf9eaf027b201cdf0ecb2bce5611014dd)

Change-Id: I691957d0c4a80d1339cb2b87c72c9aa652abfb9a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158127
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx 
b/sw/source/core/text/EnhancedPDFExportHelper.cxx
index b71b699b8e36..50e62aeff964 100644
--- a/sw/source/core/text/EnhancedPDFExportHelper.cxx
+++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx
@@ -1305,7 +1305,8 @@ void SwTaggedPDFHelper::BeginBlockStructureElements()
 const SwTextNode *const 
pTextNd(rTextFrame.GetTextNodeForParaProps());
 
 // lazy open LBody after Lbl
-if 
(rTextFrame.GetPara()->HasNumberingPortion(SwParaPortion::OnlyNumbering))
+if (!pTextNd->IsOutline()
+&& 
rTextFrame.GetPara()->HasNumberingPortion(SwParaPortion::OnlyNumbering))
 {
 sal_Int32 const nId = BeginTagImpl(nullptr, 
vcl::PDFWriter::LIBody, aListBodyString);
 SwNodeNum const*const 
pNodeNum(pTextNd->GetNum(rTextFrame.getRootFrame()));
diff --git a/sw/source/core/text/frmpaint.cxx b/sw/source/core/text/frmpaint.cxx
index 43f5922999d4..57458a021817 100644
--- a/sw/source/core/text/frmpaint.cxx
+++ b/sw/source/core/text/frmpaint.cxx
@@ -692,7 +692,9 @@ void SwTextFrame::PaintSwFrame(vcl::RenderContext& 
rRenderContext, SwRect const&
 // Paragraph tag - if there is a list label, opening should be delayed.
 ::std::optional oTaggedParagraph;
 
-if (isPDFTaggingEnabled && 
!GetPara()->HasNumberingPortion(SwParaPortion::FootnoteToo))
+if (isPDFTaggingEnabled
+&& (GetTextNodeForParaProps()->IsOutline()
+|| !GetPara()->HasNumberingPortion(SwParaPortion::FootnoteToo)))
 {   // no Lbl needed => open paragraph tag now
 Frame_Info aFrameInfo(*this, false);
 oTaggedParagraph.emplace(nullptr, , nullptr, 
rRenderContext);
diff --git a/sw/source/core/text/itrpaint.cxx b/sw/source/core/text/itrpaint.cxx
index 620838d10171..6d07ef7dc468 100644
--- a/sw/source/core/text/itrpaint.cxx
+++ b/sw/source/core/text/itrpaint.cxx
@@ -153,7 +153,8 @@ void SwTextPainter::DrawTextLine( const SwRect , 
SwSaveClip ,
 bool bSkippedNumPortions(false);
 SwLinePortion *pPor = bEndPor ? m_pCurr->GetFirstPortion() : 
CalcPaintOfst(rPaint, bSkippedNumPortions);
 
-if (bSkippedNumPortions) // ugly but hard to check earlier in PaintSwFrame:
+if (bSkippedNumPortions // ugly but hard to check earlier in PaintSwFrame:
+&& !GetInfo().GetTextFrame()->GetTextNodeForParaProps()->IsOutline())
 {   // there is a num portion but it is outside of the frame area and not 
painted
 assert(!roTaggedLabel);
 assert(!roTaggedParagraph);
@@ -436,9 +437,12 @@ void SwTextPainter::DrawTextLine( const SwRect , 
SwSaveClip ,
 {
 assert(roTaggedLabel);
 roTaggedLabel.reset(); // close Lbl
-assert(!roTaggedParagraph);
-Frame_Info aFrameInfo(*m_pFrame, false); // open LBody
-roTaggedParagraph.emplace(nullptr, , nullptr, *pOut);
+if 
(!GetInfo().GetTextFrame()->GetTextNodeForParaProps()->IsOutline())
+{
+assert(!roTaggedParagraph);
+Frame_Info aFrameInfo(*m_pFrame, false); // open LBody
+roTaggedParagraph.emplace(nullptr, , nullptr, 
*pOut);
+}
 }
 
 // reset underline font
@@ -461,7 +465,7 @@ void SwTextPainter::DrawTextLine( const SwRect , 
SwSaveClip ,
  pNext && pNext->IsHolePortion() ) ?
pNext :
nullptr;
-if (!pPor && isPDFTaggingEnabled && !roTaggedParagraph)
+if (!pPor && isPDFTaggingEnabled && (roTaggedLabel || 

[Libreoffice-commits] core.git: sw/source vcl/qa

2022-11-25 Thread Michael Stahl (via logerrit)
 sw/source/core/text/EnhancedPDFExportHelper.cxx|   32 ++-
 vcl/qa/cppunit/pdfexport/data/Description PDF Export test .odt |binary
 vcl/qa/cppunit/pdfexport/pdfexport.cxx |  102 
++
 3 files changed, 131 insertions(+), 3 deletions(-)

New commits:
commit 122b4264d23df8b11419839ba700b88c4f936a6c
Author: Michael Stahl 
AuthorDate: Thu Nov 24 13:17:56 2022 +0100
Commit: Michael Stahl 
CommitDate: Fri Nov 25 11:48:00 2022 +0100

tdf#57423 sw: PDF/UA export: Alt texts for SwNoTextNode

* Specification: ISO 14289-1:2014, Clause: 7.3, Test number: 1
Figure tags shall include an alternative representation or replacement
text that represents the contents marked with the Figure tag as noted in
ISO 32000-1:2008, 14.7.2, Table 323

This was broken by the previous commit, which tied ObjectInfoPrimitive2D
evaluation to StructureTagPrimitive2D, and is restored now, perhaps
less elegantly.

* Specification: ISO 14289-1:2014, Clause: 7.7, Test number: 1
All mathematical expressions shall be enclosed within a Formula tag as
detailed in ISO 32000-1:2008, 14.8.4.5 and shall have Alt or ActualText
attributes

Haven't checked but it's possible that this worked before commit
2840352ba56a212d191cc16e08378c87672d7b73 - for SwOLENode embedded
objects, no ObjectInfoPrimitive2D is created apparently.

Change-Id: Ia0077199601f39f666012d31883f63cff115716f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143247
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx 
b/sw/source/core/text/EnhancedPDFExportHelper.cxx
index 7491ab42d52c..57a0a145e1c1 100644
--- a/sw/source/core/text/EnhancedPDFExportHelper.cxx
+++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx
@@ -526,6 +526,7 @@ void SwTaggedPDFHelper::SetAttributes( 
vcl::PDFWriter::StructElement eType )
 bool bHeight = false;
 bool bBox = false;
 bool bRowSpan = false;
+bool bAltText = false;
 
 // Check which attributes to set:
 
@@ -586,11 +587,20 @@ void SwTaggedPDFHelper::SetAttributes( 
vcl::PDFWriter::StructElement eType )
 
 case vcl::PDFWriter::Formula :
 case vcl::PDFWriter::Figure :
+bAltText =
 bPlacement =
 bWidth =
 bHeight =
 bBox = true;
 break;
+
+case vcl::PDFWriter::Division:
+if (pFrame->IsFlyFrame()) // this can be something else too
+{
+bAltText = true;
+}
+break;
+
 default :
 break;
 }
@@ -676,9 +686,25 @@ void SwTaggedPDFHelper::SetAttributes( 
vcl::PDFWriter::StructElement eType )
 }
 }
 
-// Formerly here bAlternateText was triggered for PDF export, but this
-// was moved for more general use to primitives and usage in
-// VclMetafileProcessor2D (see processGraphicPrimitive2D).
+// ISO 14289-1:2014, Clause: 7.3
+// ISO 14289-1:2014, Clause: 7.7
+// For images (but not embedded objects), an ObjectInfoPrimitive2D is
+// created, but it's not evaluated by VclMetafileProcessor2D any more;
+// that would require producing StructureTagPrimitive2D here but that
+// looks impossible so instead duplicate the code that sets the Alt
+// text here again.
+if (bAltText)
+{
+SwFlyFrameFormat const& rFly(*static_cast(pFrame)->GetFormat());
+OUString const sep(
+(rFly.GetObjTitle().isEmpty() || 
rFly.GetObjDescription().isEmpty())
+? OUString() : OUString(" - "));
+OUString const altText(rFly.GetObjTitle() + sep + 
rFly.GetObjDescription());
+if (!altText.isEmpty())
+{
+mpPDFExtOutDevData->SetAlternateText(altText);
+}
+}
 
 if ( bWidth )
 {
diff --git a/vcl/qa/cppunit/pdfexport/data/Description PDF Export test .odt 
b/vcl/qa/cppunit/pdfexport/data/Description PDF Export test .odt
new file mode 100644
index ..78f05b09e9e9
Binary files /dev/null and b/vcl/qa/cppunit/pdfexport/data/Description PDF 
Export test .odt differ
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index 3c75ec632eae..962995a0d6e1 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -3277,6 +3277,108 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf135638)
 CPPUNIT_ASSERT_EQUAL(int(2), nFigure);
 }
 
+CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf57423)
+{
+aMediaDescriptor["FilterName"] <<= OUString("writer_pdf_Export");
+
+// Enable PDF/UA
+uno::Sequence aFilterData(
+comphelper::InitPropertySequence({ { "PDFUACompliance", 

[Libreoffice-commits] core.git: sw/source vcl/qa

2022-10-21 Thread Michael Stahl (via logerrit)
 sw/source/core/layout/paintfrm.cxx  |   15 ++--
 sw/source/core/text/EnhancedPDFExportHelper.cxx |8 +-
 vcl/qa/cppunit/pdfexport/data/tdf139736-1.odt   |binary
 vcl/qa/cppunit/pdfexport/pdfexport.cxx  |   86 
 4 files changed, 101 insertions(+), 8 deletions(-)

New commits:
commit 72b69b422d33308809070e98a6ea8daad93e16d2
Author: Michael Stahl 
AuthorDate: Wed Oct 19 16:38:02 2022 +0200
Commit: Michael Stahl 
CommitDate: Fri Oct 21 17:37:15 2022 +0200

tdf#139736 sw: PDF/UA export: flys in header/footer are Artifacts

* flys anchored in header/footer cannot simply be ignored, they need to
  get NonStructElement tag which is translated to "/Artifact"
* borders of flys need to get "/Artifact" tag as well; this is also the
  case if they're anchored in the body as veraPDF complains

Change-Id: Id69f0d80c59c3ade295da46c4413a5f0e8d96d54
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141534
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/sw/source/core/layout/paintfrm.cxx 
b/sw/source/core/layout/paintfrm.cxx
index 5a37468f0d72..2179cfbb96e3 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -4289,12 +4289,15 @@ void SwFlyFrame::PaintSwFrame(vcl::RenderContext& 
rRenderContext, SwRect const&
 
 Validate();
 
-// first paint lines added by fly frame paint
-// and then unlock other lines.
-gProp.pSLines->PaintLines( , gProp );
-gProp.pSLines->LockLines( false );
-// have to paint frame borders added in heaven layer here...
-ProcessPrimitives(gProp.pBLines->GetBorderLines_Clear());
+{
+SwTaggedPDFHelper tag(nullptr, nullptr, nullptr, *pShell->GetOut());
+// first paint lines added by fly frame paint
+// and then unlock other lines.
+gProp.pSLines->PaintLines( , gProp );
+gProp.pSLines->LockLines( false );
+// have to paint frame borders added in heaven layer here...
+ProcessPrimitives(gProp.pBLines->GetBorderLines_Clear());
+}
 
 PaintDecorators();
 
diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx 
b/sw/source/core/text/EnhancedPDFExportHelper.cxx
index f193aa354cb4..769c3a6b06f1 100644
--- a/sw/source/core/text/EnhancedPDFExportHelper.cxx
+++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx
@@ -969,7 +969,7 @@ void SwTaggedPDFHelper::BeginBlockStructureElements()
 
 // Lowers of NonStructureElements should not be considered:
 
-if ( lcl_IsInNonStructEnv( *pFrame ) )
+if (lcl_IsInNonStructEnv(*pFrame) && !pFrame->IsFlyFrame())
 return;
 
 // Check if we have to reopen an existing structure element.
@@ -1258,7 +1258,11 @@ void SwTaggedPDFHelper::BeginBlockStructureElements()
 // fly in content or fly at page
 {
 const SwFlyFrame* pFly = static_cast(pFrame);
-if ( pFly->Lower() && pFly->Lower()->IsNoTextFrame() )
+if (pFly->GetAnchorFrame()->FindFooterOrHeader() != nullptr)
+{
+nPDFType = vcl::PDFWriter::NonStructElement;
+}
+else if (pFly->Lower() && pFly->Lower()->IsNoTextFrame())
 {
 bool bFormula = false;
 
diff --git a/vcl/qa/cppunit/pdfexport/data/tdf139736-1.odt 
b/vcl/qa/cppunit/pdfexport/data/tdf139736-1.odt
new file mode 100644
index ..f17f6037885c
Binary files /dev/null and b/vcl/qa/cppunit/pdfexport/data/tdf139736-1.odt 
differ
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index b8efd4c5dc6e..7c5ee9f67952 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -3119,6 +3119,92 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testPdfUaMetadata)
 CPPUNIT_ASSERT_EQUAL(OString("1"), aPdfUaPart);
 }
 
+CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf139736)
+{
+aMediaDescriptor["FilterName"] <<= OUString("writer_pdf_Export");
+
+// Enable PDF/UA
+uno::Sequence aFilterData(
+comphelper::InitPropertySequence({ { "PDFUACompliance", uno::Any(true) 
} }));
+aMediaDescriptor["FilterData"] <<= aFilterData;
+saveAsPDF(u"tdf139736-1.odt");
+
+vcl::filter::PDFDocument aDocument;
+SvFileStream aStream(maTempFile.GetURL(), StreamMode::READ);
+CPPUNIT_ASSERT(aDocument.Read(aStream));
+
+std::vector aPages = aDocument.GetPages();
+CPPUNIT_ASSERT_EQUAL(static_cast(1), aPages.size());
+
+vcl::filter::PDFObjectElement* pContents = 
aPages[0]->LookupObject("Contents");
+CPPUNIT_ASSERT(pContents);
+vcl::filter::PDFStreamElement* pStream = pContents->GetStream();
+CPPUNIT_ASSERT(pStream);
+SvMemoryStream& rObjectStream = pStream->GetMemory();
+// Uncompress it.
+SvMemoryStream aUncompressed;
+ZCodec aZCodec;
+aZCodec.BeginCompression();
+rObjectStream.Seek(0);
+

[Libreoffice-commits] core.git: sw/source vcl/qa

2020-02-07 Thread Noel Grandin (via logerrit)
 sw/source/core/frmedt/fews.cxx  |2 
 sw/source/core/inc/txtfrm.hxx   |2 
 sw/source/core/layout/frmtool.cxx   |8 +-
 sw/source/core/layout/ssfrm.cxx |2 
 sw/source/core/objectpositioning/anchoredobjectposition.cxx |4 -
 vcl/qa/cppunit/ScanlineToolsTest.cxx|   42 
 6 files changed, 9 insertions(+), 51 deletions(-)

New commits:
commit c05680bd27f0f9fc9d5371f4ef97fd45184de1c6
Author: Noel Grandin 
AuthorDate: Fri Feb 7 14:02:01 2020 +0200
Commit: Noel Grandin 
CommitDate: Fri Feb 7 18:10:35 2020 +0100

rename GetBaseOfstForFly->GetBaseOffsetForFly

Change-Id: Ieeeaa53d916e192e7219d7d3d405584a22249e7f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88181
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sw/source/core/frmedt/fews.cxx b/sw/source/core/frmedt/fews.cxx
index e5edce6ba7f0..b608d2e8e4a8 100644
--- a/sw/source/core/frmedt/fews.cxx
+++ b/sw/source/core/frmedt/fews.cxx
@@ -1124,7 +1124,7 @@ void SwFEShell::CalcBoundRect( SwRect& _orRect,
 }
 
 const SwTwips nBaseOfstForFly = ( pFrame->IsTextFrame() && pFly ) ?
-static_cast(pFrame)->GetBaseOfstForFly( !bWrapThrough ) :
+static_cast(pFrame)->GetBaseOffsetForFly( !bWrapThrough ) :
  0;
 if( aRectFnSet.IsVert() || aRectFnSet.IsVertL2R() )
 {
diff --git a/sw/source/core/inc/txtfrm.hxx b/sw/source/core/inc/txtfrm.hxx
index f76c3b41339f..b234e242ba59 100644
--- a/sw/source/core/inc/txtfrm.hxx
+++ b/sw/source/core/inc/txtfrm.hxx
@@ -748,7 +748,7 @@ public:
 mbFollowFormatAllowed = false;
 }
 
-SwTwips GetBaseOfstForFly( bool bIgnoreFlysAnchoredAtThisFrame ) const
+SwTwips GetBaseOffsetForFly( bool bIgnoreFlysAnchoredAtThisFrame ) const
 {
 return ( bIgnoreFlysAnchoredAtThisFrame ?
  mnFlyAnchorOfst :
diff --git a/sw/source/core/layout/frmtool.cxx 
b/sw/source/core/layout/frmtool.cxx
index b8798af8a835..975bf3f9ead4 100644
--- a/sw/source/core/layout/frmtool.cxx
+++ b/sw/source/core/layout/frmtool.cxx
@@ -93,8 +93,8 @@ SwFrameNotify::SwFrameNotify( SwFrame *pF ) :
 {
 if ( pF->IsTextFrame() )
 {
-mnFlyAnchorOfst = static_cast(pF)->GetBaseOfstForFly( 
true );
-mnFlyAnchorOfstNoWrap = 
static_cast(pF)->GetBaseOfstForFly( false );
+mnFlyAnchorOfst = static_cast(pF)->GetBaseOffsetForFly( 
true );
+mnFlyAnchorOfstNoWrap = 
static_cast(pF)->GetBaseOffsetForFly( false );
 }
 else
 {
@@ -114,8 +114,8 @@ SwFrameNotify::~SwFrameNotify() COVERITY_NOEXCEPT_FALSE
 const bool bChgHeight =
 
aRectFnSet.GetHeight(maFrame)!=aRectFnSet.GetHeight(mpFrame->getFrameArea());
 const bool bChgFlyBasePos = mpFrame->IsTextFrame() &&
-   ( ( mnFlyAnchorOfst != 
static_cast(mpFrame)->GetBaseOfstForFly( true ) ) ||
- ( mnFlyAnchorOfstNoWrap != 
static_cast(mpFrame)->GetBaseOfstForFly( false ) ) );
+   ( ( mnFlyAnchorOfst != 
static_cast(mpFrame)->GetBaseOffsetForFly( true ) ) ||
+ ( mnFlyAnchorOfstNoWrap != 
static_cast(mpFrame)->GetBaseOffsetForFly( false ) ) );
 
 if ( mpFrame->IsFlowFrame() && !mpFrame->IsInFootnote() )
 {
diff --git a/sw/source/core/layout/ssfrm.cxx b/sw/source/core/layout/ssfrm.cxx
index 14193b09d260..1de1f32aa394 100644
--- a/sw/source/core/layout/ssfrm.cxx
+++ b/sw/source/core/layout/ssfrm.cxx
@@ -296,7 +296,7 @@ Point SwFrame::GetFrameAnchorPos( bool 
bIgnoreFlysAnchoredAtThisFrame ) const
 if ( IsTextFrame() )
 {
 SwTwips nBaseOfstForFly =
-static_cast(this)->GetBaseOfstForFly( 
bIgnoreFlysAnchoredAtThisFrame );
+static_cast(this)->GetBaseOffsetForFly( 
bIgnoreFlysAnchoredAtThisFrame );
 if ( IsVertical() )
 aAnchor.AdjustY(nBaseOfstForFly );
 else
diff --git a/sw/source/core/objectpositioning/anchoredobjectposition.cxx 
b/sw/source/core/objectpositioning/anchoredobjectposition.cxx
index 48a0e27c881c..5ac2514bb6d0 100644
--- a/sw/source/core/objectpositioning/anchoredobjectposition.cxx
+++ b/sw/source/core/objectpositioning/anchoredobjectposition.cxx
@@ -611,7 +611,7 @@ void SwAnchoredObjectPosition::GetHoriAlignmentValues( 
const SwFrame&  _rHoriOri
 if ( _rHoriOrientFrame.IsTextFrame() )
 {
 // consider movement of text frame left
-nOffset += static_cast(_rHoriOrientFrame).GetBaseOfstForFly( !_bObjWrapThrough );
+nOffset += static_cast(_rHoriOrientFrame).GetBaseOffsetForFly( !_bObjWrapThrough );
 }
 else if ( _rHoriOrientFrame.IsPageFrame() && aRectFnSet.IsVert() )
 {
@@ -733,7 +733,7 @@ void SwAnchoredObjectPosition::GetHoriAlignmentValues( 
const SwFrame&  _rHoriOri
 
   

[Libreoffice-commits] core.git: sw/source vcl/qa

2019-10-24 Thread Xisco Fauli (via logerrit)
 sw/source/core/doc/notxtfrm.cxx |   23 ++-
 vcl/qa/cppunit/pdfexport/data/tdf115967.odt |binary
 vcl/qa/cppunit/pdfexport/pdfexport.cxx  |   33 
 3 files changed, 36 insertions(+), 20 deletions(-)

New commits:
commit 83baaec3a087f83d0ad3371d55671d9496771586
Author: Xisco Fauli 
AuthorDate: Mon Oct 21 17:41:52 2019 +0200
Commit: Xisco FaulĂ­ 
CommitDate: Thu Oct 24 11:30:38 2019 +0200

tdf#115967: Revert "sw: Use primitive renderer for graphics"

This reverts commit 302af8c2da58719844d22483b65a9fe5b3674684

I would like to revert it until a better solution is proposed
due to the number of duplicates already reported

After the commit, Libo exports LTR formulas in RTL documents to PDF
as RTL formulas

it also introduced other problems like tdf#112513 and tdf#117560

Unittest added

Change-Id: I097fb5801eb728bd258ae96bd981c6725e7aa06a
Reviewed-on: https://gerrit.libreoffice.org/81262
Tested-by: Jenkins
Reviewed-by: Xisco FaulĂ­ 

diff --git a/sw/source/core/doc/notxtfrm.cxx b/sw/source/core/doc/notxtfrm.cxx
index 45c32b51a1b3..a8ddd5849078 100644
--- a/sw/source/core/doc/notxtfrm.cxx
+++ b/sw/source/core/doc/notxtfrm.cxx
@@ -1248,31 +1248,17 @@ void SwNoTextFrame::PaintPicture( vcl::RenderContext* 
pOut, const SwRect 
 // SwOLENode does not have a known GraphicObject, need to
 // work with Graphic instead
 const Graphic* pGraphic = pOLENd->GetGraphic();
+const Point aPosition(aAlignedGrfArea.Pos());
+const Size aSize(aAlignedGrfArea.SSize());
 
 if ( pGraphic && pGraphic->GetType() != GraphicType::NONE )
 {
-GraphicObject aTempGraphicObject(*pGraphic);
-GraphicAttr aGrfAttr;
-const basegfx::B2DHomMatrix aGraphicTransform(
-basegfx::utils::createScaleTranslateB2DHomMatrix(
-aAlignedGrfArea.Width(), aAlignedGrfArea.Height(),
-aAlignedGrfArea.Left(), aAlignedGrfArea.Top()));
-
-paintGraphicUsingPrimitivesHelper(
-*pOut,
-aTempGraphicObject,
-aGrfAttr,
-aGraphicTransform,
-nullptr == pOLENd->GetFlyFormat() ? OUString() : 
pOLENd->GetFlyFormat()->GetName(),
-rNoTNd.GetTitle(),
-rNoTNd.GetDescription());
+pGraphic->Draw( pOut, aPosition, aSize );
 
 // shade the representation if the object is activated outplace
 uno::Reference < embed::XEmbeddedObject > xObj = 
pOLENd->GetOLEObj().GetOleRef();
 if ( xObj.is() && xObj->getCurrentState() == 
embed::EmbedStates::ACTIVE )
 {
-const Point aPosition(aAlignedGrfArea.Pos());
-const Size aSize(aAlignedGrfArea.SSize());
 
 ::svt::EmbeddedObjectRef::DrawShading(
 tools::Rectangle(
@@ -1283,9 +1269,6 @@ void SwNoTextFrame::PaintPicture( vcl::RenderContext* 
pOut, const SwRect 
 }
 else
 {
-const Point aPosition(aAlignedGrfArea.Pos());
-const Size aSize(aAlignedGrfArea.SSize());
-
 ::svt::EmbeddedObjectRef::DrawPaintReplacement(
 tools::Rectangle(aPosition, aSize),
 pOLENd->GetOLEObj().GetCurrentPersistName(),
diff --git a/vcl/qa/cppunit/pdfexport/data/tdf115967.odt 
b/vcl/qa/cppunit/pdfexport/data/tdf115967.odt
new file mode 100644
index ..3c8384a101be
Binary files /dev/null and b/vcl/qa/cppunit/pdfexport/data/tdf115967.odt differ
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index 89f10ec3cf9e..4d85190ea5ac 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -128,6 +128,7 @@ public:
 void testTdf113143();
 void testTdf115262();
 void testTdf121962();
+void testTdf115967();
 void testTdf121615();
 void testTocLink();
 
@@ -162,6 +163,7 @@ public:
 CPPUNIT_TEST(testTdf113143);
 CPPUNIT_TEST(testTdf115262);
 CPPUNIT_TEST(testTdf121962);
+CPPUNIT_TEST(testTdf115967);
 CPPUNIT_TEST(testTdf121615);
 CPPUNIT_TEST(testTocLink);
 CPPUNIT_TEST_SUITE_END();
@@ -1691,6 +1693,37 @@ void PdfExportTest::testTdf121962()
 OUString sText(aText.data(), nTextSize / 2 - 1);
 CPPUNIT_ASSERT(sText != "** Expression is faulty **");
 }
+
+}
+
+void PdfExportTest::testTdf115967()
+{
+OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + 
"tdf115967.odt";
+utl::MediaDescriptor aMediaDescriptor;
+aMediaDescriptor["FilterName"] <<= OUString("writer_pdf_Export");
+auto pPdfDocument = exportAndParse(aURL, aMediaDescriptor);
+

[Libreoffice-commits] core.git: sw/source vcl/qa

2019-04-26 Thread Miklos Vajna (via logerrit)
 sw/source/core/unocore/unoidx.cxx   |   10 +
 vcl/qa/cppunit/pdfexport/data/toc-link.fodt |   45 ++
 vcl/qa/cppunit/pdfexport/pdfexport.cxx  |   47 
 3 files changed, 102 insertions(+)

New commits:
commit 9c3e5875e827c04e6dc029bba1ac179eb2484c29
Author: Miklos Vajna 
AuthorDate: Fri Apr 26 15:25:27 2019 +0200
Commit: Miklos Vajna 
CommitDate: Fri Apr 26 17:07:00 2019 +0200

sw: sync UNO API default for ToC link start char style with UI

The UI default is in the SwForm ctor, where the content type sets the
link start char style to STR_POOLCHR_TOXJUMP.

Have the same default in the UNO API in case the import filters don't
set it explicitly, since that breaks clickable hyperlinks on PDF export.

This also fixes the OSL_ENSURE() failure for missing character formats
in SwTextINetFormat::GetCharFormat().

Change-Id: Ifff354d56a569614ca7f5a89dd75f41817300078
Reviewed-on: https://gerrit.libreoffice.org/71366
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/sw/source/core/unocore/unoidx.cxx 
b/sw/source/core/unocore/unoidx.cxx
index 5e69d4a85fcf..31c1474f84c7 100644
--- a/sw/source/core/unocore/unoidx.cxx
+++ b/sw/source/core/unocore/unoidx.cxx
@@ -62,6 +62,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -2898,6 +2899,15 @@ SwXDocumentIndex::TokenAccess_Impl::replaceByIndex(
 throw lang::IllegalArgumentException();
 }
 }
+
+if (rTOXBase.GetType() == TOX_CONTENT)
+{
+if (aToken.eTokenType == TOKEN_LINK_START && 
aToken.sCharStyleName.isEmpty())
+{
+aToken.sCharStyleName = SwResId(STR_POOLCHR_TOXJUMP);
+}
+}
+
 sPattern.append(aToken.GetString());
 }
 SwForm aForm(rTOXBase.GetTOXForm());
diff --git a/vcl/qa/cppunit/pdfexport/data/toc-link.fodt 
b/vcl/qa/cppunit/pdfexport/data/toc-link.fodt
new file mode 100644
index ..ab29e88a47ba
--- /dev/null
+++ b/vcl/qa/cppunit/pdfexport/data/toc-link.fodt
@@ -0,0 +1,45 @@
+
+http://www.w3.org/1999/xlink; office:version="1.2" 
office:mimetype="application/vnd.oasis.opendocument.text">
+  
+
+
+
+  
+
+
+
+  
+
+
+  
+  
+
+
+  
+
+  
+  
+
+  
+  
+
+  
+
+  Table of 
Contents
+  
+
+
+
+  
+
+
+  
+Table of 
Contents
+  
+  Heading 11
+
+  
+  Heading 1
+
+  
+
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index 99ae3392d68b..033a886f20ec 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -17,6 +17,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include 
 #include 
@@ -29,6 +31,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -129,6 +132,7 @@ public:
 void testTdf115262();
 void testTdf121962();
 void testTdf121615();
+void testTocLink();
 
 CPPUNIT_TEST_SUITE(PdfExportTest);
 CPPUNIT_TEST(testTdf106059);
@@ -164,6 +168,7 @@ public:
 CPPUNIT_TEST(testTdf115262);
 CPPUNIT_TEST(testTdf121962);
 CPPUNIT_TEST(testTdf121615);
+CPPUNIT_TEST(testTocLink);
 CPPUNIT_TEST_SUITE_END();
 };
 
@@ -1737,6 +1742,48 @@ void PdfExportTest::testTdf121615()
 CPPUNIT_ASSERT_EQUAL( COL_BLACK, aBitmap.GetPixelColor( 199, 299 ));
 }
 
+void PdfExportTest::testTocLink()
+{
+// Load the Writer document.
+OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + 
"toc-link.fodt";
+mxComponent = loadFromDesktop(aURL);
+CPPUNIT_ASSERT(mxComponent.is());
+
+// Update the ToC.
+uno::Reference 
xDocumentIndexesSupplier(mxComponent,
+
uno::UNO_QUERY);
+CPPUNIT_ASSERT(xDocumentIndexesSupplier.is());
+
+uno::Reference xToc(
+xDocumentIndexesSupplier->getDocumentIndexes()->getByIndex(0), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT(xToc.is());
+
+xToc->refresh();
+
+// Save as PDF.
+uno::Reference xStorable(mxComponent, uno::UNO_QUERY);
+utl::MediaDescriptor aMediaDescriptor;
+aMediaDescriptor["FilterName"] <<= OUString("writer_pdf_Export");
+xStorable->storeToURL(maTempFile.GetURL(), 
aMediaDescriptor.getAsConstPropertyValueList());
+
+SvFileStream aFile(maTempFile.GetURL(), StreamMode::READ);
+maMemory.WriteStream(aFile);
+DocumentHolder pPdfDocument(
+FPDF_LoadMemDocument(maMemory.GetData(), maMemory.GetSize(), 
/*password=*/nullptr));
+CPPUNIT_ASSERT(pPdfDocument.get());
+CPPUNIT_ASSERT_EQUAL(1, FPDF_GetPageCount(pPdfDocument.get()));
+
+PageHolder pPdfPage(FPDF_LoadPage(pPdfDocument.get(), /*page_index=*/0));
+

[Libreoffice-commits] core.git: sw/source vcl/qa

2018-12-11 Thread Libreoffice Gerrit user
 sw/source/core/bastyp/calc.cxx  |4 +++
 vcl/qa/cppunit/pdfexport/data/tdf121962.odt |binary
 vcl/qa/cppunit/pdfexport/pdfexport.cxx  |   30 
 3 files changed, 34 insertions(+)

New commits:
commit d0e30c11740ba22af5f6a8156dd00dad8c378b2a
Author: Samuel Mehrbrodt 
AuthorDate: Tue Dec 11 10:52:50 2018 +0100
Commit: Samuel Mehrbrodt 
CommitDate: Tue Dec 11 16:13:43 2018 +0100

tdf#121962 Don't treat closing bracket as invalid syntax

Somehow there is a difference how the formula looks when converting via 
command line
vs exporting from UI.
In UI the sum formula looks like: 'sum( (0) ) (0|0|0|0)'
while in cmd line it looks like:  'sum( (0) ) () '

Both look sane, so just don't treat the second one as error.

Change-Id: I345c062a9e7c8b9c849885bc6cb88167a3491dd8
Reviewed-on: https://gerrit.libreoffice.org/64941
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt 

diff --git a/sw/source/core/bastyp/calc.cxx b/sw/source/core/bastyp/calc.cxx
index d58ee08bdacc..c3621b0b1a3d 100644
--- a/sw/source/core/bastyp/calc.cxx
+++ b/sw/source/core/bastyp/calc.cxx
@@ -1159,6 +1159,10 @@ SwSbxValue SwCalc::PrimFunc(bool )
 return nErg;
 break;
 }
+case CALC_RP:
+// ignore, see tdf#121962
+SAL_INFO("sw.calc", ")");
+break;
 case CALC_MEAN:
 {
 SAL_INFO("sw.calc", "mean");
diff --git a/vcl/qa/cppunit/pdfexport/data/tdf121962.odt 
b/vcl/qa/cppunit/pdfexport/data/tdf121962.odt
new file mode 100644
index ..a831b1136163
Binary files /dev/null and b/vcl/qa/cppunit/pdfexport/data/tdf121962.odt differ
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index 001b3de2f480..023c8ed261e0 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -116,6 +116,7 @@ public:
 void testTdf106702();
 void testTdf113143();
 void testTdf115262();
+void testTdf121962();
 
 CPPUNIT_TEST_SUITE(PdfExportTest);
 CPPUNIT_TEST(testTdf106059);
@@ -148,6 +149,7 @@ public:
 CPPUNIT_TEST(testTdf106702);
 CPPUNIT_TEST(testTdf113143);
 CPPUNIT_TEST(testTdf115262);
+CPPUNIT_TEST(testTdf121962);
 CPPUNIT_TEST_SUITE_END();
 };
 
@@ -1582,6 +1584,34 @@ void PdfExportTest::testTdf115262()
 FPDFText_ClosePage(pTextPage);
 }
 
+void PdfExportTest::testTdf121962()
+{
+OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + 
"tdf121962.odt";
+utl::MediaDescriptor aMediaDescriptor;
+aMediaDescriptor["FilterName"] <<= OUString("writer_pdf_Export");
+auto pPdfDocument = exportAndParse(aURL, aMediaDescriptor);
+CPPUNIT_ASSERT_EQUAL(1, FPDF_GetPageCount(pPdfDocument.get()));
+
+// Get the first page
+PageHolder pPdfPage(FPDF_LoadPage(pPdfDocument.get(), /*page_index=*/0));
+CPPUNIT_ASSERT(pPdfPage.get());
+FPDF_TEXTPAGE pTextPage = FPDFText_LoadPage(pPdfPage.get());
+
+// Make sure the table sum is displayed as "0", not faulty expression.
+int nPageObjectCount = FPDFPage_CountObjects(pPdfPage.get());
+for (int i = 0; i < nPageObjectCount; ++i)
+{
+FPDF_PAGEOBJECT pPageObject = FPDFPage_GetObject(pPdfPage.get(), i);
+if (FPDFPageObj_GetType(pPageObject) != FPDF_PAGEOBJ_TEXT)
+continue;
+unsigned long nTextSize = FPDFTextObj_GetText(pPageObject, pTextPage, 
nullptr, 0);
+std::vector aText(nTextSize);
+FPDFTextObj_GetText(pPageObject, pTextPage, aText.data(), nTextSize);
+OUString sText(aText.data(), nTextSize / 2 - 1);
+CPPUNIT_ASSERT(sText != "** Expression is faulty **");
+}
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(PdfExportTest);
 
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits