[Libreoffice-commits] core.git: sw/qa sw/source
László Németh (via logerrit)
logerrit at kemper.freedesktop.org
Tue Oct 22 16:03:34 UTC 2019
sw/qa/extras/layout/data/tdf42748.fodt | 57 +++++++++++++++++++++++++++++
sw/qa/extras/layout/layout.cxx | 17 ++++++++
sw/source/core/text/txtfld.cxx | 64 +++++++++++++++++++++++++++++++++
3 files changed, 138 insertions(+)
New commits:
commit 173b7fcaae86980809889db30ddb82f8ba883103
Author: László Németh <nemeth at numbertext.org>
AuthorDate: Mon Oct 21 17:46:11 2019 +0200
Commit: László Németh <nemeth at numbertext.org>
CommitDate: Tue Oct 22 18:02:32 2019 +0200
tdf#42748 show changes of list numbers and bullets
At splitting or joining list items or adding new ones, the
removed or new list number or bullet didn't show the change,
only a vertical line added to the left margin of the list
items. Moreover, deleting only the text of the list
item (keeping its number) looked like the full deletion of
the item.
Change-Id: I4568713b5c94584761609d891b3eb36c45f8502c
Reviewed-on: https://gerrit.libreoffice.org/81258
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth at numbertext.org>
diff --git a/sw/qa/extras/layout/data/tdf42748.fodt b/sw/qa/extras/layout/data/tdf42748.fodt
new file mode 100644
index 000000000000..e8bcb257db87
--- /dev/null
+++ b/sw/qa/extras/layout/data/tdf42748.fodt
@@ -0,0 +1,57 @@
+<?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:oas
is: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>
+ <office:forms form:automatic-focus="false" form:apply-design-mode="false"/>
+ <text:tracked-changes text:track-changes="false">
+ <text:changed-region xml:id="ct93933933058752" text:id="ct93933933058752">
+ <text:deletion>
+ <office:change-info>
+ <dc:creator>Unknown Author</dc:creator>
+ <dc:date>2019-10-22T08:48:10</dc:date>
+ </office:change-info>
+ </text:deletion>
+ </text:changed-region>
+ <text:changed-region xml:id="ct93933933061040" text:id="ct93933933061040">
+ <text:insertion>
+ <office:change-info>
+ <dc:creator>Unknown Author 2</dc:creator>
+ <dc:date>2019-10-22T08:48:12</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-decl text:display-outline-level="0" text:name="Figure"/>
+ </text:sequence-decls>
+ <text:list xml:id="list3554620173" text:style-name="L1">
+ <text:list-item>
+ <text:p text:style-name="P1">It<text:change-start text:change-id="ct93933933058752"/></text:p>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P1"><text:change-end text:change-id="ct93933933058752"/>em<text:change-start text:change-id="ct93933933061040"/></text:p>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P1"><text:change-end text:change-id="ct93933933061040"/>Item</text:p>
+ </text:list-item>
+ </text:list>
+ </office:text>
+ </office:body>
+</office:document>
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index 073cd2baf066..98eed78ca56a 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -2161,6 +2161,23 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineCharAttributes)
CheckRedlineCharAttributesHidden();
}
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineNumberInNumbering)
+{
+ SwDoc* pDoc = createDoc("tdf42748.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;
+
+ xmlDocPtr pXmlDoc = dumpAndParse(dumper, *xMetaFile);
+ CPPUNIT_ASSERT(pXmlDoc);
+
+ // Assert the tracked deletion of the number of joined list item and
+ // the tracked insertion of the number after a split list item as not black elements
+ assertXPath(pXmlDoc, "/metafile/push/push/push/textcolor[not(@color='#000000')]", 6);
+}
+
CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf116830)
{
SwDoc* pDoc = createDoc("tdf116830.odt");
diff --git a/sw/source/core/text/txtfld.cxx b/sw/source/core/text/txtfld.cxx
index 1cd40e555c93..c5d1816200df 100644
--- a/sw/source/core/text/txtfld.cxx
+++ b/sw/source/core/text/txtfld.cxx
@@ -34,6 +34,7 @@
#include <viewimp.hxx>
#include <txtatr.hxx>
#include <swfont.hxx>
+#include <swmodule.hxx>
#include <fntcache.hxx>
#include "porfld.hxx"
#include "porftn.hxx"
@@ -52,8 +53,13 @@
#include <reffld.hxx>
#include <flddat.hxx>
#include <IDocumentSettingAccess.hxx>
+#include <IDocumentRedlineAccess.hxx>
+#include <redline.hxx>
#include <sfx2/docfile.hxx>
#include <svl/itemiter.hxx>
+#include <editeng/colritem.hxx>
+#include <editeng/udlnitem.hxx>
+#include <editeng/crossedoutitem.hxx>
static bool lcl_IsInBody( SwFrame const *pFrame )
{
@@ -477,6 +483,60 @@ static void checkApplyParagraphMarkFormatToNumbering(SwFont* pNumFnt, SwTextForm
}
}
+static const SwRangeRedline* lcl_GetRedlineAtNodeInsertionOrDeletion( const SwTextNode& rTextNode )
+{
+ const SwDoc* pDoc = rTextNode.GetDoc();
+ SwRedlineTable::size_type nRedlPos = pDoc->getIDocumentRedlineAccess().GetRedlinePos( rTextNode, RedlineType::Any );
+
+ if( SwRedlineTable::npos != nRedlPos )
+ {
+ const sal_uLong nNdIdx = rTextNode.GetIndex();
+ for( ; nRedlPos < pDoc->getIDocumentRedlineAccess().GetRedlineTable().size() ; ++nRedlPos )
+ {
+ const SwRangeRedline* pTmp = pDoc->getIDocumentRedlineAccess().GetRedlineTable()[ nRedlPos ];
+ if( RedlineType::Delete == pTmp->GetType() ||
+ RedlineType::Insert == pTmp->GetType() )
+ {
+ const SwPosition *pRStt = pTmp->Start(), *pREnd = pTmp->End();
+ if( pRStt->nNode < nNdIdx && pREnd->nNode >= nNdIdx )
+ return pTmp;
+ }
+ }
+ }
+ return nullptr;
+}
+
+static void lcl_setRedlineAttr( SwTextFormatInfo &rInf, const SwTextNode& rTextNode, std::unique_ptr<SwFont>& pNumFnt )
+{
+ if ( !rInf.GetVsh()->GetLayout()->IsHideRedlines() )
+ {
+ const SwRangeRedline* pRedlineNum = lcl_GetRedlineAtNodeInsertionOrDeletion( rTextNode );
+ if (pRedlineNum)
+ {
+ std::unique_ptr<SfxItemSet> pSet;
+
+ SwAttrPool& rPool = rInf.GetVsh()->GetDoc()->GetAttrPool();
+ pSet = std::make_unique<SfxItemSet>(rPool, svl::Items<RES_CHRATR_BEGIN, RES_CHRATR_END-1>{});
+
+ std::size_t aAuthor = (1 < pRedlineNum->GetStackCount())
+ ? pRedlineNum->GetAuthor( 1 )
+ : pRedlineNum->GetAuthor();
+
+ if ( RedlineType::Delete == pRedlineNum->GetType() )
+ SW_MOD()->GetDeletedAuthorAttr(aAuthor, *pSet);
+ else
+ SW_MOD()->GetInsertAuthorAttr(aAuthor, *pSet);
+
+ const SfxPoolItem* pItem = nullptr;
+ if (SfxItemState::SET == pSet->GetItemState(RES_CHRATR_COLOR, true, &pItem))
+ pNumFnt->SetColor(static_cast<const SvxColorItem*>(pItem)->GetValue());
+ if (SfxItemState::SET == pSet->GetItemState(RES_CHRATR_UNDERLINE, true, &pItem))
+ pNumFnt->SetUnderline(static_cast<const SvxUnderlineItem*>(pItem)->GetLineStyle());
+ if (SfxItemState::SET == pSet->GetItemState(RES_CHRATR_CROSSEDOUT, true, &pItem))
+ pNumFnt->SetStrikeout( static_cast<const SvxCrossedOutItem*>(pItem)->GetStrikeout() );
+ }
+ }
+}
SwNumberPortion *SwTextFormatter::NewNumberPortion( SwTextFormatInfo &rInf ) const
{
@@ -590,6 +650,8 @@ SwNumberPortion *SwTextFormatter::NewNumberPortion( SwTextFormatInfo &rInf ) con
pNumFnt->SetVertical( pNumFnt->GetOrientation(),
m_pFrame->IsVertical() );
+ lcl_setRedlineAttr( rInf, *pTextNd, pNumFnt );
+
// --> OD 2008-01-23 #newlistelevelattrs#
pRet = new SwBulletPortion( rNumFormat.GetBulletChar(),
pTextNd->GetLabelFollowedBy(),
@@ -632,6 +694,8 @@ SwNumberPortion *SwTextFormatter::NewNumberPortion( SwTextFormatInfo &rInf ) con
checkApplyParagraphMarkFormatToNumbering(pNumFnt.get(), rInf, pIDSA, pFormat);
+ lcl_setRedlineAttr( rInf, *pTextNd, pNumFnt );
+
// we do not allow a vertical font
pNumFnt->SetVertical( pNumFnt->GetOrientation(), m_pFrame->IsVertical() );
More information about the Libreoffice-commits
mailing list