LCOV - code coverage report
Current view: top level - sw/source/core/uibase/shells - basesh.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 191 1484 12.9 %
Date: 2014-04-11 Functions: 19 42 45.2 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10