[Libreoffice-commits] core.git: offapi/com sw/inc sw/qa sw/source writerfilter/source

2022-11-22 Thread Miklos Vajna (via logerrit)
 offapi/com/sun/star/text/ContentControl.idl  |6 +++
 sw/inc/formatcontentcontrol.hxx  |7 
 sw/inc/unoprnms.hxx  |1 
 sw/qa/extras/ooxmlexport/data/sdt-duplicated-id.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport18.cxx   |   17 +++
 sw/source/core/txtnode/attrcontentcontrol.cxx|2 +
 sw/source/core/unocore/unocontentcontrol.cxx |   29 +++
 sw/source/core/unocore/unomap1.cxx   |1 
 sw/source/filter/ww8/docxattributeoutput.cxx |6 +++
 writerfilter/source/dmapper/DomainMapper.cxx |6 +++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx|5 +++
 writerfilter/source/dmapper/SdtHelper.cxx|5 +++
 writerfilter/source/dmapper/SdtHelper.hxx|6 +++
 13 files changed, 91 insertions(+)

New commits:
commit 100c914d44ae8f362924fe567d7d41d0033ae8ad
Author: Miklos Vajna 
AuthorDate: Tue Nov 22 14:30:08 2022 +0100
Commit: Miklos Vajna 
CommitDate: Tue Nov 22 19:36:37 2022 +0100

DOCX filter: fix  creating both grab-bag and content control for 


Exporting the DOCX bugdoc back to DOCX resulted in a document that can't
be opened in Word.

Examining the output, the problem is that the document had 2 inline
 elements with , and we mapped such  elements to
both grab-bags and content controls, leading to duplicate 
elements on export. This is schema-valid, but it goes against the
intention of the spec and Word can't open it.

The initial fix was just a writerfilter/ tweak to avoid grab-bagging
 for inline , but CppunitTest_sw_ooxmlexport4's
testSimpleSdts points out that in other cases we already require
preserving . Fix the problem by storing  in the content
control, which is essentially a subset of
.

Thanks to Justin Luth! - he prototyped the DOCX filter for .

Change-Id: I9f002b770049ce8be30253d0b39410d9a58981dd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143117
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/offapi/com/sun/star/text/ContentControl.idl 
b/offapi/com/sun/star/text/ContentControl.idl
index 7bdb39fa5101..6abcc79fd204 100644
--- a/offapi/com/sun/star/text/ContentControl.idl
+++ b/offapi/com/sun/star/text/ContentControl.idl
@@ -121,6 +121,12 @@ service ContentControl
 @since LibreOffice 7.5
 */
 [optional, property, readonly] string DateString;
+
+/** A unique numeric id, used by macros to identify a specific control.
+
+@since LibreOffice 7.5
+*/
+[optional, property] long Id;
 };
 
 
diff --git a/sw/inc/formatcontentcontrol.hxx b/sw/inc/formatcontentcontrol.hxx
index 2d5676a1e3dd..3ac6848e388f 100644
--- a/sw/inc/formatcontentcontrol.hxx
+++ b/sw/inc/formatcontentcontrol.hxx
@@ -176,6 +176,9 @@ class SW_DLLPUBLIC SwContentControl : public 
sw::BroadcastingModify
 /// The tag: just remembered.
 OUString m_aTag;
 
+/// The id: just remembered.
+sal_Int32 m_nId = 0;
+
 /// Stores a list item index, in case the doc model is not yet updated.
 std::optional m_oSelectedListItem;
 
@@ -342,6 +345,10 @@ public:
 
 const OUString& GetTag() const { return m_aTag; }
 
+void SetId(sal_Int32 nId) { m_nId = nId; }
+
+sal_Int32 GetId() const { return m_nId; }
+
 void SetReadWrite(bool bReadWrite) { m_bReadWrite = bReadWrite; }
 
 bool GetReadWrite() const { return m_bReadWrite; }
diff --git a/sw/inc/unoprnms.hxx b/sw/inc/unoprnms.hxx
index 4249949add6d..69ef10b881f9 100644
--- a/sw/inc/unoprnms.hxx
+++ b/sw/inc/unoprnms.hxx
@@ -893,6 +893,7 @@
 #define UNO_NAME_COLOR "Color"
 #define UNO_NAME_ALIAS "Alias"
 #define UNO_NAME_TAG "Tag"
