From bded6fd063ccb555e59290b6923cf0febe87010e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Lars=20Gullik=20Bj=C3=B8nnes?= Date: Wed, 1 May 2002 22:17:09 +0000 Subject: [PATCH] remove return arg from fullRebreak, fix last "Standards", new operaotr>> for lyxstring (might need more work), some ws changes git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4108 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView_pimpl.C | 44 +++---- src/ChangeLog | 26 +++- src/WorkArea.C | 3 + src/buffer.C | 232 ++++++++++++++++----------------- src/frontends/xforms/ChangeLog | 8 +- src/insets/insetfloat.C | 2 +- src/insets/insetindex.C | 6 +- src/insets/insetindex.h | 4 +- src/insets/insettext.C | 24 ++-- src/lyxtext.h | 5 +- src/screen.C | 8 +- src/support/ChangeLog | 6 +- src/support/filetools.C | 11 +- src/support/lyxstring.C | 46 +++++-- src/text2.C | 7 +- 15 files changed, 241 insertions(+), 191 deletions(-) diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index 87f5e13afc..5b41de1b1e 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -1092,20 +1092,19 @@ void BufferView::Pimpl::update() screen_->update(bv_->text, bv_); bool fitc = false; while (bv_->text->status() == LyXText::CHANGED_IN_DRAW) { - if (bv_->text->fullRebreak(bv_)) { - st = LyXText::NEED_MORE_REFRESH; - bv_->text->setCursor(bv_, bv_->text->cursor.par(), - bv_->text->cursor.pos()); - if (bv_->text->selection.set()) { - bv_->text->setCursor(bv_, bv_->text->selection.start, - bv_->text->selection.start.par(), - bv_->text->selection.start.pos()); - bv_->text->setCursor(bv_, bv_->text->selection.end, - bv_->text->selection.end.par(), - bv_->text->selection.end.pos()); - } - fitc = true; + bv_->text->fullRebreak(bv_); + st = LyXText::NEED_MORE_REFRESH; + bv_->text->setCursor(bv_, bv_->text->cursor.par(), + bv_->text->cursor.pos()); + if (bv_->text->selection.set()) { + bv_->text->setCursor(bv_, bv_->text->selection.start, + bv_->text->selection.start.par(), + bv_->text->selection.start.pos()); + bv_->text->setCursor(bv_, bv_->text->selection.end, + bv_->text->selection.end.par(), + bv_->text->selection.end.pos()); } + fitc = true; bv_->text->status(bv_, st); screen_->update(bv_->text, bv_); } @@ -1655,6 +1654,8 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) lyxerr[Debug::ACTION] << "BufferView::Pimpl::Dispatch: action[" << action <<"] arg[" << argument << "]" << endl; + LyXTextClass const & tclass = textclasslist[buffer_->params.textclass]; + switch (action) { // --- Misc ------------------------------------------- case LFUN_APPENDIX: @@ -1675,7 +1676,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) InsetCommandParams p; p.setCmdName("tableofcontents"); Inset * inset = new InsetTOC(p); - if (!insertInset(inset, "Standard")) + if (!insertInset(inset, tclass.defaultLayoutName())) delete inset; break; } @@ -1802,15 +1803,12 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) // Derive layout number from given argument (string) // and current buffer's textclass (number). */ - textclass_type tclass = buffer_->params.textclass; - bool hasLayout = - textclasslist[tclass].hasLayout(argument); + bool hasLayout = tclass.hasLayout(argument); string layout = argument; // If the entry is obsolete, use the new one instead. if (hasLayout) { - string const & obs = textclasslist[tclass][layout] - .obsoleted_by(); + string const & obs = tclass[layout].obsoleted_by(); if (!obs.empty()) layout = obs; } @@ -2488,7 +2486,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) { LyXText * lt = bv_->getLyXText(); - LyXLayout const & style = textclasslist[buffer_->params.textclass][lt->cursor.par()->layout()]; + LyXLayout const & style = tclass[lt->cursor.par()->layout()]; if (style.free_spacing) { lt->insertChar(bv_, ' '); @@ -3209,7 +3207,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) { InsetCommandParams p("printindex"); Inset * inset = new InsetPrintIndex(p); - if (!insertInset(inset, "Standard")) + if (!insertInset(inset, tclass.defaultLayoutName())) delete inset; } break; @@ -3218,7 +3216,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) { InsetCommandParams p("lyxparent", argument); Inset * inset = new InsetParent(p, *buffer_); - if (!insertInset(inset, "Standard")) + if (!insertInset(inset, tclass.defaultLayoutName())) delete inset; } @@ -3243,7 +3241,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) case LFUN_FLOAT_LIST: if (floatList.typeExist(argument)) { Inset * inset = new InsetFloatList(argument); - if (!insertInset(inset, "Standard")) + if (!insertInset(inset, tclass.defaultLayoutName())) delete inset; } else { lyxerr << "Non-existent float type: " diff --git a/src/ChangeLog b/src/ChangeLog index 5a4b257c06..b535130760 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,19 @@ +2002-05-02 Lars Gullik Bjønnes + + * screen.C (drawFromTo): change sine fullRebreak always return + true. + + * buffer.C (parseSingleLyXformat2Token): reindent some + + * BufferView_pimpl.C (update): change since fullRebreak always + return true. + (Dispatch): git rid of the last hardcoded "Standard"s. + +2002-05-01 Lars Gullik Bjønnes + + * text2.[Ch] (fullRebreak): make it return void now that we always + returned true. + 2002-04-30 Juergen Vigna * buffer.C (parseSingleLyXformat2Token): reset the font before the @@ -5,14 +21,14 @@ 2002-04-29 Dekel Tsur - * buffer.C (parseSingleLyXformat2Token): Fix reading of old format + * buffer.C (parseSingleLyXformat2Token): Fix reading of old format minipages: use col% instead of p%, and also use the current font. (makeLaTeXFile): Fix use babel condition. (parseSingleLyXformat2Token): Correct font when reading old floats. 2002-04-28 Dekel Tsur - * BufferView_pimpl.C (Dispatch): Check that float type exists when + * BufferView_pimpl.C (Dispatch): Check that float type exists when inserting list of floats. 2002-04-25 Herbert Voss @@ -39,11 +55,11 @@ 2002-04-23 Mike Ressler - * lyxtextclass.[Ch]: add layout keyword ProvidesNatbib. + * lyxtextclass.[Ch]: add layout keyword ProvidesNatbib. * LaTeXFeatures.C: do not add \usepackage{natbib} to tex file if natbib is provided by the LaTeX class. - + 2002-04-23 Juergen Vigna * BufferView_pimpl.[Ch]: remove use of wrong and unneeded insetSleep/ @@ -84,7 +100,7 @@ * tabular.C (OldFormatRead): check also for \\end_inset as Lars changed the read and substituted \\end_float with \\end_inset! - * BufferView_pimpl.C (cursorPrevious): + * BufferView_pimpl.C (cursorPrevious): (cursorNext): fixed to make it work with rows heigher than the work area without moving the cursor only the draw of the row. (workAreaMotionNotify): fix jumping over high rows. diff --git a/src/WorkArea.C b/src/WorkArea.C index 232e2e1651..cb114c60e0 100644 --- a/src/WorkArea.C +++ b/src/WorkArea.C @@ -401,6 +401,9 @@ int WorkArea::work_area_handler(FL_OBJECT * ob, int event, LyXLookupString(ev, dummy, 1, &keysym); #else XLookupString(xke, dummy, 1, &keysym, 0); +// int num_keys = XLookupString(xke, dummy, 10, &keysym, &xcs); +// lyxerr << "We have " << num_keys << " keys in the returned buffer" << endl; +// lyxerr << "Our dummy string is " << dummy << endl; #endif if (lyxerr.debugging(Debug::KEY)) { char const * tmp = XKeysymToString(key); diff --git a/src/buffer.C b/src/buffer.C index c3e987b959..9f4d9ef317 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -488,7 +488,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par, font = LyXFont(LyXFont::ALL_INHERIT, params.language); if (file_format < 216 && params.language->lang() == "hebrew") font.setLanguage(default_language); - + #ifndef NO_COMPABILITY if (compare_no_case(layoutname, "latex") == 0) { ert_comp.active = true; @@ -1240,19 +1240,86 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par, // minipage. Currently I am not investing any effort // in fixing those cases. - //lyxerr << "Call depth: " << call_depth << endl; +// lyxerr << "Call depth: " << call_depth << endl; +// lyxerr << "Checkminipage: " << checkminipage << endl; + if (checkminipage && (call_depth == 1)) { - checkminipage = false; - if (minipar && (minipar != par) && - (par->params().pextraType() == Paragraph::PEXTRA_MINIPAGE)) - { - lyxerr << "minipages in a row" << endl; - if (par->params().pextraStartMinipage()) { - lyxerr << "start new minipage" << endl; - // minipages in a row - par->previous()->next(0); - par->previous(0); + checkminipage = false; + if (minipar && (minipar != par) && + (par->params().pextraType() == Paragraph::PEXTRA_MINIPAGE)) { + lyxerr << "minipages in a row" << endl; + if (par->params().pextraStartMinipage()) { + lyxerr << "start new minipage" << endl; + // minipages in a row + par->previous()->next(0); + par->previous(0); + + Paragraph * tmp = minipar; + while (tmp) { + tmp->params().pextraType(0); + tmp->params().pextraWidth(string()); + tmp->params().pextraWidthp(string()); + tmp->params().pextraAlignment(0); + tmp->params().pextraHfill(false); + tmp->params().pextraStartMinipage(false); + tmp = tmp->next(); + } + // create a new paragraph to insert the + // minipages in the following case + if (par->params().pextraStartMinipage() && + !par->params().pextraHfill()) { + Paragraph * p = new Paragraph; + p->layout(textclasslist[params.textclass].defaultLayoutName()); + + p->previous(parBeforeMinipage); + parBeforeMinipage->next(p); + p->next(0); + p->params().depth(parBeforeMinipage->params().depth()); + parBeforeMinipage = p; + } + InsetMinipage * mini = new InsetMinipage(params); + mini->pos(static_cast(par->params().pextraAlignment())); + mini->pageWidth(LyXLength(par->params().pextraWidth())); + if (!par->params().pextraWidthp().empty()) { + lyxerr << "WP:" << mini->pageWidth().asString() << endl; + mini->pageWidth(LyXLength((par->params().pextraWidthp())+"col%")); + } + Paragraph * op = mini->firstParagraph(); + mini->inset.paragraph(par); + // + // and free the old ones! + // + while(op) { + Paragraph * pp = op->next(); + delete op; + op = pp; + } + // Insert the minipage last in the + // previous paragraph. + if (par->params().pextraHfill()) { + parBeforeMinipage->insertChar + (parBeforeMinipage->size(), + Paragraph::META_HFILL, font); + } + parBeforeMinipage->insertInset + (parBeforeMinipage->size(), mini, font); + minipar = par; + } else { + lyxerr << "new minipage par" << endl; + //nothing to do just continue reading + } + + } else if (minipar && (minipar != par)) { + lyxerr << "last minipage par read" << endl; + // The last paragraph read was not part of a + // minipage but the par linked list is... + // So we need to remove the last par from the + // rest + if (par->previous()) + par->previous()->next(0); + par->previous(parBeforeMinipage); + parBeforeMinipage->next(par); Paragraph * tmp = minipar; while (tmp) { tmp->params().pextraType(0); @@ -1263,28 +1330,44 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par, tmp->params().pextraStartMinipage(false); tmp = tmp->next(); } - // create a new paragraph to insert the - // minipages in the following case - if (par->params().pextraStartMinipage() && - !par->params().pextraHfill()) { - Paragraph * p = new Paragraph; - p->layout(textclasslist[params.textclass].defaultLayoutName()); + depth = parBeforeMinipage->params().depth(); + // and set this depth on the par as it has not been set already + par->params().depth(depth); + minipar = parBeforeMinipage = 0; + } else if (!minipar && + (par->params().pextraType() == Paragraph::PEXTRA_MINIPAGE)) { + // par is the first paragraph in a minipage + lyxerr << "begin minipage" << endl; + // To minimize problems for + // the users we will insert + // the first minipage in + // a sequence of minipages + // in its own paragraph. + Paragraph * p = new Paragraph; + p->layout(textclasslist[params.textclass].defaultLayoutName()); + p->previous(par->previous()); + p->next(0); + p->params().depth(depth); + par->params().depth(0); + depth = 0; + if (par->previous()) + par->previous()->next(p); + par->previous(0); + parBeforeMinipage = p; + minipar = par; + if (!first_par || (first_par == par)) + first_par = p; - p->previous(parBeforeMinipage); - parBeforeMinipage->next(p); - p->next(0); - p->params().depth(parBeforeMinipage->params().depth()); - parBeforeMinipage = p; - } InsetMinipage * mini = new InsetMinipage(params); - mini->pos(static_cast(par->params().pextraAlignment())); - mini->pageWidth(LyXLength(par->params().pextraWidth())); + mini->pos(static_cast(minipar->params().pextraAlignment())); + mini->pageWidth(LyXLength(minipar->params().pextraWidth())); if (!par->params().pextraWidthp().empty()) { - lyxerr << "WP:" << mini->pageWidth().asString() << endl; - mini->pageWidth(LyXLength((par->params().pextraWidthp())+"col%")); + lyxerr << "WP:" << mini->pageWidth().asString() << endl; + mini->pageWidth(LyXLength((par->params().pextraWidthp())+"col%")); } + Paragraph * op = mini->firstParagraph(); - mini->inset.paragraph(par); + mini->inset.paragraph(minipar); // // and free the old ones! // @@ -1293,100 +1376,17 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par, delete op; op = pp; } + // Insert the minipage last in the // previous paragraph. - if (par->params().pextraHfill()) { + if (minipar->params().pextraHfill()) { parBeforeMinipage->insertChar (parBeforeMinipage->size(), Paragraph::META_HFILL, font); } parBeforeMinipage->insertInset (parBeforeMinipage->size(), mini, font); - - minipar = par; - } else { - lyxerr << "new minipage par" << endl; - //nothing to do just continue reading - } - - } else if (minipar && (minipar != par)) { - lyxerr << "last minipage par read" << endl; - // The last paragraph read was not part of a - // minipage but the par linked list is... - // So we need to remove the last par from the - // rest - if (par->previous()) - par->previous()->next(0); - par->previous(parBeforeMinipage); - parBeforeMinipage->next(par); - Paragraph * tmp = minipar; - while (tmp) { - tmp->params().pextraType(0); - tmp->params().pextraWidth(string()); - tmp->params().pextraWidthp(string()); - tmp->params().pextraAlignment(0); - tmp->params().pextraHfill(false); - tmp->params().pextraStartMinipage(false); - tmp = tmp->next(); - } - depth = parBeforeMinipage->params().depth(); - // and set this depth on the par as it has not been set already - par->params().depth(depth); - minipar = parBeforeMinipage = 0; - } else if (!minipar && - (par->params().pextraType() == Paragraph::PEXTRA_MINIPAGE)) - { - // par is the first paragraph in a minipage - lyxerr << "begin minipage" << endl; - // To minimize problems for - // the users we will insert - // the first minipage in - // a sequence of minipages - // in its own paragraph. - Paragraph * p = new Paragraph; - p->layout(textclasslist[params.textclass].defaultLayoutName()); - p->previous(par->previous()); - p->next(0); - p->params().depth(depth); - par->params().depth(0); - depth = 0; - if (par->previous()) - par->previous()->next(p); - par->previous(0); - parBeforeMinipage = p; - minipar = par; - if (!first_par || (first_par == par)) - first_par = p; - - InsetMinipage * mini = new InsetMinipage(params); - mini->pos(static_cast(minipar->params().pextraAlignment())); - mini->pageWidth(LyXLength(minipar->params().pextraWidth())); - if (!par->params().pextraWidthp().empty()) { - lyxerr << "WP:" << mini->pageWidth().asString() << endl; - mini->pageWidth(LyXLength((par->params().pextraWidthp())+"col%")); - } - - Paragraph * op = mini->firstParagraph(); - mini->inset.paragraph(minipar); - // - // and free the old ones! - // - while(op) { - Paragraph * pp = op->next(); - delete op; - op = pp; - } - - // Insert the minipage last in the - // previous paragraph. - if (minipar->params().pextraHfill()) { - parBeforeMinipage->insertChar - (parBeforeMinipage->size(), - Paragraph::META_HFILL, font); - } - parBeforeMinipage->insertInset - (parBeforeMinipage->size(), mini, font); - } + } } // End of pextra_minipage compability --call_depth; @@ -3712,7 +3712,7 @@ vector > const Buffer::getBibkeyList() const string const opt = par->bibkey->getOptions(); string const ref = par->asString(this, false); string const info = opt + "TheBibliographyRef" + ref; - + keys.push_back(StringPair(key, info)); } par = par->next(); diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 8d8acf7ef5..ce4929d3e2 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,10 +1,10 @@ 2002-04-30 Rob Lahaye * FormDocument.C: "USletter" -> "US letter" etc. - "Other" -> "Custom". + "Other" -> "Custom". * FormParagraph.C: "Other" -> "Custom" * FormPreferences.C: "USletter" -> "US letter" etc. * forms/form_document.fd: 'Papersize" -> "Paper size" - style consistency + style consistency * forms/form_preferences.fd: style consistency 2002-04-30 Angus Leeming @@ -34,7 +34,7 @@ * FormBibtex.C: * FormCitation.C: fix two typos - + 2002-04-29 Angus Leeming * FormCharacter.h: @@ -53,7 +53,7 @@ * FormMathsPanel.C: translate Close * FormGraphics.C: a little more translation - + 2002-04-22 Angus Leeming * FormCitation.C (apply, input): ensure that the choice is always valid. diff --git a/src/insets/insetfloat.C b/src/insets/insetfloat.C index 369efd9808..862647426a 100644 --- a/src/insets/insetfloat.C +++ b/src/insets/insetfloat.C @@ -109,7 +109,7 @@ string floatname(string const & type) return _(it->second.name()); } - + } // namespace anon diff --git a/src/insets/insetindex.C b/src/insets/insetindex.C index 7c220fb782..1e673e71ec 100644 --- a/src/insets/insetindex.C +++ b/src/insets/insetindex.C @@ -39,8 +39,9 @@ void InsetIndex::edit(BufferView * bv, bool) int InsetIndex::docbook(Buffer const *, ostream & os) const { - os << "" << getContents() << ""; - return 0; + os << "" << getContents() + << ""; + return 0; } @@ -54,6 +55,7 @@ InsetPrintIndex::InsetPrintIndex(InsetCommandParams const & p, bool) : InsetCommand(p) {} + string const InsetPrintIndex::getScreenLabel(Buffer const *) const { return _("Index"); diff --git a/src/insets/insetindex.h b/src/insets/insetindex.h index ec68765ac0..88c76bab6b 100644 --- a/src/insets/insetindex.h +++ b/src/insets/insetindex.h @@ -60,13 +60,15 @@ public: /// void edit(BufferView *, bool = true) {} /// - EDITABLE editable() const{ return NOT_EDITABLE; } + EDITABLE editable() const { return NOT_EDITABLE; } /// bool display() const { return true; } /// Inset::Code lyxCode() const; /// string const getScreenLabel(Buffer const *) const; + /// + virtual bool needFullRow() const { return true; } }; #endif diff --git a/src/insets/insettext.C b/src/insets/insettext.C index ba60be164b..c4062bdba8 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -463,20 +463,20 @@ void InsetText::draw(BufferView * bv, LyXFont const & f, int yf = y_offset + first; y = 0; while ((row != 0) && (yf < ph)) { - lt->getVisibleRow(bv, y+y_offset+first, int(x), row, - y+lt->first_y, cleared); + lt->getVisibleRow(bv, y + y_offset + first, int(x), + row, y + lt->first_y, cleared); if (bv->text->status() == LyXText::CHANGED_IN_DRAW) { lt->need_break_row = row; - if (lt->fullRebreak(bv)) { - lt->setCursor(bv, lt->cursor.par(),lt->cursor.pos()); - if (lt->selection.set()) { - lt->setCursor(bv, lt->selection.start, - lt->selection.start.par(), - lt->selection.start.pos()); - lt->setCursor(bv, lt->selection.end, - lt->selection.end.par(), - lt->selection.end.pos()); - } + lt->fullRebreak(bv); + lt->setCursor(bv, lt->cursor.par(), + lt->cursor.pos()); + if (lt->selection.set()) { + lt->setCursor(bv, lt->selection.start, + lt->selection.start.par(), + lt->selection.start.pos()); + lt->setCursor(bv, lt->selection.end, + lt->selection.end.par(), + lt->selection.end.pos()); } break; } diff --git a/src/lyxtext.h b/src/lyxtext.h index 62247add0a..da5e852beb 100644 --- a/src/lyxtext.h +++ b/src/lyxtext.h @@ -177,9 +177,8 @@ public: /// void insertInset(BufferView *, Inset * inset); - /** Completes the insertion with a full rebreak. - Returns true if something was broken. */ - bool fullRebreak(BufferView *); + /** Completes the insertion with a full rebreak. */ + void fullRebreak(BufferView *); /// mutable Row * need_break_row; diff --git a/src/screen.C b/src/screen.C index 83c19bc19a..9db572309e 100644 --- a/src/screen.C +++ b/src/screen.C @@ -130,10 +130,10 @@ void LyXScreen::drawFromTo(LyXText * text, BufferView * bv, x_offset, row, y + text->first_y); internal = internal && (st != LyXText::CHANGED_IN_DRAW); while (internal && text->status() == LyXText::CHANGED_IN_DRAW) { - if (text->fullRebreak(bv)) { - st = LyXText::NEED_MORE_REFRESH; - text->setCursor(bv, text->cursor.par(), text->cursor.pos()); - } + text->fullRebreak(bv); + st = LyXText::NEED_MORE_REFRESH; + text->setCursor(bv, text->cursor.par(), + text->cursor.pos()); text->status(bv, st); text->getVisibleRow(bv, y + y_offset, x_offset, row, y + text->first_y); diff --git a/src/support/ChangeLog b/src/support/ChangeLog index b04d48b26c..26c96af68e 100644 --- a/src/support/ChangeLog +++ b/src/support/ChangeLog @@ -1,3 +1,7 @@ +2002-05-02 Lars Gullik Bjønnes + + * lyxstring.C (operator>>): try a new version of the operator>> + 2002-04-14 Herbert Voss * lstrings.[Ch]: move the getVectorFromString and the vice versa @@ -11,7 +15,7 @@ 2002-04-08 Herbert Voss - * filetools.C (getExtFromContents): get tgif run + * filetools.C (getExtFromContents): get tgif run 2002-04-08 Angus Leeming diff --git a/src/support/filetools.C b/src/support/filetools.C index 9cae088161..98272b0e0e 100644 --- a/src/support/filetools.C +++ b/src/support/filetools.C @@ -1043,7 +1043,7 @@ string const getExtFromContents(string const & filename) break; } - std::getline(ifs, str); + getline(ifs, str); lyxerr[Debug::GRAPHICS] << "Scanstring: " << str << endl; string const stamp = str.substr(0,2); @@ -1103,7 +1103,7 @@ string const getExtFromContents(string const & filename) format = "xwd"; } } - + firstLine = false; } @@ -1362,7 +1362,7 @@ string const readBB_from_PSFile(string const & file) // end of the file. Than we have in the header: // %%BoundingBox: (atend) // In this case we must check the end. - string const file_ = zippedFile(file) ? + string const file_ = zippedFile(file) ? string(unzipFile(file)) : string(file); string const format = getExtFromContents(file_); if (format != "eps" && format != "ps") @@ -1371,10 +1371,9 @@ string const readBB_from_PSFile(string const & file) std::ifstream is(file_.c_str()); while (is) { string s; - std::getline(is,s); - if (contains(s,"%%BoundingBox:") && !contains(s,"atend")) + getline(is,s); + if (contains(s,"%%BoundingBox:") && !contains(s,"atend")) return (frontStrip(s.substr(14))); } return string(); } - diff --git a/src/support/lyxstring.C b/src/support/lyxstring.C index 621239d640..150b6f8162 100644 --- a/src/support/lyxstring.C +++ b/src/support/lyxstring.C @@ -1732,16 +1732,9 @@ void swap(lyxstring & str1, lyxstring & str2) #include +#if 0 istream & operator>>(istream & is, lyxstring & s) { -#if 0 - // very bad solution - char * nome = new char[1024]; - is >> nome; - lyxstring tmp(nome); - delete [] nome; - if (!tmp.empty()) s = tmp; -#else // better solution int w = is.width(0); s.clear(); @@ -1752,9 +1745,44 @@ istream & operator>>(istream & is, lyxstring & s) if (--w == 1) break; } if (s.empty()) is.setstate(std::ios::failbit); -#endif return is; } +#else +istream & operator>>(istream & is, lyxstring & str) +{ + typedef istream istream_type; + typedef int int_type; + typedef std::streambuf streambuf_type; + typedef string string_type; + typedef string::size_type size_type; + size_type extracted = 0; + +// istream_type::sentry cerb(is, false); +// if (cerb) { + str.erase(); + std::streamsize w = is.width(); + size_type n; + n = w > 0 ? static_cast(w) : str.max_size(); + + int_type const eof = EOF; + streambuf_type * sb = is.rdbuf(); + int_type c = sb->sgetc(); + + while (extracted < n + && c != eof && !isspace(c)) { + str += c; + ++extracted; + c = sb->snextc(); + } + if (c == eof) + is.setstate(std::ios::eofbit); + is.width(0); +// } + if (!extracted) + is.setstate(std::ios::failbit); + return is; +} +#endif ostream & operator<<(ostream & o, lyxstring const & s) diff --git a/src/text2.C b/src/text2.C index 7853e65505..71f861cc81 100644 --- a/src/text2.C +++ b/src/text2.C @@ -900,18 +900,17 @@ void LyXText::redoParagraphs(BufferView * bview, LyXCursor const & cur, } -bool LyXText::fullRebreak(BufferView * bview) +void LyXText::fullRebreak(BufferView * bview) { if (!firstrow) { init(bview); - return true; + return; } if (need_break_row) { breakAgain(bview, need_break_row); need_break_row = 0; - return true; + return; } - return true; } -- 2.39.2