]> git.lyx.org Git - lyx.git/blobdiff - src/TextClass.cpp
Copy/paste error in BranchList::setColors
[lyx.git] / src / TextClass.cpp
index cd87cca2e4efd6d1b2ae052ba94ea5198c6a458f..80cb6f8e2a314b71a51c22f1457bf7b0a2d03b16 100644 (file)
@@ -59,7 +59,7 @@ namespace lyx {
 // You should also run the development/tools/updatelayouts.py script,
 // to update the format of all of our layout files.
 //
-int const LAYOUT_FORMAT = 87; // rkh: master --> parent for counters
+int const LAYOUT_FORMAT = 91; // spitz: InputGlobal method
 
 
 // Layout format for the current lyx file format. Controls which format is
@@ -165,6 +165,7 @@ enum TextClassTags {
        TC_OUTPUTTYPE = 1,
        TC_OUTPUTFORMAT,
        TC_INPUT,
+       TC_INPUT_GLOBAL,
        TC_STYLE,
        TC_MODIFYSTYLE,
        TC_PROVIDESTYLE,
@@ -249,6 +250,7 @@ LexerKeyword textClassTags[] = {
        { "htmltocsection",    TC_HTMLTOCSECTION },
        { "ifcounter",         TC_IFCOUNTER },
        { "input",             TC_INPUT },
+       { "inputglobal",       TC_INPUT_GLOBAL },
        { "insetlayout",       TC_INSETLAYOUT },
        { "leftmargin",        TC_LEFTMARGIN },
        { "maxcitenames",      TC_MAXCITENAMES },
@@ -432,6 +434,7 @@ TextClass::ReturnValues TextClass::read(Lexer & lexrc, ReadType rt)
                bool modifystyle  = false;
                bool providestyle = false;
                bool ifcounter    = false;
+               bool only_global  = false;
 
                switch (static_cast<TextClassTags>(le)) {
 
@@ -459,6 +462,9 @@ TextClass::ReturnValues TextClass::read(Lexer & lexrc, ReadType rt)
                        }
                        break;
 
+               case TC_INPUT_GLOBAL:
+                       only_global = true;
+               // fall through
                case TC_INPUT: // Include file
                        if (lexrc.next()) {
                                FileName tmp;
@@ -466,9 +472,13 @@ TextClass::ReturnValues TextClass::read(Lexer & lexrc, ReadType rt)
                                if (!path().empty() && (prefixIs(inc, "./") ||
                                                        prefixIs(inc, "../")))
                                        tmp = fileSearch(path(), inc, "layout");
-                               else
+                               else {
+                                       // InputGlobal only searches in the system and
+                                       // build directories. This allows to reuse and
+                                       // modify files in the user directory.
                                        tmp = libFileSearch("layouts", inc,
-                                                           "layout");
+                                                           "layout", must_exist, only_global);
+                               }
 
                                if (tmp.empty()) {
                                        lexrc.printError("Could not find input file: " + inc);
@@ -1868,25 +1878,26 @@ Layout TextClass::createBasicLayout(docstring const & name, bool unknown) const
 }
 
 
-DocumentClassPtr getDocumentClass(
-               LayoutFile const & baseClass, LayoutModuleList const & modlist,
-               string const & cengine, bool const clone)
+DocumentClassPtr getDocumentClass(LayoutFile const & baseClass, LayoutModuleList const & modlist,
+               string const & cengine, bool clone, bool internal)
 {
+       bool const show_warnings = !clone && !internal;
        DocumentClassPtr doc_class =
            DocumentClassPtr(new DocumentClass(baseClass));
        for (auto const & mod : modlist) {
                LyXModule * lm = theModuleList[mod];
                if (!lm) {
-                       docstring const msg =
-                                               bformat(_("The module %1$s has been requested by\n"
-                                               "this document but has not been found in the list of\n"
-                                               "available modules. If you recently installed it, you\n"
-                                               "probably need to reconfigure LyX.\n"), from_utf8(mod));
-                       if (!clone)
+                       if (show_warnings) {
+                               docstring const msg =
+                                       bformat(_("The module %1$s has been requested by\n"
+                                       "this document but has not been found in the list of\n"
+                                       "available modules. If you recently installed it, you\n"
+                                       "probably need to reconfigure LyX.\n"), from_utf8(mod));
                                frontend::Alert::warning(_("Module not available"), msg);
+                       }
                        continue;
                }
-               if (!lm->isAvailable() && !clone) {
+               if (!lm->isAvailable() && show_warnings) {
                        docstring const prereqs = from_utf8(getStringFromVector(lm->prerequisites(), "\n\t"));
                        docstring const msg =
                                bformat(_("The module %1$s requires a package that is not\n"
@@ -1901,7 +1912,7 @@ DocumentClassPtr getDocumentClass(
                FileName layout_file = libFileSearch("layouts", lm->getFilename());
                if (!doc_class->read(layout_file, TextClass::MODULE)) {
                        docstring const msg =
-                                               bformat(_("Error reading module %1$s\n"), from_utf8(mod));
+                               bformat(_("Error reading module %1$s\n"), from_utf8(mod));
                        frontend::Alert::warning(_("Read Error"), msg);
                }
        }
@@ -1911,14 +1922,15 @@ DocumentClassPtr getDocumentClass(
 
        LyXCiteEngine * ce = theCiteEnginesList[cengine];
        if (!ce) {
-               docstring const msg =
-                                       bformat(_("The cite engine %1$s has been requested by\n"
-                                       "this document but has not been found in the list of\n"
-                                       "available engines. If you recently installed it, you\n"
-                                       "probably need to reconfigure LyX.\n"), from_utf8(cengine));
-               if (!clone)
+               if (show_warnings) {
+                       docstring const msg =
+                               bformat(_("The cite engine %1$s has been requested by\n"
+                               "this document but has not been found in the list of\n"
+                               "available engines. If you recently installed it, you\n"
+                               "probably need to reconfigure LyX.\n"), from_utf8(cengine));
                        frontend::Alert::warning(_("Cite Engine not available"), msg);
-       } else if (!ce->isAvailable() && !clone) {
+               }
+       } else if (!ce->isAvailable() && show_warnings) {
                docstring const prereqs = from_utf8(getStringFromVector(ce->prerequisites(), "\n\t"));
                docstring const msg =
                        bformat(_("The cite engine %1$s requires a package that is not\n"
@@ -1933,7 +1945,7 @@ DocumentClassPtr getDocumentClass(
                FileName layout_file = libFileSearch("citeengines", ce->getFilename());
                if (!doc_class->read(layout_file, TextClass::CITE_ENGINE)) {
                        docstring const msg =
-                                               bformat(_("Error reading cite engine %1$s\n"), from_utf8(cengine));
+                               bformat(_("Error reading cite engine %1$s\n"), from_utf8(cengine));
                        frontend::Alert::warning(_("Read Error"), msg);
                }
        }