plaintext/plugin_impl/render_result_impl.cpp

Go to the documentation of this file.
00001 /*
00002  * File Name: render_result_impl.cpp
00003  */
00004 
00005 /*
00006  * This file is part of uds-plugin-plaintext.
00007  *
00008  * uds-plugin-plaintext is free software: you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation, either version 2 of the License, or
00011  * (at your option) any later version.
00012  *
00013  * uds-plugin-plaintext is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program. If not, see <http://www.gnu.org/licenses/>.
00020  */
00021 
00022 /**
00023  * Copyright (C) 2008 iRex Technologies B.V.
00024  * All rights reserved.
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     // IPluginUnknown
00046     query_interface = query_interface_impl;
00047     release = release_impl;
00048 
00049     // IPluginRenderResult
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     // IPluginRenderSettings, no method yet.
00056 
00057 
00058     // IPluginZoom
00059     // IPluginRotation
00060 
00061     // Initialize all supported interfaces. In render result, 
00062     // the render settings, zoom and rotation are read only.
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 }
Generated by  doxygen 1.6.2-20100208