mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-06 00:10:59 +00:00
shuffle stuff around
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21511 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
c1c5e5b50e
commit
14f7e7fffe
@ -132,11 +132,14 @@ bool EmbeddedFile::extract(Buffer const * buf) const
|
||||
string ext_file = absFilename();
|
||||
string emb_file = embeddedFile(buf);
|
||||
|
||||
if (!fs::exists(emb_file))
|
||||
FileName emb(emb_file);
|
||||
FileName ext(ext_file);
|
||||
|
||||
if (!emb.exists())
|
||||
return false;
|
||||
|
||||
// if external file already exists ...
|
||||
if (fs::exists(ext_file)) {
|
||||
if (ext.exists()) {
|
||||
// no need to copy if the files are the same
|
||||
if (sum(*this) == sum(FileName(emb_file)))
|
||||
return true;
|
||||
@ -156,8 +159,6 @@ bool EmbeddedFile::extract(Buffer const * buf) const
|
||||
string path = support::onlyPath(ext_file);
|
||||
if (!fs::is_directory(path))
|
||||
makedir(const_cast<char*>(path.c_str()), 0755);
|
||||
FileName emb(emb_file);
|
||||
FileName ext(ext_file);
|
||||
if (emb.copyTo(ext, false))
|
||||
return true;
|
||||
Alert::error(_("Copy file failure"),
|
||||
@ -174,11 +175,14 @@ bool EmbeddedFile::updateFromExternalFile(Buffer const * buf) const
|
||||
string ext_file = absFilename();
|
||||
string emb_file = embeddedFile(buf);
|
||||
|
||||
if (!fs::exists(ext_file))
|
||||
FileName emb(emb_file);
|
||||
FileName ext(ext_file);
|
||||
|
||||
if (!ext.exists())
|
||||
return false;
|
||||
|
||||
// if embedded file already exists ...
|
||||
if (fs::exists(emb_file)) {
|
||||
if (emb.exists()) {
|
||||
// no need to copy if the files are the same
|
||||
if (sum(*this) == sum(FileName(emb_file)))
|
||||
return true;
|
||||
@ -193,8 +197,6 @@ bool EmbeddedFile::updateFromExternalFile(Buffer const * buf) const
|
||||
return true;
|
||||
}
|
||||
// copy file
|
||||
FileName emb(emb_file);
|
||||
FileName ext(ext_file);
|
||||
// need to make directory?
|
||||
string path = support::onlyPath(emb_file);
|
||||
if (!fs::is_directory(path))
|
||||
|
@ -1,26 +1,5 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "debug.h"
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
|
||||
#include <fcntl.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_SELECT_H
|
||||
# include <sys/select.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#include <cerrno>
|
||||
#include <cstdlib>
|
||||
#include <exception>
|
||||
|
@ -20,11 +20,27 @@
|
||||
|
||||
#include "support/unicode.h"
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
using std::string;
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
/**
|
||||
* Convert a UCS4 character into a QChar.
|
||||
* This is a hack (it does only make sense for the common part of the UCS4
|
||||
* and UTF16 encodings) and should not be used.
|
||||
* This does only exist because of performance reasons (a real conversion
|
||||
* using iconv is too slow on windows).
|
||||
*/
|
||||
static inline QChar const ucs4_to_qchar(char_type const ucs4)
|
||||
{
|
||||
BOOST_ASSERT(is_utf16(ucs4));
|
||||
return QChar(static_cast<unsigned short>(ucs4));
|
||||
}
|
||||
|
||||
|
||||
// Caution: When using ucs4_to_qchar() in these methods, this is no
|
||||
// real conversion but a simple cast in reality. This is the reason
|
||||
// why this works well for symbol fonts used in mathed too, even though
|
||||
@ -223,7 +239,7 @@ int GuiFontMetrics::width(char_type c) const
|
||||
if (is_utf16(c))
|
||||
value = metrics_.width(ucs4_to_qchar(c));
|
||||
else
|
||||
value = metrics_.width(toqstr(docstring(1,c)));
|
||||
value = metrics_.width(toqstr(docstring(1, c)));
|
||||
|
||||
width_cache_.insert(c, value);
|
||||
|
||||
|
@ -15,8 +15,9 @@
|
||||
|
||||
#include "debug.h"
|
||||
|
||||
#include <climits>
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
#include <climits>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
|
@ -24,9 +24,6 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include <boost/filesystem/exception.hpp>
|
||||
|
||||
|
||||
namespace lyx {
|
||||
|
||||
@ -43,9 +40,6 @@ using std::endl;
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
namespace fs = boost::filesystem;
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
vector<string> const init_possible_cite_commands()
|
||||
@ -164,19 +158,10 @@ docstring const getNatbibLabel(Buffer const & buffer,
|
||||
for (vector<FileName>::const_iterator it = bibfilesCache.begin();
|
||||
it != bibfilesCache.end(); ++ it) {
|
||||
FileName const f = *it;
|
||||
try {
|
||||
std::time_t lastw = f.lastModified();
|
||||
if (lastw != bibfileStatus[f]) {
|
||||
changed = true;
|
||||
bibfileStatus[f] = lastw;
|
||||
}
|
||||
}
|
||||
catch (fs::filesystem_error & fserr) {
|
||||
std::time_t lastw = f.lastModified();
|
||||
if (lastw != bibfileStatus[f]) {
|
||||
changed = true;
|
||||
lyxerr << "Couldn't find or read bibtex file "
|
||||
<< f << endl;
|
||||
LYXERR(Debug::DEBUG) << "Fs error: "
|
||||
<< fserr.what() << endl;
|
||||
bibfileStatus[f] = lastw;
|
||||
}
|
||||
}
|
||||
|
||||
@ -422,9 +407,8 @@ docstring const InsetCitation::generateLabel(Buffer const & buffer) const
|
||||
}
|
||||
|
||||
// Fallback to fail-safe
|
||||
if (label.empty()) {
|
||||
if (label.empty())
|
||||
label = getBasicLabel(getParam("key"), after);
|
||||
}
|
||||
|
||||
return label;
|
||||
}
|
||||
|
@ -78,7 +78,6 @@ liblyxsupport_la_SOURCES = \
|
||||
Systemcall.cpp \
|
||||
Systemcall.h \
|
||||
tempname.cpp \
|
||||
textutils.cpp \
|
||||
textutils.h \
|
||||
Translator.h \
|
||||
Timeout.cpp \
|
||||
|
@ -12,21 +12,17 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "support/lstrings.h"
|
||||
|
||||
#include "support/lyxlib.h"
|
||||
#include "support/convert.h"
|
||||
#include "support/qstring_helpers.h"
|
||||
#include "support/textutils.h"
|
||||
|
||||
#include "debug.h"
|
||||
|
||||
#include <boost/tokenizer.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
#ifndef I_AM_NOT_AFRAID_OF_HEADER_LIBRARIES
|
||||
#if USE_BOOST_FORMAT
|
||||
#include <boost/format.hpp>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <cctype>
|
||||
#include <cstdlib>
|
||||
|
||||
@ -46,6 +42,115 @@ using std::toupper;
|
||||
|
||||
|
||||
namespace lyx {
|
||||
|
||||
/**
|
||||
* Convert a QChar into a UCS4 character.
|
||||
* This is a hack (it does only make sense for the common part of the UCS4
|
||||
* and UTF16 encodings) and should not be used.
|
||||
* This does only exist because of performance reasons (a real conversion
|
||||
* using iconv is too slow on windows).
|
||||
*/
|
||||
static inline char_type qchar_to_ucs4(QChar const & qchar)
|
||||
{
|
||||
BOOST_ASSERT(is_utf16(static_cast<char_type>(qchar.unicode())));
|
||||
return static_cast<char_type>(qchar.unicode());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert a UCS4 character into a QChar.
|
||||
* This is a hack (it does only make sense for the common part of the UCS4
|
||||
* and UTF16 encodings) and should not be used.
|
||||
* This does only exist because of performance reasons (a real conversion
|
||||
* using iconv is too slow on windows).
|
||||
*/
|
||||
static inline QChar const ucs4_to_qchar(char_type const ucs4)
|
||||
{
|
||||
BOOST_ASSERT(is_utf16(ucs4));
|
||||
return QChar(static_cast<unsigned short>(ucs4));
|
||||
}
|
||||
|
||||
|
||||
namespace {
|
||||
/// Maximum valid UCS4 code point
|
||||
char_type const ucs4_max = 0x10ffff;
|
||||
}
|
||||
|
||||
|
||||
bool isLetterChar(char_type c)
|
||||
{
|
||||
if (!is_utf16(c)) {
|
||||
if (c > ucs4_max)
|
||||
// outside the UCS4 range
|
||||
return false;
|
||||
// assume that all non-utf16 characters are letters
|
||||
return true;
|
||||
}
|
||||
return ucs4_to_qchar(c).isLetter();
|
||||
}
|
||||
|
||||
|
||||
bool isAlphaASCII(char_type c)
|
||||
{
|
||||
return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z');
|
||||
}
|
||||
|
||||
|
||||
bool isPrintable(char_type c)
|
||||
{
|
||||
if (!is_utf16(c)) {
|
||||
if (c > ucs4_max)
|
||||
// outside the UCS4 range
|
||||
return false;
|
||||
// assume that all non-utf16 characters are printable
|
||||
return true;
|
||||
}
|
||||
return ucs4_to_qchar(c).isPrint();
|
||||
}
|
||||
|
||||
|
||||
bool isPrintableNonspace(char_type c)
|
||||
{
|
||||
if (!is_utf16(c)) {
|
||||
if (c > ucs4_max)
|
||||
// outside the UCS4 range
|
||||
return false;
|
||||
// assume that all non-utf16 characters are printable and
|
||||
// no space
|
||||
return true;
|
||||
}
|
||||
QChar const qc = ucs4_to_qchar(c);
|
||||
return qc.isPrint() && !qc.isSpace();
|
||||
}
|
||||
|
||||
|
||||
bool isSpace(char_type c)
|
||||
{
|
||||
if (!is_utf16(c)) {
|
||||
// assume that no non-utf16 character is a space
|
||||
// c outside the UCS4 range is catched as well
|
||||
return false;
|
||||
}
|
||||
QChar const qc = ucs4_to_qchar(c);
|
||||
return qc.isSpace();
|
||||
}
|
||||
|
||||
|
||||
bool isDigit(char_type c)
|
||||
{
|
||||
if (!is_utf16(c))
|
||||
// assume that no non-utf16 character is a digit
|
||||
// c outside the UCS4 range is catched as well
|
||||
return false;
|
||||
return ucs4_to_qchar(c).isDigit();
|
||||
}
|
||||
|
||||
|
||||
bool isDigitASCII(char_type c)
|
||||
{
|
||||
return '0' <= c && c <= '9';
|
||||
}
|
||||
|
||||
namespace support {
|
||||
|
||||
int compare_no_case(docstring const & s, docstring const & s2)
|
||||
@ -728,7 +833,7 @@ docstring const doSplit(docstring const & a, docstring & piece, Char delim)
|
||||
return tmp;
|
||||
}
|
||||
|
||||
}
|
||||
} // anon
|
||||
|
||||
|
||||
string const split(string const & a, string & piece, char delim)
|
||||
@ -832,7 +937,7 @@ getVectorFromStringT(String const & str, String const & delim)
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
} // anon
|
||||
|
||||
|
||||
vector<string> const getVectorFromString(string const & str,
|
||||
@ -902,81 +1007,6 @@ docstring const internalLineEnding(docstring const & str)
|
||||
}
|
||||
|
||||
|
||||
#ifndef I_AM_NOT_AFRAID_OF_HEADER_LIBRARIES
|
||||
#if USE_BOOST_FORMAT
|
||||
|
||||
template<>
|
||||
docstring bformat(docstring const & fmt, int arg1)
|
||||
{
|
||||
return (boost::basic_format<char_type>(fmt) % arg1).str();
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
docstring bformat(docstring const & fmt, long arg1)
|
||||
{
|
||||
return (boost::basic_format<char_type>(fmt) % arg1).str();
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
docstring bformat(docstring const & fmt, unsigned int arg1)
|
||||
{
|
||||
return (boost::basic_format<char_type>(fmt) % arg1).str();
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
docstring bformat<docstring>(docstring const & fmt, docstring arg1)
|
||||
{
|
||||
return (boost::basic_format<char_type>(fmt) % arg1).str();
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
docstring bformat(docstring const & fmt, char * arg1)
|
||||
{
|
||||
return (boost::basic_format<char_type>(fmt) % arg1).str();
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
docstring bformat(docstring const & fmt, int arg1, int arg2)
|
||||
{
|
||||
return (boost::basic_format<char_type>(fmt) % arg1 % arg2).str();
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
docstring bformat(docstring const & fmt, docstring arg1, docstring arg2)
|
||||
{
|
||||
return (boost::basic_format<char_type>(fmt) % arg1 % arg2).str();
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
docstring bformat(docstring const & fmt, char const * arg1, docstring arg2)
|
||||
{
|
||||
return (boost::basic_format<char_type>(fmt) % arg1 % arg2).str();
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
docstring bformat(docstring const & fmt, docstring arg1, docstring arg2, docstring arg3)
|
||||
{
|
||||
return (boost::basic_format<char_type>(fmt) % arg1 % arg2 % arg3).str();
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
docstring bformat(docstring const & fmt,
|
||||
docstring arg1, docstring arg2, docstring arg3, docstring arg4)
|
||||
{
|
||||
return (boost::basic_format<char_type>(fmt) % arg1 % arg2 % arg3 % arg4).str();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
template<>
|
||||
docstring bformat(docstring const & fmt, int arg1)
|
||||
{
|
||||
@ -1083,8 +1113,5 @@ docstring bformat(docstring const & fmt,
|
||||
return subst(str, lyx::from_ascii("%%"), lyx::from_ascii("%"));
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
} // namespace support
|
||||
} // namespace lyx
|
||||
|
@ -1,25 +1,5 @@
|
||||
// -*- C++ -*-
|
||||
#include <config.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
#ifdef HAVE_SYS_STAT_H
|
||||
# include <sys/stat.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
# include <sys/types.h>
|
||||
#endif
|
||||
#include <time.h>
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
#ifndef _WIN32
|
||||
# include <sys/un.h>
|
||||
# include <sys/wait.h>
|
||||
# ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
#include <cerrno>
|
||||
@ -28,7 +8,6 @@
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <ctime>
|
||||
#include <deque>
|
||||
#include <fstream>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
@ -37,7 +16,6 @@
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <ostream>
|
||||
#include <queue>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
@ -14,11 +14,8 @@
|
||||
|
||||
#include "support/docstring.h"
|
||||
|
||||
#include <QChar>
|
||||
#include <QString>
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
namespace lyx {
|
||||
|
||||
/**
|
||||
@ -53,34 +50,6 @@ inline bool is_utf16(char_type c)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert a QChar into a UCS4 character.
|
||||
* This is a hack (it does only make sense for the common part of the UCS4
|
||||
* and UTF16 encodings) and should not be used.
|
||||
* This does only exist because of performance reasons (a real conversion
|
||||
* using iconv is too slow on windows).
|
||||
*/
|
||||
inline char_type qchar_to_ucs4(QChar const & qchar)
|
||||
{
|
||||
BOOST_ASSERT(is_utf16(static_cast<char_type>(qchar.unicode())));
|
||||
return static_cast<char_type>(qchar.unicode());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert a UCS4 character into a QChar.
|
||||
* This is a hack (it does only make sense for the common part of the UCS4
|
||||
* and UTF16 encodings) and should not be used.
|
||||
* This does only exist because of performance reasons (a real conversion
|
||||
* using iconv is too slow on windows).
|
||||
*/
|
||||
inline QChar const ucs4_to_qchar(char_type const ucs4)
|
||||
{
|
||||
BOOST_ASSERT(is_utf16(ucs4));
|
||||
return QChar(static_cast<unsigned short>(ucs4));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* toqstr - convert a UCS4 encoded docstring into a QString
|
||||
*
|
||||
|
@ -1,101 +0,0 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file textutils.cpp
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Georg Baum
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
// FIXME: I can think of a better name for this file ...
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "support/textutils.h"
|
||||
#include "support/qstring_helpers.h"
|
||||
|
||||
namespace lyx {
|
||||
|
||||
namespace {
|
||||
/// Maximum valid UCS4 code point
|
||||
char_type const ucs4_max = 0x10ffff;
|
||||
}
|
||||
|
||||
|
||||
bool isLetterChar(char_type c)
|
||||
{
|
||||
if (!is_utf16(c)) {
|
||||
if (c > ucs4_max)
|
||||
// outside the UCS4 range
|
||||
return false;
|
||||
// assume that all non-utf16 characters are letters
|
||||
return true;
|
||||
}
|
||||
return ucs4_to_qchar(c).isLetter();
|
||||
}
|
||||
|
||||
|
||||
bool isAlphaASCII(char_type c)
|
||||
{
|
||||
return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z');
|
||||
}
|
||||
|
||||
|
||||
bool isPrintable(char_type c)
|
||||
{
|
||||
if (!is_utf16(c)) {
|
||||
if (c > ucs4_max)
|
||||
// outside the UCS4 range
|
||||
return false;
|
||||
// assume that all non-utf16 characters are printable
|
||||
return true;
|
||||
}
|
||||
return ucs4_to_qchar(c).isPrint();
|
||||
}
|
||||
|
||||
|
||||
bool isPrintableNonspace(char_type c)
|
||||
{
|
||||
if (!is_utf16(c)) {
|
||||
if (c > ucs4_max)
|
||||
// outside the UCS4 range
|
||||
return false;
|
||||
// assume that all non-utf16 characters are printable and
|
||||
// no space
|
||||
return true;
|
||||
}
|
||||
QChar const qc = ucs4_to_qchar(c);
|
||||
return qc.isPrint() && !qc.isSpace();
|
||||
}
|
||||
|
||||
|
||||
bool isSpace(char_type c)
|
||||
{
|
||||
if (!is_utf16(c)) {
|
||||
// assume that no non-utf16 character is a space
|
||||
// c outside the UCS4 range is catched as well
|
||||
return false;
|
||||
}
|
||||
QChar const qc = ucs4_to_qchar(c);
|
||||
return qc.isSpace();
|
||||
}
|
||||
|
||||
|
||||
bool isDigit(char_type c)
|
||||
{
|
||||
if (!is_utf16(c))
|
||||
// assume that no non-utf16 character is a digit
|
||||
// c outside the UCS4 range is catched as well
|
||||
return false;
|
||||
return ucs4_to_qchar(c).isDigit();
|
||||
}
|
||||
|
||||
|
||||
bool isDigitASCII(char_type c)
|
||||
{
|
||||
return '0' <= c && c <= '9';
|
||||
}
|
||||
|
||||
} // namespace lyx
|
@ -1,10 +1,5 @@
|
||||
#include <config.h>
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/function.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/tuple/tuple.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
#include <exception>
|
||||
|
Loading…
Reference in New Issue
Block a user