Coder Social home page Coder Social logo

Comments (11)

neolord0 avatar neolord0 commented on July 21, 2024

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).

from hwplib.

zuoliang0 avatar zuoliang0 commented on July 21, 2024

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 ?

from hwplib.

neolord0 avatar neolord0 commented on July 21, 2024

yes. I want you to send them.

from hwplib.

zuoliang0 avatar zuoliang0 commented on July 21, 2024

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

from hwplib.

zuoliang0 avatar zuoliang0 commented on July 21, 2024

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.

from hwplib.

zuoliang0 avatar zuoliang0 commented on July 21, 2024

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

from hwplib.

neolord0 avatar neolord0 commented on July 21, 2024

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.

from hwplib.

zuoliang0 avatar zuoliang0 commented on July 21, 2024

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 ?

from hwplib.

zuoliang0 avatar zuoliang0 commented on July 21, 2024

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.

from hwplib.

zuoliang0 avatar zuoliang0 commented on July 21, 2024

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

from hwplib.

neolord0 avatar neolord0 commented on July 21, 2024

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
[email protected]

from hwplib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.