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