]> git.lyx.org Git - lyx.git/blobdiff - src/Text2.cpp
Improve fullscreen capabilities ( http://bugzilla.lyx.org/show_bug.cgi?id=4146 ).
[lyx.git] / src / Text2.cpp
index 2a6abbfb39566c6cc997e9e820d313f1fffe9b50..699d0e9d9d6d016300b1855aecfa477941856a28 100644 (file)
 #include "Changes.h"
 #include "Cursor.h"
 #include "CutAndPaste.h"
-#include "debug.h"
 #include "DispatchResult.h"
 #include "ErrorList.h"
 #include "FuncRequest.h"
-#include "gettext.h"
 #include "Language.h"
 #include "Layout.h"
 #include "Lexer.h"
@@ -44,9 +42,7 @@
 #include "Paragraph.h"
 #include "paragraph_funcs.h"
 #include "ParagraphParameters.h"
-#include "ParIterator.h"
-#include "Server.h"
-#include "ServerSocket.h"
+#include "TextClass.h"
 #include "TextMetrics.h"
 #include "VSpace.h"
 
 
 #include "mathed/InsetMathHull.h"
 
+#include "support/debug.h"
+#include "support/gettext.h"
 #include "support/textutils.h"
 
-#include <boost/current_function.hpp>
 #include <boost/next_prior.hpp>
 
 #include <sstream>
 
-using std::endl;
-using std::ostringstream;
-using std::string;
-using std::max;
-using std::min;
-using std::istringstream;
+using namespace std;
 
 namespace lyx {
 
@@ -167,10 +159,9 @@ void Text::setCharFont(Buffer const & buffer, pit_type pit,
 void Text::setInsetFont(BufferView const & bv, pit_type pit,
                pos_type pos, Font const & font, bool toggleall)
 {
-       BOOST_ASSERT(pars_[pit].isInset(pos) &&
-                    pars_[pit].getInset(pos)->noFontChange());
-
        Inset * const inset = pars_[pit].getInset(pos);
+       BOOST_ASSERT(inset && inset->noFontChange());
+
        CursorSlice::idx_type endidx = inset->nargs();
        for (CursorSlice cs(*inset); cs.idx() != endidx; ++cs.idx()) {
                Text * text = cs.text();
@@ -232,7 +223,7 @@ void Text::setLayout(Cursor & cur, docstring const & layout)
        LayoutPtr const & lyxlayout = params.getTextClass()[layout];
        if (lyxlayout->is_environment) {
                // move everything in a new environment inset
-               LYXERR(Debug::DEBUG) << "setting layout " << to_utf8(layout) << endl;
+               LYXERR(Debug::DEBUG, "setting layout " << to_utf8(layout));
                lyx::dispatch(FuncRequest(LFUN_LINE_BEGIN));
                lyx::dispatch(FuncRequest(LFUN_LINE_END_SELECT));
                lyx::dispatch(FuncRequest(LFUN_CUT));
@@ -361,13 +352,14 @@ void Text::setFont(BufferView const & bv, CursorSlice const & begin,
                if (dit.pos() != dit.lastpos()) {
                        pit_type const pit = dit.pit();
                        pos_type const pos = dit.pos();
-                       if (pars_[pit].isInset(pos) &&
-                           pars_[pit].getInset(pos)->noFontChange())
+                       Inset * inset = pars_[pit].getInset(pos);
+                       if (inset && inset->noFontChange()) {
                                // We need to propagate the font change to all
                                // text cells of the inset (bug 1973).
                                // FIXME: This should change, see documentation
                                // of noFontChange in Inset.h
                                setInsetFont(bv, pit, pos, font, toggleall);
+                       }
                        TextMetrics const & tm = bv.textMetrics(this);
                        Font f = tm.getDisplayFont(pit, pos);
                        f.update(font, language, toggleall);
@@ -746,7 +738,7 @@ void Text::fixCursorAfterDelete(CursorSlice & cur, CursorSlice const & where)
 bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
                Cursor & old, bool & need_anchor_change)
 {
-       //LYXERR(Debug::DEBUG) << "DEPM: cur:\n" << cur << "old:\n" << old << endl;
+       //LYXERR(Debug::DEBUG, "DEPM: cur:\n" << cur << "old:\n" << old);
 
        Paragraph & oldpar = old.paragraph();
 
@@ -819,7 +811,7 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
                bool const soa = oldpar.params().startOfAppendix();
                plist.erase(boost::next(plist.begin(), old.pit()));
                // do not lose start of appendix marker (bug 4212)
-               if (soa)
+               if (soa && old.pit() < pit_type(plist.size()))
                        plist[old.pit()].params().startOfAppendix(true);
 
                // see #warning (FIXME?) above