LCOV - code coverage report
Current view: top level - vcl/unx/gtk/gdi - gtkprintwrapper.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 83 0.0 %
Date: 2012-08-25 Functions: 0 24 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*
       3                 :            :  * Version: MPL 1.1 / GPLv3+ / LGPLv3+
       4                 :            :  *
       5                 :            :  * The contents of this file are subject to the Mozilla Public License Version
       6                 :            :  * 1.1 (the "License"); you may not use this file except in compliance with
       7                 :            :  * the License or as specified alternatively below. You may obtain a copy of
       8                 :            :  * the License at http://www.mozilla.org/MPL/
       9                 :            :  *
      10                 :            :  * Software distributed under the License is distributed on an "AS IS" basis,
      11                 :            :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12                 :            :  * for the specific language governing rights and limitations under the
      13                 :            :  * License.
      14                 :            :  *
      15                 :            :  * Major Contributor(s):
      16                 :            :  * Copyright (C) 2011 Red Hat, Inc., David Tardon <dtardon@redhat.com>
      17                 :            :  *  (initial developer)
      18                 :            :  *
      19                 :            :  * All Rights Reserved.
      20                 :            :  *
      21                 :            :  * For minor contributions see the git repository.
      22                 :            :  *
      23                 :            :  * Alternatively, the contents of this file may be used under the terms of
      24                 :            :  * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
      25                 :            :  * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
      26                 :            :  * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
      27                 :            :  * instead of those above.
      28                 :            :  */
      29                 :            : 
      30                 :            : #include <cassert>
      31                 :            : 
      32                 :            : #include <rtl/ustring.hxx>
      33                 :            : 
      34                 :            : #include "gtkprintwrapper.hxx"
      35                 :            : 
      36                 :            : namespace vcl
      37                 :            : {
      38                 :            : namespace unx
      39                 :            : {
      40                 :            : 
      41                 :            : #if !GTK_CHECK_VERSION(3,0,0)
      42                 :            : 
      43                 :          0 : GtkPrintWrapper::GtkPrintWrapper()
      44                 :            :     : m_page_setup_new(0)
      45                 :            :     , m_print_job_new(0)
      46                 :            :     , m_print_job_send(0)
      47                 :            :     , m_print_job_set_source_file(0)
      48                 :            :     , m_print_settings_get(0)
      49                 :            :     , m_print_settings_get_collate(0)
      50                 :            :     , m_print_settings_set_collate(0)
      51                 :            :     , m_print_settings_get_n_copies(0)
      52                 :            :     , m_print_settings_set_n_copies(0)
      53                 :            :     , m_print_settings_get_page_ranges(0)
      54                 :            :     , m_print_settings_set_print_pages(0)
      55                 :            :     , m_print_unix_dialog_new(0)
      56                 :            :     , m_print_unix_dialog_add_custom_tab(0)
      57                 :            :     , m_print_unix_dialog_get_selected_printer(0)
      58                 :            :     , m_print_unix_dialog_set_manual_capabilities(0)
      59                 :            :     , m_print_unix_dialog_get_settings(0)
      60                 :            :     , m_print_unix_dialog_set_settings(0)
      61                 :            :     , m_print_unix_dialog_set_support_selection(0)
      62                 :          0 :     , m_print_unix_dialog_set_has_selection(0)
      63                 :            : {
      64                 :          0 :     impl_load();
      65                 :          0 : }
      66                 :            : 
      67                 :            : #else
      68                 :            : 
      69                 :            : GtkPrintWrapper::GtkPrintWrapper()
      70                 :            : {
      71                 :            : }
      72                 :            : 
      73                 :            : #endif
      74                 :            : 
      75                 :          0 : GtkPrintWrapper::~GtkPrintWrapper()
      76                 :            : {
      77                 :          0 : }
      78                 :            : 
      79                 :            : #if !GTK_CHECK_VERSION(3,0,0)
      80                 :            : 
      81                 :          0 : void GtkPrintWrapper::impl_load()
      82                 :            : {
      83                 :          0 :     m_aModule.load(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("libgtk-x11-2.0.so.0")));
      84                 :          0 :     if (!m_aModule.is())
      85                 :          0 :         m_aModule.load(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("libgtk-x11-2.0.so")));
      86                 :          0 :     if (!m_aModule.is())
      87                 :          0 :         return;
      88                 :            : 
      89                 :          0 :     m_page_setup_new = reinterpret_cast<page_setup_new_t>(m_aModule.getFunctionSymbol("gtk_page_setup_new"));
      90                 :          0 :     m_print_job_new = reinterpret_cast<print_job_new_t>(m_aModule.getFunctionSymbol("gtk_print_job_new"));
      91                 :          0 :     m_print_job_send = reinterpret_cast<print_job_send_t>(m_aModule.getFunctionSymbol("gtk_print_job_send"));
      92                 :          0 :     m_print_job_set_source_file = reinterpret_cast<print_job_set_source_file_t>(m_aModule.getFunctionSymbol("gtk_print_job_set_source_file"));
      93                 :          0 :     m_print_settings_get = reinterpret_cast<print_settings_get_t>(m_aModule.getFunctionSymbol("gtk_print_settings_get"));
      94                 :          0 :     m_print_settings_get_collate = reinterpret_cast<print_settings_get_collate_t>(m_aModule.getFunctionSymbol("gtk_print_settings_get_collate"));
      95                 :          0 :     m_print_settings_set_collate = reinterpret_cast<print_settings_set_collate_t>(m_aModule.getFunctionSymbol("gtk_print_settings_set_collate"));
      96                 :          0 :     m_print_settings_get_n_copies = reinterpret_cast<print_settings_get_n_copies_t>(m_aModule.getFunctionSymbol("gtk_print_settings_get_n_copies"));
      97                 :          0 :     m_print_settings_set_n_copies = reinterpret_cast<print_settings_set_n_copies_t>(m_aModule.getFunctionSymbol("gtk_print_settings_set_n_copies"));
      98                 :          0 :     m_print_settings_get_page_ranges = reinterpret_cast<print_settings_get_page_ranges_t>(m_aModule.getFunctionSymbol("gtk_print_settings_get_page_ranges"));
      99                 :          0 :     m_print_settings_set_print_pages = reinterpret_cast<print_settings_set_print_pages_t>(m_aModule.getFunctionSymbol("gtk_print_settings_set_print_pages"));
     100                 :          0 :     m_print_unix_dialog_new = reinterpret_cast<print_unix_dialog_new_t>(m_aModule.getFunctionSymbol("gtk_print_unix_dialog_new"));
     101                 :          0 :     m_print_unix_dialog_add_custom_tab = reinterpret_cast<print_unix_dialog_add_custom_tab_t>(m_aModule.getFunctionSymbol("gtk_print_unix_dialog_add_custom_tab"));
     102                 :          0 :     m_print_unix_dialog_get_selected_printer = reinterpret_cast<print_unix_dialog_get_selected_printer_t>(m_aModule.getFunctionSymbol("gtk_print_unix_dialog_get_selected_printer"));
     103                 :          0 :     m_print_unix_dialog_set_manual_capabilities = reinterpret_cast<print_unix_dialog_set_manual_capabilities_t>(m_aModule.getFunctionSymbol("gtk_print_unix_dialog_set_manual_capabilities"));
     104                 :          0 :     m_print_unix_dialog_get_settings = reinterpret_cast<print_unix_dialog_get_settings_t>(m_aModule.getFunctionSymbol("gtk_print_unix_dialog_get_settings"));
     105                 :          0 :     m_print_unix_dialog_set_settings = reinterpret_cast<print_unix_dialog_set_settings_t>(m_aModule.getFunctionSymbol("gtk_print_unix_dialog_set_settings"));
     106                 :          0 :     m_print_unix_dialog_set_support_selection = reinterpret_cast<print_unix_dialog_set_support_selection_t>(m_aModule.getFunctionSymbol("gtk_print_unix_dialog_set_support_selection"));
     107                 :          0 :     m_print_unix_dialog_set_has_selection = reinterpret_cast<print_unix_dialog_set_has_selection_t>(m_aModule.getFunctionSymbol("gtk_print_unix_dialog_set_has_selection"));
     108                 :            : }
     109                 :            : 
     110                 :            : #endif
     111                 :            : 
     112                 :          0 : bool GtkPrintWrapper::supportsPrinting() const
     113                 :            : {
     114                 :            : #if !GTK_CHECK_VERSION(3,0,0)
     115                 :            :     return
     116                 :            :         m_page_setup_new
     117                 :            :         && m_print_job_new
     118                 :            :         && m_print_job_send
     119                 :            :         && m_print_job_set_source_file
     120                 :            :         && m_print_settings_get
     121                 :            :         && m_print_settings_get_collate
     122                 :            :         && m_print_settings_set_collate
     123                 :            :         && m_print_settings_get_n_copies
     124                 :            :         && m_print_settings_set_n_copies
     125                 :            :         && m_print_settings_get_page_ranges
     126                 :            :         && m_print_settings_set_print_pages
     127                 :            :         && m_print_unix_dialog_new
     128                 :            :         && m_print_unix_dialog_add_custom_tab
     129                 :            :         && m_print_unix_dialog_get_selected_printer
     130                 :            :         && m_print_unix_dialog_set_manual_capabilities
     131                 :            :         && m_print_unix_dialog_get_settings
     132                 :          0 :         && m_print_unix_dialog_set_settings
     133                 :            :         ;
     134                 :            : #else
     135                 :            :     return true;
     136                 :            : #endif
     137                 :            : }
     138                 :            : 
     139                 :          0 : bool GtkPrintWrapper::supportsPrintSelection() const
     140                 :            : {
     141                 :            : #if !GTK_CHECK_VERSION(3,0,0)
     142                 :            :     return
     143                 :          0 :         supportsPrinting()
     144                 :            :         && m_print_unix_dialog_set_support_selection
     145                 :          0 :         && m_print_unix_dialog_set_has_selection
     146                 :            :         ;
     147                 :            : #else
     148                 :            :     return true;
     149                 :            : #endif
     150                 :            : }
     151                 :            : 
     152                 :          0 : GtkPageSetup* GtkPrintWrapper::page_setup_new() const
     153                 :            : {
     154                 :            : #if !GTK_CHECK_VERSION(3,0,0)
     155                 :            :     assert(m_page_setup_new);
     156                 :          0 :     return (*m_page_setup_new)();
     157                 :            : #else
     158                 :            :     return gtk_page_setup_new();
     159                 :            : #endif
     160                 :            : }
     161                 :            : 
     162                 :          0 : GtkPrintJob* GtkPrintWrapper::print_job_new(const gchar* title, GtkPrinter* printer, GtkPrintSettings* settings, GtkPageSetup* page_setup) const
     163                 :            : {
     164                 :            : #if !GTK_CHECK_VERSION(3,0,0)
     165                 :            :     assert(m_print_job_new);
     166                 :          0 :     return (*m_print_job_new)(title, printer, settings, page_setup);
     167                 :            : #else
     168                 :            :     return gtk_print_job_new(title, printer, settings, page_setup);
     169                 :            : #endif
     170                 :            : }
     171                 :            : 
     172                 :          0 : void GtkPrintWrapper::print_job_send(GtkPrintJob* job, GtkPrintJobCompleteFunc callback, gpointer user_data, GDestroyNotify dnotify) const
     173                 :            : {
     174                 :            : #if !GTK_CHECK_VERSION(3,0,0)
     175                 :            :     assert(m_print_job_send);
     176                 :          0 :     (*m_print_job_send)(job, callback, user_data, dnotify);
     177                 :            : #else
     178                 :            :     gtk_print_job_send(job, callback, user_data, dnotify);
     179                 :            : #endif
     180                 :          0 : }
     181                 :            : 
     182                 :          0 : gboolean GtkPrintWrapper::print_job_set_source_file(GtkPrintJob* job, const gchar* filename, GError** error) const
     183                 :            : {
     184                 :            : #if !GTK_CHECK_VERSION(3,0,0)
     185                 :            :     assert(m_print_job_set_source_file);
     186                 :          0 :     return (*m_print_job_set_source_file)(job, filename, error);
     187                 :            : #else
     188                 :            :     return gtk_print_job_set_source_file(job, filename, error);
     189                 :            : #endif
     190                 :            : }
     191                 :            : 
     192                 :          0 : const gchar* GtkPrintWrapper::print_settings_get(GtkPrintSettings* settings, const gchar* key) const
     193                 :            : {
     194                 :            : #if !GTK_CHECK_VERSION(3,0,0)
     195                 :            :     assert(m_print_settings_get);
     196                 :          0 :     return (*m_print_settings_get)(settings, key);
     197                 :            : #else
     198                 :            :     return gtk_print_settings_get(settings, key);
     199                 :            : #endif
     200                 :            : }
     201                 :            : 
     202                 :          0 : gboolean GtkPrintWrapper::print_settings_get_collate(GtkPrintSettings* settings) const
     203                 :            : {
     204                 :            : #if !GTK_CHECK_VERSION(3,0,0)
     205                 :            :     assert(m_print_settings_get_collate);
     206                 :          0 :     return (*m_print_settings_get_collate)(settings);
     207                 :            : #else
     208                 :            :     return gtk_print_settings_get_collate(settings);
     209                 :            : #endif
     210                 :            : }
     211                 :            : 
     212                 :          0 : void GtkPrintWrapper::print_settings_set_collate(GtkPrintSettings* settings, gboolean collate) const
     213                 :            : {
     214                 :            : #if !GTK_CHECK_VERSION(3,0,0)
     215                 :            :     assert(m_print_settings_set_collate);
     216                 :          0 :     (*m_print_settings_set_collate)(settings, collate);
     217                 :            : #else
     218                 :            :     gtk_print_settings_set_collate(settings, collate);
     219                 :            : #endif
     220                 :          0 : }
     221                 :            : 
     222                 :          0 : gint GtkPrintWrapper::print_settings_get_n_copies(GtkPrintSettings* settings) const
     223                 :            : {
     224                 :            : #if !GTK_CHECK_VERSION(3,0,0)
     225                 :            :     assert(m_print_settings_get_n_copies);
     226                 :          0 :     return (*m_print_settings_get_n_copies)(settings);
     227                 :            : #else
     228                 :            :     return gtk_print_settings_get_n_copies(settings);
     229                 :            : #endif
     230                 :            : }
     231                 :            : 
     232                 :          0 : void GtkPrintWrapper::print_settings_set_n_copies(GtkPrintSettings* settings, gint num_copies) const
     233                 :            : {
     234                 :            : #if !GTK_CHECK_VERSION(3,0,0)
     235                 :            :     assert(m_print_settings_set_n_copies);
     236                 :          0 :     (*m_print_settings_set_n_copies)(settings, num_copies);
     237                 :            : #else
     238                 :            :     gtk_print_settings_set_n_copies(settings, num_copies);
     239                 :            : #endif
     240                 :          0 : }
     241                 :            : 
     242                 :          0 : GtkPageRange* GtkPrintWrapper::print_settings_get_page_ranges(GtkPrintSettings* settings, gint* num_ranges) const
     243                 :            : {
     244                 :            : #if !GTK_CHECK_VERSION(3,0,0)
     245                 :            :     assert(m_print_settings_get_page_ranges);
     246                 :          0 :     return (*m_print_settings_get_page_ranges)(settings, num_ranges);
     247                 :            : #else
     248                 :            :     return gtk_print_settings_get_page_ranges(settings, num_ranges);
     249                 :            : #endif
     250                 :            : }
     251                 :            : 
     252                 :          0 : void GtkPrintWrapper::print_settings_set_print_pages(GtkPrintSettings* settings, GtkPrintPages pages) const
     253                 :            : {
     254                 :            : #if !GTK_CHECK_VERSION(3,0,0)
     255                 :            :     assert(m_print_settings_set_print_pages);
     256                 :          0 :     (*m_print_settings_set_print_pages)(settings, pages);
     257                 :            : #else
     258                 :            :     gtk_print_settings_set_print_pages(settings, pages);
     259                 :            : #endif
     260                 :          0 : }
     261                 :            : 
     262                 :          0 : GtkWidget* GtkPrintWrapper::print_unix_dialog_new(const gchar* title, GtkWindow* parent) const
     263                 :            : {
     264                 :            : #if !GTK_CHECK_VERSION(3,0,0)
     265                 :            :     assert(m_print_unix_dialog_new);
     266                 :          0 :     return (*m_print_unix_dialog_new)(title, parent);
     267                 :            : #else
     268                 :            :     return gtk_print_unix_dialog_new(title, parent);
     269                 :            : #endif
     270                 :            : }
     271                 :            : 
     272                 :          0 : void GtkPrintWrapper::print_unix_dialog_add_custom_tab(GtkPrintUnixDialog* dialog, GtkWidget* child, GtkWidget* tab_label) const
     273                 :            : {
     274                 :            : #if !GTK_CHECK_VERSION(3,0,0)
     275                 :            :     assert(m_print_unix_dialog_add_custom_tab);
     276                 :          0 :     (*m_print_unix_dialog_add_custom_tab)(dialog, child, tab_label);
     277                 :            : #else
     278                 :            :     gtk_print_unix_dialog_add_custom_tab(dialog, child, tab_label);
     279                 :            : #endif
     280                 :          0 : }
     281                 :            : 
     282                 :          0 : GtkPrinter* GtkPrintWrapper::print_unix_dialog_get_selected_printer(GtkPrintUnixDialog* dialog) const
     283                 :            : {
     284                 :            : #if !GTK_CHECK_VERSION(3,0,0)
     285                 :            :     assert(m_print_unix_dialog_get_selected_printer);
     286                 :          0 :     return (*m_print_unix_dialog_get_selected_printer)(dialog);
     287                 :            : #else
     288                 :            :     return gtk_print_unix_dialog_get_selected_printer(dialog);
     289                 :            : #endif
     290                 :            : }
     291                 :            : 
     292                 :          0 : void GtkPrintWrapper::print_unix_dialog_set_manual_capabilities(GtkPrintUnixDialog* dialog, GtkPrintCapabilities capabilities) const
     293                 :            : {
     294                 :            : #if !GTK_CHECK_VERSION(3,0,0)
     295                 :            :     assert(m_print_unix_dialog_set_manual_capabilities);
     296                 :          0 :     (*m_print_unix_dialog_set_manual_capabilities)(dialog, capabilities);
     297                 :            : #else
     298                 :            :     gtk_print_unix_dialog_set_manual_capabilities(dialog, capabilities);
     299                 :            : #endif
     300                 :          0 : }
     301                 :            : 
     302                 :          0 : GtkPrintSettings* GtkPrintWrapper::print_unix_dialog_get_settings(GtkPrintUnixDialog* dialog) const
     303                 :            : {
     304                 :            : #if !GTK_CHECK_VERSION(3,0,0)
     305                 :            :     assert(m_print_unix_dialog_get_settings);
     306                 :          0 :     return (*m_print_unix_dialog_get_settings)(dialog);
     307                 :            : #else
     308                 :            :     return gtk_print_unix_dialog_get_settings(dialog);
     309                 :            : #endif
     310                 :            : }
     311                 :            : 
     312                 :          0 : void GtkPrintWrapper::print_unix_dialog_set_settings(GtkPrintUnixDialog* dialog, GtkPrintSettings* settings) const
     313                 :            : {
     314                 :            : #if !GTK_CHECK_VERSION(3,0,0)
     315                 :            :     assert(m_print_unix_dialog_set_settings);
     316                 :          0 :     (*m_print_unix_dialog_set_settings)(dialog, settings);
     317                 :            : #else
     318                 :            :     gtk_print_unix_dialog_set_settings(dialog, settings);
     319                 :            : #endif
     320                 :          0 : }
     321                 :            : 
     322                 :          0 : void GtkPrintWrapper::print_unix_dialog_set_support_selection(GtkPrintUnixDialog* dialog, gboolean support_selection) const
     323                 :            : {
     324                 :            : #if !GTK_CHECK_VERSION(3,0,0)
     325                 :            :     assert(m_print_unix_dialog_set_support_selection);
     326                 :          0 :     (*m_print_unix_dialog_set_support_selection)(dialog, support_selection);
     327                 :            : #else
     328                 :            :     gtk_print_unix_dialog_set_support_selection(dialog, support_selection);
     329                 :            : #endif
     330                 :          0 : }
     331                 :            : 
     332                 :          0 : void GtkPrintWrapper::print_unix_dialog_set_has_selection(GtkPrintUnixDialog* dialog, gboolean has_selection) const
     333                 :            : {
     334                 :            : #if !GTK_CHECK_VERSION(3,0,0)
     335                 :            :     assert(m_print_unix_dialog_set_has_selection);
     336                 :          0 :     (*m_print_unix_dialog_set_has_selection)(dialog, has_selection);
     337                 :            : #else
     338                 :            :     gtk_print_unix_dialog_set_has_selection(dialog, has_selection);
     339                 :            : #endif
     340                 :          0 : }
     341                 :            : 
     342                 :            : }
     343                 :            : }
     344                 :            : 
     345                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10