From 7d16b6af3c785e07d7a6a06f666ca35d1edcd6f0 Mon Sep 17 00:00:00 2001 From: Yuriy Skalko Date: Sun, 3 Jan 2021 01:09:03 +0200 Subject: [PATCH] Refactor `string2params` -> `fromString` Move `string2params` static methods of Insets into `fromString` methods of InsetParams. --- src/BufferView.cpp | 2 +- src/Text3.cpp | 2 +- src/factory.cpp | 47 +++++++++++++------------- src/frontends/qt/GuiBibtex.cpp | 2 +- src/frontends/qt/GuiCitation.cpp | 2 +- src/frontends/qt/GuiCounter.cpp | 3 +- src/frontends/qt/GuiExternal.cpp | 2 +- src/frontends/qt/GuiGraphics.cpp | 4 +-- src/frontends/qt/GuiHyperlink.cpp | 3 +- src/frontends/qt/GuiInclude.cpp | 2 +- src/frontends/qt/GuiIndex.cpp | 2 +- src/frontends/qt/GuiLabel.cpp | 3 +- src/frontends/qt/GuiListings.cpp | 2 +- src/frontends/qt/GuiNomenclature.cpp | 3 +- src/frontends/qt/GuiNote.cpp | 2 +- src/frontends/qt/GuiPhantom.cpp | 2 +- src/frontends/qt/GuiPrintindex.cpp | 2 +- src/frontends/qt/GuiRef.cpp | 2 +- src/frontends/qt/GuiWrap.cpp | 2 +- src/insets/InsetBibitem.cpp | 2 +- src/insets/InsetBibtex.cpp | 3 +- src/insets/InsetBox.cpp | 7 ++-- src/insets/InsetBox.h | 4 +-- src/insets/InsetBranch.cpp | 7 ++-- src/insets/InsetBranch.h | 4 +-- src/insets/InsetCommand.cpp | 25 +------------- src/insets/InsetCommand.h | 4 --- src/insets/InsetCommandParams.cpp | 21 ++++++++++++ src/insets/InsetCommandParams.h | 2 ++ src/insets/InsetERT.cpp | 24 +++++++++----- src/insets/InsetERT.h | 12 ++++--- src/insets/InsetExternal.cpp | 9 +++-- src/insets/InsetExternal.h | 3 +- src/insets/InsetFloat.cpp | 9 +++-- src/insets/InsetFloat.h | 4 +-- src/insets/InsetGraphics.cpp | 47 ++------------------------ src/insets/InsetGraphics.h | 4 --- src/insets/InsetGraphicsParams.cpp | 40 +++++++++++++++++++++++ src/insets/InsetGraphicsParams.h | 4 +++ src/insets/InsetIPAMacro.cpp | 6 ++-- src/insets/InsetIPAMacro.h | 4 +-- src/insets/InsetInclude.cpp | 2 +- src/insets/InsetIndex.cpp | 11 +++---- src/insets/InsetIndex.h | 4 +-- src/insets/InsetLabel.cpp | 2 +- src/insets/InsetLine.cpp | 2 +- src/insets/InsetListings.cpp | 17 +--------- src/insets/InsetListings.h | 2 -- src/insets/InsetListingsParams.cpp | 13 ++++++++ src/insets/InsetListingsParams.h | 3 ++ src/insets/InsetNewline.cpp | 9 +++-- src/insets/InsetNewline.h | 4 +-- src/insets/InsetNewpage.cpp | 9 +++-- src/insets/InsetNewpage.h | 4 +-- src/insets/InsetNomencl.cpp | 2 +- src/insets/InsetNote.cpp | 12 +++---- src/insets/InsetNote.h | 4 +-- src/insets/InsetParams.cpp | 4 +++ src/insets/InsetParams.h | 2 ++ src/insets/InsetPhantom.cpp | 10 +++--- src/insets/InsetPhantom.h | 4 +-- src/insets/InsetScript.cpp | 8 ++--- src/insets/InsetScript.h | 4 +-- src/insets/InsetSeparator.cpp | 9 +++-- src/insets/InsetSeparator.h | 4 +-- src/insets/InsetSpace.cpp | 13 ++++---- src/insets/InsetSpace.h | 4 +-- src/insets/InsetVSpace.cpp | 49 ++++++++++++++-------------- src/insets/InsetVSpace.h | 14 ++++---- src/insets/InsetWrap.cpp | 9 +++-- src/insets/InsetWrap.h | 4 +-- src/mathed/InsetMathHull.cpp | 2 +- src/mathed/MathFactory.cpp | 4 +-- 73 files changed, 288 insertions(+), 290 deletions(-) diff --git a/src/BufferView.cpp b/src/BufferView.cpp index ba25b8884c..7b4ebbf472 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -1745,7 +1745,7 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr) InsetGraphicsParams grp_par(&buffer_); if (!fetchId) - InsetGraphics::string2params(graphics::getGroupParams(buffer_, newId), grp_par); + grp_par.fromString(graphics::getGroupParams(buffer_, newId)); if (!from.nextInset()) //move to closest inset from.forwardInset(); diff --git a/src/Text3.cpp b/src/Text3.cpp index 94f8875d17..bb122c01f9 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -1392,7 +1392,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) if (id.empty()) inspar.groupId = to_utf8(cmd.argument()); else { - InsetGraphics::string2params(grp, tmp); + tmp.fromString(grp); tmp.filename = inspar.filename; inspar = tmp; } diff --git a/src/factory.cpp b/src/factory.cpp index 0fb4f1b8a3..b5ce41b350 100644 --- a/src/factory.cpp +++ b/src/factory.cpp @@ -270,7 +270,7 @@ Inset * createInsetHelper(Buffer * buf, FuncRequest const & cmd) case LFUN_SCRIPT_INSERT: { InsetScriptParams isp; - InsetScript::string2params("script script " + to_utf8(cmd.argument()), isp); + isp.fromString("script script " + to_utf8(cmd.argument())); return new InsetScript(buf, isp); } @@ -284,36 +284,37 @@ Inset * createInsetHelper(Buffer * buf, FuncRequest const & cmd) case BIBITEM_CODE: { InsetCommandParams icp(code); - InsetCommand::string2params(to_utf8(cmd.argument()), icp); + icp.fromString(to_utf8(cmd.argument())); return new InsetBibitem(buf, icp); } case BIBTEX_CODE: { InsetCommandParams icp(code); - InsetCommand::string2params(to_utf8(cmd.argument()), icp); + icp.fromString(to_utf8(cmd.argument())); return new InsetBibtex(buf, icp); } case CITE_CODE: { InsetCommandParams icp(code); - InsetCommand::string2params(to_utf8(cmd.argument()), icp); + icp.fromString(to_utf8(cmd.argument())); return new InsetCitation(buf, icp); } case COUNTER_CODE: { InsetCommandParams icp(code); - InsetCommand::string2params(to_utf8(cmd.argument()), icp); + icp.fromString(to_utf8(cmd.argument())); return new InsetCounter(buf, icp); } case ERT_CODE: { - return new InsetERT(buf, - InsetERT::string2params(to_utf8(cmd.argument()))); + InsetERTParams iep; + iep.fromString(to_utf8(cmd.argument())); + return new InsetERT(buf, iep); } case EXTERNAL_CODE: { InsetExternalParams iep(buf); - InsetExternal::string2params(to_utf8(cmd.argument()), iep); + iep.fromString(to_utf8(cmd.argument())); auto inset = make_unique(buf); inset->setBuffer(*buf); inset->setParams(iep); @@ -322,7 +323,7 @@ Inset * createInsetHelper(Buffer * buf, FuncRequest const & cmd) case GRAPHICS_CODE: { InsetGraphicsParams igp(buf); - InsetGraphics::string2params(to_utf8(cmd.argument()), igp); + igp.fromString(to_utf8(cmd.argument())); auto inset = make_unique(buf); inset->setParams(igp); return inset.release(); @@ -330,13 +331,13 @@ Inset * createInsetHelper(Buffer * buf, FuncRequest const & cmd) case HYPERLINK_CODE: { InsetCommandParams icp(code); - InsetCommand::string2params(to_utf8(cmd.argument()), icp); + icp.fromString(to_utf8(cmd.argument())); return new InsetHyperlink(buf, icp); } case INCLUDE_CODE: { InsetCommandParams icp(code); - InsetCommand::string2params(to_utf8(cmd.argument()), icp); + icp.fromString(to_utf8(cmd.argument())); return new InsetInclude(buf, icp); } @@ -347,62 +348,62 @@ Inset * createInsetHelper(Buffer * buf, FuncRequest const & cmd) case INDEX_PRINT_CODE: { InsetCommandParams icp(code); - InsetCommand::string2params(to_utf8(cmd.argument()), icp); + icp.fromString(to_utf8(cmd.argument())); return new InsetPrintIndex(buf, icp); } case LABEL_CODE: { InsetCommandParams icp(code); - InsetCommand::string2params(to_utf8(cmd.argument()), icp); + icp.fromString(to_utf8(cmd.argument())); return new InsetLabel(buf, icp); } case LINE_CODE: { InsetCommandParams icp(code); - InsetCommand::string2params(to_utf8(cmd.argument()), icp); + icp.fromString(to_utf8(cmd.argument())); return new InsetLine(buf, icp); } case LISTINGS_CODE: { InsetListingsParams par; - InsetListings::string2params(to_utf8(cmd.argument()), par); + par.fromString(to_utf8(cmd.argument())); return new InsetListings(buf, par); } case NOMENCL_CODE: { InsetCommandParams icp(code); - InsetCommand::string2params(to_utf8(cmd.argument()), icp); + icp.fromString(to_utf8(cmd.argument())); return new InsetNomencl(buf, icp); } case REF_CODE: { InsetCommandParams icp(code); - InsetCommand::string2params(to_utf8(cmd.argument()), icp); + icp.fromString(to_utf8(cmd.argument())); return new InsetRef(buf, icp); } case SCRIPT_CODE: { InsetScriptParams isp; - InsetScript::string2params(to_utf8(cmd.argument()), isp); + isp.fromString(to_utf8(cmd.argument())); return new InsetScript(buf, isp); } case SPACE_CODE: { InsetSpaceParams isp; - InsetSpace::string2params(to_utf8(cmd.argument()), isp); + isp.fromString(to_utf8(cmd.argument())); return new InsetSpace(isp); } case TOC_CODE: { InsetCommandParams icp(code); - InsetCommand::string2params(to_utf8(cmd.argument()), icp); + icp.fromString(to_utf8(cmd.argument())); return new InsetTOC(buf, icp); } case VSPACE_CODE: { - VSpace vspace; - InsetVSpace::string2params(to_utf8(cmd.argument()), vspace); - return new InsetVSpace(vspace); + InsetVSpaceParams ivp; + ivp.fromString(to_utf8(cmd.argument())); + return new InsetVSpace(ivp); } case PREVIEW_CODE: diff --git a/src/frontends/qt/GuiBibtex.cpp b/src/frontends/qt/GuiBibtex.cpp index 1ad64eeb59..9ed8835e6e 100644 --- a/src/frontends/qt/GuiBibtex.cpp +++ b/src/frontends/qt/GuiBibtex.cpp @@ -629,7 +629,7 @@ QString GuiBibtex::styleFile() const bool GuiBibtex::initialiseParams(std::string const & sdata) { - InsetCommand::string2params(sdata, params_); + params_.fromString(sdata); init(); return true; } diff --git a/src/frontends/qt/GuiCitation.cpp b/src/frontends/qt/GuiCitation.cpp index 61b3e1383f..da1cd6b4b7 100644 --- a/src/frontends/qt/GuiCitation.cpp +++ b/src/frontends/qt/GuiCitation.cpp @@ -944,7 +944,7 @@ void GuiCitation::setCitedKeys() bool GuiCitation::initialiseParams(string const & sdata) { - InsetCommand::string2params(sdata, params_); + params_.fromString(sdata); citeCmds_ = documentBuffer().params().citeCommands(); citeStyles_ = documentBuffer().params().citeStyles(); init(); diff --git a/src/frontends/qt/GuiCounter.cpp b/src/frontends/qt/GuiCounter.cpp index 6c5e9bf6e3..4ce941f874 100644 --- a/src/frontends/qt/GuiCounter.cpp +++ b/src/frontends/qt/GuiCounter.cpp @@ -115,7 +115,8 @@ void GuiCounter::paramsToDialog(Inset const * ip) bool GuiCounter::initialiseParams(std::string const & data) { InsetCommandParams params(insetCode()); - if (!InsetCommand::string2params(data, params)) + params.fromString(data); + if (data.empty()) return false; fillCombos(); diff --git a/src/frontends/qt/GuiExternal.cpp b/src/frontends/qt/GuiExternal.cpp index 0a56214f27..4cd02d28ad 100644 --- a/src/frontends/qt/GuiExternal.cpp +++ b/src/frontends/qt/GuiExternal.cpp @@ -630,7 +630,7 @@ void GuiExternal::applyView() bool GuiExternal::initialiseParams(string const & sdata) { - InsetExternal::string2params(sdata, params_); + params_.fromString(sdata); return true; } diff --git a/src/frontends/qt/GuiGraphics.cpp b/src/frontends/qt/GuiGraphics.cpp index 04b0ca3285..40b7858fca 100644 --- a/src/frontends/qt/GuiGraphics.cpp +++ b/src/frontends/qt/GuiGraphics.cpp @@ -311,7 +311,7 @@ void GuiGraphics::changeGroup(int /* index */) // group exists: load params into the dialog groupCO->blockSignals(true); params_.setBuffer(&buffer()); - InsetGraphics::string2params(grp, params_); + params_.fromString(grp); paramsToDialog(params_); groupCO->blockSignals(false); @@ -755,7 +755,7 @@ bool GuiGraphics::isValid() bool GuiGraphics::initialiseParams(string const & sdata) { params_.setBuffer(&buffer()); - InsetGraphics::string2params(sdata, params_); + params_.fromString(sdata); paramsToDialog(params_); current_group_ = params_.groupId; return true; diff --git a/src/frontends/qt/GuiHyperlink.cpp b/src/frontends/qt/GuiHyperlink.cpp index 468d3dbf3c..6f0971e734 100644 --- a/src/frontends/qt/GuiHyperlink.cpp +++ b/src/frontends/qt/GuiHyperlink.cpp @@ -74,7 +74,8 @@ void GuiHyperlink::paramsToDialog(Inset const * inset) bool GuiHyperlink::initialiseParams(std::string const & sdata) { InsetCommandParams params(insetCode()); - if (!InsetCommand::string2params(sdata, params)) + params.fromString(sdata); + if (sdata.empty()) return false; targetED->setText(toqstr(params["target"])); nameED->setText(toqstr(params["name"])); diff --git a/src/frontends/qt/GuiInclude.cpp b/src/frontends/qt/GuiInclude.cpp index 555db0eeef..f5c2e14baa 100644 --- a/src/frontends/qt/GuiInclude.cpp +++ b/src/frontends/qt/GuiInclude.cpp @@ -383,7 +383,7 @@ QString GuiInclude::browse(QString const & in_name, Type in_type) const bool GuiInclude::initialiseParams(std::string const & sdata) { - InsetCommand::string2params(sdata, params_); + params_.fromString(sdata); paramsToDialog(params_); return true; } diff --git a/src/frontends/qt/GuiIndex.cpp b/src/frontends/qt/GuiIndex.cpp index e23f5793b5..a67a8e9537 100644 --- a/src/frontends/qt/GuiIndex.cpp +++ b/src/frontends/qt/GuiIndex.cpp @@ -79,7 +79,7 @@ void GuiIndex::applyView() bool GuiIndex::initialiseParams(string const & sdata) { - InsetIndex::string2params(sdata, params_); + params_.fromString(sdata); return true; } diff --git a/src/frontends/qt/GuiLabel.cpp b/src/frontends/qt/GuiLabel.cpp index 102a89f1eb..2866a05c4e 100644 --- a/src/frontends/qt/GuiLabel.cpp +++ b/src/frontends/qt/GuiLabel.cpp @@ -61,7 +61,8 @@ docstring GuiLabel::dialogToParams() const bool GuiLabel::initialiseParams(std::string const & sdata) { InsetCommandParams p(insetCode()); - if (!InsetCommand::string2params(sdata, p)) + p.fromString(sdata); + if (sdata.empty()) return false; keywordED->setText(toqstr(p["name"])); return true; diff --git a/src/frontends/qt/GuiListings.cpp b/src/frontends/qt/GuiListings.cpp index 76483de160..74bee17c15 100644 --- a/src/frontends/qt/GuiListings.cpp +++ b/src/frontends/qt/GuiListings.cpp @@ -676,7 +676,7 @@ bool GuiListings::isValid() bool GuiListings::initialiseParams(string const & sdata) { - InsetListings::string2params(sdata, params_); + params_.fromString(sdata); return true; } diff --git a/src/frontends/qt/GuiNomenclature.cpp b/src/frontends/qt/GuiNomenclature.cpp index 0d63f55b1a..a405fc938f 100644 --- a/src/frontends/qt/GuiNomenclature.cpp +++ b/src/frontends/qt/GuiNomenclature.cpp @@ -68,7 +68,8 @@ docstring GuiNomenclature::dialogToParams() const bool GuiNomenclature::initialiseParams(std::string const & sdata) { InsetCommandParams p(insetCode()); - if (!InsetCommand::string2params(sdata, p)) + p.fromString(sdata); + if (sdata.empty()) return false; symbolED->setText(toqstr(p["symbol"])); return true; diff --git a/src/frontends/qt/GuiNote.cpp b/src/frontends/qt/GuiNote.cpp index 480f7b3f12..020e3ea5d4 100644 --- a/src/frontends/qt/GuiNote.cpp +++ b/src/frontends/qt/GuiNote.cpp @@ -73,7 +73,7 @@ void GuiNote::applyView() bool GuiNote::initialiseParams(string const & sdata) { - InsetNote::string2params(sdata, params_); + params_.fromString(sdata); return true; } diff --git a/src/frontends/qt/GuiPhantom.cpp b/src/frontends/qt/GuiPhantom.cpp index bcc8ee6d4f..e51d72e018 100644 --- a/src/frontends/qt/GuiPhantom.cpp +++ b/src/frontends/qt/GuiPhantom.cpp @@ -72,7 +72,7 @@ void GuiPhantom::applyView() bool GuiPhantom::initialiseParams(string const & sdata) { - InsetPhantom::string2params(sdata, params_); + params_.fromString(sdata); return true; } diff --git a/src/frontends/qt/GuiPrintindex.cpp b/src/frontends/qt/GuiPrintindex.cpp index 0607182335..ea77900a7c 100644 --- a/src/frontends/qt/GuiPrintindex.cpp +++ b/src/frontends/qt/GuiPrintindex.cpp @@ -118,7 +118,7 @@ bool GuiPrintindex::initialiseParams(string const & sdata) { // The name passed with LFUN_INSET_APPLY is also the name // used to identify the mailer. - InsetCommand::string2params(sdata, params_); + params_.fromString(sdata); paramsToDialog(params_); return true; } diff --git a/src/frontends/qt/GuiRef.cpp b/src/frontends/qt/GuiRef.cpp index 6686ed73c2..9bf198eb1f 100644 --- a/src/frontends/qt/GuiRef.cpp +++ b/src/frontends/qt/GuiRef.cpp @@ -604,7 +604,7 @@ void GuiRef::resetFilter() bool GuiRef::initialiseParams(std::string const & sdata) { - InsetCommand::string2params(sdata, params_); + params_.fromString(sdata); return true; } diff --git a/src/frontends/qt/GuiWrap.cpp b/src/frontends/qt/GuiWrap.cpp index 8ecacbbe5a..f27cf0b29b 100644 --- a/src/frontends/qt/GuiWrap.cpp +++ b/src/frontends/qt/GuiWrap.cpp @@ -187,7 +187,7 @@ void GuiWrap::paramsToDialog(InsetWrapParams const & params) bool GuiWrap::initialiseParams(string const & sdata) { - InsetWrap::string2params(sdata, params_); + params_.fromString(sdata); paramsToDialog(params_); return true; } diff --git a/src/insets/InsetBibitem.cpp b/src/insets/InsetBibitem.cpp index 82d8185200..f5c9d5b856 100644 --- a/src/insets/InsetBibitem.cpp +++ b/src/insets/InsetBibitem.cpp @@ -125,7 +125,7 @@ void InsetBibitem::doDispatch(Cursor & cur, FuncRequest & cmd) case LFUN_INSET_MODIFY: { InsetCommandParams p(BIBITEM_CODE); - InsetCommand::string2params(to_utf8(cmd.argument()), p); + p.fromString(to_utf8(cmd.argument())); if (p.getCmdName().empty()) { cur.noScreenUpdate(); break; diff --git a/src/insets/InsetBibtex.cpp b/src/insets/InsetBibtex.cpp index 6566c4e521..c17cc8bd13 100644 --- a/src/insets/InsetBibtex.cpp +++ b/src/insets/InsetBibtex.cpp @@ -95,7 +95,8 @@ void InsetBibtex::doDispatch(Cursor & cur, FuncRequest & cmd) case LFUN_INSET_MODIFY: { InsetCommandParams p(BIBTEX_CODE); try { - if (!InsetCommand::string2params(to_utf8(cmd.argument()), p)) { + p.fromString(to_utf8(cmd.argument())); + if (cmd.argument().empty()) { cur.noScreenUpdate(); break; } diff --git a/src/insets/InsetBox.cpp b/src/insets/InsetBox.cpp index 80518c7ddf..a4e94cd477 100644 --- a/src/insets/InsetBox.cpp +++ b/src/insets/InsetBox.cpp @@ -295,7 +295,7 @@ void InsetBox::doDispatch(Cursor & cur, FuncRequest & cmd) params_.inner_box = false; } } else - string2params(to_utf8(cmd.argument()), params_); + params_.fromString(to_utf8(cmd.argument())); setButtonLabel(); break; } @@ -834,7 +834,7 @@ string InsetBox::contextMenuName() const } -void InsetBox::string2params(string const & in, InsetBoxParams & params) +void InsetBoxParams::fromString(string const & in) { if (in.empty()) return; @@ -860,8 +860,7 @@ void InsetBox::string2params(string const & in, InsetBoxParams & params) "Expected arg 2 to be \"Box\"\n"); } - params = InsetBoxParams(string()); - params.read(lex); + read(lex); } diff --git a/src/insets/InsetBox.h b/src/insets/InsetBox.h index 16ebf4a794..0ea790b546 100644 --- a/src/insets/InsetBox.h +++ b/src/insets/InsetBox.h @@ -31,6 +31,8 @@ public: /// void read(Lexer & lex) override; /// + void fromString(std::string const & in) override; + /// std::string name() const override { return "box"; } /// @@ -94,8 +96,6 @@ public: /// InsetBox(Buffer *, std::string const &); - /// - static void string2params(std::string const &, InsetBoxParams &); /// InsetBoxParams const & params() const { return params_; } diff --git a/src/insets/InsetBranch.cpp b/src/insets/InsetBranch.cpp index 80fd56afa2..2fc1b31765 100644 --- a/src/insets/InsetBranch.cpp +++ b/src/insets/InsetBranch.cpp @@ -146,7 +146,7 @@ void InsetBranch::doDispatch(Cursor & cur, FuncRequest & cmd) switch (cmd.action()) { case LFUN_INSET_MODIFY: { InsetBranchParams params; - InsetBranch::string2params(to_utf8(cmd.argument()), params); + params.fromString(to_utf8(cmd.argument())); cur.recordUndoInset(this); params_.branch = params.branch; @@ -387,9 +387,8 @@ bool InsetBranch::isMacroScope() const } -void InsetBranch::string2params(string const & in, InsetBranchParams & params) +void InsetBranchParams::fromString(string const & in) { - params = InsetBranchParams(); if (in.empty()) return; @@ -397,7 +396,7 @@ void InsetBranch::string2params(string const & in, InsetBranchParams & params) Lexer lex; lex.setStream(data); lex.setContext("InsetBranch::string2params"); - params.read(lex); + read(lex); } diff --git a/src/insets/InsetBranch.h b/src/insets/InsetBranch.h index e7b9a50888..c40854d9df 100644 --- a/src/insets/InsetBranch.h +++ b/src/insets/InsetBranch.h @@ -28,6 +28,8 @@ public: /// void read(Lexer & lex) override; /// + void fromString(std::string const & in) override; + /// docstring branch; /// bool inverted; @@ -48,8 +50,6 @@ public: /// InsetBranch(Buffer *, InsetBranchParams const &); - /// - static void string2params(std::string const &, InsetBranchParams &); /// docstring branch() const { return params_.branch; } /// diff --git a/src/insets/InsetCommand.cpp b/src/insets/InsetCommand.cpp index ca79797e96..2365874780 100644 --- a/src/insets/InsetCommand.cpp +++ b/src/insets/InsetCommand.cpp @@ -215,7 +215,7 @@ void InsetCommand::doDispatch(Cursor & cur, FuncRequest & cmd) break; } InsetCommandParams p(p_.code()); - InsetCommand::string2params(to_utf8(cmd.argument()), p); + p.fromString(to_utf8(cmd.argument())); if (p == p_) // no change break; @@ -299,29 +299,6 @@ bool InsetCommand::showInsetDialog(BufferView * bv) const } -bool InsetCommand::string2params(string const & data, - InsetCommandParams & params) -{ - params.clear(); - if (data.empty()) - return false; - // This happens when inset-insert is called without argument except for the - // inset type; ex: - // "inset-insert toc" - string const name = insetName(params.code()); - if (data == name) - return true; - istringstream dstream(data); - Lexer lex; - lex.setStream(dstream); - lex.setContext("InsetCommand::string2params"); - lex >> name.c_str(); // check for name - lex >> "CommandInset"; - params.read(lex); - return true; -} - - bool decodeInsetParam(string const & name, string & data, Buffer const & buffer) { diff --git a/src/insets/InsetCommand.h b/src/insets/InsetCommand.h index a4c66b3d1f..66224123a2 100644 --- a/src/insets/InsetCommand.h +++ b/src/insets/InsetCommand.h @@ -46,10 +46,6 @@ public: InsetCommand * asInsetCommand() override { return this; } /// InsetCommand const * asInsetCommand() const override { return this; } - - /// \return true if params are successfully read - static bool string2params(std::string const & data, - InsetCommandParams &); /// InsetCommandParams const & params() const { return p_; } /// diff --git a/src/insets/InsetCommandParams.cpp b/src/insets/InsetCommandParams.cpp index f74f1ee40c..35b87e327e 100644 --- a/src/insets/InsetCommandParams.cpp +++ b/src/insets/InsetCommandParams.cpp @@ -406,6 +406,27 @@ void InsetCommandParams::Write(ostream & os, Buffer const * buffer) const } +void InsetCommandParams::fromString(string const & data) +{ + clear(); + if (data.empty()) + return; + // This happens when inset-insert is called without argument except for the + // inset type; ex: + // "inset-insert toc" + string const name = insetName(code()); + if (data == name) + return; + istringstream dstream(data); + Lexer lex; + lex.setStream(dstream); + lex.setContext("InsetCommand::string2params"); + lex >> name.c_str(); // check for name + lex >> "CommandInset"; + read(lex); +} + + string InsetCommandParams::name() const { return insetName(code()); diff --git a/src/insets/InsetCommandParams.h b/src/insets/InsetCommandParams.h index cd4d76a6c6..8ef7495f3f 100644 --- a/src/insets/InsetCommandParams.h +++ b/src/insets/InsetCommandParams.h @@ -137,6 +137,8 @@ public: /// void Write(std::ostream & os, Buffer const * buf) const; /// + void fromString(std::string const & in) override; + /// std::string name() const override; bool writeEndInset() const override { return true; } /// Build the complete LaTeX command diff --git a/src/insets/InsetERT.cpp b/src/insets/InsetERT.cpp index f754954466..2a0b863322 100644 --- a/src/insets/InsetERT.cpp +++ b/src/insets/InsetERT.cpp @@ -36,10 +36,19 @@ using namespace lyx::support; namespace lyx { +InsetERT::InsetERT(Buffer * buf, InsetERTParams & params) + : InsetCollapsible(buf) +{ + params_ = params; + status_ = params_.status; +} + + InsetERT::InsetERT(Buffer * buf, CollapseStatus status) : InsetCollapsible(buf) { status_ = status; + params_ = InsetERTParams(status); } @@ -134,7 +143,8 @@ void InsetERT::doDispatch(Cursor & cur, FuncRequest & cmd) case LFUN_INSET_MODIFY: if (cmd.getArg(0) == "ert") { cur.recordUndoInset(this); - setStatus(cur, string2params(to_utf8(cmd.argument()))); + params_.fromString(to_utf8(cmd.argument())); + setStatus(cur, params_.status); break; } //fall-through @@ -177,24 +187,22 @@ docstring const InsetERT::buttonLabel(BufferView const & bv) const } -InsetCollapsible::CollapseStatus InsetERT::string2params(string const & in) +void InsetERTParams::fromString(string const & in) { if (in.empty()) - return Collapsed; + return; istringstream data(in); Lexer lex; lex.setStream(data); lex.setContext("InsetERT::string2params"); lex >> "ert"; - int s; - lex >> s; - return static_cast(s); + read(lex); } void InsetERTParams::write(ostream & os) const { - os << status_; + os << status; } @@ -203,7 +211,7 @@ void InsetERTParams::read(Lexer & lex) lex.setContext("InsetERTParams::read"); int s; lex >> s; - status_ = static_cast(s); + status = static_cast(s); } diff --git a/src/insets/InsetERT.h b/src/insets/InsetERT.h index 6656a99d12..c0649b318f 100644 --- a/src/insets/InsetERT.h +++ b/src/insets/InsetERT.h @@ -22,15 +22,17 @@ struct InsetERTParams : public InsetParams { typedef InsetCollapsible::CollapseStatus CollapseStatus; explicit InsetERTParams(CollapseStatus status = CollapseStatus::Open) - : status_(status) {} + : status(status) {} /// void write(std::ostream & os) const override; /// void read(Lexer & lex) override; /// + void fromString(std::string const & in) override; + /// std::string name() const override { return "ert"; } /// - CollapseStatus status_; + CollapseStatus status; }; @@ -45,12 +47,12 @@ struct InsetERTParams : public InsetParams { class InsetERT : public InsetCollapsible { public: + /// + InsetERT(Buffer *, InsetERTParams & params); /// InsetERT(Buffer *, CollapseStatus status = Open); /// InsetERT(InsetERT const & old); - /// - static CollapseStatus string2params(std::string const &); std::string contextMenuName() const override { return "context-ert"; } @@ -84,6 +86,8 @@ private: bool allowSpellCheck() const override { return false; } /// bool insetAllowed(InsetCode code) const override { return code == QUOTE_CODE; } + + InsetERTParams params_; }; diff --git a/src/insets/InsetExternal.cpp b/src/insets/InsetExternal.cpp index 9dd0fa2690..e9b1553f75 100644 --- a/src/insets/InsetExternal.cpp +++ b/src/insets/InsetExternal.cpp @@ -462,14 +462,14 @@ void InsetExternal::doDispatch(Cursor & cur, FuncRequest & cmd) InsetExternalParams p(params()); p.setBuffer(&buffer()); if (!cmd.argument().empty()) - string2params(to_utf8(cmd.argument()), p); + p.fromString(to_utf8(cmd.argument())); external::editExternal(p, buffer()); break; } case LFUN_INSET_MODIFY: { InsetExternalParams p(&buffer()); - string2params(to_utf8(cmd.argument()), p); + p.fromString(to_utf8(cmd.argument())); cur.recordUndo(); setParams(p); break; @@ -902,9 +902,8 @@ string InsetExternal::contextMenuName() const } -void InsetExternal::string2params(string const & in, InsetExternalParams & params) +void InsetExternalParams::fromString(string const & in) { - params = InsetExternalParams(params.buffer()); if (in.empty()) return; @@ -930,7 +929,7 @@ void InsetExternal::string2params(string const & in, InsetExternalParams & param return; } - params.read(lex); + read(lex); } diff --git a/src/insets/InsetExternal.h b/src/insets/InsetExternal.h index af4c496550..dab11594a1 100644 --- a/src/insets/InsetExternal.h +++ b/src/insets/InsetExternal.h @@ -53,6 +53,7 @@ public: void write(std::ostream &) const override; void read(Lexer &) override; + void fromString(std::string const & in) override; std::string name() const override { return "external"; } bool writeEndInset() const override { return true; } @@ -105,8 +106,6 @@ public: /// ~InsetExternal(); /// - static void string2params(std::string const &, InsetExternalParams &); - /// InsetExternalParams const & params() const; /// void setParams(InsetExternalParams const &); diff --git a/src/insets/InsetFloat.cpp b/src/insets/InsetFloat.cpp index 11b349256f..2cc2d2429b 100644 --- a/src/insets/InsetFloat.cpp +++ b/src/insets/InsetFloat.cpp @@ -124,7 +124,7 @@ namespace lyx { InsetFloat::InsetFloat(Buffer * buf, string const & params_str) : InsetCaptionable(buf) { - string2params(params_str, params_); + params_.fromString(params_str); setCaptionType(params_.type); } @@ -169,7 +169,7 @@ void InsetFloat::doDispatch(Cursor & cur, FuncRequest & cmd) break; } InsetFloatParams params; - string2params(to_utf8(cmd.argument()), params); + params.fromString(to_utf8(cmd.argument())); cur.recordUndoInset(this); // placement, wide and sideways are not used for subfloats @@ -953,9 +953,8 @@ TexString InsetFloat::getCaption(OutputParams const & runparams) const } -void InsetFloat::string2params(string const & in, InsetFloatParams & params) +void InsetFloatParams::fromString(string const & in) { - params = InsetFloatParams(); if (in.empty()) return; @@ -963,7 +962,7 @@ void InsetFloat::string2params(string const & in, InsetFloatParams & params) Lexer lex; lex.setStream(data); lex.setContext("InsetFloat::string2params"); - params.read(lex); + read(lex); } diff --git a/src/insets/InsetFloat.h b/src/insets/InsetFloat.h index 58ac723a0a..7045f74d46 100644 --- a/src/insets/InsetFloat.h +++ b/src/insets/InsetFloat.h @@ -32,6 +32,8 @@ public: /// void read(Lexer & lex) override; /// + void fromString(std::string const & in) override; + /// std::string type; /// std::string placement; @@ -59,8 +61,6 @@ class InsetFloat : public InsetCaptionable public: InsetFloat(Buffer * buffer, std::string const & params_str); /// - static void string2params(std::string const &, InsetFloatParams &); - /// void setWide(bool w, bool update_label = true); /// void setSideways(bool s, bool update_label = true); diff --git a/src/insets/InsetGraphics.cpp b/src/insets/InsetGraphics.cpp index 14f303c1a5..1c898f9015 100644 --- a/src/insets/InsetGraphics.cpp +++ b/src/insets/InsetGraphics.cpp @@ -147,32 +147,6 @@ string findTargetFormat(string const & format, OutputParams const & runparams) return format; } - -void readInsetGraphics(Lexer & lex, bool allowOrigin, InsetGraphicsParams & params) -{ - bool finished = false; - - while (lex.isOK() && !finished) { - lex.next(); - - string const token = lex.getString(); - LYXERR(Debug::GRAPHICS, "Token: '" << token << '\''); - - if (token.empty()) - continue; - - if (token == "\\end_inset") { - finished = true; - } else { - if (!params.read(lex, token, allowOrigin)) - lyxerr << "Unknown token, " - << token - << ", skipping." - << endl; - } - } -} - } // namespace @@ -212,7 +186,7 @@ void InsetGraphics::doDispatch(Cursor & cur, FuncRequest & cmd) InsetGraphicsParams p(params()); p.setBuffer(&buffer()); if (!cmd.argument().empty()) - string2params(to_utf8(cmd.argument()), p); + p.fromString(to_utf8(cmd.argument())); editGraphics(p); break; } @@ -224,7 +198,7 @@ void InsetGraphics::doDispatch(Cursor & cur, FuncRequest & cmd) } InsetGraphicsParams p(&buffer()); - string2params(to_utf8(cmd.argument()), p); + p.fromString(to_utf8(cmd.argument())); if (p.filename.empty()) { cur.noScreenUpdate(); break; @@ -1163,21 +1137,6 @@ string InsetGraphics::contextMenuName() const } -void InsetGraphics::string2params(string const & in, InsetGraphicsParams & params) -{ - if (in.empty()) - return; - - istringstream data(in); - Lexer lex; - lex.setStream(data); - lex.setContext("InsetGraphics::string2params"); - lex >> "graphics"; - params = InsetGraphicsParams(params.buffer()); - readInsetGraphics(lex, false, params); -} - - docstring InsetGraphics::toolTip(BufferView const &, int, int) const { return from_utf8(params().filename.onlyFileName()); @@ -1237,7 +1196,7 @@ string getGroupParams(Buffer const & b, string const & groupId) void unifyGraphicsGroups(Buffer & b, string const & argument) { InsetGraphicsParams params(&b); - InsetGraphics::string2params(argument, params); + params.fromString(argument); // This handles undo groups automagically UndoGroupHelper ugh(&b); diff --git a/src/insets/InsetGraphics.h b/src/insets/InsetGraphics.h index a597ca31e9..11fcfabc73 100644 --- a/src/insets/InsetGraphics.h +++ b/src/insets/InsetGraphics.h @@ -38,10 +38,6 @@ public: /// ~InsetGraphics(); - /// - static void string2params(std::string const & data, - InsetGraphicsParams &); - /** Set the inset parameters, used by the GUIndependent dialog. Return true of new params are different from what was so far. */ diff --git a/src/insets/InsetGraphicsParams.cpp b/src/insets/InsetGraphicsParams.cpp index 60db34490e..077320c4e5 100644 --- a/src/insets/InsetGraphicsParams.cpp +++ b/src/insets/InsetGraphicsParams.cpp @@ -36,6 +36,32 @@ using namespace lyx::support; namespace lyx { +void readInsetGraphics(Lexer & lex, bool allowOrigin, InsetGraphicsParams & params) +{ + bool finished = false; + + while (lex.isOK() && !finished) { + lex.next(); + + string const token = lex.getString(); + LYXERR(Debug::GRAPHICS, "Token: '" << token << '\''); + + if (token.empty()) + continue; + + if (token == "\\end_inset") { + finished = true; + } else { + if (!params.read(lex, token, allowOrigin)) + lyxerr << "Unknown token, " + << token + << ", skipping." + << endl; + } + } +} + + InsetGraphicsParams::InsetGraphicsParams(Buffer const * b) { init(b); @@ -260,6 +286,20 @@ void InsetGraphicsParams::read(Lexer & lex) } +void InsetGraphicsParams::fromString(string const & in) +{ + if (in.empty()) + return; + + istringstream data(in); + Lexer lex; + lex.setStream(data); + lex.setContext("InsetGraphics::string2params"); + lex >> "graphics"; + readInsetGraphics(lex, false, *this); +} + + graphics::Params InsetGraphicsParams::as_grfxParams() const { graphics::Params pars; diff --git a/src/insets/InsetGraphicsParams.h b/src/insets/InsetGraphicsParams.h index 2315459edf..25188baad2 100644 --- a/src/insets/InsetGraphicsParams.h +++ b/src/insets/InsetGraphicsParams.h @@ -83,6 +83,8 @@ public: bool read(Lexer & lex, std::string const & token, bool allowOrigin); void read(Lexer & lex) override; /// + void fromString(std::string const & in) override; + /// std::string name() const override { return "graphics"; } /// bool writeEndInset() const override { return true; } @@ -111,6 +113,8 @@ bool operator==(InsetGraphicsParams const &, InsetGraphicsParams const &); /// bool operator!=(InsetGraphicsParams const &, InsetGraphicsParams const &); +void readInsetGraphics(Lexer & lex, bool allowOrigin, InsetGraphicsParams & params); + } // namespace lyx #endif diff --git a/src/insets/InsetIPAMacro.cpp b/src/insets/InsetIPAMacro.cpp index d908349fc8..0cb1a5ff06 100644 --- a/src/insets/InsetIPAMacro.cpp +++ b/src/insets/InsetIPAMacro.cpp @@ -340,10 +340,8 @@ docstring InsetIPADeco::toolTip(BufferView const &, int, int) const } -void InsetIPADeco::string2params(string const & in, InsetIPADecoParams & params) +void InsetIPADecoParams::fromString(string const & in) { - params = InsetIPADecoParams(); - if (in.empty()) return; @@ -353,7 +351,7 @@ void InsetIPADeco::string2params(string const & in, InsetIPADecoParams & params) lex.setContext("InsetIPADeco::string2params"); lex >> "IPADeco" >> "toptiebar"; - params.read(lex); + read(lex); } diff --git a/src/insets/InsetIPAMacro.h b/src/insets/InsetIPAMacro.h index 6627539319..69adde8401 100644 --- a/src/insets/InsetIPAMacro.h +++ b/src/insets/InsetIPAMacro.h @@ -35,6 +35,8 @@ public: /// void read(Lexer & lex) override; /// + void fromString(std::string const & in) override; + /// std::string name() const override { return "IPADeco"; } /// Type type; @@ -55,8 +57,6 @@ public: /// ~InsetIPADeco(); /// - static void string2params(std::string const &, InsetIPADecoParams &); - /// InsetIPADecoParams const & params() const { return params_; } private: /// diff --git a/src/insets/InsetInclude.cpp b/src/insets/InsetInclude.cpp index f480c0dffa..5f90ed0efe 100644 --- a/src/insets/InsetInclude.cpp +++ b/src/insets/InsetInclude.cpp @@ -275,7 +275,7 @@ void InsetInclude::doDispatch(Cursor & cur, FuncRequest & cmd) InsetCommand::doDispatch(cur, cmd); p = params(); } else - InsetCommand::string2params(to_utf8(cmd.argument()), p); + p.fromString(to_utf8(cmd.argument())); if (!p.getCmdName().empty()) { if (isListings(p)){ InsetListingsParams new_params(to_utf8(p["lstparams"])); diff --git a/src/insets/InsetIndex.cpp b/src/insets/InsetIndex.cpp index c076700ad9..a55f239d83 100644 --- a/src/insets/InsetIndex.cpp +++ b/src/insets/InsetIndex.cpp @@ -401,7 +401,7 @@ void InsetIndex::doDispatch(Cursor & cur, FuncRequest & cmd) break; } InsetIndexParams params; - InsetIndex::string2params(to_utf8(cmd.argument()), params); + params.fromString(to_utf8(cmd.argument())); cur.recordUndoInset(this); params_.index = params.index; // what we really want here is a TOC update, but that means @@ -520,9 +520,8 @@ void InsetIndex::read(Lexer & lex) } -void InsetIndex::string2params(string const & in, InsetIndexParams & params) +void InsetIndexParams::fromString(string const & in) { - params = InsetIndexParams(); if (in.empty()) return; @@ -531,7 +530,7 @@ void InsetIndex::string2params(string const & in, InsetIndexParams & params) lex.setStream(data); lex.setContext("InsetIndex::string2params"); lex >> "index"; - params.read(lex); + read(lex); } @@ -685,7 +684,7 @@ void InsetPrintIndex::doDispatch(Cursor & cur, FuncRequest & cmd) } InsetCommandParams p(INDEX_PRINT_CODE); // FIXME UNICODE - InsetCommand::string2params(to_utf8(cmd.argument()), p); + p.fromString(to_utf8(cmd.argument())); if (p.getCmdName().empty()) { cur.noScreenUpdate(); break; @@ -719,7 +718,7 @@ bool InsetPrintIndex::getStatus(Cursor & cur, FuncRequest const & cmd, } if (cmd.getArg(0) == "index_print" && cmd.getArg(1) == "CommandInset") { InsetCommandParams p(INDEX_PRINT_CODE); - InsetCommand::string2params(to_utf8(cmd.argument()), p); + p.fromString(to_utf8(cmd.argument())); if (suffixIs(p.getCmdName(), '*')) { status.setEnabled(true); status.setOnOff(false); diff --git a/src/insets/InsetIndex.h b/src/insets/InsetIndex.h index 7c0cb60753..840df7a7d1 100644 --- a/src/insets/InsetIndex.h +++ b/src/insets/InsetIndex.h @@ -29,6 +29,8 @@ public: /// void read(Lexer & lex) override; /// + void fromString(std::string const & in) override; + /// std::string name() const override { return "index"; } docstring index; @@ -41,8 +43,6 @@ class InsetIndex : public InsetCollapsible { public: /// InsetIndex(Buffer *, InsetIndexParams const &); - /// - static void string2params(std::string const &, InsetIndexParams &); private: /// bool hasSettings() const override; diff --git a/src/insets/InsetLabel.cpp b/src/insets/InsetLabel.cpp index 910c08682c..36a30eaf35 100644 --- a/src/insets/InsetLabel.cpp +++ b/src/insets/InsetLabel.cpp @@ -270,7 +270,7 @@ void InsetLabel::doDispatch(Cursor & cur, FuncRequest & cmd) } InsetCommandParams p(LABEL_CODE); // FIXME UNICODE - InsetCommand::string2params(to_utf8(cmd.argument()), p); + p.fromString(to_utf8(cmd.argument())); if (p.getCmdName().empty()) { cur.noScreenUpdate(); break; diff --git a/src/insets/InsetLine.cpp b/src/insets/InsetLine.cpp index cb0a074738..e92871a270 100644 --- a/src/insets/InsetLine.cpp +++ b/src/insets/InsetLine.cpp @@ -75,7 +75,7 @@ void InsetLine::doDispatch(Cursor & cur, FuncRequest & cmd) case LFUN_INSET_MODIFY: { InsetCommandParams p(LINE_CODE); // FIXME UNICODE - InsetCommand::string2params(to_utf8(cmd.argument()), p); + p.fromString(to_utf8(cmd.argument())); if (p.getCmdName().empty()) { cur.noScreenUpdate(); break; diff --git a/src/insets/InsetListings.cpp b/src/insets/InsetListings.cpp index c99e4c512d..ca961072ff 100644 --- a/src/insets/InsetListings.cpp +++ b/src/insets/InsetListings.cpp @@ -564,7 +564,7 @@ void InsetListings::doDispatch(Cursor & cur, FuncRequest & cmd) case LFUN_INSET_MODIFY: { cur.recordUndoInset(this); - InsetListings::string2params(to_utf8(cmd.argument()), params()); + params_.fromString(to_utf8(cmd.argument())); break; } @@ -685,19 +685,4 @@ TexString InsetListings::getCaption(OutputParams const & runparams) const } -void InsetListings::string2params(string const & in, - InsetListingsParams & params) -{ - params = InsetListingsParams(); - if (in.empty()) - return; - istringstream data(in); - Lexer lex; - lex.setStream(data); - // discard "listings", which is only used to determine inset - lex.next(); - params.read(lex); -} - - } // namespace lyx diff --git a/src/insets/InsetListings.h b/src/insets/InsetListings.h index cc65ef14a6..cc875219d8 100644 --- a/src/insets/InsetListings.h +++ b/src/insets/InsetListings.h @@ -34,8 +34,6 @@ public: InsetListings(Buffer *, InsetListingsParams const & par = InsetListingsParams()); /// ~InsetListings(); - /// - static void string2params(std::string const &, InsetListingsParams &); private: /// bool isLabeled() const override { return true; } diff --git a/src/insets/InsetListingsParams.cpp b/src/insets/InsetListingsParams.cpp index 8ffb438797..40eb5e77ae 100644 --- a/src/insets/InsetListingsParams.cpp +++ b/src/insets/InsetListingsParams.cpp @@ -1006,6 +1006,19 @@ void InsetListingsParams::read(Lexer & lex) } +void InsetListingsParams::fromString(string const & in) +{ + if (in.empty()) + return; + istringstream data(in); + Lexer lex; + lex.setStream(data); + // discard "listings", which is only used to determine inset + lex.next(); + read(lex); +} + + string InsetListingsParams::params(string const & sep) const { string par; diff --git a/src/insets/InsetListingsParams.h b/src/insets/InsetListingsParams.h index f2d43733e7..5755c868ed 100644 --- a/src/insets/InsetListingsParams.h +++ b/src/insets/InsetListingsParams.h @@ -33,6 +33,9 @@ public: /// read parameters from an ostream void read(Lexer &) override; + /// + void fromString(std::string const & in) override; + /// std::string name() const override { return "listings"; } diff --git a/src/insets/InsetNewline.cpp b/src/insets/InsetNewline.cpp index b7c83cb5bd..b2062fcd02 100644 --- a/src/insets/InsetNewline.cpp +++ b/src/insets/InsetNewline.cpp @@ -96,7 +96,7 @@ void InsetNewline::doDispatch(Cursor & cur, FuncRequest & cmd) case LFUN_INSET_MODIFY: { InsetNewlineParams params; cur.recordUndo(); - string2params(to_utf8(cmd.argument()), params); + params.fromString(to_utf8(cmd.argument())); params_.kind = params.kind; break; } @@ -116,7 +116,7 @@ bool InsetNewline::getStatus(Cursor & cur, FuncRequest const & cmd, case LFUN_INSET_MODIFY: if (cmd.getArg(0) == "newline") { InsetNewlineParams params; - string2params(to_utf8(cmd.argument()), params); + params.fromString(to_utf8(cmd.argument())); status.setOnOff(params_.kind == params.kind); } status.setEnabled(true); @@ -267,9 +267,8 @@ string InsetNewline::contextMenuName() const } -void InsetNewline::string2params(string const & in, InsetNewlineParams & params) +void InsetNewlineParams::fromString(string const & in) { - params = InsetNewlineParams(); if (in.empty()) return; istringstream data(in); @@ -277,7 +276,7 @@ void InsetNewline::string2params(string const & in, InsetNewlineParams & params) lex.setStream(data); lex.setContext("InsetNewline::string2params"); lex >> "newline"; - params.read(lex); + read(lex); } diff --git a/src/insets/InsetNewline.h b/src/insets/InsetNewline.h index 9b57e772c3..cbea8bc6c6 100644 --- a/src/insets/InsetNewline.h +++ b/src/insets/InsetNewline.h @@ -34,6 +34,8 @@ public: /// void read(Lexer & lex) override; /// + void fromString(std::string const & in) override; + /// std::string name() const override { return "newline"; } /// Kind kind; @@ -50,8 +52,6 @@ public: { params_.kind = par.kind; } /// RowFlags rowFlags() const override { return BreakAfter | RowAfter; } - /// - static void string2params(std::string const &, InsetNewlineParams &); private: /// InsetCode lyxCode() const override { return NEWLINE_CODE; } diff --git a/src/insets/InsetNewpage.cpp b/src/insets/InsetNewpage.cpp index 6a33b8469f..2ffb2bf4ad 100644 --- a/src/insets/InsetNewpage.cpp +++ b/src/insets/InsetNewpage.cpp @@ -201,7 +201,7 @@ void InsetNewpage::doDispatch(Cursor & cur, FuncRequest & cmd) case LFUN_INSET_MODIFY: { InsetNewpageParams params; cur.recordUndo(); - string2params(to_utf8(cmd.argument()), params); + params.fromString(to_utf8(cmd.argument())); params_.kind = params.kind; break; } @@ -221,7 +221,7 @@ bool InsetNewpage::getStatus(Cursor & cur, FuncRequest const & cmd, case LFUN_INSET_MODIFY: if (cmd.getArg(0) == "newpage") { InsetNewpageParams params; - string2params(to_utf8(cmd.argument()), params); + params.fromString(to_utf8(cmd.argument())); status.setOnOff(params_.kind == params.kind); } status.setEnabled(true); @@ -330,9 +330,8 @@ string InsetNewpage::contextMenuName() const } -void InsetNewpage::string2params(string const & in, InsetNewpageParams & params) +void InsetNewpageParams::fromString(string const & in) { - params = InsetNewpageParams(); if (in.empty()) return; @@ -347,7 +346,7 @@ void InsetNewpage::string2params(string const & in, InsetNewpageParams & params) return; } - params.read(lex); + read(lex); } diff --git a/src/insets/InsetNewpage.h b/src/insets/InsetNewpage.h index 72038e5ffe..757a6ce039 100644 --- a/src/insets/InsetNewpage.h +++ b/src/insets/InsetNewpage.h @@ -40,6 +40,8 @@ public: /// void read(Lexer & lex) override; /// + void fromString(std::string const & in) override; + /// std::string name() const override { return "newpage"; } /// Kind kind; @@ -53,8 +55,6 @@ public: InsetNewpage(); /// explicit InsetNewpage(InsetNewpageParams const & par); - /// - static void string2params(std::string const &, InsetNewpageParams &); private: /// InsetCode lyxCode() const override { return NEWPAGE_CODE; } diff --git a/src/insets/InsetNomencl.cpp b/src/insets/InsetNomencl.cpp index 1d77826602..5f9b9ccfe7 100644 --- a/src/insets/InsetNomencl.cpp +++ b/src/insets/InsetNomencl.cpp @@ -265,7 +265,7 @@ void InsetPrintNomencl::doDispatch(Cursor & cur, FuncRequest & cmd) case LFUN_INSET_MODIFY: { InsetCommandParams p(NOMENCL_PRINT_CODE); // FIXME UNICODE - InsetCommand::string2params(to_utf8(cmd.argument()), p); + p.fromString(to_utf8(cmd.argument())); if (p.getCmdName().empty()) { cur.noScreenUpdate(); break; diff --git a/src/insets/InsetNote.cpp b/src/insets/InsetNote.cpp index b0afd7d282..edc756919d 100644 --- a/src/insets/InsetNote.cpp +++ b/src/insets/InsetNote.cpp @@ -147,12 +147,12 @@ void InsetNote::doDispatch(Cursor & cur, FuncRequest & cmd) // In the future, we might want to have a radio button for // switching between notes. InsetNoteParams params; - string2params(to_utf8(cmd.argument()), params); + params.fromString(to_utf8(cmd.argument())); if (params_.type == params.type) break; cur.recordUndoInset(this); - string2params(to_utf8(cmd.argument()), params_); + params_.fromString(to_utf8(cmd.argument())); setButtonLabel(); // what we really want here is a TOC update, but that means // a full buffer update @@ -179,7 +179,7 @@ bool InsetNote::getStatus(Cursor & cur, FuncRequest const & cmd, case LFUN_INSET_MODIFY: if (cmd.getArg(0) == "note") { InsetNoteParams params; - string2params(to_utf8(cmd.argument()), params); + params.fromString(to_utf8(cmd.argument())); flag.setOnOff(params_.type == params.type); } return true; @@ -338,10 +338,8 @@ FontInfo InsetNote::getFont() const } -void InsetNote::string2params(string const & in, InsetNoteParams & params) +void InsetNoteParams::fromString(string const & in) { - params = InsetNoteParams(); - if (in.empty()) return; @@ -357,7 +355,7 @@ void InsetNote::string2params(string const & in, InsetNoteParams & params) return; lex >> "Note"; - params.read(lex); + read(lex); } diff --git a/src/insets/InsetNote.h b/src/insets/InsetNote.h index dca27d0d6a..575acab227 100644 --- a/src/insets/InsetNote.h +++ b/src/insets/InsetNote.h @@ -32,6 +32,8 @@ public: /// void read(Lexer & lex) override; /// + void fromString(std::string const & in) override; + /// std::string name() const override { return "note"; } Type type; @@ -53,8 +55,6 @@ public: /// ~InsetNote(); /// - static void string2params(std::string const &, InsetNoteParams &); - /// InsetNoteParams const & params() const { return params_; } private: /// diff --git a/src/insets/InsetParams.cpp b/src/insets/InsetParams.cpp index d5b2849be0..1ad3ae9868 100644 --- a/src/insets/InsetParams.cpp +++ b/src/insets/InsetParams.cpp @@ -30,4 +30,8 @@ string InsetParams::toString() const } +//void InsetParams::fromString(string const & in) +//{} + + } // namespace lyx diff --git a/src/insets/InsetParams.h b/src/insets/InsetParams.h index c6709b4de5..9348eadef9 100644 --- a/src/insets/InsetParams.h +++ b/src/insets/InsetParams.h @@ -31,6 +31,8 @@ public: virtual void read(Lexer & lex) = 0; /// std::string toString() const; + /// + virtual void fromString(std::string const & in) = 0; protected: virtual std::string name() const { return std::string(); } virtual bool writeEndInset() const { return false; } diff --git a/src/insets/InsetPhantom.cpp b/src/insets/InsetPhantom.cpp index 4a40a4238c..c3300991cc 100644 --- a/src/insets/InsetPhantom.cpp +++ b/src/insets/InsetPhantom.cpp @@ -250,7 +250,7 @@ void InsetPhantom::doDispatch(Cursor & cur, FuncRequest & cmd) case LFUN_INSET_MODIFY: cur.recordUndoInset(this); - string2params(to_utf8(cmd.argument()), params_); + params_.fromString(to_utf8(cmd.argument())); setButtonLabel(); cur.forceBufferUpdate(); break; @@ -274,7 +274,7 @@ bool InsetPhantom::getStatus(Cursor & cur, FuncRequest const & cmd, case LFUN_INSET_MODIFY: if (cmd.getArg(0) == "phantom") { InsetPhantomParams params; - string2params(to_utf8(cmd.argument()), params); + params.fromString(to_utf8(cmd.argument())); flag.setOnOff(params_.type == params.type); } flag.setEnabled(true); @@ -362,10 +362,8 @@ string InsetPhantom::contextMenuName() const } -void InsetPhantom::string2params(string const & in, InsetPhantomParams & params) +void InsetPhantomParams::fromString(string const & in) { - params = InsetPhantomParams(); - if (in.empty()) return; @@ -375,7 +373,7 @@ void InsetPhantom::string2params(string const & in, InsetPhantomParams & params) lex.setContext("InsetPhantom::string2params"); lex >> "phantom" >> "Phantom"; - params.read(lex); + read(lex); } diff --git a/src/insets/InsetPhantom.h b/src/insets/InsetPhantom.h index ebfe747c3f..7a8b136a8a 100644 --- a/src/insets/InsetPhantom.h +++ b/src/insets/InsetPhantom.h @@ -32,6 +32,8 @@ public: /// void read(Lexer & lex) override; /// + void fromString(std::string const & in) override; + /// std::string name() const override { return "phantom"; } Type type; }; @@ -52,8 +54,6 @@ public: /// ~InsetPhantom(); /// - static void string2params(std::string const &, InsetPhantomParams &); - /// InsetPhantomParams const & params() const { return params_; } private: /// diff --git a/src/insets/InsetScript.cpp b/src/insets/InsetScript.cpp index 4eb10fc2c3..2837d195a4 100644 --- a/src/insets/InsetScript.cpp +++ b/src/insets/InsetScript.cpp @@ -212,7 +212,7 @@ void InsetScript::doDispatch(Cursor & cur, FuncRequest & cmd) switch (cmd.action()) { case LFUN_INSET_MODIFY: cur.recordUndoInset(this); - string2params(to_utf8(cmd.argument()), params_); + params_.fromString(to_utf8(cmd.argument())); break; default: InsetText::doDispatch(cur, cmd); @@ -378,10 +378,8 @@ string InsetScript::contextMenuName() const } -void InsetScript::string2params(string const & in, InsetScriptParams & params) +void InsetScriptParams::fromString(string const & in) { - params = InsetScriptParams(); - if (in.empty()) return; @@ -391,7 +389,7 @@ void InsetScript::string2params(string const & in, InsetScriptParams & params) lex.setContext("InsetScript::string2params"); lex >> "script" >> "script"; - params.read(lex); + read(lex); } diff --git a/src/insets/InsetScript.h b/src/insets/InsetScript.h index 612dcb025e..900f7906be 100644 --- a/src/insets/InsetScript.h +++ b/src/insets/InsetScript.h @@ -32,6 +32,8 @@ public: /// void read(Lexer & lex) override; /// + void fromString(std::string const & in) override; + /// std::string name() const override { return "script"; } /// int shift(FontInfo const & font) const; @@ -57,8 +59,6 @@ public: /// ~InsetScript(); /// - static void string2params(std::string const &, InsetScriptParams &); - /// InsetScriptParams const & params() const { return params_; } /// \name Public functions inherited from Inset class diff --git a/src/insets/InsetSeparator.cpp b/src/insets/InsetSeparator.cpp index fdfd4157c8..de07cd5403 100644 --- a/src/insets/InsetSeparator.cpp +++ b/src/insets/InsetSeparator.cpp @@ -97,7 +97,7 @@ void InsetSeparator::doDispatch(Cursor & cur, FuncRequest & cmd) case LFUN_INSET_MODIFY: { InsetSeparatorParams params; cur.recordUndo(); - string2params(to_utf8(cmd.argument()), params); + params.fromString(to_utf8(cmd.argument())); params_.kind = params.kind; break; } @@ -118,7 +118,7 @@ bool InsetSeparator::getStatus(Cursor & cur, FuncRequest const & cmd, if (cmd.getArg(0) != "separator") break; InsetSeparatorParams params; - string2params(to_utf8(cmd.argument()), params); + params.fromString(to_utf8(cmd.argument())); status.setOnOff(params_.kind == params.kind); status.setEnabled(true); return true; @@ -288,9 +288,8 @@ string InsetSeparator::contextMenuName() const } -void InsetSeparator::string2params(string const & in, InsetSeparatorParams & params) +void InsetSeparatorParams::fromString(string const & in) { - params = InsetSeparatorParams(); if (in.empty()) return; istringstream data(in); @@ -298,7 +297,7 @@ void InsetSeparator::string2params(string const & in, InsetSeparatorParams & par lex.setStream(data); lex.setContext("InsetSeparator::string2params"); lex >> "separator"; - params.read(lex); + read(lex); } diff --git a/src/insets/InsetSeparator.h b/src/insets/InsetSeparator.h index cf6861f211..e9937911cd 100644 --- a/src/insets/InsetSeparator.h +++ b/src/insets/InsetSeparator.h @@ -33,6 +33,8 @@ public: /// void read(Lexer & lex) override; /// + void fromString(std::string const & in) override; + /// std::string name() const override { return "separator"; } Kind kind; @@ -46,8 +48,6 @@ public: InsetSeparator(); /// explicit InsetSeparator(InsetSeparatorParams const & params); - /// - static void string2params(std::string const &, InsetSeparatorParams &); /// To be used in combination with inset-forall /// Here's a command that removes every latexpar separator: /// inset-forall Separator:latexpar char-delete-forward diff --git a/src/insets/InsetSpace.cpp b/src/insets/InsetSpace.cpp index a9f4dc73c6..343991c620 100644 --- a/src/insets/InsetSpace.cpp +++ b/src/insets/InsetSpace.cpp @@ -153,7 +153,7 @@ void InsetSpace::doDispatch(Cursor & cur, FuncRequest & cmd) arg += params_.length.len().empty() ? " \\length 1" + string(stringFromUnit(Length::defaultUnit())) : " \\length " + params_.length.asString(); - string2params(arg, params_); + params_.fromString(arg); break; } @@ -176,7 +176,7 @@ bool InsetSpace::getStatus(Cursor & cur, FuncRequest const & cmd, case LFUN_INSET_MODIFY: if (cmd.getArg(0) == "space") { InsetSpaceParams params; - string2params(to_utf8(cmd.argument()), params); + params.fromString(to_utf8(cmd.argument())); status.setOnOff(params_.kind == params.kind); status.setEnabled(true); } else @@ -918,9 +918,8 @@ string InsetSpace::contextMenuName() const } -void InsetSpace::string2params(string const & in, InsetSpaceParams & params) +void InsetSpaceParams::fromString(string const & in) { - params = InsetSpaceParams(); if (in.empty()) return; @@ -931,9 +930,9 @@ void InsetSpace::string2params(string const & in, InsetSpaceParams & params) lex.next(); string const name = lex.getString(); if (name == "mathspace") - params.math = true; + math = true; else { - params.math = false; + math = false; // we can try to read this even if the name is wrong LATTEST(name == "space"); } @@ -942,7 +941,7 @@ void InsetSpace::string2params(string const & in, InsetSpaceParams & params) // Dialog::canApply(), where we are just called with "space" rather // than a full "space \type{}\n\\end_inset". if (lex.isOK()) - params.read(lex); + read(lex); } diff --git a/src/insets/InsetSpace.h b/src/insets/InsetSpace.h index 98948704a4..dadfe9302a 100644 --- a/src/insets/InsetSpace.h +++ b/src/insets/InsetSpace.h @@ -81,6 +81,8 @@ struct InsetSpaceParams : public InsetParams { /// void read(Lexer & lex) override; /// + void fromString(std::string const & in) override; + /// std::string name() const override { return math ? "mathspace" : "space"; } /// Kind kind; @@ -107,8 +109,6 @@ public: /// InsetSpaceParams::Kind kind() const; - /// - static void string2params(std::string const &, InsetSpaceParams &); /// GlueLength length() const; diff --git a/src/insets/InsetVSpace.cpp b/src/insets/InsetVSpace.cpp index 7174430c1e..e7fa955931 100644 --- a/src/insets/InsetVSpace.cpp +++ b/src/insets/InsetVSpace.cpp @@ -48,8 +48,8 @@ int const ADD_TO_VSPACE_WIDTH = 5; } // namespace -InsetVSpace::InsetVSpace(VSpace const & space) - : Inset(nullptr), space_(space) +InsetVSpace::InsetVSpace(InsetVSpaceParams const & params) + : Inset(nullptr), params_(params) {} @@ -61,10 +61,10 @@ void InsetVSpace::doDispatch(Cursor & cur, FuncRequest & cmd) cur.recordUndo(); string arg = to_utf8(cmd.argument()); if (arg == "vspace custom") - arg = (space_.kind() == VSpace::LENGTH) - ? "vspace " + space_.length().asString() + arg = (params_.space.kind() == VSpace::LENGTH) + ? "vspace " + params_.space.length().asString() : "vspace 1" + string(stringFromUnit(Length::defaultUnit())); - InsetVSpace::string2params(arg, space_); + params_.fromString(arg); break; } @@ -82,14 +82,14 @@ bool InsetVSpace::getStatus(Cursor & cur, FuncRequest const & cmd, // we handle these case LFUN_INSET_MODIFY: if (cmd.getArg(0) == "vspace") { - VSpace vspace; + InsetVSpaceParams params; string arg = to_utf8(cmd.argument()); if (arg == "vspace custom") - arg = (space_.kind() == VSpace::LENGTH) - ? "vspace " + space_.length().asString() + arg = (params_.space.kind() == VSpace::LENGTH) + ? "vspace " + params_.space.length().asString() : "vspace 1" + string(stringFromUnit(Length::defaultUnit())); - InsetVSpace::string2params(arg, vspace); - status.setOnOff(vspace == space_); + params.fromString(arg); + status.setOnOff(params.space == params_.space); } status.setEnabled(true); return true; @@ -106,21 +106,21 @@ void InsetVSpace::read(Lexer & lex) string vsp; lex >> vsp; if (lex) - space_ = VSpace(vsp); + params_.space = VSpace(vsp); lex >> "\\end_inset"; } void InsetVSpace::write(ostream & os) const { - os << "VSpace " << space_.asLyXCommand(); + os << "VSpace " << params_.space.asLyXCommand(); } docstring const InsetVSpace::label() const { static docstring const label = _("Vertical Space"); - return label + " (" + space_.asGUIName() + ')'; + return label + " (" + params_.space.asGUIName() + ')'; } @@ -132,8 +132,8 @@ int const vspace_arrow_size = 4; void InsetVSpace::metrics(MetricsInfo & mi, Dimension & dim) const { int height = 3 * vspace_arrow_size; - if (space_.length().len().value() >= 0.0) - height = max(height, space_.inPixels(*mi.base.bv)); + if (params_.space.length().len().value() >= 0.0) + height = max(height, params_.space.inPixels(*mi.base.bv)); FontInfo font; font.decSize(); @@ -164,13 +164,13 @@ void InsetVSpace::draw(PainterInfo & pi, int x, int y) const // y-values for bottom arrow int by1, by2; - if (space_.kind() == VSpace::VFILL) { + if (params_.space.kind() == VSpace::VFILL) { ty1 = ty2 = start; by1 = by2 = end; } else { // adding or removing space - bool const added = space_.kind() != VSpace::LENGTH || - space_.length().len().value() >= 0.0; + bool const added = params_.space.kind() != VSpace::LENGTH || + params_.space.length().len().value() >= 0.0; ty1 = added ? (start + vspace_arrow_size) : start; ty2 = added ? start : (start + vspace_arrow_size); by1 = added ? (end - vspace_arrow_size) : end; @@ -211,7 +211,7 @@ void InsetVSpace::draw(PainterInfo & pi, int x, int y) const void InsetVSpace::latex(otexstream & os, OutputParams const &) const { - os << from_ascii(space_.asLatexCommand(buffer().params())) << '\n'; + os << from_ascii(params_.space.asLatexCommand(buffer().params())) << '\n'; } @@ -231,7 +231,7 @@ void InsetVSpace::docbook(XMLStream & xs, OutputParams const &) const docstring InsetVSpace::xhtml(XMLStream & os, OutputParams const &) const { - string const len = space_.asHTMLLength(); + string const len = params_.space.asHTMLLength(); string const attr = "style='height:" + (len.empty() ? "1em" : len) + "'"; os << xml::StartTag("div", attr, true) << xml::EndTag("div"); return docstring(); @@ -244,9 +244,8 @@ string InsetVSpace::contextMenuName() const } -void InsetVSpace::string2params(string const & in, VSpace & vspace) +void InsetVSpaceParams::fromString(string const & in) { - vspace = VSpace(); if (in.empty()) return; @@ -254,20 +253,20 @@ void InsetVSpace::string2params(string const & in, VSpace & vspace) Lexer lex; lex.setStream(data); lex.setContext("InsetVSpace::string2params"); - lex >> "vspace" >> vspace; + lex >> "vspace" >> space; } void InsetVSpaceParams::write(ostream & os) const { - os << space_.asLyXCommand(); + os << space.asLyXCommand(); } void InsetVSpaceParams::read(Lexer & lex) { lex.setContext("InsetVSpaceParams::read"); - lex >> space_; + lex >> space; } diff --git a/src/insets/InsetVSpace.h b/src/insets/InsetVSpace.h index 55b31d6904..ac0508e5c4 100644 --- a/src/insets/InsetVSpace.h +++ b/src/insets/InsetVSpace.h @@ -21,15 +21,17 @@ namespace lyx { struct InsetVSpaceParams : public InsetParams { explicit InsetVSpaceParams(VSpace const & space = VSpace()) - : space_(space) {} + : space(space) {} /// void write(std::ostream & os) const override; /// void read(Lexer & lex) override; /// + void fromString(std::string const & in) override; + /// std::string name() const override { return "vspace"; } /// - VSpace space_; + VSpace space; }; @@ -39,9 +41,9 @@ public: /// InsetVSpace() : Inset(0) {} /// - explicit InsetVSpace(VSpace const &); + explicit InsetVSpace(InsetVSpaceParams const &); /// How much? - VSpace const & space() const { return space_; } + VSpace const & space() const { return params_.space; } /// InsetCode lyxCode() const override { return VSPACE_CODE; } /// @@ -50,8 +52,6 @@ public: bool clickable(BufferView const &, int, int) const override { return true; } /// std::string contextMenuName() const override; - /// - static void string2params(std::string const &, VSpace &); private: /// void metrics(MetricsInfo & mi, Dimension & dim) const override; @@ -86,7 +86,7 @@ private: docstring const label() const; /// - VSpace space_; + InsetVSpaceParams params_; }; diff --git a/src/insets/InsetWrap.cpp b/src/insets/InsetWrap.cpp index 9400bf85d9..c9bd7ad279 100644 --- a/src/insets/InsetWrap.cpp +++ b/src/insets/InsetWrap.cpp @@ -93,7 +93,7 @@ void InsetWrap::doDispatch(Cursor & cur, FuncRequest & cmd) case LFUN_INSET_MODIFY: { cur.recordUndoInset(this); InsetWrapParams params; - InsetWrap::string2params(to_utf8(cmd.argument()), params); + params.fromString(to_utf8(cmd.argument())); params_.lines = params.lines; params_.placement = params.placement; params_.overhang = params.overhang; @@ -254,17 +254,16 @@ bool InsetWrap::showInsetDialog(BufferView * bv) const } -void InsetWrap::string2params(string const & in, InsetWrapParams & params) +void InsetWrapParams::fromString(string const & in) { - params = InsetWrapParams(); istringstream data(in); Lexer lex; lex.setStream(data); lex.setContext("InsetWrap::string2params"); lex >> "wrap"; lex >> "Wrap"; // Part of the inset proper, swallowed by Text::readInset - lex >> params.type; // We have to read the type here! - params.read(lex); + lex >> type; // We have to read the type here! + read(lex); } diff --git a/src/insets/InsetWrap.h b/src/insets/InsetWrap.h index 795eb8b21f..be14872a10 100644 --- a/src/insets/InsetWrap.h +++ b/src/insets/InsetWrap.h @@ -27,6 +27,8 @@ public: /// void read(Lexer &) override; /// + void fromString(std::string const & in) override; + /// std::string name() const override { return "wrap"; } /// std::string type; @@ -51,8 +53,6 @@ public: ~InsetWrap(); /// InsetWrapParams const & params() const { return params_; } - /// - static void string2params(std::string const &, InsetWrapParams &); private: /// void setCaptionType(std::string const & type) override; diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp index 522c4405a5..92c5aa03a9 100644 --- a/src/mathed/InsetMathHull.cpp +++ b/src/mathed/InsetMathHull.cpp @@ -1945,7 +1945,7 @@ void InsetMathHull::doDispatch(Cursor & cur, FuncRequest & cmd) string const name = cmd.getArg(0); if (name == "label") { InsetCommandParams p(LABEL_CODE); - InsetCommand::string2params(to_utf8(cmd.argument()), p); + p.fromString(to_utf8(cmd.argument())); docstring str = p["name"]; cur.recordUndoInset(); row_type const r = (type_ == hullMultline) ? nrows() - 1 : cur.row(); diff --git a/src/mathed/MathFactory.cpp b/src/mathed/MathFactory.cpp index 08f0b01e39..0fa0ad434f 100644 --- a/src/mathed/MathFactory.cpp +++ b/src/mathed/MathFactory.cpp @@ -701,13 +701,13 @@ bool createInsetMath_fromDialogStr(docstring const & str, MathData & ar) if (name == "ref") { InsetCommandParams icp(REF_CODE); // FIXME UNICODE - InsetCommand::string2params(to_utf8(str), icp); + icp.fromString(to_utf8(str)); Encoding const * const utf8 = encodings.fromLyXName("utf8"); OutputParams op(utf8); mathed_parse_cell(ar, icp.getCommand(op)); } else if (name == "mathspace") { InsetSpaceParams isp(true); - InsetSpace::string2params(to_utf8(str), isp); + isp.fromString(to_utf8(str)); InsetSpace is(isp); odocstringstream ods; otexstream os(ods); -- 2.39.5