File: docLayoutSect.c

package info (click to toggle)
ted 2.16-5
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 13,944 kB
  • ctags: 20,273
  • sloc: ansic: 167,980; makefile: 12,518; sh: 263
file content (138 lines) | stat: -rw-r--r-- 3,588 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/************************************************************************/
/*									*/
/*  Layout of a section.						*/
/*									*/
/************************************************************************/

#   include	"tedConfig.h"

#   include	<stddef.h>
#   include	<stdio.h>
#   include	<stdlib.h>

#   include	<appImage.h>
#   include	"docLayout.h"

#   include	<appDebugon.h>

/************************************************************************/
/*									*/
/*  Adjust the position of the top of a section, depending on the kind	*/
/*  of break								*/
/*									*/
/*  1)  Note that even and odd are swapped as from the users point of	*/
/*	view page numbers count from one.				*/
/*  2)  As this routine is only called for the body of the document,	*/
/*	page wraps can be performed unconditionally.			*/
/*									*/
/************************************************************************/

void docLayoutPlaceSectTop(		BufferItem *		sectBi,
					BlockFrame *		bf,
					LayoutJob *		lj )
    {
    if  ( sectBi->biSectBreakKind != DOCsbkNONE		||
	  ( sectBi->biParent			&&
	    sectBi->biNumberInParent == 0	)	)
	{
	if  ( sectBi->biNumberInParent == 0 )
	    {
	    lj->ljPosition.lpPage= 0;
	    lj->ljPosition.lpColumn= 0;

	    docLayoutSectColumnTop( sectBi, lj->ljBd, &(lj->ljPosition), bf );
	    }
	else{
	    if  ( BF_HAS_FOOTNOTES( bf )				&&
		  docLayoutFootnotesForColumn( bf, &(lj->ljPosition), lj ) )
		{ LDEB(1); return;	}

	    docLayoutToNextColumn( sectBi, lj->ljBd, &(lj->ljPosition), bf );
	    }

	/*  1  */
	if  ( ( sectBi->biSectBreakKind == DOCsbkEVEN	&&
		! ( lj->ljPosition.lpPage % 2 )		)	||
	      ( sectBi->biSectBreakKind == DOCsbkODD	&&
		( lj->ljPosition.lpPage % 2 )		)	)
	    {
	    docLayoutToNextColumn( sectBi, lj->ljBd, &(lj->ljPosition), bf );
	    }
	}

    sectBi->biTopPosition= lj->ljPosition;

    if  ( sectBi->biNumberInParent == 0		&&
	  sectBi->biParent			)
	{ sectBi->biParent->biTopPosition= lj->ljPosition; }

    return;
    }

/************************************************************************/
/*									*/
/*  Do the layout of a section.						*/
/*									*/
/************************************************************************/

int docLayoutSectItem(			BufferItem *		sectBi,
					BlockFrame *		bf,
					LayoutJob *		lj )
    {
    BufferDocument *		bd= lj->ljBd;
    const DocumentProperties *	dp= &(bd->bdProperties);
    const NotesProperties *	npEndnotes= &(dp->dpEndnoteProperties);

    DocumentNote *		dn;

    const SectionProperties *	sp= &(sectBi->biSectProperties);
    const DocumentGeometry *	dgSect= &(sp->spDocumentGeometry);

    int				i;

    /**/
    docSectDelimitTables( sectBi );

    /**/

    if  ( docSectHeaderFooterPrelayout( sectBi, lj ) )
	{ LDEB(1); return -1;	}

    /**/

    dn= bd->bdNotes;
    for ( i= 0; i < bd->bdNoteCount; dn++, i++ )
	{
	ExternalItem *	ei= (&dn->dnExternalItem);

	if  ( dn->dnSectNr != sectBi->biNumberInParent )
	    { continue;	}
	if  ( ! ei->eiItem )
	    { continue;	}

	if  ( docExternalItemPrelayout( ei, dgSect, lj ) )
	    { LDEB(1); return -1;	}
	}

    /**/

    docLayoutPlaceSectTop( sectBi, bf, lj );

    for ( i= 0; i < sectBi->biChildCount; i++ )
	{
	if  ( docLayoutItemImplementation( sectBi->biChildren[i], bf, lj ) )
	    { LDEB(i); return -1;	}
	}

    /**/

    if  ( sectBi->biInExternalItem == DOCinBODY		&&
	  npEndnotes->npPosition == FTN_POS_SECT_END	)
	{
	if  ( docLayoutEndnotesForSection( sectBi->biNumberInParent, bf, lj ) )
	    { LDEB(sectBi->biNumberInParent); return -1;	}
	}

    return 0;
    }