fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / lotuswordpro / source / filter / lwpnotes.cxx
blob02a4de55b9f5d5dff8a8661fbfbd05fb9a7fe16f
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,
29 * MA 02111-1307 USA
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 ************************************************************************/
56 /**
57 * @file
58 * For LWP filter architecture prototype - notes
60 /*************************************************************************
61 * Change History
62 May 2005 Created
63 ************************************************************************/
64 #include "lwpnotes.hxx"
65 #include "lwppara.hxx"
66 #include "xfilter/xfannotation.hxx"
67 #include "xfilter/xftextspan.hxx"
68 #include "localtime.hxx"
69 #include "lwptools.hxx"
71 LwpFribNote::LwpFribNote(LwpPara* pPara ):LwpFrib(pPara)
75 /**
76 * @descr read frib information
78 void LwpFribNote::Read(LwpObjectStream *pObjStrm, sal_uInt16 /*len*/)
80 m_Layout.ReadIndexed(pObjStrm);
83 /**
84 * @descr Register style
86 void LwpFribNote::RegisterNewStyle()
88 rtl::Reference<LwpObject> pLayout = m_Layout.obj();
89 if(pLayout.is())
91 //register font style
92 LwpFrib::RegisterStyle(m_pPara->GetFoundry());
93 //register foonote style
94 pLayout->SetFoundry(m_pPara->GetFoundry());
95 pLayout->RegisterStyle();
99 /**
100 * @descr convert note
102 void LwpFribNote::XFConvert(XFContentContainer* pCont)
104 LwpNoteLayout* pLayout =static_cast<LwpNoteLayout*>(m_Layout.obj().get());
105 if(pLayout)
107 XFAnnotation* pXFNote = new XFAnnotation;
108 pXFNote->SetAuthor(pLayout->GetAuthor());
109 LtTm aTm;
110 long nTime = pLayout->GetTime();
111 if(LtgLocalTime(nTime, aTm))
113 pXFNote->SetDate(LwpTools::DateTimeToOUString(aTm));
116 pLayout->XFConvert(pXFNote);
117 if(m_pModifiers)
119 XFTextSpan *pSpan = new XFTextSpan();
120 pSpan->SetStyleName(GetStyleName());
121 pSpan->Add(pXFNote);
122 pCont->Add(pSpan);
124 else
126 pCont->Add(pXFNote);
132 LwpNoteLayout::LwpNoteLayout(LwpObjectHeader &objHdr, LwpSvStream* pStrm)
133 : LwpFrameLayout(objHdr, pStrm)
134 , m_nTime(0)
138 LwpNoteLayout::~LwpNoteLayout()
144 * @descr read note layout object
147 void LwpNoteLayout::Read()
149 LwpFrameLayout::Read();
151 m_nTime = m_pObjStrm->QuickReaduInt32();
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() != " ")
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().get());
221 if(pStory)
223 LwpPara* pFirst = static_cast<LwpPara*>(pStory->GetFirstPara().obj().get());
224 if(pFirst)
225 return pFirst->GetContentText(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 rtl::Reference<LwpObject> pContent = m_Content.obj();
284 if(pContent.is())
286 pContent->SetFoundry(GetFoundry());
287 pContent->RegisterStyle();
291 void LwpNoteTextLayout::XFConvert(XFContentContainer * pCont)
293 rtl::Reference<LwpObject> pContent = m_Content.obj();
294 if(pContent.is())
296 pContent->XFConvert(pCont);
300 LwpViewportLayout::LwpViewportLayout(LwpObjectHeader &objHdr, LwpSvStream* pStrm)
301 : LwpPlacableLayout(objHdr, pStrm)
305 LwpViewportLayout::~LwpViewportLayout()
310 * @descr read note layout object
313 void LwpViewportLayout::Read()
315 LwpPlacableLayout::Read();
316 m_pObjStrm->SkipExtra();
319 void LwpViewportLayout::RegisterStyle()
323 void LwpViewportLayout::XFConvert(XFContentContainer * /*pCont*/)
327 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */