]> git.lyx.org Git - lyx.git/commitdiff
Prevent automatic opening of child docs because of natbib labels
authorGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Fri, 19 May 2006 07:21:43 +0000 (07:21 +0000)
committerGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Fri, 19 May 2006 07:21:43 +0000 (07:21 +0000)
* src/insets/insetinclude.h
(updateBibfilesCache): adjust comment
(getBibfilesCache): ditto

* src/insets/insetinclude.C
(getChildBuffer): new, return the buffer of the child if it exists
(updateBibfilesCache): update the child buffer only if already loaded
(getBibfilesCache): scan the child buffer only if already loaded

* src/buffer.h
(updateBibfilesCache): adjust comment
(getBibfilesCache): ditto
(bibfilesCache_): ditto

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@13869 a592a061-630c-0410-9148-cb99ea01b6c8

src/buffer.h
src/insets/insetinclude.C
src/insets/insetinclude.h

index e537ee079ad64989d4176c4131b8481042c3216f..a3cbc3f61fd6016277c691a09444ae8e03dd23de 100644 (file)
@@ -255,10 +255,10 @@ public:
        /// return all bibkeys from buffer and its childs
        void fillWithBibKeys(std::vector<std::pair<std::string, std::string> > & keys) const;
        /// Update the cache with all bibfiles in use (including bibfiles
-       /// of child documents).
+       /// of loaded child documents).
        void updateBibfilesCache();
        /// Return the cache with all bibfiles in use (including bibfiles
-       /// of child documents).
+       /// of loaded child documents).
        std::vector<std::string> const & getBibfilesCache() const;
        ///
        void getLabelList(std::vector<std::string> &) const;
@@ -365,8 +365,8 @@ private:
        /// it's BufferView, this should be FIXED in future.
        StableDocIterator cursor_;
        StableDocIterator anchor_;
-       /// A cache for the bibfiles (including bibfiles of child documents),
-       /// needed for appropriate update of natbib labels.
+       /// A cache for the bibfiles (including bibfiles of loaded child
+       /// documents), needed for appropriate update of natbib labels.
        std::vector<std::string> bibfilesCache_;
 };
 
index 070c39f8f1e8fb11f8337b6020b34b11aeaad7df..4620c52c27d032939bc343ad8915b3c67ed819c6 100644 (file)
@@ -301,6 +301,20 @@ string const InsetInclude::getScreenLabel(Buffer const &) const
 
 namespace {
 
+/// return the child buffer if the file is a LyX doc and is loaded
+Buffer * getChildBuffer(Buffer const & buffer, InsetCommandParams const & params)
+{
+       if (isVerbatim(params))
+               return 0;
+
+       string const included_file = includedFilename(buffer, params);
+       if (!isLyXFilename(included_file))
+               return 0;
+
+       return bufferlist.getBuffer(included_file);
+}
+
+
 /// return true if the file is or got loaded.
 bool loadIfNeeded(Buffer const & buffer, InsetCommandParams const & params)
 {
@@ -616,9 +630,8 @@ void InsetInclude::fillWithBibKeys(Buffer const & buffer,
 
 void InsetInclude::updateBibfilesCache(Buffer const & buffer)
 {
-       if (loadIfNeeded(buffer, params_)) {
-               string const included_file = includedFilename(buffer, params_);
-               Buffer * tmp = bufferlist.getBuffer(included_file);
+       Buffer * const tmp = getChildBuffer(buffer, params_);
+       if (tmp) {
                tmp->setParentName("");
                tmp->updateBibfilesCache();
                tmp->setParentName(parentFilename(buffer));
@@ -629,9 +642,8 @@ void InsetInclude::updateBibfilesCache(Buffer const & buffer)
 std::vector<string> const &
 InsetInclude::getBibfilesCache(Buffer const & buffer) const
 {
-       if (loadIfNeeded(buffer, params_)) {
-               string const included_file = includedFilename(buffer, params_);
-               Buffer * tmp = bufferlist.getBuffer(included_file);
+       Buffer * const tmp = getChildBuffer(buffer, params_);
+       if (tmp) {
                tmp->setParentName("");
                std::vector<string> const & cache = tmp->getBibfilesCache();
                tmp->setParentName(parentFilename(buffer));
index 3fb919af15206257024b65aa3e9432d9d1d711ce..0f2e3255d34ad07bf4578bc156bab53c993dca2c 100644 (file)
@@ -56,11 +56,14 @@ public:
                std::vector<std::pair<std::string,std::string> > & keys) const;
        /** Update the cache with all bibfiles in use of the child buffer
         *  (including bibfiles of grandchild documents).
+        *  Does nothing if the child document is not loaded to prevent
+        *  automatic loading of all child documents upon loading the master.
         *  \param buffer the Buffer containing this inset.
         */
        void updateBibfilesCache(Buffer const & buffer);
        /** Return the cache with all bibfiles in use of the child buffer
         *  (including bibfiles of grandchild documents).
+        *  Return an empty vector if the child doc is not loaded.
         *  \param buffer the Buffer containing this inset.
         */
        std::vector<std::string> const &