Show
Ignore:
Timestamp:
04/11/08 10:08:07 (8 months ago)
Author:
jordi
Message:

Based on patches sent by Rafał Mużyło and zhou sf, I've added code to be able to build ePDFView with poppler 0.8.0 due a change in the API: poppler_page_get_selection_region() returns the a Glist wherein 0.6.* it returns a GdkRegion?.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/PDFDocument.cxx

    r286 r307  
    192192///                 path. 
    193193/// @param password The password to use to open @a filename. 
    194 /// @param error Location to store the error occurring or NULL to ignore  
     194/// @param error Location to store the error occurring or NULL to ignore 
    195195///              errors. 
    196196/// 
     
    258258        { 
    259259            // OK, the glib's wrapper don't pass the error code directly 
    260             // from Poppler. Instead returns G_FILE_ERROR_FAILED and a  
     260            // from Poppler. Instead returns G_FILE_ERROR_FAILED and a 
    261261            // non translated string. 
    262262            // Maybe I'm wrong (very probable) but that's a wrong way. 
     
    413413    // We'll already calculate the positions scaled. 
    414414    gdouble scale = getZoom (); 
    415     GList *pageLinks = poppler_page_get_link_mapping (popplerPage);  
     415    GList *pageLinks = poppler_page_get_link_mapping (popplerPage); 
    416416    for (GList *pageLink = g_list_first (pageLinks) ; 
    417417         NULL != pageLink ; 
     
    441441/// 
    442442void 
    443 PDFDocument::setOutline (DocumentOutline *outline,  
     443PDFDocument::setOutline (DocumentOutline *outline, 
    444444                         PopplerIndexIter *childrenList) 
    445445{ 
     
    475475 
    476476                    outline->addChild (child); 
    477                 PopplerIndexIter *childIter =  
     477                PopplerIndexIter *childIter = 
    478478                    poppler_index_iter_get_child (childrenList); 
    479479                setOutline (child, childIter); 
    480480            } 
    481         }  
     481        } 
    482482        while ( poppler_index_iter_next (childrenList) ); 
    483483 
     
    491491/// Retrieves the width and height of a document's page before to scale, but 
    492492/// after rotation. 
    493 ///  
     493/// 
    494494/// @param pageNum The page to get its size. 
    495495/// @param width The output pointer to save the page's width. 
     
    667667} 
    668668 
    669 void  
     669void 
    670670PDFDocument::setTextSelection (DocumentRectangle *rect) 
    671671{ 
     
    678678    gdouble pageWidth, pageHeight; 
    679679    poppler_page_get_size(page, &pageWidth, &pageHeight); 
    680      
     680 
    681681    //for get text we must exchange y coordinate, don't ask me where logic here. 
    682682    PopplerRectangle textRect = { rect->getX1() / getZoom(), 
     
    694694    if(!text) 
    695695        goto cleanup; 
    696          
     696 
    697697    for ( GList *obs = g_list_first (m_Observers) ; 
    698698          NULL != obs ; 
     
    723723    rect.y1 = r->getY1() / getZoom(); 
    724724    rect.x2 = r->getX2() / getZoom(); 
    725     rect.y2 = r->getY2() / getZoom();    
     725    rect.y2 = r->getY2() / getZoom(); 
    726726    repairEmpty(rect); 
    727727 
    728728    //calc selection size 
    729 #if defined (HAVE_POPPLER_0_6_0) 
     729#if defined (HAVE_POPPLER_0_8_0) 
     730    GList *selections = poppler_page_get_selection_region(page, getZoom(), 
     731             POPPLER_SELECTION_GLYPH, &rect); 
     732    res = gdk_region_new(); 
     733    for (GList *selection = g_list_first (selections) ; 
     734         NULL != selection ; selection = g_list_next (selection)) { 
     735        PopplerRectangle *rectangle = (PopplerRectangle *)selection->data; 
     736        GdkRectangle rect; 
     737 
     738        rect.x = (gint)rectangle->x1; 
     739        rect.y = (gint)rectangle->y1; 
     740        rect.width  = (gint) (rectangle->x2 - rectangle->x1); 
     741        rect.height = (gint) (rectangle->y2 - rectangle->y1); 
     742 
     743        gdk_region_union_with_rect (res, &rect); 
     744    } 
     745    poppler_page_selection_region_free (selections); 
     746#elif defined (HAVE_POPPLER_0_6_0) 
    730747    res = poppler_page_get_selection_region(page, getZoom(), 
    731748            POPPLER_SELECTION_GLYPH, &rect); 
     
    733750    res = poppler_page_get_selection_region(page, getZoom(), &rect); 
    734751#endif // HAVE_POPPLER_0_6_0 
    735                               
     752 
    736753    //free some local data 
    737754    g_object_unref(page);