Document layout method, apparatus and device

By determining the scope of hierarchical reformatting based on editing information when editing documents on mobile devices, and reformatting images, tables, paragraphs, and page elements separately, the problem of long editing time on mobile devices is solved, and the user experience is improved.

CN116341496BActive Publication Date: 2026-05-08UC MOBILE CHINA CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
UC MOBILE CHINA CO LTD
Filing Date
2022-11-17
Publication Date
2026-05-08

AI Technical Summary

Technical Problem

In existing technologies, when editing office documents on mobile devices, the process of reformatting the entire document after each edit takes a long time, leading to problems such as lag.

Method used

By obtaining editing information, the hierarchical reformatting scope of the document is determined, including image element level, table element level, paragraph element level, text box element level, and page element level. These scopes are then reformatted separately to avoid global reformatting of the entire document.

Benefits of technology

It effectively reduced the time spent on reflowing, decreased lag, and improved the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116341496B_ABST
    Figure CN116341496B_ABST
Patent Text Reader

Abstract

The application discloses a document layout method, device and equipment. The method comprises the following steps: obtaining editing information of a document edited by a mobile terminal; determining a hierarchical rearrangement range of the document according to the editing information, wherein the hierarchical rearrangement range comprises at least one rearrangement range of the following levels: a picture element level, a table element level, a paragraph element level, a text box element level and a page element level; and performing layout on the hierarchical rearrangement range in the document. By using the processing manner, the document rearrangement is controlled in a small range, so that the time consumption of the rearrangement can be effectively reduced, and the problem of affecting the user experience, such as lag, is avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of mobile application technology, specifically to document typesetting methods and apparatus, and electronic devices. Background Technology

[0002] With the continuous development of mobile technology, editing office documents via mobile devices has become widely used. Real-time editing of office documents emphasizes WYSIWYG (What You See Is What You Get), and the performance of reformatting office documents edited on mobile devices is a crucial factor affecting the mobile user experience.

[0003] A typical way to reformat office documents edited on mobile devices is to reformat the entire document after each edit. However, this approach has at least the following problems: when dealing with large documents, reformatizing the entire document after each edit is very time-consuming, leading to lag and other issues. Summary of the Invention

[0004] This application provides a document typesetting method to address the problem of low reformatting performance in mobile document editing applications. This application also provides a document typesetting device and an electronic device.

[0005] This application provides a document formatting method, including:

[0006] Obtain editing information for documents edited via mobile devices;

[0007] Based on the editing information, the hierarchical reformatting range of the document is determined. The hierarchical reformatting range includes at least one of the following levels: image element level, table element level, paragraph element level, text box element level, and page element level.

[0008] The hierarchical reformatting range within the document is reformatted.

[0009] Optionally, the hierarchical reformatting scope includes the target paragraph, the target paragraph includes text-wrapped document elements, the text-wrapped document elements are document elements with text wrapping, and the text-wrapped document elements include: text-wrapped images and / or text-wrapped tables.

[0010] The step of formatting the hierarchical reformatting range within the document includes:

[0011] Retrieve the text-wrapped document element;

[0012] Determine the layout position information of the text-wrapped document element;

[0013] For a text line in the target paragraph, if the text line overlaps with the text-wrapping document element, the layout position information of the text line is determined based on the layout position information and text wrapping method information of the text-wrapping document element.

[0014] The text-wrapping document element is formatted according to its layout position information; and the text line is formatted according to its layout position information.

[0015] Optional, also includes:

[0016] Obtain the vertical position information of the text line and the vertical position range information of the text-wrapping document element;

[0017] If the vertical position range information includes the vertical position information, then it is determined that there is an overlap between the text line and the text-wrapping document element.

[0018] Optionally, the target paragraph may include multiple text-wrapped document elements;

[0019] The method further includes:

[0020] If at least two text-wrapping document elements are connected or partially overlap, and the text wrapping style of the at least two text-wrapping document elements is the same, then the at least two text-wrapping document elements are merged.

[0021] Determining the layout position information of the text line based on the layout position information and text wrapping style information of the text-wrapped document element includes:

[0022] The layout position information of the text line is determined based on the layout position information and text wrapping method information of the merged text-wrapping document element.

[0023] Optionally, the text line overlaps with multiple text-wrapped document elements;

[0024] Determining the layout position information of the text line based on the layout position information and text wrapping style information of the text-wrapped document element includes:

[0025] Get the first text-wrapping document element that overlaps with the text line and has the first text wrapping style of four-sided and the text wrapping style of right-side, and the second text-wrapping document element that overlaps with the text line and has the first text wrapping style of four-sided and the text wrapping style of left-side.

[0026] The right position of the first text-wrapping document element is used as the horizontal starting point position information of the text line, and the left position of the second text-wrapping document element is used as the horizontal ending point position information of the text line element.

[0027] Optionally, the area containing the target paragraph includes the following areas: body text, header, footer, and table;

[0028] The information of text-wrapped document elements in target paragraphs located in different areas is stored in different text-wrapped document element sets.

[0029] Optionally, determining the hierarchical reformatting range of the document based on the editing information includes:

[0030] Obtain the document element corresponding to the edited information, wherein the document element includes one of the following elements: image element, table element, paragraph element, text box element;

[0031] The scope of the hierarchical reformatting is defined to include the document elements.

[0032] Optionally, determining the hierarchical reformatting range of the document based on the editing information includes:

[0033] If the editing information is text, then the scope of the hierarchical reformatting is determined to include the paragraph to which the text belongs.

[0034] Optionally, determining the hierarchical reformatting range of the document based on the editing information further includes:

[0035] Obtain the height change information of the paragraph;

