xref: /AOO41X/main/sd/source/ui/func/fuolbull.cxx (revision 766ce4d0f35a6d5b4b7c65174e638ff2dfbd4ec1)
15b190011SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
35b190011SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
45b190011SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
55b190011SAndrew Rist  * distributed with this work for additional information
65b190011SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
75b190011SAndrew Rist  * to you under the Apache License, Version 2.0 (the
85b190011SAndrew Rist  * "License"); you may not use this file except in compliance
95b190011SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
115b190011SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
135b190011SAndrew Rist  * Unless required by applicable law or agreed to in writing,
145b190011SAndrew Rist  * software distributed under the License is distributed on an
155b190011SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
165b190011SAndrew Rist  * KIND, either express or implied.  See the License for the
175b190011SAndrew Rist  * specific language governing permissions and limitations
185b190011SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
205b190011SAndrew Rist  *************************************************************/
215b190011SAndrew Rist 
225b190011SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sd.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include "fuolbull.hxx"
29cdf0e10cSrcweir #include <vcl/msgbox.hxx>
30cdf0e10cSrcweir #include <svl/intitem.hxx>
31cdf0e10cSrcweir #include <editeng/outliner.hxx>
32cdf0e10cSrcweir #include <editeng/eeitem.hxx>
33cdf0e10cSrcweir #include <sfx2/request.hxx>
34cdf0e10cSrcweir #include <svl/intitem.hxx>
35*766ce4d0SZheng Fan #include <editeng/numitem.hxx>
36*766ce4d0SZheng Fan #include "sdresid.hxx"
37*766ce4d0SZheng Fan #include "glob.hrc"
38cdf0e10cSrcweir 
39cdf0e10cSrcweir #include <editeng/editdata.hxx>
40cdf0e10cSrcweir #include <svx/svxids.hrc>
41cdf0e10cSrcweir #include "OutlineView.hxx"
42cdf0e10cSrcweir #include "OutlineViewShell.hxx"
43cdf0e10cSrcweir #include "DrawViewShell.hxx"
44cdf0e10cSrcweir #ifndef SD_WINDOW_SHELL_HXX
45cdf0e10cSrcweir #include "Window.hxx"
46cdf0e10cSrcweir #endif
47cdf0e10cSrcweir #include "drawdoc.hxx"
48cdf0e10cSrcweir #include "sdabstdlg.hxx"
49*766ce4d0SZheng Fan #include <svx/nbdtmg.hxx>
50*766ce4d0SZheng Fan #include <svx/nbdtmgfact.hxx>
51*766ce4d0SZheng Fan #include <svx/svdoutl.hxx>
52*766ce4d0SZheng Fan using namespace svx::sidebar;
53cdf0e10cSrcweir namespace sd {
54cdf0e10cSrcweir 
55cdf0e10cSrcweir TYPEINIT1( FuOutlineBullet, FuPoor );
56cdf0e10cSrcweir 
57cdf0e10cSrcweir /*************************************************************************
58cdf0e10cSrcweir |*
59cdf0e10cSrcweir |* Konstruktor
60cdf0e10cSrcweir |*
61cdf0e10cSrcweir \************************************************************************/
62cdf0e10cSrcweir 
63cdf0e10cSrcweir FuOutlineBullet::FuOutlineBullet(ViewShell* pViewShell, ::sd::Window* pWindow,
64cdf0e10cSrcweir 								 ::sd::View* pView, SdDrawDocument* pDoc,
65cdf0e10cSrcweir 								 SfxRequest& rReq)
66cdf0e10cSrcweir 	   : FuPoor(pViewShell, pWindow, pView, pDoc, rReq)
67cdf0e10cSrcweir {
68cdf0e10cSrcweir }
69cdf0e10cSrcweir 
70cdf0e10cSrcweir FunctionReference FuOutlineBullet::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
71cdf0e10cSrcweir {
72cdf0e10cSrcweir 	FunctionReference xFunc( new FuOutlineBullet( pViewSh, pWin, pView, pDoc, rReq ) );
73cdf0e10cSrcweir 	xFunc->DoExecute(rReq);
74cdf0e10cSrcweir 	return xFunc;
75cdf0e10cSrcweir }
76cdf0e10cSrcweir 
77cdf0e10cSrcweir void FuOutlineBullet::DoExecute( SfxRequest& rReq )
78cdf0e10cSrcweir {
79*766ce4d0SZheng Fan 	sal_uInt16 nSId = rReq.GetSlot();
80*766ce4d0SZheng Fan 	if (nSId == FN_SVX_SET_BULLET){
81*766ce4d0SZheng Fan 		SetCurrentBullet(rReq);
82*766ce4d0SZheng Fan 		return;
83*766ce4d0SZheng Fan 	}
84*766ce4d0SZheng Fan 	else if (nSId == FN_SVX_SET_NUMBER){
85*766ce4d0SZheng Fan 		SetCurrentNumbering(rReq);
86*766ce4d0SZheng Fan 		return;
87*766ce4d0SZheng Fan 	}
88*766ce4d0SZheng Fan 
89cdf0e10cSrcweir 	const SfxItemSet* pArgs = rReq.GetArgs();
90cdf0e10cSrcweir 
91cdf0e10cSrcweir 	if( !pArgs )
92cdf0e10cSrcweir 	{
93cdf0e10cSrcweir 		// ItemSet fuer Dialog fuellen
94cdf0e10cSrcweir 		SfxItemSet aEditAttr( mpDoc->GetPool() );
95cdf0e10cSrcweir 		mpView->GetAttributes( aEditAttr );
96cdf0e10cSrcweir 
97cdf0e10cSrcweir 		SfxItemSet aNewAttr( mpViewShell->GetPool(),
98cdf0e10cSrcweir 							 EE_ITEMS_START, EE_ITEMS_END );
99cdf0e10cSrcweir 		aNewAttr.Put( aEditAttr, sal_False );
100cdf0e10cSrcweir 
101cdf0e10cSrcweir 		// Dialog hochfahren und ausfuehren
102cdf0e10cSrcweir 		SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
103cdf0e10cSrcweir 		SfxAbstractTabDialog* pDlg = pFact ? pFact->CreateSdOutlineBulletTabDlg( NULL, &aNewAttr, mpView ) : 0;
104cdf0e10cSrcweir 		if( pDlg )
105cdf0e10cSrcweir 		{
106cdf0e10cSrcweir 			sal_uInt16 nResult = pDlg->Execute();
107cdf0e10cSrcweir 
108cdf0e10cSrcweir 			switch( nResult )
109cdf0e10cSrcweir 			{
110cdf0e10cSrcweir 				case RET_OK:
111cdf0e10cSrcweir 				{
112cdf0e10cSrcweir 					SfxItemSet aSet( *pDlg->GetOutputItemSet() );
113cdf0e10cSrcweir 
114cdf0e10cSrcweir 	                OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
115cdf0e10cSrcweir 
116cdf0e10cSrcweir 	                std::auto_ptr< OutlineViewModelChangeGuard > aGuard;
117cdf0e10cSrcweir 
118cdf0e10cSrcweir 	                if (mpView->ISA(OutlineView))
119cdf0e10cSrcweir 	                {
120cdf0e10cSrcweir 		                pOLV = static_cast<OutlineView*>(mpView)
121cdf0e10cSrcweir                             ->GetViewByWindow(mpViewShell->GetActiveWindow());
122cdf0e10cSrcweir 
123cdf0e10cSrcweir 		                aGuard.reset( new OutlineViewModelChangeGuard( static_cast<OutlineView&>(*mpView) ) );
124cdf0e10cSrcweir 	                }
125cdf0e10cSrcweir 
126cdf0e10cSrcweir                     if( pOLV )
127cdf0e10cSrcweir                         pOLV->EnableBullets();
128cdf0e10cSrcweir 
129cdf0e10cSrcweir 					rReq.Done( aSet );
130cdf0e10cSrcweir 					pArgs = rReq.GetArgs();
131cdf0e10cSrcweir 				}
132cdf0e10cSrcweir 				break;
133cdf0e10cSrcweir 
134cdf0e10cSrcweir 				default:
135cdf0e10cSrcweir 				{
136cdf0e10cSrcweir 					delete pDlg;
137cdf0e10cSrcweir 					return;
138cdf0e10cSrcweir 				}
139cdf0e10cSrcweir 			}
140cdf0e10cSrcweir 
141cdf0e10cSrcweir 			delete pDlg;
142cdf0e10cSrcweir 		}
143cdf0e10cSrcweir 	}
144cdf0e10cSrcweir 
145cdf0e10cSrcweir 	// nicht direkt an pOlView, damit SdDrawView::SetAttributes
146cdf0e10cSrcweir 	// Aenderungen auf der Masterpage abfangen und in eine
147cdf0e10cSrcweir 	// Vorlage umleiten kann
148cdf0e10cSrcweir 	mpView->SetAttributes(*pArgs);
149cdf0e10cSrcweir 
150cdf0e10cSrcweir /* #i35937#
151cdf0e10cSrcweir 	// evtl. Betroffene Felder invalidieren
152cdf0e10cSrcweir 	mpViewShell->Invalidate( FN_NUM_BULLET_ON );
153cdf0e10cSrcweir */
154cdf0e10cSrcweir }
155cdf0e10cSrcweir 
156*766ce4d0SZheng Fan void FuOutlineBullet::SetCurrentNumbering(SfxRequest& rReq)
157*766ce4d0SZheng Fan {
158*766ce4d0SZheng Fan 	if (!mpDoc || !mpView)
159*766ce4d0SZheng Fan 		return;
160cdf0e10cSrcweir 
161*766ce4d0SZheng Fan 	SfxItemSet aEditAttr( mpDoc->GetPool() );
162*766ce4d0SZheng Fan 	mpView->GetAttributes( aEditAttr );
163*766ce4d0SZheng Fan 
164*766ce4d0SZheng Fan 	SfxItemSet aNewAttr( mpViewShell->GetPool(),
165*766ce4d0SZheng Fan 							 EE_ITEMS_START, EE_ITEMS_END );
166*766ce4d0SZheng Fan 	aNewAttr.Put( aEditAttr, sal_False );
167*766ce4d0SZheng Fan 
168*766ce4d0SZheng Fan 	SfxItemSet aSetAttr( mpViewShell->GetPool(),
169*766ce4d0SZheng Fan 							 EE_ITEMS_START, EE_ITEMS_END );
170*766ce4d0SZheng Fan 
171*766ce4d0SZheng Fan 	//Init bullet level in "Customize" tab page in bullet dialog in master page view
172*766ce4d0SZheng Fan 	if( mpView && mpViewShell && mpViewShell->ISA(DrawViewShell)
173*766ce4d0SZheng Fan 		&& ((DrawViewShell *)mpViewShell)->GetEditMode() == EM_MASTERPAGE )
174*766ce4d0SZheng Fan 	{
175*766ce4d0SZheng Fan 		SdrObject* pObj = mpView->GetTextEditObject();
176*766ce4d0SZheng Fan 		if( pObj && pObj->GetObjIdentifier() == OBJ_OUTLINETEXT )
177*766ce4d0SZheng Fan 		{
178*766ce4d0SZheng Fan 			sal_uInt16 nLevel = mpView->GetSelectionLevel();
179*766ce4d0SZheng Fan 			if( nLevel != 0xFFFF )
180*766ce4d0SZheng Fan 			{
181*766ce4d0SZheng Fan 
182*766ce4d0SZheng Fan 				SfxItemSet aStoreSet( aNewAttr );
183*766ce4d0SZheng Fan 				aNewAttr.ClearItem();
184*766ce4d0SZheng Fan 				//extend range
185*766ce4d0SZheng Fan 				aNewAttr.MergeRange( SID_PARAM_NUM_PRESET, SID_PARAM_CUR_NUM_LEVEL );
186*766ce4d0SZheng Fan 				aNewAttr.Put( aStoreSet );
187*766ce4d0SZheng Fan 				//put current level user selected
188*766ce4d0SZheng Fan 				aNewAttr.Put( SfxUInt16Item( SID_PARAM_CUR_NUM_LEVEL, nLevel ) );
189*766ce4d0SZheng Fan 			}
190*766ce4d0SZheng Fan 		}
191*766ce4d0SZheng Fan 	}
192*766ce4d0SZheng Fan 	//End of add
193*766ce4d0SZheng Fan 
194*766ce4d0SZheng Fan 	sal_uInt16 nActNumLvl = (sal_uInt16)0xFFFF;
195*766ce4d0SZheng Fan 	SvxNumRule* pNumRule = NULL;
196*766ce4d0SZheng Fan 	const SfxPoolItem* pTmpItem=NULL;
197*766ce4d0SZheng Fan 	sal_uInt32 nNumItemId = SID_ATTR_NUMBERING_RULE;
198*766ce4d0SZheng Fan 
199*766ce4d0SZheng Fan 	if(SFX_ITEM_SET == aNewAttr.GetItemState(SID_PARAM_CUR_NUM_LEVEL, sal_False, &pTmpItem))
200*766ce4d0SZheng Fan 		nActNumLvl = ((const SfxUInt16Item*)pTmpItem)->GetValue();
201*766ce4d0SZheng Fan 
202*766ce4d0SZheng Fan 	pTmpItem=GetNumBulletItem(aNewAttr, nNumItemId);
203*766ce4d0SZheng Fan 
204*766ce4d0SZheng Fan 	if (pTmpItem)
205*766ce4d0SZheng Fan 		pNumRule = new SvxNumRule(*((SvxNumBulletItem*)pTmpItem)->GetNumRule());
206*766ce4d0SZheng Fan 
207*766ce4d0SZheng Fan 	SFX_REQUEST_ARG( rReq, pItem, SfxUInt16Item, FN_SVX_SET_NUMBER , sal_False );
208*766ce4d0SZheng Fan 	if (pItem && pNumRule)
209*766ce4d0SZheng Fan 	{
210*766ce4d0SZheng Fan 		sal_uInt16 nIdx = pItem->GetValue();
211*766ce4d0SZheng Fan 		// If the nIdx is (sal_uInt16)0xFFFF, means set bullet status to on/off
212*766ce4d0SZheng Fan 		// And the bullet default status is 1.
213*766ce4d0SZheng Fan 		bool bBulletSwitch = false;
214*766ce4d0SZheng Fan         sal_Bool isRemoveNum =false;
215*766ce4d0SZheng Fan 		if( nIdx == (sal_uInt16)0xFFFF )
216*766ce4d0SZheng Fan 		{
217*766ce4d0SZheng Fan 			nIdx = 1;
218*766ce4d0SZheng Fan 			bBulletSwitch = true;
219*766ce4d0SZheng Fan 		}
220*766ce4d0SZheng Fan 		if (nIdx == DEFAULT_NONE)
221*766ce4d0SZheng Fan 		{
222*766ce4d0SZheng Fan 			bBulletSwitch = false;
223*766ce4d0SZheng Fan 			isRemoveNum = true;
224*766ce4d0SZheng Fan 		}
225*766ce4d0SZheng Fan 		nIdx--;
226*766ce4d0SZheng Fan 
227*766ce4d0SZheng Fan 		NBOTypeMgrBase* pNumbering = NBOutlineTypeMgrFact::CreateInstance(eNBOType::NUMBERING);
228*766ce4d0SZheng Fan 		if ( pNumbering )
229*766ce4d0SZheng Fan 		{
230*766ce4d0SZheng Fan 			//Sym3_2508, set unit attribute to NB Manager
231*766ce4d0SZheng Fan 			pNumbering->SetItems(&aNewAttr);
232*766ce4d0SZheng Fan 			SvxNumRule aTmpRule( *pNumRule );
233*766ce4d0SZheng Fan 			pNumbering->ApplyNumRule(aTmpRule,nIdx,nActNumLvl);
234*766ce4d0SZheng Fan 			sal_uInt16 nMask = 1;
235*766ce4d0SZheng Fan 			for(sal_uInt16 i = 0; i < pNumRule->GetLevelCount(); i++)
236*766ce4d0SZheng Fan 			{
237*766ce4d0SZheng Fan 				if(nActNumLvl & nMask)
238*766ce4d0SZheng Fan 				{
239*766ce4d0SZheng Fan 					SvxNumberFormat aFmt(aTmpRule.GetLevel(i));
240*766ce4d0SZheng Fan 					pNumRule->SetLevel(i, aFmt);
241*766ce4d0SZheng Fan 				}
242*766ce4d0SZheng Fan 				nMask <<= 1 ;
243*766ce4d0SZheng Fan 			}
244*766ce4d0SZheng Fan 			aSetAttr.Put(SvxNumBulletItem( *pNumRule ), nNumItemId);
245*766ce4d0SZheng Fan 			OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
246*766ce4d0SZheng Fan 
247*766ce4d0SZheng Fan 	       	 std::auto_ptr< OutlineViewModelChangeGuard > aGuard;
248*766ce4d0SZheng Fan 
249*766ce4d0SZheng Fan 	        	if (mpView->ISA(OutlineView))
250*766ce4d0SZheng Fan 	        	{
251*766ce4d0SZheng Fan 			        pOLV = static_cast<OutlineView*>(mpView)
252*766ce4d0SZheng Fan 	                    ->GetViewByWindow(mpViewShell->GetActiveWindow());
253*766ce4d0SZheng Fan 
254*766ce4d0SZheng Fan 			        aGuard.reset( new OutlineViewModelChangeGuard( static_cast<OutlineView&>(*mpView) ) );
255*766ce4d0SZheng Fan 	        	}
256*766ce4d0SZheng Fan 
257*766ce4d0SZheng Fan             		SdrOutliner* pOwner = mpView->GetTextEditOutliner();
258*766ce4d0SZheng Fan 			bool bMasterView = false;
259*766ce4d0SZheng Fan 
260*766ce4d0SZheng Fan 			DrawViewShell* pDrawViewShell = static_cast< DrawViewShell* >(mpViewShell);
261*766ce4d0SZheng Fan 
262*766ce4d0SZheng Fan 			if ( pOwner && pDrawViewShell && pDrawViewShell->GetEditMode() == EM_MASTERPAGE )
263*766ce4d0SZheng Fan 				bMasterView = !pOwner->IsInUndo() && pOwner->IsUndoEnabled();
264*766ce4d0SZheng Fan 
265*766ce4d0SZheng Fan 			if( bMasterView )
266*766ce4d0SZheng Fan 			{
267*766ce4d0SZheng Fan 				pOwner->UndoActionStart( OLUNDO_ATTR );
268*766ce4d0SZheng Fan 				pOLV->ToggleBullets( bBulletSwitch, sal_False, bMasterView, pNumRule,isRemoveNum);
269*766ce4d0SZheng Fan 				mpView->SetAttributes(aSetAttr); //Modify for Sym2_3151
270*766ce4d0SZheng Fan 				pOwner->UndoActionEnd( OLUNDO_ATTR );
271*766ce4d0SZheng Fan 			}
272*766ce4d0SZheng Fan 			else if( pOLV )
273*766ce4d0SZheng Fan 				pOLV->ToggleBullets( bBulletSwitch, sal_False, bMasterView, pNumRule ,isRemoveNum);
274*766ce4d0SZheng Fan 			else
275*766ce4d0SZheng Fan 			{
276*766ce4d0SZheng Fan 				sal_Bool bInMasterView = pDrawViewShell && pDrawViewShell->GetEditMode() == EM_MASTERPAGE;
277*766ce4d0SZheng Fan 				SdrModel* pSdrModel = mpView->GetModel();
278*766ce4d0SZheng Fan 				sal_Bool bModelUndoEnabled = pSdrModel ? pSdrModel->IsUndoEnabled() : sal_False;
279*766ce4d0SZheng Fan 				if (bInMasterView && bModelUndoEnabled)
280*766ce4d0SZheng Fan 				{
281*766ce4d0SZheng Fan 					pSdrModel->BegUndo();
282*766ce4d0SZheng Fan 				}
283*766ce4d0SZheng Fan 				mpView->ToggleMarkedObjectsBullets(bBulletSwitch, sal_False, bInMasterView, pNumRule,isRemoveNum);
284*766ce4d0SZheng Fan 				if (bInMasterView)
285*766ce4d0SZheng Fan 				{
286*766ce4d0SZheng Fan 					mpView->SetAttributes(aSetAttr);
287*766ce4d0SZheng Fan 				}
288*766ce4d0SZheng Fan 				if (bInMasterView && bModelUndoEnabled)
289*766ce4d0SZheng Fan 				{
290*766ce4d0SZheng Fan 					pSdrModel->EndUndo();
291*766ce4d0SZheng Fan 				}
292*766ce4d0SZheng Fan 			}
293*766ce4d0SZheng Fan 		}
294*766ce4d0SZheng Fan 		//End
295*766ce4d0SZheng Fan 	}
296*766ce4d0SZheng Fan 	delete pNumRule;
297*766ce4d0SZheng Fan 	rReq.Done();
298*766ce4d0SZheng Fan }
299*766ce4d0SZheng Fan 
300*766ce4d0SZheng Fan void FuOutlineBullet::SetCurrentBullet(SfxRequest& rReq)
301*766ce4d0SZheng Fan {
302*766ce4d0SZheng Fan 	if (!mpDoc || !mpView)
303*766ce4d0SZheng Fan 		return;
304*766ce4d0SZheng Fan 
305*766ce4d0SZheng Fan 	SfxItemSet aEditAttr( mpDoc->GetPool() );
306*766ce4d0SZheng Fan 	mpView->GetAttributes( aEditAttr );
307*766ce4d0SZheng Fan 
308*766ce4d0SZheng Fan 	SfxItemSet aNewAttr( mpViewShell->GetPool(),
309*766ce4d0SZheng Fan 							 EE_ITEMS_START, EE_ITEMS_END );
310*766ce4d0SZheng Fan 	aNewAttr.Put( aEditAttr, sal_False );
311*766ce4d0SZheng Fan 
312*766ce4d0SZheng Fan 	//Add for Sym2_3151, should add new attributes in an empty item set, then use this item set as parameter in SetAttributes()
313*766ce4d0SZheng Fan 	SfxItemSet aSetAttr( mpViewShell->GetPool(),
314*766ce4d0SZheng Fan 							 EE_ITEMS_START, EE_ITEMS_END );
315*766ce4d0SZheng Fan 
316*766ce4d0SZheng Fan 	//Init bullet level in "Customize" tab page in bullet dialog in master page view
317*766ce4d0SZheng Fan 	if( mpView && mpViewShell && mpViewShell->ISA(DrawViewShell)
318*766ce4d0SZheng Fan 		&& ((DrawViewShell *)mpViewShell)->GetEditMode() == EM_MASTERPAGE )
319*766ce4d0SZheng Fan 	{
320*766ce4d0SZheng Fan 		SdrObject* pObj = mpView->GetTextEditObject();
321*766ce4d0SZheng Fan 		if( pObj && pObj->GetObjIdentifier() == OBJ_OUTLINETEXT )
322*766ce4d0SZheng Fan 		{
323*766ce4d0SZheng Fan 			sal_uInt16 nLevel = mpView->GetSelectionLevel();
324*766ce4d0SZheng Fan 			if( nLevel != 0xFFFF )
325*766ce4d0SZheng Fan 			{
326*766ce4d0SZheng Fan 				//aNewAttr.MergeRange( SID_ATTR_NUMBERING_RULE, SID_PARAM_CUR_NUM_LEVEL );
327*766ce4d0SZheng Fan 				//aNewAttr.Put( SfxUInt16Item( SID_PARAM_CUR_NUM_LEVEL, nLevel ) );
328*766ce4d0SZheng Fan 				//save the itemset value
329*766ce4d0SZheng Fan 				SfxItemSet aStoreSet( aNewAttr );
330*766ce4d0SZheng Fan 				aNewAttr.ClearItem();
331*766ce4d0SZheng Fan 				//extend range
332*766ce4d0SZheng Fan 				aNewAttr.MergeRange( SID_PARAM_NUM_PRESET, SID_PARAM_CUR_NUM_LEVEL );
333*766ce4d0SZheng Fan 				aNewAttr.Put( aStoreSet );
334*766ce4d0SZheng Fan 				//put current level user selected
335*766ce4d0SZheng Fan 				aNewAttr.Put( SfxUInt16Item( SID_PARAM_CUR_NUM_LEVEL, nLevel ) );
336*766ce4d0SZheng Fan 			}
337*766ce4d0SZheng Fan 		}
338*766ce4d0SZheng Fan 	}
339*766ce4d0SZheng Fan 	//End of add
340*766ce4d0SZheng Fan 
341*766ce4d0SZheng Fan 	sal_uInt16 nActNumLvl = (sal_uInt16)0xFFFF;
342*766ce4d0SZheng Fan 	SvxNumRule* pNumRule = NULL;
343*766ce4d0SZheng Fan 	const SfxPoolItem* pTmpItem=NULL;
344*766ce4d0SZheng Fan 	sal_uInt32 nNumItemId = SID_ATTR_NUMBERING_RULE;
345*766ce4d0SZheng Fan 
346*766ce4d0SZheng Fan 	if(SFX_ITEM_SET == aNewAttr.GetItemState(SID_PARAM_CUR_NUM_LEVEL, sal_False, &pTmpItem))
347*766ce4d0SZheng Fan 		nActNumLvl = ((const SfxUInt16Item*)pTmpItem)->GetValue();
348*766ce4d0SZheng Fan 
349*766ce4d0SZheng Fan 	pTmpItem=GetNumBulletItem(aNewAttr, nNumItemId);
350*766ce4d0SZheng Fan 
351*766ce4d0SZheng Fan 	if (pTmpItem)
352*766ce4d0SZheng Fan 		pNumRule = new SvxNumRule(*((SvxNumBulletItem*)pTmpItem)->GetNumRule());
353*766ce4d0SZheng Fan 
354*766ce4d0SZheng Fan 	SFX_REQUEST_ARG( rReq, pItem, SfxUInt16Item, FN_SVX_SET_BULLET , sal_False );
355*766ce4d0SZheng Fan 	if (pItem && pNumRule)
356*766ce4d0SZheng Fan 	{
357*766ce4d0SZheng Fan 		sal_uInt16 nIdx = pItem->GetValue();
358*766ce4d0SZheng Fan 		// If the nIdx is (sal_uInt16)0xFFFF, means set bullet status to on/off
359*766ce4d0SZheng Fan 		// And the bullet default status is 2.
360*766ce4d0SZheng Fan 		bool bBulletSwitch = false;
361*766ce4d0SZheng Fan         sal_Bool isRemoveNum =false;
362*766ce4d0SZheng Fan 		if( nIdx == (sal_uInt16)0xFFFF )
363*766ce4d0SZheng Fan 		{
364*766ce4d0SZheng Fan 			nIdx = 1;
365*766ce4d0SZheng Fan 			bBulletSwitch = true;
366*766ce4d0SZheng Fan 		}
367*766ce4d0SZheng Fan 		if (nIdx == DEFAULT_NONE)
368*766ce4d0SZheng Fan 		{
369*766ce4d0SZheng Fan 			bBulletSwitch = false;
370*766ce4d0SZheng Fan 			isRemoveNum = true;
371*766ce4d0SZheng Fan 		}
372*766ce4d0SZheng Fan 
373*766ce4d0SZheng Fan 		nIdx--;
374*766ce4d0SZheng Fan 		//Modified for Numbering&Bullets Dialog UX Enh(Story 992) by chengjh,2011.8.7
375*766ce4d0SZheng Fan 
376*766ce4d0SZheng Fan 		NBOTypeMgrBase* pBullets = NBOutlineTypeMgrFact::CreateInstance(eNBOType::MIXBULLETS);
377*766ce4d0SZheng Fan 		if ( pBullets )
378*766ce4d0SZheng Fan 		{
379*766ce4d0SZheng Fan 			//Sym3_2508, set unit attribute to NB Manager
380*766ce4d0SZheng Fan 			pBullets->SetItems(&aNewAttr);
381*766ce4d0SZheng Fan 			SvxNumRule aTmpRule( *pNumRule );
382*766ce4d0SZheng Fan 			//Sym3_3423 Always apply the "." if wants a default numbering rule
383*766ce4d0SZheng Fan 			if (bBulletSwitch==true && nIdx==0) //want to reset bullet
384*766ce4d0SZheng Fan 			{
385*766ce4d0SZheng Fan 				pBullets->ApplyNumRule(aTmpRule,nIdx,nActNumLvl,true);
386*766ce4d0SZheng Fan 			}
387*766ce4d0SZheng Fan 			else {
388*766ce4d0SZheng Fan 				pBullets->ApplyNumRule(aTmpRule,nIdx,nActNumLvl);
389*766ce4d0SZheng Fan 			}
390*766ce4d0SZheng Fan 			sal_uInt16 nMask = 1;
391*766ce4d0SZheng Fan 			for(sal_uInt16 i = 0; i < pNumRule->GetLevelCount(); i++)
392*766ce4d0SZheng Fan 			{
393*766ce4d0SZheng Fan 				if(nActNumLvl & nMask)
394*766ce4d0SZheng Fan 				{
395*766ce4d0SZheng Fan 					SvxNumberFormat aFmt(aTmpRule.GetLevel(i));
396*766ce4d0SZheng Fan 					pNumRule->SetLevel(i, aFmt);
397*766ce4d0SZheng Fan 				}
398*766ce4d0SZheng Fan 				nMask <<= 1;
399*766ce4d0SZheng Fan 			}
400*766ce4d0SZheng Fan 			aSetAttr.Put(SvxNumBulletItem( *pNumRule ), nNumItemId);
401*766ce4d0SZheng Fan 
402*766ce4d0SZheng Fan 			OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
403*766ce4d0SZheng Fan 
404*766ce4d0SZheng Fan 	        	std::auto_ptr< OutlineViewModelChangeGuard > aGuard;
405*766ce4d0SZheng Fan 
406*766ce4d0SZheng Fan 		       if (mpView->ISA(OutlineView))
407*766ce4d0SZheng Fan 		       {
408*766ce4d0SZheng Fan 			        pOLV = static_cast<OutlineView*>(mpView)
409*766ce4d0SZheng Fan 	                    ->GetViewByWindow(mpViewShell->GetActiveWindow());
410*766ce4d0SZheng Fan 
411*766ce4d0SZheng Fan 			        aGuard.reset( new OutlineViewModelChangeGuard( static_cast<OutlineView&>(*mpView) ) );
412*766ce4d0SZheng Fan 		       }
413*766ce4d0SZheng Fan 
414*766ce4d0SZheng Fan 			SdrOutliner* pOwner = mpView->GetTextEditOutliner();
415*766ce4d0SZheng Fan 			bool bMasterView = false;
416*766ce4d0SZheng Fan 
417*766ce4d0SZheng Fan 			DrawViewShell* pDrawViewShell = static_cast< DrawViewShell* >(mpViewShell);
418*766ce4d0SZheng Fan 
419*766ce4d0SZheng Fan 			if ( pOwner && pDrawViewShell && pDrawViewShell->GetEditMode() == EM_MASTERPAGE )
420*766ce4d0SZheng Fan 				bMasterView = !pOwner->IsInUndo() && pOwner->IsUndoEnabled();
421*766ce4d0SZheng Fan 
422*766ce4d0SZheng Fan 			if( bMasterView )
423*766ce4d0SZheng Fan 			{
424*766ce4d0SZheng Fan 				pOwner->UndoActionStart( OLUNDO_ATTR );
425*766ce4d0SZheng Fan 				pOLV->ToggleBullets( bBulletSwitch, sal_True, bMasterView, pNumRule, isRemoveNum );
426*766ce4d0SZheng Fan 				mpView->SetAttributes(aSetAttr); //Modify for Sym2_3151
427*766ce4d0SZheng Fan 				pOwner->UndoActionEnd( OLUNDO_ATTR );
428*766ce4d0SZheng Fan 			}
429*766ce4d0SZheng Fan 			else if( pOLV )
430*766ce4d0SZheng Fan 				pOLV->ToggleBullets( bBulletSwitch, sal_True, bMasterView, pNumRule, isRemoveNum );
431*766ce4d0SZheng Fan 			else
432*766ce4d0SZheng Fan 			{
433*766ce4d0SZheng Fan 				sal_Bool bInMasterView = pDrawViewShell && pDrawViewShell->GetEditMode() == EM_MASTERPAGE;
434*766ce4d0SZheng Fan 				SdrModel* pSdrModel = mpView->GetModel();
435*766ce4d0SZheng Fan 				sal_Bool bModelUndoEnabled = pSdrModel ? pSdrModel->IsUndoEnabled() : sal_False;
436*766ce4d0SZheng Fan 				if (bInMasterView && bModelUndoEnabled)
437*766ce4d0SZheng Fan 				{
438*766ce4d0SZheng Fan 					pSdrModel->BegUndo();
439*766ce4d0SZheng Fan 				}
440*766ce4d0SZheng Fan 				mpView->ToggleMarkedObjectsBullets(bBulletSwitch, sal_True, bInMasterView, pNumRule, isRemoveNum );
441*766ce4d0SZheng Fan 				if (bInMasterView)
442*766ce4d0SZheng Fan 				{
443*766ce4d0SZheng Fan 					mpView->SetAttributes(aSetAttr);
444*766ce4d0SZheng Fan 				}
445*766ce4d0SZheng Fan 				if (bInMasterView && bModelUndoEnabled)
446*766ce4d0SZheng Fan 				{
447*766ce4d0SZheng Fan 					pSdrModel->EndUndo();
448*766ce4d0SZheng Fan 				}
449*766ce4d0SZheng Fan 			}
450*766ce4d0SZheng Fan 		}
451*766ce4d0SZheng Fan 		//End
452*766ce4d0SZheng Fan 	}
453*766ce4d0SZheng Fan 	delete pNumRule;
454*766ce4d0SZheng Fan 	rReq.Done();
455*766ce4d0SZheng Fan }
456*766ce4d0SZheng Fan 
457*766ce4d0SZheng Fan const SfxPoolItem* FuOutlineBullet::GetNumBulletItem(SfxItemSet& aNewAttr, sal_uInt32& nNumItemId)
458*766ce4d0SZheng Fan {
459*766ce4d0SZheng Fan 	//SvxNumBulletItem* pRetItem = NULL;
460*766ce4d0SZheng Fan 	const SfxPoolItem* pTmpItem = NULL;
461*766ce4d0SZheng Fan 
462*766ce4d0SZheng Fan 	if(aNewAttr.GetItemState(nNumItemId, sal_False, &pTmpItem) == SFX_ITEM_SET)
463*766ce4d0SZheng Fan 	{
464*766ce4d0SZheng Fan 		return pTmpItem;
465*766ce4d0SZheng Fan 	}
466*766ce4d0SZheng Fan 	else
467*766ce4d0SZheng Fan 	{
468*766ce4d0SZheng Fan 		nNumItemId = aNewAttr.GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE);
469*766ce4d0SZheng Fan 		SfxItemState eState = aNewAttr.GetItemState(nNumItemId, sal_False, &pTmpItem);
470*766ce4d0SZheng Fan 		if (eState == SFX_ITEM_SET)
471*766ce4d0SZheng Fan 			return pTmpItem;
472*766ce4d0SZheng Fan 		else
473*766ce4d0SZheng Fan 		{
474*766ce4d0SZheng Fan 			sal_Bool bOutliner = sal_False;
475*766ce4d0SZheng Fan 			sal_Bool bTitle = sal_False;
476*766ce4d0SZheng Fan 
477*766ce4d0SZheng Fan 			if( mpView )
478*766ce4d0SZheng Fan      		{
479*766ce4d0SZheng Fan 				const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
480*766ce4d0SZheng Fan 				const sal_uInt32 nCount = rMarkList.GetMarkCount();
481*766ce4d0SZheng Fan 
482*766ce4d0SZheng Fan 				for(sal_uInt32 nNum = 0; nNum < nCount; nNum++)
483*766ce4d0SZheng Fan 				{
484*766ce4d0SZheng Fan 					SdrObject* pObj = rMarkList.GetMark(nNum)->GetMarkedSdrObj();
485*766ce4d0SZheng Fan 					if( pObj->GetObjInventor() == SdrInventor )
486*766ce4d0SZheng Fan 					{
487*766ce4d0SZheng Fan 						switch(pObj->GetObjIdentifier())
488*766ce4d0SZheng Fan 						{
489*766ce4d0SZheng Fan 						case OBJ_TITLETEXT:
490*766ce4d0SZheng Fan 							bTitle = sal_True;
491*766ce4d0SZheng Fan 							break;
492*766ce4d0SZheng Fan 						case OBJ_OUTLINETEXT:
493*766ce4d0SZheng Fan 							bOutliner = sal_True;
494*766ce4d0SZheng Fan 							break;
495*766ce4d0SZheng Fan 						}
496*766ce4d0SZheng Fan 					}
497*766ce4d0SZheng Fan 				}
498*766ce4d0SZheng Fan 			}
499*766ce4d0SZheng Fan 
500*766ce4d0SZheng Fan 			const SvxNumBulletItem *pItem = NULL;
501*766ce4d0SZheng Fan 			if(bOutliner)
502*766ce4d0SZheng Fan 			{
503*766ce4d0SZheng Fan 				SfxStyleSheetBasePool* pSSPool = mpView->GetDocSh()->GetStyleSheetPool();
504*766ce4d0SZheng Fan 				String aStyleName((SdResId((sal_uInt16)STR_LAYOUT_OUTLINE)));
505*766ce4d0SZheng Fan 				aStyleName.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " 1" ) );
506*766ce4d0SZheng Fan 				SfxStyleSheetBase* pFirstStyleSheet = pSSPool->Find( aStyleName, SD_STYLE_FAMILY_PSEUDO);
507*766ce4d0SZheng Fan 				if( pFirstStyleSheet )
508*766ce4d0SZheng Fan 					pFirstStyleSheet->GetItemSet().GetItemState(EE_PARA_NUMBULLET, sal_False, (const SfxPoolItem**)&pItem);
509*766ce4d0SZheng Fan 			}
510*766ce4d0SZheng Fan 
511*766ce4d0SZheng Fan 			if( pItem == NULL )
512*766ce4d0SZheng Fan 				pItem = (SvxNumBulletItem*) aNewAttr.GetPool()->GetSecondaryPool()->GetPoolDefaultItem(EE_PARA_NUMBULLET);
513*766ce4d0SZheng Fan 
514*766ce4d0SZheng Fan 			//DBG_ASSERT( pItem, "Kein EE_PARA_NUMBULLET im Pool! [CL]" );
515*766ce4d0SZheng Fan 
516*766ce4d0SZheng Fan 			aNewAttr.Put(*pItem, EE_PARA_NUMBULLET);
517*766ce4d0SZheng Fan 
518*766ce4d0SZheng Fan 			if(bTitle && aNewAttr.GetItemState(EE_PARA_NUMBULLET,sal_True) == SFX_ITEM_ON )
519*766ce4d0SZheng Fan 			{
520*766ce4d0SZheng Fan 				SvxNumBulletItem* pItem = (SvxNumBulletItem*)aNewAttr.GetItem(EE_PARA_NUMBULLET,sal_True);
521*766ce4d0SZheng Fan 				SvxNumRule* pRule = pItem->GetNumRule();
522*766ce4d0SZheng Fan 				if(pRule)
523*766ce4d0SZheng Fan 				{
524*766ce4d0SZheng Fan 					SvxNumRule aNewRule( *pRule );
525*766ce4d0SZheng Fan 					aNewRule.SetFeatureFlag( NUM_NO_NUMBERS, sal_True );
526*766ce4d0SZheng Fan 
527*766ce4d0SZheng Fan 					SvxNumBulletItem aNewItem( aNewRule, EE_PARA_NUMBULLET );
528*766ce4d0SZheng Fan 					aNewAttr.Put(aNewItem);
529*766ce4d0SZheng Fan 				}
530*766ce4d0SZheng Fan 			}
531*766ce4d0SZheng Fan 
532*766ce4d0SZheng Fan 			SfxItemState eState = aNewAttr.GetItemState(nNumItemId, sal_False, &pTmpItem);
533*766ce4d0SZheng Fan 			if (eState == SFX_ITEM_SET)
534*766ce4d0SZheng Fan 				return pTmpItem;
535*766ce4d0SZheng Fan 
536*766ce4d0SZheng Fan 		}
537*766ce4d0SZheng Fan 		//DBG_ASSERT(eState == SFX_ITEM_SET, "kein Item gefunden!")
538*766ce4d0SZheng Fan 	}
539*766ce4d0SZheng Fan 	return pTmpItem;
540*766ce4d0SZheng Fan }
541cdf0e10cSrcweir 
542cdf0e10cSrcweir } // end of namespace sd
543