]> git.lyx.org Git - lyx.git/blobdiff - src/Buffer.cpp
Style. Enum names and typedefs are almost always CamelCase in the LyX
[lyx.git] / src / Buffer.cpp
index 9768b4800948c9d8c9df1e32cb4e02f032d061a9..f8c53392a97a17033f652d1198728e3bff2d227e 100644 (file)
@@ -127,7 +127,7 @@ namespace {
 
 // Do not remove the comment below, so we get merge conflict in
 // independent branches. Instead add your own.
-int const LYX_FORMAT = 373; // jspitzm: merge g-brief class
+int const LYX_FORMAT = 374; // rgheck: HTML output options
 
 typedef map<string, bool> DepClean;
 typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;
@@ -259,12 +259,14 @@ public:
                parent_buffer = pb;
        }
 
-       /// So we can force access via the accessors.
-       mutable Buffer const * parent_buffer;
-
        /// If non zero, this buffer is a clone of existing buffer \p cloned_buffer_
        /// This one is useful for preview detached in a thread.
        Buffer const * cloned_buffer_;
+
+private:
+       /// So we can force access via the accessors.
+       mutable Buffer const * parent_buffer;
+
 };
 
 
@@ -293,7 +295,7 @@ Buffer::Impl::Impl(Buffer & parent, FileName const & file, bool readonly_,
          read_only(readonly_), filename(file), file_fully_loaded(false),
          toc_backend(&parent), macro_lock(false), timestamp_(0),
          checksum_(0), wa_(0), undo_(parent), bibinfoCacheValid_(false),
-         parent_buffer(0), cloned_buffer_(cloned_buffer)
+         cloned_buffer_(cloned_buffer), parent_buffer(0)
 {
        if (!cloned_buffer_) {
                temppath = createBufferTmpDir();
@@ -313,9 +315,15 @@ Buffer::Buffer(string const & file, bool readonly, Buffer const * cloned_buffer)
 {
        LYXERR(Debug::INFO, "Buffer::Buffer()");
        if (cloned_buffer) {
-               d->inset = static_cast<InsetText *>(cloned_buffer->d->inset->clone());
+               d->inset = new InsetText(*cloned_buffer->d->inset);
                d->inset->setBuffer(*this);
-       } else 
+               // FIXME: optimize this loop somewhat, maybe by creating a new
+               // general recursive Inset::setId().
+               DocIterator it = doc_iterator_begin(this);
+               DocIterator cloned_it = doc_iterator_begin(cloned_buffer);
+               for (; !it.atEnd(); it.forwardPar(), cloned_it.forwardPar())
+                       it.paragraph().setId(cloned_it.paragraph().id());
+       } else
                d->inset = new InsetText(this);
        d->inset->setAutoBreakRows(true);
        d->inset->getText(0)->setMacrocontextPosition(par_iterator_begin());
@@ -372,6 +380,8 @@ Buffer::~Buffer()
 
 Buffer * Buffer::clone() const
 {
+       // FIXME for asynchronous export and preview: We must also clone all
+       // the child buffers!
        return new Buffer(fileName().absFilename(), false, this);
 }
 
@@ -2329,9 +2339,8 @@ DocIterator Buffer::firstChildPosition(Buffer const * child)
 }
 
 
-std::vector<Buffer *> Buffer::getChildren(bool grand_children) const
+void Buffer::getChildren(std::vector<Buffer *> & clist, bool grand_children) const
 {
-       std::vector<Buffer *> clist;
        // loop over children
        Impl::BufferPositionMap::iterator it = d->children_positions.begin();
        Impl::BufferPositionMap::iterator end = d->children_positions.end();
@@ -2346,7 +2355,14 @@ std::vector<Buffer *> Buffer::getChildren(bool grand_children) const
                                clist.push_back(*git);
                }
        }
-       return clist;
+}
+
+
+std::vector<Buffer *> Buffer::getChildren(bool grand_children) const
+{
+       std::vector<Buffer *> v;
+       getChildren(v, grand_children);
+       return v;
 }