[0036] If the height change information indicates a change in paragraph height, then determine whether the text is located within the text box;

[0037] If the text is located within a text box and the text box is a floating image, then the hierarchical reflow range is determined to include the text box, and the text wrapping method of the floating image includes: the image is placed below the text or the image is placed above the text.

[0038] Optionally, determining the hierarchical reformatting range of the document based on the editing information further includes:

[0039] If the text is not located within a text box, then the scope of the hierarchical reformatting includes the page to which the paragraph belongs.

[0040] Optionally, determining the hierarchical reformatting range of the document based on the editing information further includes:

[0041] If there are other pages whose layout is affected by the page reflow, then the scope of the hierarchical reflow is determined to include those other pages.

[0042] Optionally, the step of formatting the hierarchical reformatting range within the document includes:

[0043] The page is formatted using the main document editing thread;

[0044] Start a child thread;

[0045] The other pages are formatted using the sub-thread.

[0046] Optionally, determining the hierarchical reformatting range of the document based on the editing information includes:

[0047] If the edited information is a floating text image, then the scope of the hierarchical reflow is determined to include the floating text image;

[0048] The step of formatting the hierarchical reformatting range within the document includes:

[0049] Reposition the floating text image.

[0050] Optionally, determining the hierarchical reformatting range of the document based on the editing information further includes:

[0051] Obtain the width and / or height change information of the floating text image;

[0052] Determine whether the floating text image contains a text box;

[0053] If the width change information and / or height change information change, and the floating text image contains a text box, then the hierarchical reflow range is determined to include the text box.

[0054] Optionally, determining the hierarchical reformatting range of the document based on the editing information includes:

[0055] If the edited information is an embedded image or a text-wrapped image, then the scope of the hierarchical reflow is determined to include the page to which the embedded image or text-wrapped image belongs.

[0056] This application also provides a document formatting method, including:

[0057] Get the text-wrapped document elements in the paragraph to be formatted. The text-wrapped document elements are document elements with text wrapping, including: text-wrapped images and / or text-wrapped tables.

[0058] Determine the layout position information of the text-wrapping document element;

[0059] For the text lines in the paragraph to be formatted, if the text lines overlap with the text-wrapping document elements, the formatting position information of the text lines is determined based on the formatting position information and text wrapping method information of the text-wrapping document elements.

[0060] The text-wrapping document element is formatted according to its layout position information; and the text line is formatted according to its layout position information.

[0061] This application also provides a document typesetting apparatus, including:

[0062] The wrapping element acquisition unit is used to acquire text-wrapping document elements in the paragraph to be formatted. The text-wrapping document elements are document elements with text wrapping, including: text-wrapping images and / or text-wrapping tables.

[0063] A text-wrapped document element position determination unit is used to determine the layout position information of the text-wrapped document element;

[0064] The text position determination unit is used to determine the layout position information of the text line in the paragraph to be formatted if the text line overlaps with the text-wrapping document element, based on the layout position information and text wrapping method information of the text-wrapping document element.

[0065] The typesetting unit is used to type the text-wrapping document element according to the typesetting position information of the text-wrapping document element; and to type the text line according to the typesetting position information of the text line.

[0066] Optionally, the paragraph to be formatted includes multiple text-wrapping document elements;

[0067] The device further includes:

[0068] A text-wrapping document element merging unit is used to merge at least two text-wrapping document elements if they are connected or partially overlapped and the text wrapping methods of the at least two text-wrapping document elements are the same.

[0069] The text position determination unit is specifically used to determine the layout position information of the text line based on the layout position information and text wrapping method information of the merged text wrapping document element.

[0070] Optionally, the text line overlaps with multiple text-wrapped document elements;

[0071] The text position determination unit is specifically used to obtain a first text-wrapping document element that overlaps with the text line and whose first text wrapping style is four-sided and whose right-side text wrapping is also present, and a second text-wrapping document element that overlaps with the text line and whose first text wrapping style is four-sided and whose left-side text wrapping is also present.

[0072] The right position of the first text-wrapping document element is used as the horizontal starting point position information of the text line, and the left position of the second text-wrapping document element is used as the horizontal ending point position information of the text line element.

[0073] This application also provides a document typesetting apparatus, including:

[0074] The editing information acquisition unit is used to acquire editing information of documents edited via mobile devices;

[0075] The hierarchical reformatting range determination unit is used to determine the hierarchical reformatting range of the document based on the editing information. The hierarchical reformatting range includes at least one reformatting range of the following levels: image element level, table element level, paragraph element level, text box element level, and page element level.

[0076] A hierarchical layout unit is used to layout the hierarchical reformatting range within the document.

[0077] This application also provides an electronic device, including:

[0078] Processor and memory;

[0079] The memory is used to store programs that implement any of the above document layout methods, and the device is powered on and the program of the method is run by the processor.

[0080] This application also provides a computer-readable storage medium storing instructions that, when executed on a computer, cause the computer to perform the various methods described above.

[0081] This application also provides a computer program product including instructions that, when run on a computer, cause the computer to perform the various methods described above.

[0082] Compared with the prior art, this application has the following advantages:

[0083] The document formatting method provided in this application obtains editing information of a document edited on a mobile device; based on the editing information, it determines the hierarchical reformatting range of the document, which includes at least one of the following levels: image element level, table element level, paragraph element level, text box element level, and page element level; and formats the hierarchical reformatting range within the document. This approach keeps document reformatting within a small scope, effectively reducing reformatting time and avoiding issues such as lag that negatively impact user experience.

