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

how to auto break or warp text line in table cell? #26

Closed
zuoliang0 opened this issue Jul 18, 2018 · 11 comments
Closed

how to auto break or warp text line in table cell? #26

zuoliang0 opened this issue Jul 18, 2018 · 11 comments

Comments

@zuoliang0
Copy link

how to make the cell content auto warp for cell width.
look like this :
image

i watch the file use 한워드 2018 create file they have two lineSegItem

image
and it have a textStartPositon
image
i want sure the textStartPositon is control the cell content line warp or maybe have other way ?

thank you .

@neolord0
Copy link
Owner

Hangul supports Text Wrapping by LineChange property in ListHeaderForTextBox Object.
The value of this attribute can be obtained as follows.

Section s = hwpFile.getBodyText().getSectionList().get(0);
Paragraph firstParagraph = s.getParagraph(0);
ControlRectangle rect = (ControlRectangle) firstParagraph.getControlList().get(2);
System.out.println(rect.getTextBox().getListHeader().getProperty().getLineChange());

If This property value is Normal, Texts have warpped.

And, I think LineSeqItem seems to store a pre-calculated value to draw a Hangul file quickly.
The text is drawn well without the LineSeqItem, except for the text line's space function.

LineSeqItem.textStartPosition is the text start position of the line represented by LineSeqItem in the full text of the paragraph. The figure above shows that the second line starts at index 2( zero-based).

@zuoliang0
Copy link
Author

ok, i find the cell's listHeader also have the ListHeaderPropertyForCell same setLineChange method .
i check the property is Normal
image

the file open look like:
image
i'am not use the text box just use the cell for contain text.

maybe i should be send the .hwp file and code for you ?

@neolord0
Copy link
Owner

yes. I want you to send them.

@zuoliang0
Copy link
Author

i test the text sure warped,but some word not show full
image

@zuoliang0
Copy link
Author

i find the problem, when i set the ParaShape for Paragraph the cell content will be not warp.

                ParaShape paraShape = hwpFile.getDocInfo().addNewParaShape();
		paraShape.getProperty1().setAlignment(Alignment.Left);
		int id = hwpFile.getDocInfo().getParaShapeList().size() - 1;
		ph.setParaShapeId(id);

but i don't know how fix it,
the new code has send for you mail.

@zuoliang0
Copy link
Author

hello ,do you receive my email? if you have any question you can give me feedback.
thank you

@neolord0
Copy link
Owner

TestMakingTableTextWarp.zip

According to my testing, we need a LineSegItem object for each line segmented for text-wrapping. However, the value of the TextStartPositon property in the LineSegItem object is hard to compute. So, I did not create any LineSegItem objects. And I set the value of the LineSpace property on the ParaShape object that is not in your code.

If you save this file again from Hangul, LineSegItem is automatically created.
Look at my attachment.

@zuoliang0
Copy link
Author

thank you.
i try you code ,it's work for auto text-wrapping.

you say

the TextStartPositon property in the LineSegItem object is hard to compute

it mean if i need set text wrapping by hand then must be compute the LineSegItem's TextStartPositon property ?

@zuoliang0
Copy link
Author

in my program i'm use the \n to mark break line,
so i just easy compute the postion.
image

this is my code:

private  void setLineBreak(String text,Paragraph firstParagraph, int width){
        ParaLineSeg lineSeg = firstParagraph.getLineSeg();
        if (text.contains("\n")) {
            int i =-1;
                while ((i=text.indexOf("\n", i+1 ))!=-1){
                LineSegItem lineSegItem = lineSeg.addNewLineSegItem();
                lineSegItem.setTextPartHeight(1000);
                lineSegItem.setStartPositionFromColumn(0);
                lineSegItem.setDistanceBaseLineToLineVerticalPosition(850);
                lineSegItem.setLineSpace(100);
                lineSegItem.setSegmentWidth(width);
                lineSegItem.setTextStartPositon(i);
                lineSegItem.getTag().setFirstSegmentAtLine(true);
                lineSegItem.getTag().setLastSegmentAtLine(true);
            }
        }

    }

thank you for you answer.

@zuoliang0
Copy link
Author

if you receive any donate, i wish do it.
such as digital cash: eth or bitcoin ete.

@neolord0
Copy link
Owner

In principle, the value of LineSegItem's TextStartPositon is the start of the string in a line break. If the string "ABCD EDFG" is divided as follows
ABCD
EDFG
Two LineSegItems are required, and TextStartPositon values must be set to 0 and 5, respectively.
Typical word processing programs do not need this value, but Hangul seems to be needed for quick drawing. To get the TextStartPositon value, you should actually draw the all paragraph attribute and the all character attribute on the string. It's awkward until you know well about word processor programming.

And your contribution will be appreciated.
I get my first donation. Thank you for giving me this experience.

BTC address
3JvZNB8P6CR3CEJmn3dDwasqjtDJRvD6qQ
neolord@hanmail.net

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

No branches or pull requests

2 participants