http://bugzilla.lyx.org/show_bug.cgi?id=1749
Since this is a file format change and a long-standing bug, I decided to have a go before 1.5.0. Attached is the fix minus the actual lyx2lyx change (i.e., I added an empty lyx2lyx conversion/reversion). What it does is adding a new graphics param scaleBeforeRotation that switches the order. This can be toggled by a checkbox in the dialog, the default is what we have in 1.4.x (and 1.3.x, probably 1.2.x, but _not_ 1.1.x). José, could you have a look at the lyx2lyx stuff? I'm not sure what to do actually, because we had an implicit change on this sometime in the past. Please have a look at the description on bugzilla. OK to go in? Jürgen
Index: lib/lyx2lyx/LyX.py =================================================================== --- lib/lyx2lyx/LyX.py (Revision 18622) +++ lib/lyx2lyx/LyX.py (Arbeitskopie) @@ -77,7 +77,7 @@ ("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,272), generate_minor_versions("1.5" , 0))] + ("1_5", range(246,273), generate_minor_versions("1.5" , 0))] def formats_list(): Index: lib/lyx2lyx/lyx_1_5.py =================================================================== --- lib/lyx2lyx/lyx_1_5.py (Revision 18622) +++ lib/lyx2lyx/lyx_1_5.py (Arbeitskopie) @@ -1687,10 +1687,12 @@ [268, []], [269, []], [270, []], - [271, [convert_ext_font_sizes]] + [271, [convert_ext_font_sizes]], + [272, []] ] revert = [ + [271, []], [270, [revert_ext_font_sizes]], [269, [revert_beamer_alert, revert_beamer_structure]], [268, [revert_preamble_listings_params, revert_listings_inset, revert_include_listings]], Index: development/FORMAT =================================================================== --- development/FORMAT (Revision 18622) +++ development/FORMAT (Arbeitskopie) @@ -1,5 +1,11 @@ LyX file-format changes ----------------------- + +2007-05-04 Jürgen Spitzmüller <[EMAIL PROTECTED]> + + * format incremented to 272: add graphics params scaleBeforeRotating + (fix bug 1749). + 2007-05-15 José Matos <[EMAIL PROTECTED]> * format incremented to 271: extended textclasses accept the normal font sizes: 10, 11 and 12pt. Index: src/insets/InsetGraphicsParams.h =================================================================== --- src/insets/InsetGraphicsParams.h (Revision 18622) +++ src/insets/InsetGraphicsParams.h (Arbeitskopie) @@ -47,6 +47,8 @@ bool draft; /// what to do with zipped files bool noUnzip; + /// scale image after rotating + bool scaleAfterRotation; /// The bounding box with "xLB yLB yRT yRT ", divided by a space! std::string bb; Index: src/insets/InsetGraphics.cpp =================================================================== --- src/insets/InsetGraphics.cpp (Revision 18622) +++ src/insets/InsetGraphics.cpp (Arbeitskopie) @@ -103,6 +103,7 @@ using support::removeExtension; using support::rtrim; using support::subst; +using support::suffixIs; using support::Systemcall; using support::unzipFile; using support::unzippedFileName; @@ -312,18 +313,21 @@ 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().scaleAfterRotation && !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. @@ -341,13 +345,18 @@ options << ','; } } + if (params().scaleAfterRotation && !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: src/insets/InsetGraphicsParams.cpp =================================================================== --- src/insets/InsetGraphicsParams.cpp (Revision 18622) +++ src/insets/InsetGraphicsParams.cpp (Arbeitskopie) @@ -74,6 +74,7 @@ keepAspectRatio = false; // for LaTeX output draft = false; // draft mode noUnzip = false; // unzip files + scaleAfterRotation = false; // scale image after rotating bb = string(); // bounding box clip = false; // clip image @@ -97,6 +98,7 @@ keepAspectRatio = igp.keepAspectRatio; draft = igp.draft; noUnzip = igp.noUnzip; + scaleAfterRotation = igp.scaleAfterRotation; bb = igp.bb; clip = igp.clip; @@ -121,6 +123,7 @@ left.keepAspectRatio == right.keepAspectRatio && left.draft == right.draft && left.noUnzip == right.noUnzip && + left.scaleAfterRotation == right.scaleAfterRotation && left.bb == right.bb && @@ -172,6 +175,8 @@ os << "\tdraft\n"; if (noUnzip) os << "\tnoUnzip\n"; + if (scaleAfterRotation) + os << "\tscaleAfterRotation\n"; if (!bb.empty()) // bounding box os << "\tBoundingBox " << bb << '\n'; @@ -221,6 +226,8 @@ draft = true; } else if (token == "noUnzip") { noUnzip = true; + } else if (token == "scaleAfterRotation") { + scaleAfterRotation = true; } else if (token == "BoundingBox") { bb.erase(); for (int i = 0; i < 4; ++i) { Index: src/frontends/qt4/QGraphicsDialog.h =================================================================== --- src/frontends/qt4/QGraphicsDialog.h (Revision 18622) +++ src/frontends/qt4/QGraphicsDialog.h (Arbeitskopie) @@ -41,6 +41,7 @@ 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: src/frontends/qt4/ui/GraphicsUi.ui =================================================================== --- src/frontends/qt4/ui/GraphicsUi.ui (Revision 18622) +++ src/frontends/qt4/ui/GraphicsUi.ui (Arbeitskopie) @@ -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" > @@ -92,79 +92,13 @@ </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&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&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" > @@ -280,6 +214,82 @@ </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&tate before 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&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&ngle (Degrees):</string> + </property> + <property name="buddy" > + <cstring>angle</cstring> + </property> + </widget> + </item> + </layout> + </widget> + </item> </layout> </widget> <widget class="QWidget" name="Clipping" > @@ -457,144 +467,72 @@ <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> + <item row="5" column="1" > + <spacer> + <property name="orientation" > + <enum>Qt::Vertical</enum> </property> - <property name="text" > - <string>LaTeX &options:</string> + <property name="sizeHint" > + <size> + <width>20</width> + <height>40</height> + </size> </property> - <property name="buddy" > - <cstring>latexoptions</cstring> - </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> - </property> - <property name="toolTip" > - <string>Additional LaTeX options</string> - </property> - </widget> - </item> - <item row="2" column="0" colspan="2" > - <widget class="QCheckBox" name="unzipCB" > - <property name="toolTip" > - <string>Don't uncompress image before exporting to LaTeX</string> - </property> - <property name="text" > - <string>Don't un&zip on export</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>&Draft mode</string> - </property> - </widget> - </item> - <item row="3" column="0" colspan="2" > - <widget class="QGroupBox" name="subfigure" > + <item row="4" column="0" colspan="2" > + <widget class="QGroupBox" name="displayGB" > <property name="focusPolicy" > <enum>Qt::StrongFocus</enum> </property> <property name="title" > - <string>S&ubfigure</string> + <string>Sho&w in LyX</string> </property> <property name="flat" > - <bool>true</bool> + <bool>false</bool> </property> <property name="checkable" > <bool>true</bool> </property> - <property name="checked" > - <bool>false</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="CaptionLA" > - <property name="toolTip" > - <string>The caption for the sub-figure</string> + <item row="0" column="3" > + <widget class="QLineEdit" name="displayscale" > + <property name="enabled" > + <bool>true</bool> </property> - <property name="text" > - <string>Ca&ption:</string> - </property> - <property name="buddy" > - <cstring>subcaption</cstring> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="subcaption" > <property name="sizePolicy" > <sizepolicy> - <hsizetype>3</hsizetype> + <hsizetype>1</hsizetype> <vsizetype>0</vsizetype> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> <property name="toolTip" > - <string>The caption for the sub-figure</string> + <string>Percentage to scale by in LyX</string> </property> </widget> </item> - </layout> - </widget> - </item> - <item row="4" column="0" colspan="2" > - <widget class="QGroupBox" name="displayGB" > - <property name="focusPolicy" > - <enum>Qt::StrongFocus</enum> - </property> - <property name="title" > - <string>Sho&w in LyX</string> - </property> - <property name="flat" > - <bool>true</bool> - </property> - <property name="checkable" > - <bool>true</bool> - </property> - <layout class="QHBoxLayout" > - <property name="margin" > - <number>9</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="showL" > + <item row="0" column="2" > + <widget class="QLabel" name="scaleLA" > <property name="toolTip" > - <string>Screen display</string> + <string>Percentage to scale by in LyX</string> </property> <property name="text" > - <string>&Display:</string> + <string>Sca&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> @@ -621,40 +559,125 @@ </item> </widget> </item> + <item row="0" column="0" > + <widget class="QLabel" name="showL" > + <property name="toolTip" > + <string>Screen display</string> + </property> + <property name="text" > + <string>&Display:</string> + </property> + <property name="buddy" > + <cstring>showCB</cstring> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="3" column="0" colspan="2" > + <widget class="QGroupBox" name="subfigure" > + <property name="focusPolicy" > + <enum>Qt::StrongFocus</enum> + </property> + <property name="title" > + <string>S&ubfigure</string> + </property> + <property name="flat" > + <bool>false</bool> + </property> + <property name="checkable" > + <bool>true</bool> + </property> + <property name="checked" > + <bool>false</bool> + </property> + <layout class="QHBoxLayout" > + <property name="margin" > + <number>9</number> + </property> + <property name="spacing" > + <number>6</number> + </property> <item> - <widget class="QLabel" name="scaleLA" > + <widget class="QLabel" name="CaptionLA" > <property name="toolTip" > - <string>Percentage to scale by in LyX</string> + <string>The caption for the sub-figure</string> </property> <property name="text" > - <string>Sca&le on Screen (%):</string> + <string>Ca&ption:</string> </property> <property name="buddy" > - <cstring>displayscale</cstring> + <cstring>subcaption</cstring> </property> </widget> </item> <item> - <widget class="QLineEdit" name="displayscale" > - <property name="enabled" > - <bool>true</bool> - </property> + <widget class="QLineEdit" name="subcaption" > <property name="sizePolicy" > <sizepolicy> - <hsizetype>1</hsizetype> + <hsizetype>3</hsizetype> <vsizetype>0</vsizetype> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> <property name="toolTip" > - <string>Percentage to scale by in LyX</string> + <string>The caption for the sub-figure</string> </property> </widget> </item> </layout> </widget> </item> + <item row="2" column="0" colspan="2" > + <widget class="QCheckBox" name="unzipCB" > + <property name="toolTip" > + <string>Don't uncompress image before exporting to LaTeX</string> + </property> + <property name="text" > + <string>Don't un&zip on export</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>&Draft mode</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 &options:</string> + </property> + <property name="buddy" > + <cstring>latexoptions</cstring> + </property> + </widget> + </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> + </property> + <property name="toolTip" > + <string>Additional LaTeX options</string> + </property> + </widget> + </item> </layout> </widget> </widget> @@ -802,6 +825,5 @@ <include location="local" >qt_helpers.h</include> </includes> <resources/> - <connections> - </connections> + <connections/> </ui> Index: src/frontends/qt4/QGraphics.cpp =================================================================== --- src/frontends/qt4/QGraphics.cpp (Revision 18622) +++ src/frontends/qt4/QGraphics.cpp (Arbeitskopie) @@ -89,6 +89,7 @@ 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,7 +265,13 @@ dialog_->setAutoText(); dialog_->angle->setText(toqstr(igp.rotateAngle)); + dialog_->rotateOrderCB->setChecked(igp.scaleAfterRotation); + dialog_->rotateOrderCB->setEnabled((widthChecked || + heightChecked || + scaleChecked) && + (igp.rotateAngle != "0")); + dialog_->origin->clear(); vector<RotationOriginPair> origindata = getRotationOriginData(); @@ -382,6 +389,8 @@ igp.rotateOrigin = QGraphics::origin_ltx[dialog_->origin->currentIndex()]; + igp.scaleAfterRotation = dialog_->rotateOrderCB->isChecked(); + // more latex options igp.special = fromqstr(dialog_->latexoptions->text()); } Index: src/frontends/qt4/QGraphicsDialog.cpp =================================================================== --- src/frontends/qt4/QGraphicsDialog.cpp (Revision 18622) +++ src/frontends/qt4/QGraphicsDialog.cpp (Arbeitskopie) @@ -77,6 +77,8 @@ 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::setAutoText() { +void QGraphicsDialog::setAutoText() +{ if (scaleCB->isChecked()) return; if (!Scale->isEnabled() && Scale->text() != "100") Scale->setText(QString("auto")); @@ -236,6 +239,11 @@ aspectratio->setDisabled(true); aspectratio->setChecked(true); + rotateOrderCB->setEnabled((WidthCB->isChecked() || + HeightCB->isChecked() || + scaleCB->isChecked()) && + (angle->text() != "0")); + setAutoText(); } @@ -256,6 +264,9 @@ //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 @@ //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: src/Buffer.cpp =================================================================== --- src/Buffer.cpp (Revision 18622) +++ src/Buffer.cpp (Arbeitskopie) @@ -142,7 +142,7 @@ namespace { -int const LYX_FORMAT = 271; +int const LYX_FORMAT = 272; } // namespace anon