X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2FInset.cpp;h=7d05c8ef1fa3097e8ae9cc8af773232e894ad969;hb=eeb36e808c9726fd3689926a3c20457e3b801341;hp=2043436ba93409edb22317a45ab8fc2ae469e2de;hpb=684d27c0fbae75931586324c061e6a6b456ea632;p=lyx.git diff --git a/src/insets/Inset.cpp b/src/insets/Inset.cpp index 2043436ba9..7d05c8ef1f 100644 --- a/src/insets/Inset.cpp +++ b/src/insets/Inset.cpp @@ -27,8 +27,10 @@ #include "DispatchResult.h" #include "FuncRequest.h" #include "FuncStatus.h" +#include "InsetLayout.h" #include "MetricsInfo.h" #include "output_xhtml.h" +#include "xml.h" #include "Text.h" #include "TextClass.h" #include "TocBackend.h" @@ -225,7 +227,7 @@ bool Inset::isBufferLoaded() const bool Inset::isBufferValid() const { return buffer_ - && (isBufferLoaded() || buffer_->isClone()); + && (isBufferLoaded() || buffer_->isInternal() || buffer_->isClone()); } @@ -235,6 +237,20 @@ docstring Inset::layoutName() const } +InsetLayout const & Inset::getLayout() const +{ + if (!buffer_) + return DocumentClass::plainInsetLayout(); + return buffer().params().documentClass().insetLayout(layoutName()); +} + + +bool Inset::isPassThru() const +{ + return getLayout().isPassThru(); +} + + bool Inset::isFreeSpacing() const { return getLayout().isFreeSpacing(); @@ -259,6 +275,18 @@ bool Inset::isInToc() const } +FontInfo Inset::getFont() const +{ + return getLayout().font(); +} + + +FontInfo Inset::getLabelfont() const +{ + return getLayout().labelfont(); +} + + docstring Inset::toolTip(BufferView const &, int, int) const { return docstring(); @@ -315,7 +343,7 @@ docstring insetDisplayName(InsetCode c) void Inset::dispatch(Cursor & cur, FuncRequest & cmd) { - if (buffer_ == 0) { + if (buffer_ == nullptr) { lyxerr << "Unassigned buffer_ member in Inset::dispatch()" << std::endl; lyxerr << "LyX Code: " << lyxCode() << " name: " << insetName(lyxCode()) << std::endl; @@ -380,7 +408,7 @@ void Inset::doDispatch(Cursor & cur, FuncRequest &cmd) bool Inset::getStatus(Cursor &, FuncRequest const & cmd, - FuncStatus & flag) const + FuncStatus & status) const { // LFUN_INSET_APPLY is sent from the dialogs when the data should // be applied. This is either changed to LFUN_INSET_MODIFY (if the @@ -395,20 +423,20 @@ bool Inset::getStatus(Cursor &, FuncRequest const & cmd, // Allow modification of our data. // This needs to be handled in the doDispatch method of our // instantiatable children. - flag.setEnabled(true); + status.setEnabled(true); return true; case LFUN_INSET_INSERT: // Don't allow insertion of new insets. // Every inset that wants to allow new insets from open // dialogs needs to override this. - flag.setEnabled(false); + status.setEnabled(false); return true; case LFUN_INSET_SETTINGS: if (cmd.argument().empty() || cmd.getArg(0) == insetName(lyxCode())) { bool const enable = hasSettings(); - flag.setEnabled(enable); + status.setEnabled(enable); return true; } else { return false; @@ -416,12 +444,12 @@ bool Inset::getStatus(Cursor &, FuncRequest const & cmd, case LFUN_IN_MATHMACROTEMPLATE: // By default we're not in a InsetMathMacroTemplate inset - flag.setEnabled(false); + status.setEnabled(false); return true; case LFUN_IN_IPA: // By default we're not in an IPA inset - flag.setEnabled(false); + status.setEnabled(false); return true; default: @@ -444,7 +472,7 @@ Inset * Inset::editXY(Cursor &, int x, int y) } -Inset::idx_type Inset::index(row_type row, col_type col) const +idx_type Inset::index(row_type row, col_type col) const { if (row != 0) LYXERR0("illegal row: " << row); @@ -466,13 +494,13 @@ bool Inset::idxUpDown(Cursor &, bool) const } -int Inset::docbook(odocstream &, OutputParams const &) const +void Inset::docbook(XMLStream & xs, OutputParams const &) const { - return 0; + xs << "[[Inset: " << from_ascii(insetName(lyxCode())) << "]]"; } -docstring Inset::xhtml(XHTMLStream & xs, OutputParams const &) const +docstring Inset::xhtml(XMLStream & xs, OutputParams const &) const { xs << "[[Inset: " << from_ascii(insetName(lyxCode())) << "]]"; return docstring(); @@ -578,18 +606,16 @@ bool Inset::covers(BufferView const & bv, int x, int y) const } -InsetLayout const & Inset::getLayout() const +bool Inset::undefined() const { - if (!buffer_) - return DocumentClass::plainInsetLayout(); - return buffer().params().documentClass().insetLayout(layoutName()); + docstring const & n = getLayout().name(); + return n.empty() || n == DocumentClass::plainInsetLayout().name(); } -bool Inset::undefined() const +CtObject Inset::getCtObject(OutputParams const &) const { - docstring const & n = getLayout().name(); - return n.empty() || n == DocumentClass::plainInsetLayout().name(); + return CtObject::Normal; } @@ -618,8 +644,8 @@ Buffer const * Inset::updateFrontend() const // are in the CutAndPaste stack. See InsetGraphics, RenderGraphics and // RenderPreview. if (!buffer_) - return 0; - return theApp() ? theApp()->updateInset(this) : 0; + return nullptr; + return theApp() ? theApp()->updateInset(this) : nullptr; }