]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathRoot.cpp
Do not throw exceptions here either. See r22806.
[lyx.git] / src / mathed / InsetMathRoot.cpp
index 0017e1c9542e38111970fac0ce880dd1d6b9e97a..050787cca891d696fe7dde721aab2b75dc403396 100644 (file)
@@ -4,7 +4,7 @@
  * Licence details can be found in the file COPYING.
  *
  * \author Alejandro Aguilar Sierra
- * \author André Pönitz
+ * \author André Pönitz
  *
  * Full author contact details are available in file CREDITS.
  */
@@ -12,6 +12,8 @@
 #include <config.h>
 
 #include "InsetMathRoot.h"
+
+#include "LaTeXFeatures.h"
 #include "MathData.h"
 #include "MathStream.h"
 #include "Cursor.h"
@@ -23,8 +25,8 @@ using namespace std;
 namespace lyx {
 
 
-InsetMathRoot::InsetMathRoot()
-       : InsetMathNest(2)
+InsetMathRoot::InsetMathRoot(Buffer * buf)
+       : InsetMathNest(buf, 2)
 {}
 
 
@@ -43,8 +45,6 @@ void InsetMathRoot::metrics(MetricsInfo & mi, Dimension & dim) const
        dim.des = max(dim0.descent() - 5, dim1.descent()) + 2;
        dim.wid = dim0.width() + dim1.width() + 10;
        metricsMarkers(dim);
-       // Cache the inset dimension. 
-       setDimCache(mi, dim);
 }
 
 
@@ -74,6 +74,7 @@ void InsetMathRoot::draw(PainterInfo & pi, int x, int y) const
 
 void InsetMathRoot::write(WriteStream & os) const
 {
+       MathEnsurer ensurer(os);
        os << "\\sqrt[" << cell(0) << "]{" << cell(1) << '}';
 }
 
@@ -119,4 +120,24 @@ void InsetMathRoot::mathmlize(MathStream & os) const
 }
 
 
+void InsetMathRoot::htmlize(HtmlStream & os) const
+{
+       os << MTag("span", "class='root'")
+          << MTag("sup") << cell(0) << ETag("sup")
+          << from_ascii("&radic;") 
+          << MTag("span", "class='rootof'")    << cell(1) << ETag("span") 
+                << ETag("span");
+}
+
+
+void InsetMathRoot::validate(LaTeXFeatures & features) const
+{
+       if (features.runparams().math_flavor == OutputParams::MathAsHTML)
+               features.addPreambleSnippet("<style type=\"text/css\">\n"
+                       "span.rootof{border-top: thin solid black;}\n"
+                       "span.root sup{font-size: 75%;}\n"
+                       "</style>");
+       InsetMathNest::validate(features);
+}
+
 } // namespace lyx