This should be my last major patch for the gui. I always miss some
more discussion from the others about the sense of all these options.
Or of still missing ones.
This patch does
apply button, scale for LyXView, finishing handle of zipped files,
other small changes and fixes


now you should be able to:
- insert any graphic filetype which can be handled by convert
   or a userdefined converter
- use zipped graphic files (gnuzip, zip, compress) which are still
   only tested with my own files.
- filetype is detected from it's contents. Extension is no more
   important.
- latex handled zipped eps-files with additional bounding box
- draft and clip option.
- rotating with specific origin.
- user defined latex options

Herbert


-- 
http://www.lyx.org/help/
Index: src/frontends/xforms/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/ChangeLog,v
retrieving revision 1.274
diff -u -r1.274 ChangeLog
--- src/frontends/xforms/ChangeLog      2002/02/04 17:14:25     1.274
+++ src/frontends/xforms/ChangeLog      2002/02/04 17:46:16
@@ -1,3 +1,10 @@
+2002-02-04  Herbert Voss  <[EMAIL PROTECTED]>
+
+       * forms/form_graphics.fd: small changes to the layout
+       * FormGraphic.C: Apply-button, keepaspectratio enabling
+       depends to case of LaTeXView. Other small changes and
+       fixes. Add LyXView scale.
+
 2002-02-01  Angus Leeming  <[EMAIL PROTECTED]>
 
        * FormGraphics.C (c-tor): prevent resizing of the dialog.
Index: src/frontends/xforms/FormGraphics.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/FormGraphics.C,v
retrieving revision 1.43
diff -u -r1.43 FormGraphics.C
--- src/frontends/xforms/FormGraphics.C 2002/02/04 17:14:25     1.43
+++ src/frontends/xforms/FormGraphics.C 2002/02/04 17:46:17
@@ -71,9 +71,10 @@
 
         // Manage the ok, apply, restore and cancel/close buttons
        bc().setOK(dialog_->button_ok);
+       bc().setApply(dialog_->button_apply);
        bc().setCancel(dialog_->button_cancel);
        bc().setRestore(dialog_->button_restore);
-       bc().setRestore(dialog_->button_help);
+       bc().addReadOnly(dialog_->button_help);
 
        // the file section
        file_.reset(build_file());
@@ -182,8 +183,8 @@
            igp.rotateOrigin = fl_get_choice_text(file_->choice_origin);
        else
            igp.rotateOrigin = string();
-       igp.scale = strToInt(getStringFromInput(size_->input_scale));
-       igp.keepAspectRatio = fl_get_button(size_->check_aspectratio);
+       igp.draft = fl_get_button(file_->button_draft);
+       igp.clip = fl_get_button(file_->button_clip);
 
        // the lyxview section
        switch (fl_get_choice(lyxview_->choice_display)) {
@@ -203,14 +204,19 @@
                igp.display = InsetGraphicsParams::NONE;                
                break;
        }
+       if (fl_get_button(lyxview_->button_lyxdefault))
+           igp.lyxsize_type = InsetGraphicsParams::DEFAULT_SIZE;
+       else if (fl_get_button(lyxview_->button_lyxwh))
+           igp.lyxsize_type = InsetGraphicsParams::WH;
+       else
+           igp.lyxsize_type = InsetGraphicsParams::SCALE;
        igp.lyxwidth = LyXLength(getLengthFromWidgets(lyxview_->input_lyxwidth,
                lyxview_->choice_width_lyxwidth));
        igp.lyxheight = LyXLength(getLengthFromWidgets(lyxview_->input_lyxheight,
                lyxview_->choice_width_lyxheight));
+       igp.lyxscale = strToInt(getStringFromInput(lyxview_->input_lyxscale));
 
        // the size section
-       igp.draft = fl_get_button(file_->button_draft);
-       igp.clip = fl_get_button(file_->button_clip);
        if (fl_get_button(size_->button_default))
            igp.size_type = InsetGraphicsParams::DEFAULT_SIZE;
        else if (fl_get_button(size_->button_wh))
