fuolbull.cxx (766ce4d0) fuolbull.cxx (af89ca6e)
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 62 unchanged lines hidden (view full) ---

71{
72 FunctionReference xFunc( new FuOutlineBullet( pViewSh, pWin, pView, pDoc, rReq ) );
73 xFunc->DoExecute(rReq);
74 return xFunc;
75}
76
77void FuOutlineBullet::DoExecute( SfxRequest& rReq )
78{
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 62 unchanged lines hidden (view full) ---

71{
72 FunctionReference xFunc( new FuOutlineBullet( pViewSh, pWin, pView, pDoc, rReq ) );
73 xFunc->DoExecute(rReq);
74 return xFunc;
75}
76
77void FuOutlineBullet::DoExecute( SfxRequest& rReq )
78{
79 sal_uInt16 nSId = rReq.GetSlot();
80 if (nSId == FN_SVX_SET_BULLET){
81 SetCurrentBullet(rReq);
82 return;
83 }
84 else if (nSId == FN_SVX_SET_NUMBER){
85 SetCurrentNumbering(rReq);
86 return;
87 }
88
79 const sal_uInt16 nSId = rReq.GetSlot();
80 if ( nSId == FN_SVX_SET_BULLET || nSId == FN_SVX_SET_NUMBER )
81 {
82 SetCurrentBulletsNumbering(rReq);
83 return;
84 }
85
89 const SfxItemSet* pArgs = rReq.GetArgs();
90
91 if( !pArgs )
92 {
93 // ItemSet fuer Dialog fuellen
94 SfxItemSet aEditAttr( mpDoc->GetPool() );
95 mpView->GetAttributes( aEditAttr );
96

--- 51 unchanged lines hidden (view full) ---

148 mpView->SetAttributes(*pArgs);
149
150/* #i35937#
151 // evtl. Betroffene Felder invalidieren
152 mpViewShell->Invalidate( FN_NUM_BULLET_ON );
153*/
154}
155
86 const SfxItemSet* pArgs = rReq.GetArgs();
87
88 if( !pArgs )
89 {
90 // ItemSet fuer Dialog fuellen
91 SfxItemSet aEditAttr( mpDoc->GetPool() );
92 mpView->GetAttributes( aEditAttr );
93

--- 51 unchanged lines hidden (view full) ---

145 mpView->SetAttributes(*pArgs);
146
147/* #i35937#
148 // evtl. Betroffene Felder invalidieren
149 mpViewShell->Invalidate( FN_NUM_BULLET_ON );
150*/
151}
152
156void FuOutlineBullet::SetCurrentNumbering(SfxRequest& rReq)
153void FuOutlineBullet::SetCurrentBulletsNumbering(SfxRequest& rReq)
157{
154{
158 if (!mpDoc || !mpView)
159 return;
155 if (!mpDoc || !mpView)
156 return;
160
157
161 SfxItemSet aEditAttr( mpDoc->GetPool() );
162 mpView->GetAttributes( aEditAttr );
158 const sal_uInt16 nSId = rReq.GetSlot();
159 if ( nSId != FN_SVX_SET_BULLET && nSId != FN_SVX_SET_NUMBER )
160 {
161 // unexpected SfxRequest
162 return;
163 }
163
164
164 SfxItemSet aNewAttr( mpViewShell->GetPool(),
165 EE_ITEMS_START, EE_ITEMS_END );
166 aNewAttr.Put( aEditAttr, sal_False );
165 SFX_REQUEST_ARG( rReq, pItem, SfxUInt16Item, nSId, sal_False );
166 if ( !pItem )
167 {
168 rReq.Done();
169 return;
170 }
167
171
168 SfxItemSet aSetAttr( mpViewShell->GetPool(),
169 EE_ITEMS_START, EE_ITEMS_END );
172 SfxItemSet aNewAttr( mpViewShell->GetPool(), EE_ITEMS_START, EE_ITEMS_END );
173 {
174 SfxItemSet aEditAttr( mpDoc->GetPool() );
175 mpView->GetAttributes( aEditAttr );
176 aNewAttr.Put( aEditAttr, sal_False );
177 }
170
178
171 //Init bullet level in "Customize" tab page in bullet dialog in master page view
172 if( mpView && mpViewShell && mpViewShell->ISA(DrawViewShell)
173 && ((DrawViewShell *)mpViewShell)->GetEditMode() == EM_MASTERPAGE )
174 {
175 SdrObject* pObj = mpView->GetTextEditObject();
176 if( pObj && pObj->GetObjIdentifier() == OBJ_OUTLINETEXT )
177 {
178 sal_uInt16 nLevel = mpView->GetSelectionLevel();
179 if( nLevel != 0xFFFF )
180 {
179 const DrawViewShell* pDrawViewShell = dynamic_cast< DrawViewShell* >(mpViewShell);
180 //Init bullet level in "Customize" tab page in bullet dialog in master page view
181 const bool bInMasterView = pDrawViewShell && pDrawViewShell->GetEditMode() == EM_MASTERPAGE;
182 if ( bInMasterView )
183 {
184 SdrObject* pObj = mpView->GetTextEditObject();
185 if( pObj && pObj->GetObjIdentifier() == OBJ_OUTLINETEXT )
186 {
187 const sal_uInt16 nLevel = mpView->GetSelectionLevel();
188 if( nLevel != 0xFFFF )
189 {
190 //save the itemset value
191 SfxItemSet aStoreSet( aNewAttr );
192 aNewAttr.ClearItem();
193 //extend range
194 aNewAttr.MergeRange( SID_PARAM_NUM_PRESET, SID_PARAM_CUR_NUM_LEVEL );
195 aNewAttr.Put( aStoreSet );
196 //put current level user selected
197 aNewAttr.Put( SfxUInt16Item( SID_PARAM_CUR_NUM_LEVEL, nLevel ) );
198 }
199 }
200 }
181
201
182 SfxItemSet aStoreSet( aNewAttr );
183 aNewAttr.ClearItem();
184 //extend range
185 aNewAttr.MergeRange( SID_PARAM_NUM_PRESET, SID_PARAM_CUR_NUM_LEVEL );
186 aNewAttr.Put( aStoreSet );
187 //put current level user selected
188 aNewAttr.Put( SfxUInt16Item( SID_PARAM_CUR_NUM_LEVEL, nLevel ) );
189 }
190 }
191 }
192 //End of add
202 sal_uInt16 nIdx = pItem->GetValue();
203 bool bToggle = false;
204 bool bSwitchOff = false;
205 if( nIdx == (sal_uInt16)0xFFFF )
206 {
207 // If the nIdx is (sal_uInt16)0xFFFF, means set bullet status to on/off
208 nIdx = 1;
209 bToggle = true;
210 }
211 else if (nIdx == DEFAULT_NONE)
212 {
213 bSwitchOff = true;
214 }
215 nIdx--;
193
216
194 sal_uInt16 nActNumLvl = (sal_uInt16)0xFFFF;
195 SvxNumRule* pNumRule = NULL;
196 const SfxPoolItem* pTmpItem=NULL;
197 sal_uInt32 nNumItemId = SID_ATTR_NUMBERING_RULE;
217 sal_uInt32 nNumItemId = SID_ATTR_NUMBERING_RULE;
218 const SfxPoolItem* pTmpItem = GetNumBulletItem( aNewAttr, nNumItemId );
219 SvxNumRule* pNumRule = NULL;
220 if ( pTmpItem )
221 {
222 pNumRule = new SvxNumRule(*((SvxNumBulletItem*)pTmpItem)->GetNumRule());
198
223
199 if(SFX_ITEM_SET == aNewAttr.GetItemState(SID_PARAM_CUR_NUM_LEVEL, sal_False, &pTmpItem))
200 nActNumLvl = ((const SfxUInt16Item*)pTmpItem)->GetValue();
201
202 pTmpItem=GetNumBulletItem(aNewAttr, nNumItemId);
224 // get numbering rule corresponding to <nIdx> and apply the needed number formats to <pNumRule>
225 NBOTypeMgrBase* pNumRuleMgr =
226 NBOutlineTypeMgrFact::CreateInstance(
227 nSId == FN_SVX_SET_BULLET ? eNBOType::MIXBULLETS : eNBOType::NUMBERING );
228 if ( pNumRuleMgr )
229 {
230 sal_uInt16 nActNumLvl = (sal_uInt16)0xFFFF;
231 const SfxPoolItem* pNumLevelItem = NULL;
232 if(SFX_ITEM_SET == aNewAttr.GetItemState(SID_PARAM_CUR_NUM_LEVEL, sal_False, &pNumLevelItem))
233 nActNumLvl = ((const SfxUInt16Item*)pNumLevelItem)->GetValue();
203
234
204 if (pTmpItem)
205 pNumRule = new SvxNumRule(*((SvxNumBulletItem*)pTmpItem)->GetNumRule());
206
207 SFX_REQUEST_ARG( rReq, pItem, SfxUInt16Item, FN_SVX_SET_NUMBER , sal_False );
208 if (pItem && pNumRule)
209 {
210 sal_uInt16 nIdx = pItem->GetValue();
211 // If the nIdx is (sal_uInt16)0xFFFF, means set bullet status to on/off
212 // And the bullet default status is 1.
213 bool bBulletSwitch = false;
214 sal_Bool isRemoveNum =false;
215 if( nIdx == (sal_uInt16)0xFFFF )
216 {
217 nIdx = 1;
218 bBulletSwitch = true;
219 }
220 if (nIdx == DEFAULT_NONE)
221 {
222 bBulletSwitch = false;
223 isRemoveNum = true;
224 }
225 nIdx--;
226
227 NBOTypeMgrBase* pNumbering = NBOutlineTypeMgrFact::CreateInstance(eNBOType::NUMBERING);
228 if ( pNumbering )
229 {
230 //Sym3_2508, set unit attribute to NB Manager
231 pNumbering->SetItems(&aNewAttr);
232 SvxNumRule aTmpRule( *pNumRule );
233 pNumbering->ApplyNumRule(aTmpRule,nIdx,nActNumLvl);
234 sal_uInt16 nMask = 1;
235 for(sal_uInt16 i = 0; i < pNumRule->GetLevelCount(); i++)
236 {
237 if(nActNumLvl & nMask)
238 {
239 SvxNumberFormat aFmt(aTmpRule.GetLevel(i));
240 pNumRule->SetLevel(i, aFmt);
241 }
242 nMask <<= 1 ;
243 }
244 aSetAttr.Put(SvxNumBulletItem( *pNumRule ), nNumItemId);
245 OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
235 pNumRuleMgr->SetItems(&aNewAttr);
236 SvxNumRule aTmpRule( *pNumRule );
237 if ( nSId == FN_SVX_SET_BULLET && bToggle && nIdx==0 )
238 {
239 // for toggling bullets get default numbering rule
240 pNumRuleMgr->ApplyNumRule( aTmpRule, nIdx, nActNumLvl, true );
241 }
242 else
243 {
244 pNumRuleMgr->ApplyNumRule( aTmpRule, nIdx, nActNumLvl );
245 }
246
246
247 std::auto_ptr< OutlineViewModelChangeGuard > aGuard;
247 sal_uInt16 nMask = 1;
248 for(sal_uInt16 i = 0; i < pNumRule->GetLevelCount(); i++)
249 {
250 if(nActNumLvl & nMask)
251 {
252 SvxNumberFormat aFmt(aTmpRule.GetLevel(i));
253 pNumRule->SetLevel(i, aFmt);
254 }
255 nMask <<= 1;
256 }
257 }
258 }
248
259
249 if (mpView->ISA(OutlineView))
250 {
251 pOLV = static_cast<OutlineView*>(mpView)
252 ->GetViewByWindow(mpViewShell->GetActiveWindow());
260 OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
261 std::auto_ptr< OutlineViewModelChangeGuard > aGuard;
262 {
263 if (mpView->ISA(OutlineView))
264 {
265 pOLV = static_cast<OutlineView*>(mpView)
266 ->GetViewByWindow(mpViewShell->GetActiveWindow());
253
267
254 aGuard.reset( new OutlineViewModelChangeGuard( static_cast<OutlineView&>(*mpView) ) );
255 }
268 aGuard.reset( new OutlineViewModelChangeGuard( static_cast<OutlineView&>(*mpView) ) );
269 }
270 }
256
271
257 SdrOutliner* pOwner = mpView->GetTextEditOutliner();
258 bool bMasterView = false;
272 SdrOutliner* pOwner = bInMasterView ? mpView->GetTextEditOutliner() : 0;
273 const bool bOutlinerUndoEnabled = pOwner && !pOwner->IsInUndo() && pOwner->IsUndoEnabled();
274 SdrModel* pSdrModel = bInMasterView ? mpView->GetModel() : 0;
275 const bool bModelUndoEnabled = pSdrModel && pSdrModel->IsUndoEnabled();
259
276
260 DrawViewShell* pDrawViewShell = static_cast< DrawViewShell* >(mpViewShell);
261
262 if ( pOwner && pDrawViewShell && pDrawViewShell->GetEditMode() == EM_MASTERPAGE )
263 bMasterView = !pOwner->IsInUndo() && pOwner->IsUndoEnabled();
277 if ( bOutlinerUndoEnabled )
278 {
279 pOwner->UndoActionStart( OLUNDO_ATTR );
280 }
281 else if ( bModelUndoEnabled )
282 {
283 pSdrModel->BegUndo();
284 }
264
285
265 if( bMasterView )
266 {
267 pOwner->UndoActionStart( OLUNDO_ATTR );
268 pOLV->ToggleBullets( bBulletSwitch, sal_False, bMasterView, pNumRule,isRemoveNum);
269 mpView->SetAttributes(aSetAttr); //Modify for Sym2_3151
270 pOwner->UndoActionEnd( OLUNDO_ATTR );
271 }
272 else if( pOLV )
273 pOLV->ToggleBullets( bBulletSwitch, sal_False, bMasterView, pNumRule ,isRemoveNum);
274 else
275 {
276 sal_Bool bInMasterView = pDrawViewShell && pDrawViewShell->GetEditMode() == EM_MASTERPAGE;
277 SdrModel* pSdrModel = mpView->GetModel();
278 sal_Bool bModelUndoEnabled = pSdrModel ? pSdrModel->IsUndoEnabled() : sal_False;
279 if (bInMasterView && bModelUndoEnabled)
280 {
281 pSdrModel->BegUndo();
282 }
283 mpView->ToggleMarkedObjectsBullets(bBulletSwitch, sal_False, bInMasterView, pNumRule,isRemoveNum);
284 if (bInMasterView)
285 {
286 mpView->SetAttributes(aSetAttr);
287 }
288 if (bInMasterView && bModelUndoEnabled)
289 {
290 pSdrModel->EndUndo();
291 }
292 }
293 }
294 //End
295 }
296 delete pNumRule;
297 rReq.Done();
298}
286 if ( pOLV )
287 {
288 if ( bSwitchOff )
289 {
290 pOLV->SwitchOffBulletsNumbering( true );
291 }
292 else
293 {
294 pOLV->ToggleBulletsNumbering( bToggle, nSId == FN_SVX_SET_BULLET, bInMasterView ? 0 : pNumRule );
295 }
296 }
297 else
298 {
299 mpView->ChangeMarkedObjectsBulletsNumbering( bToggle, nSId == FN_SVX_SET_BULLET, bInMasterView ? 0 : pNumRule, bSwitchOff );
300 }
301 if ( bInMasterView )
302 {
303 SfxItemSet aSetAttr( mpViewShell->GetPool(), EE_ITEMS_START, EE_ITEMS_END );
304 aSetAttr.Put(SvxNumBulletItem( *pNumRule ), nNumItemId);
305 mpView->SetAttributes(aSetAttr);
306 }
299
307
300void FuOutlineBullet::SetCurrentBullet(SfxRequest& rReq)
301{
302 if (!mpDoc || !mpView)
303 return;
308 if( bOutlinerUndoEnabled )
309 {
310 pOwner->UndoActionEnd( OLUNDO_ATTR );
311 }
312 else if ( bModelUndoEnabled )
313 {
314 pSdrModel->EndUndo();
315 }
304
316
305 SfxItemSet aEditAttr( mpDoc->GetPool() );
306 mpView->GetAttributes( aEditAttr );
307
308 SfxItemSet aNewAttr( mpViewShell->GetPool(),
309 EE_ITEMS_START, EE_ITEMS_END );
310 aNewAttr.Put( aEditAttr, sal_False );
311
312 //Add for Sym2_3151, should add new attributes in an empty item set, then use this item set as parameter in SetAttributes()
313 SfxItemSet aSetAttr( mpViewShell->GetPool(),
314 EE_ITEMS_START, EE_ITEMS_END );
315
316 //Init bullet level in "Customize" tab page in bullet dialog in master page view
317 if( mpView && mpViewShell && mpViewShell->ISA(DrawViewShell)
318 && ((DrawViewShell *)mpViewShell)->GetEditMode() == EM_MASTERPAGE )
319 {
320 SdrObject* pObj = mpView->GetTextEditObject();
321 if( pObj && pObj->GetObjIdentifier() == OBJ_OUTLINETEXT )
322 {
323 sal_uInt16 nLevel = mpView->GetSelectionLevel();
324 if( nLevel != 0xFFFF )
325 {
326 //aNewAttr.MergeRange( SID_ATTR_NUMBERING_RULE, SID_PARAM_CUR_NUM_LEVEL );
327 //aNewAttr.Put( SfxUInt16Item( SID_PARAM_CUR_NUM_LEVEL, nLevel ) );
328 //save the itemset value
329 SfxItemSet aStoreSet( aNewAttr );
330 aNewAttr.ClearItem();
331 //extend range
332 aNewAttr.MergeRange( SID_PARAM_NUM_PRESET, SID_PARAM_CUR_NUM_LEVEL );
333 aNewAttr.Put( aStoreSet );
334 //put current level user selected
335 aNewAttr.Put( SfxUInt16Item( SID_PARAM_CUR_NUM_LEVEL, nLevel ) );
336 }
337 }
338 }
339 //End of add
340
341 sal_uInt16 nActNumLvl = (sal_uInt16)0xFFFF;
342 SvxNumRule* pNumRule = NULL;
343 const SfxPoolItem* pTmpItem=NULL;
344 sal_uInt32 nNumItemId = SID_ATTR_NUMBERING_RULE;
345
346 if(SFX_ITEM_SET == aNewAttr.GetItemState(SID_PARAM_CUR_NUM_LEVEL, sal_False, &pTmpItem))
347 nActNumLvl = ((const SfxUInt16Item*)pTmpItem)->GetValue();
348
349 pTmpItem=GetNumBulletItem(aNewAttr, nNumItemId);
350
351 if (pTmpItem)
352 pNumRule = new SvxNumRule(*((SvxNumBulletItem*)pTmpItem)->GetNumRule());
353
354 SFX_REQUEST_ARG( rReq, pItem, SfxUInt16Item, FN_SVX_SET_BULLET , sal_False );
355 if (pItem && pNumRule)
356 {
357 sal_uInt16 nIdx = pItem->GetValue();
358 // If the nIdx is (sal_uInt16)0xFFFF, means set bullet status to on/off
359 // And the bullet default status is 2.
360 bool bBulletSwitch = false;
361 sal_Bool isRemoveNum =false;
362 if( nIdx == (sal_uInt16)0xFFFF )
363 {
364 nIdx = 1;
365 bBulletSwitch = true;
366 }
367 if (nIdx == DEFAULT_NONE)
368 {
369 bBulletSwitch = false;
370 isRemoveNum = true;
371 }
372
373 nIdx--;
374 //Modified for Numbering&Bullets Dialog UX Enh(Story 992) by chengjh,2011.8.7
375
376 NBOTypeMgrBase* pBullets = NBOutlineTypeMgrFact::CreateInstance(eNBOType::MIXBULLETS);
377 if ( pBullets )
378 {
379 //Sym3_2508, set unit attribute to NB Manager
380 pBullets->SetItems(&aNewAttr);
381 SvxNumRule aTmpRule( *pNumRule );
382 //Sym3_3423 Always apply the "." if wants a default numbering rule
383 if (bBulletSwitch==true && nIdx==0) //want to reset bullet
384 {
385 pBullets->ApplyNumRule(aTmpRule,nIdx,nActNumLvl,true);
386 }
387 else {
388 pBullets->ApplyNumRule(aTmpRule,nIdx,nActNumLvl);
389 }
390 sal_uInt16 nMask = 1;
391 for(sal_uInt16 i = 0; i < pNumRule->GetLevelCount(); i++)
392 {
393 if(nActNumLvl & nMask)
394 {
395 SvxNumberFormat aFmt(aTmpRule.GetLevel(i));
396 pNumRule->SetLevel(i, aFmt);
397 }
398 nMask <<= 1;
399 }
400 aSetAttr.Put(SvxNumBulletItem( *pNumRule ), nNumItemId);
401
402 OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
403
404 std::auto_ptr< OutlineViewModelChangeGuard > aGuard;
405
406 if (mpView->ISA(OutlineView))
407 {
408 pOLV = static_cast<OutlineView*>(mpView)
409 ->GetViewByWindow(mpViewShell->GetActiveWindow());
410
411 aGuard.reset( new OutlineViewModelChangeGuard( static_cast<OutlineView&>(*mpView) ) );
412 }
413
414 SdrOutliner* pOwner = mpView->GetTextEditOutliner();
415 bool bMasterView = false;
416
417 DrawViewShell* pDrawViewShell = static_cast< DrawViewShell* >(mpViewShell);
418
419 if ( pOwner && pDrawViewShell && pDrawViewShell->GetEditMode() == EM_MASTERPAGE )
420 bMasterView = !pOwner->IsInUndo() && pOwner->IsUndoEnabled();
421
422 if( bMasterView )
423 {
424 pOwner->UndoActionStart( OLUNDO_ATTR );
425 pOLV->ToggleBullets( bBulletSwitch, sal_True, bMasterView, pNumRule, isRemoveNum );
426 mpView->SetAttributes(aSetAttr); //Modify for Sym2_3151
427 pOwner->UndoActionEnd( OLUNDO_ATTR );
428 }
429 else if( pOLV )
430 pOLV->ToggleBullets( bBulletSwitch, sal_True, bMasterView, pNumRule, isRemoveNum );
431 else
432 {
433 sal_Bool bInMasterView = pDrawViewShell && pDrawViewShell->GetEditMode() == EM_MASTERPAGE;
434 SdrModel* pSdrModel = mpView->GetModel();
435 sal_Bool bModelUndoEnabled = pSdrModel ? pSdrModel->IsUndoEnabled() : sal_False;
436 if (bInMasterView && bModelUndoEnabled)
437 {
438 pSdrModel->BegUndo();
439 }
440 mpView->ToggleMarkedObjectsBullets(bBulletSwitch, sal_True, bInMasterView, pNumRule, isRemoveNum );
441 if (bInMasterView)
442 {
443 mpView->SetAttributes(aSetAttr);
444 }
445 if (bInMasterView && bModelUndoEnabled)
446 {
447 pSdrModel->EndUndo();
448 }
449 }
450 }
451 //End
452 }
453 delete pNumRule;
454 rReq.Done();
317 delete pNumRule;
318 rReq.Done();
455}
456
457const SfxPoolItem* FuOutlineBullet::GetNumBulletItem(SfxItemSet& aNewAttr, sal_uInt32& nNumItemId)
458{
459 //SvxNumBulletItem* pRetItem = NULL;
460 const SfxPoolItem* pTmpItem = NULL;
461
462 if(aNewAttr.GetItemState(nNumItemId, sal_False, &pTmpItem) == SFX_ITEM_SET)

--- 80 unchanged lines hidden ---
319}
320
321const SfxPoolItem* FuOutlineBullet::GetNumBulletItem(SfxItemSet& aNewAttr, sal_uInt32& nNumItemId)
322{
323 //SvxNumBulletItem* pRetItem = NULL;
324 const SfxPoolItem* pTmpItem = NULL;
325
326 if(aNewAttr.GetItemState(nNumItemId, sal_False, &pTmpItem) == SFX_ITEM_SET)

--- 80 unchanged lines hidden ---