LCOV - code coverage report
Current view: top level - sw/source/core/frmedt - fews.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 610 0.0 %
Date: 2014-04-14 Functions: 0 34 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10