+#define UNO_NAME_ID "Id"
 #define UNO_NAME_DATE_STRING "DateString"
 #endif
 
diff --git a/sw/qa/extras/ooxmlexport/data/sdt-duplicated-id.docx 
b/sw/qa/extras/ooxmlexport/data/sdt-duplicated-id.docx
new file mode 100644
index ..d21894df3007
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/sdt-duplicated-id.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
index af42616d778d..71d28b313d2a 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
@@ -155,6 +155,23 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf150966_regularInset)
 assertXPathAttrs(pXmlDoc, "//wps:bodyPr", { { "tIns", "179640" }, { 
"bIns", "36" } });
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testSdtDuplicatedId)
+{
+// Given a document with 2 inline , with each a :
+createSwDoc("sdt-duplicated-id.docx");
+
+// When exporting that back to DOCX:
+save("Office Open XML Text");
+
+// Then make sure we write 2  and no duplicates:
+xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
+// Without the accompanying fix in 

[Libreoffice-commits] core.git: offapi/com sw/inc sw/qa sw/source writerfilter/source

2021-11-17 Thread László Németh (via logerrit)
 offapi/com/sun/star/text/XRedline.idl |1 +
 sw/inc/redline.hxx|6 +-
 sw/qa/extras/layout/data/tdf104797.docx   |binary
 sw/qa/extras/layout/layout2.cxx   |   20 
 sw/qa/extras/ooxmlexport/ooxmlexport11.cxx|   20 +++-
 sw/qa/extras/ooxmlexport/ooxmlexport13.cxx|   20 
 sw/qa/extras/uiwriter/uiwriter2.cxx   |7 +++
 sw/source/core/doc/DocumentRedlineManager.cxx |7 ++-
 sw/source/core/doc/docredln.cxx   |   20 +---
 sw/source/core/text/redlnitr.cxx  |2 +-
 sw/source/core/text/txtfld.cxx|2 +-
 sw/source/core/unocore/unocrsrhelper.cxx  |6 ++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |9 -
 13 files changed, 103 insertions(+), 17 deletions(-)

New commits:
commit f51fa7534421a195a58b4a737a2e836d8c25ba81
Author: László Németh 
AuthorDate: Tue Nov 16 16:08:57 2021 +0100
Commit: László Németh 
CommitDate: Wed Nov 17 20:05:46 2021 +0100

tdf#145718 sw, DOCX import: complete tracked text moving

Add IsMoved bit to SwRangeRedline, and keep it in both
parts of a split Delete/Insert redline. Set this bit
during DOCX import, fixing incomplete import of
moveFrom/moveTo elements.

Details:

- Search text moving only at redline Insert() and AppendRedline()
  instead in the layout code (which was much slower, because
  triggered by also mouse hovering):

- detect text moving in Hide Changes mode, too;

- Insertion inside or directly after tracked text moving keeps
  "moved text" layout of the original moved text parts (before
  and after the insertion).

- at detection of text moving, invalidate (update) layout of the
  redline pair, too.

- fix DOCX import: extend makeRedline() with property RedlineMoved
  to keep all moveFrom/moveTo stored in DOCX instead of
  losing them (joining them with normal redlines) in the case
  of missing Delete/Insert pair (see unit test document);

Follow-up to commit ec577f566fa3e6d2666069180f8ec8474054aea9
"tdf#145233 sw track changes: show moved text in green color",
commit bcdebc832b272662d28035007a4796e42d1305ae
"tdf#104797 DOCX change tracking: handle moveFrom and moveTo"
and commit d32d9a2b3c5e3963f4a18f6c7bbf50fab2e9b2be
"tdf#123460 DOCX track changes: moveFrom completely".

Change-Id: Iaca80e5e326a172bc7ba5fec64b63668b9378e2d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125317
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/offapi/com/sun/star/text/XRedline.idl 
b/offapi/com/sun/star/text/XRedline.idl
index 9b259e8b9e58..a07c92ddfc62 100644
--- a/offapi/com/sun/star/text/XRedline.idl
+++ b/offapi/com/sun/star/text/XRedline.idl
@@ -46,6 +46,7 @@ published interface XRedline
 [readonly, property] string RedlineAuthor;
 [readonly, property] com::sun::star::util::DateTime 
RedlineDateTime;
 [readonly, property] string RedlineComment;
+[readonly, optional, property] boolean RedlineMoved;
 */
 void makeRedline( [in]string RedlineType, [in] 
com::sun::star::beans::PropertyValues  RedlineProperties)
 raises( com::sun::star::lang::IllegalArgumentException 
);
diff --git a/sw/inc/redline.hxx b/sw/inc/redline.hxx
index 0c5b8408d54c..8d17948205fa 100644
--- a/sw/inc/redline.hxx
+++ b/sw/inc/redline.hxx
@@ -155,6 +155,7 @@ class SW_DLLPUBLIC SwRangeRedline final : public SwPaM
 SwNodeIndex* m_pContentSect;
 bool m_bDelLastPara : 1;
 bool m_bIsVisible : 1;
+bool m_bIsMoved : 1;
 sal_uInt32 m_nId;
 
 std::optional m_oLOKLastNodeTop;
@@ -174,7 +175,7 @@ public:
 SwRangeRedline(SwRedlineData* pData, const SwPosition& rPos,
bool bDelLP) :
 SwPaM( rPos ), m_pRedlineData( pData ), m_pContentSect( nullptr ),
-m_bDelLastPara( bDelLP ), m_bIsVisible( true ), m_nId( s_nLastId++ )
+m_bDelLastPara( bDelLP ), m_bIsVisible( true ), m_bIsMoved( false ), 
m_nId( s_nLastId++ )
 {}
 SwRangeRedline( const SwRangeRedline& );
 virtual ~SwRangeRedline() override;
@@ -261,6 +262,9 @@ public:
 void dumpAsXml(xmlTextWriterPtr pWriter) const;
 
 void MaybeNotifyRedlinePositionModification(tools::Long nTop);
+
+void SetMoved() { m_bIsMoved = true; }
+bool IsMoved() const { return m_bIsMoved; }
 };
 
 void MaybeNotifyRedlineModification(SwRangeRedline& rRedline, SwDoc& rDoc);
