]> git.lyx.org Git - lyx.git/blobdiff - src/layout.C
update all .po files ot latestes pot
[lyx.git] / src / layout.C
index 777358827ff8a176839df2fe2d80be4e279d3ed6..bad3b274118812ec634e630be50b5cb6c8520857 100644 (file)
@@ -6,7 +6,8 @@
  *          Copyright 1995 Matthias Ettrich
  *          Copyright 1995-2000 The LyX Team.
  *
- * ====================================================== */
+ * ======================================================
+ */
 
 #include <config.h>
 
 #include "debug.h"
 #include "gettext.h"
 #include "support/LAssert.h"
+#include "support/lyxfunctional.h"
 
 using std::pair;
 using std::make_pair;
 using std::sort;
 using std::endl;
+using std::find_if;
+using std::remove_if;
 
 // Global variable: textclass table.
 LyXTextClassList textclasslist;
@@ -509,29 +513,6 @@ enum LabelTypeTags {
 };
 
 
-#if 0
-static keyword_item labelTypeTags[] = {
-       { "bibliography",             LA_BIBLIO },
-       { "centered_top_environment", LA_CENTERED_TOP_ENVIRONMENT },
-       { "counter_chapter",          LA_COUNTER_CHAPTER },
-       { "counter_enumi",            LA_COUNTER_ENUMI },
-       { "counter_enumii",           LA_COUNTER_ENUMII },
-       { "counter_enumiii",          LA_COUNTER_ENUMIII },
-       { "counter_enumiv",           LA_COUNTER_ENUMIV },
-       { "counter_paragraph",        LA_COUNTER_PARAGRAPH },
-       { "counter_section",          LA_COUNTER_SECTION },
-       { "counter_subparagraph",     LA_COUNTER_SUBPARAGRAPH },
-       { "counter_subsection",       LA_COUNTER_SUBSECTION },
-       { "counter_subsubsection",    LA_COUNTER_SUBSUBSECTION },
-       { "manual",                   LA_MANUAL },
-       { "no_label",                 LA_NO_LABEL },
-       { "sensitive",                LA_SENSITIVE },
-       { "static",                   LA_STATIC },
-       { "top_environment",          LA_TOP_ENVIRONMENT }
-};
-#endif
-
-
 void LyXLayout::readLabelType(LyXLex & lexrc)
 {
        keyword_item labelTypeTags[] = {
@@ -646,15 +627,6 @@ void LyXLayout::readEndLabelType(LyXLex & lexrc)
        }
 }
 
-#if 0
-static keyword_item marginTags[] = {
-       { "dynamic",           MARGIN_DYNAMIC },
-       { "first_dynamic",     MARGIN_FIRST_DYNAMIC },
-       { "manual",            MARGIN_MANUAL },
-       { "right_address_box", MARGIN_RIGHT_ADDRESS_BOX },
-       { "static",            MARGIN_STATIC }
-};
-#endif
 
 void LyXLayout::readMargin(LyXLex & lexrc)
 {
@@ -688,17 +660,6 @@ void LyXLayout::readMargin(LyXLex & lexrc)
 }
 
 
-#if 0
-static keyword_item latexTypeTags[] = {
-       { "command",          LATEX_COMMAND },
-       { "environment",      LATEX_ENVIRONMENT },
-       { "item_environment", LATEX_ITEM_ENVIRONMENT },
-       { "list_environment", LATEX_LIST_ENVIRONMENT },
-       { "paragraph",        LATEX_PARAGRAPH }
-};
-#endif
-
-
 void LyXLayout::readLatexType(LyXLex & lexrc)
 {
        keyword_item latexTypeTags[] = {
@@ -738,16 +699,6 @@ enum SpacingTags {
 };
 
 
-#if 0
-static keyword_item spacingTags[] = {
-       {"double",  ST_SPACING_DOUBLE },
-       {"onehalf", ST_SPACING_ONEHALF },
-       {"other",   ST_OTHER },
-       {"single",  ST_SPACING_SINGLE }
-};
-#endif
-
-
 void LyXLayout::readSpacing(LyXLex & lexrc)
 {
        keyword_item spacingTags[] = {
@@ -842,30 +793,6 @@ enum TextClassTags {
 };
 
 
-#if 0
-static keyword_item textClassTags[] = {
-       { "classoptions",    TC_CLASSOPTIONS },
-       { "columns",         TC_COLUMNS },
-       { "defaultfont",     TC_DEFAULTFONT },
-       { "input",           TC_INPUT },
-       { "leftmargin",      TC_LEFTMARGIN },
-       { "maxcounter",      TC_MAXCOUNTER },
-       { "nostyle",         TC_NOSTYLE },
-       { "outputtype",      TC_OUTPUTTYPE },
-       { "pagestyle",       TC_PAGESTYLE },
-       { "preamble",        TC_PREAMBLE },
-       { "providesamsmath", TC_PROVIDESAMSMATH },
-       { "providesmakeidx", TC_PROVIDESMAKEIDX },
-       { "providesurl",     TC_PROVIDESURL },
-       { "rightmargin",     TC_RIGHTMARGIN },
-       { "secnumdepth",     TC_SECNUMDEPTH },
-       { "sides",           TC_SIDES },
-       { "style",           TC_STYLE },
-       { "tocdepth",        TC_TOCDEPTH }
-};
-#endif
-
-
 // Reads a textclass structure from file.
 bool LyXTextClass::Read(string const & filename, bool merge)
 {
@@ -946,7 +873,7 @@ bool LyXTextClass::Read(string const & filename, bool merge)
                                        error = do_readStyle(lexrc, lay);
                                } else {
                                        LyXLayout lay;
-                                       lay.name(name);
+                                       lay.setName(name);
                                        if (!(error = do_readStyle(lexrc, lay)))
                                                layoutlist.push_back(lay);
                                }
@@ -1064,15 +991,6 @@ bool LyXTextClass::Read(string const & filename, bool merge)
 }
 
 
-#if 0
-static keyword_item outputTypeTags[] = {
-       { "docbook", DOCBOOK },
-       { "latex", LATEX },
-       { "linuxdoc", LINUXDOC },
-       { "literate", LITERATE }
-};
-#endif
-
 void LyXTextClass::readOutputType(LyXLex & lexrc)
 {
        keyword_item outputTypeTags[] = {
@@ -1118,22 +1036,6 @@ enum MaxCounterTags {
 };
 
 
-#if 0
-static keyword_item maxCounterTags[] = {
-       {"counter_chapter", MC_COUNTER_CHAPTER },
-       {"counter_enumi", MC_COUNTER_ENUMI },
-       {"counter_enumii", MC_COUNTER_ENUMII },
-       {"counter_enumiii", MC_COUNTER_ENUMIII },
-       {"counter_enumiv", MC_COUNTER_ENUMIV },
-       {"counter_paragraph", MC_COUNTER_PARAGRAPH },
-       {"counter_section", MC_COUNTER_SECTION },
-       {"counter_subparagraph", MC_COUNTER_SUBPARAGRAPH },
-       {"counter_subsection", MC_COUNTER_SUBSECTION },
-       {"counter_subsubsection", MC_COUNTER_SUBSUBSECTION }
-};
-#endif
-
-
 void LyXTextClass::readMaxCounter(LyXLex & lexrc)
 {
        keyword_item maxCounterTags[] = {
@@ -1200,16 +1102,6 @@ enum ClassOptionsTags {
 };
 
 
-#if 0
-static keyword_item classOptionsTags[] = {
-       {"end", CO_END },
-       {"fontsize", CO_FONTSIZE },
-       {"other", CO_OTHER },
-       {"pagestyle", CO_PAGESTYLE }
-};
-#endif
-
-
 void LyXTextClass::readClassOptions(LyXLex & lexrc)
 {
        keyword_item classOptionsTags[] = {
@@ -1253,49 +1145,43 @@ void LyXTextClass::readClassOptions(LyXLex & lexrc)
 
 bool LyXTextClass::hasLayout(string const & name) const
 {
-       for (LayoutList::const_iterator cit = layoutlist.begin();
-            cit != layoutlist.end(); ++cit) {
-               if ((*cit).name() == name)
-                       return true;
-       }
-       return false;
+       return find_if(layoutlist.begin(), layoutlist.end(),
+                      compare_memfun(&LyXLayout::name, name))
+               != layoutlist.end();
 }
 
 
 LyXLayout const & LyXTextClass::GetLayout (string const & name) const
 {
-       for (LayoutList::const_iterator cit = layoutlist.begin();
-            cit != layoutlist.end(); ++cit) {
-               if ((*cit).name() == name)
-                       return (*cit);
-       }
-       Assert(false); // we actually require the name to exist.
-       return layoutlist.front();
+       LayoutList::const_iterator cit =
+               find_if(layoutlist.begin(),
+                       layoutlist.end(),
+                       compare_memfun(&LyXLayout::name, name));
+       Assert(cit != layoutlist.end()); // we require the name to exist
+       return (*cit);
 }
 
 
 LyXLayout & LyXTextClass::GetLayout(string const & name)
 {
-       for (LayoutList::iterator it = layoutlist.begin();
-            it != layoutlist.end(); ++it) {
-               if ((*it).name() == name)
-                       return (*it);
-       }
-       Assert(false); // we actually require the name to exist.
-       return layoutlist.front();
+       LayoutList::iterator it =
+               find_if(layoutlist.begin(),
+                       layoutlist.end(),
+                       compare_memfun(&LyXLayout::name, name));
+       Assert(it != layoutlist.end()); // we require the name to exist
+       return (*it);
 }
 
 
-bool LyXTextClass::delete_layout (string const & name)
+bool LyXTextClass::delete_layout(string const & name)
 {
-       for(LayoutList::iterator it = layoutlist.begin();
-           it != layoutlist.end(); ++it) {
-               if ((*it).name() == name) {
-                       layoutlist.erase(it);
-                       return true;
-               }
-       }
-       return false;
+       LayoutList::iterator it =
+               remove_if(layoutlist.begin(), layoutlist.end(),
+                         compare_memfun(&LyXLayout::name, name));
+       LayoutList::iterator end = layoutlist.end();
+       bool const ret = (it != end);
+       layoutlist.erase(it, end);
+       return ret;
 }
 
 
@@ -1305,7 +1191,7 @@ void LyXTextClass::load()
        if (loaded) return;
 
        // Read style-file
-       string real_file = LibFileSearch("layouts", name_, "layout");
+       string const real_file = LibFileSearch("layouts", name_, "layout");
 
        if (Read(real_file)) {
                lyxerr << "Error reading `"
@@ -1321,16 +1207,15 @@ void LyXTextClass::load()
 //////////////////////////////////////////
 
 // Gets textclass number from name
-pair<bool, LyXTextClassList::size_type>
+pair<bool, LyXTextClassList::size_type> const
 LyXTextClassList::NumberOfClass(string const & textclass) const
 {
-       for (ClassList::const_iterator cit = classlist.begin();
-            cit != classlist.end(); ++cit) {
-               if ((*cit).name() == textclass)
-                       return make_pair(true,
-                                        size_type(cit - classlist.begin()));
-       }
-       return make_pair(false, size_type(0));
+       ClassList::const_iterator cit =
+               find_if(classlist.begin(), classlist.end(),
+                       compare_memfun(&LyXTextClass::name, textclass));
+       return cit != classlist.end() ?
+               make_pair(true, size_type(cit - classlist.begin())) :
+               make_pair(false, size_type(0));
 }
 
 
@@ -1347,7 +1232,7 @@ LyXTextClassList::Style(LyXTextClassList::size_type textclass,
 
 
 // Gets layout number from name and textclass number
-pair<bool, LyXTextClass::size_type>
+pair<bool, LyXTextClass::size_type> const
 LyXTextClassList::NumberOfLayout(LyXTextClassList::size_type textclass,
                                 string const & name) const
 {
@@ -1561,3 +1446,4 @@ std::ostream & operator<<(std::ostream & os, LyXTextClass::PageSides p)
        }
        return os;
 }
+