xref: /aoo42x/main/sw/source/ui/shells/basesh.cxx (revision 3f09c2ce)
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_sw.hxx"
26 
27 #include <sot/factory.hxx>
28 #include <hintids.hxx>
29 #include <svl/urihelper.hxx>
30 #include <svl/languageoptions.hxx>
31 
32 #include <svx/svxids.hrc>
33 #include <sfx2/linkmgr.hxx>
34 #include <svx/htmlmode.hxx>
35 #include <svx/imapdlg.hxx>
36 #include <svx/xflclit.hxx>
37 #include <sfx2/dispatch.hxx>
38 #include <sfx2/docfile.hxx>
39 #include <sfx2/viewfrm.hxx>
40 #include <sfx2/request.hxx>
41 #include <svl/whiter.hxx>
42 #include <svl/visitem.hxx>
43 #include <sfx2/objitem.hxx>
44 #include <svtools/filter.hxx>
45 #include <svx/gallery.hxx>
46 #include <editeng/langitem.hxx>
47 #include <svx/clipfmtitem.hxx>
48 #include <svx/contdlg.hxx>
49 #include <vcl/graph.hxx>
50 #include <svl/slstitm.hxx>
51 #include <vcl/msgbox.hxx>
52 #include <svl/ptitem.hxx>
53 #include <svl/itemiter.hxx>
54 #include <svl/stritem.hxx>
55 #include <editeng/colritem.hxx>
56 #include <editeng/shaditem.hxx>
57 #include <editeng/boxitem.hxx>
58 #include <svl/srchitem.hxx>
59 #include <editeng/ulspitem.hxx>
60 #include <editeng/lrspitem.hxx>
61 #include <editeng/brshitem.hxx>
62 #include <editeng/opaqitem.hxx>
63 #include <editeng/sizeitem.hxx>
64 #include <svx/flagsdef.hxx>
65 #include <editeng/scripttypeitem.hxx>
66 #include <sfx2/objface.hxx>
67 #include <fmturl.hxx>
68 #include <fmthdft.hxx>
69 #include <fmtclds.hxx>
70 #include <docsh.hxx>
71 #include <wrtsh.hxx>
72 #include <view.hxx>
73 #include <swmodule.hxx>
74 #include <swundo.hxx>
75 #include <fldbas.hxx>
76 #include <uitool.hxx>
77 #include <basesh.hxx>
78 #include <viewopt.hxx>
79 #include <fontcfg.hxx>
80 #include <docstat.hxx>
81 #include <usrfld.hxx>
82 #include <expfld.hxx>
83 #include <fldmgr.hxx>
84 #include <frmmgr.hxx>
85 #include <tablemgr.hxx>
86 #include <mdiexp.hxx>
87 #include <swdtflvr.hxx>
88 #include <pagedesc.hxx>
89 #include <convert.hxx>
90 #include <fmtcol.hxx>
91 #include <edtwin.hxx>
92 #include <tblafmt.hxx>
93 #include <caption.hxx>
94 #include <swwait.hxx>
95 #include <cmdid.h>
96 #include <globals.hrc>
97 #include <shells.hrc>
98 #include <statstr.hrc>
99 #include <globals.h>
100 #include <unotxdoc.hxx>
101 #include <crsskip.hxx>
102 #include <fmtinfmt.hxx>
103 #include <doc.hxx>
104 
105 #include "swabstdlg.hxx"
106 #include "dialog.hrc"
107 #include "fldui.hrc"
108 #include "table.hrc"
109 #include <modcfg.hxx>
110 #include <instable.hxx>
111 #include <svx/fmshell.hxx> // for FN_XFORMS_DESIGN_MODE
112 #include <SwRewriter.hxx>
113 #include <comcore.hrc>
114 
115 #include <unomid.h>
116 #include <svx/galleryitem.hxx>
117 #include <com/sun/star/gallery/GalleryItemType.hpp>
118 
119 FlyMode SwBaseShell::eFrameMode = FLY_DRAG_END;
120 
121 
122 //Fuer die Erkennung der Id, die variable von Gallery mit SID_GALLERY_BG_BRUSH
123 //ankommt.
124 static sal_uInt8 nParagraphPos;
125 static sal_uInt8 nGraphicPos;
126 static sal_uInt8 nOlePos;
127 static sal_uInt8 nFramePos;
128 static sal_uInt8 nTablePos;
129 static sal_uInt8 nTableRowPos;
130 static sal_uInt8 nTableCellPos;
131 static sal_uInt8 nPagePos;
132 static sal_uInt8 nHeaderPos;
133 static sal_uInt8 nFooterPos;
134 
135 #define SwBaseShell
136 #define Shadow
137 #include <sfx2/msg.hxx>
138 #include "swslots.hxx"
139 
140 #define SWCONTOURDLG(rView) ( (SvxContourDlg*) ( rView.GetViewFrame()->GetChildWindow( 	\
141 						  SvxContourDlgChildWindow::GetChildWindowId() )-> 	\
142 						  GetWindow() ) )
143 
144 #define SWIMAPDLG(rView) ( (SvxIMapDlg*) ( rView.GetViewFrame()->GetChildWindow( 		\
145 						SvxIMapDlgChildWindow::GetChildWindowId() )-> 	\
146 						GetWindow() ) )
147 
148 
149 using namespace ::com::sun::star;
150 using namespace ::com::sun::star::uno;
151 using namespace ::com::sun::star::frame;
152 using namespace ::com::sun::star::lang;
153 
154 
155 SFX_IMPL_INTERFACE(SwBaseShell, SfxShell, SW_RES(0))
156 {
157 	SFX_CHILDWINDOW_REGISTRATION(SvxIMapDlgChildWindow::GetChildWindowId());
158 	SFX_CHILDWINDOW_REGISTRATION(SvxContourDlgChildWindow::GetChildWindowId());
159 }
160 
161 TYPEINIT1(SwBaseShell,SfxShell)
162 
163 /*--------------------------------------------------------------------
164 	Beschreibung:	statics
165  --------------------------------------------------------------------*/
166 
167 
168 void lcl_UpdateIMapDlg( SwWrtShell& rSh )
169 {
170 	Graphic aGrf( rSh.GetIMapGraphic() );
171     GraphicType nGrfType = aGrf.GetType();
172 	void* pEditObj = GRAPHIC_NONE != nGrfType && GRAPHIC_DEFAULT != nGrfType
173 						? rSh.GetIMapInventor() : 0;
174 	TargetList* pList = new TargetList;
175 	rSh.GetView().GetViewFrame()->GetTopFrame().GetTargetList(*pList);
176 
177 	SfxItemSet aSet( rSh.GetAttrPool(), RES_URL, RES_URL );
178 	rSh.GetFlyFrmAttr( aSet );
179 	const SwFmtURL &rURL = (SwFmtURL&)aSet.Get( RES_URL );
180 	SvxIMapDlgChildWindow::UpdateIMapDlg(
181 			aGrf, rURL.GetMap(), pList, pEditObj );
182 
183 	sal_uInt16 nCount = (sal_uInt16)pList->Count();
184 	if(nCount)
185 		for( sal_uInt16 i = nCount; i; i--  )
186 		{
187 			delete pList->GetObject(i-1);
188 		}
189 	delete pList;
190 }
191 
192 
193 sal_Bool lcl_UpdateContourDlg( SwWrtShell &rSh, int nSel )
194 {
195 	Graphic aGraf( rSh.GetIMapGraphic() );
196     GraphicType nGrfType = aGraf.GetType();
197 	sal_Bool bRet = GRAPHIC_NONE != nGrfType && GRAPHIC_DEFAULT != nGrfType;
198 	if( bRet )
199 	{
200 		String aGrfName;
201 		if ( nSel & nsSelectionType::SEL_GRF )
202 			rSh.GetGrfNms( &aGrfName, 0 );
203 
204 		SvxContourDlg *pDlg = SWCONTOURDLG(rSh.GetView());
205 		pDlg->Update( aGraf, aGrfName.Len() > 0,
206 				  rSh.GetGraphicPolygon(), rSh.GetIMapInventor() );
207 	}
208 	return bRet;
209 }
210 
211 /*--------------------------------------------------------------------
212 	Beschreibung:	loeschen
213  --------------------------------------------------------------------*/
214 
215 void SwBaseShell::ExecDelete(SfxRequest &rReq)
216 {
217 	SwWrtShell &rSh = GetShell();
218     SwEditWin& rTmpEditWin = GetView().GetEditWin();
219 	switch(rReq.GetSlot())
220 	{
221 		case SID_DELETE:
222 			rSh.DelRight();
223 			break;
224 
225 		case FN_BACKSPACE:
226 
227 			if( rSh.IsNoNum() )
228 			{
229 				rSh.SttCrsrMove();
230 				sal_Bool bLeft = rSh.Left( CRSR_SKIP_CHARS, sal_True, 1, sal_False  );
231 				if( bLeft )
232 				{
233 					// JP 28.03.96: ein Backspace im Absatz ohne Nummer wird zum Delete
234 					//rSh.SwapPam();
235 					//rSh.DelRight( sal_False );
236 
237                     rSh.DelLeft();
238 				}
239 				else
240 					// JP 15.07.96: wenns nicht mehr nach vorne geht, die
241 					//				Numerierung aufheben. Z.B. am Doc-/
242 					//				Rahmen-/Tabellen-/Bereichs-Anfang
243 					rSh.DelNumRules();
244 
245 				rSh.EndCrsrMove();
246 				break;
247 			}
248 
249 			// ansonsten DelLeft rufen
250 		case FN_SHIFT_BACKSPACE:
251 			rSh.DelLeft();
252 			break;
253 		default:
254 			DBG_ERROR("falscher Dispatcher");
255 			return;
256 	}
257     rReq.Done();
258 
259     //#i42732# - notify the edit window that from now on we do not use the input language
260     rTmpEditWin.SetUseInputLanguage( sal_False );
261 }
262 
263 /*--------------------------------------------------------------------
264 	Beschreibung:
265  --------------------------------------------------------------------*/
266 
267 void SwBaseShell::ExecClpbrd(SfxRequest &rReq)
268 {
269 	//Achtung: Suizid gefaehrdet! Nach Paste, Paste special kann der die
270 	//Shell zerstoert sein.
271 
272 
273 	SwWrtShell &rSh = GetShell();
274 	sal_uInt16 nId = rReq.GetSlot();
275     sal_Bool bIgnore = sal_False;
276 	switch( nId )
277 	{
278 		case SID_CUT:
279 		case SID_COPY:
280             rView.GetEditWin().FlushInBuffer();
281 			if ( rSh.HasSelection() )
282 			{
283 				SwTransferable* pTransfer = new SwTransferable( rSh );
284 /*??*/          uno::Reference< datatransfer::XTransferable > xRef( pTransfer );
285 
286 				if ( nId == SID_CUT && !rSh.IsSelObjProtected(FLYPROTECT_CONTENT|FLYPROTECT_PARENT) )
287 					pTransfer->Cut();
288 				else
289                 {
290                     const sal_Bool bLockedView = rSh.IsViewLocked();
291                     rSh.LockView( sal_True );    //lock visible section
292                     pTransfer->Copy();
293                     rSh.LockView( bLockedView );
294                 }
295 				break;
296 			}
297 			return;
298 
299         case SID_PASTE:
300             {
301                 TransferableDataHelper aDataHelper(
302                     TransferableDataHelper::CreateFromSystemClipboard( &rSh.GetView().GetEditWin() ) );
303                 if( aDataHelper.GetXTransferable().is()
304                     && SwTransferable::IsPaste( rSh, aDataHelper )
305                     && !rSh.CrsrInsideInputFld() )
306                 {
307                     // temp. Variablen, da die Shell nach dem Paste schon
308                     // zerstoert sein kann
309                     SwView* pView = &rView;
310                     SwTransferable::Paste( rSh, aDataHelper );
311                     if( rSh.IsFrmSelected() || rSh.IsObjSelected() )
312                         rSh.EnterSelFrmMode();
313                     pView->AttrChangedNotify( &rSh );
314                 }
315                 else
316                     return;
317             }
318             break;
319 
320 		case SID_CLIPBOARD_FORMAT_ITEMS:
321 			{
322 				const SfxItemSet* pArgs = rReq.GetArgs();
323 				const SfxPoolItem* pFmt;
324                 if( pArgs && SFX_ITEM_SET == pArgs->GetItemState( nId, sal_False, &pFmt ) )
325 				{
326 					TransferableDataHelper aDataHelper(
327 						TransferableDataHelper::CreateFromSystemClipboard(
328 											&rSh.GetView().GetEditWin()) );
329 					if( aDataHelper.GetXTransferable().is()
330 						/*&& SwTransferable::IsPaste( rSh, aDataHelper )*/ )
331 					{
332 						// temp. Variablen, da die Shell nach dem Paste schon
333 						// zerstoert sein kann
334 						SwView* pView = &rView;
335 
336 						SwTransferable::PasteFormat( rSh, aDataHelper,
337 										((SfxUInt32Item*)pFmt)->GetValue() );
338 
339                         //Done() has to be called before the shell has been removed
340                         rReq.Done();
341                         bIgnore = sal_True;
342                         if( rSh.IsFrmSelected() || rSh.IsObjSelected())
343 							rSh.EnterSelFrmMode();
344 						pView->AttrChangedNotify( &rSh );
345                     }
346 				}
347 			}
348 			break;
349 
350         case SID_PASTE_UNFORMATTED:
351             {
352                 TransferableDataHelper aDataHelper(
353                     TransferableDataHelper::CreateFromSystemClipboard( &rSh.GetView().GetEditWin()) );
354                 if( aDataHelper.GetXTransferable().is()
355                     && SwTransferable::IsPaste( rSh, aDataHelper ) )
356                 {
357                     // temp. Variablen, da die Shell nach dem Paste schon
358                     // zerstoert sein kann
359                     SwView* pView = &rView;
360                     rReq.Ignore();
361                     bIgnore = sal_True;
362                     int nRet = SwTransferable::PasteUnformatted( rSh, aDataHelper );
363                     if(nRet)// && rReq.IsRecording() )
364                     {
365                         SfxViewFrame* pViewFrame = pView->GetViewFrame();
366                         uno::Reference< frame::XDispatchRecorder > xRecorder =
367                             pViewFrame->GetBindings().GetRecorder();
368                         if(xRecorder.is()) {
369                             SfxRequest aReq( pViewFrame, SID_CLIPBOARD_FORMAT_ITEMS );
370                             aReq.AppendItem( SfxUInt32Item( SID_CLIPBOARD_FORMAT_ITEMS, SOT_FORMAT_STRING ) );
371                             aReq.Done();
372                         }
373                     }
374 
375                     if (rSh.IsFrmSelected() || rSh.IsObjSelected())
376                         rSh.EnterSelFrmMode();
377                     pView->AttrChangedNotify( &rSh );
378                 }
379                 else
380                     return;
381             }
382             break;
383 
384         case SID_PASTE_SPECIAL:
385             {
386                 TransferableDataHelper aDataHelper(
387                     TransferableDataHelper::CreateFromSystemClipboard( &rSh.GetView().GetEditWin()) );
388                 if( aDataHelper.GetXTransferable().is()
389                     && SwTransferable::IsPaste( rSh, aDataHelper )
390                     && !rSh.CrsrInsideInputFld() )
391                 {
392                     // temp. Variablen, da die Shell nach dem Paste schon
393                     // zerstoert sein kann
394                     SwView* pView = &rView;
395                     sal_uLong nFormatId = 0;
396                     rReq.Ignore();
397                     bIgnore = sal_True;
398                     int nRet = SwTransferable::PasteSpecial( rSh, aDataHelper, nFormatId );
399                     if(nRet)// && rReq.IsRecording() )
400                     {
401                         SfxViewFrame* pViewFrame = pView->GetViewFrame();
402                         uno::Reference< frame::XDispatchRecorder > xRecorder =
403                             pViewFrame->GetBindings().GetRecorder();
404                         if(xRecorder.is()) {
405                             SfxRequest aReq( pViewFrame, SID_CLIPBOARD_FORMAT_ITEMS );
406                             aReq.AppendItem( SfxUInt32Item( SID_CLIPBOARD_FORMAT_ITEMS, nFormatId ) );
407                             aReq.Done();
408                         }
409                     }
410 
411                     if (rSh.IsFrmSelected() || rSh.IsObjSelected())
412                         rSh.EnterSelFrmMode();
413                     pView->AttrChangedNotify( &rSh );
414                 }
415                 else
416                     return;
417             }
418             break;
419 
420         default:
421             DBG_ERROR("falscher Dispatcher");
422             return;
423     }
424     if(!bIgnore)
425         rReq.Done();
426 }
427 
428 /*--------------------------------------------------------------------
429 	Beschreibung:	ClipBoard-Status
430  --------------------------------------------------------------------*/
431 
432 void SwBaseShell::StateClpbrd(SfxItemSet &rSet)
433 {
434 	SwWrtShell &rSh = GetShell();
435 	SfxWhichIter aIter(rSet);
436 
437 	const sal_Bool bCopy = rSh.HasSelection();
438 
439 	sal_uInt16 nWhich = aIter.FirstWhich();
440 
441 	while(nWhich)
442 	{
443 		switch(nWhich)
444 		{
445 		case SID_CUT:
446 			if( 0 != rSh.IsSelObjProtected(FLYPROTECT_CONTENT|FLYPROTECT_PARENT ) )
447 			{
448 				rSet.DisableItem( nWhich );
449 				break;
450 			}
451 		case SID_COPY:
452 			if( !bCopy )
453 				rSet.DisableItem( nWhich );
454 			break;
455 
456         case SID_PASTE:
457             if( !GetView().IsPasteAllowed()
458                 || rSh.CrsrInsideInputFld() )
459             {
460                 rSet.DisableItem( nWhich );
461             }
462             break;
463 
464         case SID_PASTE_SPECIAL:
465             if( !GetView().IsPasteSpecialAllowed()
466                 || rSh.CrsrInsideInputFld() )
467             {
468                 rSet.DisableItem( nWhich );
469             }
470             break;
471 
472         case SID_PASTE_UNFORMATTED:
473             if( !GetView().IsPasteSpecialAllowed() )
474             {
475                 rSet.DisableItem( nWhich );
476             }
477             break;
478 
479 		case SID_CLIPBOARD_FORMAT_ITEMS:
480 			{
481 				TransferableDataHelper aDataHelper(
482 					TransferableDataHelper::CreateFromSystemClipboard(
483 											&rSh.GetView().GetEditWin()) );
484 
485 				SvxClipboardFmtItem aFmtItem( nWhich );
486 				SwTransferable::FillClipFmtItem( rSh, aDataHelper, aFmtItem );
487 				rSet.Put( aFmtItem );
488 			}
489 			break;
490 		}
491 		nWhich = aIter.NextWhich();
492 	}
493 }
494 
495 /*--------------------------------------------------------------------
496 	Beschreibung:	Undo ausfuehren
497  --------------------------------------------------------------------*/
498 
499 void SwBaseShell::ExecUndo(SfxRequest &rReq)
500 {
501 	SwWrtShell &rSh = GetShell();
502 
503 	sal_uInt16 nId = rReq.GetSlot(), nCnt = 1;
504 	const SfxItemSet* pArgs = rReq.GetArgs();
505 	const SfxPoolItem* pItem;
506 	if( pArgs && SFX_ITEM_SET == pArgs->GetItemState( nId, sal_False, &pItem ))
507 		nCnt = ((SfxUInt16Item*)pItem)->GetValue();
508 
509     // #i106349#: save pointer: undo/redo may delete the shell, i.e., this!
510     SfxViewFrame *const pViewFrame( GetView().GetViewFrame() );
511 
512 	switch( nId )
513 	{
514 		case SID_UNDO:
515             rSh.LockPaint();
516 			rSh.Do( SwWrtShell::UNDO, nCnt );
517             rSh.UnlockPaint();
518 			break;
519 
520 		case SID_REDO:
521             rSh.LockPaint();
522 			rSh.Do( SwWrtShell::REDO, nCnt );
523             rSh.UnlockPaint();
524 			break;
525 
526 		case SID_REPEAT:
527 			rSh.Do( SwWrtShell::REPEAT );
528 			break;
529 		default:
530 			DBG_ERROR("falscher Dispatcher");
531 	}
532 
533     if (pViewFrame) { pViewFrame->GetBindings().InvalidateAll(sal_False); }
534 }
535 
536 /*--------------------------------------------------------------------
537 	Beschreibung:	Zustand Undo
538  --------------------------------------------------------------------*/
539 
540 void SwBaseShell::StateUndo(SfxItemSet &rSet)
541 {
542 	SwWrtShell &rSh = GetShell();
543 	SfxWhichIter aIter(rSet);
544 	sal_uInt16 nWhich = aIter.FirstWhich();
545 	while(nWhich)
546 	{
547 		switch(nWhich)
548 		{
549 			case SID_UNDO:
550 			{
551                 if (rSh.GetLastUndoInfo(0, 0))
552                 {
553 					rSet.Put( SfxStringItem(nWhich,
554 						rSh.GetDoString(SwWrtShell::UNDO)));
555                 }
556 				else
557 					rSet.DisableItem(nWhich);
558 				break;
559 			}
560 			case SID_REDO:
561 			{
562                 if (rSh.GetFirstRedoInfo(0))
563                 {
564 					rSet.Put(SfxStringItem(nWhich,
565 						rSh.GetDoString(SwWrtShell::REDO)));
566                 }
567 				else
568 					rSet.DisableItem(nWhich);
569 				break;
570 			}
571 			case SID_REPEAT:
572 			{	// Repeat nur moeglich wenn kein REDO moeglich - UI-Restriktion
573                 if ((!rSh.GetFirstRedoInfo(0)) &&
574 					!rSh.IsSelFrmMode() &&
575                     (UNDO_EMPTY != rSh.GetRepeatInfo(0)))
576                 {
577 					rSet.Put(SfxStringItem(nWhich, rSh.GetRepeatString()));
578                 }
579 				else
580 					rSet.DisableItem(nWhich);
581 				break;
582 			}
583 
584 			case SID_GETUNDOSTRINGS:
585                 if (rSh.GetLastUndoInfo(0, 0))
586 				{
587 					SfxStringListItem aStrLst( nWhich );
588 					rSh.GetDoStrings( SwWrtShell::UNDO, aStrLst );
589 					rSet.Put( aStrLst );
590 				}
591 				else
592 					rSet.DisableItem( nWhich );
593 				break;
594 
595 			case SID_GETREDOSTRINGS:
596                 if (rSh.GetFirstRedoInfo(0))
597 				{
598 					SfxStringListItem aStrLst( nWhich );
599 					rSh.GetDoStrings( SwWrtShell::REDO, aStrLst );
600 					rSet.Put( aStrLst );
601 				}
602 				else
603 					rSet.DisableItem( nWhich );
604 				break;
605 		}
606 		nWhich = aIter.NextWhich();
607 	}
608 }
609 
610 /*--------------------------------------------------------------------
611 	Beschreibung:	Slot-Id auswerten bzw. Dispatchen
612  --------------------------------------------------------------------*/
613 
614 void SwBaseShell::Execute(SfxRequest &rReq)
615 {
616 	const SfxPoolItem *pItem;
617 	SwWrtShell &rSh = GetShell();
618 	const SfxItemSet* pArgs = rReq.GetArgs();
619 	sal_Bool bMore = sal_False;
620 
621 	sal_uInt16 nSlot = rReq.GetSlot();
622 	switch(nSlot)
623 	{
624 		case FN_REPAGINATE:
625 			{
626 				Reference < XModel > xModel = GetView().GetDocShell()->GetModel();
627 				Reference < XUnoTunnel > xDocTunnel ( xModel, UNO_QUERY );
628 				SwXTextDocument *pDoc = reinterpret_cast < SwXTextDocument * > ( xDocTunnel->getSomething ( SwXTextDocument::getUnoTunnelId() ) );
629 				pDoc->notifyRefreshListeners();
630 				rSh.CalcLayout();
631 			}
632 			break;
633 		case FN_UPDATE_FIELDS:
634 			{
635 				SwDocStat aDocStat;
636 				rSh.UpdateDocStat(aDocStat);
637 				rSh.EndAllTblBoxEdit();
638 				rSh.ViewShell::UpdateFlds(sal_True);
639 
640 				if( rSh.IsCrsrInTbl() )
641 				{
642 					if( !rSh.IsTblComplexForChart() )
643 						SwTableFUNC( &rSh, sal_False).UpdateChart();
644 					rSh.ClearTblBoxCntnt();
645 					rSh.SaveTblBoxCntnt();
646 				}
647 			}
648 			break;
649 		case FN_UPDATE_CHARTS:
650 			{
651 				SwWait aWait( *rView.GetDocShell(), true );
652 				rSh.UpdateAllCharts();
653 			}
654 			break;
655 
656 		case FN_UPDATE_ALL:
657 			{
658                 SwView&  rTempView = GetView();
659                 rSh.EnterStdMode();
660 				if( rSh.GetLinkManager().GetLinks().Count() )
661 				{
662 					rSh.StartAllAction();
663 					rSh.GetLinkManager().UpdateAllLinks( sal_False, sal_True, sal_True );
664 					rSh.EndAllAction();
665 				}
666                 SfxDispatcher &rDis = *rTempView.GetViewFrame()->GetDispatcher();
667 				rDis.Execute( FN_UPDATE_FIELDS );
668 				rDis.Execute( FN_UPDATE_TOX );
669 				rDis.Execute( FN_UPDATE_CHARTS );
670 				rSh.CalcLayout();
671 			}
672 			break;
673 
674         case FN_UPDATE_INPUTFIELDS:
675             rSh.UpdateInputFlds();
676             break;
677 
678 		case FN_PREV_BOOKMARK:
679 			rReq.SetReturnValue(SfxBoolItem( nSlot, rSh.GoPrevBookmark()));
680 			break;
681 		case FN_NEXT_BOOKMARK:
682 			rReq.SetReturnValue(SfxBoolItem( nSlot, rSh.GoNextBookmark()));
683 			break;
684 
685 		case FN_GOTO_NEXT_MARK:
686 		case FN_GOTO_PREV_MARK:
687 		{
688 			SwFldMgr aFldMgr;
689 			SwFieldType* pFldType = aFldMgr.GetFldType(RES_JUMPEDITFLD);
690 
691 			if (pFldType)
692 			{
693 				if (rSh.IsSelFrmMode())
694 				{
695 					rSh.UnSelectFrm();
696 					rSh.LeaveSelFrmMode();
697 				}
698 
699 				if (rSh.HasMark())
700 				{
701 					MV_KONTEXT(&rSh);
702 					if (rSh.IsCrsrPtAtEnd())
703 						rSh.SwapPam();
704 					rSh.ClearMark();
705 					rSh.EndSelect();
706 				}
707 				sal_Bool bRet = rSh.MoveFldType( pFldType, nSlot == FN_GOTO_NEXT_MARK );
708                 SwField* pCurField = bRet ? rSh.GetCurFld() : 0;
709                 if (pCurField)
710 					rSh.ClickToField(*pCurField);
711 				rReq.SetReturnValue(SfxBoolItem( nSlot, bRet));
712 			}
713 		}
714 		break;
715 
716 		case FN_START_DOC_DIRECT:
717 		case FN_END_DOC_DIRECT:
718 		{
719 			if (rSh.IsSelFrmMode())
720 			{
721 				rSh.UnSelectFrm();
722 				rSh.LeaveSelFrmMode();
723 			}
724 			rSh.EnterStdMode();
725 			nSlot == FN_START_DOC_DIRECT ?
726 				rSh.SttEndDoc(sal_True) :
727 					rSh.SttEndDoc(sal_False);
728 		}
729 		break;
730 		case FN_GOTO_PREV_OBJ:
731 		case FN_GOTO_NEXT_OBJ:
732 		{
733 				sal_Bool bSuccess = rSh.GotoObj(
734 							nSlot == FN_GOTO_NEXT_OBJ ? sal_True : sal_False);
735 				rReq.SetReturnValue(SfxBoolItem(nSlot, bSuccess));
736 				if (bSuccess && !rSh.IsSelFrmMode())
737 				{
738 					rSh.HideCrsr();
739 					rSh.EnterSelFrmMode();
740 					GetView().AttrChangedNotify( &rSh );
741 				}
742 		}
743 		break;
744 		case SID_GALLERY_FORMATS:
745 		{
746             SFX_ITEMSET_ARG( pArgs, pGalleryItem, SvxGalleryItem, SID_GALLERY_FORMATS, sal_False );
747             if ( !pGalleryItem )
748                 break;
749 
750             const int nSelType = rSh.GetSelectionType();
751             sal_Int8 nGalleryItemType( pGalleryItem->GetType() );
752 
753             if ( (!rSh.IsSelFrmMode() || nSelType & nsSelectionType::SEL_GRF) &&
754                 nGalleryItemType == com::sun::star::gallery::GalleryItemType::GRAPHIC )
755             {
756                 SwWait aWait( *rView.GetDocShell(), true );
757 
758                 String aGrfName, aFltName;
759                 const Graphic aGrf( pGalleryItem->GetGraphic() );
760 
761                 if( pGalleryItem->IsLink() )
762                 {
763                     // Verknuepft
764                     aGrfName = pGalleryItem->GetURL();
765                     aFltName = pGalleryItem->GetFilterName();
766                 }
767 
768                 if ( nSelType & nsSelectionType::SEL_GRF )
769                     rSh.ReRead( aGrfName, aFltName, &aGrf );
770                 else
771                     rSh.Insert( aGrfName, aFltName, aGrf );
772 
773                 GetView().GetEditWin().GrabFocus();
774             }
775             else if(!rSh.IsSelFrmMode() &&
776                 nGalleryItemType == com::sun::star::gallery::GalleryItemType::MEDIA  )
777             {
778                 const SfxStringItem aMediaURLItem( SID_INSERT_AVMEDIA, pGalleryItem->GetURL() );
779                 GetView().GetViewFrame()->GetDispatcher()->Execute( SID_INSERT_AVMEDIA, SFX_CALLMODE_SYNCHRON, &aMediaURLItem, 0L );
780 /*
781                 String sURL( pGalleryItem->GetURL().GetMainURL( INetURLObject::NO_DECODE ) );
782                 String sLabel( pGalleryItem->GetURL().getBase() );
783                 String sTarget; // empty string!
784 
785                 bool bIsHTMLMode =
786                     0 == ( HTMLMODE_ON &
787                             ::GetHtmlMode( GetView().GetDocShell() ) );
788 
789                 // in Writer, we insert a button which plays the
790                 // sound. In Writer/Web, we just insert a (text) link.
791                 if( bIsHTMLMode )
792                     InsertURLButton( sURL, sTarget, sLabel );
793                 else
794                     rSh.InsertURL( SwFmtINetFmt( sURL, sTarget ), sLabel );
795 */
796             }
797 		}
798 		break;
799 		case FN_PAGE_STYLE_SET_COLS:
800 		{
801 			if (pArgs)
802 			{
803 				// aktuellen PageDescriptor ermitteln und damit den Set fuellen
804 				const sal_uInt16 nCurIdx = rSh.GetCurPageDesc();
805 				SwPageDesc aPageDesc(rSh.GetPageDesc(nCurIdx));
806 
807 				SwFrmFmt &rFmt = aPageDesc.GetMaster();
808 
809 				SwFmtCol aFmtCol = rFmt.GetCol();
810 
811 				sal_uInt16 nCount;
812 				if(SFX_ITEM_SET == pArgs->GetItemState(nSlot))
813 					nCount = ((SfxUInt16Item &)pArgs->Get(nSlot)).GetValue();
814 				else
815 					nCount = ((SfxUInt16Item &)pArgs->Get(SID_ATTR_COLUMNS)).GetValue();
816 				sal_uInt16 nGutterWidth = DEF_GUTTER_WIDTH;
817 
818 				aFmtCol.Init(nCount ? nCount : 1, nGutterWidth, USHRT_MAX);
819 				aFmtCol.SetWishWidth(USHRT_MAX);
820 				aFmtCol.SetGutterWidth(nGutterWidth, USHRT_MAX);
821 
822                 rFmt.SetFmtAttr(aFmtCol);
823 
824 				rSh.ChgPageDesc(nCurIdx, aPageDesc);
825 			}
826 			else
827 				GetView().GetViewFrame()->GetDispatcher()->Execute(FN_FORMAT_PAGE_COLUMN_DLG, sal_False);
828 		}
829 		break;
830         case FN_CONVERT_TABLE_TO_TEXT:
831         case FN_CONVERT_TEXT_TO_TABLE:
832         case FN_CONVERT_TEXT_TABLE:
833 		{
834             sal_Unicode cDelim = 0;
835             bool bToTable = false;
836             if( nSlot == FN_CONVERT_TEXT_TO_TABLE ||
837                 ( nSlot == FN_CONVERT_TEXT_TABLE && 0 == rSh.GetTableFmt() ))
838                 bToTable = true;
839             SwInsertTableOptions aInsTblOpts( tabopts::ALL_TBL_INS_ATTR, 1 );
840             SwTableAutoFmt* pTAFmt = 0;
841             SwTableAutoFmtTbl* pAutoFmtTbl = 0;
842             bool bDeleteFormat = true;
843             if(pArgs && SFX_ITEM_SET == pArgs->GetItemState( FN_PARAM_1, sal_True, &pItem))
844             {
845                 aInsTblOpts.mnInsMode = 0;
846                 //Delimiter
847                 String sDelim = static_cast< const SfxStringItem* >(pItem)->GetValue();
848                 if(sDelim.Len())
849                     cDelim = sDelim.GetChar(0);
850                 //AutoFormat
851                 if(SFX_ITEM_SET == pArgs->GetItemState( FN_PARAM_2, sal_True, &pItem))
852                 {
853                     String sAutoFmt = static_cast< const SfxStringItem* >(pItem)->GetValue();
854 
855                     pAutoFmtTbl = new SwTableAutoFmtTbl;
856                     pAutoFmtTbl->Load();
857 
858                     for( sal_uInt16 i = 0, nCount = pAutoFmtTbl->Count(); i < nCount; i++ )
859                     {
860                         SwTableAutoFmt* pFmt = (*pAutoFmtTbl)[ i ];
861                         if( pFmt->GetName() == sAutoFmt )
862                         {
863                             pTAFmt = pFmt;
864                             bDeleteFormat = false;
865                             break;
866                         }
867                     }
868                 }
869                 //WithHeader
870                 if(SFX_ITEM_SET == pArgs->GetItemState( FN_PARAM_3, sal_True, &pItem) &&
871                             static_cast< const SfxBoolItem* >(pItem)->GetValue())
872                     aInsTblOpts.mnInsMode |= tabopts::HEADLINE;
873                 // RepeatHeaderLines
874                 if(SFX_ITEM_SET == pArgs->GetItemState( FN_PARAM_4, sal_True, &pItem))
875                    aInsTblOpts.mnRowsToRepeat =
876                             (sal_uInt16)static_cast< const SfxInt16Item* >(pItem)->GetValue();
877                 //WithBorder
878                 if(SFX_ITEM_SET == pArgs->GetItemState( FN_PARAM_5, sal_True, &pItem) &&
879                     static_cast< const SfxBoolItem* >(pItem)->GetValue())
880                     aInsTblOpts.mnInsMode |= tabopts::DEFAULT_BORDER;
881                 //DontSplitTable
882                 if(SFX_ITEM_SET == pArgs->GetItemState( FN_PARAM_6, sal_True, &pItem) &&
883                     !static_cast< const SfxBoolItem* >(pItem)->GetValue() )
884                     aInsTblOpts.mnInsMode |= tabopts::SPLIT_LAYOUT;
885             }
886             else
887             {
888                 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
889                 DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
890 
891                 AbstractSwConvertTableDlg* pDlg = pFact->CreateSwConvertTableDlg(
892                             GetView(),DLG_CONV_TEXT_TABLE , bToTable);
893                 DBG_ASSERT(pDlg, "Dialogdiet fail!");
894                 if( RET_OK == pDlg->Execute() )
895                 {
896                     pDlg->GetValues( cDelim, aInsTblOpts, pTAFmt );
897 
898                 }
899                 delete pDlg;
900             }
901 
902 			if( cDelim )
903 			{
904 				//Shellwechsel!
905 				SwView& rSaveView = rView;
906 				sal_Bool bInserted = sal_False;
907                 //recording:
908 
909                 SfxViewFrame* pViewFrame = GetView().GetViewFrame();
910                 if( SfxRequest::HasMacroRecorder(pViewFrame) )
911                 {
912                     SfxRequest aReq( pViewFrame, nSlot);
913                     aReq.AppendItem( SfxStringItem( FN_PARAM_1, String(cDelim) ));
914                     if(bToTable)
915                     {
916                         if(pTAFmt)
917                             aReq.AppendItem( SfxStringItem( FN_PARAM_2, pTAFmt->GetName()));
918                         aReq.AppendItem( SfxBoolItem ( FN_PARAM_3, 0 != (aInsTblOpts.mnInsMode & tabopts::HEADLINE)));
919                         aReq.AppendItem( SfxInt16Item( FN_PARAM_4, (short)aInsTblOpts.mnRowsToRepeat ));
920                         aReq.AppendItem( SfxBoolItem ( FN_PARAM_5, 0 != (aInsTblOpts.mnInsMode & tabopts::DEFAULT_BORDER) ));
921                         aReq.AppendItem( SfxBoolItem ( FN_PARAM_6, !(aInsTblOpts.mnInsMode & tabopts::SPLIT_LAYOUT)));
922                     }
923                     aReq.Done();
924                 }
925 
926                 if( !bToTable )
927 					rSh.TableToText( cDelim );
928 				else
929                 {
930                     bInserted = rSh.TextToTable( aInsTblOpts, cDelim, text::HoriOrientation::FULL, pTAFmt );
931                 }
932                 rSh.EnterStdMode();
933 
934 				if( bInserted )
935 					rSaveView.AutoCaption( TABLE_CAP );
936 			}
937             if(bDeleteFormat)
938                 delete pTAFmt;
939             delete pAutoFmtTbl;
940 		}
941 		break;
942 		case SID_STYLE_WATERCAN:
943 		case SID_STYLE_UPDATE_BY_EXAMPLE:
944 		case SID_STYLE_NEW_BY_EXAMPLE:
945 		case SID_STYLE_APPLY:
946 		{
947 			ShellModes eMode = GetView().GetShellMode();
948 			if ( SHELL_MODE_DRAW != eMode &&
949 				 SHELL_MODE_DRAW_CTRL != eMode &&
950 				 SHELL_MODE_DRAW_FORM != eMode &&
951 				 SHELL_MODE_DRAWTEXT != eMode &&
952 				 SHELL_MODE_BEZIER != eMode )
953 			{
954 				// oj #107754#
955 				if ( SID_STYLE_WATERCAN == nSlot )
956 				{
957 					const sal_Bool bLockedView = rSh.IsViewLocked();
958 					rSh.LockView( sal_True );    //lock visible section
959 
960 					GetView().GetDocShell()->ExecStyleSheet(rReq);
961 
962 					rSh.LockView( bLockedView );
963 				}
964 				else
965 				// wird von der DocShell aufgezeichnet
966 					GetView().GetDocShell()->ExecStyleSheet(rReq);
967 			}
968 		}
969 		break;
970 		case FN_ESCAPE:
971 			GetView().ExecuteSlot(rReq);
972 		break;
973 		case SID_IMAP:
974 		{
975 			sal_uInt16		nId = SvxIMapDlgChildWindow::GetChildWindowId();
976 
977 			SfxViewFrame* pVFrame = GetView().GetViewFrame();
978 			pVFrame->ToggleChildWindow( nId );
979 			pVFrame->GetBindings().Invalidate( SID_IMAP );
980 
981 			if ( pVFrame->HasChildWindow( nId ) && rSh.IsFrmSelected() )
982 				lcl_UpdateIMapDlg( rSh );
983 		}
984 		break;
985 		case SID_IMAP_EXEC:
986 		{
987 			SvxIMapDlg*	pDlg = SWIMAPDLG(GetView());
988 
989 			// Kontrolle, ob Zuweisung ueberhaupt sinnvoll/erlaubt
990 			if ( rSh.IsFrmSelected() &&
991 				 pDlg->GetEditingObject() == rSh.GetIMapInventor() )
992 			{
993 					SfxItemSet aSet( rSh.GetAttrPool(), RES_URL, RES_URL );
994 					rSh.GetFlyFrmAttr( aSet );
995 					SwFmtURL aURL( (SwFmtURL&)aSet.Get( RES_URL ) );
996 					aURL.SetMap( &pDlg->GetImageMap() );
997 					aSet.Put( aURL );
998 					rSh.SetFlyFrmAttr( aSet );
999 			}
1000 		}
1001 		break;
1002 		case SID_CONTOUR_DLG:
1003 		{
1004 			sal_uInt16 nId = SvxContourDlgChildWindow::GetChildWindowId();
1005 
1006 			SfxViewFrame* pVFrame = GetView().GetViewFrame();
1007 			pVFrame->ToggleChildWindow( nId );
1008 			pVFrame->GetBindings().Invalidate( SID_CONTOUR_DLG );
1009 
1010 			int nSel = rSh.GetSelectionType();
1011 			if ( pVFrame->HasChildWindow( nId ) &&
1012 				 (nSel & (nsSelectionType::SEL_GRF|nsSelectionType::SEL_OLE)) )
1013 			{
1014 				lcl_UpdateContourDlg( rSh, nSel );
1015 			}
1016 		}
1017 		break;
1018 		case SID_CONTOUR_EXEC:
1019 		{
1020 			SvxContourDlg *pDlg = SWCONTOURDLG(GetView());
1021 
1022 			// Kontrolle, ob Zuweisung ueberhaupt sinnvoll/erlaubt
1023 			int nSel = rSh.GetSelectionType();
1024 			if ( nSel & (nsSelectionType::SEL_GRF|nsSelectionType::SEL_OLE) )
1025 			{
1026 				if ( pDlg->GetEditingObject() == rSh.GetIMapInventor() )
1027 				{
1028 					rSh.StartAction();
1029 					SfxItemSet aSet( rSh.GetAttrPool(), RES_SURROUND, RES_SURROUND);
1030 					rSh.GetFlyFrmAttr( aSet );
1031 					SwFmtSurround aSur( (SwFmtSurround&)aSet.Get( RES_SURROUND ) );
1032 					if ( !aSur.IsContour() )
1033 					{
1034 						aSur.SetContour( sal_True );
1035 						if ( aSur.GetSurround() == SURROUND_NONE )
1036 							aSur.SetSurround( SURROUND_PARALLEL );
1037 						aSet.Put( aSur );
1038 						rSh.SetFlyFrmAttr( aSet );
1039 					}
1040 					const PolyPolygon aPoly( pDlg->GetPolyPolygon() );
1041 					rSh.SetGraphicPolygon( &aPoly );
1042 					if ( pDlg->IsGraphicChanged() )
1043 						rSh.ReRead( aEmptyStr, aEmptyStr, &pDlg->GetGraphic());
1044 					rSh.EndAction();
1045 				}
1046 			}
1047 		}
1048 		break;
1049 		case FN_FRAME_TO_ANCHOR:
1050 		{
1051 			rSh.GotoFlyAnchor();
1052 			rSh.EnterStdMode();
1053 			rSh.CallChgLnk();
1054 		}
1055 		break;
1056 		case FN_TOOL_ANKER:
1057 			break;
1058 		case FN_TOOL_ANKER_PAGE:
1059 		case FN_TOOL_ANKER_PARAGRAPH:
1060 		case FN_TOOL_ANKER_CHAR:
1061 		case FN_TOOL_ANKER_AT_CHAR:
1062 		case FN_TOOL_ANKER_FRAME:
1063 		{
1064 			RndStdIds eSet = nSlot == FN_TOOL_ANKER_PAGE
1065                                 ? FLY_AT_PAGE
1066 								: nSlot == FN_TOOL_ANKER_PARAGRAPH
1067                                     ? FLY_AT_PARA
1068 									: nSlot == FN_TOOL_ANKER_FRAME
1069 										? FLY_AT_FLY
1070 										: nSlot == FN_TOOL_ANKER_CHAR
1071                                             ? FLY_AS_CHAR
1072                                             : FLY_AT_CHAR;
1073 			rSh.StartUndo();
1074 			if( rSh.IsObjSelected() )
1075 				rSh.ChgAnchor( eSet );
1076 			else if( rSh.IsFrmSelected() )
1077 			{
1078 				// Der Set beinhaltet auch VERT/HORI_ORIENT, da in FEShell::
1079 				// SetFlyFrmAttr/SetFlyFrmAnchor ggf. als Folge des Umankerns
1080 				// die Ausrichtungen veraendert werden sollen.
1081 				SfxItemSet aSet( GetPool(), RES_VERT_ORIENT, RES_ANCHOR );
1082 				SwFmtAnchor aAnc( eSet, rSh.GetPhyPageNum() );
1083 				aSet.Put( aAnc );
1084 				rSh.SetFlyFrmAttr(aSet);
1085 			}
1086 
1087             // if new anchor is 'as char' and it is a Math object and the usual
1088             // pre-conditions are met then align the formula to the baseline of the text
1089             const uno::Reference < embed::XEmbeddedObject > xObj( rSh.GetOleRef() );
1090             const bool bDoMathBaselineAlignment = xObj.is() && SotExchange::IsMath( xObj->getClassID() )
1091                     && FLY_AS_CHAR == eSet && rSh.GetDoc()->get( IDocumentSettingAccess::MATH_BASELINE_ALIGNMENT );
1092             if (bDoMathBaselineAlignment)
1093                 rSh.AlignFormulaToBaseline( xObj );
1094 
1095 			sal_uInt16 nHtmlMode = ::GetHtmlMode(GetView().GetDocShell());
1096 			if( nHtmlMode )
1097 			{
1098 				SfxItemSet aSet(GetPool(), RES_SURROUND, RES_HORI_ORIENT);
1099 				rSh.GetFlyFrmAttr(aSet);
1100 
1101 				const SwFmtSurround& rSurround = (const SwFmtSurround&)aSet.Get(RES_SURROUND);
1102 				const SwFmtVertOrient& rVert = (const SwFmtVertOrient&)aSet.Get(RES_VERT_ORIENT);
1103 				const SwFmtHoriOrient& rHori = (const SwFmtHoriOrient&)aSet.Get(RES_HORI_ORIENT);
1104                 sal_Int16 eVOrient = rVert.GetVertOrient();
1105                 sal_Int16 eHOrient = rHori.GetHoriOrient();
1106 				SwSurround eSurround = rSurround.GetSurround();
1107 
1108 				switch( eSet )
1109 				{
1110 				case FLY_AT_FLY:
1111                 case FLY_AT_PAGE:
1112 
1113 					//Durchlauf, links oder von links, oben, von oben
1114 					if(eSurround != SURROUND_THROUGHT)
1115 						aSet.Put(SwFmtSurround(SURROUND_THROUGHT));
1116 
1117                     if( eVOrient != text::VertOrientation::TOP && eVOrient != text::VertOrientation::NONE)
1118                         aSet.Put(SwFmtVertOrient(0, text::VertOrientation::TOP));
1119 
1120                     if(eHOrient != text::HoriOrientation::NONE || eHOrient != text::HoriOrientation::LEFT)
1121                         aSet.Put(SwFmtHoriOrient(0, text::HoriOrientation::LEFT));
1122 					break;
1123 
1124                 case FLY_AT_PARA:
1125 					//links, von links, rechts, oben, kein Uml, li+re Umlauf,
1126 					if(eSurround != SURROUND_LEFT || eSurround != SURROUND_RIGHT)
1127 						aSet.Put(SwFmtSurround(SURROUND_LEFT));
1128 
1129                     if( eVOrient != text::VertOrientation::TOP)
1130                         aSet.Put(SwFmtVertOrient(0, text::VertOrientation::TOP));
1131 
1132                     if(eHOrient != text::HoriOrientation::NONE || eHOrient != text::HoriOrientation::LEFT || eHOrient != text::HoriOrientation::RIGHT)
1133                         aSet.Put(SwFmtHoriOrient(0, text::HoriOrientation::LEFT));
1134 					break;
1135 
1136                 case FLY_AT_CHAR:
1137 					//links, von links, rechts, oben,  Durchlauf
1138 					if(eSurround != SURROUND_THROUGHT)
1139 						aSet.Put(SwFmtSurround(SURROUND_THROUGHT));
1140 
1141                     if( eVOrient != text::VertOrientation::TOP)
1142                         aSet.Put(SwFmtVertOrient(0, text::VertOrientation::TOP));
1143 
1144                     if(eHOrient != text::HoriOrientation::NONE || eHOrient != text::HoriOrientation::LEFT || eHOrient != text::HoriOrientation::RIGHT)
1145                         aSet.Put(SwFmtHoriOrient(0, text::HoriOrientation::LEFT));
1146 					break;
1147 
1148 				default:
1149 					;
1150 				}
1151 
1152 				if( aSet.Count() )
1153 					rSh.SetFlyFrmAttr( aSet );
1154 			}
1155 			rSh.EndUndo();
1156 
1157 			GetView().GetViewFrame()->GetBindings().Invalidate( FN_TOOL_ANKER );
1158 		}
1159 		break;
1160 
1161 		case FN_FRAME_NOWRAP:
1162 		case FN_FRAME_WRAP:
1163 		case FN_FRAME_WRAP_IDEAL:
1164 		case FN_FRAME_WRAPTHRU:
1165 		case FN_FRAME_WRAPTHRU_TRANSP:
1166 		case FN_FRAME_WRAP_CONTOUR:
1167 		case FN_WRAP_ANCHOR_ONLY:
1168 		case FN_FRAME_WRAP_LEFT:
1169 		case FN_FRAME_WRAP_RIGHT:
1170 			SetWrapMode( nSlot );
1171 			break;
1172 
1173 		case FN_UPDATE_ALL_LINKS:
1174 			{
1175 				if( rSh.GetLinkManager().GetLinks().Count() )
1176 				{
1177 					sal_Bool bUpdateGrf = sal_False, bCallErrHdl = sal_False;
1178 					rSh.EnterStdMode();
1179 					rSh.StartAllAction();
1180 					rSh.GetLinkManager().UpdateAllLinks( sal_False, bCallErrHdl, bUpdateGrf );
1181 					rSh.EndAllAction();
1182 				}
1183 			}
1184 			break;
1185 
1186         case FN_XFORMS_DESIGN_MODE:
1187             if( pArgs != NULL
1188                 && pArgs->GetItemState( nSlot, sal_True, &pItem ) == SFX_ITEM_SET
1189                 && pItem != NULL
1190                 && pItem->ISA( SfxBoolItem ) )
1191             {
1192                 sal_Bool bDesignMode =
1193                     static_cast<const SfxBoolItem*>( pItem )->GetValue();
1194 
1195                 // set form design mode
1196                 DBG_ASSERT( GetView().GetFormShell() != NULL, "form shell?" );
1197                 SfxRequest aReq( GetView().GetViewFrame(), SID_FM_DESIGN_MODE );
1198                 aReq.AppendItem( SfxBoolItem( SID_FM_DESIGN_MODE, bDesignMode ) );
1199                 GetView().GetFormShell()->Execute( aReq );
1200                 aReq.Done();
1201 
1202                 // also set suitable view options
1203                 SwViewOption aViewOption = *rSh.GetViewOptions();
1204                 aViewOption.SetFormView( ! bDesignMode );
1205                 rSh.ApplyViewOptions( aViewOption );
1206             }
1207             break;
1208 
1209 		default:
1210 			bMore = sal_True;
1211 	}
1212 	if(bMore && pArgs)
1213 	{
1214 		pItem = 0;
1215 		pArgs->GetItemState(GetPool().GetWhich(nSlot), sal_False, &pItem);
1216 		if(pItem)
1217 		switch(nSlot)
1218 		{
1219         case SID_ATTR_BRUSH:
1220 		case SID_ATTR_BORDER_SHADOW:
1221 		case RES_SHADOW:
1222 		{
1223 			rSh.StartAllAction();
1224 			SfxItemSet	 aSet( rSh.GetAttrPool(),
1225                                 RES_SHADOW, RES_SHADOW,
1226                                 RES_BACKGROUND, RES_BACKGROUND, 0 );
1227 
1228 			aSet.Put(*pItem);
1229 			// Tabellenzelle(n) selektiert?
1230 			if ( rSh.IsTableMode() )
1231 			{
1232 				SwFrmFmt *pFmt = rSh.GetTableFmt();
1233                 pFmt->SetFmtAttr( *pItem );
1234 			}
1235 			else if ( rSh.IsFrmSelected() )
1236 			{
1237 				// Umrandungsattribute ueber Frame-Manager setzen
1238 				SwFlyFrmAttrMgr aMgr( sal_False, &rSh, FRMMGR_TYPE_NONE );
1239 				aMgr.SetAttrSet( *pArgs );
1240 				aMgr.UpdateFlyFrm();
1241 			}
1242 			else
1243 			{
1244 				rSh.SetAttrSet( *pArgs );
1245 			}
1246 			rSh.EndAllAction();
1247 		}
1248 		break;
1249 		case FN_PAGE_STYLE_SET_LR_MARGIN:
1250 		case FN_PAGE_STYLE_SET_UL_MARGIN:
1251 		case FN_PAGE_STYLE_SET_NUMBER_FORMAT:
1252 		case FN_PAGE_STYLE_SET_PAPER_SIZE:
1253 		case FN_PAGE_STYLE_SET_PAPER_BIN:
1254 		{
1255 			DBG_ERROR("not implemented");
1256 		}
1257 		break;
1258 
1259 		case SID_ATTR_BORDER_OUTER:
1260 		{
1261 			// Tabellenzelle(n) selektiert?
1262 			if ( rSh.IsTableMode() )
1263 			{
1264 				// Umrandungattribute Get/SetTabBorders() setzen
1265 				rSh.SetTabBorders(*pArgs);
1266 			}
1267 			else if ( rSh.IsFrmSelected() )
1268 			{
1269 				// Umrandungsattribute ueber Frame-Manager setzen
1270 				SwFlyFrmAttrMgr aMgr( sal_False, &rSh, FRMMGR_TYPE_NONE );
1271 				aMgr.SetAttrSet(*pArgs);
1272 				aMgr.UpdateFlyFrm();
1273 			}
1274 			else
1275 			{
1276 				// Umrandungsattribute ganz normal ueber Shell setzen
1277 				rSh.SetAttrItem( *pItem );
1278 			}
1279 		}
1280 		break;
1281 		default:
1282 				DBG_ERROR("falscher Dispatcher");
1283 		}
1284 
1285 	}
1286 }
1287 
1288 /* -----------------14.04.99 15:10-------------------
1289  * Hier wird der State fuer SID_IMAP / SID_CONTOUR behandelt,
1290  * wenn die Grafik ausgeswappt ist
1291  * --------------------------------------------------*/
1292 IMPL_LINK(SwBaseShell, GraphicArrivedHdl, SwCrsrShell* , EMPTYARG )
1293 {
1294 	sal_uInt16 nGrfType;
1295 	SwWrtShell &rSh = GetShell();
1296 	if( CNT_GRF == rSh.SwEditShell::GetCntType() &&
1297 		GRAPHIC_NONE != ( nGrfType = rSh.GetGraphicType() ) &&
1298 		aGrfUpdateSlots.Count() )
1299 	{
1300 		sal_Bool bProtect = 0 != rSh.IsSelObjProtected(FLYPROTECT_CONTENT|FLYPROTECT_PARENT);
1301 		SfxViewFrame* pVFrame = GetView().GetViewFrame();
1302 		sal_uInt16 nSlot;
1303 		for( sal_uInt16 n = 0; n < aGrfUpdateSlots.Count(); ++n )
1304 		{
1305 			sal_Bool bSetState = sal_False;
1306 			sal_Bool bState = sal_False;
1307 			switch( nSlot = aGrfUpdateSlots[ n ] )
1308 			{
1309 			case SID_IMAP:
1310 			case SID_IMAP_EXEC:
1311 				{
1312 					sal_uInt16 nId = SvxIMapDlgChildWindow::GetChildWindowId();
1313 					SvxIMapDlg *pDlg = pVFrame->HasChildWindow( nId ) ?
1314 						(SvxIMapDlg*) ( pVFrame->GetChildWindow( nId )
1315 											->GetWindow()) : 0;
1316 
1317 					if( pDlg && ( SID_IMAP_EXEC == nSlot ||
1318 								( SID_IMAP == nSlot && !bProtect)) &&
1319 						pDlg->GetEditingObject() != rSh.GetIMapInventor())
1320 							lcl_UpdateIMapDlg( rSh );
1321 
1322 					if( !bProtect && SID_IMAP == nSlot )
1323 						bSetState = sal_True, bState = 0 != pDlg;
1324 				}
1325 				break;
1326 
1327 			case SID_CONTOUR_DLG:
1328 				if( !bProtect )
1329 				{
1330 					sal_uInt16 nId = SvxContourDlgChildWindow::GetChildWindowId();
1331 					SvxIMapDlg *pDlg = pVFrame->HasChildWindow( nId ) ?
1332 						(SvxIMapDlg*) ( pVFrame->GetChildWindow( nId )
1333 											->GetWindow()) : 0;
1334 					if( pDlg && pDlg->GetEditingObject() !=
1335 								rSh.GetIMapInventor() )
1336 						lcl_UpdateContourDlg( rSh, nsSelectionType::SEL_GRF );
1337 
1338 					bSetState = sal_True;
1339 					bState = 0 != pDlg;
1340 				}
1341 				break;
1342 
1343 			case FN_FRAME_WRAP_CONTOUR:
1344 				if( !bProtect )
1345 				{
1346 					SfxItemSet aSet(GetPool(), RES_SURROUND, RES_SURROUND);
1347 					rSh.GetFlyFrmAttr(aSet);
1348 					const SwFmtSurround& rWrap = (const SwFmtSurround&)aSet.Get(RES_SURROUND);
1349 					bSetState = sal_True;
1350 					bState = rWrap.IsContour();
1351 				}
1352 				break;
1353 
1354 			case SID_GRFFILTER:
1355 			case SID_GRFFILTER_INVERT:
1356 			case SID_GRFFILTER_SMOOTH:
1357 			case SID_GRFFILTER_SHARPEN:
1358 			case SID_GRFFILTER_REMOVENOISE:
1359 			case SID_GRFFILTER_SOBEL:
1360 			case SID_GRFFILTER_MOSAIC:
1361 			case SID_GRFFILTER_EMBOSS:
1362 			case SID_GRFFILTER_POSTER:
1363 			case SID_GRFFILTER_POPART:
1364 			case SID_GRFFILTER_SEPIA:
1365 			case SID_GRFFILTER_SOLARIZE:
1366 				bSetState = bState = GRAPHIC_BITMAP == nGrfType;
1367 				break;
1368 			}
1369 
1370 			if( bSetState )
1371 			{
1372 				SfxBoolItem aBool( nSlot, bState );
1373 				if( pGetStateSet )
1374 					pGetStateSet->Put( aBool );
1375 				else
1376 					pVFrame->GetBindings().SetState( aBool );
1377 			}
1378 		}
1379 		aGrfUpdateSlots.RemoveAt( 0, aGrfUpdateSlots.Count() );
1380 	}
1381 	return 0;
1382 }
1383 
1384 void SwBaseShell::GetState( SfxItemSet &rSet )
1385 {
1386 	SwWrtShell &rSh = GetShell();
1387 	SfxViewFrame* pVFrame = GetView().GetViewFrame();
1388 	SfxWhichIter aIter( rSet );
1389 	sal_uInt16 nWhich = aIter.FirstWhich();
1390 	pGetStateSet = &rSet;
1391 	while ( nWhich )
1392 	{
1393 		switch ( nWhich )
1394 		{
1395 			case SID_GALLERY_FORMATS:
1396 				if ( rSh.IsObjSelected() ||
1397 					 (rSh.IsSelFrmMode() &&
1398 					  !(rSh.GetSelectionType() & nsSelectionType::SEL_GRF)) )
1399 					rSet.DisableItem( nWhich );
1400 				break;
1401 			case SID_GALLERY_ENABLE_ADDCOPY:
1402                 // #108230# allow copy from gallery in Writer AND Writer/Web!
1403                 rSet.Put( SfxBoolItem( SID_GALLERY_ENABLE_ADDCOPY, sal_True ) );
1404 				break;
1405 			case FN_EDIT_REGION:
1406 				if( !rSh.IsAnySectionInDoc() )
1407 					rSet.DisableItem(nWhich);
1408 				break;
1409 
1410             case FN_INSERT_REGION:
1411                 if( rSh.CrsrInsideInputFld()
1412                     || rSh.IsSelFrmMode()
1413                     || !rSh.IsInsRegionAvailable() )
1414                 {
1415                     rSet.DisableItem( nWhich );
1416                 }
1417                 break;
1418 
1419             case FN_CONVERT_TABLE_TO_TEXT:
1420             {
1421                 sal_uInt16 eFrmType = rSh.GetFrmType(0,sal_True);
1422                 if( (eFrmType & FRMTYPE_FOOTNOTE) ||
1423                     !rSh.GetTableFmt() )
1424                     rSet.DisableItem( nWhich );
1425             }
1426             break;
1427             case FN_CONVERT_TEXT_TO_TABLE:
1428             {
1429                 sal_uInt16 eFrmType = rSh.GetFrmType(0,sal_True);
1430                 if( (eFrmType & FRMTYPE_FOOTNOTE) ||
1431                     !rSh.IsTextToTableAvailable()  )
1432                     rSet.DisableItem( nWhich );
1433             }
1434             break;
1435             case FN_CONVERT_TEXT_TABLE:
1436 			{
1437 				sal_uInt16 eFrmType = rSh.GetFrmType(0,sal_True);
1438 				if( (eFrmType & FRMTYPE_FOOTNOTE) ||
1439 					(!rSh.GetTableFmt() && !rSh.IsTextToTableAvailable() ) )
1440 					rSet.DisableItem( nWhich );
1441 			}
1442 			break;
1443 			case RES_SHADOW:
1444 			{
1445 				SfxItemSet	 aSet( rSh.GetAttrPool(),
1446 									RES_SHADOW, RES_SHADOW );
1447 
1448 				// Tabellenzelle(n) selektiert?
1449 				if ( rSh.IsTableMode() )
1450 				{
1451 					SwFrmFmt *pFmt = rSh.GetTableFmt();
1452                     aSet.Put(pFmt->GetFmtAttr( nWhich, sal_True ));
1453 				}
1454 				else if( rSh.IsFrmSelected() )
1455 				{
1456 					SwFlyFrmAttrMgr aMgr( sal_False, &rSh, FRMMGR_TYPE_NONE );
1457 					aSet.Put( aMgr.GetAttrSet() );
1458 				}
1459 				else
1460                     rSh.GetCurAttr( aSet );
1461 #if OSL_DEBUG_LEVEL > 1
1462 
1463 				const SvxShadowItem& rShItem = (const SvxShadowItem&)aSet.Get(nWhich);
1464 				rSet.Put(rShItem);
1465 #else
1466 				rSet.Put((const SvxShadowItem&)aSet.Get(nWhich));
1467 #endif
1468 			}
1469 			break;
1470 			case SID_IMAP:
1471 			{
1472                 // --> OD 2006-11-08 #i59688#
1473                 // improve efficiency:
1474                 // If selected object is protected, item has to disabled.
1475                 const sal_Bool bProtect = 0 != rSh.IsSelObjProtected(FLYPROTECT_CONTENT|FLYPROTECT_PARENT);
1476                 if ( bProtect )
1477                 {
1478                     rSet.DisableItem( nWhich );
1479                 }
1480                 else
1481                 {
1482                     const sal_uInt16 nId = SvxIMapDlgChildWindow::GetChildWindowId();
1483                     const sal_Bool bHas = pVFrame->HasChildWindow( nId );
1484                     const sal_Bool bFrmSel = rSh.IsFrmSelected();
1485                     const sal_Bool bIsGraphicSelection =
1486                                 rSh.GetSelectionType() == nsSelectionType::SEL_GRF;
1487 
1488                     // --> OD 2006-11-08 #i59688#
1489                     // avoid unnecessary loading of selected graphic.
1490                     // The graphic is only needed, if the dialog is open.
1491                     //wenn die Grafik ausgeswappt ist, dann muss der
1492                     //Status asynchron ermittelt werden
1493                     //bis dahin wird der Slot disabled
1494                     if ( bHas && bIsGraphicSelection && rSh.IsGrfSwapOut( sal_True ) )
1495                     {
1496                         if( AddGrfUpdateSlot( nWhich ))
1497                             rSh.GetGraphic(sal_False);  // start the loading
1498                     }
1499                     else
1500                     {
1501                         if ( !bHas &&
1502                              ( !bFrmSel ||
1503                                ( bIsGraphicSelection &&
1504                                  rSh.GetGraphicType() == GRAPHIC_NONE ) ) )
1505                         {
1506                             rSet.DisableItem( nWhich );
1507                         }
1508                         else
1509                         {
1510                             SfxBoolItem aBool(nWhich, bHas);
1511                             if ( bHas && bFrmSel )
1512                                 lcl_UpdateIMapDlg( rSh );
1513                             rSet.Put(aBool);
1514                         }
1515                     }
1516                     // <--
1517                 }
1518                 // <--
1519 			}
1520 			break;
1521 			case SID_IMAP_EXEC:
1522 			{
1523 				sal_Bool bDisable = sal_False;
1524 				if( !rSh.IsFrmSelected())
1525 					bDisable = sal_True;
1526 				sal_uInt16 nId = SvxIMapDlgChildWindow::GetChildWindowId();
1527 				if(!bDisable && pVFrame->HasChildWindow( nId ))
1528 				{
1529 					if(rSh.GetSelectionType() == nsSelectionType::SEL_GRF
1530 									&& rSh.IsGrfSwapOut(sal_True))
1531 					{
1532 						if( AddGrfUpdateSlot( nWhich ))
1533 							rSh.GetGraphic(sal_False);  // start the loading
1534 					}
1535 					else
1536 					{
1537 						SvxIMapDlg *pDlg = SWIMAPDLG(GetView());
1538 						if( pDlg->GetEditingObject() != rSh.GetIMapInventor() )
1539 							lcl_UpdateIMapDlg( rSh );
1540 					}
1541 				}
1542 				rSet.Put(SfxBoolItem(nWhich, bDisable));
1543 			}
1544 			break;
1545 
1546             case FN_BACKSPACE:
1547             case SID_DELETE:
1548                 if ( ( rSh.HasReadonlySel() && !rSh.CrsrInsideInputFld() )
1549                      || rSh.IsSelObjProtected( FLYPROTECT_CONTENT|FLYPROTECT_PARENT ) != 0 )
1550                 {
1551                     rSet.DisableItem( nWhich );
1552                 }
1553                 break;
1554 
1555 			case SID_CONTOUR_DLG:
1556 			{
1557 				sal_Bool bParentCntProt = 0 != rSh.IsSelObjProtected(FLYPROTECT_CONTENT|FLYPROTECT_PARENT );
1558 
1559 				if( bParentCntProt || 0 != (HTMLMODE_ON & ::GetHtmlMode(
1560 											GetView().GetDocShell() )) )
1561 					rSet.DisableItem( nWhich );
1562 				else
1563 				{
1564 					sal_uInt16 nId = SvxContourDlgChildWindow::GetChildWindowId();
1565 					sal_Bool bHas = GetView().GetViewFrame()->HasChildWindow( nId );
1566 					int nSel = rSh.GetSelectionType();
1567 					sal_Bool bOk = 0 != (nSel & (nsSelectionType::SEL_GRF|nsSelectionType::SEL_OLE));
1568 
1569                     sal_Bool bDisable = sal_False;
1570 					if( !bHas && !bOk )
1571 						bDisable = sal_True;
1572                     // --> OD 2006-11-08 #i59688#
1573                     // avoid unnecessary loading of selected graphic.
1574                     // The graphic is only needed, if the dialog is open.
1575 					// wenn die Grafik ausgeswappt ist, dann muss der Status
1576 					// asynchron ermittelt werden bis dahin wird der Slot
1577 					// disabled
1578                     else if ( bHas && (nSel & nsSelectionType::SEL_GRF) &&
1579                               rSh.IsGrfSwapOut(sal_True) )
1580 					{
1581 						if( AddGrfUpdateSlot( nWhich ))
1582 							rSh.GetGraphic(sal_False);  // start the loading
1583                         // --> OD 2007-07-04 #i75481#
1584                         bDisable = sal_True;
1585                         // <--
1586 					}
1587 					else if( bHas && bOk )
1588 						bDisable = !lcl_UpdateContourDlg( rSh, nSel );
1589 					else if( bOk )
1590                     {
1591                         // --> OD 2007-07-04 #i75481#
1592                         // apply fix #i59688# only for selected graphics
1593                         if ( nSel & nsSelectionType::SEL_GRF )
1594                             bDisable = GRAPHIC_NONE == rSh.GetGraphicType();
1595                         else
1596                             bDisable = GRAPHIC_NONE == rSh.GetIMapGraphic().GetType();
1597                         // <--
1598                     }
1599                     // <--
1600 
1601 					if( bDisable )
1602 						rSet.DisableItem( nWhich );
1603 					else
1604 						rSet.Put( SfxBoolItem(nWhich, bHas) );
1605 				}
1606 			}
1607 			break;
1608 			case SID_CONTOUR_EXEC:
1609 			{
1610 				sal_Bool bDisable = sal_False;
1611 				int nSel = rSh.GetSelectionType();
1612 				if( !(nSel & (nsSelectionType::SEL_GRF|nsSelectionType::SEL_OLE)) )
1613 					bDisable = sal_True;
1614 				sal_uInt16 nId = SvxContourDlgChildWindow::GetChildWindowId();
1615 				if( !bDisable && GetView().GetViewFrame()->HasChildWindow( nId ))
1616 				{
1617 					SvxContourDlg *pDlg = SWCONTOURDLG(GetView());
1618 					if( pDlg->GetEditingObject() != rSh.GetIMapInventor() )
1619 						bDisable = sal_True;
1620 				}
1621 				rSet.Put(SfxBoolItem(nWhich, bDisable));
1622 			}
1623 			break;
1624 
1625 			case FN_TOOL_ANKER:
1626 			case FN_TOOL_ANKER_PAGE:
1627 			case FN_TOOL_ANKER_PARAGRAPH:
1628 			case FN_TOOL_ANKER_CHAR:
1629 			case FN_TOOL_ANKER_AT_CHAR:
1630 			case FN_TOOL_ANKER_FRAME:
1631 			{
1632 				sal_Bool bObj = 0 != rSh.IsObjSelected();
1633 				sal_Bool bParentCntProt = rSh.IsSelObjProtected( FLYPROTECT_CONTENT|FLYPROTECT_PARENT ) != 0;
1634 
1635 				if( !bParentCntProt && (bObj || rSh.IsFrmSelected()))
1636 				{
1637 					SfxItemSet aSet(GetPool(), RES_ANCHOR, RES_ANCHOR);
1638 					if(bObj)
1639 						rSh.GetObjAttr(aSet);
1640 					else
1641 						rSh.GetFlyFrmAttr(aSet);
1642 					RndStdIds eSet = ((SwFmtAnchor&)aSet.Get(RES_ANCHOR)).GetAnchorId();
1643                     const sal_Bool bSet =
1644                            ((nWhich == FN_TOOL_ANKER_PAGE) &&
1645                             (eSet == FLY_AT_PAGE))
1646                         || ((nWhich == FN_TOOL_ANKER_PARAGRAPH) &&
1647                             (eSet == FLY_AT_PARA))
1648                         || ((nWhich == FN_TOOL_ANKER_FRAME) &&
1649                             (eSet == FLY_AT_FLY))
1650                         || ((nWhich == FN_TOOL_ANKER_AT_CHAR) &&
1651                             (eSet == FLY_AT_CHAR))
1652                         || ((nWhich == FN_TOOL_ANKER_CHAR) &&
1653                             (eSet == FLY_AS_CHAR));
1654 					if(nWhich != FN_TOOL_ANKER)
1655 					{
1656 						sal_uInt16 nHtmlMode = ::GetHtmlMode(GetView().GetDocShell());
1657 						if( ( nWhich == FN_TOOL_ANKER_PAGE &&
1658 							  ((HTMLMODE_ON & nHtmlMode) && (0 == (nHtmlMode & HTMLMODE_SOME_ABS_POS)))) ||
1659                             ( nWhich == FN_TOOL_ANKER_FRAME && !rSh.IsFlyInFly() ) )
1660 							rSet.DisableItem(nWhich);
1661 						else
1662 							rSet.Put(SfxBoolItem(nWhich, bSet));
1663 					}
1664 					else
1665 					{
1666 						sal_uInt16 nSlotId = 0;
1667 
1668 						switch (eSet)
1669 						{
1670                             case FLY_AT_PAGE:
1671 								nSlotId = FN_TOOL_ANKER_PAGE;
1672 							break;
1673                             case FLY_AT_PARA:
1674 								nSlotId = FN_TOOL_ANKER_PARAGRAPH;
1675 							break;
1676 							case FLY_AS_CHAR:
1677 								nSlotId = FN_TOOL_ANKER_CHAR;
1678 							break;
1679                             case FLY_AT_CHAR:
1680 								nSlotId = FN_TOOL_ANKER_AT_CHAR;
1681 							break;
1682 							case FLY_AT_FLY:
1683 								nSlotId = FN_TOOL_ANKER_FRAME;
1684 							break;
1685 							default:
1686 								;
1687 						}
1688 						rSet.Put(SfxUInt16Item(nWhich, nSlotId));
1689 					}
1690 				}
1691 				else
1692 					rSet.DisableItem( nWhich );
1693 			}
1694 			break;
1695 			case FN_FRAME_NOWRAP:
1696 			case FN_FRAME_WRAP:
1697 			case FN_FRAME_WRAP_IDEAL:
1698 			case FN_FRAME_WRAPTHRU:
1699 			case FN_FRAME_WRAPTHRU_TRANSP:
1700 			case FN_FRAME_WRAP_CONTOUR:
1701 			case FN_WRAP_ANCHOR_ONLY:
1702 			case FN_FRAME_WRAP_LEFT:
1703 			case FN_FRAME_WRAP_RIGHT:
1704 			{
1705 				sal_Bool bObj = 0 != rSh.IsObjSelected();
1706 				sal_Bool bParentCntProt = rSh.IsSelObjProtected( FLYPROTECT_CONTENT|FLYPROTECT_PARENT ) != 0;
1707 
1708 				if( !bParentCntProt && (bObj || rSh.IsFrmSelected()))
1709 				{
1710 					SfxItemSet aSet(GetPool(), RES_OPAQUE, RES_ANCHOR);
1711 					int nAnchorType;
1712 					if(bObj)
1713 					{
1714 						rSh.GetObjAttr(aSet);
1715 						nAnchorType = rSh.GetAnchorId();
1716 					}
1717 					else
1718 					{
1719 						rSh.GetFlyFrmAttr(aSet);
1720 						nAnchorType = ((SwFmtAnchor&)aSet.Get(RES_ANCHOR)).GetAnchorId();
1721 					}
1722 					const SwFmtSurround& rWrap = (const SwFmtSurround&)aSet.Get(RES_SURROUND);
1723 
1724 					const SvxOpaqueItem& rOpaque = (const SvxOpaqueItem&)aSet.Get(RES_OPAQUE);
1725 					sal_Bool bOpaque = rOpaque.GetValue();
1726 					SwSurround nSurround = rWrap.GetSurround();
1727                     sal_Bool bSet = sal_False;
1728 
1729                     bool bDisable =
1730                         (nAnchorType == - 1) || (nAnchorType == FLY_AS_CHAR);
1731                     const bool bHtmlMode =
1732                         0 != ::GetHtmlMode(GetView().GetDocShell());
1733 
1734 					switch( nWhich )
1735 					{
1736 						case FN_FRAME_NOWRAP:
1737                             bDisable |=
1738                                 (   (nAnchorType != FLY_AT_PARA)
1739                                  && (nAnchorType != FLY_AT_CHAR)
1740                                  && (nAnchorType != FLY_AT_PAGE));
1741 							bSet = nSurround == SURROUND_NONE;
1742 						break;
1743 						case FN_FRAME_WRAP:
1744 							bDisable |= bHtmlMode;
1745 							bSet = nSurround == SURROUND_PARALLEL;
1746 						break;
1747 						case FN_FRAME_WRAP_IDEAL:
1748 							bDisable |= bHtmlMode;
1749 							bSet = nSurround == SURROUND_IDEAL;
1750 						break;
1751 						case FN_FRAME_WRAPTHRU:
1752 							bDisable |= (bHtmlMode ||
1753                                 (   (nAnchorType != FLY_AT_PARA)
1754                                  && (nAnchorType != FLY_AT_CHAR)
1755                                  && (nAnchorType != FLY_AT_PAGE)));
1756 							if(bObj)
1757 								bSet = nSurround == SURROUND_THROUGHT && rSh.GetLayerId();
1758 							else
1759 								bSet = nSurround == SURROUND_THROUGHT && bOpaque;
1760 						break;
1761 						case FN_FRAME_WRAPTHRU_TRANSP:
1762 							bDisable |= bHtmlMode;
1763 							if(bObj)
1764 								bSet = nSurround == SURROUND_THROUGHT && !rSh.GetLayerId();
1765 							else
1766 								bSet = nSurround == SURROUND_THROUGHT && !bOpaque;
1767 						break;
1768 						case FN_FRAME_WRAP_CONTOUR:
1769 							bDisable |= bHtmlMode;
1770                             //no contour available whenn no wrap or wrap through is set
1771                             bDisable |= (nSurround == SURROUND_NONE || nSurround == SURROUND_THROUGHT);
1772 							bSet = rWrap.IsContour();
1773 							if( !bDisable )
1774 							{
1775 								int nSel = rSh.GetSelectionType();
1776 								if( (nSel & nsSelectionType::SEL_GRF) &&
1777 											rSh.IsGrfSwapOut(sal_True))
1778 								{
1779 									if( AddGrfUpdateSlot( nWhich ))
1780 										rSh.GetGraphic(sal_False);  // start the loading
1781 								}
1782 								else if( rSh.IsFrmSelected() )
1783                                 {
1784 									// #i102253# applied patch from OD (see task)
1785                                     bDisable =
1786                                         nSel & nsSelectionType::SEL_FRM ||
1787                                         GRAPHIC_NONE == rSh.GetIMapGraphic().GetType();
1788 								}
1789 							}
1790 							bSet = bDisable ? sal_False : rWrap.IsContour();
1791 
1792 						break;
1793 						case FN_WRAP_ANCHOR_ONLY:
1794 							bDisable |= (bHtmlMode ||
1795                                 (nAnchorType != FLY_AT_PARA));
1796 							bSet = rWrap.IsAnchorOnly();
1797 						break;
1798 						case FN_FRAME_WRAP_LEFT:
1799 							bSet = nSurround == SURROUND_LEFT;
1800 						break;
1801 						case FN_FRAME_WRAP_RIGHT:
1802 							bSet = nSurround == SURROUND_RIGHT;
1803 						break;
1804 					}
1805 
1806 					if(bDisable)
1807 						rSet.DisableItem(nWhich);
1808 					else
1809 						rSet.Put(SfxBoolItem(nWhich, bSet));
1810 				}
1811 				else
1812 					rSet.DisableItem(nWhich);
1813 			}
1814 			break;
1815 			case FN_UPDATE_CHARTS:
1816 				if( !rSh.HasCharts() )
1817 					rSet.DisableItem( nWhich );
1818 				break;
1819 			case FN_UPDATE_ALL_LINKS:
1820 				if ( !rSh.GetLinkManager().GetLinks().Count() )
1821 					rSet.DisableItem(nWhich);
1822 				break;
1823             case FN_XFORMS_DESIGN_MODE:
1824                 // enable if in XForms document
1825                 if( rSh.GetDoc()->isXForms() )
1826                 {
1827                     // determine current state from view options
1828                     sal_Bool bValue = ! rSh.GetViewOptions()->IsFormView();
1829                     rSet.Put( SfxBoolItem( nWhich, bValue ) );
1830                 }
1831                 else
1832                     rSet.Put( SfxVisibilityItem( nWhich, sal_False ) );
1833                 break;
1834 		}
1835 		nWhich = aIter.NextWhich();
1836 	}
1837 	pGetStateSet = 0;
1838 }
1839 
1840 /*--------------------------------------------------------------------
1841 	Beschreibung:	Slots mit dieser Statusmethode disablen
1842  --------------------------------------------------------------------*/
1843 
1844 
1845 void SwBaseShell::StateDisableItems( SfxItemSet &rSet )
1846 {
1847 	SfxWhichIter aIter(rSet);
1848 	sal_uInt16 nWhich = aIter.FirstWhich();
1849 
1850 	while (nWhich)
1851 	{
1852 		rSet.DisableItem( nWhich );
1853 		nWhich = aIter.NextWhich();
1854 	}
1855 }
1856 
1857 /*--------------------------------------------------------------------
1858 	Beschreibung:	Slots mit dieser Statusmethode disablen
1859  --------------------------------------------------------------------*/
1860 
1861 
1862 void SwBaseShell::StateStyle( SfxItemSet &rSet )
1863 {
1864 	sal_Bool bParentCntProt = GetShell().IsSelObjProtected( FLYPROTECT_CONTENT|FLYPROTECT_PARENT ) != 0;
1865 	ShellModes eMode = GetView().GetShellMode();
1866 
1867 	if ( bParentCntProt ||
1868 		 SHELL_MODE_DRAW == eMode ||
1869 		 SHELL_MODE_DRAW_CTRL == eMode ||
1870 		 SHELL_MODE_DRAW_FORM == eMode ||
1871 		 SHELL_MODE_DRAWTEXT == eMode ||
1872 		 SHELL_MODE_BEZIER == eMode )
1873 	{
1874 		SfxWhichIter aIter( rSet );
1875 		sal_uInt16 nWhich = aIter.FirstWhich();
1876 		while ( nWhich )
1877 		{
1878 			rSet.DisableItem( nWhich );
1879 			nWhich = aIter.NextWhich();
1880 		}
1881 	}
1882 	else
1883 		GetView().GetDocShell()->StateStyleSheet(rSet, &GetShell());
1884 }
1885 
1886 /*--------------------------------------------------------------------
1887 	Beschreibung:
1888  --------------------------------------------------------------------*/
1889 
1890 
1891 void SwBaseShell::SetWrapMode( sal_uInt16 nSlot )
1892 {
1893 	SwWrtShell &rSh = GetShell();
1894 	sal_Bool bObj = 0 != rSh.IsObjSelected();
1895 	if( bObj || rSh.IsFrmSelected())
1896 	{
1897 		SfxItemSet aSet(GetPool(), RES_OPAQUE, RES_SURROUND);
1898 		if(bObj)
1899 			rSh.GetObjAttr(aSet);
1900 		else
1901 			rSh.GetFlyFrmAttr(aSet);
1902 		SwFmtSurround aWrap( (SwFmtSurround&)aSet.Get(RES_SURROUND) );
1903 		SwSurround nOldSurround(aWrap.GetSurround());
1904 		SwSurround nSurround = SURROUND_PARALLEL;
1905 
1906 		switch (nSlot)
1907 		{
1908 			case FN_FRAME_NOWRAP:
1909 				nSurround = SURROUND_NONE;
1910 				if (aWrap.IsContour())
1911 					aWrap.SetContour(sal_False);
1912 				break;
1913 			case FN_FRAME_WRAP_IDEAL:
1914 				nSurround = SURROUND_IDEAL;
1915 				break;
1916 			case FN_WRAP_ANCHOR_ONLY:
1917 				aWrap.SetAnchorOnly(!aWrap.IsAnchorOnly());
1918                 // --> OD 2006-06-02 #b6432130#
1919                 // keep previous wrapping
1920                 // --> OD 2006-09-21 #138144# - adjust fix #b6432130#
1921                 // switch to wrap SURROUND_PARALLEL, if previous wrap is SURROUND_NONE
1922                 if ( nOldSurround != SURROUND_NONE )
1923                 {
1924                     nSurround = nOldSurround;
1925                 }
1926                 // <--
1927 				break;
1928 			case FN_FRAME_WRAP_CONTOUR:
1929 				aWrap.SetContour(!aWrap.IsContour());
1930 				if (nSurround == SURROUND_THROUGHT)
1931 					nSurround = SURROUND_PARALLEL;
1932 				break;
1933 			case FN_FRAME_WRAPTHRU_TRANSP:
1934 				if (aWrap.IsContour())
1935 					aWrap.SetContour(sal_False);
1936 				// kein break!!!
1937 			case FN_FRAME_WRAPTHRU:
1938 				nSurround = SURROUND_THROUGHT;
1939 				break;
1940 
1941 			case FN_FRAME_WRAP_LEFT:
1942 				nSurround = SURROUND_LEFT;
1943 				break;
1944 
1945 			case FN_FRAME_WRAP_RIGHT:
1946 				nSurround = SURROUND_RIGHT;
1947 				break;
1948 
1949 			default:
1950 				break;
1951 		}
1952 		aWrap.SetSurround(nSurround);
1953 
1954 		if (nSlot != FN_FRAME_WRAP_CONTOUR)
1955 		{
1956 			// Konturumfluss bei Draw-Objekten defaulten
1957 			if (bObj && nOldSurround != nSurround &&
1958 				(nOldSurround == SURROUND_NONE || nOldSurround == SURROUND_THROUGHT))
1959 			{
1960 				aWrap.SetContour(sal_True);
1961 			}
1962 		}
1963 
1964 		aSet.Put( aWrap );
1965 		aSet.Put(SvxOpaqueItem(RES_OPAQUE, nSlot != FN_FRAME_WRAPTHRU_TRANSP));
1966 		if(bObj)
1967 		{
1968 			rSh.SetObjAttr(aSet);
1969 			if (nSlot != FN_FRAME_WRAPTHRU_TRANSP)
1970 				rSh.SelectionToHeaven();
1971 			else
1972 				rSh.SelectionToHell();
1973 		}
1974 		else
1975 			rSh.SetFlyFrmAttr(aSet);
1976 	}
1977 }
1978 
1979 /*--------------------------------------------------------------------
1980 	Beschreibung:	Update der Statuszeile erzwingen
1981  --------------------------------------------------------------------*/
1982 
1983 void SwBaseShell::SetFrmMode(FlyMode eMode, SwWrtShell *pSh )
1984 {
1985     eFrameMode = eMode;
1986 	SfxBindings &rBnd = pSh->GetView().GetViewFrame()->GetBindings();
1987 
1988     if( eMode == FLY_DRAG ||
1989 		(pSh && (pSh->IsFrmSelected() || pSh->IsObjSelected())) )
1990 	{
1991 		const SfxPointItem aTmp1( SID_ATTR_POSITION, pSh->GetAnchorObjDiff());
1992 		const SvxSizeItem  aTmp2( SID_ATTR_SIZE,	 pSh->GetObjSize());
1993 		rBnd.SetState( aTmp1 );
1994 		rBnd.SetState( aTmp2 );
1995 	}
1996     else if( eMode == FLY_DRAG_END )
1997 	{
1998 		static sal_uInt16 __READONLY_DATA aInval[] =
1999 		{
2000 			SID_ATTR_POSITION, SID_ATTR_SIZE, 0
2001 		};
2002 		rBnd.Invalidate(aInval);
2003 	}
2004 }
2005 
2006 /*--------------------------------------------------------------------
2007 	Beschreibung:	Ctor
2008  --------------------------------------------------------------------*/
2009 
2010 SwBaseShell::SwBaseShell(SwView& rVw) :
2011 	SfxShell( &rVw ),
2012 	rView(rVw),
2013 	pGetStateSet(0)
2014 {
2015 	SwWrtShell& rWrtSh = rView.GetWrtShell();
2016 
2017 	SetPool(&rWrtSh.GetAttrPool());
2018 	SetName(C2S("Base"));
2019 	rWrtSh.SetGrfArrivedLnk( LINK( this, SwBaseShell, GraphicArrivedHdl));
2020 }
2021 
2022 
2023 SwBaseShell::~SwBaseShell()
2024 {
2025 	if( rView.GetCurShell() == this )
2026 		rView.ResetSubShell();
2027 
2028 	Link aTmp( LINK( this, SwBaseShell, GraphicArrivedHdl));
2029 	if( aTmp == rView.GetWrtShell().GetGrfArrivedLnk() )
2030 		rView.GetWrtShell().SetGrfArrivedLnk( Link() );
2031 }
2032 
2033 /*--------------------------------------------------------------------
2034 	Beschreibung:
2035  --------------------------------------------------------------------*/
2036 
2037 void SwBaseShell::ExecTxtCtrl( SfxRequest& rReq )
2038 {
2039 	const SfxItemSet *pArgs = rReq.GetArgs();
2040 
2041 	if( pArgs)
2042 	{
2043 		SwWrtShell &rSh = GetShell();
2044 		SvxScriptSetItem* pSSetItem = 0;
2045 		sal_uInt16 nSlot = rReq.GetSlot();
2046 		SfxItemPool& rPool = rSh.GetAttrPool();
2047 		sal_uInt16 nWhich = rPool.GetWhich( nSlot );
2048         sal_uInt16 nScripts = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX;
2049         SfxItemSet aHeightSet( GetPool(),  RES_CHRATR_FONTSIZE, RES_CHRATR_FONTSIZE,
2050                                             RES_CHRATR_CJK_FONTSIZE, RES_CHRATR_CJK_FONTSIZE,
2051                                             RES_CHRATR_CTL_FONTSIZE, RES_CHRATR_CTL_FONTSIZE,
2052                                         0L);
2053 
2054 		switch( nSlot )
2055 		{
2056 		    case SID_ATTR_CHAR_FONT:
2057             {
2058                 nScripts = rSh.GetScriptType();
2059                 // #i42732# input language should be preferred over
2060                 // current cursor position to detect script type
2061                 if(!rSh.HasSelection())
2062                 {
2063                     LanguageType nInputLang = GetView().GetEditWin().GetInputLanguage();
2064                     if(nInputLang != LANGUAGE_DONTKNOW && nInputLang != LANGUAGE_SYSTEM)
2065                         nScripts = SvtLanguageOptions::GetScriptTypeOfLanguage( nInputLang );
2066                 }
2067             }
2068 		    case SID_ATTR_CHAR_POSTURE:
2069 		    case SID_ATTR_CHAR_WEIGHT:
2070 			{
2071 				pSSetItem = new SvxScriptSetItem( nSlot, rPool );
2072 				pSSetItem->PutItemForScriptType( nScripts, pArgs->Get( nWhich ));
2073 				pArgs = &pSSetItem->GetItemSet();
2074 			}
2075 			break;
2076             case SID_ATTR_CHAR_FONTHEIGHT:
2077             {
2078 				if(rSh.HasSelection())
2079                 {
2080                     pSSetItem = new SvxScriptSetItem( nSlot, rPool );
2081 				    pSSetItem->PutItemForScriptType( nScripts, pArgs->Get( nWhich ));
2082 				    pArgs = &pSSetItem->GetItemSet();
2083                 }
2084                 else
2085                 {
2086                     nScripts = rSh.GetScriptType();
2087                     LanguageType nInputLang = GetView().GetEditWin().GetInputLanguage();
2088                     if(nInputLang != LANGUAGE_DONTKNOW && nInputLang != LANGUAGE_SYSTEM)
2089                         nScripts = SvtLanguageOptions::GetScriptTypeOfLanguage( nInputLang );
2090                     sal_uInt32 nHeight = static_cast< const SvxFontHeightItem& >(pArgs->Get( nWhich )).GetHeight();
2091                     SwStdFontConfig* pStdFont = SW_MOD()->GetStdFontConfig();
2092 
2093                     SfxItemSet aLangSet( GetPool(), RES_CHRATR_LANGUAGE, RES_CHRATR_LANGUAGE,
2094                                                     RES_CHRATR_CJK_LANGUAGE, RES_CHRATR_CJK_LANGUAGE,
2095                                                     RES_CHRATR_CTL_LANGUAGE, RES_CHRATR_CTL_LANGUAGE,
2096                                                     0L);
2097                     rSh.GetCurAttr( aLangSet );
2098 
2099                     sal_Int32 nWesternSize =
2100                             pStdFont->GetFontHeight(FONT_STANDARD, FONT_GROUP_DEFAULT,
2101                             static_cast<const SvxLanguageItem&>(aLangSet.Get( RES_CHRATR_LANGUAGE)).GetLanguage());
2102                     sal_Int32 nCJKSize =
2103                             pStdFont->GetFontHeight(FONT_STANDARD, FONT_GROUP_CJK,
2104                             static_cast<const SvxLanguageItem&>(aLangSet.Get( RES_CHRATR_CJK_LANGUAGE)).GetLanguage());
2105                     sal_Int32 nCTLSize =
2106                             pStdFont->GetFontHeight(FONT_STANDARD, FONT_GROUP_CTL,
2107                             static_cast<const SvxLanguageItem&>(aLangSet.Get( RES_CHRATR_CTL_LANGUAGE)).GetLanguage());
2108 
2109                     switch(nScripts)
2110                     {
2111                         case SCRIPTTYPE_LATIN:
2112                             nCJKSize = nHeight * nCJKSize / nWesternSize;
2113                             nCTLSize = nHeight * nCTLSize / nWesternSize;
2114                             nWesternSize = (sal_Int32) nHeight;
2115                         break;
2116                         case SCRIPTTYPE_ASIAN:
2117                             nCTLSize = nHeight* nCTLSize / nCJKSize;
2118                             nWesternSize = nHeight * nWesternSize / nCJKSize;
2119                             nCJKSize = (sal_Int32) nHeight;
2120                         break;
2121                         case SCRIPTTYPE_COMPLEX:
2122                             nCJKSize = nHeight * nCJKSize / nCTLSize;
2123                             nWesternSize = nHeight * nWesternSize / nCTLSize;
2124                             nCTLSize = (sal_Int32) nHeight;
2125                         break;
2126                     }
2127                     aHeightSet.Put( SvxFontHeightItem( (sal_uInt32)nWesternSize, 100, RES_CHRATR_FONTSIZE ));
2128                     aHeightSet.Put( SvxFontHeightItem( (sal_uInt32)nCJKSize, 100, RES_CHRATR_CJK_FONTSIZE ));
2129                     aHeightSet.Put( SvxFontHeightItem( (sal_uInt32)nCTLSize, 100, RES_CHRATR_CTL_FONTSIZE ));
2130                     pArgs = &aHeightSet;
2131                 }
2132             }
2133             break;
2134 		}
2135 
2136 		if( pArgs )
2137         {
2138             bool bAuto = false;
2139             if ( !isCHRATR(nWhich) ||
2140                  ( rSh.HasSelection() && rSh.IsSelFullPara() ) )
2141             {
2142                 SwTxtFmtColl * pColl = rSh.GetCurTxtFmtColl();
2143                 if ( pColl && pColl->IsAutoUpdateFmt() )
2144                 {
2145                     rSh.AutoUpdatePara( pColl, *pArgs );
2146                     bAuto = true;
2147                 }
2148             }
2149 
2150             if (!bAuto)
2151             {
2152                 rSh.SetAttrSet( *pArgs );
2153             }
2154         }
2155 		delete pSSetItem;
2156 	}
2157     else
2158         GetView().GetViewFrame()->GetDispatcher()->Execute( SID_CHAR_DLG, sal_False);
2159     rReq.Done();
2160 }
2161 
2162 /*--------------------------------------------------------------------
2163 	Beschreibung:
2164  --------------------------------------------------------------------*/
2165 
2166 void SwBaseShell::GetTxtCtrlState( SfxItemSet& rSet )
2167 {
2168 	SwWrtShell &rSh = GetShell();
2169     rSh.GetCurAttr( rSet );
2170 }
2171 
2172 void SwBaseShell::GetTxtFontCtrlState( SfxItemSet& rSet )
2173 {
2174 	SwWrtShell &rSh = GetShell();
2175 	sal_Bool bFirst = sal_True;
2176 	SfxItemSet* pFntCoreSet = 0;
2177     sal_uInt16 nScriptType = SCRIPTTYPE_LATIN;
2178 	SfxWhichIter aIter( rSet );
2179 	sal_uInt16 nWhich = aIter.FirstWhich();
2180 	while( nWhich )
2181 	{
2182 		switch( nWhich )
2183 		{
2184 		case RES_CHRATR_FONT:
2185 		case RES_CHRATR_FONTSIZE:
2186 		case RES_CHRATR_WEIGHT:
2187 		case RES_CHRATR_POSTURE:
2188 			{
2189 				if( !pFntCoreSet )
2190 				{
2191 					pFntCoreSet = new SfxItemSet( *rSet.GetPool(),
2192 									RES_CHRATR_BEGIN, RES_CHRATR_END-1 );
2193                     rSh.GetCurAttr( *pFntCoreSet );
2194                     nScriptType = rSh.GetScriptType();
2195                     // #i42732# input language should be preferred over
2196                     // current cursor position to detect script type
2197                     SwEditWin& rEditWin = GetView().GetEditWin();
2198                     if( rEditWin.IsUseInputLanguage() )
2199                     {
2200                         if(!rSh.HasSelection() && (
2201                             nWhich == RES_CHRATR_FONT ||
2202                             nWhich == RES_CHRATR_FONTSIZE ))
2203                         {
2204                             LanguageType nInputLang = rEditWin.GetInputLanguage();
2205                             if(nInputLang != LANGUAGE_DONTKNOW && nInputLang != LANGUAGE_SYSTEM)
2206                                 nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( nInputLang );
2207                         }
2208                     }
2209 				}
2210 				SfxItemPool& rPool = *rSet.GetPool();
2211 				SvxScriptSetItem aSetItem( rPool.GetSlotId( nWhich ), rPool );
2212 				aSetItem.GetItemSet().Put( *pFntCoreSet, sal_False );
2213 				const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScriptType );
2214 				if( pI )
2215 					rSet.Put( *pI, nWhich );
2216 				else
2217 					rSet.InvalidateItem( nWhich );
2218                 //set input context of the SwEditWin according to the selected font and script type
2219                 if(RES_CHRATR_FONT == nWhich)
2220                 {
2221                     Font aFont;
2222                     if(pI && pI->ISA(SvxFontItem))
2223                     {
2224                         aFont.SetName( ((const SvxFontItem*)pI)->GetFamilyName());
2225                         aFont.SetStyleName(((const SvxFontItem*)pI)->GetStyleName());
2226                         aFont.SetFamily(((const SvxFontItem*)pI)->GetFamily());
2227                         aFont.SetPitch(((const SvxFontItem*)pI)->GetPitch());
2228                         aFont.SetCharSet(((const SvxFontItem*)pI)->GetCharSet());
2229                     }
2230 
2231                     sal_Bool bVertical = rSh.IsInVerticalText();
2232                     aFont.SetOrientation(bVertical ? 2700 : 0);
2233                     aFont.SetVertical(bVertical);
2234                     GetView().GetEditWin().SetInputContext( InputContext( aFont, INPUTCONTEXT_TEXT |
2235                                                         INPUTCONTEXT_EXTTEXTINPUT ) );
2236                 }
2237 			}
2238 			break;
2239 
2240 		default:
2241 			if( bFirst )
2242 			{
2243                 rSh.GetCurAttr( rSet );
2244 				bFirst = sal_False;
2245 			}
2246 		}
2247 		nWhich = aIter.NextWhich();
2248 	}
2249 	delete pFntCoreSet;
2250 }
2251 
2252 /*--------------------------------------------------------------------
2253 	Beschreibung:
2254  --------------------------------------------------------------------*/
2255 
2256 void SwBaseShell::GetBckColState(SfxItemSet &rSet)
2257 {
2258 	SwWrtShell &rSh = GetShell();
2259 	SfxWhichIter aIter( rSet );
2260 	sal_uInt16 nWhich = aIter.FirstWhich();
2261 	int nSelType = rSh.GetSelectionType();
2262 
2263 //	if ( nSelType & nsSelectionType::SEL_GRF ||
2264 	if( nSelType & nsSelectionType::SEL_OLE )
2265 	{
2266 		rSet.DisableItem( SID_BACKGROUND_COLOR );
2267 		return;
2268 	}
2269 
2270 	if ( nSelType & nsSelectionType::SEL_FRM )
2271 	{
2272 		sal_Bool bParentCntProt = rSh.IsSelObjProtected( FLYPROTECT_CONTENT|FLYPROTECT_PARENT ) != 0;
2273 		if (bParentCntProt)
2274 		{
2275 			rSet.DisableItem( SID_BACKGROUND_COLOR );
2276 			return;
2277 		}
2278 	}
2279 
2280     SvxBrushItem aBrushItem( RES_BACKGROUND );
2281 
2282 	if( nsSelectionType::SEL_TBL_CELLS & nSelType )
2283     {
2284 		rSh.GetBoxBackground( aBrushItem );
2285     }
2286     else
2287     {
2288         //UUUU
2289         if(nSelType & nsSelectionType::SEL_GRF)
2290         {
2291             SfxItemSet aCoreSet(GetPool(), RES_BACKGROUND, RES_BACKGROUND);
2292 
2293             rSh.GetFlyFrmAttr( aCoreSet );
2294             aBrushItem = (const SvxBrushItem&)aCoreSet.Get(RES_BACKGROUND);
2295         }
2296         else if(nsSelectionType::SEL_FRM & nSelType)
2297         {
2298             SfxItemSet aCoreSet(GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST);
2299             const XFillStyleItem& rXFillStyleItem(static_cast< const XFillStyleItem&  >(aCoreSet.Get(XATTR_FILLSTYLE)));
2300 
2301             if(XFILL_SOLID == rXFillStyleItem.GetValue())
2302             {
2303                 const Color aFillColor(static_cast< const XFillColorItem& >(aCoreSet.Get(XATTR_FILLCOLOR)).GetColorValue());
2304 
2305                 aBrushItem.SetColor(aFillColor);
2306             }
2307             else
2308             {
2309                 // keep default in SvxBrushItem which equals no fill
2310             }
2311         }
2312         else
2313         {
2314             SfxItemSet aCoreSet(GetPool(), RES_BACKGROUND, RES_BACKGROUND);
2315 
2316             rSh.GetCurAttr( aCoreSet );
2317             aBrushItem = (const SvxBrushItem&)aCoreSet.Get(RES_BACKGROUND);
2318         }
2319     }
2320 
2321 	while ( nWhich )
2322 	{
2323 		switch(nWhich)
2324 		{
2325 			case SID_BACKGROUND_COLOR  :
2326 			{
2327                 SvxColorItem aColorItem(aBrushItem.GetColor(), SID_BACKGROUND_COLOR);
2328 				rSet.Put( aColorItem, SID_BACKGROUND_COLOR );
2329 			}
2330 			break;
2331 			case SID_ATTR_BRUSH:
2332 			case RES_BACKGROUND:
2333 				rSet.Put( aBrushItem, GetPool().GetWhich(nWhich) );
2334 			break;
2335 		}
2336 		nWhich = aIter.NextWhich();
2337 	}
2338 }
2339 
2340 /*--------------------------------------------------------------------
2341 	Beschreibung:
2342  --------------------------------------------------------------------*/
2343 
2344 void SwBaseShell::ExecBckCol(SfxRequest& rReq)
2345 {
2346 	SwWrtShell &rSh = GetShell();
2347 	int nSelType = rSh.GetSelectionType();
2348 	if ( nSelType & nsSelectionType::SEL_OLE )
2349 	{
2350 		return;
2351 	}
2352 
2353 	const SfxItemSet* pArgs = rReq.GetArgs();
2354 	sal_uInt16 nSlot = rReq.GetSlot();
2355 	if( !pArgs  && nSlot != SID_BACKGROUND_COLOR)
2356 		return ;
2357 
2358     SvxBrushItem aBrushItem( RES_BACKGROUND );
2359 
2360     if( nsSelectionType::SEL_TBL_CELLS & nSelType )
2361     {
2362         rSh.GetBoxBackground( aBrushItem );
2363     }
2364     else
2365     {
2366         //UUUU
2367         if(nSelType & nsSelectionType::SEL_GRF)
2368         {
2369             SfxItemSet aCoreSet(GetPool(), RES_BACKGROUND, RES_BACKGROUND);
2370 
2371             rSh.GetFlyFrmAttr( aCoreSet );
2372             aBrushItem = (const SvxBrushItem&)aCoreSet.Get(RES_BACKGROUND);
2373         }
2374         else if(nsSelectionType::SEL_FRM & nSelType)
2375         {
2376             SfxItemSet aCoreSet(GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST);
2377             const XFillStyleItem& rXFillStyleItem(static_cast< const XFillStyleItem&  >(aCoreSet.Get(XATTR_FILLSTYLE)));
2378 
2379             if(XFILL_SOLID == rXFillStyleItem.GetValue())
2380             {
2381                 const Color aFillColor(static_cast< const XFillColorItem& >(aCoreSet.Get(XATTR_FILLCOLOR)).GetColorValue());
2382 
2383                 aBrushItem.SetColor(aFillColor);
2384             }
2385             else
2386             {
2387                 // keep default in SvxBrushItem which equals no fill
2388             }
2389         }
2390         else
2391         {
2392             SfxItemSet aCoreSet(GetPool(), RES_BACKGROUND, RES_BACKGROUND);
2393 
2394             rSh.GetCurAttr( aCoreSet );
2395             aBrushItem = (const SvxBrushItem&)aCoreSet.Get(RES_BACKGROUND);
2396         }
2397     }
2398 
2399 //	sal_Bool bMsgOk = sal_False;
2400 
2401 	switch (nSlot)
2402 	{
2403 		// RES_BACKGROUND (=SID_ATTR_BRUSH) muss ueber zwei IDs
2404 		// gesetzt werden:
2405 		case SID_BACKGROUND_COLOR:
2406 			{
2407 				aBrushItem.SetGraphicPos(GPOS_NONE);
2408 
2409 				//Brush &rBrush = aBrushItem.GetBrush();
2410 				if(pArgs)
2411 				{
2412 					const SvxColorItem&	rNewColorItem = (const SvxColorItem&)
2413 											pArgs->Get(SID_BACKGROUND_COLOR);
2414 					const Color& rNewColor = rNewColorItem.GetValue();
2415 					aBrushItem.SetColor( rNewColor );
2416 					GetView().GetViewFrame()->GetBindings().SetState(rNewColorItem);
2417 				}
2418 				else
2419                 {
2420 					aBrushItem.SetColor( COL_TRANSPARENT );
2421                     rReq.AppendItem( SvxColorItem( Color( COL_TRANSPARENT ), nSlot ) );
2422                 }
2423 			}
2424 			break;
2425 
2426 		case SID_ATTR_BRUSH:
2427 		case RES_BACKGROUND:
2428 		{
2429 			const SvxBrushItem& rNewBrushItem = (const SvxBrushItem&)
2430 									pArgs->Get( GetPool().GetWhich(nSlot) );
2431 			aBrushItem = rNewBrushItem;
2432 		}
2433 		break;
2434 		default:
2435 //			bMsgOk = sal_False;
2436             rReq.Ignore();
2437 			DBG_ERROR( "Unbekannte Message bei ExecuteAttr!" );
2438 			return;
2439 	}
2440 
2441     if( nsSelectionType::SEL_TBL_CELLS & nSelType )
2442     {
2443         rSh.SetBoxBackground( aBrushItem );
2444     }
2445     //UUUU
2446     else if(nsSelectionType::SEL_GRF & nSelType)
2447     {
2448         SfxItemSet aCoreSet(GetPool(), RES_BACKGROUND, RES_BACKGROUND);
2449         aCoreSet.Put( aBrushItem );
2450         // Vorlagen-AutoUpdate
2451         SwFrmFmt* pFmt = rSh.GetCurFrmFmt();
2452         if(pFmt && pFmt->IsAutoUpdateFmt())
2453             rSh.AutoUpdateFrame( pFmt, aCoreSet);
2454         else
2455             rSh.SetFlyFrmAttr( aCoreSet );
2456     }
2457     else if(nsSelectionType::SEL_FRM & nSelType)
2458     {
2459         SfxItemSet aCoreSet(GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST);
2460         const XubString aNullStr;
2461 
2462         // set FillStyle and color when applying
2463         aCoreSet.Put(XFillStyleItem(XFILL_SOLID));
2464         aCoreSet.Put(XFillColorItem(aNullStr, aBrushItem.GetColor()));
2465 
2466         // Vorlagen-AutoUpdate
2467         SwFrmFmt* pFmt = rSh.GetCurFrmFmt();
2468 
2469         if(pFmt && pFmt->IsAutoUpdateFmt())
2470         {
2471             rSh.AutoUpdateFrame( pFmt, aCoreSet);
2472         }
2473         else
2474         {
2475             rSh.SetFlyFrmAttr( aCoreSet );
2476         }
2477     }
2478     else
2479     {
2480         SwTxtFmtColl* pColl = rSh.GetCurTxtFmtColl();
2481         if(	pColl && pColl->IsAutoUpdateFmt())
2482         {
2483             SfxItemSet aSet(GetPool(), RES_BACKGROUND, RES_BACKGROUND );
2484             aSet.Put(aBrushItem);
2485             rSh.AutoUpdatePara( pColl, aSet);
2486         }
2487         else
2488             rSh.SetAttrItem( aBrushItem );
2489     }
2490 
2491     rReq.Done();
2492 }
2493 
2494 /*--------------------------------------------------------------------
2495 	Beschreibung:
2496  --------------------------------------------------------------------*/
2497 
2498 
2499 void SwBaseShell::GetBorderState(SfxItemSet &rSet)
2500 {
2501 	SwWrtShell &rSh = GetShell();
2502 	// Tabellenzelle(n) selektiert?
2503 	sal_Bool bPrepare = sal_True;
2504     sal_Bool bTableMode = rSh.IsTableMode();
2505     if ( bTableMode )
2506 	{
2507 		SfxItemSet aCoreSet( GetPool(),
2508 							 RES_BOX, RES_BOX,
2509 							 SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, 0 );
2510         SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
2511 		aCoreSet.Put( aBoxInfo );
2512 		rSh.GetTabBorders( aCoreSet );
2513 		rSet.Put( aCoreSet );
2514 	}
2515 	else if ( rSh.IsFrmSelected() )
2516 	{
2517 		SwFlyFrmAttrMgr aMgr( sal_False, &rSh, FRMMGR_TYPE_NONE );
2518 		rSet.Put( aMgr.GetAttrSet() );
2519 		bPrepare = sal_False;
2520 	}
2521 	else
2522 		// Umrandungsattribute ganz normal ueber Shell holen
2523         rSh.GetCurAttr( rSet );
2524     if ( bPrepare )
2525 		::PrepareBoxInfo( rSet, rSh );
2526     // switch the border toolbox controller mode
2527     rSet.Put( SfxBoolItem( SID_BORDER_REDUCED_MODE, !bTableMode ));
2528 }
2529 
2530 /*--------------------------------------------------------------------
2531 	Beschreibung:
2532  --------------------------------------------------------------------*/
2533 
2534 
2535 void SwBaseShell::ExecDlg(SfxRequest &rReq)
2536 {
2537 	SwWrtShell &rSh = GetShell();
2538 	Window *pMDI = &GetView().GetViewFrame()->GetWindow();
2539 	//Damit aus dem Basic keine Dialoge fuer Hintergrund-Views aufgerufen werden:
2540 	sal_Bool bBackground = (&GetView() != GetActiveView());
2541 	const SfxPoolItem* pItem = 0;
2542 	const SfxItemSet* pArgs = rReq.GetArgs();
2543 
2544 	sal_uInt16 nSlot = rReq.GetSlot();
2545 	const SfxItemSet* pOutSet = 0;
2546     bool bDone = false;
2547 	if(pArgs)
2548 		pArgs->GetItemState( GetPool().GetWhich(nSlot), sal_False, &pItem );
2549 
2550     switch ( nSlot )
2551     {
2552         case FN_FORMAT_PAGE_DLG:
2553         case FN_FORMAT_PAGE_COLUMN_DLG:
2554         case FN_FORMAT_PAGE_SETTING_DLG:
2555         {
2556             if( !bBackground )
2557             {
2558                 const sal_uInt16 nCurIdx = rSh.GetCurPageDesc();
2559                 const SwPageDesc& rPageDesc = rSh.GetPageDesc( nCurIdx );
2560                 //temp. View, weil die Shell nach dem Dialog nicht mehr gueltig sein muss
2561                 //z.B. Kopfzeile ausschalten
2562                 SwView& rTempView = GetView();
2563                 rTempView.GetDocShell()->FormatPage(
2564                     rPageDesc.GetName(),
2565                     nSlot,
2566                     rSh );
2567                 rTempView.InvalidateRulerPos();
2568             }
2569         }
2570         break;
2571         case FN_FORMAT_BORDER_DLG:
2572 		{
2573 			SfxItemSet	 aSet( rSh.GetAttrPool(),
2574 							   RES_BOX	  			, RES_SHADOW,
2575 							   SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER,
2576 							   0 );
2577 			SfxAbstractDialog * pDlg = 0;
2578 			// Tabellenzelle(n) selektiert?
2579 			if ( rSh.IsTableMode() )
2580 			{
2581 				// Umrandungattribute Get/SetTabBorders() setzen
2582 				::PrepareBoxInfo( aSet, rSh );
2583 				rSh.GetTabBorders( aSet );
2584                 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
2585                 DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
2586 
2587                 pDlg = pFact->CreateSwBorderDlg( pMDI, aSet, SW_BORDER_MODE_TABLE, RC_DLG_SWBORDERDLG );
2588                 DBG_ASSERT(pDlg, "Dialogdiet fail!");
2589 				if ( pDlg->Execute() == RET_OK )
2590 				{
2591 					rSh.SetTabBorders( *pDlg->GetOutputItemSet() );
2592 					pOutSet = pDlg->GetOutputItemSet();
2593 				}
2594 			}
2595 			else if ( rSh.IsFrmSelected() )
2596 			{
2597 				// Umrandungsattribute ueber Frame-Manager setzen
2598 				SwFlyFrmAttrMgr aMgr( sal_False, &rSh, FRMMGR_TYPE_NONE );
2599 				aSet.Put( aMgr.GetAttrSet() );
2600 
2601                 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
2602                 DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
2603 
2604                 pDlg = pFact->CreateSwBorderDlg( pMDI, aSet, SW_BORDER_MODE_FRAME, RC_DLG_SWBORDERDLG );
2605                 DBG_ASSERT(pDlg, "Dialogdiet fail!");
2606 				if ( pDlg->Execute() == RET_OK )
2607 				{
2608 					aMgr.SetAttrSet( *pDlg->GetOutputItemSet() );
2609 					aMgr.UpdateFlyFrm();
2610 					pOutSet = pDlg->GetOutputItemSet();
2611 				}
2612 			}
2613 			else
2614 			{
2615 				// Umrandungsattribute ganz normal ueber Shell setzen
2616                 rSh.GetCurAttr( aSet );
2617 				::PrepareBoxInfo( aSet, rSh );
2618 
2619                 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
2620                 DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
2621 
2622                 pDlg = pFact->CreateSwBorderDlg( pMDI, aSet, SW_BORDER_MODE_PARA, RC_DLG_SWBORDERDLG );
2623                 DBG_ASSERT(pDlg, "Dialogdiet fail!");
2624 				if ( pDlg->Execute() == RET_OK )
2625 				{
2626 					rSh.SetAttrSet( *pDlg->GetOutputItemSet() );
2627 					pOutSet = pDlg->GetOutputItemSet();
2628 				}
2629 			}
2630             if(pOutSet)
2631             {
2632                 rReq.Done(*pOutSet);
2633                 bDone = true;
2634             }
2635             delete pDlg;
2636 		}
2637 		break;
2638 		case FN_FORMAT_BACKGROUND_DLG:
2639 		{
2640 			SfxItemSet aSet( rSh.GetAttrPool(),
2641 							 RES_BACKGROUND, RES_BACKGROUND );
2642 
2643             SfxAbstractDialog * pDlg = 0;
2644             SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
2645             DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
2646 
2647 
2648 			// Tabellenzelle(n) selektiert?
2649 			if ( rSh.IsTableMode() )
2650 			{
2651 				//Hintergrundattribute der Tabelle holen und in den Set packen
2652 				SvxBrushItem aBrush(RES_BACKGROUND);
2653 				rSh.GetBoxBackground( aBrush );
2654                 pDlg = pFact->CreateSfxDialog( pMDI, aSet,
2655 					rView.GetViewFrame()->GetFrame().GetFrameInterface(),
2656 					RC_SWDLG_BACKGROUND );
2657                 DBG_ASSERT(pDlg, "Dialogdiet fail!");
2658 				aSet.Put( aBrush );
2659 				if ( pDlg->Execute() == RET_OK )
2660 				{
2661 					//aBrush = (SvxBrushItem) pDlg->GetOutputItemSet()->Get( RES_BACKGROUND );
2662 
2663 					rSh.SetBoxBackground( (SvxBrushItem&)
2664 						pDlg->GetOutputItemSet()->Get( RES_BACKGROUND ));
2665 					pOutSet = pDlg->GetOutputItemSet();
2666 				}
2667 			}
2668 			else if ( rSh.IsFrmSelected() )
2669 			{
2670 
2671 				rSh.GetFlyFrmAttr( aSet );
2672 
2673                 pDlg = pFact->CreateSfxDialog( pMDI, aSet,
2674 					rView.GetViewFrame()->GetFrame().GetFrameInterface(),
2675 					RC_SWDLG_BACKGROUND );
2676                 DBG_ASSERT(pDlg, "Dialogdiet fail!");
2677 				if ( pDlg->Execute() == RET_OK )
2678 				{
2679 					rSh.SetFlyFrmAttr((SfxItemSet &) *pDlg->GetOutputItemSet() );
2680 					pOutSet = pDlg->GetOutputItemSet();
2681 				}
2682 			}
2683 			else
2684 			{
2685 				// Umrandungsattribute ganz normal ueber Shell setzen
2686                 rSh.GetCurAttr( aSet );
2687 
2688                 pDlg = pFact->CreateSfxDialog( pMDI, aSet,
2689 					rView.GetViewFrame()->GetFrame().GetFrameInterface(),
2690 					RC_SWDLG_BACKGROUND );
2691                 DBG_ASSERT(pDlg, "Dialogdiet fail!");
2692 				if ( pDlg->Execute() == RET_OK )
2693 				{
2694 					rSh.SetAttrSet( *pDlg->GetOutputItemSet() );
2695 					pOutSet = pDlg->GetOutputItemSet();
2696 				}
2697 			}
2698             if(pOutSet)
2699             {
2700                 rReq.Done(*pOutSet);
2701                 bDone = true;
2702             }
2703             delete pDlg;
2704 
2705 		}
2706 		break;
2707 		default:DBG_ERROR("falscher Dispatcher (basesh.cxx)");
2708 	}
2709     if(!bDone)
2710         rReq.Done();
2711 }
2712 
2713 // ----------------------------------------------------------------------------
2714 
2715 
2716 SwWrtShell& SwBaseShell::GetShell()
2717 {
2718 	return rView.GetWrtShell();
2719 }
2720 
2721 // ----------------------------------------------------------------------------
2722 
2723 SwWrtShell* SwBaseShell::GetShellPtr()
2724 {
2725 	return rView.GetWrtShellPtr();
2726 }
2727 
2728 // ----------------------------------------------------------------------------
2729 
2730 void SwBaseShell::InsertTable( SfxRequest& _rRequest )
2731 {
2732 	const SfxItemSet* pArgs = _rRequest.GetArgs();
2733 	SwWrtShell& rSh = GetShell();
2734 
2735 	if ( !( rSh.GetFrmType( 0, sal_True ) & FRMTYPE_FOOTNOTE ) )
2736 	{
2737         SwView &rTempView = GetView(); // Da GetView() nach Shellwechsel nicht mehr geht
2738         sal_Bool bHTMLMode = 0 != (::GetHtmlMode(rTempView.GetDocShell())&HTMLMODE_ON);
2739 		sal_Bool bCallEndUndo = sal_False;
2740 
2741 		if( !pArgs && rSh.IsSelection() && !rSh.IsInClickToEdit() &&
2742             !rSh.IsTableMode() )
2743 		{
2744 			const SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig();
2745             SwInsertTableOptions aInsTblOpts = pModOpt->GetInsTblFlags(bHTMLMode);
2746 
2747 			rSh.StartUndo(UNDO_INSTABLE);
2748 			bCallEndUndo = sal_True;
2749 
2750             sal_Bool bInserted = rSh.TextToTable( aInsTblOpts, '\t', text::HoriOrientation::FULL );
2751 			rSh.EnterStdMode();
2752 			if (bInserted)
2753                 rTempView.AutoCaption(TABLE_CAP);
2754 	        _rRequest.Done();
2755 		}
2756 		else
2757 		{
2758 			sal_uInt16 nCols = 0;
2759 			sal_uInt16 nRows = 0;
2760             SwInsertTableOptions aInsTblOpts( tabopts::ALL_TBL_INS_ATTR, 1 );
2761             String aTableName, aAutoName;
2762 			SwTableAutoFmt* pTAFmt = 0;
2763 
2764 			if( pArgs && pArgs->Count() >= 2 )
2765 			{
2766 	            SFX_REQUEST_ARG( _rRequest, pName, SfxStringItem, FN_INSERT_TABLE, sal_False );
2767 	            SFX_REQUEST_ARG( _rRequest, pCols, SfxUInt16Item, SID_ATTR_TABLE_COLUMN, sal_False );
2768 	            SFX_REQUEST_ARG( _rRequest, pRows, SfxUInt16Item, SID_ATTR_TABLE_ROW, sal_False );
2769 	            SFX_REQUEST_ARG( _rRequest, pFlags, SfxInt32Item, FN_PARAM_1, sal_False );
2770 	            SFX_REQUEST_ARG( _rRequest, pAuto, SfxStringItem, FN_PARAM_2, sal_False );
2771 
2772 	            if ( pName )
2773 	                aTableName = pName->GetValue();
2774 	            if ( pCols )
2775 	                nCols = pCols->GetValue();
2776 	            if ( pRows )
2777 	                nRows = pRows->GetValue();
2778 	            if ( pAuto )
2779 	            {
2780 	                aAutoName = pAuto->GetValue();
2781 	                if ( aAutoName.Len() )
2782 	                {
2783 	                    SwTableAutoFmtTbl aTableTbl;
2784 	                    aTableTbl.Load();
2785 	                    for ( sal_uInt16 n=0; n<aTableTbl.Count(); n++ )
2786 	                    {
2787 	                        if ( aTableTbl[n]->GetName() == aAutoName )
2788 	                        {
2789 	                            pTAFmt = new SwTableAutoFmt( *aTableTbl[n] );
2790 	                            break;
2791 	                        }
2792 	                    }
2793 	                }
2794 	            }
2795 
2796 	            if ( pFlags )
2797                     aInsTblOpts.mnInsMode = (sal_uInt16) pFlags->GetValue();
2798                 else
2799 	            {
2800 	                const SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig();
2801                     aInsTblOpts = pModOpt->GetInsTblFlags(bHTMLMode);
2802                 }
2803 			}
2804 
2805 			if( !nCols || !nRows )
2806 			{
2807                 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
2808                 DBG_ASSERT(pFact, "Dialogdiet fail!");
2809                 AbstractInsTableDlg* pDlg = pFact->CreateInsTableDlg( DLG_INSERT_TABLE, rTempView );
2810                 DBG_ASSERT(pDlg, "Dialogdiet fail!");
2811                 if( RET_OK == pDlg->Execute() )
2812 				{
2813 	                pDlg->GetValues( aTableName, nRows, nCols, aInsTblOpts, aAutoName, pTAFmt );
2814 				}
2815 	            else
2816 	                _rRequest.Ignore();
2817 				delete pDlg;
2818             }
2819 
2820 			if( nCols && nRows )
2821 			{
2822 	            // record before shell change
2823 	            _rRequest.AppendItem( SfxStringItem( FN_INSERT_TABLE, aTableName ) );
2824 	            if ( aAutoName.Len() )
2825 	                _rRequest.AppendItem( SfxStringItem( FN_PARAM_2, aAutoName ) );
2826 	            _rRequest.AppendItem( SfxUInt16Item( SID_ATTR_TABLE_COLUMN, nCols ) );
2827 	            _rRequest.AppendItem( SfxUInt16Item( SID_ATTR_TABLE_ROW, nRows ) );
2828                 _rRequest.AppendItem( SfxInt32Item( FN_PARAM_1, (sal_Int32) aInsTblOpts.mnInsMode ) );
2829 	            _rRequest.Done();
2830 
2831 				rSh.StartUndo(UNDO_INSTABLE);
2832 				bCallEndUndo = sal_True;
2833 
2834 				rSh.StartAllAction();
2835 				if( rSh.HasSelection() )
2836 					rSh.DelRight();
2837 
2838                 rSh.InsertTable( aInsTblOpts, nRows, nCols, text::HoriOrientation::FULL, pTAFmt );
2839 				rSh.MoveTable( fnTablePrev, fnTableStart );
2840 
2841 				if( aTableName.Len() && !rSh.GetTblStyle( aTableName ) )
2842 					rSh.GetTableFmt()->SetName( aTableName );
2843 
2844 				rSh.EndAllAction();
2845                 rTempView.AutoCaption(TABLE_CAP);
2846 			}
2847 			delete pTAFmt;
2848 		}
2849 
2850 		if( bCallEndUndo )
2851         {
2852             SwRewriter aRewriter;
2853 
2854             if (rSh.GetTableFmt())
2855             {
2856                 aRewriter.AddRule(UNDO_ARG1, SW_RES(STR_START_QUOTE));
2857                 aRewriter.AddRule(UNDO_ARG2, rSh.GetTableFmt()->GetName());
2858                 aRewriter.AddRule(UNDO_ARG3, SW_RES(STR_END_QUOTE));
2859 
2860             }
2861             rSh.EndUndo(UNDO_INSTABLE, &aRewriter);	// wegen moegl. Shellwechsel
2862         }
2863 	}
2864 }
2865 
2866 // ----------------------------------------------------------------------------
2867 
2868 void SwBaseShell::GetGalleryState( SfxItemSet &rSet )
2869 {
2870 	SwWrtShell &rSh = GetShell();
2871 	SfxWhichIter aIter( rSet );
2872 	sal_uInt16 nWhich = aIter.FirstWhich();
2873 	switch ( nWhich )
2874 	{
2875 		case SID_GALLERY_BG_BRUSH:
2876 		{
2877 			int nSel = rSh.GetSelectionType();
2878 			SfxStringListItem aLst( nWhich );
2879 			List *pLst = aLst.GetList();
2880 			nParagraphPos = nGraphicPos = nOlePos = nFramePos = nTablePos =
2881 			nTableRowPos  = nTableCellPos = nPagePos =
2882 			nHeaderPos 	  = nFooterPos = 0;
2883 			sal_uInt8 nPos = 1;
2884 			pLst->Insert( (void*) new SW_RESSTR( STR_SWBG_PAGE ), pLst->Count() );
2885 			nPagePos = nPos++;
2886 			sal_uInt16 nHtmlMode = ::GetHtmlMode(GetView().GetDocShell());
2887 			sal_Bool bHtmlMode = 0 != (nHtmlMode & HTMLMODE_ON);
2888 
2889 			if ( (!bHtmlMode || (nHtmlMode & HTMLMODE_FULL_STYLES)) &&
2890 				 (nSel & nsSelectionType::SEL_TXT) )
2891 			{
2892 				pLst->Insert( (void*) new SW_RESSTR( STR_SWBG_PARAGRAPH ), pLst->Count() );
2893 				nParagraphPos = nPos++;
2894 			}
2895 			if ( (!bHtmlMode || (nHtmlMode & HTMLMODE_SOME_STYLES)) &&
2896 					nSel & (nsSelectionType::SEL_TBL|nsSelectionType::SEL_TBL_CELLS) )
2897 			{
2898 				pLst->Insert( (void*) new SW_RESSTR( STR_SWBG_TABLE ), pLst->Count() );
2899 				nTablePos = nPos++;
2900 
2901 				if(!bHtmlMode)
2902 				{
2903 					pLst->Insert( (void*) new SW_RESSTR( STR_SWBG_TABLE_ROW ), pLst->Count() );
2904 					nTableRowPos = nPos++;
2905 				}
2906 
2907 				pLst->Insert( (void*) new SW_RESSTR( STR_SWBG_TABLE_CELL), pLst->Count() );
2908 				nTableCellPos = nPos++;
2909 			}
2910 			if(!bHtmlMode)
2911 			{
2912 				if ( nSel & nsSelectionType::SEL_FRM )
2913 				{
2914 					pLst->Insert( (void*) new SW_RESSTR( STR_SWBG_FRAME ), pLst->Count() );
2915 					nFramePos = nPos++;
2916 				}
2917 				if ( nSel & nsSelectionType::SEL_GRF )
2918 				{
2919 					pLst->Insert( (void*) new SW_RESSTR( STR_SWBG_GRAPHIC ), pLst->Count() );
2920 					nGraphicPos = nPos++;
2921 				}
2922 				if ( nSel & nsSelectionType::SEL_OLE )
2923 				{
2924 					pLst->Insert( (void*) new SW_RESSTR( STR_SWBG_OLE ), pLst->Count() );
2925 					nOlePos = nPos++;
2926 				}
2927 				const sal_uInt16 nType = rSh.GetFrmType(0,sal_True);
2928 				if ( nType & FRMTYPE_HEADER )
2929 				{
2930 					pLst->Insert( (void*) new SW_RESSTR( STR_SWBG_HEADER ), pLst->Count() );
2931 					nHeaderPos = nPos++;
2932 				}
2933 				if ( nType & FRMTYPE_FOOTER )
2934 				{
2935 					pLst->Insert( (void*) new SW_RESSTR( STR_SWBG_FOOTER ), pLst->Count() );
2936 					nFooterPos = nPos;
2937 				}
2938 			}
2939 			if ( pLst->Count() )
2940 				rSet.Put( aLst );
2941 			else
2942 				rSet.DisableItem( nWhich );
2943 			break;
2944 		}
2945 	}
2946 }
2947 
2948 
2949 void SwBaseShell::ExecuteGallery(SfxRequest &rReq)
2950 {
2951 	SwWrtShell &rSh = GetShell();
2952 	rSh.StartAction();
2953 	const SfxItemSet* pArgs = rReq.GetArgs();
2954 	sal_uInt16 nSlot = rReq.GetSlot();
2955 	switch(nSlot)
2956 	{
2957 		case SID_GALLERY_BG_BRUSH:
2958 		{
2959             if ( !pArgs )
2960                 break;
2961 
2962 			int nSel = rSh.GetSelectionType();
2963 			if ( nSel & nsSelectionType::SEL_DRW_TXT )
2964 				break;
2965 
2966             SFX_REQUEST_ARG( rReq, pPos, SfxUInt16Item, SID_GALLERY_BG_POS, sal_False );
2967             SFX_REQUEST_ARG( rReq, pBrush, SvxBrushItem, SID_GALLERY_BG_BRUSH, sal_False );
2968             if ( !pPos || !pBrush )
2969                 break;
2970 
2971 			sal_uInt8 nPos = pPos->GetValue();
2972 			++nPos;
2973 
2974 			SvxBrushItem aBrush( *pBrush );
2975 			aBrush.SetWhich( RES_BACKGROUND );
2976 			if ( nPos == nParagraphPos )
2977 				rSh.SetAttrItem( aBrush );
2978 			else if ( nPos == nTablePos )
2979 				rSh.SetTabBackground( aBrush );
2980 			else if ( nPos == nTableRowPos )
2981 				rSh.SetRowBackground( aBrush );
2982 			else if ( nPos == nTableCellPos )
2983 				rSh.SetBoxBackground( aBrush );
2984 			else if ( nPos == nFramePos || nPos == nGraphicPos || nPos == nOlePos )
2985 			{
2986 				SfxItemSet aCoreSet(GetPool(), RES_BACKGROUND, RES_BACKGROUND);
2987 				aCoreSet.Put( aBrush );
2988 				rSh.SetFlyFrmAttr( aCoreSet );
2989 			}
2990 			else if ( nPos == nPagePos || nPos == nHeaderPos || nPos == nFooterPos )
2991 			{
2992 				sal_uInt16 nDesc = rSh.GetCurPageDesc();
2993 				SwPageDesc aDesc( rSh.GetPageDesc( nDesc ) );
2994 				if ( nPos == nPagePos )
2995                     aDesc.GetMaster().SetFmtAttr( aBrush );
2996 				else if ( nPos == nHeaderPos )
2997 				{
2998 					SwFmtHeader aHead( aDesc.GetMaster().GetHeader() );
2999                     aHead.GetHeaderFmt()->SetFmtAttr( aBrush );
3000                     aDesc.GetMaster().SetFmtAttr( aHead );
3001 				}
3002 				else if ( nPos == nFooterPos )
3003 				{
3004 					SwFmtFooter aFoot( aDesc.GetMaster().GetFooter() );
3005                     aFoot.GetFooterFmt()->SetFmtAttr( aBrush );
3006                     aDesc.GetMaster().SetFmtAttr( aFoot );
3007 				}
3008 				rSh.ChgPageDesc( nDesc, aDesc );
3009 			}
3010 			break;
3011 		}
3012 	}
3013 	rSh.EndAction();
3014     rReq.Done();
3015 }
3016 
3017 void SwBaseShell::ExecField( SfxRequest& rReq )
3018 {
3019 	sal_uInt16 nSlot = rReq.GetSlot();
3020 	switch( nSlot )
3021 	{
3022 		case FN_CHANGE_DBFIELD:
3023 		{
3024             SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
3025             DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
3026 
3027             VclAbstractDialog* pDlg = pFact->CreateSwChangeDBDlg(GetView(), DLG_CHANGE_DB );
3028             DBG_ASSERT(pDlg, "Dialogdiet fail!");
3029 			pDlg->Execute();
3030 			delete pDlg;
3031 		}
3032 		break;
3033 		default:
3034 			ASSERT(sal_False, falscher Dispatcher);
3035 	}
3036 }
3037 
3038