~ubuntu-branches/ubuntu/edgy/libwpd/edgy-security

« back to all changes in this revision

Viewing changes to src/lib/WP6Parser.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Rene Engelhard
  • Date: 2006-06-11 23:56:17 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20060611235617-ce504k38fuqe8twa
Tags: 0.8.5-2
* dpatch'ize 
* add patch from upstream fixing WP5 font handling regression

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* libwpd
2
2
 * Copyright (C) 2002 William Lachance (william.lachance@sympatico.ca)
3
 
 * Copyright (C) 2002 Marc Maurer (j.m.maurer@student.utwente.nl)
 
3
 * Copyright (C) 2002 Marc Maurer (uwog@uwog.net)
4
4
 *  
5
5
 * This library is free software; you can redistribute it and/or
6
6
 * modify it under the terms of the GNU Library General Public
175
175
void WP6Parser::parse(WPXHLListenerImpl *listenerImpl)
176
176
{       
177
177
        WP6PrefixData * prefixData = NULL;
178
 
        std::vector<WPXPageSpan *> pageList;
 
178
        std::list<WPXPageSpan> pageList;
179
179
        WPXTableList tableList; 
180
180
 
181
181
        WPXInputStream *input = getInput();
186
186
                
187
187
                // do a "first-pass" parse of the document
188
188
                // gather table border information, page properties (per-page)
189
 
                WP6StylesListener stylesListener(&pageList, tableList);
 
189
                WP6StylesListener stylesListener(pageList, tableList);
190
190
                stylesListener.setPrefixData(prefixData);
191
191
                parse(input, &stylesListener);
 
192
                
 
193
                // postprocess the pageList == remove duplicate page spans due to the page breaks
 
194
                std::list<WPXPageSpan>::iterator previousPage = pageList.begin();
 
195
                for (std::list<WPXPageSpan>::iterator Iter=pageList.begin(); Iter != pageList.end(); /* Iter++ */)
 
196
                {
 
197
                        if ((Iter != previousPage) && ((*previousPage)==(*Iter)))
 
198
                        {
 
199
                                (*previousPage).setPageSpan((*previousPage).getPageSpan() + (*Iter).getPageSpan());
 
200
                                Iter = pageList.erase(Iter);
 
201
                        }
 
202
                        else
 
203
                        {
 
204
                                previousPage = Iter;
 
205
                                Iter++;
 
206
                        }
 
207
                }
192
208
 
193
209
                // second pass: here is where we actually send the messages to the target app
194
210
                // that are necessary to emit the body of the target document
195
 
                WP6ContentListener listener(&pageList, tableList, listenerImpl);
 
211
                WP6ContentListener listener(pageList, tableList, listenerImpl);
196
212
                listener.setPrefixData(prefixData);
197
213
 
198
214
                // get the relevant initial prefix packets out of storage and tell them to parse
205
221
 
206
222
                // cleanup section: free the used resources
207
223
                delete prefixData;
208
 
                for (std::vector<WPXPageSpan *>::iterator iterSpan = pageList.begin(); iterSpan != pageList.end(); iterSpan++)
209
 
                {
210
 
                        delete *iterSpan;
211
 
                }
212
224
        }
213
225
        catch(FileException)
214
226
        {
216
228
 
217
229
                delete prefixData;
218
230
                
219
 
                for (std::vector<WPXPageSpan *>::iterator iterSpan = pageList.begin(); iterSpan != pageList.end(); iterSpan++)
220
 
                {
221
 
                        delete *iterSpan;
222
 
                }
223
 
 
224
231
                throw FileException();
225
232
        }
226
233
}