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
)
74 * @descr read frib information
76 void LwpFribNote::Read(LwpObjectStream
* pObjStrm
, sal_uInt16
/*len*/)
78 m_Layout
.ReadIndexed(pObjStrm
);
82 * @descr Register style
84 void LwpFribNote::RegisterNewStyle()
86 rtl::Reference
<LwpObject
> pLayout
= m_Layout
.obj();
90 LwpFrib::RegisterStyle(m_pPara
->GetFoundry());
91 //register foonote style
92 pLayout
->SetFoundry(m_pPara
->GetFoundry());
93 pLayout
->DoRegisterStyle();
100 void LwpFribNote::XFConvert(XFContentContainer
* pCont
)
102 LwpNoteLayout
* pLayout
= dynamic_cast<LwpNoteLayout
*>(m_Layout
.obj().get());
106 XFAnnotation
* pXFNote
= new XFAnnotation
;
107 pXFNote
->SetAuthor(pLayout
->GetAuthor());
109 tools::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());
129 LwpNoteLayout::LwpNoteLayout(LwpObjectHeader
const& objHdr
, LwpSvStream
* pStrm
)
130 : LwpFrameLayout(objHdr
, pStrm
)
135 LwpNoteLayout::~LwpNoteLayout() {}
138 * @descr read note layout object
141 void LwpNoteLayout::Read()
143 LwpFrameLayout::Read();
145 m_nTime
= m_pObjStrm
->QuickReaduInt32();
146 m_UserName
.Read(m_pObjStrm
.get());
148 LwpAtomHolder aUserInitials
;
149 aUserInitials
.Read(m_pObjStrm
.get());
152 aColor
.Read(m_pObjStrm
.get());
154 // vacant note sequence
155 m_pObjStrm
->QuickReadInt32();
157 m_pObjStrm
->SkipExtra();
161 * @descr Register style
163 void LwpNoteLayout::RegisterStyle()
165 LwpVirtualLayout
* pTextLayout
= GetTextLayout();
168 pTextLayout
->SetFoundry(GetFoundry());
169 pTextLayout
->DoRegisterStyle();
174 * @descr convert note
176 void LwpNoteLayout::XFConvert(XFContentContainer
* pCont
)
178 LwpVirtualLayout
* pTextLayout
= GetTextLayout();
181 pTextLayout
->DoXFConvert(pCont
);
186 * @descr Get layout that contains note text.
188 LwpVirtualLayout
* LwpNoteLayout::GetTextLayout()
190 LwpVirtualLayout
* pLayout
= FindChildByType(LWP_VIEWPORT_LAYOUT
);
193 return pLayout
->FindChildByType(LWP_NOTETEXT_LAYOUT
);
201 OUString
LwpNoteLayout::GetAuthor()
203 if (m_UserName
.HasValue())
205 if (m_UserName
.str() != " ")
207 return m_UserName
.str();
210 //if username is null or writerspace, get username from noteheaderlayout
211 LwpNoteHeaderLayout
* pTextLayout
212 = static_cast<LwpNoteHeaderLayout
*>(FindChildByType(LWP_NOTEHEADER_LAYOUT
));
215 LwpStory
* pStory
= dynamic_cast<LwpStory
*>(pTextLayout
->GetContent().obj().get());
218 LwpPara
* pFirst
= dynamic_cast<LwpPara
*>(pStory
->GetFirstPara().obj().get());
220 return pFirst
->GetContentText(true);
224 return m_UserName
.str();
227 LwpNoteHeaderLayout::LwpNoteHeaderLayout(LwpObjectHeader
const& objHdr
, LwpSvStream
* pStrm
)
228 : LwpFrameLayout(objHdr
, pStrm
)
232 LwpNoteHeaderLayout::~LwpNoteHeaderLayout() {}
235 * @descr read note layout object
238 void LwpNoteHeaderLayout::Read()
240 LwpFrameLayout::Read();
241 m_pObjStrm
->SkipExtra();
244 void LwpNoteHeaderLayout::RegisterStyle() {}
246 void LwpNoteHeaderLayout::XFConvert(XFContentContainer
* /*pCont*/) {}
248 LwpNoteTextLayout::LwpNoteTextLayout(LwpObjectHeader
const& objHdr
, LwpSvStream
* pStrm
)
249 : LwpFrameLayout(objHdr
, pStrm
)
253 LwpNoteTextLayout::~LwpNoteTextLayout() {}
256 * @descr read note layout object
259 void LwpNoteTextLayout::Read()
261 LwpFrameLayout::Read();
262 m_pObjStrm
->SkipExtra();
266 * @descr Register style, SODC doesn't support text style in note
268 void LwpNoteTextLayout::RegisterStyle()
270 rtl::Reference
<LwpObject
> pContent
= m_Content
.obj();
273 pContent
->SetFoundry(GetFoundry());
274 pContent
->DoRegisterStyle();
278 void LwpNoteTextLayout::XFConvert(XFContentContainer
* pCont
)
280 rtl::Reference
<LwpObject
> pContent
= m_Content
.obj();
283 pContent
->DoXFConvert(pCont
);
287 LwpViewportLayout::LwpViewportLayout(LwpObjectHeader
const& objHdr
, LwpSvStream
* pStrm
)
288 : LwpPlacableLayout(objHdr
, pStrm
)
292 LwpViewportLayout::~LwpViewportLayout() {}
295 * @descr read note layout object
298 void LwpViewportLayout::Read()
300 LwpPlacableLayout::Read();
301 m_pObjStrm
->SkipExtra();
304 void LwpViewportLayout::RegisterStyle() {}
306 void LwpViewportLayout::XFConvert(XFContentContainer
* /*pCont*/) {}
308 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */