1efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3efeef26fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4efeef26fSAndrew Rist * or more contributor license agreements. See the NOTICE file
5efeef26fSAndrew Rist * distributed with this work for additional information
6efeef26fSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7efeef26fSAndrew Rist * to you under the Apache License, Version 2.0 (the
8efeef26fSAndrew Rist * "License"); you may not use this file except in compliance
9efeef26fSAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13efeef26fSAndrew Rist * Unless required by applicable law or agreed to in writing,
14efeef26fSAndrew Rist * software distributed under the License is distributed on an
15efeef26fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16efeef26fSAndrew Rist * KIND, either express or implied. See the License for the
17efeef26fSAndrew Rist * specific language governing permissions and limitations
18efeef26fSAndrew Rist * under the License.
19cdf0e10cSrcweir *
20efeef26fSAndrew Rist *************************************************************/
21efeef26fSAndrew Rist
22efeef26fSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir
28cdf0e10cSrcweir #include <hintids.hxx>
29cdf0e10cSrcweir #ifndef _MSGBOX_HXX //autogen
30cdf0e10cSrcweir #include <vcl/msgbox.hxx>
31cdf0e10cSrcweir #endif
32cdf0e10cSrcweir #include <sfx2/request.hxx>
33cdf0e10cSrcweir #include <svl/eitem.hxx>
34cdf0e10cSrcweir #include <svl/stritem.hxx>
35cdf0e10cSrcweir #include <editeng/numitem.hxx>
36cdf0e10cSrcweir #include <editeng/brshitem.hxx>
37cdf0e10cSrcweir #include <numrule.hxx>
38cdf0e10cSrcweir
39cdf0e10cSrcweir #include "cmdid.h"
40cdf0e10cSrcweir #include "wrtsh.hxx"
41cdf0e10cSrcweir #include "view.hxx"
42cdf0e10cSrcweir #include "viewopt.hxx"
43cdf0e10cSrcweir #include "wdocsh.hxx"
44cdf0e10cSrcweir #include "textsh.hxx"
45cdf0e10cSrcweir #include "uiitems.hxx"
46cdf0e10cSrcweir #include "swabstdlg.hxx"
47cdf0e10cSrcweir #include <globals.hrc>
48cdf0e10cSrcweir #include <sfx2/tabdlg.hxx>
49766ce4d0SZheng Fan #include <svx/nbdtmg.hxx>
50766ce4d0SZheng Fan #include <svx/nbdtmgfact.hxx>
511ff378efSZheng Fan #include <sfx2/viewfrm.hxx>
521ff378efSZheng Fan #include <sfx2/bindings.hxx>
53766ce4d0SZheng Fan using namespace svx::sidebar;
54cdf0e10cSrcweir
ExecEnterNum(SfxRequest & rReq)55cdf0e10cSrcweir void SwTextShell::ExecEnterNum(SfxRequest &rReq)
56cdf0e10cSrcweir {
57cdf0e10cSrcweir //wg. Aufzeichnung schon vor dem evtl. Shellwechsel
58cdf0e10cSrcweir switch(rReq.GetSlot())
59cdf0e10cSrcweir {
60cdf0e10cSrcweir case FN_NUM_NUMBERING_ON:
61cdf0e10cSrcweir {
621ff378efSZheng Fan GetShell().StartAllAction();
63cdf0e10cSrcweir SFX_REQUEST_ARG( rReq, pItem, SfxBoolItem, FN_PARAM_1 , sal_False );
641ff378efSZheng Fan sal_Bool bMode = !GetShell().SelectionHasNumber(); // #i29560#
65cdf0e10cSrcweir if ( pItem )
66cdf0e10cSrcweir bMode = pItem->GetValue();
67cdf0e10cSrcweir else
68cdf0e10cSrcweir rReq.AppendItem( SfxBoolItem( FN_PARAM_1, bMode ) );
69cdf0e10cSrcweir
701ff378efSZheng Fan if ( bMode != (GetShell().SelectionHasNumber()) ) // #i29560#
71cdf0e10cSrcweir {
72cdf0e10cSrcweir rReq.Done();
73cdf0e10cSrcweir if( bMode )
74cdf0e10cSrcweir GetShell().NumOn();
75cdf0e10cSrcweir else
76cdf0e10cSrcweir GetShell().NumOrBulletOff(); // #i29560#
77cdf0e10cSrcweir }
781ff378efSZheng Fan sal_Bool bNewResult = GetShell().SelectionHasNumber();
791ff378efSZheng Fan if (bNewResult!=bMode) {
801ff378efSZheng Fan SfxBindings& rBindings = GetView().GetViewFrame()->GetBindings();
811ff378efSZheng Fan SfxBoolItem aItem(FN_NUM_NUMBERING_ON,!bNewResult);
821ff378efSZheng Fan rBindings.SetState(aItem);
831ff378efSZheng Fan SfxBoolItem aNewItem(FN_NUM_NUMBERING_ON,bNewResult);
841ff378efSZheng Fan rBindings.SetState(aNewItem);
851ff378efSZheng Fan }
861ff378efSZheng Fan GetShell().EndAllAction();
87cdf0e10cSrcweir }
88cdf0e10cSrcweir break;
89cdf0e10cSrcweir case FN_NUM_BULLET_ON:
90cdf0e10cSrcweir {
911ff378efSZheng Fan GetShell().StartAllAction();
92cdf0e10cSrcweir SFX_REQUEST_ARG( rReq, pItem, SfxBoolItem, FN_PARAM_1 , sal_False );
931ff378efSZheng Fan sal_Bool bMode = !GetShell().SelectionHasBullet(); // #i29560#
94cdf0e10cSrcweir if ( pItem )
95cdf0e10cSrcweir bMode = pItem->GetValue();
96cdf0e10cSrcweir else
97cdf0e10cSrcweir rReq.AppendItem( SfxBoolItem( FN_PARAM_1, bMode ) );
98cdf0e10cSrcweir
991ff378efSZheng Fan if ( bMode != (GetShell().SelectionHasBullet()) ) // #i29560#
100cdf0e10cSrcweir {
101cdf0e10cSrcweir rReq.Done();
102cdf0e10cSrcweir if( bMode )
103cdf0e10cSrcweir GetShell().BulletOn();
104cdf0e10cSrcweir else
105cdf0e10cSrcweir GetShell().NumOrBulletOff(); // #i29560#
106cdf0e10cSrcweir }
1071ff378efSZheng Fan sal_Bool bNewResult = GetShell().SelectionHasBullet();
1081ff378efSZheng Fan if (bNewResult!=bMode) {
1091ff378efSZheng Fan SfxBindings& rBindings = GetView().GetViewFrame()->GetBindings();
1101ff378efSZheng Fan SfxBoolItem aItem(FN_NUM_BULLET_ON,!bNewResult);
1111ff378efSZheng Fan rBindings.SetState(aItem);
1121ff378efSZheng Fan SfxBoolItem aNewItem(FN_NUM_BULLET_ON,bNewResult);
1131ff378efSZheng Fan rBindings.SetState(aNewItem);
1141ff378efSZheng Fan }
1151ff378efSZheng Fan GetShell().EndAllAction();
116cdf0e10cSrcweir }
117cdf0e10cSrcweir break;
118cdf0e10cSrcweir case FN_NUMBER_BULLETS:
119766ce4d0SZheng Fan case SID_OUTLINE_BULLET:
120cdf0e10cSrcweir {
121cdf0e10cSrcweir // --> OD 2008-02-29 #refactorlists#
122cdf0e10cSrcweir // // per default sal_True, damit die Schleife im Dialog richtig arbeitet!
123cdf0e10cSrcweir // sal_Bool bHasChild = sal_True;
124cdf0e10cSrcweir // <--
125cdf0e10cSrcweir SfxItemSet aSet(GetPool(),
126cdf0e10cSrcweir SID_HTML_MODE, SID_HTML_MODE,
127cdf0e10cSrcweir SID_ATTR_NUMBERING_RULE, SID_PARAM_CUR_NUM_LEVEL,
128cdf0e10cSrcweir 0 );
129cdf0e10cSrcweir SwDocShell* pDocSh = GetView().GetDocShell();
130cdf0e10cSrcweir sal_Bool bHtml = 0 != PTR_CAST(SwWebDocShell, pDocSh);
131cdf0e10cSrcweir const SwNumRule* pCurRule = GetShell().GetCurNumRule();
132cdf0e10cSrcweir if( pCurRule )
133cdf0e10cSrcweir {
134cdf0e10cSrcweir SvxNumRule aRule = pCurRule->MakeSvxNumRule();
135cdf0e10cSrcweir
136cdf0e10cSrcweir //convert type of linked bitmaps from SVX_NUM_BITMAP to (SVX_NUM_BITMAP|LINK_TOKEN)
137cdf0e10cSrcweir for(sal_uInt16 i = 0; i < aRule.GetLevelCount(); i++)
138cdf0e10cSrcweir {
139cdf0e10cSrcweir SvxNumberFormat aFmt(aRule.GetLevel(i));
140cdf0e10cSrcweir if(SVX_NUM_BITMAP == aFmt.GetNumberingType())
141cdf0e10cSrcweir {
142cdf0e10cSrcweir const SvxBrushItem* pBrush = aFmt.GetBrush();
143cdf0e10cSrcweir const String* pLinkStr;
144cdf0e10cSrcweir if(pBrush &&
145cdf0e10cSrcweir 0 != (pLinkStr = pBrush->GetGraphicLink()) &&
146cdf0e10cSrcweir pLinkStr->Len())
147cdf0e10cSrcweir aFmt.SetNumberingType(SvxExtNumType(SVX_NUM_BITMAP|LINK_TOKEN));
148cdf0e10cSrcweir aRule.SetLevel(i, aFmt, aRule.Get(i) != 0);
149cdf0e10cSrcweir }
150cdf0e10cSrcweir }
151cdf0e10cSrcweir if(bHtml)
152cdf0e10cSrcweir aRule.SetFeatureFlag(NUM_ENABLE_EMBEDDED_BMP, sal_False);
153cdf0e10cSrcweir
154cdf0e10cSrcweir aSet.Put(SvxNumBulletItem(aRule));
155cdf0e10cSrcweir // --> OD 2008-02-29 #refactorlists# - removed <bHasChild>
156cdf0e10cSrcweir ASSERT( GetShell().GetNumLevel() < MAXLEVEL,
157cdf0e10cSrcweir "<SwTextShell::ExecEnterNum()> - numbered node without valid list level. Serious defect -> please inform OD." );
158cdf0e10cSrcweir sal_uInt16 nLevel = GetShell().GetNumLevel();
159cdf0e10cSrcweir // <--
160cdf0e10cSrcweir if( nLevel < MAXLEVEL )
161cdf0e10cSrcweir {
162cdf0e10cSrcweir nLevel = 1<<nLevel;
163cdf0e10cSrcweir aSet.Put( SfxUInt16Item( SID_PARAM_CUR_NUM_LEVEL, nLevel ));
164cdf0e10cSrcweir }
165cdf0e10cSrcweir }
166cdf0e10cSrcweir else
167cdf0e10cSrcweir {
168cdf0e10cSrcweir // --> OD 2008-02-11 #newlistlevelattrs#
169cdf0e10cSrcweir SwNumRule aRule( GetShell().GetUniqueNumRuleName(),
170cdf0e10cSrcweir // --> OD 2008-06-06 #i89178#
171cdf0e10cSrcweir numfunc::GetDefaultPositionAndSpaceMode() );
172cdf0e10cSrcweir // <--
173cdf0e10cSrcweir // <--
174cdf0e10cSrcweir SvxNumRule aSvxRule = aRule.MakeSvxNumRule();
175cdf0e10cSrcweir const bool bRightToLeft = GetShell().IsInRightToLeftText( 0 );
176cdf0e10cSrcweir
177cdf0e10cSrcweir if( bHtml || bRightToLeft )
178cdf0e10cSrcweir {
179cdf0e10cSrcweir for( sal_uInt8 n = 0; n < MAXLEVEL; ++n )
180cdf0e10cSrcweir {
181cdf0e10cSrcweir SvxNumberFormat aFmt( aSvxRule.GetLevel( n ) );
182cdf0e10cSrcweir if ( n && bHtml )
183cdf0e10cSrcweir {
184cdf0e10cSrcweir // 1/2" fuer HTML
185cdf0e10cSrcweir aFmt.SetLSpace(720);
186cdf0e10cSrcweir aFmt.SetAbsLSpace(n * 720);
187cdf0e10cSrcweir }
188cdf0e10cSrcweir // --> FME 2005-01-21 #i38904# Default alignment for
189cdf0e10cSrcweir // numbering/bullet should be rtl in rtl paragraph:
190cdf0e10cSrcweir if ( bRightToLeft )
191cdf0e10cSrcweir {
192cdf0e10cSrcweir aFmt.SetNumAdjust( SVX_ADJUST_RIGHT );
193cdf0e10cSrcweir }
194cdf0e10cSrcweir // <--
195cdf0e10cSrcweir aSvxRule.SetLevel( n, aFmt, sal_False );
196cdf0e10cSrcweir }
197cdf0e10cSrcweir aSvxRule.SetFeatureFlag(NUM_ENABLE_EMBEDDED_BMP, sal_False);
198cdf0e10cSrcweir }
199cdf0e10cSrcweir aSet.Put(SvxNumBulletItem(aSvxRule));
200cdf0e10cSrcweir }
201cdf0e10cSrcweir
202cdf0e10cSrcweir aSet.Put( SfxBoolItem( SID_PARAM_NUM_PRESET,sal_False ));
203cdf0e10cSrcweir
204cdf0e10cSrcweir // vor dem Dialog wird der HtmlMode an der DocShell versenkt
205cdf0e10cSrcweir pDocSh->PutItem(SfxUInt16Item(SID_HTML_MODE, ::GetHtmlMode(pDocSh)));
206cdf0e10cSrcweir
207cdf0e10cSrcweir SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
208cdf0e10cSrcweir DBG_ASSERT(pFact, "Dialogdiet fail!");
209cdf0e10cSrcweir SfxAbstractTabDialog* pDlg = pFact->CreateSwTabDialog( DLG_SVXTEST_NUM_BULLET,
210cdf0e10cSrcweir GetView().GetWindow(), &aSet, GetShell());
211cdf0e10cSrcweir DBG_ASSERT(pDlg, "Dialogdiet fail!");
212cdf0e10cSrcweir sal_uInt16 nRet = pDlg->Execute();
213cdf0e10cSrcweir const SfxPoolItem* pItem;
214cdf0e10cSrcweir if( RET_OK == nRet )
215cdf0e10cSrcweir {
216cdf0e10cSrcweir if( SFX_ITEM_SET == pDlg->GetOutputItemSet()->GetItemState( SID_ATTR_NUMBERING_RULE, sal_False, &pItem ))
217cdf0e10cSrcweir {
218cdf0e10cSrcweir rReq.AppendItem(*pItem);
219cdf0e10cSrcweir rReq.Done();
220cdf0e10cSrcweir SvxNumRule* pSetRule = ((SvxNumBulletItem*)pItem)->GetNumRule();
221cdf0e10cSrcweir pSetRule->UnLinkGraphics();
222cdf0e10cSrcweir // --> OD 2008-02-11 #newlistlevelattrs#
223cdf0e10cSrcweir SwNumRule aSetRule( pCurRule
224cdf0e10cSrcweir ? pCurRule->GetName()
225cdf0e10cSrcweir : GetShell().GetUniqueNumRuleName(),
226cdf0e10cSrcweir // --> OD 2008-06-06 #i89178#
227cdf0e10cSrcweir numfunc::GetDefaultPositionAndSpaceMode() );
228cdf0e10cSrcweir // <--
229cdf0e10cSrcweir // <--
230cdf0e10cSrcweir aSetRule.SetSvxRule( *pSetRule, GetShell().GetDoc());
231cdf0e10cSrcweir aSetRule.SetAutoRule( sal_True );
232cdf0e10cSrcweir // --> OD 2008-03-17 #refactorlists#
233cdf0e10cSrcweir // No start of new list, if an existing list style is edited.
234cdf0e10cSrcweir // Otherwise start a new list.
235cdf0e10cSrcweir const bool bCreateList = (pCurRule == 0);
236cdf0e10cSrcweir GetShell().SetCurNumRule( aSetRule, bCreateList );
237cdf0e10cSrcweir // <--
238cdf0e10cSrcweir }
239cdf0e10cSrcweir // wenn der Dialog mit OK verlassen wurde, aber nichts ausgewaehlt
240cdf0e10cSrcweir // wurde dann muss die Numerierung zumindest eingeschaltet werden,
241cdf0e10cSrcweir // wenn sie das noch nicht ist
242cdf0e10cSrcweir else if( !pCurRule && SFX_ITEM_SET == aSet.GetItemState( SID_ATTR_NUMBERING_RULE, sal_False, &pItem ))
243cdf0e10cSrcweir {
244cdf0e10cSrcweir rReq.AppendItem( *pItem );
245cdf0e10cSrcweir rReq.Done();
246cdf0e10cSrcweir SvxNumRule* pSetRule = ((SvxNumBulletItem*)pItem)->GetNumRule();
247cdf0e10cSrcweir // --> OD 2008-02-11 #newlistlevelattrs#
248cdf0e10cSrcweir SwNumRule aSetRule( GetShell().GetUniqueNumRuleName(),
249cdf0e10cSrcweir // --> OD 2008-06-06 #i89178#
250cdf0e10cSrcweir numfunc::GetDefaultPositionAndSpaceMode() );
251cdf0e10cSrcweir // <--
252cdf0e10cSrcweir // <--
253cdf0e10cSrcweir aSetRule.SetSvxRule(*pSetRule, GetShell().GetDoc());
254cdf0e10cSrcweir aSetRule.SetAutoRule( sal_True );
255cdf0e10cSrcweir // --> OD 2008-03-17 #refactorlists#
256cdf0e10cSrcweir // start new list
257cdf0e10cSrcweir GetShell().SetCurNumRule( aSetRule, true );
258cdf0e10cSrcweir // <--
259cdf0e10cSrcweir }
260cdf0e10cSrcweir }
261cdf0e10cSrcweir else if(RET_USER == nRet)
262cdf0e10cSrcweir GetShell().DelNumRules();
263cdf0e10cSrcweir
264cdf0e10cSrcweir delete pDlg;
265cdf0e10cSrcweir }
266cdf0e10cSrcweir break;
267cdf0e10cSrcweir default:
268cdf0e10cSrcweir ASSERT(sal_False, falscher Dispatcher);
269cdf0e10cSrcweir return;
270cdf0e10cSrcweir }
271cdf0e10cSrcweir }
272cdf0e10cSrcweir
ExecSetNumber(SfxRequest & rReq)273766ce4d0SZheng Fan void SwTextShell::ExecSetNumber(SfxRequest &rReq)
274766ce4d0SZheng Fan {
275766ce4d0SZheng Fan SwNumRule aRule( GetShell().GetUniqueNumRuleName(),
276766ce4d0SZheng Fan // --> OD 2008-06-06 #i89178#
277766ce4d0SZheng Fan numfunc::GetDefaultPositionAndSpaceMode() );
278766ce4d0SZheng Fan // <--
279cdf0e10cSrcweir
280766ce4d0SZheng Fan SvxNumRule aSvxRule = aRule.MakeSvxNumRule();
281766ce4d0SZheng Fan const bool bRightToLeft = GetShell().IsInRightToLeftText( 0 );
282766ce4d0SZheng Fan
283766ce4d0SZheng Fan if( bRightToLeft )
284766ce4d0SZheng Fan {
285766ce4d0SZheng Fan for( sal_uInt8 n = 0; n < MAXLEVEL; ++n )
286766ce4d0SZheng Fan {
287766ce4d0SZheng Fan SvxNumberFormat aFmt( aSvxRule.GetLevel( n ) );
288766ce4d0SZheng Fan /* if ( n && bHtml )
289766ce4d0SZheng Fan {
290766ce4d0SZheng Fan // 1/2" fuer HTML
291766ce4d0SZheng Fan aFmt.SetLSpace(720);
292766ce4d0SZheng Fan aFmt.SetAbsLSpace(n * 720);
293766ce4d0SZheng Fan }*/
294766ce4d0SZheng Fan // --> FME 2005-01-21 #i38904# Default alignment for
295766ce4d0SZheng Fan // numbering/bullet should be rtl in rtl paragraph:
296766ce4d0SZheng Fan if ( bRightToLeft )
297766ce4d0SZheng Fan {
298766ce4d0SZheng Fan aFmt.SetNumAdjust( SVX_ADJUST_RIGHT );
299766ce4d0SZheng Fan }
300766ce4d0SZheng Fan // <--
301766ce4d0SZheng Fan aSvxRule.SetLevel( n, aFmt, sal_False );
302766ce4d0SZheng Fan }
303766ce4d0SZheng Fan aSvxRule.SetFeatureFlag(NUM_ENABLE_EMBEDDED_BMP, sal_False);
304766ce4d0SZheng Fan }
305766ce4d0SZheng Fan
306766ce4d0SZheng Fan const SwNumRule* pCurRule = GetShell().GetCurNumRule();
307766ce4d0SZheng Fan sal_uInt16 nActNumLvl = (sal_uInt16)0xFFFF;
308766ce4d0SZheng Fan if( pCurRule )
309766ce4d0SZheng Fan {
310766ce4d0SZheng Fan sal_uInt16 nLevel = GetShell().GetNumLevel();
311766ce4d0SZheng Fan if( nLevel < MAXLEVEL )
312766ce4d0SZheng Fan {
313766ce4d0SZheng Fan nActNumLvl = 1<<nLevel;
314766ce4d0SZheng Fan }
315766ce4d0SZheng Fan
316766ce4d0SZheng Fan aSvxRule = pCurRule->MakeSvxNumRule();
317766ce4d0SZheng Fan
318766ce4d0SZheng Fan //convert type of linked bitmaps from SVX_NUM_BITMAP to (SVX_NUM_BITMAP|LINK_TOKEN)
319766ce4d0SZheng Fan for(sal_uInt16 i = 0; i < aSvxRule.GetLevelCount(); i++)
320766ce4d0SZheng Fan {
321766ce4d0SZheng Fan SvxNumberFormat aFmt(aSvxRule.GetLevel(i));
322766ce4d0SZheng Fan if(SVX_NUM_BITMAP == aFmt.GetNumberingType())
323766ce4d0SZheng Fan {
324766ce4d0SZheng Fan const SvxBrushItem* pBrush = aFmt.GetBrush();
325766ce4d0SZheng Fan const String* pLinkStr;
326766ce4d0SZheng Fan if(pBrush &&
327766ce4d0SZheng Fan 0 != (pLinkStr = pBrush->GetGraphicLink()) &&
328766ce4d0SZheng Fan pLinkStr->Len())
329766ce4d0SZheng Fan aFmt.SetNumberingType(SvxExtNumType(SVX_NUM_BITMAP|LINK_TOKEN));
330766ce4d0SZheng Fan aSvxRule.SetLevel(i, aFmt, aSvxRule.Get(i) != 0);
331766ce4d0SZheng Fan }
332766ce4d0SZheng Fan }
333766ce4d0SZheng Fan }
334766ce4d0SZheng Fan
335766ce4d0SZheng Fan
336766ce4d0SZheng Fan switch(rReq.GetSlot())
337766ce4d0SZheng Fan {
338766ce4d0SZheng Fan case FN_SVX_SET_NUMBER:
339766ce4d0SZheng Fan {
340766ce4d0SZheng Fan SFX_REQUEST_ARG( rReq, pItem, SfxUInt16Item, FN_SVX_SET_NUMBER , sal_False );
341766ce4d0SZheng Fan if (pItem)
342766ce4d0SZheng Fan {
343766ce4d0SZheng Fan sal_uInt16 nIdx = pItem->GetValue();
344766ce4d0SZheng Fan if (nIdx==DEFAULT_NONE) {
345766ce4d0SZheng Fan GetShell().DelNumRules();
346766ce4d0SZheng Fan break;
347766ce4d0SZheng Fan }
348766ce4d0SZheng Fan --nIdx;
349766ce4d0SZheng Fan
350766ce4d0SZheng Fan NBOTypeMgrBase* pNumbering = NBOutlineTypeMgrFact::CreateInstance(eNBOType::NUMBERING);
351766ce4d0SZheng Fan if ( pNumbering )
352766ce4d0SZheng Fan {
353766ce4d0SZheng Fan SwNumRule aTmpRule( GetShell().GetUniqueNumRuleName(),
354766ce4d0SZheng Fan numfunc::GetDefaultPositionAndSpaceMode() );
355766ce4d0SZheng Fan
356766ce4d0SZheng Fan SvxNumRule aTempRule = aTmpRule.MakeSvxNumRule();
357*0deba7fbSSteve Yin // set unit attribute to NB Manager
358766ce4d0SZheng Fan SfxItemSet aSet(GetPool(),
359766ce4d0SZheng Fan SID_ATTR_NUMBERING_RULE, SID_PARAM_CUR_NUM_LEVEL,
360766ce4d0SZheng Fan 0 );
361766ce4d0SZheng Fan aSet.Put(SvxNumBulletItem(aTempRule));
362766ce4d0SZheng Fan pNumbering->SetItems(&aSet);
363766ce4d0SZheng Fan pNumbering->ApplyNumRule(aTempRule,nIdx,nActNumLvl);
364766ce4d0SZheng Fan
365766ce4d0SZheng Fan sal_uInt16 nMask = 1;
366766ce4d0SZheng Fan for(sal_uInt16 i = 0; i < aSvxRule.GetLevelCount(); i++)
367766ce4d0SZheng Fan {
368766ce4d0SZheng Fan if(nActNumLvl & nMask)
369766ce4d0SZheng Fan {
370766ce4d0SZheng Fan SvxNumberFormat aFmt(aTempRule.GetLevel(i));
371766ce4d0SZheng Fan aSvxRule.SetLevel(i, aFmt);
372766ce4d0SZheng Fan }
373766ce4d0SZheng Fan nMask <<= 1 ;
374766ce4d0SZheng Fan }
375766ce4d0SZheng Fan
376766ce4d0SZheng Fan aSvxRule.UnLinkGraphics();
377766ce4d0SZheng Fan SwNumRule aSetRule( pCurRule
378766ce4d0SZheng Fan ? pCurRule->GetName()
379766ce4d0SZheng Fan : GetShell().GetUniqueNumRuleName(),
380766ce4d0SZheng Fan numfunc::GetDefaultPositionAndSpaceMode() );
381766ce4d0SZheng Fan aSetRule.SetSvxRule( aSvxRule, GetShell().GetDoc());
382766ce4d0SZheng Fan
383766ce4d0SZheng Fan aSetRule.SetAutoRule( sal_True );
384766ce4d0SZheng Fan const bool bCreateList = (pCurRule == 0);
385766ce4d0SZheng Fan GetShell().SetCurNumRule( aSetRule, bCreateList );
386766ce4d0SZheng Fan }
387766ce4d0SZheng Fan //End
388766ce4d0SZheng Fan }
389766ce4d0SZheng Fan break;
390766ce4d0SZheng Fan }
391766ce4d0SZheng Fan case FN_SVX_SET_BULLET:
392766ce4d0SZheng Fan {
393766ce4d0SZheng Fan SFX_REQUEST_ARG( rReq, pItem, SfxUInt16Item, FN_SVX_SET_BULLET , sal_False );
394766ce4d0SZheng Fan if (pItem)
395766ce4d0SZheng Fan {
396766ce4d0SZheng Fan sal_uInt16 nIdx = pItem->GetValue();
397766ce4d0SZheng Fan if (nIdx==DEFAULT_NONE) {
398766ce4d0SZheng Fan GetShell().DelNumRules();
399766ce4d0SZheng Fan break;
400766ce4d0SZheng Fan }
401766ce4d0SZheng Fan nIdx--;
402766ce4d0SZheng Fan
403766ce4d0SZheng Fan NBOTypeMgrBase* pBullets = NBOutlineTypeMgrFact::CreateInstance(eNBOType::MIXBULLETS);
404766ce4d0SZheng Fan if ( pBullets )
405766ce4d0SZheng Fan {
406766ce4d0SZheng Fan SwNumRule aTmpRule( GetShell().GetUniqueNumRuleName(),
407766ce4d0SZheng Fan numfunc::GetDefaultPositionAndSpaceMode() );
408766ce4d0SZheng Fan
409766ce4d0SZheng Fan SvxNumRule aTempRule = aTmpRule.MakeSvxNumRule();
410*0deba7fbSSteve Yin // set unit attribute to NB Manager
411766ce4d0SZheng Fan SfxItemSet aSet(GetPool(),
412766ce4d0SZheng Fan SID_ATTR_NUMBERING_RULE, SID_PARAM_CUR_NUM_LEVEL,
413766ce4d0SZheng Fan 0 );
414766ce4d0SZheng Fan aSet.Put(SvxNumBulletItem(aTempRule));
415766ce4d0SZheng Fan pBullets->SetItems(&aSet);
416766ce4d0SZheng Fan
417766ce4d0SZheng Fan //SvxNumRule aTempRule( 0, 10, false );
418766ce4d0SZheng Fan pBullets->ApplyNumRule(aTempRule,nIdx,nActNumLvl);
419766ce4d0SZheng Fan sal_uInt16 nMask = 1;
420766ce4d0SZheng Fan for(sal_uInt16 i = 0; i < aSvxRule.GetLevelCount(); i++)
421766ce4d0SZheng Fan {
422766ce4d0SZheng Fan if(nActNumLvl & nMask)
423766ce4d0SZheng Fan {
424766ce4d0SZheng Fan SvxNumberFormat aFmt(aTempRule.GetLevel(i));
425766ce4d0SZheng Fan aSvxRule.SetLevel(i, aFmt);
426766ce4d0SZheng Fan }
427766ce4d0SZheng Fan nMask <<= 1;
428766ce4d0SZheng Fan }
429766ce4d0SZheng Fan aSvxRule.UnLinkGraphics();
430766ce4d0SZheng Fan
431766ce4d0SZheng Fan SwNumRule aSetRule( pCurRule
432766ce4d0SZheng Fan ? pCurRule->GetName()
433766ce4d0SZheng Fan : GetShell().GetUniqueNumRuleName(),
434766ce4d0SZheng Fan numfunc::GetDefaultPositionAndSpaceMode() );
435766ce4d0SZheng Fan
436766ce4d0SZheng Fan aSetRule.SetSvxRule( aSvxRule, GetShell().GetDoc());
437766ce4d0SZheng Fan
438766ce4d0SZheng Fan aSetRule.SetAutoRule( sal_True );
439766ce4d0SZheng Fan const bool bCreateList = (pCurRule == 0);
440766ce4d0SZheng Fan GetShell().SetCurNumRule( aSetRule, bCreateList );
441766ce4d0SZheng Fan }
442766ce4d0SZheng Fan //End
443766ce4d0SZheng Fan }
444766ce4d0SZheng Fan
445766ce4d0SZheng Fan }
446766ce4d0SZheng Fan break;
447766ce4d0SZheng Fan }
448766ce4d0SZheng Fan }
449