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

« back to all changes in this revision

Viewing changes to src/lib/WP1StylesListener.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 "WP1StylesListener.h"
28
29
#include "WP1FileStructure.h"
29
30
#include "WPXFileStructure.h"
30
31
#include "libwpd_internal.h"
31
32
 
32
 
WP1StylesListener::WP1StylesListener(std::list<WPXPageSpan> &pageList, std::vector<WP1SubDocument *> &subDocuments) : 
 
33
WP1StylesListener::WP1StylesListener(std::list<WPXPageSpan> &pageList, std::vector<WP1SubDocument *> &subDocuments) :
33
34
        WP1Listener(),
34
35
        WPXStylesListener(pageList),
35
36
        m_currentPage(),
44
45
}
45
46
 
46
47
void WP1StylesListener::endDocument()
47
 
{       
 
48
{
48
49
        insertBreak(WPX_SOFT_PAGE_BREAK); // pretend we just had a soft page break (for the last page)
49
50
}
50
51
 
51
52
void WP1StylesListener::endSubDocument()
52
 
{       
 
53
{
53
54
        insertBreak(WPX_SOFT_PAGE_BREAK); // pretend we just had a soft page break (for the last page)
54
55
}
55
56
 
59
60
                return;
60
61
 
61
62
        if (!isUndoOn())
62
 
        {       
 
63
        {
63
64
                WPXTableList tableList;
64
 
                switch (breakType) 
 
65
                switch (breakType)
65
66
                {
66
67
                case WPX_PAGE_BREAK:
67
68
                case WPX_SOFT_PAGE_BREAK:
68
69
                        if ((m_pageList.size() > 0) && (m_currentPage==m_pageList.back())
69
 
                                && (m_pageListHardPageMark != m_pageList.end()))
 
70
                                && (m_pageListHardPageMark != m_pageList.end()))
70
71
                        {
71
72
                                m_pageList.back().setPageSpan(m_pageList.back().getPageSpan() + 1);
72
73
                        }
82
83
                        m_currentPage.setPageSpan(1);
83
84
 
84
85
                        for(std::vector<WPXHeaderFooter>::const_iterator HFiter = (m_nextPage.getHeaderFooterList()).begin();
85
 
                                HFiter != (m_nextPage.getHeaderFooterList()).end(); HFiter++)
 
86
                                HFiter != (m_nextPage.getHeaderFooterList()).end(); HFiter++)
86
87
                        {
87
88
                                if ((*HFiter).getOccurence() != NEVER)
88
89
                                {
89
90
                                        m_currentPage.setHeaderFooter((*HFiter).getType(), (*HFiter).getInternalType(),
90
 
                                                (*HFiter).getOccurence(), (*HFiter).getSubDocument(), (*HFiter).getTableList());
 
91
                                                                      (*HFiter).getOccurence(), (*HFiter).getSubDocument(), (*HFiter).getTableList());
91
92
                                        _handleSubDocument((*HFiter).getSubDocument(), WPX_SUBDOCUMENT_HEADER_FOOTER, (*HFiter).getTableList());
92
93
                                }
93
94
                                else
94
95
                                {
95
96
                                        m_currentPage.setHeaderFooter((*HFiter).getType(), (*HFiter).getInternalType(),
96
 
                                                (*HFiter).getOccurence(), 0, (*HFiter).getTableList());
97
 
                                }       
 
97
                                                                      (*HFiter).getOccurence(), 0, (*HFiter).getTableList());
 
98
                                }
98
99
                        }
99
100
                        m_nextPage = WPXPageSpan();
100
101
                        m_currentPageHasContent = false;
111
112
 
112
113
void WP1StylesListener::marginReset(uint16_t leftMargin, uint16_t rightMargin)
113
114
{
114
 
        if (!isUndoOn()) 
115
 
        {               
 
115
        if (!isUndoOn())
 
116
        {
116
117
                if (m_isSubDocument)
117
118
                        return; // do not collect L/R margin information in sub documents
118
119
 
159
160
 
160
161
void WP1StylesListener::topMarginSet(uint16_t topMargin)
161
162
{
162
 
        if (!isUndoOn()) 
 
163
        if (!isUndoOn())
163
164
        {
164
165
                if (!topMargin) return;
165
166
                double marginInch = (double)((double)topMargin / 72.0);
169
170
 
170
171
void WP1StylesListener::bottomMarginSet(uint16_t bottomMargin)
171
172
{
172
 
        if (!isUndoOn()) 
 
173
        if (!isUndoOn())
173
174
        {
174
175
                if (!bottomMargin) return;
175
176
                double marginInch = (double)((double)bottomMargin / 72.0);
191
192
 
192
193
                uint8_t occurenceBits = (uint8_t)((headerFooterDefinition & 0x1C) >> 2);
193
194
 
194
 
                WPD_DEBUG_MSG(("WordPerfect: headerFooterGroup (headerFooterType: %i, occurenceBits: %i)\n", 
195
 
                               headerFooterType, occurenceBits));
 
195
                WPD_DEBUG_MSG(("WordPerfect: headerFooterGroup (headerFooterType: %i, occurenceBits: %i)\n",
 
196
                               headerFooterType, occurenceBits));
196
197
 
197
198
                WPXHeaderFooterOccurence wpxOccurence;
198
199
 
221
222
                }
222
223
                m_currentPageHasContent = tempCurrentPageHasContent;
223
224
        }
224
 
}       
 
225
}
225
226
 
226
227
void WP1StylesListener::suppressPageCharacteristics(uint8_t suppressCode)
227
228
{
245
246
        }
246
247
}
247
248
 
248
 
void WP1StylesListener::_handleSubDocument(const WPXSubDocument *subDocument, WPXSubDocumentType subDocumentType, 
249
 
                                                WPXTableList /* tableList */, int /* nextTableIndice */)
 
249
void WP1StylesListener::_handleSubDocument(const WPXSubDocument *subDocument, WPXSubDocumentType subDocumentType,
 
250
        WPXTableList /* tableList */, int /* nextTableIndice */)
250
251
{
251
 
        if (!isUndoOn()) 
 
252
        if (!isUndoOn())
252
253
        {
253
254
                bool oldIsSubDocument = m_isSubDocument;
254
255
                m_isSubDocument = true;
255
 
                if (subDocumentType == WPX_SUBDOCUMENT_HEADER_FOOTER) 
 
256
                if (subDocumentType == WPX_SUBDOCUMENT_HEADER_FOOTER)
256
257
                {
257
258
                        bool oldCurrentPageHasContent = m_currentPageHasContent;
258
259
 
269
270
                m_isSubDocument = oldIsSubDocument;
270
271
        }
271
272
}
 
273
/* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */