mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-09-20 06:49:56 +00:00
move breakParagraph and breakParagraphConservative out of Paragraph
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5043 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
55ef679c8b
commit
38b325846c
@ -8,7 +8,6 @@ src/converter.C
|
||||
src/CutAndPaste.C
|
||||
src/debug.C
|
||||
src/exporter.C
|
||||
src/ext_l10n.h
|
||||
src/FloatList.C
|
||||
src/frontends/controllers/biblio.C
|
||||
src/frontends/controllers/ButtonController.h
|
||||
@ -165,5 +164,6 @@ src/paragraph.C
|
||||
src/support/filetools.C
|
||||
src/tabular.C
|
||||
src/text2.C
|
||||
src/text3.C
|
||||
src/text.C
|
||||
src/ext_l10n.h
|
||||
|
@ -1,5 +1,23 @@
|
||||
2002-08-20 Lars Gullik Bjønnes <larsbj@gullik.net>
|
||||
|
||||
* text.C: include paragraph_funcs.h
|
||||
(breakParagraph): breakParagraph is now in global scope
|
||||
|
||||
* paragraph_funcs.[Ch]: new files
|
||||
|
||||
* paragraph.C (breakParagraph,breakParagraphConservative): move to
|
||||
global scope
|
||||
|
||||
* buffer.C: include paragraph_funcs.h
|
||||
(insertStringAsLines): breakParagraph is now in global scope
|
||||
|
||||
* Makefile.am (lyx_SOURCES): add paragraph_funcs.h and
|
||||
paragraph_funcs.C
|
||||
|
||||
* CutAndPaste.C: include paragraph_funcs.h
|
||||
(cutSelection): breakParagraphConservative is now in global scope
|
||||
(pasteSelection): ditto
|
||||
|
||||
* buffer.h: declare oprator== and operator!= for
|
||||
Buffer::inset_iterator
|
||||
|
||||
|
@ -25,6 +25,8 @@
|
||||
#include "iterators.h"
|
||||
#include "lyxtextclasslist.h"
|
||||
#include "undo_funcs.h"
|
||||
#include "paragraph_funcs.h"
|
||||
|
||||
#include "insets/inseterror.h"
|
||||
|
||||
using std::pair;
|
||||
@ -111,13 +113,15 @@ bool CutAndPaste::cutSelection(Paragraph * startpar, Paragraph ** endpar,
|
||||
end = start - 1;
|
||||
} else {
|
||||
// more than one paragraph
|
||||
(*endpar)->breakParagraphConservative(current_view->buffer()->params,
|
||||
end);
|
||||
breakParagraphConservative(current_view->buffer()->params,
|
||||
*endpar,
|
||||
end);
|
||||
*endpar = (*endpar)->next();
|
||||
end = 0;
|
||||
|
||||
startpar->breakParagraphConservative(current_view->buffer()->params,
|
||||
start);
|
||||
breakParagraphConservative(current_view->buffer()->params,
|
||||
startpar,
|
||||
start);
|
||||
|
||||
// store the selection
|
||||
if (realcut) {
|
||||
@ -342,8 +346,10 @@ bool CutAndPaste::pasteSelection(Paragraph ** par, Paragraph ** endpar,
|
||||
// open the paragraph for inserting the buf
|
||||
// if necessary
|
||||
if (((*par)->size() > pos) || !(*par)->next()) {
|
||||
(*par)->breakParagraphConservative(current_view->buffer()->params,
|
||||
pos);
|
||||
breakParagraphConservative(
|
||||
current_view->buffer()->params,
|
||||
*par,
|
||||
pos);
|
||||
paste_the_end = true;
|
||||
}
|
||||
// set the end for redoing later
|
||||
|
@ -18,16 +18,9 @@ LYX_CONV_LIBS = mathed/libmathed.la insets/libinsets.la \
|
||||
BOOST_LIBS = ../boost/libs/regex/src/libboostregex.la \
|
||||
../boost/libs/signals/src/libboostsignals.la
|
||||
|
||||
#lyx_DEPENDENCIES = $(LYX_CONV_LIBS) $(INCLUDED_SIGC)
|
||||
|
||||
lyx_LDADD = $(LYX_CONV_LIBS) $(BOOST_LIBS) $(INTLLIBS) \
|
||||
$(PSPELL_LIBS) $(AIKSAURUS_LIBS)
|
||||
|
||||
#lyx_LDADD = $(LYX_CONV_LIBS) $(SIGC_LIBS) $(BOOST_LIBS) $(INCLUDED_SIGC) $(INTLLIBS) \
|
||||
# $(PSPELL_LIBS) $(AIKSAURUS_LIBS)
|
||||
|
||||
# $(FRONTEND_LDFLAGS) $(FRONTEND_LIBS)
|
||||
|
||||
#lyx_LDFLAGS=-Wl,-O1
|
||||
|
||||
EXTRA_DIST = config.h.in stamp-h.in cheaders ext_l10n.h version.C.in \
|
||||
@ -38,8 +31,7 @@ EXTRA_DIST = config.h.in stamp-h.in cheaders ext_l10n.h version.C.in \
|
||||
tracer.C \
|
||||
tracer.h
|
||||
|
||||
INCLUDES = $(SIGC_CFLAGS) $(BOOST_INCLUDES) $(PSPELL_INCLUDES)
|
||||
#INCLUDES = $(BOOST_INCLUDES) $(PSPELL_INCLUDES)
|
||||
INCLUDES = $(BOOST_INCLUDES) $(PSPELL_INCLUDES)
|
||||
|
||||
localedir = $(datadir)/locale
|
||||
|
||||
@ -79,6 +71,8 @@ lyx_SOURCES = \
|
||||
LyXAction.h \
|
||||
MenuBackend.C \
|
||||
MenuBackend.h \
|
||||
paragraph_funcs.C \
|
||||
paragraph_funcs.h \
|
||||
ParagraphList.C \
|
||||
ParagraphList.h \
|
||||
ParagraphParameters.C \
|
||||
|
13
src/buffer.C
13
src/buffer.C
@ -31,7 +31,6 @@
|
||||
#include "version.h"
|
||||
#include "LaTeX.h"
|
||||
#include "Chktex.h"
|
||||
#include "frontends/LyXView.h"
|
||||
#include "debug.h"
|
||||
#include "LaTeXFeatures.h"
|
||||
#include "lyxtext.h"
|
||||
@ -46,6 +45,9 @@
|
||||
#include "iterators.h"
|
||||
#include "lyxtextclasslist.h"
|
||||
#include "sgml.h"
|
||||
#include "paragraph_funcs.h"
|
||||
|
||||
#include "frontends/LyXView.h"
|
||||
|
||||
#include "mathed/formulamacro.h"
|
||||
#include "mathed/formula.h"
|
||||
@ -1495,8 +1497,8 @@ void Buffer::insertStringAsLines(Paragraph *& par, pos_type & pos,
|
||||
cit != str.end(); ++cit) {
|
||||
if (*cit == '\n') {
|
||||
if (autobreakrows && (!par->empty() || layout->keepempty)) {
|
||||
par->breakParagraph(params, pos,
|
||||
layout->isEnvironment());
|
||||
breakParagraph(params, par, pos,
|
||||
layout->isEnvironment());
|
||||
par = par->next();
|
||||
pos = 0;
|
||||
space_inserted = true;
|
||||
@ -4080,7 +4082,7 @@ lyx::pos_type Buffer::inset_iterator::getPos() const
|
||||
|
||||
|
||||
bool operator==(Buffer::inset_iterator const & iter1,
|
||||
Buffer::inset_iterator const & iter2)
|
||||
Buffer::inset_iterator const & iter2)
|
||||
{
|
||||
return iter1.pit == iter2.pit
|
||||
&& (iter1.pit == iter1.pend || iter1.it == iter2.it);
|
||||
@ -4088,8 +4090,7 @@ bool operator==(Buffer::inset_iterator const & iter1,
|
||||
|
||||
|
||||
bool operator!=(Buffer::inset_iterator const & iter1,
|
||||
Buffer::inset_iterator const & iter2)
|
||||
Buffer::inset_iterator const & iter2)
|
||||
{
|
||||
return !(iter1 == iter2);
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,7 @@
|
||||
2002-08-20 Lars Gullik Bjønnes <larsbj@gullik.net>
|
||||
|
||||
* Dialogs.h (noncopyable): ws changes only
|
||||
|
||||
2002-08-16 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
|
||||
|
||||
* Makefile.am: use $(variables) instead of @substitutions@
|
||||
@ -43,7 +47,7 @@
|
||||
2002-08-08 John Levon <levon@movementarian.org>
|
||||
|
||||
* Toolbar.C:
|
||||
|
||||
|
||||
2002-08-06 André Poenitz <poenitz@gmx.net>
|
||||
|
||||
* Screen.C: Honor \show_banner lyxrc setting
|
||||
@ -51,7 +55,7 @@
|
||||
2002-08-04 John Levon <levon@movementarian.org>
|
||||
|
||||
* LyXView.C: isLyxClean->isClean
|
||||
|
||||
|
||||
2002-08-02 Edwin Leuven <leuven@fee.uva.nl>
|
||||
|
||||
* Dialogs.[Ch] (updateParagraph): converted back to a signal again.
|
||||
@ -70,25 +74,25 @@
|
||||
* Dialogs.h:
|
||||
* Dialogs.C:
|
||||
* guiapi.h: remove options from spell dialog
|
||||
|
||||
|
||||
2002-07-30 John Levon <levon@movementarian.org>
|
||||
|
||||
* lyx_gui.h: add remove_read_callback()
|
||||
|
||||
|
||||
2002-07-22 John Levon <moz@compsoc.man.ac.uk>
|
||||
|
||||
* lyx_gui.h: add exit()
|
||||
|
||||
|
||||
2002-07-22 John Levon <moz@compsoc.man.ac.uk>
|
||||
|
||||
* Toolbar.h:
|
||||
* Toolbar.C: remove other unused code
|
||||
|
||||
|
||||
2002-07-22 John Levon <moz@compsoc.man.ac.uk>
|
||||
|
||||
* Toolbar.h:
|
||||
* Toolbar.C: remove ->push()
|
||||
|
||||
|
||||
2002-07-21 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
|
||||
|
||||
* LyXView.C: use BufferParams::getLyXTextClass
|
||||
@ -96,10 +100,10 @@
|
||||
2002-07-21 John Levon <moz@compsoc.man.ac.uk>
|
||||
|
||||
* LyXView.C: move autosave connect here
|
||||
|
||||
|
||||
2002-07-20 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
|
||||
|
||||
* LyXView.C (updateMenubar): remove code to set different menubars
|
||||
* LyXView.C (updateMenubar): remove code to set different menubars
|
||||
|
||||
* Menubar.C (set): remove
|
||||
|
||||
@ -108,52 +112,52 @@
|
||||
* LyXView.h:
|
||||
* LyXView.C: use ControlCommandBuffer, related
|
||||
cleanup
|
||||
|
||||
|
||||
* MiniBuffer.h:
|
||||
* MiniBuffer.C: remove
|
||||
|
||||
|
||||
2002-07-18 John Levon <moz@compsoc.man.ac.uk>
|
||||
|
||||
* LyXView.h:
|
||||
* LyXView.C:
|
||||
* MiniBuffer.h:
|
||||
* MiniBuffer.C: remove messagePush/Pop, addSet
|
||||
|
||||
|
||||
2002-07-17 John Levon <moz@compsoc.man.ac.uk>
|
||||
|
||||
* LyXView.h:
|
||||
* LyXView.C: change showState to view_state_changed signal
|
||||
|
||||
|
||||
2002-07-14 John Levon <moz@compsoc.man.ac.uk>
|
||||
|
||||
* lyx_gui.h: add set_read_callback()
|
||||
|
||||
|
||||
2002-07-12 John Levon <moz@compsoc.man.ac.uk>
|
||||
|
||||
* lyx_gui.h: remove init_graphics()
|
||||
|
||||
|
||||
2002-07-12 John Levon <moz@compsoc.man.ac.uk>
|
||||
|
||||
* Toolbar.h:
|
||||
* Toolbar.C: remove unused (de)activate()
|
||||
|
||||
|
||||
2002-07-12 John Levon <moz@compsoc.man.ac.uk>
|
||||
|
||||
* Makefile.am:
|
||||
* font_loader.h: remove
|
||||
|
||||
|
||||
* lyx_gui.h: add update_fonts(), font_available()
|
||||
|
||||
|
||||
2002-07-12 John Levon <moz@compsoc.man.ac.uk>
|
||||
|
||||
* lyx_gui.h: add update_color
|
||||
|
||||
|
||||
2002-07-09 John Levon <moz@compsoc.man.ac.uk>
|
||||
|
||||
* Painter.C:
|
||||
* Painter.h: make frame/background painting optional
|
||||
for rectText
|
||||
|
||||
|
||||
2002-07-05 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* lyx_gui.h (hexname): new function.
|
||||
|
@ -168,10 +168,10 @@ public:
|
||||
//@}
|
||||
|
||||
private:
|
||||
/// Use the Pimpl idiom to hide the internals.
|
||||
class Impl;
|
||||
/// The pointer never changes although *pimpl_'s contents may.
|
||||
boost::scoped_ptr<Impl> const pimpl_;
|
||||
/// Use the Pimpl idiom to hide the internals.
|
||||
class Impl;
|
||||
/// The pointer never changes although *pimpl_'s contents may.
|
||||
boost::scoped_ptr<Impl> const pimpl_;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
102
src/paragraph.C
102
src/paragraph.C
@ -732,79 +732,6 @@ Paragraph const * Paragraph::previous() const
|
||||
#endif
|
||||
|
||||
|
||||
void Paragraph::breakParagraph(BufferParams const & bparams,
|
||||
pos_type pos,
|
||||
int flag)
|
||||
{
|
||||
// create a new paragraph
|
||||
Paragraph * tmp = new Paragraph(this);
|
||||
tmp->layout(bparams.getLyXTextClass().defaultLayout());
|
||||
// remember to set the inset_owner
|
||||
tmp->setInsetOwner(inInset());
|
||||
|
||||
// this is an idea for a more userfriendly layout handling, I will
|
||||
// see what the users say
|
||||
|
||||
// layout stays the same with latex-environments
|
||||
if (flag) {
|
||||
tmp->layout(layout());
|
||||
tmp->setLabelWidthString(params().labelWidthString());
|
||||
}
|
||||
|
||||
bool isempty = (layout()->keepempty && empty());
|
||||
|
||||
if (!isempty && (size() > pos || empty() || flag == 2)) {
|
||||
tmp->layout(layout());
|
||||
tmp->params().align(params().align());
|
||||
tmp->setLabelWidthString(params().labelWidthString());
|
||||
|
||||
tmp->params().lineBottom(params().lineBottom());
|
||||
params().lineBottom(false);
|
||||
tmp->params().pagebreakBottom(params().pagebreakBottom());
|
||||
params().pagebreakBottom(false);
|
||||
tmp->params().spaceBottom(params().spaceBottom());
|
||||
params().spaceBottom(VSpace(VSpace::NONE));
|
||||
|
||||
tmp->params().depth(params().depth());
|
||||
tmp->params().noindent(params().noindent());
|
||||
|
||||
// copy everything behind the break-position
|
||||
// to the new paragraph
|
||||
pos_type pos_end = size() - 1;
|
||||
pos_type i = pos;
|
||||
pos_type j = pos;
|
||||
for (; i <= pos_end; ++i) {
|
||||
cutIntoMinibuffer(bparams, i);
|
||||
if (tmp->insertFromMinibuffer(j - pos))
|
||||
++j;
|
||||
}
|
||||
for (i = pos_end; i >= pos; --i) {
|
||||
erase(i);
|
||||
}
|
||||
}
|
||||
|
||||
// just an idea of me
|
||||
if (!isempty && !pos) {
|
||||
tmp->params().lineTop(params().lineTop());
|
||||
tmp->params().pagebreakTop(params().pagebreakTop());
|
||||
tmp->params().spaceTop(params().spaceTop());
|
||||
tmp->bibkey = bibkey;
|
||||
|
||||
bibkey = 0;
|
||||
params().clear();
|
||||
|
||||
layout(bparams.getLyXTextClass().defaultLayout());
|
||||
|
||||
// layout stays the same with latex-environments
|
||||
if (flag) {
|
||||
layout(tmp->layout());
|
||||
setLabelWidthString(tmp->params().labelWidthString());
|
||||
params().depth(tmp->params().depth());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Paragraph::makeSameLayout(Paragraph const * par)
|
||||
{
|
||||
layout(par->layout());
|
||||
@ -838,35 +765,6 @@ bool Paragraph::hasSameLayout(Paragraph const * par) const
|
||||
}
|
||||
|
||||
|
||||
void Paragraph::breakParagraphConservative(BufferParams const & bparams,
|
||||
pos_type pos)
|
||||
{
|
||||
// create a new paragraph
|
||||
Paragraph * tmp = new Paragraph(this);
|
||||
tmp->makeSameLayout(this);
|
||||
|
||||
// When can pos > Last()?
|
||||
// I guess pos == Last() is possible.
|
||||
if (size() > pos) {
|
||||
// copy everything behind the break-position to the new
|
||||
// paragraph
|
||||
pos_type pos_end = size() - 1;
|
||||
|
||||
//pos_type i = pos;
|
||||
//pos_type j = pos;
|
||||
for (pos_type i = pos, j = pos; i <= pos_end; ++i) {
|
||||
cutIntoMinibuffer(bparams, i);
|
||||
if (tmp->insertFromMinibuffer(j - pos))
|
||||
++j;
|
||||
}
|
||||
|
||||
for (pos_type k = pos_end; k >= pos; --k) {
|
||||
erase(k);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Be carefull, this does not make any check at all.
|
||||
// This method has wrong name, it combined this par with the next par.
|
||||
// In that sense it is the reverse of break paragraph. (Lgb)
|
||||
|
@ -226,11 +226,6 @@ public:
|
||||
void applyLayout(LyXLayout_ptr const & new_layout);
|
||||
///
|
||||
void erase(lyx::pos_type pos);
|
||||
/** the flag determines wether the layout should be copied
|
||||
*/
|
||||
void breakParagraph(BufferParams const &, lyx::pos_type pos, int flag);
|
||||
///
|
||||
void breakParagraphConservative(BufferParams const &, lyx::pos_type pos);
|
||||
/** Get unistantiated font setting. Returns the difference
|
||||
between the characters font and the layoutfont.
|
||||
This is what is stored in the fonttable
|
||||
|
220
src/paragraph_funcs.C
Normal file
220
src/paragraph_funcs.C
Normal file
@ -0,0 +1,220 @@
|
||||
/* This file is part of
|
||||
* ======================================================
|
||||
*
|
||||
* LyX, The Document Processor
|
||||
*
|
||||
* Copyright 1995 Matthias Ettrich
|
||||
* Copyright 1995-2001 The LyX Team.
|
||||
*
|
||||
* ====================================================== */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "paragraph_funcs.h"
|
||||
#include "buffer.h"
|
||||
#include "ParagraphParameters.h"
|
||||
#include "lyxtextclasslist.h"
|
||||
#include "debug.h"
|
||||
|
||||
using lyx::pos_type;
|
||||
//using lyx::layout_type;
|
||||
using std::endl;
|
||||
|
||||
|
||||
void breakParagraph(BufferParams const & bparams,
|
||||
Paragraph * par,
|
||||
pos_type pos,
|
||||
int flag)
|
||||
{
|
||||
// create a new paragraph
|
||||
Paragraph * tmp = new Paragraph(par);
|
||||
// remember to set the inset_owner
|
||||
tmp->setInsetOwner(par->inInset());
|
||||
|
||||
// this is an idea for a more userfriendly layout handling, I will
|
||||
// see what the users say
|
||||
|
||||
// layout stays the same with latex-environments
|
||||
if (flag) {
|
||||
tmp->layout(par->layout());
|
||||
tmp->setLabelWidthString(par->params().labelWidthString());
|
||||
}
|
||||
|
||||
bool isempty = (par->layout()->keepempty && par->empty());
|
||||
|
||||
if (!isempty && (par->size() > pos || par->empty() || flag == 2)) {
|
||||
tmp->layout(par->layout());
|
||||
tmp->params().align(par->params().align());
|
||||
tmp->setLabelWidthString(par->params().labelWidthString());
|
||||
|
||||
tmp->params().lineBottom(par->params().lineBottom());
|
||||
par->params().lineBottom(false);
|
||||
tmp->params().pagebreakBottom(par->params().pagebreakBottom());
|
||||
par->params().pagebreakBottom(false);
|
||||
tmp->params().spaceBottom(par->params().spaceBottom());
|
||||
par->params().spaceBottom(VSpace(VSpace::NONE));
|
||||
|
||||
tmp->params().depth(par->params().depth());
|
||||
tmp->params().noindent(par->params().noindent());
|
||||
|
||||
// copy everything behind the break-position
|
||||
// to the new paragraph
|
||||
pos_type pos_end = par->size() - 1;
|
||||
pos_type i = pos;
|
||||
pos_type j = pos;
|
||||
for (; i <= pos_end; ++i) {
|
||||
par->cutIntoMinibuffer(bparams, i);
|
||||
if (tmp->insertFromMinibuffer(j - pos))
|
||||
++j;
|
||||
}
|
||||
for (i = pos_end; i >= pos; --i) {
|
||||
par->erase(i);
|
||||
}
|
||||
}
|
||||
|
||||
// just an idea of me
|
||||
if (!pos) {
|
||||
tmp->params().lineTop(par->params().lineTop());
|
||||
tmp->params().pagebreakTop(par->params().pagebreakTop());
|
||||
tmp->params().spaceTop(par->params().spaceTop());
|
||||
tmp->bibkey = par->bibkey;
|
||||
|
||||
par->bibkey = 0;
|
||||
par->params().clear();
|
||||
|
||||
par->layout(bparams.getLyXTextClass().defaultLayout());
|
||||
|
||||
// layout stays the same with latex-environments
|
||||
if (flag) {
|
||||
par->layout(tmp->layout());
|
||||
par->setLabelWidthString(tmp->params().labelWidthString());
|
||||
par->params().depth(tmp->params().depth());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void breakParagraphConservative(BufferParams const & bparams,
|
||||
Paragraph * par,
|
||||
pos_type pos)
|
||||
{
|
||||
// create a new paragraph
|
||||
Paragraph * tmp = new Paragraph(par);
|
||||
tmp->makeSameLayout(par);
|
||||
|
||||
// When can pos > Last()?
|
||||
// I guess pos == Last() is possible.
|
||||
if (par->size() > pos) {
|
||||
// copy everything behind the break-position to the new
|
||||
// paragraph
|
||||
pos_type pos_end = par->size() - 1;
|
||||
|
||||
for (pos_type i = pos, j = pos; i <= pos_end; ++i) {
|
||||
par->cutIntoMinibuffer(bparams, i);
|
||||
if (tmp->insertFromMinibuffer(j - pos))
|
||||
++j;
|
||||
}
|
||||
|
||||
for (pos_type k = pos_end; k >= pos; --k) {
|
||||
par->erase(k);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
// Be carefull, this does not make any check at all.
|
||||
// This method has wrong name, it combined this par with the next par.
|
||||
// In that sense it is the reverse of break paragraph. (Lgb)
|
||||
void pasteParagraph(BufferParams const & bparams,
|
||||
Paragraph * par)
|
||||
{
|
||||
// copy the next paragraph to this one
|
||||
Paragraph * the_next = par->next();
|
||||
|
||||
// first the DTP-stuff
|
||||
par->params().lineBottom(the_next->params().lineBottom());
|
||||
par->params().spaceBottom(the_next->params().spaceBottom());
|
||||
par->params().pagebreakBottom(the_next->params().pagebreakBottom());
|
||||
|
||||
pos_type pos_end = the_next->size() - 1;
|
||||
pos_type pos_insert = par->size();
|
||||
|
||||
// ok, now copy the paragraph
|
||||
for (pos_type i = 0, j = 0; i <= pos_end; ++i) {
|
||||
the_next->cutIntoMinibuffer(bparams, i);
|
||||
if (par->insertFromMinibuffer(pos_insert + j))
|
||||
++j;
|
||||
}
|
||||
|
||||
// delete the next paragraph
|
||||
Paragraph * ppar = the_next->previous();
|
||||
Paragraph * npar = the_next->next();
|
||||
delete the_next;
|
||||
ppar->next(npar);
|
||||
}
|
||||
|
||||
|
||||
Paragraph * depthHook(Paragraph * par, Paragraph::depth_type depth)
|
||||
{
|
||||
Paragraph * newpar = par;
|
||||
|
||||
do {
|
||||
newpar = newpar->previous();
|
||||
} while (newpar && newpar->getDepth() > depth);
|
||||
|
||||
if (!newpar) {
|
||||
if (par->previous() || par->getDepth())
|
||||
lyxerr << "Error (depthHook): "
|
||||
<< "no hook." << endl;
|
||||
newpar = par;
|
||||
}
|
||||
return newpar;
|
||||
}
|
||||
|
||||
|
||||
Paragraph * outerHook(Paragraph * par)
|
||||
{
|
||||
if (!par->getDepth())
|
||||
return 0;
|
||||
return depthHook(par, Paragraph::depth_type(par->getDepth() - 1));
|
||||
}
|
||||
|
||||
|
||||
bool isFirstInSequence(Paragraph * par)
|
||||
{
|
||||
Paragraph const * dhook = depthHook(par, par->getDepth());
|
||||
return (dhook == par
|
||||
|| dhook->getLayout() != par->getLayout()
|
||||
|| dhook->getDepth() != par->getDepth());
|
||||
}
|
||||
|
||||
|
||||
int getEndLabel(Paragraph * para, BufferParams const & bparams)
|
||||
{
|
||||
Paragraph * par = para;
|
||||
while (par) {
|
||||
Paragraph::depth_type par_depth = par->getDepth();
|
||||
layout_type layout = par->getLayout();
|
||||
int const endlabeltype =
|
||||
textclasslist.Style(bparams.textclass,
|
||||
layout).endlabeltype;
|
||||
if (endlabeltype != END_LABEL_NO_LABEL) {
|
||||
if (!para->next())
|
||||
return endlabeltype;
|
||||
|
||||
Paragraph::depth_type const next_depth =
|
||||
para->next()->getDepth();
|
||||
if (par_depth > next_depth ||
|
||||
(par_depth == next_depth
|
||||
&& layout != para->next()->getLayout()))
|
||||
return endlabeltype;
|
||||
break;
|
||||
}
|
||||
if (par_depth == 0)
|
||||
break;
|
||||
par = outerHook(par);
|
||||
}
|
||||
return END_LABEL_NO_LABEL;
|
||||
}
|
||||
#endif
|
54
src/paragraph_funcs.h
Normal file
54
src/paragraph_funcs.h
Normal file
@ -0,0 +1,54 @@
|
||||
// -*- C++ -*-
|
||||
/* This file is part of
|
||||
* ======================================================
|
||||
*
|
||||
* LyX, The Document Processor
|
||||
*
|
||||
* Copyright 1995 Matthias Ettrich
|
||||
* Copyright 1995-2001 The LyX Team.
|
||||
*
|
||||
* ====================================================== */
|
||||
|
||||
#ifndef PARAGRAPH_FUNCS_H
|
||||
#define PARAGRAPH_FUNCS_H
|
||||
|
||||
#include "ParagraphList.h"
|
||||
#include "paragraph.h"
|
||||
|
||||
#include "support/types.h"
|
||||
|
||||
class BufferParams;
|
||||
|
||||
///
|
||||
void breakParagraph(BufferParams const & bparams,
|
||||
Paragraph *,
|
||||
lyx::pos_type pos,
|
||||
int flag);
|
||||
|
||||
///
|
||||
void breakParagraphConservative(BufferParams const & bparams,
|
||||
Paragraph *,
|
||||
lyx::pos_type pos);
|
||||
|
||||
#if 0
|
||||
/** Paste this paragraph with the next one.
|
||||
Be carefull, this doesent make any check at all.
|
||||
*/
|
||||
void pasteParagraph(BufferParams const & bparams,
|
||||
Paragraph *);
|
||||
|
||||
|
||||
/// for the environments
|
||||
Paragraph * depthHook(Paragraph * par, Paragraph::depth_type depth);
|
||||
|
||||
Paragraph * outerHook(Paragraph * par);
|
||||
|
||||
/// Is it the first par with same depth and layout?
|
||||
bool isFirstInSequence(Paragraph * par);
|
||||
|
||||
/** Check if the current paragraph is the last paragraph in a
|
||||
proof environment */
|
||||
int getEndLabel(Paragraph * para, BufferParams const & bparams);
|
||||
#endif
|
||||
|
||||
#endif
|
@ -31,6 +31,7 @@
|
||||
#include "ParagraphParameters.h"
|
||||
#include "undo_funcs.h"
|
||||
#include "WordLangTuple.h"
|
||||
#include "paragraph_funcs.h"
|
||||
|
||||
#include "insets/insetbib.h"
|
||||
#include "insets/insettext.h"
|
||||
@ -1758,8 +1759,8 @@ void LyXText::breakParagraph(BufferView * bview, char keep_layout)
|
||||
// paragraph before or behind and we should react on that one
|
||||
// but we can fix this in 1.3.0 (Jug 20020509)
|
||||
bool const isempty = (layout->keepempty && cursor.par()->empty());
|
||||
cursor.par()->breakParagraph(bview->buffer()->params, cursor.pos(),
|
||||
keep_layout);
|
||||
::breakParagraph(bview->buffer()->params, cursor.par(), cursor.pos(),
|
||||
keep_layout);
|
||||
|
||||
// well this is the caption hack since one caption is really enough
|
||||
if (layout->labeltype == LABEL_SENSITIVE) {
|
||||
@ -3948,4 +3949,3 @@ int LyXText::getDepth() const
|
||||
{
|
||||
return cursor.par()->getDepth();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user