plaintext/plugin_impl/render_result_impl.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "render_result_impl.h"
00028 #include "render_settings_impl.h"
00029 #include "view_impl.h"
00030
00031 namespace text
00032 {
00033
00034 utils::ObjectTable<PluginRenderResultImpl> PluginRenderResultImpl::g_instances_table;
00035
00036 PluginRenderResultImpl::PluginRenderResultImpl(PluginViewImpl *view,
00037 const PluginBitmapAttributes& bmp,
00038 const unsigned long id,
00039 PluginRenderSettingsImpl * s)
00040 : view_impl(view)
00041 , atts(bmp)
00042 , ref_id(id)
00043 , settings(s)
00044 {
00045
00046 query_interface = query_interface_impl;
00047 release = release_impl;
00048
00049
00050 get_bitmap_attributes = get_bitmap_attributes_impl;
00051 get_anchor_from_coordinates = get_anchor_from_coordinates_impl;
00052 get_bounding_rectangles_from_range = get_bounding_rectangles_from_range_impl;
00053 get_rendered_range = get_rendered_range_impl;
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063 g_instances_table.add_interface<IPluginUnknown>(this);
00064 g_instances_table.add_interface<IPluginRenderResult>(this);
00065 g_instances_table.add_interface<IPluginRenderSettings>(this);
00066 }
00067
00068 PluginRenderResultImpl::~PluginRenderResultImpl(void)
00069 {
00070 delete [] atts.data;
00071 g_instances_table.remove(this);
00072 }
00073
00074
00075 PluginStatus
00076 PluginRenderResultImpl::query_interface_impl(IPluginUnknown *thiz,
00077 const UDSString *id,
00078 void **ptr )
00079 {
00080 PluginRenderResultImpl *instance = g_instances_table.get_object(thiz);
00081 if (g_instances_table.query_interface(instance, id->get_buffer(id), ptr))
00082 {
00083 return PLUGIN_OK;
00084 }
00085 return PLUGIN_FAIL;
00086 }
00087
00088 int
00089 PluginRenderResultImpl::release_impl(IPluginUnknown *thiz )
00090 {
00091 PluginRenderResultImpl *instance = g_instances_table.get_object(thiz);
00092 instance->release_signal.safe_broadcast(instance);
00093 return 0;
00094 }
00095
00096 PluginStatus
00097 PluginRenderResultImpl::get_bitmap_attributes_impl(IPluginUnknown *thiz,
00098 PluginBitmapAttributes *attributes)
00099 {
00100 PluginRenderResultImpl *instance = g_instances_table.get_object(thiz);
00101 *attributes = instance->atts;
00102 return PLUGIN_OK;
00103 }
00104
00105 PluginStatus
00106 PluginRenderResultImpl::get_anchor_from_coordinates_impl(IPluginUnknown *thiz,
00107 const int x,
00108 const int y,
00109 UDSString *anchor )
00110 {
00111 PluginRenderResultImpl *instance = g_instances_table.get_object(thiz);
00112 return instance->view_impl->get_anchor_from_coordinates_impl(instance->page_range.start, x, y, anchor);
00113 }
00114
00115 IPluginUnknown*
00116 PluginRenderResultImpl::get_bounding_rectangles_from_range_impl(IPluginUnknown *thiz,
00117 const PluginRange *range)
00118 {
00119 PluginRenderResultImpl *instance = g_instances_table.get_object(thiz);
00120 return instance->view_impl->get_bounding_rectangles_from_range_impl(instance->page_range.start, range);
00121 }
00122
00123 PluginStatus
00124 PluginRenderResultImpl::get_rendered_range_impl(IPluginUnknown *thiz,
00125 PluginRange *range)
00126 {
00127 PluginRenderResultImpl *instance = g_instances_table.get_object(thiz);
00128
00129 range->start_anchor->assign(range->start_anchor, instance->page_range.start.to_string().c_str());
00130 range->end_anchor->assign(range->end_anchor, instance->page_range.end.to_string().c_str());
00131 return PLUGIN_OK;
00132 }
00133
00134 }