Changeset 222
- Timestamp:
- 06/11/06 14:46:38 (2 years ago)
- Location:
- trunk/src
- Files:
-
- 2 added
- 15 modified
-
IDocument.cxx (modified) (3 diffs)
-
IDocument.h (modified) (3 diffs)
-
IPrintView.h (modified) (4 diffs)
-
JobFind.cxx (modified) (2 diffs)
-
JobLoad.cxx (modified) (1 diff)
-
JobPrint.cxx (added)
-
JobPrint.h (added)
-
JobSave.h (modified) (1 diff)
-
MainPter.cxx (modified) (1 diff)
-
Makefile.am (modified) (1 diff)
-
PDFDocument.cxx (modified) (4 diffs)
-
PDFDocument.h (modified) (3 diffs)
-
PrintPter.cxx (modified) (3 diffs)
-
PrintPter.h (modified) (3 diffs)
-
epdfview.h (modified) (1 diff)
-
gtk/PrintView.cxx (modified) (3 diffs)
-
gtk/PrintView.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/IDocument.cxx
r206 r222 231 231 IDocumentObserver *observer = (IDocumentObserver *)item->data; 232 232 observer->notifyFindChanged (matchRect); 233 } 233 } 234 234 } 235 235 … … 903 903 /// 904 904 const gchar * 905 IDocument::getPassword () 905 IDocument::getPassword () const 906 906 { 907 907 return m_Password; … … 939 939 /// 940 940 const gchar * 941 IDocument::getFileName () 941 IDocument::getFileName () const 942 942 { 943 943 if ( NULL == m_FileName ) -
trunk/src/IDocument.h
r200 r222 134 134 135 135 /// 136 /// @brief Makes a copy of the document. 137 /// 138 /// This function must make a deep copy of the current document 139 /// and return the result. 140 /// 141 /// @return A new document class with the same content than the 142 /// caller document. 143 /// 144 virtual IDocument *copy (void) const = 0; 145 146 /// 136 147 /// @brief Finds text on a single page. 137 148 /// … … 190 201 virtual void getPageSizeForPage (gint pageNum, gdouble *width, 191 202 gdouble *height) = 0; 203 204 /// 205 /// @brief Starts the output to PostScript. 206 /// 207 /// This starts a new PostScript file with name @a fileName and 208 /// with @a numPages pages of @a width x @a height. 209 /// 210 /// @param fileName The file name to output the postscript code. 211 /// @param numOfPages The number of pages to output. 212 /// @param pageWidth The width of each page. 213 /// @param pageHeight The height of each page. 214 /// 215 virtual void outputPostscriptBegin (const gchar *fileName, 216 guint numOfPages, 217 gfloat pageWidth, 218 gfloat pageHeight) = 0; 219 220 /// 221 /// @brief Ends the output to PostScript. 222 /// 223 /// Ends any started output to PostScript by calling 224 /// outputPostscriptBegin (). 225 /// 226 virtual void outputPostscriptEnd (void) = 0; 227 228 /// 229 /// @brief Renders a single page to PostScript. 230 /// 231 /// Renders the page @a pageNum To the PostScript started 232 /// at outputPostscriptBegin (). 233 /// 234 /// @param pageNum The number of the page to render. 235 /// 236 virtual void outputPostscriptPage (guint pageNum) = 0; 192 237 193 238 /// … … 248 293 const gchar *getCreator (void); 249 294 void setCreator (gchar *creator); 250 const gchar *getPassword (void) ;295 const gchar *getPassword (void) const; 251 296 void setPassword (const gchar *password); 252 297 const gchar *getProducer (void); 253 298 void setProducer (gchar *producer); 254 const gchar *getFileName (void) ;299 const gchar *getFileName (void) const; 255 300 void setFileName (const gchar *fileName); 256 301 const gchar *getFormat (void); -
trunk/src/IPrintView.h
r221 r222 68 68 /// which page size is. 69 69 /// 70 virtual void addPageSize (const gchar *name, 70 virtual void addPageSize (const gchar *name, 71 71 const gchar *value) = 0; 72 72 … … 100 100 101 101 /// 102 /// @brief Gets the page layout. 103 /// 104 /// @return The selected page layout's value. 105 /// 106 virtual PrintPageLayout getPageLayout (void) = 0; 107 108 /// 109 /// @brief Gets the page orientation. 110 /// 111 /// @return The selected page orientation's value. 112 /// 113 virtual PrintPageOrientation getPageOrientation (void) = 0; 114 115 /// 116 /// @brief Gets the entred page range. 117 /// 118 /// @return The entered text in the page range entry. 119 /// 120 virtual const gchar *getPageRange (void) = 0; 121 122 /// 123 /// @brief Gets the currently selected page size. 124 /// 125 /// @return The name of the page size that is selected. This name 126 /// is the @a value parameter of the addPageSize() 127 /// function. 128 /// 129 virtual gchar *getPageSize (void) = 0; 130 131 /// 102 132 /// @brief Gets the name of the currently selected printer. 103 133 /// … … 109 139 110 140 /// 111 /// @brief Check is the "All Pages" range option is selected. 141 /// @brief Checks if the "Collate" option is checked. 142 /// 143 /// @return TRUE if the "Collate" option is checked. 144 /// FALSE otherwise. 145 /// 146 virtual gboolean isCheckedCollate (void) = 0; 147 148 /// 149 /// @brief Checks if the "All Pages" range option is selected. 112 150 /// 113 151 /// @return TRUE if the range's "All Pages" option is selected. … … 115 153 /// 116 154 virtual gboolean isSelectedAllPagesRangeOption (void) = 0; 155 156 /// 157 /// @brief Checks if the "Even Page" set option is selected. 158 /// 159 /// @return TRUE if the set's "Even Page" option is selected. 160 /// FALSE otherwise. 161 /// 162 virtual gboolean isSelectedEvenPageSet (void) = 0; 163 164 /// 165 /// @brief Checks if the "Odd Page" set option is selected. 166 /// 167 /// @return TRUE if the set's "Odd Page" option is selected. 168 /// FALSE otherwise. 169 /// 170 virtual gboolean isSelectedOddPageSet (void) = 0; 117 171 118 172 /// -
trunk/src/JobFind.cxx
r172 r222 227 227 GList *result = getDocument ()->findTextInPage (currentPage, 228 228 getTextToFind ()); 229 229 230 230 if ( FIND_DIRECTION_FORWARDS == getDirection () ) 231 231 { … … 236 236 setCurrentPage (currentPage - 1); 237 237 } 238 238 239 239 if ( NULL != result ) 240 240 { 241 241 setResults (currentPage, result); 242 242 JOB_NOTIFIER (job_find_results, this); 243 } 244 else 243 } 244 else 245 245 { 246 246 JOB_NOTIFIER (job_find_end, this); -
trunk/src/JobLoad.cxx
r200 r222 286 286 job->getDocument ().notifyReload (); 287 287 JOB_NOTIFIER_END(); 288 289 return FALSE; 290 } 288 289 return FALSE; 290 } -
trunk/src/JobSave.h
r200 r222 23 23 // Forward declarations. 24 24 class IDocument; 25 25 26 26 /// 27 27 /// @class JobSave -
trunk/src/MainPter.cxx
r213 r222 453 453 MainPter::printActivated () 454 454 { 455 PrintPter *print = new PrintPter ( );455 PrintPter *print = new PrintPter (m_Document); 456 456 IPrintView *view = getView ().getPrintView (); 457 457 if ( NULL != view ) -
trunk/src/Makefile.am
r213 r222 76 76 libepdfview_a_SOURCES += \ 77 77 IPrintView.h \ 78 JobPrint.cxx \ 79 JobPrint.h \ 78 80 PrintPter.cxx \ 79 81 PrintPter.h -
trunk/src/PDFDocument.cxx
r209 r222 39 39 { 40 40 m_Document = NULL; 41 m_PostScript = NULL; 41 42 } 42 43 … … 47 48 { 48 49 clearCache (); 50 outputPostscriptEnd (); 49 51 if ( NULL != m_Document ) 50 52 { … … 52 54 m_Document = NULL; 53 55 } 56 } 57 58 IDocument * 59 PDFDocument::copy () const 60 { 61 // Making a deep copy is just making a new document and loading the same 62 // file. 63 PDFDocument *newDocument = new PDFDocument (); 64 newDocument->loadFile (getFileName (), getPassword (), NULL); 65 66 return newDocument; 54 67 } 55 68 … … 474 487 } 475 488 489 void 490 PDFDocument::outputPostscriptBegin (const gchar *fileName, guint numOfPages, 491 gfloat pageWidth, gfloat pageHeight) 492 { 493 if ( NULL != m_Document ) 494 { 495 if ( NULL != m_PostScript ) 496 { 497 outputPostscriptEnd (); 498 } 499 m_PostScript = 500 poppler_ps_file_new (m_Document, fileName, 0, numOfPages); 501 if ( NULL != m_PostScript ) 502 { 503 poppler_ps_file_set_paper_size (m_PostScript, 504 pageWidth, pageHeight); 505 } 506 } 507 } 508 509 void 510 PDFDocument::outputPostscriptEnd () 511 { 512 if ( NULL != m_PostScript ) 513 { 514 poppler_ps_file_free (m_PostScript); 515 m_PostScript = NULL; 516 } 517 } 518 519 void 520 PDFDocument::outputPostscriptPage (guint pageNum) 521 { 522 if ( NULL != m_Document && NULL != m_PostScript ) 523 { 524 PopplerPage *page = poppler_document_get_page (m_Document, pageNum - 1); 525 if ( NULL != page ) 526 { 527 poppler_page_render_to_ps (page, m_PostScript); 528 } 529 } 530 } 531 532 476 533 /// 477 534 /// @brief Renders a document's page. -
trunk/src/PDFDocument.h
r200 r222 25 25 typedef struct _PopplerLinkMapping PopplerLinkMapping; 26 26 typedef struct _PopplerPage PopplerPage; 27 typedef struct _PopplerPSFile PopplerPSFile; 27 28 28 29 namespace ePDFView … … 40 41 ~PDFDocument (void); 41 42 43 IDocument *copy (void) const; 42 44 GList *findTextInPage (gint pageNum, const gchar *textToFind); 43 45 gboolean isLoaded (void); 44 46 gboolean loadFile (const gchar *filename, const gchar *password, 45 47 GError **error); 46 void getPageSizeForPage (gint pageNum, gdouble *width, 48 void getPageSizeForPage (gint pageNum, gdouble *width, 47 49 gdouble *height); 50 void outputPostscriptBegin (const gchar *fileName, guint numOfPages, 51 gfloat pageWidth, gfloat pageHeight); 52 void outputPostscriptEnd (void); 53 void outputPostscriptPage (guint pageNum); 54 48 55 DocumentPage *renderPage (gint pageNum); 49 56 gboolean saveFile (const gchar *fileName, GError **error); … … 52 59 /// The PDF document. 53 60 PopplerDocument *m_Document; 61 /// The output to PostScript. 62 PopplerPSFile *m_PostScript; 54 63 55 64 IDocumentLink *createDocumentLink (const PopplerLinkMapping *link, -
trunk/src/PrintPter.cxx
r221 r222 32 32 }; 33 33 34 PrintPter::PrintPter ( )34 PrintPter::PrintPter (IDocument *document) 35 35 { 36 36 m_View = NULL; 37 m_Document = document; 37 38 } 38 39 … … 102 103 PrintPter::printActivated () 103 104 { 105 IPrintView &view = getView (); 106 // Get the printer's name. 107 char *printerName = view.getSelectedPrinterName (); 108 if ( NULL != printerName ) 109 { 110 float pageWidth; 111 float pageHeight; 112 char *pageSizeName = view.getPageSize (); 113 getPageSizeForPrinter (printerName, pageSizeName, 114 &pageWidth, &pageHeight); 115 g_free (pageSizeName); 116 // Create the new print job. 117 JobPrint *job = new JobPrint (); 118 job->setDocument (m_Document); 119 job->setPrinterName (printerName); 120 121 if ( view.isSelectedAllPagesRangeOption () ) 122 { 123 char *pageRange = g_strdup_printf ("1-%d", 124 m_Document->getNumPages ()); 125 job->setPageRange (pageRange); 126 g_free (pageRange); 127 } 128 else 129 { 130 job->setPageRange (view.getPageRange()); 131 } 132 133 if ( view.isSelectedOddPageSet () ) 134 { 135 job->setPageSet (PRINT_ODD_PAGE_SET); 136 } 137 else if ( view.isSelectedEvenPageSet () ) 138 { 139 job->setPageSet (PRINT_EVEN_PAGE_SET); 140 } 141 else 142 { 143 job->setPageSet (PRINT_ALL_PAGE_SET); 144 } 145 job->setNumberOfCopies (view.getNumberOfCopies ()); 146 job->setCollate (view.isCheckedCollate ()); 147 job->setPageSize (pageWidth, pageHeight); 148 job->setPageOrientation (view.getPageOrientation ()); 149 job->setPageLayout (view.getPageLayout ()); 150 151 IJob::enqueue (job); 152 153 g_free (printerName); 154 } 104 155 // Once done, it's the same as canceled :-) 105 156 cancelActivated (); … … 137 188 } 138 189 190 void 191 PrintPter::getPageSizeForPrinter (const gchar *printerName, 192 const gchar *pageSizeName, 193 float *pageWidth, float *pageHeight) 194 { 195 g_assert (NULL != pageWidth && "Tried to save the page width to NULL."); 196 g_assert (NULL != pageHeight && "Tried to save the page height to NULL."); 197 198 // Set the initial value to an A4 page size (size is in 1/72 inches). 199 *pageWidth = 0.1147f; 200 *pageHeight = 0.1624f; 201 202 if ( NULL != printerName ) 203 { 204 const gchar *printerPPDName = cupsGetPPD (printerName); 205 if ( NULL != printerPPDName ) 206 { 207 ppd_file_t *printerPPD = ppdOpenFile (printerPPDName); 208 if ( NULL != printerPPD ) 209 { 210 for ( int currentSize = 0 ; 211 currentSize < printerPPD->num_sizes ; 212 ++currentSize ) 213 { 214 ppd_size_t *size = &printerPPD->sizes[currentSize]; 215 if ( 0 == g_ascii_strcasecmp (pageSizeName, size->name) ) 216 { 217 *pageWidth = size->width; 218 *pageHeight = size->length; 219 break; 220 } 221 } 222 ppdClose (printerPPD); 223 } 224 } 225 } 226 } 227 139 228 printerAttributes * 140 229 PrintPter::getPrinterAttributes (const gchar *printerName) -
trunk/src/PrintPter.h
r221 r222 25 25 { 26 26 /// 27 /// @enum PrintPageOrientation.28 ///29 enum PrintPageOrientation30 {31 PRINT_PAGE_ORIENTATION_PORTRAIT,32 PRINT_PAGE_ORIENTATION_LANDSCAPE33 };34 35 ///36 /// @enum PrintPageLayout37 ///38 enum PrintPageLayout39 {40 PRINT_PAGE_LAYOUT_PLAIN,41 PRINT_PAGE_LAYOUT_2IN1,42 PRINT_PAGE_LAYOUT_4IN143 };44 45 ///46 27 /// @class PrintPter 47 28 /// @brief Print Presenter. … … 50 31 { 51 32 public: 52 PrintPter ( void);33 PrintPter (IDocument *document); 53 34 ~PrintPter (void); 54 35 … … 63 44 64 45 protected: 46 IDocument *m_Document; 65 47 IPrintView *m_View; 66 48 49 void getPageSizeForPrinter (const gchar *printerName, 50 const gchar *sizeName, 51 float *pageWidth, float *pageHeight); 67 52 printerAttributes *getPrinterAttributes (const gchar *printerName); 68 53 void listPrinters (void); -
trunk/src/epdfview.h
r213 r222 38 38 #include <JobFind.h> 39 39 #include <JobLoad.h> 40 #include <JobPrint.h> 40 41 #include <JobRender.h> 41 42 #include <JobSave.h> -
trunk/src/gtk/PrintView.cxx
r221 r222 172 172 } 173 173 174 PrintPageLayout 175 PrintView::getPageLayout () 176 { 177 PrintPageLayout layout = PRINT_PAGE_LAYOUT_PLAIN; 178 GtkTreeIter layoutIter; 179 if ( gtk_combo_box_get_active_iter (GTK_COMBO_BOX (m_LayoutView), 180 &layoutIter) ) 181 { 182 gtk_tree_model_get (GTK_TREE_MODEL (m_Layout), &layoutIter, 183 printLayoutValueColumn, &layout, 184 -1); 185 } 186 187 return layout; 188 } 189 190 PrintPageOrientation 191 PrintView::getPageOrientation () 192 { 193 PrintPageOrientation orientation = PRINT_PAGE_ORIENTATION_PORTRAIT; 194 GtkTreeIter orientationIter; 195 if ( gtk_combo_box_get_active_iter (GTK_COMBO_BOX (m_OrientationView), 196 &orientationIter) ) 197 { 198 gtk_tree_model_get (GTK_TREE_MODEL (m_Orientation), &orientationIter, 199 printOrientationValueColumn, &orientation, 200 -1); 201 } 202 return orientation; 203 } 204 205 const gchar * 206 PrintView::getPageRange () 207 { 208 return gtk_entry_get_text (GTK_ENTRY (m_PageRange)); 209 } 210 211 gchar * 212 PrintView::getPageSize () 213 { 214 gchar *pageSize = NULL; 215 GtkTreeIter pageSizeIter; 216 if ( gtk_combo_box_get_active_iter (GTK_COMBO_BOX (m_PageSizeView), 217 &pageSizeIter) ) 218 { 219 gtk_tree_model_get (GTK_TREE_MODEL (m_PageSize), &pageSizeIter, 220 pageSizeValueColumn, &pageSize, 221 -1); 222 } 223 return pageSize; 224 } 225 174 226 gchar * 175 227 PrintView::getSelectedPrinterName () … … 192 244 193 245 gboolean 246 PrintView::isCheckedCollate () 247 { 248 return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (m_Collate)); 249 } 250 251 gboolean 194 252 PrintView::isSelectedAllPagesRangeOption () 195 253 { 196 254 return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (m_AllPagesRangeOption)); 255 } 256 257 gboolean 258 PrintView::isSelectedEvenPageSet () 259 { 260 return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (m_EvenPageSet)); 261 } 262 263 gboolean 264 PrintView::isSelectedOddPageSet () 265 { 266 return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (m_OddPageSet)); 197 267 } 198 268 … … 299 369 gtk_radio_button_new_with_mnemonic (NULL, _("A_ll pages")); 300 370 gtk_box_pack_start_defaults (GTK_BOX (pageSetBox), allPageSetRadio); 301 GtkWidget *oddPageSetRadio=371 m_OddPageSet = 302 372 gtk_radio_button_new_with_mnemonic_from_widget ( 303 373 GTK_RADIO_BUTTON (allPageSetRadio), _("O_dd pages")); 304 gtk_box_pack_start_defaults (GTK_BOX (pageSetBox), oddPageSetRadio);305 GtkWidget *evenPageSetRadio=374 gtk_box_pack_start_defaults (GTK_BOX (pageSetBox), m_OddPageSet); 375 m_EvenPageSet = 306 376 gtk_radio_button_new_with_mnemonic_from_widget ( 307 377 GTK_RADIO_BUTTON (allPageSetRadio), _("_Even pages")); 308 gtk_box_pack_start_defaults (GTK_BOX (pageSetBox), evenPageSetRadio);378 gtk_box_pack_start_defaults (GTK_BOX (pageSetBox), m_EvenPageSet); 309 379 310 380 // Copies frame -
