summaryrefslogtreecommitdiff
path: root/winrt/mupdf_cpp
diff options
context:
space:
mode:
Diffstat (limited to 'winrt/mupdf_cpp')
-rw-r--r--winrt/mupdf_cpp/DocumentPage.h3
-rw-r--r--winrt/mupdf_cpp/LVContents.cpp9
-rw-r--r--winrt/mupdf_cpp/LVContents.h12
-rw-r--r--winrt/mupdf_cpp/MainPage.xaml2
-rw-r--r--winrt/mupdf_cpp/MainPage.xaml.cpp91
-rw-r--r--winrt/mupdf_cpp/MainPage.xaml.h12
-rw-r--r--winrt/mupdf_cpp/mupdf_cpp.vcxproj2
-rw-r--r--winrt/mupdf_cpp/mupdf_cpp.vcxproj.filters2
8 files changed, 17 insertions, 116 deletions
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 @@
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel Margin="5,5,0,0" HorizontalAlignment="Left">
- <TextBlock TextWrapping="Wrap" Text="{Binding ContentItem}" FontFamily="Segoe UI" FontSize="20" />
+ <TextBlock TextWrapping="Wrap" Text="{Binding StringMargin}" FontFamily="Segoe UI" FontSize="20" />
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
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<DocumentPage^>();
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<int>;
- m_content.string_margin = ref new Vector<String^>;
- m_content.string_orig = ref new Vector<String^>;
-
-
- 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<LVContents^>(e->ClickedItem);
+ ContentItem^ b = safe_cast<ContentItem^>(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 <collection.h>
#include <algorithm>
-#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<Point>^ size;
} thumbs_t;
-typedef struct content_s
-{
- int num;
- Vector<int>^ page;
- Vector<String^>^ string_orig;
- Vector<String^>^ string_margin;
-} content_t;
-
namespace mupdf_cpp
{
/// <summary>
@@ -90,7 +80,6 @@ namespace mupdf_cpp
private:
Vector<DocumentPage^>^ 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 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="DocumentPage.h" />
- <ClInclude Include="LVContents.h" />
<ClInclude Include="pch.h" />
<ClInclude Include="App.xaml.h">
<DependentUpon>App.xaml</DependentUpon>
@@ -176,7 +175,6 @@
<DependentUpon>App.xaml</DependentUpon>
</ClCompile>
<ClCompile Include="DocumentPage.cpp" />
- <ClCompile Include="LVContents.cpp" />
<ClCompile Include="MainPage.xaml.cpp">
<DependentUpon>MainPage.xaml</DependentUpon>
</ClCompile>
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 @@
<ClCompile Include="App.xaml.cpp" />
<ClCompile Include="MainPage.xaml.cpp" />
<ClCompile Include="pch.cpp" />
- <ClCompile Include="LVContents.cpp" />
<ClCompile Include="DocumentPage.cpp" />
<ClCompile Include="RectList.cpp" />
</ItemGroup>
@@ -26,7 +25,6 @@
<ClInclude Include="pch.h" />
<ClInclude Include="App.xaml.h" />
<ClInclude Include="MainPage.xaml.h" />
- <ClInclude Include="LVContents.h" />
<ClInclude Include="DocumentPage.h" />
<ClInclude Include="RectList.h" />
</ItemGroup>