]> git.lyx.org Git - features.git/commitdiff
X dependency cleanup (2/3)
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 9 Oct 2008 07:21:48 +0000 (07:21 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 9 Oct 2008 07:21:48 +0000 (07:21 +0000)
(inernal|external)LineEnding are only used by the clipboard code. Therefore
move them to the Qt helpers, where the current environment is known.

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

src/frontends/qt4/GuiClipboard.cpp
src/frontends/qt4/GuiSelection.cpp
src/frontends/qt4/qt_helpers.cpp
src/frontends/qt4/qt_helpers.h
src/support/lstrings.cpp
src/support/lstrings.h

index c62ce68e79124025858d14512abc0c31b52f1908..dcef9a4b2611667196c58e12077543adc3333ef8 100644 (file)
@@ -311,7 +311,7 @@ docstring const GuiClipboard::getAsText() const
        if (str.isNull())
                return docstring();
 
-       return internalLineEnding(qstring_to_ucs4(str));
+       return internalLineEnding(str);
 }
 
 
index ab610765c453860e003ccc950ac8dc563f5d9c4d..c3e53a542ebfe2b942643d4345bd2f5f0e8c32ba 100644 (file)
@@ -27,9 +27,6 @@
 namespace lyx {
 namespace frontend {
 
-using support::internalLineEnding;
-using support::externalLineEnding;
-
 
 GuiSelection::GuiSelection()
        : schedule_check_(true),
@@ -75,7 +72,7 @@ docstring const GuiSelection::get() const
        if (str.isNull())
                return docstring();
 
-       return internalLineEnding(qstring_to_ucs4(str));
+       return internalLineEnding(str);
 }
 
 
@@ -83,7 +80,7 @@ void GuiSelection::put(docstring const & str)
 {
        LYXERR(Debug::SELECTION, "GuiSelection::put: " << to_utf8(str));
 
-       qApp->clipboard()->setText(toqstr(externalLineEnding(str)),
+       qApp->clipboard()->setText(externalLineEnding(str),
                                   QClipboard::Selection);
 }
 
index 5c4e7387e6ad1da31d14a459e452e8d36773bf52..ff64a08f52fdd70c05364f8574882fe3e19aab1a 100644 (file)
@@ -201,6 +201,27 @@ QStringList texFileList(QString const & filename)
        return QList<QString>::fromSet(set);
 }
 
+QString const externalLineEnding(docstring const & str)
+{
+#ifdef Q_WS_MACX
+       // The MAC clipboard uses \r for lineendings, and we use \n
+       return toqstr(subst(str, '\n', '\r'));
+#elif defined(Q_WS_WIN)
+       // Windows clipboard uses \r\n for lineendings, and we use \n
+       return toqstr(subst(str, from_ascii("\n"), from_ascii("\r\n")));
+#else
+       return toqstr(str);
+#endif
+}
+
+
+docstring const internalLineEnding(QString const & str)
+{
+       docstring const s = subst(qstring_to_ucs4(str), 
+                                 from_ascii("\r\n"), from_ascii("\n"));
+       return subst(s, '\r', '\n');
+}
+
 
 QString internalPath(const QString & str)
 {
index 234ba0042662dec7fefd07da9274ce961226b1c0..101ad94ba76ce2e484b3947f465fc2a2e5835beb 100644 (file)
@@ -96,6 +96,12 @@ void rescanTexStyles();
  */
 QStringList texFileList(QString const & filename);
 
+/// Convert internal line endings to line endings as expected by the OS
+QString const externalLineEnding(docstring const & str);
+
+/// Convert line endings in any formnat to internal line endings
+docstring const internalLineEnding(QString const & str);
+
 // wrapper around the docstring versions
 QString internalPath(QString const &);
 QString onlyFilename(QString const & str);
index 2bd5f4ea95c606954ca82639b5a3be6726947906..93c1d9b7829a2f19ad65757f81b88402ac380051 100644 (file)
@@ -1004,27 +1004,6 @@ int findToken(char const * const str[], string const & search_token)
 }
 
 
-docstring const externalLineEnding(docstring const & str)
-{
-#if defined(__APPLE__)
-       // The MAC clipboard uses \r for lineendings, and we use \n
-       return subst(str, '\n', '\r');
-#elif defined (_WIN32) || (defined (__CYGWIN__) && defined (X_DISPLAY_MISSING))
-       // Windows clipboard uses \r\n for lineendings, and we use \n
-       return subst(str, from_ascii("\n"), from_ascii("\r\n"));
-#else
-       return str;
-#endif
-}
-
-
-docstring const internalLineEnding(docstring const & str)
-{
-       docstring const s = subst(str, from_ascii("\r\n"), from_ascii("\n"));
-       return subst(s, '\r', '\n');
-}
-
-
 template<>
 docstring bformat(docstring const & fmt, int arg1)
 {
index 9130f687c8b1c564faaa38c5d6c7c5eef929fdb0..233c3fb0e393699546e70937182ebd0669359c35 100644 (file)
@@ -242,13 +242,6 @@ std::string const getStringFromVector(std::vector<std::string> const & vec,
 /// found, else -1. The last item in \p str must be "".
 int findToken(char const * const str[], std::string const & search_token);
 
-/// Convert internal line endings to line endings as expected by the OS
-docstring const externalLineEnding(docstring const & str);
-
-/// Convert line endings in any formnat to internal line endings
-docstring const internalLineEnding(docstring const & str);
-
-
 template <class Arg1>
 docstring bformat(docstring const & fmt, Arg1);