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