]> git.lyx.org Git - lyx.git/blobdiff - src/insets/figinset.C
clear()->erase() ; lots of using directives for cxx
[lyx.git] / src / insets / figinset.C
index 38d57f3f784c21faade339959b048866ca39c2ff..e39691c7d8349d694a374407e8916a30360e3428 100644 (file)
@@ -611,27 +611,32 @@ void runqueue()
                                ::sleep(1);
                                XGrabServer(tempdisp);
                        }
+#ifdef HAVE_SSTREAM
                        XChangeProperty(tempdisp, 
                                        fl_get_canvas_id(figinset_canvas),
                                        XInternAtom(tempdisp, "GHOSTVIEW", false),
                                        XInternAtom(tempdisp, "STRING", false),
                                        8, PropModeAppend, 
-#ifdef HAVE_SSTREAM
                                        reinterpret_cast<unsigned char*>(const_cast<char*>(t1.str().c_str())),
-                                       t1.str().size()
+                                       t1.str().size());
 #else
+                       
+                       XChangeProperty(tempdisp, 
+                                       fl_get_canvas_id(figinset_canvas),
+                                       XInternAtom(tempdisp, "GHOSTVIEW", false),
+                                       XInternAtom(tempdisp, "STRING", false),
+                                       8, PropModeAppend, 
                                        reinterpret_cast<unsigned char*>(const_cast<char*>(t1.str())),
-                                       strlen(t1.str())
+                                       ::strlen(t1.str()));
 #endif
-                               );
                        XUngrabServer(tempdisp);
                        XFlush(tempdisp);
 
 #ifdef HAVE_SSTREAM
                        ostringstream t3;
 #else
-                       char tbuf3[384];
-                       ostrstream t3(tbuf3, sizeof(tbuf3));
+                       //char tbuf[384];
+                       ostrstream t3(tbuf, sizeof(tbuf));
 #endif
                        switch (p->data->flags & 3) {
                        case 0: t3 << 'H'; break; // Hidden
@@ -652,20 +657,25 @@ void runqueue()
 #endif
 
                        XGrabServer(tempdisp);
+#ifdef HAVE_SSTREAM
                        XChangeProperty(tempdisp, 
                                        fl_get_canvas_id(figinset_canvas),
                                        XInternAtom(tempdisp,
                                                    "GHOSTVIEW_COLORS", false),
                                        XInternAtom(tempdisp, "STRING", false),
                                        8, PropModeReplace, 
-#ifdef HAVE_SSTREAM
                                        reinterpret_cast<unsigned char*>(const_cast<char*>(t3.str().c_str())),
-                                       t3.str().size()
+                                       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<unsigned char*>(const_cast<char*>(t3.str())),
-                                       strlen(t3.str())
+                                       ::strlen(t3.str()));
 #endif
-                               );
                        XUngrabServer(tempdisp);
                        XFlush(tempdisp);
                        
@@ -765,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) {
@@ -963,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?
@@ -1052,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]");
                
@@ -1289,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)
@@ -1465,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;
@@ -1544,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)
@@ -1751,7 +1768,7 @@ void InsetFig::CallbackFig(long arg)
                        } else {
                                if (!fname.empty()) {
                                        changedfname = true;
-                                       fname.clear();
+                                       fname.erase();
                                }
                        }
                        subcaption = fl_get_input(form->Subcaption);
@@ -1768,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?
@@ -1785,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?