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