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
61 #include "lwpfribframe.hxx"
62 #include <xfilter/xfstylemanager.hxx>
63 #include <lwpglobalmgr.hxx>
64 #include <xfilter/xfchange.hxx>
66 * @short: Read frame frib
68 void LwpFribFrame::Read(LwpObjectStream
* pObjStrm
, sal_uInt16
/*len*/)
70 m_objLayout
.ReadIndexed(pObjStrm
);
74 * @descr: Get the layout object which the frib points to
77 rtl::Reference
<LwpObject
> LwpFribFrame::GetLayout() const { return m_objLayout
.obj(); }
80 * @descr: register frame style
81 * @param: pFoundry - current foundry pointer
84 void LwpFribFrame::RegisterStyle(LwpFoundry
* pFoundry
)
86 rtl::Reference
<LwpObject
> pObject
= m_objLayout
.obj();
88 if (pObject
.is() && pObject
->GetTag() == VO_DROPCAPLAYOUT
)
90 LwpDropcapLayout
* pLayout
= dynamic_cast<LwpDropcapLayout
*>(pObject
.get());
93 pLayout
->RegisterStyle(pFoundry
);
97 //register frame style
98 LwpPlacableLayout
* pLayout
= dynamic_cast<LwpPlacableLayout
*>(pObject
.get());
101 pLayout
->SetFoundry(pFoundry
);
102 pLayout
->DoRegisterStyle();
104 //register next frib text style
105 sal_uInt8 nType
= pLayout
->GetRelativeType();
106 if (LwpLayoutRelativityGuts::LAY_INLINE_NEWLINE
== nType
&& HasNextFrib())
108 XFParaStyle
* pOldStyle
= m_pPara
->GetXFParaStyle();
109 if (pOldStyle
->GetMasterPage().isEmpty())
110 m_StyleName
= pOldStyle
->GetStyleName();
113 std::unique_ptr
<XFParaStyle
> pParaStyle(new XFParaStyle
);
114 *pParaStyle
= *pOldStyle
;
115 XFStyleManager
* pXFStyleManager
= LwpGlobalMgr::GetInstance()->GetXFStyleManager();
117 = pXFStyleManager
->AddStyle(std::move(pParaStyle
)).m_pStyle
->GetStyleName();
120 //remember the current paragraph font size which will be used in parsing frame
121 pLayout
->SetFont(GetFont());
124 void LwpFribFrame::SetParaDropcap(LwpPara
* pPara
)
126 rtl::Reference
<LwpObject
> pObject
= m_objLayout
.obj();
128 if (pObject
.is() && pObject
->GetTag() == VO_DROPCAPLAYOUT
)
130 pPara
->SetParaDropcap(true);
131 pPara
->SetDropcapLayout(dynamic_cast<LwpDropcapLayout
*>(pObject
.get()));
134 pPara
->SetParaDropcap(false);
138 * @descr: convert frame
141 void LwpFribFrame::XFConvert(XFContentContainer
* pCont
)
143 XFContentContainer
* pXFContentContainer
= pCont
;
144 LwpVirtualLayout
* pLayout
= dynamic_cast<LwpVirtualLayout
*>(GetLayout().get());
147 sal_uInt8 nType
= pLayout
->GetRelativeType();
148 if (LwpLayoutRelativityGuts::LAY_PARA_RELATIVE
== nType
)
150 rtl::Reference
<LwpVirtualLayout
> xContainerLayout(pLayout
->GetContainerLayout());
151 if (xContainerLayout
.is() && xContainerLayout
->IsFrame())
153 //same page as text and in frame
154 pXFContentContainer
= m_pPara
->GetXFContainer();
156 else if (xContainerLayout
.is() && xContainerLayout
->IsCell())
158 //same page as text and in cell, get the first xfpara
159 rtl::Reference
<XFContent
> first(pCont
->FindFirstContent(enumXFContentPara
));
160 XFContentContainer
* pXFFirtPara
= static_cast<XFContentContainer
*>(first
.get());
162 pXFContentContainer
= pXFFirtPara
;
168 LwpGlobalMgr
* pGlobal
= LwpGlobalMgr::GetInstance();
169 LwpChangeMgr
* pChangeMgr
= pGlobal
->GetLwpChangeMgr();
170 sChangeID
= pChangeMgr
->GetChangeID(this);
171 if (!sChangeID
.isEmpty())
173 rtl::Reference
<XFChangeStart
> xChangeStart(new XFChangeStart
);
174 xChangeStart
->SetChangeID(sChangeID
);
175 pXFContentContainer
->Add(xChangeStart
.get());
179 pLayout
->DoXFConvert(pXFContentContainer
);
183 if (!sChangeID
.isEmpty())
185 rtl::Reference
<XFChangeEnd
> xChangeEnd(new XFChangeEnd
);
186 xChangeEnd
->SetChangeID(sChangeID
);
187 pXFContentContainer
->Add(xChangeEnd
.get());
191 if (LwpLayoutRelativityGuts::LAY_INLINE_NEWLINE
== nType
&& HasNextFrib())
193 rtl::Reference
<XFParagraph
> xXFPara(new XFParagraph
);
194 xXFPara
->SetStyleName(m_StyleName
);
195 m_pPara
->AddXFContent(xXFPara
.get());
196 m_pPara
->GetFribs().SetXFPara(xXFPara
.get());
201 * @descr: Read Ruby frame
204 void LwpFribRubyFrame::Read(LwpObjectStream
* pObjStrm
, sal_uInt16
/*len*/)
206 m_objLayout
.ReadIndexed(pObjStrm
);
209 * @descr: Register Ruby frame style
212 void LwpFribRubyFrame::RegisterStyle(LwpFoundry
* pFoundry
)
214 LwpRubyLayout
* pLayout
= GetLayout();
217 pLayout
->SetFoundry(pFoundry
);
218 pLayout
->RegisterStyle();
222 * @descr: convert Ruby frame
225 void LwpFribRubyFrame::XFConvert()
227 LwpRubyLayout
* pLayout
= GetLayout();
230 pLayout
->ConvertContentText();
234 LwpRubyLayout
* LwpFribRubyFrame::GetLayout()
236 return dynamic_cast<LwpRubyLayout
*>(m_objLayout
.obj().get());
239 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */