xref: /trunk/main/sd/source/ui/view/drviewsf.cxx (revision 1ff378ef)
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
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sd.hxx"
26 
27 #include "DrawViewShell.hxx"
28 #include <com/sun/star/form/FormButtonType.hpp>
29 #include <com/sun/star/beans/XPropertySet.hpp>
30 
31 #ifndef _SVXIDS_HRC
32 #include <svx/svxids.hrc>
33 #endif
34 #ifndef _GLOBL3D_HXX
35 #include <svx/globl3d.hxx>
36 #endif
37 #include <svx/hlnkitem.hxx>
38 #include <editeng/eeitem.hxx>
39 #ifndef _FLDITEM_HXX
40 #include <editeng/flditem.hxx>
41 #endif
42 #include <sfx2/viewfrm.hxx>
43 #include <svl/whiter.hxx>
44 #include <svl/eitem.hxx>
45 #include <svl/itempool.hxx>
46 #include <sfx2/tplpitem.hxx>
47 #ifndef _BINDING_HXX //autogen
48 #include <sfx2/bindings.hxx>
49 #endif
50 #include <sfx2/app.hxx>
51 #include <sfx2/templdlg.hxx>
52 #include <svx/xdef.hxx>
53 #include <svx/svddef.hxx>
54 #include <svx/fmglob.hxx>
55 #include <svx/svdouno.hxx>
56 #include <tools/urlobj.hxx>
57 #include <svx/fmshell.hxx>
58 #include <svl/cjkoptions.hxx>
59 
60 #ifndef SD_FRAME_VIEW
61 #include "FrameView.hxx"
62 #endif
63 #include "Outliner.hxx"
64 #include "app.hrc"
65 
66 #include "app.hxx"
67 #include "stlsheet.hxx"
68 #include "drawview.hxx"
69 #include "drawdoc.hxx"
70 #include "Window.hxx"
71 #include "ViewShellBase.hxx"
72 #include "FormShellManager.hxx"
73 #include "cfgids.hxx"
74 #include "anminfo.hxx"
75 
76 #include <editeng/lspcitem.hxx>
77 #include <editeng/ulspitem.hxx>
78 #include <editeng/lrspitem.hxx>
79 #include <editeng/escpitem.hxx>
80 using ::rtl::OUString;
81 using namespace ::com::sun::star;
82 
83 namespace sd {
84 
85 /*************************************************************************
86 |*
87 |* Status von Controller-SfxSlots setzen
88 |*
89 \************************************************************************/
90 
91 void DrawViewShell::GetCtrlState(SfxItemSet &rSet)
92 {
93 	if (rSet.GetItemState(SID_RELOAD) != SFX_ITEM_UNKNOWN)
94 	{
95 		// "Letzte Version" vom SFx en/disablen lassen
96         GetViewFrame()->GetSlotState (SID_RELOAD, NULL, &rSet);
97 	}
98 
99 	if (SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_HYPERLINK_GETLINK))
100 	{
101 		SvxHyperlinkItem aHLinkItem;
102 
103 		OutlinerView* pOLV = mpDrawView->GetTextEditOutlinerView();
104 
105 		if (pOLV)
106 		{
107 			bool bField = false;
108 			const SvxFieldItem* pFieldItem = pOLV->GetFieldAtSelection();
109 			if (pFieldItem)
110 			{
111                 ESelection aSel = pOLV->GetSelection();
112                 if ( abs( aSel.nEndPos - aSel.nStartPos ) == 1 )
113                 {
114 				    const SvxFieldData* pField = pFieldItem->GetField();
115 				    if (pField->ISA(SvxURLField))
116 				    {
117 					    aHLinkItem.SetName(((const SvxURLField*) pField)->GetRepresentation());
118 					    aHLinkItem.SetURL(((const SvxURLField*) pField)->GetURL());
119 					    aHLinkItem.SetTargetFrame(((const SvxURLField*) pField)->GetTargetFrame());
120 						bField = true;
121 				    }
122                 }
123 			}
124 			if (!bField)
125 			{
126 				// use selected text as name for urls
127 				String sReturn = pOLV->GetSelected();
128 				sReturn.Erase(255);
129 				sReturn.EraseTrailingChars();
130 				aHLinkItem.SetName(sReturn);
131 			}
132 		}
133 		else
134 		{
135 			if (mpDrawView->GetMarkedObjectList().GetMarkCount() > 0)
136 			{
137                 bool bFound = false;
138 
139                 SdrObject* pMarkedObj = mpDrawView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
140                 if( pMarkedObj && (FmFormInventor == pMarkedObj->GetObjInventor()) )
141                 {
142 				    SdrUnoObj* pUnoCtrl = dynamic_cast< SdrUnoObj* >( pMarkedObj );
143 
144 				    if(pUnoCtrl) try
145 				    {
146                         uno::Reference< awt::XControlModel > xControlModel( pUnoCtrl->GetUnoControlModel(), uno::UNO_QUERY_THROW );
147 					    uno::Reference< beans::XPropertySet > xPropSet( xControlModel, uno::UNO_QUERY_THROW );
148 					    uno::Reference< beans::XPropertySetInfo > xPropInfo( xPropSet->getPropertySetInfo(), uno::UNO_QUERY_THROW );
149 
150 					    form::FormButtonType eButtonType = form::FormButtonType_URL;
151                         const OUString sButtonType( RTL_CONSTASCII_USTRINGPARAM( "ButtonType" ) );
152 					    if(xPropInfo->hasPropertyByName( sButtonType ) && (xPropSet->getPropertyValue( sButtonType ) >>= eButtonType ) )
153 				        {
154 					        OUString aString;
155 
156 					        // Label
157                             const OUString sLabel( RTL_CONSTASCII_USTRINGPARAM( "Label" ) );
158 					        if(xPropInfo->hasPropertyByName(sLabel))
159                             {
160 						        if( xPropSet->getPropertyValue(sLabel) >>= aString )
161     						        aHLinkItem.SetName(String( aString ));
162                             }
163 
164 					        // URL
165                             const OUString sTargetURL(RTL_CONSTASCII_USTRINGPARAM( "TargetURL" ));
166 					        if(xPropInfo->hasPropertyByName(sTargetURL))
167                             {
168 						        if( xPropSet->getPropertyValue(sTargetURL) >>= aString )
169     						        aHLinkItem.SetURL(String( aString ));
170                             }
171 
172 					        // Target
173                             const OUString sTargetFrame( RTL_CONSTASCII_USTRINGPARAM( "TargetFrame" ) );
174 					        if(xPropInfo->hasPropertyByName(sTargetFrame) )
175                             {
176 					            if( xPropSet->getPropertyValue(sTargetFrame) >>= aString )
177 						            aHLinkItem.SetTargetFrame(String( aString ));
178                             }
179 
180 					        aHLinkItem.SetInsertMode(HLINK_BUTTON);
181                             bFound = true;
182 				        }
183                     }
184                     catch( uno::Exception& )
185                     {
186                     }
187 				}
188 
189                 // try interaction link
190                 if( !bFound && pMarkedObj )
191                 {
192                     SdAnimationInfo* pInfo = SdDrawDocument::GetShapeUserData(*pMarkedObj);
193                     if( pInfo && (pInfo->meClickAction == presentation::ClickAction_DOCUMENT) )
194                         aHLinkItem.SetURL( pInfo->GetBookmark());
195                     aHLinkItem.SetInsertMode(HLINK_BUTTON);
196                 }
197 			}
198 		}
199 
200 		rSet.Put(aHLinkItem);
201 	}
202 	rSet.Put( SfxBoolItem( SID_READONLY_MODE, mbReadOnly ) );
203 
204 	// Ausgabequalitaet
205 	if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_OUTPUT_QUALITY_COLOR ) ||
206 		SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_OUTPUT_QUALITY_GRAYSCALE ) ||
207 		SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_OUTPUT_QUALITY_BLACKWHITE ) ||
208         SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_OUTPUT_QUALITY_CONTRAST ) )
209 	{
210 		const sal_uLong nMode = (sal_Int32)GetActiveWindow()->GetDrawMode();
211 		rSet.Put( SfxBoolItem( SID_OUTPUT_QUALITY_COLOR, (sal_Bool)((sal_uLong)OUTPUT_DRAWMODE_COLOR == nMode) ) );
212 		rSet.Put( SfxBoolItem( SID_OUTPUT_QUALITY_GRAYSCALE, (sal_Bool)((sal_uLong)OUTPUT_DRAWMODE_GRAYSCALE == nMode) ) );
213 		rSet.Put( SfxBoolItem( SID_OUTPUT_QUALITY_BLACKWHITE, (sal_Bool)((sal_uLong)OUTPUT_DRAWMODE_BLACKWHITE == nMode) ) );
214 		rSet.Put( SfxBoolItem( SID_OUTPUT_QUALITY_CONTRAST, (sal_Bool)((sal_uLong)OUTPUT_DRAWMODE_CONTRAST == nMode) ) );
215 	}
216 
217 	if ( SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_MAIL_SCROLLBODY_PAGEDOWN) )
218 	{
219 		rSet.Put( SfxBoolItem( SID_MAIL_SCROLLBODY_PAGEDOWN, sal_True ) );
220 	}
221 
222 	if ( SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_ATTR_YEAR2000) )
223 	{
224         FmFormShell* pFormShell = GetViewShellBase().GetFormShellManager()->GetFormShell();
225         if (pFormShell != NULL)
226         {
227             sal_uInt16 nState = 0;
228             if (pFormShell->GetY2KState(nState))
229                 rSet.Put( SfxUInt16Item( SID_ATTR_YEAR2000, nState ) );
230             else
231                 rSet.DisableItem( SID_ATTR_YEAR2000 );
232         }
233 	}
234 
235 	if ( !GetView()->GetTextEditOutliner() )
236 	{
237         SvtCJKOptions aCJKOptions;
238 		if( !aCJKOptions.IsChangeCaseMapEnabled() )
239         {
240             GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HALFWIDTH, sal_False );
241             GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_FULLWIDTH, sal_False );
242             GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HIRAGANA, sal_False );
243             GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_KATAGANA, sal_False );
244         }
245         else
246         {
247             GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HALFWIDTH, sal_True );
248             GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_FULLWIDTH, sal_True );
249             GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HIRAGANA, sal_True );
250             GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_KATAGANA, sal_True );
251         }
252 
253         rSet.DisableItem( SID_TRANSLITERATE_SENTENCE_CASE );
254         rSet.DisableItem( SID_TRANSLITERATE_TITLE_CASE );
255         rSet.DisableItem( SID_TRANSLITERATE_TOGGLE_CASE );
256         rSet.DisableItem( SID_TRANSLITERATE_UPPER );
257 		rSet.DisableItem( SID_TRANSLITERATE_LOWER );
258 		rSet.DisableItem( SID_TRANSLITERATE_HALFWIDTH );
259 		rSet.DisableItem( SID_TRANSLITERATE_FULLWIDTH );
260 		rSet.DisableItem( SID_TRANSLITERATE_HIRAGANA );
261 		rSet.DisableItem( SID_TRANSLITERATE_KATAGANA );
262 	}
263 	else
264 	{
265         SvtCJKOptions aCJKOptions;
266 		if( !aCJKOptions.IsChangeCaseMapEnabled() )
267 		{
268             GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HALFWIDTH, sal_False );
269             GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_FULLWIDTH, sal_False );
270             GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HIRAGANA, sal_False );
271             GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_KATAGANA, sal_False );
272             rSet.DisableItem( SID_TRANSLITERATE_HALFWIDTH );
273 			rSet.DisableItem( SID_TRANSLITERATE_FULLWIDTH );
274 			rSet.DisableItem( SID_TRANSLITERATE_HIRAGANA );
275 			rSet.DisableItem( SID_TRANSLITERATE_KATAGANA );
276 		}
277         else
278         {
279             GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HALFWIDTH, sal_True );
280             GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_FULLWIDTH, sal_True );
281             GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HIRAGANA, sal_True );
282             GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_KATAGANA, sal_True );
283         }
284 	}
285 }
286 
287 
288 /*************************************************************************
289 |*
290 |* Status der Attribut-Items
291 |*
292 \************************************************************************/
293 
294 void DrawViewShell::GetAttrState( SfxItemSet& rSet )
295 {
296 	SfxWhichIter	aIter( rSet );
297 	sal_uInt16			nWhich = aIter.FirstWhich();
298 
299 	sal_Bool	bAttr = sal_False;
300 	SfxAllItemSet aAllSet( *rSet.GetPool() );
301 
302 	while ( nWhich )
303 	{
304 		sal_uInt16 nSlotId = SfxItemPool::IsWhich(nWhich)
305 			? GetPool().GetSlotId(nWhich)
306 			: nWhich;
307 		switch ( nSlotId )
308 		{
309 			case SID_ATTR_PARA_LRSPACE:
310 			{
311 				SfxItemSet aAttrs( GetDoc()->GetPool() );
312 				mpDrawView->GetAttributes( aAttrs );
313 				SvxLRSpaceItem aLRSpace = ( (const SvxLRSpaceItem&) aAttrs.Get( EE_PARA_LRSPACE ) );
314 				aLRSpace.SetWhich(SID_ATTR_PARA_LRSPACE);
315 				rSet.Put(aLRSpace);
316 				bAttr = sal_True;
317 				Invalidate(SID_ATTR_PARA_LRSPACE);
318 			}
319 			break;
320 			case SID_ATTR_PARA_LINESPACE:
321 			{
322 				SfxItemSet aAttrs( GetDoc()->GetPool() );
323 				mpDrawView->GetAttributes( aAttrs );
324 				SvxLineSpacingItem aLineLR = ( (const SvxLineSpacingItem&) aAttrs.Get( EE_PARA_SBL ) );
325 				rSet.Put(aLineLR);
326 				bAttr = sal_True;
327 				Invalidate(SID_ATTR_PARA_LINESPACE);
328 			}
329 			break;
330 			case SID_ATTR_PARA_ULSPACE:
331 			{
332 				SfxItemSet aAttrs( GetDoc()->GetPool() );
333 				mpDrawView->GetAttributes( aAttrs );
334 				SvxULSpaceItem aULSP = ( (const SvxULSpaceItem&) aAttrs.Get( EE_PARA_ULSPACE ) );
335 				aULSP.SetWhich(SID_ATTR_PARA_ULSPACE);
336 				rSet.Put(aULSP);
337 				bAttr = sal_True;
338 				Invalidate(SID_ATTR_PARA_ULSPACE);
339 			}
340 			break;
341 			case SID_ATTR_FILL_STYLE:
342 			case SID_ATTR_FILL_COLOR:
343 			case SID_ATTR_FILL_GRADIENT:
344 			case SID_ATTR_FILL_HATCH:
345 			case SID_ATTR_FILL_BITMAP:
346 			case SID_ATTR_FILL_SHADOW:
347             case SID_ATTR_FILL_TRANSPARENCE:
348             case SID_ATTR_FILL_FLOATTRANSPARENCE:
349 			case SID_ATTR_LINE_STYLE:
350 			case SID_ATTR_LINE_DASH:
351 			case SID_ATTR_LINE_WIDTH:
352 			case SID_ATTR_LINE_COLOR:
353             case SID_ATTR_LINE_TRANSPARENCE:
354             case SID_ATTR_LINE_JOINT:
355             case SID_ATTR_LINE_CAP:
356 			case SID_ATTR_TEXT_FITTOSIZE:
357 			case SID_ATTR_CHAR_FONT:
358 			case SID_ATTR_CHAR_FONTHEIGHT:
359 			case SID_ATTR_CHAR_SHADOWED:
360 			case SID_ATTR_CHAR_POSTURE:
361 			case SID_ATTR_CHAR_UNDERLINE:
362 			case SID_ATTR_CHAR_STRIKEOUT:
363 			case SID_ATTR_CHAR_WEIGHT:
364 			case SID_ATTR_CHAR_COLOR:
365 			case SID_ATTR_CHAR_KERNING:
366 			case SID_SET_SUB_SCRIPT:
367 			case SID_SET_SUPER_SCRIPT:
368 			{
369 				bAttr = sal_True;
370 			}
371 			break;
372 
373 			case SID_HYPHENATION:
374 			{
375 				SfxItemSet aAttrs( GetDoc()->GetPool() );
376 				mpDrawView->GetAttributes( aAttrs );
377 				if( aAttrs.GetItemState( EE_PARA_HYPHENATE ) >= SFX_ITEM_AVAILABLE )
378 				{
379 					sal_Bool bValue = ( (const SfxBoolItem&) aAttrs.Get( EE_PARA_HYPHENATE ) ).GetValue();
380 					rSet.Put( SfxBoolItem( SID_HYPHENATION, bValue ) );
381 				}
382 			}
383 			break;
384 
385 			case SID_STYLE_FAMILY2:
386 			case SID_STYLE_FAMILY3:
387 			case SID_STYLE_FAMILY5:
388 			case SID_STYLE_APPLY: // StyleControl
389 			{
390 				SfxStyleSheet* pStyleSheet = mpDrawView->GetStyleSheet();
391 				if( pStyleSheet )
392 				{
393 					if( nSlotId != SID_STYLE_APPLY && !mpDrawView->AreObjectsMarked() )
394 					{
395 						SfxTemplateItem aTmpItem( nWhich, String() );
396 						aAllSet.Put( aTmpItem, aTmpItem.Which()  );
397 					}
398 					else
399 					{
400 						if (pStyleSheet->GetFamily() == SD_STYLE_FAMILY_MASTERPAGE)
401 							pStyleSheet = ((SdStyleSheet*)pStyleSheet)->GetPseudoStyleSheet();
402 
403 						if( pStyleSheet )
404 						{
405 							SfxStyleFamily eFamily = pStyleSheet->GetFamily();
406 
407 							if ((eFamily == SD_STYLE_FAMILY_GRAPHICS &&		nSlotId == SID_STYLE_FAMILY2)       ||
408 								(eFamily == SD_STYLE_FAMILY_CELL	 &&	nSlotId == SID_STYLE_FAMILY3)		||
409 								(eFamily == SD_STYLE_FAMILY_PSEUDO &&	nSlotId == SID_STYLE_FAMILY5))
410 							{
411 								SfxTemplateItem aTmpItem ( nWhich, pStyleSheet->GetName() );
412 								aAllSet.Put( aTmpItem, aTmpItem.Which()  );
413 							}
414 							else
415 							{
416 								SfxTemplateItem aTmpItem(nWhich, String());
417 								aAllSet.Put(aTmpItem,aTmpItem.Which()  );
418 							}
419 						}
420 					}
421 				}
422 				else
423 				{	SfxTemplateItem aItem( nWhich, String() );
424 					aAllSet.Put( aItem, aItem.Which() );
425 					// rSet.DisableItem( nWhich );
426 				}
427 			}
428 			break;
429 
430 			case SID_SET_DEFAULT:
431 			{
432                 if( !mpDrawView->GetMarkedObjectList().GetMarkCount() ||
433                     ( !mpDrawView->IsTextEdit() && !mpDrawView->GetStyleSheet() )
434                   )
435 					rSet.DisableItem( nWhich );
436 			}
437 			break;
438 
439 			case SID_STYLE_WATERCAN:
440 			{
441 				ISfxTemplateCommon* pTemplateCommon = SFX_APP()->GetCurrentTemplateCommon(GetViewFrame()->GetBindings());
442 				if (pTemplateCommon && pTemplateCommon->GetActualFamily() == SD_STYLE_FAMILY_PSEUDO)
443 					rSet.Put(SfxBoolItem(nWhich,sal_False));
444 				else
445 				{
446 					SfxBoolItem aItem(nWhich, SD_MOD()->GetWaterCan());
447 					aAllSet.Put( aItem, aItem.Which());
448 				}
449 			}
450 			break;
451 
452 			case SID_STYLE_NEW:
453 			{
454 				ISfxTemplateCommon* pTemplateCommon = SFX_APP()->GetCurrentTemplateCommon(GetViewFrame()->GetBindings());
455 				if (pTemplateCommon && pTemplateCommon->GetActualFamily() == SD_STYLE_FAMILY_PSEUDO)
456 					rSet.DisableItem(nWhich);
457 			}
458 			break;
459 
460 			case SID_STYLE_DRAGHIERARCHIE:
461 			{
462 				ISfxTemplateCommon* pTemplateCommon = SFX_APP()->GetCurrentTemplateCommon(GetViewFrame()->GetBindings());
463 				if (pTemplateCommon && pTemplateCommon->GetActualFamily() == SD_STYLE_FAMILY_PSEUDO)
464 					rSet.DisableItem(nWhich);
465 			}
466 			break;
467 
468 			case SID_STYLE_NEW_BY_EXAMPLE:
469 			{
470 				// PseudoStyleSheets koennen nicht 'by Example' erzeugt werden;
471 				// normale StyleSheets brauchen dafuer ein selektiertes Objekt
472 				ISfxTemplateCommon* pTemplCommon = SFX_APP()->GetCurrentTemplateCommon(GetViewFrame()->GetBindings());
473 				if (pTemplCommon)
474 				{
475 					if (pTemplCommon->GetActualFamily() == SD_STYLE_FAMILY_PSEUDO)
476 					{
477 						rSet.DisableItem(nWhich);
478 					}
479 					else if (pTemplCommon->GetActualFamily() == SD_STYLE_FAMILY_GRAPHICS)
480 					{
481 						if (!mpDrawView->AreObjectsMarked())
482 						{
483 							rSet.DisableItem(nWhich);
484 						}
485 					}
486 				}
487 				// falls (noch) kein Gestalter da ist, muessen wir uns auf den
488 				// View-Zustand zurueckziehen; eine aktuell eingestellte Familie
489 				// kann nicht beruecksichtigt werden
490 				else
491 				{
492 					if (!mpDrawView->AreObjectsMarked())
493 					{
494 						rSet.DisableItem(nWhich);
495 					}
496 				}
497 
498 			}
499 			break;
500 
501 			case SID_STYLE_UPDATE_BY_EXAMPLE:
502 			{
503 				if (!mpDrawView->AreObjectsMarked())
504 				{
505 					rSet.DisableItem(nWhich);
506 				}
507 			}
508 			break;
509 			case FN_BUL_NUM_RULE_INDEX:
510 			case FN_NUM_NUM_RULE_INDEX:
511 			{
512 				SfxItemSet aEditAttr( GetDoc()->GetPool() );
513 				mpDrawView->GetAttributes( aEditAttr );
514 
515 				SfxItemSet aNewAttr( GetPool(), EE_ITEMS_START, EE_ITEMS_END );
516 				aNewAttr.Put( aEditAttr, sal_False );
517 
518 
519 				sal_uInt16 nActNumLvl = (sal_uInt16)0xFFFF;
520 				SvxNumRule* pNumRule = NULL;
521 				const SfxPoolItem* pTmpItem=NULL;
522 				sal_uInt16 nNumItemId = SID_ATTR_NUMBERING_RULE;
523 
524 				//if(SFX_ITEM_SET == aNewAttr.GetItemState(SID_PARAM_CUR_NUM_LEVEL, sal_False, &pTmpItem))
525 				//	nActNumLvl = ((const SfxUInt16Item*)pTmpItem)->GetValue();
526 				rSet.Put(SfxUInt16Item(FN_NUM_NUM_RULE_INDEX,DEFAULT_NONE));
527 				rSet.Put(SfxUInt16Item(FN_BUL_NUM_RULE_INDEX,DEFAULT_NONE));
528 				nActNumLvl = mpDrawView->GetSelectionLevel();
529 				pTmpItem=GetNumBulletItem(aNewAttr, nNumItemId);
530 
531 				if (pTmpItem)
532 					pNumRule = new SvxNumRule(*((SvxNumBulletItem*)pTmpItem)->GetNumRule());
533 
534 				if ( pNumRule )
535 				{
536 					sal_uInt16 nMask = 1;
537 					sal_uInt16 nCount = 0;
538 					sal_uInt16 nCurLevel = (sal_uInt16)0xFFFF;
539 					for(sal_uInt16 i = 0; i < pNumRule->GetLevelCount(); i++)
540 					{
541 						if(nActNumLvl & nMask)
542 						{
543 							nCount++;
544 							nCurLevel = i;
545 						}
546 						nMask <<= 1;
547 					}
548 					if ( nCount == 1 )
549 					{
550 						sal_Bool bBullets = sal_False;
551 						const SvxNumberFormat* pNumFmt = pNumRule->Get(nCurLevel);
552 						if ( pNumFmt )
553 						{
554 							switch(pNumFmt->GetNumberingType())
555 							{
556 								case SVX_NUM_CHAR_SPECIAL:
557 								case SVX_NUM_BITMAP:
558 									bBullets = sal_True;
559 									break;
560 
561 								default:
562 									bBullets = sal_False;
563 							}
564 
565 							rSet.Put(SfxUInt16Item(FN_BUL_NUM_RULE_INDEX,(sal_uInt16)0xFFFF));
566 							rSet.Put(SfxUInt16Item(FN_NUM_NUM_RULE_INDEX,(sal_uInt16)0xFFFF));
567 							if ( bBullets )
568 							{
569 								NBOTypeMgrBase* pBullets = NBOutlineTypeMgrFact::CreateInstance(eNBOType::MIXBULLETS);
570 								if ( pBullets )
571 								{
572 									sal_uInt16 nBulIndex = pBullets->GetNBOIndexForNumRule(*pNumRule,nActNumLvl);
573 									 rSet.Put(SfxUInt16Item(FN_BUL_NUM_RULE_INDEX,nBulIndex));
574 								}
575 							}else
576 							{
577 								NBOTypeMgrBase* pNumbering = NBOutlineTypeMgrFact::CreateInstance(eNBOType::NUMBERING);
578 								if ( pNumbering )
579 								{
580 									sal_uInt16 nBulIndex = pNumbering->GetNBOIndexForNumRule(*pNumRule,nActNumLvl);
581 									 rSet.Put(SfxUInt16Item(FN_NUM_NUM_RULE_INDEX,nBulIndex));
582 								}
583 							}
584 						}
585 					}
586 				}
587 			}
588             		break;
589 			//End
590 			// Added by Li Hui for story 179.
591 			case FN_NUM_BULLET_ON:
592 			case FN_NUM_NUMBERING_ON:
593 			{
594 				sal_Bool bEnable = sal_False;
595 				const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
596 				const ULONG nMarkCount = rMarkList.GetMarkCount();
597 				for (ULONG nIndex = 0; nIndex < nMarkCount; nIndex++)
598 				{
599 					SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >(rMarkList.GetMark(nIndex)->GetMarkedSdrObj());
600 					if (pTextObj && pTextObj->GetObjInventor() == SdrInventor)
601 					{
602 						if (pTextObj->GetObjIdentifier() != OBJ_OLE2)
603 						{
604 							bEnable = sal_True;
605 							break;
606 						}
607 					}
608 				}
609 				if (bEnable)
610 				{
611 					rSet.Put(SfxBoolItem(FN_NUM_BULLET_ON, sal_False));
612 					rSet.Put(SfxBoolItem(FN_NUM_NUMBERING_ON, sal_False));
613 				}
614 				else
615 				{
616 					rSet.DisableItem(FN_NUM_BULLET_ON);
617 					rSet.DisableItem(FN_NUM_NUMBERING_ON);
618 				}
619 			}
620 			break;
621 		}
622 		nWhich = aIter.NextWhich();
623 	}
624 
625 	SfxItemSet* pSet = NULL;
626 
627 	if( bAttr )
628 	{
629 		pSet = new SfxItemSet( GetDoc()->GetPool() );
630 		mpDrawView->GetAttributes( *pSet );
631 		rSet.Put( *pSet, sal_False );
632 	}
633 
634 	rSet.Put( aAllSet, sal_False );
635 
636 	// Flaechen und/oder Linienattribute wurden geaendert
637 	if( bAttr && pSet )
638 	{
639 		// Wenn die View selektierte Objekte besitzt, muessen entspr. Items
640 		// von SFX_ITEM_DEFAULT (_ON) auf SFX_ITEM_DISABLED geaendert werden
641 		if( mpDrawView->AreObjectsMarked() )
642 		{
643 			SfxWhichIter aNewIter( *pSet, XATTR_LINE_FIRST, XATTR_FILL_LAST );
644 			nWhich = aNewIter.FirstWhich();
645 			while( nWhich )
646 			{
647 				if( SFX_ITEM_DEFAULT == pSet->GetItemState( nWhich ) )
648 				{
649 					rSet.ClearItem( nWhich );
650 					rSet.DisableItem( nWhich );
651 				}
652 				nWhich = aNewIter.NextWhich();
653 			}
654 		}
655 
656 		SfxItemState eState = pSet->GetItemState( EE_PARA_LRSPACE );
657 		if ( eState == SFX_ITEM_DONTCARE )
658 		{
659 			rSet.InvalidateItem(EE_PARA_LRSPACE);
660 			rSet.InvalidateItem(SID_ATTR_PARA_LRSPACE);
661 		}
662 		eState = pSet->GetItemState( EE_PARA_SBL );
663 		if ( eState == SFX_ITEM_DONTCARE )
664 		{
665 			rSet.InvalidateItem(EE_PARA_SBL);
666 			rSet.InvalidateItem(SID_ATTR_PARA_LINESPACE);
667 		}
668 		eState = pSet->GetItemState( EE_PARA_ULSPACE );
669 		if ( eState == SFX_ITEM_DONTCARE )
670 		{
671 			rSet.InvalidateItem(EE_PARA_ULSPACE);
672 			rSet.InvalidateItem(SID_ATTR_PARA_ULSPACE);
673 		}
674 
675 		SvxEscapement eEsc = (SvxEscapement) ( (const SvxEscapementItem&)
676 						pSet->Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue();
677 		if( eEsc == SVX_ESCAPEMENT_SUPERSCRIPT )
678 		{
679 			rSet.Put( SfxBoolItem( SID_SET_SUPER_SCRIPT, sal_True ) );
680 		}
681 		else if( eEsc == SVX_ESCAPEMENT_SUBSCRIPT )
682 		{
683 			rSet.Put( SfxBoolItem( SID_SET_SUB_SCRIPT, sal_True ) );
684 		}
685 
686 		eState = pSet->GetItemState( EE_CHAR_KERNING, sal_True );
687 		if ( eState == SFX_ITEM_DONTCARE )
688 		{
689 			rSet.InvalidateItem(EE_CHAR_KERNING);
690 			rSet.InvalidateItem(SID_ATTR_CHAR_KERNING);
691 		}
692 		delete pSet;
693 	}
694 }
695 
696 
697 /*************************************************************************
698 |*
699 |* Text der Selektion zurueckgeben
700 |*
701 \************************************************************************/
702 
703 String DrawViewShell::GetSelectionText(sal_Bool bCompleteWords)
704 {
705 	String aStrSelection;
706 	::Outliner* pOl = mpDrawView->GetTextEditOutliner();
707 	OutlinerView* pOlView = mpDrawView->GetTextEditOutlinerView();
708 
709 	if (pOl && pOlView)
710 	{
711 		if (bCompleteWords)
712 		{
713 			ESelection aSel = pOlView->GetSelection();
714 			String aStrCurrentDelimiters = pOl->GetWordDelimiters();
715 
716 			pOl->SetWordDelimiters( String( RTL_CONSTASCII_USTRINGPARAM( " .,;\"'" )));
717 			aStrSelection = pOl->GetWord( aSel.nEndPara, aSel.nEndPos );
718 			pOl->SetWordDelimiters( aStrCurrentDelimiters );
719 		}
720 		else
721 		{
722 			aStrSelection = pOlView->GetSelected();
723 		}
724 	}
725 
726 	return (aStrSelection);
727 }
728 
729 /*************************************************************************
730 |*
731 |* Ist etwas selektiert?
732 |*
733 \************************************************************************/
734 
735 sal_Bool DrawViewShell::HasSelection(sal_Bool bText) const
736 {
737 	sal_Bool bReturn = sal_False;
738 
739 	if (bText)
740 	{
741 		OutlinerView* pOlView = mpDrawView->GetTextEditOutlinerView();
742 
743 		if (pOlView && pOlView->GetSelected().Len() != 0)
744 		{
745 			bReturn = sal_True;
746 		}
747 	}
748 	else if (mpDrawView->GetMarkedObjectList().GetMarkCount() != 0)
749 	{
750 		bReturn = sal_True;
751 	}
752 
753 	return bReturn;
754 }
755 
756 } // end of namespace sd
757