eclipse-platform / eclipse-platform/eclipse.platform

Compare with Microsoft Word 2007 and above diffs in direction opposite to Word 2003

Aperta
#65 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Java
Stelle
165
Fork
174
Merge medio
2g 8h
PR unite (30g)
22

Descrizione

This is a fresh copy of the old [bug 401373](https://bugs.eclipse.org/bugs/show_bug.cgi?id=401373), after doing some intensive research & debugging today.

The fix seems to be pretty easy: as hinted in the linked report, it is just about switching the compared Document objects order based on the Word version, like they did it back in 2008 in TortoiseSVN:

TortoiseGit/tortoisesvn@0dabda7d91c41c085986a150afc1a368e154f102, or just look for occurrences of `vOffice2007` in their [diff-doc.js](https://github.com/TortoiseGit/tortoisesvn/blob/master/contrib/diff-scripts/diff-doc.js).

=> We can probably do something similar inside the `org.eclipse.compare.internal.win32.WordComparison.createWorkingCopy(String baseDocument, String revisedDocument, String workingCopy)` method.

We just need to get to `Word.Version` somehow, in order to implement the switch condition for backwards compatibility. The following looks like the simplest working way (possibly returning string `12.0` for Word 2007):

```java
getVariantProperty(new OleAutomation(new OleClientSite(frame, SWT.NONE, "Word.Application")), "Version")
```

_Trivia: The reported problem is technically already 14 years old, as the comparison feature, relying on pre-2007 Word versions, was implemented back in 2008. And it looks like an undocumented change in the Microsoft's [_Document.Compare()](https://docs.microsoft.com/en-us/dotnet/api/microsoft.office.interop.word._document.compare?view=word-pia) method._

**UPDATE:** Unfortunately, the problem seems to be hidden more in the core "comparison logic" which is inconsistent across the GUI. See e.g. [bug 516450](https://bugs.eclipse.org/bugs/show_bug.cgi?id=516450) for more details. For this bug, this means that it is quite possible that the diff is currently displayed incorrectly e.g. **just when comparing file versions from the History view** ("Compare with each other"). And this is caused by passing "left" and "right" versions into the Word comparator in different order from various GUI actions.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.