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 #ifndef TEXT_PLUGIN_DOCUMENT_IMPL_H_
00028 #define TEXT_PLUGIN_DOCUMENT_IMPL_H_
00029
00030 #include <string>
00031 #include <vector>
00032 #include "plugin_inc.h"
00033 #include "interfaces_utils.h"
00034 #include "signal_slot.h"
00035 #include "listeners.h"
00036 #include "text_model.h"
00037 #include "text_controller.h"
00038 #include "string_impl.h"
00039
00040 using namespace utils;
00041
00042 namespace text
00043 {
00044
00045 struct RangeImpl
00046 {
00047 public:
00048 RangeImpl(const Range& range)
00049 {
00050 start_anchor = new StringImpl(range.start.to_string());
00051 end_anchor = new StringImpl(range.end.to_string());
00052 }
00053
00054 ~RangeImpl()
00055 {
00056 delete start_anchor;
00057 delete end_anchor;
00058 }
00059
00060 public:
00061 UDSString* start_anchor;
00062 UDSString* end_anchor;
00063 };
00064
00065 class PluginViewImpl;
00066
00067
00068
00069
00070 class PluginDocImpl : public IPluginUnknown
00071 , public IPluginDocument
00072 , public IPluginDocNavigator
00073 , public IPluginDocAttributes
00074 , public IPluginEventBroadcaster
00075 , public IPluginDocHyperlink
00076 , public IPluginDocDictionary
00077 , public IPluginDocMarker
00078 , public IPluginDocSearch
00079 {
00080 public:
00081 PluginDocImpl();
00082 ~PluginDocImpl();
00083
00084 public:
00085 TextModel & get_model() { return document; }
00086
00087 public:
00088
00089 Signal<PluginDocImpl *> release_signal;
00090
00091
00092 void on_search_done(const std::vector<Range>& result, const SearchContext* sc);
00093
00094 private:
00095
00096 static PluginStatus query_interface_impl(
00097 IPluginUnknown *thiz,
00098 const UDSString *id,
00099 void **ptr );
00100
00101 static int release_impl(
00102 IPluginUnknown *thiz );
00103
00104
00105 static PluginStatus open_impl(
00106 IPluginUnknown *thiz,
00107 const UDSString *path);
00108
00109 static PluginBool is_open_impl(
00110 IPluginUnknown *thiz);
00111
00112 static PluginStatus close_impl(
00113 IPluginUnknown *thiz);
00114
00115 static IPluginUnknown * create_view_impl(
00116 IPluginUnknown *thiz);
00117
00118
00119 static PluginStatus get_initial_anchor_impl(
00120 IPluginUnknown *thiz,
00121 UDSString *anchor);
00122
00123 static PluginStatus get_object_from_anchor_impl(
00124 IPluginUnknown *thiz,
00125 const UDSString *anchor,
00126 PluginRange *range);
00127
00128 static PluginDocObjectType get_type_of_object_impl(
00129 IPluginUnknown *thiz,
00130 const PluginRange *range);
00131
00132 static PluginStatus get_words_from_range_impl(
00133 IPluginUnknown *thiz,
00134 const PluginRange *char_range,
00135 PluginRange *word_range );
00136
00137 static PluginStatus get_text_from_range_impl(
00138 IPluginUnknown *thiz,
00139 const PluginRange *range,
00140 UDSString *result );
00141
00142 static PluginBool is_anchor_in_current_document_impl(
00143 IPluginUnknown *thiz,
00144 const UDSString *anchor );
00145
00146 static PluginStatus get_file_name_from_anchor_impl(
00147 IPluginUnknown *thiz,
00148 const UDSString *anchor,
00149 UDSString *file_name );
00150
00151 static PluginStatus get_file_position_from_anchor_impl(
00152 IPluginUnknown *thiz,
00153 const UDSString *anchor,
00154 signed long long *position );
00155
00156 static int compare_anchor_location_impl(
00157 IPluginUnknown *thiz,
00158 const UDSString *anchor_a,
00159 const UDSString *anchor_b );
00160
00161
00162 static PluginStatus get_attribute_impl(
00163 IPluginUnknown *thiz,
00164 const UDSString *key,
00165 UDSString *value );
00166
00167 static PluginStatus set_attribute_impl(
00168 IPluginUnknown *thiz,
00169 const UDSString *key,
00170 const UDSString *value );
00171
00172
00173 static PluginStatus add_event_receiver_impl(
00174 IPluginUnknown *thiz,
00175 const PluginEvent plugin_event,
00176 EventFunc callback,
00177 void *user_data,
00178 unsigned long *handler_id);
00179
00180 static PluginStatus remove_event_receiver_impl(
00181 IPluginUnknown *thiz,
00182 unsigned long handler_id );
00183
00184
00185 static PluginBool is_hyperlink_impl(
00186 IPluginUnknown *thiz,
00187 const PluginRange *range );
00188
00189 static PluginStatus get_target_from_hyperlink_impl(
00190 IPluginUnknown *thiz,
00191 const PluginRange *range,
00192 UDSString *anchor );
00193
00194
00195 static PluginBool is_dictionary_impl(
00196 IPluginUnknown *thiz );
00197
00198
00199
00200 static IPluginUnknown* get_supported_marker_types_impl(
00201 IPluginUnknown *thiz );
00202
00203 static PluginStatus request_marker_trees_impl(
00204 IPluginUnknown *thiz,
00205 const unsigned int uds_private_size );
00206
00207
00208 static IPluginUnknown * create_search_criteria_impl(
00209 IPluginUnknown *thiz );
00210
00211 static PluginStatus request_search_next_impl(
00212 IPluginUnknown *thiz,
00213 IPluginUnknown *criteria,
00214 const UDSString *from_anchor,
00215 const unsigned int search_id);
00216
00217 static PluginStatus request_search_all_impl(
00218 IPluginUnknown *thiz,
00219 IPluginUnknown *criteria,
00220 const unsigned int search_id);
00221
00222 static PluginStatus abort_search_impl(
00223 IPluginUnknown *thiz,
00224 const unsigned int search_id);
00225
00226 private:
00227 typedef PluginViewImpl * ViewPtr;
00228
00229 private:
00230 static utils::ObjectTable<PluginDocImpl> g_instances_table;
00231
00232 private:
00233 TextController *controller;
00234 utils::Listeners listeners;
00235 text::TextModel document;
00236
00237 private:
00238 void init_doc_attributes();
00239 typedef std::map<std::string, std::string> DocAttrMap;
00240 typedef DocAttrMap::iterator DocAttrMapIter;
00241 DocAttrMap doc_attr_map;
00242 };
00243
00244 };
00245
00246 #endif
00247