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,
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 ************************************************************************/
57 * For LWP filter architecture prototype - notes
59 /*************************************************************************
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
)
75 * @descr read frib information
77 void LwpFribNote::Read(LwpObjectStream
*pObjStrm
, sal_uInt16 len
)
79 m_Layout
.ReadIndexed(pObjStrm
);
83 * @descr Register style
85 void LwpFribNote::RegisterStyle()
87 LwpObject
* pLayout
= m_Layout
.obj();
91 LwpFrib::RegisterStyle(m_pPara
->GetFoundry());
92 //register foonote style
93 pLayout
->SetFoundry(m_pPara
->GetFoundry());
94 pLayout
->RegisterStyle();
101 void LwpFribNote::XFConvert(XFContentContainer
* pCont
)
103 LwpNoteLayout
* pLayout
=static_cast<LwpNoteLayout
*>(m_Layout
.obj());
106 XFAnnotation
* pXFNote
= new XFAnnotation
;
107 pXFNote
->SetAuthor(pLayout
->GetAuthor());
109 long nTime
= pLayout
->GetTime();
110 if(LtgLocalTime(nTime
, aTm
))
112 pXFNote
->SetDate(LwpTools::DateTimeToOUString(aTm
));
115 pLayout
->XFConvert(pXFNote
);
118 XFTextSpan
*pSpan
= new XFTextSpan();
119 pSpan
->SetStyleName(GetStyleName());
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
);
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();
174 pTextLayout
->SetFoundry(GetFoundry());
175 pTextLayout
->RegisterStyle();
180 * @descr convert note
182 void LwpNoteLayout::XFConvert(XFContentContainer
* pCont
)
184 LwpVirtualLayout
* pTextLayout
= GetTextLayout();
187 pTextLayout
->XFConvert(pCont
);
192 * @descr Get layout that contains note text.
194 LwpVirtualLayout
* LwpNoteLayout::GetTextLayout()
196 LwpVirtualLayout
* pLayout
= FindChildByType(LWP_VIEWPORT_LAYOUT
);
199 return pLayout
->FindChildByType(LWP_NOTETEXT_LAYOUT
);
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
));
220 LwpStory
* pStory
= static_cast<LwpStory
*>(pTextLayout
->GetContent()->obj());
223 LwpPara
* pFirst
= static_cast<LwpPara
*>(pStory
->GetFirstPara()->obj());
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();
286 pContent
->SetFoundry(GetFoundry());
287 pContent
->RegisterStyle();
291 void LwpNoteTextLayout::XFConvert(XFContentContainer
* pCont
)
293 LwpObject
* pContent
= m_Content
.obj();
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
)