LCOV - code coverage report
Current view: top level - libreoffice/sw/source/ui/wrtsh - wrtsh1.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 56 786 7.1 %
Date: 2012-12-17 Functions: 10 48 20.8 %
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             : 
      21             : #include <com/sun/star/container/XChild.hpp>
      22             : #include <com/sun/star/embed/XVisualObject.hpp>
      23             : #include <com/sun/star/embed/EmbedMisc.hpp>
      24             : #include <com/sun/star/embed/EmbedStates.hpp>
      25             : #include <com/sun/star/beans/XPropertySet.hpp>
      26             : #include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
      27             : #include <com/sun/star/chart2/XChartDocument.hpp>
      28             : #include <com/sun/star/util/XModifiable.hpp>
      29             : 
      30             : #include <svx/dialogs.hrc>
      31             : 
      32             : #include <math.h>
      33             : #include <hintids.hxx>
      34             : #include <svx/svdview.hxx>
      35             : #include <sot/factory.hxx>
      36             : #include <svl/itemiter.hxx>
      37             : #include <tools/bigint.hxx>
      38             : #include <sot/storage.hxx>
      39             : #include <svtools/insdlg.hxx>
      40             : #include <sfx2/frmdescr.hxx>
      41             : #include <sfx2/ipclient.hxx>
      42             : #include <svtools/ehdl.hxx>
      43             : #include <svtools/soerr.hxx>
      44             : #include <tools/cachestr.hxx>
      45             : #include <unotools/moduleoptions.hxx>
      46             : #include <editeng/sizeitem.hxx>
      47             : #include <editeng/brkitem.hxx>
      48             : #include <editeng/svxacorr.hxx>
      49             : #include <editeng/ulspitem.hxx>
      50             : #include <vcl/graph.hxx>
      51             : #include <vcl/msgbox.hxx>
      52             : #include <sfx2/printer.hxx>
      53             : #include <unotools/charclass.hxx>
      54             : #include <comphelper/storagehelper.hxx>
      55             : #include <svx/svxdlg.hxx>
      56             : #include <svx/extrusionbar.hxx>
      57             : #include <svx/fontworkbar.hxx>
      58             : #include <frmfmt.hxx>
      59             : #include <fmtftn.hxx>
      60             : #include <fmthdft.hxx>
      61             : #include <fmtpdsc.hxx>
      62             : #include <wdocsh.hxx>
      63             : #include <basesh.hxx>
      64             : #include <swmodule.hxx>
      65             : #include <wrtsh.hxx>
      66             : #include <view.hxx>
      67             : #include <uitool.hxx>
      68             : #include <cmdid.h>
      69             : #include <cfgitems.hxx>
      70             : #include <pagedesc.hxx>
      71             : #include <frmmgr.hxx>
      72             : #include <shellio.hxx>
      73             : #include <uinums.hxx>  // fuer Anwenden einer
      74             : #include <swundo.hxx>  // fuer Undo-Ids
      75             : #include <swcli.hxx>
      76             : #include <poolfmt.hxx>
      77             : #include <wview.hxx>
      78             : #include <edtwin.hxx>
      79             : #include <fmtcol.hxx>
      80             : #include <swtable.hxx>
      81             : #include <caption.hxx>
      82             : #include <viscrs.hxx>
      83             : #include <swdtflvr.hxx>
      84             : #include <crsskip.hxx>
      85             : #include <doc.hxx>
      86             : #include <wrtsh.hrc>
      87             : #include <SwStyleNameMapper.hxx>
      88             : #include <sfx2/request.hxx>
      89             : #include <paratr.hxx>
      90             : #include <ndtxt.hxx>
      91             : #include <editeng/acorrcfg.hxx>
      92             : #include <IMark.hxx>
      93             : #include <sfx2/bindings.hxx>
      94             : #include <svx/dialmgr.hxx>
      95             : 
      96             : // -> #111827#
      97             : #include <SwRewriter.hxx>
      98             : #include <comcore.hrc>
      99             : // <- #111827#
     100             : 
     101             : #include <toolkit/helper/vclunohelper.hxx>
     102             : #include <sfx2/viewfrm.hxx>
     103             : 
     104             : #include "PostItMgr.hxx"
     105             : #include <sfx2/msgpool.hxx>
     106             : 
     107             : using namespace sw::mark;
     108             : using namespace com::sun::star;
     109             : 
     110             : #define COMMON_INI_LIST \
     111             :         fnDrag(&SwWrtShell::BeginDrag),\
     112             :         fnSetCrsr(&SwWrtShell::SetCrsr),\
     113             :         fnEndDrag(&SwWrtShell::EndDrag),\
     114             :         fnKillSel(&SwWrtShell::Ignore),\
     115             :         pModeStack(0), \
     116             :         ePageMove(MV_NO),\
     117             :         pCrsrStack(0),  \
     118             :         rView(rShell),\
     119             :         aNavigationMgr(*this), \
     120             :         bDestOnStack(sal_False)
     121             : 
     122             : #define BITFLD_INI_LIST \
     123             :         bClearMark = \
     124             :         bIns = sal_True;\
     125             :         bAddMode = \
     126             :         bBlockMode = \
     127             :         bExtMode = \
     128             :         bInSelect = \
     129             :         bCopy = \
     130             :         bLayoutMode = \
     131             :         bNoEdit = \
     132             :         bSelWrd = \
     133             :         bSelLn = \
     134             :         bIsInClickToEdit = \
     135             :         mbRetainSelection = sal_False;
     136             : 
     137             : 
     138           0 : static SvxAutoCorrect* lcl_IsAutoCorr()
     139             : {
     140           0 :     SvxAutoCorrect* pACorr = SvxAutoCorrCfg::Get().GetAutoCorrect();
     141           0 :     if( pACorr && !pACorr->IsAutoCorrFlag( CptlSttSntnc | CptlSttWrd |
     142             :                             AddNonBrkSpace | ChgOrdinalNumber |
     143           0 :                             ChgToEnEmDash | SetINetAttr | Autocorrect ))
     144           0 :         pACorr = 0;
     145           0 :     return pACorr;
     146             : }
     147             : 
     148           0 : void SwWrtShell::NoEdit(sal_Bool bHideCrsr)
     149             : {
     150           0 :     if(bHideCrsr)
     151           0 :         HideCrsr();
     152           0 :     bNoEdit = sal_True;
     153           0 : }
     154             : 
     155             : 
     156             : 
     157           0 : void SwWrtShell::Edit()
     158             : {
     159           0 :     if (CanInsert())
     160             :     {
     161           0 :         ShowCrsr();
     162           0 :         bNoEdit = sal_False;
     163             :     }
     164           0 : }
     165             : 
     166             : 
     167             : 
     168           0 : sal_Bool SwWrtShell::IsEndWrd()
     169             : {
     170           0 :     SwMvContext aMvContext(this);
     171           0 :     if(IsEndPara() && !IsSttPara())
     172           0 :         return sal_True;
     173             : 
     174           0 :     return IsEndWord();
     175             : }
     176             : 
     177             : 
     178             : /*------------------------------------------------------------------------
     179             :  Beschreibung:  String einfuegen
     180             : ------------------------------------------------------------------------*/
     181             : 
     182           0 : void SwWrtShell::InsertByWord( const String & rStr)
     183             : {
     184           0 :     if( rStr.Len() )
     185             :     {
     186           0 :         sal_Bool bDelim = GetAppCharClass().isLetterNumeric( rStr, 0 );
     187           0 :         xub_StrLen nPos = 0, nStt = 0;
     188           0 :         for( ; nPos < rStr.Len(); nPos++ )
     189             :            {
     190           0 :             sal_Bool bTmpDelim = GetAppCharClass().isLetterNumeric( rStr, nPos );
     191           0 :             if( bTmpDelim != bDelim )
     192             :             {
     193           0 :                 Insert( rStr.Copy( nStt, nPos - nStt ));
     194           0 :                 nStt = nPos;
     195             :             }
     196             :         }
     197           0 :         if( nStt != nPos )
     198           0 :             Insert( rStr.Copy( nStt, nPos - nStt ));
     199             :     }
     200           0 : }
     201             : 
     202             : 
     203           0 : void SwWrtShell::Insert( const String &rStr )
     204             : {
     205           0 :     ResetCursorStack();
     206           0 :     if( !CanInsert() )
     207           0 :         return;
     208             : 
     209           0 :     sal_Bool bStarted = sal_False, bHasSel = HasSelection(),
     210           0 :         bCallIns = bIns /*|| bHasSel*/;
     211           0 :     bool bDeleted = false;
     212             : 
     213           0 :     if( bHasSel || ( !bIns && SelectHiddenRange() ) )
     214             :     {
     215             :             // nur hier klammern, da das normale Insert schon an der
     216             :             // Editshell geklammert ist
     217           0 :         StartAllAction();
     218             : 
     219             :         // #111827#
     220           0 :         SwRewriter aRewriter;
     221             : 
     222           0 :         aRewriter.AddRule(UndoArg1, GetCrsrDescr());
     223           0 :         aRewriter.AddRule(UndoArg2, String(SW_RES(STR_YIELDS)));
     224             :         {
     225           0 :             String aTmpStr;
     226           0 :             aTmpStr += String(SW_RES(STR_START_QUOTE));
     227           0 :             aTmpStr += rStr;
     228           0 :             aTmpStr += String(SW_RES(STR_END_QUOTE));
     229             : 
     230           0 :             aRewriter.AddRule(UndoArg3, rStr);
     231             :         }
     232             : 
     233           0 :         StartUndo(UNDO_REPLACE, &aRewriter);
     234           0 :         bStarted = sal_True;
     235           0 :         bDeleted = DelRight() != 0;
     236             :     }
     237             : 
     238             :     bCallIns ?
     239           0 :         SwEditShell::Insert2( rStr, bDeleted ) : SwEditShell::Overwrite( rStr );
     240             : 
     241             : 
     242           0 :     if( bStarted )
     243             :     {
     244           0 :         EndAllAction();
     245           0 :         EndUndo();
     246             :     }
     247             : }
     248             : 
     249             : /* Begrenzung auf maximale Hoehe geht nicht, da die maximale Hoehe
     250             :  * des aktuellen Frames nicht erfragt werden kann. */
     251             : 
     252             : 
     253             : 
     254           0 : void SwWrtShell::Insert( const String &rPath, const String &rFilter,
     255             :                          const Graphic &rGrf, SwFlyFrmAttrMgr *pFrmMgr,
     256             :                          sal_Bool bRule )
     257             : {
     258           0 :     ResetCursorStack();
     259           0 :     if ( !CanInsert() )
     260           0 :         return;
     261             : 
     262           0 :     StartAllAction();
     263             : 
     264           0 :     SwRewriter aRewriter;
     265           0 :     aRewriter.AddRule(UndoArg1, SW_RES(STR_GRAPHIC));
     266             : 
     267           0 :     StartUndo(UNDO_INSERT, &aRewriter);
     268             : 
     269           0 :     if ( HasSelection() )
     270           0 :         DelRight();
     271             :         // eingefuegte Grafik in eigenen Absatz, falls am Ende
     272             :         // eines nichtleeren Absatzes
     273           0 :     if ( IsEndPara() && !IsSttPara() )
     274           0 :         SwFEShell::SplitNode();
     275             : 
     276           0 :     EnterSelFrmMode();
     277             : 
     278           0 :     sal_Bool bSetGrfSize = sal_True;
     279           0 :     sal_Bool bOwnMgr     = sal_False;
     280             : 
     281           0 :     if ( !pFrmMgr )
     282             :     {
     283           0 :         bOwnMgr = sal_True;
     284           0 :         pFrmMgr = new SwFlyFrmAttrMgr( sal_True, this, FRMMGR_TYPE_GRF );
     285             : 
     286             :         // VORSICHT
     287             :         // GetAttrSet nimmt einen Abgleich vor
     288             :         // Beim Einfuegen ist eine SwFrmSize vorhanden wegen der
     289             :         // DEF-Rahmengroesse
     290             :         // Diese muss fuer die optimale Groesse explizit entfernt werden
     291           0 :         pFrmMgr->DelAttr(RES_FRM_SIZE);
     292             :     }
     293             :     else
     294             :     {
     295           0 :         Size aSz( pFrmMgr->GetSize() );
     296           0 :         if ( !aSz.Width() || !aSz.Height() )
     297             :         {
     298           0 :             aSz.Width() = aSz.Height() = 567;
     299           0 :             pFrmMgr->SetSize( aSz );
     300             :         }
     301           0 :         else if ( aSz.Width() != DFLT_WIDTH && aSz.Height() != DFLT_HEIGHT )
     302           0 :             bSetGrfSize = sal_False;
     303             : 
     304           0 :         pFrmMgr->SetHeightSizeType(ATT_FIX_SIZE);
     305             : 
     306             :     }
     307             : 
     308             :     // Einfuegen der Grafik
     309           0 :     SwFEShell::Insert(rPath, rFilter, &rGrf, &pFrmMgr->GetAttrSet());
     310           0 :     if ( bOwnMgr )
     311           0 :         pFrmMgr->UpdateAttrMgr();
     312             : 
     313           0 :     if( bSetGrfSize && !bRule )
     314             :     {
     315           0 :         Size aGrfSize, aBound = GetGraphicDefaultSize();
     316           0 :         GetGrfSize( aGrfSize );
     317             : 
     318             :         //Die GrafikSize noch um die Randattribute vergroessern, denn die
     319             :         //Zaehlen beim Rahmen mit.
     320           0 :         aGrfSize.Width() += pFrmMgr->CalcWidthBorder();
     321           0 :         aGrfSize.Height()+= pFrmMgr->CalcHeightBorder();
     322             : 
     323           0 :         const BigInt aTempWidth( aGrfSize.Width() );
     324           0 :         const BigInt aTempHeight( aGrfSize.Height());
     325             : 
     326             :         // ggf. Breite anpassen, Hoehe dann proportional verkleinern
     327           0 :         if( aGrfSize.Width() > aBound.Width() )
     328             :         {
     329           0 :             aGrfSize.Width()  = aBound.Width();
     330           0 :             aGrfSize.Height() = ((BigInt)aBound.Width()) * aTempHeight / aTempWidth;
     331             :         }
     332             :         // ggf. Hoehe anpassen, Breite dann proportional verkleinern
     333           0 :         if( aGrfSize.Height() > aBound.Height() )
     334             :         {
     335           0 :             aGrfSize.Height() = aBound.Height();
     336           0 :             aGrfSize.Width() =  ((BigInt)aBound.Height()) * aTempWidth / aTempHeight;
     337             :         }
     338           0 :         pFrmMgr->SetSize( aGrfSize );
     339           0 :         pFrmMgr->UpdateFlyFrm();
     340             :     }
     341           0 :     if ( bOwnMgr )
     342           0 :         delete pFrmMgr;
     343             : 
     344           0 :     EndUndo();
     345           0 :     EndAllAction();
     346             : }
     347             : 
     348             : 
     349             : /*------------------------------------------------------------------------
     350             :    Beschreibung: Fuegt ein OLE-Objekt in die CORE ein.
     351             :                  Wenn kein Object uebergeben wird, so wird eins erzeugt.
     352             : ------------------------------------------------------------------------*/
     353             : 
     354             : 
     355           0 : void SwWrtShell::InsertObject( const svt::EmbeddedObjectRef& xRef, SvGlobalName *pName,
     356             :                             sal_Bool bActivate, sal_uInt16 nSlotId )
     357             : {
     358           0 :     ResetCursorStack();
     359           0 :     if( !CanInsert() )
     360           0 :         return;
     361             : 
     362           0 :     if( !xRef.is() )
     363             :     {
     364             :         // temporary storage
     365           0 :         svt::EmbeddedObjectRef xObj;
     366           0 :         uno::Reference < embed::XStorage > xStor = comphelper::OStorageHelper::GetTemporaryStorage();
     367           0 :         sal_Bool bDoVerb = sal_True;
     368           0 :         if ( pName )
     369             :         {
     370           0 :             comphelper::EmbeddedObjectContainer aCnt( xStor );
     371           0 :             ::rtl::OUString aName;
     372             :             // TODO/LATER: get aspect?
     373           0 :             xObj.Assign( aCnt.CreateEmbeddedObject( pName->GetByteSequence(), aName ), embed::Aspects::MSOLE_CONTENT );
     374             :         }
     375             :         else
     376             :         {
     377           0 :             SvObjectServerList aServerList;
     378           0 :             switch (nSlotId)
     379             :             {
     380             :                 case SID_INSERT_OBJECT:
     381             :                 {
     382           0 :                     aServerList.FillInsertObjects();
     383           0 :                     aServerList.Remove( SwDocShell::Factory().GetClassId() );
     384             :                     // Intentionally no break!
     385             :                 }
     386             : 
     387             :                 // TODO/LATER: recording! Convert properties to items
     388             :                 case SID_INSERT_PLUGIN:
     389             :                 case SID_INSERT_FLOATINGFRAME:
     390             :                 {
     391           0 :                     SfxSlotPool* pSlotPool = SW_MOD()->GetSlotPool();
     392           0 :                     const SfxSlot* pSlot = pSlotPool->GetSlot(nSlotId);
     393           0 :                     rtl::OString aCmd(".uno:");
     394           0 :                     aCmd += pSlot->GetUnoName();
     395           0 :                     SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     396             :                     SfxAbstractInsertObjectDialog* pDlg =
     397           0 :                             pFact->CreateInsertObjectDialog( GetWin(), rtl::OStringToOUString( aCmd, RTL_TEXTENCODING_UTF8 ), xStor, &aServerList );
     398           0 :                     if ( pDlg )
     399             :                     {
     400           0 :                         pDlg->Execute();
     401           0 :                         bDoVerb = pDlg->IsCreateNew();
     402           0 :                         ::rtl::OUString aIconMediaType;
     403           0 :                         uno::Reference< io::XInputStream > xIconMetaFile = pDlg->GetIconIfIconified( &aIconMediaType );
     404           0 :                         xObj.Assign( pDlg->GetObject(),
     405           0 :                                      xIconMetaFile.is() ? embed::Aspects::MSOLE_ICON : embed::Aspects::MSOLE_CONTENT );
     406           0 :                         if ( xIconMetaFile.is() )
     407           0 :                             xObj.SetGraphicStream( xIconMetaFile, aIconMediaType );
     408             : 
     409           0 :                         DELETEZ( pDlg );
     410             :                     }
     411             : 
     412           0 :                     break;
     413             :                 }
     414             : 
     415             :                 default:
     416           0 :                     break;
     417           0 :             }
     418             :         }
     419             : 
     420           0 :         if ( xObj.is() )
     421             :         {
     422           0 :             if( InsertOleObject( xObj ) && bActivate && bDoVerb )
     423             :             {
     424           0 :                 SfxInPlaceClient* pClient = GetView().FindIPClient( xObj.GetObject(), &GetView().GetEditWin() );
     425           0 :                 if ( !pClient )
     426             :                 {
     427           0 :                     pClient = new SwOleClient( &GetView(), &GetView().GetEditWin(), xObj );
     428           0 :                     SetCheckForOLEInCaption( sal_True );
     429             :                 }
     430             : 
     431           0 :                 if ( xObj.GetViewAspect() == embed::Aspects::MSOLE_ICON )
     432             :                 {
     433           0 :                     SwRect aArea = GetAnyCurRect( RECT_FLY_PRT_EMBEDDED, 0, xObj.GetObject() );
     434           0 :                     aArea.Pos() += GetAnyCurRect( RECT_FLY_EMBEDDED, 0, xObj.GetObject() ).Pos();
     435           0 :                     MapMode aMapMode( MAP_TWIP );
     436           0 :                     Size aSize = xObj.GetSize( &aMapMode );
     437           0 :                     aArea.Width( aSize.Width() );
     438           0 :                     aArea.Height( aSize.Height() );
     439           0 :                     RequestObjectResize( aArea, xObj.GetObject() );
     440             :                 }
     441             :                 else
     442           0 :                     CalcAndSetScale( xObj );
     443             : 
     444             :                 //#50270# Error brauchen wir nicht handeln, das erledigt das
     445             :                 //DoVerb in der SfxViewShell
     446           0 :                 pClient->DoVerb( SVVERB_SHOW );
     447             : 
     448             :                 // TODO/LATER: set document name - should be done in Client
     449             :             }
     450           0 :         }
     451             :     }
     452             :     else
     453             :     {
     454           0 :         if( HasSelection() )
     455           0 :             DelRight();
     456           0 :         InsertOleObject( xRef );
     457             :     }
     458             : }
     459             : 
     460             : /*------------------------------------------------------------------------
     461             :  Beschreibung:   Object in die Core einfuegen.
     462             :                  Vom ClipBoard oder Insert
     463             : ------------------------------------------------------------------------*/
     464             : 
     465           0 : sal_Bool SwWrtShell::InsertOleObject( const svt::EmbeddedObjectRef& xRef, SwFlyFrmFmt **pFlyFrmFmt )
     466             : {
     467           0 :     ResetCursorStack();
     468           0 :     StartAllAction();
     469             : 
     470           0 :     StartUndo(UNDO_INSERT);
     471             : 
     472             :     //Some differences between StarMath and any other objects:
     473             :     //1. Selections should be deleted. For StarMath the Text should be
     474             :     //   passed to the Object
     475             :     //2. If the cursor is at the end of an non empty paragraph a paragraph
     476             :     //   break should be insertet. StarMath objects are character bound and
     477             :     //   no break should be inserted.
     478             :     //3. If an selektion is passed to a StarMath object, this object should
     479             :     //   not be activated. sal_False should be returned then.
     480           0 :     sal_Bool bStarMath = sal_True;
     481           0 :     sal_Bool bActivate = sal_True;
     482             : 
     483             :     // set parent to get correct VisArea(in case of object needing parent printer)
     484           0 :     uno::Reference < container::XChild > xChild( xRef.GetObject(), uno::UNO_QUERY );
     485           0 :     if ( xChild.is() )
     486           0 :         xChild->setParent( pDoc->GetDocShell()->GetModel() );
     487             : 
     488           0 :     SvGlobalName aCLSID( xRef->getClassID() );
     489           0 :     bStarMath = ( SotExchange::IsMath( aCLSID ) != 0 );
     490           0 :     if( IsSelection() )
     491             :     {
     492           0 :         if( bStarMath )
     493             :         {
     494           0 :             String aMathData;
     495           0 :             GetSelectedText( aMathData, GETSELTXT_PARABRK_TO_ONLYCR );
     496             : 
     497           0 :             if( aMathData.Len() && svt::EmbeddedObjectRef::TryRunningState( xRef.GetObject() ) )
     498             :             {
     499           0 :                 uno::Reference < beans::XPropertySet > xSet( xRef->getComponent(), uno::UNO_QUERY );
     500           0 :                 if ( xSet.is() )
     501             :                 {
     502             :                     try
     503             :                     {
     504           0 :                         xSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Formula")), uno::makeAny( ::rtl::OUString( aMathData ) ) );
     505           0 :                         bActivate = sal_False;
     506             :                     }
     507           0 :                     catch (const uno::Exception&)
     508             :                     {
     509             :                     }
     510           0 :                 }
     511           0 :             }
     512             :         }
     513           0 :         DelRight();
     514             :     }
     515             : 
     516           0 :     if ( !bStarMath )
     517           0 :         SwFEShell::SplitNode( sal_False, sal_False );
     518             : 
     519           0 :     EnterSelFrmMode();
     520             : 
     521           0 :     SwFlyFrmAttrMgr aFrmMgr( sal_True, this, FRMMGR_TYPE_OLE );
     522           0 :     aFrmMgr.SetHeightSizeType(ATT_FIX_SIZE);
     523             : 
     524           0 :     SwRect aBound;
     525           0 :     CalcBoundRect( aBound, aFrmMgr.GetAnchor() );
     526             : 
     527             :     //The Size should be suggested by the OLE server
     528           0 :     MapMode aMapMode( MAP_TWIP );
     529           0 :     Size aSz = xRef.GetSize( &aMapMode );
     530             : 
     531             :     //Object size can be limited
     532           0 :     if ( aSz.Width() > aBound.Width() )
     533             :     {
     534             :         //Immer proportional begrenzen.
     535           0 :         aSz.Height() = aSz.Height() * aBound.Width() / aSz.Width();
     536           0 :         aSz.Width() = aBound.Width();
     537             :     }
     538           0 :     aFrmMgr.SetSize( aSz );
     539           0 :     SwFlyFrmFmt *pFmt = SwFEShell::InsertObject( xRef, &aFrmMgr.GetAttrSet() );
     540             : 
     541             :     // --> #i972#
     542           0 :     if ( bStarMath && pDoc->get( IDocumentSettingAccess::MATH_BASELINE_ALIGNMENT ) )
     543           0 :         AlignFormulaToBaseline( xRef.GetObject() );
     544             : 
     545           0 :     if (pFlyFrmFmt)
     546           0 :         *pFlyFrmFmt = pFmt;
     547             : 
     548           0 :     if ( SotExchange::IsChart( aCLSID ) )
     549             :     {
     550           0 :         uno::Reference< embed::XEmbeddedObject > xEmbeddedObj( xRef.GetObject(), uno::UNO_QUERY );
     551           0 :         if ( xEmbeddedObj.is() )
     552             :         {
     553           0 :             bool bDisableDataTableDialog = false;
     554           0 :             svt::EmbeddedObjectRef::TryRunningState( xEmbeddedObj );
     555           0 :             uno::Reference< beans::XPropertySet > xProps( xEmbeddedObj->getComponent(), uno::UNO_QUERY );
     556           0 :             if ( xProps.is() &&
     557           0 :                  ( xProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DisableDataTableDialog" ) ) ) >>= bDisableDataTableDialog ) &&
     558             :                  bDisableDataTableDialog )
     559             :             {
     560           0 :                 xProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DisableDataTableDialog" ) ),
     561           0 :                     uno::makeAny( sal_False ) );
     562           0 :                 xProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DisableComplexChartTypes" ) ),
     563           0 :                     uno::makeAny( sal_False ) );
     564           0 :                 uno::Reference< util::XModifiable > xModifiable( xProps, uno::UNO_QUERY );
     565           0 :                 if ( xModifiable.is() )
     566             :                 {
     567           0 :                     xModifiable->setModified( sal_True );
     568           0 :                 }
     569           0 :             }
     570           0 :         }
     571             :     }
     572             : 
     573           0 :     EndAllAction();
     574           0 :     GetView().AutoCaption(OLE_CAP, &aCLSID);
     575             : 
     576           0 :     SwRewriter aRewriter;
     577             : 
     578           0 :     if ( bStarMath )
     579           0 :         aRewriter.AddRule(UndoArg1, SW_RES(STR_MATH_FORMULA));
     580           0 :     else if ( SotExchange::IsChart( aCLSID ) )
     581           0 :         aRewriter.AddRule(UndoArg1, SW_RES(STR_CHART));
     582             :     else
     583           0 :         aRewriter.AddRule(UndoArg1, SW_RES(STR_OLE));
     584             : 
     585           0 :     EndUndo(UNDO_INSERT, &aRewriter);
     586             : 
     587           0 :     return bActivate;
     588             : }
     589             : 
     590             : /*------------------------------------------------------------------------
     591             :     Beschreibung: Das aktuelle selektierte OLE-Objekt wird mit dem
     592             :                   Verb in den Server geladen.
     593             : ------------------------------------------------------------------------*/
     594             : 
     595             : 
     596             : 
     597           0 : void SwWrtShell::LaunchOLEObj( long nVerb )
     598             : {
     599           0 :     if ( GetCntType() == CNT_OLE &&
     600           0 :          !GetView().GetViewFrame()->GetFrame().IsInPlace() )
     601             :     {
     602           0 :         svt::EmbeddedObjectRef& xRef = GetOLEObject();
     603             :         OSL_ENSURE( xRef.is(), "OLE not found" );
     604           0 :         SfxInPlaceClient* pCli=0;
     605             : 
     606           0 :         pCli = GetView().FindIPClient( xRef.GetObject(), &GetView().GetEditWin() );
     607           0 :         if ( !pCli )
     608           0 :             pCli = new SwOleClient( &GetView(), &GetView().GetEditWin(), xRef );
     609             : 
     610           0 :         ((SwOleClient*)pCli)->SetInDoVerb( sal_True );
     611             : 
     612           0 :         CalcAndSetScale( xRef );
     613           0 :         pCli->DoVerb( nVerb );
     614             : 
     615           0 :         ((SwOleClient*)pCli)->SetInDoVerb( sal_False );
     616           0 :         CalcAndSetScale( xRef );
     617             :     }
     618           0 : }
     619             : 
     620           0 : void SwWrtShell::MoveObjectIfActive( svt::EmbeddedObjectRef& xObj, const Point& rOffset )
     621             : {
     622             :     try
     623             :     {
     624           0 :         sal_Int32 nState = xObj->getCurrentState();
     625           0 :         if ( nState == ::com::sun::star::embed::EmbedStates::INPLACE_ACTIVE
     626             :           || nState == ::com::sun::star::embed::EmbedStates::UI_ACTIVE )
     627             :         {
     628             :             SfxInPlaceClient* pCli =
     629           0 :                 GetView().FindIPClient( xObj.GetObject(), &(GetView().GetEditWin()) );
     630           0 :             if ( pCli )
     631             :             {
     632           0 :                 Rectangle aArea = pCli->GetObjArea();
     633           0 :                 aArea += rOffset;
     634           0 :                 pCli->SetObjArea( aArea );
     635             :             }
     636             :         }
     637             :     }
     638           0 :     catch (const uno::Exception&)
     639             :     {
     640             :     }
     641           0 : }
     642             : 
     643             : 
     644         572 : void SwWrtShell::CalcAndSetScale( svt::EmbeddedObjectRef& xObj,
     645             :                                   const SwRect *pFlyPrtRect,
     646             :                                   const SwRect *pFlyFrmRect,
     647             :                                   const bool bNoTxtFrmPrtAreaChanged )
     648             : {
     649             :     //Einstellen der Skalierung am Client. Diese ergibt sich aus der Differenz
     650             :     //zwischen der VisArea des Objektes und der ObjArea.
     651             :     OSL_ENSURE( xObj.is(), "ObjectRef not  valid" );
     652             : 
     653         572 :     sal_Int64 nAspect = xObj.GetViewAspect();
     654         572 :     if ( nAspect == embed::Aspects::MSOLE_ICON )
     655             :         return; // the replacement image is completely controlled by container in this case
     656             : 
     657         572 :     sal_Int64 nMisc = 0;
     658         572 :     sal_Bool bLinkingChart = sal_False;
     659             : 
     660             :     try
     661             :     {
     662         572 :         nMisc = xObj->getStatus( nAspect );
     663             : 
     664             :         //Das kann ja wohl nur ein nicht aktives Objekt sein. Diese bekommen
     665             :         //auf Wunsch die neue Groesse als VisArea gesetzt (StarChart)
     666         572 :         if( embed::EmbedMisc::MS_EMBED_RECOMPOSEONRESIZE & nMisc )
     667             :         {
     668             :             // TODO/MBA: testing
     669             :             SwRect aRect( pFlyPrtRect ? *pFlyPrtRect
     670           0 :                         : GetAnyCurRect( RECT_FLY_PRT_EMBEDDED, 0, xObj.GetObject() ));
     671           0 :             if( !aRect.IsEmpty() )
     672             :             {
     673             :                 // TODO/LEAN: getMapUnit can switch object to running state
     674             :                 // xObj.TryRunningState();
     675             : 
     676           0 :                 MapUnit aUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( nAspect ) );
     677             : 
     678             :                 // TODO/LATER: needs complete VisArea?!
     679           0 :                 Size aSize( OutputDevice::LogicToLogic( aRect.SVRect(), MAP_TWIP, aUnit ).GetSize() );
     680           0 :                 awt::Size aSz;
     681           0 :                 aSz.Width = aSize.Width();
     682           0 :                 aSz.Height = aSize.Height();
     683           0 :                 xObj->setVisualAreaSize( nAspect, aSz );
     684             :                 // #i48419# - action 'UpdateReplacement' doesn't
     685             :                 // have to change the modified state of the document.
     686             :                 // This is only a workaround for the defect, that this action
     687             :                 // modifies a document after load, because unnecessarily the
     688             :                 // replacement graphic is updated, in spite of the fact that
     689             :                 // nothing has been changed.
     690             :                 // If the replacement graphic changes by this action, the document
     691             :                 // will be already modified via other mechanisms.
     692             :                 {
     693           0 :                     bool bResetEnableSetModified(false);
     694           0 :                     if ( GetDoc()->GetDocShell()->IsEnableSetModified() )
     695             :                     {
     696           0 :                         GetDoc()->GetDocShell()->EnableSetModified( sal_False );
     697           0 :                         bResetEnableSetModified = true;
     698             :                     }
     699             : 
     700             :                     //#i79576# don't destroy chart replacement images on load
     701             :                     //#i79578# don't request a new replacement image for charts to often
     702             :                     //a chart sends a modified call to the framework if it was changed
     703             :                     //thus the replacement update is already handled elsewhere
     704           0 :                     if ( !SotExchange::IsChart( xObj->getClassID() ) )
     705           0 :                         xObj.UpdateReplacement();
     706             : 
     707           0 :                     if ( bResetEnableSetModified )
     708             :                     {
     709           0 :                         GetDoc()->GetDocShell()->EnableSetModified( sal_True );
     710             :                     }
     711             :                 }
     712             :             }
     713             : 
     714             :             // TODO/LATER: this is only a workaround,
     715           0 :             uno::Reference< chart2::XChartDocument > xChartDocument( xObj->getComponent(), uno::UNO_QUERY );
     716           0 :             bLinkingChart = ( xChartDocument.is() && !xChartDocument->hasInternalDataProvider() );
     717             :         }
     718             :     }
     719           0 :     catch (const uno::Exception&)
     720             :     {
     721             :         // TODO/LATER: handle the error
     722             :         return;
     723             :     }
     724             : 
     725         572 :     SfxInPlaceClient* pCli = GetView().FindIPClient( xObj.GetObject(), &GetView().GetEditWin() );
     726         572 :     if ( !pCli )
     727             :     {
     728         572 :         if ( (embed::EmbedMisc::EMBED_ACTIVATEIMMEDIATELY & nMisc)
     729             :              || bLinkingChart
     730             :             // TODO/LATER: ResizeOnPrinterChange
     731             :              //|| SVOBJ_MISCSTATUS_RESIZEONPRINTERCHANGE & xObj->GetMiscStatus()
     732             :              // --> OD #i117189# - refine condition for non-resizable objects
     733             :              // non-resizable objects need to be set the size back by this method
     734             :              || ( bNoTxtFrmPrtAreaChanged && nMisc & embed::EmbedMisc::EMBED_NEVERRESIZE ) )
     735             :         {
     736           0 :             pCli = new SwOleClient( &GetView(), &GetView().GetEditWin(), xObj );
     737             :         }
     738             :         else
     739             :             return;
     740             :     }
     741             : 
     742             :     // TODO/LEAN: getMapUnit can switch object to running state
     743             :     // xObj.TryRunningState();
     744             : 
     745           0 :     awt::Size aSize;
     746             :     try
     747             :     {
     748           0 :         aSize = xObj->getVisualAreaSize( nAspect );
     749             :     }
     750           0 :     catch (const embed::NoVisualAreaSizeException&)
     751             :     {
     752             :         OSL_FAIL("Can't get visual area size!\n" );
     753             :         // the scaling will not be done
     754             :     }
     755           0 :     catch (const uno::Exception&)
     756             :     {
     757             :         // TODO/LATER: handle the error
     758             :         OSL_FAIL("Can't get visual area size!\n" );
     759             :         return;
     760             :     }
     761             : 
     762           0 :     Size _aVisArea( aSize.Width, aSize.Height );
     763             : 
     764           0 :     Fraction aScaleWidth( 1, 1 );
     765           0 :     Fraction aScaleHeight( 1, 1 );
     766             : 
     767           0 :     sal_Bool bUseObjectSize = sal_False;
     768             : 
     769             :     // solange keine vernuenftige Size vom Object kommt, kann nichts
     770             :     // skaliert werden
     771           0 :     if( _aVisArea.Width() && _aVisArea.Height() )
     772             :     {
     773           0 :         const MapMode aTmp( MAP_TWIP );
     774           0 :         MapUnit aUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( nAspect ) );
     775           0 :         _aVisArea = OutputDevice::LogicToLogic( _aVisArea, aUnit, aTmp);
     776           0 :         Size aObjArea;
     777           0 :         if ( pFlyPrtRect )
     778           0 :             aObjArea = pFlyPrtRect->SSize();
     779             :         else
     780           0 :             aObjArea = GetAnyCurRect( RECT_FLY_PRT_EMBEDDED, 0, xObj.GetObject() ).SSize();
     781             : 
     782             :         // differ the aObjArea and _aVisArea by 1 Pixel then set new VisArea
     783             :         long nX, nY;
     784           0 :         SwSelPaintRects::Get1PixelInLogic( *this, &nX, &nY );
     785           0 :         if( !( _aVisArea.Width() - nX <= aObjArea.Width() &&
     786           0 :                _aVisArea.Width() + nX >= aObjArea.Width() &&
     787           0 :                _aVisArea.Height()- nY <= aObjArea.Height()&&
     788           0 :                _aVisArea.Height()+ nY >= aObjArea.Height() ))
     789             :         {
     790             :             // TODO/LATER: MISCSTATUS_RESIZEONPRINTERCHANGE
     791             :             /*
     792             :             if( SVOBJ_MISCSTATUS_RESIZEONPRINTERCHANGE & nMisc )
     793             :             {
     794             :                 //This type of objects should never be resized.
     795             :                 //If this request comes from the Writer core (inaktive Object
     796             :                 //ist resized), the Object should be resized too.
     797             :                 //If this request comes from the Object itself, the Frame
     798             :                 //in the Writer core should be resized.
     799             :                 if ( pFlyPrtRect )      //Request from core?
     800             :                 {
     801             :                     xObj->SetVisArea( OutputDevice::LogicToLogic(
     802             :                         pFlyPrtRect->SVRect(), MAP_TWIP, xObj->GetMapUnit() ));
     803             :                 }
     804             :                 else
     805             :                 {
     806             :                     SwRect aTmp( Point( LONG_MIN, LONG_MIN ), _aVisArea );
     807             :                     RequestObjectResize( aTmp, xObj );
     808             :                 }
     809             :                 //Der Rest erledigt sich, weil wir eh wiederkommen sollten, evtl.
     810             :                 //sogar rekursiv.
     811             :                 return;
     812             :             }
     813             :             else*/
     814             : 
     815           0 :             if ( nMisc & embed::EmbedMisc::EMBED_NEVERRESIZE )
     816             :             {
     817             :                 // the object must not be scaled, the size stored in object must be used for restoring
     818           0 :                 bUseObjectSize = sal_True;
     819             :             }
     820             :             else
     821             :             {
     822           0 :                 aScaleWidth = Fraction( aObjArea.Width(),   _aVisArea.Width() );
     823           0 :                 aScaleHeight = Fraction( aObjArea.Height(), _aVisArea.Height());
     824             :             }
     825           0 :         }
     826             :     }
     827             : 
     828             :     //Jetzt ist auch der guenstige Zeitpunkt die ObjArea einzustellen.
     829             :     //Die Scalierung muss beruecksichtigt werden.
     830           0 :     SwRect aArea;
     831           0 :     if ( pFlyPrtRect )
     832             :     {
     833           0 :         aArea = *pFlyPrtRect;
     834           0 :         aArea += pFlyFrmRect->Pos();
     835             :     }
     836             :     else
     837             :     {
     838           0 :         aArea = GetAnyCurRect( RECT_FLY_PRT_EMBEDDED, 0, xObj.GetObject() );
     839           0 :         aArea.Pos() += GetAnyCurRect( RECT_FLY_EMBEDDED, 0, xObj.GetObject() ).Pos();
     840             :     }
     841             : 
     842           0 :     if ( bUseObjectSize )
     843             :     {
     844             :         // --> this moves non-resizable object so that when adding borders the baseline remains the same
     845           0 :         const SwFlyFrmFmt *pFlyFrmFmt = dynamic_cast< const SwFlyFrmFmt * >( GetFlyFrmFmt() );
     846             :         OSL_ENSURE( pFlyFrmFmt, "Could not find fly frame." );
     847           0 :         if ( pFlyFrmFmt )
     848             :         {
     849           0 :             const Point &rPoint = pFlyFrmFmt->GetLastFlyFrmPrtRectPos();
     850             :             SwRect aRect( pFlyPrtRect ? *pFlyPrtRect
     851           0 :                         : GetAnyCurRect( RECT_FLY_PRT_EMBEDDED, 0, xObj.GetObject() ));
     852           0 :             aArea += rPoint - aRect.Pos(); // adjust area by diff of printing area position in order to keep baseline alignment correct.
     853             :         }
     854           0 :         aArea.Width ( _aVisArea.Width() );
     855           0 :         aArea.Height( _aVisArea.Height() );
     856           0 :         RequestObjectResize( aArea, xObj.GetObject() );
     857             :     }
     858             :     else
     859             :     {
     860           0 :         aArea.Width ( Fraction( aArea.Width()  ) / pCli->GetScaleWidth() );
     861           0 :         aArea.Height( Fraction( aArea.Height() ) / pCli->GetScaleHeight());
     862             :     }
     863             : 
     864           0 :     pCli->SetObjAreaAndScale( aArea.SVRect(), aScaleWidth, aScaleHeight );
     865             : }
     866             : 
     867             : 
     868             : 
     869           0 : void SwWrtShell::ConnectObj( svt::EmbeddedObjectRef& xObj, const SwRect &rPrt,
     870             :                             const SwRect &rFrm )
     871             : {
     872           0 :     SfxInPlaceClient* pCli = GetView().FindIPClient( xObj.GetObject(), &GetView().GetEditWin());
     873           0 :     if ( !pCli )
     874           0 :         pCli = new SwOleClient( &GetView(), &GetView().GetEditWin(), xObj );
     875           0 :     CalcAndSetScale( xObj, &rPrt, &rFrm );
     876           0 : }
     877             : 
     878             : /*------------------------------------------------------------------------
     879             :  Beschreibung:  Einfuegen harter Seitenumbruch;
     880             :                 Selektionen werden ueberschrieben
     881             : ------------------------------------------------------------------------*/
     882             : 
     883             : 
     884             : 
     885           0 : void SwWrtShell::InsertPageBreak(const String *pPageDesc, sal_uInt16 nPgNum )
     886             : {
     887           0 :     ResetCursorStack();
     888           0 :     if( CanInsert() )
     889             :     {
     890           0 :         SwActContext aActContext(this);
     891           0 :         StartUndo(UNDO_UI_INSERT_PAGE_BREAK);
     892             : 
     893           0 :         if ( !IsCrsrInTbl() )
     894             :         {
     895           0 :             if(HasSelection())
     896           0 :                 DelRight();
     897           0 :             SwFEShell::SplitNode();
     898             :             // delete the numbered attribute of the last line if the last line is empty
     899           0 :             GetDoc()->ClearLineNumAttrs( *GetCrsr()->GetPoint() );
     900             :         }
     901             : 
     902             :         const SwPageDesc *pDesc = pPageDesc
     903           0 :                                 ? FindPageDescByName( *pPageDesc, sal_True ) : 0;
     904           0 :         if( pDesc )
     905             :         {
     906           0 :             SwFmtPageDesc aDesc( pDesc );
     907           0 :             aDesc.SetNumOffset( nPgNum );
     908           0 :             SetAttr( aDesc );
     909             :         }
     910             :         else
     911           0 :             SetAttr( SvxFmtBreakItem(SVX_BREAK_PAGE_BEFORE, RES_BREAK) );
     912           0 :         EndUndo(UNDO_UI_INSERT_PAGE_BREAK);
     913             :     }
     914           0 : }
     915             : /*------------------------------------------------------------------------
     916             :  Beschreibung:  Einfuegen harter Zeilenumbruch;
     917             :                 Selektionen werden ueberschrieben
     918             : ------------------------------------------------------------------------*/
     919             : 
     920             : 
     921           0 : void SwWrtShell::InsertLineBreak()
     922             : {
     923           0 :     ResetCursorStack();
     924           0 :     if( CanInsert() )
     925             :     {
     926           0 :         if(HasSelection())
     927           0 :             DelRight();
     928             : 
     929           0 :         const sal_Unicode cIns = 0x0A;
     930           0 :         SvxAutoCorrect* pACorr = lcl_IsAutoCorr();
     931           0 :         if( pACorr )
     932           0 :             AutoCorrect( *pACorr, cIns );
     933             :         else
     934           0 :             SwWrtShell::Insert( rtl::OUString( cIns ) );
     935             :     }
     936           0 : }
     937             : /*------------------------------------------------------------------------
     938             :  Beschreibung:  Einfuegen harter Spaltenumbruch;
     939             :                 Selektionen werden ueberschrieben
     940             : ------------------------------------------------------------------------*/
     941             : 
     942             : 
     943           0 : void SwWrtShell::InsertColumnBreak()
     944             : {
     945           0 :     SwActContext aActContext(this);
     946           0 :     ResetCursorStack();
     947           0 :     if( CanInsert() )
     948             :     {
     949           0 :         StartUndo(UNDO_UI_INSERT_COLUMN_BREAK);
     950             : 
     951           0 :         if ( !IsCrsrInTbl() )
     952             :         {
     953           0 :             if(HasSelection())
     954           0 :                 DelRight();
     955           0 :             SwFEShell::SplitNode( sal_False, sal_False );
     956             :         }
     957           0 :         SetAttr(SvxFmtBreakItem(SVX_BREAK_COLUMN_BEFORE, RES_BREAK));
     958             : 
     959           0 :         EndUndo(UNDO_UI_INSERT_COLUMN_BREAK);
     960           0 :     }
     961           0 : }
     962             : 
     963             : /*------------------------------------------------------------------------
     964             :  Beschreibung:  Einfuegen Fussnote
     965             :  Parameter:     rStr -- optionales Fussnotenzeichen
     966             : ------------------------------------------------------------------------*/
     967             : 
     968             : 
     969           0 : void SwWrtShell::InsertFootnote(const String &rStr, sal_Bool bEndNote, sal_Bool bEdit )
     970             : {
     971           0 :     ResetCursorStack();
     972           0 :     if( CanInsert() )
     973             :     {
     974           0 :         if(HasSelection())
     975             :         {
     976             :             //collapse cursor to the end
     977           0 :             if(!IsCrsrPtAtEnd())
     978           0 :                 SwapPam();
     979           0 :             ClearMark();
     980             :         }
     981           0 :         SwPosition aPos = *GetCrsr()->GetPoint();
     982           0 :         SwFmtFtn aFootNote( bEndNote );
     983           0 :         if(rStr.Len())
     984           0 :             aFootNote.SetNumStr( rStr );
     985             : 
     986           0 :         SetAttr(aFootNote);
     987             : 
     988           0 :         if( bEdit )
     989             :         {
     990             :             // zur Bearbeiung des Fussnotentextes
     991           0 :             Left(CRSR_SKIP_CHARS, sal_False, 1, sal_False );
     992           0 :             GotoFtnTxt();
     993             :         }
     994           0 :         aNavigationMgr.addEntry(aPos);
     995             :     }
     996           0 : }
     997             : /*------------------------------------------------------------------------
     998             :  Beschreibung:  SplitNode; hier auch, da
     999             :                     - selektierter Inhalt geloescht wird;
    1000             :                     - der Cursorstack gfs. zurueckgesetzt wird.
    1001             : ------------------------------------------------------------------------*/
    1002             : 
    1003             : 
    1004           0 : void SwWrtShell::SplitNode( sal_Bool bAutoFmt, sal_Bool bCheckTableStart )
    1005             : {
    1006           0 :     ResetCursorStack();
    1007           0 :     if( CanInsert() )
    1008             :     {
    1009           0 :         SwActContext aActContext(this);
    1010             : 
    1011           0 :         rView.GetEditWin().FlushInBuffer();
    1012           0 :         sal_Bool bHasSel = HasSelection();
    1013           0 :         if( bHasSel )
    1014             :         {
    1015           0 :             StartUndo( UNDO_INSERT );
    1016           0 :             DelRight();
    1017             :         }
    1018             : 
    1019           0 :         SwFEShell::SplitNode( bAutoFmt, bCheckTableStart );
    1020           0 :         if( bHasSel )
    1021           0 :             EndUndo( UNDO_INSERT );
    1022             :     }
    1023           0 : }
    1024             : 
    1025             : /*------------------------------------------------------------------------
    1026             :  Beschreibung:  Numerierung anschalten
    1027             :  Parameter:     Optionale Angabe eines Namens fuer die benannte Liste;
    1028             :                 dieser bezeichnet eine Position, wenn er in eine
    1029             :                 Zahl konvertierbar ist und kleiner ist als nMaxRules.
    1030             : -------------------------------------------------------------------------*/
    1031             : 
    1032             : 
    1033             : // zum Testen der CharFormate an der Numerierung
    1034             : // extern void SetNumChrFmt( SwWrtShell*, SwNumRules& );
    1035             : 
    1036             : // -> #i40041#
    1037             : // Preconditions (as far as OD has figured out):
    1038             : // - <SwEditShell::HasNumber()> is sal_False, if <bNum> is sal_True
    1039             : // - <SwEditShell::HasBullet()> is sal_False, if <bNum> is sal_False
    1040             : // Behavior of method is determined by the current situation at the current
    1041             : // cursor position in the document.
    1042           0 : void SwWrtShell::NumOrBulletOn(sal_Bool bNum)
    1043             : {
    1044             :     // determine numbering rule found at current cursor position in the document.
    1045           0 :     const SwNumRule* pCurRule = GetCurNumRule();
    1046             : 
    1047           0 :     StartUndo(UNDO_NUMORNONUM);
    1048             : 
    1049           0 :     const SwNumRule * pNumRule = pCurRule;
    1050             : 
    1051             :     // - activate outline rule respectively turning on outline rule for
    1052             :     //   current text node. But, only for turning on a numbering (<bNum> == sal_True).
    1053             :     // - overwrite found numbering rule at current cursor position, if
    1054             :     //   no numbering rule can be retrieved from the paragraph style.
    1055           0 :     bool bContinueFoundNumRule( false );
    1056           0 :     bool bActivateOutlineRule( false );
    1057           0 :     int nActivateOutlineLvl( MAXLEVEL );    // only relevant, if <bActivateOutlineRule> == sal_True
    1058           0 :     SwTxtFmtColl * pColl = GetCurTxtFmtColl();
    1059           0 :     if ( pColl )
    1060             :     {
    1061             :         // retrieve numbering rule at paragraph
    1062             :         // style, which is found at current cursor position in the document.
    1063           0 :         SwNumRule* pCollRule = pDoc->FindNumRulePtr(pColl->GetNumRule().GetValue());
    1064             :         // #125993# - The outline numbering rule isn't allowed
    1065             :         // to be derived from a parent paragraph style to a derived one.
    1066             :         // Thus check, if the found outline numbering rule is directly
    1067             :         // set at the paragraph style <pColl>. If not, set <pCollRule> to NULL
    1068           0 :         if ( pCollRule && pCollRule == GetDoc()->GetOutlineNumRule() )
    1069             :         {
    1070             :             const SwNumRule* pDirectCollRule =
    1071           0 :                     pDoc->FindNumRulePtr(pColl->GetNumRule( sal_False ).GetValue());
    1072           0 :             if ( !pDirectCollRule )
    1073             :             {
    1074           0 :                 pCollRule = 0;
    1075             :             }
    1076             :         }
    1077             : 
    1078           0 :         if ( !pCollRule )
    1079             :         {
    1080           0 :             pNumRule = pCollRule;
    1081             :         }
    1082             :         // no activation or continuation of outline numbering in Writer/Web document
    1083           0 :         else if ( bNum &&
    1084           0 :                   !dynamic_cast<SwWebDocShell*>(GetDoc()->GetDocShell()) &&
    1085           0 :                   pCollRule == GetDoc()->GetOutlineNumRule() )
    1086             :         {
    1087           0 :             if ( pNumRule == pCollRule )
    1088             :             {
    1089             :                 // check, if text node at current cursor positioned is counted.
    1090             :                 // If not, let it been counted. Then it has to be checked,
    1091             :                 // of the outline numbering has to be activated or continued.
    1092             :                 SwTxtNode* pTxtNode =
    1093           0 :                             GetCrsr()->GetPoint()->nNode.GetNode().GetTxtNode();
    1094           0 :                 if ( pTxtNode && !pTxtNode->IsCountedInList() )
    1095             :                 {
    1096             :                     // check, if numbering of the outline level of the paragraph
    1097             :                     // style is active. If not, activate this outline level.
    1098           0 :                     nActivateOutlineLvl = pColl->GetAssignedOutlineStyleLevel();
    1099             :                     OSL_ENSURE( pColl->IsAssignedToListLevelOfOutlineStyle(),
    1100             :                             "<SwWrtShell::NumOrBulletOn(..)> - paragraph style with outline rule, but no outline level" );
    1101           0 :                     if ( pColl->IsAssignedToListLevelOfOutlineStyle() &&
    1102           0 :                          pCollRule->Get( static_cast<sal_uInt16>(nActivateOutlineLvl) ).GetNumberingType()
    1103             :                             == SVX_NUM_NUMBER_NONE )
    1104             :                     {
    1105             :                         // activate outline numbering
    1106           0 :                         bActivateOutlineRule = true;
    1107             :                     }
    1108             :                     else
    1109             :                     {
    1110             :                         // turning on outline numbering at current cursor position
    1111           0 :                         bContinueFoundNumRule = true;
    1112             :                     }
    1113             :                 }
    1114             :                 else
    1115             :                 {
    1116             :                     // #i101234#
    1117             :                     // activate outline numbering, because from the precondition
    1118             :                     // it's known, that <SwEdit::HasNumber()> == sal_False
    1119           0 :                     bActivateOutlineRule = true;
    1120           0 :                     nActivateOutlineLvl = pColl->GetAssignedOutlineStyleLevel();//<-end,zhaojianwei
    1121             :                 }
    1122             :             }
    1123           0 :             else if ( !pNumRule )
    1124             :             {
    1125             :                 // #i101234#
    1126             :                 // Check, if corresponding list level of the outline numbering
    1127             :                 // has already a numbering format set.
    1128           0 :                 nActivateOutlineLvl = pColl->GetAssignedOutlineStyleLevel();//<-end,zhaojianwei,need further consideration
    1129           0 :                 if ( pCollRule->Get( static_cast<sal_uInt16>(nActivateOutlineLvl) ).GetNumberingType()
    1130             :                                 == SVX_NUM_NUMBER_NONE )
    1131             :                 {
    1132             :                     // activate outline numbering, because from the precondition
    1133             :                     // it's known, that <SwEdit::HasNumber()> == sal_False
    1134           0 :                     bActivateOutlineRule = true;
    1135             :                 }
    1136             :                 else
    1137             :                 {
    1138             :                     // turning on outline numbering at current cursor position
    1139           0 :                     bContinueFoundNumRule = true;
    1140             :                 }
    1141             :             }
    1142             :             else
    1143             :             {
    1144             :                 // check, if numbering of the outline level of the paragraph
    1145             :                 // style is active. If not, activate this outline level.
    1146           0 :                 nActivateOutlineLvl = pColl->GetAssignedOutlineStyleLevel();
    1147             :                 OSL_ENSURE( pColl->IsAssignedToListLevelOfOutlineStyle(),
    1148             :                         "<SwWrtShell::NumOrBulletOn(..)> - paragraph style with outline rule, but no outline level" );
    1149           0 :                 if ( pColl->IsAssignedToListLevelOfOutlineStyle() &&
    1150           0 :                      pCollRule->Get( static_cast<sal_uInt16>(nActivateOutlineLvl) ).GetNumberingType()
    1151             :                         == SVX_NUM_NUMBER_NONE )
    1152             :                 {
    1153             :                     // activate outline numbering
    1154           0 :                     bActivateOutlineRule = true;
    1155             :                 }
    1156             :                 else
    1157             :                 {
    1158             :                     // turning on outline numbering at current cursor position
    1159           0 :                     bContinueFoundNumRule = true;
    1160             :                 }
    1161             :             }
    1162           0 :             pNumRule = pCollRule;
    1163             :         }
    1164             :     }
    1165             : 
    1166             :     // Only automatic numbering/bullet rules should be changed.
    1167             :     // Note: The outline numbering rule is also an automatic one. It's only
    1168             :     //       changed, if it has to be activated.
    1169           0 :     if ( pNumRule )
    1170             :     {
    1171           0 :         if ( !pNumRule->IsAutoRule() )
    1172             :         {
    1173           0 :             pNumRule = 0;
    1174             :         }
    1175           0 :         else if ( pNumRule == GetDoc()->GetOutlineNumRule() &&
    1176           0 :                   !bActivateOutlineRule && !bContinueFoundNumRule )
    1177             :         {
    1178           0 :             pNumRule = 0;
    1179             :         }
    1180             :     }
    1181             : 
    1182             :     // Search for a previous numbering/bullet rule to continue it.
    1183           0 :     String sContinuedListId;
    1184           0 :     if ( !pNumRule )
    1185             :     {
    1186           0 :         pNumRule = GetDoc()->SearchNumRule( *GetCrsr()->GetPoint(),
    1187             :                                             false, bNum, false, 0,
    1188           0 :                                             sContinuedListId );
    1189           0 :         bContinueFoundNumRule = pNumRule != 0;
    1190             :     }
    1191             : 
    1192           0 :     if (pNumRule)
    1193             :     {
    1194           0 :         SwNumRule aNumRule(*pNumRule);
    1195             : 
    1196             :         // do not change found numbering/bullet rule, if it should only be continued.
    1197           0 :         if ( !bContinueFoundNumRule )
    1198             :         {
    1199           0 :             SwTxtNode * pTxtNode = GetCrsr()->GetPoint()->nNode.GetNode().GetTxtNode();
    1200             : 
    1201           0 :             if (pTxtNode)
    1202             :             {
    1203             :                 // use above retrieve outline level, if outline numbering has to be activated.
    1204             :                 int nLevel = bActivateOutlineRule
    1205             :                               ? nActivateOutlineLvl
    1206           0 :                               : pTxtNode->GetActualListLevel();
    1207             : 
    1208           0 :                 if (nLevel < 0)
    1209           0 :                     nLevel = 0;
    1210             : 
    1211           0 :                 if (nLevel >= MAXLEVEL)
    1212           0 :                     nLevel = MAXLEVEL - 1;
    1213             : 
    1214           0 :                 SwNumFmt aFmt(aNumRule.Get(static_cast<sal_uInt16>(nLevel)));
    1215             : 
    1216           0 :                 if (bNum)
    1217           0 :                     aFmt.SetNumberingType(SVX_NUM_ARABIC);
    1218             :                 else
    1219             :                 {
    1220             :                     // #i63395# Only apply user defined default bullet font
    1221           0 :                     if ( numfunc::IsDefBulletFontUserDefined() )
    1222             :                     {
    1223           0 :                         const Font* pFnt = &numfunc::GetDefBulletFont();
    1224           0 :                         aFmt.SetBulletFont( pFnt );
    1225             :                     }
    1226           0 :                     aFmt.SetBulletChar( numfunc::GetBulletChar(static_cast<sal_uInt8>(nLevel)));
    1227           0 :                     aFmt.SetNumberingType(SVX_NUM_CHAR_SPECIAL);
    1228             :                     // #i93908# clear suffix for bullet lists
    1229           0 :                     aFmt.SetPrefix(::rtl::OUString());
    1230           0 :                     aFmt.SetSuffix(::rtl::OUString());
    1231             :                 }
    1232           0 :                 aNumRule.Set(static_cast<sal_uInt16>(nLevel), aFmt);
    1233             :             }
    1234             :         }
    1235             : 
    1236             :         // reset indent attribute on applying list style
    1237           0 :         SetCurNumRule( aNumRule, false, sContinuedListId, true );
    1238             :     }
    1239             :     else
    1240             :     {
    1241             :         // #i95907#
    1242             :         const SvxNumberFormat::SvxNumPositionAndSpaceMode ePosAndSpaceMode(
    1243           0 :                                     numfunc::GetDefaultPositionAndSpaceMode() );
    1244           0 :         SwNumRule aNumRule( GetUniqueNumRuleName(), ePosAndSpaceMode );
    1245             :         // Zeichenvorlage an die Numerierung haengen
    1246             :         SwCharFmt* pChrFmt;
    1247           0 :         SwDocShell* pDocSh = GetView().GetDocShell();
    1248             :         // #i63395#
    1249             :         // Only apply user defined default bullet font
    1250           0 :         const Font* pFnt = numfunc::IsDefBulletFontUserDefined()
    1251             :                            ? &numfunc::GetDefBulletFont()
    1252           0 :                            : 0;
    1253             : 
    1254           0 :         if (bNum)
    1255             :         {
    1256           0 :             pChrFmt = GetCharFmtFromPool( RES_POOLCHR_NUM_LEVEL );
    1257             :         }
    1258             :         else
    1259             :         {
    1260           0 :             pChrFmt = GetCharFmtFromPool( RES_POOLCHR_BUL_LEVEL );
    1261             :         }
    1262             : 
    1263           0 :         const SwTxtNode* pTxtNode = GetCrsr()->GetPoint()->nNode.GetNode().GetTxtNode();
    1264             :         const SwTwips nWidthOfTabs = pTxtNode
    1265           0 :                                      ? pTxtNode->GetWidthOfLeadingTabs()
    1266           0 :                                      : 0;
    1267           0 :         GetDoc()->RemoveLeadingWhiteSpace( *GetCrsr()->GetPoint() );
    1268             : 
    1269           0 :         const bool bHtml = 0 != PTR_CAST(SwWebDocShell, pDocSh);
    1270           0 :         const bool bRightToLeft = IsInRightToLeftText();
    1271           0 :         for( sal_uInt8 nLvl = 0; nLvl < MAXLEVEL; ++nLvl )
    1272             :         {
    1273           0 :             SwNumFmt aFmt( aNumRule.Get( nLvl ) );
    1274           0 :             aFmt.SetCharFmt( pChrFmt );
    1275             : 
    1276           0 :             if (! bNum)
    1277             :             {
    1278             :                 // #i63395#
    1279             :                 // Only apply user defined default bullet font
    1280           0 :                 if ( pFnt )
    1281             :                 {
    1282           0 :                     aFmt.SetBulletFont( pFnt );
    1283             :                 }
    1284           0 :                 aFmt.SetBulletChar( numfunc::GetBulletChar(nLvl) );
    1285           0 :                 aFmt.SetNumberingType(SVX_NUM_CHAR_SPECIAL);
    1286             :                 // #i93908# clear suffix for bullet lists
    1287           0 :                 aFmt.SetPrefix(::rtl::OUString());
    1288           0 :                 aFmt.SetSuffix(::rtl::OUString());
    1289             :             }
    1290             : 
    1291             :             // #i95907#
    1292           0 :             if ( ePosAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
    1293             :             {
    1294           0 :                 if(bHtml && nLvl)
    1295             :                 {
    1296             :                     // 1/2" fuer HTML
    1297           0 :                     aFmt.SetLSpace(720);
    1298           0 :                     aFmt.SetAbsLSpace(nLvl * 720);
    1299             :                 }
    1300           0 :                 else if ( nWidthOfTabs > 0 )
    1301             :                 {
    1302           0 :                     aFmt.SetAbsLSpace(nWidthOfTabs + nLvl * 720);
    1303             :                 }
    1304             :             }
    1305             : 
    1306             :             // #i38904#  Default alignment for
    1307             :             // numbering/bullet should be rtl in rtl paragraph:
    1308           0 :             if ( bRightToLeft )
    1309             :             {
    1310           0 :                 aFmt.SetNumAdjust( SVX_ADJUST_RIGHT );
    1311             :             }
    1312             : 
    1313           0 :             aNumRule.Set( nLvl, aFmt );
    1314           0 :         }
    1315             : 
    1316             :         // #i95907#
    1317           0 :         if ( pTxtNode &&
    1318             :              ePosAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
    1319             :         {
    1320             : 
    1321           0 :             const SwTwips nTxtNodeIndent = pTxtNode->GetAdditionalIndentForStartingNewList();
    1322           0 :             if ( ( nTxtNodeIndent + nWidthOfTabs ) != 0 )
    1323             :             {
    1324             :                 // #i111172#
    1325             :                 // If text node is already inside a list, assure that the indents
    1326             :                 // are the same. Thus, adjust the indent change value by subtracting
    1327             :                 // indents of to be applied list style.
    1328           0 :                 SwTwips nIndentChange = nTxtNodeIndent + nWidthOfTabs;
    1329           0 :                 if ( pTxtNode->GetNumRule() )
    1330             :                 {
    1331           0 :                     const SwNumFmt aFmt( aNumRule.Get( 0 ) );
    1332           0 :                     if ( aFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
    1333             :                     {
    1334           0 :                         nIndentChange -= aFmt.GetIndentAt() + aFmt.GetFirstLineIndent();
    1335           0 :                     }
    1336             :                 }
    1337           0 :                 aNumRule.ChangeIndent( nIndentChange );
    1338             :             }
    1339             :         }
    1340             :         // reset indent attribute on applying list style
    1341             :         // start new list
    1342           0 :         SetCurNumRule( aNumRule, true, String(), true );
    1343             :     }
    1344             : 
    1345           0 :     EndUndo(UNDO_NUMORNONUM);
    1346           0 : }
    1347             : // <- #i40041#
    1348             : 
    1349           0 : void SwWrtShell::NumOn()
    1350             : {
    1351           0 :     NumOrBulletOn(sal_True);
    1352           0 : }
    1353             : 
    1354           0 : void SwWrtShell::NumOrBulletOff()
    1355             : {
    1356           0 :     const SwNumRule * pCurNumRule = GetCurNumRule();
    1357             : 
    1358           0 :     if (pCurNumRule)
    1359             :     {
    1360           0 :         if (pCurNumRule->IsOutlineRule())
    1361             :         {
    1362           0 :             SwNumRule aNumRule(*pCurNumRule);
    1363             : 
    1364             :             SwTxtNode * pTxtNode =
    1365           0 :                 GetCrsr()->GetPoint()->nNode.GetNode().GetTxtNode();
    1366             : 
    1367           0 :             if (pTxtNode)
    1368             :             {
    1369           0 :                 sal_uInt16 nLevel = sal::static_int_cast<sal_uInt16, sal_Int32>(pTxtNode->GetActualListLevel());
    1370           0 :                 SwNumFmt aFmt(aNumRule.Get(nLevel));
    1371             : 
    1372           0 :                 aFmt.SetNumberingType(SVX_NUM_NUMBER_NONE);
    1373           0 :                 aNumRule.Set(nLevel, aFmt);
    1374             : 
    1375             :                 // no start or continuation of a list - the outline style is only changed.
    1376           0 :                 SetCurNumRule( aNumRule, false );
    1377           0 :             }
    1378             :         }
    1379             :         else
    1380             :         {
    1381           0 :             DelNumRules();
    1382             :         }
    1383             : 
    1384             :         // #126346# - Cursor can not be anymore in front of
    1385             :         // a label, because numbering/bullet is switched off.
    1386           0 :         SetInFrontOfLabel( false );
    1387             :     }
    1388           0 : }
    1389             : // <- #i29560#
    1390             : 
    1391             : /*------------------------------------------------------------------------
    1392             :  Beschreibung:  Default-Bulletliste erfragen
    1393             : ------------------------------------------------------------------------*/
    1394             : 
    1395           0 : void SwWrtShell::BulletOn()
    1396             : {
    1397           0 :     NumOrBulletOn(sal_False);
    1398           0 : }
    1399             : 
    1400             : 
    1401             : 
    1402        1421 : SelectionType SwWrtShell::GetSelectionType() const
    1403             : {
    1404             :     // ContentType kann nicht ermittelt werden innerhalb einer
    1405             :     // Start-/Endactionklammerung.
    1406             :     // Da es keinen ungueltigen Wert gibt, wird TEXT geliefert.
    1407             :     // Der Wert ist egal, da in EndAction ohnehin aktualisiert wird.
    1408             : 
    1409        1421 :     if ( BasicActionPend() )
    1410           0 :         return IsSelFrmMode() ? nsSelectionType::SEL_FRM : nsSelectionType::SEL_TXT;
    1411             : 
    1412        1421 :     SwView &_rView = ((SwView&)GetView());
    1413        1421 :     if (_rView.GetPostItMgr() && _rView.GetPostItMgr()->HasActiveSidebarWin() )
    1414           0 :         return nsSelectionType::SEL_POSTIT;
    1415             :      int nCnt;
    1416             : 
    1417             :     // Rahmen einfuegen ist kein DrawMode
    1418        4263 :     if ( !_rView.GetEditWin().IsFrmAction() &&
    1419        2842 :             (IsObjSelected() || (_rView.IsDrawMode() && !IsFrmSelected()) ))
    1420             :     {
    1421           0 :         if (GetDrawView()->IsTextEdit())
    1422           0 :             nCnt = nsSelectionType::SEL_DRW_TXT;
    1423             :         else
    1424             :         {
    1425           0 :             if (GetView().IsFormMode()) // Nur Forms selektiert
    1426           0 :                 nCnt = nsSelectionType::SEL_DRW_FORM;
    1427             :             else
    1428           0 :                 nCnt = nsSelectionType::SEL_DRW;            // Irgendein Draw-Objekt
    1429             : 
    1430           0 :             if (_rView.IsBezierEditMode())
    1431           0 :                 nCnt |= nsSelectionType::SEL_BEZ;
    1432           0 :             else if( GetDrawView()->GetContext() == SDRCONTEXT_MEDIA )
    1433           0 :                 nCnt |= nsSelectionType::SEL_MEDIA;
    1434             : 
    1435           0 :             if (svx::checkForSelectedCustomShapes(
    1436           0 :                     const_cast<SdrView *>(GetDrawView()),
    1437             :                     true /* bOnlyExtruded */ ))
    1438             :             {
    1439           0 :                 nCnt |= nsSelectionType::SEL_EXTRUDED_CUSTOMSHAPE;
    1440             :             }
    1441           0 :             sal_uInt32 nCheckStatus = 0;
    1442           0 :             if (svx::checkForSelectedFontWork(
    1443           0 :                     const_cast<SdrView *>(GetDrawView()), nCheckStatus ))
    1444             :             {
    1445           0 :                 nCnt |= nsSelectionType::SEL_FONTWORK;
    1446             :             }
    1447             :         }
    1448             : 
    1449           0 :         return nCnt;
    1450             :     }
    1451             : 
    1452        1421 :     nCnt = GetCntType();
    1453             : 
    1454        1421 :     if ( IsFrmSelected() )
    1455             :     {
    1456           0 :         if (_rView.IsDrawMode())
    1457           0 :             _rView.LeaveDrawCreate();   // Aufraeumen (Bug #45639)
    1458           0 :         if ( !(nCnt & (CNT_GRF | CNT_OLE)) )
    1459           0 :             return nsSelectionType::SEL_FRM;
    1460             :     }
    1461             : 
    1462        1421 :     if ( IsCrsrInTbl() )
    1463          98 :         nCnt |= nsSelectionType::SEL_TBL;
    1464             : 
    1465        1421 :     if ( IsTableMode() )
    1466           0 :         nCnt |= (nsSelectionType::SEL_TBL | nsSelectionType::SEL_TBL_CELLS);
    1467             : 
    1468             :     // #i39855#
    1469             :     // Do not pop up numbering toolbar, if the text node has a numbering
    1470             :     // of type SVX_NUM_NUMBER_NONE.
    1471        1421 :     const SwNumRule* pNumRule = GetCurNumRule();
    1472        1421 :     if ( pNumRule )
    1473             :     {
    1474             :         const SwTxtNode* pTxtNd =
    1475          50 :             GetCrsr()->GetPoint()->nNode.GetNode().GetTxtNode();
    1476             : 
    1477          50 :         if ( pTxtNd && pTxtNd->IsInList() )
    1478             :         {
    1479          50 :             const SwNumFmt& rFmt = pNumRule->Get(sal::static_int_cast< sal_uInt8, sal_Int32>(pTxtNd->GetActualListLevel()));
    1480          50 :             if ( SVX_NUM_NUMBER_NONE != rFmt.GetNumberingType() )
    1481          42 :                 nCnt |= nsSelectionType::SEL_NUM;
    1482             :         }
    1483             :     }
    1484             : 
    1485        1421 :     return nCnt;
    1486             : }
    1487             : 
    1488             : /*------------------------------------------------------------------------
    1489             :  Beschreibung:  Finden der TextCollection mit dem Name rCollname
    1490             :  Return:                Pointer auf die Collection oder 0, wenn keine
    1491             :                                 TextCollection mit diesem Namen existiert oder
    1492             :                                 diese eine Defaultvorlage ist.
    1493             : ------------------------------------------------------------------------*/
    1494             : 
    1495             : 
    1496           0 : SwTxtFmtColl *SwWrtShell::GetParaStyle(const String &rCollName, GetStyle eCreate )
    1497             : {
    1498           0 :     SwTxtFmtColl* pColl = FindTxtFmtCollByName( rCollName );
    1499           0 :     if( !pColl && GETSTYLE_NOCREATE != eCreate )
    1500             :     {
    1501           0 :         sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName( rCollName, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
    1502           0 :         if( USHRT_MAX != nId || GETSTYLE_CREATEANY == eCreate )
    1503           0 :             pColl = GetTxtCollFromPool( nId );
    1504             :     }
    1505           0 :     return pColl;
    1506             : }
    1507             : /*------------------------------------------------------------------------
    1508             :  Beschreibung:  Finden der Zeichenvorlage mit dem Name rCollname
    1509             :  Return:                Pointer auf die Collection oder 0, wenn keine
    1510             :                                 Zeichenvorlage mit diesem Namen existiert oder
    1511             :                                 diese eine Defaultvorlage oder automatische Vorlage ist.
    1512             : ------------------------------------------------------------------------*/
    1513             : 
    1514             : 
    1515             : 
    1516           0 : SwCharFmt *SwWrtShell::GetCharStyle(const String &rFmtName, GetStyle eCreate )
    1517             : {
    1518           0 :     SwCharFmt* pFmt = FindCharFmtByName( rFmtName );
    1519           0 :     if( !pFmt && GETSTYLE_NOCREATE != eCreate )
    1520             :     {
    1521           0 :         sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName( rFmtName, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT );
    1522           0 :         if( USHRT_MAX != nId || GETSTYLE_CREATEANY == eCreate )
    1523           0 :             pFmt = (SwCharFmt*)GetFmtFromPool( nId );
    1524             :     }
    1525           0 :     return pFmt;
    1526             : }
    1527             : 
    1528             : /*------------------------------------------------------------------------
    1529             :  Beschreibung:  Finden des Tabellenformates mit dem Name rFmtname
    1530             :  Return:                Pointer auf das Format oder 0, wenn kein
    1531             :                                 Rahmenformat mit diesem Namen existiert oder
    1532             :                                 dieses eine Defaultformat oder automatisches Format ist.
    1533             : ------------------------------------------------------------------------*/
    1534             : 
    1535             : 
    1536             : 
    1537           0 : SwFrmFmt *SwWrtShell::GetTblStyle(const String &rFmtName)
    1538             : {
    1539           0 :     SwFrmFmt *pFmt = 0;
    1540           0 :     for( sal_uInt16 i = GetTblFrmFmtCount(); i; )
    1541           0 :         if( !( pFmt = &GetTblFrmFmt( --i ) )->IsDefault() &&
    1542           0 :             pFmt->GetName() == rFmtName && IsUsed( *pFmt ) )
    1543           0 :             return pFmt;
    1544           0 :     return 0;
    1545             : }
    1546             : 
    1547           0 : SwNavigationMgr& SwWrtShell::GetNavigationMgr() {
    1548           0 :     return aNavigationMgr;
    1549             : }
    1550             : 
    1551           0 : void SwWrtShell::addCurrentPosition() {
    1552           0 :     SwPaM* pPaM = GetCrsr();
    1553           0 :     aNavigationMgr.addEntry(*pPaM->GetPoint());
    1554           0 : }
    1555             : /*------------------------------------------------------------------------
    1556             :  Beschreibung:  Anwenden der Vorlagen
    1557             : ------------------------------------------------------------------------*/
    1558             : 
    1559             : 
    1560             : 
    1561           0 : void SwWrtShell::SetPageStyle(const String &rCollName)
    1562             : {
    1563           0 :     if( !SwCrsrShell::HasSelection() && !IsSelFrmMode() && !IsObjSelected() )
    1564             :     {
    1565           0 :         SwPageDesc* pDesc = FindPageDescByName( rCollName, sal_True );
    1566           0 :         if( pDesc )
    1567           0 :             ChgCurPageDesc( *pDesc );
    1568             :     }
    1569           0 : }
    1570             : 
    1571             : /*------------------------------------------------------------------------
    1572             :  Beschreibung:  Zugriff Vorlagen
    1573             : ------------------------------------------------------------------------*/
    1574             : 
    1575             : 
    1576             : 
    1577           5 : String SwWrtShell::GetCurPageStyle( const sal_Bool bCalcFrm ) const
    1578             : {
    1579           5 :     return GetPageDesc(GetCurPageDesc( bCalcFrm )).GetName();
    1580             : }
    1581             : 
    1582             : /*------------------------------------------------------------------------
    1583             :  Beschreibung:  Aktuelle Vorlage anhand der geltenden Attribute aendern
    1584             : ------------------------------------------------------------------------*/
    1585             : 
    1586             : 
    1587           0 : void SwWrtShell::QuickUpdateStyle()
    1588             : {
    1589           0 :     SwTxtFmtColl *pColl = GetCurTxtFmtColl();
    1590             : 
    1591             :     // Standard kann nicht geaendert werden
    1592           0 :     if(pColl && !pColl->IsDefault())
    1593             :     {
    1594           0 :         FillByEx(pColl);
    1595             :             // Vorlage auch anwenden, um harte Attributierung
    1596             :             // zu entfernen
    1597           0 :         SetTxtFmtColl(pColl);
    1598             :     }
    1599           0 : }
    1600             : 
    1601             : 
    1602           0 : void SwWrtShell::AutoUpdatePara(SwTxtFmtColl* pColl, const SfxItemSet& rStyleSet, SwPaM* pPaM )
    1603             : {
    1604           0 :     SwPaM* pCrsr = pPaM ? pPaM : GetCrsr( );
    1605           0 :     SfxItemSet aCoreSet( GetAttrPool(),
    1606             :             RES_CHRATR_BEGIN,           RES_CHRATR_END - 1,
    1607             :             RES_PARATR_BEGIN,           RES_PARATR_END - 1,
    1608             :             RES_FRMATR_BEGIN,           RES_FRMATR_END - 1,
    1609             :             SID_ATTR_TABSTOP_POS,       SID_ATTR_TABSTOP_POS,
    1610             :             SID_ATTR_TABSTOP_DEFAULTS,  SID_ATTR_TABSTOP_DEFAULTS,
    1611             :             SID_ATTR_TABSTOP_OFFSET,    SID_ATTR_TABSTOP_OFFSET,
    1612             :             SID_ATTR_BORDER_INNER,      SID_ATTR_BORDER_INNER,
    1613             :             SID_ATTR_PARA_MODEL,        SID_ATTR_PARA_KEEP,
    1614             :             SID_ATTR_PARA_PAGENUM,      SID_ATTR_PARA_PAGENUM,
    1615           0 :             0   );
    1616           0 :     GetPaMAttr( pCrsr, aCoreSet );
    1617           0 :     sal_Bool bReset = sal_False;
    1618           0 :     SfxItemIter aParaIter( aCoreSet );
    1619           0 :     const SfxPoolItem* pParaItem = aParaIter.FirstItem();
    1620           0 :     while( pParaItem )
    1621             :     {
    1622           0 :         if(!IsInvalidItem(pParaItem))
    1623             :         {
    1624           0 :             sal_uInt16 nWhich = pParaItem->Which();
    1625           0 :             if(SFX_ITEM_SET == aCoreSet.GetItemState(nWhich) &&
    1626           0 :                SFX_ITEM_SET == rStyleSet.GetItemState(nWhich))
    1627             :             {
    1628           0 :                 aCoreSet.ClearItem(nWhich);
    1629           0 :                 bReset = sal_True;
    1630             :             }
    1631             :         }
    1632           0 :         pParaItem = aParaIter.NextItem();
    1633             :     }
    1634           0 :     StartAction();
    1635           0 :     if(bReset)
    1636             :     {
    1637           0 :         ResetAttr( std::set<sal_uInt16>(), pCrsr );
    1638           0 :         SetAttr(aCoreSet, 0, pCrsr);
    1639             :     }
    1640           0 :     pDoc->ChgFmt(*pColl, rStyleSet );
    1641           0 :     EndAction();
    1642           0 : }
    1643             : 
    1644           0 : void SwWrtShell::AutoUpdateFrame( SwFrmFmt* pFmt, const SfxItemSet& rStyleSet )
    1645             : {
    1646           0 :     StartAction();
    1647             : 
    1648           0 :     ResetFlyFrmAttr( 0, &rStyleSet );
    1649           0 :     pFmt->SetFmtAttr( rStyleSet );
    1650             : 
    1651           0 :     EndAction();
    1652           0 : }
    1653             : 
    1654             : 
    1655           0 : void SwWrtShell::AutoCorrect( SvxAutoCorrect& rACorr, sal_Unicode cChar )
    1656             : {
    1657           0 :     ResetCursorStack();
    1658           0 :     if(CanInsert())
    1659             :     {
    1660           0 :         sal_Bool bStarted = sal_False;
    1661           0 :         if(HasSelection())
    1662             :         {
    1663             :                 // nur hier klammern, da das normale Insert schon an der
    1664             :                 // Editshell geklammert ist
    1665           0 :             StartAllAction();
    1666           0 :             StartUndo(UNDO_INSERT);
    1667           0 :             bStarted = sal_True;
    1668           0 :             DelRight();
    1669             :         }
    1670           0 :         SwEditShell::AutoCorrect( rACorr, IsInsMode(), cChar );
    1671             : 
    1672           0 :         if(bStarted)
    1673             :         {
    1674           0 :             EndAllAction();
    1675           0 :             EndUndo(UNDO_INSERT);
    1676             :         }
    1677             :     }
    1678           0 : }
    1679             : 
    1680             : 
    1681             : /*
    1682             :  * eine Art kontrollierter copy ctor
    1683             :  */
    1684             : 
    1685           0 : SwWrtShell::SwWrtShell( SwWrtShell& rSh, Window *_pWin, SwView &rShell )
    1686             :     : SwFEShell( rSh, _pWin ),
    1687           0 :      COMMON_INI_LIST
    1688             : {
    1689           0 :     BITFLD_INI_LIST
    1690           0 :     SET_CURR_SHELL( this );
    1691             : 
    1692           0 :     SetSfxViewShell( (SfxViewShell *)&rShell );
    1693           0 :     SetFlyMacroLnk( LINK(this, SwWrtShell, ExecFlyMac) );
    1694             : 
    1695             :     // place the cursor on the first field...
    1696           0 :     IFieldmark *pBM = NULL;
    1697           0 :     if ( IsFormProtected() && ( pBM = GetFieldmarkAfter( ) ) !=NULL ) {
    1698           0 :         GotoFieldmark(pBM);
    1699           0 :     }
    1700           0 : }
    1701             : 
    1702             : 
    1703         478 : SwWrtShell::SwWrtShell( SwDoc& rDoc, Window *_pWin, SwView &rShell,
    1704             :                         const SwViewOption *pViewOpt )
    1705             :     : SwFEShell( rDoc, _pWin, pViewOpt),
    1706         478 :       COMMON_INI_LIST
    1707             : {
    1708         478 :     BITFLD_INI_LIST
    1709         478 :     SET_CURR_SHELL( this );
    1710         478 :     SetSfxViewShell( (SfxViewShell *)&rShell );
    1711         478 :     SetFlyMacroLnk( LINK(this, SwWrtShell, ExecFlyMac) );
    1712             : 
    1713             :     // place the cursor on the first field...
    1714         478 :     IFieldmark *pBM = NULL;
    1715         478 :     if ( IsFormProtected() && ( pBM = GetFieldmarkAfter( ) ) !=NULL ) {
    1716           0 :         GotoFieldmark(pBM);
    1717         478 :     }
    1718         478 : }
    1719             : 
    1720             : /*
    1721             :  * ctor
    1722             :  */
    1723             : 
    1724             : 
    1725             : 
    1726         216 : SwWrtShell::~SwWrtShell()
    1727             : {
    1728          72 :     SET_CURR_SHELL( this );
    1729         144 :     while(IsModePushed())
    1730           0 :         PopMode();
    1731          72 :     while(PopCrsr(sal_False))
    1732             :         ;
    1733          72 :     SwTransferable::ClearSelection( *this );
    1734         144 : }
    1735             : 
    1736           8 : sal_Bool SwWrtShell::Pop( sal_Bool bOldCrsr )
    1737             : {
    1738           8 :     sal_Bool bRet = SwCrsrShell::Pop( bOldCrsr );
    1739           8 :     if( bRet && IsSelection() )
    1740             :     {
    1741           0 :         fnSetCrsr = &SwWrtShell::SetCrsrKillSel;
    1742           0 :         fnKillSel = &SwWrtShell::ResetSelect;
    1743             :     }
    1744           8 :     return bRet;
    1745             : }
    1746             : 
    1747           0 : sal_Bool SwWrtShell::CanInsert()
    1748             : {
    1749           0 :     return (!(IsSelFrmMode() | IsObjSelected() | (GetView().GetDrawFuncPtr() != NULL) | (GetView().GetPostItMgr()->GetActiveSidebarWin()!= NULL)));
    1750             : }
    1751             : 
    1752             : // --------------
    1753           0 : void SwWrtShell::ChgDBData(const SwDBData& aDBData)
    1754             : {
    1755           0 :     SwEditShell::ChgDBData(aDBData);
    1756             :     //notify the db-beamer if available
    1757           0 :     GetView().NotifyDBChanged();
    1758           0 : }
    1759             : 
    1760           0 : String SwWrtShell::GetSelDescr() const
    1761             : {
    1762           0 :     String aResult;
    1763             : 
    1764           0 :     int nSelType = GetSelectionType();
    1765           0 :     switch (nSelType)
    1766             :     {
    1767             :     case nsSelectionType::SEL_GRF:
    1768           0 :         aResult = SW_RESSTR(STR_GRAPHIC);
    1769             : 
    1770           0 :         break;
    1771             :     case nsSelectionType::SEL_FRM:
    1772             :         {
    1773           0 :             const SwFrmFmt * pFrmFmt = GetCurFrmFmt();
    1774             : 
    1775           0 :             if (pFrmFmt)
    1776           0 :                 aResult = pFrmFmt->GetDescription();
    1777             :         }
    1778           0 :         break;
    1779             :     case nsSelectionType::SEL_DRW:
    1780             :         {
    1781           0 :             aResult = SW_RESSTR(STR_DRAWING_OBJECTS);
    1782             :         }
    1783           0 :         break;
    1784             :     default:
    1785           0 :         if (0 != pDoc)
    1786           0 :             aResult = GetCrsrDescr();
    1787             :     }
    1788             : 
    1789           0 :     return aResult;
    1790             : }
    1791             : 
    1792          66 : void SwWrtShell::ApplyViewOptions( const SwViewOption &rOpt )
    1793             : {
    1794          66 :     SwFEShell::ApplyViewOptions( rOpt );
    1795             :     //#i115062# invalidate meta character slot
    1796          66 :     GetView().GetViewFrame()->GetBindings().Invalidate( FN_VIEW_META_CHARS );
    1797          66 : }
    1798             : 
    1799             : 
    1800           0 : void SwWrtShell::SetReadonlyOption(sal_Bool bSet)
    1801             : {
    1802           0 :     GetView().GetEditWin().GetFrameControlsManager().SetReadonlyControls( bSet );
    1803           0 :     ViewShell::SetReadonlyOption( bSet );
    1804           0 : }
    1805             : 
    1806             : /*
    1807             :  *  Switch on/off header or footer of a page style - if an empty name is
    1808             :  *  given all styles are changed
    1809             :  */
    1810           0 : void SwWrtShell::ChangeHeaderOrFooter(
    1811             :     const String& rStyleName, sal_Bool bHeader, sal_Bool bOn, sal_Bool bShowWarning)
    1812             : {
    1813           0 :     addCurrentPosition();
    1814           0 :     StartAllAction();
    1815           0 :     StartUndo( UNDO_HEADER_FOOTER ); // #i7983#
    1816           0 :     sal_Bool bExecute = sal_True;
    1817           0 :     sal_Bool bCrsrSet = sal_False;
    1818           0 :     for( sal_uInt16 nFrom = 0, nTo = GetPageDescCnt();
    1819             :             nFrom < nTo; ++nFrom )
    1820             :     {
    1821           0 :         int bChgd = sal_False;
    1822           0 :         SwPageDesc aDesc( GetPageDesc( nFrom ));
    1823           0 :         String sTmp(aDesc.GetName());
    1824           0 :         if( !rStyleName.Len() || rStyleName == sTmp )
    1825             :         {
    1826           0 :             if( bShowWarning && !bOn && GetActiveView() && GetActiveView() == &GetView() &&
    1827           0 :                 ( (bHeader && aDesc.GetMaster().GetHeader().IsActive()) ||
    1828           0 :                   (!bHeader && aDesc.GetMaster().GetFooter().IsActive()) ) )
    1829             :             {
    1830           0 :                 bShowWarning = sal_False;
    1831             :                 //Actions have to be closed while the dialog is showing
    1832           0 :                 EndAllAction();
    1833             : 
    1834           0 :                 Window* pParent = &GetView().GetViewFrame()->GetWindow();
    1835             :                 sal_Bool bRet = RET_YES == QueryBox( pParent, ResId( RID_SVXQBX_DELETE_HEADFOOT,
    1836           0 :                                         DIALOG_MGR() ) ).Execute();
    1837           0 :                 bExecute = bRet;
    1838           0 :                 StartAllAction();
    1839             :             }
    1840           0 :             if( bExecute )
    1841             :             {
    1842           0 :                 bChgd = sal_True;
    1843           0 :                 SwFrmFmt &rMaster = aDesc.GetMaster();
    1844           0 :                 if(bHeader)
    1845           0 :                     rMaster.SetFmtAttr( SwFmtHeader( bOn ));
    1846             :                 else
    1847           0 :                     rMaster.SetFmtAttr( SwFmtFooter( bOn ));
    1848           0 :                 if( bOn )
    1849             :                 {
    1850           0 :                     SvxULSpaceItem aUL(bHeader ? 0 : MM50, bHeader ? MM50 : 0, RES_UL_SPACE );
    1851             :                     SwFrmFmt* pFmt = bHeader ?
    1852           0 :                         (SwFrmFmt*)rMaster.GetHeader().GetHeaderFmt() :
    1853           0 :                         (SwFrmFmt*)rMaster.GetFooter().GetFooterFmt();
    1854           0 :                     pFmt->SetFmtAttr( aUL );
    1855             :                 }
    1856             :             }
    1857           0 :             if( bChgd )
    1858             :             {
    1859           0 :                 ChgPageDesc( nFrom, aDesc );
    1860             : 
    1861           0 :                 if( !bCrsrSet && bOn )
    1862             :                 {
    1863           0 :                     if ( !IsHeaderFooterEdit() )
    1864           0 :                         ToggleHeaderFooterEdit();
    1865             :                     bCrsrSet = SetCrsrInHdFt(
    1866           0 :                             !rStyleName.Len() ? USHRT_MAX : nFrom,
    1867           0 :                             bHeader );
    1868             :                 }
    1869             :             }
    1870             :         }
    1871           0 :     }
    1872           0 :     EndUndo( UNDO_HEADER_FOOTER ); // #i7983#
    1873           0 :     EndAllAction();
    1874           0 : }
    1875             : 
    1876           0 : void SwWrtShell::SetShowHeaderFooterSeparator( FrameControlType eControl, bool bShow )
    1877             : {
    1878           0 :     ViewShell::SetShowHeaderFooterSeparator( eControl, bShow );
    1879           0 :     if ( !bShow )
    1880           0 :         GetView().GetEditWin().GetFrameControlsManager().HideControls( eControl );
    1881          72 : }
    1882             : 
    1883             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10