Tabular matter method and apparatus
Technical field
The present invention relates to digital typesetting system field, in particular to a kind of tabular matter method and apparatus.
Background technology
At present when form carries out special symbol alignment operation, the operation provided chooses permutation to arrange, and permutation is all alignd with special symbol.
The typesetting effectiveness comparison that this operator scheme provides is simple, cannot meet the individual demand of user.
Summary of the invention
The embodiment of the present invention provides a kind of tabular matter method and apparatus, to meet the individual demand of user to tabular matter.
For this reason, the embodiment of the present invention provides following technical scheme:
A kind of tabular matter method, comprising:
When needing to do alignment adjustment to the cell in form, the cell in traversal form;
Judge whether current cell exists special symbol alignment properties;
If there is no, then continue to judge whether next unit lattice exist special symbol alignment properties;
If existed, then determine reference cell lattice;
According to the position of special symbol in described reference cell lattice and current cell, calculate off-set value;
According to described off-set value, position adjustment is carried out to described current cell;
After position has adjusted, continue to judge whether next unit lattice exist special symbol alignment properties.
Preferably, the cell in described traversal form comprises:
According to row from left to right, the order from top to bottom of row starts to travel through all cells.
Preferably, describedly determine that reference cell lattice comprise:
If described current cell is positioned at the first row, then using described current cell as reference cell lattice;
Otherwise, then belonging to described current cell, arrange the cell upwards searched and do not have alignment properties, if found, then will there is no the next line cell of the cell of alignment properties as reference cell lattice.
Preferably, described method also comprises:
Arrange belonging to described current cell upwards search the cell not having alignment properties time, if until the first row does not still find, then using the cell of this row the first row as reference cell lattice.
Preferably, described method also comprises:
After inputting the operation causing cell content to change, form is reset, generate typesetting result full-page proof;
Start unit style is whole, to do alignment adjustment to each cell.
A kind of tabular matter device, comprising:
Spider module, for when needing to do alignment adjustment to the cell in form, the cell in traversal form;
Judge module, for judging whether current cell exists special symbol alignment properties; If there is no, then notify that described spider module starts to travel through next unit lattice;
Reference cell lattice determination module, after judging that current cell exists special symbol alignment properties at described judge module, determines reference cell lattice;
Off-set value computing module, for the position according to special symbol in described reference cell lattice and current cell, calculates off-set value;
Adjusting module, for carrying out position adjustment to described current cell according to described off-set value, and after described position has adjusted, notifies that described spider module starts to travel through next unit lattice.
Preferably, described spider module, specifically for according to row from left to right, the order from top to bottom of row starts to travel through all cells.
Preferably, described reference cell lattice determination module, specifically for when described current cell is positioned at the first row, using described current cell as reference cell lattice; Otherwise, belonging to described current cell, arrange the cell upwards searched and do not have alignment properties, if found, then will there is no the next line cell of the cell of alignment properties as reference cell lattice.
Preferably, described device also comprises:
Described reference cell lattice determination module, also for arrange belonging to described current cell upwards search the cell not having alignment properties time, if until the first row does not still find, then using the cell of this row the first row as reference cell lattice.
Preferably, described device also comprises:
Type-setting module, for after inputting the operation causing cell content to change, resets form, generates typesetting result full-page proof;
Start module, whole for start unit style, to do alignment adjustment to each cell.
The tabular matter method and apparatus that the embodiment of the present invention provides, when needing to do alignment adjustment to the cell in form, by the cell in traversal form, determines reference cell lattice; According to the position of special symbol in reference cell lattice and current cell, calculate off-set value; According to this off-set value, position adjustment is carried out to current cell.Thus can align with special symbol by the cell realized easily in same row in partial row.And, further, the special symbol of aliging can also be needed to judge, realize different units lattice in row and, with the alignment of different special symbols, meet the individual demand of user to tabular matter.
Accompanying drawing explanation
Fig. 1 is the process flow diagram of embodiment of the present invention tabular matter method;
Fig. 2 is with the tabular matter schematic diagram of special symbol alignment in the embodiment of the present invention;
Fig. 3 is the concrete typesetting process flow diagram of form shown in Fig. 2;
Fig. 4 is the structural representation of embodiment of the present invention tabular matter device.
Embodiment
Below with reference to the accompanying drawings and in conjunction with the embodiments, describe the present invention in detail.
Shown in Fig. 1, be the process flow diagram of embodiment of the present invention tabular matter method, comprise the following steps:
Step 101, when needing to do alignment adjustment to the cell in form, obtains current cell.
Step 102, judges whether current cell exists special symbol alignment properties; If there is no, then step 106 is performed; Otherwise, perform step 103.
Step 103, determines reference cell lattice.
Particularly, if described current cell is positioned at the first row, then using described current cell as reference cell lattice; Otherwise, then belonging to described current cell, arrange the cell upwards searched and do not have alignment properties, if found, then will there is no the next line cell of the cell of alignment properties as reference cell lattice.If arrange belonging to described current cell upwards search the cell not having alignment properties time, if until the first row does not still find, then using the cell of this row the first row as reference cell lattice.
Step 104, according to the position of special symbol in described reference cell lattice and current cell, calculates off-set value.
Step 105, carries out position adjustment to described current cell according to described off-set value.
Step 106, judges whether all cells traveled through in form; If so, then terminate; Otherwise, perform step 107;
Step 107, obtains next unit lattice as current cell, then returns step 102, continues to judge whether next unit lattice exist special symbol alignment properties.
It should be noted that, in actual applications, when traveling through the cell in form, can according to row from left to right, the order from top to bottom of row starts to travel through all cells.Certainly, also according to other order, this embodiment of the present invention can not limited.
Below for form shown in Fig. 2, further describe embodiment of the present invention tabular matter method.
Form as shown in Figure 2, require in this example that first row and the 3rd arranges and adopt solidus alignment, and secondary series and the 4th row adopt decimal alignment, front two capable participations of all row are alignd.
In the scheme of prior art, if when adopting special symbol alignment, must take row as unit, then cannot realize the effect in Fig. 2.
And utilize the scheme of the embodiment of the present invention, can reach above-mentioned alignment effect well, detailed process is as follows:
1. choose the cell needing to do special symbol alignment, alignment properties is set, and by this attribute record in the attribute of each cell chosen.
2. reset cell sample according to normal typesetting flow process, typesetting result generates full-page proof.
Described sample refers to the content of word, and full-page proof refers to the result that word presents in region.Such as same " 1234567890 " string number, because the width of text box is different, may present 2 row, the display effect that 3 row etc. are different.Often kind of display effect is all a full-page proof, and the content of this string numeral itself can't change, sample that Here it is.The effect of typesetting is exactly the width according to different literals frame, and full-page proof corresponding for sample is presented.
3. travel through form, alignment adjustment is done to each cell.
It should be noted that, when Traversal Unit lattice, can in a certain order such as from left to right, order from top to bottom, certainly, also can random selecting first cell that will travel through, this embodiment of the present invention is not limited, as long as all cells in form can be traveled through.
Concrete adjustment process is as follows:
(1) obtain current cell, namely need the cell doing alignment adjustment, in order to be described clearly conveniently, current cell is called cell C;
(2) whether inspection unit lattice C has alignment properties; If no, then skip this cell to next unit cell; If there is alignment properties, then perform next step.
(3) the lastrow cell with cell C same column is found; If this cell does not have alignment properties, then perform next step.If this cell exists alignment properties, then repeat step (3) until find the cell not having alignment properties, for convenience, this do not had the cell of alignment properties to be called cell D.
Upwards search, object searches alignment reference cell lattice.When after finding according to the position of special symbol in this cell, come, to the text excursion in cell C, to reach alignment effect.
(4) arranging with the next line cell of cell D same column is reference cell lattice.Cell C is offset according to the position of reference cell lattice special symbol.If reference cell lattice are exactly C itself, then without the need to adjustment.
Under alignment operation simple declaration: first, calculate the width of cell C and each cell of reference cell compartment and full-page proof position Pos (x, y) of special symbol.If align center, then offset Y (width/2 mono-Pos.x) is carried out, to realize special symbol centering effect to each cell content; If occupy left-justify, first compare the maximal value MaxPos.x obtaining special symbol position Pos.x in these cell content, then all cell generalised displacement (MaxPos.x-Pos.x).Correspondingly, Right Aligns is occupied in like manner.
It should be noted that, if it is first to have found row in step (4), still have alignment properties, then using first for this row cell as reference cell lattice.
Fig. 3 shows the concrete typesetting flow process of form shown in Fig. 2, mainly comprises the steps:
(1) cause cell content to change at input characters etc. and after the operation that must reset, by normal typesetting flow process, form reset, generating typesetting result full-page proof.
(2) start unit style is whole.According to row from left to right, the order from top to bottom of row starts to travel through all cells.
(3) judge whether current cell C exists special symbol alignment properties, if there is no, then return step (2).If existed, then enter step (4).
(4) whether judging unit lattice C is the first row.If so, then arranging this cell is reference cell lattice, and enters step (6).If not, then enter step (5).
(5) obtain the lastrow cell u of this cell C same column, and whether judging unit lattice u exists special symbol alignment properties.If existed, then cell u is set to current cell temporarily, and returns step (4) and process.If there is no, then setting unit lattice C is reference cell lattice.
(6) according to the position of special symbol in reference cell lattice and current cell, the value needing skew is calculated.Current cell is carried out the adjustment of corresponding position according to this value.Return step (2) after end, continue process next unit lattice.
(7), after all cell traversals terminate, the special symbol adjustment operation of this typesetting is just completed.
As can be seen here, the tabular matter method that the embodiment of the present invention provides, when needing to do alignment adjustment to the cell in form, by the cell in traversal form, determines reference cell lattice; According to the position of special symbol in reference cell lattice and current cell, calculate off-set value; According to this off-set value, position adjustment is carried out to current cell.Thus can align with special symbol by the cell realized easily in same row in partial row, meet the individual demand of user to tabular matter.
And, further, the special symbol of aliging can also be needed to judge, realize in same row the mode of special symbol alignment different with two kinds respectively.Such as 1-1O exercises by " $ " symbol aligned, and 11-20 exercises by " $ " symbol aligned.Prior art does special symbol alignment operation in units of permutation, and this effect also cannot realize.
Correspondingly, embodiments providing a kind of tabular matter device, as shown in Figure 4, is the structural representation of this device.
In this embodiment, described device comprises:
Spider module 401, for when needing to do alignment adjustment to the cell in form, the cell in traversal form;
Judge module 402, for judging whether current cell exists special symbol alignment properties; If there is no, then notify that described spider module 401 starts to travel through next unit lattice;
Reference cell lattice determination module 403, for after described judge module 402 judges that current cell exists special symbol alignment properties, determines reference cell lattice;
Off-set value computing module 404, for the position according to special symbol in described reference cell lattice and current cell, calculates off-set value;
Adjusting module 405, for carrying out position adjustment to described current cell according to described off-set value, and after described position has adjusted, notifies that described spider module 401 starts to travel through next unit lattice.
In actual applications, above-mentioned spider module 401 specifically can according to row from left to right, and the order from top to bottom of row starts to travel through all cells, certainly, also can travel through cell according to other order, not limit this embodiment of the present invention.
Said reference cell determination module 403 specifically can when described current cell be positioned at the first row, using described current cell as reference cell lattice; Otherwise, belonging to described current cell, arrange the cell upwards searched and do not have alignment properties, if found, then will there is no the next line cell of the cell of alignment properties as reference cell lattice.In addition, reference cell lattice determination module 403 also for arrange belonging to described current cell upwards search the cell not having alignment properties time, if until the first row does not still find, then using the cell of this row the first row as reference cell lattice.
In addition, in another embodiment of apparatus of the present invention, described device also can comprise further: type-setting module and startup module, wherein:
Described type-setting module is used for, after inputting the operation causing cell content to change, resetting form, generates typesetting result full-page proof;
It is whole that described startup module is used for start unit style, to do alignment adjustment to each cell.
The tabular matter device that the embodiment of the present invention provides, when needing to do alignment adjustment to the cell in form, by the cell in traversal form, determines reference cell lattice; According to the position of special symbol in reference cell lattice and current cell, calculate off-set value; According to this off-set value, position adjustment is carried out to current cell.Thus can align with special symbol by the cell realized easily in same row in partial row.And, further, the special symbol of aliging can also be needed to judge, realize different units lattice in row and, with the alignment of different special symbols, meet the individual demand of user to tabular matter.
The invention provides the method that non-permutation cell arranges special symbol alignment, fill up the blank of current area.Achieve abundanter tabular matter effect on the one hand, also allow the operation of user more flexible on the other hand.
Obviously, those skilled in the art should be understood that, above-mentioned of the present invention each module or each step can realize with general calculation element, they can concentrate on single calculation element, or be distributed on network that multiple calculation element forms, alternatively, they can realize with the executable program code of calculation element, thus, they can be stored and be performed by calculation element in the storage device, or they are made into each integrated circuit modules respectively, or the multiple module in them or step are made into single integrated circuit module to realize.Like this, the present invention is not restricted to any specific hardware and software combination.
The foregoing is only the preferred embodiments of the present invention, be not limited to the present invention, for a person skilled in the art, the present invention can have various modifications and variations.Within the spirit and principles in the present invention all, any amendment done, equivalent replacement, improvement etc., all should be included within protection scope of the present invention.