]> git.lyx.org Git - features.git/commitdiff
Fix bug 1749. CAUTION: lyx2lyx not fully working yet (see FIXMEs).
authorJürgen Spitzmüller <spitz@lyx.org>
Mon, 25 Jun 2007 13:49:51 +0000 (13:49 +0000)
committerJürgen Spitzmüller <spitz@lyx.org>
Mon, 25 Jun 2007 13:49:51 +0000 (13:49 +0000)
* development/FORMAT:
- document file format change

* src/Buffer.cpp: bump format to 275.

* lib/lyx2lyx/LyX.py:
* lib/lyx2lyx/lyx_1_5.py:
- conversion and reversion of scaleBeforeRotation param (doesn't work yet!)

* src/insets/InsetGraphicsParams.{cpp,h}:
- new param scaleBeforeRotation
* src/insets/InsetGraphics.cpp:
- swap order of scale and rotate (if scaleBeforeRotation is false)

* src/frontends/qt4/QGraphics.C:
* src/frontends/qt4/QGraphicsDialog.{cpp,h}:
* src/frontends/qt4/ui/GraphicsUi.ui:
- add checkbox to toggle scaleBeforeRotation.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18885 a592a061-630c-0410-9148-cb99ea01b6c8

development/FORMAT
lib/lyx2lyx/LyX.py
lib/lyx2lyx/lyx_1_5.py
src/Buffer.cpp
src/frontends/qt4/QGraphics.cpp
src/frontends/qt4/QGraphicsDialog.cpp
src/frontends/qt4/QGraphicsDialog.h
src/frontends/qt4/ui/GraphicsUi.ui
src/insets/InsetGraphics.cpp
src/insets/InsetGraphicsParams.cpp
src/insets/InsetGraphicsParams.h

index b64512115aaa5b739024a8b08afa0dd89a029b6e..4eef5b799f5111f36bfaba4c091dd001985dfc9f 100644 (file)
@@ -1,6 +1,11 @@
 LyX file-format changes
 -----------------------
 
+2007-05-04  Jürgen Spitzmüller  <j.spitzmueller@gmx.de>
+
+       * format incremented to 275: add graphics params scaleBeforeRotation
+       (fix bug 1749).
+
 2007-06-13 Dov Feldstern <dov@lyx.org>
        * format incremented to 274: applying the conversion done in format 259
                to the \lang property, which was forgotten back then... This is
index f7770890ac509bf3cd2925405d5948ffaf833fb8..9088a41e2e950cb4f5f63799607fac2da16ebd04 100644 (file)
@@ -77,7 +77,7 @@ format_relation = [("0_06",    [200], generate_minor_versions("0.6" , 4)),
                    ("1_2",     [220], generate_minor_versions("1.2" , 4)),
                    ("1_3",     [221], generate_minor_versions("1.3" , 7)),
                    ("1_4", range(222,246), generate_minor_versions("1.4" , 4)),
-                   ("1_5", range(246,275), generate_minor_versions("1.5" , 0))]
+                   ("1_5", range(246,276), generate_minor_versions("1.5" , 0))]
 
 
 def formats_list():
index 32f84cd54ef153538126de8bd5dc70952969633e..595fffe15fae5e217246869612994bd5d5357bcd 100644 (file)
@@ -1356,6 +1356,65 @@ def revert_cv_textclass(document):
         document.textclass = "cv"
 
 
+#
+# add scaleBeforeRotation graphics param
+def convert_graphics_rotation(document):
+    " add scaleBeforeRotation graphics parameter. "
+    i = 0
+    while 1:
+        i = find_token(document.body, "\\begin_inset Graphics", i)
+        if i == -1:
+            return
+        j = find_end_of_inset(document.body, i+1)
+        if j == -1:
+            # should not happen
+            document.warning("Malformed LyX document: Could not find end of graphics inset.")
+        # Seach for rotateAngle and width or height or scale
+        # If these params are not there, nothing needs to be done.
+        # FIXME: this also inserts scaleBeforeRotation if "rotateAngle" is not there!
+        for k in range(i+1, j):
+            if (document.body[k].find("rotateAngle") and \
+                (document.body[k].find("width") or \
+                document.body[k].find("height") or \
+                document.body[k].find("scale"))):
+                        document.body.insert(j, 'scaleBeforeRotation')
+        i = i + 1
+
+
+# FIXME: does not work at all
+def revert_graphics_rotation(document):
+    " remove scaleBeforeRotation graphics parameter. "
+    i = 0
+    while 1:
+        i = find_token(document.body, "\\begin_inset Graphics", i)
+        if i == -1:
+            return
+        j = find_end_of_inset(document.body, i + 1)
+        if j == -1:
+            # should not happen
+            document.warning("Malformed LyX document: Could not find end of graphics inset.")
+        for k in range(i+1, j):
+            # If there's a scaleBeforeRotation param, just remove that
+            if document.body[k].find('scaleBeforeRotation'):
+                del document.body[k]
+                break
+            # if not, and if we have rotateAngle and width or height or scale,
+            # we have to put the rotateAngle value to special
+            rotateAngle = get_value(document.body, 'rotateAngle', i+1, j)
+            special = get_value(document.body, 'special', i+1, j)
+            if (document.body[k].find("width") or \
+                document.body[k].find("height") or \
+                document.body[k].find("scale") and \
+                document.body[k].find("rotateAngle")):
+                    if special == "":
+                        document.body.insert(j-1, '\tspecial angle=%s' % rotateAngle)
+                    else:
+                        l = find_token(document.body, "special", i+1, j)
+                        document.body[l].replace(special, 'angle=%s,%s' % (rotateAngle, special))
+        i = i + 1
+
+
+
 def convert_tableborder(document):
     # The problematic is: LyX double the table cell border as it ignores the "|" character in
     # the cell arguments. A fix takes care of this and therefore the "|" has to be removed
@@ -1782,10 +1841,12 @@ convert = [[246, []],
            [271, [convert_ext_font_sizes]],
            [272, []],
            [273, []],
-           [274, [normalize_font_whitespace_274]]
+           [274, [normalize_font_whitespace_274]],
+           [275, [convert_graphics_rotation]]
           ]
 
 revert =  [
+           [274, [revert_graphics_rotation]],
            [273, []],
            [272, [revert_separator_layout]],
            [271, [revert_preamble_listings_params, revert_listings_inset, revert_include_listings]],
index 73aacb1d21f8000446979cf785461681f20d16df..fbd56b8faa59901eae111bfd2e07baf1c02c3671 100644 (file)
@@ -142,7 +142,7 @@ using std::string;
 
 namespace {
 
-int const LYX_FORMAT = 274;
+int const LYX_FORMAT = 275;
 
 } // namespace anon
 
index dcd340dc7783714d6beac41cf4a3d8292ed0c9ac..f88bd150801acf1ec050812d64dd586254d29429 100644 (file)
@@ -89,6 +89,7 @@ void QGraphics::build_dialog()
        bcview().addReadOnly(dialog_->rotationGB);
        bcview().addReadOnly(dialog_->latexoptions);
        bcview().addReadOnly(dialog_->getPB);
+       bcview().addReadOnly(dialog_->rotateOrderCB);
 
        // initialize the length validator
        addCheckedLineEdit(bcview(), dialog_->Scale, dialog_->scaleCB);
@@ -264,6 +265,12 @@ void QGraphics::update_contents()
        dialog_->setAutoText();
 
        dialog_->angle->setText(toqstr(igp.rotateAngle));
+       dialog_->rotateOrderCB->setChecked(igp.scaleBeforeRotation);
+
+       dialog_->rotateOrderCB->setEnabled((widthChecked ||
+                                          heightChecked ||
+                                          scaleChecked) &&
+                                          (igp.rotateAngle != "0"));
 
        dialog_->origin->clear();
 
@@ -382,6 +389,8 @@ void QGraphics::apply()
        igp.rotateOrigin =
                QGraphics::origin_ltx[dialog_->origin->currentIndex()];
 
+       igp.scaleBeforeRotation = dialog_->rotateOrderCB->isChecked();
+
        // more latex options
        igp.special = fromqstr(dialog_->latexoptions->text());
 }