[0084] The document layout method provided in this application involves obtaining text-wrapped document elements in a paragraph to be layouted. These text-wrapped document elements include text-wrapped images and / or text-wrapped tables. The method then determines the layout position information of the text-wrapped document elements. For text lines in the paragraph to be layouted, if the text line overlaps with the text-wrapped document element, the layout position information of the text line is determined based on the layout position information and text wrapping method information of the text-wrapped document element. The text-wrapped document element is then layoutd based on its layout position information. Finally, the text line is layoutd based on its layout position information. This approach allows for the layout of text-wrapped images or tables first, followed by line-by-line layout of the text surrounding the image. This avoids text that cannot wrap around to the beginning of the paragraph, thus effectively improving the effect of mixed text and image layouts, as well as the effect of mixed table and text layouts. Attached Figure Description

[0085] Figure 1 A flowchart illustrating the document formatting method provided for this application;

[0086] Figure 2 A schematic diagram illustrating the application scenario of the document formatting method provided in this application;

[0087] Figure 3 A schematic diagram of the system architecture for the document typesetting method provided in this application;

[0088] Figure 4a , Figure 4b , Figure 4c A diagram illustrating the document editing method used in this application for document formatting;

[0089] Figure 5a , Figure 5b , Figure 5c , Figure 5d A schematic diagram illustrating the text and image layout method provided in this application;

[0090] Figure 6 This application provides a flowchart illustrating the document formatting method. Detailed Implementation

[0091] Many specific details are set forth in the following description to provide a full understanding of this application. However, this application can be implemented in many other ways different from those described herein, and those skilled in the art can make similar extensions without departing from the spirit of this application; therefore, this application is not limited to the specific embodiments disclosed below.

[0092] This application provides a document typesetting method and apparatus, as well as an electronic device. The various solutions are described in detail in the following embodiments.

[0093] First Embodiment

[0094] Please refer to Figure 1 This is a flowchart illustrating an embodiment of the document formatting method of this application. In this embodiment, the method may include the following steps:

[0095] Step S101: Obtain editing information for documents edited via mobile device.

[0096] In this embodiment, the user edits a document via a mobile device. This type of document is a formatted document, specifically a text document (such as a Word document), a spreadsheet document (such as an Excel document), a presentation (such as a PowerPoint document), etc. The mobile device can be a smartphone, tablet, or other mobile device.

[0097] Users can view and edit documents through mobile applications or mobile browsers installed on their mobile devices. These mobile applications can be various applications such as cloud storage or instant messaging; therefore, in this embodiment, the document editing environment is not the computer software used to create the document (such as Office or WPS Office). Figure 2 As shown, users can open and edit office documents in the cloud storage application. Documents opened in the cloud storage application can exist in the form of native pages.

[0098] In this embodiment, the mobile application or mobile browser that can browse and edit documents includes not only the basic functional modules of the mobile application or browser, but also a document editing module, which is used to display and edit documents. Figure 3 The available architecture of the document editing module is shown, which may include the following layers: user interface interaction layer, data layer, layout layer, rendering layer, and write-back layer.

[0099] The user interface interaction layer displays document content, cursor status, text selection, and image selection states, providing corresponding interactions to facilitate text and image editing for users. The user interface interaction layer may include the user interface layer, cursor controller, text selection controller, and image focus controller. For example... Figure 4a As shown, the cursor controller is used to maintain the cursor state and for interaction; as Figure 4b As shown, the text selection controller is used to maintain the text selection state and interaction; for example... Figure 4c As shown, the image focus controller is used to maintain the image selection state and interaction.

[0100] Depend on Figure 3 As can be seen, the data layer may include the following modules: data editing, data maintenance, and rollback / redo. The data editing module is used to modify data in the document after the user performs editing operations. Specifically, the input manager manages user editing operations, such as entering text, inserting images, and performing paste operations, and processes the corresponding data based on these operations; the element editor is used to edit text in paragraph and leaf elements, such as inserting, deleting, and replacing text; the attribute editor is used to edit text attributes, such as bold, italic, and underline; and the image editor is used to edit image information, such as moving images and modifying their width and height.

[0101] The data maintenance module is used to maintain the data representation of document content. A document can be composed of multiple paragraph elements and table elements. A paragraph element is composed of multiple leaf elements and image elements. A leaf element represents a paragraph of text, and an image element represents an image.

[0102] The rollback / redo module records every editing action a user takes. Each editing action corresponds to a command type, such as inserting text, deleting text, or moving an image. Each editing action is recorded in the rollback / redo stack. When a user performs a rollback or redo, the rollback / redo manager retrieves the most recent editing action and executes the corresponding rollback / redo operation.

[0103] The layout layer is used to perform layout work on the various elements in the document. It calculates the coordinates and dimensions of each paragraph, table, and image. Only after the layout is complete can the document content be rendered to the screen. The layout layer may include the following modules: layout controller, page layout, paragraph layout, and table layout.

[0104] The reformatting controller is used to determine the hierarchical reformatting range of the document based on the editing information; and to call the modules corresponding to each level of reformatting range. For example, if the hierarchical reformatting range includes paragraphs corresponding to the text edited by the user, then paragraph reformatting is called.

[0105] The rendering layer is used to render the text and images in the document onto the screen. After layout, the coordinates, width, and height of each paragraph, table, and image can be known, and the text and images can be rendered in the corresponding positions based on this information.

[0106] The write-back layer is used to rewrite the user-edited content into a new file, essentially performing a file save. When editing documents on a mobile device, a document with the .docx extension is essentially a zip file, composed of multiple files, each in XML format. Therefore, the .docx document editor controls the write-back operation for each file within the zip file. Because each file is in XML format, the write-back of each file is controlled by an XML stream writer (XMLStreamWriter).

