From 7b861bf1835bc247bcc2016e72899f5672d0fa61 Mon Sep 17 00:00:00 2001 From: Michael Vrhel Date: Mon, 6 May 2013 12:06:31 -0700 Subject: Addition of content display into WinRT library --- winrt/mupdf_cpp/DocumentPage.h | 3 +- winrt/mupdf_cpp/LVContents.cpp | 9 --- winrt/mupdf_cpp/LVContents.h | 12 ---- winrt/mupdf_cpp/MainPage.xaml | 2 +- winrt/mupdf_cpp/MainPage.xaml.cpp | 91 +++++------------------------ winrt/mupdf_cpp/MainPage.xaml.h | 12 ---- winrt/mupdf_cpp/mupdf_cpp.vcxproj | 2 - winrt/mupdf_cpp/mupdf_cpp.vcxproj.filters | 2 - winrt/mupdfwinrt/ContentItem.cpp | 11 ++++ winrt/mupdfwinrt/ContentItem.h | 59 +++++++++++++++++++ winrt/mupdfwinrt/muctx.cpp | 72 ++++++++++++++++++++++- winrt/mupdfwinrt/muctx.h | 28 ++++++--- winrt/mupdfwinrt/mudocument.cpp | 72 ++++++++++++++--------- winrt/mupdfwinrt/mudocument.h | 41 +++++++------ winrt/mupdfwinrt/mupdfwinrt.vcxproj | 3 + winrt/mupdfwinrt/mupdfwinrt.vcxproj.filters | 3 + winrt/mupdfwinrt/utils.cpp | 28 +++++++++ winrt/mupdfwinrt/utils.h | 8 ++- 18 files changed, 285 insertions(+), 173 deletions(-) delete mode 100644 winrt/mupdf_cpp/LVContents.cpp delete mode 100644 winrt/mupdf_cpp/LVContents.h create mode 100644 winrt/mupdfwinrt/ContentItem.cpp create mode 100644 winrt/mupdfwinrt/ContentItem.h create mode 100644 winrt/mupdfwinrt/utils.cpp (limited to 'winrt') diff --git a/winrt/mupdf_cpp/DocumentPage.h b/winrt/mupdf_cpp/DocumentPage.h index 98bbeb0e..737a7f73 100644 --- a/winrt/mupdf_cpp/DocumentPage.h +++ b/winrt/mupdf_cpp/DocumentPage.h @@ -19,7 +19,8 @@ typedef enum { namespace mupdf_cpp { - [Windows::UI::Xaml::Data::Bindable] // in c++, adding this attribute to ref classes enables data binding for more info search for 'Bindable' on the page http://go.microsoft.com/fwlink/?LinkId=254639 + // enables data binding with this class + [Windows::UI::Xaml::Data::Bindable] public ref class DocumentPage sealed { diff --git a/winrt/mupdf_cpp/LVContents.cpp b/winrt/mupdf_cpp/LVContents.cpp deleted file mode 100644 index 1905c10c..00000000 --- a/winrt/mupdf_cpp/LVContents.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include "pch.h" -#include "LVContents.h" - -using namespace ListViewContents; -LVContents::LVContents(void) -{ - ContentItem = ""; - Page = -1; -} diff --git a/winrt/mupdf_cpp/LVContents.h b/winrt/mupdf_cpp/LVContents.h deleted file mode 100644 index 1ca4179c..00000000 --- a/winrt/mupdf_cpp/LVContents.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once -namespace ListViewContents { - [Windows::UI::Xaml::Data::Bindable] - public ref class LVContents sealed - { - public: - LVContents(void); - property Platform::String^ ContentItem; - property int Page; - - }; -} diff --git a/winrt/mupdf_cpp/MainPage.xaml b/winrt/mupdf_cpp/MainPage.xaml index 99ae0f3b..54318e75 100644 --- a/winrt/mupdf_cpp/MainPage.xaml +++ b/winrt/mupdf_cpp/MainPage.xaml @@ -124,7 +124,7 @@ - + diff --git a/winrt/mupdf_cpp/MainPage.xaml.cpp b/winrt/mupdf_cpp/MainPage.xaml.cpp index 2af4a552..af38b6d3 100644 --- a/winrt/mupdf_cpp/MainPage.xaml.cpp +++ b/winrt/mupdf_cpp/MainPage.xaml.cpp @@ -5,7 +5,6 @@ #include "pch.h" #include "MainPage.xaml.h" -#include "LVContents.h" #define LOOK_AHEAD 1 /* A +/- count on the pages to pre-render */ #define MIN_SCALE 0.5 @@ -32,7 +31,6 @@ using namespace Windows::UI::Xaml::Data; using namespace Windows::UI::Xaml::Media; using namespace Windows::UI::Xaml::Navigation; using namespace Windows::Graphics::Display; -using namespace ListViewContents; //****************** Added ***************** using namespace Windows::Storage::Pickers; @@ -91,7 +89,6 @@ MainPage::MainPage() // Create the image brush m_renderedImage = ref new ImageBrush(); - m_content.num = 0; mu_doc = nullptr; m_docPages = ref new Platform::Collections::Vector(); CleanUp(); @@ -408,15 +405,6 @@ void mupdf_cpp::MainPage::CleanUp() m_thumb_page_start = 0; m_thumb_page_stop = 0; m_links_on = false; - - if (m_content.num) - { - //m_content.page->; - // m_content.string_margin->Dispose(); - //m_content.string_orig->Dispose(); - m_content.num = 0; - } - m_curr_zoom = 1.0; m_canvas_translate.X = 0; m_canvas_translate.Y = 0; @@ -1193,7 +1181,7 @@ void mupdf_cpp::MainPage::Linker(Platform::Object^ sender, Windows::UI::Xaml::Ro void mupdf_cpp::MainPage::AddLinkCanvas() { - return; + return; /* This is disabled for now until I figure out how to add the canvas with rects into the data template for the scroll view object */ if (m_links_on) @@ -1349,45 +1337,11 @@ int mupdf_cpp::MainPage::JumpToLink(int index) return 0; } -void mupdf_cpp::MainPage::FlattenOutline(fz_outline *outline, int level) -{ -#if 0 - char indent[8*4+1]; - if (level > 8) - level = 8; - memset(indent, ' ', level * 4); - indent[level * 4] = 0; - - String^ indent_str = char_to_String(indent); - String^ str_indent; - - while (outline) - { - if (outline->dest.kind == FZ_LINK_GOTO) - { - int page = outline->dest.ld.gotor.page; - if (page >= 0 && outline->title) - { - /* Add to the contents */ - m_content.page->Append(page); - String^ str = char_to_String(outline->title); - m_content.string_orig->Append(str); - str_indent = str_indent->Concat(indent_str, str); - m_content.string_margin->Append(str_indent); - m_content.num += 1; - } - } - FlattenOutline(outline->down, level + 1); - outline = outline->next; - } -#endif -} - /* Bring up the contents */ void mupdf_cpp::MainPage::ContentDisplay(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) { -#if 0 - if (this->m_num_pages < 0 || m_zoom_mode) return; + if (this->m_num_pages < 0) + return; if (this->xaml_ListView->IsEnabled) { @@ -1398,12 +1352,11 @@ void mupdf_cpp::MainPage::ContentDisplay(Platform::Object^ sender, Windows::UI:: } else { - if (!m_content.num) + if (xaml_ListView->Items->Size == 0) { /* Make sure we are good to go */ RenderingStatus_t *ren_status = &m_ren_status; cancellation_token_source *ThumbCancel = &m_ThumbCancel; - fz_outline *root = NULL; /* Create a task to wait until the renderer is available */ auto t = create_task([ren_status, ThumbCancel]() @@ -1412,30 +1365,16 @@ void mupdf_cpp::MainPage::ContentDisplay(Platform::Object^ sender, Windows::UI:: ThumbCancel->cancel(); while (*ren_status != REN_AVAILABLE) { } - }).then([this, &root]() + }).then([this]() { - root = fz_load_outline(m_doc); - if (root) + int size_content = mu_doc->ComputeContents(); + /* Bring up the content now */ + for (int k = 0; k < size_content; k++) { - /* Flatten here if needed */ - m_content.page = ref new Vector; - m_content.string_margin = ref new Vector; - m_content.string_orig = ref new Vector; - - - FlattenOutline(root, 0); - fz_free_outline(ctx, root); - - /* Bring up the content now */ - for (int k = 0; k < m_content.num; k++) - { - auto content_val = ref new LVContents; - content_val->Page = m_content.page->GetAt(k); - content_val->ContentItem = m_content.string_margin->GetAt(k); - this->xaml_ListView->Items->Append(content_val); - } - } - if (m_content.num) + ContentItem^ item = mu_doc->GetContent(k); + this->xaml_ListView->Items->Append(item); + } + if (size_content > 0) { this->xaml_ListView->Opacity = 1.0; this->xaml_ListView->IsEnabled = true; @@ -1454,14 +1393,12 @@ void mupdf_cpp::MainPage::ContentDisplay(Platform::Object^ sender, Windows::UI:: this->m_curr_flipView->Opacity = 0.0; this->m_curr_flipView->IsEnabled = false; } - } -#endif + } } void mupdf_cpp::MainPage::ContentSelected(Platform::Object^ sender, Windows::UI::Xaml::Controls::ItemClickEventArgs^ e) { - - LVContents^ b = safe_cast(e->ClickedItem); + ContentItem^ b = safe_cast(e->ClickedItem); int newpage = b->Page; if (newpage > -1 && newpage < this->m_num_pages) diff --git a/winrt/mupdf_cpp/MainPage.xaml.h b/winrt/mupdf_cpp/MainPage.xaml.h index 6d8bbe79..812ad818 100644 --- a/winrt/mupdf_cpp/MainPage.xaml.h +++ b/winrt/mupdf_cpp/MainPage.xaml.h @@ -10,7 +10,6 @@ #include "ppltasks.h" #include #include -#include "LVContents.h" #include "mudocument.h" #include "DocumentPage.h" @@ -27,7 +26,6 @@ using namespace Windows::UI::Xaml::Input; using namespace Windows::UI::Xaml::Shapes; using namespace Windows::Foundation::Collections; using namespace Platform::Collections; -using namespace ListViewContents; using namespace Windows::UI::ViewManagement; using namespace Windows::UI::Popups; using namespace Windows::UI::Xaml::Navigation; @@ -65,14 +63,6 @@ typedef struct thumbs_s Array^ size; } thumbs_t; -typedef struct content_s -{ - int num; - Vector^ page; - Vector^ string_orig; - Vector^ string_margin; -} content_t; - namespace mupdf_cpp { /// @@ -90,7 +80,6 @@ namespace mupdf_cpp private: Vector^ m_docPages; mudocument^ mu_doc; - LVContents temp; bool m_file_open; int m_currpage; int m_searchpage; @@ -125,7 +114,6 @@ namespace mupdf_cpp int m_thumb_page_start; int m_thumb_page_stop; cancellation_token_source m_ThumbCancel; - content_t m_content; TextBlock^ m_StatusBlock; bool m_zoom_mode; bool m_from_doubleflip; diff --git a/winrt/mupdf_cpp/mupdf_cpp.vcxproj b/winrt/mupdf_cpp/mupdf_cpp.vcxproj index bb616403..25964a7f 100644 --- a/winrt/mupdf_cpp/mupdf_cpp.vcxproj +++ b/winrt/mupdf_cpp/mupdf_cpp.vcxproj @@ -144,7 +144,6 @@ - App.xaml @@ -176,7 +175,6 @@ App.xaml - MainPage.xaml diff --git a/winrt/mupdf_cpp/mupdf_cpp.vcxproj.filters b/winrt/mupdf_cpp/mupdf_cpp.vcxproj.filters index 732b68c7..8b87ed11 100644 --- a/winrt/mupdf_cpp/mupdf_cpp.vcxproj.filters +++ b/winrt/mupdf_cpp/mupdf_cpp.vcxproj.filters @@ -18,7 +18,6 @@ - @@ -26,7 +25,6 @@ - diff --git a/winrt/mupdfwinrt/ContentItem.cpp b/winrt/mupdfwinrt/ContentItem.cpp new file mode 100644 index 00000000..7bb264db --- /dev/null +++ b/winrt/mupdfwinrt/ContentItem.cpp @@ -0,0 +1,11 @@ +#include "pch.h" +#include "ContentItem.h" + +using namespace mupdfwinrt; + +ContentItem::ContentItem(void) +{ + StringOrig = nullptr; + StringMargin = nullptr; + Page = 0; +} diff --git a/winrt/mupdfwinrt/ContentItem.h b/winrt/mupdfwinrt/ContentItem.h new file mode 100644 index 00000000..69dd89fe --- /dev/null +++ b/winrt/mupdfwinrt/ContentItem.h @@ -0,0 +1,59 @@ +#pragma once + +using namespace Platform; /* For String */ + +namespace mupdfwinrt { + [Windows::UI::Xaml::Data::Bindable] + public ref class ContentItem sealed + { + private: + int page; + String^ string_orig; + String^ string_margin; + + public: + ContentItem(void); + + property int Page + { + int get() { return (page); } + void set(int value) + { + if (value < 0) + { + throw ref new Platform::InvalidArgumentException(); + } + page = value; + } + } + + property String^ StringOrig + { + String^ get() { return (string_orig); } + void set(String^ value) + { + string_orig = value; + } + } + + property String^ StringMargin + { + String^ get() { return (string_margin); } + void set(String^ value) + { + string_margin = value; + } + } + + + + + + + }; +} + + + + + diff --git a/winrt/mupdfwinrt/muctx.cpp b/winrt/mupdfwinrt/muctx.cpp index fcdac960..2fefd199 100644 --- a/winrt/mupdfwinrt/muctx.cpp +++ b/winrt/mupdfwinrt/muctx.cpp @@ -200,6 +200,74 @@ Point muctx::MeasurePage(fz_page *page) return pageSize; } +void muctx::FlattenOutline(fz_outline *outline, int level, + sh_vector_content contents_vec) +{ + char indent[8*4+1]; + if (level > 8) + level = 8; + memset(indent, ' ', level * 4); + indent[level * 4] = 0; + + String^ indent_str = char_to_String(indent); + String^ str_indent; + + while (outline) + { + if (outline->dest.kind == FZ_LINK_GOTO) + { + int page = outline->dest.ld.gotor.page; + if (page >= 0 && outline->title) + { + /* Add to the contents std:vec */ + sh_content content_item(new content_t()); + content_item->page = page; + content_item->string_orig = char_to_String(outline->title); + content_item->string_margin = + str_indent->Concat(indent_str, content_item->string_orig); + contents_vec->push_back(content_item); + } + } + FlattenOutline(outline->down, level + 1, contents_vec); + outline = outline->next; + } +} + +int muctx::GetContents(sh_vector_content contents_vec) +{ + fz_outline *root = NULL; + fz_context *ctx_clone; + int has_content = 0; + + if (mu_cookie->abort == 1) + return has_content; + + ctx_clone = fz_clone_context(mu_ctx); + + fz_var(root); + fz_try(ctx_clone) + { + root = fz_load_outline(mu_doc); + if (root != NULL) + { + has_content = 1; + FlattenOutline(root, 0, contents_vec); + } + } + fz_always(ctx_clone) + { + if (root != NULL) + { + fz_free_outline(ctx_clone, root); + } + } + fz_catch(ctx_clone) + { + return E_FAIL; + } + return has_content; +} + int muctx::GetTextSearch(int page_num, char* needle, sh_vector_text texts_vec) { fz_page *page; @@ -207,8 +275,8 @@ int muctx::GetTextSearch(int page_num, char* needle, sh_vector_text texts_vec) fz_device *dev; fz_context *ctx_clone; fz_text_page *text; - int k; int hit_count = 0; + int k; if (mu_cookie->abort == 1) return hit_count; @@ -261,8 +329,6 @@ int muctx::GetTextSearch(int page_num, char* needle, sh_vector_text texts_vec) return hit_count; } - - /* Get the links and pack into a smart pointer structure */ int muctx::GetLinks(int page_num, sh_vector_link links_vec) { diff --git a/winrt/mupdfwinrt/muctx.h b/winrt/mupdfwinrt/muctx.h index 61aec5a4..2c8e45d7 100644 --- a/winrt/mupdfwinrt/muctx.h +++ b/winrt/mupdfwinrt/muctx.h @@ -3,11 +3,10 @@ #include #include #include -#include "utils.h" - #include #include #include +#include "utils.h" extern "C" { #include "fitz.h" @@ -18,8 +17,13 @@ extern "C" { #define MAX_SEARCH 500 +using namespace Platform; /* For String */ using namespace Windows::Foundation; /* For Point */ +/* These are the std objects used to interface to muctx. We do use windows + String and Point types however */ + +/* Links */ typedef struct document_link_s { link_t type; @@ -28,19 +32,28 @@ typedef struct document_link_s std::unique_ptr uri; int page_num; } document_link_t; - #define sh_link std::shared_ptr #define sh_vector_link std::shared_ptr> +/* Text Search */ typedef struct text_search_s { Point upper_left; Point lower_right; } text_search_t; - #define sh_text std::shared_ptr #define sh_vector_text std::shared_ptr> +/* Content Results */ +typedef struct content_s +{ + int page; + String^ string_orig; + String^ string_margin; +} content_t; +#define sh_content std::shared_ptr +#define sh_vector_content std::shared_ptr> + /* Needed for file handling */ using namespace Windows::Storage::Streams; using namespace Windows::Foundation; @@ -62,6 +75,8 @@ private: fz_rect mu_hit_bbox[MAX_SEARCH]; fz_cookie *mu_cookie; fz_stream *mu_stream; + void FlattenOutline(fz_outline *outline, int level, + sh_vector_content contents_vec); public: muctx(void); @@ -74,8 +89,5 @@ public: Point MeasurePage(fz_page *page); int GetLinks(int page_num, sh_vector_link links_vec); int GetTextSearch(int page_num, char* needle, sh_vector_text texts_vec); + int GetContents(sh_vector_content contents_vec); }; - - - - diff --git a/winrt/mupdfwinrt/mudocument.cpp b/winrt/mupdfwinrt/mudocument.cpp index cf02083d..18b3c63d 100644 --- a/winrt/mupdfwinrt/mudocument.cpp +++ b/winrt/mupdfwinrt/mudocument.cpp @@ -1,4 +1,9 @@ // mudocument.cpp + +/* This file contains the interface between the muctx class, which + implements the mupdf calls and the WinRT objects enabling calling from + C#, C++, Visual Basic, JavaScript applications */ + #include "pch.h" #include "mudocument.h" @@ -6,32 +11,6 @@ using namespace mupdfwinrt; using namespace concurrency; using namespace Platform::Collections; -/* Window string hurdles.... */ -static String^ char_to_String(char *char_in) -{ - size_t size = MultiByteToWideChar(CP_UTF8, 0, char_in, -1, NULL, 0); - wchar_t *pw; - pw = new wchar_t[size]; - if (!pw) - { - delete []pw; - return nullptr; - } - MultiByteToWideChar(CP_UTF8, 0, char_in, -1, pw, size ); - String^ str_out = ref new String(pw); - delete []pw; - return str_out; -} - -static char* String_to_char(String^ text) -{ - const wchar_t *w = text->Data(); - int cb = WideCharToMultiByte(CP_UTF8, 0, text->Data(), -1, nullptr, 0, nullptr, nullptr); - char* charout = new char[cb]; - WideCharToMultiByte(CP_UTF8, 0, text->Data() ,-1 ,charout ,cb ,nullptr, nullptr); - return charout; -} - mudocument::mudocument() { this->mu_object.InitializeContext(); @@ -210,3 +189,44 @@ int mudocument::ComputeTextSearch(String^ text, int page_num) return num_items; } +Links^ mudocument::GetTextSearch(int k) +{ + if (k >= this->textsearch->Size) + return nullptr; + return this->textsearch->GetAt(k); +} + +int mudocument::ComputeContents() +{ + std::lock_guard lock(mutex_lock); + /* We get back a standard smart pointer from muctx interface and go to WinRT + type here */ + + sh_vector_content content_smart_ptr_vec(new std::vector()); + + int has_content = mu_object.GetContents(content_smart_ptr_vec); + + if (!has_content) + return 0; + /* Pack into winRT type*/ + this->contents = ref new Platform::Collections::Vector(); + int num_items = content_smart_ptr_vec->size(); + + for (int k = 0; k < num_items; k++) + { + auto new_content = ref new ContentItem(); + sh_content muctx_content = content_smart_ptr_vec->at(k); + new_content->Page = muctx_content->page; + new_content->StringMargin = muctx_content->string_margin; + new_content->StringOrig = muctx_content->string_orig; + this->contents->Append(new_content); + } + return num_items; +} + +ContentItem^ mudocument::GetContent(int k) +{ + if (k >= this->contents->Size) + return nullptr; + return this->contents->GetAt(k); +} diff --git a/winrt/mupdfwinrt/mudocument.h b/winrt/mupdfwinrt/mudocument.h index b315a18f..0bce8654 100644 --- a/winrt/mupdfwinrt/mudocument.h +++ b/winrt/mupdfwinrt/mudocument.h @@ -1,12 +1,13 @@ #pragma once -/* This file contains the WinRT API interface between the muctx class which +/* This file contains the interface between the muctx class, which implements the mupdf calls and the WinRT objects enabling calling from C#, C++, Visual Basic, JavaScript applications */ #include "muctx.h" #include "Links.h" #include "ppltasks.h" +#include "ContentItem.h" #include #include @@ -19,22 +20,24 @@ namespace mupdfwinrt { public ref class mudocument sealed { - - private: - muctx mu_object; - std::mutex mutex_lock; - Platform::Collections::Vector^ links; - Platform::Collections::Vector^ textsearch; - public: - mudocument(); - Windows::Foundation::IAsyncAction^ OpenFile(StorageFile^ file); - int GetNumPages(); - Point GetPageSize(int page_num); - Windows::Foundation::IAsyncOperation^ - RenderPage(int page_num, int width, int height); - int ComputeLinks(int page_num); - Links^ GetLink(int k); - int ComputeTextSearch(String^ text, int page_num); - + private: + muctx mu_object; + std::mutex mutex_lock; + Platform::Collections::Vector^ links; + Platform::Collections::Vector^ textsearch; + Platform::Collections::Vector^ contents; + public: + mudocument(); + Windows::Foundation::IAsyncAction^ OpenFile(StorageFile^ file); + int GetNumPages(void); + Point GetPageSize(int page_num); + Windows::Foundation::IAsyncOperation^ + RenderPage(int page_num, int width, int height); + int ComputeTextSearch(String^ text, int page_num); + Links^ GetTextSearch(int k); + int ComputeContents(void); + ContentItem^ GetContent(int k); + int ComputeLinks(int page_num); + Links^ GetLink(int k); }; -} \ No newline at end of file +} diff --git a/winrt/mupdfwinrt/mupdfwinrt.vcxproj b/winrt/mupdfwinrt/mupdfwinrt.vcxproj index 5e8892be..891c3a15 100644 --- a/winrt/mupdfwinrt/mupdfwinrt.vcxproj +++ b/winrt/mupdfwinrt/mupdfwinrt.vcxproj @@ -206,6 +206,7 @@ + @@ -213,6 +214,7 @@ + Create @@ -223,6 +225,7 @@ Create + diff --git a/winrt/mupdfwinrt/mupdfwinrt.vcxproj.filters b/winrt/mupdfwinrt/mupdfwinrt.vcxproj.filters index c00d9539..23e52055 100644 --- a/winrt/mupdfwinrt/mupdfwinrt.vcxproj.filters +++ b/winrt/mupdfwinrt/mupdfwinrt.vcxproj.filters @@ -11,6 +11,8 @@ + + @@ -18,5 +20,6 @@ + \ No newline at end of file diff --git a/winrt/mupdfwinrt/utils.cpp b/winrt/mupdfwinrt/utils.cpp new file mode 100644 index 00000000..a046ec90 --- /dev/null +++ b/winrt/mupdfwinrt/utils.cpp @@ -0,0 +1,28 @@ +#include "pch.h" +#include "utils.h" + +/* Window string hurdles.... */ +String^ char_to_String(char *char_in) +{ + size_t size = MultiByteToWideChar(CP_UTF8, 0, char_in, -1, NULL, 0); + wchar_t *pw; + pw = new wchar_t[size]; + if (!pw) + { + delete []pw; + return nullptr; + } + MultiByteToWideChar(CP_UTF8, 0, char_in, -1, pw, size ); + String^ str_out = ref new String(pw); + delete []pw; + return str_out; +} + +char* String_to_char(String^ text) +{ + const wchar_t *w = text->Data(); + int cb = WideCharToMultiByte(CP_UTF8, 0, text->Data(), -1, nullptr, 0, nullptr, nullptr); + char* charout = new char[cb]; + WideCharToMultiByte(CP_UTF8, 0, text->Data() ,-1 ,charout ,cb ,nullptr, nullptr); + return charout; +} \ No newline at end of file diff --git a/winrt/mupdfwinrt/utils.h b/winrt/mupdfwinrt/utils.h index 7485ee47..33513b21 100644 --- a/winrt/mupdfwinrt/utils.h +++ b/winrt/mupdfwinrt/utils.h @@ -1,8 +1,14 @@ #pragma once +#include "Windows.h" +using namespace Platform; + typedef enum { LINK_GOTO = 0, LINK_URI, TEXTBOX, /* Do double duty with this class */ NOT_SET, -} link_t; \ No newline at end of file +} link_t; + +String^ char_to_String(char *char_in); +char* String_to_char(String^ text); \ No newline at end of file -- cgit v1.2.3