]> git.lyx.org Git - lyx.git/blobdiff - src/bufferparams.C
more cursor dispatch
[lyx.git] / src / bufferparams.C
index 4ed8a2e915e19ad5f819c40359f97f0cc016a540..0f119fe5731b17ae4706c195b7e08afb92146062 100644 (file)
 #include "gettext.h"
 #include "language.h"
 #include "LaTeXFeatures.h"
-#include "latexrunparams.h"
+#include "LColor.h"
 #include "lyxlex.h"
 #include "lyxrc.h"
 #include "lyxtextclasslist.h"
+#include "outputparams.h"
 #include "tex-strings.h"
 #include "Spacing.h"
 #include "texrow.h"
@@ -36,7 +37,6 @@
 
 #include "frontends/Alert.h"
 
-#include "support/LAssert.h"
 #include "support/lyxalgo.h" // for lyx::count
 
 #include <boost/array.hpp>
 #include "support/std_sstream.h"
 
 namespace support = lyx::support;
-using namespace lyx::support;
+using lyx::support::bformat;
+using lyx::support::rtrim;
+using lyx::support::tokenPos;
 
 using std::endl;
-
+using std::string;
 using std::istringstream;
 using std::ostream;
 using std::ostringstream;
@@ -78,13 +80,26 @@ BufferParams::Impl::Impl()
 }
 
 
+BufferParams::Impl *
+BufferParams::MemoryTraits::clone(BufferParams::Impl const * ptr)
+{
+       return new BufferParams::Impl(*ptr);
+}
+
+
+void BufferParams::MemoryTraits::destroy(BufferParams::Impl * ptr)
+{
+       delete ptr;
+}
+
+
 BufferParams::BufferParams()
-       : pimpl_(new Impl),
-         // Initialize textclass to point to article. if `first' is
+       : // Initialize textclass to point to article. if `first' is
          // true in the returned pair, then `second' is the textclass
          // number; if it is false, second is 0. In both cases, second
          // is what we want.
-         textclass(textclasslist.NumberOfClass("article").second)
+       textclass(textclasslist.NumberOfClass("article").second),
+       pimpl_(new Impl)
 {
        paragraph_separation = PARSEP_INDENT;
        quotes_language = InsetQuotes::EnglishQ;
@@ -148,28 +163,28 @@ BranchList const & BufferParams::branchlist() const
 
 Bullet & BufferParams::temp_bullet(lyx::size_type index)
 {
-       support::Assert(index < 4);
+       BOOST_ASSERT(index < 4);
        return pimpl_->temp_bullets[index];
 }
 
 
 Bullet const & BufferParams::temp_bullet(lyx::size_type index) const
 {
-       support::Assert(index < 4);
+       BOOST_ASSERT(index < 4);
        return pimpl_->temp_bullets[index];
 }
 
 
 Bullet & BufferParams::user_defined_bullet(lyx::size_type index)
 {
-       support::Assert(index < 4);
+       BOOST_ASSERT(index < 4);
        return pimpl_->user_defined_bullets[index];
 }
 
 
 Bullet const & BufferParams::user_defined_bullet(lyx::size_type index) const
 {
-       support::Assert(index < 4);
+       BOOST_ASSERT(index < 4);
        return pimpl_->user_defined_bullets[index];
 }
 
@@ -318,25 +333,27 @@ string const BufferParams::readToken(LyXLex & lex, string const & token)
                        string const tok = lex.getString();
                        if (tok == "\\end_branch")
                                break;
+                       Branch * branch_ptr = branchlist().find(branch);
                        if (tok == "\\selected") {
                                lex.nextToken();
-                               branchlist().setSelected(branch, lex.getInteger());
+                               if (branch_ptr)
+                                       branch_ptr->setSelected(lex.getInteger());
                        }
                        // not yet operational
                        if (tok == "\\color") {
                                lex.nextToken();
                                string color = lex.getString();
-                               branchlist().setColor(branch, color);
+                               if (branch_ptr)
+                                       branch_ptr->setColor(color);
                                // Update also the LColor table:
-                               if (color == "none") 
+                               if (color == "none")
                                        color = lcolor.getX11Name(LColor::background);
-                               lcolor.fill(static_cast<LColor::color>(lcolor.size()), 
-                                               branch, color);
+                               lcolor.setColor(lcolor.getFromLyXName(branch), color);
                        }
                }
        } else if (token == "\\author") {
                lex.nextToken();
-               istringstream ss(STRCONV(lex.getString()));
+               istringstream ss(lex.getString());
                Author a;
                ss >> a;
                author_map.push_back(pimpl_->authorlist.record(a));
@@ -527,9 +544,9 @@ void BufferParams::writeFile(ostream & os) const
        std::list<Branch>::const_iterator end = branchlist().end();
        for (; it != end; ++it) {
                os << "\\branch " << it->getBranch()
-                  << "\n\\selected " << it->getSelected()      
-                  << "\n\\color " << it->getColor()    
-                  << "\n\\end_branch" 
+                  << "\n\\selected " << it->getSelected()
+                  << "\n\\color " << it->getColor()
+                  << "\n\\end_branch"
                   << "\n";
        }
 
@@ -699,7 +716,7 @@ bool BufferParams::writeLaTeX(ostream & os, LaTeXFeatures & features,
                clsoptions << options << ',';
        }
 
-       string strOptions(STRCONV(clsoptions.str()));
+       string strOptions(clsoptions.str());
        if (!strOptions.empty()) {
                strOptions = rtrim(strOptions, ",");
                os << '[' << strOptions << ']';
@@ -976,7 +993,7 @@ bool BufferParams::writeLaTeX(ostream & os, LaTeXFeatures & features,
                if (!lyxrc.language_global_options
                    && tmp == "\\usepackage{babel}")
                        tmp = string("\\usepackage[") +
-                               STRCONV(language_options.str()) +
+                               language_options.str() +
                                "]{babel}";
                lyxpreamble += tmp + "\n";
                lyxpreamble += features.getBabelOptions();