fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / lotuswordpro / source / filter / lwpbulletstylemgr.cxx
blob933f239bd5faf99059248cbd32c9b37834bb98fe
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
59 ************************************************************************/
60 /*************************************************************************
61 * Change History
62 Jan 2005 Created
63 ************************************************************************/
64 #include "lwpbulletstylemgr.hxx"
65 #include "lwpdoc.hxx"
66 #include "lwpstory.hxx"
67 #include "lwpdivinfo.hxx"
68 #include "lwppara.hxx"
69 #include "lwpsilverbullet.hxx"
70 #include "lwptools.hxx"
71 #include "lwpparaproperty.hxx"
72 #include "xfilter/xfliststyle.hxx"
73 #include "xfilter/xfstylemanager.hxx"
74 #include "xfilter/xflist.hxx"
75 #include "lwpglobalmgr.hxx"
77 LwpBulletStyleMgr::LwpBulletStyleMgr()
78 : m_pFoundry(NULL)
79 , m_pBulletList(NULL)
80 , m_bContinue(true)
81 , m_bIsBulletSkipped(false)
82 , m_nCurrentPos(0xFF)
86 LwpBulletStyleMgr::~LwpBulletStyleMgr()
88 if (m_pBulletList)
90 delete m_pBulletList;
93 m_vIDsPairList.clear();
94 m_vStyleNameList.clear();
97 /**
98 * @short Register bullet style to style-list. The function only register the bullet and single customized numbering
99 * not inluding the numbering sequence.
100 * @param pPara pointer to the current paragraph which has a bullet/numbering.
101 * @param pBullOver pointer to the bulletoverride of current paragraph.
102 * @param pIndent pointer to the indentoverride of current paragraph.
104 OUString LwpBulletStyleMgr::RegisterBulletStyle(LwpPara* pPara, LwpBulletOverride* pBullOver,
105 LwpIndentOverride* pIndent)
107 OUString aEmpty;
109 if(!pPara || !pIndent || !pBullOver)
111 return aEmpty;
114 LwpSilverBullet* pSilverBullet = pPara->GetSilverBullet();
115 if (!pSilverBullet)
117 assert(false);
118 return aEmpty;
121 LwpPara* pBulletPara = pSilverBullet->GetBulletPara();
122 if (!pBulletPara)
124 assert(false);
125 return aEmpty;
128 LwpParaProperty* pProp = pPara->GetProperty(PP_LOCAL_INDENT);
129 LwpParaIndentProperty* pIndentProp = NULL;
130 LwpObjectID aIndentID;
131 if (pProp)
133 pIndentProp = static_cast<LwpParaIndentProperty*>(pProp);
134 aIndentID = pIndentProp->GetIndentID();
137 LwpObjectID aBulletID = pBullOver->GetSilverBullet();
138 boost::shared_ptr<LwpBulletOverride> pBulletOver(pBullOver->clone());
140 sal_uInt16 nNameIndex = 0;
141 std::vector <OverridePair>::iterator iter;
142 for(iter = m_vIDsPairList.begin(); iter != m_vIDsPairList.end(); ++iter)
144 if (iter->first->GetSilverBullet() == aBulletID && iter->second == aIndentID
145 && iter->first->IsRightAligned() == pBullOver->IsRightAligned())
147 return m_vStyleNameList[nNameIndex];
149 else
151 nNameIndex++;
155 m_vIDsPairList.push_back(std::make_pair(pBulletOver, aIndentID));
156 OUString aStyleName;
158 LwpFribPtr& rBulletParaFribs = pBulletPara->GetFribs();
159 bool bIsNumbering = (rBulletParaFribs.HasFrib(FRIB_TAG_PARANUMBER) != 0);
161 enumXFAlignType eAlign = enumXFAlignStart;
162 if (pBullOver->IsRightAligned())
164 eAlign = enumXFAlignEnd;
167 XFListStyle* pListStyle = new XFListStyle();
168 XFStyleManager* pXFStyleMgr = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
170 if (!bIsNumbering)
172 for (sal_uInt8 nC = 1; nC < 11; nC++)
174 pListStyle->SetListBullet(nC, pSilverBullet->GetBulletChar(), pSilverBullet->GetBulletFontName(),
175 LwpSilverBullet::GetPrefix(), LwpSilverBullet::GetSuffix());
177 if (pIndent->GetMRest() > 0) /* note: used to be 0.001, no idea why */
179 pListStyle->SetListPosition(nC, 0.0,
180 LwpTools::ConvertToMetric(LwpTools::ConvertFromUnits(pIndent->GetMRest())), 0.0, eAlign);
182 else
184 pListStyle->SetListPosition(nC, 0.0,
185 0.0, LwpTools::ConvertToMetric(LwpTools::ConvertFromUnits(pIndent->GetMFirst())), eAlign);
189 aStyleName = (pXFStyleMgr->AddStyle(pListStyle)).m_pStyle->GetStyleName();
191 else
193 ParaNumbering aParaNumbering;
194 pBulletPara->GetParaNumber(1, &aParaNumbering);
195 LwpFribParaNumber* pParaNumber = aParaNumbering.pParaNumber;
196 if (pParaNumber)
198 for (sal_uInt8 nPos = 1; nPos < 10; nPos++)
200 if (pParaNumber->GetStyleID() != NUMCHAR_other)
202 OUString aPrefix;
203 XFNumFmt aFmt;
204 if (aParaNumbering.pPrefix)
206 aPrefix += aParaNumbering.pPrefix->GetText();
209 OUString aNumber = LwpSilverBullet::GetNumCharByStyleID(pParaNumber);
210 if (pParaNumber->GetStyleID() == NUMCHAR_01 || pParaNumber->GetStyleID() == NUMCHAR_Chinese4)
212 aPrefix += "0";
214 aFmt.SetPrefix(aPrefix);
216 aFmt.SetFormat(aNumber);
218 if (aParaNumbering.pSuffix)
220 aFmt.SetSuffix(aParaNumbering.pSuffix->GetText());
223 //set numbering format into the style-list.
224 pListStyle->SetListNumber(nPos, aFmt, pParaNumber->GetStart()+1);
227 else
229 OUString aPrefix, aSuffix;
230 if (aParaNumbering.pPrefix)
232 aPrefix = aParaNumbering.pPrefix->GetText();
234 if (aParaNumbering.pSuffix)
236 aSuffix = aParaNumbering.pSuffix->GetText();
239 pListStyle->SetListBullet(nPos, LwpSilverBullet::GetNumCharByStyleID(pParaNumber).toChar(),
240 "Times New Roman", aPrefix, aSuffix);
243 pListStyle->SetListPosition(nPos, 0.0, 0.635, 0.0);
245 aStyleName = (pXFStyleMgr->AddStyle(pListStyle)).m_pStyle->GetStyleName();
247 else
248 delete pListStyle;
252 m_vStyleNameList.push_back(aStyleName);
253 return aStyleName;
257 #include "xfilter/xflistitem.hxx"
258 //Create nested XFList and XFItems and then add it to XFContentContainer(pCont)
259 //Return the inner XFItem created.
260 XFContentContainer* LwpBulletStyleMgr::AddBulletList(
261 XFContentContainer* pCont, bool bIsOrdered,
262 const OUString& rStyleName, sal_Int16 nLevel, bool bIsBulletSkiped)
264 assert(nLevel>0);
266 m_bIsBulletSkipped = bIsBulletSkiped;
268 //todo: need judge here.
269 bool bContinue = m_bContinue;
271 XFList* theList;
272 XFList* prevList = NULL;
273 XFListItem* theItem;
274 XFListItem* InnerItem = NULL;
275 for (sal_Int8 nC = nLevel-1; nC >= 0; nC--)
277 theList = new XFList();
278 theItem = new XFListItem();
279 theList->Add(theItem);
281 if (bIsOrdered)
283 theList->SetOrdered(true);
285 else
287 bContinue = false;
288 theList->SetOrdered(false);
291 if (nC == nLevel-1)
293 theList->SetContinueNumber(bContinue);
295 //Add the outer list to pCont
296 if (nC == 0)
298 theList->SetStyleName(rStyleName);
299 pCont->Add(theList);
302 if ((nC == nLevel-1) && bIsBulletSkiped)
304 theItem->SetIsHeader(true);
306 theList->SetContinueNumber(true);
307 // end of add
310 if(nC == nLevel-1)
312 InnerItem = theItem;
315 if(prevList)
317 theItem->Add(prevList);
319 prevList = theList;
321 return InnerItem;
324 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */