From 4127ff8a32c02bd622c667277a4652bdb6f41e67 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Fri, 18 Jul 2003 15:30:20 +0000 Subject: [PATCH] remove unneeded Inset::getMaxWidth( git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7319 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/insets/ChangeLog | 9 +++++++++ src/insets/insetert.C | 16 ---------------- src/insets/insetert.h | 2 -- src/insets/insetminipage.C | 20 -------------------- src/insets/insetminipage.h | 2 -- src/insets/insettabular.C | 33 --------------------------------- src/insets/insettabular.h | 4 ---- src/insets/insettext.C | 23 ----------------------- src/insets/insettext.h | 2 -- src/insets/insetwrap.C | 20 -------------------- src/insets/insetwrap.h | 2 -- src/insets/updatableinset.C | 30 ------------------------------ src/insets/updatableinset.h | 2 -- 13 files changed, 9 insertions(+), 156 deletions(-) diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index b1f6fce049..444c1140dc 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,4 +1,13 @@ +2003-07-18 André Pönitz + + * insetert.[Ch]: + * insetminipage.[Ch]: + * insettabular.[Ch]: + * insettext.[Ch]: + * insetwrap.[Ch]: + * updatableinset.[Ch]: remove unneeded Inset::getMaxWidth() + 2003-07-18 André Pönitz * inset.[Ch]: diff --git a/src/insets/insetert.C b/src/insets/insetert.C index 0a635c911d..e24c5c2a71 100644 --- a/src/insets/insetert.C +++ b/src/insets/insetert.C @@ -647,22 +647,6 @@ void InsetERT::getDrawFont(LyXFont & font) const } -int InsetERT::getMaxWidth(BufferView * bv, UpdatableInset const * in) const -{ - int w = InsetCollapsable::getMaxWidth(bv, in); - if (status_ != Inlined || w < 0) - return w; - LyXText * text = inset.getLyXText(bv); - int rw = text->rows().begin()->width(); - if (!rw) - rw = w; - rw += 40; - if (text->rows().size() == 1 && rw < w) - return -1; - return w; -} - - string const InsetERTMailer::name_("ert"); InsetERTMailer::InsetERTMailer(InsetERT & inset) diff --git a/src/insets/insetert.h b/src/insets/insetert.h index a6ed08548b..b883a1eb36 100644 --- a/src/insets/insetert.h +++ b/src/insets/insetert.h @@ -112,8 +112,6 @@ public: bool forceDefaultParagraphs(Inset const *) const { return true; } - /// - int getMaxWidth(BufferView *, UpdatableInset const *) const; private: /// diff --git a/src/insets/insetminipage.C b/src/insets/insetminipage.C index cc8a22cce4..f0d38863ff 100644 --- a/src/insets/insetminipage.C +++ b/src/insets/insetminipage.C @@ -296,26 +296,6 @@ bool InsetMinipage::showInsetDialog(BufferView * bv) const } -int InsetMinipage::getMaxWidth(BufferView * bv, UpdatableInset const * inset) - const -{ - if (owner() && - static_cast(owner())->getMaxWidth(bv, inset) < 0) { - return -1; - } - if (!params_.width.zero()) { - int ww1 = latexTextWidth(bv); - int ww2 = InsetCollapsable::getMaxWidth(bv, inset); - if (ww2 > 0 && ww2 < ww1) { - return ww2; - } - return ww1; - } - // this should not happen! - return InsetCollapsable::getMaxWidth(bv, inset); -} - - int InsetMinipage::latexTextWidth(BufferView * bv) const { return params_.width.inPixels(InsetCollapsable::latexTextWidth(bv)); diff --git a/src/insets/insetminipage.h b/src/insets/insetminipage.h index b4665cc3dc..dafcc0b1a6 100644 --- a/src/insets/insetminipage.h +++ b/src/insets/insetminipage.h @@ -79,8 +79,6 @@ public: /// bool insetAllowed(Inset::Code) const; /// - int getMaxWidth(BufferView *, UpdatableInset const *) const; - /// bool needFullRow() const { return false; } /** returns true if, when outputing LaTeX, font changes should be closed before generating this inset. This is needed for diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index 25bd89c1f8..a8104e8f85 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -2073,39 +2073,6 @@ bool InsetTabular::insetHit(BufferView *, int x, int) const } -// This returns paperWidth() if the cell-width is unlimited or the width -// in pixels if we have a pwidth for this cell. -int InsetTabular::getMaxWidthOfCell(BufferView * bv, int cell) const -{ - LyXLength const len = tabular.getPWidth(cell); - - if (len.zero()) - return -1; - return len.inPixels(latexTextWidth(bv)); -} - - -int InsetTabular::getMaxWidth(BufferView * bv, - UpdatableInset const * inset) const -{ - int cell = tabular.getCellFromInset(inset, actcell); - - if (cell == -1) { - lyxerr << "Own inset not found, shouldn't really happen!" - << endl; - return -1; - } - - int w = getMaxWidthOfCell(bv, cell); - if (w > 0) { - // because the inset then subtracts it's top_x and owner->x() - w += (inset->x() - top_x); - } - - return w; -} - - void InsetTabular::deleteLyXText(BufferView * bv, bool recursive) const { resizeLyXText(bv, recursive); diff --git a/src/insets/insettabular.h b/src/insets/insettabular.h index 6b4e735aef..ba279a30b2 100644 --- a/src/insets/insettabular.h +++ b/src/insets/insettabular.h @@ -146,8 +146,6 @@ public: void setFont(BufferView *, LyXFont const &, bool toggleall = false, bool selectall = false); /// - int getMaxWidth(BufferView *, UpdatableInset const *) const; - /// LyXText * getLyXText(BufferView const *, bool const recursive = false) const; /// @@ -289,8 +287,6 @@ private: /// bool insetHit(BufferView * bv, int x, int y) const; /// - int getMaxWidthOfCell(BufferView * bv, int cell) const; - /// bool hasPasteBuffer() const; /// bool copySelection(BufferView *); diff --git a/src/insets/insettext.C b/src/insets/insettext.C index e8303eadef..c43efa70a5 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -1758,25 +1758,6 @@ bool InsetText::checkAndActivateInset(BufferView * bv, int x, int y, } -int InsetText::getMaxWidth(BufferView * bv, UpdatableInset const * inset) const -{ -#if 0 - int w = UpdatableInset::getMaxWidth(bv, inset); - if (w < 0) { - return -1; - } - if (owner()) { - w = w - top_x + owner()->x(); - return w; - } - w -= (2 * TEXT_TO_INSET_OFFSET); - return w - top_x; -#else - return UpdatableInset::getMaxWidth(bv, inset); -#endif -} - - void InsetText::setParagraphData(ParagraphList const & plist) { // we have to unlock any locked inset otherwise we're in troubles @@ -1962,10 +1943,6 @@ void InsetText::resizeLyXText(BufferView * bv, bool force) const Assert(bv); setViewCache(bv); - // one endless line, resize normally not necessary - if (!force && getMaxWidth(bv, this) < 0) - return; - saveLyXTextState(); for_each(const_cast(paragraphs).begin(), diff --git a/src/insets/insettext.h b/src/insets/insettext.h index 70325f6530..987856b5b7 100644 --- a/src/insets/insettext.h +++ b/src/insets/insettext.h @@ -142,8 +142,6 @@ public: bool toggleall = false, bool selectall = false); /// - int getMaxWidth(BufferView *, UpdatableInset const *) const; - /// void init(InsetText const * ins); /// void writeParagraphData(Buffer const *, std::ostream &) const; diff --git a/src/insets/insetwrap.C b/src/insets/insetwrap.C index 2e0140ba28..26d532c931 100644 --- a/src/insets/insetwrap.C +++ b/src/insets/insetwrap.C @@ -218,26 +218,6 @@ bool InsetWrap::insetAllowed(Inset::Code code) const } -int InsetWrap::getMaxWidth(BufferView * bv, UpdatableInset const * inset) - const -{ - if (owner() && - static_cast(owner())->getMaxWidth(bv, inset) < 0) { - return -1; - } - if (!params_.width.zero()) { - int const ww1 = latexTextWidth(bv); - int const ww2 = InsetCollapsable::getMaxWidth(bv, inset); - if (ww2 > 0 && ww2 < ww1) { - return ww2; - } - return ww1; - } - // this should not happen! - return InsetCollapsable::getMaxWidth(bv, inset); -} - - int InsetWrap::latexTextWidth(BufferView * bv) const { return params_.width.inPixels(InsetCollapsable::latexTextWidth(bv)); diff --git a/src/insets/insetwrap.h b/src/insets/insetwrap.h index ab6721bde3..a49aa84930 100644 --- a/src/insets/insetwrap.h +++ b/src/insets/insetwrap.h @@ -62,8 +62,6 @@ public: /// bool insetAllowed(Inset::Code) const; /// - int getMaxWidth(BufferView *, UpdatableInset const *) const; - /// void addToToc(toc::TocList &, Buffer const *) const; /// bool showInsetDialog(BufferView *) const; diff --git a/src/insets/updatableinset.C b/src/insets/updatableinset.C index d9ad5d2d10..c7c5a60a84 100644 --- a/src/insets/updatableinset.C +++ b/src/insets/updatableinset.C @@ -133,36 +133,6 @@ Inset::RESULT UpdatableInset::localDispatch(FuncRequest const & ev) } -int UpdatableInset::getMaxWidth(BufferView * bv, UpdatableInset const *) const -{ - int w; - - if (owner()) { - w = owner()->getMaxWidth(bv, this); - } else { - w = bv->text->workWidth(this); - } - if (w < 0) { - return -1; - } - // check for margins left/right and extra right margin "const 5" - if ((w - (2 * TEXT_TO_INSET_OFFSET + 5)) >= 0) - w -= 2 * TEXT_TO_INSET_OFFSET + 5; - - // Deep magic. I don't understand this either. - if (owner() && owner()->owner()) { - // add the right paper margin - w -= 20; - } - - // FIXME: why ? - if (w < 10) { - w = 10; - } - return w; -} - - LyXCursor const & Inset::cursor(BufferView * bv) const { if (owner()) diff --git a/src/insets/updatableinset.h b/src/insets/updatableinset.h index 77046dc1df..5209585afe 100644 --- a/src/insets/updatableinset.h +++ b/src/insets/updatableinset.h @@ -91,8 +91,6 @@ public: /// An updatable inset could handle lyx editing commands virtual RESULT localDispatch(FuncRequest const & cmd); /// - virtual int getMaxWidth(BufferView * bv, UpdatableInset const *) const; - /// int scroll(bool recursive = true) const { // We need this method to not clobber the real method in Inset return Inset::scroll(recursive); -- 2.39.2