00001 /* 00002 * File Name: plugin_doc_navigator.h 00003 */ 00004 00005 /* 00006 * This file is part of uds-plugin-common. 00007 * 00008 * uds-plugin-common 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-common 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 #ifndef PLUGIN_DOC_NAVIGATOR_H_ 00028 #define PLUGIN_DOC_NAVIGATOR_H_ 00029 00030 #ifdef __cplusplus 00031 extern "C" { 00032 #endif 00033 00034 #include "plugin_type.h" 00035 #include "plugin_unknown.h" 00036 00037 /** 00038 * @brief Universal Document Shell Document Object Type declaration. 00039 */ 00040 typedef enum 00041 { 00042 PLUGIN_DOC_OBJECT_NONE, /**< No object. */ 00043 PLUGIN_DOC_OBJECT_TEXT, /**< Text object. */ 00044 PLUGIN_DOC_OBJECT_IMAGE, /**< Image object. */ 00045 PLUGIN_DOC_OBJECT_HYPERLINK, /**< Hyperlink object. */ 00046 PLUGIN_DOC_OBJECT_TEXT_HYPERLINK, /**< Text Hyperlink object. */ 00047 PLUGIN_DOC_OBJECT_PAGE, /**< The page object. */ 00048 } PluginDocObjectType; 00049 00050 /** 00051 * @brief Universal Document Shell Plugin Document Object Navigator interafce. 00052 * Through IPluginDocNavigator, caller is able to navigate among different 00053 * objects inside a document. Particularly, callers can get object(range) by 00054 * input anchor; get text from specified range; compare position of two 00055 * anchors. 00056 */ 00057 typedef struct 00058 { 00059 /** 00060 * @brief Get initial anchor of current document. The initial anchor is 00061 * normally the first page of text, or the table of content. 00062 * @param thiz IPluginUnknown pinter of document object. 00063 * @param anchor The returned anchor. 00064 * @return TODO. Add return code here. 00065 */ 00066 PluginStatus (* get_initial_anchor)(IPluginUnknown *thiz, 00067 UDSString *anchor); 00068 00069 /** 00070 * @brief Get the object where the anchor resides. 00071 * @param thiz IPluginUnknown pointer of document object. 00072 * @param anchor Location of user specified content. 00073 * @param range The range for returned object. 00074 * @return TODO. Add return code here. 00075 */ 00076 PluginStatus (* get_object_from_anchor)( IPluginUnknown *thiz, 00077 const UDSString *anchor, 00078 PluginRange *range); 00079 00080 /** 00081 * @brief Get the object type for a specified object. 00082 * @param thiz IPluginUnknown pointer of document object. 00083 * @param range The range of the specified object. 00084 * @return Type of the specific object. 00085 */ 00086 PluginDocObjectType (* get_type_of_object)( IPluginUnknown *thiz, 00087 const PluginRange *range ); 00088 00089 /** 00090 * @brief Extends the range from specified char to the word. 00091 * @param thiz IPluginUnknown pointer of document object. 00092 * @param char_range The range of the specified character. 00093 * @param words_range The range of extended word. 00094 * @return TODO. Add return code here. 00095 */ 00096 PluginStatus (* get_words_from_range)( IPluginUnknown *thiz, 00097 const PluginRange *char_range, 00098 PluginRange *words_range ); 00099 00100 /** 00101 * @brief Get the text within the specific range. 00102 * @param thiz IPluginUnknown pointer of document object. 00103 * @param range User specified range. 00104 * NOTE: The corresponding object within the range should be text. 00105 * @param result The result text. 00106 * @return TODO. Add return code here. 00107 */ 00108 PluginStatus (* get_text_from_range)( IPluginUnknown *thiz, 00109 const PluginRange *range, 00110 UDSString *result ); 00111 00112 /** 00113 * @brief Check whether the specified anchor is in the current document. 00114 * @param thiz IPluginUnknown pointer of document object. 00115 * @param anchor Location of user specified content. 00116 * @return Returns PLUGIN_TRUE if the anchor is in current document; 00117 * otherwise returns PLUGIN_FALSE. 00118 */ 00119 PluginBool (* is_anchor_in_current_document)( IPluginUnknown *thiz, 00120 const UDSString *anchor ); 00121 00122 /** 00123 * @brief Retrieve filename for given anchor. When the document is made up of 00124 * several files, the plugin should return the file name according to the anchor. 00125 * @param thiz IPluginUnknown pointer of document object. 00126 * @param anchor Location of user specified content. 00127 * @param file_name. The output variable stores the file name that 00128 * contains the object specified by anchor. The file name must be in UTF-8 with 00129 * extension name. 00130 * @return Returns PLUGIN_OK if plugin is able to get the file name from anchor 00131 * otherwise returns PLUGIN_ERROR. 00132 */ 00133 PluginStatus (* get_file_name_from_anchor)( IPluginUnknown *thiz, 00134 const UDSString *anchor, 00135 UDSString *file_name ); 00136 00137 /** 00138 * @brief Retrieve object position specified by anchor inside the file. 00139 * @param thiz IPluginUnknown pointer of document object. 00140 * @param anchor Location of user specified content. 00141 * @param position. The object position inside the file. The position must be 00142 * able to be compared. Usually the position is the distance of the object from 00143 * file beginning. 00144 * @return Returns PLUGIN_OK if plugin is able to get the object position specified 00145 * by anchor otherwise returns PLUGIN_ERROR. 00146 */ 00147 PluginStatus (* get_file_position_from_anchor)( IPluginUnknown *thiz, 00148 const UDSString *anchor, 00149 signed long long *position ); 00150 00151 /** 00152 * @brief Retrieve the url pointed by an anchor 00153 * @param thiz IPluginUnknown pointer of document object. 00154 * @param anchor The anchor which contains or points to a URL. 00155 * @param url The URL retrieved. 00156 * @return Returns PLUGIN_OK if plugin is able to get the URL specified 00157 * by anchor otherwise returns PLUGIN_ERROR. 00158 */ 00159 PluginStatus (* get_uri_from_anchor)( IPluginUnknown *thiz, 00160 const UDSString *anchor, 00161 UDSString *url ); 00162 00163 /** 00164 * @brief Compare position of two anchor objects. 00165 * @param thiz IPluginUnknown pointer of document object. 00166 * @param anchor_a The first anchor. 00167 * @param anchor_b The second anchor. 00168 * @return The possible return values are: 00169 * - <0 when anchor_a's location in the document is before anchor_b's 00170 * location 00171 * - =0 when anchor_a's location in the document is the same as anchor_b's 00172 * location 00173 * - >0 when anchor_a's location in the document is after anchor_b's 00174 * location 00175 */ 00176 int (* compare_anchor_location) ( IPluginUnknown *thiz, 00177 const UDSString *anchor_a, 00178 const UDSString *anchor_b ); 00179 00180 } IPluginDocNavigator; 00181 00182 #ifdef __cplusplus 00183 } 00184 #endif 00185 00186 #endif 00187