diff --git a/src/control/Control.cpp b/src/control/Control.cpp index 5f859bf2..03932dc8 100644 --- a/src/control/Control.cpp +++ b/src/control/Control.cpp @@ -53,8 +53,12 @@ namespace bf = boost::filesystem; #include #include +#include +using std::cout; +using std::cerr; +using std::endl; #include -using namespace std; +using std::vector; // TODO Check for error log on startup, also check for emergency save document! @@ -1332,9 +1336,7 @@ void Control::getDefaultPagesize(double& width, double& height) GtkPaperSize* s = (GtkPaperSize*) l->data; //it would be nice to make StringUtils method, but now I'm not in the mood - down there is basically compareIgnoreCase - using namespace bl; - using bl::collator; - if (use_facet>(std::locale()).compare(collator_base::secondary, + if (std::use_facet>(std::locale()).compare(bl::collator_base::secondary, paper, gtk_paper_size_get_display_name(s))) { size = s; diff --git a/src/control/LoadHandler.h b/src/control/LoadHandler.h index ffd38828..f40e24ed 100644 --- a/src/control/LoadHandler.h +++ b/src/control/LoadHandler.h @@ -21,7 +21,7 @@ #include #include -using namespace std; +using std::string; enum ParserPosition { diff --git a/src/control/RecentManager.cpp b/src/control/RecentManager.cpp index 8777d7e8..67638056 100644 --- a/src/control/RecentManager.cpp +++ b/src/control/RecentManager.cpp @@ -8,7 +8,8 @@ using boost::filesystem::path; #include -using namespace std; +using std::cout; +using std::endl; #define MIME "application/x-xoj" #define MIME_PDF "application/x-pdf" diff --git a/src/control/SaveHandler.cpp b/src/control/SaveHandler.cpp index 3936c135..1b840d3b 100644 --- a/src/control/SaveHandler.cpp +++ b/src/control/SaveHandler.cpp @@ -31,7 +31,8 @@ #include #include -using namespace std; +using std::cout; +using std::endl; // TODO LOW PRIO: remove all elements which are complete outside the pages // TODO LOW PRIO: remove 0 width line parts diff --git a/src/control/XournalMain.cpp b/src/control/XournalMain.cpp index 74ead03c..e6440395 100644 --- a/src/control/XournalMain.cpp +++ b/src/control/XournalMain.cpp @@ -20,8 +20,13 @@ namespace bf = boost::filesystem; #include +using std::string; #include -using namespace std; +using std::cout; +using std::cerr; +using std::endl; +#include +using std::vector; #ifdef ENABLE_PYTHON #include "plugin/python/PythonRunner.h" diff --git a/src/control/jobs/Scheduler.cpp b/src/control/jobs/Scheduler.cpp index 71e2a158..02afd582 100644 --- a/src/control/jobs/Scheduler.cpp +++ b/src/control/jobs/Scheduler.cpp @@ -6,8 +6,7 @@ #ifdef SHEDULER_DEBUG #include #include -using namespace std; -#define SDEBUG(msg) cout << bl::format(CONCAT("Scheduler::", msg, "\n")) +#define SDEBUG(msg) std::cout << bl::format(CONCAT("Scheduler::", msg, "\n")) #else //kind of workaround class no_debug_format diff --git a/src/control/settings/MetadataManager.cpp b/src/control/settings/MetadataManager.cpp index ef206ba4..aabcb30b 100644 --- a/src/control/settings/MetadataManager.cpp +++ b/src/control/settings/MetadataManager.cpp @@ -3,8 +3,12 @@ #include "cfg.h" #include "util/Util.h" +#include +using std::exception; #include -using namespace std; +using std::cout; +using std::endl; +using std::pair; #include namespace bf = boost::filesystem; @@ -164,7 +168,7 @@ void MetadataManager::cleanupMetadata() loadConfigFile(); - vector> elements; + std::vector> elements; for (bp::ptree::value_type p : *config) { @@ -172,8 +176,8 @@ void MetadataManager::cleanupMetadata() { try { - elements.push_back(pair(p.first, - config->get_child(getINIpath(p.first)).get("atime"))); + elements.push_back(std::pair(p.first, + config->get_child(getINIpath(p.first)).get("atime"))); } catch (exception& e) { @@ -183,7 +187,7 @@ void MetadataManager::cleanupMetadata() } std::sort(elements.begin(), elements.end(), - [](const pair &left, const pair &right) { + [](const std::pair &left, const std::pair &right) { return left.second >= right.second; }); @@ -193,7 +197,7 @@ void MetadataManager::cleanupMetadata() } bp::ptree* tmpTree = new bp::ptree(); - for (pair p : elements) + for (std::pair p : elements) { tmpTree->add_child(getINIpath(p.first), config->get_child(getINIpath(p.first))); } diff --git a/src/control/shaperecognizer/ShapeRecognizerConfig.h b/src/control/shaperecognizer/ShapeRecognizerConfig.h index 44a9d75d..b1edad46 100644 --- a/src/control/shaperecognizer/ShapeRecognizerConfig.h +++ b/src/control/shaperecognizer/ShapeRecognizerConfig.h @@ -36,8 +36,7 @@ #ifdef RECOGNIZER_DEBUG #include #include -using namespace std; -#define RDEBUG(msg) cout << bl::format(CONCAT("ShapeReco::", msg, "\n")) +#define RDEBUG(msg) std::cout << bl::format(CONCAT("ShapeReco::", msg, "\n")) #else class no_debug_format { diff --git a/src/control/tools/EditSelection.cpp b/src/control/tools/EditSelection.cpp index 9eedb0ed..356d29c1 100644 --- a/src/control/tools/EditSelection.cpp +++ b/src/control/tools/EditSelection.cpp @@ -22,7 +22,8 @@ #include #include -using namespace std; +using std::cout; +using std::endl; EditSelection::EditSelection(UndoRedoHandler* undo, PageRef page, PageView* view) { diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index b1565071..58c53be5 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -20,11 +20,12 @@ #include #include -using namespace std; +using std::cout; +using std::endl; MainWindow::MainWindow(GladeSearchpath* gladeSearchPath, Control* control) : - GladeGui(gladeSearchPath, "main.glade", "mainWindow") + GladeGui(gladeSearchPath, "main.glade", "mainWindow") { XOJ_INIT_TYPE(MainWindow); diff --git a/src/gui/dialog/LatexGlade.cpp b/src/gui/dialog/LatexGlade.cpp index d2887951..ec721ff2 100644 --- a/src/gui/dialog/LatexGlade.cpp +++ b/src/gui/dialog/LatexGlade.cpp @@ -6,7 +6,8 @@ #include "model/TexImage.h" #include -using namespace std; +using std::cout; +using std::endl; LatexGlade::LatexGlade(GladeSearchpath* gladeSearchPath) : GladeGui(gladeSearchPath, "texdialog.glade", "texDialog") { diff --git a/src/gui/dialog/toolbarCustomize/ToolbarAdapter.h b/src/gui/dialog/toolbarCustomize/ToolbarAdapter.h index 0356db8f..193bf172 100644 --- a/src/gui/dialog/toolbarCustomize/ToolbarAdapter.h +++ b/src/gui/dialog/toolbarCustomize/ToolbarAdapter.h @@ -25,7 +25,8 @@ #include "ToolItemDragCurrentData.h" #include -using namespace std; +using std::cout; +using std::endl; class ToolbarAdapter { diff --git a/src/gui/toolbarMenubar/model/ToolbarColorNames.cpp b/src/gui/toolbarMenubar/model/ToolbarColorNames.cpp index 344aec07..9f543924 100644 --- a/src/gui/toolbarMenubar/model/ToolbarColorNames.cpp +++ b/src/gui/toolbarMenubar/model/ToolbarColorNames.cpp @@ -8,7 +8,8 @@ #include #include #include -using namespace std; +using std::cout; +using std::endl; ToolbarColorNames::ToolbarColorNames() { diff --git a/src/gui/toolbarMenubar/model/ToolbarData.cpp b/src/gui/toolbarMenubar/model/ToolbarData.cpp index 2e894d0c..e4b2f837 100644 --- a/src/gui/toolbarMenubar/model/ToolbarData.cpp +++ b/src/gui/toolbarMenubar/model/ToolbarData.cpp @@ -4,7 +4,8 @@ #include #include -using namespace std; +using std::cout; +using std::endl; ToolbarData::ToolbarData(bool predefined) { diff --git a/src/gui/widgets/XournalWidget.cpp b/src/gui/widgets/XournalWidget.cpp index 0595dc31..dd2b8ebb 100644 --- a/src/gui/widgets/XournalWidget.cpp +++ b/src/gui/widgets/XournalWidget.cpp @@ -22,7 +22,8 @@ #include #include -using namespace std; +using std::cout; +using std::endl; static void gtk_xournal_class_init(GtkXournalClass* klass); static void gtk_xournal_init(GtkXournal* xournal); diff --git a/src/model/Document.cpp b/src/model/Document.cpp index eb5dc886..a8039898 100644 --- a/src/model/Document.cpp +++ b/src/model/Document.cpp @@ -10,8 +10,9 @@ #include #include - -using namespace std; +#include +using std::cout; +using std::endl; Document::Document(DocumentHandler* handler) { diff --git a/src/model/Layer.cpp b/src/model/Layer.cpp index 8776bcf5..c5d42932 100644 --- a/src/model/Layer.cpp +++ b/src/model/Layer.cpp @@ -2,7 +2,9 @@ #include -using namespace std; +#include +using std::cout; +using std::endl; Layer::Layer() { diff --git a/src/model/Stroke.cpp b/src/model/Stroke.cpp index 964fb1f0..5d971520 100644 --- a/src/model/Stroke.cpp +++ b/src/model/Stroke.cpp @@ -8,7 +8,8 @@ #include #include #include -using namespace std; +using std::cout; +using std::endl; Stroke::Stroke() : Element(ELEMENT_STROKE) { diff --git a/src/pdf/popplerdirect/PdfObjectWriter.cpp b/src/pdf/popplerdirect/PdfObjectWriter.cpp index 71c8f252..9fb8cff9 100644 --- a/src/pdf/popplerdirect/PdfObjectWriter.cpp +++ b/src/pdf/popplerdirect/PdfObjectWriter.cpp @@ -4,7 +4,8 @@ #include "UpdateRefKey.h" #include -using namespace std; +using std::cout; +using std::endl; PdfObjectWriter::PdfObjectWriter(PdfWriter* writer, PdfXRef* xref) { diff --git a/src/pdf/popplerdirect/PdfWriter.cpp b/src/pdf/popplerdirect/PdfWriter.cpp index 7f1aa716..e864f7c3 100644 --- a/src/pdf/popplerdirect/PdfWriter.cpp +++ b/src/pdf/popplerdirect/PdfWriter.cpp @@ -4,7 +4,8 @@ #include #include -using namespace std; +using std::cout; +using std::endl; bool PdfWriter::compressPdfOutput = true; diff --git a/src/test/control/LoadHandlerTest.cpp b/src/test/control/LoadHandlerTest.cpp index fafc6764..ad296b33 100644 --- a/src/test/control/LoadHandlerTest.cpp +++ b/src/test/control/LoadHandlerTest.cpp @@ -9,14 +9,13 @@ * @license GNU GPLv2 or later */ -#include +#include "control/LoadHandler.h" -#include "../../control/LoadHandler.h" +#include #include -#include "stdlib.h" - -using namespace std; +using std::clock; +#include class LoadHandlerTest: public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(LoadHandlerTest); diff --git a/src/util/CrashHandler.cpp b/src/util/CrashHandler.cpp index 2f9606e4..c44d3e23 100644 --- a/src/util/CrashHandler.cpp +++ b/src/util/CrashHandler.cpp @@ -13,10 +13,12 @@ #include #include +using std::cerr; +using std::endl; #include +using std::ofstream; #include #include -using namespace std; static bool alreadyCrashed = false; static Document* document = NULL; @@ -65,17 +67,17 @@ static void emergencySave(); * you can't do with it. So please don't touch anythink down there without * previous consultation. */ -class streamsplit : public stringstream +class streamsplit : public std::stringstream { public: - streamsplit(ofstream* file) + streamsplit(std::ofstream* file) { f = file; } template - ostream& operator<<(T const & rhs) + std::ostream& operator<<(T const & rhs) { *f << rhs; cerr << rhs; @@ -83,7 +85,7 @@ public: } private: - ofstream* f; + std::ofstream* f; }; /** diff --git a/src/util/GzHelper.cpp b/src/util/GzHelper.cpp index 85933d71..8b20d17b 100644 --- a/src/util/GzHelper.cpp +++ b/src/util/GzHelper.cpp @@ -4,10 +4,10 @@ #include #include +namespace bio = boost::iostreams; -#include #include -using namespace std; +using std::stringstream; GzHelper::GzHelper() { } @@ -15,25 +15,28 @@ GzHelper::~GzHelper() { } string GzHelper::gzcompress(const string& str, const bio::zlib_params& params) { - std::stringstream compressed; - std::stringstream decompressed; + stringstream decompressed; decompressed << str; - boost::iostreams::filtering_istreambuf out; + bio::filtering_istreambuf out; out.push(bio::zlib_compressor(params)); out.push(decompressed); + + stringstream compressed; bio::copy(out, compressed); return compressed.str(); } string GzHelper::gzuncompress(const string& str) { - std::stringstream compressed; - std::stringstream decompressed; + stringstream compressed; compressed << str; - bio::filtering_istreambuf in; + + bio::filtering_istreambuf in; in.push(bio::zlib_decompressor()); in.push(compressed); + + stringstream decompressed; bio::copy(in, decompressed); return decompressed.str(); } diff --git a/src/util/LatexAction.cpp b/src/util/LatexAction.cpp index c9df6374..70539480 100644 --- a/src/util/LatexAction.cpp +++ b/src/util/LatexAction.cpp @@ -15,7 +15,9 @@ #include #include -using namespace std; +using std::cout; +using std::cerr; +using std::endl; LatexAction::LatexAction(string myTex, double tArea) { diff --git a/src/util/Stacktrace.cpp b/src/util/Stacktrace.cpp index f5096899..ed387cb6 100644 --- a/src/util/Stacktrace.cpp +++ b/src/util/Stacktrace.cpp @@ -1,6 +1,8 @@ #include "Stacktrace.h" #include +#include +using std::endl; /** * This code uses addr2line @@ -19,9 +21,7 @@ void Stacktrace::setExename(string name) exeName = name; } -using namespace std; - -void Stacktrace::printStracktrace(ostream& stream) +void Stacktrace::printStracktrace(std::ostream& stream) { void* trace[32]; char** messages = (char**) NULL; diff --git a/src/util/Util.cpp b/src/util/Util.cpp index d67d5449..6d6b88db 100644 --- a/src/util/Util.cpp +++ b/src/util/Util.cpp @@ -10,7 +10,8 @@ #include #include -using namespace std; +using std::cout; +using std::endl; GdkColor Util::intToGdkColor(int c) { diff --git a/src/util/XournalType.cpp b/src/util/XournalType.cpp index fc368563..84a489d9 100644 --- a/src/util/XournalType.cpp +++ b/src/util/XournalType.cpp @@ -6,7 +6,8 @@ #include #include -using namespace std; +using std::cout; +using std::endl; #ifdef XOJ_MEMORY_CHECK_ENABLED diff --git a/src/view/DocumentView.cpp b/src/view/DocumentView.cpp index 850c7061..bfd3200c 100644 --- a/src/view/DocumentView.cpp +++ b/src/view/DocumentView.cpp @@ -18,7 +18,8 @@ #ifdef SHOW_REPAINT_BOUNDS #include -using namespace std; +using std::cout; +using std::endl; #endif DocumentView::DocumentView() @@ -279,8 +280,7 @@ void DocumentView::drawLayer(cairo_t* cr, Layer* l) gdk_threads_enter(); cairo_set_source_rgb(cr, 0, 1, 0); cairo_set_line_width(cr, 1); - cairo_rectangle(cr, e->getX(), e->getY(), e->getElementWidth(), - e->getElementHeight()); + cairo_rectangle(cr, e->getX(), e->getY(), e->getElementWidth(), e->getElementHeight()); cairo_stroke(cr); gdk_threads_leave(); #endif // SHOW_ELEMENT_BOUNDS @@ -295,12 +295,12 @@ void DocumentView::drawLayer(cairo_t* cr, Layer* l) drawed++; #endif //SHOW_REPAINT_BOUNDS } +#ifdef SHOW_REPAINT_BOUNDS else { -#ifdef SHOW_REPAINT_BOUNDS notDrawed++; -#endif //SHOW_REPAINT_BOUNDS } +#endif //SHOW_REPAINT_BOUNDS } else