LibreOffice Module lotuswordpro (master) 1
lwpfribtext.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 <lwpglobalmgr.hxx>
62#include "lwpfribtext.hxx"
63#include "lwpcharsetmgr.hxx"
64#include "lwphyperlinkmgr.hxx"
65#include <lwptools.hxx>
73
74LwpFribText::LwpFribText( LwpPara *pPara, bool bNoUnicode )
75 : LwpFrib(pPara), m_bNoUnicode(bNoUnicode)
76{}
77
78void LwpFribText::Read(LwpObjectStream* pObjStrm, sal_uInt16 len)
79{
80 if( len<1 )
81 return;
82
83 rtl_TextEncoding rEncode;
84 if(m_bNoUnicode)
85 {
86 rEncode = RTL_TEXTENCODING_ISO_8859_1;
87 }
88 else
89 {
90 if (m_pModifiers && m_pModifiers->CodePage)
91 rEncode = LwpCharSetMgr::GetInstance()->
92 GetTextCharEncoding(m_pModifiers->CodePage);
93 else
95 }
96 LwpTools::QuickReadUnicode(pObjStrm, m_Content, len, rEncode);
97}
98
100{
101 if (!pStory)
102 return;
103 LwpHyperlinkMgr* pHyperlink = pStory->GetHyperlinkMgr();
104 if (pHyperlink->GetHyperlinkFlag())
105 LwpFrib::ConvertHyperLink(pXFPara,pHyperlink,GetText());
106 else
108}
109
115void LwpFribParaNumber::Read(LwpObjectStream* pObjStrm, sal_uInt16 /*len*/)
116{
117 m_nStyleID = pObjStrm->QuickReaduInt16();
118 m_nNumberChar = pObjStrm->QuickReaduInt16();
119 m_nLevel = pObjStrm->QuickReaduInt16();
120 m_nStart = pObjStrm->QuickReaduInt16();
121}
122
127 : LwpFrib(pPara), m_nType(0)
128{
129}
134{
135}
141void LwpFribDocVar::Read(LwpObjectStream* pObjStrm, sal_uInt16 /*len*/)
142{
143 m_nType = pObjStrm->QuickReaduInt16();
144 m_aName.Read(pObjStrm);
145}
146
151{
152 LwpFrib::RegisterStyle(pFoundry);
153
154 switch(m_nType)
155 {
156 case DATECREATED:
157 case DATELASTREVISION:
158 {
160 }
161 break;
162 case TOTALEDITTIME:
164 break;
165 default:
166 break;
167 }
168}
169
174{
175 std::unique_ptr<XFDateStyle> pDateStyle(new XFDateStyle);//use the default format
176
177 pDateStyle->AddMonth();
178 pDateStyle->AddText("/");
179 pDateStyle->AddMonthDay();
180 pDateStyle->AddText("/");
181 pDateStyle->AddYear();
182 pDateStyle->AddText(",");
183 pDateStyle->AddHour();
184 pDateStyle->AddText(":");
185 pDateStyle->AddMinute();
186 pDateStyle->AddText(":");
187 pDateStyle->AddSecond();
188
190 m_TimeStyle = pXFStyleManager->AddStyle(std::move(pDateStyle)).m_pStyle->GetStyleName();
191}
193{
194 std::unique_ptr<XFTimeStyle> pTimeStyle(new XFTimeStyle);//use the default format
195 pTimeStyle->SetTruncate(false);
196 pTimeStyle->AddMinute();
198 m_TimeStyle = pXFStyleManager->AddStyle(std::move(pTimeStyle)).m_pStyle->GetStyleName();
199}
200
205{
206 XFContent* pContent=nullptr;
207 switch(m_nType)
208 {
209 case FILENAME:
210 {
211 pContent = new XFFileName;
212 static_cast<XFFileName*>(pContent)->SetType("FileName");
213 break;
214 }
215 case PATH:
216 {
217 pContent = new XFFileName;
218 static_cast<XFFileName*>(pContent)->SetType("Path");
219 break;
220 }
221 case DESCRIPTION:
222 pContent = new XFDescription;
223 break;
224 case DATECREATED:
225 {
226 pContent = new XFCreateTime;
227 pContent->SetStyleName(m_TimeStyle);
228 break;
229 }
230 case DATELASTREVISION:
231 {
232 pContent = new XFLastEditTime;
233 pContent->SetStyleName(m_TimeStyle);
234 break;
235 }
236 case NUMPAGES:
237 pContent = new XFPageCount;
238 break;
239 case NUMWORDS:
240 pContent = new XFWordCount;
241 break;
242 case NUMCHARS:
243 pContent = new XFCharCount;
244 break;
245 case TOTALEDITTIME:
246 {
247 pContent = new XFTotalEditTime;
248 pContent->SetStyleName(m_TimeStyle);
249 break;
250 }
251 case KEYWORDS:
252 pContent = new XFKeywords;
253 break;
254 case CREATEDBY:
255 pContent = new XFInitialCreator;
256 break;
257 case DOCSIZE:
258/* pContent = new XFAnnotation;
259 XFTextContent* pSpan = new XFTextContent();
260 pSpan->SetText("Document Size is Here");
261 XFParagraph* pPara = new XFParagraph;
262 pPara->Add(pSpan);
263 static_cast<XFAnnotation*>(pContent)->Add(pPara);
264 break;
265*/
266 LwpFrib::ConvertChars(pXFPara,"<Document Size>");
267 return;
268 case SMARTMASTER:
269 LwpFrib::ConvertChars(pXFPara,"<Smart master>");
270 return;
271 case DIVISIONNAME:
272 LwpFrib::ConvertChars(pXFPara,"<Division name>");
273 return;
274 case SECTIONNAME:
275 LwpFrib::ConvertChars(pXFPara,"<Section name>");
276 return;
277 case VERSIONCREATEBY:
278 LwpFrib::ConvertChars(pXFPara,"<Version Creat by>");
279 return;
281 LwpFrib::ConvertChars(pXFPara,"<Version Creat date>");
282 return;
284 LwpFrib::ConvertChars(pXFPara,"<Version other Editors>");
285 return;
286 case VERSIONNAME:
287 LwpFrib::ConvertChars(pXFPara,"<Version Name>");
288 return;
289 case VERSIONNUMBER:
290 LwpFrib::ConvertChars(pXFPara,"<Version Numbers>");
291 return;
292 case ALLVERSIONNAME:
293 LwpFrib::ConvertChars(pXFPara,"<All Version Name>");
294 return;
295 case VERSIONREMARK:
296 LwpFrib::ConvertChars(pXFPara,"<Version Remark>");
297 return;
298 case DOCUMENTCATEGORY:
299 LwpFrib::ConvertChars(pXFPara,"<Document Category>");
300 return;
301 case VERSIONLASTDATE:
302 LwpFrib::ConvertChars(pXFPara,"<Version Last Modify Date>");
303 return;
305 LwpFrib::ConvertChars(pXFPara,"<Version Last Editor>");
306 return;
307 case LASTEDIT:
308 LwpFrib::ConvertChars(pXFPara,"<Last Editor>");
309 return;
310 case OTHEREDITORS:
311 LwpFrib::ConvertChars(pXFPara,"<Other Editors>");
312 return;
313 case NUMOFREVISION:
314 LwpFrib::ConvertChars(pXFPara,"<Number of Revision>");
315 return;
316 default:
317 return;
318 }
319 if (m_ModFlag)//(m_pModifiers)
320 {
321 XFTextSpan *pSpan = new XFTextSpan;
322 pSpan->SetStyleName(GetStyleName());
323 pSpan->Add(pContent);
324 pXFPara->Add(pSpan);
325 }
326 else
327 pXFPara->Add(pContent);
328
329}
333void LwpFribUnicode::Read(LwpObjectStream* pObjStrm, sal_uInt16 len)
334{
335 if(len>1)
336 {
337 rtl_TextEncoding rEncode;
338
339 if (m_pModifiers && m_pModifiers->CodePage)
340 rEncode = LwpCharSetMgr::GetInstance()->
341 GetTextCharEncoding(m_pModifiers->CodePage);
342 else
344
345 LwpTools::QuickReadUnicode(pObjStrm, m_Content, len, rEncode);
346
347 }
348 else
349 pObjStrm->SeekRel(len);
350}
351
353{
354 if (!pStory)
355 return;
356 LwpHyperlinkMgr* pHyperlink = pStory->GetHyperlinkMgr();
357 if (pHyperlink->GetHyperlinkFlag())
358 LwpFrib::ConvertHyperLink(pXFPara,pHyperlink,GetText());
359 else
361}
362
366void LwpFribPageNumber::Read(LwpObjectStream* pObjStrm, sal_uInt16 /*len*/)
367{
368 m_nNumStyle = pObjStrm->QuickReaduInt16();
369 m_aBefText.Read(pObjStrm);
370 m_aAfterText.Read(pObjStrm);
371 m_nStartNum = pObjStrm->QuickReaduInt16();
372 m_nStartOnPage = pObjStrm->QuickReaduInt16();
373 m_nFlag = pObjStrm->QuickReaduInt16();
374}
375
377{
378 if (m_nNumStyle == 0x0)
379 return;
380 XFPageNumber* pNum = new XFPageNumber;
381// pNum->SetSelect("current");
382 switch(m_nNumStyle)
383 {
384 case 0x01:
385 pNum->SetNumFmt("1");
386 break;
387 case 0x02:
388 pNum->SetNumFmt("A");
389 break;
390 case 0x03:
391 pNum->SetNumFmt("a");
392 break;
393 case 0x04:
394 pNum->SetNumFmt("I");
395 break;
396 case 0x05:
397 pNum->SetNumFmt("i");
398 break;
399 }
400 OUString styleName = GetStyleName();
401 if (!m_aBefText.str().isEmpty())
402 {
403 OUString textStr = m_aBefText.str();
404 XFTextSpan *pBef = new XFTextSpan(textStr,styleName);
405 pXFPara->Add(pBef);
406 }
407 if (m_ModFlag)//(m_pModifiers)
408 {
409 XFTextSpan *pSpan = new XFTextSpan;
410 pSpan->SetStyleName(styleName);
411 pSpan->Add(pNum);
412 pXFPara->Add(pSpan);
413 }
414 else
415 pXFPara->Add(pNum);
416 if (!m_aAfterText.str().isEmpty())
417 {
418 OUString textStr = m_aAfterText.str();
419 XFTextSpan *pAfter = new XFTextSpan(textStr,styleName);
420 pXFPara->Add(pAfter);
421 }
422}
423
424/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual OUString GetStyleName()=0
@descr: return the style name.
void Read(LwpObjectStream *pStrm)
@descr read atomholder from object stream the default encoding used in Word Pro is 1252
const OUString & str() const
static rtl_TextEncoding GetTextCharEncoding()
static LwpCharSetMgr * GetInstance()
void XFConvert(XFContentContainer *pXFPara)
: convert the doc info field
void RegisterStyle(LwpFoundry *pFoundry) override
: register style for doc field (text style,date style)
sal_uInt16 m_nType
LwpAtomHolder m_aName
void RegisterDefaultTimeStyle()
: register default time style for doc field
LwpFribDocVar(LwpPara *pPara)
: default constructor of LwpFribDocVar
void Read(LwpObjectStream *pObjStrm, sal_uInt16 len) override
: Reading mothed of document variable frib.
virtual ~LwpFribDocVar() override
: destructor of LwpFribDocVar
OUString m_TimeStyle
void RegisterTotalTimeStyle()
LwpAtomHolder m_aAfterText
sal_uInt16 m_nFlag
sal_uInt16 m_nNumStyle
sal_uInt16 m_nStartOnPage
void Read(LwpObjectStream *pObjStrm, sal_uInt16 len) override
: Read page number
LwpAtomHolder m_aBefText
sal_uInt16 m_nStartNum
void XFConvert(XFContentContainer *pXFPara)
sal_uInt16 m_nNumberChar
void Read(LwpObjectStream *pObjStrm, sal_uInt16 len) override
: Reading mothed of paranumber frib.
sal_uInt16 m_nStart
sal_uInt16 m_nLevel
sal_uInt16 m_nStyleID
const OUString & GetText() const
Definition: lwpfribtext.hxx:76
OUString m_Content
Definition: lwpfribtext.hxx:73
void XFConvert(XFContentContainer *pXFPara, LwpStory *pStory)
Definition: lwpfribtext.cxx:99
bool m_bNoUnicode
Definition: lwpfribtext.hxx:74
void Read(LwpObjectStream *pObjStrm, sal_uInt16 len) override
Definition: lwpfribtext.cxx:78
LwpFribText(LwpPara *pPara, bool bNoUnicode)
Definition: lwpfribtext.cxx:74
void Read(LwpObjectStream *pObjStrm, sal_uInt16 len) override
: Read unicode
void XFConvert(XFContentContainer *pXFPara, LwpStory *pStory)
OUString m_Content
const OUString & GetText() const
const OUString & GetStyleName() const
Definition: lwpfrib.hxx:112
void ConvertHyperLink(XFContentContainer *pXFPara, const LwpHyperlinkMgr *pHyperlink, const OUString &text)
Definition: lwpfrib.cxx:396
virtual void RegisterStyle(LwpFoundry *pFoundry)
Definition: lwpfrib.cxx:223
std::unique_ptr< ModifierInfo > m_pModifiers
Definition: lwpfrib.hxx:107
bool m_ModFlag
Definition: lwpfrib.hxx:111
void ConvertChars(XFContentContainer *pXFPara, const OUString &text)
Definition: lwpfrib.cxx:380
XFStyleManager * GetXFStyleManager()
static LwpGlobalMgr * GetInstance(LwpSvStream *pSvStream=nullptr)
bool GetHyperlinkFlag() const
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 SeekRel(sal_uInt16 pos)
@descr SeekRel pos in object stream/buffer
Definition: lwpobjstrm.cxx:160
LwpHyperlinkMgr * GetHyperlinkMgr()
Definition: lwpstory.hxx:117
static void QuickReadUnicode(LwpObjectStream *pObjStrm, OUString &str, sal_uInt16 strlen, rtl_TextEncoding aEncoding)
@descr read lwp unicode string from stream to OUString per aEncoding
Definition: lwptools.cxx:84
A container for content.
virtual void Add(XFContent *pContent)
@descr Add content.
@descr Base class for all content object.
Definition: xfcontent.hxx:80
virtual void SetStyleName(const OUString &style)
: All content except XFTextContent can have a style.
Definition: xfcontent.hxx:90
Page count field.
Definition: xfpagecount.hxx:71
Page number field.
void SetNumFmt(const OUString &fmt)
Style manager for the filter.
IXFStyleRet AddStyle(std::unique_ptr< IXFStyle > pStyle)
void Add(XFContent *pContent)
Definition: xftextspan.cxx:87
IXFStyle * m_pStyle
Definition: xfstylecont.hxx:71