Embodiment
The embodiment of the invention is in order to improve the composing efficient of document file effectively; A kind of composition method of high-quality document file simple to operate is provided; This method comprises: composing device is according to the instrument template file of user's input; Resolve the instrument template file, obtain document rule son file, document style son file and document key element style son file; The text that composing device imports according to the user according to content structure information, is resolved each key element and the factor content that are comprised in the acquisition text; Composing device will be resolved the key element attribute that each factor content of obtaining and document manifest object and mated; The factor content that will be complementary pass to the key element attribute of coupling corresponding manifest object; Manifest style and the rule in the document rule son file in the document style son file that object uses according to this, the factor content that manifests in the object is set type.In the embodiment of the invention; Combine with the database organic phase through the instrument template file, realize from Database Systems, extracting data message, be transferred to the composing transposition; Can carry out batch, automatic typesetting; And can be by composing transposition derived data information, Database Systems are given in passback, carry out the write-back and the renewal of data.
In embodiments of the present invention, template file has been confirmed the form of whole document; By the key element style in the template, what make up document manifests object and page object, manifests object and comprises objects such as text, figure, image and form; Manifest the information such as composing style, composing rule and document key element that object also comprises use, promptly manifest object and have semantic information; Page object can contain the page number, is the page info of document.The content of text file is structurized.
The key element content sent to manifest object, with replacement or increase the content that manifests object, successively the object that manifests in the document is formatd, in the page, adjust then, discharge; When format manifests object, use its style information, in adjustment, when discharging manifests object, use its rule and style information.
In the embodiment of the invention; The instrument template file is extend markup language (Extensible MarkupLanguage, XML, XML) file; And, resolve document rule son file, document style son file and the document key element style son file that obtains by this document template file.
Below in conjunction with Figure of description, the embodiment of the invention is elaborated.
The composition method of a kind of document file that Fig. 1 provides for the embodiment of the invention, this method specifically may further comprise the steps:
S101: composing device is resolved and is obtained this document template file corresponding document rule son file, document style son file and document key element style son file according to the instrument template file of user's input.
Wherein, This document template file is extend markup language (Extensible Markup Language, XML, XML) file; And; Comprise by this document template file: document rule son file, document style son file and document key element style son file, and document rule son file, document style son file and document key element style son file all are the XML file.
Specifically comprise: resolve document rule son file, document style son file and document key element style son file respectively, that sets up the composing rule objects that defines in the instrument template, style object, document manifests object and page object.The object that manifests of document comprises visual elements such as literal object, Drawing Object, image object and table objects, and they represent the content and the form of document.Page object is the page structure of document, can comprise information such as the page number, header and footer in the page structure, and to after manifesting object and carry out the pageization, what also comprise this page in the page object and discharged manifests object.
In the embodiment of the invention, the content of this document rule son file comprises: the element that the document format rule constitutes, and this document format rule can have; Can not have yet; The document format code requirement that depends on tissue or mechanism, this document format rule comprises: key element page displayed rule, the rule of binding between key element; Key element is printed rule etc., and for example: the dispatch sign is made regulation rule, official seal and other key element same page by oneself and tied up rule etc.Each regular function can be described through explanatory note, and composing device has been realized the framework of rule invocation, and the concrete realization module of rule needs exploitation separately, adds composing device to through the mode of expansion plugin.In embodiments of the present invention in this document rule son file; The corresponding identifier of each rule; Be used to be different from other rule, and each rule comprises this regular function text description and parameter of regularity, the function of coming implementation rule through concrete regular card module.In concrete process of typeset when adopting that wherein certain is regular; Can directly adopt should the rule corresponding identifier; Composing device finds corresponding rule according to regular corresponding identifier; Find the corresponding regular plug-in unit expansion module of this rule again, employing should manifest object adjustment to being correlated with by rule plug-in unit expansion module.
Document style son file is the style collection of the various form objects that occur in the document file, and wherein the content of this document style son file comprises: the page, font statement, literal, paragraph, text box, figure, image and styles such as cell and form.Each style all has a unique identifier, can identify a style with an identifier.And; In embodiments of the present invention; Adopt the mode that certain style should contain attribute to define this kind style; Be that each style comprises definite attribute of a configuration, for example: the text box style is described the regional text formatting of document, and text frame appearance comprises: the attributes of a configuration such as literal, paragraph, position, size, alignment thereof, line style and color.The XML label that the different attribute of a configuration that each style comprises is also corresponding different respectively promptly identifies the attribute of a configuration that comprises in the style through the XML label.Resolve document style son file, make up the style of definition.In the process of setting type; Can directly quote the style corresponding identifier; Same style corresponding identifier can repeatedly be cited, and composing device finds the definition of this style according to the style corresponding identifier, is formatd by the definition of this style attribute of a configuration to relevant factor.
Content in the document key element style son file comprise the document file page info, manifest object type (like literal, figure, image etc.), manifest object and use style and manifest information such as object service regeulations, also can comprise the content information that specifically manifests object.The document file generally is divided into three parts such as eyebrow head, main body and version note, and every part comprises some document key elements again, and for example: eyebrow stem branch possibly comprise: key elements such as confidential and security deadline, issued organ, signed by or the like.The key element that document comprises is extendible, can be confirmed by the document format demand of tissue, mechanism.Document key element style son file mainly is to needing the form of content to describe in the document file; Style and rule through using realize; For example, " confidential and security deadline " that the eyebrow stem is divided will use a certain text box style, therefore; " confidential and the security deadline " that this eyebrow stem is divided just quoted the unique identifier of text frame appearance, and the mode that rule is used is identical with the mode that style is used.When resolving document key element style son file; The content object types structure that manifests by each key element style manifests object (manifesting object like text, figure, image and form etc.); This key element is to manifest the corresponding document key element of object; The style identifier that the key element style is quoted is exactly to manifest the style corresponding identifier that object adopts, and the rule identifier that the key element style is quoted is exactly to manifest the regular corresponding identifier that object adopts.
S102: composing device is according to the text of user's guiding structureization; The content structure of identification text file; And, resolve and obtain each key element and the factor content that are comprised in the text, wherein according to the content structure of text file; The structured message of text can be self-defined, and can expand.
Specifically comprise: the content structure of composing device identification text file; Wherein, The content structure of text file mainly comprises: the eyebrow of text file is first, main body and version note, because the eyebrow of text is first, main body and version note all can comprise certain content, for example eyebrow stem branch possibly comprise the information such as security classification, urgency level, Origin, Originator of text file; Thereby can be according to the content structure of text; Document key element and the corresponding content of document key element that text file comprises obtained in parsing, " urgency level " key element comprising of this eyebrow stem branch for example, and its corresponding content is " promptly ".
S103: composing device will be resolved the key element attribute that each key element of obtaining and document manifest object and mated; The corresponding factor content of the key element that will be complementary pass to the key element attribute of coupling corresponding manifest object; Manifest style and the rule in the document rule son file in the document style son file that object uses according to this, the factor content that manifests in the object is set type.
Wherein, this factor content pass to the key element attribute of coupling corresponding manifest object the time, comprise this factor content replacement, insert or append the content that this manifests object.Set type and comprise manifesting factor content in the object: the format of factor content, the pageization.
For example; The text that this composing device imports according to the user, obtaining the first corresponding content of " urgency level " key element of text file eyebrow is " promptly ", this composing device is with the key element of text file; The key element attribute that manifests object that comprises with document matees; The key element attribute that this key element and this document manifest object is the key element attributes match success of " urgency level ", and composing device should mate factors of success corresponding content " promptly ", sends that the key element attribute is the object that manifests of " urgency level " in this document to; Style in the document style son file of quoting according to this document key element style son file " urgency level " key element; And the rule in the document rule son file, promptly manifest style and the rule that object adopts and set type, for example according to this; When the sign of quoting style and certain style in the document style son file identify when identical; If it is that the Song typeface, word size are No. five that style is claimed as font, this composing device should be set type according to the Song typeface, No. five words by " promptly " two words, and according to the rule that this key element is quoted the factor content that manifests in the object is adjusted.
The text that the user imports should be structurized text, and this composing device identifies the structure and the content of text through the XML technology.
In the process that composing device is set type in embodiments of the present invention; According to the word content of setting type; Split at each section transformation character place; Thereby can produce one by one independently paragragh, section transformation character is a carriage return character, newline or carriage return character newline and then.In the process that the embodiment of the invention is set type; The mode that adopts page by page, successively the factor content that manifests in the object is set type; As shown in Figure 2, be the process of carrying out page by page in the embodiment of the invention, successively the factor content that manifests in the object being set type, this process may further comprise the steps:
S201: composing device is at the current page of setting type, but one layout region in the calculating current page.
One layout region comprises in the current page but calculate: according to the zone of having set type in this current page, and the overall area of this current page, but confirm one layout region in this current page.
S202: according to the position that manifests the factor content in the object and the size of setting type before deserving; Judge but whether one layout region in the current page can discharge the factor content in the object that manifests of setting type before deserving, when judged result when being, carry out S203; Otherwise, carry out S204.
S203: but in the one layout region of this current page, the factor content that manifests in the object of setting type before deserving is set type, to the adjustment of aliging of the factor content after this composing, carry out S205 afterwards.
S204: search adjacent with this current page page that is positioned at after this current page; Promptly following one page of this current page when not finding, produces the new page; The page that this is new is as following one page of this current page; The current factor content that manifests in the object of setting type is set type at following one page of this current page, come down the front that manifests object that one page comprises, to the adjustment of aliging of the factor content after this composing.
S205: judge current set type manifest whether service regeulations of object, when judged result when being, S206, otherwise, carry out S201.
S206: the composing device service regeulations are adjusted the relevant factor content that manifests in the object of this rule, carry out S201 afterwards.
That sets type before deserving in the above-described embodiments manifests object and can be text box, form, image and figure etc.
In embodiments of the present invention, the composing of text box is to be the format that unit carries out literal with the paragragh, and the literal that calculates one by one in the paragragh takes up space, and forms literal line one by one.Text box comprises in embodiments of the present invention: the fixed-size text box in space, reach the text box that the space size can change with the variation of word content and form, and be called for short the textbox that adapts to literal.The height that adapts to the textbox of literal is commonly defined as the height of delegation's literal; Its shared height is set after the composing; In process of typeset; Such textbox object possibly be split into a plurality of continuous textbox objects, is emitted on the different pages, and word content is forward and backward mobile between the page possibly during composing.
The embodiment of the invention is carried out in the process of text box composing; Adopt the mode of the paragragh that the text box of setting type piecemeal, successively comprises; As shown in Figure 3, be the process that the paragragh that in the embodiment of the invention text box is comprised carries out piecemeal, sets type successively, this process may further comprise the steps:
S301: composing device deserves preceding text box one layout region according to the current text frame of setting type but calculate.
Should preceding text box one layout region comprise but calculate: confirm the type of current text frame, when being the fixed-size text box in space, the length in the zone that the style that use for text box in the arranged zone of text frame defines and wide; When being when adapting to the text box of literal, regional length and wide can be arranged for current page in the arranged zone of text frame.
S302: whether have the current paragragh that will set type in the text box before judge deserving, when judged result when being, carry out S303, otherwise, carry out S315.
S303: but the one layout region of the current paragragh that will set type of calculating.
But the one layout region of calculating the current paragragh that will set type comprises: but according to the one layout region of deserving preceding text box, the zone that text box has been set type before deserving, and the preceding distance of the section of the current paragragh that will set type; But confirm the one layout region of the current paragragh that will set type; Be specially, but, deduct the zone that text box has been set type before deserving the one layout region of deserving preceding text box; And deduct distance before the section of the current paragragh that will set type, thereby but obtain the one layout region of this current paragragh that will set type.
S304: judge in this current paragragh that will set type whether have the current literal that will set type, when judged result when being, carry out S305, otherwise, carry out S310.
S305: determine whether to exist current line, when not having current line, then produce a new literal line as current line, the shared height and width of new literal line Chinese words all are 0.
S306: according to the style of the literal use of setting type before deserving; Calculate the wide and high of the current literal that will set type; The current literal that will set type is joined in the current line; Add the wide of this current line Chinese words of current adding this current line shared wide of literal of having set type, be shared wide of this current line literal.
S307: the literal according to setting type before deserving, determine whether to tear open row, but when the shared one layout region that is wider than current paragragh of current line literal wide; Then need tear row open; Carry out S308, otherwise, with literal in back of this current literal that will set type; To carry out S304 as the current literal that will set type.
S308: but according to this current line of wide fractionation of the one layout region of this current paragragh; When carrying out the fractionation of current line; According to the taboo of literal row, the attribute of on-disconnectable branch is confirmed the fractionation point of current line; The literal that literal before this fractionation point comprises for this current line splits some literal afterwards and is literal to be arranged.
S309: the literal in the current line is compressed or stretch processing, make that the shared width of literal in this current line is the width of this current line.
S310: judge that whether current line is empty, when judged result when being, carry out S311, otherwise, carry out S312.
S311: the height in arranged zone that will this current paragragh that will set type reduces the section back distance of the paragragh that will set type before deserving, carries out S313 then,
S312: calculate the shared height of literal in the current line, be about to word height the highest in the current line, confirm in the current paragragh that will set type, to add this current line as the shared height of the literal in this current line; When increasing successfully, the current behavior sky is set, carry out S304; Unsuccessful, then carry out S313.
Confirm that in this current paragragh that will set type adding this current line comprises: when the spatial altitude in the arranged zone of this current paragragh that will set type is not less than shared high of literal in this current line; This current line of discharging in this current paragragh that will set type; Recomputate the height in the arranged zone of this current paragragh that will set type; When the spatial altitude in the arranged zone of this current paragragh that will set type during, do not discharge this current line at this current paragragh that will set type less than shared high of the literal in this current line.
The height that recomputates the arranged zone of this current paragragh that will set type comprises: the height in arranged zone that will this current paragragh that will set type; Deduct the shared height of literal in this current line; Deduct the line-spacing of this current paragragh that will set type again, with the height of gained result as new the arranged zone of this current paragragh that will set type.
S313: finish the composing of the current paragragh that will set type, the row alignment of advancing in this paragragh is adjusted wherein, the alignment adjustment comprises operations such as a left side, residence, the residence is right, placed in the middle and fully support; Calculate the one layout region of text box before deserving, judge whether current line is empty, when this current line is not sky; Carry out S314; Otherwise the paragragh of a back paragragh of this current paragragh that will set type for setting type carries out S302.
Calculating the zone that text box has been set type before deserving comprises: but according to the one layout region of deserving preceding text box, but deduct the one layout region of deserving previous paragraphs, confirm the zone that the current text frame has been set type.
S314: split this current paragragh that will set type; Produce a follow-up paragragh of this current paragragh of will setting type; The literal of also not setting type in first word in this current line, the literal of this first word back, this current paragragh of will setting type all is moved in the follow-up paragragh, and is placed on the back of this current paragragh of will setting type to it.
S315: the composing of text box before finishing to deserve; The shared zone of text box is exactly the zone that text box has been set type before deserving before deserving; Text box is when adapting to the text box of literal, if any not arranging paragragh, then to produce a follow-up text frame of current text frame before deserving; Do not arrange paragragh and all be moved in this follow-up text frame, and be placed on the back of deserving preceding text box to this follow-up text frame.
Also comprise in embodiments of the present invention tabular matter; To tabular matter the time, at first need set type to each table row; Then the cell in each table row is set type, when the content in the cell was set type, its process was with similar to the process of typeset of text box.When a form can't be set type in one page, can this form be come in two pages, concrete process comprises: but calculate one layout region in the current page; But according to the space of one layout region in this current page, and the used space of this tabular matter, judge; When but the space of one layout region in this current page is not less than this tabular matter and takes up space; But this form of setting type in the one layout region in this is current, otherwise, but this form of in the one layout region of this current page, setting type; And in the zone that following one page of this current page begins to set type, the residue content of this form of setting type.
During in embodiments of the present invention to the composing of image and figure, can discharge, also need then the adjustment of aliging of this image or figure according to the space size in image and the shared zone of figure.
Also comprise direct modification instrument template file in embodiments of the present invention; Mode so that template is revised is opened the instrument template file; Can revise style, the rule of document key element use and the content of document key element correspondence that the document key element is used, revise the style that the document key element is used, revise the rule of document key element use; Content and form that amended document key element style is corresponding are written back in this document template file, realize the instrument template file modifying.
In embodiments of the present invention by instrument template file editor document file, be to serve as the newly-built document file in basis, on this basis with the instrument template file; Can import text again, the content information of document key element in this document template file is set, also can directly carry out the content input of document key element; Edit the content information of this document key element; Also can be provided with and revise the format information of document key element, in this process, when meaningful need the composing; This composing device is set type automatically in real time; The content of document file and the redjustment and modification of form all are written back in this article written matter, the process of Fig. 4 for carrying out redjustment and modification in this embodiment of the invention, and this process specifically may further comprise the steps:
S401: the document file after composing device will be set type is shown to the user.
S402: the user carries out the editor of content and/or the setting of form according to this document template file.
Wherein, content edited is kept at corresponding manifesting in the object, and the setting of form comprises: the corresponding object that manifests is set, makes it adopt different styles or employing different rules, or carry out resetting of style or resetting of rule.And can comprise modification to the content that manifests object.
S403: the information of the editor of the content that this user of composing device record carries out and/or the setting of form; The modification of rule is written back in the regular son file; The modification of style is written back in the style son file, and the modification of rule of style and employing that will manifest content, the employing of object is written back in the corresponding element in the document key element style son file.
The composing device of a kind of document file that Fig. 5 provides for the embodiment of the invention, this device comprises:
First parsing module 51 is used for the instrument template file according to user's input, resolves to obtain this document template file corresponding document rule son file, document style son file and document key element style son file;
Second parsing module 52 is used for the text according to user's importing, resolves each factor content that is comprised in the acquisition text file;
Send type-setting module 53; Be used for the key element attribute of each factor content and document key element style son file is mated; The factors of success that will be complementary content is passed to the object that manifests of key element attribute correspondence; Manifest style and the rule in the document rule son file in the document style son file that object adopts according to this, this factor content that manifests in the object is set type.
Said transmission type-setting module 53 comprises:
Computing unit 531 is used at the current page of setting type, but calculates one layout region in this current page;
Judging unit 532 is used for position and size according to the factor content of setting type before deserving, but judges whether one layout region in this current page can discharge the factor content of setting type before deserving;
When being used in confirming this current page, can discharging the factor content of setting type before deserving, but set type to this factor content in this current one layout region in also in composing unit 533; In the time of in confirming this current page, can not discharging the factor content of setting type before deserving; Confirm adjacent with this current page to be positioned at this current page afterwards; Following one page of this current page, the factor content of before deserving, setting type is set type at following one page of this current page and this current page.
Said composing unit 533 comprises:
Judgment sub-unit 5331 is used for when the row of setting type is set type, judging whether the character of setting type is the literal of on-disconnectable branch;
Composing subelement 5332, be used for according to this character take quiet and deserted, and the last space of row of should setting type determines whether at this this character of composings row composing.
Said device also comprises:
Record write-back module 54; Be used for the editor of the content that recording user carries out the instrument template file and/or the information that is provided with of form; And according to this information; The modification of rule is written back in the regular son file, the modification of style is written back in the style son file, will manifest object content, and this modification that manifests the rule of style that object adopts and employing be written back in the corresponding element in the document key element style son file.
The embodiment of the invention provides a kind of composition method and device of document file, and this method comprises: composing device is resolved and is obtained instrument template file corresponding document rule son file, document style son file and document key element style son file; According to the text that the user imports, resolve each factor content that is comprised in the acquisition text file; Composing device matees the key element attribute in each factor content and the document key element style son file; The factors of success that will be complementary content is passed to the object that manifests of key element attribute correspondence; This factor content that manifests in the object is set type; Combine with database through the instrument template file, realize from database, extracting text data and carry out automatic typesetting, thereby improve the efficient of setting type; Can also be written back in the database seamless connection of fulfillment database and composing device to key element in the document file and factor content derivation in addition.
Obviously, those skilled in the art can carry out various changes and modification to the present invention and not break away from the spirit and scope of the present invention.Like this, belong within the scope of claim of the present invention and equivalent technologies thereof if of the present invention these are revised with modification, then the present invention also is intended to comprise these changes and modification interior.