index b0beb483593fbb34073c908d5bce6a600fdeb1c2..ba801d4df85b0704f2a4b6ccfc43881ce349f43b 100644 (file)
@@ -77,6 +77,8 @@ QGraphicsDialog::QGraphicsDialog(QGraphics * form)
                this, SLOT(change_adaptor()));
        connect(Scale, SIGNAL(textChanged(const QString &)),
                this, SLOT(change_adaptor()));
+       connect(rotateOrderCB, SIGNAL(clicked()),
+               this, SLOT(change_adaptor()));
 
        filename->setValidator(new PathValidator(true, filename));
        setFocusProxy(filename);
@@ -201,7 +203,8 @@ void QGraphicsDialog::on_filename_textChanged(const QString & filename)
 }
 
 
-void QGraphicsDialog::setAutoText() {
+void QGraphicsDialog::setAutoText()
+{
        if (scaleCB->isChecked()) return;
        if (!Scale->isEnabled() && Scale->text() != "100")
                Scale->setText(QString("auto"));
@@ -236,6 +239,11 @@ void QGraphicsDialog::on_scaleCB_toggled(bool setScale)
        aspectratio->setDisabled(true);
        aspectratio->setChecked(true);
 
+       rotateOrderCB->setEnabled((WidthCB->isChecked() ||
+                                HeightCB->isChecked() ||
+                                scaleCB->isChecked()) &&
+                                (angle->text() != "0"));
+
        setAutoText();
 }
 
@@ -256,6 +264,9 @@ void QGraphicsDialog::on_WidthCB_toggled(bool setWidth)
        //already will be unchecked, so don't need to do that
        Scale->setEnabled((!setWidth && !setHeight) //=scaleCB->isEnabled()
                        && scaleCB->isChecked()); //should be false, but let's check
+       rotateOrderCB->setEnabled((setWidth || setHeight ||
+                                scaleCB->isChecked()) &&
+                                (angle->text() != "0"));
 
        setAutoText();
 }
@@ -277,11 +288,23 @@ void QGraphicsDialog::on_HeightCB_toggled(bool setHeight)
        //already unchecked
        Scale->setEnabled((!setWidth && !setHeight) //=scaleCB->isEnabled()
                && scaleCB->isChecked()); //should be false
+       rotateOrderCB->setEnabled((setWidth || setHeight ||
+                                scaleCB->isChecked()) &&
+                                (angle->text() != "0"));
 
        setAutoText();
 }
 
 
+void QGraphicsDialog::on_angle_textChanged(const QString & filename)
+{
+       rotateOrderCB->setEnabled((WidthCB->isChecked() ||
+                                HeightCB->isChecked() ||
+                                scaleCB->isChecked()) &&
+                                (filename != "0"));
+}
+
+
 } // namespace frontend
 } // namespace lyx
 
index 29ba1b4ab5f20039c73a2f32abf6d9ed2fa9aae7..0b2c2b733e3c16829b912c74a9cea5506e826b85 100644 (file)
@@ -41,6 +41,7 @@ protected Q_SLOTS:
        virtual void on_scaleCB_toggled(bool);
        virtual void on_WidthCB_toggled(bool);
        virtual void on_HeightCB_toggled(bool);
+       virtual void on_angle_textChanged(const QString &);
 protected:
        virtual void closeEvent(QCloseEvent * e);
 private:
index 38beafd67b3cbc47b5976727811f695593e194ff..40c8186a7661afffdc1e63009050ba35e0f64ea3 100644 (file)
@@ -5,8 +5,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>432</width>
-    <height>328</height>
+    <width>450</width>
+    <height>379</height>
    </rect>
   </property>
   <property name="sizePolicy" >
          </property>
         </widget>
        </item>
-       <item row="2" column="0" colspan="4" >
-        <widget class="QGroupBox" name="rotationGB" >
-         <property name="title" >
-          <string>Rotate Graphics</string>
-         </property>
-         <property name="flat" >
-          <bool>true</bool>
-         </property>
-         <layout class="QGridLayout" >
-          <property name="margin" >
-           <number>9</number>
-          </property>
-          <property name="spacing" >
-           <number>6</number>
-          </property>
-          <item row="0" column="0" >
-           <widget class="QLabel" name="angleL" >
-            <property name="toolTip" >
-             <string>Angle to rotate image by</string>
-            </property>
-            <property name="text" >
-             <string>A&amp;ngle (Degrees):</string>
-            </property>
-            <property name="buddy" >
-             <cstring>angle</cstring>
-            </property>
-           </widget>
-          </item>
-          <item row="0" column="1" >
-           <widget class="QLineEdit" name="angle" >
-            <property name="sizePolicy" >
-             <sizepolicy>
-              <hsizetype>3</hsizetype>
-              <vsizetype>0</vsizetype>
-              <horstretch>0</horstretch>
-              <verstretch>0</verstretch>
-             </sizepolicy>
-            </property>
-            <property name="toolTip" >
-             <string>Angle to rotate image by</string>
-            </property>
-           </widget>
-          </item>
-          <item row="0" column="2" >
-           <widget class="QLabel" name="originL" >
-            <property name="toolTip" >
-             <string>The origin of the rotation</string>
-            </property>
-            <property name="text" >
-             <string>Or&amp;igin:</string>
-            </property>
-            <property name="buddy" >
-             <cstring>origin</cstring>
-            </property>
-           </widget>
-          </item>
-          <item row="0" column="3" >
-           <widget class="QComboBox" name="origin" >
-            <property name="toolTip" >
-             <string>The origin of the rotation</string>
-            </property>
-           </widget>
-          </item>
-         </layout>
-        </widget>
-       </item>
        <item row="1" column="0" colspan="4" >
         <widget class="QGroupBox" name="sizeGB" >
          <property name="title" >
           <string>Output Size</string>
          </property>
          <property name="flat" >
-          <bool>true</bool>
+          <bool>false</bool>
          </property>
          <layout class="QGridLayout" >
           <property name="margin" >
          </layout>
         </widget>
        </item>
+       <item row="2" column="0" colspan="4" >
+        <widget class="QGroupBox" name="rotationGB" >
+         <property name="title" >
+          <string>Rotate Graphics</string>
+         </property>
+         <property name="flat" >
+          <bool>false</bool>
+         </property>
+         <layout class="QGridLayout" >
+          <property name="margin" >
+           <number>9</number>
+          </property>
+          <property name="spacing" >
+           <number>6</number>
+          </property>
+          <item row="1" column="0" colspan="2" >
+           <widget class="QCheckBox" name="rotateOrderCB" >
+            <property name="toolTip" >
+             <string>Check to change the order of rotating and scaling</string>
+            </property>
+            <property name="text" >
+             <string>Ro&amp;tate after scaling</string>
+            </property>
+           </widget>
+          </item>
+          <item row="0" column="3" >
+           <widget class="QComboBox" name="origin" >
+            <property name="toolTip" >
+             <string>The origin of the rotation</string>
+            </property>
+           </widget>
+          </item>
+          <item row="0" column="2" >
+           <widget class="QLabel" name="originL" >
+            <property name="toolTip" >
+             <string>The origin of the rotation</string>
+            </property>
+            <property name="text" >
+             <string>Or&amp;igin:</string>
+            </property>
+            <property name="buddy" >
+             <cstring>origin</cstring>
+            </property>
+           </widget>
+          </item>
+          <item row="0" column="1" >
+           <widget class="QLineEdit" name="angle" >
+            <property name="sizePolicy" >
+             <sizepolicy>
+              <hsizetype>3</hsizetype>
+              <vsizetype>0</vsizetype>
+              <horstretch>0</horstretch>
+              <verstretch>0</verstretch>
+             </sizepolicy>
+            </property>
+            <property name="toolTip" >
+             <string>Angle to rotate image by</string>
+            </property>
+           </widget>
+          </item>
+          <item row="0" column="0" >
+           <widget class="QLabel" name="angleL" >
+            <property name="toolTip" >
+             <string>Angle to rotate image by</string>
+            </property>
+            <property name="text" >
+             <string>A&amp;ngle (Degrees):</string>
+            </property>
+            <property name="buddy" >
+             <cstring>angle</cstring>
+            </property>
+           </widget>
+          </item>
+         </layout>
+        </widget>
+       </item>
       </layout>
      </widget>
      <widget class="QWidget" name="Clipping" >
           <enum>QFrame::StyledPanel</enum>
          </property>
          <property name="frameShadow" >
