]> git.lyx.org Git - lyx.git/blobdiff - src/Buffer.cpp
* src/buffer_funcs.{cpp,h}:
[lyx.git] / src / Buffer.cpp
index 444887bdb6e810d8904cacf4ffda1ab722748a39..5be6679dca5479e1ea9c3d989919eba9eb629ee9 100644 (file)
@@ -118,7 +118,7 @@ namespace {
 
 // Do not remove the comment below, so we get merge conflict in
 // independent branches. Instead add your own.
-int const LYX_FORMAT = 345;  // jamatos: xml elements
+int const LYX_FORMAT = 346;  // jspitzm: Swiss German
 
 typedef map<string, bool> DepClean;
 typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;
@@ -588,7 +588,7 @@ bool Buffer::readDocument(Lexer & lex)
                FileName const master_file = makeAbsPath(params().master,
                           onlyPath(absFileName()));
                if (isLyXFilename(master_file.absFilename())) {
-                       Buffer * master = checkAndLoadLyXFile(master_file);
+                       Buffer * master = checkAndLoadLyXFile(master_file, true);
                        d->parent_buffer = master;
                }
        }
@@ -685,6 +685,8 @@ bool Buffer::readFile(FileName const & filename)
 {
        FileName fname(filename);
 
+       params().compressed = fname.isZippedFile();
+
        // remove dummy empty par
        paragraphs().clear();
        Lexer lex;
@@ -1515,17 +1517,18 @@ bool Buffer::isMultiLingual() const
 
 DocIterator Buffer::getParFromID(int const id) const
 {
+       Buffer * buf = const_cast<Buffer *>(this);
        if (id < 0) {
                // John says this is called with id == -1 from undo
                lyxerr << "getParFromID(), id: " << id << endl;
-               return doc_iterator_end(inset());
+               return doc_iterator_end(buf);
        }
 
-       for (DocIterator it = doc_iterator_begin(inset()); !it.atEnd(); it.forwardPar())
+       for (DocIterator it = doc_iterator_begin(buf); !it.atEnd(); it.forwardPar())
                if (it.paragraph().id() == id)
                        return it;
 
-       return doc_iterator_end(inset());
+       return doc_iterator_end(buf);
 }
 
 
@@ -1537,25 +1540,25 @@ bool Buffer::hasParWithID(int const id) const
 
 ParIterator Buffer::par_iterator_begin()
 {
-       return ParIterator(doc_iterator_begin(inset()));
+       return ParIterator(doc_iterator_begin(this));
 }
 
 
 ParIterator Buffer::par_iterator_end()
 {
-       return ParIterator(doc_iterator_end(inset()));
+       return ParIterator(doc_iterator_end(this));
 }
 
 
 ParConstIterator Buffer::par_iterator_begin() const
 {
-       return lyx::par_const_iterator_begin(inset());
+       return ParConstIterator(doc_iterator_begin(this));
 }
 
 
 ParConstIterator Buffer::par_iterator_end() const
 {
-       return lyx::par_const_iterator_end(inset());
+       return ParConstIterator(doc_iterator_end(this));
 }
 
 
@@ -1737,7 +1740,7 @@ DocIterator Buffer::firstChildPosition(Buffer const * child)
        Impl::BufferPositionMap::iterator it;
        it = d->children_positions.find(child);
        if (it == d->children_positions.end())
-               return DocIterator();
+               return DocIterator(this);
        return it->second;
 }
 
@@ -1772,11 +1775,11 @@ MacroData const * Buffer::getBufferMacro(docstring const & name,
 
        // find macro definitions for name
        Impl::NamePositionScopeMacroMap::iterator nameIt
-       = d->macros.find(name);
+               = d->macros.find(name);
        if (nameIt != d->macros.end()) {
                // find last definition in front of pos or at pos itself
                Impl::PositionScopeMacroMap::const_iterator it
-               = greatest_below(nameIt->second, pos);
+                       = greatest_below(nameIt->second, pos);
                if (it != nameIt->second.end()) {
                        while (true) {
                                // scope ends behind pos?
@@ -1799,7 +1802,7 @@ MacroData const * Buffer::getBufferMacro(docstring const & name,
 
        // find macros in included files
        Impl::PositionScopeBufferMap::const_iterator it
-       = greatest_below(d->position_to_children, pos);
+               = greatest_below(d->position_to_children, pos);
        if (it == d->position_to_children.end())
                // no children before
                return bestData;
@@ -1924,11 +1927,10 @@ void Buffer::updateMacros(DocIterator & it, DocIterator & scope) const
                        // is it an external file?
                        if (iit->inset->lyxCode() == INCLUDE_CODE) {
                                // get buffer of external file
-                               InsetCommand const & inset
-                                       = static_cast<InsetCommand const &>(*iit->inset);
-                               InsetCommandParams const & ip = inset.params();
+                               InsetInclude const & inset
+                                       = static_cast<InsetInclude const &>(*iit->inset);
                                d->macro_lock = true;
-                               Buffer * child = loadIfNeeded(*this, ip);
+                               Buffer * child = inset.loadIfNeeded(*this);
                                d->macro_lock = false;
                                if (!child)
                                        continue;
@@ -2000,8 +2002,8 @@ void Buffer::updateMacroInstances() const
 {
        LYXERR(Debug::MACROS, "updateMacroInstances for "
                << d->filename.onlyFileName());
-       DocIterator it = doc_iterator_begin(inset());
-       DocIterator end = doc_iterator_end(inset());
+       DocIterator it = doc_iterator_begin(this);
+       DocIterator end = doc_iterator_end(this);
        for (; it != end; it.forwardPos()) {
                // look for MathData cells in InsetMathNest insets
                Inset * inset = it.nextInset();
@@ -2682,8 +2684,6 @@ void Buffer::bufferErrors(TeXErrors const & terr, ErrorList & errorList) const
 }
 
 
-// FIXME: buf should should be const because updateLabels() modifies
-// the contents of the paragraphs.
 void Buffer::updateLabels(bool childonly) const
 {
        // Use the master text class also for child documents