~ubuntu-branches/ubuntu/saucy/libwpd/saucy-proposed

« back to all changes in this revision

Viewing changes to src/lib/WP42StylesListener.cpp

  • Committer: Package Import Robot
  • Author(s): Rene Engelhard
  • Date: 2011-11-29 23:31:13 UTC
  • mfrom: (1.2.5)
  • Revision ID: package-import@ubuntu.com-20111129233113-xdtwca9h0y6wdxst
Tags: 0.9.4-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
1
2
/* libwpd
2
3
 * Copyright (C) 2003 William Lachance (wrlach@gmail.com)
3
4
 * Copyright (C) 2004 Marc Maurer (uwog@uwog.net)
4
5
 * Copyright (C) 2006 Fridrich Strba (fridrich.strba@bluewin.ch)
5
 
 *  
 
6
 *
6
7
 * This library is free software; you can redistribute it and/or
7
8
 * modify it under the terms of the GNU Library General Public
8
9
 * License as published by the Free Software Foundation; either
20
21
 * For further information visit http://libwpd.sourceforge.net
21
22
 */
22
23
 
23
 
/* "This product is not manufactured, approved, or supported by 
 
24
/* "This product is not manufactured, approved, or supported by
24
25
 * Corel Corporation or Corel Corporation Limited."
25
26
 */
26
 
 
 
27
 
27
28
#include "WP42StylesListener.h"
28
29
#include "WPXTable.h"
29
30
#include "WP42FileStructure.h"
30
31
#include "WPXFileStructure.h"
31
32
#include "libwpd_internal.h"
32
33
 
33
 
WP42StylesListener::WP42StylesListener(std::list<WPXPageSpan> &pageList, std::vector<WP42SubDocument *> &subDocuments) : 
 
34
WP42StylesListener::WP42StylesListener(std::list<WPXPageSpan> &pageList, std::vector<WP42SubDocument *> &subDocuments) :
34
35
        WP42Listener(),
35
36
        WPXStylesListener(pageList),
36
37
        m_currentPage(),
45
46
}
46
47
 
47
48
void WP42StylesListener::endDocument()
48
 
{       
 
49
{
49
50
        insertBreak(WPX_SOFT_PAGE_BREAK); // pretend we just had a soft page break (for the last page)
50
51
}
51
52
 
52
53
void WP42StylesListener::endSubDocument()
53
 
{       
 
54
{
54
55
        insertBreak(WPX_SOFT_PAGE_BREAK); // pretend we just had a soft page break (for the last page)
55
56
}
56
57
 
60
61
                return;
61
62
 
62
63
        if (!isUndoOn())
63
 
        {       
 
64
        {
64
65
                WPXTableList tableList;
65
 
                switch (breakType) 
 
66
                switch (breakType)
66
67
                {
67
68
                case WPX_PAGE_BREAK:
68
69
                case WPX_SOFT_PAGE_BREAK:
69
70
                        if ((m_pageList.size() > 0) && (m_currentPage==m_pageList.back())
70
 
                                && (m_pageListHardPageMark != m_pageList.end()))
 
71
                                && (m_pageListHardPageMark != m_pageList.end()))
71
72
                        {
72
73
                                m_pageList.back().setPageSpan(m_pageList.back().getPageSpan() + 1);
73
74
                        }
83
84
                        m_currentPage.setPageSpan(1);
84
85
 
85
86
                        for(std::vector<WPXHeaderFooter>::const_iterator HFiter = (m_nextPage.getHeaderFooterList()).begin();
86
 
                                HFiter != (m_nextPage.getHeaderFooterList()).end(); HFiter++)
 
87
                                HFiter != (m_nextPage.getHeaderFooterList()).end(); HFiter++)
87
88
                        {
88
89
                                if ((*HFiter).getOccurence() != NEVER)
89
90
                                {
90
91
                                        m_currentPage.setHeaderFooter((*HFiter).getType(), (*HFiter).getInternalType(),
91
 
                                                (*HFiter).getOccurence(), (*HFiter).getSubDocument(), (*HFiter).getTableList());
 
92
                                                                      (*HFiter).getOccurence(), (*HFiter).getSubDocument(), (*HFiter).getTableList());
92
93
                                        _handleSubDocument((*HFiter).getSubDocument(), WPX_SUBDOCUMENT_HEADER_FOOTER, (*HFiter).getTableList());
93
94
                                }
94
95
                                else
95
96
                                {
96
97
                                        m_currentPage.setHeaderFooter((*HFiter).getType(), (*HFiter).getInternalType(),
97
 
                                                (*HFiter).getOccurence(), 0, (*HFiter).getTableList());
98
 
                                }       
 
98
                                                                      (*HFiter).getOccurence(), 0, (*HFiter).getTableList());
 
99
                                }
99
100
                        }
100
101
                        m_nextPage = WPXPageSpan();
101
102
                        m_currentPageHasContent = false;
125
126
 
126
127
                uint8_t occurenceBits = ((headerFooterDefinition & 0xFC) >> 2);
127
128
 
128
 
                WPD_DEBUG_MSG(("WordPerfect: headerFooterGroup (headerFooterType: %i, occurenceBits: %i)\n", 
129
 
                               headerFooterType, occurenceBits));
 
129
                WPD_DEBUG_MSG(("WordPerfect: headerFooterGroup (headerFooterType: %i, occurenceBits: %i)\n",
 
130
                               headerFooterType, occurenceBits));
130
131
 
131
132
                WPXHeaderFooterOccurence wpxOccurence;
132
133
 
155
156
                }
156
157
                m_currentPageHasContent = tempCurrentPageHasContent;
157
158
        }
158
 
}       
 
159
}
159
160
 
160
161
void WP42StylesListener::suppressPageCharacteristics(uint8_t suppressCode)
161
162
{
184
185
        }
185
186
}
186
187
 
187
 
void WP42StylesListener::_handleSubDocument(const WPXSubDocument *subDocument, WPXSubDocumentType subDocumentType, 
188
 
                                                WPXTableList /* tableList */, int /* nextTableIndice */)
 
188
void WP42StylesListener::_handleSubDocument(const WPXSubDocument *subDocument, WPXSubDocumentType subDocumentType,
 
189
        WPXTableList /* tableList */, int /* nextTableIndice */)
189
190
{
190
 
        if (!isUndoOn()) 
 
191
        if (!isUndoOn())
191
192
        {
192
193
                bool oldIsSubDocument = m_isSubDocument;
193
194
                m_isSubDocument = true;
194
 
                if (subDocumentType == WPX_SUBDOCUMENT_HEADER_FOOTER) 
 
195
                if (subDocumentType == WPX_SUBDOCUMENT_HEADER_FOOTER)
195
196
                {
196
197
                        bool oldCurrentPageHasContent = m_currentPageHasContent;
197
198
 
208
209
                m_isSubDocument = oldIsSubDocument;
209
210
        }
210
211
}
 
212
/* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */