tdf#85610 sw: show tracked footnote insertion/deletion
also in the footnote area by formatting the footnote number there as the footnote index number in the main text (i.e. as anchor of the footnote). Previously deleted footnotes were shown as not deleted footnotes in Show Changes mode, also inserted footnotes lost their footnote number formatting (i.e. author color of the tracked change, and e.g. the default underline) after file saving. Note: for a working test, fix also MetafileXmlDump by removing the bad 0x01 from the XML dump, which resulted by the not expanded footnote index placeholder character. Change-Id: Ie003f4e19d2e2cee6f09d3b195db69fe5c10e405 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133503 Tested-by: Jenkins Reviewed-by: László Németh <nemeth@numbertext.org>
This commit is contained in:
56
sw/qa/extras/layout/data/tdf85610.fodt
Normal file
56
sw/qa/extras/layout/data/tdf85610.fodt
Normal file
@@ -0,0 +1,56 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rpt="http://openoffice.org/2005/report" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:officeooo="http://openoffice.org/2009/office" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:drawooo="http://openoffice.org/2010/draw" xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:css3t="http://www.w3.org/TR/css3-text/" office:version="1.2" office:mimetype="application/vnd.oasis.opendocument.text">
|
||||
<office:automatic-styles>
|
||||
<style:style style:name="P1" style:family="paragraph" style:parent-style-name="Standard" style:list-style-name="L1">
|
||||
<style:text-properties officeooo:rsid="001fa9e2" officeooo:paragraph-rsid="001fa9e2"/>
|
||||
</style:style>
|
||||
<text:list-style style:name="L1">
|
||||
<text:list-level-style-number text:level="1" text:style-name="Numbering_20_Symbols" style:num-suffix="." style:num-format="1">
|
||||
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
|
||||
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.27cm" fo:text-indent="-0.635cm" fo:margin-left="1.27cm"/>
|
||||
</style:list-level-properties>
|
||||
</text:list-level-style-number>
|
||||
</text:list-style>
|
||||
</office:automatic-styles>
|
||||
<office:body>
|
||||
<office:text>
|
||||
<text:tracked-changes text:track-changes="false">
|
||||
<text:changed-region xml:id="ct94243390468896" text:id="ct94243390468896">
|
||||
<text:insertion>
|
||||
<office:change-info>
|
||||
<dc:creator>C</dc:creator>
|
||||
<dc:date>2022-04-27T11:06:53</dc:date>
|
||||
</office:change-info>
|
||||
</text:insertion>
|
||||
</text:changed-region>
|
||||
<text:changed-region xml:id="ct94243403412256" text:id="ct94243403412256">
|
||||
<text:deletion>
|
||||
<office:change-info>
|
||||
<dc:creator>C</dc:creator>
|
||||
<dc:date>2022-04-27T11:07:06</dc:date>
|
||||
</office:change-info>
|
||||
</text:deletion>
|
||||
</text:changed-region>
|
||||
<text:changed-region xml:id="ct94243407515552" text:id="ct94243407515552">
|
||||
<text:insertion>
|
||||
<office:change-info>
|
||||
<dc:creator>C</dc:creator>
|
||||
<dc:date>2022-04-27T11:06:51</dc:date>
|
||||
</office:change-info>
|
||||
</text:insertion>
|
||||
</text:changed-region>
|
||||
</text:tracked-changes>
|
||||
<text:sequence-decls>
|
||||
<text:sequence-decl text:display-outline-level="0" text:name="Illustration"/>
|
||||
<text:sequence-decl text:display-outline-level="0" text:name="Table"/>
|
||||
<text:sequence-decl text:display-outline-level="0" text:name="Text"/>
|
||||
<text:sequence-decl text:display-outline-level="0" text:name="Drawing"/>
|
||||
</text:sequence-decls>
|
||||
<text:p text:style-name="P3"><text:span text:style-name="T1">Lorem.</text:span><text:change-start text:change-id="ct94243403412256"/><text:span text:style-name="T1"><text:note text:id="ftn2" text:note-class="footnote"><text:note-citation>1</text:note-citation><text:note-body>
|
||||
<text:p text:style-name="P1">Ipsum.</text:p></text:note-body></text:note></text:span><text:change-end text:change-id="ct94243403412256"/></text:p>
|
||||
<text:p text:style-name="P3"><text:span text:style-name="T1">Dolor sit.</text:span><text:change-start text:change-id="ct94243407515552"/><text:span text:style-name="T1"><text:note text:id="ftn1" text:note-class="footnote"><text:note-citation>2</text:note-citation><text:note-body>
|
||||
<text:p text:style-name="P1"><text:change-start text:change-id="ct94243390468896"/>Amet.<text:change-end text:change-id="ct94243390468896"/></text:p></text:note-body></text:note></text:span><text:change-end text:change-id="ct94243407515552"/></text:p>
|
||||
</office:text>
|
||||
</office:body>
|
||||
</office:document>
|
@@ -302,6 +302,24 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testRedlineNumberInNumbering)
|
||||
assertXPath(pXmlDoc, "/metafile/push/push/push/font[4][@color='#000000']", 0);
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testRedlineNumberInFootnote)
|
||||
{
|
||||
SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "tdf85610.fodt");
|
||||
SwDocShell* pShell = pDoc->GetDocShell();
|
||||
|
||||
// Dump the rendering of the first page as an XML file.
|
||||
std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile();
|
||||
MetafileXmlDump dumper;
|
||||
|
||||
xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile);
|
||||
CPPUNIT_ASSERT(pXmlDoc);
|
||||
|
||||
// changed color of numbers of footnote 1 (deleted footnote) and footnote 2 (inserted footnote)
|
||||
// decreased the black <font> elements by 2:
|
||||
// This was 7
|
||||
assertXPath(pXmlDoc, "/metafile/push/push/push/font[@color='#000000']", 5);
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testRedlineMoving)
|
||||
{
|
||||
SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "tdf42748.fodt");
|
||||
|
@@ -53,6 +53,13 @@
|
||||
#include <frmtool.hxx>
|
||||
#include <ndindex.hxx>
|
||||
#include <IDocumentSettingAccess.hxx>
|
||||
#include <IDocumentRedlineAccess.hxx>
|
||||
#include <swmodule.hxx>
|
||||
#include <unotextrange.hxx>
|
||||
#include <redline.hxx>
|
||||
#include <editeng/colritem.hxx>
|
||||
#include <editeng/udlnitem.hxx>
|
||||
#include <editeng/crossedoutitem.hxx>
|
||||
|
||||
#include <com/sun/star/beans/XPropertySet.hpp>
|
||||
#include <com/sun/star/awt/CharSet.hpp>
|
||||
@@ -990,6 +997,36 @@ SwNumberPortion *SwTextFormatter::NewFootnoteNumPortion( SwTextFormatInfo const
|
||||
pNumFnt->SetDiffFnt(&rSet, pIDSA );
|
||||
pNumFnt->SetVertical( pNumFnt->GetOrientation(), m_pFrame->IsVertical() );
|
||||
|
||||
// tdf#85610 apply redline coloring to the footnote numbering in the footnote area
|
||||
SwUnoInternalPaM aPam(*pDoc);
|
||||
if ( ::sw::XTextRangeToSwPaM(aPam, xAnchor) )
|
||||
{
|
||||
SwRedlineTable::size_type nRedlinePos = 0;
|
||||
const SwRedlineTable& rTable = pDoc->getIDocumentRedlineAccess().GetRedlineTable();
|
||||
const SwRangeRedline* pRedline = rTable.FindAtPosition( *aPam.Start(), nRedlinePos );
|
||||
if (pRedline)
|
||||
{
|
||||
SwAttrPool& rPool = pDoc->GetAttrPool();
|
||||
SfxItemSetFixed<RES_CHRATR_BEGIN, RES_CHRATR_END-1> aSet(rPool);
|
||||
|
||||
std::size_t aAuthor = (1 < pRedline->GetStackCount())
|
||||
? pRedline->GetAuthor( 1 )
|
||||
: pRedline->GetAuthor();
|
||||
|
||||
if ( RedlineType::Delete == pRedline->GetType() )
|
||||
SW_MOD()->GetDeletedAuthorAttr(aAuthor, aSet);
|
||||
else
|
||||
SW_MOD()->GetInsertAuthorAttr(aAuthor, aSet);
|
||||
|
||||
if (const SvxColorItem* pItem = aSet.GetItemIfSet(RES_CHRATR_COLOR))
|
||||
pNumFnt->SetColor(pItem->GetValue());
|
||||
if (const SvxUnderlineItem* pItem = aSet.GetItemIfSet(RES_CHRATR_UNDERLINE))
|
||||
pNumFnt->SetUnderline(pItem->GetLineStyle());
|
||||
if (const SvxCrossedOutItem* pItem = aSet.GetItemIfSet(RES_CHRATR_CROSSEDOUT))
|
||||
pNumFnt->SetStrikeout( pItem->GetStrikeout() );
|
||||
}
|
||||
}
|
||||
|
||||
SwFootnoteNumPortion* pNewPor = new SwFootnoteNumPortion( aFootnoteText, std::move(pNumFnt) );
|
||||
pNewPor->SetLeft( !m_pFrame->IsRightToLeft() );
|
||||
return pNewPor;
|
||||
|
@@ -823,7 +823,15 @@ void MetafileXmlDump::writeXml(const GDIMetaFile& rMetaFile, tools::XmlWriter& r
|
||||
}
|
||||
|
||||
rWriter.startElement("text");
|
||||
rWriter.content(pMetaTextArrayAction->GetText());
|
||||
|
||||
const OUString& rStr = pMetaTextArrayAction->GetText();
|
||||
// fix bad XML dump by removing forbidden 0x01
|
||||
// FIXME: expand footnote anchor point 0x01 instead of this
|
||||
if ( rStr.indexOf(0x01) > -1 )
|
||||
rWriter.content(rStr.replaceAll("\001", ""));
|
||||
else
|
||||
rWriter.content(rStr);
|
||||
|
||||
rWriter.endElement();
|
||||
|
||||
rWriter.endElement();
|
||||
|
Reference in New Issue
Block a user