]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetpagebreak.C
* src/LyXAction.C: mark goto-clear-bookmark as working without buffer
[lyx.git] / src / insets / insetpagebreak.C
index 037e9b7293381b2f89ec43e0b5c8596ec6e10449..3be10572cf9c11741a68dae83aa3af3cff103325 100644 (file)
 #include "insetpagebreak.h"
 
 #include "debug.h"
+#include "gettext.h"
 #include "LColor.h"
 #include "lyxtext.h"
 #include "metricsinfo.h"
-#include "gettext.h"
+#include "TextMetrics.h"
 
-#include "frontends/Application.h"
-#include "frontends/FontLoader.h"
 #include "frontends/FontMetrics.h"
 #include "frontends/Painter.h"
 
-using lyx::docstring;
-using lyx::frontend::Painter;
+
+namespace lyx {
+
+using frontend::Painter;
 
 using std::endl;
 using std::ostream;
@@ -38,23 +39,23 @@ void InsetPagebreak::read(Buffer const &, LyXLex &)
 
 void InsetPagebreak::write(Buffer const &, ostream & os) const
 {
-       os << "\n\\newpage\n";
+       os << "\n" << getCmdName() << '\n';
 }
 
 
-void InsetPagebreak::metrics(MetricsInfo & mi, Dimension & dim) const
+bool InsetPagebreak::metrics(MetricsInfo & mi, Dimension & dim) const
 {
        dim.asc = defaultRowHeight();
        dim.des = defaultRowHeight();
        dim.wid = mi.base.textwidth;
+       bool const changed = dim_ != dim;
        dim_ = dim;
+       return changed;
 }
 
 
 void InsetPagebreak::draw(PainterInfo & pi, int x, int y) const
 {
-       static docstring const label = _("Page Break");
-
        LyXFont font;
        font.setColor(LColor::pagebreak);
        font.decSize();
@@ -62,12 +63,12 @@ void InsetPagebreak::draw(PainterInfo & pi, int x, int y) const
        int w = 0;
        int a = 0;
        int d = 0;
-       theApp->fontLoader().metrics(font).rectText(label, w, a, d);
+       theFontMetrics(font).rectText(insetLabel(), w, a, d);
 
        int const text_start = int(x + (dim_.wid - w) / 2);
        int const text_end = text_start + w;
 
-       pi.pain.rectText(text_start, y + d, label, font,
+       pi.pain.rectText(text_start, y + d, insetLabel(), font,
                LColor::none, LColor::none);
 
        pi.pain.line(x, y, text_start, y,
@@ -77,15 +78,15 @@ void InsetPagebreak::draw(PainterInfo & pi, int x, int y) const
 }
 
 
-int InsetPagebreak::latex(Buffer const &, ostream & os,
+int InsetPagebreak::latex(Buffer const &, odocstream & os,
                          OutputParams const &) const
 {
-       os << "\\newpage{}";
+       os << from_ascii(getCmdName()) << "{}";
        return 0;
 }
 
 
-int InsetPagebreak::plaintext(Buffer const &, ostream & os,
+int InsetPagebreak::plaintext(Buffer const &, odocstream & os,
                          OutputParams const &) const
 {
        os << '\n';
@@ -93,9 +94,12 @@ int InsetPagebreak::plaintext(Buffer const &, ostream & os,
 }
 
 
-int InsetPagebreak::docbook(Buffer const &, std::ostream & os,
+int InsetPagebreak::docbook(Buffer const &, odocstream & os,
                            OutputParams const &) const
 {
        os << '\n';
        return 0;
 }
+
+
+} // namespace lyx