2003-08-17 11:28:23 +00:00
|
|
|
/**
|
2007-04-25 01:24:38 +00:00
|
|
|
* \file InsetBranch.cpp
|
2003-08-17 11:28:23 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author Martin Vermeer
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2003-08-17 11:28:23 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2007-04-25 01:24:38 +00:00
|
|
|
#include "InsetBranch.h"
|
2003-09-05 09:01:27 +00:00
|
|
|
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "Buffer.h"
|
|
|
|
#include "BufferParams.h"
|
2008-03-27 22:26:24 +00:00
|
|
|
#include "BufferView.h"
|
2003-12-14 16:33:56 +00:00
|
|
|
#include "BranchList.h"
|
2009-02-09 23:30:24 +00:00
|
|
|
#include "ColorSet.h"
|
2007-04-26 14:56:30 +00:00
|
|
|
#include "Cursor.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "DispatchResult.h"
|
|
|
|
#include "FuncRequest.h"
|
2005-04-22 08:57:22 +00:00
|
|
|
#include "FuncStatus.h"
|
2007-04-26 11:30:54 +00:00
|
|
|
#include "Lexer.h"
|
2012-09-30 15:32:00 +00:00
|
|
|
#include "LyX.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "OutputParams.h"
|
2009-11-21 23:24:21 +00:00
|
|
|
#include "output_xhtml.h"
|
2007-11-07 23:25:08 +00:00
|
|
|
#include "TextClass.h"
|
2008-05-30 13:59:29 +00:00
|
|
|
#include "TocBackend.h"
|
2003-08-17 11:28:23 +00:00
|
|
|
|
2008-03-27 22:26:24 +00:00
|
|
|
#include "support/debug.h"
|
|
|
|
#include "support/gettext.h"
|
2009-04-11 07:11:37 +00:00
|
|
|
#include "support/lstrings.h"
|
2008-03-27 22:26:24 +00:00
|
|
|
|
2012-10-01 10:37:16 +00:00
|
|
|
#include "frontends/alert.h"
|
2008-03-27 22:26:24 +00:00
|
|
|
#include "frontends/Application.h"
|
|
|
|
|
2004-07-24 10:55:30 +00:00
|
|
|
#include <sstream>
|
2003-09-05 09:01:27 +00:00
|
|
|
|
2007-12-12 10:16:00 +00:00
|
|
|
using namespace std;
|
2006-10-21 00:16:43 +00:00
|
|
|
|
2006-09-09 18:52:00 +00:00
|
|
|
|
2008-03-27 22:26:24 +00:00
|
|
|
namespace lyx {
|
2003-08-17 11:28:23 +00:00
|
|
|
|
2009-11-08 15:53:21 +00:00
|
|
|
InsetBranch::InsetBranch(Buffer * buf, InsetBranchParams const & params)
|
2017-10-16 08:12:21 +00:00
|
|
|
: InsetCollapsible(buf, InsetText::DefaultLayout), params_(params)
|
2009-04-04 19:34:14 +00:00
|
|
|
{}
|
2003-08-17 11:28:23 +00:00
|
|
|
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
void InsetBranch::write(ostream & os) const
|
2003-08-17 11:28:23 +00:00
|
|
|
{
|
2010-03-11 12:56:25 +00:00
|
|
|
os << "Branch ";
|
2003-08-17 11:28:23 +00:00
|
|
|
params_.write(os);
|
2010-03-10 20:56:45 +00:00
|
|
|
os << '\n';
|
2017-10-16 08:12:21 +00:00
|
|
|
InsetCollapsible::write(os);
|
2003-08-17 11:28:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
void InsetBranch::read(Lexer & lex)
|
2003-08-17 11:28:23 +00:00
|
|
|
{
|
2003-12-14 16:33:56 +00:00
|
|
|
params_.read(lex);
|
2017-10-16 08:12:21 +00:00
|
|
|
InsetCollapsible::read(lex);
|
2003-08-17 11:28:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-08-02 20:33:18 +00:00
|
|
|
docstring InsetBranch::toolTip(BufferView const & bv, int, int) const
|
2008-02-12 09:11:06 +00:00
|
|
|
{
|
2012-09-30 12:59:24 +00:00
|
|
|
docstring const masterstatus = isBranchSelected() ?
|
2009-04-11 07:11:37 +00:00
|
|
|
_("active") : _("non-active");
|
2012-09-30 12:59:24 +00:00
|
|
|
docstring const childstatus = isBranchSelected(true) ?
|
|
|
|
_("active") : _("non-active");
|
|
|
|
docstring const status = (masterstatus == childstatus) ?
|
|
|
|
masterstatus :
|
2016-07-30 02:58:03 +00:00
|
|
|
support::bformat(_("master %1$s, child %2$s"),
|
2012-09-30 12:59:24 +00:00
|
|
|
masterstatus, childstatus);
|
2016-07-30 02:58:03 +00:00
|
|
|
|
|
|
|
docstring const masteron = producesOutput() ?
|
|
|
|
_("on") : _("off");
|
2016-08-28 04:02:43 +00:00
|
|
|
docstring const childon =
|
|
|
|
(isBranchSelected(true) != params_.inverted) ?
|
|
|
|
_("on") : _("off");
|
2016-07-30 02:58:03 +00:00
|
|
|
docstring const onoff = (masteron == childon) ?
|
|
|
|
masteron :
|
|
|
|
support::bformat(_("master %1$s, child %2$s"),
|
|
|
|
masteron, childon);
|
|
|
|
|
2017-07-03 17:53:14 +00:00
|
|
|
docstring const heading =
|
2016-07-30 02:58:03 +00:00
|
|
|
support::bformat(_("Branch Name: %1$s\nBranch Status: %2$s\nInset Status: %3$s"),
|
|
|
|
params_.branch, status, onoff);
|
2016-08-02 20:33:18 +00:00
|
|
|
|
|
|
|
if (isOpen(bv))
|
|
|
|
return heading;
|
|
|
|
return toolTipText(heading + from_ascii("\n"));
|
2008-02-12 09:11:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-06-14 17:55:18 +00:00
|
|
|
docstring const InsetBranch::buttonLabel(BufferView const &) const
|
2003-08-17 11:28:23 +00:00
|
|
|
{
|
2015-12-02 21:56:10 +00:00
|
|
|
static char_type const tick = 0x2714; // ✔ U+2714 HEAVY CHECK MARK
|
|
|
|
static char_type const cross = 0x2716; // ✖ U+2716 HEAVY MULTIPLICATION X
|
2016-06-14 17:55:18 +00:00
|
|
|
|
2009-03-27 11:44:40 +00:00
|
|
|
Buffer const & realbuffer = *buffer().masterBuffer();
|
|
|
|
BranchList const & branchlist = realbuffer.params().branchlist();
|
2012-09-30 12:59:24 +00:00
|
|
|
bool const inmaster = branchlist.find(params_.branch);
|
|
|
|
bool const inchild = buffer().params().branchlist().find(params_.branch);
|
2016-06-14 17:55:18 +00:00
|
|
|
|
2016-07-30 02:58:03 +00:00
|
|
|
bool const master_selected = producesOutput();
|
2016-08-28 04:02:43 +00:00
|
|
|
bool const child_selected = isBranchSelected(true) != params_.inverted;
|
2016-06-14 17:55:18 +00:00
|
|
|
|
2016-07-30 02:58:03 +00:00
|
|
|
docstring symb = docstring(1, master_selected ? tick : cross);
|
|
|
|
if (inchild && master_selected != child_selected)
|
|
|
|
symb += (child_selected ? tick : cross);
|
2016-06-14 17:55:18 +00:00
|
|
|
|
|
|
|
if (decoration() == InsetLayout::MINIMALISTIC)
|
|
|
|
return symb + params_.branch;
|
|
|
|
|
|
|
|
docstring s;
|
|
|
|
if (inmaster && inchild)
|
|
|
|
s = _("Branch: ");
|
|
|
|
else if (inchild) // && !inmaster
|
2016-06-20 13:49:48 +00:00
|
|
|
s = _("Branch (child): ");
|
2016-06-14 17:55:18 +00:00
|
|
|
else if (inmaster) // && !inchild
|
2016-06-20 13:49:48 +00:00
|
|
|
s = _("Branch (master): ");
|
2016-06-14 17:55:18 +00:00
|
|
|
else // !inmaster && !inchild
|
|
|
|
s = _("Branch (undefined): ");
|
|
|
|
s += params_.branch;
|
|
|
|
|
2016-07-12 03:56:32 +00:00
|
|
|
return symb + s;
|
2003-08-17 11:28:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-17 14:09:37 +00:00
|
|
|
ColorCode InsetBranch::backgroundColor(PainterInfo const & pi) const
|
2007-06-12 13:45:49 +00:00
|
|
|
{
|
2008-05-31 22:39:52 +00:00
|
|
|
if (params_.branch.empty())
|
2009-12-17 14:09:37 +00:00
|
|
|
return Inset::backgroundColor(pi);
|
2008-05-31 22:39:52 +00:00
|
|
|
// FIXME UNICODE
|
|
|
|
ColorCode c = lcolor.getFromLyXName(to_utf8(params_.branch));
|
|
|
|
if (c == Color_none)
|
|
|
|
c = Color_error;
|
|
|
|
return c;
|
2007-06-12 13:45:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-04-26 14:56:30 +00:00
|
|
|
void InsetBranch::doDispatch(Cursor & cur, FuncRequest & cmd)
|
2003-08-17 11:28:23 +00:00
|
|
|
{
|
2010-04-09 19:00:42 +00:00
|
|
|
switch (cmd.action()) {
|
2003-11-03 19:52:47 +00:00
|
|
|
case LFUN_INSET_MODIFY: {
|
2003-08-17 11:28:23 +00:00
|
|
|
InsetBranchParams params;
|
2008-03-27 22:26:24 +00:00
|
|
|
InsetBranch::string2params(to_utf8(cmd.argument()), params);
|
2010-12-08 09:24:04 +00:00
|
|
|
|
2015-03-12 14:57:29 +00:00
|
|
|
cur.recordUndoInset(this);
|
2003-08-17 11:28:23 +00:00
|
|
|
params_.branch = params.branch;
|
2016-07-12 03:56:32 +00:00
|
|
|
params_.inverted = params.inverted;
|
2010-07-09 14:37:00 +00:00
|
|
|
// what we really want here is a TOC update, but that means
|
|
|
|
// a full buffer update
|
|
|
|
cur.forceBufferUpdate();
|
2004-02-16 11:58:51 +00:00
|
|
|
break;
|
2003-11-03 19:52:47 +00:00
|
|
|
}
|
2009-03-31 09:38:07 +00:00
|
|
|
case LFUN_BRANCH_ACTIVATE:
|
2012-09-30 12:59:24 +00:00
|
|
|
case LFUN_BRANCH_DEACTIVATE:
|
|
|
|
case LFUN_BRANCH_MASTER_ACTIVATE:
|
|
|
|
case LFUN_BRANCH_MASTER_DEACTIVATE: {
|
|
|
|
bool const master = (cmd.action() == LFUN_BRANCH_MASTER_ACTIVATE
|
2012-09-30 14:12:52 +00:00
|
|
|
|| cmd.action() == LFUN_BRANCH_MASTER_DEACTIVATE);
|
2012-09-30 12:59:24 +00:00
|
|
|
Buffer * buf = master ? const_cast<Buffer *>(buffer().masterBuffer())
|
2012-09-30 14:12:52 +00:00
|
|
|
: &buffer();
|
2011-12-02 21:21:37 +00:00
|
|
|
|
|
|
|
Branch * our_branch = buf->params().branchlist().find(params_.branch);
|
2012-09-30 12:59:24 +00:00
|
|
|
if (!our_branch)
|
|
|
|
break;
|
|
|
|
|
|
|
|
bool const activate = (cmd.action() == LFUN_BRANCH_ACTIVATE
|
2012-09-30 14:12:52 +00:00
|
|
|
|| cmd.action() == LFUN_BRANCH_MASTER_ACTIVATE);
|
2010-11-29 16:50:22 +00:00
|
|
|
if (our_branch->isSelected() != activate) {
|
2011-12-02 21:21:37 +00:00
|
|
|
// FIXME If the branch is in the master document, we cannot
|
2012-09-30 12:59:24 +00:00
|
|
|
// call recordUndo..., because the master may be hidden, and
|
2011-12-02 21:21:37 +00:00
|
|
|
// the code presently assumes that hidden documents can never
|
|
|
|
// be dirty. See GuiView::closeBufferAll(), for example.
|
2012-10-01 10:37:16 +00:00
|
|
|
// An option would be to check if the master is hidden.
|
|
|
|
// If it is, unhide.
|
2012-09-30 12:59:24 +00:00
|
|
|
if (!master)
|
2015-01-17 19:38:22 +00:00
|
|
|
buffer().undo().recordUndoBufferParams(cur);
|
2012-10-01 10:37:16 +00:00
|
|
|
else
|
|
|
|
// at least issue a warning for now (ugly, but better than dataloss).
|
|
|
|
frontend::Alert::warning(_("Branch state changes in master document"),
|
|
|
|
lyx::support::bformat(_("The state of the branch '%1$s' "
|
|
|
|
"was changed in the master file. "
|
|
|
|
"Please make sure to save the master."), params_.branch), true);
|
2010-11-29 16:50:22 +00:00
|
|
|
our_branch->setSelected(activate);
|
2012-10-01 10:37:16 +00:00
|
|
|
// cur.forceBufferUpdate() is not enough
|
|
|
|
buf->updateBuffer();
|
2010-11-29 16:50:22 +00:00
|
|
|
}
|
2019-12-11 16:46:56 +00:00
|
|
|
|
|
|
|
// if branch exists in a descendant, update previews.
|
|
|
|
// TODO: only needed if "Show preview" is enabled in the included inset.
|
|
|
|
bool exists_in_desc = false;
|
2019-12-16 04:36:17 +00:00
|
|
|
for (auto const & it : buf->getDescendants()) {
|
2019-12-11 16:46:56 +00:00
|
|
|
if (it->params().branchlist().find(params_.branch))
|
|
|
|
exists_in_desc = true;
|
|
|
|
}
|
|
|
|
if (exists_in_desc) {
|
|
|
|
// TODO: ideally we would only update the previews of the
|
|
|
|
// specific children that have this branch directly or
|
|
|
|
// in one of their descendants
|
|
|
|
buf->removePreviews();
|
|
|
|
buf->updatePreviews();
|
|
|
|
}
|
2009-03-31 09:38:07 +00:00
|
|
|
break;
|
|
|
|
}
|
2016-07-12 04:16:05 +00:00
|
|
|
case LFUN_BRANCH_INVERT:
|
2016-07-12 13:27:40 +00:00
|
|
|
cur.recordUndoInset(this);
|
2016-07-12 04:16:05 +00:00
|
|
|
params_.inverted = !params_.inverted;
|
2016-07-12 13:27:40 +00:00
|
|
|
// what we really want here is a TOC update, but that means
|
|
|
|
// a full buffer update
|
|
|
|
cur.forceBufferUpdate();
|
2016-07-12 04:16:05 +00:00
|
|
|
break;
|
2012-09-30 15:32:00 +00:00
|
|
|
case LFUN_BRANCH_ADD:
|
|
|
|
lyx::dispatch(FuncRequest(LFUN_BRANCH_ADD, params_.branch));
|
|
|
|
break;
|
2004-03-30 12:36:33 +00:00
|
|
|
case LFUN_INSET_TOGGLE:
|
2009-03-30 12:45:33 +00:00
|
|
|
if (cmd.argument() == "assign")
|
|
|
|
setStatus(cur, isBranchSelected() ? Open : Collapsed);
|
2005-10-24 09:42:20 +00:00
|
|
|
else
|
2017-10-16 08:12:21 +00:00
|
|
|
InsetCollapsible::doDispatch(cur, cmd);
|
2004-03-30 12:36:33 +00:00
|
|
|
break;
|
|
|
|
|
2003-08-17 11:28:23 +00:00
|
|
|
default:
|
2017-10-16 08:12:21 +00:00
|
|
|
InsetCollapsible::doDispatch(cur, cmd);
|
2004-02-16 11:58:51 +00:00
|
|
|
break;
|
2003-08-17 11:28:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-04-26 14:56:30 +00:00
|
|
|
bool InsetBranch::getStatus(Cursor & cur, FuncRequest const & cmd,
|
2005-04-22 08:57:22 +00:00
|
|
|
FuncStatus & flag) const
|
|
|
|
{
|
2012-09-30 15:32:00 +00:00
|
|
|
bool const known_branch =
|
|
|
|
buffer().params().branchlist().find(params_.branch);
|
|
|
|
|
2010-04-09 19:00:42 +00:00
|
|
|
switch (cmd.action()) {
|
2005-04-22 08:57:22 +00:00
|
|
|
case LFUN_INSET_MODIFY:
|
2008-05-29 15:14:00 +00:00
|
|
|
flag.setEnabled(true);
|
2005-04-22 08:57:22 +00:00
|
|
|
break;
|
|
|
|
|
2009-03-31 09:38:07 +00:00
|
|
|
case LFUN_BRANCH_ACTIVATE:
|
2012-09-30 15:32:00 +00:00
|
|
|
flag.setEnabled(known_branch && !isBranchSelected(true));
|
|
|
|
break;
|
|
|
|
|
2016-07-12 04:16:05 +00:00
|
|
|
case LFUN_BRANCH_INVERT:
|
|
|
|
flag.setEnabled(true);
|
2016-07-12 13:27:08 +00:00
|
|
|
flag.setOnOff(params_.inverted);
|
2016-07-12 04:16:05 +00:00
|
|
|
break;
|
|
|
|
|
2012-09-30 15:32:00 +00:00
|
|
|
case LFUN_BRANCH_ADD:
|
|
|
|
flag.setEnabled(!known_branch);
|
2009-03-31 09:38:07 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_BRANCH_DEACTIVATE:
|
2012-09-30 12:59:24 +00:00
|
|
|
flag.setEnabled(isBranchSelected(true));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_BRANCH_MASTER_ACTIVATE:
|
2012-09-30 15:32:00 +00:00
|
|
|
flag.setEnabled(buffer().parent()
|
|
|
|
&& buffer().masterBuffer()->params().branchlist().find(params_.branch)
|
|
|
|
&& !isBranchSelected());
|
2012-09-30 12:59:24 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_BRANCH_MASTER_DEACTIVATE:
|
|
|
|
flag.setEnabled(buffer().parent() && isBranchSelected());
|
2009-03-31 09:38:07 +00:00
|
|
|
break;
|
|
|
|
|
2005-04-22 08:57:22 +00:00
|
|
|
case LFUN_INSET_TOGGLE:
|
2009-03-31 09:38:07 +00:00
|
|
|
if (cmd.argument() == "assign")
|
2008-05-29 15:14:00 +00:00
|
|
|
flag.setEnabled(true);
|
2009-03-31 09:38:07 +00:00
|
|
|
else
|
2017-10-16 08:12:21 +00:00
|
|
|
return InsetCollapsible::getStatus(cur, cmd, flag);
|
2010-11-30 00:21:08 +00:00
|
|
|
break;
|
2005-04-22 08:57:22 +00:00
|
|
|
|
|
|
|
default:
|
2017-10-16 08:12:21 +00:00
|
|
|
return InsetCollapsible::getStatus(cur, cmd, flag);
|
2005-04-22 08:57:22 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-09-30 12:59:24 +00:00
|
|
|
bool InsetBranch::isBranchSelected(bool const child) const
|
2003-12-14 16:33:56 +00:00
|
|
|
{
|
2012-09-30 12:59:24 +00:00
|
|
|
Buffer const & realbuffer = child ? buffer() : *buffer().masterBuffer();
|
2005-10-25 15:21:49 +00:00
|
|
|
BranchList const & branchlist = realbuffer.params().branchlist();
|
2008-05-27 18:57:16 +00:00
|
|
|
Branch const * ourBranch = branchlist.find(params_.branch);
|
2009-07-11 00:10:18 +00:00
|
|
|
|
|
|
|
if (!ourBranch) {
|
|
|
|
// this branch is defined in child only
|
|
|
|
ourBranch = buffer().params().branchlist().find(params_.branch);
|
|
|
|
if (!ourBranch)
|
|
|
|
return false;
|
|
|
|
}
|
2008-09-21 19:27:20 +00:00
|
|
|
return ourBranch->isSelected();
|
2003-12-14 16:33:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-08-28 04:02:43 +00:00
|
|
|
bool InsetBranch::producesOutput() const
|
2016-07-12 13:28:12 +00:00
|
|
|
{
|
2016-08-28 04:02:43 +00:00
|
|
|
return isBranchSelected() != params_.inverted;
|
2016-07-12 13:28:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-10 20:02:48 +00:00
|
|
|
void InsetBranch::latex(otexstream & os, OutputParams const & runparams) const
|
2003-08-17 11:28:23 +00:00
|
|
|
{
|
2019-05-10 06:09:26 +00:00
|
|
|
if (producesOutput()) {
|
|
|
|
OutputParams rp = runparams;
|
2019-07-18 15:04:18 +00:00
|
|
|
rp.inbranch = true;
|
2019-05-10 06:09:26 +00:00
|
|
|
InsetText::latex(os, rp);
|
|
|
|
}
|
2003-08-17 11:28:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-03-08 19:52:18 +00:00
|
|
|
int InsetBranch::plaintext(odocstringstream & os,
|
|
|
|
OutputParams const & runparams, size_t max_length) const
|
2003-08-17 11:28:23 +00:00
|
|
|
{
|
2016-07-12 13:28:12 +00:00
|
|
|
if (!producesOutput())
|
2007-02-16 09:28:25 +00:00
|
|
|
return 0;
|
|
|
|
|
2013-03-08 19:52:18 +00:00
|
|
|
int len = InsetText::plaintext(os, runparams, max_length);
|
2011-08-11 21:39:04 +00:00
|
|
|
return len;
|
2003-08-17 11:28:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
int InsetBranch::docbook(odocstream & os,
|
2007-05-28 22:27:45 +00:00
|
|
|
OutputParams const & runparams) const
|
2003-08-17 11:28:23 +00:00
|
|
|
{
|
2016-07-12 13:28:12 +00:00
|
|
|
return producesOutput() ? InsetText::docbook(os, runparams) : 0;
|
2003-08-17 11:28:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-21 23:24:21 +00:00
|
|
|
docstring InsetBranch::xhtml(XHTMLStream & xs, OutputParams const & rp) const
|
2009-06-05 17:48:14 +00:00
|
|
|
{
|
2016-07-12 13:28:12 +00:00
|
|
|
if (producesOutput()) {
|
2011-10-29 20:14:43 +00:00
|
|
|
OutputParams newrp = rp;
|
|
|
|
newrp.par_begin = 0;
|
|
|
|
newrp.par_end = text().paragraphs().size();
|
|
|
|
xhtmlParagraphs(text(), buffer(), xs, newrp);
|
|
|
|
}
|
2009-06-12 17:23:17 +00:00
|
|
|
return docstring();
|
2009-06-05 17:48:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-15 01:34:04 +00:00
|
|
|
void InsetBranch::toString(odocstream & os) const
|
2007-01-19 16:23:47 +00:00
|
|
|
{
|
2016-07-12 13:28:12 +00:00
|
|
|
if (producesOutput())
|
2017-10-16 08:12:21 +00:00
|
|
|
InsetCollapsible::toString(os);
|
2007-01-19 16:23:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-10-04 18:38:47 +00:00
|
|
|
void InsetBranch::forOutliner(docstring & os, size_t const maxlen,
|
|
|
|
bool const shorten) const
|
2010-12-20 21:55:09 +00:00
|
|
|
{
|
2016-07-12 13:28:12 +00:00
|
|
|
if (producesOutput())
|
2017-10-16 08:12:21 +00:00
|
|
|
InsetCollapsible::forOutliner(os, maxlen, shorten);
|
2010-12-20 21:55:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-08-17 11:28:23 +00:00
|
|
|
void InsetBranch::validate(LaTeXFeatures & features) const
|
|
|
|
{
|
2016-07-12 13:28:12 +00:00
|
|
|
if (producesOutput())
|
2017-10-16 08:12:21 +00:00
|
|
|
InsetCollapsible::validate(features);
|
2003-08-17 11:28:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-10-29 14:48:55 +00:00
|
|
|
string InsetBranch::contextMenuName() const
|
2009-03-31 09:38:07 +00:00
|
|
|
{
|
2011-10-29 14:48:55 +00:00
|
|
|
return "context-branch";
|
2009-03-31 09:38:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-07-03 17:53:14 +00:00
|
|
|
bool InsetBranch::isMacroScope() const
|
2007-12-21 20:42:46 +00:00
|
|
|
{
|
|
|
|
// Its own scope if not selected by buffer
|
2016-07-12 13:28:12 +00:00
|
|
|
return !producesOutput();
|
2007-12-21 20:42:46 +00:00
|
|
|
}
|
|
|
|
|
2003-08-17 11:28:23 +00:00
|
|
|
|
2008-03-27 22:26:24 +00:00
|
|
|
string InsetBranch::params2string(InsetBranchParams const & params)
|
2003-08-17 11:28:23 +00:00
|
|
|
{
|
|
|
|
ostringstream data;
|
|
|
|
params.write(data);
|
2003-09-15 11:00:00 +00:00
|
|
|
return data.str();
|
2003-08-17 11:28:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-27 22:26:24 +00:00
|
|
|
void InsetBranch::string2params(string const & in, InsetBranchParams & params)
|
2003-08-17 11:28:23 +00:00
|
|
|
{
|
|
|
|
params = InsetBranchParams();
|
|
|
|
if (in.empty())
|
|
|
|
return;
|
|
|
|
|
2003-09-15 11:00:00 +00:00
|
|
|
istringstream data(in);
|
2008-04-02 23:06:22 +00:00
|
|
|
Lexer lex;
|
2003-08-17 11:28:23 +00:00
|
|
|
lex.setStream(data);
|
2008-04-05 10:34:29 +00:00
|
|
|
lex.setContext("InsetBranch::string2params");
|
2003-08-17 11:28:23 +00:00
|
|
|
params.read(lex);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-03-06 12:23:01 +00:00
|
|
|
void InsetBranch::updateBuffer(ParIterator const & it, UpdateType utype, bool const deleted)
|
2008-05-30 13:59:29 +00:00
|
|
|
{
|
2017-01-09 12:28:48 +00:00
|
|
|
setLabel(params_.branch + (params_.inverted ? " (-)" : ""));
|
2020-03-06 12:23:01 +00:00
|
|
|
InsetCollapsible::updateBuffer(it, utype, deleted);
|
2008-05-30 13:59:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-08-17 11:28:23 +00:00
|
|
|
void InsetBranchParams::write(ostream & os) const
|
|
|
|
{
|
2017-07-03 17:53:14 +00:00
|
|
|
os << to_utf8(branch)
|
|
|
|
<< '\n'
|
|
|
|
<< "inverted "
|
2016-07-12 03:56:32 +00:00
|
|
|
<< inverted;
|
2003-08-17 11:28:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-04-26 11:30:54 +00:00
|
|
|
void InsetBranchParams::read(Lexer & lex)
|
2003-08-17 11:28:23 +00:00
|
|
|
{
|
2018-09-07 13:49:21 +00:00
|
|
|
// There may be a space in branch name
|
|
|
|
// if we wanted to use lex>>, the branch name should be properly in quotes
|
|
|
|
lex.eatLine();
|
|
|
|
branch = lex.getDocString();
|
2016-07-12 03:56:32 +00:00
|
|
|
lex >> "inverted" >> inverted;
|
2003-08-17 11:28:23 +00:00
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
} // namespace lyx
|