-          <enum>QFrame::Raised</enum>
+          <enum>QFrame::Plain</enum>
          </property>
          <layout class="QGridLayout" >
           <property name="margin" >
        <property name="spacing" >
         <number>6</number>
        </property>
-       <item row="0" column="0" >
-        <widget class="QLabel" name="latexoptionsLA" >
-         <property name="toolTip" >
-          <string>Additional LaTeX options</string>
-         </property>
-         <property name="text" >
-          <string>LaTeX &amp;options:</string>
+       <item row="3" column="1" >
+        <spacer>
+         <property name="orientation" >
+          <enum>Qt::Vertical</enum>
          </property>
-         <property name="buddy" >
-          <cstring>latexoptions</cstring>
+         <property name="sizeHint" >
+          <size>
+           <width>20</width>
+           <height>21</height>
+          </size>
          </property>
-        </widget>
+        </spacer>
        </item>
-       <item row="0" column="1" >
-        <widget class="QLineEdit" name="latexoptions" >
-         <property name="sizePolicy" >
-          <sizepolicy>
-           <hsizetype>3</hsizetype>
-           <vsizetype>0</vsizetype>
-           <horstretch>0</horstretch>
-           <verstretch>0</verstretch>
-          </sizepolicy>
+       <item row="6" column="2" >
+        <spacer>
+         <property name="orientation" >
+          <enum>Qt::Vertical</enum>
          </property>
-         <property name="toolTip" >
-          <string>Additional LaTeX options</string>
+         <property name="sizeHint" >
+          <size>
+           <width>20</width>
+           <height>41</height>
+          </size>
          </property>
-        </widget>
+        </spacer>
        </item>
-       <item row="2" column="0" colspan="2" >
+       <item row="2" column="0" colspan="3" >
         <widget class="QCheckBox" name="unzipCB" >
          <property name="toolTip" >
           <string>Don't uncompress image before exporting to LaTeX</string>
          </property>
         </widget>
        </item>
-       <item row="1" column="0" colspan="2" >
-        <widget class="QCheckBox" name="draftCB" >
-         <property name="toolTip" >
-          <string>Draft mode</string>
-         </property>
-         <property name="text" >
-          <string>&amp;Draft mode</string>
-         </property>
-        </widget>
-       </item>
-       <item row="3" column="0" colspan="2" >
+       <item row="4" column="0" colspan="3" >
         <widget class="QGroupBox" name="subfigure" >
          <property name="focusPolicy" >
           <enum>Qt::StrongFocus</enum>
           <string>S&amp;ubfigure</string>
          </property>
          <property name="flat" >
-          <bool>true</bool>
+          <bool>false</bool>
          </property>
          <property name="checkable" >
           <bool>true</bool>
          </layout>
         </widget>
        </item>
-       <item row="4" column="0" colspan="2" >
+       <item row="5" column="0" colspan="3" >
         <widget class="QGroupBox" name="displayGB" >
          <property name="focusPolicy" >
           <enum>Qt::StrongFocus</enum>
           <string>Sho&amp;w in LyX</string>
          </property>
          <property name="flat" >
-          <bool>true</bool>
+          <bool>false</bool>
          </property>
          <property name="checkable" >
           <bool>true</bool>
          </property>
-         <layout class="QHBoxLayout" >
+         <layout class="QGridLayout" >
           <property name="margin" >
            <number>9</number>
           </property>
           <property name="spacing" >
            <number>6</number>
           </property>
-          <item>
-           <widget class="QLabel" name="showL" >
+          <item row="0" column="3" >
+           <widget class="QLineEdit" name="displayscale" >
+            <property name="enabled" >
+             <bool>true</bool>
+            </property>
+            <property name="sizePolicy" >
+             <sizepolicy>
+              <hsizetype>1</hsizetype>
+              <vsizetype>0</vsizetype>
+              <horstretch>0</horstretch>
+              <verstretch>0</verstretch>
+             </sizepolicy>
+            </property>
             <property name="toolTip" >
-             <string>Screen display</string>
+             <string>Percentage to scale by in LyX</string>
+            </property>
+           </widget>
+          </item>
+          <item row="0" column="2" >
+           <widget class="QLabel" name="scaleLA" >
+            <property name="toolTip" >
+             <string>Percentage to scale by in LyX</string>
             </property>
             <property name="text" >
-             <string>&amp;Display:</string>
+             <string>Sca&amp;le on Screen (%):</string>
             </property>
             <property name="buddy" >
-             <cstring>showCB</cstring>
+             <cstring>displayscale</cstring>
             </property>
            </widget>
           </item>
-          <item>
+          <item row="0" column="1" >
            <widget class="QComboBox" name="showCB" >
             <property name="toolTip" >
              <string>Screen display</string>
             </item>
            </widget>
           </item>
-          <item>
-           <widget class="QLabel" name="scaleLA" >
+          <item row="0" column="0" >
+           <widget class="QLabel" name="showL" >
             <property name="toolTip" >
-             <string>Percentage to scale by in LyX</string>
+             <string>Screen display</string>
             </property>
             <property name="text" >
-             <string>Sca&amp;le on Screen (%):</string>
+             <string>&amp;Display:</string>
             </property>
             <property name="buddy" >
-             <cstring>displayscale</cstring>
-            </property>
-           </widget>
-          </item>
-          <item>
-           <widget class="QLineEdit" name="displayscale" >
-            <property name="enabled" >
-             <bool>true</bool>
-            </property>
-            <property name="sizePolicy" >
-             <sizepolicy>
-              <hsizetype>1</hsizetype>
-              <vsizetype>0</vsizetype>
-              <horstretch>0</horstretch>
-              <verstretch>0</verstretch>
-             </sizepolicy>
-            </property>
-            <property name="toolTip" >
-             <string>Percentage to scale by in LyX</string>
+             <cstring>showCB</cstring>
             </property>
            </widget>
           </item>
          </layout>
         </widget>
        </item>
+       <item row="0" column="1" colspan="2" >
+        <widget class="QLineEdit" name="latexoptions" >
+         <property name="sizePolicy" >
+          <sizepolicy>
+           <hsizetype>3</hsizetype>
+           <vsizetype>0</vsizetype>
+           <horstretch>0</horstretch>
+           <verstretch>0</verstretch>
+          </sizepolicy>
+         </property>
+         <property name="toolTip" >
+          <string>Additional LaTeX options</string>
+         </property>
+        </widget>
+       </item>
+       <item row="0" column="0" >
+        <widget class="QLabel" name="latexoptionsLA" >
+         <property name="toolTip" >
+          <string>Additional LaTeX options</string>
+         </property>
+         <property name="text" >
+          <string>LaTeX &amp;options:</string>
+         </property>
+         <property name="buddy" >
+          <cstring>latexoptions</cstring>
+         </property>
+        </widget>
+       </item>
+       <item row="1" column="0" colspan="3" >
+        <widget class="QCheckBox" name="draftCB" >
+         <property name="toolTip" >
+          <string>Draft mode</string>
+         </property>
+         <property name="text" >
+          <string>&amp;Draft mode</string>
+         </property>
+        </widget>
+       </item>
       </layout>
      </widget>
     </widget>
   <tabstop>aspectratio</tabstop>
   <tabstop>angle</tabstop>
   <tabstop>origin</tabstop>
+  <tabstop>rotateOrderCB</tabstop>
   <tabstop>restorePB</tabstop>
   <tabstop>okPB</tabstop>
   <tabstop>applyPB</tabstop>
   <include location="local" >qt_helpers.h</include>
  </includes>
  <resources/>
- <connections>
- </connections>
+ <connections/>
 </ui>
index 477f884e2e34fb3a963f33e656c4cbd24f7a3d54..f48f784e7f99dccf5a2261797bcb39bec0602148 100644 (file)
@@ -104,6 +104,7 @@ using support::onlyFilename;
 using support::removeExtension;
 using support::rtrim;
 using support::subst;
+using support::suffixIs;
 using support::Systemcall;
 using support::unzipFile;
 using support::unzippedFileName;
