CN113486633B - Document editing method, device, storage medium and equipment - Google Patents

Document editing method, device, storage medium and equipment Download PDF

Info

Publication number
CN113486633B
CN113486633B CN202110719954.8A CN202110719954A CN113486633B CN 113486633 B CN113486633 B CN 113486633B CN 202110719954 A CN202110719954 A CN 202110719954A CN 113486633 B CN113486633 B CN 113486633B
Authority
CN
China
Prior art keywords
line
layout
standard
data
spacing
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202110719954.8A
Other languages
Chinese (zh)
Other versions
CN113486633A (en
Inventor
张泽鼎
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Kingsoft Office Software Inc
Zhuhai Kingsoft Office Software Co Ltd
Wuhan Kingsoft Office Software Co Ltd
Original Assignee
Beijing Kingsoft Office Software Inc
Zhuhai Kingsoft Office Software Co Ltd
Wuhan Kingsoft Office Software Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Kingsoft Office Software Inc, Zhuhai Kingsoft Office Software Co Ltd, Wuhan Kingsoft Office Software Co Ltd filed Critical Beijing Kingsoft Office Software Inc
Priority to CN202110719954.8A priority Critical patent/CN113486633B/en
Publication of CN113486633A publication Critical patent/CN113486633A/en
Application granted granted Critical
Publication of CN113486633B publication Critical patent/CN113486633B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/166Editing, e.g. inserting or deleting
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/166Editing, e.g. inserting or deleting
    • G06F40/177Editing, e.g. inserting or deleting of tables; using ruled lines
    • G06F40/18Editing, e.g. inserting or deleting of tables; using ruled lines of spreadsheets
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/189Automatic justification
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/543User-generated data transfer, e.g. clipboards, dynamic data exchange [DDE], object linking and embedding [OLE]

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Software Systems (AREA)
  • Document Processing Apparatus (AREA)

Abstract

The specification provides a document editing method, a device, a storage medium and equipment, in the method, original layout setting of table data is obtained by analyzing the table data, and the original layout setting is adjusted according to a preset layout standard, so that a displayed table accords with the preset layout standard, in the process of editing a document, a user can be actively helped to complete a layout effect, the workload of repeated typesetting layout of the user is reduced, and the document editing efficiency of the user is improved.

Description

Document editing method, device, storage medium and equipment
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a method, an apparatus, a storage medium, and a device for editing a document.
Background
In the process of editing a document, a user often encounters a requirement of copying contents from other documents to a current document, when the copied contents are tables, the format of the tables pasted to the current document may not achieve an ideal layout effect due to the table layout characteristics of the copy source, and at the moment, the user is required to adjust for multiple times, which can certainly increase the workload and reduce the efficiency of editing the document of the user.
Disclosure of Invention
In order to overcome the problems in the related art, the present specification provides a document editing method, apparatus, storage medium, and device.
According to a first aspect of embodiments of the present specification, there is provided a document editing method including:
Acquiring form data of a form to be displayed in a current document;
Analyzing the table data and determining original layout setting of the table data;
And after the original layout setting of the table data is adjusted based on a preset layout standard, displaying the table, so that the displayed table accords with the preset layout standard.
In some examples, the preset layout criteria are determined based on typesetting requirements corresponding to the current document and/or are determined based on space planning requirements of cells.
In some examples, the preset layout criteria include: standard margin ranges for cells; the adjusting the original layout setting of the table data based on the preset layout standard includes:
and if the margin of any cell of the table data does not meet the standard margin range, adjusting the margin of the cell to meet the standard margin range.
In some examples, the adjusting the original layout setting of the table data based on the preset layout criteria includes:
If any cell of the table data has lines with different word sizes, and the line spacing type of each line is a multiple line spacing, the line spacing is adjusted according to the word size, so that the line spacing of each line is matched with the word size of the line.
In some examples, for the lines of which the line spacing is adjusted, after adjusting the line spacing according to the word size, further comprising:
the pre-segment spacing and/or post-segment spacing of the rows is adjusted.
In some examples, if text of any line within any cell of the tabular data has different size word sizes, the line spacing of the line is determined based on the largest word size in the text.
In some examples, the adjusting the original layout setting of the table data based on the preset layout criteria includes:
And if the line spacing exists in the last line in any cell of the table data, removing the line spacing of the last line.
In some examples, the table data includes XML code, and the original layout setting is obtained by reading XML attributes recorded in the XML code.
In some examples, the adjusting the original layout setting of the table data based on the preset layout criteria includes:
modifying corresponding XML attributes based on a preset layout standard; and/or the number of the groups of groups,
And determining a rendering strategy based on the XML attributes through a typesetting engine, adjusting the rendering strategy according to a preset layout standard, and rendering the table by utilizing the adjusted rendering strategy.
In some examples, after modifying the corresponding XML attribute based on the preset layout criteria, further comprising:
And inserting the adjusted form data into XML codes of the current document.
In some examples, the tabular data includes: form data copied from other documents, or form data formed by inserting text copied from other documents into a newly created form.
According to a second aspect of embodiments of the present specification, there is provided a document editing apparatus comprising:
An acquisition module for acquiring form data of a form to be displayed in a current document;
The analysis module is used for analyzing the table data and determining the original layout setting of the table data;
And the adjustment module is used for displaying the table after adjusting the original layout setting of the table data based on a preset layout standard so that the displayed table accords with the preset layout standard.
According to a third aspect of the embodiments of the present description, there is provided a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements any of the methods of the embodiments of the present description.
According to a fourth aspect of embodiments of the present specification, there is provided a computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements any of the methods of the embodiments of the present specification when the program is executed.
The technical scheme provided by the embodiment of the specification can comprise the following beneficial effects:
in the embodiment of the specification, a document editing method, a device, a storage medium and equipment are disclosed, in the method, table data are analyzed to obtain original layout setting of the table data, and the original layout setting is adjusted according to a preset layout standard, so that a displayed table accords with the preset layout standard, in the process of editing a document, a user can be actively helped to complete a layout effect, the workload of repeated typesetting layout of the user is reduced, and the document editing efficiency of the user is improved.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the specification and together with the description, serve to explain the principles of the specification.
FIG. 1 is a flow chart of a document editing method according to an exemplary embodiment of the present disclosure;
FIG. 2 is a schematic diagram illustrating a flow of an application program automatically performing layout settings according to an exemplary embodiment of the present disclosure;
FIG. 3 is a schematic diagram of a table rendering effect before and after adjusting cell margins, as illustrated in the present specification according to an example embodiment;
FIG. 4 is a schematic diagram of a table rendering effect before and after adjustment of line spacing, shown in accordance with an exemplary embodiment of the present disclosure;
FIG. 5 is a schematic diagram of a table rendering effect before and after removing the line spacing of the last line, according to an exemplary embodiment of the present disclosure;
FIG. 6 is a hardware configuration diagram of a computer device in which the document editing apparatus is located, according to an exemplary embodiment of the present specification;
FIG. 7 is a block diagram of a document editing apparatus according to an exemplary embodiment of the present description.
Detailed Description
Reference will now be made in detail to exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, the same numbers in different drawings refer to the same or similar elements, unless otherwise indicated. The implementations described in the following exemplary examples do not represent all implementations consistent with the present specification. Rather, they are merely examples of apparatus and methods consistent with some aspects of the present description as detailed in the accompanying claims.
The terminology used in the description presented herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the description. As used in this specification and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used herein refers to and encompasses any or all possible combinations of one or more of the associated listed items.
It should be understood that although the terms first, second, third, etc. may be used in this specification to describe various information, these information should not be limited to these terms. These terms are only used to distinguish one type of information from another. For example, the first information may also be referred to as second information, and similarly, the second information may also be referred to as first information, without departing from the scope of the present description. The word "if" as used herein may be interpreted as "at … …" or "at … …" or "in response to a determination" depending on the context.
In the process of editing a document, a user often encounters a requirement of copying contents from other documents to a current document, when the copied contents are tables, the format of the tables pasted to the current document may not achieve an ideal layout effect due to the table layout characteristics of the copy source, and at the moment, the user is required to adjust for multiple times, which can certainly increase the workload and reduce the efficiency of editing the document of the user. Based on this, the present embodiment provides a document editing scheme to solve the above-described problems.
Next, embodiments of the present specification will be described in detail.
As shown in fig. 1, fig. 1 is a flowchart illustrating a document editing method according to an exemplary embodiment of the present specification, the method including:
in step 101, table data of a table to be displayed in a current document is acquired;
The method of the embodiments of the present specification may be applied to an application program for editing a document, and the document referred to herein may be any one of a text document, a form document, a presentation document, and the like.
The form is a visual communication mode and is also a means for organizing and organizing data. A form is made up of one or more rows of cells for displaying text, numbers, and/or other items for statistical viewing. The form data mentioned in this step may include data entered in the form, as well as structural data of the form. Wherein, the data entered in the table may include multimedia data in the table and/or attribute data of the multimedia data, and the multimedia data may include text, image, audio, video, and the like. Correspondingly, if the multimedia data is text, the attribute data of the text may include font type, word size, numerical format, etc.; as another example, the multimedia data is an image, and the attribute data of the image may include a size of the image, a filter type, and the like; as another example, the multimedia data is audio or video, and the attribute data of the audio or video may include an address of the audio or video. The structural data of the table is data indicating layout setting of the table, and may include table attributes such as cell margin, cell spacing, and the like, and may also include paragraph patterns within cells such as indentation of paragraphs, line spacing, and the like.
For clarity, in this embodiment, the detailed description mainly uses multimedia data as text, but is not limited to other types of multimedia data. Other layout forms, intervals, etc. in the cell pictures can be converted to be in accordance with the preset layout standard by the method provided in the embodiment for display. The layout form of the pictures in the cells can be that the pictures are arranged in rows, columns or a plurality of rows and columns in the same cell; the interval may be a distance between pictures, or a distance between pictures and a frame of a cell.
In this embodiment, the table data may be stored in a document in a preset format. Since the current document editing software adopts a markup language of extensible markup language (Extensible Markup Language, XML), in this embodiment, the document data is described using XML as an example at the bottom layer, but is not limited to the document described using other forms. For example, a doc or docx file is in fact a compressed file that contains an XML file. That is, the form data of the present embodiment can be regarded as a piece of XML code. XML is a markup language used to mark electronic documents to be structured. An XML document contains XML elements, which refer to the portion from a start tag until an end tag, one XML element may contain other XML elements and/or text. And the XML attribute is information contained in a start tag of the XML element for providing additional information about the XML element, where the additional information is information not belonging to a data component, for example, < file type= "gif" > computer. Gif </file >, which is an XML element whose value of the XML attribute contained therein indicates such information that the file type is in gif format.
The form data may be copied from another application or document, or may be formed by inserting text copied from another application or document into a newly created form.
It should be noted that, because different applications use different formats to store data, when cross-application copy and paste is performed, format incompatibility easily occurs, so that the copied data and the pasted data have different display effects and even cannot be pasted. For this reason, in the present embodiment, when the form data is data copied from the copy source, the form data is converted from the format corresponding to the copy source into the format used by the current document. For example, in some embodiments, if the copy source of the form data is a website, i.e., the nature of the form data is an HTML code, and the format is in HTML standard, the application program may first convert the form data into a corresponding XML code, i.e., into a format conforming to the XML standard, through a software development kit.
In step 102, analyzing the table data, and determining an original layout setting of the table data;
in this step, it is mentioned that the original layout setting refers to a setting for a table layout, a cell layout, or the like indicated by the table data, and may correspond to the structure data in the above-mentioned table data. Specifically, the structure data may be parsed from the table data to determine the original layout settings of the table data.
In an alternative embodiment, parsing of the form data may be implemented based on a document object model (Document Object Model, DOM), where the DOM is a tree-based application programming interface (Application Programming Interface, API) that, when parsing the XML document, may present the XML document as a tree structure with elements, attributes and text, i.e., a DOM tree that defines the logical structure of the XML document, through which an application may implement operations on the XML document data, e.g., by traversing the DOM tree, the value of each XML element may be extracted. Correspondingly, in this embodiment, the application program may present the table data as a DOM tree, and then traverse the DOM tree to obtain the value of the XML attribute corresponding to the layout setting of the table data, so as to obtain the original layout setting in the table data.
Of course, in other embodiments, the form data may also be parsed based on other means, such as SAX (SIMPLE API for XML, for processing XML event driven "push" model), JDOM (Java-based Document Object Model, java document object model), which is not limiting in this specification.
And step 103, after the original layout setting of the table data is adjusted based on a preset layout standard, displaying the table so that the displayed table accords with the preset layout standard.
In this embodiment, under the influence of the table layout characteristics of the copy source, if the table is directly displayed by using the table data, the requirement of the current document on the layout setting of the table is not necessarily met, and in the related art, after the table is displayed, the edge distance of the table, the line distance of characters in the table, and the like are manually adjusted by a user. However, this approach affects the efficiency of editing the document by the user, and the layout effect of the adjusted form is not necessarily ideal. In the solution of this embodiment, after the original layout setting of the table is obtained by analyzing the table data, the original layout setting may be automatically adjusted based on the preset layout standard, so as to determine that the display effect of the table meets the preset layout standard.
The preset layout standard can be determined based on the typesetting requirement corresponding to the current document, taking the document as an example, the preset layout standard can be determined according to the typesetting requirement of the document, and thus, the application program automatically adjusts the rendering strategy according to the condition of the table to be displayed, so that the rendered table can meet the typesetting requirement of the document.
In the related art, one common table case includes: in the default cell margins, the upper and lower margins are both set to 0. However, this form situation can result in text welting, which is unacceptable for documents with regulatory requirements, especially in documents with official documents. The official document, namely the official document, is a written material which is formed and used by legal authorities and organizations in official activities according to specific body types and through a certain processing program, has very strict specification requirements, and for the official document, the format of the official document is not specified, so that the official document cannot play a role.
Based on this, in some examples, this step may include: and if the margin of any cell of the table data does not meet the standard margin range, adjusting the margin of the cell to meet the standard margin range. Cell margins refer to the distance between the content and the frame in the cells of the form, including the top margin, bottom margin, left margin, and right margin.
The standard margin range is a rule in the preset layout standard, so that the standard margin range can be determined according to typesetting requirements of the current document or according to user-defined standards.
For example, if the standard margin range corresponding to the upper and lower margins is 2±0.5 mm, for the aforementioned common table case, since the upper and lower margins of each cell of the table do not satisfy the standard margin range, the application program may adjust the upper and lower margins of each cell to satisfy the standard margin range, for example, to 2 mm, so as to avoid the situation of text welting.
For another example, the standard margin range may be replaced with a standard margin to make the judgment and adjustment. In other examples, it may also be directly determined whether the upper and lower margins of the cell are 0, if so, the upper and lower margins of the cell are increased by 2mm margins, otherwise, rendering is still performed according to the original margins to avoid welting.
It should be noted that, when adjusting the margins of each cell, the following two manners may be adopted for setting: one is to set cell margins one by one as standard margins for each cell; the other is to set the cell attribute as "the cell margin is the same as the whole table", and set the table attribute as "the default cell margin is the standard margin". Therefore, when the application program automatically renders the cell layout, the margin of the cell can be automatically rendered to meet the standard margin range, so that a user is helped to complete the layout effect, and the workload of manually adjusting the layout by the user is reduced.
Of course, in addition to the above table case, the preset layout standard based on the typesetting requirement may include rules, such as setting the text margin in the cell as a standard text margin, etc., which is not limited in this specification. Through the setting, the rendering of the table can be automatically adjusted, so that the displayed table meets the typesetting requirement of the current document, the workload of frequent manual adjustment of a user is reduced, and meanwhile, the error operation caused in the manual adjustment process is also reduced.
In addition to normalization, the display effect of the table by the user often has the need for cell space utilization and beautification of the presentation, and based on this, in other embodiments, the preset layout criteria may also be determined based on the space planning requirement of the cells, where the space planning requirement may be a rule for managing the space of the cells, which may include rules for line spacing, paragraph spacing, and so on, formulated by a skilled person.
In practical applications, a situation that a plurality of lines of text are presented in a cell, the word sizes adopted by the text in each line are not uniform, and the line space types of the lines are multiple line spaces often occurs, in the case of a table, if the word size of one line is smaller, the line space of the line looks larger, that is, the line space and the ratio of the word size to the line space presented by different lines in the cell are often inconsistent, which affects the appearance and occupies too much cell space, and the situation is unacceptable for documents with standard requirements.
Based on this, in some examples, this step may include: if any cell of the table data has lines with different word sizes, and the line spacing type of each line is a multiple line spacing, the line spacing is adjusted according to the word size, so that the line spacing of each line is matched with the word size of the line.
In this embodiment, the line space generally refers to the distance between a line of text and the next line of text, where the line space type of each line in a cell often adopts a multiple line space, where the multiple line space includes a single line space, 1.5 times line space, 2 times line space, and multiple line spaces, where the single line space is a line span set in a line grid, when the page space is fixed, the minimum line span of each page is determined by the text height, for example, in a document, the text height is 12 lbs, and each page line is set to 42 lines, then the line span may be considered as a result of dividing the difference between the page height and the upper page margin by the lower page margin by the line number of each page, where the calculation result is 16.6 lbs, that is, the single line space at this time is 16.6 lbs, and when the text is vertically centered in the line, there is 2.3 lbs of space between the upper page and the lower page. And 1.5 row spacing is 1.5 row grids, 1.5 times the single row spacing, i.e., 24.9 pounds, and so on. And line spacing generally refers to the distance from the bottom of one line of text to the top of the next line of text, i.e., the "blank" between the two lines, e.g., if the text of the current line is vertically centered within the line with 2.3 pounds of empty space above and below each, and the text of the next line is also vertically centered within the line with 3.8 pounds of empty space above and below each, then the line spacing of the current line is 6.1 pounds.
In an embodiment, in the case where the paragraph is set to N times the line pitch, it can be considered that the line pitch of each line in the paragraph is N times the paragraph pitch, for example, 10 pixels are set in the paragraph line pitch, and using 1.5 times the line pitch, the calculated line pitch result=10x1.5=15 pixels.
It follows that the line space size is associated with the word height, which is typically set by word size in the document layout, i.e. the line space size is associated with the word size. In documents such as documents, text is typically required to be displayed on top of the lines, and therefore, the line spacing may be considered as the difference between the line spacing and the text height.
Based on this, this embodiment proposes to adjust the line spacing according to the size of the font, so that the line spacing of each line matches the font of the line, so that the proportion of the line spacing and the size of the font maintains coordination, which can not only achieve the aesthetic property of the typesetting visual effect, but also achieve the reasonable utilization of the cell space.
Further, in an alternative embodiment, when the line spacing is adjusted according to the size of the font size, the line spacing of the lines used for the text with the font size larger than the preset font size may be enlarged; for lines whose text uses a word size smaller than the preset word size, the line spacing can be reduced.
In another alternative embodiment, the line spacing adjustment according to word size may be adjusted based on the following rules: if the size of the word size used by any line of text in any cell of the table data is smaller than or equal to the preset word size, determining that the space of the line in rendering is a preset proportion of the actual space, wherein the actual space is calculated according to the line space corresponding to the line in the table data and the used word size. Assuming that the line space of a line is 45 pixels, the line size used by the line corresponds to 30 pixels, the related art renders the line at 15 pixels, and in this embodiment, if the line size used by the line text is determined to be smaller than the preset line size, the application program renders the line at a preset ratio of 15 pixels, and if the preset ratio is 0.5, the line space actually rendered is 7.5 pixels. According to the summary of experimental data, if the line spacing multiple of each line is set to be the same, the size of the word size used by one line of text (for convenience of explanation, the target line is recorded) is smaller than or equal to the size of the word size of the fourth line, and the size of the word size used by other lines of text is larger than the size of the fourth line, the effect presented by the target line has the problem of overlarge gap, and has larger contrast, and after the line spacing obtained by calculation is halved, a more ideal rendering effect can be obtained, therefore, the size of the previous preset word size can be the size of the fourth line, and the preset proportion can be 0.5. Of course, in other embodiments, the preset word size and the preset ratio may be set according to the requirements of the specific scenario. In addition, after shortening the originally calculated line spacing, the pre-segment spacing and/or the post-segment spacing can be increased for the current line to further adjust the line spacing effect.
Also, in some embodiments, if text of any line within any cell of the form data has different size word sizes, the line spacing of the line is determined based on the largest word size in the text. For example, if the font size adopted in the text of a certain line includes a fourth font, a fifth font and a sixth font, the line spacing of the line is determined according to the fourth font. In addition, the application program may adjust the pre-segment spacing and/or the post-segment spacing of any row after adjusting the row spacing of the row according to the size of the word size. For example, there are four lines of text in a cell, the text in the first line and the text in the fourth line all adopt the number three, the text in the second line and the text in the third line all adopt the number four, when the actual rendering is performed according to the scheme of adjusting the line spacing according to the size of the word, the line spacing between the first line and the fourth line still maintains the original line spacing, and the line spacing between the second line and the third line is halved, so that the situation that the gap between the first line and the second line is larger than the gap between the third line and the fourth line is caused, and the situation that the front is loose and the back is compact easily forms an irregular visual effect can be formed, so that after the line spacing of the third line is adjusted, the line spacing after the section can be increased to form a more regular visual effect.
Furthermore, since the application program renders the current line, the line spacing of the current line is set after the current line, and the next line starts layout rendering after the line spacing of the current line, for the case of the table in which the line spacing exists in the last line of the cell, the gap between the text and the last line in the cell is easily oversized, and the aesthetic feeling and normalization of the table are affected. Based on this, in some examples, this step may include: and if the line spacing exists in the last line in any cell of the table data, removing the line spacing of the last line. That is, the application may remove the line spacing of the last row of the rendering cells, i.e., the line spacing actually rendered for that row is 0 pixels.
By the arrangement, more contents can be displayed in the display space with limited cells as much as possible, namely, redundant space possibly appearing in the cells is reasonably compressed. In practical application, a text document is a typesetting mode of streaming text, an application program can typeset according to the size of a screen, the size of a page of the document, fonts adopted in the document and the like, when the scheme is not adjusted, the situation that a user needs to frequently switch interfaces because enough contents cannot be observed in a limited screen often occurs, so that the application program needs to reserve enough hardware resources to process interface switching, and otherwise, the problem of blocking easily occurs. The scheme of the embodiment adjusts the rendering strategy of the table according to the space planning requirement of the cells, so that the reasonable utilization of the limited display space of the cells is realized, and the whole application program can run more smoothly.
Of course, the preset layout standard can also be determined according to the user-defined standard, and the application program automatically adjusts the rendering strategy of the table to achieve the ideal layout effect of the user. In addition, the preset layout standard may be directly written into the code of the application program, or may be stored in a specific location of the memory of the device where the application program is located, or in a website server, and the application program obtains the preset layout standard through a corresponding path when needed, which is not limited in this embodiment.
As mentioned above, the table data in this embodiment may be a section of code recorded with XML attributes corresponding to layout settings, and the typesetting engine generally determines a rendering policy according to the XML attributes in the table data for the rendering process of the table, and further renders the document content in the table data according to the rendering policy, and further displays the rendered document content in the application program, so that the displayed document content has corresponding attributes. Based on this, in some examples, the adjustment mentioned in this step may refer to modifying the corresponding XML attribute based on the preset layout criteria, for example, if the preset layout criteria include: the standard margin of the cell is 2mm, the value of the XML attribute corresponding to the margin of the cell in the table data can be modified to be 2mm, and thus, when the typesetting engine renders the table, the typesetting engine can render according to the modified XML attribute. For the situation, the modified XML attributes can be stored in the document, and then, when the document is opened, the document is directly rendered according to the modified XML attributes, so that the display effect meeting the preset layout standard can be obtained.
It should be noted that the partial adjustment of the content is not obtained by changing the value of a certain XML attribute, as mentioned above for the content of which the line spacing is adjusted according to the word size. Specifically, since the form data is typeset in a stream typesetting manner, for different devices, even for the same form data, the number of lines and the content in the lines obtained by the corresponding typesetting are different, so that the XML attribute directly corresponding to the line spacing in the form data is not available, and the typesetting engine calculates the rendered line spacing through the related XML attributes such as line span, word size, line spacing multiple and the like, and then renders based on the calculation result.
For this case, an alternative embodiment of the present description provides the following adjustment: and in the process that the typesetting engine renders the table according to the XML attributes, determining a rendering strategy based on the XML attributes, and adjusting the rendering strategy according to a preset layout standard, so that the typesetting engine renders the table according to the adjusted rendering strategy. Along the previous examples, the typesetting engine may obtain the calculated line spacing based on XML attributes corresponding to the line span, the word size, the line spacing multiple, and the like in the table data, and then adjust the line spacing according to the preset layout standard, if the word size used by the line text is smaller than the preset word size, the typesetting engine may halve the calculated line spacing in the rendering process, obtain the adjusted line spacing, and then render based on the adjusted line spacing.
After the rendering strategy is adjusted according to the preset layout standard, the application program displays the table according to the rendering strategy. For example, when the application program renders the table layout, the application program may render according to the setting of the cell margin of the table in the rendering policy, and when the application program renders the cell layout, the application program may render according to the setting of the row interval in the rendering policy, so that the displayed table meets the layout standard.
According to the scheme of the embodiment of the specification, the original layout setting of the table data is automatically analyzed, and the displayed table is modified according to the preset layout standard, so that the displayed table meets the standard, a user can be helped to complete the layout effect, and the efficiency of editing the user document is improved.
In addition, to achieve the same layout effect when opening the current document in other document editing software, in some examples, the application may also modify the value of the corresponding XML attribute in the form data based on the rendering policy and insert the modified form data into the XML code of the current document. By adopting the example of the margin adjusting effect, the application program can modify the XML attribute values of the margins on the upper and lower sides of the corresponding cells in the form data of the form while displaying the form to modify the standard margin to 2 mm, and insert the modified form data into the XML code of the current document, so that when other document editing software is applied to open the document, the form can still keep the display effect that the margins on the upper and lower sides of the cells are the standard margins, thereby being beneficial to improving the use experience of users.
For a more detailed description of the document editing scheme of the present specification, a specific embodiment is described below:
In this embodiment, in the process of writing a document, a user needs to copy a table from a common document to a current document, and because the table layout of the common document adopts a conventional setting and does not meet the typesetting requirement of the document, improper layout effects, such as text welting of part of cells and too large line spacing of part of lines, may occur in pasting the document to the current document.
When the document editing scheme of the embodiment is applied to an application program and the user writes a document by using the application program, the scheme of automatically performing layout setting by the application program for a copied form may be embodied based on the following flow shown in the schematic diagram of fig. 2:
S201, acquiring form data of the form;
S202, analyzing the table data and determining original layout setting of the table data;
S203, judging whether the upper edge distance and the lower edge distance of the cell are 0, if yes, executing S204, otherwise executing S205;
S204, setting the upper and lower margins of the cell as standard margins of 2mm, and rendering the upper and lower margins of the cell based on the value of the standard margins; as shown in fig. 3, fig. 3 is a schematic diagram showing a table rendering effect before and after adjusting a cell margin, wherein a left graph indicates a table rendering effect with a cell upper and lower margin of 0, and a right graph indicates a table rendering effect with a cell upper and lower margin set as a standard margin, and as can be seen from the graph, the present embodiment can avoid the case of first line and last line welting;
S205, rendering the upper and lower margins of the cell based on the corresponding values in the original layout setting;
S206, judging whether the size of the word size used by any line of text in the cell is smaller than or equal to the size of the fourth word, if yes, executing S207, otherwise, executing S208;
s207, determining that the target pitch of the line in rendering is half of the actual pitch, and rendering the pitch of the line based on the target pitch, wherein the actual pitch is calculated according to the line pitch of the line and the size of a word size used by a text in the table data;
In this embodiment, for example, the row spacing type of each row is a single row spacing, and the pound value corresponding to the single row spacing is 10.5 pounds, that is, the pound value corresponding to one row grid is 10.5 pounds; the size of the word size used by a certain line of text is four words, and the corresponding pound value is 14 pounds; because the height of the characters of the fourth character is larger than the single line spacing, and the attribute of the character alignment grid is generally set for the typesetting regularity of the current document, the line occupies two line grids, and the line spacing of the line is 2 times of the pound value corresponding to the single line spacing and is 21 pounds; further, since the current document specifies that the text is displayed on the line, the line spacing of the line is calculated to be the line spacing of the line minus the text height, i.e., 7 lbs., and therefore the line spacing of the line is actually rendered to be half of the calculated line spacing, i.e., 3.5 lbs.; as shown in fig. 4, fig. 4 is a schematic diagram showing a table rendering effect before and after the line spacing adjustment in this embodiment, in which a left graph indicates a table rendering result including a line spacing of a fourth character for cell content in the related art, an upper right graph indicates a table rendering effect after the line spacing adjustment of the fourth character, and a lower right graph indicates a table rendering effect after the line spacing adjustment of the fourth character further increases the line spacing slightly, as can be seen from the graph, the situation that the line spacing appears too large on the visual effect can be avoided in this embodiment;
s208, rendering the row spacing of the row based on the corresponding value in the original layout setting;
S209, judging whether the line spacing exists in the last line in the cell, if so, executing S210, otherwise, executing S211;
S210, removing the row spacing of the last row, namely rendering the row spacing of the last row to be 0 pixels; as shown in fig. 5, fig. 5 is a schematic diagram showing a table rendering effect before and after removing a line pitch of a last line in the embodiment, where a left graph indicates a table rendering effect of the last line with the line pitch, and a right graph indicates a table rendering effect after removing the line pitch of the last line, and as can be seen from the graph, the embodiment can reduce a situation that a blank area between a last line and a lower edge in a cell is too wide;
s211, after all the cells are rendered based on the processes of S206 to S210, the table is displayed.
In the embodiment, when the user copies, pastes or edits the table content, the user does not need to consider the table layout characteristic of the copy source, but the application program automatically helps the user to complete the layout effect, and the edited document can well accord with the typesetting requirement of the document, so that the efficiency of the user for editing the document is improved.
In addition, the scheme of the embodiment adjusts the line spacing of the paragraphs in the unit cells according to the size of the word size while meeting the standardization of typesetting layout, so that the unit cells show a neat visual effect and meet the requirement of beautiful appearance; and the limited display space of the unit cells can be reasonably utilized, so that the application program does not need to reserve more hardware resources to process interface switching, and the running of the application program is smoother.
Corresponding to the embodiments of the foregoing method, the present specification also provides embodiments of a document editing apparatus and a terminal to which the document editing apparatus is applied.
Embodiments of the present document editing apparatus may be applied to a computer device, such as a server or a terminal device. The apparatus embodiments may be implemented by software, or may be implemented by hardware or a combination of hardware and software. Taking software implementation as an example, the device in a logic sense is formed by reading corresponding computer program instructions in the nonvolatile memory into the memory through a processor of the file processing where the device is located. In terms of hardware, as shown in fig. 6, a hardware structure diagram of a computer device where the document editing apparatus according to the embodiment of the present disclosure is located is shown in fig. 6, and in addition to the processor 610, the memory 630, the network interface 620, and the nonvolatile memory 640, a server or an electronic device where the apparatus 631 is located in the embodiment may generally include other hardware according to an actual function of the computer device, which is not described herein again.
Accordingly, the present specification embodiment also provides a computer storage medium having a program stored therein, which when executed by a processor, implements the method in any of the above embodiments.
Embodiments of the present description may take the form of a computer program product embodied on one or more storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) having program code embodied therein. Computer-usable storage media include both permanent and non-permanent, removable and non-removable media, and information storage may be implemented by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of storage media for a computer include, but are not limited to: phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Disks (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium, may be used to store information that may be accessed by the computing device.
As shown in fig. 7, fig. 7 is a block diagram of a document editing apparatus according to an exemplary embodiment of the present specification, the apparatus comprising:
an acquisition module 71 for acquiring form data of a form to be displayed in a current document;
A parsing module 72, configured to parse the table data and determine an original layout setting of the table data;
and the adjustment module 73 is configured to display the table after adjusting the original layout setting of the table data based on the preset layout standard, so that the displayed table meets the preset layout standard.
In some examples, the preset layout criteria are determined based on typesetting requirements corresponding to the current document and/or are determined based on space planning requirements of cells.
In some examples, the preset layout criteria include: standard margin ranges for cells; the adjusting module comprises a first adjusting submodule, wherein the first adjusting submodule is used for: and if the margin of any cell of the table data does not meet the standard margin range, adjusting the margin of the cell to meet the standard margin range.
In some examples, the adjustment module includes a second adjustment sub-module for: if any cell of the table data has lines with different word sizes, and the line spacing type of each line is a multiple line spacing, the line spacing is adjusted according to the word size, so that the line spacing of each line is matched with the word size of the line.
In some examples, the adjustment module includes a third adjustment sub-module for: for the lines with the adjusted line spacing, after the second adjustment submodule adjusts the line spacing according to the word size, the pre-segment spacing and/or the post-segment spacing of the lines are adjusted.
In some examples, the second adjustment sub-module is further configured to: if the text of any line in any cell of the table data has different word sizes, determining the line spacing of the line based on the maximum word size in the text.
In some examples, the adjustment module includes a fourth adjustment sub-module for: and if the line spacing exists in the last line in any cell of the table data, removing the line spacing of the last line.
In some examples, the table data includes XML code, and the original layout setting is obtained by reading XML attributes recorded in the XML code.
In some examples, the adjustment module is specifically configured to: modifying corresponding XML attributes based on a preset layout standard; and/or determining a rendering strategy based on the XML attributes through a typesetting engine, adjusting the rendering strategy according to a preset layout standard, and rendering the table by utilizing the adjusted rendering strategy.
In some examples, the adjustment module is specifically further configured to: and after the corresponding XML attributes are modified based on the preset layout standard, inserting the adjusted form data into XML codes of the current document.
The implementation process of the functions and roles of each module in the above device is specifically shown in the implementation process of the corresponding steps in the above method, and will not be described herein again.
For the device embodiments, reference is made to the description of the method embodiments for the relevant points, since they essentially correspond to the method embodiments. The apparatus embodiments described above are merely illustrative, wherein the modules illustrated as separate components may or may not be physically separate, and the components shown as modules may or may not be physical, i.e., may be located in one place, or may be distributed over a plurality of network modules. Some or all of the modules may be selected according to actual needs to achieve the purposes of the present description. Those of ordinary skill in the art will understand and implement the present invention without undue burden.
The foregoing describes specific embodiments of the present disclosure. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims can be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
Other embodiments of the present description will be apparent to those skilled in the art from consideration of the specification and practice of the invention disclosed herein. This specification is intended to cover any variations, uses, or adaptations of the specification following, in general, the principles of the specification and including such departures from the present disclosure as come within known or customary practice within the art to which the specification pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the specification being indicated by the following claims.
It is to be understood that the present description is not limited to the precise arrangements and instrumentalities shown in the drawings, which have been described above, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present description is limited only by the appended claims.
The foregoing description of the preferred embodiments is provided for the purpose of illustration only, and is not intended to limit the scope of the disclosure, since any modifications, equivalents, improvements, etc. that fall within the spirit and principles of the disclosure are intended to be included within the scope of the disclosure.

Claims (13)

1. A document editing method, comprising:
Acquiring form data of a form to be displayed in a current document;
analyzing the table data, and determining original layout settings of the table data, wherein the layout settings comprise table attributes and paragraph patterns in cells;
After the original layout setting of the table data is adjusted based on a preset layout standard, displaying the table in the current document to enable the displayed table to conform to the preset layout standard, wherein the preset layout standard is determined based on typesetting requirements corresponding to the current document, and the preset layout standard comprises at least one of the following: standard margin ranges for cells, line spacing within cells, paragraph spacing within cells.
2. The method of claim 1, wherein the preset layout criteria comprises: standard margin ranges for cells; the adjusting the original layout setting of the table data based on the preset layout standard includes:
and if the margin of any cell of the table data does not meet the standard margin range, adjusting the margin of the cell to meet the standard margin range.
3. The method of claim 1, wherein adjusting the original layout setting of the form data based on a preset layout criteria comprises:
If any cell of the table data has lines with different word sizes, and the line spacing type of each line is a multiple line spacing, the line spacing is adjusted according to the word size, so that the line spacing of each line is matched with the word size of the line.
4. A method according to claim 3, characterized in that for the lines of which the line spacing is adjusted, after adjusting the line spacing according to the word size, further comprises:
the pre-segment spacing and/or post-segment spacing of the rows is adjusted.
5. A method according to claim 3, wherein if text of any line within any cell of the form data has different size word sizes, the line spacing of the lines is determined based on the largest word size in the text.
6. The method of claim 1, wherein adjusting the original layout setting of the form data based on a preset layout criteria comprises:
And if the line spacing exists in the last line in any cell of the table data, removing the line spacing of the last line.
7. The method of claim 1, wherein the form data comprises XML code, and the original layout setting is obtained by reading XML attributes recorded in the XML code.
8. The method of claim 7, wherein the adjusting the original layout setting of the form data based on the preset layout criteria comprises:
modifying corresponding XML attributes based on a preset layout standard; and/or the number of the groups of groups,
And determining a rendering strategy based on the XML attributes through a typesetting engine, adjusting the rendering strategy according to a preset layout standard, and rendering the table by utilizing the adjusted rendering strategy.
9. The method of claim 8, further comprising, after modifying the corresponding XML attribute based on the preset layout criteria:
And inserting the adjusted form data into XML codes of the current document.
10. The method of claim 1, wherein the tabular data comprises: form data copied from other applications or documents, or form data formed by inserting text copied from other applications or documents into a newly created form.
11. A document editing apparatus, comprising:
An acquisition module for acquiring form data of a form to be displayed in a current document;
The analysis module is used for analyzing the table data and determining original layout settings of the table data, wherein the layout settings comprise table attributes and paragraph patterns in cells;
the adjustment module is used for displaying the table in the current document after adjusting the original layout setting of the table data based on a preset layout standard, so that the displayed table accords with the preset layout standard, the preset layout standard is determined based on the typesetting requirement corresponding to the current document, and the preset layout standard comprises at least one of the following components: standard margin ranges for cells, line spacing within cells, paragraph spacing within cells.
12. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the method of any one of claims 1 to 10 when the program is executed by the processor.
13. A computer readable storage medium, characterized in that a computer program is stored thereon, which program, when being executed by a processor, implements the method of any of claims 1 to 10.
CN202110719954.8A 2021-06-28 2021-06-28 Document editing method, device, storage medium and equipment Active CN113486633B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110719954.8A CN113486633B (en) 2021-06-28 2021-06-28 Document editing method, device, storage medium and equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110719954.8A CN113486633B (en) 2021-06-28 2021-06-28 Document editing method, device, storage medium and equipment

Publications (2)

Publication Number Publication Date
CN113486633A CN113486633A (en) 2021-10-08
CN113486633B true CN113486633B (en) 2024-05-24

Family

ID=77937753

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110719954.8A Active CN113486633B (en) 2021-06-28 2021-06-28 Document editing method, device, storage medium and equipment

Country Status (1)

Country Link
CN (1) CN113486633B (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106557454A (en) * 2015-09-30 2017-04-05 腾讯科技(深圳)有限公司 Conversion method and converting system of the document to form
CN111338827A (en) * 2020-03-20 2020-06-26 北京字节跳动网络技术有限公司 Method and device for pasting table data and electronic equipment

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6613099B2 (en) * 1999-08-20 2003-09-02 Apple Computer, Inc. Process and system for providing a table view of a form layout for a database
US6968504B2 (en) * 2001-06-29 2005-11-22 Microsoft Corporation Automated document formatting tool
US9098969B2 (en) * 2013-06-20 2015-08-04 Timothy Mulligan Interchangeable gaming layout powered by a display element

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106557454A (en) * 2015-09-30 2017-04-05 腾讯科技(深圳)有限公司 Conversion method and converting system of the document to form
CN111338827A (en) * 2020-03-20 2020-06-26 北京字节跳动网络技术有限公司 Method and device for pasting table data and electronic equipment

Also Published As

Publication number Publication date
CN113486633A (en) 2021-10-08

Similar Documents

Publication Publication Date Title
JP6725714B2 (en) System and method for automatic conversion of interactive sites and applications that support mobile and other viewing environments
CN110489116B (en) Page rendering method and device and computer storage medium
US7461332B2 (en) Automatic layout of content in a design for a medium
US7584415B2 (en) Common charting using shapes
US5895476A (en) Design engine for automatic reformatting for design and media
US8996981B2 (en) Managing forms in electronic documents
US20040133854A1 (en) Persistent document object model
US20130185632A1 (en) Generating variable document templates
US20130014007A1 (en) Method for creating an enrichment file associated with a page of an electronic document
KR20060046002A (en) Method and system for mapping content between a starting template and a target template
US9235559B2 (en) Progressive page loading
CN105335445A (en) Layout display method and device
JP2009048450A (en) Document management program and thumbnail display method
CN115757272A (en) Method and system for converting HTML file into OFD file
CN113486633B (en) Document editing method, device, storage medium and equipment
US20070162848A1 (en) Predictive styling
CN115659087B (en) Page rendering method, equipment and storage medium
US20100083083A1 (en) Compressed table format
CN113822023B (en) Automatic standard document generation method and system
CN117688916A (en) Method, device, equipment and storage medium for inserting form in layout document
CN113553798B (en) Seal insertion method and device, electronic equipment and storage medium
Bessler Data Visualization Tips and Techniques for Effective Communication
CN118228699A (en) File editing method and device, electronic equipment and storage medium
CN117908882A (en) Page label display method and device, storage medium and electronic equipment
CN116882365A (en) Method and system for converting HTML (hypertext markup language) file into Word file

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant