owner_ = bv;
firstrow = 0;
lastrow = 0;
- currentrow = 0;
- currentrow_y = 0;
paperwidth = pw;
- //bparams = &p->params;
buffer = p;
number_of_rows = 0;
refresh_y = 0;
// Default layouttype for copy environment type
copylayouttype = 0;
+
+#if 0
+ // Dump all rowinformation:
+ Row * tmprow = firstrow;
+ lyxerr << "Baseline Paragraph Pos Height Ascent Fill\n";
+ while (tmprow) {
+ lyxerr << tmprow->baseline << '\t'
+ << tmprow->par << '\t'
+ << tmprow->pos << '\t'
+ << tmprow->height << '\t'
+ << tmprow->ascent_of_text << '\t'
+ << tmprow->fill << '\n';
+ tmprow = tmprow->next;
+ }
+ lyxerr.flush();
+#endif
}
row of this row */
long unused_y;
GetRow(row->par, row->pos, unused_y);
- currentrow = currentrow->previous;
- if (currentrow)
- currentrow_y -= currentrow->height;
- else
- currentrow_y = 0;
if (row->next)
row->next->previous = row->previous;
}
}
+LyXParagraph * LyXText::SetLayout(LyXCursor & cur, LyXCursor & sstart_cur,
+ LyXCursor & send_cur,
+ LyXTextClass::size_type layout)
+{
+ LyXParagraph * endpar = send_cur.par->LastPhysicalPar()->Next();
+ LyXParagraph * undoendpar = endpar;
+
+ if (endpar && endpar->GetDepth()) {
+ while (endpar && endpar->GetDepth()) {
+ endpar = endpar->LastPhysicalPar()->Next();
+ undoendpar = endpar;
+ }
+ } else if (endpar) {
+ endpar = endpar->Next(); // because of parindents etc.
+ }
+
+ SetUndo(Undo::EDIT,
+ sstart_cur.par->ParFromPos(sstart_cur.pos)->previous,
+ undoendpar);
+
+ /* ok we have a selection. This is always between sstart_cur
+ * and sel_end cursor */
+ cur = sstart_cur;
+
+ LyXLayout const & lyxlayout =
+ textclasslist.Style(buffer->params.textclass, layout);
+
+ while (cur.par != send_cur.par) {
+ if (cur.par->footnoteflag == sstart_cur.par->footnoteflag) {
+ cur.par->SetLayout(layout);
+ MakeFontEntriesLayoutSpecific(cur.par);
+ LyXParagraph* fppar = cur.par->FirstPhysicalPar();
+ fppar->added_space_top = lyxlayout.fill_top ?
+ VSpace(VSpace::VFILL) : VSpace(VSpace::NONE);
+ fppar->added_space_bottom = lyxlayout.fill_bottom ?
+ VSpace(VSpace::VFILL) : VSpace(VSpace::NONE);
+ if (lyxlayout.margintype == MARGIN_MANUAL)
+ cur.par->SetLabelWidthString(lyxlayout.labelstring());
+ if (lyxlayout.labeltype != LABEL_BIBLIO
+ && fppar->bibkey) {
+ delete fppar->bibkey;
+ fppar->bibkey = 0;
+ }
+ }
+ cur.par = cur.par->Next();
+ }
+ if (cur.par->footnoteflag == sstart_cur.par->footnoteflag) {
+ cur.par->SetLayout(layout);
+ MakeFontEntriesLayoutSpecific(cur.par);
+ LyXParagraph* fppar = cur.par->FirstPhysicalPar();
+ fppar->added_space_top = lyxlayout.fill_top ?
+ VSpace(VSpace::VFILL) : VSpace(VSpace::NONE);
+ fppar->added_space_bottom = lyxlayout.fill_bottom ?
+ VSpace(VSpace::VFILL) : VSpace(VSpace::NONE);
+ if (lyxlayout.margintype == MARGIN_MANUAL)
+ cur.par->SetLabelWidthString(lyxlayout.labelstring());
+ if (lyxlayout.labeltype != LABEL_BIBLIO
+ && fppar->bibkey) {
+ delete fppar->bibkey;
+ fppar->bibkey = 0;
+ }
+ }
+ return endpar;
+}
// set layout over selection and make a total rebreak of those paragraphs
void LyXText::SetLayout(LyXTextClass::size_type layout)
{
- LyXCursor tmpcursor;
+ LyXCursor
+ tmpcursor = cursor; /* store the current cursor */
+#ifdef USE_OLD_SET_LAYOUT
// if there is no selection just set the layout
// of the current paragraph */
if (!selection) {
sel_start_cursor.par->ParFromPos(sel_start_cursor.pos)->previous,
undoendpar);
- tmpcursor = cursor; /* store the current cursor */
-
/* ok we have a selection. This is always between sel_start_cursor
* and sel_end cursor */
cursor = sel_start_cursor;
fppar->bibkey = 0;
}
}
-
+#else
+ // if there is no selection just set the layout
+ // of the current paragraph */
+ if (!selection) {
+ sel_start_cursor = cursor; // dummy selection
+ sel_end_cursor = cursor;
+ }
+ LyXParagraph *
+ endpar = SetLayout(cursor, sel_start_cursor, sel_end_cursor, layout);
+#endif
RedoParagraphs(sel_start_cursor, endpar);
// we have to reset the selection, because the
}
-int LyXText::FullRebreak()
+bool LyXText::FullRebreak()
{
if (need_break_row) {
BreakAgain(need_break_row);
need_break_row = 0;
- return 1;
+ return true;
}
- return 0;
+ return false;
}
/* returns a pointer to the row near the specified y-coordinate
* (relative to the whole text). y is set to the real beginning
-* of this row */
+* of this row */
Row * LyXText::GetRowNearY(long & y) const
{
- Row * tmprow;
- long tmpy;
-
- if (currentrow) {
- tmprow = currentrow;
- tmpy = currentrow_y;
- } else {
- tmprow = firstrow;
- tmpy = 0;
- }
-
- if (tmpy <= y)
- while (tmprow->next && tmpy + tmprow->height <= y) {
- tmpy += tmprow->height;
- tmprow = tmprow->next;
- }
- else
- while (tmprow->previous && tmpy > y) {
- tmprow = tmprow->previous;
- tmpy -= tmprow->height;
- }
+ Row * tmprow = firstrow;
+ long tmpy = 0;
- currentrow = tmprow;
- currentrow_y = tmpy;
+ while (tmprow->next && tmpy + tmprow->height <= y) {
+ tmpy += tmprow->height;
+ tmprow = tmprow->next;
+ }
y = tmpy; // return the real y
return tmprow;
}
-
+
void LyXText::ToggleFree(LyXFont const & font, bool toggleall)
{
}
if (!par->labelstring.empty()) {
- par->labelstring.clear();
+ par->labelstring.erase();
}
if (layout.margintype == MARGIN_MANUAL) {
if (!layout.labelstring().empty())
par->labelstring = layout.labelstring();
else
- par->labelstring.clear();
+ par->labelstring.erase();
} else {
if (!layout.labelstring_appendix().empty())
par->labelstring = layout.labelstring_appendix();
else
- par->labelstring.clear();
+ par->labelstring.erase();
}
#ifdef HAVE_SSTREAM
DeleteSimpleCutBuffer();
// set the textclass
- simple_cut_buffer_textclass = buffer->params->textclass;
+ simple_cut_buffer_textclass = buffer->params.textclass;
// copy behind a space if there is one
while (sel_start_cursor.par->Last() > sel_start_cursor.pos
// make sure there is no class difference
cap.SwitchLayoutsBetweenClasses(simple_cut_buffer_textclass,
- buffer->params->textclass,
+ buffer->params.textclass,
simple_cut_buffer);
// make the simple_cut_buffer exactly the same layout than
void LyXText::CheckParagraph(LyXParagraph * par,
LyXParagraph::size_type pos)
{
-
- LyXCursor tmpcursor;
+ LyXCursor tmpcursor;
+
/* table stuff -- begin*/
if (undo->kind == Undo::EDIT) {
tmppar2->setContentsFromPar(tmppar);
tmppar->clearContents();
- //tmppar2->text = tmppar->text;
- //tmppar->text.clear();
tmppar2 = tmppar2->next;
}
- if ( currentrow && currentrow->par == tmppar )
- currentrow = currentrow -> previous;
- // Commenting out this might remove the error
- // reported by Purify, but it might also
- // introduce a memory leak. We need to
- // check this (Lgb)
- //delete tmppar;
}
}