diff --git a/po/POTFILES.in b/po/POTFILES.in index 17e2f1d40c..43f1bf43df 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -9,6 +9,7 @@ src/converter.C src/CutAndPaste.C src/debug.C src/exporter.C +src/ext_l10n.h src/figure_form.C src/figureForm.C src/FontLoader.C diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index ca6784f1ee..2ef0d98485 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -367,7 +367,9 @@ int BufferView::Pimpl::resizeCurrentBuffer() bv_->theLockingInset(the_locking_inset); } bv_->text->first = screen_->topCursorVisible(bv_->text); +#if 0 buffer_->resizeInsets(bv_); +#endif // this will scroll the screen such that the cursor becomes visible updateScrollbar(); redraw(); @@ -1554,7 +1556,8 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) case LFUN_PASTESELECTION: { bool asPara = false; - if (argument == "paragraph") asPara = true; + if (argument == "paragraph") + asPara = true; pasteClipboard(asPara); } break; diff --git a/src/ColorHandler.C b/src/ColorHandler.C index 82b71e8d56..54968146a1 100644 --- a/src/ColorHandler.C +++ b/src/ColorHandler.C @@ -108,7 +108,6 @@ GC LyXColorHandler::getGCForeground(LColor::color c) // the color closest to the one we want. Visual * vi = DefaultVisual(display, DefaultScreen(display)); - //XColor * cmap = new XColor[vi->map_entries]; boost::scoped_array cmap(new XColor[vi->map_entries]); for (int i = 0; i < vi->map_entries; ++i) { @@ -154,7 +153,6 @@ GC LyXColorHandler::getGCForeground(LColor::color c) << _("Pixel [") << closest_pixel << _("] is used.") << endl; val.foreground = cmap[closest_pixel].pixel; - //delete[] cmap; } val.function = GXcopy; diff --git a/src/FontInfo.C b/src/FontInfo.C index e7eb8117c0..3cb9af0911 100644 --- a/src/FontInfo.C +++ b/src/FontInfo.C @@ -9,24 +9,25 @@ * ====================================================== */ #include -#include // fabs() #ifdef __GNUG__ -#pragma implementation "FontInfo.h" +#pragma implementation #endif #include "FontInfo.h" #include "debug.h" #include "lyxrc.h" // lyxrc.use_scalable_fonts + #include "support/lstrings.h" #include "support/lyxlib.h" + #include "frontends/GUIRunTime.h" -using std::endl; +#include // abs() + +using std::endl; +using std::abs; -#ifndef CXX_GLOBAL_CSTD -using std::fabs; -#endif /// Load font close to this size string const FontInfo::getFontname(int size) @@ -44,8 +45,8 @@ string const FontInfo::getFontname(int size) lyxerr[Debug::FONT] << "Exact font match with\n" << strings[i] << endl; return strings[i]; - } else if (fabs(sizes[i] - size - 0.1) < error) { - error = fabs(sizes[i] - size - 0.1); + } else if (abs(sizes[i] - size - 0.1) < error) { + error = abs(sizes[i] - size - 0.1); closestind = i; } } @@ -98,7 +99,6 @@ string const FontInfo::resize(string const & font, int size) const /// Set new pattern void FontInfo::setPattern(string const & pat) { - release(); init(); pattern = pat; } @@ -125,11 +125,10 @@ void FontInfo::query() if (list == 0) { // No fonts matched scalable = false; - sizes = 0; + sizes.reset(); } else { - release(); - sizes = new int[matches]; - strings = new string[matches]; + sizes.reset(new int[matches]); + strings.reset(new string[matches]); // We have matches. Run them through for (int i = 0; i < matches; ++i) { @@ -153,24 +152,10 @@ void FontInfo::query() void FontInfo::init() { - sizes = 0; - strings = 0; + sizes.reset(); + strings.reset(); matches = 0; queried = false; scalable = false; scaleindex = -1; } - - -/// Release allocated stuff -void FontInfo::release() -{ - if (sizes) { - delete [] sizes; - sizes = 0; - } - if (strings) { - delete [] strings; - strings = 0; - } -} diff --git a/src/FontInfo.h b/src/FontInfo.h index 3bc79d9135..13e3470897 100644 --- a/src/FontInfo.h +++ b/src/FontInfo.h @@ -18,6 +18,8 @@ #include "LString.h" +#include + /** This class manages a font. The idea is to create a FontInfo object with a font name pattern with a wildcard at the size field. Then this object can host request for font- @@ -35,9 +37,6 @@ public: explicit FontInfo(string const & pat) : pattern(pat) { init(); } - /// Destructor - ~FontInfo() { release(); } - /// Does any font match our pattern? bool exist() { query(); @@ -51,7 +50,7 @@ public: } /// Get existing pattern - string const getPattern() const { return pattern; } + string const & getPattern() const { return pattern; } /// Set new pattern void setPattern(string const & pat); @@ -64,10 +63,10 @@ private: string pattern; /// Available size list - int * sizes; + boost::scoped_array sizes; /// Corresponding name list - string * strings; + boost::scoped_array strings; /// Number of matches int matches; @@ -84,9 +83,6 @@ private: /// Initialize empty record void init(); - /// Release allocated stuff - void release(); - /// Ask X11 about this font pattern void query(); diff --git a/src/WorkArea.C b/src/WorkArea.C index c3b0d5f0ab..f969ff3cf3 100644 --- a/src/WorkArea.C +++ b/src/WorkArea.C @@ -32,13 +32,10 @@ #include using std::endl; +using std::abs; FL_OBJECT * figinset_canvas; -// needed to make the c++ compiler find the correct version of abs. -// This is at least true for g++. -//using std::abs; - namespace { inline @@ -83,7 +80,7 @@ WorkArea::WorkArea(int xpos, int ypos, int width, int height) << width << 'x' << height << endl; // FL_OBJECT * obj; - int const bw = int(std::abs(float(fl_get_border_width()))); + int const bw = int(abs(fl_get_border_width())); // We really want to get rid of figinset_canvas. ::figinset_canvas = figinset_canvas = obj = @@ -205,7 +202,7 @@ void WorkArea::resize(int xpos, int ypos, int width, int height) { fl_freeze_all_forms(); - int const bw = int(std::abs(float(fl_get_border_width()))); + int const bw = int(abs(fl_get_border_width())); // a box fl_set_object_geometry(backgroundbox, xpos, ypos, width - 15, height); diff --git a/src/font.C b/src/font.C index c2cb085c08..17e589a6ba 100644 --- a/src/font.C +++ b/src/font.C @@ -14,14 +14,16 @@ #pragma implementation #endif -#include - #include "font.h" #include "FontLoader.h" #include "lyxrc.h" #include "encoding.h" #include "language.h" +#include + +#include + namespace { inline @@ -110,16 +112,13 @@ int lyxfont::width(char const * s, size_t n, LyXFont const & f) return n; if (lyxrc.font_norm_type == LyXRC::ISO_10646_1) { - XChar2b * xs = new XChar2b[n]; + boost::scoped_array xs(new XChar2b[n]); Encoding const * encoding = f.language()->encoding(); - //LyXFont const * font = &f; LyXFont font(f); if (f.isSymbolFont()) { #ifdef USE_UNICODE_FOR_SYMBOLS - //LyXFont font2 = f; font.setFamily(LyXFont::ROMAN_FAMILY); font.setShape(LyXFont::UP_SHAPE); - //font = &font2; #endif encoding = encodings.symbol_encoding(); } @@ -128,8 +127,7 @@ int lyxfont::width(char const * s, size_t n, LyXFont const & f) xs[i].byte1 = c >> 8; xs[i].byte2 = c & 0xff; } - int result = width(xs, n, font); - delete[] xs; + int result = width(xs.get(), n, font); return result; } diff --git a/src/gettext.C b/src/gettext.C index 506178db8c..d8b9b96bc6 100644 --- a/src/gettext.C +++ b/src/gettext.C @@ -16,6 +16,8 @@ #include "LString.h" +#include + #ifdef ENABLE_NLS # if HAVE_GETTEXT @@ -40,17 +42,17 @@ string const _(string const & str) { if (!str.empty()) { int const s = str.length(); - char * tmp = new char[s + 1]; - str.copy(tmp, s); + boost::scoped_array tmp(new char[s + 1]); + str.copy(tmp.get(), s); tmp[s] = '\0'; - string const ret(gettext(tmp)); - delete [] tmp; + string const ret(gettext(tmp.get())); return ret; } else { return string(); } } + void locale_init() { # ifdef HAVE_LC_MESSAGES @@ -60,6 +62,7 @@ void locale_init() setlocale(LC_NUMERIC, "C"); } + void gettext_init(string const & localedir) { bindtextdomain(PACKAGE, localedir.c_str()); @@ -74,6 +77,7 @@ void locale_init() setlocale(LC_NUMERIC, "C"); } + void gettext_init(string const &) { } diff --git a/src/lyx_main.C b/src/lyx_main.C index 9b738a9bc0..d95b6a9842 100644 --- a/src/lyx_main.C +++ b/src/lyx_main.C @@ -62,7 +62,7 @@ string user_lyxdir; // Default $HOME/.lyx // Should this be kept global? Asger says Yes. DebugStream lyxerr; -LastFiles * lastfiles; +boost::scoped_ptr lastfiles; // This is the global bufferlist object BufferList bufferlist; @@ -77,10 +77,6 @@ boost::scoped_ptr toplevel_keymap; LyX::LyX(int * argc, char * argv[]) { - // Prevent crash with --help - lyxGUI = 0; - lastfiles = 0; - // Here we need to parse the command line. At least // we need to parse for "-dbg" and "-help" bool gui = easyParse(argc, argv); @@ -92,7 +88,7 @@ LyX::LyX(int * argc, char * argv[]) // Make the GUI object, and let it take care of the // command line arguments that concerns it. lyxerr[Debug::INIT] << "Initializing LyXGUI..." << endl; - lyxGUI = new LyXGUI(this, argc, argv, gui); + lyxGUI.reset(new LyXGUI(this, argc, argv, gui)); lyxerr[Debug::INIT] << "Initializing LyXGUI...done" << endl; // Now the GUI and LyX have taken care of their arguments, so @@ -181,8 +177,6 @@ LyX::LyX(int * argc, char * argv[]) // A destructor is always necessary (asierra-970604) LyX::~LyX() { - delete lastfiles; - delete lyxGUI; } @@ -491,9 +485,9 @@ void LyX::init(bool gui) // load the lastfiles mini-database lyxerr[Debug::INIT] << "Reading lastfiles `" << lyxrc.lastfiles << "'..." << endl; - lastfiles = new LastFiles(lyxrc.lastfiles, - lyxrc.check_lastfiles, - lyxrc.num_lastfiles); + lastfiles.reset(new LastFiles(lyxrc.lastfiles, + lyxrc.check_lastfiles, + lyxrc.num_lastfiles)); // start up the lyxserver. (is this a bit early?) (Lgb) // 0.12 this will be way to early, we need the GUI to be initialized @@ -887,8 +881,8 @@ bool LyX::easyParse(int * argc, char * argv[]) } else if (arg == "-i" || arg == "--import") { if (i + 1 < *argc) { - string type(argv[i+1]); - string file(argv[i+2]); + string const type(argv[i+1]); + string const file(argv[i+2]); removeargs = 3; batch_command = "buffer-import " + type + " " + file; diff --git a/src/lyx_main.h b/src/lyx_main.h index fddfd674e0..523de58dd9 100644 --- a/src/lyx_main.h +++ b/src/lyx_main.h @@ -22,6 +22,8 @@ #include #include "LString.h" + +#include #include class LyXGUI; @@ -37,8 +39,9 @@ extern string user_lyxdir; /// extern string system_tempdir; /// -extern LastFiles * lastfiles; /* we should hopefully be able to move this - * inside the LyX class */ +extern boost::scoped_ptr lastfiles; +/* we should hopefully be able to move this + * inside the LyX class */ /** @@ -56,7 +59,7 @@ public: private: /// Should be a maximum of 1 LyXGUI. - LyXGUI * lyxGUI; + boost::scoped_ptr lyxGUI; /// does this user start lyx for the first time? bool first_start; /// diff --git a/src/vc-backend.C b/src/vc-backend.C index 2a9d69c559..a5fd7be2a5 100644 --- a/src/vc-backend.C +++ b/src/vc-backend.C @@ -4,20 +4,21 @@ #pragma implementation #endif -#include - #include "vc-backend.h" #include "debug.h" +#include "buffer.h" +#include "BufferView.h" +#include "LyXView.h" +#include "lyxfunc.h" + #include "support/FileInfo.h" #include "support/LRegex.h" #include "support/LSubstring.h" #include "support/path.h" #include "support/filetools.h" #include "support/lstrings.h" -#include "buffer.h" -#include "BufferView.h" -#include "LyXView.h" -#include "lyxfunc.h" + +#include using std::endl; using std::ifstream;