Changeset 196
- Timestamp:
- 05/28/06 11:53:35 (2 years ago)
- Location:
- trunk/src
- Files:
-
- 4 added
- 7 modified
- 2 moved
-
DocumentLinkGoto.cxx (added)
-
DocumentLinkGoto.h (added)
-
DocumentLinkUri.cxx (added)
-
DocumentLinkUri.h (added)
-
DocumentPage.cxx (modified) (5 diffs)
-
DocumentPage.h (modified) (1 diff)
-
IDocument.cxx (modified) (1 diff)
-
IDocumentLink.cxx (moved) (moved from trunk/src/DocumentLink.cxx) (3 diffs)
-
IDocumentLink.h (moved) (moved from trunk/src/DocumentLink.h) (2 diffs)
-
Makefile.am (modified) (3 diffs)
-
PDFDocument.cxx (modified) (3 diffs)
-
PDFDocument.h (modified) (2 diffs)
-
epdfview.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/DocumentPage.cxx
r172 r196 46 46 linkItem = g_list_next (linkItem) ) 47 47 { 48 DocumentLink *link = (DocumentLink *)linkItem->data;48 IDocumentLink *link = (IDocumentLink *)linkItem->data; 49 49 delete link; 50 50 } … … 61 61 /// 62 62 void 63 DocumentPage::addLink ( DocumentLink *link)63 DocumentPage::addLink (IDocumentLink *link) 64 64 { 65 65 m_LinkList = g_list_prepend (m_LinkList, link); … … 111 111 /// @return The link under the position (x, y) or NULL if no link exists. 112 112 /// 113 DocumentLink *113 IDocumentLink * 114 114 DocumentPage::getLinkAtPosition (gint x, gint y) 115 115 { 116 DocumentLink *link = NULL;116 IDocumentLink *link = NULL; 117 117 118 118 for ( GList *linkItem = g_list_first (m_LinkList) ; … … 120 120 linkItem = g_list_next (linkItem) ) 121 121 { 122 DocumentLink *tmpLink = (DocumentLink *)linkItem->data;122 IDocumentLink *tmpLink = (IDocumentLink *)linkItem->data; 123 123 if ( tmpLink->positionIsOver (x, y) ) 124 124 { … … 126 126 } 127 127 } 128 128 129 129 return link; 130 130 } -
trunk/src/DocumentPage.h
r163 r196 32 32 DocumentPage (void); 33 33 ~DocumentPage (void); 34 35 void addLink ( DocumentLink *link);34 35 void addLink (IDocumentLink *link); 36 36 void clearSelection (void); 37 37 guchar *getData (void); 38 38 gint getHeight (void); 39 DocumentLink *getLinkAtPosition (gint x, gint y);39 IDocumentLink *getLinkAtPosition (gint x, gint y); 40 40 gint getRowStride (void); 41 41 gint getWidth (void); -
trunk/src/IDocument.cxx
r172 r196 1476 1476 if ( NULL != page && 0 == getRotation () ) 1477 1477 { 1478 DocumentLink *link = page->getLinkAtPosition (x, y);1478 IDocumentLink *link = page->getLinkAtPosition (x, y); 1479 1479 if ( NULL != link ) 1480 1480 { 1481 goToPage (link->getDestinationPage ());1481 link->activate (this); 1482 1482 } 1483 } 1484 } 1483 } 1484 } -
trunk/src/IDocumentLink.cxx
r155 r196 22 22 23 23 /// 24 /// @brief Construct a new DocumentLink object.24 /// @brief Construct a new IDocumentLink object. 25 25 /// 26 26 /// @param x1 The X coordinate of the link's top-left corner. … … 28 28 /// @param x2 The X coordinate of the link's bottom-right corner. 29 29 /// @param y2 The Y coordinate of the link's bottom-right corner. 30 /// @param destinationPage The page number the links points to.31 30 /// 32 DocumentLink::DocumentLink (gdouble x1, gdouble y1, gdouble x2, gdouble y2, 33 gint destinationPage) 31 IDocumentLink::IDocumentLink (gdouble x1, gdouble y1, gdouble x2, gdouble y2) 34 32 { 35 m_DestinationPage = destinationPage;36 33 m_Rect = new DocumentRectangle (x1, y1, x2, y2); 37 34 } 38 35 39 36 /// 40 /// @brief Destroys all dynamically allocated memory by DocumentLink.37 /// @brief Destroys all dynamically allocated memory by IDocumentLink. 41 38 /// 42 DocumentLink::~DocumentLink ()39 IDocumentLink::~IDocumentLink () 43 40 { 44 41 delete m_Rect; 45 42 } 46 43 47 ///48 /// @brief Gets the destination page number.49 ///50 /// @return The page number the link's points at.51 ///52 gint53 DocumentLink::getDestinationPage ()54 {55 return m_DestinationPage;56 }57 58 ///59 44 /// @brief Checks if a position is over the link. 60 45 /// … … 68 53 /// 69 54 gboolean 70 DocumentLink::positionIsOver (gint x, gint y)55 IDocumentLink::positionIsOver (gint x, gint y) 71 56 { 72 57 return ( (gint)m_Rect->getX1 () <= x && (gint)m_Rect->getY1 () <= y && -
trunk/src/IDocumentLink.h
r155 r196 16 16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 17 18 #if !defined (__ DOCUMENT_LINK_H__)19 #define __ DOCUMENT_LINK_H__18 #if !defined (__IDOCUMENT_LINK_H__) 19 #define __IDOCUMENT_LINK_H__ 20 20 21 21 namespace ePDFView 22 22 { 23 // Forward declarations. 24 class IDocument; 25 23 26 /// 24 /// @class DocumentLink27 /// @class IDocumentLink 25 28 /// @brief A single link on a page. 26 29 /// 27 30 /// This class is used by ePDFView::DocumentPage to maintain a list 28 /// of all links that a single page have. A link, in this version of 29 /// ePDFView, is just a rectangle on a page that points to another page. 31 /// of all links that a single page have. 30 32 /// 31 class DocumentLink33 class IDocumentLink 32 34 { 33 35 public: 34 DocumentLink (gdouble x1, gdouble y1, gdouble x2, gdouble y1, 35 gint destinationPage); 36 ~DocumentLink (void); 36 IDocumentLink (gdouble x1, gdouble y1, gdouble x2, gdouble y1); 37 virtual ~IDocumentLink (void); 37 38 38 gint getDestinationPage (void);39 virtual void activate (IDocument *document) = 0; 39 40 gboolean positionIsOver (gint x, gint y); 40 41 41 42 protected: 42 /// The number of the link's destination page.43 gint m_DestinationPage;44 43 /// The link rectangle. 45 44 DocumentRectangle *m_Rect; … … 47 46 } 48 47 49 #endif // !__ DOCUMENT_LINK_H__48 #endif // !__IDOCUMENT_LINK_H__ -
trunk/src/Makefile.am
r182 r196 5 5 6 6 libepdfview_a_SOURCES = \ 7 Config.cxx \ 8 Config.h \ 9 DocumentLink.cxx \ 10 DocumentLink.h \ 7 Config.cxx \ 8 Config.h \ 9 DocumentLinkGoto.cxx \ 10 DocumentLinkGoto.h \ 11 DocumentLinkUri.cxx \ 12 DocumentLinkUri.h \ 11 13 DocumentOutline.cxx \ 12 14 DocumentOutline.h \ … … 15 17 DocumentRectangle.cxx \ 16 18 DocumentRectangle.h \ 17 epdfview.h \19 epdfview.h \ 18 20 FindPter.cxx \ 19 21 FindPter.h \ 20 gettext.h \ 21 IDocument.cxx \ 22 IDocument.h \ 22 gettext.h \ 23 IDocument.cxx \ 24 IDocument.h \ 25 IDocumentLink.cxx \ 26 IDocumentLink.h \ 23 27 IDocumentObserver.h \ 24 28 IFindView.h \ … … 29 33 JobFind.cxx \ 30 34 JobFind.h \ 31 JobLoad.cxx \32 JobLoad.h \35 JobLoad.cxx \ 36 JobLoad.h \ 33 37 JobRender.cxx \ 34 38 JobRender.h \ 35 MainPter.cxx \36 MainPter.h \39 MainPter.cxx \ 40 MainPter.h \ 37 41 PagePter.cxx \ 38 42 PagePter.h \ 39 PDFDocument.cxx \43 PDFDocument.cxx \ 40 44 PDFDocument.h 41 45 42 46 libepdfview_a_CXXFLAGS = \ 43 $(GLIB_CFLAGS) \47 $(GLIB_CFLAGS) \ 44 48 $(POPPLER_CFLAGS) 45 49 -
trunk/src/PDFDocument.cxx
r183 r196 54 54 } 55 55 56 /// 57 /// @brief Creates a new document link. 58 /// 59 /// Based on the passed @a link, this function creates a new document 60 /// links of the best type for the link's action. 61 /// 62 /// @param link The link to create the document link from. 63 /// @param pageHeight The unscaled size of the page's height. 64 /// @param scale The scale to calculate the link's coordinates. 65 /// 66 /// @return The link best suited for @a link or NULL if no link can be 67 /// created. 68 IDocumentLink * 69 PDFDocument::createDocumentLink (const PopplerLinkMapping *link, 70 const gdouble pageHeight, 71 const gdouble scale) 72 { 73 PopplerAction *action = link->action; 74 IDocumentLink *documentLink = NULL; 75 76 // Calculate the four link's corners. 77 gdouble topLeft = link->area.x1 * scale; 78 gdouble topRight = link->area.x2 * scale; 79 gdouble bottomLeft = (pageHeight - link->area.y2) * scale; 80 gdouble bottomRight = (pageHeight - link->area.y1) * scale; 81 82 switch (action->type) 83 { 84 // Internal cross-reference link. 85 case POPPLER_ACTION_GOTO_DEST: 86 { 87 PopplerActionGotoDest *actionGoTo = (PopplerActionGotoDest *)action; 88 documentLink = new DocumentLinkGoto ( 89 topLeft, bottomLeft, topRight, bottomRight, 90 actionGoTo->dest->page_num); 91 break; 92 } 93 // Internet address. 94 case POPPLER_ACTION_URI: 95 { 96 PopplerActionUri *actionUri = (PopplerActionUri *)action; 97 documentLink = new DocumentLinkUri ( 98 topLeft, bottomLeft, topRight, bottomRight, 99 actionUri->uri); 100 break; 101 } 102 103 default: 104 g_warning ("Poppler's link type %d not handled.", action->type); 105 break; 106 } 107 108 return documentLink; 109 } 110 56 111 GList * 57 112 PDFDocument::findTextInPage (gint pageNum, const gchar *textToFind) 58 113 { 59 114 GList *results = NULL; 60 115 61 116 if ( NULL == m_Document ) 62 { 117 { 63 118 return results; 64 119 } … … 161 216 return FALSE; 162 217 } 163 218 164 219 // Set the used filename and password to let the user reload the 165 220 // document. 166 setFileName (filename); 221 setFileName (filename); 167 222 setPassword (password); 168 223 if ( NULL != m_Document ) … … 289 344 { 290 345 PopplerLinkMapping *link = (PopplerLinkMapping *)pageLink->data; 291 PopplerAction *action = link->action; 292 // Only internal links. 293 if ( POPPLER_ACTION_GOTO_DEST == action->type ) 294 { 295 PopplerActionGotoDest *actionGoTo = (PopplerActionGotoDest *)action; 296 DocumentLink *documentLink = 297 new DocumentLink (link->area.x1 * scale, 298 (pageHeight - link->area.y2) * scale, 299 link->area.x2 * scale, 300 (pageHeight - link->area.y1) * scale, 301 actionGoTo->dest->page_num); 346 IDocumentLink *documentLink = createDocumentLink (link, pageHeight, scale); 347 if ( NULL != documentLink ) 348 { 302 349 renderedPage->addLink (documentLink); 303 350 } -
trunk/src/PDFDocument.h
r154 r196 21 21 22 22 /// Forward declarations. 23 typedef struct _PopplerDocument PopplerDocument; 23 24 typedef struct _PopplerIndexIter PopplerIndexIter; 24 typedef struct _Poppler Document PopplerDocument;25 typedef struct _PopplerLinkMapping PopplerLinkMapping; 25 26 typedef struct _PopplerPage PopplerPage; 26 27 … … 51 52 PopplerDocument *m_Document; 52 53 54 IDocumentLink *createDocumentLink (const PopplerLinkMapping *link, 55 const gdouble pageHeight, 56 const gdouble scale); 53 57 void loadMetadata (void); 54 void setOutline (DocumentOutline *outline, 58 void setOutline (DocumentOutline *outline, 55 59 PopplerIndexIter *childrenList); 56 60 void setLinks (DocumentPage *renderedPage, -
trunk/src/epdfview.h
r174 r196 26 26 27 27 #include <DocumentRectangle.h> 28 #include <DocumentLink.h> 28 #include <IDocumentLink.h> 29 #include <DocumentLinkGoto.h> 30 #include <DocumentLinkUri.h> 29 31 #include <DocumentOutline.h> 30 32 #include <DocumentPage.h>
