mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-08 10:51:03 +00:00
* BufferView.[Ch] (insertInset):
* BufferView_pimpl.[Ch] (insertInset): remove unneeded return value * text2.C: * text3.C: adjust git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8400 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
982344dc61
commit
ccd12088c5
@ -18,6 +18,7 @@
|
||||
|
||||
#include "buffer.h"
|
||||
#include "bufferlist.h"
|
||||
#include "bufferparams.h"
|
||||
#include "BufferView_pimpl.h"
|
||||
#include "debug.h"
|
||||
#include "funcrequest.h"
|
||||
@ -26,6 +27,7 @@
|
||||
#include "language.h"
|
||||
#include "lyxlayout.h"
|
||||
#include "lyxtext.h"
|
||||
#include "lyxtextclass.h"
|
||||
#include "paragraph.h"
|
||||
#include "paragraph_funcs.h"
|
||||
#include "PosIterator.h"
|
||||
@ -301,9 +303,30 @@ void BufferView::setCursorFromRow(int row)
|
||||
}
|
||||
|
||||
|
||||
bool BufferView::insertInset(InsetBase * inset, string const & lout)
|
||||
void BufferView::insertInset(InsetBase * inset, string const & lout)
|
||||
{
|
||||
return pimpl_->insertInset(inset, lout);
|
||||
// not quite sure if we want this...
|
||||
text()->recUndo(text()->cursor().par());
|
||||
freezeUndo();
|
||||
|
||||
cursor().clearSelection();
|
||||
if (!lout.empty()) {
|
||||
text()->breakParagraph(buffer()->paragraphs());
|
||||
|
||||
if (!text()->cursorPar()->empty()) {
|
||||
text()->cursorLeft(true);
|
||||
text()->breakParagraph(buffer()->paragraphs());
|
||||
}
|
||||
|
||||
string lres = lout;
|
||||
LyXTextClass const & tclass = buffer()->params().getLyXTextClass();
|
||||
bool hasLayout = tclass.hasLayout(lres);
|
||||
|
||||
text()->setLayout(hasLayout ? lres : tclass.defaultLayoutName());
|
||||
text()->setParagraph(Spacing(), LYX_ALIGN_LAYOUT, string(), 0);
|
||||
}
|
||||
cursor().innerText()->insertInset(inset);
|
||||
unFreezeUndo();
|
||||
}
|
||||
|
||||
|
||||
|
@ -140,11 +140,9 @@ public:
|
||||
/// set the cursor based on the given TeX source row
|
||||
void setCursorFromRow(int row);
|
||||
|
||||
/**
|
||||
* Insert an inset into the buffer.
|
||||
* Place it in a layout of lout,
|
||||
*/
|
||||
bool insertInset(InsetBase * inset, std::string const & lout = std::string());
|
||||
/// Insert an inset into the buffer, in a layout of lout.
|
||||
void insertInset(InsetBase * inset,
|
||||
std::string const & lout = std::string());
|
||||
|
||||
/// Inserts a lyx file at cursor position. return false if it fails
|
||||
bool insertLyXFile(std::string const & file);
|
||||
|
@ -1077,20 +1077,10 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & cmd)
|
||||
}
|
||||
break;
|
||||
|
||||
case LFUN_INSET_INSERT: {
|
||||
// Same as above.
|
||||
BOOST_ASSERT(false);
|
||||
InsetBase * inset = createInset(bv_, cmd);
|
||||
if (!inset || !insertInset(inset))
|
||||
delete inset;
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_FLOAT_LIST:
|
||||
if (tclass.floats().typeExist(cmd.argument)) {
|
||||
InsetBase * inset = new InsetFloatList(cmd.argument);
|
||||
if (!insertInset(inset, tclass.defaultLayoutName()))
|
||||
delete inset;
|
||||
bv_->insertInset(inset, tclass.defaultLayoutName());
|
||||
} else {
|
||||
lyxerr << "Non-existent float type: "
|
||||
<< cmd.argument << endl;
|
||||
@ -1218,34 +1208,6 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & cmd)
|
||||
}
|
||||
|
||||
|
||||
bool BufferView::Pimpl::insertInset(InsetBase * inset, string const & lout)
|
||||
{
|
||||
// not quite sure if we want this...
|
||||
bv_->text()->recUndo(bv_->text()->cursor().par());
|
||||
freezeUndo();
|
||||
|
||||
bv_->cursor().clearSelection();
|
||||
if (!lout.empty()) {
|
||||
bv_->text()->breakParagraph(bv_->buffer()->paragraphs());
|
||||
|
||||
if (!bv_->text()->cursorPar()->empty()) {
|
||||
bv_->text()->cursorLeft(bv_);
|
||||
bv_->text()->breakParagraph(bv_->buffer()->paragraphs());
|
||||
}
|
||||
|
||||
string lres = lout;
|
||||
LyXTextClass const & tclass = buffer_->params().getLyXTextClass();
|
||||
bool hasLayout = tclass.hasLayout(lres);
|
||||
|
||||
bv_->text()->setLayout(hasLayout ? lres : tclass.defaultLayoutName());
|
||||
bv_->text()->setParagraph(Spacing(), LYX_ALIGN_LAYOUT, string(), 0);
|
||||
}
|
||||
bv_->cursor().innerText()->insertInset(inset);
|
||||
unFreezeUndo();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool BufferView::Pimpl::ChangeInsets(InsetBase::Code code,
|
||||
string const & from, string const & to)
|
||||
{
|
||||
|
@ -101,8 +101,6 @@ struct BufferView::Pimpl : public boost::signals::trackable {
|
||||
void switchKeyMap();
|
||||
///
|
||||
void center();
|
||||
///
|
||||
bool insertInset(InsetBase * inset, std::string const & lout = std::string());
|
||||
/// a function should be executed from the workarea
|
||||
bool workAreaDispatch(FuncRequest const & ev);
|
||||
/// a function should be executed
|
||||
|
@ -1,4 +1,12 @@
|
||||
|
||||
2004-02-04 André Pönitz <poenitz@gmx.net>
|
||||
|
||||
* BufferView.[Ch] (insertInset):
|
||||
* BufferView_pimpl.[Ch] (insertInset): remove unneeded return value
|
||||
|
||||
* text2.C:
|
||||
* text3.C: adjust
|
||||
|
||||
2004-02-03 Alfredo Braunstein <abraunst@lyx.org>
|
||||
|
||||
* BufferView_pimpl.C (dispatch): remove call to LCursor::dispatch
|
||||
|
@ -1328,10 +1328,7 @@ namespace {
|
||||
|
||||
bool openNewInset(LCursor & cur, InsetBase * inset)
|
||||
{
|
||||
if (!cur.bv().insertInset(inset)) {
|
||||
delete inset;
|
||||
return false;
|
||||
}
|
||||
cur.bv().insertInset(inset);
|
||||
inset->edit(cur, true);
|
||||
return true;
|
||||
}
|
||||
|
@ -291,11 +291,9 @@ void LyXText::setLayout(string const & layout)
|
||||
bv()->owner()->dispatch(FuncRequest(LFUN_ENDSEL));
|
||||
bv()->owner()->dispatch(FuncRequest(LFUN_CUT));
|
||||
InsetBase * inset = new InsetEnvironment(params, layout);
|
||||
if (bv()->insertInset(inset)) {
|
||||
//inset->edit(bv());
|
||||
//bv()->owner()->dispatch(FuncRequest(LFUN_PASTE));
|
||||
} else
|
||||
delete inset;
|
||||
bv()->insertInset(inset);
|
||||
//inset->edit(bv());
|
||||
//bv()->owner()->dispatch(FuncRequest(LFUN_PASTE));
|
||||
return;
|
||||
}
|
||||
|
||||
|
28
src/text3.C
28
src/text3.C
@ -400,10 +400,8 @@ void specialChar(LyXText * text, BufferView * bv, InsetSpecialChar::Kind kind)
|
||||
bv->update();
|
||||
InsetSpecialChar * new_inset = new InsetSpecialChar(kind);
|
||||
replaceSelection(text);
|
||||
if (!bv->insertInset(new_inset))
|
||||
delete new_inset;
|
||||
else
|
||||
bv->update();
|
||||
bv->insertInset(new_inset);
|
||||
bv->update();
|
||||
}
|
||||
|
||||
|
||||
@ -419,14 +417,11 @@ void doInsertInset(BufferView * bv, FuncRequest const & cmd,
|
||||
bv->owner()->dispatch(FuncRequest(LFUN_CUT));
|
||||
gotsel = true;
|
||||
}
|
||||
if (bv->insertInset(inset)) {
|
||||
if (edit)
|
||||
inset->edit(bv->cursor(), true);
|
||||
if (gotsel && pastesel)
|
||||
bv->owner()->dispatch(FuncRequest(LFUN_PASTE));
|
||||
} else {
|
||||
delete inset;
|
||||
}
|
||||
bv->insertInset(inset);
|
||||
if (edit)
|
||||
inset->edit(bv->cursor(), true);
|
||||
if (gotsel && pastesel)
|
||||
bv->owner()->dispatch(FuncRequest(LFUN_PASTE));
|
||||
}
|
||||
|
||||
} // anon namespace
|
||||
@ -867,8 +862,8 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
|
||||
case LFUN_INSET_INSERT: {
|
||||
InsetBase * inset = createInset(bv, cmd);
|
||||
if (inset && !bv->insertInset(inset))
|
||||
delete inset;
|
||||
if (inset)
|
||||
bv->insertInset(inset);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1112,8 +1107,9 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
|
||||
BufferParams const & bufparams = bv->buffer()->params();
|
||||
if (style->pass_thru ||
|
||||
pit->getFontSettings(bufparams,pos).language()->lang() == "hebrew" ||
|
||||
!bv->insertInset(new InsetQuotes(c, bufparams)))
|
||||
pit->getFontSettings(bufparams,pos).language()->lang() == "hebrew")
|
||||
bv->insertInset(new InsetQuotes(c, bufparams));
|
||||
else
|
||||
bv->owner()->dispatch(FuncRequest(LFUN_SELFINSERT, "\""));
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user