pdf_search_task.cpp

Go to the documentation of this file.
00001 /*
00002  * File Name: pdf_search_task.cpp
00003  */
00004 
00005 /*
00006  * This file is part of uds-plugin-pdf.
00007  *
00008  * uds-plugin-pdf is free software: you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation, either version 2 of the License, or
00011  * (at your option) any later version.
00012  *
00013  * uds-plugin-pdf is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program. If not, see <http://www.gnu.org/licenses/>.
00020  */
00021 
00022 /**
00023  * Copyright (C) 2008 iRex Technologies B.V.
00024  * All rights reserved.
00025  */
00026 
00027 #include "log.h"
00028 
00029 #include "pdf_search_task.h"
00030 
00031 namespace pdf
00032 {
00033 
00034 PDFSearchTask::PDFSearchTask(const PDFSearchCriteria &c
00035                              , const string &anchor
00036                              , PDFSearchType t
00037                              , PDFSearcher *s
00038                              , unsigned int id)
00039 : search_type(t)
00040 , searcher(s)
00041 , criteria(c)
00042 , from_anchor(anchor)
00043 , search_id(id)
00044 {
00045     type = TASK_SEARCH;
00046 }
00047 
00048 PDFSearchTask::~PDFSearchTask()
00049 {
00050 }
00051 
00052 void PDFSearchTask::execute()
00053 {
00054     LOGPRINTF("Execute Search Task\n");
00055     reset();
00056     SearchResult res = RES_NOT_FOUND;
00057 
00058     // construct a container to keep all of the search results
00059     PDFSearchDocument results;
00060     
00061     if (search_type == PDF_SEARCH_ALL)
00062     {
00063         if (searcher->begin_search_all(criteria))
00064         {
00065             res = searcher->seach_all(results, this);
00066         }
00067     }
00068     else if (search_type == PDF_SEARCH_NEXT)
00069     {
00070         if (searcher->begin_search_next(criteria, from_anchor))
00071         {
00072             res = searcher->search_next(results, this);
00073         }
00074     }
00075 
00076     if (res == RES_PAUSED)
00077     {
00078         // the search task might restart later, so update the from anchor
00079         searcher->dump_search_process(from_anchor);
00080     }
00081     else if (res != RES_ABORTED)
00082     {
00083         // broadcast
00084         searcher->notify(res, results, search_id);
00085     }
00086 }
00087 
00088 void* PDFSearchTask::get_user_data()
00089 {
00090     return searcher->get_doc_ctrl();
00091 }
00092 
00093 unsigned int PDFSearchTask::get_id()
00094 {
00095     return search_id;
00096 }
00097 
00098 }// namespace pdf
00099 
Generated by  doxygen 1.6.2-20100208