Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LT-21708 Add image and caption textframes to word export #28

Merged
merged 7 commits into from
Apr 24, 2024

Conversation

aror92
Copy link
Contributor

@aror92 aror92 commented Apr 24, 2024

  • Reconfigure images to be inline instead of anchored. (Textframes require inline images; textboxes require anchored.)
  • Clean up cloning of image runs.
  • Create a global paragraph style to use for textframes.
  • Link textframe style to images and their captions and ensure image and associated caption are added to the same textframe.
  • Ensure Word does not merge adjacent images into the same textframe. This requires adding an empty paragraph between the image textframes, otherwise Word will automatically merge them into a single textframe that can't be split.

This change is Reviewable

aror92 and others added 3 commits April 23, 2024 20:32
- Reconfigure images to be inline instead of anchored.
(Textframes require inline images; textboxes require anchored.)
- Clean up cloning of image runs.
- Create a global paragraph style to use for textframes.
- Link textframe style to images and their captions and ensure image
and associated caption are added to the same textframe.
- Ensure Word does not merge adjacent images into the same textframe.
This requires adding an empty paragraph between the image textframes,
otherwise Word will automatically merge them into a single textframe
that can't be split.

Change-Id: I331b0d0294c137ea685a42ddac41282c4f7bb146
Change-Id: Ib93eaab6519cecb11e71fe2b22aabb890477a47c
Copy link
Contributor

@mark-sil mark-sil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 2 of 2 files at r1.
Reviewable status: 1 of 2 files reviewed, 4 unresolved discussions (waiting on @aror92)


Src/xWorks/LcmWordGenerator.cs line 6 at r1 (raw file):

using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Office2010.Drawing;

Probably remove.

Code quote:

using DocumentFormat.OpenXml.Office2010.Drawing;

Src/xWorks/LcmWordGenerator.cs line 310 at r1 (raw file):

				{
					WP.ParagraphProperties paragraphProps = new WP.ParagraphProperties(new ParagraphStyleId() { Val = styleName });
					par.PrependChild(paragraphProps);

Nice catch! This fixes some of the problems I was seeing with styles not being applied.

Code quote:

PrependChild

Src/xWorks/LcmWordGenerator.cs line 1008 at r1 (raw file):

								// and it is being added after another image run was previously added from the same piece,
								// we need to append an empty paragraph between to maintain separate textframes.
								if (run.Descendants<Drawing>().Any())

If we only care about adjacent images then instead of Any should we check Last?

Code quote:

Any

Src/xWorks/WordStylesGenerator.cs line 335 at r1 (raw file):

				case DictionaryNodePictureOptions pictureOptions:
					//return new Styles();

Should this be removed?

Code quote:

//return new Styles();

@aror92
Copy link
Contributor Author

aror92 commented Apr 24, 2024

Src/xWorks/LcmWordGenerator.cs line 1008 at r1 (raw file):

Previously, mark-sil (Mark Kidder) wrote…

If we only care about adjacent images then instead of Any should we check Last?

This line only functions to verify that the current run contains an image. (Any is preferable to last for that check because the image run could contain e.g. a text object after the image, but if an image is contained anywhere inside the run, the run is an "image run".)

We could add a check for if the image runs in question are adjacent. But, looking for adjacent images won't have the expected result because each image run is followed by other runs containing associated items like Caption, Copyright & License that are added to the textframe but do not contain images.

My understanding is that a piece corresponds to one lexical entry, and the images are all added sequentially at the end of the piece, after all of the senses. So the order of runs within a piece is: headword run, sense1 run, sense2 run, ... , [image1 run, caption1 run, copyright&license1 run], [image2 run, caption2 run, copyright&license2 run]... In other words, if a piece contains more than one image, they will all be adjacent. Since we need empty paragraphs added between the [] textframe chunks, this corresponds to adding an empty paragraph immediately before any image run that is not the first image run.

Change-Id: Ida735978efdc85c5c8df2038e99110d6e28ee8f5
Copy link
Contributor

@mark-sil mark-sil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed all commit messages.
Reviewable status: 1 of 2 files reviewed, 2 unresolved discussions (waiting on @aror92)

Copy link
Contributor Author

@aror92 aror92 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 3 files reviewed, 2 unresolved discussions (waiting on @mark-sil)


Src/xWorks/LcmWordGenerator.cs line 6 at r1 (raw file):

Previously, mark-sil (Mark Kidder) wrote…

Probably remove.

Done.


Src/xWorks/LcmWordGenerator.cs line 310 at r1 (raw file):

Previously, mark-sil (Mark Kidder) wrote…

Nice catch! This fixes some of the problems I was seeing with styles not being applied.

Done. Thanks!


Src/xWorks/WordStylesGenerator.cs line 335 at r1 (raw file):

Previously, mark-sil (Mark Kidder) wrote…

Should this be removed?

Done.

Copy link
Contributor

@mark-sil mark-sil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 3 files at r3, 2 of 2 files at r4, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @aror92)

Copy link
Contributor

@mark-sil mark-sil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @aror92)

Change-Id: Ibd4aa655e630c8195ab238e8c6c618c579ba7d98
Copy link
Contributor

@mark-sil mark-sil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 1 files at r5, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @aror92)

@aror92 aror92 merged commit 81f697a into release/9.1 Apr 24, 2024
5 checks passed
@aror92 aror92 deleted the feature/caption branch April 24, 2024 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants