LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sw/source/ui/wrtsh - wrtsh1.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 132 792 16.7 %
Date: 2013-07-09 Functions: 14 48 29.2 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10