| 1 |
// ePDFView - Dumb Test Document. |
|---|
| 2 |
// Copyright (C) 2006 Emma's Software. |
|---|
| 3 |
// |
|---|
| 4 |
// This program is free software; you can redistribute it and/or modify |
|---|
| 5 |
// it under the terms of the GNU General Public License as published by |
|---|
| 6 |
// the Free Software Foundation; either version 2 of the License, or |
|---|
| 7 |
// (at your option) any later version. |
|---|
| 8 |
// |
|---|
| 9 |
// This program is distributed in the hope that it will be useful, |
|---|
| 10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 12 |
// GNU General Public License for more details. |
|---|
| 13 |
// |
|---|
| 14 |
// You should have received a copy of the GNU General Public License |
|---|
| 15 |
// along with this program; if not, write to the Free Software |
|---|
| 16 |
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 17 |
|
|---|
| 18 |
#include <epdfview.h> |
|---|
| 19 |
#include "DumbDocument.h" |
|---|
| 20 |
|
|---|
| 21 |
using namespace ePDFView; |
|---|
| 22 |
|
|---|
| 23 |
//////////////////////////////////////////////////////////////// |
|---|
| 24 |
// Interface Methods |
|---|
| 25 |
//////////////////////////////////////////////////////////////// |
|---|
| 26 |
|
|---|
| 27 |
DumbDocument::DumbDocument (): |
|---|
| 28 |
IDocument () |
|---|
| 29 |
{ |
|---|
| 30 |
m_Loaded = FALSE; |
|---|
| 31 |
m_OpenError = DocumentErrorNone; |
|---|
| 32 |
m_SavedFileName = g_strdup (""); |
|---|
| 33 |
m_TestPassword = NULL; |
|---|
| 34 |
setNumPages (2); |
|---|
| 35 |
} |
|---|
| 36 |
|
|---|
| 37 |
DumbDocument::~DumbDocument () |
|---|
| 38 |
{ |
|---|
| 39 |
clearCache (); |
|---|
| 40 |
g_free (m_SavedFileName); |
|---|
| 41 |
g_free (m_TestPassword); |
|---|
| 42 |
} |
|---|
| 43 |
|
|---|
| 44 |
IDocument * |
|---|
| 45 |
DumbDocument::copy () const |
|---|
| 46 |
{ |
|---|
| 47 |
return new DumbDocument (); |
|---|
| 48 |
} |
|---|
| 49 |
|
|---|
| 50 |
GList * |
|---|
| 51 |
DumbDocument::findTextInPage (gint pageNum, const gchar *textToFind) |
|---|
| 52 |
{ |
|---|
| 53 |
return NULL; |
|---|
| 54 |
} |
|---|
| 55 |
|
|---|
| 56 |
gboolean |
|---|
| 57 |
DumbDocument::isLoaded () |
|---|
| 58 |
{ |
|---|
| 59 |
return m_Loaded; |
|---|
| 60 |
} |
|---|
| 61 |
|
|---|
| 62 |
gboolean |
|---|
| 63 |
DumbDocument::loadFile (const gchar *filename, const gchar *password, |
|---|
| 64 |
GError **error) |
|---|
| 65 |
{ |
|---|
| 66 |
if ( DocumentErrorNone == m_OpenError ) |
|---|
| 67 |
{ |
|---|
| 68 |
m_Loaded = TRUE; |
|---|
| 69 |
setFileName (filename); |
|---|
| 70 |
setPassword (password); |
|---|
| 71 |
} |
|---|
| 72 |
else if ( DocumentErrorEncrypted == m_OpenError && |
|---|
| 73 |
NULL != password && NULL != m_TestPassword && |
|---|
| 74 |
0 == g_ascii_strcasecmp (password, m_TestPassword)) |
|---|
| 75 |
{ |
|---|
| 76 |
m_Loaded = TRUE; |
|---|
| 77 |
setFileName (filename); |
|---|
| 78 |
setPassword (password); |
|---|
| 79 |
} |
|---|
| 80 |
else |
|---|
| 81 |
{ |
|---|
| 82 |
g_set_error (error, EPDFVIEW_DOCUMENT_ERROR, m_OpenError, |
|---|
| 83 |
"%s", IDocument::getErrorMessage (m_OpenError)); |
|---|
| 84 |
m_Loaded = FALSE; |
|---|
| 85 |
} |
|---|
| 86 |
return m_Loaded; |
|---|
| 87 |
} |
|---|
| 88 |
|
|---|
| 89 |
void |
|---|
| 90 |
DumbDocument::getPageSizeForPage (gint pageNum, gdouble *width, gdouble *height) |
|---|
| 91 |
{ |
|---|
| 92 |
if ( 90 == getRotation () || 270 == getRotation () ) |
|---|
| 93 |
{ |
|---|
| 94 |
*width = 250; |
|---|
| 95 |
*height = 100; |
|---|
| 96 |
} |
|---|
| 97 |
else |
|---|
| 98 |
{ |
|---|
| 99 |
*width = 100; |
|---|
| 100 |
*height = 250; |
|---|
| 101 |
} |
|---|
| 102 |
} |
|---|
| 103 |
|
|---|
| 104 |
void |
|---|
| 105 |
DumbDocument::outputPostscriptBegin (const gchar *fileName, guint numberOfPages, |
|---|
| 106 |
gfloat pageWidth, gfloat pageHeight) |
|---|
| 107 |
{ |
|---|
| 108 |
} |
|---|
| 109 |
|
|---|
| 110 |
void |
|---|
| 111 |
DumbDocument::outputPostscriptEnd () |
|---|
| 112 |
{ |
|---|
| 113 |
} |
|---|
| 114 |
|
|---|
| 115 |
void |
|---|
| 116 |
DumbDocument::outputPostscriptPage (guint pageNumber) |
|---|
| 117 |
{ |
|---|
| 118 |
} |
|---|
| 119 |
|
|---|
| 120 |
DocumentPage * |
|---|
| 121 |
DumbDocument::renderPage (gint pageNum) |
|---|
| 122 |
{ |
|---|
| 123 |
return new DocumentPage (); |
|---|
| 124 |
} |
|---|
| 125 |
|
|---|
| 126 |
gboolean |
|---|
| 127 |
DumbDocument::saveFile (const gchar *fileName, GError **error) |
|---|
| 128 |
{ |
|---|
| 129 |
g_free (m_SavedFileName); |
|---|
| 130 |
m_SavedFileName = g_strdup (fileName); |
|---|
| 131 |
return TRUE; |
|---|
| 132 |
} |
|---|
| 133 |
|
|---|
| 134 |
//////////////////////////////////////////////////////////////// |
|---|
| 135 |
// Tests Methods |
|---|
| 136 |
//////////////////////////////////////////////////////////////// |
|---|
| 137 |
|
|---|
| 138 |
const gchar * |
|---|
| 139 |
DumbDocument::getSavedFileName () |
|---|
| 140 |
{ |
|---|
| 141 |
return m_SavedFileName; |
|---|
| 142 |
} |
|---|
| 143 |
|
|---|
| 144 |
void |
|---|
| 145 |
DumbDocument::setOpenError (DocumentError error) |
|---|
| 146 |
{ |
|---|
| 147 |
m_OpenError = error; |
|---|
| 148 |
} |
|---|
| 149 |
|
|---|
| 150 |
void |
|---|
| 151 |
DumbDocument::setOutline (DocumentOutline *outline) |
|---|
| 152 |
{ |
|---|
| 153 |
m_Outline = outline; |
|---|
| 154 |
} |
|---|
| 155 |
|
|---|
| 156 |
void |
|---|
| 157 |
DumbDocument::setTestPassword (const gchar *password) |
|---|
| 158 |
{ |
|---|
| 159 |
gchar *oldPassword = m_TestPassword; |
|---|
| 160 |
m_TestPassword = g_strdup (password); |
|---|
| 161 |
g_free (oldPassword); |
|---|
| 162 |
} |
|---|