@@ -313,18 +314,21 @@ string const InsetGraphics::createLatexOptions() const
            options << "draft,";
        if (params().clip)
            options << "clip,";
+       ostringstream size;
        double const scl = convert<double>(params().scale);
        if (!params().scale.empty() && !float_equal(scl, 0.0, 0.05)) {
                if (!float_equal(scl, 100.0, 0.05))
-                       options << "scale=" << scl / 100.0 << ',';
+                       size << "scale=" << scl / 100.0 << ',';
        } else {
                if (!params().width.zero())
-                       options << "width=" << params().width.asLatexString() << ',';
+                       size << "width=" << params().width.asLatexString() << ',';
                if (!params().height.zero())
-                       options << "height=" << params().height.asLatexString() << ',';
+                       size << "height=" << params().height.asLatexString() << ',';
                if (params().keepAspectRatio)
-                       options << "keepaspectratio,";
+                       size << "keepaspectratio,";
        }
+       if (params().scaleBeforeRotation && !size.str().empty())
+               options << size.str();
 
        // Make sure rotation angle is not very close to zero;
        // a float can be effectively zero but not exactly zero.
@@ -342,13 +346,18 @@ string const InsetGraphics::createLatexOptions() const
                options << ',';
            }
        }
+       if (!params().scaleBeforeRotation && !size.str().empty())
+               options << size.str();
 
        if (!params().special.empty())
            options << params().special << ',';
 
        string opts = options.str();
        // delete last ','
-       return opts.substr(0, opts.size() - 1);
+       if (suffixIs(opts, ','))
+               opts = opts.substr(0, opts.size() - 1);
+
+       return opts;
 }
 
 
index 858ce5e8f0bfce0c2bb8770e258fb57c90c54066..b7d97400b8a52ce0e0db95a5c00c41bff9297101 100644 (file)
@@ -74,6 +74,7 @@ void InsetGraphicsParams::init()
        keepAspectRatio = false;        // for LaTeX output
        draft = false;                  // draft mode
        noUnzip = false;                // unzip files
+       scaleBeforeRotation = false;    // scale image before rotating
 
        bb = string();                  // bounding box
        clip = false;                   // clip image
@@ -97,6 +98,7 @@ void InsetGraphicsParams::copy(InsetGraphicsParams const & igp)
        keepAspectRatio = igp.keepAspectRatio;
        draft = igp.draft;
        noUnzip = igp.noUnzip;
+       scaleBeforeRotation = igp.scaleBeforeRotation;
 
        bb = igp.bb;
        clip = igp.clip;
@@ -121,6 +123,7 @@ bool operator==(InsetGraphicsParams const & left,
            left.keepAspectRatio == right.keepAspectRatio &&
            left.draft == right.draft &&
            left.noUnzip == right.noUnzip &&
+           left.scaleBeforeRotation == right.scaleBeforeRotation &&
 
 
            left.bb == right.bb &&
@@ -172,6 +175,8 @@ void InsetGraphicsParams::Write(ostream & os, string const & bufpath) const
                os << "\tdraft\n";
        if (noUnzip)
                os << "\tnoUnzip\n";
+       if (scaleBeforeRotation)
+               os << "\tscaleBeforeRotation\n";
 
        if (!bb.empty())                // bounding box
                os << "\tBoundingBox " << bb << '\n';
@@ -221,6 +226,8 @@ bool InsetGraphicsParams::Read(Lexer & lex, string const & token, string const &
                draft = true;
        } else if (token == "noUnzip") {
                noUnzip = true;
+       } else if (token == "scaleBeforeRotation") {
+               scaleBeforeRotation = true;
        } else if (token == "BoundingBox") {
                bb.erase();
                for (int i = 0; i < 4; ++i) {
index 5294a42ba3f5576e31c67fbe9b8daa1600643a7c..b6cea1fd9bae7f05c02bd6024a13c595c2f1ca82 100644 (file)
@@ -47,6 +47,8 @@ public:
        bool draft;
        /// what to do with zipped files
        bool noUnzip;
+       /// scale image before rotating
+       bool scaleBeforeRotation;
 
        /// The bounding box with "xLB yLB yRT yRT ", divided by a space!
        std::string bb;