Switch to unified view

a/src/qtgui/plaintorich.cpp b/src/qtgui/plaintorich.cpp
1
#ifndef lint
1
#ifndef lint
2
static char rcsid[] = "@(#$Id: plaintorich.cpp,v 1.6 2005-11-24 07:16:16 dockes Exp $ (C) 2005 J.F.Dockes";
2
static char rcsid[] = "@(#$Id: plaintorich.cpp,v 1.7 2006-01-19 12:01:42 dockes Exp $ (C) 2005 J.F.Dockes";
3
#endif
3
#endif
4
4
5
5
6
#include <string>
6
#include <string>
7
#include <utility>
7
#include <utility>
...
...
47
         
47
         
48
    return true;
48
    return true;
49
    }
49
    }
50
};
50
};
51
51
52
// Just strip/escape things that would look like markup
53
string stripMarkup(const string &in)
54
{
55
    string out;
56
    for (string::size_type pos = 0; pos < in.length(); pos++) {
57
  switch(in.at(pos)) {
58
  case '<':
59
      out += "&lt;";
60
      break;
61
  case '&':
62
      out += "&amp;";
63
      break;
64
  default:
65
      out += in.at(pos);
66
  }
67
    }
68
    return out;
69
}
70
71
// Fix result text for display inside the gui text window.
52
// Fix result text for display inside the gui text window.
72
//
53
//
73
// To compute the term character positions in the output text, we have
54
// To compute the term character positions in the output text, we have
74
// to emulate how qt's textedit counts chars (ignoring tags and
55
// to emulate how qt's textedit counts chars (ignoring tags and
75
// duplicate whitespace etc...). This is tricky business and it might
56
// duplicate whitespace etc...). This is tricky business and it might
...
...
81
    LOGDEB(("plaintorich: terms: %s\n", 
62
    LOGDEB(("plaintorich: terms: %s\n", 
82
        stringlistdisp(terms).c_str()));
63
        stringlistdisp(terms).c_str()));
83
64
84
    termoffsets.erase(termoffsets.begin(), termoffsets.end());
65
    termoffsets.erase(termoffsets.begin(), termoffsets.end());
85
66
67
    // We first use the text splitter to break the text into words,
68
    // and compare the words to the search terms, which yields the
69
    // query terms positions inside the text
86
    myTextSplitCB cb(terms);
70
    myTextSplitCB cb(terms);
87
    TextSplit splitter(&cb, true);
71
    TextSplit splitter(&cb, true);
88
    // Note that splitter returns the term locations in byte, not
72
    // Note that splitter returns the term locations in byte, not
89
    // character offset
73
    // character offset
90
    splitter.text_to_words(in);
74
    splitter.text_to_words(in);