]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetSpace.cpp
Cocoa based Qt-4.6 needs to paint every character separately to match metrics computa...
[lyx.git] / src / insets / InsetSpace.cpp
index 3be9dee51b1bcfbf840c0bdcd0079fa19147aa9f..6e7c94d76576f28c0caffa1697c1d75be72bc2c4 100644 (file)
@@ -26,6 +26,7 @@
 #include "Lexer.h"
 #include "MetricsInfo.h"
 #include "OutputParams.h"
+#include "output_xhtml.h"
 
 #include "support/debug.h"
 #include "support/docstream.h"
@@ -43,7 +44,7 @@ namespace lyx {
 
 
 InsetSpace::InsetSpace(InsetSpaceParams const & params)
-       : params_(params)
+       : Inset(0), params_(params)
 {}
 
 
@@ -59,12 +60,6 @@ GlueLength InsetSpace::length() const
 }
 
 
-InsetSpace::~InsetSpace()
-{
-       hideDialogs("space", this);
-}
-
-
 docstring InsetSpace::toolTip(BufferView const &, int, int) const
 {
        docstring message;
@@ -88,7 +83,7 @@ docstring InsetSpace::toolTip(BufferView const &, int, int) const
                message = _("Quad Space");
                break;
        case InsetSpaceParams::QQUAD:
-               message = _("QQuad Space");
+               message = _("Double Quad Space");
                break;
        case InsetSpaceParams::ENSPACE:
                message = _("Enspace");
@@ -146,9 +141,10 @@ docstring InsetSpace::toolTip(BufferView const &, int, int) const
 
 void InsetSpace::doDispatch(Cursor & cur, FuncRequest & cmd)
 {
-       switch (cmd.action) {
+       switch (cmd.action()) {
 
        case LFUN_INSET_MODIFY:
+               cur.recordUndo();
                string2params(to_utf8(cmd.argument()), params_);
                break;
 
@@ -166,15 +162,18 @@ void InsetSpace::doDispatch(Cursor & cur, FuncRequest & cmd)
 bool InsetSpace::getStatus(Cursor & cur, FuncRequest const & cmd,
        FuncStatus & status) const
 {
-       switch (cmd.action) {
+       switch (cmd.action()) {
        // we handle these
        case LFUN_INSET_MODIFY:
                if (cmd.getArg(0) == "space") {
                        InsetSpaceParams params;
                        string2params(to_utf8(cmd.argument()), params);
                        status.setOnOff(params_.kind == params.kind);
-               }
-               // fall through
+                       status.setEnabled(true);        
+               } else
+                       status.setEnabled(false);
+               return true;
+
        case LFUN_INSET_DIALOG_UPDATE:
                status.setEnabled(true);
                return true;
@@ -184,14 +183,6 @@ bool InsetSpace::getStatus(Cursor & cur, FuncRequest const & cmd,
 }
 
 
-bool InsetSpace::showInsetDialog(BufferView * bv) const
-{
-       bv->showDialog("space", params2string(params()),
-               const_cast<InsetSpace *>(this));
-       return true;
-}
-
-
 namespace {
 int const arrow_size = 8;
 }
@@ -530,7 +521,7 @@ void InsetSpace::read(Lexer & lex)
 }
 
 
-int InsetSpace::latex(odocstream & os, OutputParams const & runparams) const
+void InsetSpace::latex(otexstream & os, OutputParams const & runparams) const
 {
        switch (params_.kind) {
        case InsetSpaceParams::NORMAL:
@@ -611,7 +602,6 @@ int InsetSpace::latex(odocstream & os, OutputParams const & runparams) const
                        os << "\\hspace*{" << from_ascii(params_.length.asLatexString()) << "}";
                break;
        }
-       return 0;
 }
 
 
@@ -688,31 +678,32 @@ int InsetSpace::docbook(odocstream & os, OutputParams const &) const
 }
 
 
-docstring InsetSpace::xhtml(odocstream & os, OutputParams const &) const
+docstring InsetSpace::xhtml(XHTMLStream & xs, OutputParams const &) const
 {
+       string output;
        switch (params_.kind) {
        case InsetSpaceParams::NORMAL:
-               os << " ";
+               output = " ";
                break;
        case InsetSpaceParams::ENSKIP:
        case InsetSpaceParams::ENSPACE:
-               os << "&ensp;";
+               output ="&ensp;";
                break;
        case InsetSpaceParams::QQUAD:
-               os << "&emsp;";
+               output ="&emsp;";
        case InsetSpaceParams::THICK:
        case InsetSpaceParams::QUAD:
-               os << "&emsp;";
+               output ="&emsp;";
                break;
        case InsetSpaceParams::THIN:
-               os << "&thinsp;";
+               output ="&thinsp;";
                break;
        case InsetSpaceParams::PROTECTED:
        case InsetSpaceParams::MEDIUM:
        case InsetSpaceParams::NEGTHIN:
        case InsetSpaceParams::NEGMEDIUM:
        case InsetSpaceParams::NEGTHICK:
-               os << "&nbsp;";
+               output ="&nbsp;";
                break;
        case InsetSpaceParams::HFILL:
        case InsetSpaceParams::HFILL_PROTECTED:
@@ -722,14 +713,17 @@ docstring InsetSpace::xhtml(odocstream & os, OutputParams const &) const
        case InsetSpaceParams::RIGHTARROWFILL:
        case InsetSpaceParams::UPBRACEFILL:
        case InsetSpaceParams::DOWNBRACEFILL:
-               // FIXME Can we do anything with those in HTML?
-               os << '\n';
+               // FIXME XHTML
+               // Can we do anything with those in HTML?
                break;
        case InsetSpaceParams::CUSTOM:
        case InsetSpaceParams::CUSTOM_PROTECTED:
-               // FIXME Probably we could do some sort of blank span?
-               os << '\n';
+               // FIXME XHTML
+               // Probably we could do some sort of blank span?
+               break;
        }
+       // don't escape the entities!
+       xs << XHTMLStream::ESCAPE_NONE << from_ascii(output);
        return docstring();
 }
 
@@ -742,12 +736,19 @@ void InsetSpace::validate(LaTeXFeatures & features) const
 }
 
 
-void InsetSpace::tocString(odocstream & os) const
+void InsetSpace::toString(odocstream & os) const
 {
        plaintext(os, OutputParams(0));
 }
 
 
+void InsetSpace::forToc(docstring & os, size_t) const
+{
+       // There's no need to be cute here.
+       os += " ";
+}
+
+
 bool InsetSpace::isStretchableSpace() const
 {
        return params_.kind == InsetSpaceParams::HFILL
@@ -761,7 +762,7 @@ bool InsetSpace::isStretchableSpace() const
 }
 
 
-docstring InsetSpace::contextMenu(BufferView const &, int, int) const
+docstring InsetSpace::contextMenuName() const
 {
        return from_ascii("context-space");
 }