tdf#137105: crash in table with Style Inspector active
[LibreOffice.git] / lotuswordpro / source / filter / lwpfribframe.cxx
blob8a94efb8cbdade80a3d28370df9bbf47bfccc182
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 - footnote
61 #include "lwpfribframe.hxx"
62 #include <xfilter/xfstylemanager.hxx>
63 #include <lwpglobalmgr.hxx>
64 #include <xfilter/xfchange.hxx>
65 /**
66 * @short: Read frame frib
68 void LwpFribFrame::Read(LwpObjectStream* pObjStrm, sal_uInt16 /*len*/)
70 m_objLayout.ReadIndexed(pObjStrm);
73 /**
74 * @descr: Get the layout object which the frib points to
77 rtl::Reference<LwpObject> LwpFribFrame::GetLayout() const
79 return m_objLayout.obj();
82 /**
83 * @descr: register frame style
84 * @param: pFoundry - current foundry pointer
87 void LwpFribFrame::RegisterStyle(LwpFoundry* pFoundry)
89 rtl::Reference<LwpObject> pObject = m_objLayout.obj();
91 if (pObject.is() && pObject->GetTag() == VO_DROPCAPLAYOUT)
93 LwpDropcapLayout *pLayout = dynamic_cast<LwpDropcapLayout*>(pObject.get());
94 if (!pLayout)
95 return;
96 pLayout->RegisterStyle(pFoundry);
98 else
100 //register frame style
101 LwpPlacableLayout* pLayout = dynamic_cast<LwpPlacableLayout*>(pObject.get());
102 if (!pLayout)
103 return;
104 pLayout->SetFoundry(pFoundry);
105 pLayout->DoRegisterStyle();
107 //register next frib text style
108 sal_uInt8 nType = pLayout->GetRelativeType();
109 if(LwpLayoutRelativityGuts::LAY_INLINE_NEWLINE == nType
110 && HasNextFrib())
112 XFParaStyle* pOldStyle = m_pPara->GetXFParaStyle();
113 if (pOldStyle->GetMasterPage().isEmpty())
114 m_StyleName = pOldStyle->GetStyleName();
115 else
117 std::unique_ptr<XFParaStyle> pParaStyle(new XFParaStyle);
118 *pParaStyle = *pOldStyle;
119 XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
120 m_StyleName = pXFStyleManager->AddStyle(std::move(pParaStyle)).m_pStyle->GetStyleName();
123 //remember the current paragraph font size which will be used in parsing frame
124 pLayout->SetFont(GetFont());
127 void LwpFribFrame::SetParaDropcap(LwpPara* pPara)
129 rtl::Reference<LwpObject> pObject = m_objLayout.obj();
131 if (pObject.is() && pObject->GetTag() == VO_DROPCAPLAYOUT)
133 pPara->SetParaDropcap(true);
134 pPara->SetDropcapLayout(dynamic_cast<LwpDropcapLayout*>(pObject.get()));
136 else
137 pPara->SetParaDropcap(false);
141 * @descr: convert frame
144 void LwpFribFrame::XFConvert(XFContentContainer* pCont)
146 XFContentContainer* pXFContentContainer = pCont;
147 LwpVirtualLayout* pLayout = dynamic_cast<LwpVirtualLayout*>(GetLayout().get());
148 if (!pLayout)
149 return;
150 sal_uInt8 nType = pLayout->GetRelativeType();
151 if( LwpLayoutRelativityGuts::LAY_PARA_RELATIVE == nType)
153 rtl::Reference<LwpVirtualLayout> xContainerLayout(pLayout->GetContainerLayout());
154 if (xContainerLayout.is() && xContainerLayout->IsFrame())
156 //same page as text and in frame
157 pXFContentContainer = m_pPara->GetXFContainer();
159 else if (xContainerLayout.is() && xContainerLayout->IsCell())
161 //same page as text and in cell, get the first xfpara
162 rtl::Reference<XFContent> first(
163 pCont->FindFirstContent(enumXFContentPara));
164 XFContentContainer* pXFFirtPara = static_cast<XFContentContainer*>(first.get());
165 if(pXFFirtPara)
166 pXFContentContainer = pXFFirtPara;
169 OUString sChangeID;
170 if(m_bRevisionFlag)
172 LwpGlobalMgr* pGlobal = LwpGlobalMgr::GetInstance();
173 LwpChangeMgr* pChangeMgr = pGlobal->GetLwpChangeMgr();
174 sChangeID = pChangeMgr->GetChangeID(this);
175 if (!sChangeID.isEmpty())
177 XFChangeStart* pChangeStart = new XFChangeStart;
178 pChangeStart->SetChangeID(sChangeID);
179 pXFContentContainer->Add(pChangeStart);
183 pLayout->DoXFConvert(pXFContentContainer);
185 if(m_bRevisionFlag)
187 if (!sChangeID.isEmpty())
189 XFChangeEnd* pChangeEnd = new XFChangeEnd;
190 pChangeEnd->SetChangeID(sChangeID);
191 pXFContentContainer->Add(pChangeEnd);
195 if(LwpLayoutRelativityGuts::LAY_INLINE_NEWLINE == nType
196 && HasNextFrib())
198 XFParagraph* pXFPara = new XFParagraph();
199 pXFPara->SetStyleName(m_StyleName);
200 m_pPara->AddXFContent(pXFPara);
201 m_pPara->GetFribs().SetXFPara(pXFPara);
207 * @descr: Read Ruby frame
210 void LwpFribRubyFrame::Read(LwpObjectStream* pObjStrm, sal_uInt16 /*len*/)
212 m_objLayout.ReadIndexed(pObjStrm);
215 * @descr: Register Ruby frame style
218 void LwpFribRubyFrame::RegisterStyle(LwpFoundry* pFoundry)
220 LwpRubyLayout* pLayout = GetLayout();
221 if (pLayout)
223 pLayout->SetFoundry(pFoundry);
224 pLayout->RegisterStyle();
228 * @descr: convert Ruby frame
231 void LwpFribRubyFrame::XFConvert()
233 LwpRubyLayout* pLayout = GetLayout();
234 if (pLayout)
236 pLayout->ConvertContentText();
240 LwpRubyLayout* LwpFribRubyFrame::GetLayout()
242 return dynamic_cast<LwpRubyLayout*>(m_objLayout.obj().get());
245 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */