Method and device for deleting document content, electronic equipment and storage medium

文档序号:1391825 发布日期:2020-02-28 浏览:13次 中文

阅读说明:本技术 一种删除文档内容的方法、装置、电子设备及存储介质 (Method and device for deleting document content, electronic equipment and storage medium ) 是由 吴峰 于 2018-08-01 设计创作,主要内容包括:本发明实施例提供了一种删除文档内容的方法、装置、电子设备及存储介质。所述方法包括:确定目标文档中,待删除页的目标页码;基于所述目标文档的排版缓存区域和所述目标页码,确定所述待删除页的内容的开始位置和结束位置;其中,所述排版缓存区域中存储有所述目标文档的各个页码对应的页面信息,任一页码对应的页面信息中含有该页码对应的内容的开始位置和结束位置;基于所述开始位置和所述结束位置,对所述待删除页的内容进行删除。应用本发明实施例能够实现提高效率的目的。(The embodiment of the invention provides a method and a device for deleting document contents, electronic equipment and a storage medium. The method comprises the following steps: determining a target page number of a page to be deleted in a target document; determining the starting position and the ending position of the content of the page to be deleted based on the typesetting cache region of the target document and the target page number; page information corresponding to each page number of the target document is stored in the typesetting cache region, and the page information corresponding to any page number contains the starting position and the ending position of content corresponding to the page number; and deleting the content of the page to be deleted based on the starting position and the ending position. The embodiment of the invention can achieve the aim of improving the efficiency.)

1. A method of deleting document content, comprising:

determining a target page number of a page to be deleted in a target document;

determining the starting position and the ending position of the content of the page to be deleted based on the typesetting cache region of the target document and the target page number; page information corresponding to each page number of the target document is stored in the typesetting cache region, and the page information corresponding to any page number contains the starting position and the ending position of content corresponding to the page number;

and deleting the content of the page to be deleted based on the starting position and the ending position.

2. The method according to claim 1, wherein before deleting the content of the page to be deleted based on the start position and the end position, the method further comprises:

judging whether a first type element exists in the page to be deleted or not; wherein the attribute of the first type element is set to be undeletable;

and if the first type elements exist in the page to be deleted, canceling the setting about the non-deletable property of the first type elements.

3. The method according to claim 1 or 2, wherein the step of deleting the content of the page to be deleted based on the start position and the end position comprises:

judging whether an element in the page to be deleted spans a page or not based on the starting position and the ending position;

if the page to be deleted has element spread pages, deleting the content of the page to be deleted based on the starting position, the ending position and the types of the elements with spread pages;

and if no element spans the page in the page to be deleted, deleting the content between the starting position and the ending position.

4. The method according to claim 3, wherein the determining whether any element in the page to be deleted crosses a page based on the start position and the end position comprises:

determining a first element corresponding to the starting position and a second element corresponding to the ending position;

judging whether the first element spans a page or not and judging whether the second element spans a page or not;

and when at least one element in the first element and the second element spans pages, determining that the page to be deleted has element span pages, otherwise, determining that the page to be deleted has no element span pages.

5. The method of claim 4, wherein the determining whether the first element is page-crossing comprises:

when the first element is a table, a control or a form domain, judging whether the initial position of the first element is before the initial position, and if so, judging that the first element spans pages;

and when the first element is a picture, a text frame, a picture-text frame, a footnote or a final note which consists of an anchor point and an object, judging whether the position of the anchor point of the first element is before the starting position, and if so, judging that the first element spans the page.

6. The method of claim 4, wherein the determining whether the second element is page crossing comprises:

when the second element is a table, a control or a form domain, judging whether the termination position of the second element is behind the termination position, and if so, judging that the second element spans the page;

and when the second element is a picture, a text frame, a picture-text frame, a footnote or a final note which consists of an anchor point and an object, judging whether the position of the object of the second element is behind the end position, and if so, judging that the second element spans the page.

7. The method of claim 4, wherein deleting the content of the page to be deleted based on the start position, the end position, and the type of element for which page crossing occurs while the first element is page crossing comprises:

if the first element is a table, deleting the content between the starting position and the ending position, and deleting a blank page or a blank line corresponding to the page to be deleted;

if the first element is a control or a form domain, deleting the content between the starting position and the ending position, and modifying the ending position of the control or the form domain into: an end position of a page immediately preceding the page to be deleted;

if the first element is a picture, a text frame, a picture-text frame, a footnote or a tailnote which consists of an anchor point and an object, recalculating the starting position and the ending position of the page to be deleted based on the position of the anchor point of the first element, the starting position and the ending position, deleting the content between the calculated new starting position and the new ending position, and deleting the anchor point of the first element.

8. The method according to claim 4, wherein deleting the content of the page to be deleted based on the start position, the end position and the type of the element in which page crossing occurs at the time of the second element page crossing comprises:

deleting the content between the start position and the end position if the second element is a table;

if the second element is a control or a form domain, deleting the content between the starting position and the ending position, and modifying the starting position of the control or the form domain into: a starting position of a next page of the page to be deleted;

if the second element is a picture, a text frame, a picture-text frame, a footnote or a tailnote which is composed of an anchor point and an object, based on the position of the anchor point of the second element, the starting position and the ending position, recalculating the starting position and the ending position of the page to be deleted, and modifying the position of the anchor point of the second element into: and deleting the content between the new start position and the new end position obtained by calculation.

9. The method according to claim 1, wherein when the target page number is at least two, the deleting the content of the page to be deleted based on the start position and the end position comprises:

and deleting the content of the page to be deleted corresponding to the target page number according to the reverse order of the at least two target page numbers and based on the starting position and the ending position of each target page number in sequence.

10. An apparatus for deleting document content, comprising:

the first determining module is used for determining the target page number of the page to be deleted in the target document;

a second determining module, configured to determine a starting position and an ending position of the content of the page to be deleted based on the layout cache area of the target document and the target page number; page information corresponding to each page number of the target document is stored in the typesetting cache region, and the page information corresponding to any page number contains the starting position and the ending position of content corresponding to the page number;

and the deleting module is used for deleting the content of the page to be deleted based on the starting position and the ending position.

11. An electronic device comprising a processor and a memory, wherein,

the memory is used for storing a computer program;

the processor, when executing the program stored in the memory, implementing the method steps of any of claims 1-9.

12. A computer-readable storage medium, characterized in that a computer program is stored in the computer-readable storage medium, which computer program, when being executed by a processor, carries out the method steps of any one of the claims 1-9.

Technical Field

The present invention relates to the field of document processing, and in particular, to a method and an apparatus for deleting document content, an electronic device, and a storage medium.

Background

When a user processes a document, the user often needs to delete the content of a certain page in the document, in the prior art, the deletion operation is usually performed manually, and the specific process may be as follows: manually positioning the page cursor to the end of the page to be deleted, and then deleting the contents of the page to be deleted one by utilizing a delete key.

It can be seen that the prior art is inefficient in deleting the content of a certain page in a document.

Disclosure of Invention

Embodiments of the present invention provide a method, an apparatus, an electronic device, and a storage medium for deleting document content, so as to achieve the purpose of improving efficiency. The specific technical scheme is as follows:

in a first aspect, an embodiment of the present invention provides a method for deleting document content, where the method includes:

determining a target page number of a page to be deleted in a target document;

determining the starting position and the ending position of the content of the page to be deleted based on the typesetting cache region of the target document and the target page number; page information corresponding to each page number of the target document is stored in the typesetting cache region, and the page information corresponding to any page number contains the starting position and the ending position of content corresponding to the page number;

and deleting the content of the page to be deleted based on the starting position and the ending position.

Optionally, before deleting the content of the page to be deleted based on the start position and the end position, the method further includes:

judging whether a first type element exists in the page to be deleted or not; wherein the attribute of the first type element is set to be undeletable;

and if the first type elements exist in the page to be deleted, canceling the setting about the non-deletable property of the first type elements.

Optionally, the step of deleting the content of the page to be deleted based on the start position and the end position includes:

judging whether an element in the page to be deleted spans a page or not based on the starting position and the ending position;

if the page to be deleted has element spread pages, deleting the content of the page to be deleted based on the starting position, the ending position and the types of the elements with spread pages;

and if no element spans the page in the page to be deleted, deleting the content between the starting position and the ending position.

Optionally, the determining, based on the start position and the end position, whether there is an element page spread in the page to be deleted includes:

determining a first element corresponding to the starting position and a second element corresponding to the ending position;

judging whether the first element spans a page or not and judging whether the second element spans a page or not;

and when at least one element in the first element and the second element spans pages, determining that the page to be deleted has element span pages, otherwise, determining that the page to be deleted has no element span pages.

Optionally, the determining whether the first element spans a page includes:

when the first element is a table, a control or a form domain, judging whether the initial position of the first element is before the initial position, and if so, judging that the first element spans pages;

and when the first element is a picture, a text frame, a picture-text frame, a footnote or a final note which consists of an anchor point and an object, judging whether the position of the anchor point of the first element is before the starting position, and if so, judging that the first element spans the page.

Optionally, the determining whether the second element spans a page includes:

when the second element is a table, a control or a form domain, judging whether the termination position of the second element is behind the termination position, and if so, judging that the second element spans the page;

and when the second element is a picture, a text frame, a picture-text frame, a footnote or a final note which consists of an anchor point and an object, judging whether the position of the object of the second element is behind the end position, and if so, judging that the second element spans the page.

Optionally, when the first element is spread, deleting the content of the page to be deleted based on the start position, the end position, and the type of the element in which the spread occurs, includes:

if the first element is a table, deleting the content between the starting position and the ending position, and deleting a blank page or a blank line corresponding to the page to be deleted;

if the first element is a control or a form domain, deleting the content between the starting position and the ending position, and modifying the ending position of the control or the form domain into: an end position of a page immediately preceding the page to be deleted;

if the first element is a picture, a text frame, a picture-text frame, a footnote or a tailnote which consists of an anchor point and an object, recalculating the starting position and the ending position of the page to be deleted based on the position of the anchor point of the first element, the starting position and the ending position, deleting the content between the calculated new starting position and the new ending position, and deleting the anchor point of the first element.

Optionally, when the second element is spread, deleting the content of the page to be deleted based on the start position, the end position, and the type of the element in which the spread occurs, includes:

deleting the content between the start position and the end position if the second element is a table;

if the second element is a control or a form domain, deleting the content between the starting position and the ending position, and modifying the starting position of the control or the form domain into: a starting position of a next page of the page to be deleted;

if the second element is a picture, a text frame, a picture-text frame, a footnote or a tailnote which is composed of an anchor point and an object, based on the position of the anchor point of the second element, the starting position and the ending position, recalculating the starting position and the ending position of the page to be deleted, and modifying the position of the anchor point of the second element into: and deleting the content between the new start position and the new end position obtained by calculation.

Optionally, when the number of the target pages is at least two, deleting the content of the page to be deleted based on the starting position and the ending position includes:

and deleting the content of the page to be deleted corresponding to the target page number according to the reverse order of the at least two target page numbers and based on the starting position and the ending position of each target page number in sequence.

In a second aspect, an embodiment of the present invention provides an apparatus for deleting document content, where the apparatus includes:

the first determining module is used for determining the target page number of the page to be deleted in the target document;

a second determining module, configured to determine a starting position and an ending position of the content of the page to be deleted based on the layout cache area of the target document and the target page number; page information corresponding to each page number of the target document is stored in the typesetting cache region, and the page information corresponding to any page number contains the starting position and the ending position of content corresponding to the page number;

and the deleting module is used for deleting the content of the page to be deleted based on the starting position and the ending position.

Optionally, the apparatus further comprises:

the judging module is used for judging whether a first type element exists in the page to be deleted before deleting the content of the page to be deleted based on the starting position and the ending position; wherein the attribute of the first type element is set to be undeletable;

and the canceling module is used for canceling the setting which cannot be deleted in the attribute of the first type element if the first type element exists in the page to be deleted.

Optionally, the deleting module includes:

the judging submodule is used for judging whether the page to be deleted has element spread pages or not based on the starting position and the ending position;

the first deleting submodule is used for deleting the content of the page to be deleted based on the starting position, the ending position and the type of the element generating the page spread if the page to be deleted has the element spread;

and the second deletion submodule is used for deleting the content between the starting position and the ending position if no element in the page to be deleted crosses the page.

Optionally, the determining sub-module includes:

a first determining unit, configured to determine a first element corresponding to the start position and a second element corresponding to the end position;

the judging unit is used for judging whether the first element spans a page or not and judging whether the second element spans the page or not;

a second determining unit, configured to determine that there is an element page spread in the page to be deleted when at least one of the first element and the second element is page spread, and otherwise, determine that there is no element page spread in the page to be deleted.

Optionally, the determining unit is specifically configured to:

when the first element is a table, a control or a form domain, judging whether the initial position of the first element is before the initial position, and if so, judging that the first element spans pages;

and when the first element is a picture, a text frame, a picture-text frame, a footnote or a final note which consists of an anchor point and an object, judging whether the position of the anchor point of the first element is before the starting position, and if so, judging that the first element spans the page.

Optionally, the determining unit is specifically configured to:

when the second element is a table, a control or a form domain, judging whether the termination position of the second element is behind the termination position, and if so, judging that the second element spans the page;

and when the second element is a picture, a text frame, a picture-text frame, a footnote or a final note which consists of an anchor point and an object, judging whether the position of the object of the second element is behind the end position, and if so, judging that the second element spans the page.

Optionally, when the first element is page-crossing, the first deletion sub-module is specifically configured to:

if the first element is a table, deleting the content between the starting position and the ending position, and deleting a blank page or a blank line corresponding to the page to be deleted;

if the first element is a control or a form domain, deleting the content between the starting position and the ending position, and modifying the ending position of the control or the form domain into: an end position of a page immediately preceding the page to be deleted;

if the first element is a picture, a text frame, a picture-text frame, a footnote or a tailnote which consists of an anchor point and an object, recalculating the starting position and the ending position of the page to be deleted based on the position of the anchor point of the first element, the starting position and the ending position, deleting the content between the calculated new starting position and the new ending position, and deleting the anchor point of the first element.

Optionally, when the second element is page-spread, the first deletion submodule is specifically configured to:

deleting the content between the start position and the end position if the second element is a table;

if the second element is a control or a form domain, deleting the content between the starting position and the ending position, and modifying the starting position of the control or the form domain into: a starting position of a next page of the page to be deleted;

if the second element is a picture, a text frame, a picture-text frame, a footnote or a tailnote which is composed of an anchor point and an object, based on the position of the anchor point of the second element, the starting position and the ending position, recalculating the starting position and the ending position of the page to be deleted, and modifying the position of the anchor point of the second element into: and deleting the content between the new start position and the new end position obtained by calculation.

Optionally, when the number of the target pages is at least two, the deleting module is specifically configured to:

and deleting the content of the page to be deleted corresponding to the target page number according to the reverse order of the at least two target page numbers and based on the starting position and the ending position of each target page number in sequence.

In a third aspect, an embodiment of the present invention provides an electronic device, including a processor and a memory, wherein,

the memory is used for storing a computer program;

the processor is configured to implement the steps of the method for deleting document contents provided by the embodiment of the present invention when executing the program stored in the memory.

In a fourth aspect, the embodiment of the present invention provides a computer-readable storage medium, in which a computer program is stored, and the computer program, when executed by a processor, implements the steps of the method for deleting document content provided by the embodiment of the present invention.

In the scheme provided by the embodiment of the invention, firstly, the target page number of the page to be deleted in the target document is determined; then determining the starting position and the ending position of the content of the page to be deleted based on the typesetting cache region of the target document and the target page number; and finally deleting the content of the page to be deleted based on the starting position and the ending position. According to the scheme provided by the embodiment of the invention, the range of the content to be deleted corresponding to the target page number can be automatically determined according to the target page number of the page to be deleted, and the content in the range can be deleted. Therefore, compared with the prior art that the contents of the pages to be deleted are deleted one by one manually, the efficiency can be improved by the scheme provided by the embodiment of the invention.

Of course, it is not necessary for any product or method of practicing the invention to achieve all of the above-described advantages at the same time.

Drawings

In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.

FIG. 1 is a flowchart illustrating a method for deleting document contents according to an embodiment of the present invention;

FIG. 2 is a schematic flow chart illustrating a method for deleting document contents according to an embodiment of the present invention;

FIG. 3 is a schematic structural diagram of an apparatus for deleting document contents according to an embodiment of the present invention;

fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.

Detailed Description

The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.

In order to improve efficiency, the embodiment of the invention provides a method and a device for deleting document content, electronic equipment and a storage medium.

It should be noted that an execution subject of the method for deleting document content provided by the embodiment of the present invention may be a device for deleting document content, where the device may be run in an electronic device; the electronic device can be a smart phone, a tablet computer, a desktop computer and the like. In addition, the device for deleting the document content may be a plug-in the document client, or a special client which is independent of the document client but can access the document client, wherein the document client is a client with a document editing function, for example, the document client may be an office client. First, a method for deleting document contents according to an embodiment of the present invention will be described.

As shown in fig. 1, a method for deleting document content according to an embodiment of the present invention may include the following steps:

s101, determining a target page number of a page to be deleted in a target document.

The electronic document can be generally divided into a streaming document and a format document according to different storage modes, and in the embodiment of the invention, the target document is a streaming document, such as a Microsoft office Word document or a Jinshan office Word WPS document. It is reasonable to understand that the target document is located in the electronic device, and the target document may be a currently opened document or a currently unopened document.

The target page number is a page number of a page to be deleted in the target document, for example, a target page number of 3 indicates that the user desires to delete the 3 rd page in the target document.

In the embodiment of the present invention, the method for determining the target page number of the page to be deleted in the target document may be: receiving target information input by a user at a preset position, wherein the target information comprises a target page number; of course, the target information may also include the name or storage location of the target document.

Of course, in the embodiment of the present invention, the manner of determining the target page number of the page to be deleted in the target document is not limited to this.

S102, determining the starting position and the ending position of the content of the page to be deleted based on the typesetting cache region of the target document and the target page number.

The layout cache region may be understood as a storage space in the electronic device, where page information corresponding to each page number of the target document is stored in the layout cache region, and the page information corresponding to any page number includes a start position and an end position of content corresponding to the page number.

The main process of this step may be: firstly, entering a typesetting cache region through the typesetting service of the target document based on the name and the like of the target document; then, in a typesetting cache region of a target document, searching page information corresponding to the target page number by using the target page number; and finally, determining the starting position and the ending position of the content in the page information corresponding to the target page number.

It should be noted that the start position and the end position are represented by a string of numbers, for example, the start position may be represented as 000.

S103, deleting the content of the page to be deleted based on the starting position and the ending position.

In this embodiment of the present invention, the deleting the content of the page to be deleted based on the start position and the end position includes: deleting the content between the start position and the end position.

And when the target page number is at least two, deleting the content of the page to be deleted based on the starting position and the ending position, including:

and deleting the content of the page to be deleted corresponding to the target page number according to the reverse order of the at least two target page numbers and based on the starting position and the ending position of each target page number in sequence.

For example, if the target page numbers are 3 and 5, deleting the content of the page to be deleted, where the target page number is 5, according to the corresponding start position and end position; and then deleting the content of the page to be deleted with the target page number of 3 according to the corresponding starting position and ending position.

It will be appreciated that the target document is a streaming document, and the way in which the position of the pages is recorded by the streaming document is front to back. When deleting at least two target page numbers of a target document, such as a 3 rd page and a 5 th page, if the target page numbers are deleted according to the forward sequence, after deleting the 3 rd page, the page number of the 5 th page needs to be adjusted to a 4 th page, and then deleting the adjusted 4 th page; and the deletion is performed in the reverse order, and the sequence number of the previous target page number does not need to be adjusted during the deletion, so that the deletion efficiency can be improved.

Generally, a document contains a plurality of elements, and the elements can be understood as components of the document, for example, the elements can be characters, punctuations, tables, pictures, and the like.

Since some elements in the target document may be set as undeletable in a specific application, before deleting the content of the page to be deleted based on the start position and the end position, the method further includes:

judging whether a first type element exists in the page to be deleted or not; the first type element may be a control or a form field with protection settings, and the protection settings may be: and setting the attributes of the control or the form field and the like as being unable to be deleted.

And if the first type elements exist in the page to be deleted, canceling the setting about the non-deletable property of the first type elements.

Because the first-class element cannot be deleted directly, the page to be deleted where the first-class element is located cannot be deleted directly, and thus, the setting about the non-deletion in the attribute of the first-class element must be cancelled first. For example, the "protection setting" option in the attribute setting of the first type element may be modified from "yes" to "no".

It is understood that, before deleting the content of the page to be deleted based on the start position and the end position, the above-mentioned determination and processing procedures are performed, which aim to identify and process the first type element with the protection setting, so that the operation of deleting the content of the page to be deleted can be performed subsequently. Therefore, the deleting efficiency of the pages to be deleted can be improved through the process.

In addition, for a target document that does not support element spread, the deleting the content of the page to be deleted based on the start position and the end position may be: deleting the content between the start position and the end position. And for the target document supporting element page spread, in the process of deleting the content of the page to be deleted based on the starting position and the ending position, judging the page spread elements, and further executing different deleting modes according to different judging results. For clarity of the scheme, for a target document supporting element span, a specific implementation manner of deleting the content of the page to be deleted based on the start position and the end position is described later with reference to a specific embodiment.

In the scheme provided by the embodiment of the invention, firstly, the target page number of the page to be deleted in the target document is determined; then determining the starting position and the ending position of the content of the page to be deleted based on the typesetting cache region of the target document and the target page number; and finally deleting the content of the page to be deleted based on the starting position and the ending position. According to the scheme provided by the embodiment of the invention, the range of the content to be deleted corresponding to the target page number can be automatically determined according to the target page number of the page to be deleted, and the content in the range can be deleted. Therefore, compared with the prior art that the contents of the pages to be deleted are deleted one by one manually, the efficiency can be improved by the scheme provided by the embodiment of the invention.

Referring to fig. 2 as another embodiment, fig. 2 is another schematic flow chart of a method for deleting document contents according to an embodiment of the present invention; as shown in fig. 2, a method for deleting document content according to an embodiment of the present invention may include the following steps:

s201, determining the target page number of the page to be deleted in the target document.

S202, based on the typesetting cache region of the target document and the target page number, determining the starting position and the ending position of the content of the page to be deleted.

S201-S202 are the same as S101-S102, and are not described herein.

S203, judging whether an element page span exists in the page to be deleted or not based on the starting position and the ending position, and if so, executing S204; otherwise, S205 is performed.

It will be appreciated that the extent occupied by an element in which a page spread occurs is beyond the extent of a page in the document. A common element in which page crossing occurs may be a table of page crossings, such as a table that spans between page 1 and page 2, which may occupy the lower portion of page 1 and the upper portion of page 2.

The purpose of the step is to identify the elements with the page crossing so as to execute different deleting modes according to different judgment results. By the method, the deleting efficiency of the page to be deleted can be improved.

In this embodiment of the present invention, determining whether there is an element page spread in the page to be deleted based on the start position and the end position may include the following three steps:

and step one, determining a first element corresponding to the starting position and a second element corresponding to the ending position.

Specifically, the related information of the first element corresponding to the start position and the second element corresponding to the end position, such as the names, types, and positions of the first element and the second element, may be determined based on page information of the target document and the like.

And secondly, judging whether the first element spans the page or not and judging whether the second element spans the page or not.

In the embodiment of the present invention, determining whether the first element is page-crossing includes two determination methods a1 and B1:

a1, when the first element is a table, a control or a form field, judging whether the starting position of the first element is before the starting position, if so, judging that the first element is spread.

It is to be understood that, when the first element is a table, a control, or a form field, the first element has a start position and an end position, because it has been determined that the element corresponding to the start position of the page to be deleted is the first element, at least the back portion of the first element is located in the page to be deleted, that is, at least the end position of the first element is located in the page to be deleted; then, if the starting position of the first element is before the starting position, it indicates that the front content of the first element is located in the page that is previous to the page to be deleted, it indicates that the first element is spread.

It should be noted that, when the first element is a control, the manner of determining the starting position of the first element is as follows: determining a starting position of the first element from kernel data of the electronic device.

B1, when the first element is a picture, a text box, a picture-text box, a footnote or a final note composed of an anchor point and an object, judging whether the position of the anchor point of the first element is before the starting position, and if so, judging that the first element spans the page.

If an element is a picture, a text frame, a footnote or a footer, etc. composed of an anchor point and an object, generally, the position of the anchor point of the element and the position of the corresponding object are the same, but in practice, the position of the anchor point and the position of the corresponding object are separated, that is, the position of the anchor point is before, the position of the corresponding object is behind, and the separation of the two positions may cause the element to cross pages.

It will be appreciated that when the first element is a picture, text box, footnote or a footer made up of an anchor point and an object, the first element has the location of the anchor point and the location of the object. Because the element corresponding to the starting position of the page to be deleted is determined to be the first element, the content of the object of at least the first element is located in the page to be deleted, that is, the position of the object of the first element is located in the page to be deleted; then, if the position of the anchor point of the first element is before the start position, the content of the anchor point of the first element is located in the page which is previous to the page to be deleted, and the first element is indicated to be page-crossing.

In the embodiment of the present invention, determining whether the second element is page-crossing includes two determination methods a2 and B2:

a2, when the second element is a table, a control or a form field, judging whether the termination position of the second element is behind the termination position, if so, judging that the second element is spread.

It is to be understood that, when the second element is a table, a control, or a form field, the second element has a start position and an end position, because it has been determined that the element corresponding to the end position of the page to be deleted is the second element, at least the front portion content of the second element is located in the page to be deleted, that is, at least the start position of the second element is located in the page to be deleted; then, if the ending position of the second element is after the ending position, the rear content of the second element is located at the next page of the page to be deleted, and the second element page crossing is indicated.

It should be noted that, when the second element is a control, the manner of determining the termination position of the second element is as follows: determining a termination location of the second element from kernel data of the electronic device.

B2, when the second element is a picture, a text box, a picture frame, a footnote or a tailnote which is composed of an anchor point and an object, judging whether the position of the object of the second element is behind the end position, and if so, judging that the second element spans the page.

It will be appreciated that when the second element is a picture, text box, footnote or a footer made up of an anchor point and an object, the second element has the location of the anchor point and the location of the object. Because the element corresponding to the end position of the page to be deleted has been determined to be the second element, at least the content of the anchor point of the second element is located in the page to be deleted, that is, the position of the anchor point of the second element is located in the page to be deleted; then, if the position of the object of the second element is after the end position, it indicates that the content of the object of the second element is located in the next page of the page to be deleted, it indicates that the second element is spread.

And thirdly, determining that the page to be deleted has element spread when at least one element of the first element and the second element is spread, and otherwise, determining that the page to be deleted has no element spread.

And S204, deleting the content of the page to be deleted based on the starting position, the ending position and the type of the element generating the page spread.

It should be noted that, in the embodiment of the present invention, the elements of the page to be deleted are based on the typesetting position of the target document, where the typesetting position is the position observed by the naked eye of the user, and the position is the format position. For example, the user may desire to delete page 2 of the target document, and the actual location of an element in the target document is at page 1, i.e., at page 1 in the text stream, but the element is at page 2 in the position that the user can see with the naked eye, and the element needs to be deleted.

This step is used when there is an element spread in the page to be deleted, and it can be understood that the types of elements that are spread are different, and the manner of deleting the content of the page to be deleted is different, and therefore, the content of the page to be deleted can be deleted based on the start position, the end position, and the types of elements that are spread.

Specifically, when the first element is spread, the deleting of the content of the page to be deleted based on the start position, the end position and the type of the element in which the spread occurs includes three deleting manners C1-C3:

and C1, if the first element is a table, deleting the content between the starting position and the ending position, and deleting the blank page or the blank line corresponding to the page to be deleted.

It is understood that if the first element is a table, after deleting the content between the start position and the end position, a blank page or a blank line may appear on the page to be deleted, and therefore, the corresponding blank page or blank line needs to be deleted.

C2, if the first element is a control or a form field, deleting the content between the starting position and the ending position, and modifying the ending position of the control or the form field to: and the end position of the previous page of the page to be deleted.

It can be understood that, if the first element is a control or a frame field, after deleting the content between the start position and the end position, the content of the first element in the page to be deleted has been deleted together with the end position, but since Office software Office specifies the integrity of the data, the placeholder of the start position and the placeholder of the end position of the element must be paired, and therefore, the end position of the control or the frame field needs to be modified to: and the end position of the previous page of the page to be deleted.

C3, if the first element is a picture, a text box, a picture-text box, a footnote or a footer composed of an anchor point and an object, recalculating the start position and the end position of the page to be deleted based on the position of the anchor point of the first element, the start position and the end position, deleting the content between the calculated new start position and the new end position, and deleting the anchor point of the first element.

It can be understood that, if the first element is a picture, a text box, a picture-text box, a footnote or a suffix composed of an anchor point and an object, it indicates that the anchor point of the first element is located in a page previous to the page to be deleted, the object of the first element is located in the page to be deleted, and the first element is an element to be deleted according to the visual effect of the user. However, it can be understood that the object of the first element cannot be deleted directly, and the anchor point of the first element needs to be deleted, so that the object of the first element disappears.

Since the range of the to-be-deleted content of the to-be-deleted page needs to be re-determined according to the position occupied by the anchor point of the first element, the start position and the end position of the to-be-deleted page may be re-calculated based on the position of the anchor point of the first element, for example, if the position occupied by the anchor point of the first element is one byte, the start position and the end position may be subtracted by one byte respectively to obtain a new start position and a new end position, and the like; and deleting the content between the new start position and the new end position obtained by calculation, and finally deleting the anchor point of the first element.

Specifically, when the second element is spread, the deleting the content of the page to be deleted based on the start position, the end position and the type of the element of the spread, includes three deleting manners D1-D3:

d1, if the second element is a table, deleting the content between the start position and the end position.

It is understood that if the second element is a table, the content between the start position and the end position can be deleted directly.

D2, if the second element is a control or a form field, deleting the content between the starting position and the ending position, and modifying the starting position of the control or the form field into: a starting position of a page next to the page to be deleted.

It can be understood that, if the second element is a control or a frame field, after deleting the content between the start position and the end position, the content of the second element in the page to be deleted together with the start position has been deleted, but since Office software Office specifies the integrity of the data, the placeholder of the start position and the placeholder of the end position of the element must be paired, and therefore, the start position of the control or the frame field needs to be modified to: a starting position of a page next to the page to be deleted.

D3, if the second element is a picture, a text box, a picture frame, a footnote or a tailnote composed of an anchor point and an object, recalculating the start position and the end position of the page to be deleted based on the position of the anchor point of the second element, the start position and the end position, and modifying the position of the anchor point of the second element to be: and deleting the content between the new start position and the new end position obtained by calculation.

It can be understood that, if the second element is a picture, a text box, a picture-text box, a footnote or a suffix composed of an anchor point and an object, it indicates that the anchor point of the second element is located on the page to be deleted, the object of the second element is located on the next page of the page to be deleted, and the second element is not an element to be deleted according to the visual effect of the user. Then, if the page to be deleted is deleted, the second element may be deleted by mistake, and therefore, the position of the anchor point of the second element may be modified as follows: a starting position of a next page of the to-be-deleted page to protect the second element.

And because the position occupied by the anchor point of the second element requires re-determining the range of the content to be deleted of the page to be deleted, the start position and the end position of the page to be deleted may be re-calculated based on the position of the anchor point of the second element, the start position and the end position, and then the position of the anchor point of the second element is modified to: and finally deleting the content between the new start position and the new end position obtained by calculation at the start position of the next page of the page to be deleted.

S203-S204 are a specific implementation manner of S103 in the above embodiment.

S205, delete the content between the start position and the end position.

This step is used in the case of no element page crossing in the page to be deleted, and it can be understood that if there is no element page crossing in the page to be deleted, the content between the start position and the end position can be deleted directly.

In the scheme provided by the embodiment of the invention, firstly, the target page number of the page to be deleted in the target document is determined; secondly, determining the starting position and the ending position of the content of the page to be deleted based on the typesetting cache region of the target document and the target page number; then, based on the starting position and the ending position, judging whether an element in the page to be deleted spans a page or not, if so, deleting the content of the page to be deleted based on the starting position, the ending position and the type of the element which has the span; and if not, deleting the content between the starting position and the ending position. According to the scheme provided by the embodiment of the invention, when the content of the page to be deleted is deleted, the corresponding deletion mode is adopted by judging whether the page to be deleted has element cross pages or not, and the range of the content to be deleted is automatically determined, so that the corresponding deletion operation is realized. Therefore, compared with the prior art that the contents of the pages to be deleted are deleted one by one manually, the efficiency can be improved by the scheme provided by the embodiment of the invention.

Corresponding to the above method embodiment, an embodiment of the present invention further provides an apparatus for deleting document content, as shown in fig. 3, where the apparatus includes:

a first determining module 301, configured to determine a target page number of a page to be deleted in a target document;

a second determining module 302, configured to determine a starting position and an ending position of the content of the page to be deleted based on the layout cache area of the target document and the target page number; page information corresponding to each page number of the target document is stored in the typesetting cache region, and the page information corresponding to any page number contains the starting position and the ending position of content corresponding to the page number;

a deleting module 303, configured to delete the content of the page to be deleted based on the start position and the end position.

Optionally, in an embodiment of the present invention, the apparatus further includes:

the judging module is used for judging whether a first type element exists in the page to be deleted before deleting the content of the page to be deleted based on the starting position and the ending position; wherein the attribute of the first type element is set to be undeletable;

and the canceling module is used for canceling the setting which cannot be deleted in the attribute of the first type element if the first type element exists in the page to be deleted.

Optionally, in this embodiment of the present invention, the deleting module 303 includes:

the judging submodule is used for judging whether the page to be deleted has element spread pages or not based on the starting position and the ending position;

the first deleting submodule is used for deleting the content of the page to be deleted based on the starting position, the ending position and the type of the element generating the page spread if the page to be deleted has the element spread;

and the second deletion submodule is used for deleting the content between the starting position and the ending position if no element in the page to be deleted crosses the page.

Optionally, in this embodiment of the present invention, the determining sub-module includes:

a first determining unit, configured to determine a first element corresponding to the start position and a second element corresponding to the end position;

the judging unit is used for judging whether the first element spans a page or not and judging whether the second element spans the page or not;

a second determining unit, configured to determine that there is an element page spread in the page to be deleted when at least one of the first element and the second element is page spread, and otherwise, determine that there is no element page spread in the page to be deleted.

Optionally, in an embodiment of the present invention, the determining unit is specifically configured to:

when the first element is a table, a control or a form domain, judging whether the initial position of the first element is before the initial position, and if so, judging that the first element spans pages;

and when the first element is a picture, a text frame, a picture-text frame, a footnote or a final note which consists of an anchor point and an object, judging whether the position of the anchor point of the first element is before the starting position, and if so, judging that the first element spans the page.

Optionally, in an embodiment of the present invention, the determining unit is specifically configured to:

when the second element is a table, a control or a form domain, judging whether the termination position of the second element is behind the termination position, and if so, judging that the second element spans the page;

and when the second element is a picture, a text frame, a picture-text frame, a footnote or a final note which consists of an anchor point and an object, judging whether the position of the object of the second element is behind the end position, and if so, judging that the second element spans the page.

Optionally, in this embodiment of the present invention, when the first element crosses the page, the first deletion sub-module is specifically configured to:

if the first element is a table, deleting the content between the starting position and the ending position, and deleting a blank page or a blank line corresponding to the page to be deleted;

if the first element is a control or a form domain, deleting the content between the starting position and the ending position, and modifying the ending position of the control or the form domain into: an end position of a page immediately preceding the page to be deleted;

if the first element is a picture, a text frame, a picture-text frame, a footnote or a tailnote which consists of an anchor point and an object, recalculating the starting position and the ending position of the page to be deleted based on the position of the anchor point of the first element, the starting position and the ending position, deleting the content between the calculated new starting position and the new ending position, and deleting the anchor point of the first element.

Optionally, in this embodiment of the present invention, when the second element crosses the page, the first deletion submodule is specifically configured to:

deleting the content between the start position and the end position if the second element is a table;

if the second element is a control or a form domain, deleting the content between the starting position and the ending position, and modifying the starting position of the control or the form domain into: a starting position of a next page of the page to be deleted;

if the second element is a picture, a text frame, a picture-text frame, a footnote or a tailnote which is composed of an anchor point and an object, based on the position of the anchor point of the second element, the starting position and the ending position, recalculating the starting position and the ending position of the page to be deleted, and modifying the position of the anchor point of the second element into: and deleting the content between the new start position and the new end position obtained by calculation.

Optionally, in this embodiment of the present invention, when the target page number is at least two, the deleting module 303 is specifically configured to:

and deleting the content of the page to be deleted corresponding to the target page number according to the reverse order of the at least two target page numbers and based on the starting position and the ending position of each target page number in sequence.

In the scheme provided by the embodiment of the invention, firstly, the target page number of the page to be deleted in the target document is determined; then determining the starting position and the ending position of the content of the page to be deleted based on the typesetting cache region of the target document and the target page number; and finally deleting the content of the page to be deleted based on the starting position and the ending position. According to the scheme provided by the embodiment of the invention, the range of the content to be deleted corresponding to the target page number can be automatically determined according to the target page number of the page to be deleted, and the content in the range can be deleted. Therefore, compared with the prior art that the contents of the pages to be deleted are deleted one by one manually, the efficiency can be improved by the scheme provided by the embodiment of the invention.

Corresponding to the above method embodiments, the embodiment of the present invention further provides an electronic device, as shown in fig. 4, which may include a processor 401 and a memory 402, wherein,

the memory 402 for storing a computer program;

the processor 401 is configured to implement the steps of the method for deleting document content according to the embodiment of the present invention when executing the program stored in the memory 402.

The Memory may include a RAM (Random Access Memory) or an NVM (Non-Volatile Memory), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the processor.

The Processor may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but also a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field-Programmable Gate Array) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware component.

Through above-mentioned electronic equipment, can realize: firstly, determining a target page number of a page to be deleted in a target document; then determining the starting position and the ending position of the content of the page to be deleted based on the typesetting cache region of the target document and the target page number; and finally deleting the content of the page to be deleted based on the starting position and the ending position. According to the scheme provided by the embodiment of the invention, the range of the content to be deleted corresponding to the target page number can be automatically determined according to the target page number of the page to be deleted, and the content in the range can be deleted. Therefore, compared with the prior art that the contents of the pages to be deleted are deleted one by one manually, the efficiency can be improved by the scheme provided by the embodiment of the invention.

In addition, corresponding to the method for deleting document contents provided in the foregoing embodiments, an embodiment of the present invention provides a computer-readable storage medium, in which a computer program is stored, and when the computer program is executed by a processor, the steps of the method for deleting document contents provided in the embodiment of the present invention are implemented.

The above-mentioned computer-readable storage medium stores an application program that, when executed, executes the method for deleting document contents provided by the embodiment of the present invention, and thus can implement: firstly, determining a target page number of a page to be deleted in a target document; then determining the starting position and the ending position of the content of the page to be deleted based on the typesetting cache region of the target document and the target page number; and finally deleting the content of the page to be deleted based on the starting position and the ending position. According to the scheme provided by the embodiment of the invention, the range of the content to be deleted corresponding to the target page number can be automatically determined according to the target page number of the page to be deleted, and the content in the range can be deleted. Therefore, compared with the prior art that the contents of the pages to be deleted are deleted one by one manually, the efficiency can be improved by the scheme provided by the embodiment of the invention.

For the embodiments of the electronic device and the computer-readable storage medium, since the contents of the related methods are substantially similar to those of the foregoing embodiments of the methods, the description is relatively simple, and for the relevant points, reference may be made to the partial description of the embodiments of the methods.

It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.

All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the system embodiment, since it is substantially similar to the method embodiment, the description is simple, and for the relevant points, reference may be made to the partial description of the method embodiment.

The above description is only for the preferred embodiment of the present invention, and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention shall fall within the protection scope of the present invention.

All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the system embodiment, since it is substantially similar to the method embodiment, the description is simple, and for the relevant points, reference may be made to the partial description of the method embodiment.

The above description is only for the preferred embodiment of the present invention, and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention shall fall within the protection scope of the present invention.

18页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种文本后缀索引的分块归纳排序方法及系统

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!