]> git.lyx.org Git - lyx.git/blobdiff - src/Buffer.cpp
Refactor InsetQuotes.h enums
[lyx.git] / src / Buffer.cpp
index f537ac047d5ea73a1a67f8cdf5e8a9ce154ac905..64513fada1916611dc432c40427eabacc600da3a 100644 (file)
@@ -1275,9 +1275,9 @@ void Buffer::updatePreviews() const
        if (!ploader)
                return;
 
-       InsetIterator it = inset_iterator_begin(*d->inset);
-       InsetIterator const end = inset_iterator_end(*d->inset);
-       for (; it != end; ++it)
+       InsetIterator it = begin(*d->inset);
+       InsetIterator const itend = end(*d->inset);
+       for (; it != itend; ++it)
                it->addPreview(it, *ploader);
 
        ploader->startLoading();
@@ -2321,7 +2321,7 @@ int Buffer::runChktex()
 
        // Generate the LaTeX file if neccessary
        OutputParams runparams(&params().encoding());
-       runparams.flavor = OutputParams::LATEX;
+       runparams.flavor = FLAVOR::LATEX;
        runparams.nice = false;
        runparams.linelen = lyxrc.plaintext_linelen;
        ExportStatus const retval =
@@ -2581,7 +2581,7 @@ void Buffer::collectBibKeys(FileNameList & checkedFiles) const
        if (!parent())
                clearIncludeList();
 
