From 060ae5d3483fb4f060ecbbf2d706c1159b760114 Mon Sep 17 00:00:00 2001 From: Michael Vrhel Date: Fri, 27 Feb 2015 07:52:56 -0800 Subject: gsview and windows: Fixes for changes in mupdf API Also a few fixes in the project files based upon recent updates. --- platform/windows/gsview/mudocument.cs | 17 +- platform/windows/libmupdf/libmupdf.vcxproj | 19 +- platform/windows/libmupdf/libmupdf.vcxproj.filters | 66 ++- platform/windows/libmupdf_winRT.vcxproj | 21 +- platform/windows/libmupdf_winRT.vcxproj.filters | 484 +++++++++++---------- platform/windows/mupdfnet/mupdfnet.cpp | 6 +- platform/windows/mupdfnet/mupdfnet.h | 6 +- platform/windows/mupdfwinrt/muctx.cpp | 171 ++++---- platform/windows/mupdfwinrt/muctx.h | 1 + 9 files changed, 445 insertions(+), 346 deletions(-) (limited to 'platform/windows') diff --git a/platform/windows/gsview/mudocument.cs b/platform/windows/gsview/mudocument.cs index e41de6e3..eb7afac6 100644 --- a/platform/windows/gsview/mudocument.cs +++ b/platform/windows/gsview/mudocument.cs @@ -217,8 +217,8 @@ namespace gsview [DllImport("mupdfnet64.dll", EntryPoint = "mGetTextCharacter", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] - private static extern int mGetTextCharacter64(IntPtr textpage, int block_num, - int line_num, int item_num, ref double top_x, + private static extern int mGetTextCharacter64(IntPtr ctx, IntPtr textpage, + int block_num, int line_num, int item_num, ref double top_x, ref double top_y, ref double height, ref double width); [DllImport("mupdfnet64.dll", EntryPoint = "mExtractPages", CharSet = CharSet.Auto, @@ -371,8 +371,8 @@ namespace gsview [DllImport("mupdfnet32.dll", EntryPoint = "mGetTextCharacter", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] - private static extern int mGetTextCharacter32(IntPtr textpage, int block_num, - int line_num, int item_num, ref double top_x, + private static extern int mGetTextCharacter32(IntPtr ctx, IntPtr textpage, + int block_num, int line_num, int item_num, ref double top_x, ref double top_y, ref double height, ref double width); [DllImport("mupdfnet32.dll", EntryPoint = "mExtractPages", CharSet = CharSet.Auto, @@ -1127,7 +1127,7 @@ namespace gsview return output; } - private int tc_mGetTextCharacter(IntPtr textpage, int block_num, + private int tc_mGetTextCharacter(IntPtr ctx, IntPtr textpage, int block_num, int line_num, int item_num, ref double top_x, ref double top_y, ref double height, ref double width) { @@ -1135,10 +1135,10 @@ namespace gsview try { if (is64bit) - output = mGetTextCharacter64(textpage, block_num, line_num, + output = mGetTextCharacter64(ctx, textpage, block_num, line_num, item_num, ref top_x, ref top_y, ref height, ref width); else - output = mGetTextCharacter32(textpage, block_num, line_num, + output = mGetTextCharacter32(ctx, textpage, block_num, line_num, item_num, ref top_x, ref top_y, ref height, ref width); } catch (DllNotFoundException) @@ -1404,7 +1404,8 @@ namespace gsview for (int mm = 0; mm < num_chars; mm++) { var textchars = new TextCharacter(); - int character = tc_mGetTextCharacter(text, kk, jj, mm, ref top_x, + int character = tc_mGetTextCharacter(mu_object, + text, kk, jj, mm, ref top_x, ref top_y, ref height, ref width); textchars.X = top_x; textchars.Y = top_y; diff --git a/platform/windows/libmupdf/libmupdf.vcxproj b/platform/windows/libmupdf/libmupdf.vcxproj index 78df5e8d..cfea7582 100644 --- a/platform/windows/libmupdf/libmupdf.vcxproj +++ b/platform/windows/libmupdf/libmupdf.vcxproj @@ -19,7 +19,6 @@ - @@ -58,9 +57,10 @@ + - + @@ -82,7 +82,6 @@ - @@ -91,6 +90,8 @@ + + @@ -157,18 +158,27 @@ + + + - + + + + + + + @@ -211,7 +221,6 @@ - diff --git a/platform/windows/libmupdf/libmupdf.vcxproj.filters b/platform/windows/libmupdf/libmupdf.vcxproj.filters index 62f050df..e08a9dfd 100644 --- a/platform/windows/libmupdf/libmupdf.vcxproj.filters +++ b/platform/windows/libmupdf/libmupdf.vcxproj.filters @@ -16,32 +16,23 @@ {71d27c79-d67f-4b0e-8a5c-ad2355c905b1} - - {7f13938e-5486-404e-8c72-1cb35d92d68b} - {766fb080-9cd3-4755-a074-a20a7f1748b8} - - {e464f8d3-dcda-4cbe-bae2-48bdc6f0afd7} - {92cc8877-4351-49e6-8a73-9696779675ed} {6350172f-767f-4cdd-8c14-3a9e5af8d4c4} + + {cb023422-71c6-4ca1-beb1-28a9e92764fc} + - - !include - !include - - !include - !include @@ -171,9 +162,6 @@ !include\fitz - - !include\fitz - !include\pdf @@ -240,6 +228,12 @@ pdf + + !include + + + !include\fitz + @@ -467,9 +461,6 @@ fitz - - img - pdf @@ -596,9 +587,6 @@ pdf - - tiff - tools @@ -644,5 +632,41 @@ fitz + + pdf + + + html + + + html + + + html + + + html + + + html + + + html + + + fitz + + + fitz + + + fitz + + + cbz + + + cbz + \ No newline at end of file diff --git a/platform/windows/libmupdf_winRT.vcxproj b/platform/windows/libmupdf_winRT.vcxproj index 525a59d1..b29c66b4 100644 --- a/platform/windows/libmupdf_winRT.vcxproj +++ b/platform/windows/libmupdf_winRT.vcxproj @@ -40,6 +40,8 @@ + + @@ -106,18 +108,27 @@ + + + - + + + + + + + @@ -160,7 +171,6 @@ - @@ -192,6 +202,7 @@ + @@ -203,6 +214,7 @@ + @@ -214,9 +226,12 @@ + + + - + diff --git a/platform/windows/libmupdf_winRT.vcxproj.filters b/platform/windows/libmupdf_winRT.vcxproj.filters index 86036ee8..d964561c 100644 --- a/platform/windows/libmupdf_winRT.vcxproj.filters +++ b/platform/windows/libmupdf_winRT.vcxproj.filters @@ -10,18 +10,12 @@ {7b0f7938-a977-4cd9-a8bc-aeef816ae84c} - - {631e9425-7a6a-4529-95c8-06ea5b145899} - {8de280a7-9403-401a-8ab5-bf7f0ce3a27f} {ebee942a-03ff-4a0b-8e41-1ffa2a16d448} - - {87d18a14-080e-4bad-8db6-c9df888baa1c} - {ec1b8208-f4f4-4c3f-a071-dcecc79bbd72} @@ -34,57 +28,99 @@ {4e3d83f6-3258-4f7b-8174-bc825377658e} + + {357f89f4-4c0a-4661-b81d-6173c5bdb134} + - - !include\fitz - cbz - + + tools + + + xps + + + xps + + + xps + + + xps + + + xps + + + xps + + + xps + + + xps + + + xps + + + xps + + + xps + + + cbz + + + cbz + + fitz - + fitz - + fitz - + fitz - + fitz - + fitz - + fitz - + fitz - + fitz - + fitz - + fitz - + fitz - + fitz - + fitz - + fitz @@ -99,9 +135,6 @@ fitz - - fitz - fitz @@ -111,9 +144,6 @@ fitz - - fitz - fitz @@ -147,15 +177,9 @@ fitz - - fitz - fitz - - fitz - fitz @@ -168,15 +192,6 @@ fitz - - fitz - - - fitz - - - fitz - fitz @@ -192,13 +207,13 @@ fitz - + fitz - + fitz - + fitz @@ -207,9 +222,6 @@ fitz - - fitz - fitz @@ -219,9 +231,6 @@ fitz - - fitz - fitz @@ -231,58 +240,103 @@ fitz + + fitz + fitz + + fitz + + + fitz + + + fitz + fitz - + fitz - + + fitz + + + fitz + + + fitz + + + fitz + + + fitz + + + fitz + + + fitz + + + fitz + + fitz fitz - + fitz - + fitz fitz - + fitz - + fitz - - img + + fitz + + + fitz + + + fitz + + + fitz pdf - + pdf - + pdf - + pdf - + pdf - + pdf - + pdf @@ -294,9 +348,6 @@ pdf - - pdf - pdf @@ -324,9 +375,6 @@ pdf - - pdf - pdf @@ -384,68 +432,155 @@ pdf - - pdf - pdf - - tiff - - - tools - - - xps - - - xps - - - xps - - - xps - - - xps + + pdf - - xps + + pdf - - xps + + pdf - - xps + + pdf - - xps + + html - - xps + + html - - xps + + html - - fitz + + html - - fitz + + html - - fitz + + html + + !include\pdf + + + !include\pdf + + + !include\pdf + + + !include\pdf + + + !include\pdf + + + !include\pdf + + + !include\pdf + + + !include\pdf + + + !include\pdf + + + !include\pdf + + + !include\pdf + + + !include\pdf + + + !include\pdf + + + !include\pdf + + + !include\pdf + + + !include + + + !include + + + !include + + + !include + + + !include + + + !include\pdf + + + !include + + + !include + + + !include\fitz + + + !include\fitz + + + !include\fitz + + + !include\fitz + + + !include\fitz + + + !include\fitz + + + !include\fitz + + + !include\fitz + + + !include\fitz + + + !include\fitz + + + !include\fitz + + + !include\fitz + !include\fitz !include\fitz + + !include\fitz + !include\fitz @@ -485,6 +620,9 @@ !include\fitz + + !include\fitz + !include\fitz @@ -515,121 +653,25 @@ !include\fitz - - !include\fitz - - - !include\fitz - - - !include\fitz - - - !include\fitz - - - !include\fitz - - - !include\fitz - - - !include\fitz - - - !include\fitz - - - !include\fitz - - + !include\fitz - + !include\fitz - + !include\fitz - + !include\fitz - + !include\fitz - - !include\pdf - - - !include\pdf - - - !include\pdf - - - !include\pdf - - - !include\pdf - - - !include\pdf - - - !include\pdf - - - !include\pdf - - - !include\pdf - - - !include\pdf - - - !include\pdf - - - !include\pdf - - - !include\pdf - - - !include\pdf - - - !include\pdf - - - !include - - - !include - - - !include - - - !include - - - !include - - - !include - - - !include\pdf - - - !include + + fitz - !include\fitz - - fitz @@ -638,13 +680,13 @@ fitz - + pdf - + pdf - + pdf diff --git a/platform/windows/mupdfnet/mupdfnet.cpp b/platform/windows/mupdfnet/mupdfnet.cpp index a778537a..c544bcd9 100644 --- a/platform/windows/mupdfnet/mupdfnet.cpp +++ b/platform/windows/mupdfnet/mupdfnet.cpp @@ -356,7 +356,7 @@ SYMBOL_DECLSPEC int __stdcall mGetTextLine(void *page, int block_num, int line_n } /* Information down to the character level */ -SYMBOL_DECLSPEC int __stdcall mGetTextCharacter(void *page, int block_num, int line_num, +SYMBOL_DECLSPEC int __stdcall mGetTextCharacter(void *ctx, void *page, int block_num, int line_num, int item_num, double *top_x, double *top_y, double *height, double *width) { fz_text_block *block; @@ -365,6 +365,7 @@ SYMBOL_DECLSPEC int __stdcall mGetTextCharacter(void *page, int block_num, int l fz_text_page *text = (fz_text_page*)page; fz_char_and_box cab; int index = item_num; + muctx *mu_ctx = static_cast(ctx); block = text->blocks[block_num].u.text; line = block->lines[line_num]; @@ -377,7 +378,8 @@ SYMBOL_DECLSPEC int __stdcall mGetTextCharacter(void *page, int block_num, int l } cab.c = span->text[index].c; - fz_text_char_bbox(&(cab.bbox), span, index); + mu_ctx->GetCharBBox(&(cab.bbox), span, index); + *top_x = cab.bbox.x0; *top_y = cab.bbox.y0; *height = cab.bbox.y1 - *top_y; diff --git a/platform/windows/mupdfnet/mupdfnet.h b/platform/windows/mupdfnet/mupdfnet.h index 44a4382b..b300b1f6 100644 --- a/platform/windows/mupdfnet/mupdfnet.h +++ b/platform/windows/mupdfnet/mupdfnet.h @@ -63,9 +63,9 @@ EXTERN_C SYMBOL_DECLSPEC int __stdcall mGetTextBlock(void *text, int block_num, EXTERN_C SYMBOL_DECLSPEC int __stdcall mGetTextLine(void *text, int block_num, int line_num, double *top_x, double *top_y, double *height, double *width); -EXTERN_C SYMBOL_DECLSPEC int __stdcall mGetTextCharacter(void *text, int block_num, - int line_num, int item_num, double *top_x, double *top_y, double *height, - double *width); +EXTERN_C SYMBOL_DECLSPEC int __stdcall mGetTextCharacter(void *ctx, void *text, + int block_num, int line_num, int item_num, double *top_x, double *top_y, + double *height, double *width); EXTERN_C SYMBOL_DECLSPEC void __stdcall mReleaseText(void *ctx, void *page); diff --git a/platform/windows/mupdfwinrt/muctx.cpp b/platform/windows/mupdfwinrt/muctx.cpp index e51ea403..f5bd741b 100644 --- a/platform/windows/mupdfwinrt/muctx.cpp +++ b/platform/windows/mupdfwinrt/muctx.cpp @@ -14,7 +14,7 @@ static int textlen(fz_text_page *page); //#include //using namespace concurrency; /* File streaming set up for WinRT */ -static int win_next_file(fz_stream *stm, int len) +static int win_next_file(fz_context *ctx, fz_stream *stm, int len) { void *temp = stm->state; win_stream_struct *state = reinterpret_cast (temp); @@ -60,7 +60,7 @@ static int win_next_file(fz_stream *stm, int len) return *stm->rp++; } -static void win_seek_file(fz_stream *stm, int offset, int whence) +static void win_seek_file(fz_context *ctx, fz_stream *stm, int offset, int whence) { void *temp = stm->state; win_stream_struct *stream = reinterpret_cast (temp); @@ -97,7 +97,7 @@ static void win_close_file(fz_context *ctx, void *state) status_t muctx::InitializeStream(IRandomAccessStream^ readStream, char *ext) { win_stream.stream = readStream; - fz_stream *mu_stream = fz_new_stream(mu_ctx, 0, win_next_file, win_close_file, NULL); + fz_stream *mu_stream = fz_new_stream(mu_ctx, 0, win_next_file, win_close_file); mu_stream->seek = win_seek_file; mu_stream->state = reinterpret_cast (&win_stream); @@ -108,7 +108,7 @@ status_t muctx::InitializeStream(IRandomAccessStream^ readStream, char *ext) } fz_always(mu_ctx) { - fz_close(mu_stream); + fz_drop_stream(mu_ctx, mu_stream); } fz_catch(mu_ctx) { @@ -146,11 +146,11 @@ static void unlock_mutex(void *user, int lock) void muctx::CleanUp(void) { - fz_free_outline(mu_ctx, mu_outline); - fz_close_document(mu_doc); + fz_drop_outline(mu_ctx, mu_outline); + fz_drop_document(mu_ctx, mu_doc); page_cache->Empty(mu_ctx); annot_cache->Empty(mu_ctx); - fz_free_context(mu_ctx); + fz_drop_context(mu_ctx); delete page_cache; delete annot_cache; @@ -204,11 +204,11 @@ muctx::muctx(void) /* Destructor */ muctx::~muctx(void) { - fz_free_outline(mu_ctx, mu_outline); - fz_close_document(mu_doc); + fz_drop_outline(mu_ctx, mu_outline); + fz_drop_document(mu_ctx, mu_doc); page_cache->Empty(mu_ctx); annot_cache->Empty(mu_ctx); - fz_free_context(mu_ctx); + fz_drop_context(mu_ctx); mu_ctx = NULL; mu_doc = NULL; @@ -222,10 +222,10 @@ muctx::~muctx(void) /* Return the documents page count */ int muctx::GetPageCount() { - if (this->mu_doc == NULL) + if (mu_doc == NULL) return -1; else - return this->mu_doc->count_pages(this->mu_doc); + return this->mu_doc->count_pages(mu_ctx, mu_doc); } /* Get page size */ @@ -237,14 +237,14 @@ int muctx::MeasurePage(int page_num, point_t *size) fz_try(mu_ctx) { - page = fz_load_page(mu_doc, page_num); - bounds = fz_bound_page(mu_doc, page, &rect); + page = fz_load_page(mu_ctx, mu_doc, page_num); + bounds = fz_bound_page(mu_ctx, page, &rect); size->X = bounds->x1 - bounds->x0; size->Y = bounds->y1 - bounds->y0; } fz_always(mu_ctx) { - fz_free_page(mu_doc, page); + fz_drop_page(mu_ctx, page); } fz_catch(mu_ctx) { @@ -260,7 +260,7 @@ point_t muctx::MeasurePage(fz_page *page) fz_rect rect; fz_rect *bounds; - bounds = fz_bound_page(mu_doc, page, &rect); + bounds = fz_bound_page(mu_ctx, page, &rect); pageSize.X = bounds->x1 - bounds->x0; pageSize.Y = bounds->y1 - bounds->y0; @@ -309,7 +309,7 @@ int muctx::GetContents(sh_vector_content contents_vec) fz_var(root); fz_try(mu_ctx) { - root = fz_load_outline(mu_doc); + root = fz_load_outline(mu_ctx, mu_doc); if (root != NULL) { has_content = 1; @@ -318,7 +318,7 @@ int muctx::GetContents(sh_vector_content contents_vec) } fz_always(mu_ctx) { - fz_free_outline(mu_ctx, root); + fz_drop_outline(mu_ctx, root); } fz_catch(mu_ctx) { @@ -341,12 +341,12 @@ int muctx::GetTextSearch(int page_num, char* needle, sh_vector_text texts_vec) fz_var(dev); fz_try(mu_ctx) { - page = fz_load_page(mu_doc, page_num); + page = fz_load_page(mu_ctx, mu_doc, page_num); sheet = fz_new_text_sheet(mu_ctx); text = fz_new_text_page(mu_ctx); dev = fz_new_text_device(mu_ctx, sheet, text); - fz_run_page(mu_doc, page, dev, &fz_identity, NULL); - fz_free_device(dev); /* Why does this need to be done here? Seems odd */ + fz_run_page(mu_ctx, page, dev, &fz_identity, NULL); + fz_drop_device(mu_ctx, dev); /* Why does this need to be done here? Seems odd */ dev = NULL; hit_count = fz_search_text_page(mu_ctx, text, needle, mu_hit_bbox, nelem(mu_hit_bbox)); @@ -362,10 +362,10 @@ int muctx::GetTextSearch(int page_num, char* needle, sh_vector_text texts_vec) } fz_always(mu_ctx) { - fz_free_page(mu_doc, page); - fz_free_device(dev); - fz_free_text_sheet(mu_ctx, sheet); - fz_free_text_page(mu_ctx, text); + fz_drop_page(mu_ctx, page); + fz_drop_device(mu_ctx, dev); + fz_drop_text_sheet(mu_ctx, sheet); + fz_drop_text_page(mu_ctx, text); } fz_catch(mu_ctx) { @@ -386,8 +386,8 @@ unsigned int muctx::GetLinks(int page_num, sh_vector_link links_vec) fz_var(links); fz_try(mu_ctx) { - page = fz_load_page(mu_doc, page_num); - links = fz_load_links(mu_doc, page); + page = fz_load_page(mu_ctx, mu_doc, page_num); + links = fz_load_links(mu_ctx, page); fz_link *curr_link = links; if (curr_link != NULL) @@ -433,7 +433,7 @@ unsigned int muctx::GetLinks(int page_num, sh_vector_link links_vec) } fz_always(mu_ctx) { - fz_free_page(mu_doc, page); + fz_drop_page(mu_ctx, page); fz_drop_link(mu_ctx, links); } fz_catch(mu_ctx) @@ -462,23 +462,23 @@ fz_display_list * muctx::CreateAnnotationList(int page_num) fz_try(mu_ctx) { fz_annot *annot; - page = fz_load_page(mu_doc, page_num); - annot = fz_first_annot(mu_doc, page); + page = fz_load_page(mu_ctx, mu_doc, page_num); + annot = fz_first_annot(mu_ctx, page); if (annot != NULL) { /* Create display list */ dlist = fz_new_display_list(mu_ctx); dev = fz_new_list_device(mu_ctx, dlist); - for (annot = fz_first_annot(mu_doc, page); annot; annot = fz_next_annot(mu_doc, annot)) - fz_run_annot(mu_doc, page, annot, dev, &fz_identity, NULL); + for (annot = fz_first_annot(mu_ctx, page); annot; annot = fz_next_annot(mu_ctx, page, annot)) + fz_run_annot(mu_ctx, page, annot, dev, &fz_identity, NULL); annot_cache->Add(page_num, 0, 0, dlist, mu_ctx); } } fz_always(mu_ctx) { - fz_free_device(dev); - fz_free_page(mu_doc, page); + fz_drop_device(mu_ctx, dev); + fz_drop_page(mu_ctx, page); } fz_catch(mu_ctx) { @@ -506,12 +506,12 @@ fz_display_list * muctx::CreateDisplayList(int page_num, int *width, int *height fz_try(mu_ctx) { - page = fz_load_page(mu_doc, page_num); + page = fz_load_page(mu_ctx, mu_doc, page_num); /* Create a new list */ dlist = fz_new_display_list(mu_ctx); dev = fz_new_list_device(mu_ctx, dlist); - fz_run_page_contents(mu_doc, page, dev, &fz_identity, NULL); + fz_run_page_contents(mu_ctx, page, dev, &fz_identity, NULL); page_size = MeasurePage(page); *width = page_size.X; *height = page_size.Y; @@ -520,8 +520,8 @@ fz_display_list * muctx::CreateDisplayList(int page_num, int *width, int *height } fz_always(mu_ctx) { - fz_free_device(dev); - fz_free_page(mu_doc, page); + fz_drop_device(mu_ctx, dev); + fz_drop_page(mu_ctx, page); } fz_catch(mu_ctx) { @@ -575,7 +575,7 @@ fz_display_list * muctx::CreateDisplayListText(int page_num, int *width, int *he fz_try(mu_ctx) { - page = fz_load_page(mu_doc, page_num); + page = fz_load_page(mu_ctx,mu_doc, page_num); sheet = fz_new_text_sheet(mu_ctx); text = fz_new_text_page(mu_ctx); @@ -585,14 +585,14 @@ fz_display_list * muctx::CreateDisplayListText(int page_num, int *width, int *he /* Deal with text device */ textdev = fz_new_text_device(mu_ctx, sheet, text); - fz_run_page(mu_doc, page, textdev, &fz_identity, NULL); + fz_run_page(mu_ctx, page, textdev, &fz_identity, NULL); *length = text->len; - fz_free_device(textdev); + fz_drop_device(mu_ctx, textdev); textdev = NULL; *text_out = text; - fz_run_page_contents(mu_doc, page, dev, &fz_identity, NULL); + fz_run_page_contents(mu_ctx, page, dev, &fz_identity, NULL); page_size = MeasurePage(page); *width = page_size.X; *height = page_size.Y; @@ -601,9 +601,9 @@ fz_display_list * muctx::CreateDisplayListText(int page_num, int *width, int *he } fz_always(mu_ctx) { - fz_free_device(dev); - fz_free_page(mu_doc, page); - fz_free_text_sheet(mu_ctx, sheet); + fz_drop_device(mu_ctx, dev); + fz_drop_page(mu_ctx, page); + fz_drop_text_sheet(mu_ctx, sheet); } fz_catch(mu_ctx) @@ -654,22 +654,22 @@ status_t muctx::RenderPageMT(void *dlist, void *a_dlist, int page_width, int pag bmp_width, bmp_height, bmp_data); fz_clear_pixmap_with_value(ctx_clone, pix, 255); dev = fz_new_draw_device(ctx_clone, pix); - fz_run_display_list(display_list, dev, pctm, NULL, NULL); + fz_run_display_list(ctx_clone, display_list, dev, pctm, NULL, NULL); if (annot_displaylist != NULL) - fz_run_display_list(annot_displaylist, dev, pctm, NULL, NULL); + fz_run_display_list(ctx_clone, annot_displaylist, dev, pctm, NULL, NULL); } fz_always(ctx_clone) { - fz_free_device(dev); + fz_drop_device(ctx_clone, dev); fz_drop_pixmap(ctx_clone, pix); } fz_catch(ctx_clone) { - fz_free_context(ctx_clone); + fz_drop_context(ctx_clone); return E_FAILURE; } - fz_free_context(ctx_clone); + fz_drop_context(ctx_clone); return S_ISOK; } @@ -689,7 +689,7 @@ status_t muctx::RenderPage(int page_num, unsigned char *bmp_data, int bmp_width, fz_try(mu_ctx) { - page = fz_load_page(mu_doc, page_num); + page = fz_load_page(mu_ctx, mu_doc, page_num); page_size = MeasurePage(page); pctm = fz_scale(pctm, scale, scale); /* Flip on Y */ @@ -702,17 +702,17 @@ status_t muctx::RenderPage(int page_num, unsigned char *bmp_data, int bmp_width, bmp_height, bmp_data); fz_clear_pixmap_with_value(mu_ctx, pix, 255); dev = fz_new_draw_device(mu_ctx, pix); - fz_run_page_contents(mu_doc, page, dev, pctm, NULL); + fz_run_page_contents(mu_ctx, page, dev, pctm, NULL); fz_annot *annot; - for (annot = fz_first_annot(mu_doc, page); annot; annot = fz_next_annot(mu_doc, annot)) - fz_run_annot(mu_doc, page, annot, dev, pctm, NULL); + for (annot = fz_first_annot(mu_ctx, page); annot; annot = fz_next_annot(mu_ctx, page, annot)) + fz_run_annot(mu_ctx, page, annot, dev, pctm, NULL); } fz_always(mu_ctx) { - fz_free_device(dev); + fz_drop_device(mu_ctx, dev); fz_drop_pixmap(mu_ctx, pix); - fz_free_page(mu_doc, page); + fz_drop_page(mu_ctx, page); } fz_catch(mu_ctx) { @@ -723,12 +723,12 @@ status_t muctx::RenderPage(int page_num, unsigned char *bmp_data, int bmp_width, bool muctx::RequiresPassword(void) { - return fz_needs_password(mu_doc) != 0; + return fz_needs_password(mu_ctx, mu_doc) != 0; } bool muctx::ApplyPassword(char* password) { - return fz_authenticate_password(mu_doc, password) != 0; + return fz_authenticate_password(mu_ctx, mu_doc, password) != 0; } std::string muctx::GetText(int page_num, int type) @@ -748,12 +748,12 @@ std::string muctx::GetText(int page_num, int type) fz_var(buf); fz_try(mu_ctx) { - page = fz_load_page(mu_doc, page_num); + page = fz_load_page(mu_ctx, mu_doc, page_num); sheet = fz_new_text_sheet(mu_ctx); text = fz_new_text_page(mu_ctx); dev = fz_new_text_device(mu_ctx, sheet, text); - fz_run_page(mu_doc, page, dev, &fz_identity, NULL); - fz_free_device(dev); + fz_run_page(mu_ctx, page, dev, &fz_identity, NULL); + fz_drop_device(mu_ctx, dev); dev = NULL; fz_analyze_text(mu_ctx, sheet, text); buf = fz_new_buffer(mu_ctx, 256); @@ -774,10 +774,10 @@ std::string muctx::GetText(int page_num, int type) } fz_always(mu_ctx) { - fz_free_device(dev); - fz_free_page(mu_doc, page); - fz_free_text_sheet(mu_ctx, sheet); - fz_free_text_page(mu_ctx, text); + fz_drop_device(mu_ctx, dev); + fz_drop_page(mu_ctx, page); + fz_drop_text_sheet(mu_ctx, sheet); + fz_drop_text_page(mu_ctx, text); fz_drop_buffer(mu_ctx, buf); } fz_catch(mu_ctx) @@ -790,7 +790,7 @@ std::string muctx::GetText(int page_num, int type) void muctx::ReleaseText(void *text) { fz_text_page *text_page = (fz_text_page*) text; - fz_free_text_page(mu_ctx, text_page); + fz_drop_text_page(mu_ctx, text_page); } /* To do: banding */ @@ -819,8 +819,8 @@ status_t muctx::SavePage(char *filename, int page_num, int resolution, int type, fz_try(mu_ctx) { - page = fz_load_page(mu_doc, page_num); - fz_bound_page(mu_doc, page, &bounds); + page = fz_load_page(mu_ctx, mu_doc, page_num); + fz_bound_page(mu_ctx, page, &bounds); zoom = resolution / 72; fz_scale(&ctm, zoom, zoom); tbounds = bounds; @@ -836,20 +836,20 @@ status_t muctx::SavePage(char *filename, int page_num, int resolution, int type, file = fopen(filename, "wb"); if (file == NULL) fz_throw(mu_ctx, FZ_ERROR_GENERIC, "cannot open file '%s'", filename); - out = fz_new_output_with_file(mu_ctx, file); + out = fz_new_output_with_file(mu_ctx, file, 0); dev = fz_new_svg_device(mu_ctx, out, tbounds.x1 - tbounds.x0, tbounds.y1 - tbounds.y0); if (dlist != NULL) - fz_run_display_list(dlist, dev, &ctm, &tbounds, NULL); + fz_run_display_list(mu_ctx, dlist, dev, &ctm, &tbounds, NULL); else - fz_run_page(mu_doc, page, dev, &ctm, NULL); + fz_run_page(mu_ctx, page, dev, &ctm, NULL); if (annot_dlist != NULL) - fz_run_display_list(annot_dlist, dev, &ctm, &tbounds, NULL); + fz_run_display_list(mu_ctx, annot_dlist, dev, &ctm, &tbounds, NULL); else { fz_annot *annot; - for (annot = fz_first_annot(mu_doc, page); annot; annot = fz_next_annot(mu_doc, annot)) - fz_run_annot(mu_doc, page, annot, dev, &fz_identity, NULL); + for (annot = fz_first_annot(mu_ctx, page); annot; annot = fz_next_annot(mu_ctx, page, annot)) + fz_run_annot(mu_ctx, page, annot, dev, &fz_identity, NULL); } } else @@ -859,16 +859,16 @@ status_t muctx::SavePage(char *filename, int page_num, int resolution, int type, fz_clear_pixmap_with_value(mu_ctx, pix, 255); dev = fz_new_draw_device(mu_ctx, pix); if (dlist != NULL) - fz_run_display_list(dlist, dev, &ctm, &tbounds, NULL); + fz_run_display_list(mu_ctx, dlist, dev, &ctm, &tbounds, NULL); else - fz_run_page(mu_doc, page, dev, &ctm, NULL); + fz_run_page(mu_ctx, page, dev, &ctm, NULL); if (annot_dlist != NULL) - fz_run_display_list(annot_dlist, dev, &ctm, &tbounds, NULL); + fz_run_display_list(mu_ctx, annot_dlist, dev, &ctm, &tbounds, NULL); else { fz_annot *annot; - for (annot = fz_first_annot(mu_doc, page); annot; annot = fz_next_annot(mu_doc, annot)) - fz_run_annot(mu_doc, page, annot, dev, &fz_identity, NULL); + for (annot = fz_first_annot(mu_ctx, page); annot; annot = fz_next_annot(mu_ctx, page, annot)) + fz_run_annot(mu_ctx, page, annot, dev, &fz_identity, NULL); } switch (type) { @@ -890,11 +890,11 @@ status_t muctx::SavePage(char *filename, int page_num, int resolution, int type, { if (pix != NULL) fz_drop_pixmap(mu_ctx, pix); - fz_free_device(dev); - fz_free_page(mu_doc, page); + fz_drop_device(mu_ctx, dev); + fz_drop_page(mu_ctx, page); if (out != NULL) { - fz_close_output(out); + fz_drop_output(mu_ctx, out); fclose(file); } } @@ -903,4 +903,9 @@ status_t muctx::SavePage(char *filename, int page_num, int resolution, int type, return E_FAILURE; } return S_ISOK; -} \ No newline at end of file +} + +void muctx::GetCharBBox(fz_rect *rect, fz_text_span *span, int index) +{ + fz_text_char_bbox(mu_ctx, rect, span, index); +} diff --git a/platform/windows/mupdfwinrt/muctx.h b/platform/windows/mupdfwinrt/muctx.h index 5b870543..314d404b 100644 --- a/platform/windows/mupdfwinrt/muctx.h +++ b/platform/windows/mupdfwinrt/muctx.h @@ -114,6 +114,7 @@ public: bool ApplyPassword(char* password); status_t SavePage(char *filename, int pagenum, int resolution, int type, bool append); + void GetCharBBox(fz_rect *rect, fz_text_span *span, int index); #ifdef _WINRT_DLL status_t InitializeStream(IRandomAccessStream^ readStream, char *ext); -- cgit v1.2.3