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 ************************************************************************/
56 /*************************************************************************
58 * For LWP filter architecture prototype
59 ************************************************************************/
60 /*************************************************************************
63 ************************************************************************/
64 #include "lwpbulletstylemgr.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()
81 , m_bIsBulletSkipped(false)
86 LwpBulletStyleMgr::~LwpBulletStyleMgr()
93 m_vIDsPairList
.clear();
94 m_vStyleNameList
.clear();
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
)
109 if(!pPara
|| !pIndent
|| !pBullOver
)
114 LwpSilverBullet
* pSilverBullet
= pPara
->GetSilverBullet();
121 LwpPara
* pBulletPara
= pSilverBullet
->GetBulletPara();
128 LwpParaProperty
* pProp
= pPara
->GetProperty(PP_LOCAL_INDENT
);
129 LwpParaIndentProperty
* pIndentProp
= NULL
;
130 LwpObjectID aIndentID
;
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
];
155 m_vIDsPairList
.push_back(std::make_pair(pBulletOver
, aIndentID
));
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();
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
);
184 pListStyle
->SetListPosition(nC
, 0.0,
185 0.0, LwpTools::ConvertToMetric(LwpTools::ConvertFromUnits(pIndent
->GetMFirst())), eAlign
);
189 aStyleName
= (pXFStyleMgr
->AddStyle(pListStyle
)).m_pStyle
->GetStyleName();
193 ParaNumbering aParaNumbering
;
194 pBulletPara
->GetParaNumber(1, &aParaNumbering
);
195 LwpFribParaNumber
* pParaNumber
= aParaNumbering
.pParaNumber
;
198 for (sal_uInt8 nPos
= 1; nPos
< 10; nPos
++)
200 if (pParaNumber
->GetStyleID() != NUMCHAR_other
)
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
)
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);
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();
252 m_vStyleNameList
.push_back(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
)
266 m_bIsBulletSkipped
= bIsBulletSkiped
;
268 //todo: need judge here.
269 bool bContinue
= m_bContinue
;
272 XFList
* prevList
= NULL
;
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
);
283 theList
->SetOrdered(true);
288 theList
->SetOrdered(false);
293 theList
->SetContinueNumber(bContinue
);
295 //Add the outer list to pCont
298 theList
->SetStyleName(rStyleName
);
302 if ((nC
== nLevel
-1) && bIsBulletSkiped
)
304 theItem
->SetIsHeader(true);
306 theList
->SetContinueNumber(true);
317 theItem
->Add(prevList
);
324 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */