1 /**
2  * \file InsetMathUnknown.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author André Pönitz
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10 
11 #include <config.h>
12 
13 #include "InsetMathUnknown.h"
14 
15 #include "MathSupport.h"
16 #include "MathAtom.h"
17 #include "MathStream.h"
18 
19 #include "MetricsInfo.h"
20 
21 #include "frontends/Painter.h"
22 
23 
24 namespace lyx {
25 
InsetMathUnknown(docstring const & nm,docstring const & selection,bool final,bool black)26 InsetMathUnknown::InsetMathUnknown(docstring const & nm,
27 	docstring const & selection, bool final, bool black)
28 	: name_(nm), final_(final), black_(black), kerning_(0),
29 	  selection_(selection)
30 {}
31 
32 
name() const33 docstring InsetMathUnknown::name() const
34 {
35 	return name_;
36 }
37 
38 
setName(docstring const & name)39 void InsetMathUnknown::setName(docstring const & name)
40 {
41 	name_ = name;
42 }
43 
44 
normalize(NormalStream & os) const45 void InsetMathUnknown::normalize(NormalStream & os) const
46 {
47 	os << "[unknown " << name_ << ']';
48 }
49 
50 
metrics(MetricsInfo & mi,Dimension & dim) const51 void InsetMathUnknown::metrics(MetricsInfo & mi, Dimension & dim) const
52 {
53 	metricsStrRedBlack(mi, dim, name_);
54 	docstring::const_reverse_iterator rit = name_.rbegin();
55 	kerning_ = mathed_char_kerning(mi.base.font, *rit);
56 }
57 
58 
draw(PainterInfo & pi,int x,int y) const59 void InsetMathUnknown::draw(PainterInfo & pi, int x, int y) const
60 {
61 	if (black_)
62 		drawStrBlack(pi, x, y, name_);
63 	else
64 		drawStrRed(pi, x, y, name_);
65 }
66 
67 
finalize()68 void InsetMathUnknown::finalize()
69 {
70 	final_ = true;
71 }
72 
73 
final() const74 bool InsetMathUnknown::final() const
75 {
76 	return final_;
77 }
78 
79 
maple(MapleStream & os) const80 void InsetMathUnknown::maple(MapleStream & os) const
81 {
82 	os << name_;
83 }
84 
85 
mathematica(MathematicaStream & os) const86 void InsetMathUnknown::mathematica(MathematicaStream & os) const
87 {
88 	os << name_;
89 }
90 
91 
mathmlize(MathStream &) const92 void InsetMathUnknown::mathmlize(MathStream &) const
93 {
94 	throw MathExportException();
95 }
96 
97 
htmlize(HtmlStream &) const98 void InsetMathUnknown::htmlize(HtmlStream &) const
99 {
100 	throw MathExportException();
101 }
102 
103 
octave(OctaveStream & os) const104 void InsetMathUnknown::octave(OctaveStream & os) const
105 {
106 	os << name_;
107 }
108 
109 
110 } // namespace lyx
111