diff --git a/sw/qa/extras/layout/data/tdf104797.docx 
b/sw/qa/extras/layout/data/tdf104797.docx
new file mode 100644
index ..6e52190ce671
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf104797.docx differ
diff --git a/sw/qa/extras/layout/layout2.cxx 

[Libreoffice-commits] core.git: offapi/com sw/inc sw/qa sw/source writerfilter/source

2013-09-29 Thread Zolnai Tamás
 offapi/com/sun/star/style/CharacterProperties.idl |6 ++
 sw/inc/charatr.hxx|4 +
 sw/inc/format.hxx |1 
 sw/inc/hintids.hxx|2 
 sw/inc/swatrset.hxx   |1 
 sw/inc/unoprnms.hxx   |1 
 sw/qa/extras/ooxmlexport/data/char_highlight.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx  |   49 ++
 sw/source/core/bastyp/init.cxx|2 
 sw/source/core/doc/dbgoutsw.cxx   |1 
 sw/source/core/inc/swfntcch.hxx   |2 
 sw/source/core/inc/swfont.hxx |   10 
 sw/source/core/text/atrhndl.hxx   |2 
 sw/source/core/text/atrstck.cxx   |   15 --
 sw/source/core/text/inftxt.cxx|   13 -
 sw/source/core/txtnode/swfont.cxx |   11 
 sw/source/core/unocore/unomap.cxx |4 +
 sw/source/core/unocore/unoprnms.cxx   |2 
 sw/source/filter/html/css1atr.cxx |2 
 sw/source/filter/html/htmlatr.cxx |2 
 sw/source/filter/ww8/attributeoutputbase.hxx  |3 +
 sw/source/filter/ww8/docxattributeoutput.cxx  |   34 +++
 sw/source/filter/ww8/docxattributeoutput.hxx  |   11 
 sw/source/filter/ww8/rtfattributeoutput.hxx   |3 +
 sw/source/filter/ww8/ww8atr.cxx   |3 +
 sw/source/filter/ww8/ww8attributeoutput.hxx   |3 +
 writerfilter/source/dmapper/DomainMapper.cxx  |4 -
 writerfilter/source/dmapper/PropertyIds.cxx   |1 
 writerfilter/source/dmapper/PropertyIds.hxx   |1 
 29 files changed, 173 insertions(+), 20 deletions(-)

