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 ************************************************************************/
61 #include "lwpbulletstylemgr.hxx"
63 #include "lwpstory.hxx"
64 #include "lwpdivinfo.hxx"
65 #include "lwppara.hxx"
66 #include "lwpsilverbullet.hxx"
67 #include "lwptools.hxx"
68 #include "lwpparaproperty.hxx"
69 #include "xfilter/xfliststyle.hxx"
70 #include "xfilter/xfstylemanager.hxx"
71 #include "xfilter/xflist.hxx"
72 #include "lwpglobalmgr.hxx"
74 LwpBulletStyleMgr::LwpBulletStyleMgr()
76 , m_pBulletList(nullptr)
78 , m_bIsBulletSkipped(false)
82 LwpBulletStyleMgr::~LwpBulletStyleMgr()
89 m_vIDsPairList
.clear();
90 m_vStyleNameList
.clear();
94 * @short Register bullet style to style-list. The function only register the bullet and single customized numbering
95 * not including the numbering sequence.
96 * @param pPara pointer to the current paragraph which has a bullet/numbering.
97 * @param pBullOver pointer to the bulletoverride of current paragraph.
98 * @param pIndent pointer to the indentoverride of current paragraph.
100 OUString
LwpBulletStyleMgr::RegisterBulletStyle(LwpPara
* pPara
, LwpBulletOverride
* pBullOver
,
101 LwpIndentOverride
* pIndent
)
103 if(!pPara
|| !pIndent
|| !pBullOver
)
108 LwpSilverBullet
* pSilverBullet
= pPara
->GetSilverBullet();
115 LwpPara
* pBulletPara
= pSilverBullet
->GetBulletPara();
122 LwpParaProperty
* pProp
= pPara
->GetProperty(PP_LOCAL_INDENT
);
123 LwpParaIndentProperty
* pIndentProp
= nullptr;
124 LwpObjectID aIndentID
;
127 pIndentProp
= static_cast<LwpParaIndentProperty
*>(pProp
);
128 aIndentID
= pIndentProp
->GetIndentID();
131 LwpObjectID aBulletID
= pBullOver
->GetSilverBullet();
132 std::shared_ptr
<LwpBulletOverride
> pBulletOver(pBullOver
->clone());
134 sal_uInt16 nNameIndex
= 0;
135 std::vector
<OverridePair
>::iterator iter
;
136 for(iter
= m_vIDsPairList
.begin(); iter
!= m_vIDsPairList
.end(); ++iter
)
138 if (iter
->first
->GetSilverBullet() == aBulletID
&& iter
->second
== aIndentID
139 && iter
->first
->IsRightAligned() == pBullOver
->IsRightAligned())
141 return m_vStyleNameList
[nNameIndex
];
149 m_vIDsPairList
.push_back(std::make_pair(pBulletOver
, aIndentID
));
152 LwpFribPtr
& rBulletParaFribs
= pBulletPara
->GetFribs();
153 bool bIsNumbering
= (rBulletParaFribs
.HasFrib(FRIB_TAG_PARANUMBER
) != nullptr);
155 enumXFAlignType eAlign
= enumXFAlignStart
;
156 if (pBullOver
->IsRightAligned())
158 eAlign
= enumXFAlignEnd
;
161 XFListStyle
* pListStyle
= new XFListStyle();
162 XFStyleManager
* pXFStyleMgr
= LwpGlobalMgr::GetInstance()->GetXFStyleManager();
166 for (sal_uInt8 nC
= 1; nC
< 11; nC
++)
168 pListStyle
->SetListBullet(nC
, pSilverBullet
->GetBulletChar(), pSilverBullet
->GetBulletFontName(),
169 LwpSilverBullet::GetPrefix(), LwpSilverBullet::GetSuffix());
171 if (pIndent
->GetMRest() > 0) /* note: used to be 0.001, no idea why */
173 pListStyle
->SetListPosition(nC
, 0.0,
174 LwpTools::ConvertToMetric(LwpTools::ConvertFromUnits(pIndent
->GetMRest())), 0.0, eAlign
);
178 pListStyle
->SetListPosition(nC
, 0.0,
179 0.0, LwpTools::ConvertToMetric(LwpTools::ConvertFromUnits(pIndent
->GetMFirst())), eAlign
);
183 aStyleName
= (pXFStyleMgr
->AddStyle(pListStyle
)).m_pStyle
->GetStyleName();
187 ParaNumbering aParaNumbering
;
188 pBulletPara
->GetParaNumber(1, &aParaNumbering
);
189 LwpFribParaNumber
* pParaNumber
= aParaNumbering
.pParaNumber
;
192 for (sal_uInt8 nPos
= 1; nPos
< 10; nPos
++)
194 if (pParaNumber
->GetStyleID() != NUMCHAR_other
)
198 if (aParaNumbering
.pPrefix
)
200 aPrefix
+= aParaNumbering
.pPrefix
->GetText();
203 OUString aNumber
= LwpSilverBullet::GetNumCharByStyleID(pParaNumber
);
204 if (pParaNumber
->GetStyleID() == NUMCHAR_01
|| pParaNumber
->GetStyleID() == NUMCHAR_Chinese4
)
208 aFmt
.SetPrefix(aPrefix
);
210 aFmt
.SetFormat(aNumber
);
212 if (aParaNumbering
.pSuffix
)
214 aFmt
.SetSuffix(aParaNumbering
.pSuffix
->GetText());
217 //set numbering format into the style-list.
218 pListStyle
->SetListNumber(nPos
, aFmt
, pParaNumber
->GetStart()+1);
223 OUString aPrefix
, aSuffix
;
224 if (aParaNumbering
.pPrefix
)
226 aPrefix
= aParaNumbering
.pPrefix
->GetText();
228 if (aParaNumbering
.pSuffix
)
230 aSuffix
= aParaNumbering
.pSuffix
->GetText();
233 pListStyle
->SetListBullet(nPos
, LwpSilverBullet::GetNumCharByStyleID(pParaNumber
),
234 "Times New Roman", aPrefix
, aSuffix
);
237 pListStyle
->SetListPosition(nPos
, 0.0, 0.635, 0.0);
239 aStyleName
= (pXFStyleMgr
->AddStyle(pListStyle
)).m_pStyle
->GetStyleName();
246 m_vStyleNameList
.push_back(aStyleName
);
251 #include "xfilter/xflistitem.hxx"
252 //Create nested XFList and XFItems and then add it to XFContentContainer(pCont)
253 //Return the inner XFItem created.
254 XFContentContainer
* LwpBulletStyleMgr::AddBulletList(
255 XFContentContainer
* pCont
, bool bIsOrdered
,
256 const OUString
& rStyleName
, sal_Int16 nLevel
, bool bIsBulletSkiped
)
260 m_bIsBulletSkipped
= bIsBulletSkiped
;
262 //todo: need judge here.
263 bool bContinue
= m_bContinue
;
266 XFList
* prevList
= nullptr;
268 XFListItem
* InnerItem
= nullptr;
269 for (sal_Int8 nC
= nLevel
-1; nC
>= 0; nC
--)
271 theList
= new XFList();
272 theItem
= new XFListItem();
273 theList
->Add(theItem
);
277 theList
->SetOrdered(true);
282 theList
->SetOrdered(false);
287 theList
->SetContinueNumber(bContinue
);
289 //Add the outer list to pCont
290 if (nC
== 0 && pCont
)
292 theList
->SetStyleName(rStyleName
);
296 if ((nC
== nLevel
-1) && bIsBulletSkiped
)
298 theItem
->SetIsHeader();
300 theList
->SetContinueNumber(true);
310 theItem
->Add(prevList
);
317 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */