]> git.lyx.org Git - lyx.git/blobdiff - src/insets/figinset.C
reformatting and remove using delc
[lyx.git] / src / insets / figinset.C
index 2b8a109d49fbab980d514c3a14755576ec963082..d80165688c7c6cfe32821a65b88c70f0dac623b1 100644 (file)
@@ -45,7 +45,6 @@
 #include <cmath>
 
 #include "figinset.h"
-#include "lyx.h"
 #include "lyx_main.h"
 #include "buffer.h"
 #include "frontends/FileDialog.h"
 #include "converter.h"
 #include "frontends/Dialogs.h" // redrawGUI
 
-#ifdef SIGC_CXX_NAMESPACES
-using SigC::slot;
-#endif
-
 using std::ostream;
 using std::istream;
 using std::ofstream;
@@ -89,7 +84,13 @@ extern FL_OBJECT * figinset_canvas;
 
 extern char ** environ; // is this only redundtant on linux systems? Lgb.
 
-static float const DEG2PI = 57.295779513;
+// xforms doesn't define this (but it should be in <forms.h>).
+extern "C"
+FL_APPEVENT_CB fl_set_preemptive_callback(Window, FL_APPEVENT_CB, void *);
+
+namespace {
+
+float const DEG2PI = 57.295779513;
 
 struct queue_element {
        float rx, ry;          // resolution x and y
@@ -97,28 +98,27 @@ struct queue_element {
        figdata * data;        // we are doing it for this data
 };
 
-static int const MAXGS = 3;                    /* maximum 3 gs's at a time */
+int const MAXGS = 3;                   /* maximum 3 gs's at a time */
 
 typedef vector<Figref *> figures_type;
 typedef vector<figdata *> bitmaps_type;
-static figures_type figures; // all figures
-static bitmaps_type bitmaps; // all bitmaps
+figures_type figures; // all figures
+bitmaps_type bitmaps; // all bitmaps
 
-static queue<queue_element> gsqueue; // queue for ghostscripting
+queue<queue_element> gsqueue; // queue for ghostscripting
 
-static int gsrunning = 0;      /* currently so many gs's are running */
-static bool bitmap_waiting = false; /* bitmaps are waiting finished */
+int gsrunning = 0;     /* currently so many gs's are running */
+bool bitmap_waiting = false; /* bitmaps are waiting finished */
 
-static bool gs_color;                  // do we allocate colors for gs?
-static bool color_visual;              // is the visual color?
-static bool gs_xcolor = false;         // allocated extended colors
-static unsigned long gs_pixels[128];   // allocated pixels
-static int gs_spc;                     // shades per color
-static int gs_allcolors;               // number of all colors
+bool gs_color;                 // do we allocate colors for gs?
+bool color_visual;                     // is the visual color?
+bool gs_xcolor = false;                // allocated extended colors
+unsigned long gs_pixels[128];  // allocated pixels
+int gs_spc;                    // shades per color
+int gs_allcolors;              // number of all colors
 
-static list<int> pidwaitlist; // pid wait list
+list<int> pidwaitlist; // pid wait list
 
-static
 GC createGC()
 {
        XGCValues val;
@@ -134,11 +134,9 @@ GC createGC()
                         | GCLineWidth | GCLineStyle , &val);
 }
 
-static
 GC local_gc_copy;
 
 
-static
 void addpidwait(int pid)
 {
        // adds pid to pid wait list
@@ -153,14 +151,12 @@ void addpidwait(int pid)
 }
 
 
-static
 string make_tmp(int pid)
 {
        return system_tempdir + "/~lyxgs" + tostr(pid) + ".ps";
 }
 
 
-static
 void kill_gs(int pid, int sig)
 {
        if (lyxerr.debugging()) 
@@ -170,8 +166,7 @@ void kill_gs(int pid, int sig)
 }
 
 
-extern "C" {
-static
+extern "C"
 int GhostscriptMsg(XEvent * ev, void *)
 {
        // bin all events not of interest
@@ -306,10 +301,8 @@ int GhostscriptMsg(XEvent * ev, void *)
                }
        return FL_PREEMPT;
 }
-}
 
 
-static
 void AllocColors(int num)
 // allocate color cube numxnumxnum, if possible
 {
@@ -350,7 +343,6 @@ void AllocColors(int num)
 
 
 // allocate grayscale ramp
-static
 void AllocGrays(int num)
 {
        if (lyxerr.debugging()) {
@@ -385,11 +377,6 @@ void AllocGrays(int num)
        gs_color = true;
 }
 
-
-// xforms doesn't define this
-extern "C" FL_APPEVENT_CB fl_set_preemptive_callback(Window, FL_APPEVENT_CB, void *);
-
-static
 void InitFigures()
 {
        // if bitmaps and figures are not empty we will leak mem
@@ -434,7 +421,6 @@ void InitFigures()
 }
 
 
-static
 void DoneFigures()
 {
        // if bitmaps and figures are not empty we will leak mem
@@ -445,7 +431,6 @@ void DoneFigures()
 }
 
 
-static
 void freefigdata(figdata * tmpdata)
 {
        tmpdata->ref--;
@@ -464,7 +449,6 @@ void freefigdata(figdata * tmpdata)
 }
 
 
-static
 void runqueue()
 {
        // This _have_ to be set before the fork!
@@ -697,7 +681,6 @@ void runqueue()
 }
 
 
-static
 void addwait(int psx, int psy, int pswid, int pshgh, figdata * data)
 {
        // recompute the stuff and put in the queue
@@ -716,7 +699,6 @@ void addwait(int psx, int psy, int pswid, int pshgh, figdata * data)
 }
 
 
-static
 figdata * getfigdata(int wid, int hgh, string const & fname, 
                     int psx, int psy, int pswid, int pshgh, 
                     int raw_wid, int raw_hgh, float angle, char flags)
@@ -776,14 +758,12 @@ figdata * getfigdata(int wid, int hgh, string const & fname,
 }
 
 
-static
 void getbitmap(figdata * p)
 {
        p->gspid = -1;
 }
 
 
-static
 void makeupdatelist(figdata * p)
 {
        for (figures_type::iterator it = figures.begin();
@@ -799,6 +779,8 @@ void makeupdatelist(figdata * p)
                }
 }
 
+} // namespace anon
+
 
 // this func is only "called" in spellchecker.C
 void sigchldchecker(pid_t pid, int * status)
@@ -880,7 +862,8 @@ void sigchldchecker(pid_t pid, int * status)
 }
 
 
-static
+namespace {
+
 void getbitmaps()
 {
        bitmap_waiting = false;
@@ -891,7 +874,6 @@ void getbitmaps()
 }
 
 
-static
 void RegisterFigure(InsetFig * fi)
 {
        if (figures.empty()) InitFigures();
@@ -909,7 +891,6 @@ void RegisterFigure(InsetFig * fi)
 }
 
 
-static
 void UnregisterFigure(InsetFig * fi)
 {
        if (!lyxrc.use_gui)
@@ -938,6 +919,8 @@ void UnregisterFigure(InsetFig * fi)
        if (figures.empty()) DoneFigures();
 }
 
+} // namespace anon
+
 
 InsetFig::InsetFig(int tmpx, int tmpy, Buffer const & o)
        : owner(&o)
@@ -955,7 +938,7 @@ InsetFig::InsetFig(int tmpx, int tmpy, Buffer const & o)
        raw_wid = raw_hgh = 0;
        changedfname = false;
        RegisterFigure(this);
-       r_ = Dialogs::redrawGUI.connect(slot(this, &InsetFig::redraw));
+       r_ = Dialogs::redrawGUI.connect(SigC::slot(this, &InsetFig::redraw));
 }
 
 
@@ -1271,12 +1254,15 @@ Inset * InsetFig::Clone(Buffer const & buffer) const
        tmp->pswid = pswid;
        tmp->pshgh = pshgh;
        tmp->fname = fname;
-       if (!fname.empty() && IsFileReadable(fname) 
+       string lfname = fname;
+       if (!fname.empty() && GetExtension(fname).empty())
+               lfname += ".eps";
+       if (!fname.empty() && IsFileReadable(lfname) 
            && (flags & 3) && !lyxrc.ps_command.empty()
            && lyxrc.use_gui) { 
                // do not display if there is
                // "do not display" chosen (Matthias 260696)
-               tmp->figure->data = getfigdata(wid, hgh, fname, psx, psy,
+               tmp->figure->data = getfigdata(wid, hgh, lfname, psx, psy,
                                               pswid, pshgh, raw_wid, raw_hgh,
                                               angle, flags & (3|8));
        } else tmp->figure->data = 0;
@@ -1294,8 +1280,9 @@ Inset::Code InsetFig::LyxCode() const
 }
 
 
-static
-string stringify(InsetFig::HWTYPE hw, float f, string suffix)
+namespace {
+
+string const stringify(InsetFig::HWTYPE hw, float f, string suffix)
 {
        string res;
        switch (hw) {
@@ -1318,6 +1305,8 @@ string stringify(InsetFig::HWTYPE hw, float f, string suffix)
        return res;
 }
 
+} // namespace anon
+
 
 void InsetFig::Regenerate() const
 {
@@ -1566,7 +1555,10 @@ void InsetFig::GetPSSizes()
 
        if (fname.empty()) return;
        string p;
-       ifstream ifs(fname.c_str());
+       string lfname = fname;
+       if (GetExtension(fname).empty())
+               lfname += ".eps";
+       ifstream ifs(lfname.c_str());
 
        if (!ifs) return;       // file not found !!!!