Merge branch 'release-0.1.4'

This commit is contained in:
Kolan Sh 2015-03-02 17:11:50 +03:00
commit 8674b21272
3 changed files with 24 additions and 25 deletions

View File

@ -7,7 +7,7 @@ SET (PROJECT_DESCRIPTION "LaTeX representation in the memory.")
SET (MAJOR 0) SET (MAJOR 0)
SET (MINOR 1) SET (MINOR 1)
SET (PATCH 3) SET (PATCH 4)
LIST (APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/backbone) LIST (APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/backbone)

View File

@ -219,48 +219,48 @@ namespace LAview {
uint max_cols; uint max_cols;
} }
bool check_limits (Array<SplitLimit?> sorted_limits) { bool check_limits (List<SplitLimit?> sorted_limits) {
/* check nearby limits */ /* check nearby limits */
for (var i = 1; i < sorted_limits.length; ++i) for (var i = 1; i < sorted_limits.length(); ++i)
if (sorted_limits.index (i - 1).last >= sorted_limits.index (i).first if (sorted_limits.nth_data(i - 1).last >= sorted_limits.nth_data(i).first
|| sorted_limits.index (i).first > sorted_limits.index (i).last) || sorted_limits.nth_data(i).first > sorted_limits.nth_data(i).last)
return false; return false;
/* check limits of the first and last elements */ /* check limits of the first and last elements */
if (sorted_limits.index (0).first > sorted_limits.index (0).last if (sorted_limits.nth_data(0).first > sorted_limits.nth_data(0).last
|| params.size <= sorted_limits.index (sorted_limits.length - 1).last) || params.size <= sorted_limits.nth_data(sorted_limits.length() - 1).last)
return false; return false;
return true; return true;
} }
uint [] get_indexes (Array<SplitLimit?> sorted_limits) { uint [] get_indexes (List<SplitLimit?> sorted_limits) {
var lim_indexes = new uint[sorted_limits.length]; var lim_indexes = new uint[sorted_limits.length()];
for (var i = 0; i < sorted_limits.length; ++i) for (var i = 0; i < sorted_limits.length(); ++i)
lim_indexes[i] = sorted_limits.index (i).first; lim_indexes[i] = sorted_limits.nth_data(i).first;
return lim_indexes; return lim_indexes;
} }
ATable? split_table (Array<SplitLimit?> sorted_limits, uint [] lim_indexes, ATable? split_table (List<SplitLimit?> sorted_limits, uint [] lim_indexes,
Row.OpLineStyle line_style) { Row.OpLineStyle line_style) {
var return_table = copy () as ATable; var return_table = copy () as ATable;
bool split_finish = true; bool split_finish = true;
/* removing spare columns */ /* removing spare columns */
for (uint i = sorted_limits.length - 1; i < sorted_limits.length; --i) { // group for (uint i = sorted_limits.length() - 1; i < sorted_limits.length(); --i) { // group
for (uint j = sorted_limits.index (i).last; for (uint j = sorted_limits.nth_data(i).last;
j >= lim_indexes[i] + sorted_limits.index (i).max_cols j >= lim_indexes[i] + sorted_limits.nth_data(i).max_cols
&& j <= sorted_limits.index (i).last; --j) && j <= sorted_limits.nth_data(i).last; --j)
return_table.remove_col ((int)j, line_style); return_table.remove_col ((int)j, line_style);
for (uint j = lim_indexes[i] - 1; j >= sorted_limits.index (i).first && j < lim_indexes[i]; --j) for (uint j = lim_indexes[i] - 1; j >= sorted_limits.nth_data(i).first && j < lim_indexes[i]; --j)
return_table.remove_col ((int)j, line_style); return_table.remove_col ((int)j, line_style);
/* count indexes */ /* count indexes */
if (lim_indexes[i] <= sorted_limits.index (i).last) { if (lim_indexes[i] <= sorted_limits.nth_data(i).last) {
split_finish = false; split_finish = false;
lim_indexes[i] += sorted_limits.index (i).max_cols; lim_indexes[i] += sorted_limits.nth_data(i).max_cols;
} }
} }
@ -290,7 +290,7 @@ namespace LAview {
* *
* @return number of ``ATable``s the table splitted to. * @return number of ``ATable``s the table splitted to.
*/ */
public uint split (Glob glob, Array<SplitLimit?> limits, public uint split (Glob glob, List<SplitLimit?> limits,
Row.OpLineStyle line_style = Row.OpLineStyle.BORDER_DBLLINES) throws SplitError { Row.OpLineStyle line_style = Row.OpLineStyle.BORDER_DBLLINES) throws SplitError {
/* is table a child of glob */ /* is table a child of glob */
var glob_index = glob.index_of (this); var glob_index = glob.index_of (this);
@ -298,10 +298,9 @@ namespace LAview {
throw new SplitError.ISNT_CHILD (_("2nd param (ATable) isn't a child of the 1st (Glob).")); throw new SplitError.ISNT_CHILD (_("2nd param (ATable) isn't a child of the 1st (Glob)."));
/* sorting limits */ /* sorting limits */
var sorted_limits = new Array<SplitLimit?>.sized (false, false, sizeof (SplitLimit), limits.length); var sorted_limits = limits.copy ();
sorted_limits.append_vals (limits.data, limits.length);
sorted_limits.sort ((ref a, ref b) => { sorted_limits.sort ((a, b) => {
if (a.first < b.first) return -1; if (a.first < b.first) return -1;
if (a.first > b.first) return 1; if (a.first > b.first) return 1;
return 0; return 0;

View File

@ -43,14 +43,14 @@ public class Main : Object {
} }
uint lim[3] = { 0, 0, 0}; uint lim[3] = { 0, 0, 0};
var limits = new Array<Table.ATable.SplitLimit?> (); var limits = new List<Table.ATable.SplitLimit?> ();
while (3 == stream.scanf ("%u %u %u", out lim[0], out lim[1], out lim[2])) { while (3 == stream.scanf ("%u %u %u", out lim[0], out lim[1], out lim[2])) {
var split_lim = Table.ATable.SplitLimit (); var split_lim = Table.ATable.SplitLimit ();
split_lim.first = lim[0]; split_lim.first = lim[0];
split_lim.last = lim[1]; split_lim.last = lim[1];
split_lim.max_cols = lim[2]; split_lim.max_cols = lim[2];
limits.append_val (split_lim); limits.append (split_lim);
} }
/* read table */ /* read table */