images/plugin_impl/document_impl.h

Go to the documentation of this file.
00001 /*
00002  * File Name: document_impl.h
00003  */
00004 
00005 /*
00006  * This file is part of uds-plugin-images.
00007  *
00008  * uds-plugin-images 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-images 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 IMAGES_PLUGIN_DOCUMENT_IMPL_H_
00028 #define IMAGES_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 "images_document.h"
00037 
00038 using namespace utils;
00039 
00040 namespace images
00041 {
00042 
00043 class PluginViewImpl;
00044 
00045 /// @brief Implement all necessary interfaces for document object.
00046 /// If the interface is not supported, the impl can remove 
00047 /// them from parent class list.
00048 class PluginDocImpl : public IPluginUnknown 
00049                     , public IPluginDocument 
00050                     , public IPluginDocNavigator
00051                     , public IPluginDocAttributes
00052                     , public IPluginEventBroadcaster
00053                     , public IPluginDocHyperlink
00054                     , public IPluginDocDictionary
00055                     , public IPluginDocMarker
00056 {
00057 public:
00058     PluginDocImpl();
00059     ~PluginDocImpl();
00060 
00061 public:
00062     /// Retrieve total page number. This function is used by
00063     /// PluginViewImpl
00064     unsigned int get_page_count();
00065 
00066     /// Retrieve page number from anchor. This function is used
00067     /// by PluginViewImpl.
00068     unsigned int get_page_number(const std::string & anchor);
00069 
00070     bool get_page_name(const std::string & anchor,
00071                        std::string & name);
00072 
00073     /// Retrieve the image directly.
00074     int get_page(const std::string & anchor);
00075 
00076     /// Retrieve the anchor for given page number.
00077     bool get_anchor_of_page(const unsigned int page_number, 
00078                             std::string & anchor);
00079 
00080     /// Anchor iteraotr: retrieve the previous anchor.
00081     bool get_prev_page(std::string & anchor);
00082 
00083     /// Anchor iteraotr: retrieve the next anchor.
00084     bool get_next_page(std::string & anchor);
00085 
00086     ImagesDocument * get_doc(void);
00087 
00088     bool get_original_size(const std::string &anchor,
00089                           unsigned int &width,
00090                           unsigned int &height);
00091 
00092     bool get_original_rotation(const std::string &anchor,
00093                                PluginRotationDegree &rotation);
00094 
00095 public:
00096     /// The release signal.
00097     Signal<PluginDocImpl *> release_signal;
00098 
00099 private:
00100     // IPluginUnknown.
00101     static PluginStatus query_interface_impl(
00102         IPluginUnknown      *thiz,
00103         const UDSString     *id, 
00104         void                **ptr );
00105 
00106     static int release_impl(
00107         IPluginUnknown      *thiz );
00108 
00109     // IPluginDocument.
00110     static PluginStatus open_impl(
00111         IPluginUnknown      *thiz, 
00112         const UDSString     *path);
00113 
00114     static PluginBool is_open_impl(
00115         IPluginUnknown      *thiz);
00116 
00117     static PluginStatus close_impl(
00118         IPluginUnknown      *thiz);
00119 
00120     static IPluginUnknown * create_view_impl(
00121         IPluginUnknown      *thiz);
00122 
00123     // IPluginDocNavigator
00124     static PluginStatus get_initial_anchor_impl(
00125         IPluginUnknown      *thiz, 
00126         UDSString           *anchor);
00127 
00128     static PluginStatus get_object_from_anchor_impl(
00129         IPluginUnknown      *thiz,
00130         const UDSString     *anchor, 
00131         PluginRange         *range);
00132 
00133     static PluginDocObjectType get_type_of_object_impl(
00134         IPluginUnknown      *thiz,
00135         const PluginRange   *range);
00136     
00137     static PluginStatus get_words_from_range_impl(
00138         IPluginUnknown      *thiz, 
00139         const PluginRange   *chars_range, 
00140         PluginRange         *words_range );
00141 
00142     static PluginStatus get_text_from_range_impl(
00143         IPluginUnknown      *thiz, 
00144         const PluginRange   *range, 
00145         UDSString           *result );
00146 
00147     static PluginBool is_anchor_in_current_document_impl(
00148         IPluginUnknown      *thiz,
00149         const UDSString     *anchor );
00150     
00151     static PluginStatus get_file_name_from_anchor_impl( 
00152         IPluginUnknown    *thiz,
00153         const UDSString   *anchor,
00154         UDSString         *file_name );
00155 
00156     static PluginStatus get_file_position_from_anchor_impl( 
00157         IPluginUnknown    *thiz,
00158         const UDSString   *anchor,
00159         signed long long  *position );
00160 
00161     static int compare_anchor_location_impl(
00162         IPluginUnknown      *thiz,
00163         const UDSString     *anchor_a,
00164         const UDSString     *anchor_b );
00165 
00166     static PluginStatus get_attribute_impl(
00167         IPluginUnknown      *thiz,
00168         const UDSString     *key, 
00169         UDSString           *value );
00170 
00171     static PluginStatus set_attribute_impl(
00172         IPluginUnknown      *thiz,
00173         const UDSString     *key,
00174         const UDSString     *value );
00175 
00176     // IPluginEventBroadcaster
00177     static PluginStatus add_event_receiver_impl(
00178         IPluginUnknown      *thiz,
00179         const PluginEvent   plugin_event,
00180         EventFunc           callback,
00181         void                *user_data,
00182         unsigned long       *handler_id);
00183 
00184     static PluginStatus remove_event_receiver_impl(
00185         IPluginUnknown      *thiz,
00186         unsigned long       handler_id );
00187 
00188     // IPluginDocHyperlink
00189     static PluginBool is_hyperlink_impl(
00190         IPluginUnknown      *thiz,
00191         const PluginRange   *range );
00192 
00193     static PluginStatus get_target_from_hyperlink_impl(
00194         IPluginUnknown      *thiz,
00195         const PluginRange   *range, 
00196         UDSString           *anchor );
00197 
00198     // IPluginDocDictionary
00199     static PluginBool is_dictionary_impl( 
00200         IPluginUnknown      *thiz );
00201 
00202     // IPluginDocMarker
00203     static IPluginUnknown* get_supported_marker_types_impl(
00204         IPluginUnknown      *thiz );
00205 
00206     static PluginStatus request_marker_trees_impl(
00207         IPluginUnknown      *thiz, 
00208         const unsigned int  uds_private_size );
00209 
00210 private:
00211     typedef PluginViewImpl * ViewPtr;
00212     typedef std::vector<ViewPtr> Views;
00213     typedef std::vector<ViewPtr>::iterator ViewsIter;
00214     
00215 private:
00216     void on_view_released(ViewPtr view);
00217     void remove_slots(void);
00218 
00219 private:
00220     static utils::ObjectTable<PluginDocImpl> g_instances_table;
00221 
00222 private:
00223     utils::Listeners listeners;
00224     images::ImagesDocument document;
00225     Views views;
00226 
00227 private:
00228     void init_doc_attributes();
00229     typedef std::map<std::string, std::string> DocAttrMap;
00230     typedef DocAttrMap::iterator               DocAttrMapIter;
00231     DocAttrMap doc_attr_map;
00232 };
00233 
00234 };  // namespace images
00235 
00236 #endif
00237 
Generated by  doxygen 1.6.2-20100208