New commits:
commit 8b949134441056a1455d67ddfdd7e0bc5f2ee682
Author: Zolnai Tamás zolnaitamas2...@gmail.com
Date:   Sun Sep 29 10:24:53 2013 +0200

fdo#65403, fdo#65404 DOCX export/import of character highlight

Steps
-Add a new character attribute (RES_CHRATR_HIGHLIGHT)
-Get this character attribute via SwFont class just like
background
-If has highlight, then paint that, otherwise paint background
-Extend UNO API
-Implement DOCX export and import filter
Note: By now character highlight can't be set via UI.
It's a next step to add a highlight option.

Change-Id: I7f81e173744bf256891487f898d06dbf372a2f88

diff --git a/offapi/com/sun/star/style/CharacterProperties.idl 
b/offapi/com/sun/star/style/CharacterProperties.idl
index c4f5452..ae8313d 100644
--- a/offapi/com/sun/star/style/CharacterProperties.idl
+++ b/offapi/com/sun/star/style/CharacterProperties.idl
@@ -435,6 +435,12 @@ published service CharacterProperties
 **/
 [optional, property] com::sun::star::table::ShadowFormat CharShadowFormat;
 
+/** Determines the color of the highlight.
+ *
+ *  @since LibreOffice 4.2
+**/
+[optional, property] com::sun::star::util::Color CharHighLight;
+
 };
 
 }; }; }; };
diff --git a/sw/inc/charatr.hxx b/sw/inc/charatr.hxx
index b0a77c2..e248205 100644
--- a/sw/inc/charatr.hxx
+++ b/sw/inc/charatr.hxx
@@ -87,6 +87,8 @@ inline const SvxBlinkItem  SwAttrSet::GetBlink(sal_Bool 
bInP) const
 {   return (const SvxBlinkItem)Get( RES_CHRATR_BLINK,bInP); }
 inline const SvxBrushItem SwAttrSet::GetChrBackground( sal_Bool bInP ) const
 {   return (const SvxBrushItem)Get( RES_CHRATR_BACKGROUND, bInP ); }
+inline const SvxBrushItem SwAttrSet::GetChrHighLight( sal_Bool bInP ) const
+{   return (const SvxBrushItem)Get( RES_CHRATR_HIGHLIGHT, bInP ); }
 inline const SvxEmphasisMarkItem SwAttrSet::GetEmphasisMark( sal_Bool bInP ) 
const
 {   return (const SvxEmphasisMarkItem)Get( RES_CHRATR_EMPHASIS_MARK, bInP 
); }
 inline const SvxTwoLinesItemSwAttrSet::Get2Lines( sal_Bool bInP ) const
@@ -152,6 +154,8 @@ inline const SvxBlinkItem   
SwFmt::GetBlink(sal_Bool bInP) const
 {   return aSet.GetBlink(bInP); }
 inline const SvxBrushItem   SwFmt::GetChrBackground(sal_Bool bInP) 
const
 {   return aSet.GetChrBackground(bInP); }
+inline const SvxBrushItem SwFmt::GetChrHighLight(sal_Bool bInP) const
+{   return aSet.GetChrHighLight(bInP); }
 inline const SvxEmphasisMarkItem   SwFmt::GetEmphasisMark( sal_Bool bInP ) 
const
 {   return aSet.GetEmphasisMark(bInP); }
 inline const SvxTwoLinesItem   SwFmt::Get2Lines( sal_Bool bInP ) const
diff --git a/sw/inc/format.hxx b/sw/inc/format.hxx
index a058dc6..88c5402 100644
--- a/sw/inc/format.hxx
+++ b/sw/inc/format.hxx
@@ -190,6 +190,7 @@ public:
 inline const SvxNoHyphenItem GetNoHyphenHere( sal_Bool = sal_True ) 
const;
 inline const SvxBlinkItemGetBlink( sal_Bool = sal_True ) const;
 inline const SvxBrushItemGetChrBackground( sal_Bool = sal_True ) 
const;
+inline const SvxBrushItemGetChrHighLight( sal_Bool = sal_True )