]> git.lyx.org Git - features.git/commitdiff
NEW_INSETS changes (reformatting)
authorLars Gullik Bjønnes <larsbj@gullik.org>
Wed, 4 Apr 2001 21:47:26 +0000 (21:47 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Wed, 4 Apr 2001 21:47:26 +0000 (21:47 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1892 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/buffer.C
src/lastfiles.C
src/lyxparagraph.h
src/paragraph.C
src/tabular.C
src/text2.C

index 4c2806022fad674fbd11c28130995264189a5bc9..a6de52b947dbf6a3b2e88b120638af684a4b639b 100644 (file)
@@ -1,5 +1,23 @@
 2001-04-04  Lars Gullik Bjønnes  <larsbj@birdstep.com>
 
+       * text2.C (SetLayout): split in NEW_INSETS and non NEW_INSETS version
+
+       * tabular.C: small reformat
+
+       * paragraph.C (GetFontSettings): split in NEW_INSETS and non
+       NEW_INSETS verison
+       (GetChar): ditto
+       (BreakParagraph): ditto
+       (SetOnlyLayout): ditto
+       (SetLayout): ditto
+
+       * lyxparagraph.h: add definitions for SetLayout and SetOnlyLayout
+       with one arg less.
+
+       * lastfiles.C: removed most using decl, add std:: where needed
+
+       * buffer.C: ws changes
+
        * MenuBackend.C (class compare_format): put into anon namespace
        (expand): constify label, names, action, action2
        (expand): 
index 469426dc52e4856ba3a88f7a4014fa21f9f55a50..02af8ca44ffb8598d3e5c1e3d02c9f752cb73feb 100644 (file)
@@ -2583,7 +2583,7 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only)
                                }
                                sgmlOpenTag(ofs, depth, style.latexname());
 
-                               if (environment_stack.size() == depth+1)
+                               if (environment_stack.size() == depth + 1)
                                        environment_stack.push_back("!-- --");
                                environment_stack[depth] = style.latexname();
                        }
@@ -3075,10 +3075,10 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
    
        texrow.reset();
 
-       string top_element= textclasslist.LatexnameOfClass(params.textclass);
+       string top_element = textclasslist.LatexnameOfClass(params.textclass);
 
        if (!only_body) {
-               string sgml_includedfiles=features.getIncludedFiles(fname);
+               string sgml_includedfiles = features.getIncludedFiles(fname);
 
                ofs << "<!doctype " << top_element
                    << " public \"-//OASIS//DTD DocBook V3.1//EN\"";
@@ -3104,18 +3104,23 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
        ofs << "<!-- DocBook file was created by " << LYX_DOCVERSION 
            << "\n  See http://www.lyx.org/ for more information -->\n";
 
-       vector <string> environment_stack(10);
-       vector <string> environment_inner(10);
-       vector <string> command_stack(10);
+       vector<string> environment_stack(10);
+       vector<string> environment_inner(10);
+       vector<string> command_stack(10);
 
-       bool command_flag= false;
-       int command_depth= 0, command_base= 0, cmd_depth= 0;
+       bool command_flag = false;
+       int command_depth = 0;
+       int command_base = 0;
+       int cmd_depth = 0;
        int depth = 0; // paragraph depth
 
-        string item_name, command_name;
+        string item_name;
+       string command_name;
 
        while (par) {
-               string sgmlparam, c_depth, c_params;
+               string sgmlparam;
+               string c_depth;
+               string c_params;
                int desc_on = 0; // description mode
 
                LyXLayout const & style =
@@ -3125,7 +3130,7 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
                // environment tag closing
                for (; depth > par->params.depth(); --depth) {
                        if (environment_inner[depth] != "!-- --") {
-                               item_name= "listitem";
+                               item_name = "listitem";
                                sgmlCloseTag(ofs, command_depth + depth,
                                             item_name);
                                if (environment_inner[depth] == "varlistentry")
@@ -3161,11 +3166,12 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
                // Write opening SGML tags.
                switch (style.latextype) {
                case LATEX_PARAGRAPH:
-                       sgmlOpenTag(ofs, depth+command_depth, style.latexname());
+                       sgmlOpenTag(ofs, depth + command_depth,
+                                   style.latexname());
                        break;
 
                case LATEX_COMMAND:
-                       if (depth!= 0)
+                       if (depth != 0)
                                LinuxDocError(par, 0,
                                              _("Error : Wrong depth for "
                                                "LatexType Command.\n"));
@@ -3175,26 +3181,26 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
                        sgmlparam = style.latexparam();
                        c_params = split(sgmlparam, c_depth,'|');
                        
-                       cmd_depth= lyx::atoi(c_depth);
+                       cmd_depth = lyx::atoi(c_depth);
                        
                        if (command_flag) {
-                               if (cmd_depth<command_base) {
+                               if (cmd_depth < command_base) {
                                        for (int j = command_depth; j >= command_base; --j)
                                                sgmlCloseTag(ofs, j, command_stack[j]);
-                                       command_depth= command_base= cmd_depth;
+                                       command_depth = command_base = cmd_depth;
                                } else if (cmd_depth <= command_depth) {
                                        for (int j = command_depth; j >= cmd_depth; --j)
                                                sgmlCloseTag(ofs, j, command_stack[j]);
-                                       command_depth= cmd_depth;
+                                       command_depth = cmd_depth;
                                } else
-                                       command_depth= cmd_depth;
+                                       command_depth = cmd_depth;
                        } else {
                                command_depth = command_base = cmd_depth;
                                command_flag = true;
                        }
-                       if (command_stack.size() == command_depth +1)
+                       if (command_stack.size() == command_depth + 1)
                                command_stack.push_back("");
-                       command_stack[command_depth]= command_name;
+                       command_stack[command_depth] = command_name;
 
                        // treat label as a special case for
                        // more WYSIWYM handling.
@@ -3225,7 +3231,7 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
                        }
 
                        if (environment_stack[depth] != style.latexname()) {
-                               if(environment_stack.size() == depth+1) {
+                               if(environment_stack.size() == depth + 1) {
                                        environment_stack.push_back("!-- --");
                                        environment_inner.push_back("!-- --");
                                }
@@ -3335,7 +3341,7 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
        for (; depth >= 0; --depth) {
                if (!environment_stack[depth].empty()) {
                        if (environment_inner[depth] != "!-- --") {
-                               item_name= "listitem";
+                               item_name = "listitem";
                                sgmlCloseTag(ofs, command_depth + depth,
                                             item_name);
                                if (environment_inner[depth] == "varlistentry")
index d53206221975b11dcc12033aadf5c5eb1f449669..588a46d29c60e67b09e0a791fc82b01ec1990bfc 100644 (file)
 #include "lastfiles.h"
 #include "debug.h"
 
-using std::ifstream;
 using std::getline;
-using std::ofstream;
-using std::copy;
-using std::ostream_iterator;
-using std::find;
 using std::endl;
 
+
 LastFiles::LastFiles(string const & filename, bool st, unsigned int num)
        : dostat(st)
 {
@@ -55,7 +51,7 @@ void LastFiles::readFile(string const & filename)
 {
        // we will not complain if we can't find filename nor will
        // we issue a warning. (Lgb)
-       ifstream ifs(filename.c_str());
+       std::ifstream ifs(filename.c_str());
        string tmp;
        FileInfo fileInfo;
 
@@ -72,10 +68,10 @@ void LastFiles::readFile(string const & filename)
 
 void LastFiles::writeFile(string const & filename) const
 {
-       ofstream ofs(filename.c_str());
+       std::ofstream ofs(filename.c_str());
        if (ofs) {
-               copy(files.begin(), files.end(),
-                    ostream_iterator<string>(ofs, "\n"));
+               std::copy(files.begin(), files.end(),
+                         std::ostream_iterator<string>(ofs, "\n"));
        } else
                lyxerr << "LyX: Warning: unable to save LastFiles: "
                       << filename << endl;
@@ -85,7 +81,7 @@ void LastFiles::writeFile(string const & filename) const
 void LastFiles::newFile(string const & file)
 {
        // If file already exist, delete it and reinsert at front.
-       Files::iterator it = find(files.begin(), files.end(), file);
+       Files::iterator it = std::find(files.begin(), files.end(), file);
        if (it != files.end())
                files.erase(it);
        files.push_front(file);
index aacc6f2c4e315748c94c751322a8869e3b669a57..6d7f0fad7e18d70022c272e2c356aa0a3c279002 100644 (file)
@@ -333,6 +333,7 @@ public:
        char GetAlign() const;
        ///
        char GetDepth() const;
+#ifndef NEW_INSETS
        ///
        void SetLayout(BufferParams const &,
                       LyXTextClass::LayoutList::size_type new_layout);
@@ -340,11 +341,15 @@ public:
        void SetOnlyLayout(BufferParams const &,
                           LyXTextClass::LayoutList::size_type new_layout);
        ///
-       int GetFirstCounter(int i) const;
-#ifndef NEW_INSETS
-       ///
        size_type Last() const;
+#else
+       ///
+       void SetLayout(LyXTextClass::LayoutList::size_type new_layout);
+       ///
+       void SetOnlyLayout(LyXTextClass::LayoutList::size_type new_layout);
 #endif
+       ///
+       int GetFirstCounter(int i) const;
        ///
        void Erase(size_type pos);
        /** the flag determines wether the layout should be copied
index 7b04bddeb6471e55091a792188c87f3d3e0fd8be..d3f6f779fc2bdb0ef4980cc9fb83ec774ea505e2 100644 (file)
@@ -778,25 +778,18 @@ Inset const * LyXParagraph::GetInset(LyXParagraph::size_type pos) const
 
 // Gets uninstantiated font setting at position.
 // Optimized after profiling. (Asger)
+#ifndef NEW_INSETS
 LyXFont const LyXParagraph::GetFontSettings(BufferParams const & bparams,
                                      LyXParagraph::size_type pos) const
 {
-#ifdef NEW_INSETS
-       Assert(pos <= size());
-#endif
-#ifndef NEW_INSETS
        if (pos < size()) {
-#endif
                FontTable search_font(pos, LyXFont());
                FontList::const_iterator cit = lower_bound(fontlist.begin(),
                                                    fontlist.end(),
                                                    search_font, matchFT());
                if (cit != fontlist.end())
                        return (*cit).font();
-#ifndef NEW_INSETS
        }
-#endif
-#ifndef NEW_INSETS
        // > because last is the next unused position, and you can 
        // use it if you want
        else if (pos > size()) {
@@ -818,16 +811,27 @@ LyXFont const LyXParagraph::GetFontSettings(BufferParams const & bparams,
        } else if (pos > 0) {
                return GetFontSettings(bparams, pos - 1);
        }
+
+       return LyXFont(LyXFont::ALL_INHERIT, getParLanguage(bparams));
+}
 #else
+LyXFont const LyXParagraph::GetFontSettings(BufferParams const & bparams,
+                                           LyXParagraph::size_type pos) const
+{
+       Assert(pos <= size());
+       FontTable search_font(pos, LyXFont());
+       FontList::const_iterator cit = lower_bound(fontlist.begin(),
+                                                  fontlist.end(),
+                                                  search_font, matchFT());
+       if (cit != fontlist.end())
+               return (*cit).font();
+       
        if (pos == size() && size())
                return GetFontSettings(bparams, pos - 1);
-#endif
-       //else
-       // pos = size() = 0
+       
        return LyXFont(LyXFont::ALL_INHERIT, getParLanguage(bparams));
-
-       //return LyXFont(LyXFont::ALL_INHERIT);
 }
+#endif
 
 
 // Gets uninstantiated font setting at position 0
@@ -931,32 +935,23 @@ LyXParagraph::HighestFontInRange(LyXParagraph::size_type startpos,
 }
 
 
+#ifndef NEW_INSETS
 LyXParagraph::value_type
 LyXParagraph::GetChar(LyXParagraph::size_type pos) const
 {
-#ifndef NEW_INSETS
        Assert(pos >= 0);
-#else
-       Assert(pos <= size());
-       if (!size() || pos == size()) return '\0';
-#endif
-
-#ifndef NEW_INSETS
+       
        if (pos < size()) {
-#endif
                return text[pos];
-#ifndef NEW_INSETS
        }
-#endif
-#ifndef NEW_INSETS
+       
        // > because last is the next unused position, and you can 
        // use it if you want
        else if (pos > size()) {
                if (next_ && next_->footnoteflag != LyXParagraph::NO_FOOTNOTE) 
                        return NextAfterFootnote()
                                ->GetChar(pos - text.size() - 1);
-               else
-                       {
+               else {
                        lyxerr << "ERROR (LyXParagraph::GetChar const): "
                                "position does not exist."
                               << pos << " (" << static_cast<int>(pos)
@@ -989,8 +984,17 @@ LyXParagraph::GetChar(LyXParagraph::size_type pos) const
                }
                return '\0'; // to shut up gcc
        }
-#endif
 }
+#else
+LyXParagraph::value_type
+LyXParagraph::GetChar(LyXParagraph::size_type pos) const
+{
+       Assert(pos <= size());
+       if (!size() || pos == size()) return '\0';
+       
+       return text[pos];
+}
+#endif
 
 
 LyXParagraph::value_type
@@ -1034,6 +1038,7 @@ LyXParagraph::GetUChar(BufferParams const & bparams,
                return c;
 }
 
+
 // return an string of the current word, and the end of the word in lastpos.
 string const LyXParagraph::GetWord(LyXParagraph::size_type & lastpos) const
 {
@@ -1077,7 +1082,6 @@ string const LyXParagraph::GetWord(LyXParagraph::size_type & lastpos) const
        while (IsLetter(lastpos)) theword += GetChar(lastpos++);
        
        return theword;
-
 }
 
 
@@ -1443,6 +1447,7 @@ LyXParagraph const * LyXParagraph::previous() const
 }
 
 
+#ifndef NEW_INSETS
 void LyXParagraph::BreakParagraph(BufferParams const & bparams,
                                  LyXParagraph::size_type pos,
                                  int flag)
@@ -1450,40 +1455,25 @@ void LyXParagraph::BreakParagraph(BufferParams const & bparams,
        size_type i;
        size_type j;
        // create a new paragraph
-#ifndef NEW_INSETS
        size_type pos_end;
        size_type pos_first;
        LyXParagraph * par = ParFromPos(pos);
        LyXParagraph * firstpar = FirstPhysicalPar();
    
        LyXParagraph * tmp = new LyXParagraph(par);
-#else
-       //LyXParagraph * par = this;
-       //LyXParagraph * firstpar = this;
-       LyXParagraph * tmp = new LyXParagraph(this);
-#endif
 
-#ifndef NEW_INSETS
        tmp->footnoteflag = footnoteflag;
        tmp->footnotekind = footnotekind;
-#endif
+
        // this is an idea for a more userfriendly layout handling, I will
        // see what the users say
 
-#ifndef NEW_INSETS
        // layout stays the same with latex-environments
        if (flag) {
                tmp->SetOnlyLayout(bparams, firstpar->layout);
                tmp->SetLabelWidthString(firstpar->params.labelWidthString());
        }
-#else
-       // layout stays the same with latex-environments
-       if (flag) {
-               tmp->SetOnlyLayout(bparams, layout);
-               tmp->SetLabelWidthString(params.labelWidthString());
-       }
-#endif
-#ifndef NEW_INSETS
+
        if (Last() > pos || !Last() || flag == 2) {
                tmp->SetOnlyLayout(bparams, firstpar->layout);
                tmp->params.align(firstpar->params.align());
@@ -1498,25 +1488,9 @@ void LyXParagraph::BreakParagraph(BufferParams const & bparams,
       
                tmp->params.depth(firstpar->params.depth());
                tmp->params.noindent(firstpar->params.noindent());
-#else
-       if (size() > pos || !size() || flag == 2) {
-               tmp->SetOnlyLayout(bparams, layout);
-               tmp->params.align(params.align());
-               tmp->SetLabelWidthString(params.labelWidthString());
-      
-               tmp->params.lineBottom(params.lineBottom());
-               params.lineBottom(false);
-               tmp->params.pagebreakBottom(params.pagebreakBottom());
-               params.pagebreakBottom(false);
-               tmp->params.spaceBottom(params.spaceBottom());
-               params.spaceBottom(VSpace(VSpace::NONE));
-      
-               tmp->params.depth(params.depth());
-               tmp->params.noindent(params.noindent());
-#endif
+
                // copy everything behind the break-position
                // to the new paragraph
-#ifndef NEW_INSETS
                pos_first = 0;
                while (ParFromPos(pos_first) != par)
                        ++pos_first;
@@ -1535,23 +1509,8 @@ void LyXParagraph::BreakParagraph(BufferParams const & bparams,
                        par->Erase(i - pos_first);
 
                par->fitToSize();
-#else
-               size_type pos_end = text.size() - 1;
-               
-               for (i = j = pos; i <= pos_end; ++i) {
-                       CutIntoMinibuffer(bparams, i);
-                       if (tmp->InsertFromMinibuffer(j - pos))
-                               ++j;
-               }
-               tmp->fitToSize();
-               for (i = pos_end; i >= pos; --i)
-                       Erase(i);
-
-               fitToSize();
-#endif
        }
 
-#ifndef NEW_INSETS
        // just an idea of me
        if (!pos) {
                tmp->params.lineTop(firstpar->params.lineTop());
@@ -1566,7 +1525,56 @@ void LyXParagraph::BreakParagraph(BufferParams const & bparams,
                        firstpar->params.depth(tmp->params.depth());
                }
        }
+}
 #else
+void LyXParagraph::BreakParagraph(BufferParams const & bparams,
+                                 LyXParagraph::size_type pos,
+                                 int flag)
+{
+       // create a new paragraph
+       LyXParagraph * tmp = new LyXParagraph(this);
+       
+       // this is an idea for a more userfriendly layout handling, I will
+       // see what the users say
+       
+       // layout stays the same with latex-environments
+       if (flag) {
+               tmp->SetOnlyLayout(layout);
+               tmp->SetLabelWidthString(params.labelWidthString());
+       }
+       
+       if (size() > pos || !size() || flag == 2) {
+               tmp->SetOnlyLayout(layout);
+               tmp->params.align(params.align());
+               tmp->SetLabelWidthString(params.labelWidthString());
+               
+               tmp->params.lineBottom(params.lineBottom());
+               params.lineBottom(false);
+               tmp->params.pagebreakBottom(params.pagebreakBottom());
+               params.pagebreakBottom(false);
+               tmp->params.spaceBottom(params.spaceBottom());
+               params.spaceBottom(VSpace(VSpace::NONE));
+               
+               tmp->params.depth(params.depth());
+               tmp->params.noindent(params.noindent());
+               
+               // copy everything behind the break-position
+               // to the new paragraph
+               size_type pos_end = text.size() - 1;
+               size_type i = pos;
+               size_type j = pos;
+               for (; i <= pos_end; ++i) {
+                       CutIntoMinibuffer(bparams, i);
+                       if (tmp->InsertFromMinibuffer(j - pos))
+                               ++j;
+               }
+               tmp->fitToSize();
+               for (i = pos_end; i >= pos; --i)
+                       Erase(i);
+               
+               fitToSize();
+       }
+       
        // just an idea of me
        if (!pos) {
                tmp->params.lineTop(params.lineTop());
@@ -1576,14 +1584,14 @@ void LyXParagraph::BreakParagraph(BufferParams const & bparams,
                Clear();
                // layout stays the same with latex-environments
                if (flag) {
-                       SetOnlyLayout(bparams, tmp->layout);
+                       SetOnlyLayout(tmp->layout);
                        SetLabelWidthString(tmp->params.labelWidthString());
                        params.depth(tmp->params.depth());
                }
        }
-#endif
 }
-
+#endif
+       
 
 void LyXParagraph::MakeSameLayout(LyXParagraph const * par)
 {
@@ -1937,53 +1945,31 @@ void LyXParagraph::SetLabelWidthString(string const & s)
 }
 
 
+#ifndef NEW_INSETS
 void LyXParagraph::SetOnlyLayout(BufferParams const & bparams,
                                 LyXTextClass::size_type new_layout)
 {
-#ifndef NEW_INSETS
        LyXParagraph * par = FirstPhysicalPar();
-#else
-       LyXParagraph * par = this;
-#endif
        LyXParagraph * ppar = 0;
        LyXParagraph * npar = 0;
-
+       
        par->layout = new_layout;
-
-#ifndef NO_PEXTRA
+       
         if (par->params.pextraType() == PEXTRA_NONE) {
-#endif
                 if (par->previous()) {
-#ifndef NEW_INSETS
                         ppar = par->previous()->FirstPhysicalPar();
-#else
-                       ppar = par->previous();
-#endif
                         while(ppar
                              && ppar->previous()
                              && (ppar->params.depth() > par->params.depth()))
-#ifndef NEW_INSETS
                                 ppar = ppar->previous()->FirstPhysicalPar();
-#else
-                       ppar = ppar->previous();
-#endif
                 }
                 if (par->next()) {
-#ifndef NEW_INSETS
                         npar = par->next()->NextAfterFootnote();
-#else
-                       npar = par->next();
-#endif
                         while(npar
                              && npar->next()
                              && (npar->params.depth() > par->params.depth()))
-#ifndef NEW_INSETS
                                 npar = npar->next()->NextAfterFootnote();
-#else
-                       npar = npar->next();
-#endif
                 }
-#ifndef NO_PEXTRA
                 if (ppar && (ppar->params.pextraType() != PEXTRA_NONE)) {
                         string p1 = ppar->params.pextraWidth();
                        string p2 = ppar->params.pextraWidthp();
@@ -1999,63 +1985,69 @@ void LyXParagraph::SetOnlyLayout(BufferParams const & bparams,
                                             p1, p2);
                 }
         }
+}
+#else
+void LyXParagraph::SetOnlyLayout(LyXTextClass::size_type new_layout)
+{
+#if 0
+       LyXParagraph * par = this;
+       LyXParagraph * ppar = 0;
+       LyXParagraph * npar = 0;
+       
+       par->layout = new_layout;
+       
+       if (par->previous()) {
+               ppar = par->previous();
+               while(ppar
+                     && ppar->previous()
+                     && (ppar->params.depth() > par->params.depth()))
+                       ppar = ppar->previous();
+       }
+       if (par->next()) {
+               npar = par->next();
+               while(npar
+                     && npar->next()
+                     && (npar->params.depth() > par->params.depth()))
+                       npar = npar->next();
+       }
+#else
+       layout = new_layout;
 #endif
 }
+#endif
 
 
+#ifndef NEW_INSETS
 void LyXParagraph::SetLayout(BufferParams const & bparams,
                             LyXTextClass::size_type new_layout)
 {
        LyXParagraph
-#ifndef NEW_INSETS
                * par = FirstPhysicalPar(),
-#else
-               * par = this,
-#endif
                * ppar = 0,
                * npar = 0;
-
+       
         par->layout = new_layout;
        par->params.labelWidthString(string());
        par->params.align(LYX_ALIGN_LAYOUT);
        par->params.spaceTop(VSpace(VSpace::NONE));
        par->params.spaceBottom(VSpace(VSpace::NONE));
        par->params.spacing(Spacing(Spacing::Default));
-
-#ifndef NO_PEXTRA
+       
         if (par->params.pextraType() == PEXTRA_NONE) {
-#endif
                 if (par->previous()) {
-#ifndef NEW_INSETS
                         ppar = par->previous()->FirstPhysicalPar();
-#else
-                       ppar = par->previous();
-#endif
                         while(ppar
                              && ppar->previous()
                              && (ppar->params.depth() > par->params.depth()))
-#ifndef NEW_INSETS
                                 ppar = ppar->previous()->FirstPhysicalPar();
-#else
-                       ppar = ppar->previous();
-#endif
                 }
                 if (par->next()) {
-#ifndef NEW_INSETS
                         npar = par->next()->NextAfterFootnote();
-#else
-                       npar = par->next();
-#endif
                         while(npar
                              && npar->next()
                              && (npar->params.depth() > par->params.depth()))
-#ifndef NEW_INSETS
                                 npar = npar->next()->NextAfterFootnote();
-#else
-                       npar = npar->next();
-#endif
                 }
-#ifndef NO_PEXTRA
                 if (ppar && (ppar->params.pextraType() != PEXTRA_NONE)) {
                         string const p1 = ppar->params.pextraWidth();
                        string const p2 = ppar->params.pextraWidthp();
@@ -2070,8 +2062,18 @@ void LyXParagraph::SetLayout(BufferParams const & bparams,
                                             p1, p2);
                 }
         }
-#endif
 }
+#else
+void LyXParagraph::SetLayout(LyXTextClass::size_type new_layout)
+{
+        layout = new_layout;
+       params.labelWidthString(string());
+       params.align(LYX_ALIGN_LAYOUT);
+       params.spaceTop(VSpace(VSpace::NONE));
+       params.spaceBottom(VSpace(VSpace::NONE));
+       params.spacing(Spacing(Spacing::Default));
+}
+#endif
 
 
 // if the layout of a paragraph contains a manual label, the beginning of the 
index 4e0ee4515b7770b4bcdd746a7aaa9c30d989f9ca..b06f5b9a91c25dbe2b75b7fceb5f31357458a92d 100644 (file)
@@ -667,7 +667,7 @@ bool LyXTabular::SetMColumnPWidth(int cell, string const & width)
 
 
 bool LyXTabular::SetAlignSpecial(int cell, string const & special,
-                                                                LyXTabular::Feature what)
+                                LyXTabular::Feature what)
 {
        if (what == SET_SPECIAL_MULTI)
                cellinfo_of_cell(cell)->align_special = special;
index 213fa9aa5107f78337990ff0d9335029d2b7e193..c0a845a424916b7896996a4750f4abffbfe98c61 100644 (file)
@@ -543,61 +543,44 @@ void LyXText::MakeFontEntriesLayoutSpecific(Buffer const * buf,
 }
 
 
+#ifndef NEW_INSETS
 LyXParagraph * LyXText::SetLayout(BufferView * bview,
                                  LyXCursor & cur, LyXCursor & sstart_cur,
                                  LyXCursor & send_cur,
                                  LyXTextClass::size_type layout)
 {
-#ifndef NEW_INSETS
        LyXParagraph * endpar = send_cur.par()->LastPhysicalPar()->next();
-#else
-       LyXParagraph * endpar = send_cur.par()->next();
-#endif
        LyXParagraph * undoendpar = endpar;
-
+       
        if (endpar && endpar->GetDepth()) {
                while (endpar && endpar->GetDepth()) {
-#ifndef NEW_INSETS
                        endpar = endpar->LastPhysicalPar()->next();
-#else
-                       endpar = endpar->next();
-#endif
                        undoendpar = endpar;
                }
        } else if (endpar) {
                endpar = endpar->next(); // because of parindents etc.
        }
-   
+       
        SetUndo(bview->buffer(), Undo::EDIT,
-#ifndef NEW_INSETS
                sstart_cur.par()->ParFromPos(sstart_cur.pos())->previous_,
-#else
-               sstart_cur.par()->previous(),
-#endif
                undoendpar);
-
+       
        /* ok we have a selection. This is always between sstart_cur
         * and sel_end cursor */ 
        cur = sstart_cur;
-   
+       
        LyXLayout const & lyxlayout =
                textclasslist.Style(bview->buffer()->params.textclass, layout);
-   
+       
        while (cur.par() != send_cur.par()) {
-#ifndef NEW_INSETS
                if (cur.par()->footnoteflag == sstart_cur.par()->footnoteflag) {
-#endif
                        cur.par()->SetLayout(bview->buffer()->params, layout);
                        MakeFontEntriesLayoutSpecific(bview->buffer(), cur.par());
-#ifndef NEW_INSETS
                        LyXParagraph * fppar = cur.par()->FirstPhysicalPar();
-#else
-                       LyXParagraph * fppar = cur.par();
-#endif
                        fppar->params.spaceTop(lyxlayout.fill_top ?
-                               VSpace(VSpace::VFILL) : VSpace(VSpace::NONE));
+                                              VSpace(VSpace::VFILL) : VSpace(VSpace::NONE));
                        fppar->params.spaceBottom(lyxlayout.fill_bottom ? 
-                               VSpace(VSpace::VFILL) : VSpace(VSpace::NONE));
+                                                 VSpace(VSpace::VFILL) : VSpace(VSpace::NONE));
                        if (lyxlayout.margintype == MARGIN_MANUAL)
                                cur.par()->SetLabelWidthString(lyxlayout.labelstring());
                        if (lyxlayout.labeltype != LABEL_BIBLIO
@@ -605,25 +588,66 @@ LyXParagraph * LyXText::SetLayout(BufferView * bview,
                                delete fppar->bibkey;
                                fppar->bibkey = 0;
                        }
-#ifndef NEW_INSETS
                }
-#endif
                cur.par(cur.par()->next());
        }
-#ifndef NEW_INSETS
        if (cur.par()->footnoteflag == sstart_cur.par()->footnoteflag) {
-#endif
                cur.par()->SetLayout(bview->buffer()->params, layout);
                MakeFontEntriesLayoutSpecific(bview->buffer(), cur.par());
-#ifndef NEW_INSETS
                LyXParagraph * fppar = cur.par()->FirstPhysicalPar();
+               fppar->params.spaceTop(lyxlayout.fill_top ?
+                                      VSpace(VSpace::VFILL) : VSpace(VSpace::NONE));
+               fppar->params.spaceBottom(lyxlayout.fill_bottom ? 
+                                         VSpace(VSpace::VFILL) : VSpace(VSpace::NONE));
+               if (lyxlayout.margintype == MARGIN_MANUAL)
+                       cur.par()->SetLabelWidthString(lyxlayout.labelstring());
+               if (lyxlayout.labeltype != LABEL_BIBLIO
+                   && fppar->bibkey) {
+                       delete fppar->bibkey;
+                       fppar->bibkey = 0;
+               }
+       }
+       return endpar;
+}
 #else
+LyXParagraph * LyXText::SetLayout(BufferView * bview,
+                                 LyXCursor & cur, LyXCursor & sstart_cur,
+                                 LyXCursor & send_cur,
+                                 LyXTextClass::size_type layout)
+{
+       LyXParagraph * endpar = send_cur.par()->next();
+       LyXParagraph * undoendpar = endpar;
+       
+       if (endpar && endpar->GetDepth()) {
+               while (endpar && endpar->GetDepth()) {
+                       endpar = endpar->next();
+                       undoendpar = endpar;
+               }
+       } else if (endpar) {
+               endpar = endpar->next(); // because of parindents etc.
+       }
+       
+       SetUndo(bview->buffer(), Undo::EDIT,
+               sstart_cur.par()->previous(),
+               undoendpar);
+       
+       /* ok we have a selection. This is always between sstart_cur
+        * and sel_end cursor */ 
+       cur = sstart_cur;
+       
+       LyXLayout const & lyxlayout =
+               textclasslist.Style(bview->buffer()->params.textclass, layout);
+       
+       while (cur.par() != send_cur.par()) {
+               cur.par()->SetLayout(layout);
+               MakeFontEntriesLayoutSpecific(bview->buffer(), cur.par());
                LyXParagraph * fppar = cur.par();
-#endif
                fppar->params.spaceTop(lyxlayout.fill_top ?
-                       VSpace(VSpace::VFILL) : VSpace(VSpace::NONE));
+                                      VSpace(VSpace::VFILL)
+                                      : VSpace(VSpace::NONE));
                fppar->params.spaceBottom(lyxlayout.fill_bottom ? 
-                       VSpace(VSpace::VFILL) : VSpace(VSpace::NONE));
+                                         VSpace(VSpace::VFILL)
+                                         : VSpace(VSpace::NONE));
                if (lyxlayout.margintype == MARGIN_MANUAL)
                        cur.par()->SetLabelWidthString(lyxlayout.labelstring());
                if (lyxlayout.labeltype != LABEL_BIBLIO
@@ -631,11 +655,26 @@ LyXParagraph * LyXText::SetLayout(BufferView * bview,
                        delete fppar->bibkey;
                        fppar->bibkey = 0;
                }
-#ifndef NEW_INSETS
+               cur.par(cur.par()->next());
+       }
+       cur.par()->SetLayout(layout);
+       MakeFontEntriesLayoutSpecific(bview->buffer(), cur.par());
+       LyXParagraph * fppar = cur.par();
+       fppar->params.spaceTop(lyxlayout.fill_top ?
+                              VSpace(VSpace::VFILL) : VSpace(VSpace::NONE));
+       fppar->params.spaceBottom(lyxlayout.fill_bottom ? 
+                                 VSpace(VSpace::VFILL) : VSpace(VSpace::NONE));
+       if (lyxlayout.margintype == MARGIN_MANUAL)
+               cur.par()->SetLabelWidthString(lyxlayout.labelstring());
+       if (lyxlayout.labeltype != LABEL_BIBLIO
+           && fppar->bibkey) {
+               delete fppar->bibkey;
+               fppar->bibkey = 0;
        }
-#endif
        return endpar;
 }
+#endif
+
 
 // set layout over selection and make a total rebreak of those paragraphs
 void LyXText::SetLayout(BufferView * bview, LyXTextClass::size_type layout)