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