"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/Typeset/Page/page_breaker.cpp" between
TeXmacs-1.99.4-src.tar.gz and TeXmacs-1.99.5-src.tar.gz

About: GNU TeXmacs is a what-you-see-is-what-you-get scientific text editor, which was both inspired by TeX and GNU Emacs.

page_breaker.cpp  (TeXmacs-1.99.4-src):page_breaker.cpp  (TeXmacs-1.99.5-src)
skipping to change at line 15 skipping to change at line 15
* COPYRIGHT : (C) 1999 Joris van der Hoeven * COPYRIGHT : (C) 1999 Joris van der Hoeven
******************************************************************************* *******************************************************************************
* This software falls under the GNU general public license version 3 or later. * This software falls under the GNU general public license version 3 or later.
* It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
* in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>. * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
******************************************************************************/ ******************************************************************************/
#include "Line/lazy_vstream.hpp" #include "Line/lazy_vstream.hpp"
#include "vpenalty.hpp" #include "vpenalty.hpp"
#include "skeleton.hpp" #include "skeleton.hpp"
#include "boot.hpp"
#include "merge_sort.hpp" #include "merge_sort.hpp"
void sort (pagelet& pg); void sort (pagelet& pg);
vpenalty as_vpenalty (SI diff); vpenalty as_vpenalty (SI diff);
typedef array<int> vbreak; typedef array<int> vbreak;
typedef array<int> ladder; typedef array<int> ladder;
#define MAIN_FLOW 0 #define MAIN_FLOW 0
#define FNOTE_FLOW 1 #define FNOTE_FLOW 1
#define FLOAT_FLOW 2 #define FLOAT_FLOW 2
skipping to change at line 907 skipping to change at line 908
pg << float_sep; pg << float_sep;
} }
} }
// cout << "height : " << pg->ht << LF; // cout << "height : " << pg->ht << LF;
// cout << "penalty: " << pg->pen << LF; // cout << "penalty: " << pg->pen << LF;
// cout << UNINDENT << "Pagelet: " << pg << LF << LF; // cout << UNINDENT << "Pagelet: " << pg << LF << LF;
return pg; return pg;
} }
SI
stretch_space (space spc, double stretch) {
if (stretch > 0.0) return (SI) (spc->def + stretch * (spc->max - spc->def));
if (stretch < 0.0) return (SI) (spc->def + stretch * (spc->def - spc->min));
return spc->def;
}
vpenalty vpenalty
page_breaker_rep::format_insertion (insertion& ins, double stretch) { page_breaker_rep::format_insertion (insertion& ins, double stretch) {
// cout << "Stretch " << ins << ": " << stretch << LF; // cout << "Stretch " << ins << ": " << stretch << LF;
ins->stretch= stretch; ins->stretch= stretch;
skeleton sk = ins->sk; skeleton sk = ins->sk;
if (N(sk) == 0) return vpenalty (); if (N(sk) == 0) return vpenalty ();
int i, k=N(sk); int i, k=N(sk);
vpenalty pen; vpenalty pen;
SI ht= stretch_space (ins->ht, stretch); SI ht= stretch_space (ins->ht, stretch);
skipping to change at line 1251 skipping to change at line 1245
vpenalty pen= best_pens[i1] + vpenalty (bpen); vpenalty pen= best_pens[i1] + vpenalty (bpen);
if ((i2 < n) || (!last_page_flag)) if ((i2 < n) || (!last_page_flag))
pen += as_vpenalty (spc->def - height->def); pen += as_vpenalty (spc->def - height->def);
if (((i2 < n) || (!last_page_flag)) && (spc->max < height->def)) { if (((i2 < n) || (!last_page_flag)) && (spc->max < height->def)) {
if (spc->max >= height->min) pen += EXTEND_PAGE_PENALTY; if (spc->max >= height->min) pen += EXTEND_PAGE_PENALTY;
else { else {
double factor= double factor=
((double) max (spc->def, 1))/((double) max (height->def, 1)); ((double) max (spc->def, 1))/((double) max (height->def, 1));
if (factor < 0.0 ) factor= 0.0; if (factor < 0.0 ) factor= 0.0;
if (factor > 0.99) factor= 0.99; if (factor > 0.99) factor= 0.99;
pen= vpenalty ((int) ((1.0 - factor) * TOO_SHORT_PENALTY)); pen += vpenalty ((int) ((1.0 - factor) * TOO_SHORT_PENALTY));
} }
} }
else if (spc->min > height->def) { else if (spc->min > height->def) {
if (spc->min <= height->max) pen += REDUCE_PAGE_PENALTY; if (spc->min <= height->max) pen += REDUCE_PAGE_PENALTY;
else { else {
double factor= double factor=
((double) max (spc->def, 1))/((double) max (height->def, 1)); ((double) max (spc->def, 1))/((double) max (height->def, 1));
if (factor < 1.0 ) factor= 1.0; if (factor < 1.0 ) factor= 1.0;
if (factor > 100.0) factor= 100.0; if (factor > 100.0) factor= 100.0;
pen= vpenalty ((int) (factor * TOO_LONG_PENALTY)); pen += vpenalty ((int) (factor * TOO_LONG_PENALTY));
} }
} }
if (pen < best_pens[i2]) { if (pen < best_pens[i2]) {
best_prev[i2]= i1; best_prev[i2]= i1;
best_pens[i2]= pen; best_pens[i2]= pen;
} }
} }
if ((i2 >= n) || (ok && (spc->min > height->max))) break; if ((i2 >= n) || (ok && (spc->min > height->max))) break;
i2++; i2++;
} }
skipping to change at line 1478 skipping to change at line 1472
// cout << HRULE << LF << LF; // cout << HRULE << LF << LF;
} }
skeleton skeleton
page_breaker_rep::make_skeleton () { page_breaker_rep::make_skeleton () {
skeleton sk; skeleton sk;
int i, j, n= N(l); int i, j, n= N(l);
bool dpage_flag= false; bool dpage_flag= false;
int page_offset= first_page - 1; int page_offset= first_page - 1;
for (i=0, j=0; j<n; j++) { for (i=0, j=0; j<n; j++) {
if ((!papyrus_mode) && (l[j]->type == PAGE_CONTROL_ITEM)) if ((!papyrus_mode) && (l[j]->type == PAGE_CONTROL_ITEM)) {
if ((l[j]->t == PAGE_BREAK) || if ((l[j]->t == PAGE_BREAK) ||
(l[j]->t == NEW_PAGE) || (l[j]->t == NEW_DPAGE)) (l[j]->t == NEW_PAGE) || (l[j]->t == NEW_DPAGE))
{ {
if (dpage_flag && ((N(sk) + page_offset) & 1) == 1) if (dpage_flag && ((N(sk) + page_offset) & 1) == 1)
sk << pagelet (space (0)); sk << pagelet (space (0));
dpage_flag= (l[j]->t == NEW_DPAGE); dpage_flag= (l[j]->t == NEW_DPAGE);
last_page_flag= (l[j]->t != PAGE_BREAK); last_page_flag= (l[j]->t != PAGE_BREAK);
if (i<j) assemble_skeleton (sk, i, j); if (i<j) assemble_skeleton (sk, i, j);
i=j+1; i=j+1;
} }
else if (is_tuple (l[j]->t, "env_page") && l[j]->t[1] == PAGE_NR) else if (is_tuple (l[j]->t, "env_page") && l[j]->t[1] == PAGE_NR)
page_offset= as_int (l[j]->t[2]->label) - N(sk) - 1; page_offset= as_int (l[j]->t[2]->label) - N(sk) - 1;
}
} }
if (i<j) { if (i<j) {
if (dpage_flag && ((N(sk)&1) == 1)) if (dpage_flag && ((N(sk)&1) == 1))
sk << pagelet (space (0)); sk << pagelet (space (0));
last_page_flag= true; last_page_flag= true;
assemble_skeleton (sk, i, j); assemble_skeleton (sk, i, j);
} }
return sk; return sk;
} }
/****************************************************************************** /******************************************************************************
* The exported page breaking routine * The exported page breaking routine
******************************************************************************/ ******************************************************************************/
skeleton new_break_pages (array<page_item> l, space ph, int qual,
space fn_sep, space fnote_sep, space float_sep,
font fn, int first_page);
skeleton skeleton
break_pages (array<page_item> l, space ph, int qual, break_pages (array<page_item> l, space ph, int qual,
space fn_sep, space fnote_sep, space float_sep, space fn_sep, space fnote_sep, space float_sep,
font fn, int first_page) font fn, int first_page)
{ {
page_breaker_rep* H= if (get_user_preference ("new style page breaking") == "on")
tm_new<page_breaker_rep> (l, ph, qual, fn_sep, fnote_sep, float_sep, return new_break_pages (l, ph, qual, fn_sep, fnote_sep, float_sep,
fn, first_page); fn, first_page);
// cout << HRULE << LF; else {
skeleton sk= H->make_skeleton (); page_breaker_rep* H=
tm_delete (H); tm_new<page_breaker_rep> (l, ph, qual, fn_sep, fnote_sep, float_sep,
return sk; fn, first_page);
// cout << HRULE << LF;
skeleton sk= H->make_skeleton ();
tm_delete (H);
return sk;
}
} }
 End of changes. 8 change blocks. 
17 lines changed or deleted 21 lines changed or added

Home  |  About  |  All  |  Newest  |  Fossies Dox  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTPS