From eaad9ff595befab46fba2909632201b923ba8189 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Tue, 26 Aug 2003 14:50:16 +0000 Subject: [PATCH] outerPar "fix" loading problem git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7608 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView_pimpl.C | 3 ++- src/ChangeLog | 4 ++++ src/buffer.C | 1 + src/insets/insetgraphics.C | 6 +++++- src/insets/insettext.C | 2 +- src/lyxrow.C | 28 ++-------------------------- src/lyxrow.h | 14 +++++++------- src/paragraph.C | 4 ++-- src/paragraph.h | 2 ++ src/paragraph_funcs.C | 19 +++++++++++++++++++ src/paragraph_funcs.h | 5 +++++ 11 files changed, 50 insertions(+), 38 deletions(-) diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index 20645f567e..723cbad73c 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -1377,7 +1377,8 @@ void BufferView::Pimpl::updateInset() return; // this should not be needed, but it is... - bv_->text->redoParagraph(bv_->text->cursor.par()); + //bv_->text->redoParagraph(bv_->text->cursor.par()); + //bv_->text->fullRebreak(); update(); updateScrollbar(); diff --git a/src/ChangeLog b/src/ChangeLog index ac3cd42758..7d40d30ec9 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,4 +1,8 @@ +2003-08-26 André Pönitz + + * paragraph_func.[Ch] (outerPar): new function + 2003-08-25 Martin Vermeer * lyxrow_funcs.C: diff --git a/src/buffer.C b/src/buffer.C index 59b6562b9c..60ec4d88c6 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -2190,6 +2190,7 @@ ParIterator Buffer::par_iterator_end() return ParIterator(paragraphs.end(), paragraphs); } + ParConstIterator Buffer::par_iterator_begin() const { return ParConstIterator(const_cast(paragraphs).begin(), paragraphs); diff --git a/src/insets/insetgraphics.C b/src/insets/insetgraphics.C index 23593f85d7..21162b67bd 100644 --- a/src/insets/insetgraphics.C +++ b/src/insets/insetgraphics.C @@ -68,6 +68,8 @@ TODO #include "Lsstream.h" #include "lyxlex.h" #include "lyxrc.h" +#include "paragraph_funcs.h" +#include "lyxtext.h" #include "frontends/Alert.h" #include "frontends/Dialogs.h" @@ -168,8 +170,10 @@ InsetGraphics::~InsetGraphics() void InsetGraphics::statusChanged() { BufferView * bv = graphic_->view(); - if (bv) + if (bv) { + bv->text->redoParagraph(outerPar(*bv->buffer(), this)); bv->updateInset(); + } } diff --git a/src/insets/insettext.C b/src/insets/insettext.C index b88b744f87..e184d8b893 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -247,7 +247,7 @@ void InsetText::metrics(MetricsInfo & mi, Dimension & dim) const int InsetText::textWidth() const { - return textwidth_; + return textwidth_; } diff --git a/src/lyxrow.C b/src/lyxrow.C index 67e8a777f1..a93192a5fb 100644 --- a/src/lyxrow.C +++ b/src/lyxrow.C @@ -38,24 +38,6 @@ Row::Row(pos_type pos) {} -void Row::y(unsigned int newy) -{ - y_ = newy; -} - - -unsigned int Row::y() const -{ - return y_; -} - - -unsigned short Row::height() const -{ - return height_; -} - - void Row::pos(pos_type p) { pos_ = p; @@ -92,12 +74,6 @@ int Row::fill() const } -void Row::height(unsigned short h) -{ - height_ = h; -} - - void Row::width(unsigned int w) { width_ = w; @@ -110,13 +86,13 @@ unsigned int Row::width() const } -void Row::ascent_of_text(unsigned short a) +void Row::ascent_of_text(unsigned int a) { ascent_of_text_ = a; } -unsigned short Row::ascent_of_text() const +unsigned int Row::ascent_of_text() const { return ascent_of_text_; } diff --git a/src/lyxrow.h b/src/lyxrow.h index b68b91b076..2b21b3265c 100644 --- a/src/lyxrow.h +++ b/src/lyxrow.h @@ -37,17 +37,17 @@ public: /// int fill() const; /// - void height(unsigned short h); + void height(unsigned int h) { height_ = h; } /// - unsigned short height() const; + unsigned int height() const { return height_; } /// void width(unsigned int w); /// unsigned int width() const; /// - void ascent_of_text(unsigned short a); + void ascent_of_text(unsigned int a); /// - unsigned short ascent_of_text() const; + unsigned int ascent_of_text() const; /// void top_of_text(unsigned int top); /// @@ -59,9 +59,9 @@ public: /// return true if this row is the start of a paragraph bool isParStart() const; /// return the cached y position - unsigned int y() const; + unsigned int y() const { return y_; } /// cache the y position - void y(unsigned int newy); + void y(unsigned int newy) { y_ = newy; } /// float x() const; /// @@ -89,7 +89,7 @@ private: Needed for hfills, flushright, block etc. */ mutable int fill_; /// - unsigned short height_; + unsigned int height_; /// unsigned int width_; /// cached y position diff --git a/src/paragraph.C b/src/paragraph.C index 2e22229df0..cf68c0e7ef 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -66,7 +66,7 @@ using lyx::pos_type; Paragraph::Paragraph() - : pimpl_(new Paragraph::Pimpl(this)) + : pimpl_(new Paragraph::Pimpl(this)), y(0) { enumdepth = 0; itemdepth = 0; @@ -75,7 +75,7 @@ Paragraph::Paragraph() Paragraph::Paragraph(Paragraph const & lp) - : pimpl_(new Paragraph::Pimpl(*lp.pimpl_, this)) + : pimpl_(new Paragraph::Pimpl(*lp.pimpl_, this)), y(0) { enumdepth = 0; itemdepth = 0; diff --git a/src/paragraph.h b/src/paragraph.h index 68de3902ba..f668965f1b 100644 --- a/src/paragraph.h +++ b/src/paragraph.h @@ -303,6 +303,8 @@ public: /// mutable RowList rows; + /// last draw y position (baseline of top row) + int y; private: /// diff --git a/src/paragraph_funcs.C b/src/paragraph_funcs.C index 8f7a1986a1..e50cf74fbf 100644 --- a/src/paragraph_funcs.C +++ b/src/paragraph_funcs.C @@ -25,6 +25,7 @@ #include "Lsstream.h" #include "support/lstrings.h" +#include "support/LAssert.h" #include "insets/insetoptarg.h" #include "insets/insetcommandparams.h" @@ -1045,3 +1046,21 @@ LyXFont const outerFont(ParagraphList::iterator pit, return tmpfont; } + + +ParagraphList::iterator outerPar(Buffer & buf, InsetOld * inset) +{ + ParIterator pit = buf.par_iterator_begin(); + ParIterator end = buf.par_iterator_end(); + for ( ; pit != end; ++pit) { + InsetList::iterator ii = pit->insetlist.begin(); + InsetList::iterator iend = pit->insetlist.end(); + for ( ; ii != iend; ++ii) + if (ii->inset == inset) + return pit.outerPar(); + } + lyxerr << "outerPar: should not happen\n"; + Assert(false); + return end.pit(); // shut up compiler +} + diff --git a/src/paragraph_funcs.h b/src/paragraph_funcs.h index 1d9190fc7b..e4f0033279 100644 --- a/src/paragraph_funcs.h +++ b/src/paragraph_funcs.h @@ -20,6 +20,7 @@ class BufferParams; class TexRow; class LatexRunParams; class LyXLex; +class InsetOld; /// void breakParagraph(BufferParams const & bparams, @@ -74,4 +75,8 @@ int readParagraph(Buffer & buf, Paragraph & par, LyXLex & lex); LyXFont const outerFont(ParagraphList::iterator pit, ParagraphList const & plist); +/// find outermost paragraph containing an inset +ParagraphList::iterator outerPar(Buffer & buf, InsetOld * inset); + + #endif // PARAGRAPH_FUNCS_H