plaintext/plugin_impl/view_impl.h

Go to the documentation of this file.
00001 /*
00002  * File Name: view_impl.h
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 #ifndef TEXT_PLUGIN_VIEW_IMPL_H_
00028 #define TEXT_PLUGIN_VIEW_IMPL_H_
00029 
00030 #include <map>
00031 
00032 #include "plugin_inc.h"
00033 #include "render_settings_impl.h"
00034 #include "render_result_impl.h"
00035 #include "interfaces_utils.h"
00036 #include "listeners.h"
00037 #include "text_view.h"
00038 
00039 namespace text
00040 {
00041 
00042 class PluginDocImpl;
00043 
00044 /// @brief Implement all interfaces of view object. If view object
00045 /// provider does not want to support optional interface, it may
00046 /// remove the interface from parent class list.
00047 class PluginViewImpl : public IPluginUnknown
00048                      , public IPluginView
00049                      , public IPluginViewSettings
00050                      , public IPluginRender
00051                      , public IPluginFont
00052                      , public IPluginEventBroadcaster
00053                      
00054 {
00055 public:
00056     explicit PluginViewImpl(PluginDocImpl *doc);
00057     ~PluginViewImpl(void);
00058 
00059 public:
00060     TextView & get_text_view() { return view; }
00061     TextController * get_text_controller() {return &controller;}
00062 
00063     /// @brief Get bounding rectangles given by specified range.
00064     /// @param page_start_pos The start position of the page.
00065     /// @param range Identify a range.
00066     IPluginUnknown* get_bounding_rectangles_from_range_impl(const Position&    page_start_pos,
00067                                                             const PluginRange* range);
00068 
00069     /// @brief Get anchor given by specified coordinates.
00070     /// @param page_start_pos The start position of the page.
00071     /// @param x The x coordinate.
00072     /// @param y The y coordinate.
00073     /// @param anchor The output (result) anchor.
00074     /// @return The operation status code.
00075     PluginStatus get_anchor_from_coordinates_impl(const Position& page_start_pos,
00076                                                   const int       x,
00077                                                   const int       y,
00078                                                   UDSString*      anchor);
00079 
00080 private:
00081     // IPluginUnknown
00082     static PluginStatus query_interface_impl(
00083         IPluginUnknown      *thiz,
00084         const UDSString     *id, 
00085         void                **ptr );
00086 
00087     static int release_impl(
00088         IPluginUnknown      *thiz );
00089 
00090     static int get_page_number_impl(
00091         IPluginUnknown      *thiz,
00092         const UDSString     *anchor );
00093 
00094     static PluginStatus get_page_name_impl(
00095         IPluginUnknown      *thiz,
00096         const UDSString     *page_start_anchor,
00097         UDSString           *name);
00098 
00099     static PluginStatus get_rendered_page_start_impl(
00100         IPluginUnknown  *thiz, 
00101         const UDSString *anchor, 
00102         UDSString       *start_anchor);
00103         
00104     static PluginStatus get_physical_page_start_impl(
00105         IPluginUnknown  *thiz, 
00106         const UDSString *anchor, 
00107         UDSString       *start_anchor);
00108 
00109     static int get_number_of_pages_impl(
00110         IPluginUnknown      *thiz);
00111 
00112     static PluginStatus get_anchor_by_page_impl(
00113         IPluginUnknown      *thiz,
00114         unsigned int        page,
00115         UDSString           *anchor);
00116 
00117     static PluginStatus get_prev_page_impl(
00118         IPluginUnknown      *thiz,
00119         UDSString           *anchor);
00120 
00121     static PluginStatus get_next_page_impl(
00122         IPluginUnknown *thiz,
00123         UDSString      *anchor);
00124 
00125     static PluginStatus get_cover_page_impl(
00126         IPluginUnknown *thiz,
00127         const int      width,
00128         const int      height,
00129         PluginBitmapAttributes *cover_page);
00130 
00131     static PluginStatus set_display_size_impl(
00132         IPluginUnknown      *thiz,
00133         const int           width,
00134         const int           height );
00135 
00136     static PluginStatus set_DPI_impl( 
00137         IPluginUnknown      *thiz,
00138         const unsigned int  dpi );
00139 
00140     static PluginStatus set_color_depth_impl(
00141         IPluginUnknown        *thiz,
00142         const unsigned int    color_depth );
00143 
00144     static PluginStatus render_impl(
00145         IPluginUnknown      *thiz,
00146         const UDSString     *anchor,
00147         const int           page_offset,
00148         IPluginUnknown      *settings,
00149         const RenderArea    *area, 
00150         const unsigned int  refId );
00151 
00152     static IPluginUnknown * create_render_settings_impl(
00153         IPluginUnknown      *thiz );
00154 
00155     static PluginStatus set_memory_limit_impl(
00156         IPluginUnknown       *thiz,   
00157         const unsigned int   bytes );
00158 
00159     static PluginStatus get_original_size_impl(
00160         IPluginUnknown       *thiz,
00161         const UDSString      *anchor,
00162         unsigned int         *width,
00163         unsigned int         *height );
00164 
00165     static PluginStatus get_page_content_area_impl(
00166         IPluginUnknown       *thiz,
00167         const UDSString      *start_of_page_anchor,
00168         RenderArea           *area );
00169 
00170     static int get_font_size_impl(
00171         IPluginUnknown      *thiz );
00172 
00173     static PluginStatus set_font_size_impl(
00174         IPluginUnknown      *thiz, 
00175         const unsigned int  font_size );
00176 
00177     static PluginStatus get_font_family_impl(
00178         IPluginUnknown      *thiz, 
00179         UDSString           *font_family );
00180 
00181     static PluginStatus set_font_family_impl(
00182         IPluginUnknown      *thiz, 
00183         const UDSString     *font_family );
00184 
00185     static PluginStatus add_event_receiver_impl(
00186         IPluginUnknown      *thiz,
00187         const PluginEvent   plugin_event,
00188         EventFunc           callback,
00189         void                *user_data,
00190         unsigned long       *handler_id );
00191 
00192     static PluginStatus remove_event_receiver_impl(
00193         IPluginUnknown      *thiz,
00194         unsigned long       handler_id );
00195 
00196 private:
00197     void on_render_done(unsigned int id,
00198                         const Position&,
00199                         const Position&,
00200                         void  *data);
00201     void on_pagination_start(unsigned int total);
00202     void on_pagination_done(unsigned int current, unsigned int total);
00203 
00204 private:
00205     typedef PluginRenderSettingsImpl * RenderSettingsPtr;
00206     typedef std::vector<RenderSettingsPtr> RenderSettings;
00207     typedef std::vector<RenderSettingsPtr>::iterator RenderSettingsIter;
00208 
00209     typedef PluginRenderResultImpl * RenderResultPtr;
00210     typedef std::vector<RenderResultPtr> RenderResults;
00211     typedef std::vector<RenderResultPtr>::iterator RenderResultIter;
00212 
00213     static utils::ObjectTable<PluginViewImpl> g_instances_table;
00214 
00215     PluginDocImpl  *document;    ///< Reference to the document.
00216     TextView       view;
00217     TextController controller;
00218     RenderSettings render_settings;
00219     RenderResults  render_results;
00220     utils::Listeners listeners;
00221 
00222 private:
00223     void on_render_settings_released(PluginRenderSettingsImpl * settings);
00224     void on_render_result_released(PluginRenderResultImpl * result);
00225 };
00226 
00227 };  // namespace text
00228 
00229 #endif
00230 
00231 
00232 
Generated by  doxygen 1.6.2-20100208