-       for (InsetIterator it = inset_iterator_begin(inset()); it; ++it) {
+       for (InsetIterator it = begin(inset()); it; ++it) {
                it->collectBibKeys(it, checkedFiles);
                if (it->lyxCode() == BIBITEM_CODE) {
                        if (parent() != nullptr)
@@ -2959,10 +2959,10 @@ void Buffer::dispatch(FuncRequest const & func, DispatchResult & dr)
 
                docstring const oldname = from_utf8(func.getArg(0));
                docstring const newname = from_utf8(func.getArg(1));
-               InsetIterator it  = inset_iterator_begin(inset());
-               InsetIterator const end = inset_iterator_end(inset());
+               InsetIterator it  = begin(inset());
+               InsetIterator const itend = end(inset());
                bool success = false;
-               for (; it != end; ++it) {
+               for (; it != itend; ++it) {
                        if (it->lyxCode() == BRANCH_CODE) {
                                InsetBranch & ins = static_cast<InsetBranch &>(*it);
                                if (ins.branch() == oldname) {
@@ -3841,11 +3841,9 @@ void Buffer::updateMacros() const
 
 void Buffer::getUsedBranches(std::list<docstring> & result, bool const from_master) const
 {
-       InsetIterator it  = inset_iterator_begin(inset());
-       InsetIterator const end = inset_iterator_end(inset());
-       for (; it != end; ++it) {
-               if (it->lyxCode() == BRANCH_CODE) {
-                       InsetBranch & br = static_cast<InsetBranch &>(*it);
+       for (Inset const & it : inset()) {
+               if (it.lyxCode() == BRANCH_CODE) {
+                       InsetBranch const & br = static_cast<InsetBranch const &>(it);
                        docstring const name = br.branch();
                        if (!from_master && !params().branchlist().find(name))
                                result.push_back(name);
@@ -3853,10 +3851,10 @@ void Buffer::getUsedBranches(std::list<docstring> & result, bool const from_mast
                                result.push_back(name);
                        continue;
                }
-               if (it->lyxCode() == INCLUDE_CODE) {
+               if (it.lyxCode() == INCLUDE_CODE) {
                        // get buffer of external file
                        InsetInclude const & ins =
-                               static_cast<InsetInclude const &>(*it);
+                               static_cast<InsetInclude const &>(it);
                        Buffer * child = ins.loadIfNeeded();
                        if (!child)
                                continue;
@@ -4027,7 +4025,7 @@ void Buffer::changeRefsIfUnique(docstring const & from, docstring const & to)
 
        string const paramName = "key";
        UndoGroupHelper ugh(this);
-       InsetIterator it = inset_iterator_begin(inset());
+       InsetIterator it = begin(inset());
        for (; it; ++it) {
                if (it->lyxCode() != CITE_CODE)
                        continue;
@@ -4071,23 +4069,23 @@ unique_ptr<TexRow> Buffer::getSourceCode(odocstream & os, string const & format,
                           << "\n\n";
                }
                // output paragraphs
-               if (runparams.flavor == OutputParams::LYX) {
+               if (runparams.flavor == FLAVOR::LYX) {
                        Paragraph const & par = text().paragraphs()[par_begin];
                        ostringstream ods;
                        depth_type dt = par.getDepth();
                        par.write(ods, params(), dt);
                        os << from_utf8(ods.str());
-               } else if (runparams.flavor == OutputParams::HTML) {
+               } else if (runparams.flavor == FLAVOR::HTML) {
                        XMLStream xs(os);
                        setMathFlavor(runparams);
                        xhtmlParagraphs(text(), *this, xs, runparams);
-               } else if (runparams.flavor == OutputParams::TEXT) {
+               } else if (runparams.flavor == FLAVOR::TEXT) {
                        bool dummy = false;
                        // FIXME Handles only one paragraph, unlike the others.
                        // Probably should have some routine with a signature like them.
                        writePlaintextParagraph(*this,
                                text().paragraphs()[par_begin], os, runparams, dummy);
-               } else if (runparams.flavor == OutputParams::DOCBOOK5) {
+               } else if (runparams.flavor == FLAVOR::DOCBOOK5) {
                        XMLStream xs{os};
                        docbookParagraphs(text(), *this, xs, runparams);
                } else {
@@ -4125,7 +4123,7 @@ unique_ptr<TexRow> Buffer::getSourceCode(odocstream & os, string const & format,
                else if (output == OnlyBody)
                        os << _("Preview body");
                os << "\n\n";
-               if (runparams.flavor == OutputParams::LYX) {
+               if (runparams.flavor == FLAVOR::LYX) {
                        ostringstream ods;
                        if (output == FullSource)
                                write(ods);
@@ -4134,14 +4132,14 @@ unique_ptr<TexRow> Buffer::getSourceCode(odocstream & os, string const & format,
                        else if (output == OnlyBody)
                                text().write(ods);
                        os << from_utf8(ods.str());
-               } else if (runparams.flavor == OutputParams::HTML) {
+               } else if (runparams.flavor == FLAVOR::HTML) {
                        writeLyXHTMLSource(os, runparams, output);
-               } else if (runparams.flavor == OutputParams::TEXT) {
+               } else if (runparams.flavor == FLAVOR::TEXT) {
                        if (output == OnlyPreamble) {
                                os << "% "<< _("Plain text does not have a preamble.");
                        } else
                                writePlaintextFile(*this, os, runparams);
-               } else if (runparams.flavor == OutputParams::DOCBOOK5) {
+               } else if (runparams.flavor == FLAVOR::DOCBOOK5) {
                        writeDocBookSource(os, runparams, output);
                } else {
                        // latex or literate
@@ -4376,7 +4374,7 @@ Buffer::ExportStatus Buffer::doExport(string const & target, bool put_in_tempdir
        }
        MarkAsExporting exporting(this);
        string backend_format;
-       runparams.flavor = OutputParams::LATEX;
+       runparams.flavor = FLAVOR::LATEX;
        runparams.linelen = lyxrc.plaintext_linelen;
        runparams.includeall = includeall;
        vector<string> backs = params().backends();
@@ -4420,13 +4418,13 @@ Buffer::ExportStatus Buffer::doExport(string const & target, bool put_in_tempdir
                LYXERR(Debug::FILES, "backend_format=" << backend_format);
                // FIXME: Don't hardcode format names here, but use a flag
                if (backend_format == "pdflatex")
-                       runparams.flavor = OutputParams::PDFLATEX;
+                       runparams.flavor = FLAVOR::PDFLATEX;
                else if (backend_format == "luatex")
-                       runparams.flavor = OutputParams::LUATEX;
+                       runparams.flavor = FLAVOR::LUATEX;
                else if (backend_format == "dviluatex")
-                       runparams.flavor = OutputParams::DVILUATEX;
+                       runparams.flavor = FLAVOR::DVILUATEX;
                else if (backend_format == "xetex")
-                       runparams.flavor = OutputParams::XETEX;
+                       runparams.flavor = FLAVOR::XETEX;
        }
 
        string filename = latexName(false);
@@ -4437,7 +4435,7 @@ Buffer::ExportStatus Buffer::doExport(string const & target, bool put_in_tempdir
 
        // Plain text backend
        if (backend_format == "text") {
-               runparams.flavor = OutputParams::TEXT;
+               runparams.flavor = FLAVOR::TEXT;
                try {
                        writePlaintextFile(*this, FileName(filename), runparams);
                }
@@ -4445,7 +4443,7 @@ Buffer::ExportStatus Buffer::doExport(string const & target, bool put_in_tempdir
        }
        // HTML backend
        else if (backend_format == "xhtml") {
-               runparams.flavor = OutputParams::HTML;
+               runparams.flavor = FLAVOR::HTML;
                setMathFlavor(runparams);
                if (makeLyXHTMLFile(FileName(filename), runparams) == ExportKilled)
                        return ExportKilled;
@@ -4453,7 +4451,7 @@ Buffer::ExportStatus Buffer::doExport(string const & target, bool put_in_tempdir
                writeFile(FileName(filename));
        // DocBook backend
        else if (backend_format == "docbook5") {
-               runparams.flavor = OutputParams::DOCBOOK5;
+               runparams.flavor = FLAVOR::DOCBOOK5;
                runparams.nice = false;
                if (makeDocBookFile(FileName(filename), runparams) == ExportKilled)
                        return ExportKilled;