Merge pull request #572 from andreasb242/windows-build

Windows build
presentation
andreasb242 7 years ago committed by GitHub
commit 470188207e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      src/control/XournalMain.cpp
  2. 11
      src/control/settings/MetadataManager.cpp
  3. 4
      src/gui/sidebar/previews/layer/SidebarPreviewLayerEntry.h
  4. 7
      src/gui/sidebar/previews/layer/SidebarPreviewLayers.cpp
  5. 48
      src/util/PlaceholderString.cpp
  6. 3
      src/util/PlaceholderString.h
  7. 5
      src/util/i18n.h

@ -46,7 +46,6 @@ XournalMain::~XournalMain()
XOJ_RELEASE_TYPE(XournalMain);
}
// it HAS to be done – otherwise such things like boost::algorithm::to_lower wont work, throwing casting exceptions
void XournalMain::initLocalisation()
{
XOJ_CHECK_TYPE(XournalMain);
@ -62,7 +61,10 @@ void XournalMain::initLocalisation()
textdomain(GETTEXT_PACKAGE);
#endif //ENABLE_NLS
// Not working on Windows! Working on Linux, but not sure if it's needed
#ifndef WIN32
std::locale::global(std::locale("")); // "" - system default locale
#endif
std::cout.imbue(std::locale());
}

@ -172,7 +172,16 @@ MetadataEntry MetadataManager::loadMetadataFile(string path, string file)
// Not valid
return entry;
}
entry.page = std::stoi(line.substr(5));
try
{
entry.page = std::stoi(line.substr(5));
}
catch (const std::exception& e)
{
// Return invalid entry
return entry;
}
if (!getline(infile, line))
{

@ -24,13 +24,13 @@ public:
public:
/**
* @return What should be renderered
* @return What should be rendered
* @override
*/
virtual PreviewRenderType getRenderType();
/**
* @return The layer to be rendererd
* @return The layer to be rendered
*/
int getLayer();

@ -8,10 +8,10 @@
#include <i18n.h>
SidebarPreviewLayers::SidebarPreviewLayers(Control* control, GladeGui* gui, SidebarToolbar* toolbar)
: SidebarPreviewBase(control, gui, toolbar)
: SidebarPreviewBase(control, gui, toolbar),
displayedPage(0)
{
XOJ_INIT_TYPE(SidebarPreviewLayers);
displayedPage = 0;
}
SidebarPreviewLayers::~SidebarPreviewLayers()
@ -46,12 +46,10 @@ void SidebarPreviewLayers::updatePreviews()
this->previews.clear();
Document* doc = this->getControl()->getDocument();
// doc->lock();
int len = doc->getPageCount();
if (displayedPage < 0 || displayedPage >= len)
{
// doc->unlock();
return;
}
@ -72,7 +70,6 @@ void SidebarPreviewLayers::updatePreviews()
gtk_layout_put(GTK_LAYOUT(this->iconViewPreview), p->getWidget(), 0, 0);
layout();
// doc->unlock();
}
void SidebarPreviewLayers::pageSelected(int page)

@ -1,5 +1,7 @@
#include "PlaceholderString.h"
#include <glib.h>
/**
* Base class for Formatting
*/
@ -39,28 +41,7 @@ private:
*/
class PlaceholderElementInt : public PlaceholderElement{
public:
PlaceholderElementInt(int value)
: value(value)
{
}
public:
string format(string format)
{
return std::to_string(value);
}
private:
int value;
};
/**
* Format uint64_t
*/
class PlaceholderElementUint64_t : public PlaceholderElement{
public:
PlaceholderElementUint64_t(uint64_t value)
PlaceholderElementInt(int64_t value)
: value(value)
{
}
@ -72,11 +53,9 @@ public:
}
private:
uint64_t value;
int64_t value;
};
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
@ -96,13 +75,7 @@ PlaceholderString::~PlaceholderString()
data.clear();
}
PlaceholderString& PlaceholderString::operator%(uint64_t value)
{
data.push_back(new PlaceholderElementUint64_t(value));
return *this;
}
PlaceholderString& PlaceholderString::operator%(int value)
PlaceholderString& PlaceholderString::operator%(int64_t value)
{
data.push_back(new PlaceholderElementInt(value));
return *this;
@ -125,7 +98,16 @@ string PlaceholderString::formatPart(string format)
format = format.substr(0, comma);
}
int index = std::stoi(format);
int index;
try
{
index = std::stoi(format);
}
catch (const std::exception& e)
{
g_error("Could not parse «%s» as int, error: %s", format.c_str(), e.what());
return "{?}";
}
// Placeholder index starting at 1, vector at 0
index--;

@ -30,8 +30,7 @@ public:
// Placeholder methods
public:
PlaceholderString& operator%(uint64_t value);
PlaceholderString& operator%(int value);
PlaceholderString& operator%(int64_t value);
PlaceholderString& operator%(string value);
private:

@ -14,6 +14,7 @@
#include "PlaceholderString.h"
#include <libintl.h>
#undef snprintf
#define _(msg) gettext(msg)
#define C_(context, msg) g_dpgettext (NULL, context "\004" msg, strlen(msg) + 1)
@ -34,7 +35,7 @@
/* Some helper macros */
// boost::locale::format → std::string
// PlaceholderString → std::string
#define FS(format) (format).str()
// boost::locale::format → char*
// PlaceholderString → const char*
#define FC(format) FS(format).c_str()

Loading…
Cancel
Save