]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetInclude.cpp
* src/paragraph_funcs.cpp (breakParagraph): change parameter 'flag' to
[lyx.git] / src / insets / InsetInclude.cpp
index 8ad44093aa7f13b8da28c8d7effee4d6588c58eb..965fe1764a6e30c2cd917aab0c5970315cf68f56 100644 (file)
@@ -52,7 +52,7 @@
 
 
 namespace lyx {
-  
+
 // Implementation is in LyX.cpp
 extern void dispatch(FuncRequest const & action);
 
@@ -80,8 +80,8 @@ using support::subst;
 using support::sum;
 
 using std::endl;
+using std::find;
 using std::string;
-using std::auto_ptr;
 using std::istringstream;
 using std::ostream;
 using std::ostringstream;
@@ -279,9 +279,9 @@ void InsetInclude::set(InsetCommandParams const & p, Buffer const & buffer)
 }
 
 
-auto_ptr<Inset> InsetInclude::doClone() const
+Inset * InsetInclude::clone() const
 {
-       return auto_ptr<Inset>(new InsetInclude(*this));
+       return new InsetInclude(*this);
 }
 
 
@@ -462,7 +462,7 @@ int InsetInclude::latex(Buffer const & buffer, odocstream & os,
                incfile = mangled;
        else if (!isValidLaTeXFilename(incfile)) {
                frontend::Alert::warning(_("Invalid filename"),
-                                        _("The following filename is likely to cause trouble "
+                                        _("The following filename is likely to cause trouble "
                                           "when running the exported file through LaTeX: ") +
                                            from_utf8(incfile));
        }
@@ -494,6 +494,26 @@ int InsetInclude::latex(Buffer const & buffer, odocstream & os,
                        //return 0;
                }
 
+               // Make sure modules used in child are all included in master
+               //FIXME It might be worth loading the children's modules into the master
+               //over in BufferParams rather than doing this check.
+               vector<string> const masterModules = m_buffer->params().getModules();
+               vector<string> const childModules = tmp->params().getModules();
+               vector<string>::const_iterator it = childModules.begin();
+               vector<string>::const_iterator end = childModules.end();
+               for (; it != end; ++it) {
+                       string const module = *it;
+                       vector<string>::const_iterator found =
+                               find(masterModules.begin(), masterModules.end(), module);
+                       if (found != masterModules.end()) {
+                               docstring text = bformat(_("Included file `%1$s'\n"
+                                                       "uses module `%2$s'\n"
+                                                       "which is not used in parent file."),
+                                      makeDisplayPath(included_file.absFilename()), from_utf8(module));
+                               Alert::warning(_("Module not found"), text);
+                       }
+               }
+
                tmp->markDepClean(m_buffer->temppath());
 
 // FIXME: handle non existing files
@@ -763,7 +783,7 @@ InsetInclude::getBibfilesCache(Buffer const & buffer) const
 }
 
 
-bool InsetInclude::metrics(MetricsInfo & mi, Dimension & dim) const
+void InsetInclude::metrics(MetricsInfo & mi, Dimension & dim) const
 {
        BOOST_ASSERT(mi.base.bv);
 
@@ -787,17 +807,11 @@ bool InsetInclude::metrics(MetricsInfo & mi, Dimension & dim) const
 
        Box b(0, dim.wid, -dim.asc, dim.des);
        button_.setBox(b);
-
-       bool const changed = dim_ != dim;
-       dim_ = dim;
-       return changed;
 }
 
 
 void InsetInclude::draw(PainterInfo & pi, int x, int y) const
 {
-       setPosCache(pi, x, y);
-
        BOOST_ASSERT(pi.base.bv);
 
        bool use_preview = false;
@@ -897,7 +911,7 @@ void InsetInclude::addToToc(TocList & toclist, Buffer const & buffer, ParConstIt
                        Toc & toc = toclist["listing"];
                        docstring const str = convert<docstring>(toc.size() + 1)
                                + ". " +  from_utf8(caption);
-                       // This inset does not have a valid ParConstIterator 
+                       // This inset does not have a valid ParConstIterator
                        // so it has to use the iterator of its parent paragraph
                        toc.push_back(TocItem(pit, 0, str));
                }
@@ -916,7 +930,7 @@ void InsetInclude::addToToc(TocList & toclist, Buffer const & buffer, ParConstIt
 }
 
 
-void InsetInclude::updateLabels(Buffer const & buffer, 
+void InsetInclude::updateLabels(Buffer const & buffer,
                                ParIterator const &)
 {
        Buffer const * const childbuffer = getChildBuffer(buffer, params_);
@@ -939,6 +953,16 @@ void InsetInclude::updateLabels(Buffer const & buffer,
 }
 
 
+void InsetInclude::registerEmbeddedFiles(Buffer const & buffer,
+       EmbeddedFiles & files) const
+{
+       // include and input are temprarily not considered.
+       if (isVerbatim(params_) || isListings(params_))
+               files.registerFile(includedFilename(buffer, params_).absFilename(),
+                       false, this);
+}
+
+
 string const InsetIncludeMailer::name_("include");
 
 InsetIncludeMailer::InsetIncludeMailer(InsetInclude & inset)