Skip to content

fix(hwpx): keep the captions of text boxes, shapes and group members - #2107

Open
RionHwang0 wants to merge 1 commit into
KnifeLemon:mainfrom
RionHwang0:fix/hwpx-shape-captions
Open

RionHwang0 wants to merge 1 commit into
KnifeLemon:mainfrom
RionHwang0:fix/hwpx-shape-captions

Conversation

@RionHwang0

Copy link
Copy Markdown
Contributor

What does this change?

HwpxReader reads a caption only from hp:pic. In 한글 any drawing object can carry one, and in a group each member keeps its own, so captions on text boxes and shapes were dropped on every route that reads HWPX with Filee's own reader. That covers HWPX → DOCX, HTML, EPUB and the other formats DocumentReaders writes, and HWPX translation.

Affected:

  • text boxes and shapes: hp:rect, hp:ellipse, hp:polygon, ...
  • members of a group (hp:container), including pictures inside a group

I found this by reading 198 public HWPX files (government press releases and a few synthetic files) with HwpxReader and comparing the text with the hp:t text of each section. One press release (a cost table drawn as grouped boxes with captions such as "* 포괄수가 380만 원 + 치료재료 55만 원") lost 12 paragraphs, all of them shape captions. With this change that file reads complete. Its text is the only output that changes across the 198 files (it appears twice in the set).

What changed:

  • DrawingObject calls a new AddCaptions for every drawing object. It adds the object's own caption and, for a group, each member's caption in member order.
  • ParagraphBuilder.AddPictureCaption is renamed to AddObjectCaption, and its field to _objectCaptions. The behaviour is the same: captions follow the complete anchor paragraph, as picture captions already do since fix(hwp): keep picture captions when converting to DOCX #2080.

Type of change

  • Bug fix
  • New feature or improvement
  • New format or engine
  • Translation
  • Documentation
  • Build, CI or dependencies

How was it tested?

  • dotnet format --verify-no-changes
  • dotnet test tests/Filee.Engines.Tests --filter "FullyQualifiedName~Hwpx|FullyQualifiedName~Hwp|FullyQualifiedName~Docx|FullyQualifiedName~NestingLimit": 275 passed, 27 skipped. Three tests fail the same way on main here: two PandocMarkupTests (local pandoc version) and DocxNoteMarksTests.The_number_stays_inside_its_brackets_in_the_pdf.
  • New test HwpxReaderTests.A_text_box_caption_follows_its_anchor_paragraph_also_in_a_group. It writes a document with a text box through HwpxWriter, adds a caption to the hp:rect (once as is, once with the box wrapped in an hp:container), reads it back and checks that the caption is the paragraph right after the anchor paragraph, before the next paragraph. Both cases fail on main.
  • The 198-file comparison above.
  • Tried it in the app: ran on Linux through the engine test fixture only.

Checklist

  • New UI strings are in all src/Filee.App/Assets/i18n/*.json files (none added)
  • New third-party code or binaries are listed in THIRD-PARTY-NOTICES.md (none added)
  • The PR does one thing (unrelated changes go in a separate PR)

CHANGELOG lines (for your CHANGELOG PR):

- **Captions of text boxes and grouped objects kept from HWPX.** HWPX → DOCX, HTML, EPUB and the other formats keep the caption of a text box, a shape or an object in a group, after its paragraph, like a picture's caption.
ko: HWPX를 DOCX·HTML·EPUB 등으로 바꿀 때 글상자·도형·묶음 개체의 캡션도 남겨요
en: HWPX to DOCX, HTML, EPUB and more keep the captions of text boxes, shapes and grouped objects

HwpxReader kept a caption only on hp:pic, so the caption of a text box or other
shape (hp:rect, hp:ellipse, ...) and of every member of a group (hp:container) was
dropped on HWPX → DOCX, HTML, EPUB and the other routes that read HWPX with
Filee's own reader. Every drawing object's caption now follows its anchor
paragraph, as a picture's already does.

@KnifeLemon KnifeLemon left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks, and the 198-file comparison is a good way to find this. Reading the caption of every drawing object, and of each member of a group in member order, matches what 한글 allows. AddCaptions walks containers the same way Group already does, so it adds no new depth exposure. The rename to AddObjectCaption reads better too. I'll merge main, add the CHANGELOG line under 2.6.0 Fixes after #2105 and #2106, and merge once CI is green.

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.

2 participants