[LyX/master] Rename DocumentCLass:plainInsetLayout() to InsetLayout::undefined()
Jean-Marc Lasgouttes
lasgouttes at lyx.org
Thu Jun 20 16:30:20 UTC 2024
commit 608929a857de98c0ca7af4edb79e5c0a017ede35
Author: Jean-Marc Lasgouttes <lasgouttes at lyx.org>
Date: Thu Jun 20 18:26:50 2024 +0200
Rename DocumentCLass:plainInsetLayout() to InsetLayout::undefined()
This makes the code easier to understand.
---
src/CutAndPaste.cpp | 4 ++--
src/TextClass.cpp | 8 +-------
src/TextClass.h | 2 --
src/insets/Inset.cpp | 4 ++--
src/insets/InsetFlex.cpp | 6 +++---
src/insets/InsetLayout.cpp | 6 ++++++
src/insets/InsetLayout.h | 3 +++
7 files changed, 17 insertions(+), 16 deletions(-)
diff --git a/src/CutAndPaste.cpp b/src/CutAndPaste.cpp
index abed1567d7..26cfc9bec8 100644
--- a/src/CutAndPaste.cpp
+++ b/src/CutAndPaste.cpp
@@ -883,10 +883,10 @@ void switchBetweenClasses(DocumentClassConstPtr oldone,
docstring const layoutName = iit->layoutName();
docstring const & n = newone->insetLayout(layoutName).name();
bool const is_undefined = n.empty() ||
- n == DocumentClass::plainInsetLayout().name();
+ n == InsetLayout::undefined().name();
docstring const & oldn = oldone->insetLayout(layoutName).name();
bool const was_undefined = oldn.empty() ||
- oldn == DocumentClass::plainInsetLayout().name();
+ oldn == InsetLayout::undefined().name();
if (!is_undefined || was_undefined)
continue;
diff --git a/src/TextClass.cpp b/src/TextClass.cpp
index b9c75259b4..8816470552 100644
--- a/src/TextClass.cpp
+++ b/src/TextClass.cpp
@@ -1869,13 +1869,7 @@ InsetLayout const & DocumentClass::insetLayout(docstring const & name) const
n = n.substr(0, i);
}
// Layout "name" not found.
- return plainInsetLayout();
-}
-
-
-InsetLayout const & DocumentClass::plainInsetLayout() {
- static const InsetLayout plain_insetlayout_;
- return plain_insetlayout_;
+ return InsetLayout::undefined();
}
diff --git a/src/TextClass.h b/src/TextClass.h
index 5a7f4c45bd..7626dc329d 100644
--- a/src/TextClass.h
+++ b/src/TextClass.h
@@ -448,8 +448,6 @@ public:
/// If that doesn't work either, an empty object returns (shouldn't
/// happen). -- Idea JMarc, comment MV
InsetLayout const & insetLayout(docstring const & name) const;
- /// a plain inset layout for use as a default
- static InsetLayout const & plainInsetLayout();
/// add a new layout \c name if it does not exist in layoutlist_
/// \return whether we had to add one.
bool addLayoutIfNeeded(docstring const & name) const;
diff --git a/src/insets/Inset.cpp b/src/insets/Inset.cpp
index 165df39657..b949f9c989 100644
--- a/src/insets/Inset.cpp
+++ b/src/insets/Inset.cpp
@@ -241,7 +241,7 @@ docstring Inset::layoutName() const
InsetLayout const & Inset::getLayout() const
{
if (!buffer_)
- return DocumentClass::plainInsetLayout();
+ return InsetLayout::undefined();
return buffer().params().documentClass().insetLayout(layoutName());
}
@@ -622,7 +622,7 @@ bool Inset::covers(BufferView const & bv, int x, int y) const
bool Inset::undefined() const
{
docstring const & n = getLayout().name();
- return n.empty() || n == DocumentClass::plainInsetLayout().name();
+ return n.empty() || n == InsetLayout::undefined().name();
}
diff --git a/src/insets/InsetFlex.cpp b/src/insets/InsetFlex.cpp
index 2a8af67fae..ee7f18b029 100644
--- a/src/insets/InsetFlex.cpp
+++ b/src/insets/InsetFlex.cpp
@@ -49,7 +49,7 @@ InsetFlex::InsetFlex(InsetFlex const & in)
InsetLayout const & InsetFlex::getLayout() const
{
if (!buffer_)
- return DocumentClass::plainInsetLayout();
+ return InsetLayout::undefined();
DocumentClass const & dc = buffer().params().documentClass();
docstring const dname = from_utf8(name_);
@@ -102,7 +102,7 @@ bool InsetFlex::getStatus(Cursor & cur, FuncRequest const & cmd,
InsetLyXType const type =
translateLyXType(to_utf8(cmd.argument()));
if (il.lyxtype() == type
- || (il.name() == DocumentClass::plainInsetLayout().name()
+ || (il.name() == InsetLayout::undefined().name()
&& type == InsetLyXType::CHARSTYLE)) {
FuncRequest temp_cmd(cmd.action());
return InsetCollapsible::getStatus(cur, temp_cmd, flag);
@@ -127,7 +127,7 @@ void InsetFlex::doDispatch(Cursor & cur, FuncRequest & cmd)
translateLyXType(to_utf8(cmd.argument()));
if (il.lyxtype() == type
- || (il.name() == DocumentClass::plainInsetLayout().name()
+ || (il.name() == InsetLayout::undefined().name()
&& type == InsetLyXType::CHARSTYLE)) {
FuncRequest temp_cmd(cmd.action());
InsetCollapsible::doDispatch(cur, temp_cmd);
diff --git a/src/insets/InsetLayout.cpp b/src/insets/InsetLayout.cpp
index d61c809394..024c81e40b 100644
--- a/src/insets/InsetLayout.cpp
+++ b/src/insets/InsetLayout.cpp
@@ -59,6 +59,12 @@ InsetLaTeXType translateLaTeXType(std::string const & str)
} // namespace
+InsetLayout const & InsetLayout::undefined() {
+ static const InsetLayout undefined_;
+ return undefined_;
+}
+
+
bool InsetLayout::read(Lexer & lex, TextClass const & tclass,
bool validating)
{
diff --git a/src/insets/InsetLayout.h b/src/insets/InsetLayout.h
index 2d206fd7a5..a426a4ca86 100644
--- a/src/insets/InsetLayout.h
+++ b/src/insets/InsetLayout.h
@@ -56,6 +56,9 @@ class InsetLayout {
public:
///
InsetLayout() { labelfont_.setColor(Color_insetlabel); }
+ /// a plain inset layout for when there is no inset layout
+ static InsetLayout const & undefined();
+
///
bool read(support::Lexer & lexrc, TextClass const & tclass,
bool validating = false);
More information about the lyx-cvs
mailing list