Collaborative editing document formatting method and device, equipment and storage medium
By prioritizing local layout of the visible area, the problems of low page rendering frame rate and high interaction response latency in collaborative document editing are solved, improving the collaborative editing experience and operation smoothness.
Patent Information
- Application Number
- CN202611129820.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-28
- Publication Date
- 2026-11-24
AI Technical Summary
When multiple people are collaboratively editing a document, the existing technology suffers from low page rendering frame rate and high interaction response latency due to the global continuous typesetting mechanism, which affects the collaborative editing experience and the smoothness of operation.
By prioritizing local layout of data units corresponding to the visible area, rapid response to local user interactions is achieved, avoiding global updates and improving the document page rendering efficiency and user interaction response efficiency of the visible area.
It improves the collaborative editing experience and operational smoothness of documents, and solves the problems of low page rendering frame rate and high interaction response latency.
Smart Images

Figure CN123159273A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a collaborative document editing typesetting method, apparatus, device, and storage medium. Background Technology
[0002] With the rapid popularization of cloud-based and online collaborative office technologies, online word processing components that support real-time collaboration among multiple users have become mainstream office tools, widely used in various office scenarios such as document editing, online annotation, and collaborative revision. In collaborative editing scenarios, streaming documents and reflowable documents are commonly used as the core collaborative editing carriers. Unlike fixed-format documents, these documents abandon the constraints of fixed page layouts and possess the core characteristics of adaptive content layout and dynamic reflow. They can adapt to the display needs of different terminal screen sizes and window sizes, highly meeting the business needs of real-time collaborative editing among multiple users. The core implementation logic of multi-user collaborative editing of streaming and reflowable documents is to use consistent collaborative algorithms such as OT (Operational Transformation) to merge local and collaborative editing operations into the local document data model in real time. After data synchronization is completed, the document layout and page rendering are triggered, ultimately achieving a consistent display of content and layout across multiple terminals.
[0003] In related technologies, since streaming typesetting is based on the sequential arrangement of characters in a document, the position of characters arranged earlier affects the position of subsequent characters. Therefore, to ensure the accuracy and integrity of line breaks and pagination, a global continuous typesetting mechanism is used. Starting from the document header or the smallest dirty mark, typesetting, line breaks, and pagination calculations are performed sequentially along the document symbol flow until the typesetting area completely covers the user's visible area or the entire document symbol flow is fully typeset. Therefore, the global continuous typesetting mechanism requires multiple pages to be typeset continuously to ensure that the typesetting reaches the visible area. The farther the smallest dirty mark or document header is from the visible area, the more pages are typeset, and the higher the load on the main thread becomes. Once the number of collaborators increases and version changes become more frequent, typesetting triggers become more intensive, the main thread accumulates a large number of typesetting tasks or frequently re-typesets, significantly increasing the latency of interactive responses and severely impacting the collaborative editing experience and operational smoothness. Summary of the Invention
[0004] This application provides a collaborative document editing layout method, apparatus, device, and storage medium, which prioritizes local layout of data units corresponding to the visible area, enabling rapid response of local user interaction, solving the problem of high interaction response latency in the prior art, and improving the collaborative document editing experience and operation smoothness.
[0005] Firstly, this application provides a collaborative document editing and formatting method, including: When the data model is updated based on an editing operation, if the data unit whose layout has been changed in the updated data model includes the first data unit corresponding to the visible area, the layout data of the first data unit is updated. The document layout of the visible area is rendered based on the layout data updated by the first data unit.
[0006] Secondly, this application provides a collaborative document editing and typesetting apparatus, comprising: The partial layout update module is configured to update the layout data of the first data unit when the data unit whose layout has been changed in the updated data model is included in the first data unit corresponding to the visible area after the data model is updated based on the editing operation. The visible area rendering module is configured to render the document layout of the visible area based on the layout data updated by the first data unit.
[0007] Thirdly, this application provides a collaborative document editing typesetting device, comprising: One or more processors; A memory that stores one or more programs that, when executed by one or more processors, enable the one or more processors to implement the collaborative document editing layout method as described in the first aspect.
[0008] Fourthly, this application provides a storage medium containing computer-executable instructions, which, when executed by a computer processor, are used to perform the collaborative document editing typesetting method as described in the first aspect.
[0009] In this application, after the data model is updated based on an editing operation, if the data unit whose layout has changed in the updated data model includes the first data unit corresponding to the visible area, the layout data of the first data unit is updated. The document layout of the visible area is then rendered based on the updated layout data of the first data unit, thereby completing the layout update of the document content in the visible area. Through this technical means, when a document's data unit undergoes a layout change, the first data unit displayed in the visible area is located, thus prioritizing a local update of the document layout in the visible area. This avoids a global layout update from beginning to end before rendering the document layout in the visible area. The main thread is no longer preempted by numerous layout tasks; instead, it prioritizes updating the layout of the visible area and responding to user interactions. This improves the rendering efficiency of the document page in the visible area and the response efficiency of user interactions, solving the problems of low page rendering frame rate and high interaction response latency in existing technologies, and improving the collaborative editing experience and operational smoothness of documents. Attached Figure Description
[0010] Figure 1This is a flowchart illustrating a collaborative document editing and formatting method provided in an embodiment of this application; Figure 2 This is a flowchart of the dirty processing of data units with layout changes provided in the embodiments of this application; Figure 3 This is a flowchart of the typesetting task execution and generation process provided in the embodiments of this application; Figure 4 This is a schematic diagram of the task scheduling process provided in an embodiment of this application; Figure 5 This is a layout diagram of page k provided in the embodiments of this application; Figure 6 This is a schematic diagram of a cross-page cell provided in an embodiment of this application; Figure 7 This is a schematic diagram of the task enqueuing process provided in an embodiment of this application; Figure 8 This is a schematic diagram illustrating the process of interrupting and resuming pre-arranged subtasks according to an embodiment of this application; Figure 9 This is a schematic diagram of the process of queuing subtasks generated by the new editing operation provided in the embodiments of this application; Figure 10 A schematic diagram of a collaborative document editing typesetting device provided in this application embodiment; Figure 11 This is a schematic diagram of the structure of a collaborative document editing typesetting device provided in an embodiment of this application. Detailed Implementation
[0011] To make the objectives, technical solutions, and advantages of this application clearer, specific embodiments of this application will be described in further detail below with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are merely for explaining this application and not for limiting it. It should also be noted that, for ease of description, only the parts relevant to this application are shown in the drawings, not all of them. Before discussing exemplary embodiments in more detail, it should be mentioned that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although the flowcharts describe operations (or steps) as sequential processes, many of these operations can be performed in parallel, concurrently, or simultaneously. Furthermore, the order of the operations can be rearranged. A process can be terminated when its operation is completed, but it may also have additional steps not included in the drawings. A process can correspond to a method, function, procedure, subroutine, subprogram, etc.
[0012] The terms "first," "second," etc., used in the specification and claims of this application are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such use of data can be interchanged where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," etc., are generally of the same class and the number of objects is not limited; for example, a first object can be one or more. Furthermore, in the specification and claims, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship.
[0013] In common existing implementations, to ensure the accuracy and completeness of line breaks and pagination, a global continuous typesetting mechanism is used. Starting from the document header or the smallest mark, typesetting, line breaks, and pagination calculations are performed sequentially along the document symbol flow until the typesetting area completely covers the user's visible area or the entire document symbol flow is fully typeset. Specifically, in collaborative scenarios, when the collaborating user's editing position is before the local user's visible area and the editing operation involves factors incompatible with or strongly dependent on versioning, such as line breaks, cross-page tables, text wrapping, and automatic numbering, the global continuous typesetting mechanism needs to re-typeset multiple pages to ensure the typesetting reaches the visible area and guarantees the correctness of the visible area's typesetting, such as the correctness of line breaks and page breaks. The farther the collaborating user's editing position is from the local user's visible area, the more pages are typed, increasing the load on the main thread. Furthermore, online documents on the browser side rely on single-threaded JavaScript execution; time-consuming tasks such as document typesetting, comment position updates, outline updates, image updates, and font checks compete with user input events and rendering-related scheduling. As the number of collaborators increases, version change notifications become more frequent, layout triggers become more intensive, and layout tasks become severely backlogged, leading to a decrease in rendering frame rate, slow input response, or even prolonged periods of unresponsiveness. This seriously affects the collaborative editing experience and operational smoothness of documents.
[0014] To address the aforementioned issues, this embodiment provides a collaborative document editing layout method that prioritizes local layout of data units corresponding to the visible area, enabling rapid response to local user interactions. This solves the problems of low page rendering frame rate and high interaction response latency in existing technologies, thereby improving the collaborative document editing experience and operational smoothness.
[0015] The collaborative document editing layout method provided in this embodiment can be executed by a collaborative document editing layout device. This device can be implemented through software and / or hardware, and can consist of two or more physical entities, or a single physical entity. For example, the collaborative document editing layout device can be a terminal device with a collaborative document editor installed, such as a computer, tablet, or mobile phone. The collaborative document editor is an application and browser that supports multi-user collaborative editing of streaming and reflowable documents. This application possesses complex capabilities such as streaming layout, comment rendering, and outlines, and can be an enterprise collaboration platform deployed in a public cloud or private location, an online office suite, or an embedded component of office software.
[0016] The collaborative document editing typesetting device is equipped with at least one type of operating system, including but not limited to Android, Linux, and Windows. The device can have at least one application installed on the operating system; this application can be a built-in application of the operating system or an application downloaded from a third-party device or server. In this embodiment, the collaborative document editing typesetting device has at least one application capable of executing collaborative document editing typesetting methods.
[0017] For ease of understanding, this embodiment uses a terminal device as the main body for executing the collaborative document editing layout method as an example for description.
[0018] Figure 1 A flowchart of a collaborative document editing layout method provided in an embodiment of this application is given. (Reference) Figure 1 The specific formatting methods for this collaboratively edited document include: S110. After the data model is updated based on the editing operation, if the data unit with the layout change in the updated data model includes the first data unit corresponding to the visible area, the layout data of the first data unit is updated.
[0019] Collaborative editing documents are documents that support simultaneous editing on multiple devices. Editing operations include local editing operations and / or collaborative editing operations. Local editing operations refer to the input, deletion, replacement, and formatting adjustments performed by the local user on the collaborative editing document displayed on the terminal device. Collaborative editing operations refer to the input, deletion, replacement, and formatting adjustments performed by collaborating users on the collaborative editing document displayed on the collaborating end, which refers to other devices editing the same document as the terminal device. Formatting adjustments include, but are not limited to, switching between full-width and half-width characters, switching fonts, switching font sizes, and adjusting character spacing, line spacing, and paragraph spacing. Collaborating users can be the same or different users as the local user. If the collaborating user and the local user are the same user, that user can collaboratively edit the same document through different applications or different windows of the same application. Furthermore, the application operated by the user can be installed on the same or different terminal devices.
[0020] The data model serves as the underlying structured storage medium for collaboratively edited documents, comprising symbol flow and layout rules. Symbol flow is the sequence of entity symbols (characters, inline objects, control characters) arranged in order in the document; layout rules are used to describe the styles (such as color, font, bold, underline, background, etc.) and layouts (such as font size, line spacing, alignment, etc.) of various structured objects (such as paragraph objects, table objects, character objects, floating objects, etc.).
[0021] In this embodiment, the data model is divided into multiple data units, each including corresponding symbols and even corresponding layout rules. That is, the symbol flow of the data model consists of symbols from multiple data units. A data unit can be a structured object or a collection of structured objects, such as a paragraph, page, or text block. For example, when the data unit is a paragraph, it is equivalent to dividing the symbol sequence of each paragraph in the symbol flow into the symbol sequence of the corresponding data unit. When the data unit is a page, it is equivalent to dividing the symbol sequence of each page in the symbol flow into the symbol sequence of the corresponding data unit.
[0022] For example, the terminal device listens for local editing operations triggered by the local keyboard, formatting panel, etc., and simultaneously listens for network access to receive collaborative editing operations pushed by multiple collaborating devices. Upon receiving both local editing operations and multiple collaborative editing operations, the device modifies the symbolic flow and / or layout rules in the data model according to the local editing operations. Then, using an OT algorithm, the multiple collaborative editing operations are transformed and merged into a single, conflict-free editing operation. This editing operation contains modification instructions for multiple operations, and the symbolic flow and / or layout rules in the data model can be updated based on these modification instructions.
[0023] This embodiment provides two methods for updating the data model: one is a single-stage comprehensive update of all data units in the data model, and the other is an initial stage update of the first data unit in the data model, followed by a second stage comprehensive update of all data units in the data model. The first data unit is the data unit currently displayed in the visible area, that is, the data unit to which the symbol content displayed in the visible area belongs.
[0024] In the first update method, all data units of the data model are fully updated based on all modification instructions in the editing operation. After the data model is fully updated, the data units with layout changes in the updated data model are identified. For example, a merging operation includes modification instruction A to insert a string into data unit A and modification instruction B to update the line spacing of data unit B. After inserting the string corresponding to modification instruction A into data unit A of the data model and updating the line spacing of data unit B, the data model update is confirmed to be complete.
[0025] In the second update method, modification instructions for the first data unit corresponding to the visible area can be selected first. The data model is then updated preferentially based on the modification instructions for the first data unit to confirm that the data model has completed the initial update. Subsequently, layout calculations are performed on the first data unit in the data model that has completed the initial update to generate new layout data. The document layout of the visible area is then rendered based on the new layout data.
[0026] Another execution process of the second update method is as follows: Upon receiving both a local editing operation and multiple collaborative editing operations, the operations that edit the visible area can be merged to obtain the editing operation corresponding to the visible area. Based on the modification instructions of this editing operation, the symbols and / or layout rules of the first data unit corresponding to the visible area are updated to obtain the updated first data unit, thus completing the initial update of the data model. Subsequently, layout calculations are performed on the first data unit in the initially updated data model to generate new layout data, and the document layout of the visible area is rendered based on the new layout data. For example, if the terminal device receives a local editing operation on a section of text within the visible area, and simultaneously receives a global collaborative editing operation to modify the font size, the local editing operation and the collaborative editing operation are merged to obtain the editing operation for the visible area. This editing operation includes instructions to modify the text within the visible area and instructions to modify the font size of the first data unit corresponding to the visible area. Based on this editing operation, the symbol stream and layout rules of the first data unit can be updated, and then the next stage of layout data update processing begins.
[0027] After updating the first data unit in the data model to complete the initial update, and waiting for the layout data of the first data unit to update and the document layout of the visible area to be re-rendered, a full update of the data model can be performed based on the remaining modification commands in the editing operation or the modification commands that have not been executed, thus completing the full update of the data model. After the full update of the data model, the data units with layout changes in the updated data model are identified, and layout calculations are performed on the data units with layout changes to update the corresponding layout data, so as to ensure the layout accuracy of collaboratively edited documents.
[0028] In another embodiment, after a comprehensive update of the data model, if the data unit with layout changes in the updated data model includes the first data unit, then the first data unit is reformatted, and the first data unit is re-rendered based on the reformatted data. In this case, although the first data unit has not undergone any additional editing operations, it needs to be reformatted because it may be affected by the layout of data preceding the first data unit in the document. Furthermore, after reformatting, the first data unit can be re-rendered based on the reformatted data if preset conditions are met. The preset conditions are used to delay the re-rendering of the first data unit to avoid frequent updates of the first data unit affecting the user's reading experience and increasing the device's computing power. If there is an editing operation on the first data unit, then step S110 continues.
[0029] Furthermore, each data unit in the data model corresponds to its own symbol interval, which indicates the position of the symbol sequence of the data unit in the symbol stream of the data model. For example, the symbol interval corresponding to a data unit is [n1, n2], where n1 and n2 are the start and end points of the symbol interval of the data unit, respectively indicating the position of the start symbol and the end symbol in the symbol stream. It should be noted that the symbol interval can be stored separately from the data model or stored in the data model; this embodiment does not impose any restrictions on this.
[0030] When the symbolic flow in the data model is updated, the symbolic intervals corresponding to the data units are also updated to ensure that the symbolic intervals of each data unit completely correspond to the intervals of the symbolic flow. For example, if the data unit is the data page of the k-th document page, and a local or collaborative editing operation inserts x characters on the k-th page, then the symbolic interval of the k-th page changes from [n1, n2] to [n1, n2+x]. Of course, if the symbolic intervals of other data pages have changed before, the starting point of the symbolic interval of this data page will be updated first, and then the ending point of the symbolic interval will be updated based on the number of newly added characters.
[0031] In one embodiment, during the data model update triggered by an edit operation, the symbol interval of the data unit is updated. Specifically, when the edit operation includes symbol addition and deletion operations, the corresponding edited data unit is determined based on the edit position of the symbol addition and deletion operation, and the symbol interval of the corresponding edited data unit is updated based on the symbol increase or decrease amount of the symbol addition and deletion operation; the symbol interval of subsequent data units is updated based on the latest symbol interval of the edited data unit. The symbol addition and deletion operations include symbol addition and symbol deletion operations. These operations change the total number of symbols in the data unit, thereby changing the symbol interval of the data unit. Therefore, the symbol interval of the data unit can be updated only when the edit operation involves symbol addition and symbol deletion operations, avoiding unnecessary operation steps. The edit position of the symbol addition and deletion operation is the position of the added or deleted character in the symbol stream. This position is compared with the symbol interval of each data unit, and the data unit corresponding to the symbol interval at that position is determined as the edited data unit. The symbol increase or decrease amount of the symbol addition and deletion operation is the number of characters deleted or added. The updated endpoint of the symbol interval is obtained by subtracting the number of characters deleted or adding the number of characters added from the endpoint of the symbol interval of the edited data unit. After the end point of the symbol interval is updated, the start and end points of the symbol intervals for all subsequent data units will be updated accordingly. If no characters are added or deleted from a data unit, the number of characters in the data unit remains unchanged, meaning the interval between the symbol intervals of the data unit remains constant.
[0032] If the editing operation includes multiple symbol addition and deletion operations, the symbol addition and deletion amounts for the same data unit are accumulated to obtain the total addition and deletion amount. Then, the symbol intervals of the data units are updated sequentially from front to back according to the interval order of the data units to ensure that the symbol interval of the final data unit completely covers the interval of the symbol stream. For example, the editing operation includes a collaborative editing operation to insert 10 characters into the data page at page k, a collaborative editing operation to delete 2 characters into the data page at page k, and a local editing operation to insert 20 characters into the data page at page k+1. Assume that the symbol interval of the data page at page k is [n1, n2], the symbol interval of the data page at page k+1 is [n2, n3], and the symbol interval of the data page at page k+2 is [n3, n4]. After inserting and deleting corresponding characters in the symbol stream based on local editing operations and two collaborative editing operations, the symbol interval of page k is modified to [n1, n2+8], the symbol interval of page k+1 is modified to [n2+8, n3+28], the symbol interval of page k+2 is modified to [n3+28, n4+28], and so on. The start and end points of the symbol intervals of subsequent data pages are all increased by 28 to keep the number of symbols unchanged. The final number of symbols in the symbol stream is the original number plus 28.
[0033] It should be noted that if the data model is updated in two phases (first updating the sign and / or layout rules of the first data unit, then updating the sign and / or layout rules of the remaining data units), then the sign interval is also updated in two phases, that is, first updating the sign interval of the first data unit, then updating the sign interval of the remaining data units. If the sign interval of the remaining data units affects the sign interval of the first data unit, then the sign interval of the first data unit continues to be updated.
[0034] In this embodiment, when updating the symbol stream of the data model based on symbol addition and deletion operations, the symbol range of the data unit is updated to ensure that the symbol range of the data unit completely covers the symbol stream of the data model, thereby ensuring the accuracy of subsequent typesetting.
[0035] Optionally, the symbol range of a data unit is stored through the corresponding tree node in the first interval tree. The first interval tree is a red-black tree, which supports rapid modification and indexing of the symbol range stored in the tree nodes. Once the symbol range of a tree node changes, the symbol ranges of its child nodes are also updated accordingly, thus automatically updating the symbol range of the entire first interval tree, improving the efficiency of symbol range updates. This embodiment stores the symbol range of a data unit through a first interval tree to facilitate rapid updates and indexing of the data unit's symbol range, thereby improving the efficiency of updating and indexing the symbol range of the data unit.
[0036] In addition, the symbol range of a data unit can also be stored using skip lists, balanced trees, or hierarchical index data structures.
[0037] After the data model triggers an initial update based on an edit operation, since the initial update independently updates the symbols and / or layout rules of the first data unit, the layout change of the first data unit can be directly confirmed, and the process of updating the layout data of the first data unit can be executed. After the data model triggers a single-stage full update based on an edit operation, the data units with layout changes in the data model are identified, and it is then determined whether the data units with layout changes include the first data unit. If it is confirmed that the data units with layout changes include the first data unit, the layout data of the first data unit is updated.
[0038] In one embodiment, after completing a preliminary or comprehensive update of the data model, data units with changed layouts in the updated data model can be marked as dirty units. A dirty unit is a data unit whose original layout has changed due to an editing operation, rendering the currently cached layout data invalid and requiring re-execution of layout calculations. For example, if the data model updates global layout rules, all data units can be directly marked as dirty units. If the data model updates the layout rules and / or symbol ranges of a data unit, then that data unit and the remaining data units whose layouts depend on it are marked as dirty units. It should be noted that if there is no layout dependency between data units in the data model, i.e., a layout change in any data unit does not affect the layout of other data units, then only data units whose layout rules and / or symbol ranges have been updated are marked as dirty units.
[0039] Optional, Figure 2 This is a flowchart illustrating the process of marking dirty data units for layout changes, provided in an embodiment of this application. For example... Figure 2 As shown, the specific steps for marking dirty data units that have undergone layout changes include S1101-S1103: S1101. Determine the starting change data unit based on the updated data model.
[0040] S1102. Determine the dependent data units in the updated data model whose layout depends on the initial changed data unit.
[0041] S1103, mark the starting change data unit and dependent change data units as dirty units.
[0042] Layout dependency refers to a relationship where the layout of two adjacent data units depends on each other; that is, a change in the layout of the previous data unit will affect the layout of the next data unit. For example, for two adjacent pages, a change in the layout of the previous page may cause the characters on the previous page to be displayed on the next page, thus causing a change in the layout of the next page. This is used to determine that the two pages have a layout dependency.
[0043] For example, the updated data model is traversed from the beginning. The first data unit encountered that shows an update to the typesetting rules and / or symbol range is designated as the starting changed data unit and marked as dirty. Of course, if the starting changed data unit is already dirty, indicating that the typesetting change triggered by the previous operation has not yet completed the corresponding typesetting update, the dirty marking process for the starting changed data unit is skipped.
[0044] After determining the initial data unit to be changed, if the next data unit encountered in the traversal has a dependency relationship with the initial data unit, then the next data unit is treated as a dependent data unit and marked as dirty. This process continues traversing the next data unit. Whenever a traversed data unit has a layout dependency with the previous data unit and the previous data unit is a dirty unit, the traversed data unit is treated as a dependent data unit and marked as dirty. For example, if page 1 is the initial data unit to be changed, and adjacent pages from page 1 to page 4 have layout dependencies, then when traversing pages 2 to 4, pages 2 to 4 will be treated as dependent data units to be changed and marked as dirty. Similarly, if a dependent data unit is already a dirty unit, indicating that the layout change triggered by the previous operation has not yet completed the corresponding layout update, then the dirty marking process for the dependent data unit is skipped.
[0045] If the most recently traversed data unit has no dependency on the previous data unit, then it is determined whether the most recently traversed data unit has undergone typesetting rule and / or symbol range updates. If it has, then this most recently traversed data unit is used as the new starting change data unit. If it has not, then the traversal continues to the next data unit until a data unit with typesetting rule and / or symbol range updates is encountered, at which point this data unit is used as the new starting change data unit. After determining the new starting change data unit, subsequent data units are traversed to identify dependent change data units for data units whose typesetting depends on the starting change data unit. This process continues until all data units have been traversed.
[0046] Understandably, during the traversal process, since there may be no layout dependency between adjacent data units, multiple starting change data units may be marked. Each starting change data unit is the first data unit with a layout change among the multiple data units with layout dependency. The remaining data units with layout changes can be quickly filtered out by the starting change data unit, which improves the efficiency of marking dirty data units.
[0047] When a mandatory isolation symbol or object is set between adjacent data units, there is no layout dependency between them. The mandatory isolation symbol or object is a symbol or object that causes the next data unit to start layout from a new page. For example, page k is the starting change data unit, and pages k+1, k+2, and k+3 are consecutive data pages, but page k+3 has a mandatory form break. This mandatory form break causes the characters to start layout from the beginning of page k+4 even if page k+3 is not full, regardless of how the page layout changes before page k+4. Alternatively, page k+4 may have a table that cannot span multiple pages or an image that fills the entire page. This table or image isolates the layout of page k+3 from page k+5, so changes in the layout of page k+3 will not affect the layout of page k+5. Therefore, only pages k+1, k+2, and k+3 are identified as dependent change data units.
[0048] In one embodiment, data units can be divided based on mandatory isolation symbols or objects, so that there is no dependency between multiple data units.
[0049] Optionally, if the change in the initial data unit is only the addition or deletion of characters, it can be determined whether the number of characters added or deleted will change the number of rows in the initial data unit. If it does not change the number of rows in the initial data unit, it indicates that the layout change of the initial data unit does not affect the layout of subsequent data units, thus determining that there are currently no dependent data units.
[0050] This embodiment can quickly identify the data unit that initiates the typesetting change and the data unit that depends on the data unit that initiates the change, based on the updated data model. This allows the data unit that initiates the change and the data unit that depends on the change to be marked as dirty units, ensuring the efficiency and accuracy of dirty unit marking.
[0051] In one embodiment, when an editing operation includes multiple operations, the data model is updated sequentially according to the operation sequence. Each update triggers the marking of dirty data units with layout changes. One operation can trigger the marking of dirty data units. After multiple operations trigger the updating of the data model and the marking of dirty data units with layout changes, the dirty units corresponding to the multiple operations can be aggregated and deduplicated to obtain the dirty units in the updated data model corresponding to the editing operation. For example, a terminal device simultaneously receives one local editing operation and two collaborative editing operations. The dirty units generated by one collaborative editing operation include pages k+1, k+2, and k+3; the dirty units generated by the other collaborative editing operation include pages k, k+1, k+2, and k+3; and the dirty unit generated by the local editing operation is page k+3. Aggregating and deduplicating these dirty units yields the dirty units corresponding to the editing operation, which include pages k, k+1, k+2, and k+3. This embodiment aggregates and removes duplicates from the dirty units corresponding to multiple operations to obtain the final dirty units that need to be re-formatted, so as to avoid wasting computing resources by repeatedly performing layout calculations on the same data unit and improve layout efficiency.
[0052] In another embodiment, to reduce the caching of layout data on the terminal device, the terminal device only caches the layout data and character measurement data of the visible area and its neighboring range of the collaboratively edited document locally, without caching the layout data and character measurement data of other data units. The required layout data and character measurement data are then restored when the visible area changes or when recalculating the layout. Specifically, the layout data and character measurement data of the first data unit and its preset neighboring range are cached locally, while the layout data and character measurement data of the remaining data units are not cached locally. The first data unit is the data unit displayed in the visible area. For example, if the visible area displays page k, then page k is used as the first data unit. The neighboring range is a preset range adjacent to the first data unit. For example, if the neighboring range can be 15 pages before and after, then the neighboring range of page k is k-15 to k+15. The terminal device locally caches the layout data and character measurement data of data pages k-15 to k+15. Character measurement data is the geometric measurement of characters and is the basic input for the layout engine to perform layout calculations. Layout data is data obtained after the layout engine performs layout calculations, used to describe the precise position and distribution of document content on the page. Understandably, users generally don't swipe extensively when scrolling the visible area; the data unit corresponding to the next visible area is still within the neighborhood of the previous visible area. The terminal device can quickly load locally cached layout data to render the document content of the next visible area. Even if editing operations change the data unit, the terminal device can quickly update the layout data of the data unit based on locally cached character measurement data. Therefore, locally cached layout data and character measurement data are sufficient to meet the regular operational needs of collaborative document editing.
[0053] In this embodiment, since the terminal device only caches the first data unit and its neighboring data units locally, it is not necessary to mark data units after the end of the neighboring range as dirty during dirty processing, thereby reducing the amount of typesetting calculation. Specifically, when marking data units with typesetting changes, data units that have undergone typesetting changes and are located before the neighboring end unit corresponding to the first data unit can be marked as dirty units; wherein, the neighboring end unit is the data unit located at the end of the preset neighboring range of the first data unit. The starting changed data unit and dependent changed data units can be determined based on the editing operation first, and the data units after the neighboring end unit in the starting changed data unit and dependent changed data units can be deleted, and the remaining data units can be marked as dirty units. For example, if the first data unit is the k-th page, and its corresponding neighboring end unit is the k+15-th page, even if the k+16-th page also undergoes typesetting changes, it will not be marked as a dirty unit, because the typesetting data generated by the typesetting calculation on the k+16-th page will still be cleared. In this embodiment, only the data units whose layout has been changed before the neighboring end unit corresponding to the first data unit are marked as dirty, thereby reducing the number of dirty units and reducing the amount of layout calculation.
[0054] It should be noted that in this embodiment, the layout data of the data units before the front end of the neighborhood range also needs to be cleared. However, the data units with layout changes before the front end of the neighborhood range are marked as dirty because the layout of these data units affects the layout of the subsequent first data unit and the data units in its neighborhood range. In order to ensure the accuracy of the locally cached layout data, the layout calculation can start from the first data unit with changes.
[0055] The layout of data units following the end of a neighboring unit does not affect the layout of the preceding first data unit and its neighboring units. Therefore, layout calculations are not required; instead, the symbol intervals are updated synchronously. Of course, because the data units following the end of a neighboring unit have not undergone layout calculations, their symbol intervals are inaccurate. However, this still clearly indicates which characters' layout data are not saved locally, ensuring correct document processing.
[0056] Another scenario is where the first data unit within the first data unit and its neighboring data units undergoes a layout change. This is the starting data unit for the change. Since the starting data unit's layout either doesn't depend on the preceding data unit, or the preceding data unit it depends on hasn't undergone a layout change, the layout change of the starting data unit doesn't depend on the data units preceding the beginning of its neighboring range. Therefore, the layout changes of the data units preceding the beginning of the neighboring range don't affect the layout changes of the first data unit and its neighboring data units. In this case, the data units preceding the beginning of the neighboring range that have undergone layout changes don't need to be marked as dirty.
[0057] Optionally, the symbol intervals of the remaining data units are stored through the corresponding tree nodes in the second interval tree. That is, each tree node in the second interval tree stores the symbol interval of one data unit whose layout data and character measurement data are not stored locally. It can be understood that the first interval tree manages the symbol intervals of all data units, while the second interval tree manages the symbol intervals of data units whose layout data and character measurement data are not cached locally. When updating the symbol intervals of data units in the first interval tree, the symbol intervals of the same data unit in the second interval tree are updated synchronously to ensure that the second interval tree accurately reflects which data units' layout data and character measurement data are not stored locally.
[0058] As can be seen from the above, if the data model is updated in two stages—preliminary update and full update—the first data unit can be directly identified as the data unit with layout changes after the preliminary update, and the process of updating the layout data of the first data unit will then be executed. If the data model is updated in a single stage—full update—the process of updating the layout data of the first data unit will be executed after the full update, determining whether the dirty unit includes the first data unit. If it does, the process of updating the layout data of the first data unit will then be executed.
[0059] It should be noted that if the editing operation is only a collaborative editing operation and it edits data units that are not dependent on the visible area (because local editing operations are triggered within the visible area, thus affecting the layout of the visible area), then the collaborative editing operation will not affect the layout of the visible area. In this case, the data model is not updated in two phases, but rather in a single phase as a complete update. Moreover, after marking the data units with layout changes as dirty based on the updated data model, the first data unit will not be marked as a dirty unit.
[0060] During the process of updating the layout data of the first data unit, layout calculations can be performed on the first data unit based on the symbol range of the first data unit and the updated data model to obtain the new layout data of the first data unit. For example, the first data unit is the k-th data page, and the updated data model records the symbol range of the k-th page as [n1, n2+8]. During the layout calculation, the symbol sequence of the corresponding range is obtained from the updated symbol stream based on [n1, n2+8]. The character measurement data of the k-th page is obtained from the local cache. Based on the character measurement data and the updated structured object, the layout calculation starts from the starting point of the symbol sequence of the k-th page, that is, the n1-th character. If an end symbol is generated before the end point is calculated, the position of the symbol before the end symbol is updated to the end point of the k-th page, and the layout of the k-th page is confirmed to be finished. The layout data obtained from the start point to the end point is used as the latest layout data of the k-th page. For a data page, its end symbol is the symbol that triggers pagination in the page layout. Simultaneously, update the endpoint of the symbol interval on page k in the first interval tree. For example, assuming the end symbol is reached after the n2+6th character, update the symbol interval on page k to [n1, n2+6]. Then, synchronously update the starting point of the symbol interval on the next page to n2+6, while keeping the endpoint unchanged. If the end symbol is not reached after calculating the endpoint, obtain the next symbol from the symbol stream and continue the layout calculation until the end symbol is generated. Then, update the position of the symbol before the end symbol to the endpoint of page k and confirm the end of the layout on page k. For example, assuming the end symbol is not reached after the n2+8th symbol, continue obtaining n2+9 symbols for layout calculation. Finally, after calculating the n2+11th symbol, the end symbol is generated. Update the symbol interval on page k to [n1, n2+11], then synchronously update the starting point of the symbol interval on the next page to n2+11, while keeping the endpoint unchanged.
[0061] For example, the first data unit is the i-th data segment, and the updated data model records the symbol interval of the i-th segment as [m1, m2]. During typesetting calculation, based on [m1, m2], the symbol sequence of the corresponding interval is obtained from the updated symbol stream, and the character measurement data of the i-th segment is retrieved from the local cache. Typesetting calculation starts from the starting point of the symbol sequence of the i-th segment, i.e., the m1-th character, according to the character measurement data and the updated structured object, until the m2-th character is calculated and an end symbol is generated. At this point, the typesetting of the i-th segment can be confirmed as complete, and the typesetting data obtained from the starting point to the end point is used as the latest typesetting data for the i-th segment. For data segments, updating the typesetting data does not change the corresponding symbol sequence and symbol interval; therefore, data segments do not need to update their symbol interval when updating typesetting data.
[0062] S120. Render the document layout of the visible area based on the layout data updated in the first data unit.
[0063] For example, after generating the latest layout data for the first data unit, the document layout of the visible area is rendered based on the latest layout data. It can be understood that the update of the layout data for the first data unit is executed immediately after a layout change is confirmed in the first data unit. Even if layout changes occur in other data units before the first data unit, there is no need to wait for these data units to perform layout calculations before performing layout calculations and rendering on the first data unit. This ensures the high priority of the visible area layout, guaranteeing that local users are the first to know the response results of local editing operations within the visible area and the editing status of other collaborating devices within the visible area, indirectly improving the interaction response efficiency of local users and the rendering efficiency of the visible area.
[0064] It should be noted that in scenarios where a single-stage comprehensive update is triggered by the data model, if the data unit whose formatting has been changed only includes the first data unit (e.g., only the symbol range or layout rules of the first data unit have changed, and there is no formatting dependency between the first data unit and the next data unit), then after the first data unit completes its formatting calculation, the formatting of all data units in the document will be correct, confirming that the document has completed the formatting triggered by the editing operation. If the dirty unit includes the first data unit and other data units, then some data units will still have incorrect formatting, and the document has not yet completed the formatting triggered by the editing operation. Therefore, it is necessary to continue to perform formatting calculations on the data units with abnormal formatting to ensure the accuracy of the document's formatting.
[0065] In scenarios where the data model triggers initial and full updates, after the initial update, the layout data of the first data unit can be updated directly. Then, a second-stage full update is performed on the data model, and dirty units are identified based on the updated data model. Dirty units have incorrect layouts, indicating that the document's editing operations have not yet been completed, triggering the layout process. Therefore, subsequent layout calculations must be performed on data units with incorrect layouts to ensure document layout accuracy. It should be noted that after an initial or full update, data units whose layout depends on the first data unit will be marked as dirty units to avoid missing layout calculations for data units with layout changes.
[0066] In one embodiment, after updating and rendering the layout data of the first data unit, the layout data of each data unit with layout changes can be updated during idle periods. Idle periods refer to the periods when the main thread is in an idle state. For example, after a full update of the data model, data units with layout changes in the updated data model are marked as dirty units. If the first data unit is the first data unit among the dirty units, it indicates that the latest layout data of the first data unit is accurate (because the layout of data units preceding the first data unit has not changed), thus canceling the dirty attribute of the first data unit. During the idle period, the main thread performs layout calculations on the remaining dirty units based on the updated data model to obtain the latest layout data of the remaining dirty units. If the first data unit is not the first data unit among the dirty units, the latest layout data of the first data unit may not be accurate (because the layout of data units preceding the first data unit has changed). During the idle period, the main thread performs layout calculations on all dirty units based on the updated data model to obtain the latest layout data of all dirty units. When multiple dirty cells need to be reformatted, the reformatting calculations for multiple dirty cells with reformatting dependencies should be performed sequentially according to the distribution order of the cells in the document. This ensures that the reformatting data of the dirty cells is generated based on the accurate reformatting data of the preceding data cell, thus guaranteeing the reformatting accuracy of the document.
[0067] Of course, if there is no layout dependency between two dirty cells, then the layout data of one dirty cell will not affect the layout data of the other dirty cell. In this case, the layout calculation order of the two dirty cells can be set arbitrarily, or the priority of the dirty cell closer to the first data cell can be increased to prioritize the layout of the dirty cells near the first data cell. This allows the updated layout data of the corresponding dirty cell to be quickly rendered in the visible area when the user moves the visible area to the dirty cell near the first data cell.
[0068] In this embodiment, to prevent the main thread from being occupied by dirty unit layout calculations for an extended period, which could lead to unresponsive local interactions or page rendering, a maximum continuous duration for the main thread to perform dirty unit layout calculations can be set. Once the cumulative duration of the main thread's dirty unit layout calculations exceeds the maximum continuous duration, the layout calculations for dirty units are interrupted, and the currently calculated symbol position is set as a checkpoint. This allows the main thread to check if there are any higher-priority interactive operations or page rendering tasks to process. If so, the higher-priority tasks are processed first; otherwise, the dirty unit layout calculations continue from the checkpoint. This process continues until the layout data and symbol ranges of all dirty units are updated.
[0069] Optionally, to strictly constrain the order in which the terminal device prioritizes updating the layout of the first data unit and updating the layout of the dirty unit during idle periods, layout tasks with different priorities can be generated for the first data unit and the dirty unit. The scheduler then allocates higher-priority layout tasks to the main thread for execution, ensuring the accuracy of the layout logic. Specifically, Figure 3 This is a flowchart illustrating the typesetting task execution and generation process provided in an embodiment of this application. For example... Figure 3 As shown, the specific steps of the typesetting task execution and generation process include S1301-S1305: S1301. Mark the data cells with layout changes in the updated data model as dirty cells.
[0070] Step S1301 can be referred to the specific execution process of steps S1101 to S1103, and will not be repeated here.
[0071] S1302. Generate a background pre-sorting task based on the dirty cell. The background pre-sorting task is used to indicate the updating of the layout data of the dirty cell.
[0072] For example, first determine whether the first data unit is included in all dirty units; if it is, then determine whether the first data unit is the first data unit among all dirty units; if so, then generate a background pre-schedule task based on the remaining dirty units excluding the first data unit; if not, then generate a background pre-schedule task based on all dirty units. The process of executing the background pre-schedule task is equivalent to executing the process of updating the layout data of each layout-changed data unit during idle periods. For details, please refer to the above embodiment.
[0073] S1303. When the dirty unit includes a first data unit corresponding to the visible area, a local layout task is generated based on the first data unit. The local layout task is used to instruct the updating of the layout data of the first data unit and the re-rendering of the document layout of the visible area.
[0074] For example, after confirming in step S1302 that the dirty unit includes the first data unit, step S1303 can be executed to generate a partial layout task based on the first data unit. The process of executing the partial layout task is equivalent to executing step S120, and the specific process can be referred to in the embodiment of step S120 above.
[0075] S1304. Store partial layout tasks and background pre-layout tasks in the task queue, with the priority of partial layout tasks being higher than that of background pre-layout tasks.
[0076] The task queue is a queue that stores tasks to be executed. The task queue can be a priority queue, where tasks are automatically ordered from the head to the tail of the queue according to their priority from highest to lowest.
[0077] S1305. The scheduler allocates tasks in the task queue to the main thread for execution in sequence based on priority.
[0078] For example, the task queue is a priority queue. The scheduler can determine that the task at the head of the queue is the highest priority task, and thus prioritize assigning the head task to the main thread for execution. After the head task is assigned, the next highest priority task is automatically moved to the head of the queue. After the main thread finishes executing its tasks, the scheduler assigns the new task at the head of the queue to the main thread for execution. Since the partial layout task has the highest priority among all tasks, it is automatically moved to the head of the task queue, and the scheduler prioritizes assigning it to the main thread for execution. Once the main thread has completed the partial layout task to update the layout of the first data unit and render the visible area, the scheduler assigns the new task at the head of the queue to the main thread for execution.
[0079] It should be noted that this embodiment sets the priority of background pre-scheduled tasks to be lower than that of interactive response tasks, such as responding to visible area switching operations and scheduled rendering tasks. This is to ensure that the main thread prioritizes interactive response tasks and scheduled rendering tasks, avoiding a drop in page rendering frame rate and delays in interactive responses. When the terminal device does not generate higher-priority tasks such as interactive response tasks and scheduled rendering tasks, the priority of the background pre-scheduled tasks is the highest priority task in the task queue. In this case, the scheduler will assign the background pre-scheduled tasks to the main thread for execution.
[0080] Furthermore, to prevent background pre-scheduled tasks from occupying the main thread for extended periods, a maximum execution time for these tasks can be set. Once the cumulative execution time of background pre-scheduled tasks on the main thread exceeds the maximum, the task is interrupted, and the latest scheduled symbol position is set as a checkpoint. At this point, the main thread is no longer occupied by background pre-scheduled tasks and can be used to handle higher-priority interactive tasks or scheduled rendering tasks, avoiding interaction response latency and a significant drop in rendering frame rate. After the main thread finishes processing the interactive or scheduled rendering tasks, it can resume executing background pre-scheduled tasks from the checkpoint.
[0081] This embodiment generates a local layout task with the highest priority for the first data unit and a background pre-layout task with a lower priority for dirty units. This ensures that the main thread prioritizes the execution of local layout tasks to quickly update the layout of the visible area, thereby improving the response speed of local editing operations. During idle periods, the main thread executes background pre-layout tasks, ensuring the accuracy of document layout without affecting interactive response and timed rendering, thus improving the collaborative editing experience and operational smoothness of the document.
[0082] When the updated data model includes multiple dirty cells, the background pre-sorting task is equivalent to performing sorting calculations on these dirty cells sequentially according to their priority to obtain the latest sorted data. Since the background pre-sorting task rearranges the layout of multiple data cells at once, the main thread needs to synchronously load a large amount of symbol and character measurement data, consuming excessive memory. If a checkpoint of the background pre-sorting task is lost during task execution, the main thread must execute the background pre-sorting task from the beginning, resulting in a significant waste of computational resources. Furthermore, if a new editing operation is received and a new dirty cell is generated before the background pre-sorting task is completed, a new background pre-sorting task will be generated based on the new dirty cell. This new background pre-sorting task may contain dirty cells that overlap with the currently executing background pre-sorting task, leading to duplicate sorting of the same dirty cell and wasting sorting computational resources.
[0083] Based on this, when editing operations involve multiple dirty units, the background pre-layout task can be divided into multiple pre-layout sub-tasks corresponding to each dirty unit. These sub-tasks are ordered based on a preset priority. The pre-layout sub-tasks instruct the main thread to recalculate the layout of the corresponding dirty units to generate new layout data. The preset priority can be determined based on the distribution position of the dirty units in the document; the earlier the dirty unit is in the document, the higher its preset priority. For example, if the background pre-layout task involves calculating the layout of pages k, k+1, k+2, and k+3, then the background pre-layout task can be divided into a pre-layout sub-task k for page k, a pre-layout sub-task k+1 for page k+1, a pre-layout sub-task k+2 for page k+2, and a pre-layout sub-task k+3 for page k+3. Among them, the priority of pre-arranged sub-tasks k, k+1, k+2 and k+3 is from high to low.
[0084] Optionally, multiple dirty units can be grouped based on layout dependencies. Dirty units with layout dependencies are grouped into the same group, while those without are grouped into different groups. Then, the priority of pre-layout subtasks corresponding to dirty units within the same group is sorted according to their distribution position in the document, while the priority of pre-layout subtasks corresponding to dirty units in different groups is sorted according to their positional relationship with the first data unit. The closer a dirty unit is to the first data unit, the higher the probability that the visible area will move to that dirty unit, thus assigning higher priority to dirty units closer to the first data unit. Alternatively, the priority of pre-layout subtasks corresponding to dirty units in different groups can be sorted according to the user's reading frequency of each group of dirty units. The higher the reading frequency of a dirty unit, the higher the probability that the visible area will move to that dirty unit, thus assigning higher priority to dirty units with higher reading frequency. For example, a background pre-sorting task might involve calculating the layout of pages k, k+1, k+2, and k+3. Pages k and k+1 have a layout dependency, while pages k+1 and k+2 do not, but pages k+2 and k+3 do. Pages k and k+1 can be grouped together, and pages k+2 and k+3 can be grouped together. Pre-sorting subtask k has a higher priority than pre-sorting subtask k+1, and pre-sorting subtask k+2 has a higher priority than pre-sorting subtask k+3. Assuming page k+3 is the first data unit, pages k+2 and k+3 are closer to the first data unit, so the priorities of pre-sorting subtasks k+2 and k+3 can be set higher than those of pre-sorting subtasks k and k+1. Ultimately, the priority of the four pre-arranged subtasks, from highest to lowest, is: pre-arranged subtask k+2, pre-arranged subtask k+3, pre-arranged subtask k, and pre-arranged subtask k+1.
[0085] The main thread executes pre-sorted subtasks sequentially from highest to lowest priority. Even if a checkpoint is lost due to an interruption of a pre-sorted subtask, the main thread will only re-execute that pre-sorted subtask, without starting from the first pre-sorted subtask in the background, thus avoiding unnecessary computation and effectively saving computing resources. Moreover, when executing pre-sorted subtasks, the main thread only needs to load the symbol sequence and character measurement data of the corresponding dirty unit into memory, without consuming excessive memory space.
[0086] In this embodiment, the pre-sorting subtask is an independent task in the task queue, allocated to the main thread by the scheduler for independent execution. When the main thread executes the pre-sorting subtask, it performs layout calculations on the data unit corresponding to the pre-sorting subtask to update the layout data and symbol range of that data unit. Specifically, when the scheduler determines that the pre-sorting subtask of the first dirty unit in the task queue has the highest priority, the scheduler allocates the pre-sorting subtask of the first dirty unit to the main thread for execution. The main thread starts the layout calculation from the beginning of the symbol range of the first dirty unit. When the end symbol of the first dirty unit is calculated, the pre-sorting subtask of the first dirty unit is confirmed to have ended, and the layout data from the beginning to the end symbol is determined as the latest layout data of the first dirty unit. The position of the symbol preceding the end symbol is determined as the latest end point of the symbol range of the first dirty unit. Based on the latest end point of the symbol range of the first dirty unit, the beginning of the symbol range of the next dirty unit is updated. Here, the first dirty unit is the dirty unit to be layout calculated by the highest priority pre-sorting subtask in the task queue. The next dirty unit is the dirty unit adjacent to the first dirty unit in the symbol range. The end-of-line character is a symbol that indicates the end of the layout of a data unit. For example, when the data unit is a data page, the end-of-line character is a line break; when the data unit is a paragraph, the end-of-line character is a carriage return.
[0087] For example, Figure 4 This is a schematic diagram of the task scheduling process provided in an embodiment of this application. Figure 4 As shown, after generating the partial layout task and dividing the background pre-layout task into pre-layout sub-tasks k, k+1, k+2, and k+3, all four tasks are stored in a priority queue. The partial layout task has the highest priority and is therefore placed at the head of the priority queue. Pre-layout sub-tasks k, k+1, k+2, and k+3 are placed after the partial layout task, respectively. The scheduler prioritizes retrieving the partial layout task from the priority queue and assigns it to the main thread. After the main thread completes the partial layout task, it updates the layout view of the visible area. After the main thread completes the partial layout task, if no interactive response task or timed rendering task with a higher priority than the pre-layout sub-task is generated or enqueued, the pre-layout sub-task k automatically moves to the head of the priority queue and becomes the highest priority task. The scheduler confirms that the main thread is currently idle and that pre-sorting subtask k has the highest priority. Therefore, it retrieves pre-sorting subtask k from the priority queue and assigns it to the main thread. The main thread executes pre-sorting subtask k to perform layout calculations on page k. At this point, page k is the first dirty unit, and page k+1 is the second dirty unit.
[0088] When the main thread performs layout calculations on page k, it retrieves the symbol sequence of the corresponding interval from the symbol stream based on the symbol interval of page k. It then retrieves the character measurement data of page k from the local cache and starts the layout calculation from the starting symbol of the symbol sequence on page k based on the character measurement data and the structured object. If an end symbol is generated before the end symbol of the symbol sequence is calculated, the symbol preceding the end symbol is determined as the end symbol of page k; if the end symbol is calculated before the end symbol is reached, the next symbol is retrieved from the symbol stream, and the layout calculation continues until an end symbol is generated. The position of the symbol preceding the end symbol is determined as the end symbol of page k. Once the end symbol of page k is determined, the layout of page k is complete. The layout data from the starting symbol to the end symbol is then used as the latest layout data for page k. The end symbol of the symbol interval on page k and the starting symbol of the symbol interval on page k+1 in the first interval tree are updated to the position of the symbol preceding the end symbol. The end symbol of the symbol interval on page k+1 remains unchanged. For example, Figure 5 This is a layout diagram of page k provided in an embodiment of this application. For example... Figure 5 As shown, symbol A is the starting symbol of the symbol sequence on page k. Starting from the top left of page k, symbol A and the remaining symbols in the symbol sequence are sequentially laid out. After reaching the right boundary, the sequence moves to the next line, and the layout continues from the left boundary of the next line until the bottom right of the page. When symbol B reaches the bottom right of the page, the ending symbol is calculated. Therefore, symbol B is confirmed as the ending symbol of page k. The position of symbol B in the symbol stream is taken as the latest ending point of the symbol interval on page k and the latest starting point of the symbol interval on page k+1.
[0089] In another embodiment, when the main thread performs typesetting calculations on the i-th segment, it obtains the symbol sequence of the corresponding interval [m1, m2] in the symbol stream according to the symbol interval [m1, m2] of the i-th segment, obtains the character measurement data of the i-th segment from the local cache, and starts typesetting calculation from the starting point of the symbol sequence of the i-th segment, that is, the m1-th character, according to the character measurement data and the updated structured object, until the m2-th character is calculated and the end character is generated. At this time, it can be confirmed that the typesetting of the i-th segment is finished, and the typesetting data obtained from the typesetting calculation from the starting point to the end point is used as the latest typesetting data of the i-th segment.
[0090] After the pre-sorting subtask of the first dirty unit is completed, the main thread enters an idle state. The scheduler can query the highest priority task in the task queue. If the pre-sorting subtask of the second dirty unit has the highest priority, the scheduler will assign the pre-sorting subtask of the second dirty unit to the main thread so that the main thread can execute the pre-sorting subtask of the second dirty unit to perform sorting calculations on the second dirty unit. When the main thread performs sorting calculations on the second dirty unit, it can index the symbol range of the second dirty unit in the first interval tree, then obtain the starting symbol of the second dirty unit, and start the sorting calculations from the starting symbol until the ending symbol of the second dirty unit is calculated.
[0091] Optionally, if the main thread confirms that the currently executing pre-sorting subtask has finished, the latest calculated sign position of the finished pre-sorting subtask is set as a checkpoint. If the next pre-sorting subtask has the highest priority in the task queue, the main thread executes the next pre-sorting subtask starting from the checkpoint. Here, the latest calculated sign position of the finished pre-sorting subtask can be understood as the latest endpoint of the data unit corresponding to the pre-sorting subtask. In this embodiment, the latest endpoint of the data unit corresponding to the pre-sorting subtask is set as the checkpoint so that when the main thread executes the next pre-sorting subtask, it can directly start the sorting calculation of the corresponding data unit from the checkpoint without querying the sign starting point of the data unit corresponding to the next pre-sorting subtask in the first interval tree, which helps improve the execution efficiency of the pre-sorting subtask. For example, after confirming that the pre-sorting subtasks of the first dirty unit have been completed, the latest endpoint of the symbol interval of the first dirty unit can be set as the checkpoint. If the scheduler determines that the main thread is idle and the pre-sorting subtasks of the second dirty unit have the highest priority in the task queue, the scheduler will assign the pre-sorting subtasks of the second dirty unit to the main thread for execution. The second dirty unit is the next dirty unit after the first dirty unit. The main thread will calculate the layout from the checkpoint. When the end symbol of the second dirty unit is calculated, the pre-sorting subtasks of the second dirty unit will be confirmed to have been completed. The layout data from the start point to the end symbol will be determined as the latest layout data of the second dirty unit, and the position of the symbol before the end symbol will be determined as the latest endpoint of the symbol interval of the second dirty unit. Based on the latest endpoint of the symbol interval of the second dirty unit, the start point of the symbol interval of the next dirty unit of the second dirty unit will be updated.
[0092] refer to Figure 4After the main thread finishes executing pre-sorting subtask k, the scheduler confirms that the main thread is idle and that pre-sorting subtask k+1 in the priority queue is the highest priority task. If so, pre-sorting subtask k+1 is retrieved and assigned to the main thread, which then executes it to perform layout calculations for page k+1. When performing layout calculations for page k, the main thread retrieves the corresponding symbol from the symbol stream based on the currently set checkpoint as the starting symbol for page k+1. Based on the character measurement data and structured objects of page k+1, the layout calculations begin from the starting symbol. After completing the layout calculation for the first starting symbol, the next symbol is retrieved from the symbol stream for layout calculation, and so on, until the end symbol is calculated. The symbol preceding the end symbol is then determined as the end symbol for page k+1. Once the end symbol of page k+1 is determined, the layout of page k+1 is considered complete. The layout data from the start symbol to the end symbol is then used as the latest layout data for page k+1. The end symbol of the symbol interval on page k+1 and the position of the symbol interval on page k+2 (preceded by the end symbol) in the first interval tree are updated, while the end symbol of the symbol interval on page k+2 remains unchanged. Then, the latest end symbol of the symbol interval on page k+1 is set as the new checkpoint, so that the main thread can begin layout calculations for page k+2 from this checkpoint.
[0093] It's important to note that when a document contains spanning cells and the data unit is a data page, these spanning cells will spread from the previous data page to the next, affecting the layout of the subsequent data page. To ensure correct layout on the next data page, layout calculations are often performed starting from the beginning of the spanning cell. For example, when the data unit is a data page, the data model also includes spanning cells that spread from the first data page to the second data page. When the main thread is assigned a pre-layout subtask for the second data page, the main thread starts layout calculations from the beginning of the symbol interval of the spanning cell. When the end marker of the second data page is calculated, the pre-layout subtask for the second data page is considered complete, and the layout data from the beginning to the end marker of the symbol interval of the second data page is determined as the latest layout data for the second data page. The position of the symbol preceding the end marker is determined as the latest end point of the symbol interval of the second data page. Based on the latest end point of the symbol interval of the second data page, the beginning of the symbol interval of the next data page is updated.
[0094] Figure 6 This is a schematic diagram of a cross-page cell provided in an embodiment of this application. For example... Figure 6As shown, in the six-row, seven-column grid, all cells in the fourth row are page-crossing cells, laid out from the first data page to the second data page. After laying out the first data page, the main thread confirms that all cells in the fourth row are page-crossing cells, and then determines the positions of the start and end symbols in the symbol stream as the start and end points of the symbol interval for the corresponding page-crossing cells. When the main thread performs layout calculations for the second data page, it obtains the symbol intervals of the page-crossing cells laid out from the first data page to the second data page, and starts the layout calculation from the start symbol of the page-crossing cell with the smallest symbol interval, that is, from... Figure 6 The layout calculation begins with the starting symbol X in the cell of the fourth row and first column, and continues until the ending symbol Y of that cell is reached. Then, the layout calculation begins again with the starting symbol in the cell of the fourth row and second column, and continues until the ending symbol of that cell is reached. This process is repeated for all cells spanning multiple pages. After completing the layout calculation for the entire table, the layout calculation begins for the latter half of the second data page, continuing until the end symbol of the second data page is determined. The symbol preceding the end symbol is then identified as the end symbol of the second data page. Once the end symbol of the second data page is determined, the layout of the second data page is considered complete. The layout data from the starting symbol to the end symbol is then used as the latest layout data for the second data page. The end symbol of the symbol interval for the second data page in the first interval tree and the starting symbol of the corresponding next data page are updated to the position preceding the end symbol. The end symbol of the next data page remains unchanged.
[0095] It should be noted that although the second data page is calculated and formatted starting from the beginning of the cross-page cell, this beginning is already determined when the first data page is formatted. Therefore, the main thread can clearly identify which formatted data belongs to the first data page and which belongs to the second, ensuring page formatting accuracy. In this embodiment, when calculating the formatting of data pages containing portions after cross-page cells, the calculation begins from the starting position of the cross-page cell, ensuring the formatting accuracy of cross-page cells and paragraphs within the data page.
[0096] In the above embodiment, the main thread can continuously execute pre-scheduled subtasks, meaning the main thread only enters an idle state after all pre-scheduled subtasks are completed. If a higher-priority interactive response task or timed rendering task is added to the priority queue while the main thread is executing pre-scheduled subtasks, the priority queue automatically moves the interactive response task or timed rendering task to the head of the queue. After the main thread finishes executing the pre-scheduled subtasks and enters an idle state, the scheduler can allocate the interactive response task or timed rendering task to the main thread, allowing the main thread to prioritize interactive operations to avoid interactive response delays and timed page rendering to avoid page frame rate drops. For example, Figure 7This is a schematic diagram of the task enqueueing process provided in an embodiment of this application. For example... Figure 7 As shown, when the main thread generates a new interactive response task while executing pre-scheduled subtask k, the interactive response task has a higher priority than the pre-scheduled subtasks divided from the background pre-scheduled tasks. After being enqueued, the interactive response task is automatically placed before pre-scheduled subtask k+1, that is, at the head of the task queue. Figure 7 The task queue is used for scheduling. After the main thread finishes executing the pre-sorting subtask k, the scheduler retrieves the interactive response task and assigns it to the main thread. The main thread prioritizes responding to interactive operations to avoid delays in interactive responses. Once the main thread finishes processing the interactive response task and enters an idle state, and the pre-sorting subtask k+1 has the highest priority in the current task queue, the scheduler assigns pre-sorting subtask k+1 to the main thread, allowing the main thread to execute the layout calculation for page k+1.
[0097] If the execution time of pre-scheduled subtasks is long, the main thread's completion of these subtasks before entering an idle state can cause congestion in the queue of interactive response tasks or scheduled rendering tasks, resulting in latency in interactive responses and a decrease in page frame rate. To address this, a preset maximum execution time for pre-scheduled subtasks can be set. Once the cumulative execution time exceeds this preset time, the pre-scheduled subtasks are interrupted, forcing the main thread into an idle state. This allows the idle main thread to process interactive response tasks or scheduled rendering tasks in the queue, preventing long execution times of pre-scheduled subtasks from blocking the main thread and ensuring normal functionality within the visible area. Specifically, the cumulative execution time of pre-scheduled subtasks is detected. If the cumulative time is greater than or equal to the preset time, the currently executing pre-scheduled subtask is interrupted, and the latest calculated sign position of the currently executing pre-scheduled subtask is set as a checkpoint. If the interrupted pre-scheduled subtask has the highest priority in the task queue, the main thread resumes execution from the checkpoint.
[0098] Figure 8 This is a schematic diagram illustrating the process of interrupting and resuming pre-arranged subtasks according to an embodiment of this application. For example... Figure 8 As shown, during the execution of pre-sorting subtask k by the main thread, the cumulative execution time of pre-sorting subtask k is counted. When the cumulative duration exceeds the preset duration of 5ms, the main thread interrupts pre-sorting subtask k and sets the sign position of the latest layout calculation in pre-sorting subtask k as the checkpoint. (Reference) Figure 5Assuming the main thread is calculating the layout of symbol C on page k, the position of symbol C in the symbol stream is set as a checkpoint. After the main thread interrupts pre-layout subtask k and enters an idle state, the scheduler, upon confirming the main thread's idle state, compares the priority of the interactive response task at the head of the priority queue with the priority of the interrupted pre-layout subtask k. Since the interactive response task has a higher priority than pre-layout subtask k, the scheduler retrieves the interactive response task and assigns it to the main thread, which then executes it. After retrieving the interactive response task, the head of the priority queue is automatically updated to pre-layout subtask k+1. After the main thread completes the interactive response task and enters an idle state again, the scheduler, upon confirming the main thread's idle state, compares the priority of the pre-layout subtask k+1 at the head of the priority queue with the priority of the interrupted pre-layout subtask k. Since the interrupted pre-layout subtask k has a higher priority, the scheduler allows the main thread to continue executing pre-layout subtask k. The main thread continues the layout calculation for page k from the layout position of symbol C until the next interruption occurs or the end symbol is calculated. This embodiment limits the cumulative duration of continuous pre-arrangement of sub-tasks on the main thread to prevent the main thread from being blocked due to prolonged execution of pre-arrangement sub-tasks. This ensures that the main thread can process interactive operations and timed page refreshes in a timely manner, guaranteeing the document's interactive response speed and rendering frame rate.
[0099] The main thread can enter an idle state after the pre-assigned subtasks have finished executing, waiting for the scheduler to assign the highest-priority task in the queue to the main thread before it re-enters the working state. If the main thread takes too short a time to complete the pre-assigned subtasks, it will frequently enter an idle state, affecting its running efficiency. Therefore, if the cumulative time is less than a preset time, and the main thread confirms that the currently executing pre-assigned subtask has finished, it will continue executing the next pre-assigned subtask. (See reference) Figure 7 The main thread executes pre-assigned subtask k in only 2ms. Therefore, the scheduler assigns pre-assigned subtask k+1 to the main thread to continue execution, preventing the main thread from entering an idle state and ensuring the continuity of the main thread's work. Even if a new interactive response task is enqueued during the execution of pre-assigned subtask k, the scheduler will not assign the interactive response task to the main thread. The execution time of pre-assigned subtask k+1 is accumulated with the execution time of pre-assigned subtask k to obtain the cumulative execution time of pre-assigned subtasks. When the execution time of pre-assigned subtask k+1 reaches 3ms, and the cumulative time reaches the preset time of 5ms, the main thread interrupts pre-assigned subtask k+1 and enters an idle state. Afterward, the scheduler assigns interactive response tasks to the main thread for execution to avoid long waiting times for interactive response tasks, balancing the continuity of the main thread's work and the speed of interactive responses.
[0100] In one embodiment, after multiple pre-scheduled subtasks, divided into background pre-scheduled tasks, are stored in the task queue, if the terminal device receives a new editing operation, a new dirty unit is marked based on the newly received editing operation, and a corresponding new background pre-scheduled task is generated based on the new dirty unit. This new background pre-scheduled task is then divided into multiple pre-scheduled subtasks. Correspondingly, upon receiving a new editing operation, after generating at least one pre-scheduled subtask based on the new editing operation, if the data unit corresponding to the newly generated pre-scheduled subtask is the same as the data unit corresponding to a pre-scheduled subtask in the task queue, the newly generated pre-scheduled subtask is deleted; the remaining pre-scheduled subtasks are stored in the task queue. For example, Figure 9 This is a schematic diagram illustrating the process of queuing subtasks generated by the new editing operation provided in an embodiment of this application. (Reference) Figure 9 The background pre-scheduling task generated by the previous editing operation is divided into pre-scheduling sub-tasks k, k+1, k+2, and k+3 and stored in the task queue. When the main thread executes pre-scheduling sub-task k, the terminal device receives a new editing operation and generates pre-scheduling sub-tasks k+2, k+3, and k+4. Since the newly generated pre-scheduling sub-tasks k+2 and k+3 are identical to those stored in the task queue, only pre-scheduling sub-tasks k+2 and k+3 are added to the task queue. Because pre-scheduling sub-task k+4 has a lower priority than pre-scheduling sub-task k+3 during generation, it is automatically placed after pre-scheduling sub-task k+3 after being stored in the task queue. This embodiment avoids repeated layout calculations for the same data unit by aggregating and deduplicating the pre-scheduling sub-tasks generated by the newly received editing operation with the pre-scheduling sub-tasks in the task queue, thus saving layout calculation resources.
[0101] Of course, if the new editing operation also generates a new local layout task, the local layout task will be stored at the head of the priority queue so that the scheduler will prioritize the allocation of the new local layout task to the main thread for execution, ensuring priority layout and rendering of the visible area, and achieving a fast response to local user editing.
[0102] As described above, when the main thread executes the pre-sorting subtask of dirty units, it retrieves the character measurement data of the dirty units from the local cache. Based on this character measurement data, it performs layout calculations on the dirty units to update the layout data and symbol range. Therefore, with the terminal device locally caching the character measurement data and layout data of all data units, after dividing the background pre-sorting task into multiple pre-sorting subtasks, these subtasks are stored in a task queue. The main thread then performs layout calculations based on the locally cached character measurement data when executing these subtasks.
[0103] In another embodiment, if the terminal device only caches the layout data and character measurement data of the first data unit and its preset neighborhood data units locally, without caching the layout data and character measurement data of the remaining data units, the character measurement data of some dirty units will be missing, and the main thread cannot execute the pre-layout subtasks of these dirty units. Therefore, these dirty units need to be converted from pre-layout subtasks to recovery subtasks. The recovery subtasks instruct the main thread to perform character measurement on the dirty units, and then perform layout calculations based on the data obtained from the character measurement, ensuring the layout feasibility of the dirty units. Since the data model stores the symbol intervals of the remaining data units through a second interval tree, it can determine whether the character measurement data of the dirty units is cached locally by using the symbol intervals recorded in the second interval tree, thereby determining whether to convert the pre-layout subtasks of the dirty units into recovery subtasks. Specifically, if the second interval tree stores the symbol intervals of the dirty units, the pre-layout subtasks corresponding to the dirty units are converted into recovery subtasks; the recovery subtasks are used to instruct character measurement and layout calculations on the dirty units, and the recovery subtasks and pre-layout subtasks are sorted according to a preset priority.
[0104] For example, suppose the first data unit corresponding to the visible area is page k, and the data units within its preset neighborhood range are k-15 to k+15. The dirty units marked by the editing operation include pages k-17 to k+3. Then, the background pre-sorting task will divide the pre-sorting sub-tasks corresponding to pages k-17 to k+3 one by one. The symbol range of page k-17 is indexed in the second interval tree. The indexed corresponding tree node indicates that the second interval tree stores the symbol range of page k-17, thus confirming that the character measurement data of page k-17 is not cached locally. Therefore, the pre-sorting sub-task of page k-17 is converted into a recovery sub-task so that the main thread can measure the character measurement data of page k-17 before performing the layout calculation, ensuring the correct execution of the task. Similarly, the symbol range of page k-16 is also stored in the second interval tree, and the pre-sorting sub-task of page k-16 is converted into a recovery sub-task. If the symbol range of the remaining dirty units is not stored in the second interval tree, then the remaining dirty units are kept as pre-sorted subtasks.
[0105] The preset priorities of pre-sorting and recovery subtasks can be determined based on the distribution position of the corresponding dirty units in the document; for example, the earlier the dirty unit is in the document, the higher its preset priority. Optionally, multiple dirty units can be grouped according to layout dependencies, with dirty units that have layout dependencies grouped into the same group and those that do not have layout dependencies grouped into different groups. Then, the priorities of the pre-sorting and recovery subtasks corresponding to dirty units within the same group are sorted according to the distribution position of the dirty units in the document, while the priorities of the pre-sorting and recovery subtasks corresponding to dirty units in different groups are sorted according to their positional relationship with the first data unit. Alternatively, the priorities of the pre-sorting and recovery subtasks corresponding to dirty units in different groups can be sorted according to the user's reading frequency of each group of dirty units.
[0106] The recovery subtask and pre-layout subtask are stored in a priority queue. Assuming any two adjacent pages from page k-17 to page k+3 have a layout dependency, the recovery subtasks for pages k-17 and k-16 have a higher priority than the other pre-layout subtasks. Therefore, the order of the recovery subtasks for pages k-17, k-16, and the pre-layout subtasks from page k-15 to k+3 in the priority queue is from front to back. The scheduler will first assign the recovery subtask for page k-17 to the main thread for execution, ensuring that the main thread's layout order for dirty data pages is from front to back, thus guaranteeing document layout accuracy.
[0107] This embodiment utilizes a second interval tree to query whether the character measurement data of dirty units is cached locally. If the character measurement data of dirty units is not cached locally, the pre-sorting subtask of the dirty unit is converted into a recovery subtask, ensuring that the main thread performs character measurement on the dirty unit before performing the sorting calculation, thus guaranteeing the normal execution of the task.
[0108] In one embodiment, when a user triggers a view area switching operation (such as sliding the view window, clicking the page break control, or clicking the window sliding control), the view area and the corresponding first data unit will change. To ensure that the locally cached layout data can continuously support the sliding of the view area, once the first data unit changes, the terminal device will update the data units of the locally cached layout data accordingly, so that the data units of the locally cached layout data are always the first data unit corresponding to the latest view area and the data units within its neighborhood. Specifically, upon receiving a view area switching operation, the terminal device moves the view area according to the operation and determines the unit to be restored; during idle periods, it generates character measurement data and layout data for each unit to be restored based on the data model and updates the symbol range of the unit to be restored. The unit to be restored is a data unit that is within the neighborhood of the new first data unit but whose layout data and character measurement data are not cached locally. For example, if the view area moves from page k to page k+2, the first data unit and its neighborhood range become pages k-13 to k+17. Pages k+16 and k+17 enter the neighborhood of the new first data unit. However, a query using the second interval tree confirms that the local cache for the layout and character measurement data of these two pages is not yet available. Therefore, pages k+16 and k+17 are marked as units to be recovered. During idle periods, character measurements are performed on page k+16 based on the data model, followed by layout calculations to generate the character measurement and layout data for page k+16. Then, character measurements are performed on page k+17 based on the data model, followed by layout calculations to generate the same data. After generating the character measurement and layout data for pages k+16 and k+17, this data is cached locally, and the locally cached character measurement and layout data for pages k-15 and k-14 are cleared. The symbol intervals in the second interval tree are synchronously updated to ensure that the second interval tree accurately reflects the locally cached data.
[0109] Optionally, after the view area changes, the user may switch the view area to the unit to be restored where the local layout data is not cached. In the previous embodiment, to ensure accurate layout of the unit to be restored, the restoration subtasks of the units to be restored were executed sequentially according to the distribution order of the data units in the document. This would undoubtedly require the user to wait for the subsequent restoration subtasks to complete before switching the view area to the corresponding data unit, affecting the user experience. To address this, after determining the unit to be restored based on the view area switching operation, the distance between the unit to be restored and the view area can be determined. The restoration subtask of the unit to be restored closest to the view area is given the highest priority to restore the layout data of that unit first. This allows for a quick response when the user switches the view area to that unit, and the layout content of the unit to be restored is rendered in the view area. After prioritizing the execution of the restoration subtask of the unit to be restored closest to the view area, the restoration subtasks of the units to be restored are executed sequentially according to the distribution order of each unit to be restored to ensure the accuracy of the subsequently restored layout data.
[0110] In this embodiment, a recovery subtask can be generated for each unit to be recovered. The recovery subtask is stored in a task queue, and the scheduler assigns it to the main thread for execution when the main thread is idle and there are no higher-priority tasks. Optionally, if the cumulative execution time of the recovery subtask by the main thread exceeds a preset time, the execution of the recovery subtask is interrupted and a checkpoint is recorded. The execution of the recovery subtask will continue after the main thread has finished processing other higher-priority tasks.
[0111] Under the aforementioned recovery mechanism, if the recovery subtasks and / or pre-sorting subtasks in the task queue have not been completed, and the local user triggers a visible area switching operation again, a newly generated recovery subtask may correspond to the same dirty unit as a recovery subtask in the task queue. To prevent recalculation of character measurement and layout for the same dirty unit, the newly generated recovery subtask and the recovery subtasks in the task queue can be aggregated and deduplicated, deleting redundant recovery subtasks. Specifically, upon receiving a visible area switching operation, the visible area is adjusted according to the operation, and the unit to be recovered is determined. A corresponding recovery subtask is generated based on the unit to be recovered. If the data unit corresponding to the newly generated recovery subtask is the same as the data unit corresponding to the recovery subtask in the task queue, the recovery subtask is deleted. The remaining recovery subtasks are stored in the task queue. For example, if the visible area moves from page k to page (k-2), the first data unit and its neighborhood range become pages (k-17 to k+13). Then, pages (k-17 and k-16) are marked as units to be recovered. For pages k-17 and k-16, recovery subtasks k-17 and k-16 are generated. If the data pages marked as dirty in the previous edit operation were pages k-16 to k-10, and the previously visible area was still on page k, with the corresponding first data unit and its neighborhood range still being pages k-15 to k+15, the edit operation will generate recovery subtask k-16 and pre-sorting subtasks k-15 to k-10. If the task queue still stores recovery subtask k-16 and pre-sorting subtasks k-15 to k-10 when the visible area switching operation is triggered, then only the newly generated recovery subtask k-16 needs to be deleted, and then recovery subtask k-17 needs to be added to the task queue. As a priority queue, the task queue determines that the priority of recovery subtask k-17 is higher than that of recovery subtask k-16, and therefore automatically places recovery subtask k-17 before recovery subtask k-16. In this embodiment, after generating a recovery subtask based on the visual area switching operation, the newly generated recovery subtask is aggregated and deduplicated with the recovery subtasks in the task queue to avoid storing recovery subtasks with the same data unit in the task queue, thereby reducing invalid character measurement and typesetting calculations and improving document typesetting efficiency.
[0112] Optionally, after generating a new recovery subtask based on the view area switching operation, if this new recovery subtask and a recovery subtask in the task queue point to the same unit to be recovered, and the unit to be recovered corresponding to this recovery subtask is closest to the latest view area, then the priority of this recovery subtask is raised to the highest and stored in the task queue. At this time, the task queue stores two recovery subtasks pointing to the same unit to be recovered, but one of the recovery subtasks has the highest priority, and the priority of the other recovery subtask is sorted according to the distribution order of the units to be recovered. The recovery subtask with the highest priority allows the main thread to recover the layout data of the unit to be recovered first, so that when the user slides the view area to the unit to be recovered, the layout data can be loaded for layout rendering, improving the response speed to the view area switching operation. The recovery subtask with normal priority allows the main thread to execute the pre-layout subtask and the recovery subtask in the order of the data unit distribution, ensuring the accurate calculation of the layout data. For example, if the currently visible area is page k, and the local storage only contains layout data and character measurement data for pages k-15 to k+15, when a collaborative editing operation modifies page k-16, a restore subtask will be generated for page k-16, and pre-layout subtasks will be generated for pages k-15 to k. Subsequently, the visible area quickly scrolls to page k+13, and corresponding restore subtasks are added for pages k+16 to k+28. The priority of the restore subtask for page k+16 is increased (this example only shows increasing the priority of one restore subtask; multiple restore subtasks can be increased simultaneously) to prioritize the execution of the restore subtask for page k+16. Assuming the restore subtask for page k-16 has already been executed, but the pre-layout subtasks for pages k-15 to k have not yet been executed, the pre-layout subtasks for pages k-15 to k and the restore subtasks for pages k+16 to k+28 must be executed sequentially.
[0113] After the main thread completes the recovery subtask to generate the character measurement data and layout data for the corresponding data unit, it can query whether the data unit is within the latest first data unit and its neighborhood (because the view area switching operation will cause the first data unit to change, making the data unit enter the neighborhood of the latest first data unit). If yes, the character measurement data and layout data of the data unit are cached locally, and the second interval tree is updated synchronously; otherwise, the character measurement data and layout data of the data unit are deleted.
[0114] If a dirty cell in a pre-sorted subtask in the task queue is moved out of the neighborhood of the new first data cell due to a visual area switching operation, the terminal device may not clear the character measurement data of the dirty cell in the local cache. Instead, it may wait until the pre-sorted subtask is completed and the symbol range of the dirty cell is updated before clearing the character measurement data of the dirty cell. This avoids the pre-sorted subtask from failing to execute properly due to the lack of character measurement data of the corresponding dirty cell, thus ensuring the reliability of task execution.
[0115] Furthermore, if multiple recovery subtasks generated by the visual area switching operation are stored in the task queue, and the terminal device receives a new editing operation and generates recovery subtasks and pre-arranged subtasks based on the new editing operation, the newly generated recovery subtasks can be aggregated with the recovery subtasks in the task queue to remove duplicates, thereby filtering redundant recovery subtasks and avoiding duplicate processing of recovery subtasks for the same data unit.
[0116] In one embodiment, after completing the layout rendering of the visible area, comment data associated with corresponding symbols can be rendered in the visible area to avoid page lag and unresponsiveness caused by rendering a large number of comments. Specifically, after rendering the document layout of the visible area based on the layout data of the first data unit, comment data associated with the first symbol in the visible area is obtained; the rendering position of the comment data is determined based on the layout position of the first symbol; and the comment data is rendered in the visible area based on the rendering position. Here, the first symbol is a symbol associated with comment data in the visible area. The comment data set of the document can be traversed based on the range of symbols in the visible area to obtain comment data associated with the first symbol in the visible area. The layout position of the associated comment is calculated based on the layout position of the first symbol, and then the rendering coordinates of the comment are determined based on the layout position of the comment to ensure that the rendering coordinates of the comment and the symbol correspond precisely. Finally, the text content of the comment data is rendered in the visible area based on the rendering coordinates of the comment, thereby achieving targeted rendering of comment content associated with symbols in the visible area and lightweight display of document comments.
[0117] In summary, the collaborative document editing layout method provided in this application updates the layout data of the first data unit when the data unit whose layout has changed includes the first data unit corresponding to the visible area after the data model is updated based on the editing operation. The document layout of the visible area is then rendered based on the updated layout data of the first data unit, thus completing the layout update of the document content in the visible area. Through this technical means, when a document's data unit undergoes a layout change, the first data unit displayed in the visible area is located, thereby prioritizing a local update of the document layout in the visible area. This avoids a global update of the layout from beginning to end before rendering the document layout in the visible area. The main thread is no longer preempted by a large number of layout tasks; instead, it prioritizes updating the layout of the visible area and responding to user interactions. This improves the rendering efficiency of the document page in the visible area and the response efficiency of user interactions, solving the problems of low page rendering frame rate and high interaction response latency in the prior art, and improving the collaborative editing experience and operational smoothness of the document.
[0118] Based on the above embodiments, Figure 10 This is a schematic diagram of a collaborative document editing and typesetting device provided in an embodiment of this application. (Reference) Figure 10 The collaborative document editing layout device provided in this embodiment specifically includes: a local layout update module 21 and a visible area rendering module 22.
[0119] Among them, the partial layout update module 21 is configured to update the layout data of the first data unit when the data unit whose layout has been changed in the updated data model includes the first data unit corresponding to the visible area after the data model is updated based on the editing operation. The visible area rendering module 22 is configured to render the document layout of the visible area based on the layout data updated by the first data unit.
[0120] Based on the above embodiments, the collaborative document editing layout device further includes: a background layout update module, configured to update the layout data of each layout-changed data unit during idle periods after rendering the document layout of the visible area based on the layout data updated according to the first data unit.
[0121] Based on the above embodiments, the symbol stream of the data model consists of symbols of multiple data units, each data unit corresponding to its own symbol range; correspondingly, the layout device for collaborative editing documents further includes: a data model update module, configured to determine the corresponding edited data unit according to the editing position of the symbol addition / deletion operation when the editing operation includes symbol addition / deletion operation, update the symbol range of the corresponding edited data unit according to the symbol addition / deletion operation, and update the symbol range of subsequent data units according to the latest symbol range of the edited data unit.
[0122] Based on the above embodiments, the collaborative document editing layout device further includes: a first dirty unit module, configured to determine the starting change data unit according to the updated data model after the data model is updated based on the editing operation; determine the dependent change data units in the updated data model whose layout depends on the starting change data unit; and mark the starting change data unit and the dependent change data units as dirty units.
[0123] Based on the above embodiments, the editing operation includes multiple operations, which sequentially trigger the updating of the data model and the labeling of data units with layout changes. Correspondingly, the layout device for collaborative document editing also includes a labeling aggregation module configured to aggregate and deduplicate the dirty units corresponding to multiple operations after the data model is updated based on the editing operation, thereby obtaining the dirty units in the updated data model corresponding to the editing operation.
[0124] Based on the above embodiments, the layout data and character measurement data of the first data unit and the data units within its preset neighborhood are cached locally, while the layout data and character measurement data of the remaining data units are not cached locally.
[0125] Based on the above embodiments, the layout device for collaborative document editing further includes: a second dirty labeling module, configured to mark data units that have undergone layout changes and are located before the neighboring end unit corresponding to the first data unit as dirty units after the data model is updated based on the editing operation; wherein, the neighboring end unit is a data unit located at the end of a preset neighborhood range of the first data unit.
[0126] Based on the above embodiments, the collaborative document editing layout device includes: a layout task processing module, configured to mark data units with layout changes in the updated data model as dirty units after the data model is updated based on an editing operation; generate background pre-layout tasks based on the dirty units, which are used to indicate the updating of the layout data of the dirty units; when the dirty unit includes a first data unit corresponding to the visible area, generate a local layout task based on the first data unit, which is used to indicate the updating of the layout data of the first data unit and the re-rendering of the document layout of the visible area; store the local layout tasks and the background pre-layout tasks in a task queue, with the local layout tasks having a higher priority than the background pre-layout tasks; and allocate the tasks in the task queue to the main thread for execution in sequence based on priority using a scheduler.
[0127] Based on the above embodiments, the typesetting task processing module includes a subtask division submodule, which is configured to divide the background pre-sorting task into multiple pre-sorting subtasks corresponding to multiple dirty units after generating the background pre-sorting task based on dirty units, in the case that the updated data model includes multiple dirty units, and the pre-sorting subtasks are sorted based on a preset priority.
[0128] Based on the above embodiments, the typesetting task processing module includes: a task allocation submodule, configured to allocate the pre-sorting subtask of the first dirty unit to the main thread for execution when the scheduler determines that the pre-sorting subtask of the first dirty unit has the highest priority in the task queue; a first typesetting calculation submodule, configured to start typesetting calculation from the beginning of the symbol interval of the first dirty unit through the main thread, confirm the end of the pre-sorting subtask of the first dirty unit when the end symbol of the first dirty unit is calculated, and determine the typesetting data from the beginning to the end symbol as the latest typesetting data of the first dirty unit, and determine the position of the symbol before the end symbol as the latest end point of the symbol interval of the first dirty unit; and a first interval update submodule, configured to update the beginning of the symbol interval of the next dirty unit of the first dirty unit according to the latest end point of the symbol interval of the first dirty unit.
[0129] Based on the above embodiments, the data unit is a data page, and the data model also includes cross-page cells from the first data page to the second data page; correspondingly, the layout task processing module includes: a second layout calculation submodule, configured to, when the main thread assigns a pre-layout sub-task to the second data page, start layout calculation from the beginning of the symbol interval of the cross-page cell through the main thread, confirm the end of the pre-layout sub-task of the second data page when the end symbol of the second data page is calculated, and determine the layout data from the beginning to the end symbol of the second data page as the latest layout data of the second data page, and determine the position of the symbol before the end symbol as the latest end point of the symbol interval of the second data page; a second interval update submodule, configured to update the beginning of the symbol interval of the next data page of the second data page according to the latest end point of the symbol interval of the second data page.
[0130] Based on the above embodiments, the typesetting task processing module includes: a first checkpoint setting submodule, configured to set the latest calculated symbol position of the completed pre-sorting subtask as a checkpoint when the main thread confirms that the currently executed pre-sorting subtask has finished executing; and a first task execution submodule, configured to execute the next pre-sorting subtask from the checkpoint through the main thread when the next pre-sorting subtask has the highest priority in the task queue.
[0131] Based on the above embodiments, the typesetting task processing module includes: a duration detection submodule, configured to detect the cumulative duration of the main thread continuously executing pre-sorting sub-tasks; a second checkpoint setting submodule, configured to interrupt the currently executing pre-sorting sub-task of the main thread and set the latest calculated sign position of the currently executing pre-sorting sub-task as the checkpoint when the cumulative duration is greater than or equal to a preset duration; and a second task execution submodule, configured to continue executing the interrupted pre-sorting sub-task from the checkpoint through the main thread when the interrupted pre-sorting sub-task has the highest priority in the task queue.
[0132] Based on the above embodiments, the typesetting task processing module includes: a first task generation submodule, configured to generate at least one pre-typesetting sub-task based on a new editing operation after storing the local typesetting task and the background pre-typesetting task into the task queue; a first deletion submodule, configured to delete the corresponding newly generated pre-typesetting sub-task if the data unit corresponding to the newly generated pre-typesetting sub-task is the same as the data unit corresponding to the pre-typesetting sub-task in the task queue; and a first enqueue submodule, configured to store the remaining pre-typesetting sub-tasks into the task queue.
[0133] Based on the above embodiments, the layout data and character measurement data of the first data unit and the data units within its preset neighborhood are cached locally, while the layout data and character measurement data of the remaining data units are not cached locally; the symbol intervals of the remaining data units are stored through the corresponding tree nodes in the second interval tree; correspondingly, the layout task processing module further includes: a subtask conversion submodule, configured to, after dividing the background pre-layout task into multiple pre-layout subtasks corresponding to multiple dirty units, if the second interval tree stores the symbol intervals of dirty units, convert the pre-layout subtasks corresponding to the dirty units into recovery subtasks; the recovery subtasks are used to indicate character measurement and layout calculation for dirty units, and the recovery subtasks and pre-layout subtasks are sorted based on a preset priority.
[0134] Based on the above embodiments, the typesetting task processing module includes: a second task generation submodule, configured to, after dividing the background pre-scheduling task into multiple pre-scheduling subtasks corresponding to multiple dirty units, adjust the visible area according to the visible area switching operation and determine the unit to be restored, and generate the corresponding restoration subtask based on the unit to be restored; a second deletion submodule, configured to delete the restoration subtask if the data unit corresponding to the newly generated restoration subtask is the same as the data unit corresponding to the restoration subtask in the task queue; and a second enqueue submodule, configured to store the remaining restoration subtasks into the task queue.
[0135] Based on the above embodiments, the collaborative document editing layout device further includes: a comment rendering module, configured to, after rendering the document layout of the visible area according to the layout data of the first data unit, obtain comment data associated with a first symbol in the visible area; determine the rendering position of the comment data according to the layout position of the first symbol; and render the comment data in the visible area according to the rendering position.
[0136] The collaborative document editing layout device provided in this application, after the data model is updated based on an editing operation, updates the layout data of the first data unit when the data unit whose layout has changed in the updated data model includes the first data unit corresponding to the visible area; and renders the document layout of the visible area according to the updated layout data of the first data unit, thereby completing the layout update of the document content in the visible area. Through the above technical means, when a document's data unit undergoes a layout change, the first data unit displayed in the visible area is located, thus prioritizing the local update of the document layout in the visible area. This avoids a global update of the layout from beginning to end before rendering the document layout in the visible area. The main thread is no longer preempted by a large number of layout tasks, but instead prioritizes updating the layout of the visible area and responding to user interactions, improving the rendering efficiency of the document page in the visible area and the response efficiency of user interactions. This solves the problems of low page rendering frame rate and high interaction response latency in the prior art, improving the collaborative editing experience and operational smoothness of documents.
[0137] The collaborative document typesetting device provided in this application embodiment can be used to execute the collaborative document typesetting method provided in the above embodiment, and has corresponding functions and beneficial effects.
[0138] Figure 11 This is a schematic diagram of the structure of a collaborative document editing typesetting device provided in an embodiment of this application, with reference to... Figure 11 The collaborative document editing typesetting device includes a processor 31, a memory 32, a communication device 33, an input device 34, and an output device 35. The number of processors 31 and the number of memories 32 in the collaborative document editing typesetting device can be one or more. The processor 31, memory 32, communication device 33, input device 34, and output device 35 of the collaborative document editing typesetting device can be connected via a bus or other means.
[0139] The memory 32, as a computer-readable storage medium, can be used to store software programs, computer-executable programs, and modules, such as program instructions / modules corresponding to the collaborative document editing typesetting method in any embodiment of this application (e.g., the partial typesetting update module 21 and the visible area rendering module 22 in the collaborative document editing typesetting device). The memory 32 may primarily include a program storage area and a data storage area. The program storage area may store the operating system and at least one application program required for a function; the data storage area may store data created based on the use of the device, etc. Furthermore, the memory 32 may include high-speed random access memory and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other non-volatile solid-state storage device. In some instances, the memory may further include memory remotely located relative to the processor, and these remote memories can be connected to the device via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0140] The communication device 33 is used for data transmission.
[0141] The processor 31 executes various functional applications and data processing of the device by running software programs, instructions and modules stored in the memory 32, thereby realizing the above-mentioned collaborative document editing layout method.
[0142] Input device 34 can be used to receive input digital or character information, and to generate key signal inputs related to user settings and function control of the device. Output device 35 may include display devices such as a display screen.
[0143] The collaborative document typesetting device provided above can be used to execute the collaborative document typesetting method provided in the above embodiments, and has corresponding functions and beneficial effects.
[0144] This application embodiment also provides a storage medium containing computer-executable instructions. When executed by a computer processor, the computer-executable instructions are used to execute a collaborative document editing layout method. The collaborative document editing layout method includes: after the data model is updated based on an editing operation, if the data unit whose layout has been changed in the updated data model includes a first data unit corresponding to the visible area, updating the layout data of the first data unit; and rendering the document layout of the visible area according to the updated layout data of the first data unit.
[0145] Storage medium – any type of memory device or storage device. The term “storage medium” is intended to include: mounting media, such as CD-ROM, floppy disk, or magnetic tape devices; computer system memory or random access memory, such as DRAM, DDR RAM, SRAM, EDO RAM, Rambus RAM, etc.; non-volatile memory, such as flash memory, magnetic media (e.g., hard disk or optical storage); registers or other similar types of memory elements, etc. Storage medium may also include other types of memory or combinations thereof. Furthermore, storage medium may reside in a first computer system in which the program is executed, or it may reside in a different second computer system connected to the first computer system via a network (such as the Internet). The second computer system can provide program instructions to the first computer for execution. The term “storage medium” can include two or more storage media residing in different locations (e.g., in different computer systems connected via a network). Storage medium may store program instructions (e.g., specifically implemented as a computer program) executable by one or more processors.
[0146] Of course, the computer-executable instructions provided in the embodiments of this application are not limited to the collaborative document editing layout method described above, but can also execute related operations in the collaborative document editing layout method provided in any embodiment of this application.
[0147] The collaborative document typesetting device, storage medium, and collaborative document typesetting equipment provided in the above embodiments can execute the collaborative document typesetting method provided in any embodiment of this application. For technical details not described in detail in the above embodiments, please refer to the collaborative document typesetting method provided in any embodiment of this application.
[0148] The above description is merely a preferred embodiment and the technical principles employed in this application. This application is not limited to the specific embodiments described herein, and various obvious changes, readjustments, and substitutions that can be made by those skilled in the art will not depart from the scope of protection of this application. Therefore, although this application has been described in detail through the above embodiments, this application is not limited to the above embodiments, and may include many other equivalent embodiments without departing from the concept of this application. The scope of this application is determined by the scope of the claims.
Claims
1. A collaborative document editing and formatting method, characterized in that, include: When the data model is updated based on an editing operation, if the data unit whose layout has been changed in the updated data model includes the first data unit corresponding to the visible area, the layout data of the first data unit is updated. The document layout of the visible area is rendered based on the layout data updated by the first data unit.
2. The collaborative document editing and formatting method according to claim 1, characterized in that, After rendering the document layout of the visible area based on the layout data updated according to the first data unit, the method further includes: During idle periods, update the layout data of each data unit for the aforementioned layout change.
3. The collaborative document editing and formatting method according to claim 1, characterized in that, The symbol stream of the data model consists of symbols of multiple data units, each data unit corresponding to its own symbol range; Accordingly, the process of triggering an update of the data model based on an edit operation also includes: When the editing operation includes symbol addition and deletion operations, the corresponding data unit to be edited is determined according to the editing position of the symbol addition and deletion operation, and the symbol range of the corresponding data unit to be edited is updated according to the symbol addition and deletion operation. The sign interval of subsequent data units is updated based on the latest sign interval of the edited data unit.
4. The collaborative document editing and formatting method according to claim 1, characterized in that, The data model, after being updated based on an edit operation, also includes: The initial data unit for change is determined based on the updated data model; In the updated data model, the data units whose layout depends on the initial changed data unit are identified as dependent changed data units. The initial change data unit and the dependent change data unit are marked as dirty units.
5. The collaborative document editing layout method according to claim 1, characterized in that, The editing operation includes multiple operations, which sequentially trigger the updating of the data model and the labeling of data units with layout changes; Accordingly, after the data model is updated based on an edit operation, it also includes: The dirty units corresponding to the multiple operations are aggregated and deduplicated to obtain the dirty units in the updated data model corresponding to the edit operation.
6. The collaborative document editing layout method according to claim 1, characterized in that, The layout data and character measurement data of the first data unit and the data units within its preset neighborhood are cached locally, while the layout data and character measurement data of the remaining data units are not cached locally.
7. The collaborative document editing and formatting method according to claim 6, characterized in that, The data model, after being updated based on an edit operation, also includes: Data units whose layout has been changed and which are located before the neighboring end unit corresponding to the first data unit are marked as dirty units; wherein, the neighboring end unit is a data unit located at the end of a preset neighborhood range of the first data unit.
8. The collaborative document editing and formatting method according to claim 1, characterized in that, The data model, after being updated based on an edit operation, also includes: Mark the data cells with layout changes in the updated data model as dirty cells; Based on the dirty unit, a background pre-sorting task is generated, which is used to instruct the updating of the layout data of the dirty unit; In the case where the dirty unit includes a first data unit corresponding to the visible area, a local layout task is generated based on the first data unit. The local layout task is used to instruct the updating of the layout data of the first data unit and the re-rendering of the document layout of the visible area. The partial layout task and the background pre-layout task are stored in a task queue, with the priority of the partial layout task being higher than that of the background pre-layout task. The scheduler assigns tasks from the task queue to the main thread for execution based on priority.
9. The collaborative document editing and formatting method according to claim 8, characterized in that, After generating the background pre-scheduled task based on the dirty unit, the method further includes: In the case where the updated data model includes multiple dirty units, the background pre-sorting task is divided into multiple pre-sorting sub-tasks corresponding to the multiple dirty units, and the pre-sorting sub-tasks are sorted based on a preset priority.
10. The collaborative document editing and formatting method according to claim 9, characterized in that, The step of allocating tasks in the task queue to the main thread for execution sequentially based on priority using a scheduler includes: If the scheduler determines that the pre-sorted subtask of the first dirty unit in the task queue has the highest priority, the scheduler will allocate the pre-sorted subtask of the first dirty unit to the main thread for execution. The main thread starts the layout calculation from the beginning of the symbol interval of the first dirty unit. When the end symbol of the first dirty unit is calculated, the pre-sorting subtask of the first dirty unit is confirmed to be completed. The layout data from the beginning to the end symbol is determined as the latest layout data of the first dirty unit, and the position of the symbol before the end symbol is determined as the latest end point of the symbol interval of the first dirty unit. Update the starting point of the sign interval of the next dirty cell to the latest endpoint of the sign interval of the first dirty cell.
11. The collaborative document editing and formatting method according to claim 9, characterized in that, The data unit is a data page, and the data model also includes cross-page cells from the first data page layout to the second data page; Accordingly, the step of allocating tasks in the task queue to the main thread for execution sequentially based on priority using a scheduler includes: When the main thread is assigned a pre-layout subtask to the second data page, the main thread starts the layout calculation from the beginning of the symbol range of the spanning cell. When the end symbol of the second data page is calculated, the pre-layout subtask of the second data page is confirmed to be completed. The layout data from the beginning of the symbol range of the second data page to the end symbol is determined as the latest layout data of the second data page, and the position of the symbol before the end symbol is determined as the latest end point of the symbol range of the second data page. Update the starting point of the sign interval of the next data page of the second data page based on the latest end point of the sign interval of the second data page.
12. The collaborative document editing and formatting method according to claim 9, characterized in that, The step of allocating tasks in the task queue to the main thread for execution sequentially based on priority using a scheduler includes: If the main thread confirms that the currently executing pre-sorting subtask has finished executing, the latest calculated symbol position of the finished pre-sorting subtask is set as the checkpoint; If the next pre-arranged subtask has the highest priority in the task queue, the next pre-arranged subtask is executed from the checkpoint via the main thread.
13. The collaborative document editing layout method according to claim 9, characterized in that, The step of allocating tasks in the task queue to the main thread for execution sequentially based on priority using a scheduler includes: Detect the cumulative duration of the main thread continuously executing pre-arranged sub-tasks; If the cumulative duration is greater than or equal to the preset duration, the pre-arranged subtask currently being executed by the main thread is interrupted, and the latest calculated symbol position of the currently executed pre-arranged subtask is set as the checkpoint. If the interrupted pre-scheduled subtask has the highest priority in the task queue, the main thread will continue executing the interrupted pre-scheduled subtask from the checkpoint.
14. The collaborative document editing and formatting method according to claim 9, characterized in that, After storing the partial layout task and the background pre-layout task into the task queue, the method further includes: Upon receiving a new edit operation, at least one pre-sorted subtask is generated based on the new edit operation; If the data unit corresponding to the newly generated pre-arranged subtask is the same as the data unit corresponding to the pre-arranged subtask in the task queue, then the newly generated pre-arranged subtask will be deleted. Store the remaining pre-arranged subtasks into the task queue.
15. The collaborative document editing and formatting method according to claim 9, characterized in that, The layout data and character measurement data of the first data unit and the data units within its preset neighborhood are cached locally, while the layout data and character measurement data of the remaining data units are not cached locally; the symbol intervals of the remaining data units are stored through the corresponding tree nodes in the second interval tree; Accordingly, after dividing the background pre-scheduling task into multiple pre-scheduling sub-tasks corresponding to the multiple dirty units, the method further includes: If the second interval tree stores the symbol interval of the dirty unit, then the pre-sorted subtask corresponding to the dirty unit is converted into a recovery subtask; The recovery subtask is used to instruct character measurement and layout calculation for the dirty unit, and the recovery subtask and the pre-layout subtask are sorted based on a preset priority.
16. The collaborative document editing and formatting method according to claim 15, characterized in that, After converting the pre-sorting subtask corresponding to the dirty unit into a recovery subtask, the method further includes: Upon receiving a visible area switching operation, the visible area is adjusted according to the visible area switching operation, and the unit to be restored is determined. A corresponding restoration subtask is generated based on the unit to be restored. If the data unit corresponding to the newly generated recovery subtask is the same as the data unit corresponding to the recovery subtask in the task queue, then the recovery subtask is deleted. Store the remaining recovery subtasks into the task queue.
17. The collaborative document editing layout method according to claim 1, characterized in that, After rendering the document layout of the visible area based on the layout data of the first data unit, the method further includes: Obtain the comment data associated with the first symbol in the visible area; The rendering position of the comment data is determined based on the layout position of the first symbol; The comment data is rendered in the visible area according to the rendering location.
18. A collaborative document editing typesetting device, characterized in that, include: The partial layout update module is configured to update the layout data of the first data unit when the data unit whose layout has been changed in the updated data model is included in the first data unit corresponding to the visible area after the data model is updated based on the editing operation. The visible area rendering module is configured to render the document layout of the visible area based on the layout data updated by the first data unit.
19. A collaborative document editing typesetting device, characterized in that, include: One or more processors; A memory that stores one or more programs that, when executed by one or more processors, enable the one or more processors to implement the collaborative document editing layout method as described in any one of claims 1-17.
20. A storage medium containing computer-executable instructions, characterized in that, The computer-executable instructions, when executed by a computer processor, are used to perform the layout method for collaboratively editing documents as described in any one of claims 1-17.
