update dev300-m57
[ooovba.git] / lotuswordpro / source / filter / lwpnotes.cxx
blobcc5040d90fbf3900ef89345b8b2e0b8cecc9df46
1 /*************************************************************************
3 * The Contents of this file are made available subject to the terms of
4 * either of the following licenses
6 * - GNU Lesser General Public License Version 2.1
7 * - Sun Industry Standards Source License Version 1.1
9 * Sun Microsystems Inc., October, 2000
11 * GNU Lesser General Public License Version 2.1
12 * =============================================
13 * Copyright 2000 by Sun Microsystems, Inc.
14 * 901 San Antonio Road, Palo Alto, CA 94303, USA
16 * This library is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU Lesser General Public
18 * License version 2.1, as published by the Free Software Foundation.
20 * This library is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 * Lesser General Public License for more details.
25 * You should have received a copy of the GNU Lesser General Public
26 * License along with this library; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
28 * MA 02111-1307 USA
31 * Sun Industry Standards Source License Version 1.1
32 * =================================================
33 * The contents of this file are subject to the Sun Industry Standards
34 * Source License Version 1.1 (the "License"); You may not use this file
35 * except in compliance with the License. You may obtain a copy of the
36 * License at http://www.openoffice.org/license.html.
38 * Software provided under this License is provided on an "AS IS" basis,
39 * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
40 * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
41 * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
42 * See the License for the specific provisions governing your rights and
43 * obligations concerning the Software.
45 * The Initial Developer of the Original Code is: IBM Corporation
47 * Copyright: 2008 by IBM Corporation
49 * All Rights Reserved.
51 * Contributor(s): _______________________________________
54 ************************************************************************/
55 /**
56 * @file
57 * For LWP filter architecture prototype - notes
59 /*************************************************************************
60 * Change History
61 May 2005 Created
62 ************************************************************************/
63 #include "lwpnotes.hxx"
64 #include "lwppara.hxx"
65 #include "xfilter/xfannotation.hxx"
66 #include "xfilter/xftextspan.hxx"
67 #include "localtime.hxx"
68 #include "lwptools.hxx"
70 LwpFribNote::LwpFribNote(LwpPara* pPara ):LwpFrib(pPara)
74 /**
75 * @descr read frib information
77 void LwpFribNote::Read(LwpObjectStream *pObjStrm, sal_uInt16 len)
79 m_Layout.ReadIndexed(pObjStrm);
82 /**
83 * @descr Register style
85 void LwpFribNote::RegisterStyle()
87 LwpObject* pLayout = m_Layout.obj();
88 if(pLayout)
90 //register font style
91 LwpFrib::RegisterStyle(m_pPara->GetFoundry());
92 //register foonote style
93 pLayout->SetFoundry(m_pPara->GetFoundry());
94 pLayout->RegisterStyle();
98 /**
99 * @descr convert note
101 void LwpFribNote::XFConvert(XFContentContainer* pCont)
103 LwpNoteLayout* pLayout =static_cast<LwpNoteLayout*>(m_Layout.obj());
104 if(pLayout)
106 XFAnnotation* pXFNote = new XFAnnotation;
107 pXFNote->SetAuthor(pLayout->GetAuthor());
108 LtTm aTm;
109 long nTime = pLayout->GetTime();
110 if(LtgLocalTime(nTime, aTm))
112 pXFNote->SetDate(LwpTools::DateTimeToOUString(aTm));
115 pLayout->XFConvert(pXFNote);
116 if(m_pModifiers)
118 XFTextSpan *pSpan = new XFTextSpan();
119 pSpan->SetStyleName(GetStyleName());
120 pSpan->Add(pXFNote);
121 pCont->Add(pSpan);
123 else
125 pCont->Add(pXFNote);
132 LwpNoteLayout::LwpNoteLayout(LwpObjectHeader &objHdr, LwpSvStream* pStrm)
133 : LwpFrameLayout(objHdr, pStrm)
138 LwpNoteLayout::~LwpNoteLayout()
144 * @descr read note layout object
147 void LwpNoteLayout::Read()
149 LwpFrameLayout::Read();
151 m_pObjStrm->QuickRead(&m_nTime, sizeof(m_nTime));
152 m_UserName.Read(m_pObjStrm);
154 LwpAtomHolder aUserInitials;
155 aUserInitials.Read(m_pObjStrm);
157 LwpColor aColor;
158 aColor.Read(m_pObjStrm);
160 // vacant note sequence
161 m_pObjStrm->QuickReadInt32();
163 m_pObjStrm->SkipExtra();
167 * @descr Register style
169 void LwpNoteLayout::RegisterStyle()
171 LwpVirtualLayout* pTextLayout = GetTextLayout();
172 if(pTextLayout)
174 pTextLayout->SetFoundry(GetFoundry());
175 pTextLayout->RegisterStyle();
180 * @descr convert note
182 void LwpNoteLayout::XFConvert(XFContentContainer * pCont)
184 LwpVirtualLayout* pTextLayout = GetTextLayout();
185 if(pTextLayout)
187 pTextLayout->XFConvert(pCont);
192 * @descr Get layout that contains note text.
194 LwpVirtualLayout* LwpNoteLayout::GetTextLayout()
196 LwpVirtualLayout* pLayout = FindChildByType(LWP_VIEWPORT_LAYOUT);
197 if(pLayout)
199 return pLayout->FindChildByType(LWP_NOTETEXT_LAYOUT);
202 return NULL;
205 * @descr Get author.
207 OUString LwpNoteLayout::GetAuthor()
209 if(m_UserName.HasValue())
211 if(m_UserName.str() != A2OUSTR(" "))
213 return m_UserName.str();
216 //if username is null or writerspace, get username from noteheaderlayout
217 LwpNoteHeaderLayout* pTextLayout = static_cast<LwpNoteHeaderLayout*>(FindChildByType(LWP_NOTEHEADER_LAYOUT));
218 if(pTextLayout)
220 LwpStory* pStory = static_cast<LwpStory*>(pTextLayout->GetContent()->obj());
221 if(pStory)
223 LwpPara* pFirst = static_cast<LwpPara*>(pStory->GetFirstPara()->obj());
224 if(pFirst)
225 return pFirst->GetContentText(sal_True);
229 return m_UserName.str();
232 LwpNoteHeaderLayout::LwpNoteHeaderLayout(LwpObjectHeader &objHdr, LwpSvStream* pStrm)
233 : LwpFrameLayout(objHdr, pStrm)
237 LwpNoteHeaderLayout::~LwpNoteHeaderLayout()
242 * @descr read note layout object
245 void LwpNoteHeaderLayout::Read()
247 LwpFrameLayout::Read();
248 m_pObjStrm->SkipExtra();
251 void LwpNoteHeaderLayout::RegisterStyle()
255 void LwpNoteHeaderLayout::XFConvert(XFContentContainer * pCont)
259 LwpNoteTextLayout::LwpNoteTextLayout(LwpObjectHeader &objHdr, LwpSvStream* pStrm)
260 : LwpFrameLayout(objHdr, pStrm)
264 LwpNoteTextLayout::~LwpNoteTextLayout()
269 * @descr read note layout object
272 void LwpNoteTextLayout::Read()
274 LwpFrameLayout::Read();
275 m_pObjStrm->SkipExtra();
279 * @descr Register style, SODC doesn't support text style in note
281 void LwpNoteTextLayout::RegisterStyle()
283 LwpObject* pContent = m_Content.obj();
284 if(pContent)
286 pContent->SetFoundry(GetFoundry());
287 pContent->RegisterStyle();
291 void LwpNoteTextLayout::XFConvert(XFContentContainer * pCont)
293 LwpObject* pContent = m_Content.obj();
294 if(pContent)
296 pContent->XFConvert(pCont);
301 LwpViewportLayout::LwpViewportLayout(LwpObjectHeader &objHdr, LwpSvStream* pStrm)
302 : LwpPlacableLayout(objHdr, pStrm)
306 LwpViewportLayout::~LwpViewportLayout()
311 * @descr read note layout object
314 void LwpViewportLayout::Read()
316 LwpPlacableLayout::Read();
317 m_pObjStrm->SkipExtra();
320 void LwpViewportLayout::RegisterStyle()
324 void LwpViewportLayout::XFConvert(XFContentContainer * pCont)