xref: /trunk/main/sd/source/ui/view/drviews7.cxx (revision 7950f2af)
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 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
27 #include <com/sun/star/lang/Locale.hpp>
28 #include <com/sun/star/linguistic2/XThesaurus.hpp>
29 #include <svx/fmglob.hxx>
30 #include <svx/globl3d.hxx>
31 #include <svx/svdouno.hxx>
32 #include <editeng/eeitem.hxx>
33 #include <editeng/flditem.hxx>
34 #include <editeng/outlobj.hxx>
35 #include <svx/svxids.hrc>
36 #include <svx/svdpagv.hxx>
37 #include <svx/clipfmtitem.hxx>
38 #include <svx/fmshell.hxx>
39 #include <svl/eitem.hxx>
40 #include <svl/aeitem.hxx>
41 #include <svl/stritem.hxx>
42 #include <svl/visitem.hxx>
43 #include <svl/whiter.hxx>
44 #include <sfx2/dispatch.hxx>
45 #include <svx/svdograf.hxx>
46 #include <editeng/unolingu.hxx>
47 #include <svx/extrusionbar.hxx>
48 #include <svx/fontworkbar.hxx>
49 
50 // #UndoRedo#
51 #include <svl/slstitm.hxx>
52 #include <sfx2/app.hxx>
53 #include <svtools/insdlg.hxx>
54 #include <unotools/moduleoptions.hxx>
55 #include <svl/languageoptions.hxx>
56 #include <comphelper/processfactory.hxx>
57 #include <sfx2/request.hxx>
58 
59 
60 #include <svx/pfiledlg.hxx>
61 #include <svx/grafctrl.hxx>
62 #include <svtools/cliplistener.hxx>
63 #include <sfx2/viewfrm.hxx>
64 
65 #include "app.hrc"
66 #include "glob.hrc"
67 #include "res_bmp.hrc"
68 #include "PresentationViewShell.hxx"
69 
70 #include "misc.hxx"
71 #include "Outliner.hxx"
72 #include "drawdoc.hxx"
73 #include "sdresid.hxx"
74 #include "sdpage.hxx"
75 #include "Client.hxx"
76 #include "DrawDocShell.hxx"
77 #include "zoomlist.hxx"
78 #include "slideshow.hxx"
79 #include "drawview.hxx"
80 #include "ViewShellBase.hxx"
81 #include "ViewShellManager.hxx"
82 #include "LayerTabBar.hxx"
83 #include "fupoor.hxx"
84 #include "Window.hxx"
85 #include "fuediglu.hxx"
86 #include "fubullet.hxx"
87 #include "fuformatpaintbrush.hxx"
88 
89 using ::rtl::OUString;
90 using namespace ::com::sun::star;
91 using namespace ::com::sun::star::uno;
92 using namespace ::com::sun::star::lang;
93 using namespace ::com::sun::star::linguistic2;
94 
95 /** Create a list of clipboard formats that are supported both from the
96     current clipboard content and the DrawViewShell.
97     The list is stored in a new instance of SvxClipboardFmtItem.
98 */
GetSupportedClipboardFormats(TransferableDataHelper & rDataHelper)99 ::std::auto_ptr<SvxClipboardFmtItem> GetSupportedClipboardFormats (
100     TransferableDataHelper& rDataHelper)
101 {
102     ::std::auto_ptr<SvxClipboardFmtItem> pResult (
103         new SvxClipboardFmtItem(SID_CLIPBOARD_FORMAT_ITEMS));
104 
105     sal_uInt32 nFormatCount (rDataHelper.GetFormatCount());
106     for (sal_uInt32 i=0; i<nFormatCount; i++)
107     {
108         const SotFormatStringId nTestFormat = rDataHelper.GetFormat(i);
109 
110         // Check if the current format is the same as one that has already
111         // been handled.
112         bool bDuplicate (false);
113         for (sal_uInt32 j=0; j<i; j++)
114         {
115             if (nTestFormat == rDataHelper.GetFormat(j))
116             {
117                 bDuplicate = true;
118                 break;
119             }
120         }
121 
122         // Look up the format among those that are supported by the
123         // DrawViewShell.
124         if ( ! bDuplicate)
125         {
126             switch (nTestFormat)
127             {
128                 case SOT_FORMATSTR_ID_EMBED_SOURCE:
129                 {
130                     String sName;
131 
132                     TransferableObjectDescriptor aDescriptor;
133                     if (rDataHelper.GetTransferableObjectDescriptor(
134                         SOT_FORMATSTR_ID_OBJECTDESCRIPTOR, aDescriptor))
135                         {
136                             sName = aDescriptor.maTypeName;
137                         }
138                     if (sName.Len() > 0)
139                         pResult->AddClipbrdFormat(nTestFormat, sName);
140                     else
141                         pResult->AddClipbrdFormat(nTestFormat);
142 
143                     break;
144                 }
145 
146                 case SOT_FORMATSTR_ID_LINK_SOURCE:
147                 case SOT_FORMATSTR_ID_DRAWING:
148                 case SOT_FORMATSTR_ID_SVXB:
149                 case FORMAT_GDIMETAFILE:
150                 case FORMAT_BITMAP:
151                 case SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK:
152                 case FORMAT_STRING:
153                 case SOT_FORMATSTR_ID_HTML:
154                 case FORMAT_RTF:
155                 case SOT_FORMATSTR_ID_EDITENGINE:
156                     pResult->AddClipbrdFormat(nTestFormat);
157                     break;
158             }
159         }
160     }
161 
162     // Check some OLE formats whose names are handled differently.
163     SotFormatStringId nFormat (SOT_FORMATSTR_ID_EMBED_SOURCE_OLE);
164     bool bHasFormat (rDataHelper.HasFormat(nFormat));
165     if ( ! bHasFormat)
166     {
167         bHasFormat = rDataHelper.HasFormat(nFormat);
168     }
169     if (bHasFormat)
170     {
171         String sName;
172         String sSource;
173         if (SvPasteObjectHelper::GetEmbeddedName (rDataHelper, sName, sSource, nFormat))
174             pResult->AddClipbrdFormat (nFormat, sName);
175     }
176 
177     return pResult;
178 }
179 
180 namespace sd {
181 
IMPL_LINK(DrawViewShell,ClipboardChanged,TransferableDataHelper *,pDataHelper)182 IMPL_LINK( DrawViewShell, ClipboardChanged, TransferableDataHelper*, pDataHelper )
183 {
184 	if ( pDataHelper )
185 	{
186 		mbPastePossible = ( pDataHelper->GetFormatCount() != 0 );
187 
188         // Update the list of supported clipboard formats according to the
189         // new clipboard content.
190         // There are some stack traces that indicate the possibility of the
191         // DrawViewShell destructor called during the call to
192         // GetSupportedClipboardFormats().  If that really has happened then
193         // exit immediately.
194         TransferableDataHelper aDataHelper (
195             TransferableDataHelper::CreateFromSystemClipboard(GetActiveWindow()));
196         ::std::auto_ptr<SvxClipboardFmtItem> pFormats (GetSupportedClipboardFormats(aDataHelper));
197         if (mpDrawView == NULL)
198             return 0;
199         mpCurrentClipboardFormats = pFormats;
200 
201 		SfxBindings& rBindings = GetViewFrame()->GetBindings();
202 		rBindings.Invalidate( SID_PASTE );
203         rBindings.Invalidate( SID_PASTE_SPECIAL );
204 		rBindings.Invalidate( SID_CLIPBOARD_FORMAT_ITEMS );
205 	}
206 	return 0;
207 }
208 
209 
210 
211 
GetDrawAttrState(SfxItemSet & rSet)212 void DrawViewShell::GetDrawAttrState(SfxItemSet& rSet)
213 {
214     SfxItemSet aSet( mpDrawView->GetGeoAttrFromMarked() );
215     rSet.Put(aSet,sal_False);
216 }
217 
218 
219 
220 
221 /*************************************************************************
222 |*
223 |* Status (Enabled/Disabled) von Menue-SfxSlots setzen
224 |*
225 \************************************************************************/
226 
GetMenuState(SfxItemSet & rSet)227 void DrawViewShell::GetMenuState( SfxItemSet &rSet )
228 {
229     if (mpDrawView == NULL)
230     {
231         // This assertion and return are here to prevent crashes like that
232         // of issue #126202#.
233         DBG_ASSERT(mpDrawView!=NULL, "Please report this assertion to the Impress team.");
234         return;
235     }
236 
237     ViewShell::GetMenuState(rSet);
238 	sal_Bool bDisableVerticalText = !SvtLanguageOptions().IsVerticalTextEnabled();
239 
240 	if ( bDisableVerticalText )
241 	{
242 		rSet.DisableItem( SID_DRAW_FONTWORK_VERTICAL );
243 		rSet.DisableItem( SID_DRAW_CAPTION_VERTICAL );
244 		rSet.DisableItem( SID_TEXT_FITTOSIZE_VERTICAL );
245 		rSet.DisableItem( SID_DRAW_TEXT_VERTICAL );
246 	}
247 
248 	FASTBOOL bConvertToPathPossible = mpDrawView->IsConvertToPathObjPossible(sal_False);
249 
250 	const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
251 	const sal_uLong nMarkCount = rMarkList.GetMarkCount();
252 
253     //format paintbrush
254     FuFormatPaintBrush::GetMenuState( *this, rSet );
255 
256 	// Stati der SfxChild-Windows (Animator, Fontwork etc.)
257 	SetChildWindowState( rSet );
258 
259 	// Images der Toolboxen mappen (nur Zoom)
260 	UpdateToolboxImages( rSet, sal_False );
261 
262 	if(HasCurrentFunction())
263 	{
264 		sal_uInt16 nSId = GetCurrentFunction()->GetSlotID();
265 
266 		rSet.Put( SfxBoolItem( nSId, sal_True ) );
267 
268         // Bewirkt ein uncheck eines simulierten Slots
269 		sal_uInt16 nId = GetIdBySubId( nSId );
270 
271 		// Images der Toolboxen mappen
272 		UpdateToolboxImages( rSet );
273 
274 		if( nId != SID_ZOOM_TOOLBOX &&
275 			nSId != SID_DRAWTBX_INSERT &&
276 			nSId != SID_POSITION &&
277 			nSId != SID_OBJECT_ALIGN )
278 		{
279 			if( nId != SID_OBJECT_CHOOSE_MODE )
280 				rSet.Put( TbxImageItem( SID_OBJECT_CHOOSE_MODE, 0 ) );
281 			if( nId != SID_DRAWTBX_TEXT )
282 				rSet.Put( TbxImageItem( SID_DRAWTBX_TEXT, 0 ) );
283 			if( nId != SID_DRAWTBX_RECTANGLES )
284 				rSet.Put( TbxImageItem( SID_DRAWTBX_RECTANGLES, 0 ) );
285 			if( nId != SID_DRAWTBX_ELLIPSES )
286 				rSet.Put( TbxImageItem( SID_DRAWTBX_ELLIPSES, 0 ) );
287 			if( nId != SID_DRAWTBX_LINES )
288 				rSet.Put( TbxImageItem( SID_DRAWTBX_LINES, 0 ) );
289 			if( nId != SID_DRAWTBX_ARROWS )
290 				rSet.Put( TbxImageItem( SID_DRAWTBX_ARROWS, 0 ) );
291 			if( nId != SID_DRAWTBX_3D_OBJECTS )
292 				rSet.Put( TbxImageItem( SID_DRAWTBX_3D_OBJECTS, 0 ) );
293             if( nId != SID_DRAWTBX_CONNECTORS )
294                 rSet.Put( TbxImageItem( SID_DRAWTBX_CONNECTORS, 0 ) );
295         }
296 	}
297 
298 	SdrPageView* pPageView = mpDrawView->GetSdrPageView();
299 
300 	GetMenuStateSel(rSet);
301 
302 	if (SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_ASSIGN_LAYOUT))
303 	{
304         bool bDisable = true;
305 		if( pPageView )
306 		{
307 			SdPage* pPage = dynamic_cast< SdPage* >( pPageView->GetPage() );
308 
309 			if( pPage && !pPage->IsMasterPage() )
310 			{
311 				rSet.Put( SfxUInt32Item( SID_ASSIGN_LAYOUT, static_cast< sal_uInt32 >(pPage->GetAutoLayout()) ) );
312 				bDisable = false;
313 			}
314 		}
315 
316         if(bDisable)
317         {
318             rSet.DisableItem(SID_ASSIGN_LAYOUT);
319         }
320 	}
321 
322     if (SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_EXPAND_PAGE))
323     {
324         bool bDisable = true;
325 		if( pPageView )
326 		{
327 			SdPage* pPage = dynamic_cast< SdPage* >( pPageView->GetPage() );
328 
329 			if( pPage && (pPage->GetPageKind() == PK_STANDARD) && !pPage->IsMasterPage() )
330 			{
331 				SdrObject* pObj = pPage->GetPresObj(PRESOBJ_OUTLINE);
332 
333                 if (pObj!=NULL )
334 				{
335 					if( !pObj->IsEmptyPresObj() )
336 					{
337 						bDisable = false;
338 					}
339 					else
340 					{
341 						// check if the object is in edit, than its temporarely not empty
342 						SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( pObj );
343 						if( pTextObj )
344 						{
345 							OutlinerParaObject* pParaObj = pTextObj->GetEditOutlinerParaObject();
346 							if( pParaObj )
347 							{
348 								delete pParaObj;
349 								bDisable = false;
350 							}
351 						}
352 					}
353 				}
354 			}
355 		}
356 
357         if(bDisable)
358         {
359             rSet.DisableItem(SID_EXPAND_PAGE);
360         }
361     }
362 
363     if (SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_SUMMARY_PAGE))
364     {
365         bool bDisable = true;
366 		if( pPageView )
367 		{
368 			SdPage* pPage = dynamic_cast< SdPage* >( pPageView->GetPage() );
369 
370 			if( pPage && (pPage->GetPageKind() == PK_STANDARD) && !pPage->IsMasterPage() )
371 			{
372 				SdrObject* pObj = pPage->GetPresObj(PRESOBJ_TITLE);
373 
374 				if(pObj && !pObj->IsEmptyPresObj())
375 				{
376 					bDisable = false;
377 				}
378 			}
379 		}
380 
381         if(bDisable)
382         {
383             rSet.DisableItem(SID_SUMMARY_PAGE);
384         }
385     }
386 
387     if (SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_ASSIGN_LAYOUT))
388     {
389         bool bDisable = true;
390 		if( pPageView )
391 		{
392 			SdPage* pPage = dynamic_cast< SdPage* >( pPageView->GetPage() );
393 
394 			if( pPage && !pPage->IsMasterPage() )
395 			{
396 				rSet.Put( SfxUInt32Item(SID_ASSIGN_LAYOUT, pPage->GetAutoLayout()) );
397 				bDisable = false;
398 			}
399 		}
400 
401         if(bDisable)
402         {
403             rSet.DisableItem(SID_ASSIGN_LAYOUT);
404         }
405     }
406 
407 	// Starten der Praesentation moeglich?
408 	if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_PRESENTATION ) ||
409 		SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_REHEARSE_TIMINGS ) )
410     {
411         sal_Bool bDisable = sal_True;
412         sal_uInt16 nCount = GetDoc()->GetSdPageCount( PK_STANDARD );
413 
414         for( sal_uInt16 i = 0; i < nCount && bDisable; i++ )
415         {
416             SdPage* pPage = GetDoc()->GetSdPage(i, PK_STANDARD);
417 
418             if( !pPage->IsExcluded() )
419 				bDisable = sal_False;
420         }
421 
422         if( bDisable || GetDocSh()->IsPreview())
423 		{
424             rSet.DisableItem( SID_PRESENTATION );
425             rSet.DisableItem( SID_REHEARSE_TIMINGS );
426 		}
427     }
428 
429     // Klebepunkte
430 	if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_GLUE_EDITMODE ) ||
431 		SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_GLUE_INSERT_POINT ) ||
432 		SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_GLUE_PERCENT ) ||
433 		SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_GLUE_ESCDIR ) ||
434 		SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_GLUE_ESCDIR_LEFT ) ||
435 		SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_GLUE_ESCDIR_RIGHT ) ||
436 		SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_GLUE_ESCDIR_TOP ) ||
437 		SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_GLUE_ESCDIR_BOTTOM ) ||
438 		SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_GLUE_HORZALIGN_CENTER ) ||
439 		SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_GLUE_HORZALIGN_LEFT ) ||
440 		SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_GLUE_HORZALIGN_RIGHT ) ||
441 		SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_GLUE_VERTALIGN_CENTER ) ||
442 		SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_GLUE_VERTALIGN_TOP ) ||
443 		SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_GLUE_VERTALIGN_BOTTOM ) )
444 	{
445 		// Prozent
446 		TRISTATE eState = mpDrawView->IsMarkedGluePointsPercent();
447 		if( eState == STATE_DONTKNOW )
448 			rSet.InvalidateItem( SID_GLUE_PERCENT );
449 		else
450 			rSet.Put( SfxBoolItem( SID_GLUE_PERCENT, eState == STATE_CHECK ) );
451 
452 		// Bei Prozent hat Alignment keinen Effekt
453 		if( eState == STATE_CHECK )
454 		{
455 			rSet.DisableItem( SID_GLUE_HORZALIGN_CENTER );
456 			rSet.DisableItem( SID_GLUE_HORZALIGN_LEFT );
457 			rSet.DisableItem( SID_GLUE_HORZALIGN_RIGHT );
458 			rSet.DisableItem( SID_GLUE_VERTALIGN_CENTER );
459 			rSet.DisableItem( SID_GLUE_VERTALIGN_TOP );
460 			rSet.DisableItem( SID_GLUE_VERTALIGN_BOTTOM );
461 		}
462 		else
463 		{
464 			// Horizontale Ausrichtung
465 			sal_uInt16 nHorz = mpDrawView->GetMarkedGluePointsAlign( sal_False );
466 			rSet.Put( SfxBoolItem( SID_GLUE_HORZALIGN_CENTER, nHorz == SDRHORZALIGN_CENTER ) );
467 			rSet.Put( SfxBoolItem( SID_GLUE_HORZALIGN_LEFT,   nHorz == SDRHORZALIGN_LEFT ) );
468 			rSet.Put( SfxBoolItem( SID_GLUE_HORZALIGN_RIGHT,  nHorz == SDRHORZALIGN_RIGHT ) );
469 			// Vertikale Ausrichtung
470 			sal_uInt16 nVert = mpDrawView->GetMarkedGluePointsAlign( sal_True );
471 			rSet.Put( SfxBoolItem( SID_GLUE_VERTALIGN_CENTER, nVert == SDRVERTALIGN_CENTER ) );
472 			rSet.Put( SfxBoolItem( SID_GLUE_VERTALIGN_TOP,	  nVert == SDRVERTALIGN_TOP ) );
473 			rSet.Put( SfxBoolItem( SID_GLUE_VERTALIGN_BOTTOM, nVert == SDRVERTALIGN_BOTTOM ) );
474 		}
475 
476 		// Punkt einfuegen
477 		rSet.Put( SfxBoolItem( SID_GLUE_INSERT_POINT, mpDrawView->IsInsGluePointMode() ) );
478 
479 		// Autrittsrichtung
480 		// Links
481 		eState = mpDrawView->IsMarkedGluePointsEscDir( SDRESC_LEFT );
482 		if( eState == STATE_DONTKNOW )
483 			rSet.InvalidateItem( SID_GLUE_ESCDIR_LEFT );
484 		else
485 			rSet.Put( SfxBoolItem( SID_GLUE_ESCDIR_LEFT, eState == STATE_CHECK ) );
486 		// Rechts
487 		eState = mpDrawView->IsMarkedGluePointsEscDir( SDRESC_RIGHT );
488 		if( eState == STATE_DONTKNOW )
489 			rSet.InvalidateItem( SID_GLUE_ESCDIR_RIGHT );
490 		else
491 			rSet.Put( SfxBoolItem( SID_GLUE_ESCDIR_RIGHT, eState == STATE_CHECK ) );
492 		// Oben
493 		eState = mpDrawView->IsMarkedGluePointsEscDir( SDRESC_TOP );
494 		if( eState == STATE_DONTKNOW )
495 			rSet.InvalidateItem( SID_GLUE_ESCDIR_TOP );
496 		else
497 			rSet.Put( SfxBoolItem( SID_GLUE_ESCDIR_TOP, eState == STATE_CHECK ) );
498 		// Unten
499 		eState = mpDrawView->IsMarkedGluePointsEscDir( SDRESC_BOTTOM );
500 		if( eState == STATE_DONTKNOW )
501 			rSet.InvalidateItem( SID_GLUE_ESCDIR_BOTTOM );
502 		else
503 			rSet.Put( SfxBoolItem( SID_GLUE_ESCDIR_BOTTOM, eState == STATE_CHECK ) );
504 	}
505 
506 	if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_GRID_FRONT ) ||
507 		SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_HELPLINES_FRONT ) )
508 	{
509 		rSet.Put( SfxBoolItem( SID_GRID_FRONT, mpDrawView->IsGridFront() ) );
510 		rSet.Put( SfxBoolItem( SID_HELPLINES_FRONT, mpDrawView->IsHlplFront() ) );
511 	}
512 
513 	if (!mpDrawView->IsFrameDragSingles())
514         rSet.Put(SfxBoolItem(SID_BEZIER_EDIT, sal_True));
515     else
516         rSet.Put(SfxBoolItem(SID_BEZIER_EDIT, sal_False));
517 
518     if(dynamic_cast<FuEditGluePoints*>( GetCurrentFunction().get()))
519         rSet.Put(SfxBoolItem(SID_GLUE_EDITMODE, sal_True));
520     else
521         rSet.Put(SfxBoolItem(SID_GLUE_EDITMODE, sal_False));
522 
523     if( !mpDrawView->IsMirrorAllowed( sal_True, sal_True ) )
524 	{
525 		rSet.DisableItem( SID_HORIZONTAL );
526 		rSet.DisableItem( SID_VERTICAL );
527 		rSet.DisableItem( SID_FLIP_HORIZONTAL );
528 		rSet.DisableItem( SID_FLIP_VERTICAL );
529     }
530 
531     if( !mpDrawView->IsMirrorAllowed() )
532 	{
533         rSet.DisableItem( SID_OBJECT_MIRROR );
534 //        rSet.DisableItem( SID_CONVERT_TO_3D_LATHE );
535 //        rSet.DisableItem( SID_CONVERT_TO_3D_LATHE_FAST );
536     }
537 
538 	// interactive transparence control
539     if(!mpDrawView->IsTransparenceAllowed())
540 	{
541         rSet.DisableItem( SID_OBJECT_TRANSPARENCE );
542     }
543 
544 	// interactive gradient control
545     if(!mpDrawView->IsGradientAllowed())
546 	{
547         rSet.DisableItem( SID_OBJECT_GRADIENT );
548     }
549 
550 	// Morphen ggf. disablen
551 	if ( !mpDrawView->IsMorphingAllowed() )
552 		rSet.DisableItem( SID_POLYGON_MORPHING );
553 
554 	// Vectorize ggf. disablen
555 	if ( !mpDrawView->IsVectorizeAllowed() )
556 		rSet.DisableItem( SID_VECTORIZE );
557 
558 	if( !mpDrawView->IsReverseOrderPossible() )
559 	{
560 		rSet.DisableItem( SID_REVERSE_ORDER );
561 	}
562 
563 	if ( !bConvertToPathPossible &&
564 		 !mpDrawView->IsCrookAllowed( mpDrawView->IsCrookNoContortion() ) )
565 	{
566 		// Implizite Wandlung in Kurve nicht moeglich
567 		rSet.DisableItem(SID_OBJECT_CROOK_ROTATE);
568 		rSet.DisableItem(SID_OBJECT_CROOK_SLANT);
569 		rSet.DisableItem(SID_OBJECT_CROOK_STRETCH);
570 	}
571 
572 	if ( !mpDrawView->IsGroupEntered() )
573 	{
574 		rSet.DisableItem( SID_LEAVE_GROUP );
575 		rSet.Put( SfxBoolItem( SID_LEAVE_ALL_GROUPS, sal_False ) );
576 		rSet.ClearItem( SID_LEAVE_ALL_GROUPS );
577 		rSet.DisableItem( SID_LEAVE_ALL_GROUPS );
578 	}
579 	else
580 		rSet.Put( SfxBoolItem( SID_LEAVE_ALL_GROUPS, sal_True ) );
581 
582     if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_THESAURUS ) )
583 	{
584 		if ( !mpDrawView->IsTextEdit() )
585 		{
586 			rSet.DisableItem( SID_THESAURUS );
587 		}
588 		else
589 		{
590 			LanguageType            eLang = GetDoc()->GetLanguage( EE_CHAR_LANGUAGE );
591 	        Reference< XThesaurus > xThesaurus( LinguMgr::GetThesaurus() );
592 			Locale                  aLocale;
593 
594             SvxLanguageToLocale( aLocale, eLang );
595 
596             if (!xThesaurus.is() || eLang == LANGUAGE_NONE || !xThesaurus->hasLocale(aLocale) )
597 				rSet.DisableItem( SID_THESAURUS );
598 		}
599 	}
600 
601 	if ( !mpDrawView->IsTextEdit() )
602 	{
603 		rSet.DisableItem( SID_THESAURUS );
604 	}
605 
606 	if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_SELECTALL ) ||
607 		SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_SIZE_ALL ) )
608 	{
609 		if( pPageView && pPageView->GetObjList()->GetObjCount() == 0 )
610 		{
611 			// Sollte disabled sein, wenn kein Objekt auf der Zeichenflaeche ist:
612 			rSet.DisableItem( SID_SELECTALL );
613 			rSet.DisableItem( SID_SIZE_ALL );
614 		}
615 	}
616 
617 	if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_CONTEXT ) )
618 		rSet.Put( SfxStringItem( SID_CONTEXT, mpDrawView->GetStatusText() ) );
619 
620 	// clipboard (paste)
621     if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_PASTE ) ||
622         SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_PASTE_SPECIAL ) ||
623 		SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_CLIPBOARD_FORMAT_ITEMS ) )
624 	{
625 		if ( !mpClipEvtLstnr )
626 		{
627             // SSA: #108717# avoid clipboard initialization for
628             // read-only presentation views (workaround for NT4.0
629             // clipboard prob...)
630 			if( !ISA(PresentationViewShell) )
631 			{
632 				// create listener
633 				mpClipEvtLstnr = new TransferableClipboardListener( LINK( this, DrawViewShell, ClipboardChanged ) );
634 				mpClipEvtLstnr->acquire();
635 				mpClipEvtLstnr->AddRemoveListener( GetActiveWindow(), sal_True );
636 
637 			    // get initial state
638 			    TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( GetActiveWindow() ) );
639 			    mbPastePossible = ( aDataHelper.GetFormatCount() != 0 );
640 			}
641             else
642 			    mbPastePossible = sal_False;
643 		}
644 
645 		if( !mbPastePossible )
646 		{
647 			rSet.DisableItem( SID_PASTE );
648             rSet.DisableItem( SID_PASTE_SPECIAL );
649             rSet.DisableItem( SID_CLIPBOARD_FORMAT_ITEMS );
650 		}
651 		else if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_CLIPBOARD_FORMAT_ITEMS ) )
652 		{
653             if (mpCurrentClipboardFormats.get() != NULL)
654                 rSet.Put(*mpCurrentClipboardFormats);
655 		}
656 	}
657 
658 	if ( !bConvertToPathPossible )
659 	{
660 		rSet.DisableItem(SID_CHANGEBEZIER);
661 	}
662 
663     if (mpDrawView == NULL)
664     {
665         // When we come to this line then we probably have another
666         // incarnation of issue #126202#.  The mpDrawView was not NULL but is
667         // now.  The reason for this may be that the DrawViewShell has been
668         // destroyed in the mean time.
669         // We can only return immediately and hope that the deleted
670         // DrawViewShell is not called again.
671         DBG_ASSERT(mpDrawView!=NULL, "Please report this assertion to the Impress team.");
672         return;
673     }
674 
675 	if( !( mpDrawView->IsConvertToPolyObjPossible(sal_False) || mpDrawView->IsVectorizeAllowed() ) )
676         rSet.DisableItem(SID_CHANGEPOLYGON);
677 
678 	if( !( mpDrawView->IsConvertToPolyObjPossible(sal_False) || mpDrawView->IsConvertToContourPossible() ) )
679         rSet.DisableItem(SID_CONVERT_TO_CONTOUR);
680 
681 	if ( !mpDrawView->IsConvertTo3DObjPossible() )
682 	{
683 		rSet.DisableItem(SID_CONVERT_TO_3D);
684 		rSet.DisableItem(SID_CONVERT_TO_3D_LATHE);
685 		rSet.DisableItem(SID_CONVERT_TO_3D_LATHE_FAST);
686 	}
687 
688     if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_MANAGE_LINKS ) )
689 	{
690 		if ( GetDoc()->GetLinkCount() == 0 )
691 		{
692 			rSet.DisableItem(SID_MANAGE_LINKS);
693 		}
694 	}
695 
696 	if (mePageKind == PK_HANDOUT)
697 	{
698 		rSet.DisableItem(SID_PRESENTATION_LAYOUT);
699 		rSet.DisableItem(SID_SELECT_BACKGROUND);
700 	}
701 
702 	if (mePageKind == PK_NOTES)
703 	{
704 		rSet.DisableItem(SID_INSERTPAGE);
705 		rSet.DisableItem(SID_RENAMEPAGE);
706 		rSet.DisableItem(SID_RENAMEPAGE_QUICK);
707         rSet.DisableItem(SID_DUPLICATE_PAGE);
708 		rSet.ClearItem(SID_ANIMATION_OBJECTS);
709 		rSet.DisableItem(SID_ANIMATION_OBJECTS);
710 		rSet.DisableItem(SID_ANIMATION_EFFECTS);
711 
712 		if (meEditMode == EM_MASTERPAGE)
713 			rSet.DisableItem(SID_MODIFYPAGE);
714 
715 		rSet.DisableItem(SID_SELECT_BACKGROUND);
716 		rSet.DisableItem(SID_INSERTLAYER);
717 		rSet.DisableItem(SID_LAYERMODE);
718 		rSet.DisableItem(SID_INSERTFILE);
719 	}
720 	else if (mePageKind == PK_HANDOUT)
721 	{
722 		rSet.DisableItem(SID_INSERTPAGE);
723         rSet.DisableItem(SID_DUPLICATE_PAGE);
724 		rSet.ClearItem(SID_ANIMATION_OBJECTS);
725 		rSet.DisableItem(SID_ANIMATION_OBJECTS);
726 		rSet.DisableItem(SID_ANIMATION_EFFECTS);
727 		rSet.DisableItem(SID_RENAMEPAGE);
728 		rSet.DisableItem(SID_RENAMEPAGE_QUICK);
729 		rSet.DisableItem(SID_INSERTLAYER);
730 		rSet.DisableItem(SID_MODIFYLAYER);
731 		rSet.DisableItem(SID_RENAMELAYER);
732 		rSet.DisableItem(SID_LAYERMODE);
733 		rSet.DisableItem(SID_INSERTFILE);
734 		rSet.DisableItem(SID_PAGEMODE);
735 		rSet.DisableItem(SID_SELECT_BACKGROUND);
736 	}
737 	else
738 	{
739 		if (meEditMode == EM_MASTERPAGE)
740 		{
741 			rSet.DisableItem(SID_INSERTPAGE);
742             rSet.DisableItem(SID_DUPLICATE_PAGE);
743 			rSet.DisableItem(SID_MODIFYPAGE);
744 			rSet.ClearItem(SID_ANIMATION_OBJECTS);
745 			rSet.DisableItem(SID_ANIMATION_OBJECTS);
746 		}
747 
748 		rSet.Put (SfxBoolItem (SID_LAYERMODE, IsLayerModeActive()));
749 	}
750 
751 	if ( ! IsLayerModeActive())
752 	{
753 		rSet.DisableItem( SID_INSERTLAYER );
754 		rSet.DisableItem( SID_MODIFYLAYER );
755 		rSet.DisableItem( SID_DELETE_LAYER );
756 		rSet.DisableItem( SID_RENAMELAYER );
757 	}
758 
759 	if (meEditMode == EM_PAGE)
760 	{
761         /**********************************************************************
762         * Seiten-Modus
763         **********************************************************************/
764 		rSet.Put(SfxBoolItem(SID_PAGEMODE, sal_True));
765 		rSet.Put(SfxBoolItem(SID_MASTERPAGE, sal_False));
766         rSet.Put(SfxBoolItem(SID_SLIDE_MASTERPAGE, sal_False));
767         rSet.Put(SfxBoolItem(SID_NOTES_MASTERPAGE, sal_False));
768         rSet.Put(SfxBoolItem(SID_HANDOUT_MASTERPAGE, sal_False));
769 
770         if (mePageKind == PK_STANDARD &&
771             rSet.GetItemState(SID_TITLE_MASTERPAGE) == SFX_ITEM_AVAILABLE)
772         {
773             // Gibt es eine Seite mit dem AutoLayout "Titel"?
774             sal_Bool bDisable = sal_True;
775             sal_uInt16 i = 0;
776             sal_uInt16 nCount = GetDoc()->GetSdPageCount(PK_STANDARD);
777 
778             while (i < nCount && bDisable)
779             {
780                 SdPage* pPage = GetDoc()->GetSdPage(i, PK_STANDARD);
781 
782                 if (pPage->GetAutoLayout() == AUTOLAYOUT_TITLE)
783                 {
784                     bDisable = sal_False;
785                 }
786 
787                 i++;
788             }
789 
790             if (bDisable)
791             {
792                 rSet.DisableItem(SID_TITLE_MASTERPAGE);
793             }
794             else
795             {
796                 rSet.Put(SfxBoolItem(SID_TITLE_MASTERPAGE, sal_False));
797             }
798         }
799         else
800         {
801             rSet.DisableItem(SID_TITLE_MASTERPAGE);
802         }
803 
804         rSet.DisableItem (SID_INSERT_MASTER_PAGE);
805         rSet.DisableItem (SID_DELETE_MASTER_PAGE);
806         rSet.DisableItem (SID_RENAME_MASTER_PAGE);
807         rSet.DisableItem (SID_CLOSE_MASTER_VIEW);
808 	}
809 	else
810 	{
811 		rSet.Put(SfxBoolItem(SID_PAGEMODE, sal_False));
812 		rSet.Put(SfxBoolItem(SID_MASTERPAGE, sal_True));
813 
814         /**********************************************************************
815         * Hintergrundseiten-Modus
816         **********************************************************************/
817         if (mePageKind == PK_STANDARD)
818         {
819             rSet.Put(SfxBoolItem(SID_SLIDE_MASTERPAGE, sal_True));
820             rSet.Put(SfxBoolItem(SID_NOTES_MASTERPAGE, sal_False));
821             rSet.Put(SfxBoolItem(SID_HANDOUT_MASTERPAGE, sal_False));
822 
823             if (rSet.GetItemState(SID_TITLE_MASTERPAGE) == SFX_ITEM_AVAILABLE)
824             {
825 				sal_Bool bCheck = sal_False;
826 				sal_Bool bDisable = sal_True;
827 				if( pPageView )
828 				{
829 					SdPage* pMPage = dynamic_cast< SdPage* >( pPageView->GetPage() );
830 
831 					sal_uInt16 i = 0;
832 					sal_uInt16 nCount = GetDoc()->GetSdPageCount(PK_STANDARD);
833 
834 					// Referenziert eine Seite mit dem AutoLayout "Titel" die
835 					// aktuelle MasterPage?
836 					while (i < nCount && !bCheck && bDisable)
837 					{
838 						SdPage* pPage = GetDoc()->GetSdPage(i, PK_STANDARD);
839 
840 						// Seite referenziert aktuelle MasterPage
841 						if (pPage->GetAutoLayout() == AUTOLAYOUT_TITLE)
842 						{
843 							// Eine Seite hat das AutoLayout "Titel"
844 							bDisable = sal_False;
845 
846 							SdPage& rRefMPage = (SdPage&)(pPage->TRG_GetMasterPage());
847 
848 							if(&rRefMPage == pMPage)
849 							{
850 								// Eine Seite mit dem AutoLayout "Titel"
851 								// referenziert die aktuelle MasterPage
852 								bCheck = sal_True;
853 							}
854 						}
855 
856 						i++;
857 					}
858 				}
859 
860 				if (bCheck)
861 				{
862 					rSet.Put(SfxBoolItem(SID_SLIDE_MASTERPAGE, sal_False));
863 				}
864 
865 				rSet.Put(SfxBoolItem(SID_TITLE_MASTERPAGE, bCheck));
866 
867 				if (bDisable)
868 				{
869 					rSet.ClearItem(SID_TITLE_MASTERPAGE);
870 					rSet.DisableItem(SID_TITLE_MASTERPAGE);
871 				}
872             }
873         }
874         else if (mePageKind == PK_NOTES)
875         {
876             rSet.Put(SfxBoolItem(SID_SLIDE_MASTERPAGE, sal_False));
877             rSet.DisableItem(SID_TITLE_MASTERPAGE);
878             rSet.Put(SfxBoolItem(SID_NOTES_MASTERPAGE, sal_True));
879             rSet.Put(SfxBoolItem(SID_HANDOUT_MASTERPAGE, sal_False));
880         }
881         else if (mePageKind == PK_HANDOUT)
882         {
883             rSet.Put(SfxBoolItem(SID_SLIDE_MASTERPAGE, sal_False));
884             rSet.DisableItem(SID_TITLE_MASTERPAGE);
885             rSet.Put(SfxBoolItem(SID_NOTES_MASTERPAGE, sal_False));
886             rSet.Put(SfxBoolItem(SID_HANDOUT_MASTERPAGE, sal_True));
887         }
888     }
889 
890     // Status der Lineale setzen
891     if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_RULER ) )
892 		rSet.Put( SfxBoolItem( SID_RULER, HasRuler() ) );
893 
894 	// nicht die letzte Seite oder eine Masterpage loeschen
895 	if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_DELETE_PAGE )
896         || SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_DELETE_MASTER_PAGE ) )
897 	{
898 		if (maTabControl.GetPageCount() == 1 ||
899 			meEditMode == EM_MASTERPAGE		||
900 			mePageKind == PK_NOTES			||
901 			mePageKind == PK_HANDOUT 		||
902 			(GetShellType()!=ST_DRAW&&IsLayerModeActive()))
903 		{
904             if (rSet.GetItemState(SID_DELETE_PAGE) == SFX_ITEM_AVAILABLE)
905                 rSet.DisableItem(SID_DELETE_PAGE);
906             if (rSet.GetItemState(SID_DELETE_MASTER_PAGE)==SFX_ITEM_AVAILABLE)
907                 rSet.DisableItem(SID_DELETE_MASTER_PAGE);
908 		}
909 	}
910 
911 	// darf der aktuelle Layer geloescht werden?
912 	if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_DELETE_LAYER ) )
913 	{
914         if(GetLayerTabControl()) // #87182#
915         {
916             sal_uInt16		  nCurrentLayer = GetLayerTabControl()->GetCurPageId();
917             const String& rName 		= GetLayerTabControl()->GetPageText(nCurrentLayer);
918 
919             sal_Bool bDisableIt = !IsLayerModeActive();
920             bDisableIt |= (rName == String(SdResId(STR_LAYER_LAYOUT)));
921             bDisableIt |= (rName == String(SdResId(STR_LAYER_BCKGRND)));
922             bDisableIt |= (rName == String(SdResId(STR_LAYER_BCKGRNDOBJ)));
923             bDisableIt |= (rName == String(SdResId(STR_LAYER_CONTROLS)));
924             bDisableIt |= (rName == String(SdResId(STR_LAYER_MEASURELINES)));
925 
926             if (bDisableIt)
927             {
928                 rSet.DisableItem(SID_DELETE_LAYER);
929                 rSet.DisableItem(SID_RENAMELAYER);
930             }
931         }
932         else
933         {
934             OSL_ENSURE(false, "No LayerTabBar (!)");
935         }
936     }
937 
938 	if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_CUT ) ||
939 		SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_COPY ) ||
940 		SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_OUTLINE_BULLET ))
941 	{
942 		OutlinerView* pOlView = mpDrawView->GetTextEditOutlinerView();
943 
944 		// Sonderbehandlung f�r SID_OUTLINE_BULLET wenn Objekte
945 		// mit unterschiedlichen arten von NumBullet Items markiert
946 		// sind
947 		sal_Bool bHasOutliner = sal_False;
948 		sal_Bool bHasOther    = sal_False;
949 		for(sal_uLong nNum = 0; nNum < nMarkCount; nNum++)
950 		{
951 		    SdrObject* pObj = rMarkList.GetMark(nNum)->GetMarkedSdrObj();
952 			if( pObj->GetObjInventor() == SdrInventor )
953 			{
954 				if( pObj->GetObjIdentifier() == OBJ_OUTLINETEXT )
955 				{
956 					bHasOutliner = sal_True;
957 					if(bHasOther)
958 						break;
959 				}
960 				else
961 				{
962 					bHasOther = sal_True;
963 					if(bHasOutliner)
964 						break;
965 				}
966 			}
967 		}
968 
969 		if( bHasOther && bHasOutliner )
970 			rSet.DisableItem( SID_OUTLINE_BULLET );
971 
972 		if (pOlView)
973 		{
974 			if ( pOlView->GetSelected().Len() == 0 )
975 			{
976 				rSet.DisableItem( SID_CUT );
977 				rSet.DisableItem( SID_COPY );
978 			}
979 		}
980 
981 	}
982 
983 	FuBullet::GetSlotState( rSet, this, GetViewFrame() );
984 
985 	if ( GetDocSh()->IsUIActive() )
986 	{
987 		rSet.DisableItem( SID_INSERT_OBJECT );
988         rSet.DisableItem( SID_INSERT_PLUGIN );
989         rSet.DisableItem( SID_INSERT_SOUND );
990         rSet.DisableItem( SID_INSERT_VIDEO );
991         rSet.DisableItem( SID_INSERT_FLOATINGFRAME );
992 		rSet.DisableItem( SID_INSERT_MATH );
993 		rSet.DisableItem( SID_INSERT_DIAGRAM );
994 		rSet.DisableItem( SID_ATTR_TABLE );
995 		rSet.DisableItem( SID_SIZE_REAL );
996 		rSet.DisableItem( SID_SIZE_OPTIMAL );
997 		rSet.DisableItem( SID_SIZE_ALL );
998 		rSet.DisableItem( SID_SIZE_PAGE_WIDTH );
999 		rSet.DisableItem( SID_SIZE_PAGE );
1000         rSet.DisableItem( SID_DUPLICATE_PAGE );
1001         rSet.DisableItem( SID_ZOOM_TOOLBOX );
1002 	}
1003 
1004 	// Zoom-Stati
1005 	if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_ZOOM_IN ) ||
1006 		SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_ZOOM_OUT )||
1007 		SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_ZOOM_PANNING ) )
1008 	{
1009 		if( GetActiveWindow()->GetZoom() <= GetActiveWindow()->GetMinZoom() || GetDocSh()->IsUIActive() )
1010 		{
1011 			rSet.DisableItem( SID_ZOOM_IN );
1012 			rSet.DisableItem( SID_ZOOM_PANNING );
1013 		}
1014 		if( GetActiveWindow()->GetZoom() >= GetActiveWindow()->GetMaxZoom() || GetDocSh()->IsUIActive() )
1015 			rSet.DisableItem( SID_ZOOM_OUT );
1016 	}
1017 
1018 	if (!mpZoomList->IsNextPossible())
1019 	{
1020 	   rSet.DisableItem(SID_ZOOM_NEXT);
1021 	}
1022 	if (!mpZoomList->IsPreviousPossible())
1023 	{
1024 	   rSet.DisableItem(SID_ZOOM_PREV);
1025 	}
1026 
1027 	// EditText aktiv
1028     if (GetViewShellBase().GetViewShellManager()->GetShell(RID_DRAW_TEXT_TOOLBOX) != NULL)
1029     {
1030         sal_uInt16 nCurrentSId = SID_ATTR_CHAR;
1031 
1032         if(HasCurrentFunction())
1033         {
1034             nCurrentSId = GetCurrentFunction()->GetSlotID();
1035         }
1036         if( nCurrentSId != SID_TEXT_FITTOSIZE &&
1037             nCurrentSId != SID_TEXT_FITTOSIZE_VERTICAL &&
1038             nCurrentSId != SID_ATTR_CHAR_VERTICAL )
1039             nCurrentSId = SID_ATTR_CHAR;
1040 
1041         rSet.Put( SfxBoolItem( nCurrentSId, sal_True ) );
1042 
1043         // Kurzform von UpdateToolboxImages()
1044         rSet.Put( TbxImageItem( SID_DRAWTBX_TEXT, nCurrentSId ) );
1045     }
1046 
1047 	if ( GetDocSh()->IsReadOnly() )
1048 	{
1049 		rSet.DisableItem( SID_AUTOSPELL_CHECK );
1050 	}
1051 	else
1052 	{
1053 	    if (GetDoc()->GetOnlineSpell())
1054     	{
1055         	rSet.Put(SfxBoolItem(SID_AUTOSPELL_CHECK, sal_True));
1056 	    }
1057     	else
1058 	    {
1059     	    rSet.Put(SfxBoolItem(SID_AUTOSPELL_CHECK, sal_False));
1060     	}
1061 	}
1062 
1063 	SdrPageView* pPV = mpDrawView->GetSdrPageView();
1064 	String aActiveLayer = mpDrawView->GetActiveLayer();
1065 
1066 	if ( ( aActiveLayer.Len() != 0 && pPV && ( pPV->IsLayerLocked(aActiveLayer) ||
1067 		  !pPV->IsLayerVisible(aActiveLayer) ) ) ||
1068           SD_MOD()->GetWaterCan() )
1069 	{
1070 		rSet.DisableItem( SID_PASTE );
1071         rSet.DisableItem( SID_PASTE_SPECIAL );
1072         rSet.DisableItem( SID_CLIPBOARD_FORMAT_ITEMS );
1073 
1074         rSet.DisableItem( SID_INSERT_FLD_DATE_FIX );
1075         rSet.DisableItem( SID_INSERT_FLD_DATE_VAR );
1076         rSet.DisableItem( SID_INSERT_FLD_TIME_FIX );
1077         rSet.DisableItem( SID_INSERT_FLD_TIME_VAR );
1078         rSet.DisableItem( SID_INSERT_FLD_AUTHOR );
1079         rSet.DisableItem( SID_INSERT_FLD_PAGE );
1080         rSet.DisableItem( SID_INSERT_FLD_PAGES );
1081         rSet.DisableItem( SID_INSERT_FLD_FILE );
1082 
1083 		rSet.DisableItem( SID_INSERT_GRAPHIC );
1084 		rSet.DisableItem( SID_INSERT_AVMEDIA );
1085 		rSet.DisableItem( SID_INSERT_DIAGRAM );
1086 		rSet.DisableItem( SID_INSERT_OBJECT );
1087         rSet.DisableItem( SID_INSERT_PLUGIN );
1088         rSet.DisableItem( SID_INSERT_SOUND );
1089         rSet.DisableItem( SID_INSERT_VIDEO );
1090         rSet.DisableItem( SID_INSERT_FLOATINGFRAME );
1091 
1092 		rSet.DisableItem( SID_INSERT_MATH );
1093 		rSet.DisableItem( SID_INSERT_FRAME );
1094 		rSet.DisableItem( SID_INSERTFILE );
1095 		rSet.DisableItem( SID_ATTR_TABLE );
1096 		rSet.DisableItem( SID_COPYOBJECTS );
1097 
1098 		rSet.DisableItem( SID_SCAN );
1099 		rSet.DisableItem( SID_TWAIN_SELECT );
1100 		rSet.DisableItem( SID_TWAIN_TRANSFER );
1101 
1102 //        rSet.DisableItem( SID_BEZIER_EDIT );
1103 		rSet.DisableItem( SID_GLUE_EDITMODE );
1104 		rSet.DisableItem( SID_OBJECT_ROTATE );
1105 		rSet.DisableItem( SID_OBJECT_SHEAR );
1106 		rSet.DisableItem( SID_OBJECT_MIRROR );
1107 		rSet.DisableItem( SID_OBJECT_CROP );
1108 		rSet.DisableItem( SID_ATTR_GRAF_CROP );
1109 		rSet.DisableItem( SID_OBJECT_TRANSPARENCE );
1110 		rSet.DisableItem( SID_OBJECT_GRADIENT );
1111 		rSet.DisableItem( SID_OBJECT_CROOK_ROTATE );
1112 		rSet.DisableItem( SID_OBJECT_CROOK_SLANT );
1113 		rSet.DisableItem( SID_OBJECT_CROOK_STRETCH );
1114 
1115 		// Alle objekterzeugenden Werkzeuge disablen
1116 		rSet.ClearItem( SID_ATTR_CHAR );
1117 		rSet.DisableItem( SID_ATTR_CHAR );
1118 		rSet.ClearItem( SID_ATTR_CHAR_VERTICAL );
1119 		rSet.DisableItem( SID_ATTR_CHAR_VERTICAL );
1120 		rSet.ClearItem(SID_DRAW_LINE);
1121 		rSet.DisableItem(SID_DRAW_LINE);
1122         rSet.ClearItem(SID_DRAW_MEASURELINE);
1123         rSet.DisableItem(SID_DRAW_MEASURELINE);
1124         rSet.ClearItem(SID_DRAW_XLINE);
1125 		rSet.DisableItem(SID_DRAW_XLINE);
1126 		rSet.ClearItem( SID_LINE_ARROW_START );
1127 		rSet.DisableItem( SID_LINE_ARROW_START );
1128 		rSet.ClearItem( SID_LINE_ARROW_END );
1129 		rSet.DisableItem( SID_LINE_ARROW_END );
1130 		rSet.ClearItem( SID_LINE_ARROWS );
1131 		rSet.DisableItem( SID_LINE_ARROWS );
1132 		rSet.ClearItem( SID_LINE_ARROW_CIRCLE );
1133 		rSet.DisableItem( SID_LINE_ARROW_CIRCLE );
1134 		rSet.ClearItem( SID_LINE_CIRCLE_ARROW );
1135 		rSet.DisableItem( SID_LINE_CIRCLE_ARROW );
1136 		rSet.ClearItem( SID_LINE_ARROW_SQUARE );
1137 		rSet.DisableItem( SID_LINE_ARROW_SQUARE );
1138 		rSet.ClearItem( SID_LINE_SQUARE_ARROW );
1139 		rSet.DisableItem( SID_LINE_SQUARE_ARROW );
1140 
1141 		rSet.ClearItem(SID_DRAW_RECT);
1142 		rSet.DisableItem(SID_DRAW_RECT);
1143 		rSet.ClearItem(SID_DRAW_RECT_NOFILL);
1144 		rSet.DisableItem(SID_DRAW_RECT_NOFILL);
1145 		rSet.ClearItem(SID_DRAW_RECT_ROUND);
1146 		rSet.DisableItem(SID_DRAW_RECT_ROUND);
1147 		rSet.ClearItem(SID_DRAW_RECT_ROUND_NOFILL);
1148 		rSet.DisableItem(SID_DRAW_RECT_ROUND_NOFILL);
1149 		rSet.ClearItem(SID_DRAW_SQUARE);
1150 		rSet.DisableItem(SID_DRAW_SQUARE);
1151 		rSet.ClearItem(SID_DRAW_SQUARE_NOFILL);
1152 		rSet.DisableItem(SID_DRAW_SQUARE_NOFILL);
1153 		rSet.ClearItem(SID_DRAW_SQUARE_ROUND);
1154 		rSet.DisableItem(SID_DRAW_SQUARE_ROUND);
1155 		rSet.ClearItem(SID_DRAW_SQUARE_ROUND_NOFILL);
1156 		rSet.DisableItem(SID_DRAW_SQUARE_ROUND_NOFILL);
1157 		rSet.ClearItem(SID_DRAW_ELLIPSE);
1158 		rSet.DisableItem(SID_DRAW_ELLIPSE);
1159 		rSet.ClearItem(SID_DRAW_ELLIPSE_NOFILL);
1160 		rSet.DisableItem(SID_DRAW_ELLIPSE_NOFILL);
1161 		rSet.ClearItem(SID_DRAW_CIRCLE);
1162 		rSet.DisableItem(SID_DRAW_CIRCLE);
1163 		rSet.ClearItem(SID_DRAW_CIRCLE_NOFILL);
1164 		rSet.DisableItem(SID_DRAW_CIRCLE_NOFILL);
1165 		rSet.ClearItem(SID_DRAW_CAPTION);
1166 		rSet.DisableItem(SID_DRAW_CAPTION);
1167 		rSet.ClearItem(SID_DRAW_FONTWORK);
1168 		rSet.DisableItem(SID_DRAW_FONTWORK);
1169 		rSet.ClearItem(SID_DRAW_FONTWORK_VERTICAL);
1170 		rSet.DisableItem(SID_DRAW_FONTWORK_VERTICAL);
1171 		rSet.ClearItem(SID_DRAW_CAPTION_VERTICAL);
1172 		rSet.DisableItem(SID_DRAW_CAPTION_VERTICAL);
1173 		rSet.ClearItem(SID_TEXT_FITTOSIZE);
1174 		rSet.DisableItem(SID_TEXT_FITTOSIZE);
1175 		rSet.ClearItem(SID_TEXT_FITTOSIZE_VERTICAL);
1176 		rSet.DisableItem(SID_TEXT_FITTOSIZE_VERTICAL);
1177 		rSet.ClearItem(SID_TOOL_CONNECTOR);
1178 		rSet.DisableItem(SID_TOOL_CONNECTOR);
1179         rSet.ClearItem(SID_CONNECTOR_ARROW_START);
1180         rSet.DisableItem(SID_CONNECTOR_ARROW_START);
1181         rSet.ClearItem(SID_CONNECTOR_ARROW_END);
1182         rSet.DisableItem(SID_CONNECTOR_ARROW_END);
1183         rSet.ClearItem(SID_CONNECTOR_ARROWS);
1184         rSet.DisableItem(SID_CONNECTOR_ARROWS);
1185         rSet.ClearItem(SID_CONNECTOR_CIRCLE_START);
1186         rSet.DisableItem(SID_CONNECTOR_CIRCLE_START);
1187         rSet.ClearItem(SID_CONNECTOR_CIRCLE_END);
1188         rSet.DisableItem(SID_CONNECTOR_CIRCLE_END);
1189         rSet.ClearItem(SID_CONNECTOR_CIRCLES);
1190         rSet.DisableItem(SID_CONNECTOR_CIRCLES);
1191         rSet.ClearItem(SID_CONNECTOR_LINE);
1192         rSet.DisableItem(SID_CONNECTOR_LINE);
1193         rSet.ClearItem(SID_CONNECTOR_LINE_ARROW_START);
1194         rSet.DisableItem(SID_CONNECTOR_LINE_ARROW_START);
1195         rSet.ClearItem(SID_CONNECTOR_LINE_ARROW_END);
1196         rSet.DisableItem(SID_CONNECTOR_LINE_ARROW_END);
1197         rSet.ClearItem(SID_CONNECTOR_LINE_ARROWS);
1198         rSet.DisableItem(SID_CONNECTOR_LINE_ARROWS);
1199         rSet.ClearItem(SID_CONNECTOR_LINE_CIRCLE_START);
1200         rSet.DisableItem(SID_CONNECTOR_LINE_CIRCLE_START);
1201         rSet.ClearItem(SID_CONNECTOR_LINE_CIRCLE_END);
1202         rSet.DisableItem(SID_CONNECTOR_LINE_CIRCLE_END);
1203         rSet.ClearItem(SID_CONNECTOR_LINE_CIRCLES);
1204         rSet.DisableItem(SID_CONNECTOR_LINE_CIRCLES);
1205         rSet.ClearItem(SID_CONNECTOR_CURVE);
1206         rSet.DisableItem(SID_CONNECTOR_CURVE);
1207         rSet.ClearItem(SID_CONNECTOR_CURVE_ARROW_START);
1208         rSet.DisableItem(SID_CONNECTOR_CURVE_ARROW_START);
1209         rSet.ClearItem(SID_CONNECTOR_CURVE_ARROW_END);
1210         rSet.DisableItem(SID_CONNECTOR_CURVE_ARROW_END);
1211         rSet.ClearItem(SID_CONNECTOR_CURVE_ARROWS);
1212         rSet.DisableItem(SID_CONNECTOR_CURVE_ARROWS);
1213         rSet.ClearItem(SID_CONNECTOR_CURVE_CIRCLE_START);
1214         rSet.DisableItem(SID_CONNECTOR_CURVE_CIRCLE_START);
1215         rSet.ClearItem(SID_CONNECTOR_CURVE_CIRCLE_END);
1216         rSet.DisableItem(SID_CONNECTOR_CURVE_CIRCLE_END);
1217         rSet.ClearItem(SID_CONNECTOR_CURVE_CIRCLES);
1218         rSet.DisableItem(SID_CONNECTOR_CURVE_CIRCLES);
1219         rSet.ClearItem(SID_CONNECTOR_LINES);
1220         rSet.DisableItem(SID_CONNECTOR_LINES);
1221         rSet.ClearItem(SID_CONNECTOR_LINES_ARROW_START);
1222         rSet.DisableItem(SID_CONNECTOR_LINES_ARROW_START);
1223         rSet.ClearItem(SID_CONNECTOR_LINES_ARROW_END);
1224         rSet.DisableItem(SID_CONNECTOR_LINES_ARROW_END);
1225         rSet.ClearItem(SID_CONNECTOR_LINES_ARROWS);
1226         rSet.DisableItem(SID_CONNECTOR_LINES_ARROWS);
1227         rSet.ClearItem(SID_CONNECTOR_LINES_CIRCLE_START);
1228         rSet.DisableItem(SID_CONNECTOR_LINES_CIRCLE_START);
1229         rSet.ClearItem(SID_CONNECTOR_LINES_CIRCLE_END);
1230         rSet.DisableItem(SID_CONNECTOR_LINES_CIRCLE_END);
1231         rSet.ClearItem(SID_CONNECTOR_LINES_CIRCLES);
1232         rSet.DisableItem(SID_CONNECTOR_LINES_CIRCLES);
1233         rSet.ClearItem(SID_DRAW_ARC);
1234 		rSet.DisableItem(SID_DRAW_ARC);
1235 		rSet.ClearItem(SID_DRAW_CIRCLEARC);
1236 		rSet.DisableItem(SID_DRAW_CIRCLEARC);
1237 		rSet.ClearItem(SID_DRAW_PIE);
1238 		rSet.DisableItem(SID_DRAW_PIE);
1239 		rSet.ClearItem(SID_DRAW_PIE_NOFILL);
1240 		rSet.DisableItem(SID_DRAW_PIE_NOFILL);
1241 		rSet.ClearItem(SID_DRAW_CIRCLEPIE);
1242 		rSet.DisableItem(SID_DRAW_CIRCLEPIE);
1243 		rSet.ClearItem(SID_DRAW_CIRCLEPIE_NOFILL);
1244 		rSet.DisableItem(SID_DRAW_CIRCLEPIE_NOFILL);
1245 		rSet.ClearItem(SID_DRAW_ELLIPSECUT);
1246 		rSet.DisableItem(SID_DRAW_ELLIPSECUT);
1247 		rSet.ClearItem(SID_DRAW_ELLIPSECUT_NOFILL);
1248 		rSet.DisableItem(SID_DRAW_ELLIPSECUT_NOFILL);
1249 		rSet.ClearItem(SID_DRAW_CIRCLECUT);
1250 		rSet.DisableItem(SID_DRAW_CIRCLECUT);
1251 		rSet.ClearItem(SID_DRAW_CIRCLECUT_NOFILL);
1252 		rSet.DisableItem(SID_DRAW_CIRCLECUT_NOFILL);
1253 		rSet.ClearItem(SID_DRAW_POLYGON);
1254 		rSet.DisableItem(SID_DRAW_POLYGON);
1255 		rSet.ClearItem(SID_DRAW_POLYGON_NOFILL);
1256 		rSet.DisableItem(SID_DRAW_POLYGON_NOFILL);
1257         rSet.ClearItem(SID_DRAW_FREELINE);
1258         rSet.DisableItem(SID_DRAW_FREELINE);
1259         rSet.ClearItem(SID_DRAW_FREELINE_NOFILL);
1260         rSet.DisableItem(SID_DRAW_FREELINE_NOFILL);
1261         rSet.ClearItem(SID_DRAW_XPOLYGON);
1262         rSet.DisableItem(SID_DRAW_XPOLYGON);
1263         rSet.ClearItem(SID_DRAW_XPOLYGON_NOFILL);
1264 		rSet.DisableItem(SID_DRAW_XPOLYGON_NOFILL);
1265         rSet.ClearItem(SID_DRAW_BEZIER_FILL);
1266         rSet.DisableItem(SID_DRAW_BEZIER_FILL);
1267         rSet.ClearItem(SID_DRAW_BEZIER_NOFILL);
1268         rSet.DisableItem(SID_DRAW_BEZIER_NOFILL);
1269 		rSet.ClearItem(SID_3D_CUBE);
1270 		rSet.DisableItem(SID_3D_CUBE);
1271 		rSet.ClearItem(SID_3D_SHELL);
1272 		rSet.DisableItem(SID_3D_SHELL);
1273 		rSet.ClearItem(SID_3D_SPHERE);
1274 		rSet.DisableItem(SID_3D_SPHERE);
1275 		rSet.ClearItem(SID_3D_HALF_SPHERE);
1276 		rSet.DisableItem(SID_3D_HALF_SPHERE);
1277 		rSet.ClearItem(SID_3D_CYLINDER);
1278 		rSet.DisableItem(SID_3D_CYLINDER);
1279 		rSet.ClearItem(SID_3D_CONE);
1280 		rSet.DisableItem(SID_3D_CONE);
1281 		rSet.ClearItem(SID_3D_TORUS);
1282 		rSet.DisableItem(SID_3D_TORUS);
1283 		rSet.ClearItem(SID_3D_PYRAMID);
1284 		rSet.DisableItem(SID_3D_PYRAMID);
1285 	}
1286 
1287 	// Sind die Module verfuegbar?
1288 
1289 	if (!SvtModuleOptions().IsCalc())
1290 	{
1291         // remove menu entry if module is not available
1292         rSet.Put( SfxVisibilityItem( SID_ATTR_TABLE, sal_False ) );
1293 	}
1294 	if (!SvtModuleOptions().IsChart())
1295 	{
1296 		rSet.DisableItem( SID_INSERT_DIAGRAM );
1297 	}
1298 #ifdef STARIMAGE_AVAILABLE
1299 	if (!(pApp->HasFeature(SFX_FEATURE_SIMAGE)))
1300 	{
1301 		rSet.DisableItem( SID_INSERT_IMAGE );
1302 	}
1303 #endif
1304 	if (!SvtModuleOptions().IsMath())
1305 	{
1306 		rSet.DisableItem( SID_INSERT_MATH );
1307 	}
1308 
1309 	rtl::Reference< sd::SlideShow > xSlideshow( SlideShow::GetSlideShow( GetViewShellBase() ) );
1310 	if( (xSlideshow.is() && xSlideshow->isRunning() && (xSlideshow->getAnimationMode() != ANIMATIONMODE_PREVIEW) ) || GetDocSh()->IsPreview() )
1311 	{
1312 		// Eigene Slots
1313 		rSet.DisableItem( SID_PRESENTATION );
1314 		rSet.DisableItem( SID_ZOOM_IN );
1315 		rSet.DisableItem( SID_ZOOM_OUT );
1316 		rSet.DisableItem( SID_ZOOM_PANNING );
1317 		rSet.DisableItem( SID_ZOOM_NEXT );
1318 		rSet.DisableItem( SID_ZOOM_PREV );
1319 		rSet.DisableItem( SID_SIZE_REAL );
1320 		rSet.DisableItem( SID_SIZE_OPTIMAL );
1321 		rSet.DisableItem( SID_SIZE_ALL );
1322 		rSet.DisableItem( SID_SIZE_PAGE_WIDTH );
1323 		rSet.DisableItem( SID_SIZE_PAGE );
1324 		rSet.DisableItem( SID_INSERTPAGE );
1325         rSet.DisableItem( SID_DUPLICATE_PAGE );
1326 		rSet.DisableItem( SID_MODIFYPAGE );
1327 		rSet.DisableItem( SID_RENAMEPAGE );
1328 		rSet.DisableItem( SID_RENAMEPAGE_QUICK );
1329 		rSet.DisableItem( SID_DELETE_PAGE );
1330 		rSet.DisableItem( SID_PAGESETUP );
1331 
1332 		if( xSlideshow.is() && xSlideshow->isRunning() )
1333 		{
1334 			rSet.ClearItem(SID_OBJECT_ALIGN);
1335 			rSet.ClearItem(SID_ZOOM_TOOLBOX);
1336 			rSet.ClearItem(SID_OBJECT_CHOOSE_MODE);
1337 			rSet.ClearItem(SID_DRAWTBX_TEXT);
1338 			rSet.ClearItem(SID_DRAWTBX_RECTANGLES);
1339 			rSet.ClearItem(SID_DRAWTBX_ELLIPSES);
1340 			rSet.ClearItem(SID_DRAWTBX_LINES);
1341 			rSet.ClearItem(SID_DRAWTBX_ARROWS);
1342 			rSet.ClearItem(SID_DRAWTBX_3D_OBJECTS);
1343 		    rSet.ClearItem(SID_DRAWTBX_CONNECTORS);
1344 			rSet.ClearItem(SID_OBJECT_CHOOSE_MODE );
1345 			rSet.ClearItem(SID_DRAWTBX_INSERT);
1346 			rSet.ClearItem(SID_INSERTFILE);
1347 			rSet.ClearItem(SID_OBJECT_ROTATE);
1348 			rSet.ClearItem(SID_OBJECT_ALIGN);
1349 			rSet.ClearItem(SID_POSITION);
1350 			rSet.ClearItem(SID_FM_CONFIG);
1351 			rSet.ClearItem(SID_ANIMATION_EFFECTS);
1352 			rSet.ClearItem(SID_ANIMATION_OBJECTS);
1353 			rSet.ClearItem(SID_3D_WIN);
1354 
1355 			rSet.DisableItem(SID_OBJECT_ALIGN);
1356 			rSet.DisableItem(SID_ZOOM_TOOLBOX);
1357 			rSet.DisableItem(SID_OBJECT_CHOOSE_MODE);
1358 			rSet.DisableItem(SID_DRAWTBX_TEXT);
1359 			rSet.DisableItem(SID_DRAWTBX_RECTANGLES);
1360 			rSet.DisableItem(SID_DRAWTBX_ELLIPSES);
1361 			rSet.DisableItem(SID_DRAWTBX_LINES);
1362 			rSet.DisableItem(SID_DRAWTBX_ARROWS);
1363 			rSet.DisableItem(SID_DRAWTBX_3D_OBJECTS);
1364 		    rSet.DisableItem(SID_DRAWTBX_CONNECTORS);
1365 			rSet.DisableItem(SID_OBJECT_CHOOSE_MODE );
1366 			rSet.DisableItem(SID_DRAWTBX_INSERT);
1367 			rSet.DisableItem(SID_INSERTFILE);
1368 			rSet.DisableItem(SID_OBJECT_ROTATE);
1369 			rSet.DisableItem(SID_OBJECT_ALIGN);
1370 			rSet.DisableItem(SID_POSITION);
1371 			rSet.DisableItem(SID_FM_CONFIG);
1372 			rSet.DisableItem(SID_ANIMATION_EFFECTS);
1373 			rSet.DisableItem(SID_ANIMATION_OBJECTS);
1374 			rSet.DisableItem(SID_3D_WIN);
1375 		}
1376 	}
1377 
1378     // #i102735# discussed with CL: removed for performance reasons
1379     #if 0
1380 	if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_INSERT_SOUND ) ||
1381 		SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_INSERT_VIDEO ) )
1382 	{
1383 		///////////////////////////////////////////////////////////////////////
1384 		// Menuoption : Insert->Object->Sound and Insert->Object->Video
1385 		//              diable, if there isn't installed any appropriate plugin
1386 		//
1387 		if (!SvxPluginFileDlg::IsAvailable (SID_INSERT_SOUND))
1388 			rSet.DisableItem (SID_INSERT_SOUND);
1389 		if (!SvxPluginFileDlg::IsAvailable (SID_INSERT_VIDEO))
1390 			rSet.DisableItem (SID_INSERT_VIDEO);
1391 	}
1392     #endif
1393 
1394 	///////////////////////////////////////////////////////////////////////
1395 	// Menuoption: Change->Convert->To Bitmap, Change->Convert->To Metafile
1396 	//             disable, if there only Bitmap or Metafiles marked
1397 	// Menuoption: Format->Area, Format->Line
1398 	//             disabled, if the marked objects not able to handle
1399 	//             these attributes
1400 	//
1401 
1402 	bool bSingleGraphicSelected = false;
1403 
1404 	if (!mpDrawView->AreObjectsMarked())
1405 	{
1406 		rSet.DisableItem (SID_CONVERT_TO_METAFILE);
1407 		rSet.DisableItem (SID_CONVERT_TO_BITMAP);
1408 	}
1409 	else
1410 	{
1411 		// get marklist
1412 		SdrMarkList aMarkList = mpDrawView->GetMarkedObjectList();
1413 
1414 		sal_Bool bFoundBitmap         = sal_False;
1415 		sal_Bool bFoundMetafile       = sal_False;
1416 		sal_Bool bFoundObjNoLine      = sal_False;
1417 		sal_Bool bFoundObjNoArea      = sal_False;
1418 		sal_Bool bFoundNoGraphicObj = sal_False;
1419 		sal_Bool bFoundAny            = sal_False;
1420 		bool bFoundTable = false;
1421 
1422 //		const int nMarkCount = (int) aMarkList.GetMarkCount();
1423 		for (sal_uLong i=0; i < nMarkCount && !bFoundAny; i++)
1424 		{
1425 			SdrObject* pObj=  aMarkList.GetMark(i)->GetMarkedSdrObj();
1426 			sal_uInt16 nId = pObj->GetObjIdentifier();
1427 			sal_uInt32 nInv = pObj->GetObjInventor();
1428 
1429 			if(nInv == SdrInventor)
1430 			{
1431 				// 2D objects
1432 				switch( nId )
1433 				{
1434 					case OBJ_PATHLINE :
1435 					case OBJ_PLIN :
1436 					case OBJ_LINE:
1437 					case OBJ_FREELINE :
1438 					case OBJ_EDGE:
1439 					case OBJ_CARC :
1440 						bFoundObjNoArea      = sal_True;
1441 						bFoundNoGraphicObj = sal_True;
1442 						break;
1443 					case OBJ_OLE2 :
1444 						// #i118485# #i118525# Allow Line, Area and Graphic (Metafile, Bitmap)
1445 						bSingleGraphicSelected = nMarkCount == 1;
1446     					bFoundBitmap = true;
1447     					bFoundMetafile = true;
1448 						break;
1449 					case OBJ_GRAF :
1450                     {
1451 						bSingleGraphicSelected = nMarkCount == 1;
1452                         const SdrGrafObj* pSdrGrafObj = static_cast< const SdrGrafObj* >(pObj);
1453 						switch(pSdrGrafObj->GetGraphicType())
1454 						{
1455 							case GRAPHIC_BITMAP :
1456 								bFoundBitmap = sal_True;
1457                                 if(pSdrGrafObj->isEmbeddedSvg())
1458                                 {
1459                                     bFoundMetafile = true;
1460                                 }
1461 								break;
1462 							case GRAPHIC_GDIMETAFILE :
1463 								bFoundMetafile = sal_True;
1464 								break;
1465 							default:
1466 								break;
1467 						}
1468 
1469 						// #i25616# bFoundObjNoLine = sal_True;
1470 						// #i25616# bFoundObjNoArea = sal_True;
1471 						break;
1472                     }
1473 					case OBJ_TABLE:
1474 						bFoundTable = true;
1475 						break;
1476 					default :
1477 						bFoundAny = sal_True;
1478 				}
1479 			}
1480 			else if(nInv == E3dInventor)
1481 			{
1482 				// 3D objects
1483 				bFoundAny = sal_True;
1484 			}
1485 		}
1486 
1487 		if( bFoundTable )
1488 			rSet.DisableItem( SID_ATTRIBUTES_LINE );
1489 
1490 		if (!bFoundAny)
1491 		{
1492 			// Disable menuitem for area-dialog
1493 			if( bFoundObjNoArea ) // #i25616#
1494 				rSet.DisableItem( SID_ATTRIBUTES_AREA );
1495 
1496 			// Disable menuitem for line-dialog
1497 			if( bFoundObjNoLine )
1498 				rSet.DisableItem( SID_ATTRIBUTES_LINE );
1499 
1500 			if( bFoundBitmap && !bFoundMetafile && !bFoundNoGraphicObj )	// only Bitmaps marked
1501 				rSet.DisableItem( SID_CONVERT_TO_BITMAP );
1502 			else if( !bFoundBitmap && bFoundMetafile && !bFoundNoGraphicObj )	// only Metafiles marked
1503 				rSet.DisableItem( SID_CONVERT_TO_METAFILE );
1504 			else if( !bFoundBitmap && !bFoundMetafile && !bFoundNoGraphicObj )	// nothing to do
1505 			{
1506 				rSet.DisableItem( SID_CONVERT_TO_BITMAP );
1507 				rSet.DisableItem( SID_CONVERT_TO_METAFILE );
1508 			}
1509 		}
1510 	}
1511 
1512 	if( !bSingleGraphicSelected )
1513 	{
1514 		rSet.DisableItem (SID_OBJECT_CROP);
1515 		rSet.DisableItem (SID_ATTR_GRAF_CROP);
1516 	}
1517 
1518 	// #96090# moved SID_UNDO to ViewShell::GetMenuState()
1519 	// #96090# moved SID_REDO to ViewShell::GetMenuState()
1520 	// #96090# moved SID_GETUNDOSTRINGS to ViewShell::GetMenuState()
1521 	// #96090# moved SID_GETREDOSTRINGS to ViewShell::GetMenuState()
1522 
1523 	///////////////////////////////////////////////////////////////////////
1524 	// Menuoption: Edit->Hyperlink
1525 	// Disable, if there is no hyperlink
1526 	//
1527     sal_Bool bDisableEditHyperlink = sal_True;
1528 	if( mpDrawView->AreObjectsMarked() && ( mpDrawView->GetMarkedObjectList().GetMarkCount() == 1 ) )
1529 	{
1530 		if( mpDrawView->IsTextEdit() )
1531 		{
1532 			OutlinerView* pOLV = mpDrawView->GetTextEditOutlinerView();
1533 			if (pOLV)
1534 			{
1535 				const SvxFieldItem* pFieldItem = pOLV->GetFieldAtSelection();
1536 				if (pFieldItem)
1537 				{
1538                     ESelection aSel = pOLV->GetSelection();
1539                     if ( abs( aSel.nEndPos - aSel.nStartPos ) == 1 )
1540                     {
1541 					    const SvxFieldData* pField = pFieldItem->GetField();
1542 					    if ( pField->ISA(SvxURLField) )
1543                             bDisableEditHyperlink = sal_False;
1544                     }
1545 				}
1546 			}
1547 		}
1548 		else
1549 		{
1550 			SdrUnoObj* pUnoCtrl = PTR_CAST(SdrUnoObj, mpDrawView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj());
1551 
1552 			if ( pUnoCtrl && FmFormInventor == pUnoCtrl->GetObjInventor() )
1553 			{
1554 				uno::Reference< awt::XControlModel > xControlModel( pUnoCtrl->GetUnoControlModel() );
1555 				if( xControlModel.is() )
1556 				{
1557 					uno::Reference< beans::XPropertySet > xPropSet( xControlModel, uno::UNO_QUERY );
1558 					if( xPropSet.is() )
1559 					{
1560 						uno::Reference< beans::XPropertySetInfo > xPropInfo( xPropSet->getPropertySetInfo() );
1561 						if( xPropInfo.is() && xPropInfo->hasPropertyByName(
1562 							rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TargetURL"))))
1563 						{
1564 							bDisableEditHyperlink = sal_False;
1565 						}
1566 					}
1567 				}
1568 			}
1569 		}
1570 	}
1571 
1572 	//highlight selected custom shape
1573 	{
1574 		sal_uInt16 nCurrentSId = 0;
1575 		if(HasCurrentFunction())
1576 			nCurrentSId = GetCurrentFunction()->GetSlotID();
1577 
1578 		if ( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_DRAWTBX_CS_BASIC ) )
1579 			rSet.Put(SfxBoolItem(SID_DRAWTBX_CS_BASIC, SID_DRAWTBX_CS_BASIC == nCurrentSId ));
1580 		if ( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_DRAWTBX_CS_SYMBOL ) )
1581 			rSet.Put(SfxBoolItem(SID_DRAWTBX_CS_SYMBOL, SID_DRAWTBX_CS_SYMBOL == nCurrentSId ));
1582 		if ( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_DRAWTBX_CS_ARROW ) )
1583 			rSet.Put(SfxBoolItem(SID_DRAWTBX_CS_ARROW, SID_DRAWTBX_CS_ARROW == nCurrentSId ));
1584 		if ( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_DRAWTBX_CS_FLOWCHART ) )
1585 			rSet.Put(SfxBoolItem(SID_DRAWTBX_CS_FLOWCHART, SID_DRAWTBX_CS_FLOWCHART == nCurrentSId ));
1586 		if ( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_DRAWTBX_CS_CALLOUT ) )
1587 			rSet.Put(SfxBoolItem(SID_DRAWTBX_CS_CALLOUT,SID_DRAWTBX_CS_CALLOUT == nCurrentSId ));
1588 		if ( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_DRAWTBX_CS_STAR ) )
1589 			rSet.Put(SfxBoolItem(SID_DRAWTBX_CS_STAR, SID_DRAWTBX_CS_STAR == nCurrentSId ));
1590 	}
1591 
1592     if ( bDisableEditHyperlink || GetDocSh()->IsReadOnly() )
1593         rSet.DisableItem( SID_EDIT_HYPERLINK );
1594 
1595 	if ( bDisableEditHyperlink )
1596 		rSet.DisableItem( SID_OPEN_HYPERLINK );
1597 
1598 #if defined WNT || defined UNX
1599 	if( !mxScannerManager.is() )
1600 	{
1601 		rSet.DisableItem( SID_TWAIN_SELECT );
1602 		rSet.DisableItem( SID_TWAIN_TRANSFER );
1603 	}
1604 #endif
1605 
1606     // Set the state of two entries in the 'Slide' context sub-menu
1607     // concerning the visibility of master page background and master page
1608     // shapes.
1609     if (rSet.GetItemState(SID_DISPLAY_MASTER_BACKGROUND) == SFX_ITEM_AVAILABLE
1610         || rSet.GetItemState(SID_DISPLAY_MASTER_OBJECTS) == SFX_ITEM_AVAILABLE)
1611     {
1612         SdPage* pPage = GetActualPage();
1613         if (pPage != NULL
1614             && GetDoc() != NULL)
1615         {
1616             SetOfByte aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers();
1617             SdrLayerAdmin& rLayerAdmin = GetDoc()->GetLayerAdmin();
1618             sal_uInt8 aBackgroundId = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRND)), sal_False);
1619             sal_uInt8 aObjectId = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False);
1620             rSet.Put(SfxBoolItem(SID_DISPLAY_MASTER_BACKGROUND,
1621                     aVisibleLayers.IsSet(aBackgroundId)));
1622             rSet.Put(SfxBoolItem(SID_DISPLAY_MASTER_OBJECTS,
1623                     aVisibleLayers.IsSet(aObjectId)));
1624         }
1625     }
1626 
1627     GetModeSwitchingMenuState (rSet);
1628 }
1629 
GetModeSwitchingMenuState(SfxItemSet & rSet)1630 void DrawViewShell::GetModeSwitchingMenuState (SfxItemSet &rSet)
1631 {
1632     //draview
1633 	rSet.Put(SfxBoolItem(SID_DIAMODE, sal_False));
1634 	rSet.Put(SfxBoolItem(SID_OUTLINEMODE, sal_False));
1635 	if (mePageKind == PK_NOTES)
1636 	{
1637 		rSet.Put(SfxBoolItem(SID_DRAWINGMODE, sal_False));
1638 		rSet.Put(SfxBoolItem(SID_NOTESMODE, sal_True));
1639 		rSet.Put(SfxBoolItem(SID_HANDOUTMODE, sal_False));
1640     }
1641 	else if (mePageKind == PK_HANDOUT)
1642 	{
1643 		rSet.Put(SfxBoolItem(SID_DRAWINGMODE, sal_False));
1644 		rSet.Put(SfxBoolItem(SID_NOTESMODE, sal_False));
1645 		rSet.Put(SfxBoolItem(SID_HANDOUTMODE, sal_True));
1646     }
1647     else
1648     {
1649 		rSet.Put(SfxBoolItem(SID_DRAWINGMODE, sal_True));
1650 		rSet.Put(SfxBoolItem(SID_NOTESMODE, sal_False));
1651 		rSet.Put(SfxBoolItem(SID_HANDOUTMODE, sal_False));
1652     }
1653 
1654     // #101976# Removed [GetDocSh()->GetCurrentFunction() ||] from the following
1655     // clause because the current function of the docshell can only be
1656     // search and replace or spell checking and in that case switching the
1657     // view mode is allowed.
1658 	const bool bIsRunning = SlideShow::IsRunning(GetViewShellBase());
1659 
1660     if (GetViewFrame()->GetFrame().IsInPlace() || bIsRunning)
1661 	{
1662         if ( !GetViewFrame()->GetFrame().IsInPlace() )
1663 		{
1664 			rSet.ClearItem( SID_DRAWINGMODE );
1665 			rSet.DisableItem( SID_DRAWINGMODE );
1666 		}
1667 
1668 		rSet.ClearItem( SID_NOTESMODE );
1669 		rSet.DisableItem( SID_NOTESMODE );
1670 
1671 		rSet.ClearItem( SID_HANDOUTMODE );
1672 		rSet.DisableItem( SID_HANDOUTMODE );
1673 
1674 		rSet.ClearItem( SID_OUTLINEMODE );
1675 		rSet.DisableItem( SID_OUTLINEMODE );
1676 
1677 		rSet.ClearItem( SID_DIAMODE );
1678 		rSet.DisableItem( SID_DIAMODE );
1679 	}
1680 
1681 	if (GetDocSh()->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED)
1682 	{
1683 		// Outplace-Edit: Kein Umschalten erlauben
1684 		rSet.ClearItem( SID_OUTLINEMODE );
1685 		rSet.DisableItem( SID_OUTLINEMODE );
1686 
1687 		rSet.ClearItem( SID_DIAMODE );
1688 		rSet.DisableItem( SID_DIAMODE );
1689 
1690 		rSet.ClearItem( SID_NOTESMODE );
1691 		rSet.DisableItem( SID_NOTESMODE );
1692 
1693 		rSet.ClearItem( SID_HANDOUTMODE );
1694 		rSet.DisableItem( SID_HANDOUTMODE );
1695 	}
1696 
1697 	svx::ExtrusionBar::getState( mpDrawView, rSet );
1698 	svx::FontworkBar::getState( mpDrawView, rSet );
1699 }
1700 
1701 
1702 
GetState(SfxItemSet & rSet)1703 void DrawViewShell::GetState (SfxItemSet& rSet)
1704 {
1705     // Iterate over all requested items in the set.
1706 	SfxWhichIter aIter( rSet );
1707 	sal_uInt16 nWhich = aIter.FirstWhich();
1708 	while (nWhich)
1709 	{
1710 		switch (nWhich)
1711 		{
1712 			case SID_SEARCH_ITEM:
1713 			case SID_SEARCH_OPTIONS:
1714                 // Forward this request to the common (old) code of the
1715                 // document shell.
1716                 GetDocSh()->GetState (rSet);
1717                 break;
1718 			default:
1719                 OSL_TRACE ("DrawViewShell::GetState(): can not handle which id %d", nWhich);
1720                 break;
1721 		}
1722 		nWhich = aIter.NextWhich();
1723 	}
1724 }
1725 
1726 
1727 
1728 
Execute(SfxRequest & rReq)1729 void DrawViewShell::Execute (SfxRequest& rReq)
1730 {
1731 	if(SlideShow::IsRunning(GetViewShellBase()))
1732     {
1733         // Do not execute anything during a native slide show.
1734         return;
1735 	}
1736 
1737 	switch (rReq.GetSlot())
1738 	{
1739 		case SID_SEARCH_ITEM:
1740             // Forward this request to the common (old) code of the
1741             // document shell.
1742             GetDocSh()->Execute (rReq);
1743 		break;
1744 
1745         case SID_SPELL_DIALOG:
1746         {
1747             SfxViewFrame* pViewFrame = GetViewFrame();
1748             if (rReq.GetArgs() != NULL)
1749                 pViewFrame->SetChildWindow (SID_SPELL_DIALOG,
1750                     ((const SfxBoolItem&) (rReq.GetArgs()->
1751                         Get(SID_SPELL_DIALOG))).GetValue());
1752             else
1753                 pViewFrame->ToggleChildWindow(SID_SPELL_DIALOG);
1754 
1755             pViewFrame->GetBindings().Invalidate(SID_SPELL_DIALOG);
1756             rReq.Ignore ();
1757         }
1758         break;
1759 
1760 		default:
1761             OSL_TRACE ("DrawViewShell::Execute(): can not handle slot %d", rReq.GetSlot());
1762             break;
1763 	}
1764 }
1765 
1766 } // end of namespace sd
1767