@@ -221,6 +227,8 @@
                size_->choice_width_units));
        igp.height = LyXLength(getLengthFromWidgets(size_->input_height,
                size_->choice_height_units));
+       igp.scale = strToInt(getStringFromInput(size_->input_scale));
+       igp.keepAspectRatio = fl_get_button(size_->check_aspectratio);
 
        // the bb section
        if (!controller().bbChanged)            // different to the original one?
@@ -300,6 +308,36 @@
                lyxview_->choice_width_lyxwidth, igp.lyxwidth,defaultUnit);
        updateWidgetsFromLength(lyxview_->input_lyxheight,
                lyxview_->choice_width_lyxheight, igp.lyxheight,defaultUnit);
+       fl_set_input(lyxview_->input_lyxscale, tostr(igp.lyxscale).c_str());
+       switch (igp.lyxsize_type) {
+           case InsetGraphicsParams::DEFAULT_SIZE: {
+               fl_set_button(lyxview_->button_lyxdefault,1);
+               setEnabled(lyxview_->input_lyxwidth, 0);
+               setEnabled(lyxview_->choice_width_lyxwidth, 0);
+               setEnabled(lyxview_->input_lyxheight, 0);
+               setEnabled(lyxview_->choice_width_lyxheight, 0);
+               setEnabled(lyxview_->input_lyxscale, 0);
+               break;
+           }
+           case InsetGraphicsParams::WH: {
+               fl_set_button(lyxview_->button_lyxwh, 1);
+               setEnabled(lyxview_->input_lyxwidth, 1);
+               setEnabled(lyxview_->choice_width_lyxwidth, 1);
+               setEnabled(lyxview_->input_lyxheight, 1);
+               setEnabled(lyxview_->choice_width_lyxheight, 1);
+               setEnabled(lyxview_->input_lyxscale, 0);
+               break;
+           }
+           case InsetGraphicsParams::SCALE: {
+               fl_set_button(lyxview_->button_lyxscale, 1);
+               setEnabled(lyxview_->input_lyxwidth, 0);
+               setEnabled(lyxview_->choice_width_lyxwidth, 0);
+               setEnabled(lyxview_->input_lyxheight, 0);
+               setEnabled(lyxview_->choice_width_lyxheight, 0);
+               setEnabled(lyxview_->input_lyxscale, 1);
+               break;
+           }
+       }
 
        // the size section
        // Update the draft and clip mode
@@ -315,6 +353,7 @@
                setEnabled(size_->choice_width_units, 0);
                setEnabled(size_->input_height, 0);
                setEnabled(size_->choice_height_units, 0);
+               setEnabled(size_->check_aspectratio, 0);
                setEnabled(size_->input_scale, 0);
                break;
            }
@@ -324,6 +363,7 @@
                setEnabled(size_->choice_width_units, 1);
                setEnabled(size_->input_height, 1);
                setEnabled(size_->choice_height_units, 1);
+               setEnabled(size_->check_aspectratio, 1);
                setEnabled(size_->input_scale, 0);
                break;
            }
@@ -333,6 +373,7 @@
                setEnabled(size_->choice_width_units, 0);
                setEnabled(size_->input_height, 0);
                setEnabled(size_->choice_height_units, 0);
+               setEnabled(size_->check_aspectratio, 0);
                setEnabled(size_->input_scale, 1);
                break;
            }
