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 - footnote
60 /*************************************************************************
63 ************************************************************************/
64 #include "lwpfribframe.hxx"
65 #include "xfilter/xfstylemanager.hxx"
66 #include "lwpglobalmgr.hxx"
67 #include "xfilter/xfchange.hxx"
69 * @short: Read frame frib
74 void LwpFribFrame::Read(LwpObjectStream
* pObjStrm
, sal_uInt16
/*len*/)
76 m_objLayout
.ReadIndexed(pObjStrm
);
80 * @descr: Get the layout object which the frib points to
83 LwpObject
* LwpFribFrame::GetLayout()
85 return m_objLayout
.obj();
89 * @descr: register frame style
90 * @param: pFoundry - current foundry pointer
93 void LwpFribFrame::RegisterStyle(LwpFoundry
* pFoundry
)
95 LwpObject
*pObject
= m_objLayout
.obj();
97 if (pObject
&& pObject
->GetTag() == VO_DROPCAPLAYOUT
)
99 LwpDropcapLayout
*pLayout
= dynamic_cast<LwpDropcapLayout
*>(pObject
);
102 pLayout
->RegisterStyle(pFoundry
);
106 //register frame style
107 LwpPlacableLayout
* pLayout
= dynamic_cast<LwpPlacableLayout
*>(pObject
);
110 pLayout
->SetFoundry(pFoundry
);
111 pLayout
->RegisterStyle();
113 //register next frib text style
114 sal_uInt8 nType
= pLayout
->GetRelativeType();
115 if(LwpLayoutRelativityGuts::LAY_INLINE_NEWLINE
== nType
118 XFParaStyle
* pOldStyle
= m_pPara
->GetXFParaStyle();
119 if (pOldStyle
->GetMasterPage().isEmpty())
120 m_StyleName
= pOldStyle
->GetStyleName();
123 XFParaStyle
* pParaStyle
= new XFParaStyle
;
124 *pParaStyle
= *(pOldStyle
);
125 XFStyleManager
* pXFStyleManager
= LwpGlobalMgr::GetInstance()->GetXFStyleManager();
126 m_StyleName
= pXFStyleManager
->AddStyle(pParaStyle
)->GetStyleName();
129 //remember the current paragraph font size which will be used in parsing frame
130 pLayout
->SetFont(GetFont());
133 void LwpFribFrame::SetParaDropcap(LwpPara
* pPara
)
135 LwpObject
*pObject
= m_objLayout
.obj();
137 if (pObject
&& pObject
->GetTag() == VO_DROPCAPLAYOUT
)
139 pPara
->SetParaDropcap(true);
140 pPara
->SetDropcapLayout(dynamic_cast<LwpDropcapLayout
*>(pObject
));
143 pPara
->SetParaDropcap(false);
147 * @descr: convert frame
150 void LwpFribFrame::XFConvert(XFContentContainer
* pCont
)
152 XFContentContainer
* pXFContentContainer
= pCont
;
153 LwpVirtualLayout
* pLayout
= dynamic_cast<LwpVirtualLayout
*>(GetLayout());
156 sal_uInt8 nType
= pLayout
->GetRelativeType();
157 if( LwpLayoutRelativityGuts::LAY_PARA_RELATIVE
== nType
)
159 LwpVirtualLayout
* pContainerLayout
= pLayout
->GetContainerLayout();
160 if(pContainerLayout
&& pContainerLayout
->IsFrame())
162 //same page as text and in frame
163 pXFContentContainer
= m_pPara
->GetXFContainer();
165 else if(pContainerLayout
&& pContainerLayout
->IsCell())
167 //same page as text and in cell, get the first xfpara
168 XFContentContainer
* pXFFirtPara
= static_cast<XFContentContainer
*>(pCont
->FindFirstContent(enumXFContentPara
));
170 pXFContentContainer
= pXFFirtPara
;
176 LwpGlobalMgr
* pGlobal
= LwpGlobalMgr::GetInstance();
177 LwpChangeMgr
* pChangeMgr
= pGlobal
->GetLwpChangeMgr();
178 sChangeID
= pChangeMgr
->GetChangeID(this);
179 if (!sChangeID
.isEmpty())
181 XFChangeStart
* pChangeStart
= new XFChangeStart
;
182 pChangeStart
->SetChangeID(sChangeID
);
183 pXFContentContainer
->Add(pChangeStart
);
187 pLayout
->XFConvert(pXFContentContainer
);
191 if (!sChangeID
.isEmpty())
193 XFChangeEnd
* pChangeEnd
= new XFChangeEnd
;
194 pChangeEnd
->SetChangeID(sChangeID
);
195 pXFContentContainer
->Add(pChangeEnd
);
199 if(LwpLayoutRelativityGuts::LAY_INLINE_NEWLINE
== nType
202 XFParagraph
* pXFPara
= new XFParagraph();
203 pXFPara
->SetStyleName(m_StyleName
);
204 m_pPara
->AddXFContent(pXFPara
);
205 m_pPara
->GetFribs()->SetXFPara(pXFPara
);
211 * @descr: Read Ruby frame
214 void LwpFribRubyFrame::Read(LwpObjectStream
* pObjStrm
, sal_uInt16
/*len*/)
216 m_objLayout
.ReadIndexed(pObjStrm
);
219 * @descr: Register Ruby frame style
222 void LwpFribRubyFrame::RegisterStyle(LwpFoundry
* pFoundry
)
224 LwpRubyLayout
* pLayout
= GetLayout();
227 pLayout
->SetFoundry(pFoundry
);
228 pLayout
->RegisterStyle();
232 * @descr: convert Ruby frame
235 void LwpFribRubyFrame::XFConvert(XFContentContainer
* /*pCont*/)
237 LwpRubyLayout
* pLayout
= GetLayout();
240 pLayout
->ConvertContentText();
244 LwpRubyLayout
* LwpFribRubyFrame::GetLayout()
246 return dynamic_cast<LwpRubyLayout
*>(m_objLayout
.obj());
249 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */