]> git.lyx.org Git - features.git/commitdiff
* paragraph_funcs.{cpp,h}:
authorJürgen Spitzmüller <spitz@lyx.org>
Mon, 25 May 2009 07:52:55 +0000 (07:52 +0000)
committerJürgen Spitzmüller <spitz@lyx.org>
Mon, 25 May 2009 07:52:55 +0000 (07:52 +0000)
- new member setLabelWidthStringToSequence

* Text2.cpp (setParagraphs):
- use that.

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

src/Text2.cpp
src/paragraph_funcs.cpp
src/paragraph_funcs.h

index b32f3a05261809cd9f922c4c99e10fe67e5d7703..9da71eb76eaa9eb7ee149b7587989150a47be2c0 100644 (file)
@@ -449,6 +449,10 @@ void Text::setParagraphs(Cursor & cur, docstring arg, bool merge)
                Paragraph & par = pars_[pit];
                ParagraphParameters params = par.params();
                params.read(argument, merge);
+               // changes to label width string apply to all
+               // paragraph with same layout in a sequence
+               setLabelWidthStringToSequence(pit, pars_,
+                               params.labelWidthString());
                par.params().apply(params, par.layout());
        }
 }
@@ -467,6 +471,10 @@ void Text::setParagraphs(Cursor & cur, ParagraphParameters const & p)
        for (pit_type pit = cur.selBegin().pit(), end = cur.selEnd().pit();
             pit <= end; ++pit) {
                Paragraph & par = pars_[pit];
+               // changes to label width string apply to all
+               // paragraph with same layout in a sequence
+               setLabelWidthStringToSequence(pit, pars_,
+                               par.params().labelWidthString());
                par.params().apply(p, par.layout());
        }       
 }
index 0459ed79117dcef4dbdddd46935e9b637735bd2e..0d626e3d64f11dac0cbebadce2aee3d76a7a3092 100644 (file)
@@ -256,6 +256,33 @@ bool isFirstInSequence(pit_type par_offset, ParagraphList const & pars)
 }
 
 
+void setLabelWidthStringToSequence(pit_type par_offset,
+       ParagraphList & pars, docstring const & s)
+{
+       Paragraph & par = pars[par_offset];
+       // Find first of same layout in sequence
+       while (!isFirstInSequence(par_offset, pars)) {
+               par_offset = depthHook(par_offset, pars, par.getDepth());
+               par = pars[par_offset];
+       }
+
+       // now apply label width string to every par
+       // in sequence
+       pit_type const end = pars.size();
+       depth_type const depth = par.getDepth();
+       Layout const & layout = par.layout();
+       for (pit_type pit = par_offset; pit != end; ++pit) {
+               while (pars[pit].getDepth() > depth)
+                       ++pit;
+               if (pars[pit].getDepth() < depth)
+                       return;
+               if (pars[pit].layout() != layout)
+                       return;
+               pars[pit].setLabelWidthString(s);
+       }
+}
+
+
 int getEndLabel(pit_type p, ParagraphList const & pars)
 {
        pit_type pit = p;
index fa9aba20786f2c4794fbb1418de7cb4a5a50753d..e41fc455e63bab4d7d13e1c06c81efde5c8d4ea6 100644 (file)
@@ -12,6 +12,7 @@
 #ifndef PARAGRAPH_FUNCS_H
 #define PARAGRAPH_FUNCS_H
 
+#include "support/docstring.h"
 #include "support/types.h"
 
 
@@ -60,6 +61,11 @@ pit_type outerHook(pit_type par, ParagraphList const & plist);
 /// Is it the first par with same depth and layout?
 bool isFirstInSequence(pit_type par, ParagraphList const & plist);
 
+/** Set Label Width string to all paragraphs of the same layout
+    and depth in a sequence */
+void setLabelWidthStringToSequence(pit_type par_offset,
+       ParagraphList & pars, docstring const & s);
+
 /** Check if the current paragraph is the last paragraph in a
     proof environment */
 int getEndLabel(pit_type par, ParagraphList const & plist);