LibreOffice Module lotuswordpro (master) 1
lwpmarker.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 * @file
58 * For LWP filter architecture prototype
59 ************************************************************************/
60
61#include <lwpfilehdr.hxx>
62#include "lwpstory.hxx"
63#include "lwpmarker.hxx"
64#include "lwpproplist.hxx"
65#include <lwpglobalmgr.hxx>
68
70 : LwpDLNFPVList(objHdr,pStrm)
71 , m_nFlag(0)
72 , m_nPageNumber(0)
73 , m_nNeedUpdate(0)
74{
75}
76
78{
83 m_nNeedUpdate = m_pObjStrm->QuickReaduInt16();
84 m_nFlag = m_pObjStrm->QuickReaduInt16();
85 m_nPageNumber = m_pObjStrm->QuickReaduInt16();
86
87 m_pObjStrm->SkipExtra();
88}
89
90OUString LwpMarker::GetNamedProperty(std::u16string_view name)
91{
92 LwpPropList* pProp = GetPropList();
93 if (pProp)
94 return pProp->GetNamedProperty(name);
95 else
96 return OUString();
97}
98
100 : LwpMarker(objHdr,pStrm)
101 , m_nFlag(0)
102{
103}
104
106{
108 m_nFlag = m_pObjStrm->QuickReaduInt16();
109 m_Range.Read(m_pObjStrm.get());
110 m_pObjStrm->SkipExtra();
111}
112
114{
115 m_StartPara.ReadIndexed(pObjStrm);
116 m_EndPara.ReadIndexed(pObjStrm);
117}
118
120 : LwpStoryMarker(objHdr, pStrm)
121 , m_nTab(0)
122 , m_nFlag(0)
123 , m_nAction(0)
124{
125}
126
128{
131 m_Help.Read(m_pObjStrm.get());
132 m_nAction = m_pObjStrm->QuickReaduInt16();
133 m_nTab = m_pObjStrm->QuickReaduInt32();
134 m_nFlag = m_pObjStrm->QuickReaduInt16();
135 if(m_pObjStrm->CheckExtra())
136 {
137 m_Mirror.Read(m_pObjStrm.get());
138 m_pObjStrm->SkipExtra();
139 }
140}
141
143{
144 LwpStory* pStory = nullptr;
145 if (m_objPromptStory.obj().is())
146 pStory = dynamic_cast<LwpStory*>(m_objPromptStory.obj().get());
147 if (pStory)
148 return pStory->GetContentText();
149 return OUString();
150}
151
153{
154 sal_uInt16 nAction = GetAction();
155
156 switch(nAction)
157 {
162 ProcessPlaceHolder(pXFPara,nAction,nType);
163 break;
172 ProcessOtherCHB(pXFPara,nType);
173 break;
175 ProcessKeylist(pXFPara,nType);
176 break;
177 default:
178 break;
179 }
180}
181
183 sal_uInt8 nType)
184{
185 bool bFillFlag = IsHasFilled();
186 bool bHelpFlag = IsBubbleHelp();
187
188 if ( bFillFlag )
189 return;
190 if (nType == MARKER_START)
191 {
192 XFHolderStart* pHolder= new XFHolderStart;
193 switch(nAction)
194 {
196 pHolder->SetType("text");
197 break;
199 pHolder->SetType("table");
200 break;
202 pHolder->SetType("image");
203 break;
205 pHolder->SetType("object");
206 break;
207 default:
208 break;
209 }
210
211 if (bHelpFlag)
212 pHolder->SetDesc(m_Help.str());
213 pHolder->SetPrompt(GetPromptText());
214 pXFPara->Add(pHolder);
215 }
216 else if (nType == MARKER_END)
217 {
218 XFHolderEnd* pHolder = new XFHolderEnd;
219 pXFPara->Add(pHolder);
220 }
221}
222
224{
225 bool bFillFlag = IsHasFilled();
226 bool bHelpFlag = IsBubbleHelp();
227
228 if ( bFillFlag )
229 return;
230 if (nType == MARKER_START)
231 {
232 XFHolderStart* pHolder= new XFHolderStart;
233 pHolder->SetType("text");
234 if (bHelpFlag)
235 pHolder->SetDesc(m_Help.str());
236 pHolder->SetPrompt(GetPromptText());
237 pXFPara->Add(pHolder);
238 }
239 else if (nType == MARKER_END)
240 {
241 XFHolderEnd* pHolder = new XFHolderEnd;
242 pXFPara->Add(pHolder);
243 }
244
245}
246
247//note: there will be a blank to mark the list
248//all input content of key list processed as normal text
250{
251 bool bFillFlag = IsHasFilled();
252
253 if ( bFillFlag )
254 {
255 if (nType == MARKER_START)
256 {
257 EnumAllKeywords();//traverse the proplist to find all keywords
258 XFInputList* pList = new XFInputList;
259 pList->SetName(LwpDLNFPVList::m_Name.str());
260 pList->SetLabels(std::vector(m_Keylist));
261 pXFPara->Add(pList);
262 }
263 // else skip MARKER_END
264 }
265 else
266 {
267 if (nType == MARKER_START)
268 {
270 XFInputList* pList = new XFInputList;
271 pList->SetName(LwpDLNFPVList::m_Name.str());
272 pList->SetLabels(std::vector(m_Keylist));
273 pXFPara->Add(pList);
274
275 XFHolderStart* pHolder= new XFHolderStart;
276 pHolder->SetType("text");
277 pHolder->SetPrompt(GetPromptText());
278 pXFPara->Add(pHolder);
279 }
280 else if (nType == MARKER_END)
281 {
282 XFHolderEnd* pHolder = new XFHolderEnd;
283 pXFPara->Add(pHolder);
284 }
285 }
286}
287
289{
290 return (CHB_PROMPT & m_nFlag) == 0;
291}
292
294{
295 return (CHB_HELP & m_nFlag) != 0;
296}
297
299{
300 OUString name1("");
301 OUString value1("");
302 OUString name2("start");
303 LwpPropList* pProp = GetPropList();
304 if (!pProp)
305 return;
306 while(!name2.isEmpty())
307 {
308 name2 = pProp->EnumNamedProperty(name1,value1);
309 if ( name1.match("LIST",0) )
310 {
311 m_Keylist.push_back(value1);
312 }
313 name1 = name2;
314 }
315}
316
318 : LwpDLNFVList(objHdr,pStrm)
319 , m_nFlag(0)
320{
321}
322
324{
328 {
329 if (m_pObjStrm->QuickReadBool())
331 }
332 else
333 m_nFlag = m_pObjStrm->QuickReaduInt16();
334 m_pObjStrm->SkipExtra();
335}
336
338{
339 return objMarker == m_objMarker;
340}
341
342OUString const & LwpBookMark::GetName()
343{
344 return LwpDLNFVList::GetName().str();
345}
346
348 : LwpStoryMarker(objHdr,pStrm)
349 , m_nFlag(0)
350 , m_nFieldType(0)
351 , m_bHasStyle(false)
352 , m_bHasStart(false)
353 , m_pFrib(nullptr)
354 , m_bRevisionFlag(false)
355{
356}
357
359{
364 return;
366 m_nFlag = m_pObjStrm->QuickReaduInt16();
367 m_nFieldType = m_pObjStrm->QuickReaduInt16();
368 m_pObjStrm->SkipExtra();
369}
370
371void LwpFieldMark::ParseIndex(OUString& sKey1,OUString& sKey2)
372{
373 OUString sFormula = m_Formula.str();
374 sal_Int32 index[4];
375 sal_Unicode ch(0x0022);//"
376 index[0] = sFormula.indexOf(ch);
377 index[1] = sFormula.indexOf(ch,index[0]+1);
378
379 index[2] = sFormula.indexOf(ch,index[1]+1);
380 index[3] = sFormula.indexOf(ch,index[2]+1);
381 if (index[0]>=0 && index[1]>=0)
382 sKey1 = sFormula.copy(index[0]+1,index[1]-index[0]-1);
383 else
384 sKey1.clear();
385 if (index[2]>=0 && index[3]>=0)
386 sKey2 = sFormula.copy(index[2]+1,index[3]-index[2]-1);
387 else
388 sKey2.clear();
389}
390
391void LwpFieldMark::ParseTOC(OUString& sLevel,OUString& sText)
392{
393 OUString sFormula = m_Formula.str();
394 sal_Int32 index[4];
395 sal_Unicode ch1(0x0020);//space
396 sal_Unicode ch2(0x0022);//"
397
398 index[0] = sFormula.indexOf(ch1);
399 index[1] = sFormula.indexOf(ch1,index[0]+1);
400
401 index[2] = sFormula.indexOf(ch2,index[1]+1);
402 index[3] = sFormula.indexOf(ch2,index[2]+1);
403 if (index[0]>=0 && index[1]>=0)
404 sLevel = sFormula.copy(index[0]+1,index[1]-index[0]-1);
405 else
406 sLevel.clear();
407 if (index[2]>=0 && index[3]>=0)
408 sText = sFormula.copy(index[2]+1,index[3]-index[2]-1);
409 else
410 sText.clear();
411}
412
414{
415 return (m_nFlag & FF_FORMULAINSERTED) != 0;
416}
417
419{
420 OUString sFormula = m_Formula.str();
421 sal_Int32 index = sFormula.indexOf(0x20); // space
422 if (index < 0)
423 {
424 if (sFormula == "TotalEditingTime")
425 {
427 return true;
428 }
429 return false;
430 }
431
432 std::u16string_view tag = sFormula.subView(0,index);
433 if (tag == u"Now()")
434 {
436 formula = sFormula.copy(index+1);
437 return true;
438 }
439 else if (tag == u"CreateDate")
440 {
442 formula = sFormula.copy(index+1);
443 return true;
444 }
445 else if (tag == u"EditDate")
446 {
448 formula = sFormula.copy(index+1);
449 return true;
450 }
451 else if (tag == u"YesterdaysDate" || tag == u"TomorrowsDate"
452 || tag == u"TodaysDate")
453 {
455 return true;
456 }
457 else
458 return false;
459}
460
461bool LwpFieldMark::IsCrossRefField(sal_uInt8& nType, OUString& sMarkName)
462{
463 OUString sFormula = m_Formula.str();
464 sal_Int32 index = sFormula.indexOf(0x20); // space
465 if (index < 0)
466 {
468 LwpBookmarkMgr* pMarkMgr = pGlobal->GetLwpBookmarkMgr();
469 if (pMarkMgr->FindBookmark(sFormula))
470 {
471 sMarkName = sFormula;
473 return true;
474 }
475 else
476 return false;
477 }
478
479 std::u16string_view tag = sFormula.subView(0,index);
480 if (tag == u"PageRef")
481 {
482 sMarkName = sFormula.copy(index+1);
484 return true;
485 }
486 else if (tag == u"ParaRef")
487 {
488 sMarkName = sFormula.copy(index+1);
490 return true;
491 }
492 else
493 return false;
494}
495
496bool LwpFieldMark::IsDocPowerField(sal_uInt8& nType,OUString& sFormula)
497{
499
500 if (sFormula == "Description")
501 {
503 return true;
504 }
505 else if (sFormula == "NumPages")
506 {
508 return true;
509 }
510 else if (sFormula == "NumChars")
511 {
513 return true;
514 }
515 else if (sFormula == "NumWords")
516 {
518 return true;
519 }
520 else
521 {
522 return false;
523 }
524}
525
527{
528}
529
531{
534 m_pObjStrm->SkipExtra();
535}
536
537/* 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
const OUString & str() const
OUString const & GetName()
Definition: lwpmarker.cxx:342
LwpBookMark(LwpObjectHeader const &objHdr, LwpSvStream *pStrm)
Definition: lwpmarker.cxx:317
sal_uInt16 m_nFlag
Definition: lwpmarker.hxx:180
void Read() override
@descr Read LwpDLNFVList data from object stream
Definition: lwpmarker.cxx:323
bool IsRightMarker(LwpObjectID objMarker)
Definition: lwpmarker.cxx:337
LwpObjectID m_objMarker
Definition: lwpmarker.hxx:179
bool FindBookmark(const OUString &sName)
void ProcessPlaceHolder(XFContentContainer *pXFPara, sal_uInt16 nAction, sal_uInt8 nType)
Definition: lwpmarker.cxx:182
void ConvertCHBlock(XFContentContainer *pXFPara, sal_uInt8 nType)
Definition: lwpmarker.cxx:152
std::vector< OUString > m_Keylist
Definition: lwpmarker.hxx:163
LwpCHBlkMarker(LwpObjectHeader const &objHdr, LwpSvStream *pStrm)
Definition: lwpmarker.cxx:119
bool IsBubbleHelp() const
Definition: lwpmarker.cxx:293
void Read() override
@descr Read name of LwpDLNFVList from object stream
Definition: lwpmarker.cxx:127
sal_uInt16 GetAction() const
Definition: lwpmarker.hxx:114
void ProcessOtherCHB(XFContentContainer *pXFPara, sal_uInt8 nType)
Definition: lwpmarker.cxx:223
LwpAtomHolder m_Help
Definition: lwpmarker.hxx:161
void ProcessKeylist(XFContentContainer *pXFPara, sal_uInt8 nType)
Definition: lwpmarker.cxx:249
sal_uInt32 m_nTab
Definition: lwpmarker.hxx:158
@ CLICKHERE_CHBEHAVIORDRAWING
Definition: lwpmarker.hxx:122
@ CLICKHERE_CHBEHAVIORPAGENUM
Definition: lwpmarker.hxx:131
@ CLICKHERE_CHBEHAVIORSYMBOL
Definition: lwpmarker.hxx:129
@ CLICKHERE_CHBEHAVIOREQUATION
Definition: lwpmarker.hxx:125
@ CLICKHERE_CHBEHAVIORSTRINGLIST
Definition: lwpmarker.hxx:127
@ CLICKHERE_CHBEHAVIORDATETIME
Definition: lwpmarker.hxx:128
@ CLICKHERE_CHBEHAVIOROLEOBJECT
Definition: lwpmarker.hxx:120
@ CLICKHERE_CHBEHAVIORPICTURE
Definition: lwpmarker.hxx:119
@ CLICKHERE_CHBEHAVIORGLOSSARY
Definition: lwpmarker.hxx:124
@ CLICKHERE_CHBEHAVIORTEXT
Definition: lwpmarker.hxx:117
@ CLICKHERE_CHBEHAVIORTABLE
Definition: lwpmarker.hxx:118
@ CLICKHERE_CHBEHAVIORCHART
Definition: lwpmarker.hxx:121
@ CLICKHERE_CHBEHAVIORDOCFIELD
Definition: lwpmarker.hxx:130
void EnumAllKeywords()
Definition: lwpmarker.cxx:298
bool IsHasFilled() const
Definition: lwpmarker.cxx:288
OUString GetPromptText() const
Definition: lwpmarker.cxx:142
LwpAtomHolder m_Mirror
Definition: lwpmarker.hxx:162
sal_uInt16 m_nFlag
Definition: lwpmarker.hxx:159
sal_uInt16 m_nAction
Definition: lwpmarker.hxx:160
LwpObjectID m_objPromptStory
Definition: lwpmarker.hxx:157
Double Linked Named Family Properties Virtual List.
Definition: lwpdlvlist.hxx:119
void Read() override
@descr Read name of LwpDLNFVList from object stream
Definition: lwpdlvlist.cxx:129
LwpPropList * GetPropList()
Definition: lwpdlvlist.hxx:123
Double Linked Named Family Virtual List.
Definition: lwpdlvlist.hxx:91
void Read() override
@descr Read LwpDLNFVList data from object stream
Definition: lwpdlvlist.cxx:90
LwpAtomHolder m_Name
Definition: lwpdlvlist.hxx:101
LwpAtomHolder & GetName()
Definition: lwpdlvlist.hxx:108
bool IsCrossRefField(sal_uInt8 &nType, OUString &sMarkName)
Definition: lwpmarker.cxx:461
bool IsDocPowerField(sal_uInt8 &nType, OUString &sFormula)
Definition: lwpmarker.cxx:496
LwpFieldMark(LwpObjectHeader const &objHdr, LwpSvStream *pStrm)
Definition: lwpmarker.cxx:347
LwpObjectID m_objResultContent
Definition: lwpmarker.hxx:234
bool IsFormulaInsert() const
Definition: lwpmarker.cxx:413
sal_uInt16 m_nFieldType
Definition: lwpmarker.hxx:236
void ParseTOC(OUString &sLevel, OUString &sText)
Definition: lwpmarker.cxx:391
LwpAtomHolder m_Formula
Definition: lwpmarker.hxx:237
void ParseIndex(OUString &sKey1, OUString &sKey2)
Definition: lwpmarker.cxx:371
sal_uInt16 m_nFlag
Definition: lwpmarker.hxx:235
LwpObjectID m_objFormulaStory
Definition: lwpmarker.hxx:233
bool IsDateTimeField(sal_uInt8 &type, OUString &formula)
Definition: lwpmarker.cxx:418
void Read() override
@descr Read name of LwpDLNFVList from object stream
Definition: lwpmarker.cxx:358
static sal_uInt16 m_nFileRevision
Definition: lwpfilehdr.hxx:77
LwpObjectID m_StartPara
Definition: lwpmarker.hxx:95
LwpObjectID m_EndPara
Definition: lwpmarker.hxx:96
void Read(LwpObjectStream *pObjStrm)
Definition: lwpmarker.cxx:113
LwpBookmarkMgr * GetLwpBookmarkMgr()
static LwpGlobalMgr * GetInstance(LwpSvStream *pSvStream=nullptr)
void Read() override
@descr Read name of LwpDLNFVList from object stream
Definition: lwpmarker.cxx:77
@ MARKER_START
Definition: lwpmarker.hxx:76
LwpMarker(LwpObjectHeader const &objHdr, LwpSvStream *pStrm)
Definition: lwpmarker.cxx:69
sal_uInt16 m_nNeedUpdate
Definition: lwpmarker.hxx:82
LwpObjectID m_objLayout
Definition: lwpmarker.hxx:83
sal_uInt16 m_nPageNumber
Definition: lwpmarker.hxx:81
LwpObjectID m_objContent
Definition: lwpmarker.hxx:85
sal_uInt16 m_nFlag
Definition: lwpmarker.hxx:80
OUString GetNamedProperty(std::u16string_view name)
Definition: lwpmarker.cxx:90
LwpObjectID m_objMarkerList
Definition: lwpmarker.hxx:84
Base class of all Lwp VO objects.
Definition: lwpobjhdr.hxx:71
object id class
Definition: lwpobjid.hxx:79
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
stream class for LwpObject body data provide stream like interface to read object data
Definition: lwpobjstrm.hxx:77
std::unique_ptr< LwpObjectStream > m_pObjStrm
Definition: lwpobj.hxx:90
OUString GetNamedProperty(std::u16string_view name)
Definition: lwpproplist.cxx:86
OUString EnumNamedProperty(OUString &name, OUString &value)
void Read() override
@descr Read name of LwpDLNFVList from object stream
Definition: lwpmarker.cxx:530
LwpObjectID m_objLayout
Definition: lwpmarker.hxx:258
LwpRubyMarker(LwpObjectHeader const &objHdr, LwpSvStream *pStrm)
Definition: lwpmarker.cxx:526
LwpFribRange m_Range
Definition: lwpmarker.hxx:105
sal_uInt16 m_nFlag
Definition: lwpmarker.hxx:106
LwpStoryMarker(LwpObjectHeader const &objHdr, LwpSvStream *pStrm)
Definition: lwpmarker.cxx:99
void Read() override
@descr Read name of LwpDLNFVList from object stream
Definition: lwpmarker.cxx:105
OUString GetContentText(bool bAllText=false)
Definition: lwpstory.cxx:419
encapsulate XInputStream to provide SvStream like interfaces
Definition: lwpsvstream.hxx:69
A container for content.
virtual void Add(XFContent *pContent)
@descr Add content.
Index entry object.
void SetType(const OUString &sType)
void SetDesc(const OUString &sDesc)
void SetPrompt(const OUString &sText)
input list field.
Definition: xfinputlist.hxx:72
void SetName(const OUString &sName)
Definition: xfinputlist.hxx:74
void SetLabels(std::vector< OUString > &&list)
Definition: xfinputlist.hxx:79
OString sFormula
float u
const char * name
index
QPRO_FUNC_TYPE nType
unsigned char sal_uInt8
sal_uInt16 sal_Unicode
ResultType type