diff --git a/builds/360/360/latest.zip b/builds/360/360/latest.zip index cd02e077..0b9de383 100644 Binary files a/builds/360/360/latest.zip and b/builds/360/360/latest.zip differ diff --git a/builds/515/pro4/latest.zip b/builds/515/pro4/latest.zip index 01b1f0ee..5a9dcc65 100644 Binary files a/builds/515/pro4/latest.zip and b/builds/515/pro4/latest.zip differ diff --git a/builds/515/pro5/latest.zip b/builds/515/pro5/latest.zip index 3a884add..b284e9b5 100644 Binary files a/builds/515/pro5/latest.zip and b/builds/515/pro5/latest.zip differ diff --git a/builds/602/pro2/latest.zip b/builds/602/pro2/latest.zip index b26d9569..8ae6ee3f 100644 Binary files a/builds/602/pro2/latest.zip and b/builds/602/pro2/latest.zip differ diff --git a/builds/626/pro4/latest.zip b/builds/626/pro4/latest.zip index fb9123a7..2d87b015 100644 Binary files a/builds/626/pro4/latest.zip and b/builds/626/pro4/latest.zip differ diff --git a/builds/626/pro5/latest.zip b/builds/626/pro5/latest.zip index 8b151a95..cd9ae14d 100644 Binary files a/builds/626/pro5/latest.zip and b/builds/626/pro5/latest.zip differ diff --git a/builds/current.version b/builds/current.version index c4599c3f..c35a4b71 100644 --- a/builds/current.version +++ b/builds/current.version @@ -1 +1 @@ -0.0.6-17-31 \ No newline at end of file +0.0.6-17-32 \ No newline at end of file diff --git a/cr3gui/src/cr3pocketbook.cpp b/cr3gui/src/cr3pocketbook.cpp index d354198c..f12fa5ac 100644 --- a/cr3gui/src/cr3pocketbook.cpp +++ b/cr3gui/src/cr3pocketbook.cpp @@ -941,6 +941,8 @@ class CRPocketBookQuickMenuWindow : public CRPocketBookInkViewWindow } virtual void showWindow() { + CRLog::trace("CRPocketBookQuickMenuWindow::showWindow()"); + #if defined(POCKETBOOK_PRO) && !defined(POCKETBOOK_PRO_PRO2) // Touch menu @@ -955,15 +957,18 @@ class CRPocketBookQuickMenuWindow : public CRPocketBookInkViewWindow #if defined(POCKETBOOK_PRO) && !defined(POCKETBOOK_PRO_PRO2) virtual bool onTouch( int x, int y, CRGUITouchEventType evType ) { + CRLog::trace("CRPocketBookQuickMenuWindow::onTouch(%d, %d, ?)", x, y); // PRESS if( evType == CRTOUCH_DOWN ) { + CRLog::trace("CRPocketBookQuickMenuWindow::onTouch(): CRTOUCH_DOWN"); touchDown.x = x; touchDown.y = y; // BOTTOM Page Bar if( y >= bottomY + (int)(bottomH/2) && y < bottomY+bottomH ) { + CRLog::trace("CRPocketBookQuickMenuWindow::onTouch(): bottom page bar"); draggingPage = true; TM_lastDragPage = -1; } @@ -974,18 +979,22 @@ class CRPocketBookQuickMenuWindow : public CRPocketBookInkViewWindow // DRAG else if( evType == CRTOUCH_MOVE ) { + CRLog::trace("CRPocketBookQuickMenuWindow::onTouch(): CRTOUCH_MOVE"); // BOTTOM if( draggingPage ) { + CRLog::trace("CRPocketBookQuickMenuWindow::onTouch(): draggingPage"); DrawBottom(true, -1, x); } } // RELEASE else if( evType == CRTOUCH_UP ) { + CRLog::trace("CRPocketBookQuickMenuWindow::onTouch(): CRTOUCH_UP"); // TOP if( max(touchDown.y, y) <= icon_height ) { + CRLog::trace("CRPocketBookQuickMenuWindow::onTouch(): TOP"); // Match tapped icon int position = icon_space; @@ -1006,6 +1015,7 @@ class CRPocketBookQuickMenuWindow : public CRPocketBookInkViewWindow // Dragged page bar if( draggingPage ) { + CRLog::trace("CRPocketBookQuickMenuWindow::onTouch(): Dragged page bar"); if( TM_lastDragPage == -1 ) DrawBottom(true, -1, x); @@ -1013,6 +1023,7 @@ class CRPocketBookQuickMenuWindow : public CRPocketBookInkViewWindow draggingPage = false; if( TM_lastDragPage != main_win->getDocView()->getCurPage() ) { + CRLog::trace("CRPocketBookQuickMenuWindow::onTouch(): go to page %d", TM_lastDragPage); SelfClose(); pageSelector(TM_lastDragPage); return true; @@ -1022,13 +1033,15 @@ class CRPocketBookQuickMenuWindow : public CRPocketBookInkViewWindow // Go to page (progress text) if( y >= bottomY && y < bottomY+(int)(bottomH/2) ) { + CRLog::trace("CRPocketBookQuickMenuWindow::onTouch(): Bottom"); if( x >= textX-20 && x <= textX+textW+20 ) { + CRLog::trace("CRPocketBookQuickMenuWindow::onTouch(): progress text"); lString16 pageTmp = lString16::itoa(TM_lastDragPage); strcpy( key_buffer, UnicodeToUtf8(pageTmp).c_str() ); SelfClose(); + CRLog::trace("CRPocketBookQuickMenuWindow::onTouch(): OpenKeyboard(..., KBD_NUMERIC)"); OpenKeyboard(const_cast("@Page"), key_buffer, KEY_BUFFER_LEN, KBD_NUMERIC, goToPageKeyboardHandler); - // OpenKeyboard(const_cast("@Page"), key_buffer, KEY_BUFFER_LEN, 0, goToPageKeyboardHandler); return true; } return true; @@ -1043,23 +1056,32 @@ class CRPocketBookQuickMenuWindow : public CRPocketBookInkViewWindow } virtual void IconTapped(int iconKey, int position) { + CRLog::trace("CRPocketBookQuickMenuWindow::IconTapped(%d, %d)", iconKey, position); // Image name lString16 path = lString16("icon_") + lString16(touchMenuIcons[iconKey]) + lString16("_tap.png"); + CRLog::trace("CRPocketBookQuickMenuWindow::IconTapped(): [%d] %s", iconKey, UnicodeToUtf8(path).c_str()); // Get image LVImageSourceRef img = CRPocketBookWindowManager::instance->getSkin()->getImage(path); - ibitmap* bmp = LVImageSourceRef_to_ibitmab(img); - // Draw - DrawBitmap(position, 0, bmp); + if( !img.isNull() ) { + + // Convert + ibitmap* bmp = LVImageSourceRef_to_ibitmab(img); + + // Draw + DrawBitmap(position, 0, bmp); - // Free memory - free(bmp); + // Free memory + free(bmp); - // Highlight tapped icon - // InvertAreaBW(position, 0, icon_width, icon_height); - PartialUpdateBW(position, 0, icon_width, icon_height); + // Highlight tapped icon + PartialUpdateBW(position, 0, icon_width, icon_height); + } + else { + CRLog::trace("CRPocketBookQuickMenuWindow::IconTapped(): NOT FOUND: [%d] %s", iconKey, UnicodeToUtf8(path).c_str()); + } // Close current window SelfClose(); @@ -1076,6 +1098,7 @@ class CRPocketBookQuickMenuWindow : public CRPocketBookInkViewWindow } virtual void DrawTop(bool updateScreen) { + CRLog::trace("CRPocketBookQuickMenuWindow::DrawTop(%d)", updateScreen?1:0); // Draw top background FillArea(0, 0, ScreenWidth(), icon_height+2, 0x00FFFFFF); @@ -1087,27 +1110,38 @@ class CRPocketBookQuickMenuWindow : public CRPocketBookInkViewWindow // Image name lString16 path = lString16("icon_") + lString16(touchMenuIcons[i]) + lString16(".png"); + CRLog::trace("CRPocketBookQuickMenuWindow::DrawTop(): [%d] %s", i, UnicodeToUtf8(path).c_str()); // Get image LVImageSourceRef img = CRPocketBookWindowManager::instance->getSkin()->getImage(path); - ibitmap* bmp = LVImageSourceRef_to_ibitmab(img); - // Draw - DrawBitmap(position, 0, bmp); + if( !img.isNull() ) { + + // Convert + ibitmap* bmp = LVImageSourceRef_to_ibitmab(img); - // Free memory - free(bmp); + // Draw + DrawBitmap(position, 0, bmp); + + // Free memory + free(bmp); + } + else { + CRLog::trace("CRPocketBookQuickMenuWindow::DrawTop(): NOT FOUND: [%d] %s", i, UnicodeToUtf8(path).c_str()); + } // Increase position position += icon_width + icon_space; } if( updateScreen ) { + CRLog::trace("CRPocketBookQuickMenuWindow::DrawTop(): PartialUpdate(0, 0, %d, %d);", ScreenWidth(), icon_height+1); PartialUpdate(0, 0, ScreenWidth(), icon_height+1); } } virtual void DrawBottom(bool updateScreen, int page, int px) { + CRLog::trace("CRPocketBookQuickMenuWindow::DrawBottom(%d, %d, %d)", updateScreen?1:0, page, px); int drawPosition; int pageCount; @@ -1165,31 +1199,43 @@ class CRPocketBookQuickMenuWindow : public CRPocketBookInkViewWindow DrawString( textX, textY, UnicodeToUtf8(progress).c_str() ); if( updateScreen ) { - if( dragging ) + if( dragging ) { + CRLog::trace("CRPocketBookQuickMenuWindow::DrawBottom(): PartialUpdateBW(0, %d, %d, %d);", + bottomY, ScreenWidth(), bottomH); PartialUpdateBW(0, bottomY, ScreenWidth(), bottomH); - else + } + else { + CRLog::trace("CRPocketBookQuickMenuWindow::DrawBottom(): PartialUpdate(0, %d, %d, %d);", + bottomY, ScreenWidth(), PanelHeight()+bottomH); PartialUpdate(0, bottomY, ScreenWidth(), PanelHeight()+bottomH); + } } } virtual void OpenTouchMenu() { + CRLog::trace("CRPocketBookQuickMenuWindow::OpenTouchMenu()"); isTouchMenuVisible = true; TM_lastDragPage = -1; - // Activate panel + + // Activate system panel + CRLog::trace("CRPocketBookQuickMenuWindow::OpenTouchMenu(): Activate system panel"); showSystemPanel(false); // Offset the background + CRLog::trace("CRPocketBookQuickMenuWindow::OpenTouchMenu(): Offset the background"); ibitmap * bkg = BitmapFromScreen(0, PanelHeight(), ScreenWidth(), ScreenHeight()-PanelHeight()); DrawBitmap(0, 0, bkg); free(bkg); // Draw side lines + CRLog::trace("CRPocketBookQuickMenuWindow::OpenTouchMenu(): Draw side lines"); FillArea(0, 0, 1, ScreenHeight()-PanelHeight(), 0x00000000); FillArea(ScreenWidth()-1, 0, 1, ScreenHeight()-PanelHeight(), 0x00000000); // Set class vars + CRLog::trace("CRPocketBookQuickMenuWindow::OpenTouchMenu(): Set class vars"); icon_width = 75; icon_height = 75; icon_space = (ScreenWidth() - icon_width * TM_NB_ICONS) / (TM_NB_ICONS + 1); @@ -1201,15 +1247,21 @@ class CRPocketBookQuickMenuWindow : public CRPocketBookInkViewWindow barX1 = (int)(ScreenWidth()*0.05); barX2 = barX1 + barW; barY = bottomY + bottomH - (int)(bottomH/4); - textY = bottomY+20; + textY = bottomY+33; // Draw + CRLog::trace("CRPocketBookQuickMenuWindow::OpenTouchMenu(): Draw"); DrawTop(false); DrawBottom(false, -1, -1); + + // Update screen + CRLog::trace("CRPocketBookQuickMenuWindow::OpenTouchMenu(): PartialUpdate(0, 0, %d);", + ScreenWidth(), ScreenHeight()); PartialUpdate(0, 0, ScreenWidth(), ScreenHeight()); } virtual bool TouchMenuCanBeUsed() { + CRLog::trace("CRPocketBookQuickMenuWindow::TouchMenuCanBeUsed()"); return pbSkinFileName == lString16("pb626fw5.cr3skin") && CRPocketBookScreen::instance->isTouchSupported() && /*touch device*/ @@ -1217,6 +1269,7 @@ class CRPocketBookQuickMenuWindow : public CRPocketBookInkViewWindow } virtual void SelfClose() { + CRLog::trace("CRPocketBookQuickMenuWindow::SelfClose()"); isTouchMenuVisible = false; _wm->closeWindow( this ); hideSystemPanel(false); @@ -4955,8 +5008,9 @@ int main(int argc, char **argv) forcePartialUpdates = false; useDeveloperFeatures = access( PB_DEV_MARKER, F_OK ) != -1; OpenScreen(); - if (argc < 2) { - Message(ICON_WARNING, const_cast("CoolReader"), const_cast("@Cant_open_file"), 2000); + if (argc < 2 || strlen(argv[1]) == 0 ) { + Message(ICON_WARNING, const_cast("CoolReader"), const_cast("No book to open!"), 2000); + printf("No book to open!\n"); return 1; } if (!InitDoc(argv[0], argv[1])) { diff --git a/cr3gui/src/cr3pocketbook.h b/cr3gui/src/cr3pocketbook.h index 7aa3111e..dd06b378 100644 --- a/cr3gui/src/cr3pocketbook.h +++ b/cr3gui/src/cr3pocketbook.h @@ -75,8 +75,8 @@ enum CRPbCommands { #define PB_CR3_CACHE_SIZE (0x100000 * 64) -#define CR_PB_VERSION "0.0.6-17-31" -#define CR_PB_BUILD_DATE "2015-07-31" +#define CR_PB_VERSION "0.0.6-17-32" +#define CR_PB_BUILD_DATE "2015-08-06" #define PB_ROTATE_MODE_360 0 #define PB_ROTATE_MODE_180 1 diff --git a/crengine/include/crconcurrent.h b/crengine/include/crconcurrent.h index f79ee2c5..580642c8 100644 --- a/crengine/include/crconcurrent.h +++ b/crengine/include/crconcurrent.h @@ -7,6 +7,13 @@ #include "lvref.h" #include "lvqueue.h" + +enum { + CR_THREAD_PRIORITY_LOW, + CR_THREAD_PRIORITY_NORMAL, + CR_THREAD_PRIORITY_HIGH, +}; + class CRConcurrencyProvider { public: virtual ~CRConcurrencyProvider() {} @@ -18,6 +25,9 @@ class CRConcurrencyProvider { virtual void executeGui(CRRunnable * task, int delayMillis) = 0; /// sleep current thread virtual void sleepMs(int durationMs) = 0; + virtual void setThreadPriority(int p) { + CR_UNUSED(p); + } }; extern CRConcurrencyProvider * concurrencyProvider; diff --git a/crengine/include/hyphman.h b/crengine/include/hyphman.h index efe75689..4b1d8435 100644 --- a/crengine/include/hyphman.h +++ b/crengine/include/hyphman.h @@ -26,8 +26,8 @@ class HyphMethod }; -#define WORD_LENGTH 64 -#define MAX_REAL_WORD 24 +#define WORD_LENGTH 2048 +//#define MAX_REAL_WORD 24 enum HyphDictType diff --git a/crengine/include/lvautoptr.h b/crengine/include/lvautoptr.h index e296d140..74b986cd 100644 --- a/crengine/include/lvautoptr.h +++ b/crengine/include/lvautoptr.h @@ -5,8 +5,13 @@ template class LVAutoPtr { T * p; - LVAutoPtr( const LVAutoPtr & v ) { } // no copy allowed - LVAutoPtr & operator = (const LVAutoPtr & v) { return *this; } // no copy + LVAutoPtr( const LVAutoPtr & v ) { + CR_UNUSED(v); + } // no copy allowed + LVAutoPtr & operator = (const LVAutoPtr & v) { + CR_UNUSED(v); + return *this; + } // no copy public: LVAutoPtr() : p(NULL) diff --git a/crengine/include/lvdocview.h b/crengine/include/lvdocview.h index 9fe10027..b4d279b9 100755 --- a/crengine/include/lvdocview.h +++ b/crengine/include/lvdocview.h @@ -320,6 +320,7 @@ class LVDocView : public CacheLoadingCallback lvRect m_pageMargins; lvRect m_pageRects[2]; int m_pagesVisible; + int m_pagesVisibleOverride; int m_pageHeaderInfo; bool m_showCover; LVRefVec m_headerIcons; @@ -620,7 +621,9 @@ class LVDocView : public CacheLoadingCallback /// set list of battery icons to display battery state void setBatteryIcons( LVRefVec icons ); /// sets page margins - void setPageMargins( const lvRect & rc ); + void setPageMargins(lvRect rc); + /// update page margins based on current settings + void updatePageMargins(); /// returns page margins lvRect getPageMargins() const { return m_pageMargins; } #if CR_INTERNAL_PAGE_ORIENTATION==1 @@ -665,10 +668,14 @@ class LVDocView : public CacheLoadingCallback LVDocViewMode getViewMode(); /// toggle pages/scroll view mode void toggleViewMode(); + /// returns current pages visible setting value (independent on window and font size) + int getPagesVisibleSetting(); /// get window visible page count (1 or 2) int getVisiblePageCount(); /// set window visible page count (1 or 2) void setVisiblePageCount( int n ); + /// set window visible page count, to use exact value independent of font size and window sides + void overrideVisiblePageCount(int n); /// get page header info mask int getPageHeaderInfo() { return m_pageHeaderInfo; } @@ -804,6 +811,8 @@ class LVDocView : public CacheLoadingCallback int scrollPosToDocPos( int scrollpos ); /// returns position in 1/100 of percents (0..10000) int getPosPercent(); + /// returns position in 1/100 of percents (0..10000) + int getPosEndPagePercent(); /// execute command int doCommand( LVDocCmd cmd, int param=0 ); diff --git a/crengine/include/lvfntman.h b/crengine/include/lvfntman.h index 431570c0..d7227541 100644 --- a/crengine/include/lvfntman.h +++ b/crengine/include/lvfntman.h @@ -382,10 +382,6 @@ class LVFontManager /// sets current gamma level virtual void SetGamma( double gamma ); - /// sets current hinting mode - virtual void SetHintingMode(hinting_mode_t /*mode*/) { } - /// returns current hinting mode - virtual hinting_mode_t GetHintingMode() { return HINTING_MODE_AUTOHINT; } /// sets current embolding virtual void SetEmbolding(int embolding) { } /// returns current embolding @@ -394,7 +390,14 @@ class LVFontManager virtual void SetTracking(int tracking) { } /// ruturns current tracking virtual int GetTracking() { return 0; } - + /// sets current hinting mode + virtual void SetHintingMode(hinting_mode_t /*mode*/) { } + /// returns current hinting mode + virtual hinting_mode_t GetHintingMode() { return HINTING_MODE_AUTOHINT; } + virtual bool setalias(lString8 alias,lString8 facename,int id,bool italic,bool bold){ + CR_UNUSED5(alias, facename, id, italic, bold); + return false; + } }; diff --git a/crengine/include/lvstream.h b/crengine/include/lvstream.h index 96f0852c..c7ffd043 100644 --- a/crengine/include/lvstream.h +++ b/crengine/include/lvstream.h @@ -606,8 +606,8 @@ class LVNamedContainer : public LVContainer break; } } - int pos = p-fn; - if (p>fn) + int pos = (int)(p - fn); + if (p > fn) m_path = m_fname.substr(0, pos); m_filename = m_fname.substr(pos, m_fname.length() - pos); } @@ -817,12 +817,19 @@ LVContainerRef LVOpenDirectory( const lChar16 * path, const wchar_t * mask = L"* LVContainerRef LVOpenDirectory(const lString16& path, const wchar_t * mask = L"*.*" ); LVContainerRef LVOpenDirectory(const lString8& path, const wchar_t * mask = L"*.*" ); +bool LVDirectoryIsEmpty(const lString8& path); +bool LVDirectoryIsEmpty(const lString16& path); + /// Create directory if not exist bool LVCreateDirectory( lString16 path ); /// delete file, return true if file found and successfully deleted bool LVDeleteFile( lString16 filename ); /// delete file, return true if file found and successfully deleted bool LVDeleteFile( lString8 filename ); +/// delete directory, return true if directory is found and successfully deleted +bool LVDeleteDirectory( lString16 filename ); +/// delete directory, return true if directory is found and successfully deleted +bool LVDeleteDirectory( lString8 filename ); /// rename file bool LVRenameFile(lString16 oldname, lString16 newname); /// rename file diff --git a/crengine/include/lvstring.h b/crengine/include/lvstring.h index 04c81ee8..b4369d13 100644 --- a/crengine/include/lvstring.h +++ b/crengine/include/lvstring.h @@ -337,7 +337,11 @@ class lString8 lUInt32 getHash() const; /// get character at specified position with range check - value_type & at( size_type pos ) { if (pos > (size_type)pchunk->len) crFatalError(); return modify()[pos]; } + value_type & at(size_type pos) { + if (pos > pchunk->len) + crFatalError(); + return modify()[pos]; + } /// get character at specified position without range check value_type operator [] ( size_type pos ) const { return pchunk->buf8[pos]; } /// get reference to character at specified position @@ -627,6 +631,8 @@ class lString16 /// trims all unused space at end of string (sets size to length) lString16 & pack(); + /// trims non alpha at beginning and end of string + lString16 & trimNonAlpha(); /// trims spaces at beginning and end of string lString16 & trim(); /// trims duplicate space characters inside string and (optionally) at end and beginning of string @@ -893,6 +899,7 @@ template class lStringBuf16 { int pos; lStringBuf16 & operator = (lStringBuf16 & v) { + CR_UNUSED(v); // not available return *this; } diff --git a/crengine/include/lvstsheet.h b/crengine/include/lvstsheet.h index 8b9112d6..e93463c4 100644 --- a/crengine/include/lvstsheet.h +++ b/crengine/include/lvstsheet.h @@ -212,7 +212,7 @@ class LVStyleSheet { } /// remove all rules from stylesheet - void clear() { _selectors.clear(); } + void clear() { _selectors.clear(); _stack.clear(); } /// set document to retrieve ID values from void setDocument( lxmlDocBase * doc ) { _doc = doc; } /// constructor diff --git a/crengine/include/lvtypes.h b/crengine/include/lvtypes.h index 97c914ea..13934602 100644 --- a/crengine/include/lvtypes.h +++ b/crengine/include/lvtypes.h @@ -113,6 +113,7 @@ class lvRect { int width() const { return right - left; } /// returns rectangle height int height() const { return bottom - top; } + int minDimension() { return (right - left < bottom - top) ? right - left : bottom - top; } lvPoint size() const { return lvPoint(right-left, bottom - top); } void shrink( int delta ) { left+=delta; right-=delta; top+=delta; bottom-=delta; } void shrinkBy( const lvRect & rc ) { left+=rc.left; right-=rc.right; top+=rc.top; bottom-=rc.bottom; } @@ -160,7 +161,7 @@ class lvRect { } /// returns true if point is inside this rectangle - bool isPointInside ( lvPoint & pt ) const + bool isPointInside ( const lvPoint & pt ) const { return left<=pt.x && top<=pt.y && right>pt.x && bottom > pt.y; } diff --git a/crengine/src/chmfmt.cpp b/crengine/src/chmfmt.cpp index 2862d2ba..48a9b575 100644 --- a/crengine/src/chmfmt.cpp +++ b/crengine/src/chmfmt.cpp @@ -438,7 +438,7 @@ class CHMUrlStr { const lUInt8 * data = ptr; const lUInt8 * maxdata = ptr + size; while ( data + 8 < maxdata ) { - lUInt32 offset = blockOffset + (data - ptr); + lUInt32 offset = (lUInt32)(blockOffset + (data - ptr)); //lUInt32 urlOffset = readInt32(data); //lUInt32 frameOffset = @@ -446,7 +446,7 @@ class CHMUrlStr { if ( data < maxdata ) { //urlOffset > offset ) { CHMUrlStrEntry * item = new CHMUrlStrEntry(); item->offset = offset; - item->url = readString(data, maxdata - data); + item->url = readString(data, (int)(maxdata - data)); //CRLog::trace("urlstr[offs=%x, url=%s]", item->offset, item->url.c_str()); _table.add( item ); } diff --git a/crengine/src/cri18n.cpp b/crengine/src/cri18n.cpp index b8c6ae66..45501c9c 100644 --- a/crengine/src/cri18n.cpp +++ b/crengine/src/cri18n.cpp @@ -254,8 +254,8 @@ bool CRIniFileTranslator::open(const char * fileName) elp++; } if ( eqpos!=NULL && eqpos>p && *elp!='#' ) { - lString8 name( p, eqpos-p ); - lString8 value( eqpos+1, elp - eqpos - 1); + lString8 name( p, (lvsize_t)(eqpos-p) ); + lString8 value( eqpos+1, (lvsize_t)(elp - eqpos - 1)); _map.set(name, value); } for ( p=elp; *elp && *elp!='\r' && *elp!='\n'; elp++) diff --git a/crengine/src/crtxtenc.cpp b/crengine/src/crtxtenc.cpp index ca909c0d..aa286fcd 100644 --- a/crengine/src/crtxtenc.cpp +++ b/crengine/src/crtxtenc.cpp @@ -1952,7 +1952,7 @@ int strincmp(const unsigned char * buf, const char * pattern, int len) int strnstr(const unsigned char * buf, int buf_len, const char * pattern) { - int plen = strlen(pattern); + int plen = (int)strlen(pattern); for (int i=0; i<=buf_len - plen; i++) { if (!strincmp(buf + i, pattern, plen)) { return i; @@ -1963,7 +1963,7 @@ int strnstr(const unsigned char * buf, int buf_len, const char * pattern) int rstrnstr(const unsigned char * buf, int buf_len, const char * pattern) { - int plen = strlen(pattern); + int plen = (int)strlen(pattern); for (int i=buf_len - plen; i>=0; i--) { if (!strincmp(buf + i, pattern, plen)) { return i; diff --git a/crengine/src/epubfmt.cpp b/crengine/src/epubfmt.cpp index 68fe7add..a0679f5a 100644 --- a/crengine/src/epubfmt.cpp +++ b/crengine/src/epubfmt.cpp @@ -484,6 +484,7 @@ class EmbeddedFontStyleParser { bool _italic; bool _bold; lString16 _url; + lString8 islocal; public: EmbeddedFontStyleParser(LVEmbeddedFontList & fontList) : _fontList(fontList) { } void onToken(char token) { @@ -526,15 +527,19 @@ class EmbeddedFontStyleParser { if (!_url.empty()) { // CRLog::trace("@font { face: %s; bold: %s; italic: %s; url: %s", _face.c_str(), _bold ? "yes" : "no", // _italic ? "yes" : "no", LCSTR(_url)); - _fontList.add(_url, _face, _bold, _italic); - } + if (islocal.length()==5) _url=(_url.substr((_basePath.length()+1),(_url.length()-_basePath.length()))); + _fontList.add(_url, _face, _bold, _italic); } + } _state = 0; break; case ',': if (_state == 2) { if (!_url.empty()) +{ + if (islocal.length()==5) _url=(_url.substr((_basePath.length()+1),(_url.length()-_basePath.length()))); _fontList.add(_url, _face, _bold, _italic); +} _state = 11; } break; @@ -583,7 +588,15 @@ class EmbeddedFontStyleParser { _state = 2; } else if (_state == 11) { if (t == "url") + { _state = 12; + islocal=t; + } + else if (t=="local") + { + _state=12; + islocal=t; + } else _state = 2; } diff --git a/crengine/src/hist.cpp b/crengine/src/hist.cpp index a82070e4..f6990bf0 100644 --- a/crengine/src/hist.cpp +++ b/crengine/src/hist.cpp @@ -510,7 +510,7 @@ CRFileHistRecord * CRFileHist::savePosition( lString16 fpathname, size_t sz, splitFName( fpathname, path, name ); CRBookmark bmk( ptr ); //CRLog::trace("Bookmark created"); - int index = findEntry( name, path, sz ); + int index = findEntry( name, path, (lvsize_t)sz ); //CRLog::trace("findEntry exited"); if ( index>=0 ) { makeTop( index ); @@ -524,7 +524,7 @@ CRFileHistRecord * CRFileHist::savePosition( lString16 fpathname, size_t sz, rec->setSeries( series ); rec->setFileName( name ); rec->setFilePath( path ); - rec->setFileSize( sz ); + rec->setFileSize( (lvsize_t)sz ); rec->setLastPos( &bmk ); rec->setLastTime( (time_t)time(0) ); @@ -538,7 +538,7 @@ ldomXPointer CRFileHist::restorePosition( ldomDocument * doc, lString16 fpathnam lString16 name; lString16 path; splitFName( fpathname, path, name ); - int index = findEntry( name, path, sz ); + int index = findEntry( name, path, (lvsize_t)sz ); if ( index>=0 ) { makeTop( index ); return doc->createXPointer( _records[0]->getLastPos()->getStartPos() ); diff --git a/crengine/src/lvdocview.cpp b/crengine/src/lvdocview.cpp index 6b225e16..c7e7bee5 100755 --- a/crengine/src/lvdocview.cpp +++ b/crengine/src/lvdocview.cpp @@ -47,9 +47,13 @@ #if 0 #define REQUEST_RENDER(txt) {CRLog::trace("request render from " txt); requestRender();} -#define CHECK_RENDER(txt) {CRLog::trace("LVDocView::checkRender() - from " txt); checkRender();} #else #define REQUEST_RENDER(txt) requestRender(); +#endif + +#if 0 +#define CHECK_RENDER(txt) {CRLog::trace("LVDocView::checkRender() - from " txt); checkRender();} +#else #define CHECK_RENDER(txt) checkRender(); #endif @@ -141,7 +145,7 @@ LVDocView::LVDocView(int bitsPerPixel) : m_pageMargins(DEFAULT_PAGE_MARGIN, DEFAULT_PAGE_MARGIN / 2 /*+ INFO_FONT_SIZE + 4 */, DEFAULT_PAGE_MARGIN, DEFAULT_PAGE_MARGIN / 2), - m_pagesVisible(2), m_pageHeaderInfo(PGHDR_PAGE_NUMBER + m_pagesVisible(2), m_pagesVisibleOverride(0), m_pageHeaderInfo(PGHDR_PAGE_NUMBER #ifndef LBOOK | PGHDR_CLOCK #endif @@ -377,9 +381,41 @@ lvPoint LVDocView::rotatePoint(lvPoint & pt, bool winToDoc) { #endif } +/// update page margins based on current settings +void LVDocView::updatePageMargins() { + lvRect rc = getPageMargins(); + rc.left = m_props->getIntDef(PROP_PAGE_MARGIN_LEFT, rc.left); + rc.top = m_props->getIntDef(PROP_PAGE_MARGIN_TOP, rc.top); + rc.right = m_props->getIntDef(PROP_PAGE_MARGIN_RIGHT, rc.right); + rc.bottom = m_props->getIntDef(PROP_PAGE_MARGIN_BOTTOM, rc.bottom); + int maxhmargin = m_dx / 5; + int maxvmargin = m_dy / 5; + if (rc.left > maxhmargin) + rc.left = maxhmargin; + if (rc.right > maxhmargin) + rc.right = maxhmargin; + if (rc.top > maxvmargin) + rc.top = maxvmargin; + if (rc.bottom > maxvmargin) + rc.bottom = maxvmargin; + setPageMargins(rc); +} + /// sets page margins -void LVDocView::setPageMargins(const lvRect & rc) { - if (m_pageMargins.left + m_pageMargins.right != rc.left + rc.right +void LVDocView::setPageMargins(lvRect rc) { + bool floatingPunct = m_props->getBoolDef(PROP_FLOATING_PUNCTUATION, true); + int align = 0; + if (floatingPunct) { + m_font = fontMan->GetFont(m_font_size, 400 + LVRendGetFontEmbolden(), + false, DEFAULT_FONT_FAMILY, m_defaultFontFace); + align = m_font->getVisualAligmentWidth() / 2; + } + if (align > rc.right) + align = rc.right; + rc.left += align; + rc.right -= align; + + if (m_pageMargins.left + m_pageMargins.right != rc.left + rc.right || m_pageMargins.top + m_pageMargins.bottom != rc.top + rc.bottom) { m_pageMargins = rc; @@ -439,7 +475,7 @@ lString8 substituteCssMacros(lString8 src, CRPropRef props) { } if (!err) { // substitute variable - lString8 prop(s + 1, s2 - s - 1); + lString8 prop(s + 1, (lvsize_t)(s2 - s - 1)); lString16 v; // $styles.stylename.all will merge all properties like styles.stylename.* if (prop.endsWith(".all")) { @@ -474,11 +510,12 @@ lString8 substituteCssMacros(lString8 src, CRPropRef props) { void LVDocView::setStyleSheet(lString8 css_text) { LVLock lock(getMutex()); REQUEST_RENDER("setStyleSheet") - + //CRLog::trace("LVDocView::setStyleSheet()"); m_stylesheet = css_text; } void LVDocView::updateDocStyleSheet() { + //CRLog::trace("LVDocView::updateDocStyleSheet()"); CRPropRef p = m_props->getSubProps("styles."); m_doc->setStyleSheet(substituteCssMacros(m_stylesheet, p).c_str(), true); } @@ -1443,6 +1480,37 @@ LVArray & LVDocView::getSectionBounds() { return m_section_bounds; } +int LVDocView::getPosEndPagePercent() { + LVLock lock(getMutex()); + checkPos(); + if (getViewMode() == DVM_SCROLL) { + int fh = GetFullHeight(); + int p = GetPos() + m_pageRects[0].height() - m_pageMargins.top - m_pageMargins.bottom - 10; + if (fh > 0) + return (int) (((lInt64) p * 10000) / fh); + else + return 0; + } else { + int fh = m_pages.length(); + if (fh > 0) { + int p = getCurPage() + 1;// + 1; + if (getVisiblePageCount() > 1) + p++; + if (p > fh - 1) + p = fh - 1; + if (p < 0) + p = 0; + p = m_pages[p]->start - 10; + int fh = GetFullHeight(); + if (fh > 0) + return (int) (((lInt64) p * 10000) / fh); + else + return 0; + } else + return 0; + } +} + int LVDocView::getPosPercent() { LVLock lock(getMutex()); checkPos(); @@ -1532,6 +1600,7 @@ void LVDocView::drawPageHeader(LVDrawBuf * drawbuf, const lvRect & headerRc, lvRect oldcr; drawbuf->GetClipRect(&oldcr); lvRect hrc = headerRc; + hrc.bottom += 2; drawbuf->SetClipRect(&hrc); bool drawGauge = true; lvRect info = headerRc; @@ -1562,7 +1631,7 @@ void LVDocView::drawPageHeader(LVDrawBuf * drawbuf, const lvRect & headerRc, // //pal[0] = cl1; // } if ( leftPage ) - drawbuf->FillRect(info.left, gpos - 2, info.right, gpos - 2 + 1, cl1); + drawbuf->FillRect(info.left, gpos - 2, info.right, gpos - 2 + 1, cl1); //drawbuf->FillRect(info.left+percent_pos, gpos-gh, info.right, gpos-gh+1, cl1 ); //cl3 // drawbuf->FillRect(info.left + percent_pos, gpos - 2, info.right, gpos - 2 // + 1, cl1); // cl3 @@ -1572,12 +1641,23 @@ void LVDocView::drawPageHeader(LVDrawBuf * drawbuf, const lvRect & headerRc, LVArray & sbounds = dummy; int sbound_index = 0; bool enableMarks = !leftPage && (phi & PGHDR_CHAPTER_MARKS); + int w = GetWidth(); + int h = GetHeight(); + if (w > h) + w = h; + int markh = 3; + int markw = 1; + if (w > 700) { + markh = 5; + markw = 2; + } if ( enableMarks || (phi & PGHDR_CHAPTER_PAGE_REM) ) sbounds = getSectionBounds(); enableMarks = enableMarks && sbounds.length()0 ) { @@ -1618,8 +1699,9 @@ void LVDocView::drawPageHeader(LVDrawBuf * drawbuf, const lvRect & headerRc, if ( boundCategoryOld ) boundCategoryOld--; else - drawbuf->FillRect( x, gpos - 0 - sz/1, - x + 1, gpos - 0 + sz/1 + 1, cl ); + drawbuf->FillRect(x, gpos - 2 - sz/2, x + szx, gpos - 2 + sz/2 + 1, cl); + // drawbuf->FillRect( x, gpos - 0 - sz/1, + // x + 1, gpos - 0 + sz/1 + 1, cl ); } else //skip stroke(white on black) boundCategoryOld= 1; @@ -1627,7 +1709,7 @@ void LVDocView::drawPageHeader(LVDrawBuf * drawbuf, const lvRect & headerRc, lString16 text; //int iy = info.top; // + (info.height() - m_infoFont->getHeight()) * 2 / 3; - int iy = info.top + /*m_infoFont->getHeight() +*/ (info.height() - m_infoFont->getHeight()) / 2 - HEADER_MARGIN/2; + int iy = info.top + /*m_infoFont->getHeight() +*/ (info.height() - m_infoFont->getHeight()) / 2 - HEADER_MARGIN/2 - 1; if (!m_pageHeaderOverride.empty()) { text = m_pageHeaderOverride; @@ -1726,7 +1808,7 @@ void LVDocView::drawPageHeader(LVDrawBuf * drawbuf, const lvRect & headerRc, pageinfo << fmt::decimal(pp) << "%"; } if ( batteryPercentNormalFont && m_battery_state>=0 ) { - pageinfo << " [" << fmt::decimal(m_battery_state) << "%]"; + pageinfo << " " << fmt::decimal(m_battery_state) << "%"; } } int piw = 0; @@ -2352,8 +2434,8 @@ void LVDocView::updateLayout() { m_pageRects[1] = rc; if (getVisiblePageCount() == 2) { int middle = (rc.left + rc.right) >> 1; - m_pageRects[0].right = middle - m_pageMargins.right / 2; - m_pageRects[1].left = middle + m_pageMargins.left / 2; + m_pageRects[0].right = middle; // - m_pageMargins.right; + m_pageRects[1].left = middle; // + m_pageMargins.left; } } @@ -3121,9 +3203,32 @@ void LVDocView::toggleViewMode() { } +/// returns current pages visible setting value +int LVDocView::getPagesVisibleSetting() { + if (m_view_mode == DVM_PAGES && m_pagesVisible == 2) + return 2; + return 1; +} + int LVDocView::getVisiblePageCount() { - return (m_view_mode == DVM_SCROLL || m_dx < m_font_size * MIN_EM_PER_PAGE - || m_dx * 5 < m_dy * 6) ? 1 : m_pagesVisible; + if (m_view_mode == DVM_SCROLL || m_pagesVisible == 1) + return 1; + if (m_pagesVisibleOverride > 0) + return m_pagesVisibleOverride; + return (m_dx < m_font_size * MIN_EM_PER_PAGE || m_dx * 5 < m_dy * 6) + ? 1 : m_pagesVisible; +} + +void LVDocView::overrideVisiblePageCount(int n) { + clearImageCache(); + LVLock lock(getMutex()); + int newCount = n > 0 ? ((n == 2) ? 2 : 1) : 0; + if (m_pagesVisibleOverride == newCount) + return; + m_pagesVisibleOverride = newCount; + updateLayout(); + REQUEST_RENDER("setVisiblePageCount") + _posIsSet = false; } /// set window visible page count (1 or 2) @@ -4610,7 +4715,7 @@ void LVDocView::updateScroll() { int vpc = getVisiblePageCount(); m_scrollinfo.pos = page / vpc; m_scrollinfo.maxpos = (m_pages.length() + vpc - 1) / vpc - 1; - m_scrollinfo.pagesize = 1; + m_scrollinfo.pagesize = 1; //getVisiblePageCount(); m_scrollinfo.scale = 0; char str[32] = { 0 }; if (m_pages.length() > 1) { @@ -5399,7 +5504,8 @@ int LVDocView::onSelectionCommand( int cmd, int param ) currSel = *sel[0]; bool moved = false; bool makeSelStartVisible = true; // true: start, false: end - if ( !currSel.isNull() && !pageRange->isInside(currSel.getStart()) && !pageRange->isInside(currSel.getEnd()) ) + if ( !currSel.isNull() && cmd == DCMD_SELECT_FIRST_SENTENCE + && !pageRange->isInside(currSel.getStart()) && !pageRange->isInside(currSel.getEnd()) ) currSel.clear(); if ( currSel.isNull() || currSel.getStart().isNull() ) { // select first sentence on page @@ -5457,6 +5563,7 @@ int LVDocView::onSelectionCommand( int cmd, int param ) } else { // selection start doesn't match sentence bounds if ( !currSel.getStart().isSentenceStart() ) { + CRLog::trace("moving to selection start"); currSel.getStart().thisSentenceStart(); moved = true; } @@ -5464,12 +5571,16 @@ int LVDocView::onSelectionCommand( int cmd, int param ) if ( !moved ) switch ( cmd ) { case DCMD_SELECT_NEXT_SENTENCE: - if ( !currSel.getStart().nextSentenceStart() ) + if ( !currSel.getStart().nextSentenceStart() ) { + CRLog::trace("nextSentenceStart() returned false"); return 0; + } break; case DCMD_SELECT_PREV_SENTENCE: - if ( !currSel.getStart().prevSentenceStart() ) + if ( !currSel.getStart().prevSentenceStart() ) { + CRLog::trace("prevSentenceStart() returned false"); return 0; + } break; case DCMD_SELECT_FIRST_SENTENCE: default: // unknown action @@ -5766,9 +5877,9 @@ void LVDocView::setStatusMode(int newMode, bool showClock, bool showTitle, showBattery ? "battery" : "", showChapterMarks ? "marks" : ""); #if ALLOW_BOTTOM_STATUSBAR==1 lvRect margins( H_MARGIN, V_MARGIN, H_MARGIN, V_MARGIN/2 ); - lvRect oldMargins = _docview->getPageMargins( ); + // lvRect oldMargins = _docview->getPageMargins( ); if (newMode==1) - margins.bottom = STANDARD_STATUSBAR_HEIGHT + V_MARGIN/4; + margins.bottom = getPageHeaderHeight() + V_MARGIN/4; #endif if (newMode == 0) setPageHeaderInfo( @@ -5900,22 +6011,11 @@ CRPropRef LVDocView::propsApply(CRPropRef props) { } else if (name == PROP_PAGE_MARGIN_TOP || name == PROP_PAGE_MARGIN_LEFT || name == PROP_PAGE_MARGIN_RIGHT || name == PROP_PAGE_MARGIN_BOTTOM) { - int margin = props->getIntDef(name.c_str(), 8); - int maxmargin = (name == PROP_PAGE_MARGIN_LEFT || name == PROP_PAGE_MARGIN_RIGHT) ? m_dx / 4 : m_dy / 4; - if (margin > maxmargin) - margin = maxmargin; - lvRect rc = getPageMargins(); - if (name == PROP_PAGE_MARGIN_TOP) - rc.top = margin; - else if (name == PROP_PAGE_MARGIN_BOTTOM) - rc.bottom = margin; - else if (name == PROP_PAGE_MARGIN_LEFT) - rc.left = margin; - else if (name == PROP_PAGE_MARGIN_RIGHT) - rc.right = margin; - setPageMargins(rc); + m_props->setString(name.c_str(), value); + updatePageMargins(); } else if (name == PROP_FONT_FACE) { setDefaultFontFace(UnicodeToUtf8(value)); + updatePageMargins(); } else if (name == PROP_FALLBACK_FONT_FACE) { lString8 oldFace = fontMan->GetFallbackFontFace(); if ( UnicodeToUtf8(value)!=oldFace ) @@ -5954,6 +6054,7 @@ CRPropRef LVDocView::propsApply(CRPropRef props) { int fontSize = props->getIntDef(PROP_FONT_SIZE, m_font_sizes[0]); setFontSize(fontSize);//cr_font_sizes value = lString16::itoa(m_font_size); + updatePageMargins(); } else if (name == PROP_STATUS_FONT_SIZE) { int fontSize = props->getIntDef(PROP_STATUS_FONT_SIZE, DEF_STATUS_FONT_SIZE); diff --git a/crengine/src/lvfntman.cpp b/crengine/src/lvfntman.cpp index ef3b5931..36a68b72 100644 --- a/crengine/src/lvfntman.cpp +++ b/crengine/src/lvfntman.cpp @@ -38,7 +38,7 @@ #define GAMMA_TABLES_IMPL #include "../include/gammatbl.h" -#if (USE_FREETYPE==1) +//#if (USE_FREETYPE==1) //#include @@ -70,9 +70,6 @@ #include #endif -#endif - - #if COLOR_BACKBUFFER==0 //#define USE_BITMAP_FONT #endif @@ -273,7 +270,11 @@ int LVFont::getVisualAligmentWidth() FONT_GUARD if ( _visual_alignment_width==-1 ) { //lChar16 chars[] = { getHyphChar(), ',', '.', '!', ':', ';', 0 }; - lChar16 chars[] = { getHyphChar(), ',', '.', '!', ':', ';', L',', L'。', L'!', 0 }; + lChar16 chars[] = { getHyphChar(), ',', '.', '!', ':', ';', + (lChar16)L'\xff0c', (lChar16)L'\x3302', (lChar16)L'\xff01', 0 }; + // (lChar16)L',', (lChar16)L'。', (lChar16)L'!', 0 }; + // 65292 12290 65281 + // ff0c 3002 ff01 int maxw = 0; for ( int i=0; chars[i]; i++ ) { int w = getCharWidth( chars[i] ); @@ -449,6 +450,7 @@ class LVFontCache void clear() { _registered_list.clear(); _instance_list.clear(); } void gc(); // garbage collector void update( const LVFontDef * def, LVFontRef ref ); + void removefont(const LVFontDef * def); void removeDocumentFonts(int documentId); int length() { return _registered_list.length(); } void addInstance( const LVFontDef * def, LVFontRef ref ); @@ -2300,6 +2302,28 @@ class LVFreeTypeFontManager : public LVFontManager return facesFound > 0; } + #elif (CR3_OSX == 1) + + int facesFound = 0; + facesFound += fontMan->RegisterFont(lString8("/Library/Fonts/Arial.ttf")); + facesFound += fontMan->RegisterFont(lString8("/Library/Fonts/Arial Bold.ttf")); + facesFound += fontMan->RegisterFont(lString8("/Library/Fonts/Arial Italic.ttf")); + facesFound += fontMan->RegisterFont(lString8("/Library/Fonts/Arial Bold Italic.ttf")); + facesFound += fontMan->RegisterFont(lString8("/Library/Fonts/Arial Unicode.ttf")); + facesFound += fontMan->RegisterFont(lString8("/Library/Fonts/Arial Narrow.ttf")); + facesFound += fontMan->RegisterFont(lString8("/Library/Fonts/Arial Narrow Bold.ttf")); + facesFound += fontMan->RegisterFont(lString8("/Library/Fonts/Arial Narrow Italic.ttf")); + facesFound += fontMan->RegisterFont(lString8("/Library/Fonts/Courier New.ttf")); + facesFound += fontMan->RegisterFont(lString8("/Library/Fonts/Courier New Bold.ttf")); + facesFound += fontMan->RegisterFont(lString8("/Library/Fonts/Courier New Italic.ttf")); + facesFound += fontMan->RegisterFont(lString8("/Library/Fonts/Courier New Bold Italic.ttf")); + facesFound += fontMan->RegisterFont(lString8("/Library/Fonts/Georgia.ttf")); + facesFound += fontMan->RegisterFont(lString8("/Library/Fonts/Georgia Bold.ttf")); + facesFound += fontMan->RegisterFont(lString8("/Library/Fonts/Georgia Italic.ttf")); + facesFound += fontMan->RegisterFont(lString8("/Library/Fonts/Georgia Bold Italic.ttf")); + + return facesFound > 0; + #else return false; #endif @@ -2358,7 +2382,105 @@ class LVFreeTypeFontManager : public LVFontManager FONT_MAN_GUARD _cache.getFaceList( list ); } +bool setalias(lString8 alias,lString8 facename,int id,bool italic, bool bold) +{ + FONT_MAN_GUARD + lString8 fontname=lString8("\0"); + LVFontDef def( + fontname, + 10, + 400, + true, + css_ff_inherit, + facename, + -1, + id + ); + LVFontCacheItem * item = _cache.find( &def); + LVFontDef def1( + fontname, + 10, + 400, + false, + css_ff_inherit, + alias, + -1, + id + ); + if (!item->getDef()->getName().empty()) { + _cache.removefont(&def1); + /*def.setTypeFace(alias); + def.setName(item->getDef()->getName()); + def.setItalic(1); + LVFontDef newDef(*item->getDef()); + newDef.setTypeFace(alias); + LVFontRef ref = item->getFont(); + _cache.update(&newDef, ref);*/ + int index = 0; + + FT_Face face = NULL; + + // for all faces in file + for ( ;; index++ ) { + int error = FT_New_Face( _library, item->getDef()->getName().c_str(), index, &face ); /* create face object */ + if ( error ) { + if (index == 0) { + CRLog::error("FT_New_Face returned error %d", error); + } + break; + } + //bool scal = FT_IS_SCALABLE( face ); + //bool charset = checkCharSet( face ); + + int num_faces = face->num_faces; + + css_font_family_t fontFamily = css_ff_sans_serif; + if ( face->face_flags & FT_FACE_FLAG_FIXED_WIDTH ) + fontFamily = css_ff_monospace; + lString8 familyName(!facename.empty() ? facename : ::familyName(face)); + if ( familyName=="Times" || familyName=="Times New Roman" ) + fontFamily = css_ff_serif; + + bool boldFlag = !facename.empty() ? bold : (face->style_flags & FT_STYLE_FLAG_BOLD) != 0; + bool italicFlag = !facename.empty() ? italic : (face->style_flags & FT_STYLE_FLAG_ITALIC) != 0; + + LVFontDef def2( + item->getDef()->getName(), + -1, // height==-1 for scalable fonts + boldFlag ? 700 : 400, + italicFlag, + fontFamily, + alias, + index, + id + ); + if ( face ) { + FT_Done_Face( face ); + face = NULL; + } + + if ( _cache.findDuplicate( &def2 ) ) { + CRLog::trace("font definition is duplicate"); + return false; + } + _cache.update( &def2, LVFontRef(NULL) ); + if (!def.getItalic()) { + LVFontDef newDef( def2 ); + newDef.setItalic(2); // can italicize + if ( !_cache.findDuplicate( &newDef ) ) + _cache.update( &newDef, LVFontRef(NULL) ); + } + if ( index>=num_faces-1 ) + break; + } + return true; + } + else + { + return false; + } +} virtual LVFontRef GetFont(int size, int weight, bool italic, css_font_family_t family, lString8 typeface, int documentId) { FONT_MAN_GUARD @@ -3490,6 +3612,26 @@ void LVFontCache::addInstance( const LVFontDef * def, LVFontRef ref ) _instance_list.add( item ); } +void LVFontCache::removefont(const LVFontDef * def) +{ + int i; + for (i=0; i<_instance_list.length(); i++) + { + if ( _instance_list[i]->_def.getTypeFace() == def->getTypeFace() ) + { + _instance_list.remove(i); + } + + } + for (i=0; i<_registered_list.length(); i++) + { + if ( _registered_list[i]->_def.getTypeFace() == def->getTypeFace() ) + { + _registered_list.remove(i); + } + } + +} void LVFontCache::update( const LVFontDef * def, LVFontRef ref ) { int i; diff --git a/crengine/src/lvimg.cpp b/crengine/src/lvimg.cpp index 60960c31..9e62eb90 100644 --- a/crengine/src/lvimg.cpp +++ b/crengine/src/lvimg.cpp @@ -506,16 +506,16 @@ class LVPngImageSource : public LVNodeImageSource }; -static void lvpng_error_func (png_structp png, png_const_charp) +static void lvpng_error_func (png_structp png, png_const_charp msg) { - //fprintf(stderr, "png error: %s\n", msg) + CRLog::error("libpng: %s", msg); longjmp(png_jmpbuf(png), 1); } -static void lvpng_warning_func (png_structp png, png_const_charp) +static void lvpng_warning_func (png_structp png, png_const_charp msg) { - //fprintf(stderr, "png warning: %s\n", msg) - longjmp(png_jmpbuf(png), 1); + CR_UNUSED(png); + CRLog::warn("libpng: %s", msg); } static void lvpng_read_func(png_structp png, png_bytep buf, png_size_t len) @@ -523,7 +523,7 @@ static void lvpng_read_func(png_structp png, png_bytep buf, png_size_t len) LVNodeImageSource * obj = (LVNodeImageSource *) png_get_io_ptr(png); LVStream * stream = obj->GetSourceStream(); lvsize_t bytesRead = 0; - if ( stream->Read( buf, len, &bytesRead )!=LVERR_OK || bytesRead!=(lvsize_t)len ) + if ( stream->Read( buf, (int)len, &bytesRead )!=LVERR_OK || bytesRead!=len ) longjmp(png_jmpbuf(png), 1); } @@ -1168,7 +1168,7 @@ int LVGifImageSource::DecodeFromBuffer(unsigned char *buf, int buf_size, LVImage { LVGifFrame * pFrame = new LVGifFrame(this); int cbRead = 0; - if (pFrame->DecodeFromBuffer(p, buf_size - (p - buf), cbRead) ) { + if (pFrame->DecodeFromBuffer(p, (int)(buf_size - (p - buf)), cbRead) ) { found = true; pFrame->Draw( callback ); } @@ -1178,7 +1178,7 @@ int LVGifImageSource::DecodeFromBuffer(unsigned char *buf, int buf_size, LVImage break; case '!': // extension record { - res = skipGifExtension(p, buf_size - (p - buf)); + res = skipGifExtension(p, (int)(buf_size - (p - buf))); } break; case ';': // terminate record @@ -1516,7 +1516,7 @@ int LVGifFrame::DecodeFromBuffer( unsigned char * buf, int buf_size, int &bytes_ // test raster stream size int i; - int rest_buf_size = buf_size - (p-buf); + int rest_buf_size = (int)(buf_size - (p-buf)); for (i=0; i +#include + +namespace { + +struct BacktraceState +{ + void** current; + void** end; +}; + +static _Unwind_Reason_Code unwindCallback(struct _Unwind_Context* context, void* arg) +{ + BacktraceState* state = static_cast(arg); + uintptr_t pc = _Unwind_GetIP(context); + if (pc) { + if (state->current == state->end) { + return _URC_END_OF_STACK; + } else { + *state->current++ = reinterpret_cast(pc); + } + } + return _URC_NO_REASON; +} + +} + +size_t captureBacktrace(void** buffer, size_t max) +{ + BacktraceState state = {buffer, buffer + max}; + _Unwind_Backtrace(unwindCallback, &state); + + return state.current - buffer; +} + +void dumpBacktrace(void** addrs, size_t count) +{ + for (size_t idx = 0; idx < count; ++idx) { + const void* addr = addrs[idx]; + const char* symbol = ""; + + Dl_info info; + if (dladdr(addr, &info) && info.dli_sname) { + symbol = info.dli_sname; + } + + CRLog::trace(" # %02d : 0x%08x %s", idx, addr, symbol); + + } +} + +#endif // ANDROID_BACKTRACE + + + void cr_sigaction(int signal, siginfo_t *info, void *reserved) { CR_UNUSED2(info, reserved); if (file_to_remove_on_crash[0]) unlink(file_to_remove_on_crash); + CRLog::error("cr_sigaction(%d)", signal); + +#ifdef ANDROID_BACKTRACE + void* buffer[50]; + dumpBacktrace(buffer, captureBacktrace(buffer, 50)); +#endif + old_sa[signal].sa_handler(signal); } #endif diff --git a/crengine/src/lvrend.cpp b/crengine/src/lvrend.cpp index 5e37b42a..ed1aa967 100755 --- a/crengine/src/lvrend.cpp +++ b/crengine/src/lvrend.cpp @@ -960,7 +960,7 @@ void SplitLines( const lString16 & str, lString16Collection & lines ) while ( *start=='\r' || *start=='\n' ) start++; if ( s > start ) - lines.add( lString16( start, s-start ) ); + lines.add( lString16( start, (lvsize_t)(s-start) ) ); } //======================================================================= diff --git a/crengine/src/lvstream.cpp b/crengine/src/lvstream.cpp index 34c856d6..b4ade70b 100644 --- a/crengine/src/lvstream.cpp +++ b/crengine/src/lvstream.cpp @@ -159,7 +159,7 @@ void LVNamedStream::SetName(const lChar16 * name) if (p[-1] == '/' || p[-1]=='\\') break; } - int pos = p-fn; + int pos = (int)(p - fn); if (p>fn) m_path = m_fname.substr(0, pos); m_filename = m_fname.substr(pos, m_fname.length() - pos); @@ -1003,6 +1003,7 @@ class LVFileStream : public LVNamedStream /// flushes unsaved data from buffers to file, with optional flush of OS buffers virtual lverror_t Flush( bool sync ) { + CR_UNUSED(sync); #ifdef _WIN32 if ( m_hFile==INVALID_HANDLE_VALUE || !FlushFileBuffers( m_hFile ) ) return LVERR_FAIL; @@ -1045,7 +1046,7 @@ class LVFileStream : public LVNamedStream m_pos += dwBytesRead; return LVERR_OK; } else { - DWORD err = GetLastError(); + //DWORD err = GetLastError(); if (nBytesRead) *nBytesRead = 0; return LVERR_FAIL; @@ -2187,7 +2188,7 @@ class LVZipDecodeStream : public LVNamedStream { if (m_zstream.avail_in < ARC_INBUF_SIZE / 4 && m_inbytesleft > 0) { - int inpos = m_zstream.next_in ? (m_zstream.next_in - m_inbuf) : 0; + int inpos = (int)(m_zstream.next_in ? (m_zstream.next_in - m_inbuf) : 0); if ( inpos > ARC_INBUF_SIZE/2 ) { // move rest of data to beginning of buffer @@ -2254,7 +2255,7 @@ class LVZipDecodeStream : public LVNamedStream // returns count of available decoded bytes in buffer inline int getAvailBytes() { - return m_zstream.next_out - m_outbuf - m_decodedpos; + return (int)(m_zstream.next_out - m_outbuf - m_decodedpos); } /// decode next portion of data, returns number of decoded bytes available, -1 if error int decodeNext() @@ -2270,7 +2271,7 @@ class LVZipDecodeStream : public LVNamedStream if (m_decodedpos > ARC_OUTBUF_SIZE/2 || (m_zstream.avail_out < ARC_OUTBUF_SIZE / 4 && m_outbytesleft > 0) ) { - int outpos = m_zstream.next_out - m_outbuf; + int outpos = (int)(m_zstream.next_out - m_outbuf); if ( m_decodedpos > ARC_OUTBUF_SIZE/2 || outpos > ARC_OUTBUF_SIZE*2/4 || m_zstream.avail_out==0 || m_inbytesleft==0 ) { // move rest of data to beginning of buffer @@ -3173,6 +3174,16 @@ lvsize_t LVPumpStream( LVStream * out, LVStream * in ) return totalBytesRead; } +bool LVDirectoryIsEmpty(const lString8& path) { + return LVDirectoryIsEmpty(Utf8ToUnicode(path)); +} + +bool LVDirectoryIsEmpty(const lString16& path) { + LVContainerRef dir = LVOpenDirectory(path); + if (dir.isNull()) + return false; + return dir->GetObjectCount() == 0; +} LVContainerRef LVOpenDirectory(const lString16& path, const wchar_t * mask) { return LVOpenDirectory(path.c_str(), mask); @@ -3981,6 +3992,22 @@ bool LVDeleteFile( lString8 filename ) { return LVDeleteFile(Utf8ToUnicode(filename)); } +/// delete directory, return true if directory is found and successfully deleted +bool LVDeleteDirectory( lString16 filename ) { +#ifdef _WIN32 + return RemoveDirectoryW( filename.c_str() ) ? true : false; +#else + if ( unlink( UnicodeToUtf8( filename ).c_str() ) ) + return false; + return true; +#endif +} + +/// delete directory, return true if directory is found and successfully deleted +bool LVDeleteDirectory( lString8 filename ) { + return LVDeleteDirectory(Utf8ToUnicode(filename)); +} + #define TRACE_BLOCK_WRITE_STREAM 0 class LVBlockWriteStream : public LVNamedStream diff --git a/crengine/src/lvstring.cpp b/crengine/src/lvstring.cpp index a5b4d84f..1fb3eb00 100644 --- a/crengine/src/lvstring.cpp +++ b/crengine/src/lvstring.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #ifdef LINUX @@ -1051,6 +1052,49 @@ lString16 & lString16::pack() return *this; } +bool isAlNum(lChar16 ch) { + lUInt16 props = lGetCharProps(ch); + return (props & (CH_PROP_ALPHA | CH_PROP_DIGIT)) != 0; +} + +/// trims non alpha at beginning and end of string +lString16 & lString16::trimNonAlpha() +{ + int firstns; + for (firstns = 0; firstnslen && + !isAlNum(pchunk->buf16[firstns]); ++firstns) + ; + if (firstns >= pchunk->len) + { + clear(); + return *this; + } + int lastns; + for (lastns = pchunk->len-1; lastns>0 && + !isAlNum(pchunk->buf16[lastns]); --lastns) + ; + int newlen = lastns-firstns+1; + if (newlen == pchunk->len) + return *this; + if (pchunk->nref == 1) + { + if (firstns>0) + lStr_memcpy( pchunk->buf16, pchunk->buf16+firstns, newlen ); + pchunk->buf16[newlen] = 0; + pchunk->len = newlen; + } + else + { + lstring_chunk_t * poldchunk = pchunk; + release(); + alloc( newlen ); + _lStr_memcpy( pchunk->buf16, poldchunk->buf16+firstns, newlen ); + pchunk->buf16[newlen] = 0; + pchunk->len = newlen; + } + return *this; +} + lString16 & lString16::trim() { // @@ -2357,7 +2401,7 @@ lString8 & lString8::trim() (pchunk->buf8[lastns]==' ' || pchunk->buf8[lastns]=='\t'); --lastns) ; - int newlen = lastns-firstns+1; + int newlen = (int)(lastns - firstns + 1); if (newlen == pchunk->len) return *this; if (pchunk->nref == 1) @@ -2677,7 +2721,7 @@ int TrimDoubleSpaces(lChar16 * buf, int len, bool allowStartSpace, bool allowEn state = 2; } } - return pdst - buf; + return (int)(pdst - buf); } lString16 & lString16::trimDoubleSpaces( bool allowStartSpace, bool allowEndSpace, bool removeEolHyphens ) @@ -2939,8 +2983,8 @@ void Utf8ToUnicode(const lUInt8 * src, int &srclen, lChar16 * dst, int &dstlen) s += 6; } } - srclen = s - src; - dstlen = p - dst; + srclen = (int)(s - src); + dstlen = (int)(p - dst); } lString16 Utf8ToUnicode( const char * s ) { @@ -4295,7 +4339,7 @@ void CRLog::info( const char * msg, ... ) return; va_list args; va_start( args, msg ); - CRLOG->log( "WARN", msg, args ); + CRLOG->log( "INFO", msg, args ); va_end(args); } @@ -4433,7 +4477,7 @@ bool lString8::startsWith( const char * substring ) const { if (!substring || !substring[0]) return true; - int len = strlen(substring); + int len = (int)strlen(substring); if (length() < len) return false; const lChar8 * s1 = c_str(); @@ -4465,7 +4509,7 @@ bool lString8::endsWith( const lChar8 * substring ) const { if ( !substring || !*substring ) return true; - int len = strlen(substring); + int len = (int)strlen(substring); if ( length() < len ) return false; const lChar8 * s1 = c_str() + (length()-len); diff --git a/crengine/src/lvstsheet.cpp b/crengine/src/lvstsheet.cpp index 98602f48..f0261d31 100644 --- a/crengine/src/lvstsheet.cpp +++ b/crengine/src/lvstsheet.cpp @@ -1408,6 +1408,7 @@ lUInt32 LVCssSelector::getHash() hash = hash * 31 + nextHash; if (!_decl.isNull()) hash = hash * 31 + _decl->getHash(); + //CRLog::trace("selector hash: %8x", hash); return hash; } @@ -1419,6 +1420,7 @@ lUInt32 LVStyleSheet::getHash() if ( _selectors[i] ) hash = hash * 31 + _selectors[i]->getHash() + i*15324; } + //CRLog::trace("LVStyleSheet::getHash() selector count: %d hash: %x", _selectors.length(), hash); return hash; } diff --git a/crengine/src/lvtinydom.cpp b/crengine/src/lvtinydom.cpp index dd7a7f81..231ed7de 100755 --- a/crengine/src/lvtinydom.cpp +++ b/crengine/src/lvtinydom.cpp @@ -13,7 +13,7 @@ /// change in case of incompatible changes in swap/cache file format to avoid using incompatible swap file // increment to force complete reload/reparsing of old file -#define CACHE_FILE_FORMAT_VERSION "3.12.52" +#define CACHE_FILE_FORMAT_VERSION "3.12.53" /// increment following value to force re-formatting of old book after load #define FORMATTING_VERSION_ID 0x0003 @@ -3180,7 +3180,7 @@ bool ldomDocument::setRenderProps( int width, int dy, bool /*showCover*/, int /* changed = true; } if ( _page_height != dy ) { - CRLog::trace("ldomDocument::setRenderProps() - page height is changed"); + CRLog::trace("ldomDocument::setRenderProps() - page height is changed: %d != %d", _page_height, dy); _page_height = dy; changed = true; } @@ -8179,15 +8179,6 @@ bool ldomDocument::loadCacheFileContent(CacheLoadingCallback * formatCallback) return false; } - if ( formatCallback ) { - int fmt = getProps()->getIntDef(DOC_PROP_FILE_FORMAT_ID, - doc_format_fb2); - if (fmt < doc_format_fb2 || fmt > doc_format_max) - fmt = doc_format_fb2; - // notify about format detection, to allow setting format-specific CSS - formatCallback->OnCacheFileFormatDetected((doc_format_t)fmt); - } - CRLog::trace("ldomDocument::loadCacheFileContent() - ID data"); SerialBuf idbuf(0, true); if ( !_cacheFile->read( CBT_MAPS_DATA, idbuf ) ) { @@ -8242,7 +8233,7 @@ bool ldomDocument::loadCacheFileContent(CacheLoadingCallback * formatCallback) return false; } _hdr = h; - CRLog::info("Loaded render properties: styleHash=%x, stylesheetHash=%x, docflags=%x, width=%x, height=%x", + CRLog::info("Loaded render properties: styleHash=%x, stylesheetHash=%x, docflags=%04x, width=%d, height=%d", _hdr.render_style_hash, _hdr.stylesheet_hash, _hdr.render_docflags, _hdr.render_dx, _hdr.render_dy); } @@ -8286,6 +8277,15 @@ bool ldomDocument::loadCacheFileContent(CacheLoadingCallback * formatCallback) } } + if ( formatCallback ) { + int fmt = getProps()->getIntDef(DOC_PROP_FILE_FORMAT_ID, + doc_format_fb2); + if (fmt < doc_format_fb2 || fmt > doc_format_max) + fmt = doc_format_fb2; + // notify about format detection, to allow setting format-specific CSS + formatCallback->OnCacheFileFormatDetected((doc_format_t)fmt); + } + if ( loadStylesData() ) { CRLog::trace("ldomDocument::loadCacheFileContent() - using loaded styles"); updateLoadedStyles( true ); @@ -8461,7 +8461,7 @@ ContinuousOperationResult ldomDocument::saveChanges( CRTimerUtil & maxTime ) return CR_ERROR; } } - CRLog::info("Saving render properties: styleHash=%x, stylesheetHash=%x, docflags=%x, width=%x, height=%x", + CRLog::info("Saving render properties: styleHash=%x, stylesheetHash=%x, docflags=%04x, width=%d, height=%d", _hdr.render_style_hash, _hdr.stylesheet_hash, _hdr.render_docflags, _hdr.render_dx, _hdr.render_dy); @@ -8573,7 +8573,7 @@ bool tinyNodeCollection::loadStylesData() stylebuf.checkMagic(styles_magic); stylebuf >> stHash; if ( stHash != myHash ) { - CRLog::info("tinyNodeCollection::loadStylesData() - stylesheet hash is changed: skip loading styles"); + CRLog::info("tinyNodeCollection::loadStylesData() - stylesheet hash is changed: skip loading styles %08x != %08x", stHash, myHash); return false; } stylebuf >> len; // index @@ -9249,7 +9249,7 @@ void ldomDocument::updateRenderContext() _hdr.render_dx = dx; _hdr.render_dy = dy; _hdr.render_docflags = _docFlags; - CRLog::info("Updating render properties: styleHash=%x, stylesheetHash=%x, docflags=%x, width=%x, height=%x", + CRLog::info("Updating render properties: styleHash=%x, stylesheetHash=%x, docflags=%04x, width=%d, height=%d", _hdr.render_style_hash, _hdr.stylesheet_hash, _hdr.render_docflags, _hdr.render_dx, _hdr.render_dy); } @@ -9297,7 +9297,7 @@ bool ldomDocument::checkRenderContext() // _hdr.render_dx = dx; // _hdr.render_dy = dy; // _hdr.render_docflags = _docFlags; -// CRLog::info("New render properties: styleHash=%x, stylesheetHash=%x, docflags=%x, width=%x, height=%x", +// CRLog::info("New render properties: styleHash=%x, stylesheetHash=%x, docflags=%04x, width=%d, height=%d", // _hdr.render_style_hash, _hdr.stylesheet_hash, _hdr.render_docflags, _hdr.render_dx, _hdr.render_dy); return false; } @@ -9306,6 +9306,9 @@ bool ldomDocument::checkRenderContext() void lxmlDocBase::setStyleSheet( const char * css, bool replace ) { + lString8 s(css); + + //CRLog::trace("lxmlDocBase::setStyleSheet(length:%d replace:%s css text hash: %x)", strlen(css), replace ? "yes" : "no", s.getHash()); lUInt32 oldHash = _stylesheet.getHash(); if ( replace ) { //CRLog::debug("cleaning stylesheet contents"); @@ -11179,17 +11182,40 @@ void ldomDocument::registerEmbeddedFonts() { if (_fontList.empty()) return; - for (int i=0; i<_fontList.length(); i++) { - LVEmbeddedFontDef * item = _fontList.get(i); + int list = _fontList.length(); + lString8 lastface = lString8(""); + for (int i = list; i > 0; i--) { + LVEmbeddedFontDef *item = _fontList.get(i - 1); lString16 url = item->getUrl(); + lString8 face = item->getFace(); + if (face.empty()) face = lastface; + else lastface = face; + CRLog::debug("url is %s\n", UnicodeToLocal(url).c_str()); if (url.startsWithNoCase(lString16("res://")) || url.startsWithNoCase(lString16("file://"))) { if (!fontMan->RegisterExternalFont(item->getUrl(), item->getFace(), item->getBold(), item->getItalic())) { CRLog::error("Failed to register external font face: %s file: %s", item->getFace().c_str(), LCSTR(item->getUrl())); } continue; } - if (!fontMan->RegisterDocumentFont(getDocIndex(), _container, item->getUrl(), item->getFace(), item->getBold(), item->getItalic())) { - CRLog::error("Failed to register document font face: %s file: %s", item->getFace().c_str(), LCSTR(item->getUrl())); + else { + if (!fontMan->RegisterDocumentFont(getDocIndex(), _container, item->getUrl(), item->getFace(), item->getBold(), item->getItalic())) { + CRLog::error("Failed to register document font face: %s file: %s", item->getFace().c_str(), LCSTR(item->getUrl())); + lString16Collection flist; + fontMan->getFaceList(flist); + int cnt = flist.length(); + lString16 fontface = lString16(""); + CRLog::debug("fontlist has %d fontfaces\n", cnt); + for (int j = 0; j < cnt; j = j + 1) { + fontface = flist[j]; + do { (fontface.replace(lString16(" "), lString16("\0"))); } + while (fontface.pos(lString16(" ")) != -1); + if (fontface.lowercase().pos(url.lowercase()) != -1) { + CRLog::debug("****found %s\n", UnicodeToLocal(fontface).c_str()); + fontMan->setalias(face, UnicodeToLocal(flist[j]), getDocIndex(),item->getItalic(),item->getBold()) ; + break; + } + } + } } } } diff --git a/crengine/src/lvxml.cpp b/crengine/src/lvxml.cpp index 0ea57189..98c586d6 100644 --- a/crengine/src/lvxml.cpp +++ b/crengine/src/lvxml.cpp @@ -100,7 +100,7 @@ void LVFileParserBase::updateProgress() m_progressUpdateCounter = (m_progressUpdateCounter + 1) & PROGRESS_UPDATE_RATE_MASK; if ( m_progressUpdateCounter!=0 ) return; // to speed up checks - time_t t = (time_t)time((time_t)0); + time_t t = (time_t)time(NULL); if ( m_lastProgressTime==0 ) { m_lastProgressTime = t; return; diff --git a/crengine/src/props.cpp b/crengine/src/props.cpp index 67e6c681..68b9b81e 100644 --- a/crengine/src/props.cpp +++ b/crengine/src/props.cpp @@ -604,8 +604,8 @@ bool CRPropAccessor::loadFromStream( LVStream * stream ) elp++; } if ( eqpos!=NULL && eqpos>p && *elp!='#' ) { - lString8 name( p, eqpos-p ); - lString8 value( eqpos+1, elp - eqpos - 1); + lString8 name( p, (int)(eqpos - p) ); + lString8 value( eqpos+1, (int)(elp - eqpos - 1)); setString( name.c_str(), Utf8ToUnicode(removeBackslashChars(value)) ); } for ( p=elp; *elp && *elp!='\r' && *elp!='\n'; elp++) diff --git a/crengine/src/rtfimp.cpp b/crengine/src/rtfimp.cpp index cf631b82..d7493c61 100644 --- a/crengine/src/rtfimp.cpp +++ b/crengine/src/rtfimp.cpp @@ -561,7 +561,7 @@ bool LVRtfParser::Parse() p++; OnControlWord( cwname, PARAM_VALUE_NONE, asteriskFlag ); } - m_buf_pos += p - (m_buf + m_buf_pos); + m_buf_pos += (int)(p - (m_buf + m_buf_pos)); } else { //lChar16 txtch = 0; if ( ch=='\\' ) { @@ -588,7 +588,7 @@ bool LVRtfParser::Parse() } //======================================================= //======================================================= - m_buf_pos += p - (m_buf + m_buf_pos); + m_buf_pos += (int)(p - (m_buf + m_buf_pos)); } } m_callback->OnStop(); diff --git a/crengine/src/wordfmt.cpp b/crengine/src/wordfmt.cpp index 34f3bac6..c3358704 100644 --- a/crengine/src/wordfmt.cpp +++ b/crengine/src/wordfmt.cpp @@ -23,7 +23,7 @@ #ifdef _WIN32 extern "C" { int strcasecmp(const char *s1, const char *s2) { - return stricmp(s1,s2); + return _stricmp(s1,s2); } //char *optarg = NULL; // int optind = 0; @@ -286,7 +286,7 @@ vSubstring2Diagram(diagram_type *pDiag, UCHAR ucFontColor, USHORT usFontstyle, drawfile_fontref tFontRef, USHORT usFontSize, USHORT usMaxFontSize) { - lString16 s( szString, tStringLength); + lString16 s( szString, (int)tStringLength); #ifdef _LINUX TRACE("antiword::vSubstring2Diagram(%s)", LCSTR(s)); #else @@ -631,7 +631,7 @@ bReadBytes(UCHAR *aucBytes, size_t tMemb, ULONG ulOffset, FILE *pFile) return FALSE; } lvsize_t bytesRead=0; - if ( stream->Read(aucBytes, tMemb*sizeof(UCHAR), &bytesRead)!=LVERR_OK || bytesRead!=tMemb ) { + if ( stream->Read(aucBytes, tMemb*sizeof(UCHAR), &bytesRead)!=LVERR_OK || bytesRead != (lvsize_t)tMemb ) { return FALSE; } } else { @@ -682,8 +682,8 @@ bTranslateImage(diagram_type *pDiag, FILE *pFile, BOOL bMinimalInformation, case imagetype_is_jpeg: case imagetype_is_png: { - lUInt32 offset = ulFileOffsetImage + pImg->tPosition; - lUInt32 len = pImg->tLength - pImg->tPosition; + lUInt32 offset = (lUInt32)(ulFileOffsetImage + pImg->tPosition); + lUInt32 len = lUInt32(pImg->tLength - pImg->tPosition); if (!bSetDataOffset(pFile, offset)) { return FALSE;