]> git.lyx.org Git - features.git/commitdiff
InsetText: remove InsetText default ctor and make text_ member private.
authorAbdelrazak Younes <younes@lyx.org>
Tue, 29 Jul 2008 12:07:08 +0000 (12:07 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Tue, 29 Jul 2008 12:07:08 +0000 (12:07 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25974 a592a061-630c-0410-9148-cb99ea01b6c8

src/Buffer.cpp
src/CutAndPaste.cpp
src/Text3.cpp
src/insets/InsetBranch.cpp
src/insets/InsetCaption.cpp
src/insets/InsetCollapsable.cpp
src/insets/InsetTabular.cpp
src/insets/InsetText.cpp
src/insets/InsetText.h

index 96c4c6adc638db22c61883647e2464cbfa06dee6..406682b0ef46373b826b5c41a3a82b5fa5fd45ed 100644 (file)
@@ -315,7 +315,7 @@ frontend::WorkAreaManager & Buffer::workAreaManager() const
 
 Text & Buffer::text() const
 {
-       return d->inset->text_;
+       return d->inset->text();
 }
 
 
index e878e30c1f4bd647bbe0c6411dabf06ba8f2faa0..ba82e9439f9bd2729debd796e752320b8b0eb44d 100644 (file)
@@ -154,8 +154,9 @@ pasteSelectionHelper(Cursor & cur, ParagraphList const & parlist,
                }
        }
 
+       InsetText in(buffer);
        // Make sure there is no class difference.
-       InsetText in;
+       in.paragraphs().clear();
        // This works without copying any paragraph data because we have
        // a specialized swap method for ParagraphList. This is important
        // since we store pointers to insets at some places and we don't
index 3671170eaf1007af8930085bed4db8dd1d1e64d0..b1635e2f55ffa5675ce3fa8333327185ae2cf20b 100644 (file)
@@ -202,7 +202,7 @@ static bool doInsertInset(Cursor & cur, Text * text,
                if (edit)
                        inset->edit(cur, true);
                // Now put this into inset
-               static_cast<InsetCollapsable *>(inset)->text_.insertStringAsParagraphs(cur, ds);
+               static_cast<InsetCollapsable *>(inset)->text().insertStringAsParagraphs(cur, ds);
                return true;
        }
 
index 02537c05f60353e75903f4de61e51b2bca2ea906..3eea5ddefb2032cce8f7cb38b608ce58620b3417 100644 (file)
@@ -277,7 +277,7 @@ void InsetBranch::addToToc(DocIterator const & cpit)
        pit.push_back(CursorSlice(*this));
 
        Toc & toc = buffer().tocBackend().toc("branch");
-       docstring const str = params_.branch + ": " + text_.getPar(0).asString();
+       docstring const str = params_.branch + ": " + text().getPar(0).asString();
        toc.push_back(TocItem(pit, 0, str));
        // Proceed with the rest of the inset.
        InsetCollapsable::addToToc(cpit);
index b0f4d029817a9fde3df699ae6f7faa8d9c741f56..be5bc00d3fd38aa1ceeac3d4266b99410b2a94a9 100644 (file)
@@ -61,7 +61,7 @@ InsetCaption::InsetCaption(Buffer const & buf)
 void InsetCaption::write(ostream & os) const
 {
        os << "Caption\n";
-       text_.write(buffer(), os);
+       text().write(buffer(), os);
 }
 
 
@@ -111,7 +111,7 @@ void InsetCaption::addToToc(DocIterator const & cpit)
        pit.push_back(CursorSlice(*this));
 
        Toc & toc = buffer().tocBackend().toc(type_);
-       docstring const str = full_label_ + ". " + text_.getPar(0).asString();
+       docstring const str = full_label_ + ". " + text().getPar(0).asString();
        toc.push_back(TocItem(pit, 0, str));
 
        // Proceed with the rest of the inset.
index 7cb36e2a9a4fc2406d3a6c7209f62280ee14551b..e897ee02b7b32ea193c4c26abd11422e61cd556c 100644 (file)
@@ -167,7 +167,7 @@ void InsetCollapsable::write(ostream & os) const
                break;
        }
        os << "\n";
-       text_.write(buffer(), os);
+       text().write(buffer(), os);
 }
 
 
index cbce92c348593b2b8c07740eb93d61e13a1b55b6..7cf33c3288373ca21b0404d9b2269f21d87c5d35 100644 (file)
@@ -3903,14 +3903,14 @@ Inset * InsetTabular::editXY(Cursor & cur, int x, int y)
        cur.push(*this);
        cur.idx() = getNearestCell(cur.bv(), x, y);
        resetPos(cur);
-       return cur.bv().textMetrics(&cell(cur.idx())->text_).editXY(cur, x, y);
+       return cur.bv().textMetrics(&cell(cur.idx())->text()).editXY(cur, x, y);
 }
 
 
 void InsetTabular::setCursorFromCoordinates(Cursor & cur, int x, int y) const
 {
        cur.idx() = getNearestCell(cur.bv(), x, y);
-       cur.bv().textMetrics(&cell(cur.idx())->text_).setCursorFromCoordinates(cur, x, y);
+       cur.bv().textMetrics(&cell(cur.idx())->text()).setCursorFromCoordinates(cur, x, y);
 }
 
 
@@ -4755,7 +4755,7 @@ bool InsetTabular::insertPlaintextString(BufferView & bv, docstring const & buf,
                        // we can only set this if we are not too far right
                        if (cols < columns) {
                                shared_ptr<InsetTableCell> inset = loctab->cellInset(cell);
-                               Font const font = bv.textMetrics(&inset->text_).
+                               Font const font = bv.textMetrics(&inset->text()).
                                        displayFont(0, 0);
                                inset->setText(buf.substr(op, p - op), font,
                                               buffer().params().trackChanges);
@@ -4767,7 +4767,7 @@ bool InsetTabular::insertPlaintextString(BufferView & bv, docstring const & buf,
                        // we can only set this if we are not too far right
                        if (cols < columns) {
                                shared_ptr<InsetTableCell> inset = tabular.cellInset(cell);
-                               Font const font = bv.textMetrics(&inset->text_).
+                               Font const font = bv.textMetrics(&inset->text()).
                                        displayFont(0, 0);
                                inset->setText(buf.substr(op, p - op), font,
                                               buffer().params().trackChanges);
@@ -4784,7 +4784,7 @@ bool InsetTabular::insertPlaintextString(BufferView & bv, docstring const & buf,
        // check for the last cell if there is no trailing '\n'
        if (cell < cells && op < len) {
                shared_ptr<InsetTableCell> inset = loctab->cellInset(cell);
-               Font const font = bv.textMetrics(&inset->text_).displayFont(0, 0);
+               Font const font = bv.textMetrics(&inset->text()).displayFont(0, 0);
                inset->setText(buf.substr(op, len - op), font,
                        buffer().params().trackChanges);
        }
index 71bc8ae80e72290076f0f859c8ad2e8eca9bc38c..cf34fc9ed06dede2719afbe4a3c929fcda76ceb3 100644 (file)
@@ -73,7 +73,8 @@ using graphics::PreviewLoader;
 InsetText::InsetText(Buffer const & buf)
        : drawFrame_(false), frame_color_(Color_insetframe)
 {
-       initParagraphs(buf);
+       initParagraphs(buf.params());
+       setBuffer(const_cast<Buffer &>(buf));
 }
 
 
@@ -88,10 +89,6 @@ InsetText::InsetText(InsetText const & in)
 }
 
 
-InsetText::InsetText()
-{}
-
-
 void InsetText::setBuffer(Buffer & buf)
 {
        ParagraphList::iterator end = paragraphs().end();
@@ -101,16 +98,16 @@ void InsetText::setBuffer(Buffer & buf)
 }
 
 
-void InsetText::initParagraphs(Buffer const & buf)
+void InsetText::initParagraphs(BufferParams const & bparams)
 {
        LASSERT(paragraphs().empty(), /**/);
-       buffer_ = const_cast<Buffer *>(&buf);
        paragraphs().push_back(Paragraph());
        Paragraph & ourpar = paragraphs().back();
-       ourpar.setPlainOrDefaultLayout(buf.params().documentClass());
+       ourpar.setPlainOrDefaultLayout(bparams.documentClass());
        ourpar.setInsetOwner(this);
 }
 
+
 void InsetText::setParagraphOwner()
 {
        for_each(paragraphs().begin(), paragraphs().end(),
index 7be51ddd0113ad3336041db572ab0397081ed4d8..f20fd4a0b36e88098410c90d9e48c41e6871371c 100644 (file)
@@ -37,12 +37,8 @@ public:
        ///
        explicit InsetText(Buffer const & buffer);
        ///
-       InsetText();
-       ///
        InsetText(InsetText const &);
        ///
-       void initParagraphs(Buffer const & buffer);
-       ///
        void setBuffer(Buffer &);
 
        ///
@@ -69,6 +65,9 @@ public:
        ///
        InsetText const * asInsetText() const { return this; }
        ///
+       Text & text() { return text_; }
+       Text const & text() const { return text_; }
+       ///
        int latex(odocstream &, OutputParams const &) const;
        ///
        int plaintext(odocstream &, OutputParams const &) const;
@@ -169,6 +168,8 @@ public:
        ///
        void doDispatch(Cursor & cur, FuncRequest & cmd);
 private:
+       ///
+       void initParagraphs(BufferParams const &);
        ///
        void setParagraphOwner();
        ///
@@ -177,8 +178,6 @@ private:
        ColorCode frame_color_;
        ///
        mutable pit_type old_pit;
-
-public:
        ///
        mutable Text text_;
 };