1 /* AbiWord
2 * Copyright (C) 1998 AbiSource, Inc.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 * 02110-1301 USA.
18 */
19
20
21
22 #include "ut_types.h"
23 #include "pt_Types.h"
24 #include "ut_assert.h"
25 #include "ut_debugmsg.h"
26 #include "fl_Layout.h"
27 #include "pd_Document.h"
28 #include "fd_Field.h"
29 #include "po_Bookmark.h"
30 #include "pp_AttrProp.h"
31 #include "pf_Frag.h"
32 #include "pf_Frag_Strux.h"
33
fl_Layout(PTStruxType type,pf_Frag_Strux * sdh)34 fl_Layout::fl_Layout(PTStruxType type, pf_Frag_Strux* sdh) :
35 m_type(type),
36 m_apIndex(0),
37 m_pAutoNum(NULL),
38 m_pDoc(NULL), // set by child
39 m_sdh(sdh),
40 m_endSdh(NULL)
41 {
42 xxx_UT_DEBUGMSG(("Layout Strux type = %d \n",type));
43 const pf_Frag * pf = static_cast<const pf_Frag *>(sdh);
44 if(pf)
45 {
46 UT_ASSERT(pf->getType() == pf_Frag::PFT_Strux);
47 }
48 }
49
~fl_Layout()50 fl_Layout::~fl_Layout()
51 {
52 }
53
getStruxDocHandle(void) const54 pf_Frag_Strux* fl_Layout::getStruxDocHandle(void) const
55 {
56 return m_sdh;
57 }
58
59
getEndStruxDocHandle(void) const60 pf_Frag_Strux* fl_Layout::getEndStruxDocHandle(void) const
61 {
62 return m_endSdh;
63 }
64
setEndStruxDocHandle(pf_Frag_Strux * pfs)65 void fl_Layout::setEndStruxDocHandle(pf_Frag_Strux* pfs)
66 {
67 UT_ASSERT(!m_endSdh);
68 m_endSdh = pfs;
69 }
70
getType(void) const71 PTStruxType fl_Layout::getType(void) const
72 {
73 return m_type;
74 }
75
76
setType(PTStruxType type)77 void fl_Layout::setType(PTStruxType type)
78 {
79 m_type = type;
80 }
81
getAttrPropIndex(void) const82 PT_AttrPropIndex fl_Layout::getAttrPropIndex(void) const
83 {
84 return m_apIndex;
85 }
86
setAttrPropIndex(PT_AttrPropIndex apIndex)87 void fl_Layout::setAttrPropIndex(PT_AttrPropIndex apIndex)
88 {
89 m_apIndex = apIndex;
90 }
91
92 /*!
93 ppAP [out] -- the requested AP
94
95 pRevisions [in/out] -- revisions attribute; can be set to NULL, in
96 which case an instance will be created; the
97 caller is responsible for deleting
98
99 bShowRevisions -- indicates if in the current view revisions are
100 to be shown
101
102 iRevisionId -- the id of revision which is shown in the current view
103
104 bHiddenRevision [out] indicates if the element associated with
105 ppAP is hidden or visible
106
107 bDelete [out] -- if set, the caller must delete ppAP when done
108 with it.
109
110 */
getAttrProp(const PP_AttrProp ** ppAP,PP_RevisionAttr ** pRevisions,bool bShowRevisions,UT_uint32 iRevisionId,bool & bHiddenRevision) const111 bool fl_Layout::getAttrProp(const PP_AttrProp ** ppAP, PP_RevisionAttr ** pRevisions,
112 bool bShowRevisions, UT_uint32 iRevisionId, bool &bHiddenRevision) const
113 {
114 UT_return_val_if_fail(m_pDoc, false);
115 return m_pDoc->getAttrProp(m_apIndex, ppAP, pRevisions, bShowRevisions, iRevisionId, bHiddenRevision);
116 }
117
118 /*!
119 if pRevisions is not needed, set the pointer to NULL(this speeds up things)
120 */
getSpanAttrProp(UT_uint32 offset,bool bLeftSide,const PP_AttrProp ** ppAP,PP_RevisionAttr ** pRevisions,bool bShowRevisions,UT_uint32 iRevisionId,bool & bHiddenRevision) const121 bool fl_Layout::getSpanAttrProp(UT_uint32 offset, bool bLeftSide, const PP_AttrProp ** ppAP,
122 PP_RevisionAttr ** pRevisions,
123 bool bShowRevisions, UT_uint32 iRevisionId,
124 bool &bHiddenRevision) const
125 {
126 UT_return_val_if_fail(m_pDoc, false);
127 return m_pDoc->getSpanAttrProp(m_sdh,offset, bLeftSide, ppAP, pRevisions,
128 bShowRevisions, iRevisionId, bHiddenRevision);
129 }
130
getField(UT_uint32 offset,fd_Field * & pField)131 bool fl_Layout::getField(UT_uint32 offset, fd_Field * & pField)
132 {
133 return m_pDoc->getField(m_sdh,offset,pField);
134 }
135
getBookmark(UT_uint32 offset)136 po_Bookmark * fl_Layout::getBookmark(UT_uint32 offset)
137 {
138 return m_pDoc->getBookmark(m_sdh,offset);
139 }
140
setAutoNum(fl_AutoNum * pAutoNum)141 void fl_Layout::setAutoNum(fl_AutoNum * pAutoNum)
142 {
143 m_pAutoNum = pAutoNum;
144 }
145