Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*************************************************************************
3 : *
4 : * The Contents of this file are made available subject to the terms of
5 : * either of the following licenses
6 : *
7 : * - GNU Lesser General Public License Version 2.1
8 : * - Sun Industry Standards Source License Version 1.1
9 : *
10 : * Sun Microsystems Inc., October, 2000
11 : *
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
16 : *
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.
20 : *
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.
25 : *
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
30 : *
31 : *
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.
38 : *
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.
45 : *
46 : * The Initial Developer of the Original Code is: IBM Corporation
47 : *
48 : * Copyright: 2008 by IBM Corporation
49 : *
50 : * All Rights Reserved.
51 : *
52 : * Contributor(s): _______________________________________
53 : *
54 : *
55 : ************************************************************************/
56 : /**
57 : * @file
58 : * For LWP filter architecture prototype - footnote
59 : */
60 : /*************************************************************************
61 : * Change History
62 : Mar 2005 Created
63 : ************************************************************************/
64 : #include "lwpfribframe.hxx"
65 : #include "xfilter/xfstylemanager.hxx"
66 : #include "lwpglobalmgr.hxx"
67 : #include "xfilter/xfchange.hxx"
68 : /**
69 : * @short: Read frame frib
70 : * @param:
71 : * @param:
72 : */
73 :
74 0 : void LwpFribFrame::Read(LwpObjectStream* pObjStrm, sal_uInt16 /*len*/)
75 : {
76 0 : m_objLayout.ReadIndexed(pObjStrm);
77 0 : }
78 :
79 : /**
80 : * @descr: Get the layout object which the frib points to
81 : *
82 : */
83 0 : LwpObject* LwpFribFrame::GetLayout()
84 : {
85 0 : return m_objLayout.obj();
86 : }
87 :
88 : /**
89 : * @descr: register frame style
90 : * @param: pFoundry - current foundry pointer
91 : *
92 : */
93 0 : void LwpFribFrame::RegisterStyle(LwpFoundry* pFoundry)
94 : {
95 0 : LwpObject *pObject = m_objLayout.obj();
96 :
97 0 : if (pObject && pObject->GetTag() == VO_DROPCAPLAYOUT)
98 : {
99 0 : LwpDropcapLayout *pLayout = dynamic_cast<LwpDropcapLayout*>(pObject);
100 0 : if (!pLayout)
101 0 : return;
102 0 : pLayout->RegisterStyle(pFoundry);
103 : }
104 : else
105 : {
106 : //register frame style
107 0 : LwpPlacableLayout* pLayout = dynamic_cast<LwpPlacableLayout*>(pObject);
108 0 : if (!pLayout)
109 0 : return;
110 0 : pLayout->SetFoundry(pFoundry);
111 0 : pLayout->RegisterStyle();
112 :
113 : //register next frib text style
114 0 : sal_uInt8 nType = pLayout->GetRelativeType();
115 0 : if(LwpLayoutRelativityGuts::LAY_INLINE_NEWLINE == nType
116 0 : && HasNextFrib())
117 : {
118 0 : XFParaStyle* pOldStyle = m_pPara->GetXFParaStyle();
119 0 : if (pOldStyle->GetMasterPage().isEmpty())
120 0 : m_StyleName = pOldStyle->GetStyleName();
121 : else
122 : {
123 0 : XFParaStyle* pParaStyle = new XFParaStyle;
124 0 : *pParaStyle = *(pOldStyle);
125 0 : XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
126 0 : m_StyleName = pXFStyleManager->AddStyle(pParaStyle)->GetStyleName();
127 : }
128 : }
129 : //remember the current paragraph font size which will be used in parsing frame
130 0 : pLayout->SetFont(GetFont());
131 : }
132 : }
133 0 : void LwpFribFrame::SetParaDropcap(LwpPara* pPara)
134 : {
135 0 : LwpObject *pObject = m_objLayout.obj();
136 :
137 0 : if (pObject && pObject->GetTag() == VO_DROPCAPLAYOUT)
138 : {
139 0 : pPara->SetParaDropcap(sal_True);
140 0 : pPara->SetDropcapLayout(dynamic_cast<LwpDropcapLayout*>(pObject));
141 : }
142 : else
143 0 : pPara->SetParaDropcap(sal_False);
144 0 : }
145 :
146 : /**
147 : * @descr: convert frame
148 : *
149 : */
150 0 : void LwpFribFrame::XFConvert(XFContentContainer* pCont)
151 : {
152 0 : XFContentContainer* pXFContentContainer = pCont;
153 0 : LwpVirtualLayout* pLayout = dynamic_cast<LwpVirtualLayout*>(GetLayout());
154 0 : if (!pLayout)
155 0 : return;
156 0 : sal_uInt8 nType = pLayout->GetRelativeType();
157 0 : if( LwpLayoutRelativityGuts::LAY_PARA_RELATIVE == nType)
158 : {
159 0 : LwpVirtualLayout* pContainerLayout = pLayout->GetContainerLayout();
160 0 : if(pContainerLayout && pContainerLayout->IsFrame())
161 : {
162 : //same page as text and in frame
163 0 : pXFContentContainer = m_pPara->GetXFContainer();
164 : }
165 0 : else if(pContainerLayout && pContainerLayout->IsCell())
166 : {
167 : //same page as text and in cell, get the first xfpara
168 0 : XFContentContainer* pXFFirtPara = static_cast<XFContentContainer*>(pCont->FindFirstContent(enumXFContentPara));
169 0 : if(pXFFirtPara)
170 0 : pXFContentContainer = pXFFirtPara;
171 : }
172 : }
173 0 : OUString sChangeID;
174 0 : if(m_bRevisionFlag)
175 : {
176 0 : LwpGlobalMgr* pGlobal = LwpGlobalMgr::GetInstance();
177 0 : LwpChangeMgr* pChangeMgr = pGlobal->GetLwpChangeMgr();
178 0 : sChangeID = pChangeMgr->GetChangeID(this);
179 0 : if (!sChangeID.isEmpty())
180 : {
181 0 : XFChangeStart* pChangeStart = new XFChangeStart;
182 0 : pChangeStart->SetChangeID(sChangeID);
183 0 : pXFContentContainer->Add(pChangeStart);
184 : }
185 : }
186 :
187 0 : pLayout->XFConvert(pXFContentContainer);
188 :
189 0 : if(m_bRevisionFlag)
190 : {
191 0 : if (!sChangeID.isEmpty())
192 : {
193 0 : XFChangeEnd* pChangeEnd = new XFChangeEnd;
194 0 : pChangeEnd->SetChangeID(sChangeID);
195 0 : pXFContentContainer->Add(pChangeEnd);
196 : }
197 : }
198 :
199 0 : if(LwpLayoutRelativityGuts::LAY_INLINE_NEWLINE == nType
200 0 : && HasNextFrib())
201 : {
202 0 : XFParagraph* pXFPara = new XFParagraph();
203 0 : pXFPara->SetStyleName(m_StyleName);
204 0 : m_pPara->AddXFContent(pXFPara);
205 0 : m_pPara->GetFribs()->SetXFPara(pXFPara);
206 0 : }
207 :
208 : }
209 :
210 : /**
211 : * @descr: Read Ruby frame
212 : *
213 : */
214 0 : void LwpFribRubyFrame::Read(LwpObjectStream* pObjStrm, sal_uInt16 /*len*/)
215 : {
216 0 : m_objLayout.ReadIndexed(pObjStrm);
217 0 : }
218 : /**
219 : * @descr: Register Ruby frame style
220 : *
221 : */
222 0 : void LwpFribRubyFrame::RegisterStyle(LwpFoundry* pFoundry)
223 : {
224 0 : LwpRubyLayout* pLayout = GetLayout();
225 0 : if (pLayout)
226 : {
227 0 : pLayout->SetFoundry(pFoundry);
228 0 : pLayout->RegisterStyle();
229 : }
230 0 : }
231 : /**
232 : * @descr: convert Ruby frame
233 : *
234 : */
235 0 : void LwpFribRubyFrame::XFConvert(XFContentContainer* /*pCont*/)
236 : {
237 0 : LwpRubyLayout* pLayout = GetLayout();
238 0 : if (pLayout)
239 : {
240 0 : pLayout->ConvertContentText();
241 : }
242 0 : }
243 :
244 0 : LwpRubyLayout* LwpFribRubyFrame::GetLayout()
245 : {
246 0 : return dynamic_cast<LwpRubyLayout*>(m_objLayout.obj());
247 : }
248 :
249 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|