LCOV - code coverage report
Current view: top level - libreoffice/sw/source/core/frmedt - fews.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 94 599 15.7 %
Date: 2012-12-27 Functions: 13 34 38.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 <svx/svdobj.hxx>
      22             : #include <init.hxx>
      23             : #include <fesh.hxx>
      24             : #include <pagefrm.hxx>
      25             : #include <rootfrm.hxx>
      26             : #include <cntfrm.hxx>
      27             : #include <doc.hxx>
      28             : #include <frmtool.hxx>
      29             : #include <swtable.hxx>
      30             : #include <viewimp.hxx>
      31             : #include <dview.hxx>
      32             : #include <flyfrm.hxx>
      33             : #include <node.hxx>
      34             : #include <pam.hxx>
      35             : #include <sectfrm.hxx>
      36             : #include <fmtpdsc.hxx>
      37             : #include <fmtsrnd.hxx>
      38             : #include <fmtcntnt.hxx>
      39             : #include <tabfrm.hxx>
      40             : #include <cellfrm.hxx>
      41             : #include <flyfrms.hxx>
      42             : #include <txtfrm.hxx>       // SwTxtFrm
      43             : #include <mdiexp.hxx>
      44             : #include <edimp.hxx>
      45             : #include <pagedesc.hxx>
      46             : #include <fmtanchr.hxx>
      47             : #include <environmentofanchoredobject.hxx>
      48             : #include <ndtxt.hxx> // #i22341#
      49             : #include <dflyobj.hxx>
      50             : #include <dcontact.hxx> // #i26791#
      51             : 
      52             : 
      53             : using namespace com::sun::star;
      54             : 
      55             : 
      56       25940 : TYPEINIT1(SwFEShell,SwEditShell)
      57             : 
      58             : /***********************************************************************
      59             : #*  Class      :  SwFEShell
      60             : #*  Method     :  EndAllActionAndCall()
      61             : #***********************************************************************/
      62             : 
      63           0 : void SwFEShell::EndAllActionAndCall()
      64             : {
      65           0 :     ViewShell *pTmp = this;
      66           0 :     do {
      67           0 :         if( pTmp->IsA( TYPE(SwCrsrShell) ) )
      68             :         {
      69           0 :             ((SwFEShell*)pTmp)->EndAction();
      70           0 :             ((SwFEShell*)pTmp)->CallChgLnk();
      71             :         }
      72             :         else
      73           0 :             pTmp->EndAction();
      74           0 :     } while( this != ( pTmp = (ViewShell*)pTmp->GetNext() ));
      75           0 : }
      76             : 
      77             : 
      78             : /***********************************************************************
      79             : #*  Class       :  SwFEShell
      80             : #*  Method      :  GetCntntPos
      81             : #*  Description :  Determine the Cntnt's nearest to the point
      82             : #***********************************************************************/
      83             : 
      84           0 : Point SwFEShell::GetCntntPos( const Point& rPoint, sal_Bool bNext ) const
      85             : {
      86           0 :     SET_CURR_SHELL( (ViewShell*)this );
      87           0 :     return GetLayout()->GetNextPrevCntntPos( rPoint, bNext );
      88             : }
      89             : 
      90             : 
      91         220 : const SwRect& SwFEShell::GetAnyCurRect( CurRectType eType, const Point* pPt,
      92             :                                         const uno::Reference < embed::XEmbeddedObject >& xObj ) const
      93             : {
      94         220 :     const SwFrm *pFrm = Imp()->HasDrawView()
      95         220 :                 ? ::GetFlyFromMarked( &Imp()->GetDrawView()->GetMarkedObjectList(),
      96         220 :                                       (ViewShell*)this)
      97         440 :                 : 0;
      98             : 
      99         220 :     if( !pFrm )
     100             :     {
     101         220 :         if( pPt )
     102             :         {
     103           0 :             SwPosition aPos( *GetCrsr()->GetPoint() );
     104           0 :             Point aPt( *pPt );
     105           0 :             GetLayout()->GetCrsrOfst( &aPos, aPt );
     106           0 :             SwCntntNode *pNd = aPos.nNode.GetNode().GetCntntNode();
     107           0 :             pFrm = pNd->getLayoutFrm( GetLayout(), pPt );
     108             :         }
     109             :         else
     110             :         {
     111         220 :             const bool bOldCallbackActionEnabled = GetLayout()->IsCallbackActionEnabled();
     112         220 :             if( bOldCallbackActionEnabled )
     113         220 :                 GetLayout()->SetCallbackActionEnabled( sal_False );
     114         220 :             pFrm = GetCurrFrm();
     115         220 :             if( bOldCallbackActionEnabled )
     116         220 :                 GetLayout()->SetCallbackActionEnabled( sal_True );
     117             :         }
     118             :     }
     119             : 
     120         220 :     if( !pFrm )
     121           0 :         return GetLayout()->Frm();
     122             : 
     123         220 :     bool bFrm = true;
     124         220 :     switch ( eType )
     125             :     {
     126         106 :         case RECT_PAGE_PRT:         bFrm = false; /* no break */
     127         210 :         case RECT_PAGE :            pFrm = pFrm->FindPageFrm();
     128         210 :                                     break;
     129             : 
     130           2 :         case RECT_PAGE_CALC:        pFrm->Calc();
     131           2 :                                     pFrm = pFrm->FindPageFrm();
     132           2 :                                     pFrm->Calc();
     133           2 :                                     break;
     134             : 
     135           0 :         case RECT_FLY_PRT_EMBEDDED: bFrm = false; /* no break */
     136           0 :         case RECT_FLY_EMBEDDED:     pFrm = xObj.is() ? FindFlyFrm( xObj )
     137           0 :                                                 : pFrm->IsFlyFrm()
     138             :                                                     ? pFrm
     139           0 :                                                     : pFrm->FindFlyFrm();
     140           0 :                                     break;
     141             : 
     142             :         case RECT_OUTTABSECTION_PRT:
     143           0 :         case RECT_OUTTABSECTION :   if( pFrm->IsInTab() )
     144           0 :                                         pFrm = pFrm->FindTabFrm();
     145             :                                     else {
     146             :                                         OSL_FAIL( "Missing Table" );
     147             :                                     }
     148             :                                     /* no break */
     149             :         case RECT_SECTION_PRT:
     150           6 :         case RECT_SECTION:          if( pFrm->IsInSct() )
     151           6 :                                         pFrm = pFrm->FindSctFrm();
     152             :                                     else {
     153             :                                         OSL_FAIL( "Missing section" );
     154             :                                     }
     155             : 
     156           6 :                                     if( RECT_OUTTABSECTION_PRT == eType ||
     157             :                                         RECT_SECTION_PRT == eType )
     158           3 :                                         bFrm = false;
     159           6 :                                     break;
     160             : 
     161           0 :         case RECT_HEADERFOOTER_PRT: bFrm = false; /* no break */
     162           0 :         case RECT_HEADERFOOTER:     if( 0 == (pFrm = pFrm->FindFooterOrHeader()) )
     163           0 :                                         return GetLayout()->Frm();
     164           0 :                                     break;
     165             : 
     166           2 :         case RECT_PAGES_AREA:       return GetLayout()->GetPagesArea();
     167             : 
     168           0 :         default:                    break;
     169             :     }
     170         218 :     return bFrm ? pFrm->Frm() : pFrm->Prt();
     171             : }
     172             : 
     173             : 
     174           0 : sal_uInt16 SwFEShell::GetPageNumber( const Point &rPoint ) const
     175             : {
     176           0 :     const SwFrm *pPage = GetLayout()->Lower();
     177           0 :     while ( pPage && !pPage->Frm().IsInside( rPoint ) )
     178           0 :         pPage = pPage->GetNext();
     179           0 :     if ( pPage )
     180           0 :         return ((const SwPageFrm*)pPage)->GetPhyPageNum();
     181             :     else
     182           0 :         return 0;
     183             : }
     184             : 
     185             : 
     186           0 : sal_Bool SwFEShell::GetPageNumber( long nYPos, sal_Bool bAtCrsrPos, sal_uInt16& rPhyNum, sal_uInt16& rVirtNum, String &rDisplay) const
     187             : {
     188             :     const SwFrm *pPage;
     189             : 
     190           0 :     if ( bAtCrsrPos )                   // get page of Crsr
     191             :     {
     192           0 :         pPage = GetCurrFrm( sal_False );
     193           0 :         if ( pPage )
     194           0 :             pPage = pPage->FindPageFrm();
     195             :     }
     196           0 :     else if ( nYPos > -1 )              // determine page via the position
     197             :     {
     198           0 :         pPage = GetLayout()->Lower();
     199           0 :         while( pPage &&  (pPage->Frm().Bottom() < nYPos ||
     200           0 :                             nYPos < pPage->Frm().Top() ) )
     201           0 :             pPage = pPage->GetNext();
     202             :     }
     203             :     else                                // first visible page
     204             :     {
     205           0 :         pPage = Imp()->GetFirstVisPage();
     206           0 :         if ( pPage && ((SwPageFrm*)pPage)->IsEmptyPage() )
     207           0 :             pPage = pPage->GetNext();
     208             :     }
     209             : 
     210           0 :     if( pPage )
     211             :     {
     212           0 :         rPhyNum  = ((const SwPageFrm*)pPage)->GetPhyPageNum();
     213           0 :         rVirtNum = ((const SwPageFrm*)pPage)->GetVirtPageNum();
     214           0 :         const SvxNumberType& rNum = ((const SwPageFrm*)pPage)->GetPageDesc()->GetNumType();
     215           0 :         rDisplay = rNum.GetNumStr( rVirtNum );
     216             :     }
     217             : 
     218           0 :     return 0 != pPage;
     219             : }
     220             : 
     221             : /*************************************************************************
     222             : |*
     223             : |*  SwFEShell::IsDirectlyInSection()
     224             : |*
     225             : |*  Hack for OS:
     226             : |*
     227             : *************************************************************************/
     228             : 
     229         199 : bool SwFEShell::IsDirectlyInSection() const
     230             : {
     231         199 :     SwFrm* pFrm = GetCurrFrm( sal_False );
     232         199 :     return pFrm && pFrm->GetUpper() && pFrm->GetUpper()->IsSctFrm();
     233             : }
     234             : 
     235             : /*************************************************************************
     236             : |*
     237             : |*  SwFEShell::GetFrmType()
     238             : |*
     239             : *************************************************************************/
     240             : 
     241         111 : sal_uInt16 SwFEShell::GetFrmType( const Point *pPt, sal_Bool bStopAtFly ) const
     242             : {
     243         111 :     sal_uInt16 nReturn = FRMTYPE_NONE;
     244             :     const SwFrm *pFrm;
     245         111 :     if ( pPt )
     246             :     {
     247           0 :         SwPosition aPos( *GetCrsr()->GetPoint() );
     248           0 :         Point aPt( *pPt );
     249           0 :         GetLayout()->GetCrsrOfst( &aPos, aPt );
     250           0 :         SwCntntNode *pNd = aPos.nNode.GetNode().GetCntntNode();
     251           0 :         pFrm = pNd->getLayoutFrm( GetLayout(), pPt );
     252             :     }
     253             :     else
     254         111 :         pFrm = GetCurrFrm( sal_False );
     255         701 :     while ( pFrm )
     256             :     {
     257         479 :         switch ( pFrm->GetType() )
     258             :         {
     259           1 :             case FRM_COLUMN:    if( pFrm->GetUpper()->IsSctFrm() )
     260             :                                 {
     261             :                                     // Check, if isn't not only a single column
     262             :                                     // from a section with footnotes at the end.
     263           0 :                                     if( pFrm->GetNext() || pFrm->GetPrev() )
     264             :                                         // Sectioncolumns
     265             :                                         nReturn |= ( nReturn & FRMTYPE_TABLE ) ?
     266           0 :                                             FRMTYPE_COLSECTOUTTAB : FRMTYPE_COLSECT;
     267             :                                 }
     268             :                                 else // only pages and frame columns
     269           1 :                                     nReturn |= FRMTYPE_COLUMN;
     270           1 :                                 break;
     271         111 :             case FRM_PAGE:      nReturn |= FRMTYPE_PAGE;
     272         111 :                                 if( ((SwPageFrm*)pFrm)->IsFtnPage() )
     273           0 :                                     nReturn |= FRMTYPE_FTNPAGE;
     274         111 :                                 break;
     275           0 :             case FRM_HEADER:    nReturn |= FRMTYPE_HEADER;      break;
     276           0 :             case FRM_FOOTER:    nReturn |= FRMTYPE_FOOTER;      break;
     277         112 :             case FRM_BODY:      if( pFrm->GetUpper()->IsPageFrm() ) // not for ColumnFrms
     278         111 :                                     nReturn |= FRMTYPE_BODY;
     279         112 :                                 break;
     280           0 :             case FRM_FTN:       nReturn |= FRMTYPE_FOOTNOTE;    break;
     281           0 :             case FRM_FLY:       if( ((SwFlyFrm*)pFrm)->IsFlyLayFrm() )
     282           0 :                                     nReturn |= FRMTYPE_FLY_FREE;
     283           0 :                                 else if ( ((SwFlyFrm*)pFrm)->IsFlyAtCntFrm() )
     284           0 :                                     nReturn |= FRMTYPE_FLY_ATCNT;
     285             :                                 else
     286             :                                 {
     287             :                                     OSL_ENSURE( ((SwFlyFrm*)pFrm)->IsFlyInCntFrm(),
     288             :                                             "New frametype?" );
     289           0 :                                     nReturn |= FRMTYPE_FLY_INCNT;
     290             :                                 }
     291           0 :                                 nReturn |= FRMTYPE_FLY_ANY;
     292           0 :                                 if( bStopAtFly )
     293           0 :                                     return nReturn;
     294           0 :                                 break;
     295             :             case FRM_TAB:
     296             :             case FRM_ROW:
     297          27 :             case FRM_CELL:      nReturn |= FRMTYPE_TABLE;       break;
     298         228 :             default:            /* do nothing */                break;
     299             :         }
     300         479 :         if ( pFrm->IsFlyFrm() )
     301           0 :             pFrm = ((SwFlyFrm*)pFrm)->GetAnchorFrm();
     302             :         else
     303         479 :             pFrm = pFrm->GetUpper();
     304             :     }
     305         111 :     return nReturn;
     306             : }
     307             : 
     308             : /*************************************************************************
     309             : |*
     310             : |*  SwFEShell::ShLooseFcs(), ShGetFcs()
     311             : |*
     312             : *************************************************************************/
     313             : 
     314         236 : void SwFEShell::ShGetFcs( sal_Bool bUpdate )
     315             : {
     316         236 :     ::SetShell( this );
     317         236 :     SwCrsrShell::ShGetFcs( bUpdate );
     318             : 
     319         236 :     if ( HasDrawView() )
     320             :     {
     321         236 :         Imp()->GetDrawView()->showMarkHandles();
     322         236 :         if ( Imp()->GetDrawView()->AreObjectsMarked() )
     323           0 :             FrameNotify( this, FLY_DRAG_START );
     324             :     }
     325         236 : }
     326             : 
     327         236 : void SwFEShell::ShLooseFcs()
     328             : {
     329         236 :     SwCrsrShell::ShLooseFcs();
     330             : 
     331         236 :     if ( HasDrawView() && Imp()->GetDrawView()->AreObjectsMarked() )
     332             :     {
     333           0 :         Imp()->GetDrawView()->hideMarkHandles();
     334           0 :         FrameNotify( this, FLY_DRAG_END );
     335             :     }
     336         236 : }
     337             : 
     338             : /*************************************************************************
     339             : |*
     340             : |*  SwFEShell::GetPhyPageNum()
     341             : |*  SwFEShell::GetVirtPageNum()
     342             : |*
     343             : *************************************************************************/
     344             : 
     345           0 : sal_uInt16 SwFEShell::GetPhyPageNum()
     346             : {
     347           0 :     SwFrm *pFrm = GetCurrFrm();
     348           0 :     if ( pFrm )
     349           0 :         return pFrm->GetPhyPageNum();
     350           0 :     return 0;
     351             : }
     352             : 
     353           0 : sal_uInt16 SwFEShell::GetVirtPageNum( const sal_Bool bCalcFrm )
     354             : {
     355           0 :     SwFrm *pFrm = GetCurrFrm( bCalcFrm );
     356           0 :     if ( pFrm )
     357           0 :         return pFrm->GetVirtPageNum();
     358           0 :     return 0;
     359             : }
     360             : 
     361             : /*************************************************************************
     362             : |*
     363             : |*  void lcl_SetAPageOffset()
     364             : |*  void SwFEShell::SetNewPageOffset()
     365             : |*  void SwFEShell::SetPageOffset()
     366             : |*  sal_uInt16 SwFEShell::GetPageOffset() const
     367             : |*
     368             : *************************************************************************/
     369             : 
     370           0 : static void lcl_SetAPageOffset( sal_uInt16 nOffset, SwPageFrm* pPage, SwFEShell* pThis )
     371             : {
     372           0 :     pThis->StartAllAction();
     373             :     OSL_ENSURE( pPage->FindFirstBodyCntnt(),
     374             :             "SwFEShell _SetAPageOffset() without CntntFrm" );
     375             : 
     376           0 :     SwFmtPageDesc aDesc( pPage->GetPageDesc() );
     377           0 :     aDesc.SetNumOffset( nOffset );
     378             : 
     379           0 :     SwFrm *pFrm = pThis->GetCurrFrm( sal_False );
     380           0 :     if ( pFrm->IsInTab() )
     381           0 :         pThis->GetDoc()->SetAttr( aDesc, *pFrm->FindTabFrm()->GetFmt() );
     382             :     else
     383             :     {
     384           0 :         pThis->GetDoc()->InsertPoolItem( *pThis->GetCrsr(), aDesc, 0 );
     385             :     }
     386             : 
     387           0 :     pThis->EndAllAction();
     388           0 : }
     389             : 
     390           0 : void SwFEShell::SetNewPageOffset( sal_uInt16 nOffset )
     391             : {
     392           0 :     GetLayout()->SetVirtPageNum( sal_True );
     393           0 :     const SwPageFrm *pPage = GetCurrFrm( sal_False )->FindPageFrm();
     394           0 :     lcl_SetAPageOffset( nOffset, (SwPageFrm*)pPage, this );
     395           0 : }
     396             : 
     397           0 : void SwFEShell::SetPageOffset( sal_uInt16 nOffset )
     398             : {
     399           0 :     const SwPageFrm *pPage = GetCurrFrm( sal_False )->FindPageFrm();
     400           0 :     const SwRootFrm* pDocLayout = GetLayout();
     401           0 :     while ( pPage )
     402             :     {
     403           0 :         const SwFrm *pFlow = pPage->FindFirstBodyCntnt();
     404           0 :         if ( pFlow )
     405             :         {
     406           0 :             if ( pFlow->IsInTab() )
     407           0 :                 pFlow = pFlow->FindTabFrm();
     408           0 :             const SwFmtPageDesc& rPgDesc = pFlow->GetAttrSet()->GetPageDesc();
     409           0 :             if ( rPgDesc.GetNumOffset() )
     410             :             {
     411           0 :                 pDocLayout->SetVirtPageNum( sal_True );
     412           0 :                 lcl_SetAPageOffset( nOffset, (SwPageFrm*)pPage, this );
     413           0 :                 break;
     414             :             }
     415             :         }
     416           0 :         pPage = (SwPageFrm*)pPage->GetPrev();
     417             :     }
     418           0 : }
     419             : 
     420           0 : sal_uInt16 SwFEShell::GetPageOffset() const
     421             : {
     422           0 :     const SwPageFrm *pPage = GetCurrFrm()->FindPageFrm();
     423           0 :     while ( pPage )
     424             :     {
     425           0 :         const SwFrm *pFlow = pPage->FindFirstBodyCntnt();
     426           0 :         if ( pFlow )
     427             :         {
     428           0 :             if ( pFlow->IsInTab() )
     429           0 :                 pFlow = pFlow->FindTabFrm();
     430           0 :             const sal_uInt16 nOffset = pFlow->GetAttrSet()->GetPageDesc().GetNumOffset();
     431           0 :             if ( nOffset )
     432           0 :                 return nOffset;
     433             :         }
     434           0 :         pPage = (SwPageFrm*)pPage->GetPrev();
     435             :     }
     436           0 :     return 0;
     437             : }
     438             : 
     439             : /*************************************************************************
     440             : |*
     441             : |*  SwFEShell::InsertLabel()
     442             : |*
     443             : *************************************************************************/
     444             : 
     445           0 : void SwFEShell::InsertLabel( const SwLabelType eType, const String &rTxt, const String& rSeparator,
     446             :                              const String& rNumberSeparator,
     447             :                              const sal_Bool bBefore, const sal_uInt16 nId,
     448             :                              const String& rCharacterStyle,
     449             :                              const sal_Bool bCpyBrd )
     450             : {
     451             :     // get node index of cursor position, SwDoc can do everything else itself
     452           0 :     SwCntntFrm *pCnt = LTYPE_DRAW==eType ? 0 : GetCurrFrm( sal_False );
     453           0 :     if( LTYPE_DRAW==eType || pCnt )
     454             :     {
     455           0 :         StartAllAction();
     456             : 
     457           0 :         sal_uLong nIdx = 0;
     458           0 :         SwFlyFrmFmt* pFlyFmt = 0;
     459           0 :         switch( eType )
     460             :         {
     461             :         case LTYPE_OBJECT:
     462             :         case LTYPE_FLY:
     463           0 :             if( pCnt->IsInFly() )
     464             :             {
     465             :                 // pass down index to the startnode for flys
     466           0 :                 nIdx = pCnt->FindFlyFrm()->
     467           0 :                             GetFmt()->GetCntnt().GetCntntIdx()->GetIndex();
     468             :             }
     469           0 :             break;
     470             :         case LTYPE_TABLE:
     471           0 :             if( pCnt->IsInTab() )
     472             :             {
     473             :                 // pass down index to the TblNode for tables
     474           0 :                 const SwTable& rTbl = *pCnt->FindTabFrm()->GetTable();
     475           0 :                 nIdx = rTbl.GetTabSortBoxes()[ 0 ]
     476           0 :                             ->GetSttNd()->FindTableNode()->GetIndex();
     477             :             }
     478           0 :             break;
     479             :         case LTYPE_DRAW:
     480           0 :             if( Imp()->GetDrawView() )
     481             :             {
     482           0 :                 SwDrawView *pDView = Imp()->GetDrawView();
     483           0 :                 const SdrMarkList& rMrkList = pDView->GetMarkedObjectList();
     484           0 :                 StartUndo();
     485             : 
     486             :                 // copy marked drawing objects to
     487             :                 // local list to perform the corresponding action for each object
     488           0 :                 std::vector<SdrObject*> aDrawObjs;
     489             :                 {
     490           0 :                     for ( sal_uInt16 i = 0; i < rMrkList.GetMarkCount(); ++i )
     491             :                     {
     492           0 :                         SdrObject* pDrawObj = rMrkList.GetMark(i)->GetMarkedSdrObj();
     493           0 :                         if( pDrawObj )
     494           0 :                         aDrawObjs.push_back( pDrawObj );
     495             :                     }
     496             :                 }
     497             :                 // loop on marked drawing objects
     498           0 :                 while ( !aDrawObjs.empty() )
     499             :                 {
     500           0 :                     SdrObject* pDrawObj = aDrawObjs.back();
     501           0 :                     if ( !pDrawObj->ISA(SwVirtFlyDrawObj) &&
     502           0 :                          !pDrawObj->ISA(SwFlyDrawObj) )
     503             :                     {
     504             :                         SwFlyFrmFmt *pFmt =
     505           0 :                             GetDoc()->InsertDrawLabel( rTxt, rSeparator, rNumberSeparator, nId, rCharacterStyle, *pDrawObj );
     506           0 :                         if( !pFlyFmt )
     507           0 :                             pFlyFmt = pFmt;
     508             :                     }
     509             : 
     510           0 :                     aDrawObjs.pop_back();
     511             :                 }
     512             : 
     513           0 :                 EndUndo();
     514             :             }
     515           0 :             break;
     516             :         default:
     517             :             OSL_ENSURE( !this, "Crsr neither in table nor in fly." );
     518             :         }
     519             : 
     520           0 :         if( nIdx )
     521             :             pFlyFmt = GetDoc()->InsertLabel( eType, rTxt, rSeparator, rNumberSeparator, bBefore, nId,
     522           0 :                                              nIdx, rCharacterStyle, bCpyBrd );
     523             : 
     524             :         SwFlyFrm* pFrm;
     525           0 :         const Point aPt( GetCrsrDocPos() );
     526           0 :         if( pFlyFmt && 0 != ( pFrm = pFlyFmt->GetFrm( &aPt )))
     527           0 :             SelectFlyFrm( *pFrm, sal_True );
     528             : 
     529           0 :         EndAllActionAndCall();
     530             :     }
     531           0 : }
     532             : 
     533             : 
     534             : /***********************************************************************
     535             : #*  Class       :  SwFEShell
     536             : #*  Method      :  Sort
     537             : #***********************************************************************/
     538             : 
     539           0 : sal_Bool SwFEShell::Sort(const SwSortOptions& rOpt)
     540             : {
     541           0 :     if( !HasSelection() )
     542           0 :         return sal_False;
     543             : 
     544           0 :     SET_CURR_SHELL( this );
     545             :     sal_Bool bRet;
     546           0 :     StartAllAction();
     547           0 :     if(IsTableMode())
     548             :     {
     549             :         // Sort table
     550             :         // check if Point/Mark of current Crsr are in one table
     551           0 :         SwFrm *pFrm = GetCurrFrm( sal_False );
     552             :         OSL_ENSURE( pFrm->FindTabFrm(), "Crsr not in table." );
     553             : 
     554             :         // search boxes via the layout
     555           0 :         SwSelBoxes  aBoxes;
     556           0 :         GetTblSel(*this, aBoxes);
     557             : 
     558             :         // The Crsr should be removed from the deletion area.
     559             :         // Always put them behind/on the table; via the
     560             :         // document position they will always be set to the old position
     561           0 :         while( !pFrm->IsCellFrm() )
     562           0 :             pFrm = pFrm->GetUpper();
     563             :         {
     564             :             /* ParkCursor->ParkCursorTab */
     565           0 :             ParkCursorInTab();
     566             :         }
     567             : 
     568             :         // call sorting on document
     569           0 :         bRet = pDoc->SortTbl(aBoxes, rOpt) ? sal_True : sal_False;
     570             :     }
     571             :     else
     572             :     {
     573             :         // Sort text nothing else
     574           0 :         FOREACHPAM_START(this)
     575             : 
     576           0 :             SwPaM* pPam = PCURCRSR;
     577             : 
     578           0 :             SwPosition* pStart = pPam->Start();
     579           0 :             SwPosition* pEnd   = pPam->End();
     580             : 
     581           0 :             SwNodeIndex aPrevIdx( pStart->nNode, -1 );
     582           0 :             sal_uLong nOffset = pEnd->nNode.GetIndex() - pStart->nNode.GetIndex();
     583           0 :             xub_StrLen nCntStt  = pStart->nContent.GetIndex();
     584             : 
     585             :             // Sorting
     586           0 :             bRet = pDoc->SortText(*pPam, rOpt) ? sal_True : sal_False;
     587             : 
     588             :             // put selection again
     589           0 :             pPam->DeleteMark();
     590           0 :             pPam->GetPoint()->nNode.Assign( aPrevIdx.GetNode(), +1 );
     591           0 :             SwCntntNode* pCNd = pPam->GetCntntNode();
     592           0 :             xub_StrLen nLen = pCNd->Len();
     593           0 :             if( nLen > nCntStt )
     594           0 :                 nLen = nCntStt;
     595           0 :             pPam->GetPoint()->nContent.Assign(pCNd, nLen );
     596           0 :             pPam->SetMark();
     597             : 
     598           0 :             pPam->GetPoint()->nNode += nOffset;
     599           0 :             pCNd = pPam->GetCntntNode();
     600           0 :             pPam->GetPoint()->nContent.Assign( pCNd, pCNd->Len() );
     601             : 
     602           0 :         FOREACHPAM_END()
     603             :     }
     604             : 
     605           0 :     EndAllAction();
     606           0 :     return bRet;
     607             : }
     608             : 
     609             : /*************************************************************************
     610             : |*
     611             : |*  SwFEShell::GetCurColNum(), _GetColNum()
     612             : |*
     613             : |*************************************************************************/
     614             : 
     615           1 : sal_uInt16 SwFEShell::_GetCurColNum( const SwFrm *pFrm,
     616             :                                 SwGetCurColNumPara* pPara ) const
     617             : {
     618           1 :     sal_uInt16 nRet = 0;
     619           3 :     while ( pFrm )
     620             :     {
     621           2 :         pFrm = pFrm->GetUpper();
     622           2 :         if( pFrm && pFrm->IsColumnFrm() )
     623             :         {
     624           1 :             const SwFrm *pCurFrm = pFrm;
     625           1 :             do {
     626           1 :                 ++nRet;
     627           1 :                 pFrm = pFrm->GetPrev();
     628             :             } while ( pFrm );
     629             : 
     630           1 :             if( pPara )
     631             :             {
     632             :                 // now search the format, determining the columness
     633           0 :                 pFrm = pCurFrm->GetUpper();
     634           0 :                 while( pFrm )
     635             :                 {
     636           0 :                     if( ( FRM_PAGE | FRM_FLY | FRM_SECTION ) & pFrm->GetType() )
     637             :                     {
     638           0 :                         pPara->pFrmFmt = ((SwLayoutFrm*)pFrm)->GetFmt();
     639           0 :                         pPara->pPrtRect = &pFrm->Prt();
     640           0 :                         pPara->pFrmRect = &pFrm->Frm();
     641           0 :                         break;
     642             :                     }
     643           0 :                     pFrm = pFrm->GetUpper();
     644             :                 }
     645           0 :                 if( !pFrm )
     646             :                 {
     647           0 :                     pPara->pFrmFmt = 0;
     648           0 :                     pPara->pPrtRect = 0;
     649           0 :                     pPara->pFrmRect = 0;
     650             :                 }
     651             :             }
     652           1 :             break;
     653             :         }
     654             :     }
     655           1 :     return nRet;
     656             : }
     657             : 
     658           1 : sal_uInt16 SwFEShell::GetCurColNum( SwGetCurColNumPara* pPara ) const
     659             : {
     660             :     OSL_ENSURE( GetCurrFrm(), "Crsr parked?" );
     661           1 :     return _GetCurColNum( GetCurrFrm(), pPara );
     662             : }
     663             : 
     664           0 : sal_uInt16 SwFEShell::GetCurOutColNum( SwGetCurColNumPara* pPara ) const
     665             : {
     666           0 :     sal_uInt16 nRet = 0;
     667           0 :     SwFrm* pFrm = GetCurrFrm();
     668             :     OSL_ENSURE( pFrm, "Crsr parked?" );
     669           0 :     if( pFrm )
     670             :     {
     671           0 :         pFrm = pFrm->IsInTab() ? (SwFrm*)pFrm->FindTabFrm()
     672           0 :                                : (SwFrm*)pFrm->FindSctFrm();
     673             :         OSL_ENSURE( pFrm, "No Tab, no Sect" );
     674           0 :         if( pFrm )
     675           0 :             nRet = _GetCurColNum( pFrm, pPara );
     676             :     }
     677           0 :     return nRet;
     678             : }
     679             : 
     680         236 : SwFEShell::SwFEShell( SwDoc& rDoc, Window *pWindow, const SwViewOption *pOptions )
     681             :     : SwEditShell( rDoc, pWindow, pOptions ),
     682         236 :     pChainFrom( 0 ), pChainTo( 0 ), bCheckForOLEInCaption( sal_False )
     683             : {
     684         236 : }
     685             : 
     686           0 : SwFEShell::SwFEShell( SwEditShell& rShell, Window *pWindow )
     687             :     : SwEditShell( rShell, pWindow ),
     688           0 :     pChainFrom( 0 ), pChainTo( 0 ), bCheckForOLEInCaption( sal_False )
     689             : {
     690           0 : }
     691             : 
     692         126 : SwFEShell::~SwFEShell()
     693             : {
     694          63 :     delete pChainFrom;
     695          63 :     delete pChainTo;
     696          63 : }
     697             : 
     698             : // #i17567# - adjustments for allowing
     699             : //          negative vertical positions for fly frames anchored to paragraph/to character.
     700             : // #i22305# - adjustments for option 'Follow text flow'
     701             : //          for to frame anchored objects.
     702             : // #i22341# - adjustments for vertical alignment at top of line
     703             : //          for to character anchored objects.
     704           0 : void SwFEShell::CalcBoundRect( SwRect& _orRect,
     705             :                                const RndStdIds _nAnchorId,
     706             :                                const sal_Int16 _eHoriRelOrient,
     707             :                                const sal_Int16 _eVertRelOrient,
     708             :                                const SwPosition* _pToCharCntntPos,
     709             :                                const bool _bFollowTextFlow,
     710             :                                bool _bMirror,
     711             :                                Point* _opRef,
     712             :                                Size* _opPercent ) const
     713             : {
     714             :     const SwFrm* pFrm;
     715             :     const SwFlyFrm* pFly;
     716           0 :     if( _opRef )
     717             :     {
     718           0 :         pFrm = GetCurrFrm();
     719           0 :         if( 0 != ( pFly = pFrm->FindFlyFrm() ) )
     720           0 :             pFrm = pFly->GetAnchorFrm();
     721             :     }
     722             :     else
     723             :     {
     724           0 :         pFly = FindFlyFrm();
     725           0 :         pFrm = pFly ? pFly->GetAnchorFrm() : GetCurrFrm();
     726             :     }
     727             : 
     728           0 :     sal_Bool bWrapThrough = sal_False;
     729           0 :     if ( pFly )
     730             :     {
     731           0 :         SwFlyFrmFmt* pFmt = (SwFlyFrmFmt*)pFly->GetFmt();
     732           0 :         const SwFmtSurround& rSurround = pFmt->GetSurround();
     733           0 :         bWrapThrough = rSurround.GetSurround() == SURROUND_THROUGHT;
     734             :     }
     735             : 
     736           0 :     const SwPageFrm* pPage = pFrm->FindPageFrm();
     737           0 :     _bMirror = _bMirror && !pPage->OnRightPage();
     738             : 
     739           0 :     Point aPos;
     740           0 :     bool bVertic = false;
     741           0 :     sal_Bool bRTL = sal_False;
     742           0 :     bool bVerticalL2R = false;
     743             : 
     744           0 :     if ((FLY_AT_PAGE == _nAnchorId) || (FLY_AT_FLY == _nAnchorId)) // LAYER_IMPL
     745             :     {
     746           0 :         const SwFrm* pTmp = pFrm;
     747             :         // #i22305#
     748           0 :         if ((FLY_AT_PAGE == _nAnchorId) ||
     749           0 :             ((FLY_AT_FLY == _nAnchorId) && !_bFollowTextFlow))
     750             :         {
     751           0 :             pFrm = pPage;
     752             :         }
     753             :         else
     754             :         {
     755           0 :             pFrm = pFrm->FindFlyFrm();
     756             :         }
     757           0 :         if ( !pFrm )
     758           0 :             pFrm = pTmp;
     759           0 :         _orRect = pFrm->Frm();
     760           0 :         SWRECTFN( pFrm )
     761           0 :         bRTL = pFrm->IsRightToLeft();
     762           0 :         if ( bRTL )
     763           0 :             aPos = pFrm->Frm().TopRight();
     764             :         else
     765           0 :             aPos = (pFrm->Frm().*fnRect->fnGetPos)();
     766             : 
     767           0 :         if( bVert || bVertL2R )
     768             :         {
     769           0 :             bVertic = bVert ? true : false;
     770           0 :             bVerticalL2R = bVertL2R ? true : false;
     771           0 :             _bMirror = false; // no mirroring in vertical environment
     772           0 :             switch ( _eHoriRelOrient )
     773             :             {
     774             :                 case text::RelOrientation::PAGE_RIGHT:
     775           0 :                 case text::RelOrientation::FRAME_RIGHT: aPos.Y() += pFrm->Prt().Height();
     776             :                 // no break!
     777             :                 case text::RelOrientation::PRINT_AREA:
     778           0 :                 case text::RelOrientation::PAGE_PRINT_AREA: aPos.Y() += pFrm->Prt().Top(); break;
     779           0 :                 default: break;
     780             :             }
     781             :         }
     782           0 :         else if ( _bMirror )
     783             :         {
     784           0 :             switch ( _eHoriRelOrient )
     785             :             {
     786             :                 case text::RelOrientation::PRINT_AREA:
     787           0 :                 case text::RelOrientation::PAGE_PRINT_AREA: aPos.X() += pFrm->Prt().Width();
     788             :                 // no break
     789             :                 case text::RelOrientation::PAGE_RIGHT:
     790           0 :                 case text::RelOrientation::FRAME_RIGHT: aPos.X() += pFrm->Prt().Left(); break;
     791           0 :                 default: aPos.X() += pFrm->Frm().Width();
     792             :             }
     793             :         }
     794           0 :         else if ( bRTL )
     795             :         {
     796           0 :             switch ( _eHoriRelOrient )
     797             :             {
     798             :                 case text::RelOrientation::PRINT_AREA:
     799           0 :                 case text::RelOrientation::PAGE_PRINT_AREA: aPos.X() += pFrm->Prt().Width();
     800             :                 // no break!
     801             :                 case text::RelOrientation::PAGE_LEFT:
     802           0 :                 case text::RelOrientation::FRAME_LEFT: aPos.X() += pFrm->Prt().Left() -
     803           0 :                                                pFrm->Frm().Width(); break;
     804           0 :                 default: break;
     805             :             }
     806             :         }
     807             :         else
     808             :         {
     809           0 :             switch ( _eHoriRelOrient )
     810             :             {
     811             :                 case text::RelOrientation::PAGE_RIGHT:
     812           0 :                 case text::RelOrientation::FRAME_RIGHT:   aPos.X() += pFrm->Prt().Width();
     813             :                 // no break!
     814             :                 case text::RelOrientation::PRINT_AREA:
     815           0 :                 case text::RelOrientation::PAGE_PRINT_AREA: aPos.X() += pFrm->Prt().Left(); break;
     816           0 :                 default:break;
     817             :             }
     818             :         }
     819             : 
     820           0 :         if ( bVert && !bVertL2R )
     821             :         {
     822           0 :             switch ( _eVertRelOrient )
     823             :             {
     824             :                 case text::RelOrientation::PRINT_AREA:
     825             :                 case text::RelOrientation::PAGE_PRINT_AREA:
     826             :                 {
     827           0 :                     aPos.X() -= pFrm->GetRightMargin();
     828             :                 }
     829           0 :                 break;
     830             :             }
     831             :         }
     832           0 :         else if ( bVertL2R )
     833             :         {
     834           0 :             switch ( _eVertRelOrient )
     835             :             {
     836             :                 case text::RelOrientation::PRINT_AREA:
     837             :                 case text::RelOrientation::PAGE_PRINT_AREA:
     838             :                 {
     839           0 :                     aPos.X() += pFrm->GetLeftMargin();
     840             :                 }
     841           0 :                 break;
     842             :             }
     843             :         }
     844             :         else
     845             :         {
     846           0 :             switch ( _eVertRelOrient )
     847             :             {
     848             :                 case text::RelOrientation::PRINT_AREA:
     849             :                 case text::RelOrientation::PAGE_PRINT_AREA:
     850             :                 {
     851           0 :                     if ( pFrm->IsPageFrm() )
     852             :                     {
     853           0 :                         aPos.Y() =
     854           0 :                             static_cast<const SwPageFrm*>(pFrm)->PrtWithoutHeaderAndFooter().Top();
     855             :                     }
     856             :                     else
     857             :                     {
     858           0 :                         aPos.Y() += pFrm->Prt().Top();
     859             :                     }
     860             :                 }
     861           0 :                 break;
     862             :             }
     863             :         }
     864           0 :         if ( _opPercent )
     865           0 :             *_opPercent = pFrm->Prt().SSize();
     866             :     }
     867             :     else
     868             :     {
     869           0 :         const SwFrm* pUpper = ( pFrm->IsPageFrm() || pFrm->IsFlyFrm() ) ?
     870           0 :                               pFrm : pFrm->GetUpper();
     871           0 :         SWRECTFN( pUpper );
     872           0 :         if ( _opPercent )
     873           0 :             *_opPercent = pUpper->Prt().SSize();
     874             : 
     875           0 :         bRTL = pFrm->IsRightToLeft();
     876           0 :         if ( bRTL )
     877           0 :             aPos = pFrm->Frm().TopRight();
     878             :         else
     879           0 :             aPos = (pFrm->Frm().*fnRect->fnGetPos)();
     880             :         // #i17567# - allow negative positions
     881             :         // for fly frames anchor to paragraph/to character.
     882           0 :         if ((_nAnchorId == FLY_AT_PARA) || (_nAnchorId == FLY_AT_CHAR))
     883             :         {
     884             :             // The rectangle, the fly frame can be positioned in, is determined
     885             :             // horizontally by the frame area of the horizontal environment
     886             :             // and vertically by the printing area of the vertical environment,
     887             :             // if the object follows the text flow, or by the frame area of the
     888             :             // vertical environment, if the object doesn't follow the text flow.
     889             :             // new class <SwEnvironmentOfAnchoredObject>
     890             :             objectpositioning::SwEnvironmentOfAnchoredObject aEnvOfObj(
     891           0 :                                                             _bFollowTextFlow );
     892             :             const SwLayoutFrm& rHoriEnvironLayFrm =
     893           0 :                                 aEnvOfObj.GetHoriEnvironmentLayoutFrm( *pFrm );
     894             :             const SwLayoutFrm& rVertEnvironLayFrm =
     895           0 :                                 aEnvOfObj.GetVertEnvironmentLayoutFrm( *pFrm );
     896           0 :             SwRect aHoriEnvironRect( rHoriEnvironLayFrm.Frm() );
     897           0 :             SwRect aVertEnvironRect;
     898           0 :             if ( _bFollowTextFlow )
     899             :             {
     900           0 :                 aVertEnvironRect = rVertEnvironLayFrm.Prt();
     901           0 :                 aVertEnvironRect.Pos() += rVertEnvironLayFrm.Frm().Pos();
     902             :                 // #i18732# - adjust vertical 'virtual' anchor position
     903             :                 // (<aPos.Y()> respectively <aPos.X()>), if object is vertical aligned
     904             :                 // to page areas.
     905           0 :                 if ( _eVertRelOrient == text::RelOrientation::PAGE_FRAME || _eVertRelOrient == text::RelOrientation::PAGE_PRINT_AREA )
     906             :                 {
     907           0 :                     if ( bVert && !bVertL2R )
     908             :                     {
     909           0 :                         aPos.X() = aVertEnvironRect.Right();
     910             :                     }
     911           0 :                     else if ( bVertL2R )
     912             :                     {
     913           0 :                         aPos.X() = aVertEnvironRect.Left();
     914             :                     }
     915             :                     else
     916             :                     {
     917           0 :                         aPos.Y() = aVertEnvironRect.Top();
     918             :                     }
     919             :                 }
     920             :             }
     921             :             else
     922             :             {
     923             :                 OSL_ENSURE( rVertEnvironLayFrm.IsPageFrm(),
     924             :                         "<SwFEShell::CalcBoundRect(..)> - not following text flow, but vertical environment *not* page!" );
     925           0 :                 aVertEnvironRect = rVertEnvironLayFrm.Frm();
     926             :                 // #i18732# - adjustment vertical 'virtual' anchor position
     927             :                 // (<aPos.Y()> respectively <aPos.X()>), if object is vertical aligned
     928             :                 // to page areas.
     929           0 :                 if ( _eVertRelOrient == text::RelOrientation::PAGE_FRAME || _eVertRelOrient == text::RelOrientation::PAGE_PRINT_AREA )
     930             :                 {
     931           0 :                     if ( bVert && !bVertL2R )
     932             :                     {
     933           0 :                         aPos.X() = aVertEnvironRect.Right();
     934           0 :                         if ( _eVertRelOrient == text::RelOrientation::PAGE_PRINT_AREA )
     935             :                         {
     936           0 :                             aPos.X() -= rVertEnvironLayFrm.GetRightMargin();
     937             :                         }
     938             :                     }
     939           0 :                     else if ( bVertL2R )
     940             :                     {
     941           0 :                         aPos.X() = aVertEnvironRect.Left();
     942           0 :                         if ( _eVertRelOrient == text::RelOrientation::PAGE_PRINT_AREA )
     943             :                         {
     944           0 :                             aPos.X() += rVertEnvironLayFrm.GetLeftMargin();
     945             :                         }
     946             :                     }
     947             :                     else
     948             :                     {
     949           0 :                         aPos.Y() = aVertEnvironRect.Top();
     950           0 :                         if ( _eVertRelOrient == text::RelOrientation::PAGE_PRINT_AREA )
     951             :                         {
     952           0 :                             aPos.Y() += rVertEnvironLayFrm.GetTopMargin();
     953             :                             // add height of page header
     954           0 :                             const SwFrm* pTmpFrm = rVertEnvironLayFrm.Lower();
     955           0 :                             if ( pTmpFrm->IsHeaderFrm() )
     956             :                             {
     957           0 :                                 aPos.Y() += pTmpFrm->Frm().Height();
     958             :                             }
     959             :                         }
     960             :                     }
     961             :                 }
     962             :             }
     963             : 
     964             :             // #i22341# - adjust vertical 'virtual' anchor position
     965             :             // (<aPos.Y()> respectively <aPos.X()>), if object is anchored to
     966             :             // character and vertical aligned at character or top of line
     967             :             // <pFrm>, which is the anchor frame or the proposed anchor frame,
     968             :             // doesn't have to be a text frame (e.g. edit a to-page anchored
     969             :             // fly frame). Thus, assure this.
     970           0 :             const SwTxtFrm* pTxtFrm( dynamic_cast<const SwTxtFrm*>(pFrm) );
     971           0 :             if ( pTxtFrm &&
     972             :                  (_nAnchorId == FLY_AT_CHAR) &&
     973             :                  ( _eVertRelOrient == text::RelOrientation::CHAR ||
     974             :                    _eVertRelOrient == text::RelOrientation::TEXT_LINE ) )
     975             :             {
     976           0 :                 SwTwips nTop = 0L;
     977           0 :                 if ( _eVertRelOrient == text::RelOrientation::CHAR )
     978             :                 {
     979           0 :                     SwRect aChRect;
     980           0 :                     if ( _pToCharCntntPos )
     981             :                     {
     982           0 :                         pTxtFrm->GetAutoPos( aChRect, *_pToCharCntntPos );
     983             :                     }
     984             :                     else
     985             :                     {
     986             :                         // No content position provided. Thus, use a default one.
     987           0 :                         SwPosition aDefaultCntntPos( *(pTxtFrm->GetTxtNode()) );
     988           0 :                         pTxtFrm->GetAutoPos( aChRect, aDefaultCntntPos );
     989             :                     }
     990           0 :                     nTop = (aChRect.*fnRect->fnGetBottom)();
     991             :                 }
     992             :                 else
     993             :                 {
     994           0 :                     if ( _pToCharCntntPos )
     995             :                     {
     996           0 :                         pTxtFrm->GetTopOfLine( nTop, *_pToCharCntntPos );
     997             :                     }
     998             :                     else
     999             :                     {
    1000             :                         // No content position provided. Thus, use a default one.
    1001           0 :                         SwPosition aDefaultCntntPos( *(pTxtFrm->GetTxtNode()) );
    1002           0 :                         pTxtFrm->GetTopOfLine( nTop, aDefaultCntntPos );
    1003             :                     }
    1004             :                 }
    1005           0 :                 if ( bVert || bVertL2R )
    1006             :                 {
    1007           0 :                     aPos.X() = nTop;
    1008             :                 }
    1009             :                 else
    1010             :                 {
    1011           0 :                     aPos.Y() = nTop;
    1012             :                 }
    1013             :             }
    1014             : 
    1015             :             // #i26945# - adjust horizontal 'virtual' anchor
    1016             :             // position (<aPos.X()> respectively <aPos.Y()>), if object is
    1017             :             // anchored to character and horizontal aligned at character.
    1018           0 :             if ( pTxtFrm &&
    1019             :                  (_nAnchorId == FLY_AT_CHAR) &&
    1020             :                  _eHoriRelOrient == text::RelOrientation::CHAR )
    1021             :             {
    1022           0 :                 SwTwips nLeft = 0L;
    1023           0 :                 SwRect aChRect;
    1024           0 :                 if ( _pToCharCntntPos )
    1025             :                 {
    1026           0 :                     pTxtFrm->GetAutoPos( aChRect, *_pToCharCntntPos );
    1027             :                 }
    1028             :                 else
    1029             :                 {
    1030             :                     // No content position provided. Thus, use a default one.
    1031           0 :                     SwPosition aDefaultCntntPos( *(pTxtFrm->GetTxtNode()) );
    1032           0 :                     pTxtFrm->GetAutoPos( aChRect, aDefaultCntntPos );
    1033             :                 }
    1034           0 :                 nLeft = (aChRect.*fnRect->fnGetLeft)();
    1035           0 :                 if ( bVert || bVertL2R )
    1036             :                 {
    1037           0 :                     aPos.Y() = nLeft;
    1038             :                 }
    1039             :                 else
    1040             :                 {
    1041           0 :                     aPos.X() = nLeft;
    1042             :                 }
    1043             :             }
    1044           0 :             if ( bVert || bVertL2R )
    1045             :             {
    1046             :                 _orRect = SwRect( aVertEnvironRect.Left(),
    1047             :                                   aHoriEnvironRect.Top(),
    1048             :                                   aVertEnvironRect.Width(),
    1049           0 :                                   aHoriEnvironRect.Height() );
    1050             :             }
    1051             :             else
    1052             :             {
    1053             :                 _orRect = SwRect( aHoriEnvironRect.Left(),
    1054             :                                   aVertEnvironRect.Top(),
    1055             :                                   aHoriEnvironRect.Width(),
    1056           0 :                                   aVertEnvironRect.Height() );
    1057           0 :             }
    1058             :         }
    1059             :         else
    1060             :         {
    1061           0 :             if( _opRef && pFly && pFly->IsFlyInCntFrm() )
    1062           0 :                 *_opRef = ( (SwFlyInCntFrm*)pFly )->GetRefPoint();
    1063             : 
    1064           0 :             _orRect = pUpper->Frm();
    1065           0 :             if( !pUpper->IsBodyFrm() )
    1066             :             {
    1067           0 :                 _orRect += pUpper->Prt().Pos();
    1068           0 :                 _orRect.SSize( pUpper->Prt().SSize() );
    1069           0 :                 if ( pUpper->IsCellFrm() )//MA_FLY_HEIGHT
    1070             :                 {
    1071           0 :                     const SwFrm* pTab = pUpper->FindTabFrm();
    1072           0 :                     long nBottom = (pTab->GetUpper()->*fnRect->fnGetPrtBottom)();
    1073           0 :                     (_orRect.*fnRect->fnSetBottom)( nBottom );
    1074             :                 }
    1075             :             }
    1076             :             // only use 90% of height for character bound
    1077             :             {
    1078           0 :                 if( bVert || bVertL2R )
    1079           0 :                     _orRect.Width( (_orRect.Width()*9)/10 );
    1080             :                 else
    1081           0 :                     _orRect.Height( (_orRect.Height()*9)/10 );
    1082             :             }
    1083             :         }
    1084             : 
    1085           0 :         const SwTwips nBaseOfstForFly = ( pFrm->IsTxtFrm() && pFly ) ?
    1086           0 :                                         ((SwTxtFrm*)pFrm)->GetBaseOfstForFly( !bWrapThrough ) :
    1087           0 :                                          0;
    1088           0 :         if( bVert || bVertL2R )
    1089             :         {
    1090           0 :             bVertic = bVert ? true : false;
    1091           0 :             bVerticalL2R = bVertL2R ? true : false;
    1092           0 :             _bMirror = false;
    1093             : 
    1094           0 :             switch ( _eHoriRelOrient )
    1095             :             {
    1096             :                 case text::RelOrientation::FRAME_RIGHT:
    1097             :                 {
    1098           0 :                     aPos.Y() += pFrm->Prt().Height();
    1099           0 :                     aPos += (pFrm->Prt().*fnRect->fnGetPos)();
    1100           0 :                     break;
    1101             :                 }
    1102             :                 case text::RelOrientation::PRINT_AREA:
    1103             :                 {
    1104           0 :                     aPos += (pFrm->Prt().*fnRect->fnGetPos)();
    1105           0 :                     aPos.Y() += nBaseOfstForFly;
    1106           0 :                     break;
    1107             :                 }
    1108             :                 case text::RelOrientation::PAGE_RIGHT:
    1109             :                 {
    1110           0 :                     aPos.Y() = pPage->Frm().Top() + pPage->Prt().Bottom();
    1111           0 :                     break;
    1112             :                 }
    1113             :                 case text::RelOrientation::PAGE_PRINT_AREA:
    1114             :                 {
    1115           0 :                     aPos.Y() = pPage->Frm().Top() + pPage->Prt().Top();
    1116           0 :                     break;
    1117             :                 }
    1118             :                 case text::RelOrientation::PAGE_LEFT:
    1119             :                 case text::RelOrientation::PAGE_FRAME:
    1120             :                 {
    1121           0 :                     aPos.Y() = pPage->Frm().Top();
    1122           0 :                     break;
    1123             :                 }
    1124             :                 case text::RelOrientation::FRAME:
    1125             :                 {
    1126           0 :                     aPos.Y() += nBaseOfstForFly;
    1127           0 :                     break;
    1128             :                 }
    1129           0 :                 default: break;
    1130             :             }
    1131             :         }
    1132           0 :         else if( _bMirror )
    1133             :         {
    1134           0 :             switch ( _eHoriRelOrient )
    1135             :             {
    1136           0 :                 case text::RelOrientation::FRAME_RIGHT:   aPos.X() += pFrm->Prt().Left(); break;
    1137             :                 case text::RelOrientation::FRAME:
    1138           0 :                 case text::RelOrientation::FRAME_LEFT: aPos.X() += pFrm->Frm().Width(); break;
    1139           0 :                 case text::RelOrientation::PRINT_AREA: aPos.X() += pFrm->Prt().Right(); break;
    1140             :                 case text::RelOrientation::PAGE_LEFT:
    1141           0 :                 case text::RelOrientation::PAGE_FRAME: aPos.X() = pPage->Frm().Right(); break;
    1142           0 :                 case text::RelOrientation::PAGE_PRINT_AREA: aPos.X() = pPage->Frm().Left()
    1143           0 :                                               + pPage->Prt().Left(); break;
    1144           0 :                 default: break;
    1145             :             }
    1146             :         }
    1147           0 :         else if ( bRTL )
    1148             :         {
    1149           0 :             switch ( _eHoriRelOrient )
    1150             :             {
    1151             :                 case text::RelOrientation::FRAME_LEFT:
    1152           0 :                     aPos.X() = pFrm->Frm().Left() +
    1153           0 :                                pFrm->Prt().Left();
    1154           0 :                     break;
    1155             : 
    1156             :                 case text::RelOrientation::PRINT_AREA:
    1157           0 :                     aPos.X() = pFrm->Frm().Left() + pFrm->Prt().Left() +
    1158           0 :                                pFrm->Prt().Width();
    1159           0 :                     aPos.X() += nBaseOfstForFly;
    1160           0 :                     break;
    1161             : 
    1162             :                 case text::RelOrientation::PAGE_LEFT:
    1163           0 :                     aPos.X() = pPage->Frm().Left() + pPage->Prt().Left();
    1164           0 :                     break;
    1165             : 
    1166             :                 case text::RelOrientation::PAGE_PRINT_AREA:
    1167           0 :                     aPos.X() = pPage->Frm().Left() + pPage->Prt().Left() +
    1168           0 :                                pPage->Prt().Width() ;
    1169           0 :                     break;
    1170             : 
    1171             :                 case text::RelOrientation::PAGE_RIGHT:
    1172             :                 case text::RelOrientation::PAGE_FRAME:
    1173           0 :                     aPos.X() = pPage->Frm().Right();
    1174           0 :                     break;
    1175             : 
    1176             :                 case text::RelOrientation::FRAME:
    1177           0 :                     aPos.X() += nBaseOfstForFly;
    1178           0 :                     break;
    1179           0 :                 default: break;
    1180             :             }
    1181             :         }
    1182             :         else
    1183             :         {
    1184           0 :             switch ( _eHoriRelOrient )
    1185             :             {
    1186             :                 case text::RelOrientation::FRAME_RIGHT:
    1187           0 :                     aPos.X() += pFrm->Prt().Width();
    1188           0 :                     aPos += pFrm->Prt().Pos();
    1189           0 :                     break;
    1190             :                 case text::RelOrientation::PRINT_AREA:
    1191           0 :                     aPos += pFrm->Prt().Pos();
    1192           0 :                     aPos.X() += nBaseOfstForFly;
    1193           0 :                     break;
    1194             :                 case text::RelOrientation::PAGE_RIGHT:
    1195           0 :                     aPos.X() = pPage->Frm().Left() + pPage->Prt().Right();
    1196           0 :                     break;
    1197             :                 case text::RelOrientation::PAGE_PRINT_AREA:
    1198           0 :                     aPos.X() = pPage->Frm().Left() + pPage->Prt().Left();
    1199           0 :                     break;
    1200             :                 case text::RelOrientation::PAGE_LEFT:
    1201             :                 case text::RelOrientation::PAGE_FRAME:
    1202           0 :                     aPos.X() = pPage->Frm().Left();
    1203           0 :                     break;
    1204             :                 case text::RelOrientation::FRAME:
    1205           0 :                     aPos.X() += nBaseOfstForFly;
    1206           0 :                     break;
    1207           0 :                 default: break;
    1208             :             }
    1209             :         }
    1210             : 
    1211             :     }
    1212           0 :     if( !_opRef )
    1213             :     {
    1214           0 :         if( bVertic && !bVerticalL2R )
    1215           0 :             _orRect.Pos( aPos.X() - _orRect.Width() - _orRect.Left(), _orRect.Top() - aPos.Y() );
    1216           0 :         else if( bVerticalL2R )
    1217           0 :             _orRect.Pos( _orRect.Left() - aPos.X(), _orRect.Top() - aPos.Y() );
    1218           0 :         else if ( bRTL )
    1219           0 :             _orRect.Pos( - ( _orRect.Right() - aPos.X() ), _orRect.Top() - aPos.Y() );
    1220             :         else
    1221           0 :             _orRect.Pos( _orRect.Left() - aPos.X(), _orRect.Top() - aPos.Y() );
    1222           0 :         if( _bMirror )
    1223           0 :             _orRect.Pos( -_orRect.Right(), _orRect.Top() );
    1224             :     }
    1225           0 : }
    1226             : 
    1227           0 : Size SwFEShell::GetGraphicDefaultSize() const
    1228             : {
    1229           0 :     Size aRet;
    1230           0 :     SwFlyFrm *pFly = FindFlyFrm();
    1231           0 :     if ( pFly )
    1232             :     {
    1233             :         // #i32951# - due to issue #i28701# no format of a
    1234             :         // newly inserted Writer fly frame or its anchor frame is performed
    1235             :         // any more. Thus, it could be possible (e.g. on insert of a horizontal
    1236             :         // line) that the anchor frame isn't formatted and its printing area
    1237             :         // size is (0,0). If this is the case the printing area of the upper
    1238             :         // of the anchor frame is taken.
    1239           0 :         const SwFrm* pAnchorFrm = pFly->GetAnchorFrm();
    1240           0 :         aRet = pAnchorFrm->Prt().SSize();
    1241           0 :         if ( aRet.Width() == 0 && aRet.Height() == 0 &&
    1242           0 :              pAnchorFrm->GetUpper() )
    1243             :         {
    1244           0 :             aRet = pAnchorFrm->GetUpper()->Prt().SSize();
    1245             :         }
    1246             : 
    1247           0 :         SwRect aBound;
    1248           0 :         CalcBoundRect( aBound, pFly->GetFmt()->GetAnchor().GetAnchorId());
    1249           0 :         if ( pFly->GetAnchorFrm()->IsVertical() )
    1250           0 :             aRet.Width() = aBound.Width();
    1251             :         else
    1252           0 :             aRet.Height() = aBound.Height();
    1253             :     }
    1254           0 :     return aRet;
    1255             : }
    1256             : 
    1257         416 : sal_Bool SwFEShell::IsFrmVertical(const sal_Bool bEnvironment, sal_Bool& bRTL, sal_Bool& bVertL2R) const
    1258             : {
    1259         416 :     sal_Bool bVert = sal_False;
    1260         416 :     bRTL = sal_False;
    1261         416 :     bVertL2R = sal_False;
    1262             : 
    1263         416 :     if ( Imp()->HasDrawView() )
    1264             :     {
    1265         416 :         const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
    1266         416 :         if( rMrkList.GetMarkCount() != 1 )
    1267         416 :             return bVert;
    1268             : 
    1269           0 :         SdrObject* pObj = rMrkList.GetMark( 0 )->GetMarkedSdrObj();
    1270           0 :         if ( !pObj )
    1271             :         {
    1272             :             OSL_FAIL( "<SwFEShell::IsFrmVertical(..)> - missing SdrObject instance in marked object list -> This is a serious situation, please inform OD" );
    1273           0 :             return bVert;
    1274             :         }
    1275             :         // #i26791#
    1276           0 :         SwContact* pContact = static_cast<SwContact*>(GetUserCall( pObj ));
    1277           0 :         if ( !pContact )
    1278             :         {
    1279             :             OSL_FAIL( "<SwFEShell::IsFrmVertical(..)> - missing SwContact instance at marked object -> This is a serious situation, please inform OD" );
    1280           0 :             return bVert;
    1281             :         }
    1282           0 :         const SwFrm* pRef = pContact->GetAnchoredObj( pObj )->GetAnchorFrm();
    1283           0 :         if ( !pRef )
    1284             :         {
    1285             :             OSL_FAIL( "<SwFEShell::IsFrmVertical(..)> - missing anchor frame at marked object -> This is a serious situation, please inform OD" );
    1286           0 :             return bVert;
    1287             :         }
    1288             : 
    1289           0 :         if ( pObj->ISA(SwVirtFlyDrawObj) && !bEnvironment )
    1290           0 :             pRef = static_cast<const SwVirtFlyDrawObj*>(pObj)->GetFlyFrm();
    1291             : 
    1292           0 :         bVert = pRef->IsVertical();
    1293           0 :         bRTL = pRef->IsRightToLeft();
    1294           0 :         bVertL2R = pRef->IsVertLR();
    1295             :     }
    1296             : 
    1297           0 :     return bVert;
    1298             : }
    1299             : 
    1300           0 : void SwFEShell::MoveObjectIfActive( svt::EmbeddedObjectRef&, const Point& )
    1301             : {
    1302             :     // does not do anything, only avoids crash if the method is used for wrong shell
    1303           0 : }
    1304             : 
    1305           0 : void SwFEShell::ToggleHeaderFooterEdit()
    1306             : {
    1307             :     // Clear objects selection
    1308           0 :     if ( Imp()->GetDrawView()->AreObjectsMarked() )
    1309             :     {
    1310           0 :         Imp()->GetDrawView()->UnmarkAll();
    1311           0 :         ClearMark();
    1312             :     }
    1313             : 
    1314           0 :     SwCrsrShell::ToggleHeaderFooterEdit();
    1315           0 : }
    1316             : 
    1317             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10