]> git.lyx.org Git - features.git/commitdiff
Move setLabelWidthStringToSequence() to Text private member.
authorAbdelrazak Younes <younes@lyx.org>
Sun, 9 Aug 2009 17:45:24 +0000 (17:45 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Sun, 9 Aug 2009 17:45:24 +0000 (17:45 +0000)
Move isFullyDeleted() to static function in CutAndPaste.cpp.

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

src/CutAndPaste.cpp
src/Text.cpp
src/Text.h
src/Text2.cpp

index 1efca23341064d63d4f91d4294ed68194abbe0e8..96063774977460fb2b336ed752522c14b08da4db 100644 (file)
@@ -429,6 +429,21 @@ void putClipboard(ParagraphList const & paragraphs,
 }
 
 
+/// return true if the whole ParagraphList is deleted
+static bool isFullyDeleted(ParagraphList const & pars)
+{
+       pit_type const pars_size = static_cast<pit_type>(pars.size());
+
+       // check all paragraphs
+       for (pit_type pit = 0; pit < pars_size; ++pit) {
+               if (!pars[pit].empty())   // prevent assertion failure
+                       if (!pars[pit].isDeleted(0, pars[pit].size()))
+                               return false;
+       }
+       return true;
+}
+
+
 void copySelectionHelper(Buffer const & buf, Text const & text,
        pit_type startpit, pit_type endpit,
        int start, int end, DocumentClass const * const dc, CutStack & cutstack)
index 153685cc9eb8981c0e17acd5d60e0de96e228353..fbdb2e7eccca0e84cf8b09d7c15731287356af30 100644 (file)
@@ -214,32 +214,6 @@ bool isFirstInSequence(pit_type par_offset, ParagraphList const & pars)
 }
 
 
-void setLabelWidthStringToSequence(pit_type const par_offset,
-       ParagraphList & pars, docstring const & s)
-{
-       pit_type offset = par_offset;
-       // Find first of same layout in sequence
-       while (!isFirstInSequence(offset, pars)) {
-               offset = depthHook(offset, pars, pars[offset].getDepth());
-       }
-
-       // now apply label width string to every par
-       // in sequence
-       pit_type const end = pars.size();
-       depth_type const depth = pars[offset].getDepth();
-       Layout const & layout = pars[offset].layout();
-       for (pit_type pit = 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;
@@ -289,20 +263,6 @@ Font const outerFont(pit_type par_offset, ParagraphList const & pars)
 }
 
 
-bool isFullyDeleted(ParagraphList const & pars)
-{
-       pit_type const pars_size = static_cast<pit_type>(pars.size());
-
-       // check all paragraphs
-       for (pit_type pit = 0; pit < pars_size; ++pit) {
-               if (!pars[pit].empty())   // prevent assertion failure
-                       if (!pars[pit].isDeleted(0, pars[pit].size()))
-                               return false;
-       }
-       return true;
-}
-
-
 void acceptChanges(ParagraphList & pars, BufferParams const & bparams)
 {
        pit_type pars_size = static_cast<pit_type>(pars.size());
index 47860104a45d469bd0ce9bd0778f31e3e0ad845e..0f4039e0c857d61a8fb4c7860cefbfd0e8ad409b 100644 (file)
@@ -347,6 +347,9 @@ private:
                Font & font, Change & change, ErrorList & errorList);
        ///
        void readParagraph(Paragraph & par, Lexer & lex, ErrorList & errorList);
+       /// Set Label Width string to all paragraphs of the same layout
+    /// and depth in a sequence.
+       void setLabelWidthStringToSequence(pit_type const par_offset, docstring const & s);
 
        /// Owner Inset.
        InsetText * owner_;
@@ -382,11 +385,6 @@ 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 const 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);
@@ -400,9 +398,6 @@ Font const outerFont(pit_type par_offset, ParagraphList const & pars);
 /// accept the changes within the complete ParagraphList
 void acceptChanges(ParagraphList & pars, BufferParams const & bparams);
 
-/// return true if the whole ParagraphList is deleted
-bool isFullyDeleted(ParagraphList const & pars);
-
 } // namespace lyx
 
 #endif // TEXT_H
index 080fdc0c463e332b12ae32a7986cf1f9f0a3f164..d83402b3c37edd145b5f4f0ce468a93f56a7cbe0 100644 (file)
@@ -431,6 +431,32 @@ docstring Text::getStringToIndex(Cursor const & cur)
 }
 
 
+void Text::setLabelWidthStringToSequence(pit_type const par_offset,
+               docstring const & s)
+{
+       pit_type offset = par_offset;
+       // Find first of same layout in sequence
+       while (!isFirstInSequence(offset, pars_)) {
+               offset = depthHook(offset, pars_, pars_[offset].getDepth());
+       }
+
+       // now apply label width string to every par
+       // in sequence
+       pit_type const end = pars_.size();
+       depth_type const depth = pars_[offset].getDepth();
+       Layout const & layout = pars_[offset].layout();
+       for (pit_type pit = 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);
+       }
+}
+
+
 void Text::setParagraphs(Cursor & cur, docstring arg, bool merge) 
 {
        LASSERT(cur.text(), /**/);
@@ -452,8 +478,7 @@ void Text::setParagraphs(Cursor & cur, docstring arg, bool merge)
                // Do this only once for a selected range of paragraphs
                // of the same layout and depth.
                if (par.getDepth() != priordepth || par.layout() != priorlayout)
-                       setLabelWidthStringToSequence(pit, pars_,
-                                       params.labelWidthString());
+                       setLabelWidthStringToSequence(pit, params.labelWidthString());
                par.params().apply(params, par.layout());
                priordepth = par.getDepth();
                priorlayout = par.layout();
@@ -481,8 +506,8 @@ void Text::setParagraphs(Cursor & cur, ParagraphParameters const & p)
                // Do this only once for a selected range of paragraphs
                // of the same layout and depth.
                if (par.getDepth() != priordepth || par.layout() != priorlayout)
-                       setLabelWidthStringToSequence(pit, pars_,
-                                       par.params().labelWidthString());
+                       setLabelWidthStringToSequence(pit,
+                               par.params().labelWidthString());
                par.params().apply(p, par.layout());
                priordepth = par.getDepth();
                priorlayout = par.layout();