From: Yuriy Skalko Date: Mon, 21 Dec 2020 15:30:34 +0000 (+0200) Subject: Refactor `params2string` -> `toString` X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=a4acdf6fd3e7f37b5a2593825dde13960a5225a0;p=features.git Refactor `params2string` -> `toString` Move `params2string` static methods of Insets into `toString` methods of InsetParams. --- diff --git a/src/BufferView.cpp b/src/BufferView.cpp index dafab28c7b..ba25b8884c 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -2121,7 +2121,7 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr) icp["before"] = from_utf8(opt1); icp["literal"] = from_ascii(InsetCitation::last_literal ? "true" : "false"); - string icstr = InsetCommand::params2string(icp); + string icstr = icp.toString(); FuncRequest fr(LFUN_INSET_INSERT, icstr); lyx::dispatch(fr); break; diff --git a/src/Text3.cpp b/src/Text3.cpp index a59eec8b97..94f8875d17 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -2018,7 +2018,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) } else p["name"] = content; } - string const data = InsetCommand::params2string(p); + string const data = p.toString(); // we need to have a target. if we already have one, then // that gets used at the default for the name, too, which @@ -2038,7 +2038,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) p["name"] = (cmd.argument().empty()) ? cur.getPossibleLabel() : cmd.argument(); - string const data = InsetCommand::params2string(p); + string const data = p.toString(); if (cmd.argument().empty()) { bv->showDialog("label", data); @@ -2274,7 +2274,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) cur.clearSelection(); } else p["symbol"] = cmd.argument(); - string const data = InsetCommand::params2string(p); + string const data = p.toString(); bv->showDialog("nomenclature", data); break; } @@ -2285,7 +2285,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) p["type"] = from_ascii("idx"); else p["type"] = cmd.argument(); - string const data = InsetCommand::params2string(p); + string const data = p.toString(); FuncRequest fr(LFUN_INSET_INSERT, data); dispatch(cur, fr); break; diff --git a/src/frontends/qt/FloatPlacement.cpp b/src/frontends/qt/FloatPlacement.cpp index 21d13e9c3b..4141608e4e 100644 --- a/src/frontends/qt/FloatPlacement.cpp +++ b/src/frontends/qt/FloatPlacement.cpp @@ -73,7 +73,7 @@ docstring FloatPlacement::dialogToParams() const params.sideways = sidewaysCB->isChecked(); params.alignment = getAlignment(); params.placement = getPlacement(); - return from_ascii(InsetFloat::params2string(params)); + return from_ascii(params.toString()); } diff --git a/src/frontends/qt/GuiBibitem.cpp b/src/frontends/qt/GuiBibitem.cpp index ccbbf95b20..a0321f18c9 100644 --- a/src/frontends/qt/GuiBibitem.cpp +++ b/src/frontends/qt/GuiBibitem.cpp @@ -106,7 +106,7 @@ docstring GuiBibitem::dialogToParams() const params["label"] = qstring_to_ucs4(label); params["literal"] = literalCB->isChecked() ? from_ascii("true") : from_ascii("false"); - return from_utf8(InsetCommand::params2string(params)); + return from_utf8(params.toString()); } diff --git a/src/frontends/qt/GuiBibtex.cpp b/src/frontends/qt/GuiBibtex.cpp index a9b5fade51..1ad64eeb59 100644 --- a/src/frontends/qt/GuiBibtex.cpp +++ b/src/frontends/qt/GuiBibtex.cpp @@ -637,7 +637,7 @@ bool GuiBibtex::initialiseParams(std::string const & sdata) void GuiBibtex::dispatchParams() { - std::string const lfun = InsetCommand::params2string(params_); + std::string const lfun = params_.toString(); dispatch(FuncRequest(getLfun(), lfun)); connectToNewInset(); } diff --git a/src/frontends/qt/GuiBox.cpp b/src/frontends/qt/GuiBox.cpp index 0d22aa7963..14cbaf7f5b 100644 --- a/src/frontends/qt/GuiBox.cpp +++ b/src/frontends/qt/GuiBox.cpp @@ -493,7 +493,7 @@ docstring GuiBox::dialogToParams() const else params.backgroundcolor = "none"; - return from_ascii(InsetBox::params2string(params)); + return from_ascii(params.toString()); } diff --git a/src/frontends/qt/GuiBranch.cpp b/src/frontends/qt/GuiBranch.cpp index 24b6977390..e66cff2e42 100644 --- a/src/frontends/qt/GuiBranch.cpp +++ b/src/frontends/qt/GuiBranch.cpp @@ -63,7 +63,7 @@ void GuiBranch::paramsToDialog(Inset const * inset) docstring GuiBranch::dialogToParams() const { InsetBranchParams params(qstring_to_ucs4(branchCO->currentText()), invertedCB->isChecked()); - return from_utf8(InsetBranch::params2string(params)); + return from_utf8(params.toString()); } diff --git a/src/frontends/qt/GuiCitation.cpp b/src/frontends/qt/GuiCitation.cpp index eed9574904..61b3e1383f 100644 --- a/src/frontends/qt/GuiCitation.cpp +++ b/src/frontends/qt/GuiCitation.cpp @@ -1061,7 +1061,7 @@ vector GuiCitation::searchKeys(BiblioInfo const & bi, void GuiCitation::dispatchParams() { - std::string const lfun = InsetCommand::params2string(params_); + std::string const lfun = params_.toString(); dispatch(FuncRequest(getLfun(), lfun)); } diff --git a/src/frontends/qt/GuiCounter.cpp b/src/frontends/qt/GuiCounter.cpp index 1c79725a87..6c5e9bf6e3 100644 --- a/src/frontends/qt/GuiCounter.cpp +++ b/src/frontends/qt/GuiCounter.cpp @@ -132,7 +132,7 @@ docstring GuiCounter::dialogToParams() const params["value"] = convert(valueSB->value()); params.setCmdName(fromqstr(actionCB->itemData(actionCB->currentIndex()).toString())); params["lyxonly"] = from_ascii(lyxonlyXB->isChecked() ? "true" : "false"); - return from_utf8(InsetCounter::params2string(params)); + return from_utf8(params.toString()); } diff --git a/src/frontends/qt/GuiExternal.cpp b/src/frontends/qt/GuiExternal.cpp index 25f0e65733..0a56214f27 100644 --- a/src/frontends/qt/GuiExternal.cpp +++ b/src/frontends/qt/GuiExternal.cpp @@ -643,7 +643,7 @@ void GuiExternal::clearParams() void GuiExternal::dispatchParams() { - string const lfun = InsetExternal::params2string(params_); + string const lfun = params_.toString(); dispatch(FuncRequest(getLfun(), lfun)); connectToNewInset(); } diff --git a/src/frontends/qt/GuiGraphics.cpp b/src/frontends/qt/GuiGraphics.cpp index db911613bc..04b0ca3285 100644 --- a/src/frontends/qt/GuiGraphics.cpp +++ b/src/frontends/qt/GuiGraphics.cpp @@ -772,7 +772,7 @@ void GuiGraphics::dispatchParams() { InsetGraphicsParams tmp_params(params_); tmp_params.setBuffer(&buffer()); - string const lfun = InsetGraphics::params2string(tmp_params); + string const lfun = tmp_params.toString(); dispatch(FuncRequest(getLfun(), lfun)); connectToNewInset(); } diff --git a/src/frontends/qt/GuiHSpace.cpp b/src/frontends/qt/GuiHSpace.cpp index 64c5b3809f..a02cfa517c 100644 --- a/src/frontends/qt/GuiHSpace.cpp +++ b/src/frontends/qt/GuiHSpace.cpp @@ -286,7 +286,7 @@ docstring GuiHSpace::dialogToParams() const } else if (item == "visible") params.kind = InsetSpaceParams::VISIBLE; - return from_ascii(InsetSpace::params2string(params)); + return from_ascii(params.toString()); } diff --git a/src/frontends/qt/GuiHyperlink.cpp b/src/frontends/qt/GuiHyperlink.cpp index c063ca2362..468d3dbf3c 100644 --- a/src/frontends/qt/GuiHyperlink.cpp +++ b/src/frontends/qt/GuiHyperlink.cpp @@ -104,7 +104,7 @@ docstring GuiHyperlink::dialogToParams() const params["literal"] = literalCB->isChecked() ? from_ascii("true") : from_ascii("false"); params.setCmdName("href"); - return from_utf8(InsetHyperlink::params2string(params)); + return from_utf8(params.toString()); } diff --git a/src/frontends/qt/GuiInclude.cpp b/src/frontends/qt/GuiInclude.cpp index 3d4f3dde1b..555db0eeef 100644 --- a/src/frontends/qt/GuiInclude.cpp +++ b/src/frontends/qt/GuiInclude.cpp @@ -391,7 +391,7 @@ bool GuiInclude::initialiseParams(std::string const & sdata) void GuiInclude::dispatchParams() { - std::string const lfun = InsetCommand::params2string(params_); + std::string const lfun = params_.toString(); dispatch(FuncRequest(getLfun(), lfun)); } diff --git a/src/frontends/qt/GuiIndex.cpp b/src/frontends/qt/GuiIndex.cpp index 6264d6a101..e23f5793b5 100644 --- a/src/frontends/qt/GuiIndex.cpp +++ b/src/frontends/qt/GuiIndex.cpp @@ -92,7 +92,7 @@ void GuiIndex::clearParams() void GuiIndex::dispatchParams() { - dispatch(FuncRequest(getLfun(), InsetIndex::params2string(params_))); + dispatch(FuncRequest(getLfun(), params_.toString())); } diff --git a/src/frontends/qt/GuiLabel.cpp b/src/frontends/qt/GuiLabel.cpp index 78d1e3fc43..102a89f1eb 100644 --- a/src/frontends/qt/GuiLabel.cpp +++ b/src/frontends/qt/GuiLabel.cpp @@ -54,7 +54,7 @@ docstring GuiLabel::dialogToParams() const { InsetCommandParams params(insetCode()); params["name"] = qstring_to_ucs4(keywordED->text()); - return from_utf8(InsetLabel::params2string(params)); + return from_utf8(params.toString()); } diff --git a/src/frontends/qt/GuiLine.cpp b/src/frontends/qt/GuiLine.cpp index 2a8b9de2bc..139d12cc45 100644 --- a/src/frontends/qt/GuiLine.cpp +++ b/src/frontends/qt/GuiLine.cpp @@ -77,7 +77,7 @@ docstring GuiLine::dialogToParams() const params["width"] = from_utf8(widgetsToLength(WidthLE, WidthUnitCO)); params["height"] = from_utf8(widgetsToLength(HeightLE, HeightUnitCO)); params.setCmdName("rule"); - return from_ascii(InsetLine::params2string(params)); + return from_ascii(params.toString()); } diff --git a/src/frontends/qt/GuiListings.cpp b/src/frontends/qt/GuiListings.cpp index 0b3cb24b3b..76483de160 100644 --- a/src/frontends/qt/GuiListings.cpp +++ b/src/frontends/qt/GuiListings.cpp @@ -690,7 +690,7 @@ void GuiListings::clearParams() void GuiListings::dispatchParams() { - string const lfun = InsetListings::params2string(params_); + string const lfun = params_.toString(); dispatch(FuncRequest(getLfun(), lfun)); } diff --git a/src/frontends/qt/GuiNomenclature.cpp b/src/frontends/qt/GuiNomenclature.cpp index 92e7760abe..0d63f55b1a 100644 --- a/src/frontends/qt/GuiNomenclature.cpp +++ b/src/frontends/qt/GuiNomenclature.cpp @@ -61,7 +61,7 @@ docstring GuiNomenclature::dialogToParams() const params["description"] = qstring_to_ucs4(description); params["literal"] = literalCB->isChecked() ? from_ascii("true") : from_ascii("false"); - return from_utf8(InsetNomencl::params2string(params)); + return from_utf8(params.toString()); } diff --git a/src/frontends/qt/GuiNote.cpp b/src/frontends/qt/GuiNote.cpp index 59c771d55c..480f7b3f12 100644 --- a/src/frontends/qt/GuiNote.cpp +++ b/src/frontends/qt/GuiNote.cpp @@ -86,7 +86,7 @@ void GuiNote::clearParams() void GuiNote::dispatchParams() { - dispatch(FuncRequest(getLfun(), InsetNote::params2string(params_))); + dispatch(FuncRequest(getLfun(), params_.toString())); } diff --git a/src/frontends/qt/GuiPhantom.cpp b/src/frontends/qt/GuiPhantom.cpp index 62fc99036c..bcc8ee6d4f 100644 --- a/src/frontends/qt/GuiPhantom.cpp +++ b/src/frontends/qt/GuiPhantom.cpp @@ -85,7 +85,7 @@ void GuiPhantom::clearParams() void GuiPhantom::dispatchParams() { - dispatch(FuncRequest(getLfun(), InsetPhantom::params2string(params_))); + dispatch(FuncRequest(getLfun(), params_.toString())); } diff --git a/src/frontends/qt/GuiPrintNomencl.cpp b/src/frontends/qt/GuiPrintNomencl.cpp index a70a9e091c..8ea61cfdcc 100644 --- a/src/frontends/qt/GuiPrintNomencl.cpp +++ b/src/frontends/qt/GuiPrintNomencl.cpp @@ -86,7 +86,7 @@ docstring GuiPrintNomencl::dialogToParams() const if (set_width == from_ascii("custom")) width = from_utf8(widgetsToLength(valueLE, unitLC)); params["width"] = width; - return from_ascii(InsetNomencl::params2string(params)); + return from_ascii(params.toString()); } diff --git a/src/frontends/qt/GuiPrintindex.cpp b/src/frontends/qt/GuiPrintindex.cpp index b618287ae1..0607182335 100644 --- a/src/frontends/qt/GuiPrintindex.cpp +++ b/src/frontends/qt/GuiPrintindex.cpp @@ -126,7 +126,7 @@ bool GuiPrintindex::initialiseParams(string const & sdata) void GuiPrintindex::dispatchParams() { - std::string const lfun = InsetCommand::params2string(params_); + std::string const lfun = params_.toString(); dispatch(FuncRequest(getLfun(), lfun)); } diff --git a/src/frontends/qt/GuiRef.cpp b/src/frontends/qt/GuiRef.cpp index 77ab51535d..6686ed73c2 100644 --- a/src/frontends/qt/GuiRef.cpp +++ b/src/frontends/qt/GuiRef.cpp @@ -611,7 +611,7 @@ bool GuiRef::initialiseParams(std::string const & sdata) void GuiRef::dispatchParams() { - std::string const lfun = InsetCommand::params2string(params_); + std::string const lfun = params_.toString(); dispatch(FuncRequest(getLfun(), lfun)); connectToNewInset(); } diff --git a/src/frontends/qt/GuiWrap.cpp b/src/frontends/qt/GuiWrap.cpp index 0f66cf0758..8ecacbbe5a 100644 --- a/src/frontends/qt/GuiWrap.cpp +++ b/src/frontends/qt/GuiWrap.cpp @@ -201,7 +201,7 @@ void GuiWrap::clearParams() void GuiWrap::dispatchParams() { - string const lfun = InsetWrap::params2string(params_); + string const lfun = params_.toString(); dispatch(FuncRequest(getLfun(), lfun)); } diff --git a/src/frontends/qt/Menus.cpp b/src/frontends/qt/Menus.cpp index 266fb68d30..584f22f5a1 100644 --- a/src/frontends/qt/Menus.cpp +++ b/src/frontends/qt/Menus.cpp @@ -1563,7 +1563,7 @@ void MenuDefinition::expandIndicesContext(Buffer const * buf, bool listof) if (listof) { InsetCommandParams p(INDEX_PRINT_CODE); p["type"] = cit->shortcut(); - string const data = InsetCommand::params2string(p); + string const data = p.toString(); addWithStatusCheck(MenuItem(MenuItem::Command, toqstr(cit->index()), FuncRequest(LFUN_INSET_MODIFY, data))); } else { diff --git a/src/insets/InsetBox.cpp b/src/insets/InsetBox.cpp index 9cf0169422..60291bf62b 100644 --- a/src/insets/InsetBox.cpp +++ b/src/insets/InsetBox.cpp @@ -834,11 +834,11 @@ string InsetBox::contextMenuName() const } -string InsetBox::params2string(InsetBoxParams const & params) +string InsetBoxParams::toString() const { ostringstream data; data << "box" << ' '; - params.write(data); + write(data); return data.str(); } diff --git a/src/insets/InsetBox.h b/src/insets/InsetBox.h index a0a2334df9..6cc0db6bf3 100644 --- a/src/insets/InsetBox.h +++ b/src/insets/InsetBox.h @@ -30,6 +30,8 @@ public: void write(std::ostream & os) const override; /// void read(Lexer & lex) override; + /// + std::string toString() const override; /// std::string type; @@ -92,8 +94,6 @@ public: /// InsetBox(Buffer *, std::string const &); - /// - static std::string params2string(InsetBoxParams const &); /// static void string2params(std::string const &, InsetBoxParams &); /// diff --git a/src/insets/InsetBranch.cpp b/src/insets/InsetBranch.cpp index c0d6bd31e2..baa6c58768 100644 --- a/src/insets/InsetBranch.cpp +++ b/src/insets/InsetBranch.cpp @@ -387,10 +387,10 @@ bool InsetBranch::isMacroScope() const } -string InsetBranch::params2string(InsetBranchParams const & params) +string InsetBranchParams::toString() const { ostringstream data; - params.write(data); + write(data); return data.str(); } diff --git a/src/insets/InsetBranch.h b/src/insets/InsetBranch.h index fdde0a1816..87eb71ff91 100644 --- a/src/insets/InsetBranch.h +++ b/src/insets/InsetBranch.h @@ -28,6 +28,8 @@ public: /// void read(Lexer & lex) override; /// + std::string toString() const override; + /// docstring branch; /// bool inverted; @@ -48,8 +50,6 @@ public: /// InsetBranch(Buffer *, InsetBranchParams const &); - /// - static std::string params2string(InsetBranchParams const &); /// static void string2params(std::string const &, InsetBranchParams &); /// diff --git a/src/insets/InsetCommand.cpp b/src/insets/InsetCommand.cpp index 1089247f83..0f3b33327b 100644 --- a/src/insets/InsetCommand.cpp +++ b/src/insets/InsetCommand.cpp @@ -195,7 +195,7 @@ void InsetCommand::changeCmdName(string const & new_name) InsetCommandParams p(p_.code()); p = p_; p.setCmdName(new_name); - string const data = InsetCommand::params2string(p); + string const data = p.toString(); lyx::dispatch(FuncRequest(LFUN_INSET_INSERT, data)); lyx::dispatch(FuncRequest(LFUN_CHAR_DELETE_FORWARD)); } else @@ -226,7 +226,7 @@ void InsetCommand::doDispatch(Cursor & cur, FuncRequest & cmd) if (buffer().masterParams().track_changes) { // With change tracking, we insert a new inset and // delete the old one - string const data = InsetCommand::params2string(p); + string const data = p.toString(); lyx::dispatch(FuncRequest(LFUN_INSET_INSERT, data)); lyx::dispatch(FuncRequest(LFUN_CHAR_DELETE_FORWARD)); cur.forceBufferUpdate(); @@ -243,7 +243,7 @@ void InsetCommand::doDispatch(Cursor & cur, FuncRequest & cmd) case LFUN_INSET_DIALOG_UPDATE: { string const name = to_utf8(cmd.argument()); - cur.bv().updateDialog(name, params2string(params())); + cur.bv().updateDialog(name, params().toString()); break; } @@ -293,7 +293,7 @@ string InsetCommand::contextMenuName() const bool InsetCommand::showInsetDialog(BufferView * bv) const { if (p_.code() != NO_CODE) - bv->showDialog(insetName(p_.code()), params2string(p_), + bv->showDialog(insetName(p_.code()), p_.toString(), const_cast(this)); return true; } @@ -322,16 +322,6 @@ bool InsetCommand::string2params(string const & data, } -string InsetCommand::params2string(InsetCommandParams const & params) -{ - ostringstream data; - data << insetName(params.code()) << ' '; - params.write(data); - data << "\\end_inset\n"; - return data.str(); -} - - bool decodeInsetParam(string const & name, string & data, Buffer const & buffer) { @@ -348,8 +338,7 @@ bool decodeInsetParam(string const & name, string & data, case TOC_CODE: case HYPERLINK_CODE: case COUNTER_CODE: { - InsetCommandParams p(code); - data = InsetCommand::params2string(p); + data = InsetCommandParams(code).toString(); break; } case INCLUDE_CODE: { @@ -358,24 +347,20 @@ bool decodeInsetParam(string const & name, string & data, if (data.empty()) // default type is requested data = "include"; - InsetCommandParams p(INCLUDE_CODE, data); - data = InsetCommand::params2string(p); + data = InsetCommandParams(INCLUDE_CODE, data).toString(); break; } case BOX_CODE: { // \c data == "Boxed" || "Frameless" etc - InsetBoxParams p(data); - data = InsetBox::params2string(p); + data = InsetBoxParams(data).toString(); break; } case BRANCH_CODE: { - InsetBranchParams p; - data = InsetBranch::params2string(p); + data = InsetBranchParams().toString(); break; } case CITE_CODE: { - InsetCommandParams p(CITE_CODE); - data = InsetCommand::params2string(p); + data = InsetCommandParams(CITE_CODE).toString(); break; } case ERT_CODE: { @@ -383,48 +368,39 @@ bool decodeInsetParam(string const & name, string & data, break; } case EXTERNAL_CODE: { - InsetExternalParams p(&buffer); - data = InsetExternal::params2string(p); + data = InsetExternalParams(&buffer).toString(); break; } case FLOAT_CODE: { - InsetFloatParams p; - data = InsetFloat::params2string(p); + data = InsetFloatParams().toString(); break; } case INDEX_CODE: { - InsetIndexParams p; - data = InsetIndex::params2string(p); + data = InsetIndexParams().toString(); break; } case LISTINGS_CODE: { - InsetListingsParams p; - data = InsetListings::params2string(p); + data = InsetListingsParams().toString(); break; } case GRAPHICS_CODE: { - InsetGraphicsParams p(&buffer); - data = InsetGraphics::params2string(p); + data = InsetGraphicsParams(&buffer).toString(); break; } case MATH_SPACE_CODE: { - InsetSpaceParams p(true); - data = InsetSpace::params2string(p); + data = InsetSpaceParams(true).toString(); break; } case NOTE_CODE: { - InsetNoteParams p; - data = InsetNote::params2string(p); + data = InsetNoteParams().toString(); break; } case PHANTOM_CODE: { - InsetPhantomParams p; - data = InsetPhantom::params2string(p); + data = InsetPhantomParams().toString(); break; } case SPACE_CODE: { - InsetSpaceParams p; - data = InsetSpace::params2string(p); + data = InsetSpaceParams().toString(); break; } case VSPACE_CODE: { @@ -433,8 +409,7 @@ bool decodeInsetParam(string const & name, string & data, break; } case WRAP_CODE: { - InsetWrapParams p; - data = InsetWrap::params2string(p); + data = InsetWrapParams().toString(); break; } default: diff --git a/src/insets/InsetCommand.h b/src/insets/InsetCommand.h index 7b2b5bde08..a4c66b3d1f 100644 --- a/src/insets/InsetCommand.h +++ b/src/insets/InsetCommand.h @@ -51,8 +51,6 @@ public: static bool string2params(std::string const & data, InsetCommandParams &); /// - static std::string params2string(InsetCommandParams const &); - /// InsetCommandParams const & params() const { return p_; } /// void setParams(InsetCommandParams const &); diff --git a/src/insets/InsetCommandParams.cpp b/src/insets/InsetCommandParams.cpp index 09c9ee85a0..4ea716f9c4 100644 --- a/src/insets/InsetCommandParams.cpp +++ b/src/insets/InsetCommandParams.cpp @@ -604,6 +604,16 @@ docstring InsetCommandParams::getFirstNonOptParam() const } +string InsetCommandParams::toString() const +{ + ostringstream data; + data << insetName(code()) << ' '; + write(data); + data << "\\end_inset\n"; + return data.str(); +} + + docstring const & InsetCommandParams::operator[](string const & name) const { static const docstring dummy; diff --git a/src/insets/InsetCommandParams.h b/src/insets/InsetCommandParams.h index 4e417ad94d..a7656dc4fc 100644 --- a/src/insets/InsetCommandParams.h +++ b/src/insets/InsetCommandParams.h @@ -136,6 +136,8 @@ public: void write(std::ostream &) const override; /// void Write(std::ostream & os, Buffer const * buf) const; + /// + std::string toString() const override; /// Build the complete LaTeX command docstring getCommand(OutputParams const &) const; /// Return the command name diff --git a/src/insets/InsetExternal.cpp b/src/insets/InsetExternal.cpp index eba8756056..42918ec81d 100644 --- a/src/insets/InsetExternal.cpp +++ b/src/insets/InsetExternal.cpp @@ -478,8 +478,7 @@ void InsetExternal::doDispatch(Cursor & cur, FuncRequest & cmd) case LFUN_INSET_DIALOG_UPDATE: { InsetExternalParams p(params()); p.setBuffer(&cur.bv().buffer()); - cur.bv().updateDialog("external", - params2string(p)); + cur.bv().updateDialog("external", p.toString()); break; } @@ -520,7 +519,7 @@ bool InsetExternal::showInsetDialog(BufferView * bv) const { InsetExternalParams p(params()); p.setBuffer(&bv->buffer()); - bv->showDialog("external", params2string(p), + bv->showDialog("external", p.toString(), const_cast(this)); return true; } @@ -935,11 +934,11 @@ void InsetExternal::string2params(string const & in, InsetExternalParams & param } -string InsetExternal::params2string(InsetExternalParams const & params) +string InsetExternalParams::toString() const { ostringstream data; data << "external" << ' '; - params.write(data); + write(data); data << "\\end_inset\n"; return data.str(); } diff --git a/src/insets/InsetExternal.h b/src/insets/InsetExternal.h index 1649802d07..8d233c80b7 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; + std::string toString() const override; Buffer const * buffer() { return buffer_; } void setBuffer(Buffer const * b) { buffer_ = b; } @@ -105,8 +106,6 @@ public: /// static void string2params(std::string const &, InsetExternalParams &); /// - static std::string params2string(InsetExternalParams const &); - /// InsetExternalParams const & params() const; /// void setParams(InsetExternalParams const &); diff --git a/src/insets/InsetFloat.cpp b/src/insets/InsetFloat.cpp index db74e9ef1b..b6120ddd98 100644 --- a/src/insets/InsetFloat.cpp +++ b/src/insets/InsetFloat.cpp @@ -189,7 +189,7 @@ void InsetFloat::doDispatch(Cursor & cur, FuncRequest & cmd) } case LFUN_INSET_DIALOG_UPDATE: { - cur.bv().updateDialog("float", params2string(params())); + cur.bv().updateDialog("float", params().toString()); break; } @@ -281,7 +281,7 @@ void InsetFloatParams::write(ostream & os) const { if (type.empty()) { // Better this than creating a parse error. This in fact happens in the - // parameters dialog via InsetFloatParams::params2string. + // parameters dialog via InsetFloatParams::toString. os << "senseless" << '\n'; } else os << type << '\n'; @@ -967,10 +967,10 @@ void InsetFloat::string2params(string const & in, InsetFloatParams & params) } -string InsetFloat::params2string(InsetFloatParams const & params) +string InsetFloatParams::toString() const { ostringstream data; - params.write(data); + write(data); return data.str(); } diff --git a/src/insets/InsetFloat.h b/src/insets/InsetFloat.h index daa5b3181d..9a043b5bab 100644 --- a/src/insets/InsetFloat.h +++ b/src/insets/InsetFloat.h @@ -32,6 +32,8 @@ public: /// void read(Lexer & lex) override; /// + std::string toString() const override; + /// std::string type; /// std::string placement; @@ -61,8 +63,6 @@ public: /// static void string2params(std::string const &, InsetFloatParams &); /// - static std::string params2string(InsetFloatParams const &); - /// void setWide(bool w, bool update_label = true); /// void setSideways(bool s, bool update_label = true); diff --git a/src/insets/InsetFloatList.cpp b/src/insets/InsetFloatList.cpp index e711feebf4..d5ff6cd604 100644 --- a/src/insets/InsetFloatList.cpp +++ b/src/insets/InsetFloatList.cpp @@ -87,7 +87,7 @@ void InsetFloatList::doDispatch(Cursor & cur, FuncRequest & cmd) { switch (cmd.action()) { case LFUN_MOUSE_RELEASE: if (!cur.selection() && cmd.button() == mouse_button::button1) { - cur.bv().showDialog("toc", params2string(params())); + cur.bv().showDialog("toc", params().toString()); cur.dispatched(); } break; diff --git a/src/insets/InsetGraphics.cpp b/src/insets/InsetGraphics.cpp index 8d56fc9f1c..14f303c1a5 100644 --- a/src/insets/InsetGraphics.cpp +++ b/src/insets/InsetGraphics.cpp @@ -243,7 +243,7 @@ void InsetGraphics::doDispatch(Cursor & cur, FuncRequest & cmd) case LFUN_INSET_DIALOG_UPDATE: { InsetGraphicsParams p(params()); p.setBuffer(&buffer()); - cur.bv().updateDialog("graphics", params2string(p)); + cur.bv().updateDialog("graphics", p.toString()); break; } @@ -283,7 +283,7 @@ bool InsetGraphics::showInsetDialog(BufferView * bv) const { InsetGraphicsParams p(params()); p.setBuffer(&bv->buffer()); - bv->showDialog("graphics", params2string(p), + bv->showDialog("graphics", p.toString(), const_cast(this)); return true; } @@ -1178,16 +1178,6 @@ void InsetGraphics::string2params(string const & in, InsetGraphicsParams & param } -string InsetGraphics::params2string(InsetGraphicsParams const & params) -{ - ostringstream data; - data << "graphics" << ' '; - params.write(data); - data << "\\end_inset\n"; - return data.str(); -} - - docstring InsetGraphics::toolTip(BufferView const &, int, int) const { return from_utf8(params().filename.onlyFileName()); @@ -1237,7 +1227,7 @@ string getGroupParams(Buffer const & b, string const & groupId) InsetGraphicsParams tmp = inspar; tmp.setBuffer(&b); tmp.filename.erase(); - return InsetGraphics::params2string(tmp); + return tmp.toString(); } } return string(); diff --git a/src/insets/InsetGraphics.h b/src/insets/InsetGraphics.h index 151e4313f2..a597ca31e9 100644 --- a/src/insets/InsetGraphics.h +++ b/src/insets/InsetGraphics.h @@ -41,8 +41,6 @@ public: /// static void string2params(std::string const & data, InsetGraphicsParams &); - /// - static std::string params2string(InsetGraphicsParams const &); /** 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 a33ef66103..c4de633552 100644 --- a/src/insets/InsetGraphicsParams.cpp +++ b/src/insets/InsetGraphicsParams.cpp @@ -28,6 +28,7 @@ #include "support/Translator.h" #include +#include using namespace std; using namespace lyx::support; @@ -253,6 +254,16 @@ bool InsetGraphicsParams::read(Lexer & lex, string const & token, bool allowOrig } +string InsetGraphicsParams::toString() const +{ + ostringstream data; + data << "graphics" << ' '; + write(data); + data << "\\end_inset\n"; + return data.str(); +} + + graphics::Params InsetGraphicsParams::as_grfxParams() const { graphics::Params pars; diff --git a/src/insets/InsetGraphicsParams.h b/src/insets/InsetGraphicsParams.h index bae4d35982..be3fae8a14 100644 --- a/src/insets/InsetGraphicsParams.h +++ b/src/insets/InsetGraphicsParams.h @@ -81,6 +81,8 @@ public: void write(std::ostream & os) const; /// If the token belongs to our parameters, read it. bool read(Lexer & lex, std::string const & token, bool allowOrigin); + /// + std::string toString() const; /// convert // Only a subset of InsetGraphicsParams is needed for display purposes. // This function also interrogates lyxrc to ascertain whether diff --git a/src/insets/InsetIPAMacro.cpp b/src/insets/InsetIPAMacro.cpp index 5d2035b559..1da5e29599 100644 --- a/src/insets/InsetIPAMacro.cpp +++ b/src/insets/InsetIPAMacro.cpp @@ -340,11 +340,11 @@ docstring InsetIPADeco::toolTip(BufferView const &, int, int) const } -string InsetIPADeco::params2string(InsetIPADecoParams const & params) +string InsetIPADecoParams::toString() const { ostringstream data; data << "IPADeco" << ' '; - params.write(data); + write(data); return data.str(); } diff --git a/src/insets/InsetIPAMacro.h b/src/insets/InsetIPAMacro.h index 432bb5a897..41dd3bf405 100644 --- a/src/insets/InsetIPAMacro.h +++ b/src/insets/InsetIPAMacro.h @@ -35,6 +35,8 @@ public: /// void read(Lexer & lex) override; /// + std::string toString() const override; + /// Type type; }; @@ -53,8 +55,6 @@ public: /// ~InsetIPADeco(); /// - static std::string params2string(InsetIPADecoParams const &); - /// static void string2params(std::string const &, InsetIPADecoParams &); /// InsetIPADecoParams const & params() const { return params_; } diff --git a/src/insets/InsetIndex.cpp b/src/insets/InsetIndex.cpp index 149ef6506a..4deae0eba3 100644 --- a/src/insets/InsetIndex.cpp +++ b/src/insets/InsetIndex.cpp @@ -384,7 +384,7 @@ docstring InsetIndex::xhtml(XMLStream & xs, OutputParams const &) const bool InsetIndex::showInsetDialog(BufferView * bv) const { - bv->showDialog("index", params2string(params_), + bv->showDialog("index", params_.toString(), const_cast(this)); return true; } @@ -411,7 +411,7 @@ void InsetIndex::doDispatch(Cursor & cur, FuncRequest & cmd) } case LFUN_INSET_DIALOG_UPDATE: - cur.bv().updateDialog("index", params2string(params_)); + cur.bv().updateDialog("index", params_.toString()); break; default: @@ -520,11 +520,11 @@ void InsetIndex::read(Lexer & lex) } -string InsetIndex::params2string(InsetIndexParams const & params) +string InsetIndexParams::toString() const { ostringstream data; data << "index"; - params.write(data); + write(data); return data.str(); } diff --git a/src/insets/InsetIndex.h b/src/insets/InsetIndex.h index b2038536f2..c2f23a610c 100644 --- a/src/insets/InsetIndex.h +++ b/src/insets/InsetIndex.h @@ -29,6 +29,8 @@ public: /// void read(Lexer & lex) override; /// + std::string toString() const override; + docstring index; }; @@ -40,8 +42,6 @@ public: /// InsetIndex(Buffer *, InsetIndexParams const &); /// - static std::string params2string(InsetIndexParams const &); - /// static void string2params(std::string const &, InsetIndexParams &); private: /// diff --git a/src/insets/InsetLabel.cpp b/src/insets/InsetLabel.cpp index 2c0c1e5194..910c08682c 100644 --- a/src/insets/InsetLabel.cpp +++ b/src/insets/InsetLabel.cpp @@ -104,7 +104,7 @@ void InsetLabel::updateLabelAndRefs(docstring const & new_label, // delete the old one InsetCommandParams p(LABEL_CODE, "label"); p["name"] = label; - string const data = InsetCommand::params2string(p); + string const data = p.toString(); lyx::dispatch(FuncRequest(LFUN_INSET_INSERT, data)); lyx::dispatch(FuncRequest(LFUN_CHAR_DELETE_FORWARD)); } else @@ -294,7 +294,7 @@ void InsetLabel::doDispatch(Cursor & cur, FuncRequest & cmd) case LFUN_LABEL_INSERT_AS_REFERENCE: { InsetCommandParams p(REF_CODE, "ref"); p["reference"] = getParam("name"); - string const data = InsetCommand::params2string(p); + string const data = p.toString(); lyx::dispatch(FuncRequest(LFUN_INSET_INSERT, data)); break; } diff --git a/src/insets/InsetListings.cpp b/src/insets/InsetListings.cpp index 51763d40af..c99e4c512d 100644 --- a/src/insets/InsetListings.cpp +++ b/src/insets/InsetListings.cpp @@ -569,7 +569,7 @@ void InsetListings::doDispatch(Cursor & cur, FuncRequest & cmd) } case LFUN_INSET_DIALOG_UPDATE: - cur.bv().updateDialog("listings", params2string(params())); + cur.bv().updateDialog("listings", params().toString()); break; default: @@ -635,7 +635,7 @@ void InsetListings::validate(LaTeXFeatures & features) const bool InsetListings::showInsetDialog(BufferView * bv) const { - bv->showDialog("listings", params2string(params()), + bv->showDialog("listings", params().toString(), const_cast(this)); return true; } @@ -700,13 +700,4 @@ void InsetListings::string2params(string const & in, } -string InsetListings::params2string(InsetListingsParams const & params) -{ - ostringstream data; - data << "listings" << ' '; - params.write(data); - return data.str(); -} - - } // namespace lyx diff --git a/src/insets/InsetListings.h b/src/insets/InsetListings.h index 1a80078645..cc65ef14a6 100644 --- a/src/insets/InsetListings.h +++ b/src/insets/InsetListings.h @@ -36,8 +36,6 @@ public: ~InsetListings(); /// static void string2params(std::string const &, InsetListingsParams &); - /// - static std::string params2string(InsetListingsParams const &); private: /// bool isLabeled() const override { return true; } diff --git a/src/insets/InsetListingsParams.cpp b/src/insets/InsetListingsParams.cpp index 8ffb438797..ab8a0573c3 100644 --- a/src/insets/InsetListingsParams.cpp +++ b/src/insets/InsetListingsParams.cpp @@ -1006,6 +1006,15 @@ void InsetListingsParams::read(Lexer & lex) } +string InsetListingsParams::toString() const +{ + ostringstream data; + data << "listings" << ' '; + write(data); + return data.str(); +} + + string InsetListingsParams::params(string const & sep) const { string par; diff --git a/src/insets/InsetListingsParams.h b/src/insets/InsetListingsParams.h index 7497110738..6f008b8865 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; + /// + std::string toString() const override; + /// valid parameter string std::string params(std::string const & sep=",") const; diff --git a/src/insets/InsetNewline.cpp b/src/insets/InsetNewline.cpp index f5fcd42ac6..983457dd53 100644 --- a/src/insets/InsetNewline.cpp +++ b/src/insets/InsetNewline.cpp @@ -281,11 +281,11 @@ void InsetNewline::string2params(string const & in, InsetNewlineParams & params) } -string InsetNewline::params2string(InsetNewlineParams const & params) +string InsetNewlineParams::toString() const { ostringstream data; data << "newline" << ' '; - params.write(data); + write(data); return data.str(); } diff --git a/src/insets/InsetNewline.h b/src/insets/InsetNewline.h index 10f894d1e6..82667f5240 100644 --- a/src/insets/InsetNewline.h +++ b/src/insets/InsetNewline.h @@ -34,6 +34,8 @@ public: /// void read(Lexer & lex) override; /// + std::string toString() const override; + /// Kind kind; }; @@ -50,8 +52,6 @@ public: RowFlags rowFlags() const override { return BreakAfter | RowAfter; } /// static void string2params(std::string const &, InsetNewlineParams &); - /// - static std::string params2string(InsetNewlineParams const &); private: /// InsetCode lyxCode() const override { return NEWLINE_CODE; } diff --git a/src/insets/InsetNewpage.cpp b/src/insets/InsetNewpage.cpp index da94452632..6ab41fa3ce 100644 --- a/src/insets/InsetNewpage.cpp +++ b/src/insets/InsetNewpage.cpp @@ -351,11 +351,11 @@ void InsetNewpage::string2params(string const & in, InsetNewpageParams & params) } -string InsetNewpage::params2string(InsetNewpageParams const & params) +string InsetNewpageParams::toString() const { ostringstream data; data << "newpage" << ' '; - params.write(data); + write(data); return data.str(); } diff --git a/src/insets/InsetNewpage.h b/src/insets/InsetNewpage.h index 633b81ffd7..55df6b8b96 100644 --- a/src/insets/InsetNewpage.h +++ b/src/insets/InsetNewpage.h @@ -40,6 +40,8 @@ public: /// void read(Lexer & lex) override; /// + std::string toString() const override; + /// Kind kind; }; @@ -53,8 +55,6 @@ public: explicit InsetNewpage(InsetNewpageParams const & par); /// static void string2params(std::string const &, InsetNewpageParams &); - /// - static std::string params2string(InsetNewpageParams const &); private: /// InsetCode lyxCode() const override { return NEWPAGE_CODE; } diff --git a/src/insets/InsetNote.cpp b/src/insets/InsetNote.cpp index 28d8db18e5..c2ab7e003f 100644 --- a/src/insets/InsetNote.cpp +++ b/src/insets/InsetNote.cpp @@ -129,7 +129,7 @@ void InsetNote::read(Lexer & lex) bool InsetNote::showInsetDialog(BufferView * bv) const { - bv->showDialog("note", params2string(params()), + bv->showDialog("note", params().toString(), const_cast(this)); return true; } @@ -161,7 +161,7 @@ void InsetNote::doDispatch(Cursor & cur, FuncRequest & cmd) } case LFUN_INSET_DIALOG_UPDATE: - cur.bv().updateDialog("note", params2string(params())); + cur.bv().updateDialog("note", params().toString()); break; default: @@ -338,11 +338,11 @@ FontInfo InsetNote::getFont() const } -string InsetNote::params2string(InsetNoteParams const & params) +string InsetNoteParams::toString() const { ostringstream data; data << "note" << ' '; - params.write(data); + write(data); return data.str(); } diff --git a/src/insets/InsetNote.h b/src/insets/InsetNote.h index bf14e14758..eb99a139e0 100644 --- a/src/insets/InsetNote.h +++ b/src/insets/InsetNote.h @@ -32,6 +32,8 @@ public: /// void read(Lexer & lex) override; /// + std::string toString() const override; + Type type; }; @@ -51,8 +53,6 @@ public: /// ~InsetNote(); /// - static std::string params2string(InsetNoteParams const &); - /// static void string2params(std::string const &, InsetNoteParams &); /// InsetNoteParams const & params() const { return params_; } diff --git a/src/insets/InsetParams.h b/src/insets/InsetParams.h index 0d7060317a..81866cb33a 100644 --- a/src/insets/InsetParams.h +++ b/src/insets/InsetParams.h @@ -13,6 +13,7 @@ #define INSETPARAMS_H #include +#include namespace lyx { @@ -28,6 +29,8 @@ public: virtual void write(std::ostream & os) const = 0; /// virtual void read(Lexer & lex) = 0; + /// + virtual std::string toString() const = 0; }; diff --git a/src/insets/InsetPhantom.cpp b/src/insets/InsetPhantom.cpp index d1a25f6a70..61d41ca2b2 100644 --- a/src/insets/InsetPhantom.cpp +++ b/src/insets/InsetPhantom.cpp @@ -238,7 +238,7 @@ void InsetPhantom::setButtonLabel() bool InsetPhantom::showInsetDialog(BufferView * bv) const { - bv->showDialog("phantom", params2string(params()), + bv->showDialog("phantom", params().toString(), const_cast(this)); return true; } @@ -256,7 +256,7 @@ void InsetPhantom::doDispatch(Cursor & cur, FuncRequest & cmd) break; case LFUN_INSET_DIALOG_UPDATE: - cur.bv().updateDialog("phantom", params2string(params())); + cur.bv().updateDialog("phantom", params().toString()); break; default: @@ -362,11 +362,11 @@ string InsetPhantom::contextMenuName() const } -string InsetPhantom::params2string(InsetPhantomParams const & params) +string InsetPhantomParams::toString() const { ostringstream data; data << "phantom" << ' '; - params.write(data); + write(data); return data.str(); } diff --git a/src/insets/InsetPhantom.h b/src/insets/InsetPhantom.h index 2ca9b05622..4d31099b03 100644 --- a/src/insets/InsetPhantom.h +++ b/src/insets/InsetPhantom.h @@ -32,6 +32,7 @@ public: /// void read(Lexer & lex) override; /// + std::string toString() const override; Type type; }; @@ -51,8 +52,6 @@ public: /// ~InsetPhantom(); /// - static std::string params2string(InsetPhantomParams const &); - /// static void string2params(std::string const &, InsetPhantomParams &); /// InsetPhantomParams const & params() const { return params_; } diff --git a/src/insets/InsetRef.cpp b/src/insets/InsetRef.cpp index ed43d6a950..2a5415ab53 100644 --- a/src/insets/InsetRef.cpp +++ b/src/insets/InsetRef.cpp @@ -92,7 +92,7 @@ void InsetRef::changeTarget(docstring const & new_label) if (buffer().masterParams().track_changes) { InsetCommandParams icp(REF_CODE, "ref"); icp["reference"] = new_label; - string const data = InsetCommand::params2string(icp); + string const data = icp.toString(); lyx::dispatch(FuncRequest(LFUN_INSET_INSERT, data)); lyx::dispatch(FuncRequest(LFUN_CHAR_DELETE_FORWARD)); } else diff --git a/src/insets/InsetScript.cpp b/src/insets/InsetScript.cpp index c1f8da1e82..4a9ed85ee8 100644 --- a/src/insets/InsetScript.cpp +++ b/src/insets/InsetScript.cpp @@ -378,11 +378,11 @@ string InsetScript::contextMenuName() const } -string InsetScript::params2string(InsetScriptParams const & params) +string InsetScriptParams::toString() const { ostringstream data; data << "script "; - params.write(data); + write(data); return data.str(); } diff --git a/src/insets/InsetScript.h b/src/insets/InsetScript.h index e4a9da7621..516f40fc14 100644 --- a/src/insets/InsetScript.h +++ b/src/insets/InsetScript.h @@ -32,6 +32,8 @@ public: /// void read(Lexer & lex) override; /// + std::string toString() const override; + /// int shift(FontInfo const & font) const; /// Type type; @@ -55,8 +57,6 @@ public: /// ~InsetScript(); /// - static std::string params2string(InsetScriptParams const &); - /// static void string2params(std::string const &, InsetScriptParams &); /// InsetScriptParams const & params() const { return params_; } diff --git a/src/insets/InsetSeparator.cpp b/src/insets/InsetSeparator.cpp index 218172c87a..5d6b71f734 100644 --- a/src/insets/InsetSeparator.cpp +++ b/src/insets/InsetSeparator.cpp @@ -302,11 +302,11 @@ void InsetSeparator::string2params(string const & in, InsetSeparatorParams & par } -string InsetSeparator::params2string(InsetSeparatorParams const & params) +string InsetSeparatorParams::toString() const { ostringstream data; data << "separator" << ' '; - params.write(data); + write(data); return data.str(); } diff --git a/src/insets/InsetSeparator.h b/src/insets/InsetSeparator.h index 212d3894b4..b930a2ada2 100644 --- a/src/insets/InsetSeparator.h +++ b/src/insets/InsetSeparator.h @@ -33,6 +33,8 @@ public: /// void read(Lexer & lex) override; /// + std::string toString() const override; + Kind kind; }; @@ -46,8 +48,6 @@ public: explicit InsetSeparator(InsetSeparatorParams const & params); /// static void string2params(std::string const &, InsetSeparatorParams &); - /// - static std::string params2string(InsetSeparatorParams const &); /// 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 2deea3097e..4f9ba96e59 100644 --- a/src/insets/InsetSpace.cpp +++ b/src/insets/InsetSpace.cpp @@ -158,7 +158,7 @@ void InsetSpace::doDispatch(Cursor & cur, FuncRequest & cmd) } case LFUN_INSET_DIALOG_UPDATE: - cur.bv().updateDialog("space", params2string(params())); + cur.bv().updateDialog("space", params().toString()); break; default: @@ -946,13 +946,13 @@ void InsetSpace::string2params(string const & in, InsetSpaceParams & params) } -string InsetSpace::params2string(InsetSpaceParams const & params) +string InsetSpaceParams::toString() const { ostringstream data; - if (params.math) + if (math) data << "math"; data << "space" << ' '; - params.write(data); + write(data); return data.str(); } diff --git a/src/insets/InsetSpace.h b/src/insets/InsetSpace.h index a4fb63357f..44f6a5e61e 100644 --- a/src/insets/InsetSpace.h +++ b/src/insets/InsetSpace.h @@ -81,6 +81,8 @@ struct InsetSpaceParams : public InsetParams { /// void read(Lexer & lex) override; /// + std::string toString() const override; + /// Kind kind; /// GlueLength length; @@ -108,8 +110,6 @@ public: /// static void string2params(std::string const &, InsetSpaceParams &); /// - static std::string params2string(InsetSpaceParams const &); - /// GlueLength length() const; /// diff --git a/src/insets/InsetTOC.cpp b/src/insets/InsetTOC.cpp index a429d2d5bc..6302f819ad 100644 --- a/src/insets/InsetTOC.cpp +++ b/src/insets/InsetTOC.cpp @@ -83,7 +83,7 @@ void InsetTOC::doDispatch(Cursor & cur, FuncRequest & cmd) { switch (cmd.action()) { case LFUN_MOUSE_RELEASE: if (!cur.selection() && cmd.button() == mouse_button::button1) { - cur.bv().showDialog("toc", params2string(params())); + cur.bv().showDialog("toc", params().toString()); cur.dispatched(); } break; diff --git a/src/insets/InsetWrap.cpp b/src/insets/InsetWrap.cpp index c862b175f7..d70f8818da 100644 --- a/src/insets/InsetWrap.cpp +++ b/src/insets/InsetWrap.cpp @@ -102,7 +102,7 @@ void InsetWrap::doDispatch(Cursor & cur, FuncRequest & cmd) } case LFUN_INSET_DIALOG_UPDATE: - cur.bv().updateDialog("wrap", params2string(params())); + cur.bv().updateDialog("wrap", params().toString()); break; default: @@ -248,7 +248,7 @@ bool InsetWrap::insetAllowed(InsetCode code) const bool InsetWrap::showInsetDialog(BufferView * bv) const { if (!InsetText::showInsetDialog(bv)) - bv->showDialog("wrap", params2string(params()), + bv->showDialog("wrap", params().toString(), const_cast(this)); return true; } @@ -268,11 +268,11 @@ void InsetWrap::string2params(string const & in, InsetWrapParams & params) } -string InsetWrap::params2string(InsetWrapParams const & params) +string InsetWrapParams::toString() const { ostringstream data; data << "wrap" << ' '; - params.write(data); + write(data); return data.str(); } diff --git a/src/insets/InsetWrap.h b/src/insets/InsetWrap.h index bbf4000820..bf65db4e58 100644 --- a/src/insets/InsetWrap.h +++ b/src/insets/InsetWrap.h @@ -26,7 +26,8 @@ public: void write(std::ostream &) const override; /// void read(Lexer &) override; - + /// + std::string toString() const override; /// std::string type; /// @@ -52,8 +53,6 @@ public: InsetWrapParams const & params() const { return params_; } /// static void string2params(std::string const &, InsetWrapParams &); - /// - static std::string params2string(InsetWrapParams const &); private: /// void setCaptionType(std::string const & type) override; diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp index 24e4397490..522c4405a5 100644 --- a/src/mathed/InsetMathHull.cpp +++ b/src/mathed/InsetMathHull.cpp @@ -1881,7 +1881,7 @@ void InsetMathHull::doDispatch(Cursor & cur, FuncRequest & cmd) InsetCommandParams p(LABEL_CODE); p["name"] = cmd.argument().empty() ? old_label : cmd.argument(); - string const data = InsetCommand::params2string(p); + string const data = p.toString(); if (cmd.argument().empty()) cur.bv().showDialog("label", data); diff --git a/src/mathed/InsetMathRef.cpp b/src/mathed/InsetMathRef.cpp index 7170ca6378..bdff268559 100644 --- a/src/mathed/InsetMathRef.cpp +++ b/src/mathed/InsetMathRef.cpp @@ -233,7 +233,7 @@ string const InsetMathRef::createDialogStr() const icp["reference"] = asString(cell(0)); if (!cell(1).empty()) icp["name"] = asString(cell(1)); - return InsetCommand::params2string(icp); + return icp.toString(); } @@ -252,7 +252,7 @@ void InsetMathRef::changeTarget(docstring const & target) MathData ar; Buffer & buf = buffer(); if (createInsetMath_fromDialogStr( - from_utf8(InsetCommand::params2string(icp)), ar)) { + from_utf8(icp.toString()), ar)) { *this = *ar[0].nucleus()->asRefInset(); // FIXME audit setBuffer calls setBuffer(buf);