1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * The Contents of this file are made available subject to the terms of
5 * either of the following licenses
7 * - GNU Lesser General Public License Version 2.1
8 * - Sun Industry Standards Source License Version 1.1
10 * Sun Microsystems Inc., October, 2000
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
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.
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.
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,
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.
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.
46 * The Initial Developer of the Original Code is: IBM Corporation
48 * Copyright: 2008 by IBM Corporation
50 * All Rights Reserved.
52 * Contributor(s): _______________________________________
55 ************************************************************************/
58 * For LWP filter architecture prototype - notes
61 #include "lwpnotes.hxx"
62 #include "lwppara.hxx"
63 #include "xfilter/xfannotation.hxx"
64 #include "xfilter/xftextspan.hxx"
65 #include "localtime.hxx"
66 #include "lwptools.hxx"
68 LwpFribNote::LwpFribNote(LwpPara
* pPara
):LwpFrib(pPara
)
73 * @descr read frib information
75 void LwpFribNote::Read(LwpObjectStream
*pObjStrm
, sal_uInt16
/*len*/)
77 m_Layout
.ReadIndexed(pObjStrm
);
81 * @descr Register style
83 void LwpFribNote::RegisterNewStyle()
85 rtl::Reference
<LwpObject
> pLayout
= m_Layout
.obj();
89 LwpFrib::RegisterStyle(m_pPara
->GetFoundry());
90 //register foonote style
91 pLayout
->SetFoundry(m_pPara
->GetFoundry());
92 pLayout
->DoRegisterStyle();
99 void LwpFribNote::XFConvert(XFContentContainer
* pCont
)
101 LwpNoteLayout
* pLayout
= dynamic_cast<LwpNoteLayout
*>(m_Layout
.obj().get());
104 XFAnnotation
* pXFNote
= new XFAnnotation
;
105 pXFNote
->SetAuthor(pLayout
->GetAuthor());
107 long nTime
= pLayout
->GetTime();
108 if(LtgLocalTime(nTime
, aTm
))
110 pXFNote
->SetDate(LwpTools::DateTimeToOUString(aTm
));
113 pLayout
->XFConvert(pXFNote
);
116 XFTextSpan
*pSpan
= new XFTextSpan();
117 pSpan
->SetStyleName(GetStyleName());
129 LwpNoteLayout::LwpNoteLayout(LwpObjectHeader
&objHdr
, LwpSvStream
* pStrm
)
130 : LwpFrameLayout(objHdr
, pStrm
)
135 LwpNoteLayout::~LwpNoteLayout()
141 * @descr read note layout object
144 void LwpNoteLayout::Read()
146 LwpFrameLayout::Read();
148 m_nTime
= m_pObjStrm
->QuickReaduInt32();
149 m_UserName
.Read(m_pObjStrm
);
151 LwpAtomHolder aUserInitials
;
152 aUserInitials
.Read(m_pObjStrm
);
155 aColor
.Read(m_pObjStrm
);
157 // vacant note sequence
158 m_pObjStrm
->QuickReadInt32();
160 m_pObjStrm
->SkipExtra();
164 * @descr Register style
166 void LwpNoteLayout::RegisterStyle()
168 LwpVirtualLayout
* pTextLayout
= GetTextLayout();
171 pTextLayout
->SetFoundry(GetFoundry());
172 pTextLayout
->DoRegisterStyle();
177 * @descr convert note
179 void LwpNoteLayout::XFConvert(XFContentContainer
* pCont
)
181 LwpVirtualLayout
* pTextLayout
= GetTextLayout();
184 pTextLayout
->DoXFConvert(pCont
);
189 * @descr Get layout that contains note text.
191 LwpVirtualLayout
* LwpNoteLayout::GetTextLayout()
193 LwpVirtualLayout
* pLayout
= FindChildByType(LWP_VIEWPORT_LAYOUT
);
196 return pLayout
->FindChildByType(LWP_NOTETEXT_LAYOUT
);
204 OUString
LwpNoteLayout::GetAuthor()
206 if(m_UserName
.HasValue())
208 if(m_UserName
.str() != " ")
210 return m_UserName
.str();
213 //if username is null or writerspace, get username from noteheaderlayout
214 LwpNoteHeaderLayout
* pTextLayout
= static_cast<LwpNoteHeaderLayout
*>(FindChildByType(LWP_NOTEHEADER_LAYOUT
));
217 LwpStory
* pStory
= dynamic_cast<LwpStory
*>(pTextLayout
->GetContent().obj().get());
220 LwpPara
* pFirst
= dynamic_cast<LwpPara
*>(pStory
->GetFirstPara().obj().get());
222 return pFirst
->GetContentText(true);
226 return m_UserName
.str();
229 LwpNoteHeaderLayout::LwpNoteHeaderLayout(LwpObjectHeader
&objHdr
, LwpSvStream
* pStrm
)
230 : LwpFrameLayout(objHdr
, pStrm
)
234 LwpNoteHeaderLayout::~LwpNoteHeaderLayout()
239 * @descr read note layout object
242 void LwpNoteHeaderLayout::Read()
244 LwpFrameLayout::Read();
245 m_pObjStrm
->SkipExtra();
248 void LwpNoteHeaderLayout::RegisterStyle()
252 void LwpNoteHeaderLayout::XFConvert(XFContentContainer
* /*pCont*/)
256 LwpNoteTextLayout::LwpNoteTextLayout(LwpObjectHeader
&objHdr
, LwpSvStream
* pStrm
)
257 : LwpFrameLayout(objHdr
, pStrm
)
261 LwpNoteTextLayout::~LwpNoteTextLayout()
266 * @descr read note layout object
269 void LwpNoteTextLayout::Read()
271 LwpFrameLayout::Read();
272 m_pObjStrm
->SkipExtra();
276 * @descr Register style, SODC doesn't support text style in note
278 void LwpNoteTextLayout::RegisterStyle()
280 rtl::Reference
<LwpObject
> pContent
= m_Content
.obj();
283 pContent
->SetFoundry(GetFoundry());
284 pContent
->DoRegisterStyle();
288 void LwpNoteTextLayout::XFConvert(XFContentContainer
* pCont
)
290 rtl::Reference
<LwpObject
> pContent
= m_Content
.obj();
293 pContent
->DoXFConvert(pCont
);
297 LwpViewportLayout::LwpViewportLayout(LwpObjectHeader
&objHdr
, LwpSvStream
* pStrm
)
298 : LwpPlacableLayout(objHdr
, pStrm
)
302 LwpViewportLayout::~LwpViewportLayout()
307 * @descr read note layout object
310 void LwpViewportLayout::Read()
312 LwpPlacableLayout::Read();
313 m_pObjStrm
->SkipExtra();
316 void LwpViewportLayout::RegisterStyle()
320 void LwpViewportLayout::XFConvert(XFContentContainer
* /*pCont*/)
324 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */