X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2Ffiginset.C;h=e39691c7d8349d694a374407e8916a30360e3428;hb=3c8aba3b556871fb1100a2f98cd93d5d4e3f70c9;hp=d40996c3e3a9063593585facbc70e609fffaf001;hpb=c6150425e56563ab9bb311b5785efc5e9d4928da;p=lyx.git diff --git a/src/insets/figinset.C b/src/insets/figinset.C index d40996c3e3..e39691c7d8 100644 --- a/src/insets/figinset.C +++ b/src/insets/figinset.C @@ -72,7 +72,9 @@ using std::vector; using std::find; using std::flush; using std::endl; +#ifdef HAVE_SSTREAM using std::ostringstream; +#endif extern BufferView * current_view; extern FL_OBJECT * figinset_canvas; @@ -540,12 +542,12 @@ void runqueue() ostringstream t2; #else char tbuf2[80]; - ostrstream t2(tbuf2, sizeof(tbuf)); + ostrstream t2(tbuf2, sizeof(tbuf2)); #endif t2 << "GHOSTVIEW=" << fl_get_canvas_id(figinset_canvas) << ' ' << p->data->bitmap; #ifndef HAVE_SSTREAM - << '\0'; + t2 << '\0'; #endif // now set up ghostview property on a window // #warning BUG seems that the only bug here @@ -559,7 +561,7 @@ void runqueue() t1 << "0 0 0 0 " << p->data->wid << ' ' << p->data->hgh << " 72 72 0 0 0 0"; #ifndef HAVE_SSTREAM - << '\0'; + t1 << '\0'; #endif if (lyxerr.debugging()) { @@ -609,6 +611,7 @@ void runqueue() ::sleep(1); XGrabServer(tempdisp); } +#ifdef HAVE_SSTREAM XChangeProperty(tempdisp, fl_get_canvas_id(figinset_canvas), XInternAtom(tempdisp, "GHOSTVIEW", false), @@ -616,13 +619,23 @@ void runqueue() 8, PropModeAppend, reinterpret_cast(const_cast(t1.str().c_str())), t1.str().size()); +#else + + XChangeProperty(tempdisp, + fl_get_canvas_id(figinset_canvas), + XInternAtom(tempdisp, "GHOSTVIEW", false), + XInternAtom(tempdisp, "STRING", false), + 8, PropModeAppend, + reinterpret_cast(const_cast(t1.str())), + ::strlen(t1.str())); +#endif XUngrabServer(tempdisp); XFlush(tempdisp); #ifdef HAVE_SSTREAM ostringstream t3; #else - char tbuf[384]; + //char tbuf[384]; ostrstream t3(tbuf, sizeof(tbuf)); #endif switch (p->data->flags & 3) { @@ -640,10 +653,11 @@ void runqueue() t3 << ' ' << BlackPixelOfScreen(DefaultScreenOfDisplay(tempdisp)) << ' ' << background_pixel; #ifndef HAVE_SSTREAM - << '\0'; + t3 << '\0'; #endif XGrabServer(tempdisp); +#ifdef HAVE_SSTREAM XChangeProperty(tempdisp, fl_get_canvas_id(figinset_canvas), XInternAtom(tempdisp, @@ -652,6 +666,16 @@ void runqueue() 8, PropModeReplace, reinterpret_cast(const_cast(t3.str().c_str())), t3.str().size()); +#else + XChangeProperty(tempdisp, + fl_get_canvas_id(figinset_canvas), + XInternAtom(tempdisp, + "GHOSTVIEW_COLORS", false), + XInternAtom(tempdisp, "STRING", false), + 8, PropModeReplace, + reinterpret_cast(const_cast(t3.str())), + ::strlen(t3.str())); +#endif XUngrabServer(tempdisp); XFlush(tempdisp); @@ -751,7 +775,8 @@ figdata * getfigdata(int wid, int hgh, string const & fname, { /* first search for an exact match with fname and width/height */ - if (fname.empty()) return 0; + if (fname.empty() || !IsFileReadable(fname)) + return 0; for (bitmaps_type::iterator it = bitmaps.begin(); it != bitmaps.end(); ++it) { @@ -949,7 +974,7 @@ void UnregisterFigure(InsetFig * fi) fl_hide_form(tmpfig->inset->form->Figure); } #if FL_REVISION == 89 -#warning Reactivate this free_form calls + // CHECK Reactivate this free_form calls #else fl_free_form(tmpfig->inset->form->Figure); free(tmpfig->inset->form); // Why free? @@ -1038,10 +1063,15 @@ void InsetFig::draw(Painter & pain, LyXFont const & f, if (figure && figure->data) { if (figure->data->broken) msg = _("[render error]"); else if (figure->data->reading) msg = _("[rendering ... ]"); - } else - if (fname.empty()) msg = _("[no file]"); - else if ((flags & 3) == 0) msg = _("[not displayed]"); - else if (lyxrc.ps_command.empty()) msg = _("[no ghostscript]"); + } + else if (fname.empty()) + msg = _("[no file]"); + else if (!IsFileReadable(fname)) + msg = _("[bad file name]"); + else if ((flags & 3) == 0) + msg = _("[not displayed]"); + else if (lyxrc.ps_command.empty()) + msg = _("[no ghostscript]"); if (!msg) msg = _("[unknown error]"); @@ -1275,7 +1305,8 @@ Inset * InsetFig::Clone() const tmp->pswid = pswid; tmp->pshgh = pshgh; tmp->fname = fname; - if (!fname.empty() && (flags & 3) && !lyxrc.ps_command.empty() + if (!fname.empty() && IsFileReadable(fname) + && (flags & 3) && !lyxrc.ps_command.empty() && lyxrc.use_gui) { // do not display if there is // "do not display" chosen (Matthias 260696) @@ -1451,7 +1482,7 @@ void InsetFig::Recompute() /* now recompute wid and hgh, and if that is changed, set changed */ /* this depends on chosen size of the picture and its bbox */ // This will be redone in 0.13 ... (hen) - if (!fname.empty()) { + if (!fname.empty() && IsFileReadable(fname)) { // say, total width is 595 pts, as A4 in TeX, thats in 1/72" */ newx = frame_wid; @@ -1530,7 +1561,7 @@ void InsetFig::Recompute() figdata * pf = figure->data; // get new data - if (!fname.empty() && (flags & 3) + if (!fname.empty() && IsFileReadable(fname) && (flags & 3) && !lyxrc.ps_command.empty()) { // do not display if there is "do not display" // chosen (Matthias 260696) @@ -1737,7 +1768,7 @@ void InsetFig::CallbackFig(long arg) } else { if (!fname.empty()) { changedfname = true; - fname.clear(); + fname.erase(); } } subcaption = fl_get_input(form->Subcaption); @@ -1754,7 +1785,7 @@ void InsetFig::CallbackFig(long arg) fl_set_focus_object(form->Figure, form->OkBtn); fl_hide_form(form->Figure); #if FL_REVISION == 89 -#warning Reactivate this free_form calls + // CHECK Reactivate this free_form calls #else fl_free_form(form->Figure); free(form); // Why free? @@ -1771,8 +1802,8 @@ void InsetFig::CallbackFig(long arg) fl_set_focus_object(form->Figure, form->OkBtn); fl_hide_form(form->Figure); #if FL_REVISION == 89 -#warning Reactivate this free_form calls -#warning Jug, is this still a problem? + // CHECK Reactivate this free_form calls + // Jug, is this still a problem? #else fl_free_form(form->Figure); free(form); // Why free?