]> git.lyx.org Git - features.git/commitdiff
cosmetics
authorAndré Pönitz <poenitz@gmx.net>
Fri, 18 Apr 2008 20:14:20 +0000 (20:14 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Fri, 18 Apr 2008 20:14:20 +0000 (20:14 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24334 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/GuiExternal.cpp
src/frontends/qt4/GuiExternal.h

index c14ccbedf22f1d4f100403bc2183e5a52f0c391c..2fe1ce848abe26dbd71a81587f4a6f7e824e47a3 100644 (file)
@@ -54,7 +54,7 @@ using namespace external;
 
 namespace {
 
-RotationDataType origins_array[] = {
+RotationDataType origins[] = {
        RotationData::DEFAULT,
        RotationData::TOPLEFT,
        RotationData::BOTTOMLEFT,
@@ -69,12 +69,6 @@ RotationDataType origins_array[] = {
 };
 
 
-size_type const origins_array_size =
-sizeof(origins_array) / sizeof(origins_array[0]);
-
-vector<external::RotationDataType> const
-all_origins(origins_array, origins_array + origins_array_size);
-
 // These are the strings, corresponding to the above, that the GUI should
 // use. Note that they can/should be translated.
 char const * const origin_gui_strs[] = {
@@ -92,8 +86,6 @@ external::Template getTemplate(int i)
        return i1->second;
 }
 
-
-
 } // namespace anon
 
 
@@ -214,7 +206,7 @@ GuiExternal::GuiExternal(GuiView & lv)
                externalCO->addItem(qt_(i1->second.lyxName));
 
        // Fill the origins combo
-       for (size_t i = 0; i != all_origins.size(); ++i)
+       for (size_t i = 0; i != sizeof(origins) / sizeof(origins[0]); ++i)
                originCO->addItem(qt_(origin_gui_strs[i]));
 
        // Fill the width combo
@@ -298,7 +290,42 @@ void GuiExternal::formatChanged(const QString & format)
 
 void GuiExternal::getbbClicked()
 {
-       getBB();
+       xlED->setText("0");
+       ybED->setText("0");
+       xrED->setText("0");
+       ytED->setText("0");
+
+       string const filename = fromqstr(fileED->text());
+       if (filename.empty())
+               return;
+
+       FileName const abs_file(makeAbsPath(filename, fromqstr(bufferFilepath())));
+
+       // try to get it from the file, if possible
+       string bb = readBB_from_PSFile(abs_file);
+       if (bb.empty()) {
+               // we don't, so ask the Graphics Cache if it has loaded the file
+               int width = 0;
+               int height = 0;
+
+               graphics::Cache & gc = graphics::Cache::get();
+               if (gc.inCache(abs_file)) {
+                       graphics::Image const * image = gc.item(abs_file)->image();
+
+                       if (image) {
+                               width  = image->width();
+                               height = image->height();
+                       }
+               }
+               bb = "0 0 " + convert<string>(width) + ' ' + convert<string>(height);
+       }
+
+       xlED->setText(toqstr(token(bb, ' ', 0)));
+       ybED->setText(toqstr(token(bb, ' ', 1)));
+       xrED->setText(toqstr(token(bb, ' ', 2)));
+       ytED->setText(toqstr(token(bb, ' ', 3)));
+
+       bbChanged_ = false;
 }
 
 
@@ -382,34 +409,24 @@ static void setDisplay(
 }
 
 
-static void getDisplay(external::DisplayType & display,
-               unsigned int & scale,
-               QCheckBox const & displayCB,
-               QComboBox const & showCO,
-               QLineEdit const & scaleED)
+static external::DisplayType display(QCheckBox const & displayCB,
+       QComboBox const & showCO)
 {
+       if (!displayCB.isChecked())
+               return external::NoDisplay;
        switch (showCO.currentIndex()) {
+       default:
        case 0:
-               display = external::DefaultDisplay;
-               break;
+               return external::DefaultDisplay;
        case 1:
-               display = external::MonochromeDisplay;
-               break;
+               return external::MonochromeDisplay;
        case 2:
-               display = external::GrayscaleDisplay;
-               break;
+               return external::GrayscaleDisplay;
        case 3:
-               display = external::ColorDisplay;
-               break;
+               return external::ColorDisplay;
        case 4:
-               display = external::PreviewDisplay;
-               break;
+               return external::PreviewDisplay;
        }
-
-       if (!displayCB.isChecked())
-               display = external::NoDisplay;
-
-       scale = scaleED.text().toInt();
 }
 
 
@@ -639,9 +656,8 @@ void GuiExternal::applyView()
        params_.settemplate(getTemplate(externalCO->currentIndex()).lyxName);
 
        params_.draft = draftCB->isChecked();
-
-       getDisplay(params_.display, params_.lyxscale,
-               *displayCB, *showCO, *displayscaleED);
+       params_.lyxscale = displayscaleED->text().toInt();
+       params_.display = display(*displayCB, *showCO);
 
        if (tab->isTabEnabled(tab->indexOf(rotatetab)))
                getRotation(params_.rotationdata, *angleED, *originCO);
@@ -663,30 +679,6 @@ void GuiExternal::applyView()
 }
 
 
-void GuiExternal::getBB()
-{
-       xlED->setText("0");
-       ybED->setText("0");
-       xrED->setText("0");
-       ytED->setText("0");
-
-       string const filename = fromqstr(fileED->text());
-       if (filename.empty())
-               return;
-
-       string const bb = readBB(filename);
-       if (bb.empty())
-               return;
-
-       xlED->setText(toqstr(token(bb, ' ', 0)));
-       ybED->setText(toqstr(token(bb, ' ', 1)));
-       xrED->setText(toqstr(token(bb, ' ', 2)));
-       ytED->setText(toqstr(token(bb, ' ', 3)));
-
-       bbChanged_ = false;
-}
-
-
 bool GuiExternal::initialiseParams(string const & data)
 {
        InsetExternal::string2params(data, buffer(), params_);
@@ -741,34 +733,6 @@ QString GuiExternal::browse(QString const & input,
 }
 
 
-string const GuiExternal::readBB(string const & file)
-{
-       FileName const abs_file(makeAbsPath(file, fromqstr(bufferFilepath())));
-
-       // try to get it from the file, if possible. Zipped files are
-       // unzipped in the readBB_from_PSFile-Function
-       string const bb = readBB_from_PSFile(abs_file);
-       if (!bb.empty())
-               return bb;
-
-       // we don't, so ask the Graphics Cache if it has loaded the file
-       int width = 0;
-       int height = 0;
-
-       graphics::Cache & gc = graphics::Cache::get();
-       if (gc.inCache(abs_file)) {
-               graphics::Image const * image = gc.item(abs_file)->image();
-
-               if (image) {
-                       width  = image->width();
-                       height = image->height();
-               }
-       }
-
-       return ("0 0 " + convert<string>(width) + ' ' + convert<string>(height));
-}
-
-
 Dialog * createGuiExternal(GuiView & lv) { return new GuiExternal(lv); }
 
 
index 3a41a1833b1db3c90682353126c9560f85c8c720..5183a1ec1cdd3f1c45bc7c4a65e95ff237b15b00 100644 (file)
@@ -17,8 +17,6 @@
 #include "GuiDialog.h"
 #include "ui_ExternalUi.h"
 
-#include "support/types.h"
-
 #include "insets/InsetExternal.h"
 
 #include <QHash>
@@ -57,8 +55,6 @@ private:
        void updateContents();
        /// Helper function called when the template is changed.
        void updateTemplate();
-       /// get bounding box from file
-       void getBB();
 
        ///
        MapType extra_;
@@ -76,10 +72,6 @@ private:
        ///
        QString browse(QString const & input_file,
                                 QString const & template_name) const;
-
-       /// Read the Bounding Box from a eps or ps-file
-       std::string const readBB(std::string const & file);
-       ///
 private:
        ///
        InsetExternalParams params_;