@@ -392,6 +433,7 @@
        
 ButtonPolicy::SMInput FormGraphics::input(FL_OBJECT * ob, long)
 {
+       // the file section
        if (ob == file_->button_browse) {
                // Get the filename from the dialog
                string const in_name = getStringFromInput(file_->input_filename);
@@ -399,47 +441,74 @@
                if (out_name != in_name && !out_name.empty()) {
                        fl_set_input(file_->input_filename, out_name.c_str());
                }
+       } else if (ob == file_->check_subcaption) {
+               setEnabled(file_->input_subcaption,
+                          fl_get_button(file_->check_subcaption));
+
+       // the lyxview section
+       } else if (ob == lyxview_->button_lyxdefault) {
+               setEnabled(lyxview_->input_lyxwidth, 0);
+               setEnabled(lyxview_->choice_width_lyxwidth, 0);
+               setEnabled(lyxview_->input_lyxheight, 0);
+               setEnabled(lyxview_->choice_width_lyxheight, 0);
+               setEnabled(lyxview_->input_lyxscale, 0);
+       } else if (ob == lyxview_->button_lyxwh) {
+               setEnabled(lyxview_->input_lyxwidth, 1);
+               setEnabled(lyxview_->choice_width_lyxwidth, 1);
+               setEnabled(lyxview_->input_lyxheight, 1);
+               setEnabled(lyxview_->choice_width_lyxheight, 1);
+               setEnabled(lyxview_->input_lyxscale, 0);
+       } else if (ob == lyxview_->button_lyxscale) {
+               setEnabled(lyxview_->input_lyxwidth, 0);
+               setEnabled(lyxview_->choice_width_lyxwidth, 0);
+               setEnabled(lyxview_->input_lyxheight, 0);
+               setEnabled(lyxview_->choice_width_lyxheight, 0);
+               setEnabled(lyxview_->input_lyxscale, 1);
+
+       // the bb section
        } else if (!controller().bbChanged && 
                    ((ob == bbox_->input_bb_x0) || (ob == bbox_->input_bb_y0) ||
                    (ob == bbox_->input_bb_x1) || (ob == bbox_->input_bb_y1) ||
                    (ob == bbox_->choice_bb_x0) || (ob == bbox_->choice_bb_y0) ||
                    (ob == bbox_->choice_bb_x1) || (ob == bbox_->choice_bb_y1))) {
            controller().bbChanged = true; 
+       } else if (ob == bbox_->button_getBB) {
+           string const filename = getStringFromInput(file_->input_filename);
+           if (!filename.empty()) {
+               string const fileWithAbsPath = MakeAbsPath(filename, 
+OnlyPath(filename));       
+               string bb = controller().readBB(fileWithAbsPath);
+               lyxerr << "getBB::BoundingBox = " << bb << "\n";
+               if (!bb.empty()) {              
+                   fl_set_input(bbox_->input_bb_x0, token(bb,' ',0).c_str());
+                   fl_set_input(bbox_->input_bb_y0, token(bb,' ',1).c_str());
+                   fl_set_input(bbox_->input_bb_x1, token(bb,' ',2).c_str());
+                   fl_set_input(bbox_->input_bb_y1, token(bb,' ',3).c_str());
+               }
+               controller().bbChanged = false;
+           }
+
+       // the size section
        } else if (ob == size_->button_default) {
                setEnabled(size_->input_width, 0);
                setEnabled(size_->choice_width_units, 0);
                setEnabled(size_->input_height, 0);
                setEnabled(size_->choice_height_units, 0);
+               setEnabled(size_->check_aspectratio, 0);
                setEnabled(size_->input_scale, 0);
        } else if (ob == size_->button_wh) {
                setEnabled(size_->input_width, 1);
                setEnabled(size_->choice_width_units, 1);
                setEnabled(size_->input_height, 1);
                setEnabled(size_->choice_height_units, 1);
+               setEnabled(size_->check_aspectratio, 1);
                setEnabled(size_->input_scale, 0);
        } else if (ob == size_->button_scale) {
                setEnabled(size_->input_width, 0);
                setEnabled(size_->choice_width_units, 0);
                setEnabled(size_->input_height, 0);
                setEnabled(size_->choice_height_units, 0);
+               setEnabled(size_->check_aspectratio, 0);
                setEnabled(size_->input_scale, 1);
-       } else if (ob == file_->check_subcaption) {
-               setEnabled(file_->input_subcaption,
-                          fl_get_button(file_->check_subcaption));
-       } else if (ob == bbox_->button_getBB) {
-           string const filename = getStringFromInput(file_->input_filename);
-           if (!filename.empty()) {
-               string const fileWithAbsPath = MakeAbsPath(filename, 
OnlyPath(filename));       
-               string bb = controller().readBB(fileWithAbsPath);
-               lyxerr << "getBB::BoundingBox = " << bb << "\n";
-               if (!bb.empty()) {              
-                   fl_set_input(bbox_->input_bb_x0, token(bb,' ',0).c_str());
-                   fl_set_input(bbox_->input_bb_y0, token(bb,' ',1).c_str());
-                   fl_set_input(bbox_->input_bb_x1, token(bb,' ',2).c_str());
-                   fl_set_input(bbox_->input_bb_y1, token(bb,' ',3).c_str());
-               }
-               controller().bbChanged = false;
-           }
        } else if (ob == dialog_->button_help) {
            controller().help();
        }
Index: src/frontends/xforms/form_graphics.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/form_graphics.C,v
retrieving revision 1.28
diff -u -r1.28 form_graphics.C
--- src/frontends/xforms/form_graphics.C        2002/02/04 15:36:44     1.28
+++ src/frontends/xforms/form_graphics.C        2002/02/04 17:46:17
@@ -31,33 +31,38 @@
     fl_set_object_resize(obj, FL_RESIZE_ALL);
   {
     char const * const dummy = N_("Help|#H");
-    fdui->button_help = obj = fl_add_button(FL_NORMAL_BUTTON, 15, 320, 90, 30, 
idex(_(dummy)));
+    fdui->button_help = obj = fl_add_button(FL_NORMAL_BUTTON, 435, 320, 65, 30, 
+idex(_(dummy)));
     fl_set_button_shortcut(obj, scex(_(dummy)), 1);
   }
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_callback(obj, C_FormBaseInputCB, 0);
   {
     char const * const dummy = N_("Restore|#R");
-    fdui->button_restore = obj = fl_add_button(FL_NORMAL_BUTTON, 165, 320, 90, 30, 
idex(_(dummy)));
+    fdui->button_restore = obj = fl_add_button(FL_NORMAL_BUTTON, 205, 320, 80, 30, 
+idex(_(dummy)));
     fl_set_button_shortcut(obj, scex(_(dummy)), 1);
   }
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_gravity(obj, FL_SouthWest, FL_SouthWest);
     fl_set_object_callback(obj, C_FormBaseRestoreCB, 0);
-  fdui->button_ok = obj = fl_add_button(FL_RETURN_BUTTON, 315, 320, 90, 30, _("Ok"));
+  fdui->button_ok = obj = fl_add_button(FL_RETURN_BUTTON, 10, 320, 75, 30, _("Ok"));
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_callback(obj, C_FormBaseOKCB, 0);
   {
     char const * const dummy = N_("Cancel|^[");
-    fdui->button_cancel = obj = fl_add_button(FL_NORMAL_BUTTON, 410, 320, 90, 30, 
idex(_(dummy)));
+    fdui->button_cancel = obj = fl_add_button(FL_NORMAL_BUTTON, 325, 320, 75, 30, 
+idex(_(dummy)));
     fl_set_button_shortcut(obj, scex(_(dummy)), 1);
   }
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_callback(obj, C_FormBaseCancelCB, 0);
-  fdui->text_warning = obj = fl_add_text(FL_NORMAL_TEXT, 10, 280, 485, 35, "");
+  {
+    char const * const dummy = N_("Apply|#A");
+    fdui->button_apply = obj = fl_add_button(FL_RETURN_BUTTON, 95, 320, 75, 30, 
+idex(_(dummy)));
+    fl_set_button_shortcut(obj, scex(_(dummy)), 1);
+  }
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+    fl_set_object_callback(obj, C_FormBaseApplyCB, 0);
+  fdui->text_warning = obj = fl_add_text(FL_NORMAL_TEXT, 15, 275, 485, 35, "");
     fl_set_object_lalign(obj, FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
-    fl_set_object_lstyle(obj, FL_BOLD_STYLE);
   fl_end_form();
 
   fdui->form->fdui = fdui;
@@ -124,7 +129,7 @@
   }
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_callback(obj, C_FormBaseInputCB, 0);
-  obj = fl_add_text(FL_NORMAL_TEXT, 175, 130, 66, 30, _("degrees"));
+  obj = fl_add_text(FL_NORMAL_TEXT, 180, 130, 66, 30, _("degrees"));
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_lalign(obj, FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
   {
@@ -436,12 +441,20 @@
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_callback(obj, C_FormBaseInputCB, 0);
  fl_bgn_group();
-  obj = fl_add_round3dbutton(FL_RADIO_BUTTON, 205, 20, 30, 30, "Default|#D");
+  {
+    char const * const dummy = N_("Default|#D");
+    fdui->button_lyxdefault = obj = fl_add_round3dbutton(FL_RADIO_BUTTON, 205, 20, 
+30, 30, idex(_(dummy)));
+    fl_set_button_shortcut(obj, scex(_(dummy)), 1);
+  }
     fl_set_object_color(obj, FL_COL1, FL_YELLOW);
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_lalign(obj, FL_ALIGN_LEFT);
     fl_set_object_callback(obj, C_FormBaseInputCB, 0);
-  obj = fl_add_round3dbutton(FL_RADIO_BUTTON, 205, 70, 30, 30, "Custom|#C");
+  {
+    char const * const dummy = N_("Custom|#C");
+    fdui->button_lyxwh = obj = fl_add_round3dbutton(FL_RADIO_BUTTON, 205, 70, 30, 30, 
+idex(_(dummy)));
+    fl_set_button_shortcut(obj, scex(_(dummy)), 1);
+  }
     fl_set_object_color(obj, FL_COL1, FL_YELLOW);
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_lalign(obj, FL_ALIGN_LEFT);
Index: src/frontends/xforms/form_graphics.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/form_graphics.h,v
retrieving revision 1.14
diff -u -r1.14 form_graphics.h
--- src/frontends/xforms/form_graphics.h        2002/02/04 15:36:44     1.14
+++ src/frontends/xforms/form_graphics.h        2002/02/04 17:46:17
@@ -9,6 +9,7 @@
 extern  "C" void C_FormBaseRestoreCB(FL_OBJECT *, long);
 extern  "C" void C_FormBaseOKCB(FL_OBJECT *, long);
 extern  "C" void C_FormBaseCancelCB(FL_OBJECT *, long);
+extern  "C" void C_FormBaseApplyCB(FL_OBJECT *, long);
 
 extern  "C" void C_FormBaseInputCB(FL_OBJECT *, long);
 
@@ -31,6 +32,7 @@
        FL_OBJECT *button_restore;
        FL_OBJECT *button_ok;
        FL_OBJECT *button_cancel;
+       FL_OBJECT *button_apply;
        FL_OBJECT *text_warning;
 };
 struct FD_form_file {
@@ -91,6 +93,8 @@
        FL_OBJECT *input_lyxheight;
        FL_OBJECT *choice_width_lyxheight;
        FL_OBJECT *input_lyxscale;
+       FL_OBJECT *button_lyxdefault;
+       FL_OBJECT *button_lyxwh;
        FL_OBJECT *button_lyxscale;
 };
 
Index: src/frontends/xforms/forms/form_graphics.fd
===================================================================
RCS file: 
/usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/forms/form_graphics.fd,v
retrieving revision 1.20
diff -u -r1.20 form_graphics.fd
--- src/frontends/xforms/forms/form_graphics.fd 2002/02/04 15:36:45     1.20
+++ src/frontends/xforms/forms/form_graphics.fd 2002/02/04 17:46:17
@@ -11,7 +11,7 @@
 Name: form_graphics
 Width: 510
 Height: 360
-Number of Objects: 7
+Number of Objects: 8
 
 --------------------
 class: FL_BOX
@@ -52,7 +52,7 @@
 --------------------
 class: FL_BUTTON
 type: NORMAL_BUTTON
-box: 15 320 90 30
+box: 435 320 65 30
 boxtype: FL_UP_BOX
 colors: FL_COL1 FL_COL1
 alignment: FL_ALIGN_CENTER
@@ -70,7 +70,7 @@
 --------------------
 class: FL_BUTTON
 type: NORMAL_BUTTON
-box: 165 320 90 30
+box: 205 320 80 30
 boxtype: FL_UP_BOX
 colors: FL_COL1 FL_COL1
 alignment: FL_ALIGN_CENTER
@@ -88,7 +88,7 @@
 --------------------
 class: FL_BUTTON
 type: RETURN_BUTTON
-box: 315 320 90 30
+box: 10 320 75 30
 boxtype: FL_UP_BOX
 colors: FL_COL1 FL_COL1
 alignment: FL_ALIGN_CENTER
@@ -106,7 +106,7 @@
 --------------------
 class: FL_BUTTON
 type: NORMAL_BUTTON
-box: 410 320 90 30
+box: 325 320 75 30
 boxtype: FL_UP_BOX
 colors: FL_COL1 FL_COL1
 alignment: FL_ALIGN_CENTER
@@ -122,14 +122,32 @@
 argument: 0
 
 --------------------
+class: FL_BUTTON
+type: RETURN_BUTTON
+box: 95 320 75 30
+boxtype: FL_UP_BOX
+colors: FL_COL1 FL_COL1
+alignment: FL_ALIGN_CENTER
+style: FL_NORMAL_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: Apply|#A
+shortcut: ^M
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: button_apply
+callback: C_FormBaseApplyCB
+argument: 0
+
+--------------------
 class: FL_TEXT
 type: NORMAL_TEXT
-box: 10 280 485 35
+box: 15 275 485 35
 boxtype: FL_FLAT_BOX
 colors: FL_COL1 FL_MCOL
 alignment: FL_ALIGN_LEFT|FL_ALIGN_INSIDE
-style: FL_BOLD_STYLE
-size: FL_NORMAL_SIZE
+style: FL_NORMAL_STYLE
+size: FL_DEFAULT_SIZE
 lcol: FL_BLACK
 label: 
 shortcut: 
@@ -292,7 +310,7 @@
 --------------------
 class: FL_TEXT
 type: NORMAL_TEXT
-box: 175 130 66 30
+box: 180 130 66 30
 boxtype: FL_FLAT_BOX
 colors: FL_COL1 FL_MCOL
 alignment: FL_ALIGN_LEFT|FL_ALIGN_INSIDE
@@ -1119,7 +1137,7 @@
 shortcut: 
 resize: FL_RESIZE_ALL
 gravity: FL_NoGravity FL_NoGravity
-name: 
+name: button_lyxdefault
 callback: C_FormBaseInputCB
 argument: 0
 
@@ -1137,7 +1155,7 @@
 shortcut: 
 resize: FL_RESIZE_ALL
 gravity: FL_NoGravity FL_NoGravity
-name: 
+name: button_lyxwh
 callback: C_FormBaseInputCB
 argument: 0
 
Index: src/insets/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/ChangeLog,v
retrieving revision 1.303
diff -u -r1.303 ChangeLog
--- src/insets/ChangeLog        2002/02/04 15:36:45     1.303
+++ src/insets/ChangeLog        2002/02/04 17:46:18
@@ -1,3 +1,9 @@
+2002-02-04  Herbert Voss  <[EMAIL PROTECTED]>
+
+       * insetgraphic.C: 
+       * insetgraphicsParams.[Ch]: add a LyXView-scale to have a
+       similiar view to the LaTeX one. Get zipped files work.
+
 2002-02-04  Angus Leeming  <[EMAIL PROTECTED]>
 
        * insetgraphicsParams.C (init): set display to DEFAULT.
Index: src/insets/insetgraphics.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetgraphics.C,v
retrieving revision 1.72
diff -u -r1.72 insetgraphics.C
--- src/insets/insetgraphics.C  2002/02/04 15:36:45     1.72
+++ src/insets/insetgraphics.C  2002/02/04 17:46:18
@@ -126,7 +126,7 @@
 using std::endl;
 
 ///////////////////////////////////////////////////////////////////////////
-int VersionNumber = 1;
+int const VersionNumber = 1;
 ///////////////////////////////////////////////////////////////////////////
 
 // This function is a utility function
@@ -542,8 +542,8 @@
        // we handle it like a virtual one, so we can have
        // different extensions with the same type.
        // if it's a zipped one, than let LaTeX do the rest!!!
-       //if (zippedFile(params.filename))      
-       //    return params.filename;
+       if (zippedFile(params.filename))        
+           return params.filename;
        // now we have unzipped files
        string const extension = getExtFromContents(params.filename);
        // Are we creating a PDF or a PS file?
Index: src/insets/insetgraphicsParams.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetgraphicsParams.C,v
retrieving revision 1.22
diff -u -r1.22 insetgraphicsParams.C
--- src/insets/insetgraphicsParams.C    2002/02/04 15:36:45     1.22
+++ src/insets/insetgraphicsParams.C    2002/02/04 17:46:18
@@ -104,7 +104,9 @@
        lyxwidth = LyXLength();         // for the view in lyx
        lyxheight = LyXLength();
        scale = 0;
+       lyxscale = 0;
        size_type = DEFAULT_SIZE;       // do nothing
+       lyxsize_type = DEFAULT_SIZE;    // do nothing
        keepAspectRatio = false;        //
        rotateOrigin = "center";        // 
        rotateAngle = 0.0;              // in degrees
@@ -125,8 +127,10 @@
        height = igp.height;
        scale = igp.scale;
        size_type = igp.size_type;
+       lyxsize_type = igp.lyxsize_type;
        lyxwidth = igp.lyxwidth;
        lyxheight = igp.lyxheight;
+       lyxscale = igp.lyxscale;
        rotateOrigin = igp.rotateOrigin;
        rotateAngle = igp.rotateAngle;
        special = igp.special;
@@ -147,8 +151,10 @@
                left.height == right.height &&
                left.scale == right.scale &&
                left.size_type == right.size_type &&
+               left.lyxsize_type == right.lyxsize_type &&
                left.lyxwidth == right.lyxwidth &&
                left.lyxheight == right.lyxheight &&
+               left.lyxscale == right.lyxscale &&
                left.rotateOrigin == right.rotateOrigin &&
                lyx::float_equal(left.rotateAngle, right.rotateAngle, 0.001 &&
                left.special == right.special) 
@@ -205,10 +211,13 @@
                os << "\trotateOrigin " << rotateOrigin << '\n';
        if (!special.empty())
                os << "\tspecial " << special << '\n';
+       os << "\tlyxsize_type " <<  lyxsize_type << '\n';
        if (!lyxwidth.zero())           // the lyx-viewsize
            os << "\tlyxwidth " << lyxwidth.asString() << '\n';
        if (!lyxheight.zero())
            os << "\tlyxheight " << lyxheight.asString();
+       if (lyxscale != 0)
+           os << "\tlyxscale " << lyxscale << '\n';
 }
 
 
@@ -284,12 +293,24 @@
        } else if (token == "rotateOrigin") {
                lex.next();
                rotateOrigin=lex.getString();
+       } else if (token == "lyxsize_type") {
+               lex.next();
+               switch (lex.getInteger()) {
+                   case 0 : lyxsize_type = DEFAULT_SIZE;
+                       break;
+                   case 1 : lyxsize_type = WH;
+                       break;
+                   case 2 : lyxsize_type = SCALE;
+               }
        } else if (token == "lyxwidth") {
                lex.next();
                lyxwidth = LyXLength(lex.getString());
        } else if (token == "lyxheight") {
                lex.next();
                lyxheight = LyXLength(lex.getString());
+       } else if (token == "lyxscale") {
+               lex.next();
+               lyxscale = lex.getInteger();
        } else {
                // If it's none of the above, its not ours.
                return false;
Index: src/insets/insetgraphicsParams.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetgraphicsParams.h,v
retrieving revision 1.11
diff -u -r1.11 insetgraphicsParams.h
--- src/insets/insetgraphicsParams.h    2002/02/04 15:36:45     1.11
+++ src/insets/insetgraphicsParams.h    2002/02/04 17:46:18
@@ -71,6 +71,10 @@
        LyXLength lyxwidth;
        ///
        LyXLength lyxheight;
+       /// Typ of rescaling the Screen
+       int lyxscale;
+       /// Typ of the LyXView, same as for latex
+       sizeType lyxsize_type;
        /// Origin point of rotation
        string rotateOrigin;
        /// Rotation angle.
Index: src/support/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/ChangeLog,v
retrieving revision 1.60
diff -u -r1.60 ChangeLog
--- src/support/ChangeLog       2002/02/04 10:41:30     1.60
+++ src/support/ChangeLog       2002/02/04 17:46:19
@@ -1,3 +1,8 @@
+2002-02-04  Herbert Voss  <[EMAIL PROTECTED]>
+
+       * filetools.[Ch]: add ifZippedFile() for zipped
+       graphic files 
+
 2002-02-04  Jean-Marc Lasgouttes  <[EMAIL PROTECTED]>
 
        * filetools.C (FileOpenSearch): remove duplicated line, probably
Index: src/support/filetools.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/filetools.C,v
retrieving revision 1.94
diff -u -r1.94 filetools.C
--- src/support/filetools.C     2002/02/04 10:41:30     1.94
+++ src/support/filetools.C     2002/02/04 17:46:19
@@ -971,8 +971,12 @@
 // PDF %PDF-...
 // PNG .PNG...
 // PS  %!PS-Adobe-2.0
-// XBM static char ...
+// XBM ... static char ...
 // XPM /* XPM */
+//
+// GZIP        \213\037\008\008...     http://www.ietf.org/rfc/rfc1952.txt
+// ZIP PK...                   http://www.halyava.ru/document/ind_arch.htm
+// Z   \177\037                UNIX compress
 /// return the "extension" which belongs to the contents
 string const getExtFromContents(string const & filename) {
        if (filename.empty() || !IsFileReadable(filename)) 
@@ -980,9 +984,13 @@
        ifstream ifs(filename.c_str());
        if (!ifs) 
            return string();    // Couldn't open file...
+       string const gzipStamp = "\213\037\008\008";    // gnuzip
+       string const zipStamp = "PK";                   // PKZIP
+       string const compressStamp = "\177\037";        // compress
        int const max_count = 50; // Maximum strings to read to attempt recognition
        int count = 0; // Counter of attempts.
        string str;
+       bool zipChecked = false;
        for (; count < max_count; ++count) {
                if (ifs.eof()) {
                        lyxerr[Debug::INFO] << "InsetGraphics (classifyFiletype)"
@@ -990,6 +998,17 @@
                        break;
                }
                ifs >> str;
+               if (!zipChecked) {
+                   // at first we check for a zipped file, because this information
+                   // is saved in the first bytes of the file!
+                   if (str.substr(0,4) == gzipStamp)
+                       return "gzip";
+                   else if (str.substr(0,2) == zipStamp)
+                       return "zip";
+                   else if (str.substr(0,2) == compressStamp)
+                       return "compress";
+                   zipChecked = true;
+               }
                if (contains(str,"EPSF"))
                    return "eps";
                else if (contains(str,"GIF"))
@@ -1013,6 +1032,14 @@
 }
 
 
+/// check for zipped file
+bool zippedFile(string const & name) {
+       string const type = getExtFromContents(name);
+       if (contains("gzip zip",type) && !type.empty())
+           return true;
+       return false;
+}
+
 // Creates a nice compact path for displaying
 string const
 MakeDisplayPath (string const & path, unsigned int threshold)
@@ -1166,4 +1193,5 @@
                }
        }
 }
+
 
Index: src/support/filetools.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/filetools.h,v
retrieving revision 1.29
diff -u -r1.29 filetools.h
--- src/support/filetools.h     2002/01/31 14:20:09     1.29
+++ src/support/filetools.h     2002/02/04 17:46:19
@@ -133,8 +133,10 @@
 string const GetExtension(string const & name);
 
 /// Return the type of the file as an extension from contents
-///
 string const getExtFromContents(string const & name);
+
+/// check for zipped file
+bool zippedFile(string const & name);
 
 /// Returns true is path is absolute
 bool AbsolutePath(string const & path);

Reply via email to