LibreOffice Module lotuswordpro (master) 1
lwpfootnote.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*************************************************************************
3 *
4 * The Contents of this file are made available subject to the terms of
5 * either of the following licenses
6 *
7 * - GNU Lesser General Public License Version 2.1
8 * - Sun Industry Standards Source License Version 1.1
9 *
10 * Sun Microsystems Inc., October, 2000
11 *
12 * GNU Lesser General Public License Version 2.1
13 * =============================================
14 * Copyright 2000 by Sun Microsystems, Inc.
15 * 901 San Antonio Road, Palo Alto, CA 94303, USA
16 *
17 * This library is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU Lesser General Public
19 * License version 2.1, as published by the Free Software Foundation.
20 *
21 * This library is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 * Lesser General Public License for more details.
25 *
26 * You should have received a copy of the GNU Lesser General Public
27 * License along with this library; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
29 * MA 02111-1307 USA
30 *
31 *
32 * Sun Industry Standards Source License Version 1.1
33 * =================================================
34 * The contents of this file are subject to the Sun Industry Standards
35 * Source License Version 1.1 (the "License"); You may not use this file
36 * except in compliance with the License. You may obtain a copy of the
37 * License at http://www.openoffice.org/license.html.
38 *
39 * Software provided under this License is provided on an "AS IS" basis,
40 * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
41 * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
42 * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
43 * See the License for the specific provisions governing your rights and
44 * obligations concerning the Software.
45 *
46 * The Initial Developer of the Original Code is: IBM Corporation
47 *
48 * Copyright: 2008 by IBM Corporation
49 *
50 * All Rights Reserved.
51 *
52 * Contributor(s): _______________________________________
53 *
54 *
55 ************************************************************************/
56
57#include <memory>
58#include "lwpfootnote.hxx"
60#include <xfilter/xfendnote.hxx>
65#include "lwppara.hxx"
66#include "lwpdoc.hxx"
67#include "lwpfnlayout.hxx"
68#include <lwpglobalmgr.hxx>
69
71 : LwpFrib(pPara)
72{
73}
74
78void LwpFribFootnote::Read(LwpObjectStream* pObjStrm, sal_uInt16 /*len*/)
79{
80 m_Footnote.ReadIndexed(pObjStrm);
81}
82
87{
88 LwpFootnote* pFootnote = GetFootnote();
89 if (pFootnote)
90 {
91 //register footnote number font style
93 //register footnote content style
94 pFootnote->SetFoundry(m_pPara->GetFoundry());
95 pFootnote->RegisterStyle();
96 }
97}
98
103{
104 LwpFootnote* pFootnote = GetFootnote();
105 if (!pFootnote)
106 return;
107
109 if (pFootnote->GetType() == FN_FOOTNOTE)
110 {
111 xContent.set(new XFFootNote);
112 }
113 else
114 {
115 xContent.set(new XFEndNote);
116 }
117 pFootnote->XFConvert(xContent.get());
118 if (m_ModFlag)
119 {
120 //set footnote number font style
122 xSpan->SetStyleName(GetStyleName());
123 //add the xffootnote into the content container
124 xSpan->Add(xContent.get());
125 pCont->Add(xSpan.get());
126 }
127 else
128 {
129 pCont->Add(xContent.get());
130 }
131}
132
137{
138 return dynamic_cast<LwpFootnote*>(m_Footnote.obj().get());
139}
140
142 : LwpOrderedObject(objHdr, pStrm)
143 , m_nType(0)
144 , m_nRow(0)
145{
146}
147
149
154{
156 m_nType = m_pObjStrm->QuickReaduInt16();
157 m_nRow = m_pObjStrm->QuickReaduInt16();
159 m_pObjStrm->SkipExtra();
160}
161
166{
167 //Only register footnote contents style,
168 //Endnote contents style registers in LwpEnSuperTableLayout::RegisterStyle
169 if (m_nType == FN_FOOTNOTE)
170 {
171 LwpContent* pContent = FindFootnoteContent();
172 if (pContent)
173 {
174 pContent->SetFoundry(m_pFoundry);
175 pContent->DoRegisterStyle();
176 }
177 }
178}
179
184{
185 LwpContent* pContent = FindFootnoteContent();
186 if (pContent)
187 {
188 pContent->DoXFConvert(pCont);
189 }
190}
191
196{
198 if (pEnSuperLayout)
199 {
200 LwpTableLayout* pTableLayout
201 = dynamic_cast<LwpTableLayout*>(pEnSuperLayout->GetMainTableLayout());
202 if (pTableLayout)
203 {
204 LwpRowLayout* pRowLayout = pTableLayout->GetRowLayout(m_nRow);
205 if (pRowLayout)
206 {
207 return dynamic_cast<LwpCellLayout*>(pRowLayout->GetChildHead().obj().get());
208 }
209 }
210 }
211 return nullptr;
212}
213
218{
219 if (!m_pFoundry)
220 return nullptr;
221
222 LwpDocument* pPrev = nullptr;
223 LwpDocument* pDivision = nullptr;
224 LwpDocument* pFootnoteDivision = nullptr;
225
226 // Make sure the footnote does belong to some division
227 // The division might not have a DivisionInfo if it's being Destruct()ed
228 pPrev = m_pFoundry->GetDocument();
229 pFootnoteDivision = pPrev;
230 if (!pPrev || pPrev->GetDivInfoID().IsNull())
231 return nullptr;
232
233 switch (m_nType)
234 {
235 case FN_FOOTNOTE:
236 {
237 // Footnotes always use the source division
238 return pFootnoteDivision;
239 }
240 case FN_DIVISION:
241 {
242 // Start with the footnote's division
243 pDivision = pPrev;
244 break;
245 }
247 {
248 // It had better be the next division
249 pDivision = pPrev->GetNextDivision();
250 break;
251 }
252 case FN_DIVISIONGROUP:
254 {
255 pDivision = pPrev->GetLastInGroupWithContents();
256 break;
257 }
258 case FN_DOCUMENT:
260 {
261 pDivision = pFootnoteDivision->GetRootDocument();
262 if (pDivision)
263 pDivision = pDivision->GetLastDivisionWithContents();
264 break;
265 }
266 }
267
268 // Make sure we're using the proper endnote division, if it's separate
270 pDivision = GetEndnoteDivision(pDivision);
271 // Don't use a division that's specifically for endnotes
272 else
273 {
274 while (pDivision)
275 {
276 if (pDivision->GetEndnoteType() == FN_DONTCARE)
277 break;
279 pDivision = pDivision->GetPreviousInGroup();
280 else
281 pDivision = pDivision->GetPreviousDivisionWithContents();
282 }
283 }
284 if (pDivision)
285 return pDivision;
286 return nullptr;
287}
288
293{
294 LwpDocument* pDivision = pPossible;
295 sal_uInt16 nDivType;
296
297 // In case we have multiple endnote divisions, walk backwards until
298 // we find one.
299 while (pDivision)
300 {
301 // Do we already have the right division?
302 nDivType = pDivision->GetEndnoteType();
303 if (nDivType == m_nType)
304 return pDivision;
305 // When we hit the first non-endnote division, stop looking.
306 // -- SDC 10/8/96
307 if (nDivType == FN_DONTCARE)
308 break;
309 pDivision = pDivision->GetPreviousDivision();
310 }
311 return nullptr;
312}
313
318{
319 OUString strClassName;
320 switch (GetType() & FN_MASK_BASE)
321 {
322 case FN_BASE_FOOTNOTE:
323 {
324 strClassName = STR_DivisionFootnote;
325 break;
326 }
327 case FN_BASE_DOCUMENT:
328 {
329 strClassName = STR_DocumentEndnote;
330 break;
331 }
332 case FN_BASE_DIVISION:
333 {
334 strClassName = STR_DivisionEndnote;
335 break;
336 }
338 {
339 strClassName = STR_DivisionGroupEndnote;
340 break;
341 }
342 }
343 return strClassName;
344}
345
350{
352 if (!pDivision)
353 return nullptr;
354
355 LwpFoundry* pFoundry = pDivision->GetFoundry();
356 OUString strClassName = GetTableClass();
357 if (strClassName.isEmpty())
358 return nullptr;
359
360 LwpContent* pContent = nullptr;
361
362 while ((pContent = pFoundry->EnumContents(pContent)) != nullptr)
363 if (pContent->IsTable() && (strClassName == pContent->GetClassName())
364 && pContent->IsActive() && pContent->GetLayout(nullptr).is())
365 {
366 // Found it!
367 return static_cast<LwpEnSuperTableLayout*>(
368 static_cast<LwpTable*>(pContent)->GetSuperTableLayout());
369 }
370
371 return nullptr;
372}
373
378{
379 LwpContent* pContent = dynamic_cast<LwpContent*>(m_Content.obj().get());
380 //if the content has layout, the content has footnote contents;
381 //or looking for the celllayout and return the footnote contents.
382 if (pContent && pContent->GetLayout(nullptr).is())
383 return pContent;
384
385 LwpCellLayout* pCellLayout = GetCellLayout();
386 if (pCellLayout)
387 {
388 pContent = dynamic_cast<LwpContent*>(pCellLayout->GetContent().obj().get());
389 }
390
391 return pContent;
392}
393
395 : LwpTable(objHdr, pStrm)
396{
397}
398
400{
402 m_pObjStrm->SkipExtra();
403}
404
409{
410 m_nFlag = pObjStrm->QuickReaduInt16();
412 m_LeadingText.Read(pObjStrm);
413 m_TrailingText.Read(pObjStrm);
414 pObjStrm->SkipExtra();
415}
416
421{
422 m_nFlag = pObjStrm->QuickReaduInt16();
423 m_nLength = pObjStrm->QuickReaduInt32();
424 m_nIndent = pObjStrm->QuickReaduInt32();
425 m_nAbove = pObjStrm->QuickReaduInt32();
426 m_nBelow = pObjStrm->QuickReaduInt32();
427 m_BorderStuff.Read(pObjStrm);
428 pObjStrm->SkipExtra();
429}
430
432 : LwpObject(objHdr, pStrm)
433 , m_nFlag(0)
434{
435}
436
438
443{
444 m_nFlag = m_pObjStrm->QuickReaduInt16();
453 m_pObjStrm->SkipExtra();
454}
455
460{
463}
464
469{
470 std::unique_ptr<XFFootnoteConfig> xFootnoteConfig(new XFFootnoteConfig);
471 xFootnoteConfig->SetStartValue(m_FootnoteNumbering.GetStartingNumber() - 1);
472 xFootnoteConfig->SetNumPrefix(m_FootnoteNumbering.GetLeadingText());
473 xFootnoteConfig->SetNumSuffix(m_FootnoteNumbering.GetTrailingText());
475 {
476 xFootnoteConfig->SetRestartOnPage();
477 }
478 if (GetContinuedFrom())
479 {
480 xFootnoteConfig->SetMessageFrom(GetContinuedFromMessage());
481 }
482 if (GetContinuedOn())
483 {
484 xFootnoteConfig->SetMessageOn(GetContinuedOnMessage());
485 }
486
487 xFootnoteConfig->SetMasterPage(m_strMasterPage);
489 pXFStyleManager->SetFootnoteConfig(xFootnoteConfig.release());
490}
491
496{
497 std::unique_ptr<XFEndnoteConfig> xEndnoteConfig(new XFEndnoteConfig);
498 xEndnoteConfig->SetStartValue(m_EndnoteDocNumbering.GetStartingNumber() - 1);
499 OUString message = m_EndnoteDocNumbering.GetLeadingText();
500 if (message.isEmpty())
501 {
502 message = "["; //default prefix
503 }
504 xEndnoteConfig->SetNumPrefix(message);
506 if (message.isEmpty())
507 {
508 message = "]"; //default suffix
509 }
510 xEndnoteConfig->SetNumSuffix(message);
512 {
513 xEndnoteConfig->SetRestartOnPage();
514 }
515
516 xEndnoteConfig->SetMasterPage(m_strMasterPage);
517
519 pXFStyleManager->SetEndnoteConfig(xEndnoteConfig.release());
520}
521
526{
528 {
529 return m_ContinuedOnMessage.str();
530 }
531 // else return default message
533}
534
539{
541 {
543 }
544 // else return default message
546}
547
548/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void Read(LwpObjectStream *pStrm)
@descr read atomholder from object stream the default encoding used in Word Pro is 1252
bool HasValue() const
const OUString & str() const
void Read(LwpObjectStream *pStrm)
VO_CELLLAYOUT object.
Base class of all Lwp content objects.
Definition: lwpcontent.hxx:74
bool IsActive() const
Definition: lwpcontent.hxx:122
virtual bool IsTable()
Definition: lwpcontent.hxx:127
OUString const & GetClassName() const
Definition: lwpcontent.hxx:132
rtl::Reference< LwpVirtualLayout > GetLayout(LwpVirtualLayout const *pStartLayout)
Definition: lwpcontent.cxx:124
LwpObjectID & GetChildHead()
Definition: lwpdlvlist.hxx:109
Document object, represent document and division.
Definition: lwpdoc.hxx:76
LwpObjectID & GetDivInfoID()
Definition: lwpdoc.hxx:183
sal_uInt16 GetEndnoteType()
@descr Get the endnote type
Definition: lwpdoc.cxx:456
LwpDocument * GetNextDivision()
@descr Get next division
Definition: lwpdoc.cxx:485
LwpFoundry * GetFoundry()
Definition: lwpdoc.hxx:182
LwpDocument * GetLastInGroupWithContents()
@descr Get last division in group which has contents, copy from lwp source code
Definition: lwpdoc.cxx:596
LwpDocument * GetPreviousDivisionWithContents()
@descr Get previous division which has contents, copy from lwp source code
Definition: lwpdoc.cxx:540
LwpDocument * GetLastDivisionWithContents()
@descr Get last division which has contents, copy from lwp source code
Definition: lwpdoc.cxx:559
LwpDocument * GetPreviousDivision()
@descr Get previous division
Definition: lwpdoc.cxx:473
LwpDocument * GetRootDocument()
@descr Get root document
Definition: lwpdoc.cxx:637
LwpDocument * GetPreviousInGroup()
@descr Get previous division in group, copy from lwp source code
Definition: lwpdoc.cxx:509
VO_ENSUPERTABLELAYOUT object.
virtual LwpVirtualLayout * GetMainTableLayout()
Get child endnote layout.
LwpAtomHolder m_LeadingText
sal_uInt16 GetStartingNumber() const
sal_uInt16 GetReset() const
OUString const & GetTrailingText() const
LwpAtomHolder m_TrailingText
void Read(LwpObjectStream *pObjStrm)
@descr Read footnote number options information
OUString const & GetLeadingText() const
void Read() override
@descr Register footnote options object
LwpFootnoteSeparatorOptions m_FootnoteContinuedSeparator
void RegisterStyle() override
@descr Register footnote options style
OUString GetContinuedFromMessage() const
@descr Get continue from message
LwpFootnoteNumberOptions m_EndnoteDivisionGroupNumbering
LwpFootnoteOptions(LwpObjectHeader const &objHdr, LwpSvStream *pStrm)
bool GetContinuedOn() const
virtual ~LwpFootnoteOptions() override
LwpAtomHolder m_ContinuedFromMessage
OUString GetContinuedOnMessage() const
@descr Get continue on message
bool GetContinuedFrom() const
OUString m_strMasterPage
LwpFootnoteNumberOptions m_EndnoteDocNumbering
LwpFootnoteSeparatorOptions m_FootnoteSeparator
void RegisterFootnoteStyle()
@descr Register footnote configuration information
void RegisterEndnoteStyle()
@descr Register endnote configuration information
LwpAtomHolder m_ContinuedOnMessage
LwpFootnoteNumberOptions m_EndnoteDivisionNumbering
LwpFootnoteNumberOptions m_FootnoteNumbering
void Read(LwpObjectStream *pObjStrm)
@descr Read footnote separator options information
LwpFootnoteTable(LwpObjectHeader const &objHdr, LwpSvStream *pStrm)
void Read() override
@descr default read function
sal_uInt16 m_nType
LwpCellLayout * GetCellLayout()
@descr Get endnote cell layout which contains current endnote content
LwpObjectID m_Content
LwpDocument * GetFootnoteTableDivision()
@descr Get division which footnote table contains current footnote content, copy from lwp source code
OUString GetTableClass() const
@descr Get footnote table class name
LwpFootnote(LwpObjectHeader const &objHdr, LwpSvStream *pStrm)
sal_uInt16 m_nRow
virtual ~LwpFootnote() override
LwpEnSuperTableLayout * FindFootnoteTableLayout()
@descr Find footnote tablelayout, copy from lwp source code
void XFConvert(XFContentContainer *pCont) override
@descr Parse footnote
LwpContent * FindFootnoteContent()
@descr Find footnote contents
void Read() override
@descr Read foonote object
sal_uInt16 GetType() const
void RegisterStyle() override
@descr Register footnote style
LwpDocument * GetEndnoteDivision(LwpDocument *pPossible)
@descr Get division which endnote table contains current endnote content, copy from lwp source code
LwpContent * EnumContents(LwpContent *pContent)
@descr: Get next content
Definition: lwpfoundry.cxx:235
LwpDocument * GetDocument()
Definition: lwpfoundry.hxx:254
void RegisterNewStyle()
@descr Register footnote style by calling LwpFootnote::RegisterStyle()
Definition: lwpfootnote.cxx:86
LwpFootnote * GetFootnote()
@descr Get foonote object
void Read(LwpObjectStream *pObjStrm, sal_uInt16 len) override
@descr read footnote frib information
Definition: lwpfootnote.cxx:78
void XFConvert(XFContentContainer *pCont)
@descr Parse footnote by calling LwpFootnote::XFConvert()
LwpObjectID m_Footnote
LwpFribFootnote(LwpPara *pPara)
Definition: lwpfootnote.cxx:70
const OUString & GetStyleName() const
Definition: lwpfrib.hxx:112
LwpPara * m_pPara
Definition: lwpfrib.hxx:104
virtual void RegisterStyle(LwpFoundry *pFoundry)
Definition: lwpfrib.cxx:223
bool m_ModFlag
Definition: lwpfrib.hxx:111
XFStyleManager * GetXFStyleManager()
static LwpGlobalMgr * GetInstance(LwpSvStream *pSvStream=nullptr)
LwpObjectID & GetContent()
Definition: lwplayout.hxx:415
Base class of all Lwp VO objects.
Definition: lwpobjhdr.hxx:71
void ReadIndexed(LwpSvStream *pStrm)
@descr Read object id with indexed format from stream if index>0, lowid is get from time table per th...
Definition: lwpobjid.cxx:96
rtl::Reference< LwpObject > obj(VO_TYPE tag=VO_INVALID) const
@descr get object from object factory per the object id
Definition: lwpobjid.cxx:183
bool IsNull() const
Definition: lwpobjid.hxx:110
stream class for LwpObject body data provide stream like interface to read object data
Definition: lwpobjstrm.hxx:77
sal_uInt16 QuickReaduInt16(bool *pFailure=nullptr)
@descr Quick read sal_uInt32
Definition: lwpobjstrm.cxx:200
void SkipExtra()
@descr skip extra bytes
Definition: lwpobjstrm.cxx:258
sal_uInt32 QuickReaduInt32(bool *pFailure=nullptr)
@descr Quick read sal_uInt32
Definition: lwpobjstrm.cxx:189
Base class of all Lwp VO objects.
Definition: lwpobj.hxx:83
void DoRegisterStyle()
Definition: lwpobj.hxx:107
void SetFoundry(LwpFoundry *pFoundry)
Definition: lwpobj.hxx:137
LwpFoundry * m_pFoundry
Definition: lwpobj.hxx:91
std::unique_ptr< LwpObjectStream > m_pObjStrm
Definition: lwpobj.hxx:90
LwpFoundry * GetFoundry()
Definition: lwpobj.hxx:136
void DoXFConvert(XFContentContainer *pCont)
Definition: lwpobj.hxx:127
void Read() override
@descr: read object information
Definition: lwpsection.cxx:75
VO_ROWLAYOUT obj.
encapsulate XInputStream to provide SvStream like interfaces
Definition: lwpsvstream.hxx:69
VO_TABLELAYOUT object and functions for registering styles and converting tables.
LwpRowLayout * GetRowLayout(sal_uInt16 nRow)
@descr Get row layout by row id
VO_TABLE object.
Definition: lwptable.hxx:107
void Read() override
@descr default read function
Definition: lwptable.cxx:99
A container for content.
virtual void Add(XFContent *pContent)
@descr Add content.
End note object.
Definition: xfendnote.hxx:72
Foot note object.
Definition: xffootnote.hxx:73
Style manager for the filter.
void SetFootnoteConfig(XFFootnoteConfig *pFNConfig)
void SetEndnoteConfig(XFEndnoteConfig *pFNConfig)
For LWP filter architecture prototype - footnote layouts.
constexpr OUStringLiteral STRID_FOOTCONTINUEDFROM
Definition: lwpfootnote.hxx:90
#define FN_BASE_DOCUMENT
Definition: lwpfootnote.hxx:79
constexpr OUStringLiteral STR_DivisionFootnote
Definition: lwpfootnote.hxx:93
#define FN_MASK_BASE
Definition: lwpfootnote.hxx:74
#define FN_MASK_SEPARATE
Definition: lwpfootnote.hxx:72
constexpr OUStringLiteral STR_DocumentEndnote
Definition: lwpfootnote.hxx:96
constexpr OUStringLiteral STRID_FOOTCONTINUEDON
Definition: lwpfootnote.hxx:91
#define FN_DIVISIONGROUP_SEPARATE
Definition: lwpfootnote.hxx:87
#define FN_BASE_DIVISION
Definition: lwpfootnote.hxx:77
#define FN_BASE_FOOTNOTE
Definition: lwpfootnote.hxx:76
#define FN_DOCUMENT_SEPARATE
Definition: lwpfootnote.hxx:89
constexpr OUStringLiteral STR_DivisionGroupEndnote
Definition: lwpfootnote.hxx:95
#define FN_DIVISION_SEPARATE
Definition: lwpfootnote.hxx:85
#define FN_DIVISION
Definition: lwpfootnote.hxx:84
constexpr OUStringLiteral STR_DivisionEndnote
Definition: lwpfootnote.hxx:94
#define FN_DIVISIONGROUP
Definition: lwpfootnote.hxx:86
#define FN_DONTCARE
Definition: lwpfootnote.hxx:82
#define FN_DOCUMENT
Definition: lwpfootnote.hxx:88
#define FN_BASE_DIVISIONGROUP
Definition: lwpfootnote.hxx:78
#define FN_FOOTNOTE
Definition: lwpfootnote.hxx:83