[0107] The DocumentFileWriter is used to write back the document.xml file inside the docx document. This file contains a... <document>Document tags consist of text tags, which in turn are composed of paragraphs, each paragraph being a separate element. The `` tag (paragraph tag) is composed of multiple text tags and image tags. Therefore, the function of `DocumentFileWriter` is to write back the data of paragraph elements, leaf elements, image elements, etc., as corresponding XML tags and then write them back to the file. After writing back each file within the `.docx` document, they can be packaged and compressed into a single `.docx` document, thus completing the file saving function.

[0108] Step S103: Determine the hierarchical reformatting range of the document based on the editing information.

[0109] The hierarchical reformatting scope includes at least one of the following levels: image element level, table element level, paragraph element level, text box element level, and page element level. The parent document element of image elements, table elements, paragraph elements, and text box elements can be page elements, and a document can include multiple page elements.

[0110] In this embodiment, step S103 may include the following sub-steps:

[0111] Step S1031: Obtain the document element corresponding to the editing information.

[0112] The document elements include one of the following: image elements, table elements, paragraph elements, and text box elements.

[0113] Step S1033: Determine that the scope of the hierarchical reformatting includes the document elements.

[0114] In practice, if the layout change of a document element corresponding to the editing information affects the layout of the parent document element, then it can be determined that the hierarchical reflow scope also includes the parent document element. It can be determined whether the layout change of each document element will affect the layout change of the parent document element, down to the document level element.

[0115] Step S105: Format the hierarchical reformatting range within the document.

[0116] This step avoids reformatting the entire document by reformatting the scope of each level.

[0117] In one example, step S103 may include the following sub-step: if the editing information is text, then determine that the hierarchical reformatting scope includes the paragraph to which the text belongs; correspondingly, step S105 may include the following sub-step: reformat the paragraph to which the text belongs. Figure 2 As shown in the right image, when the user only enters a few words that will not affect other paragraphs, only that paragraph will be reformatted.

[0118] In practical applications, the paragraph to which the user-edited text belongs can be located within a text box or within the page. In this case, step S103 may further include the following sub-steps: obtaining the height change information of the paragraph, such as if the height of the paragraph to which the user-edited text belongs before reformatting is h1, and the height of the paragraph after reformatting is h2, then the height change is the difference between h2 and h1; if the height change information indicates a change in paragraph height, then determining whether the text is located within a text box; if the text is located within a text box, and the text box is a floating text image, then determining that the hierarchical reformatting range includes the text box; if the text is not located within a text box, then determining that the hierarchical reformatting range includes the page to which the paragraph belongs. The floating text image refers to an image whose text wrapping mode is below or above the text. Correspondingly, step S105 may include the following sub-steps: reformatting the text box or the page.

[0119] Floating text images can be positioned freely. In contrast, embedded images are placed on the same line as the text, and their position cannot be changed. Floating text images are images that do not wrap around the text; they do not affect the text's layout, while images that wrap around the text (also known as text-wrapping images) will. Text wrapping images can be done in various ways, such as wrapping around the text on all sides, wrapping top and bottom, wrapping tightly, or wrapping through the text.

[0120] In practice, Figure 3 The paragraph reflow module can perform the following steps: obtain the paragraph element edited by the user; find the old paragraph view corresponding to the paragraph element; clear the information of the old paragraph view; re-execute paragraph reflow; recalculate the position, width and height information of the text and images in the paragraph; obtain the information of the new paragraph view; determine whether the height of the paragraph view before and after has changed. If it has changed, execute page reflow; otherwise, the reflow is completed.

[0121] In practice, page reflow can be performed as follows: clear the information of the old page view; obtain the first paragraph of the current page; start the reflow from the first paragraph until the current page is full of text / images and there is no space to reflow other content, or until all content is reflowed and the information of the new page view is obtained; determine whether the new page view matches the next page after the reflow, that is, whether the next page can retain the original content without reflowing. If so, the reflow is complete; otherwise, the reflow of the next page is performed.

[0122] In practical applications, user-edited text not only affects the paragraph and corresponding page it resides in, but may also influence the layout of subsequent pages. In this case, step S103 may further include the following sub-step: if there are other pages whose layout is affected by the page reflow, then determine that the hierarchical reflow scope includes the other pages. Other pages may include one or more pages following the currently visible page. Correspondingly, step S105 may further include the following sub-step: formatting the other pages.

[0123] In one example, step S105 can be implemented as follows: The page is formatted using the main document editing thread; a sub-thread is started; and the other pages are formatted using the sub-thread. Real-time editing emphasizes WYSIWYG (What You See Is What You Get). When the content edited by the user affects the entire document, the re-formatting of the currently visible page can be completed only on the main thread, typically within 50 milliseconds. Simultaneously, a sub-thread is started to complete the re-formatting of subsequent pages. Although re-formatting the currently visible page takes slightly longer than re-formatting paragraphs, there is no noticeable lag, and a good editing experience is still provided to the user.

[0124] In practical applications, the content edited by the user can be not only text, but also floating images that do not wrap around text. In this embodiment, such images are referred to as floating text images, meaning that the text wraps around the image either below or above the text. In this case, step S103 may include the following sub-step: if the edited information is a floating text image, then determine that the hierarchical reflow range includes the floating text image; correspondingly, step S105 may include the following sub-step: reposition the floating text image.

[0125] A floating text image may contain text boxes where the user can edit text. In this case, step S103 may further include the following sub-steps: obtaining the width change information and / or height change information of the floating text image, and determining whether the floating text image contains text boxes; if the width change information and / or height change information change and the floating text image contains text boxes, then determining that the hierarchical reflow range includes the text boxes; correspondingly, step S105 may include the following sub-step: laying out the text boxes present in the floating text image.

[0126] In practical applications, the content edited by the user can be not only text or floating text images, but also text-wrapped images or embedded images. In this case, step S103 may include the following sub-step: if the edited information is an embedded image or a text-wrapped image, then determine that the hierarchical reflow range includes the page to which the embedded image or text-wrapped image belongs; correspondingly, step S105 may include the following sub-step: reflow the page.

[0127] In practice, table reflow is part of page reflow and can be performed as follows: clear the information of the old table view; obtain the information of the first row of the table on the current page (the table may have been partially formatted on the previous page); start formatting from the first row, and perform formatting on each cell and its internal text, images, and other elements; after the formatting is completed, continue to perform reflowing on the subsequent paragraphs.

[0128] In one example, the hierarchical reflow scope includes a target paragraph, which includes text-wrapped document elements. These text-wrapped document elements include text-wrapped images and / or text-wrapped tables. Taking a text-wrapped image as an example, the text wrapping style can be square, tight, through, or top-bottom. The target paragraph can be located in the body text, header, footer, or table. Different paragraphs can be located in different areas or the same area, such as paragraph A in the body text, and paragraphs B and C in the header. In this case, step S105 may include the following sub-steps:

[0129] Step S1051: Obtain the text-wrapped document element.

[0130] In this embodiment, information about text-wrapping document elements located in different areas can be stored in different text-wrapping document element sets. For example, images in the body text are stored in set 1, images in the header are stored in set 2, and so on. This step can retrieve the text-wrapping document elements included in the target paragraph from the text-wrapping document element set corresponding to the area where the target paragraph is located. The target paragraph may include 0, 1, or more text-wrapping document elements.

[0131] Step S1053: Determine the layout position information of the text-wrapping document element.

[0132] In this embodiment, the layout position information of text-wrapped document elements in the target paragraph can be determined based on the target position of the target paragraph.

[0133] In practice, the target starting position (including horizontal and vertical starting positions) of the text-wrapping document element can be determined based on the target starting position of the target paragraph (including horizontal and vertical starting positions) and the position of the text-wrapping document element relative to the paragraph's starting point (including horizontal and vertical relative positions). The text-wrapping document element may also include width and height information. The layout position information of the text-wrapping document element may include its target starting position, as well as its width and height information.

[0134] Step S1055: For a text line in the target paragraph, if the text line overlaps with the text-wrapping document element, then determine the layout position information of the text line based on the layout position information and text wrapping method information of the text-wrapping document element.

[0135] After determining the layout position of text-wrapping document elements in the target paragraph through steps S1053 and S1054, this step S1055 determines the text layout position information line by line in the target paragraph. Taking a text-wrapping graphic as an example, the lines included in the target paragraph can be text lines wrapping around the graphic or text lines not wrapping around the graphic. The text lines can contain text, and the layout position information of the text lines includes the horizontal start position information and the horizontal end position information of the text in that line. By adopting this processing method of first laying out the graphic and then laying out the text, it is possible to avoid text that cannot wrap around the beginning of the paragraph, ensuring that the graphic is correctly wrapped by the text.

[0136] In this embodiment, the following method can be used to determine whether any line of text in the target paragraph overlaps with a text-wrapped document element: obtain the vertical position information of the text line and the vertical position range information of the text-wrapped document element; if the vertical position range information includes the vertical position information, then it is determined that the text line and the text-wrapped document element overlap.

[0137] If the currently processed text line does not overlap with the text-wrapped document element, the horizontal start and end positions of the currently processed text line can be determined based on the indentation information of the target paragraph. The paragraph indentation information may include the first-line indent (e.g., 2 characters), left indent (e.g., 0 characters), and right indent (e.g., 0 characters). For example, if the first line of text does not overlap with the text-wrapped image, the horizontal start position of the first line can be an indent of 2 characters, and the horizontal end position can be a right indent of 0 characters. If the fifth line of text does not overlap with the text-wrapped image, the horizontal start position of the fifth line can be a left indent of 0 characters, and the horizontal end position can be a right indent of 0 characters.

[0138] If the currently processed text line overlaps with a text-wrapped image, the layout position of the text line can be determined based on the layout position information and text wrapping style information of the text-wrapped image. Specifically, the layout position of the text line can be determined based on the horizontal starting position information and text wrapping style information of the text-wrapped image, as well as the width and height information of the text-wrapped image.

[0139] Taking text-wrapped images as an example, in practical applications, any line of text in the target paragraph that overlaps with a text-wrapped image can overlap with multiple text-wrapped images, such as... Figure 5a , 5b As shown in 5c and 5d.

[0140] Figure 5a This indicates that two text-wrapping images are connected or partially overlapped, and both images have a four-sided wrapping style with text wrapped around both sides. In this case, reformatting the target paragraph may further include the following sub-step: if at least two text-wrapping images are connected or partially overlapped, and the text wrapping styles of the at least two text-wrapping images are the same, then merge the at least two text-wrapping images, that is, merge these text-wrapping images into one text-wrapping image. Accordingly, the step of determining the layout position information of the text line based on the layout position information and text wrapping style information of the text-wrapping images can be implemented as follows: determine the layout position information of the text line based on the layout position information and text wrapping style information of the merged text-wrapping images. Figure 5a As shown, in specific implementation, the text line's layout position information can include multiple pairs of horizontal start and end point positions for that line of text. This processing method simplifies the process of text-wrapping layout for multiple text-wrapping images to a single merged text-wrapping image; therefore, it effectively improves the efficiency of mixed text and image layout.

[0141] Figure 5b This indicates that two text-wrapped images are separated, and both images have text wrapping around the entire screen with the text wrapping on the right. Figure 5c This indicates that two text-wrapped images are separated, and both images have text wrapping around the left side. Figure 5d This indicates that two text-wrapping images are separated, and the text wrapping styles of these two text-wrapping images are different. The text wrapping style of the left image is four-sided with the text wrapping on the right, and the text wrapping style of the right image is four-sided with the text wrapping on the left. In these cases, determining the layout position information of the text line based on the layout position information and text wrapping style information of the text-wrapping images may include the following sub-steps: 1) Obtaining a first text-wrapping image whose last overlapping text with the text line has a four-sided wrapping style with the text wrapping on the right, and a second text-wrapping image whose first overlapping text with the text line has a four-sided wrapping style with the text wrapping on the left; 2) Using the right position of the first text-wrapping image as the horizontal starting position information of the text line, and using the left position of the second text-wrapping image as the horizontal ending position information of the text line element. The "right-sided" style refers to text wrapping on the right side of the image, and the "left-sided" style refers to text wrapping on the left side of the image.

[0142] For example, Figure 5b The right image in the image is the first text-wrapped image. The horizontal starting position information of the line that overlaps with this image can be the sum of the horizontal position information of this image and the width information of this image. The horizontal ending position information of this line is the right indentation information of the target paragraph (such as 0 characters).

[0143] For example, Figure 5c The left image in the image is the second text-wrapped image. The horizontal starting point position information of the line overlapping with this image is the left indentation information of the target paragraph (such as 0 characters). The horizontal ending point position information of this line can be the horizontal position information of the left image.

[0144] For example, Figure 5d The left image in the image is the first text-wrapped image, and the right image is the second text-wrapped image. The horizontal starting point position information of the row that overlaps with the image can be the sum of the horizontal position information of the left image and the width information of the left image. The horizontal ending point position information of the row can be the horizontal position information of the right image.

[0145] Step S1057: Arrange the text-wrapped image according to the layout position information of the text-wrapped image; and arrange the text line according to the layout position information of the text line.

[0146] Once the layout position information of the text-wrapping image is determined, it can be reformatted accordingly. For example, if the target position of the target paragraph is moved down four lines from its original position, the layout position of the text-wrapping image in that paragraph can be adjusted to four lines down. Similarly, once the layout position information of a line of text is determined, that line of text can be reformatted accordingly.

[0147] As can be seen from the above embodiments, the document layout method provided in this application obtains editing information of a document edited on a mobile device; determines the hierarchical layout range of the document based on the editing information, wherein the hierarchical layout range includes at least one of the following levels: image element level, table element level, paragraph element level, text box element level, and page element level; and formats the hierarchical layout range within the document. This approach keeps document layout within a small scope, thus effectively reducing layout time and avoiding issues such as lag that affect user experience.

[0148] Second Embodiment

[0149] In the above embodiments, a document typesetting method is provided. Correspondingly, this application also provides a document typesetting apparatus. This apparatus corresponds to the embodiments of the above method. The parts of this embodiment that are the same as those in the first embodiment will not be repeated; please refer to the corresponding parts in Embodiment 1.

[0150] This application provides a document typesetting device comprising: an editing information acquisition unit, a hierarchical reformatting range determination unit, and a hierarchical typesetting unit. The editing information acquisition unit is used to acquire editing information of a document edited via a mobile device; the hierarchical reformatting range determination unit is used to determine the hierarchical reformatting range of the document based on the editing information, wherein the hierarchical reformatting range includes at least one of the following levels: image element level, table element level, paragraph element level, text box element level, and page element level; and the hierarchical typesetting unit is used to typeset the hierarchical reformatting range within the document.

[0151] In one example, the hierarchical reformatting scope includes a target paragraph, which includes text-wrapped document elements. The text-wrapped document elements are document elements with text wrapping, including: text-wrapped images and / or text-wrapped tables; the hierarchical layout unit includes: a wrapping element acquisition unit, a text-wrapped document element position determination unit, a text position determination unit, and a layout unit.

[0152] The system includes: a wrapping element acquisition unit for acquiring the text-wrapping document element; a text-wrapping document element position determination unit for determining the layout position information of the text-wrapping document element; a text position determination unit for determining the layout position information of the text line based on the layout position information and text wrapping method information of the text line in the target paragraph if the text line and the text-wrapping document element overlap; a layout unit for layouting the text-wrapping document element based on its layout position information; and a text line for layouting the text line based on its layout position information.

[0153] In one example, the device further includes: a vertical position acquisition unit, configured to acquire vertical position information of the text line and vertical position range information of the text-wrapped document element; and a determination unit, configured to determine that the text line and the text-wrapped document element overlap if the vertical position range information includes the vertical position information.

[0154] In one example, the target paragraph includes multiple text-wrapping document elements; the device further includes: a text-wrapping document element merging unit, used to merge at least two text-wrapping document elements if they are connected or partially overlapped and the text wrapping methods of the at least two text-wrapping document elements are the same; and a text position determination unit, specifically used to determine the layout position information of the text line based on the layout position information and text wrapping method information of the merged text-wrapping document elements.

[0155] In one example, the text line overlaps with multiple text-wrapping document elements; the text position determination unit is specifically used to obtain a first text-wrapping document element that overlaps with the text line, whose first text wrapping style is four-sided and whose right-side text wrapping is also present, and a second text-wrapping document element that overlaps with the text line, whose first text wrapping style is four-sided and whose left-side text wrapping is also present; the right-side position of the first text-wrapping document element is used as the horizontal starting point position information of the text line, and the left-side position of the second text-wrapping document element is used as the horizontal ending point position information of the text line element.

[0156] In one example, the target paragraph area includes the following areas: body text, header, footer, and table; and a text-wrapping document element storage unit, used to store the information of text-wrapping document elements in the target paragraph located in different areas into different text-wrapping document element sets.

[0157] Third Embodiment

[0158] In the above embodiments, a document formatting method is provided. Correspondingly, this application also provides a document formatting method. This method corresponds to Embodiment 1 of the above method. The parts of this embodiment that are the same as those in the first embodiment will not be repeated here; please refer to the corresponding parts in Embodiment 1.

[0159] Please refer to Figure 6 This is a flowchart illustrating an embodiment of the document formatting method of this application. In this embodiment, the method may include the following steps:

[0160] Step S601: Obtain text-wrapping document elements in the paragraph to be formatted. The text-wrapping document elements are document elements with text wrapping, including: text-wrapping images and / or text-wrapping tables.

[0161] This step corresponds to step S1051 in Embodiment 1. For related explanations, please refer to the step S1051 section, which will not be repeated here.

[0162] The method provided in this application can be used to format paragraphs with mixed text and images when browsing documents on a mobile device, and can also be used to reformat paragraphs with mixed text and images when editing documents.

[0163] Step S603: Determine the layout position information of the text-wrapping document element.

[0164] This step corresponds to step S1053 in Embodiment 1. For related explanations, please refer to the step S1053 section, which will not be repeated here.

[0165] Step S605: For the text lines in the paragraph to be formatted, if the text lines overlap with the text-wrapping document elements, then determine the formatting position information of the text lines based on the formatting position information and text wrapping method information of the text-wrapping document elements.

[0166] This step corresponds to step S1055 in Embodiment 1. For related explanations, please refer to the step S1055 section, which will not be repeated here.

[0167] Step S607: Layout the text-wrapping document element according to its layout position information; and layout the text line according to its layout position information.

[0168] This step corresponds to step S1057 in Embodiment 1. For related explanations, please refer to the step S1057 section, which will not be repeated here.

[0169] As can be seen from the above embodiments, the document layout method provided in this application obtains text-wrapping document elements in the paragraph to be layouted. These text-wrapping document elements include text-wrapping images and / or text-wrapping tables. The method then determines the layout position information of the text-wrapping document elements. For text lines in the paragraph to be layouted, if the text line overlaps with the text-wrapping document element, the method determines the layout position information of the text line based on the layout position information and text wrapping method information of the text-wrapping document element. The method then typeset the text-wrapping document element based on its layout position information and typeset the text line based on its layout position information. This processing method allows for the layout of images or tables with text wrapping first, followed by the layout of the text wrapping the image line by line, avoiding text that cannot wrap around to the beginning of the paragraph. Therefore, it can effectively improve the mixed text and image layout effect and the mixed table and text layout effect.

[0170] Fourth embodiment

[0171] In the above embodiments, a document typesetting method is provided. Correspondingly, this application also provides a document typesetting apparatus. This apparatus corresponds to the embodiments of the above method. The parts of this embodiment that are the same as those in the first embodiment will not be repeated; please refer to the corresponding parts in Embodiment 1.

[0172] This application provides a document typesetting device comprising: a wrapping element acquisition unit, a text-wrapped document element position determination unit, a text position determination unit, and a typesetting unit. The wrapping element acquisition unit is used to acquire text-wrapped document elements in a paragraph to be typed, wherein the text-wrapped document elements are document elements with text wrapping, and the text-wrapped document elements include: text-wrapped images and / or text-wrapped tables; the text-wrapped document element position determination unit is used to determine the typesetting position information of the text-wrapped document elements; the text position determination unit is used to, for a text line in the paragraph to be typed, if the text line and the text-wrapped document element overlap, determine the typesetting position information of the text line based on the typesetting position information and text wrapping method information of the text-wrapped document element; and the typesetting unit is used to type the text-wrapped document elements according to the typesetting position information of the text-wrapped document elements; and to type the text lines according to the typesetting position information of the text lines.

[0173] In one example, the paragraph to be formatted includes multiple text-wrapping document elements; the device further includes: a text-wrapping document element merging unit, used to merge at least two text-wrapping document elements if they are connected or partially overlapped and the text wrapping methods of the at least two text-wrapping document elements are the same; and a text position determination unit, specifically used to determine the formatting position information of the text line based on the formatting position information and text wrapping method information of the merged text-wrapping document elements.

[0174] In one example, the text line overlaps with multiple text-wrapping document elements; the text position determination unit is specifically used to obtain a first text-wrapping document element that overlaps with the text line, whose first text wrapping style is four-sided and whose right-side text wrapping is also present, and a second text-wrapping document element that overlaps with the text line, whose first text wrapping style is four-sided and whose left-side text wrapping is also present; the right-side position of the first text-wrapping document element is used as the horizontal starting point position information of the text line, and the left-side position of the second text-wrapping document element is used as the horizontal ending point position information of the text line element.

[0175] Fifth embodiment

[0176] This application also provides an electronic device. Since the device embodiments are substantially similar to the method embodiments, the description is relatively simple; relevant details can be found in the description of the method embodiments. The device embodiments described below are merely illustrative.

[0177] An electronic device according to this embodiment includes a processor and a memory; the memory is used to store a program that implements any of the above-described document typesetting methods, and the device is powered on and runs the program of the method through the processor.

[0178] Although this application discloses preferred embodiments as described above, it is not intended to limit this application. Any person skilled in the art can make possible changes and modifications without departing from the spirit and scope of this application. Therefore, the scope of protection of this application should be determined by the scope defined in the claims of this application.

[0179] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0180] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.

[0181] 1. Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information by any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include non-transitory computer-readable media, such as modulated data signals and carrier waves.

[0182] 2. Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code. < / document>

Claims

1. A document formatting method, characterized in that, Applied to mobile applications or mobile browsers installed on mobile devices, including: Obtain editing information for documents edited via mobile devices; Determining the hierarchical reformatting range of the document based on the editing information includes: obtaining the document element corresponding to the editing information; determining that the hierarchical reformatting range includes the document element; when the layout change of the document element corresponding to the editing information affects the layout of the parent document element of the document element, the hierarchical reformatting range includes the parent document element of the document element; the hierarchical reformatting range includes at least one of the following levels of reformatting range: image element level, table element level, paragraph element level, text box element level, and page element level; The method of formatting the hierarchical reformatting range within the document includes: repositioning the floating text image if the hierarchical reformatting range is a floating text image; determining the formatting position information of the text lines within the target paragraph if the text lines and the text-wrapping document elements do not overlap, based on the indentation information of the target paragraph; the formatting position information of the text lines includes multiple pairs of horizontal start point position information and horizontal end point position information; and formatting the text lines according to the formatting position information of the text lines. The step of determining the hierarchical reformatization range of the document based on the editing information includes: If the edited information is a floating text image, then the scope of the hierarchical reflow is determined to include the floating text image; If the editing information is an embedded image or a text-wrapped image, then the scope of the hierarchical reflow is determined to include the page to which the embedded image or text-wrapped image belongs; If the editing information is text, then the hierarchical reflow range includes the paragraph to which the text belongs; obtain the height change information of the paragraph; if the height change information indicates a change in paragraph height, then determine whether the text is located within a text box; if the text is located within a text box and the text box is a floating text image, then the hierarchical reflow range includes the text box; if the text is not located within a text box, then the hierarchical reflow range includes the page to which the paragraph belongs.

2. The method according to claim 1, characterized in that, The hierarchical reformatting scope includes the target paragraph, which includes text-wrapped document elements. The text-wrapped document elements are document elements with text wrapping, including: text-wrapped images and / or text-wrapped tables. The step of formatting the hierarchical reformatting range within the document includes: Retrieve the text-wrapped document element; Determine the layout position information of the text-wrapped document element; For a text line in the target paragraph, if the text line overlaps with the text-wrapping document element, the layout position information of the text line is determined based on the layout position information and text wrapping method information of the text-wrapping document element. The text-wrapping document element is formatted according to its layout position information; and the text line is formatted according to its layout position information.

3. The method according to claim 2, characterized in that, Also includes: Obtain the vertical position information of the text line and the vertical position range information of the text-wrapping document element; If the vertical position range information includes the vertical position information, then it is determined that there is an overlap between the text line and the text-wrapping document element.

4. The method according to claim 2, characterized in that, The target paragraph includes multiple text-wrapped document elements; The method further includes: If at least two text-wrapping document elements are connected or partially overlap, and the text wrapping style of the at least two text-wrapping document elements is the same, then the at least two text-wrapping document elements are merged. Determining the layout position information of the text line based on the layout position information and text wrapping style information of the text-wrapped document element includes: The layout position information of the text line is determined based on the layout position information and text wrapping method information of the merged text-wrapping document element.

5. The method according to claim 2, characterized in that, The text lines overlap with multiple text-wrapped document elements; Determining the layout position information of the text line based on the layout position information and text wrapping style information of the text-wrapped document element includes: Get the first text-wrapping document element that overlaps with the text line and has the first text wrapping style of four-sided and the text wrapping style of right-side, and the second text-wrapping document element that overlaps with the text line and has the first text wrapping style of four-sided and the text wrapping style of left-side. The right position of the first text-wrapping document element is used as the horizontal starting point position information of the text line, and the left position of the second text-wrapping document element is used as the horizontal ending point position information of the text line.

6. The method according to claim 2, characterized in that, The target paragraph is located in the following areas: body text, header, footer, and table; The information of text-wrapped document elements in target paragraphs located in different areas is stored in different text-wrapped document element sets.

7. The method according to claim 1, characterized in that, The document elements include one of the following: image elements, table elements, paragraph elements, and text box elements.

8. The method according to claim 1, characterized in that, The text wrapping methods for the floating text image include: the image is placed below the text or the image is placed above the text.

9. The method according to claim 1, characterized in that, Determining the hierarchical reformatization range of the document based on the editing information further includes: If there are other pages whose layout is affected by the page reflow, then the scope of the hierarchical reflow is determined to include those other pages.

10. The method according to claim 9, characterized in that, The step of formatting the hierarchical reformatting range within the document includes: The page is formatted using the main document editing thread; Start a child thread; The other pages are formatted using the sub-thread.

11. A document formatting method, characterized in that, include: Get the text-wrapped document elements in the paragraph to be formatted. The text-wrapped document elements are document elements with text wrapping, including: text-wrapped images and / or text-wrapped tables. Determining the layout position information of the text-wrapping document element includes: determining the target starting position of the text-wrapping document element based on the target starting position of the paragraph to be formatted and the position of the text-wrapping document element relative to the paragraph starting point; the layout position information of the text-wrapping document element includes the target starting position, width information, and height information of the text-wrapping document element. For the text lines in the paragraph to be formatted, if the text lines overlap with the text-wrapping document elements, the formatting position information of the text lines is determined line by line based on the formatting position information and text wrapping method information of the text-wrapping document elements; if the text lines do not overlap with the text-wrapping document elements, the formatting position information of the text lines is determined based on the indentation information of the paragraph to be formatted; the formatting position information of the text lines includes multiple pairs of horizontal start position information and horizontal end position information. The text-wrapping document element is formatted according to its layout position information; and the text line is formatted according to its layout position information.

12. An electronic device, characterized in that, include: Processor and memory; A memory for storing a program for implementing the document typesetting method according to any one of claims 1-11, wherein the device is powered on and the program of the method is executed by the processor.